From 9bb98b314b287bde7ebf087089b289a6ee5525fa Mon Sep 17 00:00:00 2001 From: PHILIP White Date: Thu, 4 May 2023 01:42:54 +0100 Subject: [PATCH] Updated Dialogue for Optimisations and Abstraction --- .../Blueprints/Game_UI/WBP_IntroText.uasset | 4 +- .../Dialogue/DialogueNPC.cpp | 40 +++++++------------ .../the_twilight_abyss/Dialogue/DialogueNPC.h | 2 + 3 files changed, 19 insertions(+), 27 deletions(-) diff --git a/Content/Blueprints/Game_UI/WBP_IntroText.uasset b/Content/Blueprints/Game_UI/WBP_IntroText.uasset index 9badfbc..675c6db 100644 --- a/Content/Blueprints/Game_UI/WBP_IntroText.uasset +++ b/Content/Blueprints/Game_UI/WBP_IntroText.uasset @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:3090fac343cac9b839ccc9a5c7afcb649eff4b6f768b1e3df5cdf6fa5c798070 -size 52421 +oid sha256:9dafbdb642ea78e24dc8da5889cfd443613e8a140858ad1234fdbe8684d75fcd +size 55114 diff --git a/Source/the_twilight_abyss/Dialogue/DialogueNPC.cpp b/Source/the_twilight_abyss/Dialogue/DialogueNPC.cpp index 20ea9f1..b2f5d5f 100644 --- a/Source/the_twilight_abyss/Dialogue/DialogueNPC.cpp +++ b/Source/the_twilight_abyss/Dialogue/DialogueNPC.cpp @@ -6,7 +6,6 @@ #include "Components/TextBlock.h" #include "GameFramework/Character.h" #include "Kismet/KismetStringLibrary.h" -#include "the_twilight_abyss/PlayerTemp/TempCharacter.h" #include "the_twilight_abyss/Quest/QuestSystem.h" // Sets default values for this component's properties @@ -94,6 +93,18 @@ void UDialogueNPC::NextCharacter() } } +void UDialogueNPC::ResetDialogueUI() +{ + DialogueIndex = 0; + CurrentDialogue = ""; + CurrentDialogueStringPath = CurrentDialoguePath->Dialogue; + GetWorld()->GetTimerManager().UnPauseTimer(TextAnimationTimerHandle); + Choice1Button->SetVisibility(ESlateVisibility::Hidden); + Choice2Button->SetVisibility(ESlateVisibility::Hidden); + Choice3Button->SetVisibility(ESlateVisibility::Hidden); + NextArrow->SetVisibility(ESlateVisibility::Visible); +} + // Called every frame void UDialogueNPC::TickComponent(float DeltaTime, ELevelTick TickType, FActorComponentTickFunction* ThisTickFunction) { @@ -185,38 +196,17 @@ UDialoguePath* UDialogueNPC::AddQuest(UDialoguePath* DialoguePath, UQuest* Quest void UDialogueNPC::Choice1() { CurrentDialoguePath = CurrentDialoguePath->Choices[0]; - DialogueIndex = 0; - CurrentDialogue = ""; - CurrentDialogueStringPath = CurrentDialoguePath->Dialogue; - GetWorld()->GetTimerManager().UnPauseTimer(TextAnimationTimerHandle); - Choice1Button->SetVisibility(ESlateVisibility::Hidden); - Choice2Button->SetVisibility(ESlateVisibility::Hidden); - Choice3Button->SetVisibility(ESlateVisibility::Hidden); - NextArrow->SetVisibility(ESlateVisibility::Visible); + ResetDialogueUI(); } void UDialogueNPC::Choice2() { CurrentDialoguePath = CurrentDialoguePath->Choices[1]; - DialogueIndex = 0; - CurrentDialogue = ""; - CurrentDialogueStringPath = CurrentDialoguePath->Dialogue; - GetWorld()->GetTimerManager().UnPauseTimer(TextAnimationTimerHandle); - Choice1Button->SetVisibility(ESlateVisibility::Hidden); - Choice2Button->SetVisibility(ESlateVisibility::Hidden); - Choice3Button->SetVisibility(ESlateVisibility::Hidden); - NextArrow->SetVisibility(ESlateVisibility::Visible); + ResetDialogueUI(); } void UDialogueNPC::Choice3() { CurrentDialoguePath = CurrentDialoguePath->Choices[2]; - DialogueIndex = 0; - CurrentDialogue = ""; - CurrentDialogueStringPath = CurrentDialoguePath->Dialogue; - GetWorld()->GetTimerManager().UnPauseTimer(TextAnimationTimerHandle); - Choice1Button->SetVisibility(ESlateVisibility::Hidden); - Choice2Button->SetVisibility(ESlateVisibility::Hidden); - Choice3Button->SetVisibility(ESlateVisibility::Hidden); - NextArrow->SetVisibility(ESlateVisibility::Visible); + ResetDialogueUI(); } diff --git a/Source/the_twilight_abyss/Dialogue/DialogueNPC.h b/Source/the_twilight_abyss/Dialogue/DialogueNPC.h index daa9f79..880c3b3 100644 --- a/Source/the_twilight_abyss/Dialogue/DialogueNPC.h +++ b/Source/the_twilight_abyss/Dialogue/DialogueNPC.h @@ -95,6 +95,8 @@ private: UPROPERTY() TMap Quests; + void ResetDialogueUI(); + public: // Called every frame virtual void TickComponent(float DeltaTime, ELevelTick TickType, FActorComponentTickFunction* ThisTickFunction) override;