From 9bfb07fbbacc54f98a6e411dec9b3c365fb29c90 Mon Sep 17 00:00:00 2001 From: PHILIP White Date: Thu, 9 Feb 2023 17:01:03 +0000 Subject: [PATCH] Updated DialogueNPC to Add Ids for Dialogue Paths --- .../Dialogue/DialogueNPC.cpp | 31 ++++++++++++++++--- .../the_twilight_abyss/Dialogue/DialogueNPC.h | 26 ++++++++++++++-- 2 files changed, 51 insertions(+), 6 deletions(-) diff --git a/Source/the_twilight_abyss/Dialogue/DialogueNPC.cpp b/Source/the_twilight_abyss/Dialogue/DialogueNPC.cpp index 31ab5ca..a62d7bb 100644 --- a/Source/the_twilight_abyss/Dialogue/DialogueNPC.cpp +++ b/Source/the_twilight_abyss/Dialogue/DialogueNPC.cpp @@ -106,11 +106,34 @@ void UDialogueNPC::EndDialogue() PlayerController->bShowMouseCursor = false; } -TArray UDialogueNPC::AddDialogue(FText TextInput, TArray DialogueArrayInput) +FDialoguePath UDialogueNPC::CreateRootDialoguePath() { - if (TextInput.IsEmpty()) return DialogueArrayInput; - DialogueArrayInput.Add(TextInput.ToString()); - return DialogueArrayInput; + return FDialoguePath(); +} + +FDialoguePath UDialogueNPC::CreateDialoguePath(FDialoguePath ParentDialoguePath) +{ + return FDialoguePath("#" + FString::FromInt(DialoguePaths.Num())); +} + +bool UDialogueNPC::GotoDialoguePath(FString PathId) +{ + for each (FDialoguePath DialogPath in DialoguePaths) + { + if (DialogPath.Dialogue[0] == PathId) + { + CurrentDialoguePath = DialogPath.Dialogue; + return true; + } + } + return false; +} + +FDialoguePath UDialogueNPC::AddDialogue(FText TextInput, FDialoguePath DialoguePath) +{ + if (TextInput.IsEmpty()) return DialoguePath; + DialoguePath.Dialogue.Add(TextInput.ToString()); + return DialoguePath; } void UDialogueNPC::GetFinalDialogue(TArray DialogueArray) diff --git a/Source/the_twilight_abyss/Dialogue/DialogueNPC.h b/Source/the_twilight_abyss/Dialogue/DialogueNPC.h index a9afa2b..f2a9409 100644 --- a/Source/the_twilight_abyss/Dialogue/DialogueNPC.h +++ b/Source/the_twilight_abyss/Dialogue/DialogueNPC.h @@ -24,7 +24,17 @@ struct FDialoguePath UPROPERTY() TArray Dialogue; - explicit FDialoguePath(const TArray Dialogue) + FDialoguePath() + { + Dialogue.Add("#ROOT"); + } + + FDialoguePath(FString Id) + { + Dialogue.Add(Id); + } + + explicit FDialoguePath(TArray Dialogue) { this->Dialogue = Dialogue; } @@ -91,7 +101,19 @@ public: void EndDialogue(); UFUNCTION(BlueprintPure) - TArray AddDialogue(FText TextInput, TArray DialogueArrayInput); + FDialoguePath CreateRootDialoguePath(); + + UFUNCTION() + FDialoguePath CreateDialoguePath(FDialoguePath ParentDialoguePath); + + UFUNCTION(BlueprintPure) + void CreateDialogueChoice(FDialoguePath PreviousDialoguePath); + + UFUNCTION() + bool GotoDialoguePath(FString PathId); + + UFUNCTION(BlueprintPure) + FDialoguePath AddDialogue(FText TextInput, FDialoguePath DialoguePath); UFUNCTION(BlueprintCallable) void GetFinalDialogue(TArray DialogueArray);