Update Dialogue to Validate Choice Structure
This commit is contained in:
parent
773c69a99b
commit
dd9156e1fc
BIN
EndlessVendetta/Content/Dialogue/Testing/TestDialogueTree.uasset
(Stored with Git LFS)
BIN
EndlessVendetta/Content/Dialogue/Testing/TestDialogueTree.uasset
(Stored with Git LFS)
Binary file not shown.
@ -1,4 +1,6 @@
|
|||||||
#include "DialogueChoiceNode.h"
|
#include "DialogueChoiceNode.h"
|
||||||
|
|
||||||
|
#include "DialogueEdge.h"
|
||||||
#include "DialogueTree.h"
|
#include "DialogueTree.h"
|
||||||
|
|
||||||
#define LOCTEXT_NAMESPACE "UDialogueChoiceNode"
|
#define LOCTEXT_NAMESPACE "UDialogueChoiceNode"
|
||||||
@ -16,6 +18,27 @@ UDialogueChoiceNode::UDialogueChoiceNode()
|
|||||||
|
|
||||||
FText UDialogueChoiceNode::GetNodeTitle() const
|
FText UDialogueChoiceNode::GetNodeTitle() const
|
||||||
{
|
{
|
||||||
|
bool bHasValidNumberOfChoices = false;
|
||||||
|
if (Choices.Num() == ChildrenNodes.Num()) bHasValidNumberOfChoices = true;
|
||||||
|
for (int i = 0; i < Edges.Num(); i++)
|
||||||
|
{
|
||||||
|
if (!bHasValidNumberOfChoices)
|
||||||
|
{
|
||||||
|
Cast<UDialogueEdge>(Edges[ChildrenNodes[i]])->EdgeColour = FLinearColor::Red;
|
||||||
|
Cast<UDialogueEdge>(Edges[ChildrenNodes[i]])->SetNodeTitle(FText::FromString("INVALID"));
|
||||||
|
}
|
||||||
|
else if (Choices[i].Len() > 15)
|
||||||
|
{
|
||||||
|
FString Substring = Choices[i].Left(15);
|
||||||
|
Substring.Append("...");
|
||||||
|
Cast<UDialogueEdge>(Edges[ChildrenNodes[i]])->SetNodeTitle(FText::FromString(Substring));
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
Cast<UDialogueEdge>(Edges[ChildrenNodes[i]])->SetNodeTitle(FText::FromString(Choices[i]));
|
||||||
|
Cast<UDialogueEdge>(Edges[ChildrenNodes[i]])->EdgeColour = FLinearColor::White;
|
||||||
|
}
|
||||||
|
}
|
||||||
const FText ChoiceNodeTitle = NodeTitle.IsEmpty() ? LOCTEXT("Choice Node", "Choice Node") : NodeTitle;
|
const FText ChoiceNodeTitle = NodeTitle.IsEmpty() ? LOCTEXT("Choice Node", "Choice Node") : NodeTitle;
|
||||||
return FText::Format(LOCTEXT("Choice Node Title", "{0} [{1}]"), ChoiceNodeTitle, FText::AsNumber(Choices.Num()));
|
return FText::Format(LOCTEXT("Choice Node Title", "{0} [{1}]"), ChoiceNodeTitle, FText::AsNumber(Choices.Num()));
|
||||||
}
|
}
|
||||||
|
@ -6,11 +6,14 @@
|
|||||||
|
|
||||||
|
|
||||||
UCLASS(Blueprintable)
|
UCLASS(Blueprintable)
|
||||||
class UDialogueEdge: public UGenericGraphEdge
|
class UDialogueEdge : public UGenericGraphEdge
|
||||||
{
|
{
|
||||||
GENERATED_BODY()
|
GENERATED_BODY()
|
||||||
|
|
||||||
// public:
|
UDialogueEdge();
|
||||||
// UPROPERTY(EditDefaultsOnly, BlueprintReadOnly, Category = "Dialogue")
|
};
|
||||||
// FText Selection;
|
|
||||||
};
|
inline UDialogueEdge::UDialogueEdge()
|
||||||
|
{
|
||||||
|
bShouldDrawTitle = true;
|
||||||
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user