Skip to content

Commit fd2d508

Browse files
Merge branch '5.6_dev' into 5.6
2 parents cfa2745 + 5e8160f commit fd2d508

File tree

36 files changed

+522
-169
lines changed

36 files changed

+522
-169
lines changed

MounteaDialogueSystem.uplugin

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,15 @@
11
{
22
"FileVersion": 3,
33
"Version": 3,
4-
"VersionName": "3.0.3.56",
4+
"VersionName": "3.0.4.56",
55
"FriendlyName": "Mountea Dialogue System",
66
"Description": "Mountea Dialogue System is an Open-source Mountea Framework tool for Unreal Engine for creating (not just) complex dialogues!\nProvides its own Dialogue Tree editor and validation system.",
77
"Category": "Mountea Framework",
88
"CreatedBy": "Dominik (Pavlicek) Morse",
99
"CreatedByURL": "https://github.com/Mountea-Framework",
10-
"DocsURL": "https://github.com/Mountea-Framework/MounteaDialogueSystem/wiki",
10+
"DocsURL": "https://mountea.tools/docs/dialoguesystem/gettingstarted/firststeps/",
1111
"MarketplaceURL": "com.epicgames.launcher://ue/marketplace/product/ea38ae1f87b24807a66fdf4fa65ef521",
12-
"SupportURL": "https://bit.ly/DominikPavlicek_SupportServer",
12+
"SupportURL": "https://discord.gg/c2WQ658V44",
1313
"EngineVersion": "5.6.0",
1414
"CanContainContent": true,
1515
"Installed": true,
21.9 KB
Loading

Source/MounteaDialogueSystem/MounteaDialogueSystem.Build.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ public MounteaDialogueSystem(ReadOnlyTargetRules Target) : base(Target)
88
{
99
PCHUsage = PCHUsageMode.UseExplicitOrSharedPCHs;
1010
bLegacyPublicIncludePaths = false;
11-
ShadowVariableWarningLevel = WarningLevel.Error;
11+
CppCompileWarningSettings.ShadowVariableWarningLevel = WarningLevel.Error;
1212

1313
PublicIncludePaths.AddRange
1414
(

Source/MounteaDialogueSystem/Private/Helpers/MounteaDialogueSystemBFC.cpp

Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33

44
#include "Helpers/MounteaDialogueSystemBFC.h"
55

6+
#include "Algo/ForEach.h"
67
#include "Kismet/KismetSystemLibrary.h"
78

89
#include "Graph/MounteaDialogueGraph.h"
@@ -576,6 +577,70 @@ bool UMounteaDialogueSystemBFC::DoesRowMatchParticipant(const TScriptInterface<I
576577
return Row.CompatibleTags.HasTagExact(participantTag);
577578
}
578579

580+
TArray<TSubclassOf<UMounteaDialogueGraphNode>> UMounteaDialogueSystemBFC::GetAllowedInputClasses(UMounteaDialogueGraphNode* Target)
581+
{
582+
if (!IsValid(Target))
583+
{
584+
LOG_ERROR(TEXT("[Get Allowed Input Classes] Invalid Target!"));
585+
return {};
586+
}
587+
588+
if (!Target->Implements<UMounteaDialogueGraphNodeInterface>())
589+
{
590+
LOG_ERROR(TEXT("[Get Allowed Input Classes] Target does not implement IMounteaDialogueGraphNodeInterface!"));
591+
return {};
592+
}
593+
594+
TArray<TSubclassOf<UMounteaDialogueGraphNode>> nodeAllowedClasses = IMounteaDialogueGraphNodeInterface::Execute_GetAllowedInputClasses(Target);
595+
596+
const auto dialogueSettings = GetDefault<UMounteaDialogueSystemSettings>();
597+
if (!IsValid(dialogueSettings))
598+
{
599+
LOG_WARNING(TEXT("[Get Allowed Input Classes] Dialogue Settings are not valid!"));
600+
return nodeAllowedClasses;
601+
}
602+
603+
const auto dialogueConfig = dialogueSettings->GetDialogueConfiguration().LoadSynchronous();
604+
if (!IsValid(dialogueConfig))
605+
{
606+
LOG_WARNING(TEXT("[Get Allowed Input Classes] Dialogue Configuration is not valid! Returning Node Allowed Classes only."));
607+
return nodeAllowedClasses;
608+
}
609+
610+
const auto nodeConfig = dialogueConfig->NodesConfiguration.Find(Target->GetClass());
611+
if (!nodeConfig)
612+
{
613+
LOG_WARNING(TEXT("[Get Allowed Input Classes] Target Node is not configured in Dialogue Configuration! Returning Node Allowed Classes only."));
614+
return nodeAllowedClasses;
615+
}
616+
617+
const auto configInputClasses = nodeConfig->AllowedInputClasses;
618+
if (configInputClasses.IsEmpty())
619+
{
620+
LOG_WARNING(TEXT("[Get Allowed Input Classes] AllowedInputClasses is empty in configuration! Returning Node Allowed Classes only."));
621+
return nodeAllowedClasses;
622+
}
623+
624+
Algo::ForEach(configInputClasses, [&](const TSoftClassPtr<UMounteaDialogueGraphNode>& configClass)
625+
{
626+
if (!configClass.IsNull())
627+
{
628+
const TSubclassOf<UMounteaDialogueGraphNode> loadedClass = configClass.LoadSynchronous();
629+
630+
if (loadedClass && !nodeAllowedClasses.ContainsByPredicate(
631+
[&](const TSubclassOf<UMounteaDialogueGraphNode>& existingClass)
632+
{
633+
return existingClass == loadedClass;
634+
}))
635+
{
636+
nodeAllowedClasses.Add(loadedClass);
637+
}
638+
}
639+
});
640+
641+
return nodeAllowedClasses;
642+
}
643+
579644
FDialogueRow UMounteaDialogueSystemBFC::GetDialogueRow(const UMounteaDialogueGraphNode* Node)
580645
{
581646
if (!Node)

Source/MounteaDialogueSystem/Private/Nodes/MounteaDialogueGraphNode.cpp

Lines changed: 29 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
#include "Nodes/MounteaDialogueGraphNode.h"
44

5+
#include "Algo/AnyOf.h"
56
#include "Graph/MounteaDialogueGraph.h"
67
#include "Helpers/MounteaDialogueGraphHelpers.h"
78
#include "Helpers/MounteaDialogueSystemBFC.h"
@@ -66,6 +67,11 @@ void UMounteaDialogueGraphNode::SetNewWorld(UWorld* NewWorld)
6667
OwningWorld = NewWorld;
6768
}
6869

70+
TArray<TSubclassOf<UMounteaDialogueGraphNode>> UMounteaDialogueGraphNode::GetAllowedInputClasses_Implementation() const
71+
{
72+
return AllowedInputClasses;
73+
}
74+
6975
void UMounteaDialogueGraphNode::RegisterTick_Implementation( const TScriptInterface<IMounteaDialogueTickableObject>& ParentTickable)
7076
{
7177
if (ParentTickable.GetObject() && ParentTickable.GetInterface())
@@ -211,7 +217,7 @@ FText UMounteaDialogueGraphNode::GetNodeCategory_Implementation() const
211217

212218
FString UMounteaDialogueGraphNode::GetNodeDocumentationLink_Implementation() const
213219
{
214-
return TEXT("https://github.com/Mountea-Framework/MounteaDialogueSystem/wiki/Dialogue-Nodes");
220+
return TEXT("https://mountea.tools/docs/DialogueSystem/DialogueNodes/DialogueNode/");
215221
}
216222

217223
FText UMounteaDialogueGraphNode::GetNodeTooltipText_Implementation() const
@@ -229,43 +235,44 @@ void UMounteaDialogueGraphNode::SetNodeTitle(const FText& NewTitle)
229235
NodeTitle = NewTitle;
230236
}
231237

232-
bool UMounteaDialogueGraphNode::CanCreateConnection(UMounteaDialogueGraphNode* Other, enum EEdGraphPinDirection Direction, FText& ErrorMessage)
238+
bool UMounteaDialogueGraphNode::CanCreateConnection(UMounteaDialogueGraphNode* Other, EEdGraphPinDirection Direction, FText& ErrorMessage)
233239
{
234-
if (Other == nullptr)
240+
// Validate input
241+
if (!IsValid(Other))
235242
{
236243
ErrorMessage = FText::FromString("Invalid Other Node!");
244+
return false;
237245
}
238246

247+
// Enforce max child nodes
239248
if (Other->GetMaxChildNodes() > -1 && Other->ChildrenNodes.Num() >= Other->GetMaxChildNodes())
240249
{
241-
const FString TextReturn =
242-
FString(Other->GetNodeTitle().ToString()).
243-
Append(": Cannot have more than ").Append(FString::FromInt(Other->GetMaxChildNodes())).Append(" Children Nodes!");
244-
245-
ErrorMessage = FText::FromString(TextReturn);
250+
ErrorMessage = FText::Format(
251+
NSLOCTEXT("MounteaDialogue", "MaxChildrenReached", "{0}: Cannot have more than {1} Children Nodes!"),
252+
Other->GetNodeTitle(),
253+
FText::AsNumber(Other->GetMaxChildNodes())
254+
);
246255
return false;
247256
}
248257

258+
// Check allowed input classes (only applies for output pins)
249259
if (Direction == EGPD_Output)
250260
{
251-
252-
// Fast checking for native classes
253-
if ( AllowedInputClasses.Contains(Other->GetClass()) )
261+
// Use centralized logic from the Dialogue System
262+
const TArray<TSubclassOf<UMounteaDialogueGraphNode>> allowedClasses = UMounteaDialogueSystemBFC::GetAllowedInputClasses(this);
263+
264+
const UClass* otherClass = Other->GetClass();
265+
266+
const bool bIsAllowed = Algo::AnyOf(allowedClasses, [otherClass](const TSubclassOf<UMounteaDialogueGraphNode>& allowedClass)
254267
{
255-
return true;
256-
}
268+
return otherClass->IsChildOf(allowedClass);
269+
});
257270

258-
// Slower iterative checking for child classes
259-
for (auto Itr : AllowedInputClasses)
271+
if (!bIsAllowed)
260272
{
261-
if (Other->GetClass()->IsChildOf(Itr))
262-
{
263-
return true;
264-
}
273+
ErrorMessage = FText::FromString("Invalid Node Connection: Target node type is not allowed.\nIf connection is required, please modify the AllowedInputClasses in the Dialogue Configuration.");
274+
return false;
265275
}
266-
267-
ErrorMessage = FText::FromString("Invalid Node Connection!");
268-
return false;
269276
}
270277

271278
return true;

Source/MounteaDialogueSystem/Private/Nodes/MounteaDialogueGraphNode_ReturnToNode.cpp

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
#include "Helpers/MounteaDialogueSystemBFC.h"
88
#include "Misc/DataValidation.h"
99
#include "TimerManager.h"
10+
#include "Algo/AnyOf.h"
1011
#include "Nodes/MounteaDialogueGraphNode_CompleteNode.h"
1112
#include "Nodes/MounteaDialogueGraphNode_StartNode.h"
1213

@@ -87,6 +88,50 @@ void UMounteaDialogueGraphNode_ReturnToNode::OnDelayDurationExpired(const TScrip
8788
}
8889
}
8990

91+
TArray<FString> UMounteaDialogueGraphNode_ReturnToNode::GetRowNames() const
92+
{
93+
if (!Graph)
94+
return {};
95+
96+
const auto AllNodes = Graph->GetAllNodes();
97+
const int32 NumNodes = AllNodes.Num();
98+
99+
TArray<int32> Indices;
100+
Indices.Reserve(NumNodes);
101+
102+
for (int32 i = 0; i < NumNodes; ++i)
103+
{
104+
Indices.Add(i);
105+
}
106+
107+
TArray<FString> NodeNames;
108+
NodeNames.Reserve(NumNodes);
109+
110+
Algo::TransformIf(
111+
Indices,
112+
NodeNames,
113+
[&](const int32 Index)
114+
{
115+
const auto Node = AllNodes[Index];
116+
if (!Node)
117+
return false;
118+
return !Algo::AnyOf(
119+
AllowedNodesFilter,
120+
[Node](const TSubclassOf<UMounteaDialogueGraphNode>& FilterClass)
121+
{
122+
return Node->IsA(FilterClass);
123+
}
124+
);
125+
},
126+
[](int32 Index)
127+
{
128+
return FString::FromInt(Index);
129+
}
130+
);
131+
132+
return NodeNames;
133+
}
134+
90135
#if WITH_EDITOR
91136

92137
FText UMounteaDialogueGraphNode_ReturnToNode::GetNodeCategory_Implementation() const

Source/MounteaDialogueSystem/Private/Settings/MounteaDialogueConfiguration.cpp

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,11 @@
44
#include "Settings/MounteaDialogueConfiguration.h"
55

66
#include "Engine/Font.h"
7+
#include "Nodes/MounteaDialogueGraphNode_AnswerNode.h"
8+
#include "Nodes/MounteaDialogueGraphNode_CompleteNode.h"
9+
#include "Nodes/MounteaDialogueGraphNode_Delay.h"
10+
#include "Nodes/MounteaDialogueGraphNode_LeadNode.h"
11+
#include "Nodes/MounteaDialogueGraphNode_StartNode.h"
712

813
UMounteaDialogueConfiguration::UMounteaDialogueConfiguration() :
914
InputMode(EMounteaInputMode::EIM_UIAndGame),
@@ -16,6 +21,36 @@ UMounteaDialogueConfiguration::UMounteaDialogueConfiguration() :
1621
if (SubtitlesSettings.SubtitlesFont.FontObject == nullptr)
1722
SubtitlesSettings.SubtitlesFont = SetupDefaultFontSettings();
1823
#endif
24+
25+
{
26+
FMounteaDialogueGraphNodeConfig leadNodeConfig;
27+
leadNodeConfig.AllowedInputClasses.Add(UMounteaDialogueGraphNode_LeadNode::StaticClass());
28+
leadNodeConfig.AllowedInputClasses.Add(UMounteaDialogueGraphNode_StartNode::StaticClass());
29+
leadNodeConfig.AllowedInputClasses.Add(UMounteaDialogueGraphNode_AnswerNode::StaticClass());
30+
NodesConfiguration.Add(UMounteaDialogueGraphNode_AnswerNode::StaticClass(), leadNodeConfig);
31+
}
32+
{
33+
FMounteaDialogueGraphNodeConfig answerNodeConfig;
34+
answerNodeConfig.AllowedInputClasses.Add(UMounteaDialogueGraphNode_LeadNode::StaticClass());
35+
answerNodeConfig.AllowedInputClasses.Add(UMounteaDialogueGraphNode_StartNode::StaticClass());
36+
answerNodeConfig.AllowedInputClasses.Add(UMounteaDialogueGraphNode_AnswerNode::StaticClass());
37+
NodesConfiguration.Add(UMounteaDialogueGraphNode_LeadNode::StaticClass(), answerNodeConfig);
38+
}
39+
{
40+
FMounteaDialogueGraphNodeConfig completeNodeConfig;
41+
completeNodeConfig.AllowedInputClasses.Add(UMounteaDialogueGraphNode_DialogueNodeBase::StaticClass());
42+
NodesConfiguration.Add(UMounteaDialogueGraphNode_CompleteNode::StaticClass(), completeNodeConfig);
43+
}
44+
{
45+
FMounteaDialogueGraphNodeConfig delayNodeConfig;
46+
delayNodeConfig.AllowedInputClasses.Add(UMounteaDialogueGraphNode::StaticClass());
47+
NodesConfiguration.Add(UMounteaDialogueGraphNode_Delay::StaticClass(), delayNodeConfig);
48+
}
49+
{
50+
FMounteaDialogueGraphNodeConfig dialogueBaseNodeConfig;
51+
dialogueBaseNodeConfig.AllowedInputClasses.Add(UMounteaDialogueGraphNode_Delay::StaticClass());
52+
NodesConfiguration.Add(UMounteaDialogueGraphNode_DialogueNodeBase::StaticClass(), dialogueBaseNodeConfig);
53+
}
1954
}
2055

2156
#if WITH_EDITOR

Source/MounteaDialogueSystem/Public/Decorators/MounteaDialogueDecoratorBase.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ class MOUNTEADIALOGUESYSTEM_API UMounteaDialogueDecoratorBase : public UObject,
6767
FString GetDecoratorDocumentationLink() const;
6868
virtual FString GetDecoratorDocumentationLink_Implementation() const
6969
{
70-
return TEXT("https://github.com/Mountea-Framework/MounteaDialogueSystem/wiki/Dialogue-Decorators");
70+
return TEXT("https://mountea.tools/docs/DialogueSystem/DialogueDecorators/DialogueDecorator");
7171
}
7272

7373
public:

Source/MounteaDialogueSystem/Public/Decorators/MounteaDialogueDecorator_OnlyFirstTime.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ class MOUNTEADIALOGUESYSTEM_API UMounteaDialogueDecorator_OnlyFirstTime : publi
3636
virtual bool IsDecoratorAllowedForGraph_Implementation() const override { return false; };
3737

3838
virtual FString GetDecoratorDocumentationLink_Implementation() const override
39-
{ return TEXT("https://github.com/Mountea-Framework/MounteaDialogueSystem/wiki/Decorator:-Only-First-Time-Base"); }
39+
{ return TEXT("https://mountea.tools/docs/DialogueSystem/DialogueDecorators/OnlyFirstTimeBase"); }
4040

4141
// Returns whether Owning Node has never been called before.
4242
UFUNCTION(BlueprintCallable, BlueprintPure, Category="Mountea|Dialogue|Decorator", meta=(CustomTag="MounteaK2Validate"))

Source/MounteaDialogueSystem/Public/Decorators/MounteaDialogueDecorator_OverrideDialogue.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ class MOUNTEADIALOGUESYSTEM_API UMounteaDialogueDecorator_OverrideDialogue : pub
2727
virtual bool IsDecoratorAllowedForGraph_Implementation() const override { return false; };
2828

2929
virtual FString GetDecoratorDocumentationLink_Implementation() const override
30-
{ return TEXT("https://github.com/Mountea-Framework/MounteaDialogueSystem/wiki/Decorator:-Override-Dialogue-Row-Data"); }
30+
{ return TEXT("https://mountea.tools/docs/DialogueSystem/DialogueDecorators/OverrideDialogueRowData"); }
3131

3232
protected:
3333

0 commit comments

Comments
 (0)