Skip to content

Commit

Permalink
Merge branch '5.3_dev' into 5.3
Browse files Browse the repository at this point in the history
  • Loading branch information
pavlicekdominik committed Oct 12, 2024
2 parents d5cf66d + ae52c41 commit abd730e
Show file tree
Hide file tree
Showing 32 changed files with 485 additions and 169 deletions.
Binary file modified Content/Blueprints/Core/BP_DialoguePlayerState.uasset
Binary file not shown.
Binary file modified Content/Dialogues/D_TestDialogue.uasset
Binary file not shown.
Binary file modified Content/Example/M_DialogueExample.umap
Binary file not shown.
Binary file modified Content/WBP/WBP_Dialogue.uasset
Binary file not shown.
2 changes: 1 addition & 1 deletion MounteaDialogueSystem.uplugin
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"FileVersion": 3,
"Version": 2,
"VersionName": "2.0.3.53",
"VersionName": "2.0.4.53",
"FriendlyName": "Mountea Dialogue System",
"Description": "Mountea Dialogue System is an Open-source Mountea Framework tool for Unreal Engine for creating (not just) complex dialogues!\nProvides its own Dialogue Tree editor and validation system.",
"Category": "Mountea Framework",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ UMounteaDialogueManager::UMounteaDialogueManager()
, DefaultManagerState(EDialogueManagerState::EDMS_Enabled)
, DialogueContext(nullptr)
, ReplicatedDialogueContext(nullptr)
, bWasCursorVisible(false)
, DialogueContextReplicationKey(0)
{
bAutoActivate = true;
Expand Down Expand Up @@ -130,7 +129,9 @@ void UMounteaDialogueManager::CallDialogueNodeSelected_Implementation(const FGui
}

// Straight up set dialogue row from Node and index to 0
DialogueContext->SetDialogueContext(DialogueContext->DialogueParticipant, selectedNode, UMounteaDialogueSystemBFC::GetAllowedChildNodes(selectedNode));
auto allowedChildNodes = UMounteaDialogueSystemBFC::GetAllowedChildNodes(selectedNode);
UMounteaDialogueSystemBFC::SortNodes(allowedChildNodes);
DialogueContext->SetDialogueContext(DialogueContext->DialogueParticipant, selectedNode, allowedChildNodes);
DialogueContext->UpdateActiveDialogueRow(UMounteaDialogueSystemBFC::GetDialogueRow(DialogueContext->ActiveNode));
DialogueContext->UpdateActiveDialogueRowDataIndex(0);

Expand Down Expand Up @@ -250,7 +251,8 @@ void UMounteaDialogueManager::OnDialogueNodeFinishedEvent_Internal(UMounteaDialo

OnDialogueNodeFinishedEvent(DialogueContext);

const TArray<UMounteaDialogueGraphNode*> allowedChildrenNodes = UMounteaDialogueSystemBFC::GetAllowedChildNodes(DialogueContext->ActiveNode);
TArray<UMounteaDialogueGraphNode*> allowedChildrenNodes = UMounteaDialogueSystemBFC::GetAllowedChildNodes(DialogueContext->ActiveNode);
UMounteaDialogueSystemBFC::SortNodes(allowedChildrenNodes);

// If there are only Complete Nodes left or no DialogueNodes left, just shut it down
if (allowedChildrenNodes.Num() == 0)
Expand All @@ -270,8 +272,10 @@ void UMounteaDialogueManager::OnDialogueNodeFinishedEvent_Internal(UMounteaDialo
{
OnDialogueClosed.Broadcast(DialogueContext);
}

DialogueContext->SetDialogueContext(DialogueContext->DialogueParticipant, newActiveNode, UMounteaDialogueSystemBFC::GetAllowedChildNodes(newActiveNode));

auto allowedChildNodes = UMounteaDialogueSystemBFC::GetAllowedChildNodes(newActiveNode);
UMounteaDialogueSystemBFC::SortNodes(allowedChildNodes);
DialogueContext->SetDialogueContext(DialogueContext->DialogueParticipant, newActiveNode, allowedChildNodes);

OnDialogueNodeSelected.Broadcast(DialogueContext);

Expand Down Expand Up @@ -1003,14 +1007,9 @@ bool UMounteaDialogueManager::InvokeDialogueUI_Implementation(FString& Message)
return false;
}

bWasCursorVisible = playerController->bShowMouseCursor;

// This event should be responsible for calling logic in Player Controller
OnDialogueUserInterfaceChanged.Broadcast(DialogueWidgetClass, DialogueWidgetPtr);

// This Component should not be responsible for setting up Player Controller!
playerController->SetShowMouseCursor(true);

return Execute_UpdateDialogueUI(this, Message, MounteaDialogueWidgetCommands::CreateDialogueWidget);
}

Expand Down Expand Up @@ -1054,8 +1053,6 @@ bool UMounteaDialogueManager::CloseDialogueUI_Implementation()

OnDialogueUserInterfaceChanged.Broadcast(DialogueWidgetClass, nullptr);

playerController->SetShowMouseCursor(bWasCursorVisible);

if (DialogueWidgetPtr->Implements<UMounteaDialogueWBPInterface>())
{
FString errorMessage;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -210,17 +210,15 @@ void UMounteaDialogueGraph::PostInitProperties()
#endif
}

void UMounteaDialogueGraph::RegisterTick_Implementation(
const TScriptInterface<IMounteaDialogueTickableObject>& ParentTickable)
void UMounteaDialogueGraph::RegisterTick_Implementation(const TScriptInterface<IMounteaDialogueTickableObject>& ParentTickable)
{
if (ParentTickable.GetObject() && ParentTickable.GetInterface())
{
ParentTickable->GetMounteaDialogueTickHandle().AddUniqueDynamic(this, &UMounteaDialogueGraph::TickMounteaEvent);
}
}

void UMounteaDialogueGraph::UnregisterTick_Implementation(
const TScriptInterface<IMounteaDialogueTickableObject>& ParentTickable)
void UMounteaDialogueGraph::UnregisterTick_Implementation(const TScriptInterface<IMounteaDialogueTickableObject>& ParentTickable)
{
if (ParentTickable.GetObject() && ParentTickable.GetInterface())
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -352,7 +352,8 @@ bool UMounteaDialogueSystemBFC::StartDialogue(const UObject* WorldContextObject,
}
}

const TArray<UMounteaDialogueGraphNode*> StartNode_Children = GetAllowedChildNodes(NodeToStart);
TArray<UMounteaDialogueGraphNode*> StartNode_Children = GetAllowedChildNodes(NodeToStart);
SortNodes(StartNode_Children);

UMounteaDialogueContext* Context = NewObject<UMounteaDialogueContext>();
Context->SetDialogueContext(MainParticipant, NodeToStart, StartNode_Children);
Expand Down Expand Up @@ -448,7 +449,8 @@ bool UMounteaDialogueSystemBFC::InitializeDialogue(const UObject* WorldContextOb
NodeToStart = GetFirstChildNode(NodeToStart);
}

const TArray<UMounteaDialogueGraphNode*> StartNode_Children = GetAllowedChildNodes(NodeToStart);
TArray<UMounteaDialogueGraphNode*> StartNode_Children = GetAllowedChildNodes(NodeToStart);
SortNodes(StartNode_Children);

UMounteaDialogueContext* Context = NewObject<UMounteaDialogueContext>();
Context->SetDialogueContext(DialogueParticipant, NodeToStart, StartNode_Children);
Expand Down Expand Up @@ -671,6 +673,12 @@ TArray<UMounteaDialogueGraphNode*> UMounteaDialogueSystemBFC::GetAllowedChildNod
return ReturnNodes;
}

void UMounteaDialogueSystemBFC::SortNodes(TArray<UMounteaDialogueGraphNode*>& SortedNodes)
{
SortNodes<UMounteaDialogueGraphNode>(SortedNodes);
}


FDialogueRow UMounteaDialogueSystemBFC::GetDialogueRow(const UMounteaDialogueGraphNode* Node)
{
if (!Node)
Expand Down Expand Up @@ -717,48 +725,47 @@ float UMounteaDialogueSystemBFC::GetRowDuration(const FDialogueRowData& Row)
switch (Row.RowDurationMode)
{
case ERowDurationMode::ERDM_Duration:
{
if (Row.RowSound)
{
if (Row.RowSound)
{
ReturnValue = Row.RowSound->Duration;
break;
}

ReturnValue = Row.RowDuration;
ReturnValue = Row.RowSound->Duration;
break;
}
ReturnValue = Row.RowDuration;
break;
}
case ERowDurationMode::EDRM_Override:
{
ReturnValue = Row.RowDurationOverride;
}
{
ReturnValue = Row.RowDurationOverride;
break;
}
case ERowDurationMode::EDRM_Add:
{
if (Row.RowSound)
{
if (Row.RowSound)
{
ReturnValue = Row.RowSound->Duration;
ReturnValue = ReturnValue + Row.RowDurationOverride;
break;
}
ReturnValue = Row.RowDurationOverride;
ReturnValue = Row.RowSound->Duration;
ReturnValue = ReturnValue + Row.RowDurationOverride;
break;
}
ReturnValue = Row.RowDurationOverride;
break;
}
case ERowDurationMode::ERDM_AutoCalculate:
{
if (GetDialogueSystemSettings_Internal())
{
//TODO: Make 8:100 ratio editable in Settings!
if (GetDialogueSystemSettings_Internal())
{
ReturnValue= ((Row.RowText.ToString().Len() * GetDialogueSystemSettings_Internal()->GetDurationCoefficient()) / 100.f);
}
else
{
ReturnValue= ((Row.RowText.ToString().Len() * 8.f) / 100.f);
}
break;
ReturnValue= ((Row.RowText.ToString().Len() * GetDialogueSystemSettings_Internal()->GetDurationCoefficient()) / 100.f);
}
else
{
ReturnValue= ((Row.RowText.ToString().Len() * 8.f) / 100.f);
}
break;
}
}

ReturnValue = FMath::Max(1.f, ReturnValue);
// Timer running in background need some time and replication takes a few ms, too
ReturnValue = FMath::Max(UE_KINDA_SMALL_NUMBER, ReturnValue);

return ReturnValue;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
#include "Interfaces/UMG/MounteaDialogueViewportWidgetInterface.h"
#include "Internationalization/Regex.h"
#include "Nodes/MounteaDialogueGraphNode_DialogueNodeBase.h"
#include "WBP/MounteaDialogueOptionsContainer.h"

FDialogueOptionData UMounteaDialogueUIBFL::NewDialogueOptionData(const FGuid& Node, const FDialogueRow& DialogueRow)
{
Expand Down Expand Up @@ -40,7 +41,7 @@ FDialogueRow UMounteaDialogueUIBFL::GetDialogueNodeRow(UMounteaDialogueGraphNode
TArray<UMounteaDialogueGraphNode_DialogueNodeBase*> UMounteaDialogueUIBFL::FilterDialogueFriendlyNodes(const TArray<UMounteaDialogueGraphNode*>& RawNodes)
{
TArray<UMounteaDialogueGraphNode_DialogueNodeBase*> returnArray;

for (const auto& Itr : RawNodes)
{
if (!Itr) continue;
Expand All @@ -51,6 +52,7 @@ TArray<UMounteaDialogueGraphNode_DialogueNodeBase*> UMounteaDialogueUIBFL::Filte
}
}

UMounteaDialogueSystemBFC::SortNodes(returnArray);
return returnArray;
}

Expand Down Expand Up @@ -209,3 +211,21 @@ void UMounteaDialogueUIBFL::RemoveChildWidget(UUserWidget* ParentWidget, UUserWi

LOG_ERROR(TEXT("[RemoveChildWidget] ParentWidget does not implement `MounteaDialogueViewportWidgetInterface`!"));
}

TArray<UUserWidget*> UMounteaDialogueUIBFL::GetDialogueOptions(UUserWidget* ParentWidget)
{
TArray<UUserWidget*> dialogueOptions;
if (!IsValid(ParentWidget))
{
LOG_ERROR(TEXT("[GetDialogueOptions] Invalid Parent Widget provided!"));
return dialogueOptions;
}

if (ParentWidget->Implements<UMounteaDialogueOptionsContainer>())
{
return IMounteaDialogueOptionsContainerInterface::Execute_GetDialogueOptions(ParentWidget);
}

LOG_ERROR(TEXT("[GetDialogueOptions] ParentWidget does not implement `MounteaDialogueOptionsContainerInterface`!"));
return dialogueOptions;
}
Original file line number Diff line number Diff line change
Expand Up @@ -429,14 +429,13 @@ FText UMounteaDialogueGraphNode::GetDefaultTooltipBody() const
{
const FText InheritsValue = bInheritGraphDecorators ? LOCTEXT("True","Yes") : LOCTEXT("False","No");
const FText Inherits = FText::Format(LOCTEXT("UMounteaDialogueGraphNode_InheritsTooltip", "Inherits Graph Decorators: {0}"), InheritsValue);

FText ImplementsNumber;
if (NodeDecorators.Num() == 0) ImplementsNumber = LOCTEXT("None","-");
else ImplementsNumber = FText::FromString(FString::FromInt(NodeDecorators.Num()));

const FText Implements = FText::Format(LOCTEXT("UMounteaDialogueGraphNode_ImplementsTooltip", "Implements Decorators: {0}"), ImplementsNumber);

return FText::Format(LOCTEXT("UMounteaDialogueGraphNode_BaseTooltip", "{0} - {1}\n\n{2}\n{3}"), NodeTypeName, FText::FromString(NodeGUID.ToString()), Inherits, Implements);
return FText::Format(LOCTEXT("UMounteaDialogueGraphNode_BaseTooltip", "{0} - {1}\n\n{2}\n{3}\nNode Execution Order: {4}"), NodeTypeName, FText::FromString(NodeGUID.ToString(EGuidFormats::DigitsWithHyphensLower)), Inherits, Implements, ExecutionOrder);
}

#endif
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -126,3 +126,12 @@ void UMounteaDialogueOptionsContainer::ProcessOptionSelected_Implementation(cons
dialogueInterface->Execute_OnOptionSelected(ParentDialogueWidget, SelectedOption);
}
}

TArray<UUserWidget*> UMounteaDialogueOptionsContainer::GetDialogueOptions_Implementation() const
{
TArray<TObjectPtr<UUserWidget>> dialogueOptions;
for (const auto dialogueOption : DialogueOptions)
dialogueOptions.Add(dialogueOption.Value);

return dialogueOptions;
}
Original file line number Diff line number Diff line change
Expand Up @@ -418,13 +418,6 @@ class MOUNTEADIALOGUESYSTEM_API UMounteaDialogueManager : public UActorComponent
UPROPERTY(Transient, VisibleAnywhere, Category="Mountea|Dialogue|Manager", AdvancedDisplay, meta=(DisplayThumbnail=false))
FTimerHandle TimerHandle_RowTimer;

/**
* Is saved once Dialogue starts.
* Once Dialogue ends, cached value is set back again.
*/
UPROPERTY(Transient, VisibleAnywhere, Category="Mountea|Dialogue|Manager", AdvancedDisplay)
uint8 bWasCursorVisible : 1;

/**
*
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,14 +59,11 @@ enum class EDialogueParticipantState : uint8
UENUM(BlueprintType)
enum class ERowDurationMode : uint8
{
ERDM_Manual UMETA(DisplayName="Manual",
Tooltip="Row won't start automatically and will wait for `NextDialogueRow` request.", hidden),
ERDM_Duration UMETA(DisplayName="Duration",
Tooltip="Uses either duration of 'Row Sound' or value from 'Duration'."),
ERDM_Manual UMETA(DisplayName="Manual", Tooltip="Row won't start automatically and will wait for `NextDialogueRow` request.", hidden),
ERDM_Duration UMETA(DisplayName="Duration", Tooltip="Uses either duration of 'Row Sound' or value from 'Duration'."),
EDRM_Override UMETA(DisplayName="Override", Tooltip="Uses 'Duration Override' value."),
EDRM_Add UMETA(DisplayName="Add Time", Tooltip="Adds 'Duration Override' value to 'Duration'."),
ERDM_AutoCalculate UMETA(DisplayName="Calculate",
Tooltip="Calculates Duration automatically. Base value is: 100 characters per 8 seconds."),
ERDM_AutoCalculate UMETA(DisplayName="Calculate", Tooltip="Calculates Duration automatically. Base value is: 100 characters per 8 seconds."),

Default UMETA(hidden)
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -249,7 +249,7 @@ class MOUNTEADIALOGUESYSTEM_API UMounteaDialogueSystemBFC : public UBlueprintFun
*/
UFUNCTION(BlueprintCallable, BlueprintPure, Category="Mountea|Dialogue|Helpers", meta=(Keywords="diaogue, child, nodes"), meta=(CustomTag="MounteaK2Getter"))
static TArray<UMounteaDialogueGraphNode*> GetAllowedChildNodes(const UMounteaDialogueGraphNode* ParentNode);

/**
* Returns whether Dialogue Row is valid or not.
*
Expand Down Expand Up @@ -391,4 +391,21 @@ class MOUNTEADIALOGUESYSTEM_API UMounteaDialogueSystemBFC : public UBlueprintFun
UFUNCTION(BlueprintCallable, BlueprintPure, Category="Mountea|Dialogue|Helpers", meta = (ClassFilter = "Interface"), meta=(DeterminesOutputType = "InterfaceFilter"), meta=(CustomTag="MounteaK2Getter"))
static UActorComponent* GetSingleComponentByInterface(const AActor* Target, TSubclassOf<UInterface> InterfaceFilter, bool& bResult);

template <typename NodeType>
static void SortNodes(TArray<NodeType*>& SortedNodes)
{
SortedNodes.Sort([](const NodeType& A, const NodeType& B)
{
return A.ExecutionOrder < B.ExecutionOrder;
});
}

/**
* Sorts given array of Dialogue Nodes based on their Execution Order.
*
* @param SortedNodes OUT Nodes array that will be sorted
*/
UFUNCTION(BlueprintCallable, BlueprintPure, Category="Mountea|Dialogue|Helpers", meta=(Keywords="sort,order,diaogue,child,nodes"), meta=(CustomTag="MounteaK2Getter"))
static void SortNodes(TArray<UMounteaDialogueGraphNode*>& SortedNodes);

};
Original file line number Diff line number Diff line change
Expand Up @@ -184,4 +184,11 @@ class MOUNTEADIALOGUESYSTEM_API UMounteaDialogueUIBFL : public UBlueprintFunctio
UFUNCTION(BlueprintCallable, Category="Mountea|Dialogue|Helpers|HUD", meta=(CustomTag="MounteaK2Setter", HideSelfPin="true"))
static void RemoveChildWidget(UPARAM(meta=(MustImplement="/Script/MounteaDialogueSystem.MounteaDialogueViewportWidgetInterface")) UUserWidget* ParentWidget, UUserWidget* ChildWidget);

/**
* Returns all Dialogue Options from the specified Dialogue Options Container parent widget that implements the MounteaDialogueOptionsContainerInterface.
*
* @param ParentWidget The parent widget that should implement the MounteaDialogueOptionsContainerInterface.
*/
UFUNCTION(BlueprintCallable, Category="Mountea|Dialogue|Helpers|HUD", meta=(CustomTag="MounteaK2Setter", HideSelfPin="true"))
static TArray<UUserWidget*> GetDialogueOptions(UPARAM(meta=(MustImplement="/Script/MounteaDialogueSystem.MounteaDialogueOptionsContainerInterface")) UUserWidget* ParentWidget);
};
Original file line number Diff line number Diff line change
Expand Up @@ -117,4 +117,8 @@ class MOUNTEADIALOGUESYSTEM_API IMounteaDialogueOptionsContainerInterface
void ProcessOptionSelected(const FGuid& SelectedOption, UUserWidget* CallingWidget);
virtual void ProcessOptionSelected_Implementation(const FGuid& SelectedOption, UUserWidget* CallingWidget) = 0;

UFUNCTION(BlueprintNativeEvent, Category="Mountea|Dialogue|UserInterface|OptionsContainer")
TArray<UUserWidget*> GetDialogueOptions() const;
virtual TArray<UUserWidget*> GetDialogueOptions_Implementation() const = 0;

};
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ class MOUNTEADIALOGUESYSTEM_API UMounteaDialogueGraphNode : public UObject, publ
#pragma region Variables

#pragma region ReadOnly

public:

/**
Expand Down Expand Up @@ -68,6 +69,9 @@ class MOUNTEADIALOGUESYSTEM_API UMounteaDialogueGraphNode : public UObject, publ
UPROPERTY(BlueprintReadOnly, VisibleAnywhere, Category = "Private")
int32 NodeIndex = INDEX_NONE;

/** Execution order within Parent's scope */
UPROPERTY(BlueprintReadOnly, VisibleAnywhere, Category = "Private")
int32 ExecutionOrder = INDEX_NONE;

protected:

Expand Down
Loading

0 comments on commit abd730e

Please sign in to comment.