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
|
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)
|
void UDialogueTextNode::SetNodeTitle(const FText& NewTitle)
|
||||||
@ -31,12 +53,16 @@ FLinearColor UDialogueTextNode::GetBackgroundColor() const
|
|||||||
if (DialogueTree == nullptr)
|
if (DialogueTree == nullptr)
|
||||||
return Super::GetBackgroundColor();
|
return Super::GetBackgroundColor();
|
||||||
|
|
||||||
switch (DialoguePosition)
|
switch (DialogueCharacterSpeaking)
|
||||||
{
|
{
|
||||||
case EDialoguePosition::Left:
|
case ECharacterSpeaking::Character1:
|
||||||
return DialogueTree->LeftDialogueBgColor;
|
return DialogueTree->Character1.DialogueNodeBgColor;
|
||||||
case EDialoguePosition::Right:
|
case ECharacterSpeaking::Character2:
|
||||||
return DialogueTree->RightDialogueBgColor;
|
return DialogueTree->Character2.DialogueNodeBgColor;
|
||||||
|
case ECharacterSpeaking::Character3:
|
||||||
|
return DialogueTree->Character3.DialogueNodeBgColor;
|
||||||
|
case ECharacterSpeaking::Character4:
|
||||||
|
return DialogueTree->Character4.DialogueNodeBgColor;
|
||||||
default:
|
default:
|
||||||
return FLinearColor::Black;
|
return FLinearColor::Black;
|
||||||
}
|
}
|
||||||
|
@ -2,27 +2,31 @@
|
|||||||
|
|
||||||
#include "CoreMinimal.h"
|
#include "CoreMinimal.h"
|
||||||
#include "GenericGraphNode.h"
|
#include "GenericGraphNode.h"
|
||||||
|
#include "DialogueTree.h"
|
||||||
#include "DialogueTextNode.generated.h"
|
#include "DialogueTextNode.generated.h"
|
||||||
|
|
||||||
UENUM(BlueprintType)
|
UENUM(BlueprintType)
|
||||||
enum class EDialoguePosition : uint8
|
enum class ECharacterSpeaking : uint8
|
||||||
{
|
{
|
||||||
Left,
|
Character1,
|
||||||
Right
|
Character2,
|
||||||
|
Character3,
|
||||||
|
Character4
|
||||||
};
|
};
|
||||||
|
|
||||||
UCLASS(Blueprintable)
|
UCLASS(Blueprintable)
|
||||||
class UDialogueTextNode : public UGenericGraphNode
|
class UDialogueTextNode : public UGenericGraphNode
|
||||||
{
|
{
|
||||||
GENERATED_BODY()
|
GENERATED_BODY()
|
||||||
|
|
||||||
public:
|
public:
|
||||||
UDialogueTextNode();
|
UDialogueTextNode();
|
||||||
|
|
||||||
UPROPERTY(EditDefaultsOnly, BlueprintReadOnly, Category = "Dialogue")
|
UPROPERTY(EditDefaultsOnly, BlueprintReadOnly, Category = "Dialogue", meta = (MultiLine = true))
|
||||||
FText Text;
|
FText Text;
|
||||||
|
|
||||||
UPROPERTY(EditDefaultsOnly, BlueprintReadOnly, Category = "Dialogue")
|
UPROPERTY(EditDefaultsOnly, BlueprintReadOnly, Category = "Dialogue")
|
||||||
EDialoguePosition DialoguePosition;
|
ECharacterSpeaking DialogueCharacterSpeaking = ECharacterSpeaking::Character1;
|
||||||
|
|
||||||
#if WITH_EDITOR
|
#if WITH_EDITOR
|
||||||
virtual FText GetNodeTitle() const override;
|
virtual FText GetNodeTitle() const override;
|
||||||
|
@ -9,10 +9,18 @@ UDialogueTree::UDialogueTree()
|
|||||||
NodeType = UGenericGraphNode::StaticClass();
|
NodeType = UGenericGraphNode::StaticClass();
|
||||||
EdgeType = UDialogueEdge::StaticClass();
|
EdgeType = UDialogueEdge::StaticClass();
|
||||||
|
|
||||||
LeftDialogueBgColor = FLinearColor::Black;
|
|
||||||
RightDialogueBgColor = FLinearColor(0.93f, 0.93f, 0.93f, 1.f);
|
|
||||||
bCanBeCyclical = true;
|
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";
|
Name = "Dialogue Tree";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -4,6 +4,19 @@
|
|||||||
#include "GenericGraph.h"
|
#include "GenericGraph.h"
|
||||||
#include "DialogueTree.generated.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)
|
UCLASS(Blueprintable)
|
||||||
class ENDLESSVENDETTA_API UDialogueTree : public UGenericGraph
|
class ENDLESSVENDETTA_API UDialogueTree : public UGenericGraph
|
||||||
{
|
{
|
||||||
@ -13,8 +26,11 @@ public:
|
|||||||
UDialogueTree();
|
UDialogueTree();
|
||||||
|
|
||||||
UPROPERTY(EditDefaultsOnly, Category = "Dialogue")
|
UPROPERTY(EditDefaultsOnly, Category = "Dialogue")
|
||||||
FLinearColor LeftDialogueBgColor;
|
FDialogueCharacter Character1;
|
||||||
|
|
||||||
UPROPERTY(EditDefaultsOnly, Category = "Dialogue")
|
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