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 "DialogueEdge.h"
|
||||
#include "DialogueTree.h"
|
||||
|
||||
#define LOCTEXT_NAMESPACE "UDialogueChoiceNode"
|
||||
@ -16,6 +18,27 @@ UDialogueChoiceNode::UDialogueChoiceNode()
|
||||
|
||||
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;
|
||||
return FText::Format(LOCTEXT("Choice Node Title", "{0} [{1}]"), ChoiceNodeTitle, FText::AsNumber(Choices.Num()));
|
||||
}
|
||||
|
@ -10,7 +10,10 @@ class UDialogueEdge: public UGenericGraphEdge
|
||||
{
|
||||
GENERATED_BODY()
|
||||
|
||||
// public:
|
||||
// UPROPERTY(EditDefaultsOnly, BlueprintReadOnly, Category = "Dialogue")
|
||||
// FText Selection;
|
||||
UDialogueEdge();
|
||||
};
|
||||
|
||||
inline UDialogueEdge::UDialogueEdge()
|
||||
{
|
||||
bShouldDrawTitle = true;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user