diff --git a/Content/Blueprints/Combat_UI/CombatCharacter.uasset b/Content/Blueprints/Combat_UI/CombatCharacter.uasset index 55b464e..5a5a38a 100644 --- a/Content/Blueprints/Combat_UI/CombatCharacter.uasset +++ b/Content/Blueprints/Combat_UI/CombatCharacter.uasset @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:59e49f5ac21ef2b66e0d6eba22bb309b9a177d9c454e8a78eedc9b40788fe3b7 -size 74399 +oid sha256:fa5a4588db7886e28e8862809e819137d8bc98e191f2b8d8369cebdf7e425737 +size 84101 diff --git a/Content/Dialogue/BungeeManPortrait.uasset b/Content/Dialogue/BungeeManPortrait.uasset new file mode 100644 index 0000000..2af7db7 --- /dev/null +++ b/Content/Dialogue/BungeeManPortrait.uasset @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:0ce66a0de831991e0a11f66633428bfe3dc25d9beecd5ed3c99a20e454e42822 +size 107279 diff --git a/Content/Dialogue/DialogueTest.umap b/Content/Dialogue/DialogueTest.umap index 9ce057c..d2cca9e 100644 --- a/Content/Dialogue/DialogueTest.umap +++ b/Content/Dialogue/DialogueTest.umap @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:10874d3de45d0093660a3b6e12561bc69214daafe2cd3072f9574c83f6cbc5d1 -size 40398 +oid sha256:6cebce24cfcd1333109dac833b39e7e0d425562e5bfad6e06ed1beaaac7ed181 +size 40317 diff --git a/Content/Dialogue/NPCTest.uasset b/Content/Dialogue/NPCTest.uasset index 7ee990d..68a9f1e 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:f99fe93ed5bc4534338fea5cabf8e1d078c3b91032f9813339bbc56ac21caf6b -size 46996 +oid sha256:f0ad8840517a535b9c0ed3e940916072540e85bb94f95e85f07c29e6d9fdc481 +size 63292 diff --git a/Content/Dialogue/TextPrompt.uasset b/Content/Dialogue/TextPrompt.uasset index 36af6e8..047ed0c 100644 --- a/Content/Dialogue/TextPrompt.uasset +++ b/Content/Dialogue/TextPrompt.uasset @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:9f186852f793c0cf57654d61c8314956651f3c41f25d508459e48d00f7ea0581 -size 45953 +oid sha256:a3b5fa6517a77733e630214224da6e359af110afe3736a12a23d0f92c52b6a35 +size 45981 diff --git a/Source/the_twilight_abyss/Dialogue/DialogueNPC.cpp b/Source/the_twilight_abyss/Dialogue/DialogueNPC.cpp index db464e5..4630d66 100644 --- a/Source/the_twilight_abyss/Dialogue/DialogueNPC.cpp +++ b/Source/the_twilight_abyss/Dialogue/DialogueNPC.cpp @@ -29,23 +29,45 @@ void UDialogueNPC::BeginPlay() DialogueText = Cast(DialogueWidgetInstance->GetWidgetFromName("Text_Dialogue")); NextButton = Cast(DialogueWidgetInstance->GetWidgetFromName("Button_Next")); NextButton->OnClicked.AddDynamic(this, &UDialogueNPC::NextDialogue); + NPCPortraitImage = Cast(DialogueWidgetInstance->GetWidgetFromName("Image_Portrait")); + if (IsValid(NPCPortrait)) NPCPortraitImage->SetBrushFromTexture(NPCPortrait); + + Choice1Button = Cast(DialogueWidgetInstance->GetWidgetFromName("Button_Choice1")); + Choice1Button->OnClicked.AddDynamic(this, &UDialogueNPC::Choice1); + Choice2Button = Cast(DialogueWidgetInstance->GetWidgetFromName("Button_Choice2")); + Choice2Button->OnClicked.AddDynamic(this, &UDialogueNPC::Choice2); + Choice3Button = Cast(DialogueWidgetInstance->GetWidgetFromName("Button_Choice3")); + Choice3Button->OnClicked.AddDynamic(this, &UDialogueNPC::Choice3); + Choice1Text = Cast(DialogueWidgetInstance->GetWidgetFromName("Text_Choice1")); + Choice2Text = Cast(DialogueWidgetInstance->GetWidgetFromName("Text_Choice2")); + Choice3Text = Cast(DialogueWidgetInstance->GetWidgetFromName("Text_Choice3")); } void UDialogueNPC::NextDialogue() { //Dialogue Skip - if (CurrentDialogue.Len() < CurrentDialoguePath[DialogueIndex].Len()) + if (CurrentDialogue.Len() < CurrentDialogueStringPath[DialogueIndex].Len()) { - CurrentDialogue = CurrentDialoguePath[DialogueIndex]; + CurrentDialogue = CurrentDialogueStringPath[DialogueIndex]; DialogueText->SetText(FText::FromString(CurrentDialogue)); return; } DialogueIndex++; - if (DialogueIndex >= CurrentDialoguePath.Num()) + if (DialogueIndex >= CurrentDialogueStringPath.Num()) { - EndDialogue(); + if (CurrentDialoguePath->Choices.IsEmpty()) + { + EndDialogue(); + return; + } + GetWorld()->GetTimerManager().PauseTimer(TextAnimationTimerHandle); + DialogueText->SetText(FText::FromString("")); + Choice1Button->SetVisibility(ESlateVisibility::Visible); + Choice2Button->SetVisibility(ESlateVisibility::Visible); + if (Choice3Text->GetText().ToString() != "") Choice3Button->SetVisibility(ESlateVisibility::Visible); + NextButton->SetVisibility(ESlateVisibility::Hidden); return; } CurrentDialogue = ""; @@ -53,11 +75,11 @@ void UDialogueNPC::NextDialogue() void UDialogueNPC::NextCharacter() { - if (DialogueIndex >= CurrentDialoguePath.Num()) return; + if (DialogueIndex >= CurrentDialogueStringPath.Num()) return; - if (CurrentDialogue.Len() < CurrentDialoguePath[DialogueIndex].Len()) + if (CurrentDialogue.Len() < CurrentDialogueStringPath[DialogueIndex].Len()) { - CurrentDialogue.AppendChar(CurrentDialoguePath[DialogueIndex][CurrentDialogue.Len()]); + CurrentDialogue.AppendChar(CurrentDialogueStringPath[DialogueIndex][CurrentDialogue.Len()]); DialogueText->SetText(FText::FromString(CurrentDialogue)); } } @@ -72,6 +94,12 @@ void UDialogueNPC::TickComponent(float DeltaTime, ELevelTick TickType, FActorCom void UDialogueNPC::StartDialogue() { + if (IsValid(RootDialoguePath)) CurrentDialogueStringPath = RootDialoguePath->Dialogue; + if (CurrentDialogueStringPath.IsEmpty()) + { + UE_LOG(LogTemp, Warning, TEXT("Dialogue Path is Empty")); + return; + } //Disable Character Movement if (ACharacter* PlayerCharacter = Cast(GetWorld()->GetFirstPlayerController()->GetPawn())) { @@ -82,11 +110,16 @@ void UDialogueNPC::StartDialogue() PlayerController->SetInputMode(FInputModeUIOnly()); PlayerController->bShowMouseCursor = true; + Choice1Button->SetVisibility(ESlateVisibility::Hidden); + Choice2Button->SetVisibility(ESlateVisibility::Hidden); + Choice3Button->SetVisibility(ESlateVisibility::Hidden); + DialogueText->SetText(FText::FromString("")); DialogueWidgetInstance->AddToViewport(); - DialogueIndex = 1; NPCNameText->SetText(FText::FromString(NPCName)); + DialogueIndex = 0; CurrentDialogue = ""; - CurrentDialoguePath = DialoguePaths[0].Dialogue; + CurrentDialoguePath = RootDialoguePath; + CurrentDialogueStringPath = RootDialoguePath->Dialogue; GetWorld()->GetTimerManager().SetTimer(TextAnimationTimerHandle, this, &UDialogueNPC::NextCharacter, TextAnimationSpeed, true); } @@ -106,42 +139,67 @@ void UDialogueNPC::EndDialogue() PlayerController->bShowMouseCursor = false; } -FDialoguePath UDialogueNPC::CreateRootDialoguePath() +UDialoguePath* UDialogueNPC::CreateRootDialoguePath() { - return FDialoguePath(); + RootDialoguePath = NewObject(); + return RootDialoguePath; } -FDialoguePath UDialogueNPC::CreateDialoguePath(FDialoguePath ParentDialoguePath) -{ - return FDialoguePath("#" + FString::FromInt(DialoguePaths.Num())); -} - -FDialoguePath UDialogueNPC::CreateDialogueChoice(FDialoguePath PreviousDialoguePath) -{ - return FDialoguePath(); -} - -bool UDialogueNPC::GotoDialoguePath(FString PathId) -{ - for (FDialoguePath DialogPath : DialoguePaths) - { - if (DialogPath.Dialogue[0] == PathId) - { - CurrentDialoguePath = DialogPath.Dialogue; - return true; - } - } - return false; -} - -FDialoguePath UDialogueNPC::AddDialogue(FText TextInput, FDialoguePath DialoguePath) +UDialoguePath* UDialogueNPC::AddDialogue(UDialoguePath* DialoguePath, FText TextInput) { if (TextInput.IsEmpty()) return DialoguePath; - DialoguePath.Dialogue.Add(TextInput.ToString()); + DialoguePath->Dialogue.Add(TextInput.ToString()); return DialoguePath; } -void UDialogueNPC::GetFinalDialogue(TArray DialogueArray) +void UDialogueNPC::AddChoices(UDialoguePath* ParentPath, FText ChoiceText1, FText ChoiceText2, FText ChoiceText3, UDialoguePath*& Out_ChoicePath1, UDialoguePath*& Out_ChoicePath2, UDialoguePath*& Out_ChoicePath3) { - DialoguePaths.Add(FDialoguePath(DialogueArray)); + ParentPath->Choices.Add(NewObject()); + ParentPath->Choices.Add(NewObject()); + ParentPath->Choices.Add(NewObject()); + Out_ChoicePath1 = ParentPath->Choices[0]; + Out_ChoicePath2 = ParentPath->Choices[1]; + Out_ChoicePath3 = ParentPath->Choices[2]; + Choice1Text->SetText(ChoiceText1); + Choice2Text->SetText(ChoiceText2); + Choice3Text->SetText(ChoiceText3); +} + +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); + NextButton->SetVisibility(ESlateVisibility::Visible); +} + +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); + NextButton->SetVisibility(ESlateVisibility::Visible); +} + +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); + NextButton->SetVisibility(ESlateVisibility::Visible); } diff --git a/Source/the_twilight_abyss/Dialogue/DialogueNPC.h b/Source/the_twilight_abyss/Dialogue/DialogueNPC.h index 4b6f2f9..4ceda47 100644 --- a/Source/the_twilight_abyss/Dialogue/DialogueNPC.h +++ b/Source/the_twilight_abyss/Dialogue/DialogueNPC.h @@ -6,38 +6,20 @@ #include "Components/ActorComponent.h" #include "Components/Button.h" #include "Components/TextBlock.h" +#include "Components/Image.h" #include "DialogueNPC.generated.h" -UENUM(BlueprintType) -enum class EChoices : uint8 -{ - Choice1 UMETA(DisplayName="Choice 1"), - Choice2 UMETA(DisplayName="Choice 2"), - Choice3 UMETA(DisplayName="Choice 3"), -}; - -USTRUCT(BlueprintType) -struct FDialoguePath +UCLASS(ClassGroup=(Custom), meta=(BlueprintSpawnableComponent)) +class UDialoguePath : public UObject { GENERATED_BODY() - UPROPERTY() +public: + UPROPERTY(BlueprintReadWrite) TArray Dialogue; - FDialoguePath() - { - Dialogue.Add("#ROOT"); - } - - FDialoguePath(FString Id) - { - Dialogue.Add(Id); - } - - explicit FDialoguePath(TArray Dialogue) - { - this->Dialogue = Dialogue; - } + UPROPERTY(BlueprintReadWrite) + TArray Choices; }; UCLASS(ClassGroup=(Custom), meta=(BlueprintSpawnableComponent)) @@ -51,11 +33,15 @@ public: UPROPERTY(EditAnywhere) FString NPCName; - - UPROPERTY() - TArray DialoguePaths; - TArray CurrentDialoguePath; + UPROPERTY() + UDialoguePath* RootDialoguePath; + UPROPERTY() + UDialoguePath* CurrentDialoguePath; + TArray CurrentDialogueStringPath; + + UPROPERTY(EditAnywhere) + UTexture2D* NPCPortrait; UPROPERTY(EditAnywhere) float TextAnimationSpeed = 0.05f; @@ -70,13 +56,26 @@ protected: private: UPROPERTY() UUserWidget* DialogueWidgetInstance; - - UPROPERTY() - UTextBlock* NPCNameText; + UPROPERTY() + UTextBlock* NPCNameText; UPROPERTY() UTextBlock* DialogueText; - + UPROPERTY() + UImage* NPCPortraitImage; + UPROPERTY() + UButton* Choice1Button; + UPROPERTY() + UButton* Choice2Button; + UPROPERTY() + UButton* Choice3Button; + UPROPERTY() + UTextBlock* Choice1Text; + UPROPERTY() + UTextBlock* Choice2Text; + UPROPERTY() + UTextBlock* Choice3Text; + UPROPERTY() UButton* NextButton; @@ -100,21 +99,19 @@ public: UFUNCTION(BlueprintCallable) void EndDialogue(); - UFUNCTION(BlueprintPure) - FDialoguePath CreateRootDialoguePath(); - - UFUNCTION() - FDialoguePath CreateDialoguePath(FDialoguePath ParentDialoguePath); - - UFUNCTION(BlueprintPure) - FDialoguePath CreateDialogueChoice(FDialoguePath PreviousDialoguePath); - - UFUNCTION() - bool GotoDialoguePath(FString PathId); - - UFUNCTION(BlueprintPure) - FDialoguePath AddDialogue(FText TextInput, FDialoguePath DialoguePath); + UFUNCTION(BlueprintCallable) + UDialoguePath* CreateRootDialoguePath(); UFUNCTION(BlueprintCallable) - void GetFinalDialogue(TArray DialogueArray); + UDialoguePath* AddDialogue(UDialoguePath* DialoguePath, FText TextInput); + UFUNCTION(BlueprintCallable) + void AddChoices(UDialoguePath* ParentPath, FText ChoiceText1, FText ChoiceText2, FText ChoiceText3, + UDialoguePath*& ChoicePath1, UDialoguePath*& ChoicePath2, UDialoguePath*& ChoicePath3); + + UFUNCTION() + void Choice1(); + UFUNCTION() + void Choice2(); + UFUNCTION() + void Choice3(); };