Merge branch 'Dialogue-System' into Bounty-System-Rework

This commit is contained in:
RAFAL SWIERCZEK 2024-02-02 10:56:20 +00:00
commit bc8a390332
23 changed files with 106 additions and 20 deletions

BIN
EndlessVendetta/Content/Dialogue/BP_ChoiceButton.uasset (Stored with Git LFS) Normal file

Binary file not shown.

Binary file not shown.

BIN
EndlessVendetta/Content/Dialogue/D_Mayor_Tutorial.uasset (Stored with Git LFS) Normal file

Binary file not shown.

BIN
EndlessVendetta/Content/Dialogue/TestDialogueCube.uasset (Stored with Git LFS) Normal file

Binary file not shown.

BIN
EndlessVendetta/Content/Dialogue/Testing/BP_Mayor.uasset (Stored with Git LFS) Normal file

Binary file not shown.

BIN
EndlessVendetta/Content/Dialogue/Testing/Catman_Idle.uasset (Stored with Git LFS) Normal file

Binary file not shown.

Binary file not shown.

Binary file not shown.

BIN
EndlessVendetta/Content/Dialogue/Testing/Material.uasset (Stored with Git LFS) Normal file

Binary file not shown.

BIN
EndlessVendetta/Content/Dialogue/Testing/Material_001.uasset (Stored with Git LFS) Normal file

Binary file not shown.

BIN
EndlessVendetta/Content/Dialogue/Testing/Material_002.uasset (Stored with Git LFS) Normal file

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

View File

@ -25,6 +25,21 @@ void UAC_PlayerDialogueInterpreter::BeginPlay()
// ... // ...
} }
FDialogueCharacter* UAC_PlayerDialogueInterpreter::GetCharacterSpeakingFromEnum(ECharacterSpeaking CharacterSpeakingEnum) const
{
switch (CharacterSpeakingEnum)
{
case ECharacterSpeaking::Character1:
return &CurrentDialogueTree->Character1;
case ECharacterSpeaking::Character2:
return &CurrentDialogueTree->Character2;
case ECharacterSpeaking::Character3:
return &CurrentDialogueTree->Character3;
case ECharacterSpeaking::Character4:
return &CurrentDialogueTree->Character4;
}
return nullptr;
}
// Called every frame // Called every frame
void UAC_PlayerDialogueInterpreter::TickComponent(float DeltaTime, ELevelTick TickType, FActorComponentTickFunction* ThisTickFunction) void UAC_PlayerDialogueInterpreter::TickComponent(float DeltaTime, ELevelTick TickType, FActorComponentTickFunction* ThisTickFunction)
@ -38,6 +53,8 @@ void UAC_PlayerDialogueInterpreter::StartDialogue(UDialogueTree* DialogueTree)
{ {
CurrentDialogueTree = DialogueTree; CurrentDialogueTree = DialogueTree;
CurrentTextNode = Cast<UDialogueTextNode>(DialogueTree->RootNodes[0]->ChildrenNodes[0]); CurrentTextNode = Cast<UDialogueTextNode>(DialogueTree->RootNodes[0]->ChildrenNodes[0]);
if (!IsValid(CurrentTextNode)) return;
CurrentCharacterSpeaking = *GetCharacterSpeakingFromEnum(CurrentTextNode->DialogueCharacterSpeaking);
OnStartDialogue.Broadcast(CurrentTextNode); OnStartDialogue.Broadcast(CurrentTextNode);
if (APlayerController* PlayerController = GetWorld()->GetFirstPlayerController()) if (APlayerController* PlayerController = GetWorld()->GetFirstPlayerController())
@ -66,6 +83,7 @@ void UAC_PlayerDialogueInterpreter::NextDialogue()
else else
{ {
CurrentTextNode = Cast<UDialogueTextNode>(CurrentTextNode->ChildrenNodes[0]); CurrentTextNode = Cast<UDialogueTextNode>(CurrentTextNode->ChildrenNodes[0]);
CurrentCharacterSpeaking = *GetCharacterSpeakingFromEnum(CurrentTextNode->DialogueCharacterSpeaking);
OnNextDialogue.Broadcast(CurrentTextNode); OnNextDialogue.Broadcast(CurrentTextNode);
CurrentChoiceNode = nullptr; CurrentChoiceNode = nullptr;
} }
@ -83,6 +101,7 @@ void UAC_PlayerDialogueInterpreter::MakeChoiceDialogue(const int Choice)
else else
{ {
CurrentTextNode = Cast<UDialogueTextNode>(CurrentChoiceNode->ChildrenNodes[Choice]); CurrentTextNode = Cast<UDialogueTextNode>(CurrentChoiceNode->ChildrenNodes[Choice]);
CurrentCharacterSpeaking = *GetCharacterSpeakingFromEnum(CurrentTextNode->DialogueCharacterSpeaking);
OnNextDialogue.Broadcast(CurrentTextNode); OnNextDialogue.Broadcast(CurrentTextNode);
CurrentChoiceNode = nullptr; CurrentChoiceNode = nullptr;
} }
@ -92,6 +111,7 @@ void UAC_PlayerDialogueInterpreter::EndDialogue()
{ {
CurrentChoiceNode = nullptr; CurrentChoiceNode = nullptr;
CurrentTextNode = nullptr; CurrentTextNode = nullptr;
CurrentCharacterSpeaking = FDialogueCharacter();
OnEndDialogue.Broadcast(); OnEndDialogue.Broadcast();
if (APlayerController* PlayerController = GetWorld()->GetFirstPlayerController()) if (APlayerController* PlayerController = GetWorld()->GetFirstPlayerController())

View File

@ -37,6 +37,8 @@ public:
UPROPERTY(BlueprintReadOnly, VisibleAnywhere, Category = "Dialogue") UPROPERTY(BlueprintReadOnly, VisibleAnywhere, Category = "Dialogue")
UDialogueTree* CurrentDialogueTree; UDialogueTree* CurrentDialogueTree;
UPROPERTY(BlueprintReadOnly, VisibleAnywhere, Category = "Dialogue")
FDialogueCharacter CurrentCharacterSpeaking;
protected: protected:
// Called when the game starts // Called when the game starts
@ -47,6 +49,7 @@ private:
UDialogueTextNode* CurrentTextNode; UDialogueTextNode* CurrentTextNode;
UPROPERTY() UPROPERTY()
UDialogueChoiceNode* CurrentChoiceNode; UDialogueChoiceNode* CurrentChoiceNode;
FDialogueCharacter* GetCharacterSpeakingFromEnum(ECharacterSpeaking CharacterSpeakingEnum) const;
public: public:
// Called every frame // Called every frame

View File

@ -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"
@ -14,6 +16,33 @@ UDialogueChoiceNode::UDialogueChoiceNode()
#if WITH_EDITOR #if WITH_EDITOR
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()));
}
FLinearColor UDialogueChoiceNode::GetBackgroundColor() const FLinearColor UDialogueChoiceNode::GetBackgroundColor() const
{ {
const UDialogueTree* DialogueTree = Cast<UDialogueTree>(GetGraph()); const UDialogueTree* DialogueTree = Cast<UDialogueTree>(GetGraph());

View File

@ -13,13 +13,10 @@ public:
UDialogueChoiceNode(); UDialogueChoiceNode();
UPROPERTY(EditDefaultsOnly, BlueprintReadOnly, Category = "Dialogue") UPROPERTY(EditDefaultsOnly, BlueprintReadOnly, Category = "Dialogue")
FString Choice1Text = "None"; TArray<FString> Choices;
UPROPERTY(EditDefaultsOnly, BlueprintReadOnly, Category = "Dialogue")
FString Choice2Text = "None";
UPROPERTY(EditDefaultsOnly, BlueprintReadOnly, Category = "Dialogue")
FString Choice3Text = "None";
#if WITH_EDITOR #if WITH_EDITOR
virtual FText GetNodeTitle() const override;
virtual FLinearColor GetBackgroundColor() const override; virtual FLinearColor GetBackgroundColor() const override;
#endif #endif
}; };

View File

@ -10,7 +10,10 @@ class UDialogueEdge: public UGenericGraphEdge
{ {
GENERATED_BODY() GENERATED_BODY()
// public: UDialogueEdge();
// UPROPERTY(EditDefaultsOnly, BlueprintReadOnly, Category = "Dialogue")
// FText Selection;
}; };
inline UDialogueEdge::UDialogueEdge()
{
bShouldDrawTitle = true;
}

View File

@ -23,7 +23,7 @@ FLinearColor UDialogueRootNode::GetBackgroundColor() const
if (const UDialogueTree* DialogueTree = Cast<UDialogueTree>(GetGraph()); DialogueTree == nullptr) if (const UDialogueTree* DialogueTree = Cast<UDialogueTree>(GetGraph()); DialogueTree == nullptr)
return Super::GetBackgroundColor(); return Super::GetBackgroundColor();
return FLinearColor(1.f, 1.f, 1.f, 1.f); return FLinearColor(0.f, 1.f, 0.f, 1.f);
} }
#endif #endif

View File

@ -30,9 +30,7 @@ public:
#if WITH_EDITOR #if WITH_EDITOR
virtual FText GetNodeTitle() const override; virtual FText GetNodeTitle() const override;
virtual void SetNodeTitle(const FText& NewTitle) override; virtual void SetNodeTitle(const FText& NewTitle) override;
virtual FLinearColor GetBackgroundColor() const override; virtual FLinearColor GetBackgroundColor() const override;
#endif #endif
}; };

View File

@ -12,9 +12,9 @@ struct FDialogueCharacter
UPROPERTY(BlueprintReadOnly, EditDefaultsOnly, Category = "Dialogue") UPROPERTY(BlueprintReadOnly, EditDefaultsOnly, Category = "Dialogue")
FName CharacterName; FName CharacterName;
UPROPERTY(BlueprintReadOnly, EditDefaultsOnly, Category = "Dialogue") UPROPERTY(BlueprintReadOnly, EditDefaultsOnly, Category = "Dialogue")
FLinearColor DialogueNodeBgColor;
UPROPERTY(BlueprintReadOnly, EditDefaultsOnly, Category = "Dialogue")
UTexture2D* DialogueCharacterPortrait; UTexture2D* DialogueCharacterPortrait;
UPROPERTY(BlueprintReadOnly, EditDefaultsOnly, Category = "Node")
FLinearColor DialogueNodeBgColor;
}; };
UCLASS(Blueprintable) UCLASS(Blueprintable)