From 7f3e3cbb52f2a9324b5cbd310f47bb34ad66a13a Mon Sep 17 00:00:00 2001 From: PHILIP White Date: Mon, 6 Feb 2023 03:28:53 +0000 Subject: [PATCH] Updated DialogueNPC to Add Dialogue via Blueprints --- Content/Dialogue/NPCTest.uasset | 4 ++-- .../Dialogue/DialogueNPC.cpp | 16 ++++++++++--- .../the_twilight_abyss/Dialogue/DialogueNPC.h | 23 +++++++++++-------- 3 files changed, 28 insertions(+), 15 deletions(-) diff --git a/Content/Dialogue/NPCTest.uasset b/Content/Dialogue/NPCTest.uasset index 8bcd011..e33f5cc 100644 --- a/Content/Dialogue/NPCTest.uasset +++ b/Content/Dialogue/NPCTest.uasset @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:721d5229ead581f3db621f16f64292467e4f049587194e59b3c23343e61076c8 -size 31202 +oid sha256:3d8d35e08f9a82472293b350e194a815b8e58c85084e33c6211de9f7c59a67a8 +size 47133 diff --git a/Source/the_twilight_abyss/Dialogue/DialogueNPC.cpp b/Source/the_twilight_abyss/Dialogue/DialogueNPC.cpp index 50e8379..af4c7ba 100644 --- a/Source/the_twilight_abyss/Dialogue/DialogueNPC.cpp +++ b/Source/the_twilight_abyss/Dialogue/DialogueNPC.cpp @@ -34,8 +34,6 @@ void UDialogueNPC::BeginPlay() void UDialogueNPC::NextDialogue() { - //log bruh - UE_LOG(LogTemp, Warning, TEXT("Next Dialogue")); //Dialogue Skip if (CurrentDialogue.Len() < Dialogue[DialogueIndex].Len()) { @@ -85,7 +83,7 @@ void UDialogueNPC::StartDialogue() PlayerController->bShowMouseCursor = true; DialogueWidgetInstance->AddToViewport(); - DialogueIndex = 0; + DialogueIndex = 1; NPCNameText->SetText(FText::FromString(NPCName)); CurrentDialogue = ""; GetWorld()->GetTimerManager().SetTimer(TextAnimationTimerHandle, this, &UDialogueNPC::NextCharacter, TextAnimationSpeed, true); @@ -106,3 +104,15 @@ void UDialogueNPC::EndDialogue() PlayerController->SetInputMode(FInputModeGameOnly()); PlayerController->bShowMouseCursor = false; } + +TArray UDialogueNPC::AddDialogue(FText TextInput, TArray DialogueArrayInput) +{ + if (TextInput.IsEmpty()) return DialogueArrayInput; + DialogueArrayInput.Add(TextInput.ToString()); + return DialogueArrayInput; +} + +void UDialogueNPC::GetFinalDialogue(TArray DialogueArray) +{ + Dialogue = DialogueArray; +} diff --git a/Source/the_twilight_abyss/Dialogue/DialogueNPC.h b/Source/the_twilight_abyss/Dialogue/DialogueNPC.h index a674427..eeb8276 100644 --- a/Source/the_twilight_abyss/Dialogue/DialogueNPC.h +++ b/Source/the_twilight_abyss/Dialogue/DialogueNPC.h @@ -8,12 +8,12 @@ #include "Components/TextBlock.h" #include "DialogueNPC.generated.h" -UENUM() -enum class EDialogueType +UENUM(BlueprintType) +enum class EChoices : uint8 { - Text UMETA(DisplayName="Text"), - End UMETA(DisplayName="End"), - Action UMETA(DisplayName="Action"), + Choice1 UMETA(DisplayName="Choice 1"), + Choice2 UMETA(DisplayName="Choice 2"), + Choice3 UMETA(DisplayName="Choice 3"), }; UCLASS(ClassGroup=(Custom), meta=(BlueprintSpawnableComponent)) @@ -28,10 +28,7 @@ public: UPROPERTY(EditAnywhere) FString NPCName; - UPROPERTY(EditAnywhere) - TArray DialogueType; - - UPROPERTY(EditAnywhere) + UPROPERTY() TArray Dialogue; UPROPERTY(EditAnywhere) @@ -57,7 +54,7 @@ private: UPROPERTY() UButton* NextButton; - int DialogueIndex = 0; + int DialogueIndex = 1; FString CurrentDialogue; UPROPERTY() @@ -76,4 +73,10 @@ public: UFUNCTION(BlueprintCallable) void EndDialogue(); + + UFUNCTION(BlueprintPure) + TArray AddDialogue(FText TextInput, TArray DialogueArrayInput); + + UFUNCTION(BlueprintCallable) + void GetFinalDialogue(TArray DialogueArray); };