From 2f1fe1c0ca0d2092a4f79583f282efe81f165302 Mon Sep 17 00:00:00 2001 From: PHILIP WHITE Date: Tue, 23 Jan 2024 21:21:56 +0000 Subject: [PATCH] Update Dialogue System for Changing Speaker --- .../Content/Dialogue/BP_DialogueUI.uasset | 4 ++-- .../Content/Dialogue/D_Mayor_Tutorial.uasset | 3 +++ .../Content/Dialogue/TestDialogueCube.uasset | 3 +++ .../Dialogue/Testing/TestDialogueCube.uasset | 3 +++ .../Dialogue/Testing/TestDialogueTree.uasset | 3 +++ EndlessVendetta/Content/Dialogue/test.uasset | 3 --- .../E/WM/7S8OEF1ALOX6NKI759UPUB.uasset | 3 +++ .../AC_PlayerDialogueInterpreter.cpp | 20 +++++++++++++++++++ .../AC_PlayerDialogueInterpreter.h | 3 +++ .../DialogueSystem/DialogueChoiceNode.cpp | 5 +++++ .../DialogueSystem/DialogueChoiceNode.h | 1 + .../DialogueSystem/DialogueRootNode.cpp | 2 +- .../DialogueSystem/DialogueTextNode.h | 2 -- .../DialogueSystem/DialogueTree.h | 4 ++-- 14 files changed, 49 insertions(+), 10 deletions(-) create mode 100644 EndlessVendetta/Content/Dialogue/D_Mayor_Tutorial.uasset create mode 100644 EndlessVendetta/Content/Dialogue/TestDialogueCube.uasset create mode 100644 EndlessVendetta/Content/Dialogue/Testing/TestDialogueCube.uasset create mode 100644 EndlessVendetta/Content/Dialogue/Testing/TestDialogueTree.uasset delete mode 100644 EndlessVendetta/Content/Dialogue/test.uasset create mode 100644 EndlessVendetta/Content/__ExternalActors__/Levels/EnemyAITest/E/WM/7S8OEF1ALOX6NKI759UPUB.uasset diff --git a/EndlessVendetta/Content/Dialogue/BP_DialogueUI.uasset b/EndlessVendetta/Content/Dialogue/BP_DialogueUI.uasset index 5a865577..9f3915c0 100644 --- a/EndlessVendetta/Content/Dialogue/BP_DialogueUI.uasset +++ b/EndlessVendetta/Content/Dialogue/BP_DialogueUI.uasset @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:6d51f9881a6133d0034410344d0809ed18ed108981b46507868b51c2bcacd7b6 -size 287864 +oid sha256:047d1379f4ccba4e09d8a17663400ec72aa8143be0404993b4195c6e707683ed +size 294565 diff --git a/EndlessVendetta/Content/Dialogue/D_Mayor_Tutorial.uasset b/EndlessVendetta/Content/Dialogue/D_Mayor_Tutorial.uasset new file mode 100644 index 00000000..d4bbebf6 --- /dev/null +++ b/EndlessVendetta/Content/Dialogue/D_Mayor_Tutorial.uasset @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:ec928f3868dc58bd404ba1745a960d964039c2a2a4140ccad7f94b08ae1fd3a8 +size 4013 diff --git a/EndlessVendetta/Content/Dialogue/TestDialogueCube.uasset b/EndlessVendetta/Content/Dialogue/TestDialogueCube.uasset new file mode 100644 index 00000000..c527979a --- /dev/null +++ b/EndlessVendetta/Content/Dialogue/TestDialogueCube.uasset @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:1f02a139ca0765bc88152d89b253c76f11837193aaaaf1822f950d38578cc5e1 +size 2455 diff --git a/EndlessVendetta/Content/Dialogue/Testing/TestDialogueCube.uasset b/EndlessVendetta/Content/Dialogue/Testing/TestDialogueCube.uasset new file mode 100644 index 00000000..c12313ff --- /dev/null +++ b/EndlessVendetta/Content/Dialogue/Testing/TestDialogueCube.uasset @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:e7323a610767b1f1cc758dd6fa1c9cb34407545561ad153e0ad0ac12cb78f894 +size 28384 diff --git a/EndlessVendetta/Content/Dialogue/Testing/TestDialogueTree.uasset b/EndlessVendetta/Content/Dialogue/Testing/TestDialogueTree.uasset new file mode 100644 index 00000000..f225d161 --- /dev/null +++ b/EndlessVendetta/Content/Dialogue/Testing/TestDialogueTree.uasset @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:85744af1e8b9b15150bb480251591069d637cca3792bb42111744a77347ddc06 +size 17581 diff --git a/EndlessVendetta/Content/Dialogue/test.uasset b/EndlessVendetta/Content/Dialogue/test.uasset deleted file mode 100644 index c8e7f317..00000000 --- a/EndlessVendetta/Content/Dialogue/test.uasset +++ /dev/null @@ -1,3 +0,0 @@ -version https://git-lfs.github.com/spec/v1 -oid sha256:af6de724c9c9f4c366b93b385ebe76dc85d3dbfdde418ecc65fe7492d76c6c4f -size 16429 diff --git a/EndlessVendetta/Content/__ExternalActors__/Levels/EnemyAITest/E/WM/7S8OEF1ALOX6NKI759UPUB.uasset b/EndlessVendetta/Content/__ExternalActors__/Levels/EnemyAITest/E/WM/7S8OEF1ALOX6NKI759UPUB.uasset new file mode 100644 index 00000000..33189d8b --- /dev/null +++ b/EndlessVendetta/Content/__ExternalActors__/Levels/EnemyAITest/E/WM/7S8OEF1ALOX6NKI759UPUB.uasset @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:4e230c10405edc83911b7a264e397dfa14d304c5492cfdd64add703df2b758b6 +size 4769 diff --git a/EndlessVendetta/Source/EndlessVendetta/DialogueSystem/AC_PlayerDialogueInterpreter.cpp b/EndlessVendetta/Source/EndlessVendetta/DialogueSystem/AC_PlayerDialogueInterpreter.cpp index f87077dc..f11997ca 100644 --- a/EndlessVendetta/Source/EndlessVendetta/DialogueSystem/AC_PlayerDialogueInterpreter.cpp +++ b/EndlessVendetta/Source/EndlessVendetta/DialogueSystem/AC_PlayerDialogueInterpreter.cpp @@ -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 void UAC_PlayerDialogueInterpreter::TickComponent(float DeltaTime, ELevelTick TickType, FActorComponentTickFunction* ThisTickFunction) @@ -38,6 +53,8 @@ void UAC_PlayerDialogueInterpreter::StartDialogue(UDialogueTree* DialogueTree) { CurrentDialogueTree = DialogueTree; CurrentTextNode = Cast(DialogueTree->RootNodes[0]->ChildrenNodes[0]); + if (!IsValid(CurrentTextNode)) return; + CurrentCharacterSpeaking = *GetCharacterSpeakingFromEnum(CurrentTextNode->DialogueCharacterSpeaking); OnStartDialogue.Broadcast(CurrentTextNode); if (APlayerController* PlayerController = GetWorld()->GetFirstPlayerController()) @@ -66,6 +83,7 @@ void UAC_PlayerDialogueInterpreter::NextDialogue() else { CurrentTextNode = Cast(CurrentTextNode->ChildrenNodes[0]); + CurrentCharacterSpeaking = *GetCharacterSpeakingFromEnum(CurrentTextNode->DialogueCharacterSpeaking); OnNextDialogue.Broadcast(CurrentTextNode); CurrentChoiceNode = nullptr; } @@ -83,6 +101,7 @@ void UAC_PlayerDialogueInterpreter::MakeChoiceDialogue(const int Choice) else { CurrentTextNode = Cast(CurrentChoiceNode->ChildrenNodes[Choice]); + CurrentCharacterSpeaking = *GetCharacterSpeakingFromEnum(CurrentTextNode->DialogueCharacterSpeaking); OnNextDialogue.Broadcast(CurrentTextNode); CurrentChoiceNode = nullptr; } @@ -92,6 +111,7 @@ void UAC_PlayerDialogueInterpreter::EndDialogue() { CurrentChoiceNode = nullptr; CurrentTextNode = nullptr; + CurrentCharacterSpeaking = FDialogueCharacter(); OnEndDialogue.Broadcast(); if (APlayerController* PlayerController = GetWorld()->GetFirstPlayerController()) diff --git a/EndlessVendetta/Source/EndlessVendetta/DialogueSystem/AC_PlayerDialogueInterpreter.h b/EndlessVendetta/Source/EndlessVendetta/DialogueSystem/AC_PlayerDialogueInterpreter.h index 31da0195..4da84a18 100644 --- a/EndlessVendetta/Source/EndlessVendetta/DialogueSystem/AC_PlayerDialogueInterpreter.h +++ b/EndlessVendetta/Source/EndlessVendetta/DialogueSystem/AC_PlayerDialogueInterpreter.h @@ -37,6 +37,8 @@ public: UPROPERTY(BlueprintReadOnly, VisibleAnywhere, Category = "Dialogue") UDialogueTree* CurrentDialogueTree; + UPROPERTY(BlueprintReadOnly, VisibleAnywhere, Category = "Dialogue") + FDialogueCharacter CurrentCharacterSpeaking; protected: // Called when the game starts @@ -47,6 +49,7 @@ private: UDialogueTextNode* CurrentTextNode; UPROPERTY() UDialogueChoiceNode* CurrentChoiceNode; + FDialogueCharacter* GetCharacterSpeakingFromEnum(ECharacterSpeaking CharacterSpeakingEnum) const; public: // Called every frame diff --git a/EndlessVendetta/Source/EndlessVendetta/DialogueSystem/DialogueChoiceNode.cpp b/EndlessVendetta/Source/EndlessVendetta/DialogueSystem/DialogueChoiceNode.cpp index 2758d6af..a36202da 100644 --- a/EndlessVendetta/Source/EndlessVendetta/DialogueSystem/DialogueChoiceNode.cpp +++ b/EndlessVendetta/Source/EndlessVendetta/DialogueSystem/DialogueChoiceNode.cpp @@ -14,6 +14,11 @@ UDialogueChoiceNode::UDialogueChoiceNode() #if WITH_EDITOR +FText UDialogueChoiceNode::GetNodeTitle() const +{ + return NodeTitle.IsEmpty() ? LOCTEXT("Choice Node", "Choice Node") : NodeTitle; +} + FLinearColor UDialogueChoiceNode::GetBackgroundColor() const { const UDialogueTree* DialogueTree = Cast(GetGraph()); diff --git a/EndlessVendetta/Source/EndlessVendetta/DialogueSystem/DialogueChoiceNode.h b/EndlessVendetta/Source/EndlessVendetta/DialogueSystem/DialogueChoiceNode.h index 0b0550b2..e0d0512c 100644 --- a/EndlessVendetta/Source/EndlessVendetta/DialogueSystem/DialogueChoiceNode.h +++ b/EndlessVendetta/Source/EndlessVendetta/DialogueSystem/DialogueChoiceNode.h @@ -20,6 +20,7 @@ public: FString Choice3Text = "None"; #if WITH_EDITOR + virtual FText GetNodeTitle() const override; virtual FLinearColor GetBackgroundColor() const override; #endif }; diff --git a/EndlessVendetta/Source/EndlessVendetta/DialogueSystem/DialogueRootNode.cpp b/EndlessVendetta/Source/EndlessVendetta/DialogueSystem/DialogueRootNode.cpp index 43a8ab4b..a4981347 100644 --- a/EndlessVendetta/Source/EndlessVendetta/DialogueSystem/DialogueRootNode.cpp +++ b/EndlessVendetta/Source/EndlessVendetta/DialogueSystem/DialogueRootNode.cpp @@ -23,7 +23,7 @@ FLinearColor UDialogueRootNode::GetBackgroundColor() const if (const UDialogueTree* DialogueTree = Cast(GetGraph()); DialogueTree == nullptr) return Super::GetBackgroundColor(); - return FLinearColor(1.f, 1.f, 1.f, 1.f); + return FLinearColor(0.f, 1.f, 0.f, 1.f); } #endif diff --git a/EndlessVendetta/Source/EndlessVendetta/DialogueSystem/DialogueTextNode.h b/EndlessVendetta/Source/EndlessVendetta/DialogueSystem/DialogueTextNode.h index af556e4b..4eb9f33d 100644 --- a/EndlessVendetta/Source/EndlessVendetta/DialogueSystem/DialogueTextNode.h +++ b/EndlessVendetta/Source/EndlessVendetta/DialogueSystem/DialogueTextNode.h @@ -30,9 +30,7 @@ public: #if WITH_EDITOR virtual FText GetNodeTitle() const override; - virtual void SetNodeTitle(const FText& NewTitle) override; - virtual FLinearColor GetBackgroundColor() const override; #endif }; diff --git a/EndlessVendetta/Source/EndlessVendetta/DialogueSystem/DialogueTree.h b/EndlessVendetta/Source/EndlessVendetta/DialogueSystem/DialogueTree.h index ed992455..92f3f1bd 100644 --- a/EndlessVendetta/Source/EndlessVendetta/DialogueSystem/DialogueTree.h +++ b/EndlessVendetta/Source/EndlessVendetta/DialogueSystem/DialogueTree.h @@ -12,9 +12,9 @@ struct FDialogueCharacter UPROPERTY(BlueprintReadOnly, EditDefaultsOnly, Category = "Dialogue") FName CharacterName; UPROPERTY(BlueprintReadOnly, EditDefaultsOnly, Category = "Dialogue") - FLinearColor DialogueNodeBgColor; - UPROPERTY(BlueprintReadOnly, EditDefaultsOnly, Category = "Dialogue") UTexture2D* DialogueCharacterPortrait; + UPROPERTY(BlueprintReadOnly, EditDefaultsOnly, Category = "Node") + FLinearColor DialogueNodeBgColor; }; UCLASS(Blueprintable)