Some work done on dialogue fixes and more bazaar iterations

This commit is contained in:
2026-08-18 22:58:29 +02:00
parent 1a3c2013b5
commit 28f27d032a
13 changed files with 57 additions and 35 deletions

View File

@@ -20,6 +20,9 @@ NetIndexFirstBitSegment=16
+GameplayTagList=(Tag="Characters.Yuki",DevComment="") +GameplayTagList=(Tag="Characters.Yuki",DevComment="")
+GameplayTagList=(Tag="Dialogue.Event",DevComment="") +GameplayTagList=(Tag="Dialogue.Event",DevComment="")
+GameplayTagList=(Tag="Dialogue.Event.Bazaar.Haggle",DevComment="") +GameplayTagList=(Tag="Dialogue.Event.Bazaar.Haggle",DevComment="")
+GameplayTagList=(Tag="Dialogue.Event.Bazaar.HaggleOption1",DevComment="")
+GameplayTagList=(Tag="Dialogue.Event.Bazaar.HaggleOption2",DevComment="")
+GameplayTagList=(Tag="Dialogue.Event.Bazaar.HaggleOption3",DevComment="")
+GameplayTagList=(Tag="Dialogue.Event.Bazaar.QuickSell",DevComment="") +GameplayTagList=(Tag="Dialogue.Event.Bazaar.QuickSell",DevComment="")
+GameplayTagList=(Tag="Dialogue.Event.Merchant",DevComment="") +GameplayTagList=(Tag="Dialogue.Event.Merchant",DevComment="")
+GameplayTagList=(Tag="Dialogue.Event.Merchant.Buy",DevComment="") +GameplayTagList=(Tag="Dialogue.Event.Merchant.Buy",DevComment="")

View File

@@ -93,12 +93,14 @@ void UDialogueComponent::TriggerDialogue(USpeechDataAsset* DialogueAssetPath, co
UDialogueSubsystem* DialogueSubsystem = UDialogueSubsystem::Get(this); UDialogueSubsystem* DialogueSubsystem = UDialogueSubsystem::Get(this);
if (!DialogueSubsystem) return; if (!DialogueSubsystem) return;
if (!DialogueSubsystem->StartDialogue()) return; if (!DialogueSubsystem->IsDialogueStarted())
{
BindToControllerInput(); BindToControllerInput();
bDialogueSelectOpen = false; bDialogueSelectOpen = false;
DialogueWidget = Cast<UDialogueWidget>(EleriPlayerController->ToggleDialogueWindow(true)); DialogueWidget = Cast<UDialogueWidget>(EleriPlayerController->ToggleDialogueWindow(true));
DialogueWidget->AssignDialogueComponent(this); DialogueWidget->AssignDialogueComponent(this);
}
CurrentLineIndex = 0; CurrentLineIndex = 0;
CurrentActiveDialogue = DialogueAssetPath; CurrentActiveDialogue = DialogueAssetPath;
CurrentDialogueReplacementMap = ReplacementMap; CurrentDialogueReplacementMap = ReplacementMap;
@@ -113,8 +115,10 @@ void UDialogueComponent::TriggerDialogue(USpeechDataAsset* DialogueAssetPath, co
MappedDialogueOptions.Add(i, CurrentActiveDialogue->PlayerSpeechMap[i]); MappedDialogueOptions.Add(i, CurrentActiveDialogue->PlayerSpeechMap[i]);
PlayerSpeakOptions.Add(CurrentActiveDialogue->PlayerSpeechMap[i].PlayerSpeak); PlayerSpeakOptions.Add(CurrentActiveDialogue->PlayerSpeechMap[i].PlayerSpeak);
} }
TriggerDialogueSelect(PlayerSpeakOptions, false); //TriggerDialogueSelect(PlayerSpeakOptions, false);
} }
DialogueSubsystem->StartDialogue();
} }
TArray<USpeechDataAsset*> UDialogueComponent::GetActiveSpeechData() { return ActiveSpeechData; } TArray<USpeechDataAsset*> UDialogueComponent::GetActiveSpeechData() { return ActiveSpeechData; }
@@ -231,6 +235,7 @@ void UDialogueComponent::OnDialogueOptionSelected(int32 Index)
{ {
DialogueWidget->OnDialogueOptionSelected.RemoveDynamic(this, &UDialogueComponent::OnDialogueOptionSelected); DialogueWidget->OnDialogueOptionSelected.RemoveDynamic(this, &UDialogueComponent::OnDialogueOptionSelected);
SelectedDialogueOptionIndex = Index; SelectedDialogueOptionIndex = Index;
bDialogueSelectOpen = false;
if (const FPlayerSpeakToDialogue* PlayerSpeak = MappedDialogueOptions.Find(SelectedDialogueOptionIndex)) if (const FPlayerSpeakToDialogue* PlayerSpeak = MappedDialogueOptions.Find(SelectedDialogueOptionIndex))
{ {
@@ -244,6 +249,11 @@ void UDialogueComponent::OnDialogueOptionSelected(int32 Index)
TriggerDialogue_Async(PlayerSpeak->NextSpeechDataAsset, CurrentDialogueReplacementMap); TriggerDialogue_Async(PlayerSpeak->NextSpeechDataAsset, CurrentDialogueReplacementMap);
return; return;
} }
if (!PlayerSpeak->bEndDialogueAfterSelecting)
{
return;
}
} }
CloseDialogue(); CloseDialogue();

View File

@@ -88,7 +88,7 @@ protected:
USpeechDataAsset* CurrentActiveDialogue; USpeechDataAsset* CurrentActiveDialogue;
UPROPERTY(EditAnywhere, BlueprintReadWrite) UPROPERTY(EditAnywhere, BlueprintReadWrite)
TMap<int32, FPlayerSpeakToDialogue> MappedDialogueOptions; TMap<int32, FPlayerSpeakToDialogue> MappedDialogueOptions;
UPROPERTY() UPROPERTY(EditAnywhere, BlueprintReadWrite)
TMap<FString, FText> CurrentDialogueReplacementMap; TMap<FString, FText> CurrentDialogueReplacementMap;
protected: protected:

View File

@@ -58,15 +58,15 @@ TArray<TObjectPtr<USpeechDataAsset>> UDialogueSubsystem::GetDialogueForActor(con
bool UDialogueSubsystem::StartDialogue() bool UDialogueSubsystem::StartDialogue()
{ {
if(bDialogueStartd) return false; if(bDialogueStarted) return false;
bDialogueStartd = true; bDialogueStarted = true;
return true; return true;
} }
void UDialogueSubsystem::EndDialogue() void UDialogueSubsystem::EndDialogue()
{ {
bDialogueStartd = false; bDialogueStarted = false;
} }
void UDialogueSubsystem::DialogueAssetsLoaded() void UDialogueSubsystem::DialogueAssetsLoaded()

View File

@@ -32,6 +32,8 @@ public:
virtual void Initialize(FSubsystemCollectionBase& Collection) override; virtual void Initialize(FSubsystemCollectionBase& Collection) override;
bool IsDialogueLoaded() const { return bDialogueLoaded; } bool IsDialogueLoaded() const { return bDialogueLoaded; }
UFUNCTION(BlueprintPure, Category = "Eleri|Dialogue")
bool IsDialogueStarted() const {return bDialogueStarted; }
TArray<TObjectPtr<USpeechDataAsset>> GetDialogueForActor(const AActor* Actor); TArray<TObjectPtr<USpeechDataAsset>> GetDialogueForActor(const AActor* Actor);
UFUNCTION(BlueprintCallable) UFUNCTION(BlueprintCallable)
@@ -45,7 +47,7 @@ protected:
TArray<FAssetData> AllAssetPaths; TArray<FAssetData> AllAssetPaths;
UPROPERTY() UPROPERTY()
bool bDialogueStartd; bool bDialogueStarted;
UPROPERTY() UPROPERTY()
bool bDialogueLoaded; bool bDialogueLoaded;

View File

@@ -30,18 +30,21 @@ bool USpeechDataAsset::TestRequirements(UWorld* World)
return true; return true;
} }
FText USpeechDataAsset::GetFormattedDialogueLine(const int32 Index, TMap<FString, FText> ReplacementMap) FText USpeechDataAsset::GetFormattedDialogueLine(const int32 Index, const TMap<FString, FText> ReplacementMap)
{ {
if (DialogueLines.Num() - 1 < Index || Index < 0) if (DialogueLines.Num() - 1 < Index || Index < 0)
return FText(); return FText();
const FText& LineRef = DialogueLines[Index].DialogueLine; return ReplaceTextInLine(DialogueLines[Index].DialogueLine, ReplacementMap);
}
FText USpeechDataAsset::ReplaceTextInLine(const FText& Text, TMap<FString, FText> ReplacementMap)
{
FFormatNamedArguments Args; FFormatNamedArguments Args;
for (const TTuple<FString, FText>& ReplacementPair : ReplacementMap) for (const TTuple<FString, FText>& ReplacementPair : ReplacementMap)
{ {
Args.Add(ReplacementPair.Key, ReplacementPair.Value); Args.Add(ReplacementPair.Key, ReplacementPair.Value);
} }
return FText::Format(LineRef, Args); return FText::Format(Text, Args);
} }

View File

@@ -29,6 +29,8 @@ struct FPlayerSpeakToDialogue
{ {
GENERATED_BODY() GENERATED_BODY()
public: public:
UPROPERTY(EditAnywhere, BlueprintReadWrite)
bool bEndDialogueAfterSelecting = true;
UPROPERTY(EditAnywhere, BlueprintReadWrite) UPROPERTY(EditAnywhere, BlueprintReadWrite)
FText PlayerSpeak; FText PlayerSpeak;
UPROPERTY(EditAnywhere, BlueprintReadWrite) UPROPERTY(EditAnywhere, BlueprintReadWrite)
@@ -46,30 +48,32 @@ class PROJECTELERI_API USpeechDataAsset : public UDataAsset
GENERATED_BODY() GENERATED_BODY()
public: public:
UPROPERTY(EditDefaultsOnly, BlueprintReadOnly, Category = "Event Requirment") UPROPERTY(EditDefaultsOnly, BlueprintReadOnly, Category = "Eleri|Event Requirment")
TArray<FEventRequirement> EventsMustMeetRequirement; TArray<FEventRequirement> EventsMustMeetRequirement;
UPROPERTY(EditDefaultsOnly, BlueprintReadOnly, Category = "Event Requirment") UPROPERTY(EditDefaultsOnly, BlueprintReadOnly, Category = "Eleri|Event Requirment")
TArray<FEventRequirement> EventsMustNotMeetRequirement; TArray<FEventRequirement> EventsMustNotMeetRequirement;
UPROPERTY(EditDefaultsOnly, BlueprintReadOnly, Category = "Speech") UPROPERTY(EditDefaultsOnly, BlueprintReadOnly, Category = "Eleri|Speech")
TSoftClassPtr<AActor> Npc; TSoftClassPtr<AActor> Npc;
UPROPERTY(EditDefaultsOnly, BlueprintReadOnly, Category = "Speech") UPROPERTY(EditDefaultsOnly, BlueprintReadOnly, Category = "Eleri|Speech")
FText PlayerAsk; FText PlayerAsk;
UPROPERTY(EditAnywhere, BlueprintReadOnly, Category = "Speech") UPROPERTY(EditAnywhere, BlueprintReadOnly, Category = "Eleri|Speech")
bool RandomizeLines; bool RandomizeLines;
UPROPERTY(EditAnywhere, BlueprintReadOnly, Category = "Speech") UPROPERTY(EditAnywhere, BlueprintReadOnly, Category = "Eleri|Speech")
TArray<FLineData> DialogueLines; TArray<FLineData> DialogueLines;
UPROPERTY(EditAnywhere, BlueprintReadOnly, Category = "Options") UPROPERTY(EditAnywhere, BlueprintReadOnly, Category = "Eleri|Options")
TArray<FPlayerSpeakToDialogue> PlayerSpeechMap; TArray<FPlayerSpeakToDialogue> PlayerSpeechMap;
UFUNCTION() UFUNCTION()
bool TestRequirements(UWorld* World); bool TestRequirements(UWorld* World);
UFUNCTION(BlueprintCallable) UFUNCTION(BlueprintCallable, Category = "Eleri|Options")
FText GetFormattedDialogueLine(const int32 Index, TMap<FString, FText> ReplacementMap); FText GetFormattedDialogueLine(const int32 Index, const TMap<FString, FText> ReplacementMap);
UFUNCTION(BlueprintPure, Category = "Eleri|Options")
static FText ReplaceTextInLine(const FText& Text, TMap<FString, FText> ReplacementMap);
}; };