Update Dialogue Tree for Text Wrapping & Multiple Speakers
This commit is contained in:
parent
eb8f90016f
commit
adc5787b43
@ -16,7 +16,29 @@ UDialogueTextNode::UDialogueTextNode()
|
||||
|
||||
FText UDialogueTextNode::GetNodeTitle() const
|
||||
{
|
||||
return Text.IsEmpty() ? LOCTEXT("EmptyParagraph", "(Empty paragraph)") : Text;
|
||||
if (Text.IsEmpty()) return LOCTEXT("EmptyParagraph", "(Empty paragraph)");
|
||||
FString WrappedText = Text.ToString();
|
||||
WrappedText = WrappedText.TrimStartAndEnd();
|
||||
if (Text.ToString().Len() > 20)
|
||||
{
|
||||
WrappedText = "";
|
||||
int CharCount = 0;
|
||||
for (int i = 0; i < Text.ToString().Len(); i++)
|
||||
{
|
||||
if (CharCount > 20 && Text.ToString()[i] == ' ')
|
||||
{
|
||||
WrappedText += "\n";
|
||||
CharCount = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
WrappedText += Text.ToString()[i];
|
||||
CharCount++;
|
||||
}
|
||||
}
|
||||
}
|
||||
UE_LOG(LogTemp, Warning, TEXT("Wrapped Text: %s"), *WrappedText);
|
||||
return FText::FromString(WrappedText);
|
||||
}
|
||||
|
||||
void UDialogueTextNode::SetNodeTitle(const FText& NewTitle)
|
||||
@ -31,12 +53,16 @@ FLinearColor UDialogueTextNode::GetBackgroundColor() const
|
||||
if (DialogueTree == nullptr)
|
||||
return Super::GetBackgroundColor();
|
||||
|
||||
switch (DialoguePosition)
|
||||
switch (DialogueCharacterSpeaking)
|
||||
{
|
||||
case EDialoguePosition::Left:
|
||||
return DialogueTree->LeftDialogueBgColor;
|
||||
case EDialoguePosition::Right:
|
||||
return DialogueTree->RightDialogueBgColor;
|
||||
case ECharacterSpeaking::Character1:
|
||||
return DialogueTree->Character1.DialogueNodeBgColor;
|
||||
case ECharacterSpeaking::Character2:
|
||||
return DialogueTree->Character2.DialogueNodeBgColor;
|
||||
case ECharacterSpeaking::Character3:
|
||||
return DialogueTree->Character3.DialogueNodeBgColor;
|
||||
case ECharacterSpeaking::Character4:
|
||||
return DialogueTree->Character4.DialogueNodeBgColor;
|
||||
default:
|
||||
return FLinearColor::Black;
|
||||
}
|
||||
@ -44,4 +70,4 @@ FLinearColor UDialogueTextNode::GetBackgroundColor() const
|
||||
|
||||
#endif
|
||||
|
||||
#undef LOCTEXT_NAMESPACE
|
||||
#undef LOCTEXT_NAMESPACE
|
||||
|
@ -2,27 +2,31 @@
|
||||
|
||||
#include "CoreMinimal.h"
|
||||
#include "GenericGraphNode.h"
|
||||
#include "DialogueTree.h"
|
||||
#include "DialogueTextNode.generated.h"
|
||||
|
||||
UENUM(BlueprintType)
|
||||
enum class EDialoguePosition : uint8
|
||||
enum class ECharacterSpeaking : uint8
|
||||
{
|
||||
Left,
|
||||
Right
|
||||
Character1,
|
||||
Character2,
|
||||
Character3,
|
||||
Character4
|
||||
};
|
||||
|
||||
UCLASS(Blueprintable)
|
||||
class UDialogueTextNode : public UGenericGraphNode
|
||||
{
|
||||
GENERATED_BODY()
|
||||
|
||||
public:
|
||||
UDialogueTextNode();
|
||||
|
||||
UPROPERTY(EditDefaultsOnly, BlueprintReadOnly, Category = "Dialogue")
|
||||
UPROPERTY(EditDefaultsOnly, BlueprintReadOnly, Category = "Dialogue", meta = (MultiLine = true))
|
||||
FText Text;
|
||||
|
||||
UPROPERTY(EditDefaultsOnly, BlueprintReadOnly, Category = "Dialogue")
|
||||
EDialoguePosition DialoguePosition;
|
||||
ECharacterSpeaking DialogueCharacterSpeaking = ECharacterSpeaking::Character1;
|
||||
|
||||
#if WITH_EDITOR
|
||||
virtual FText GetNodeTitle() const override;
|
||||
@ -31,4 +35,4 @@ public:
|
||||
|
||||
virtual FLinearColor GetBackgroundColor() const override;
|
||||
#endif
|
||||
};
|
||||
};
|
||||
|
@ -9,11 +9,19 @@ UDialogueTree::UDialogueTree()
|
||||
NodeType = UGenericGraphNode::StaticClass();
|
||||
EdgeType = UDialogueEdge::StaticClass();
|
||||
|
||||
LeftDialogueBgColor = FLinearColor::Black;
|
||||
RightDialogueBgColor = FLinearColor(0.93f, 0.93f, 0.93f, 1.f);
|
||||
bCanBeCyclical = true;
|
||||
|
||||
Character1.CharacterName = "Character 1";
|
||||
Character2.CharacterName = "Character 2";
|
||||
Character3.CharacterName = "None";
|
||||
Character4.CharacterName = "None";
|
||||
|
||||
Character1.DialogueNodeBgColor = FLinearColor::Black;
|
||||
Character2.DialogueNodeBgColor = FLinearColor(0.93f, 0.93f, 0.93f, 1.f);
|
||||
Character3.DialogueNodeBgColor = FLinearColor::Yellow;
|
||||
Character4.DialogueNodeBgColor = FLinearColor::Blue;
|
||||
|
||||
Name = "Dialogue Tree";
|
||||
}
|
||||
|
||||
#undef LOCTEXT_NAMESPACE
|
||||
#undef LOCTEXT_NAMESPACE
|
||||
|
@ -4,8 +4,21 @@
|
||||
#include "GenericGraph.h"
|
||||
#include "DialogueTree.generated.h"
|
||||
|
||||
USTRUCT(BlueprintType)
|
||||
struct FDialogueCharacter
|
||||
{
|
||||
GENERATED_BODY()
|
||||
|
||||
UPROPERTY(BlueprintReadOnly, EditDefaultsOnly, Category = "Dialogue")
|
||||
FName CharacterName;
|
||||
UPROPERTY(BlueprintReadOnly, EditDefaultsOnly, Category = "Dialogue")
|
||||
FLinearColor DialogueNodeBgColor;
|
||||
UPROPERTY(BlueprintReadOnly, EditDefaultsOnly, Category = "Dialogue")
|
||||
UTexture2D* DialogueCharacterPortrait;
|
||||
};
|
||||
|
||||
UCLASS(Blueprintable)
|
||||
class ENDLESSVENDETTA_API UDialogueTree: public UGenericGraph
|
||||
class ENDLESSVENDETTA_API UDialogueTree : public UGenericGraph
|
||||
{
|
||||
GENERATED_BODY()
|
||||
|
||||
@ -13,8 +26,11 @@ public:
|
||||
UDialogueTree();
|
||||
|
||||
UPROPERTY(EditDefaultsOnly, Category = "Dialogue")
|
||||
FLinearColor LeftDialogueBgColor;
|
||||
|
||||
FDialogueCharacter Character1;
|
||||
UPROPERTY(EditDefaultsOnly, Category = "Dialogue")
|
||||
FLinearColor RightDialogueBgColor;
|
||||
};
|
||||
FDialogueCharacter Character2;
|
||||
UPROPERTY(EditDefaultsOnly, Category = "Dialogue")
|
||||
FDialogueCharacter Character3;
|
||||
UPROPERTY(EditDefaultsOnly, Category = "Dialogue")
|
||||
FDialogueCharacter Character4;
|
||||
};
|
||||
|
Loading…
Reference in New Issue
Block a user