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

View File

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

View File

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

View File

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

View File

@@ -30,18 +30,21 @@ bool USpeechDataAsset::TestRequirements(UWorld* World)
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)
return FText();
return ReplaceTextInLine(DialogueLines[Index].DialogueLine, ReplacementMap);
}
const FText& LineRef = DialogueLines[Index].DialogueLine;
FText USpeechDataAsset::ReplaceTextInLine(const FText& Text, TMap<FString, FText> ReplacementMap)
{
FFormatNamedArguments Args;
for (const TTuple<FString, FText>& ReplacementPair : ReplacementMap)
{
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()
public:
UPROPERTY(EditAnywhere, BlueprintReadWrite)
bool bEndDialogueAfterSelecting = true;
UPROPERTY(EditAnywhere, BlueprintReadWrite)
FText PlayerSpeak;
UPROPERTY(EditAnywhere, BlueprintReadWrite)
@@ -46,30 +48,32 @@ class PROJECTELERI_API USpeechDataAsset : public UDataAsset
GENERATED_BODY()
public:
UPROPERTY(EditDefaultsOnly, BlueprintReadOnly, Category = "Event Requirment")
UPROPERTY(EditDefaultsOnly, BlueprintReadOnly, Category = "Eleri|Event Requirment")
TArray<FEventRequirement> EventsMustMeetRequirement;
UPROPERTY(EditDefaultsOnly, BlueprintReadOnly, Category = "Event Requirment")
UPROPERTY(EditDefaultsOnly, BlueprintReadOnly, Category = "Eleri|Event Requirment")
TArray<FEventRequirement> EventsMustNotMeetRequirement;
UPROPERTY(EditDefaultsOnly, BlueprintReadOnly, Category = "Speech")
UPROPERTY(EditDefaultsOnly, BlueprintReadOnly, Category = "Eleri|Speech")
TSoftClassPtr<AActor> Npc;
UPROPERTY(EditDefaultsOnly, BlueprintReadOnly, Category = "Speech")
UPROPERTY(EditDefaultsOnly, BlueprintReadOnly, Category = "Eleri|Speech")
FText PlayerAsk;
UPROPERTY(EditAnywhere, BlueprintReadOnly, Category = "Speech")
UPROPERTY(EditAnywhere, BlueprintReadOnly, Category = "Eleri|Speech")
bool RandomizeLines;
UPROPERTY(EditAnywhere, BlueprintReadOnly, Category = "Speech")
UPROPERTY(EditAnywhere, BlueprintReadOnly, Category = "Eleri|Speech")
TArray<FLineData> DialogueLines;
UPROPERTY(EditAnywhere, BlueprintReadOnly, Category = "Options")
UPROPERTY(EditAnywhere, BlueprintReadOnly, Category = "Eleri|Options")
TArray<FPlayerSpeakToDialogue> PlayerSpeechMap;
UFUNCTION()
bool TestRequirements(UWorld* World);
UFUNCTION(BlueprintCallable)
FText GetFormattedDialogueLine(const int32 Index, TMap<FString, FText> ReplacementMap);
UFUNCTION(BlueprintCallable, Category = "Eleri|Options")
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);
};