diff --git a/Source/ComboInput/Private/ComboActionGraph.cpp b/Source/ComboInput/Private/ComboActionGraph.cpp index 324d33f..c55f37d 100644 --- a/Source/ComboInput/Private/ComboActionGraph.cpp +++ b/Source/ComboInput/Private/ComboActionGraph.cpp @@ -13,8 +13,8 @@ DEFINE_LOG_CATEGORY(LogComboActionGraph); UComboActionGraph::UComboActionGraph() { - this->NodeType = UComboActionGraph::StaticClass(); - this->EdgeType = UComboActionGraph::StaticClass(); + this->NodeType = UComboActionGraphNode::StaticClass(); + this->EdgeType = UComboActionGraphEdge::StaticClass(); this->bEdgeEnabled = false; this->GraphGUID = FGuid::NewGuid(); diff --git a/Source/ComboInput/Private/Nodes/ComboActionGraphNode.cpp b/Source/ComboInput/Private/Nodes/ComboActionGraphNode.cpp index 98455c4..8dc70cd 100644 --- a/Source/ComboInput/Private/Nodes/ComboActionGraphNode.cpp +++ b/Source/ComboInput/Private/Nodes/ComboActionGraphNode.cpp @@ -57,7 +57,7 @@ void UComboActionGraphNode::InitializeNode_Implementation(UWorld *InWorld) } } -void UComboActionGraphNode::ProcessNode() +void UComboActionGraphNode::ProcessNode(const TScriptInterface &Manager) { if (!this->GetWorld()) { diff --git a/Source/ComboInput/Private/Nodes/ComboActionGraphNode_ActionNode.cpp b/Source/ComboInput/Private/Nodes/ComboActionGraphNode_ActionNode.cpp new file mode 100644 index 0000000..ef30909 --- /dev/null +++ b/Source/ComboInput/Private/Nodes/ComboActionGraphNode_ActionNode.cpp @@ -0,0 +1,69 @@ +// 2023 Batty Bovine Productions, LLC. All Rights Reserved. + +#include "Nodes/ComboActionGraphNode_ActionNode.h" + +#include "Data/ComboActionContext.h" +#include "Interfaces/ComboActionGraphManagerInterface.h" +#include "Nodes/ComboActionGraphNode_StartNode.h" + +#define LOCTEXT_NAMESPACE "ComboActionGraphNode_ActionNode" + + +UComboActionGraphNode_ActionNode::UComboActionGraphNode_ActionNode() +{ +#if WITH_EDITORONLY_DATA + this->NodeTitle = LOCTEXT("ComboActionGraphNode_ActionNodeTitle", "Action Node"); + this->NodeTypeName = LOCTEXT("ComboActionGraphNode_ActionNodeInternalTitle", "Action Node"); + this->ContextMenuName = LOCTEXT("ComboActionGraphNode_ActionNodeContextMenuName", "Action Node"); + + this->BackgroundColor = FLinearColor(FColor::Turquoise); + + this->NodeTooltipText = LOCTEXT("ComboActionGraphNode_ActionTooltip", "Action node is a node which contains combo actions based on inputs."); +#endif + + this->AllowedInputClasses.Add(UComboActionGraphNode_StartNode::StaticClass()); + this->AllowedInputClasses.Add(UComboActionGraphNode_ActionNode::StaticClass()); + + this->bAutoStarts = false; + this->bUseGameplayTags = false; + + this->MaxChildrenNodes = 1; +} + +void UComboActionGraphNode_ActionNode::PreProcessNode(const TScriptInterface &Manager) +{ + if (!bUseGameplayTags) + { + // Switch Active Participant to Player + if (Manager.GetInterface()) + { + //if (const auto TempContext = Manager->GetDialogueContext()) + //{ + // TempContext->UpdateActiveDialogueParticipant(TempContext->GetDialoguePlayerParticipant()); + //} + } + } + + Super::PreProcessNode(Manager); +} + +void UComboActionGraphNode_ActionNode::ProcessNode(const TScriptInterface &Manager) +{ + Super::ProcessNode(Manager); +} + +#if WITH_EDITOR + +FText UComboActionGraphNode_ActionNode::GetDescription_Implementation() const +{ + return LOCTEXT("ComboActionGraphNode_ActionNodeDescription", "Action node is a node which contains combo actions based on inputs."); +} + +FText UComboActionGraphNode_ActionNode::GetNodeCategory_Implementation() const +{ + return LOCTEXT("ComboActionGraphNode_ActionNodeCategory", "Combo Action Branch Nodes"); +} + +#endif + +#undef LOCTEXT_NAMESPACE diff --git a/Source/ComboInput/Private/Nodes/ComboActionGraphNode_ActionNodeBase.cpp b/Source/ComboInput/Private/Nodes/ComboActionGraphNode_ActionNodeBase.cpp index 85ffb3e..3e34182 100644 --- a/Source/ComboInput/Private/Nodes/ComboActionGraphNode_ActionNodeBase.cpp +++ b/Source/ComboInput/Private/Nodes/ComboActionGraphNode_ActionNodeBase.cpp @@ -23,70 +23,70 @@ UComboActionGraphNode_ActionNodeBase::UComboActionGraphNode_ActionNodeBase() this->bUseGameplayTags = true; } -void UComboActionGraphNode_ActionNodeBase::ProcessNode() +void UComboActionGraphNode_ActionNodeBase::ProcessNode(const TScriptInterface &Manager) { - //if (Manager) - //{ - // if (UComboActionContext *Context = Manager->GetDialogueContext()) - // { - // this->GetWorld()->GetTimerManager().ClearTimer(Manager->GetDialogueRowTimerHandle()); + if (Manager) + { + //if (UComboActionContext *Context = Manager->GetDialogueContext()) + //{ + // this->GetWorld()->GetTimerManager().ClearTimer(Manager->GetDialogueRowTimerHandle()); - // const FDialogueRow DialogueRow = UComboActionSystemBFC::GetDialogueRow(Context->ActiveNode); - // if (UComboActionSystemBFC::IsDialogueRowValid(DialogueRow) && DialogueRow.DialogueRowData.Array().IsValidIndex(Context->GetActiveDialogueRowDataIndex())) - // { - // Context->UpdateActiveDialogueRow(DialogueRow); - // Context->UpdateActiveDialogueRowDataIndex(Context->ActiveDialogueRowDataIndex); - // Manager->GetDialogueContextUpdatedEventHande().Broadcast(Context); - // } - // } - //} + // const FDialogueRow DialogueRow = UComboActionSystemBFC::GetDialogueRow(Context->ActiveNode); + // if (UComboActionSystemBFC::IsDialogueRowValid(DialogueRow) && DialogueRow.DialogueRowData.Array().IsValidIndex(Context->GetActiveDialogueRowDataIndex())) + // { + // Context->UpdateActiveDialogueRow(DialogueRow); + // Context->UpdateActiveDialogueRowDataIndex(Context->ActiveDialogueRowDataIndex); + // Manager->GetDialogueContextUpdatedEventHande().Broadcast(Context); + // } + //} + } - Super::ProcessNode(); + Super::ProcessNode(Manager); } -void UComboActionGraphNode_ActionNodeBase::PreProcessNode() +void UComboActionGraphNode_ActionNodeBase::PreProcessNode(const TScriptInterface &Manager) { - //if (bUseGameplayTags) - //{ - // // Switch Participants based on Tags - // if (Manager.GetInterface()) - // { - // if (const auto TempContext = Manager->GetDialogueContext()) - // { - // const TScriptInterface BestMatchingParticipant = UComboActionSystemBFC::FindBestMatchingParticipant(Manager.GetObject(), TempContext); - // - // TempContext->UpdateActiveDialogueParticipant(BestMatchingParticipant); - // } - // } - //} + if (this->bUseGameplayTags) + { + // Switch Participants based on Tags + if (Manager.GetInterface()) + { + //if (const auto TempContext = Manager->GetDialogueContext()) + //{ + // const TScriptInterface BestMatchingParticipant = UComboActionSystemBFC::FindBestMatchingParticipant(Manager.GetObject(), TempContext); + // + // TempContext->UpdateActiveDialogueParticipant(BestMatchingParticipant); + //} + } + } - Super::PreProcessNode(); + Super::PreProcessNode(Manager); } UDataTable *UComboActionGraphNode_ActionNodeBase::GetDataTable() const { - return DataTable; + return this->DataTable; } bool UComboActionGraphNode_ActionNodeBase::ValidateNodeRuntime_Implementation() const { - //if (DataTable == nullptr) + if (this->DataTable == nullptr) + { + return false; + } + + //if (this->RowName.IsNone()) //{ // return false; //} - //if (RowName.IsNone()) - //{ - // return false; - //} - - //if (MaxChildrenNodes > -1 && ChildrenNodes.Num() > MaxChildrenNodes) - //{ - // return false; - //} + if (this->MaxChildrenNodes > -1 && this->ChildrenNodes.Num() > this->MaxChildrenNodes) + { + return false; + } //const FString Context; - //const FDialogueRow* SelectedRow = DataTable->FindRow(RowName, Context); + //const FDialogueRow *SelectedRow = DataTable->FindRow(RowName, Context); //if (SelectedRow == nullptr) //{ @@ -106,7 +106,7 @@ bool UComboActionGraphNode_ActionNodeBase::ValidateNodeRuntime_Implementation() #if WITH_EDITOR -bool UComboActionGraphNode_ActionNodeBase::ValidateNode(TArray& ValidationsMessages, const bool RichFormat) +bool UComboActionGraphNode_ActionNodeBase::ValidateNode(TArray &ValidationsMessages, const bool RichFormat) { bool bResult = Super::ValidateNode(ValidationsMessages, RichFormat); @@ -128,7 +128,7 @@ bool UComboActionGraphNode_ActionNodeBase::ValidateNode(TArray& Validatio // ValidationsMessages.Add(FText::FromString(RichFormat ? RichTextReturn : TextReturn)); //} - //if (RowName.IsNone()) + //if (this->RowName.IsNone()) //{ // bResult = false; @@ -146,25 +146,23 @@ bool UComboActionGraphNode_ActionNodeBase::ValidateNode(TArray& Validatio // ValidationsMessages.Add(FText::FromString(RichFormat ? RichTextReturn : TextReturn)); //} - //if (MaxChildrenNodes > -1 && ChildrenNodes.Num() > MaxChildrenNodes) - //{ - // const FString RichTextReturn = - // FString("* "). - // Append(""). - // Append(NodeTitle.ToString()). - // Append(""). - // Append(": Has more than "). - // Append(""). - // Append(FString::FromInt(MaxChildrenNodes)). - // Append(""). - // Append(" Children Nodes!"); + if (this->MaxChildrenNodes > -1 && this->ChildrenNodes.Num() > this->MaxChildrenNodes) + { + const FString RichTextReturn = FString("* ") + .Append("") + .Append(this->NodeTitle.ToString()) + .Append("") + .Append(": Has more than ") + .Append("") + .Append(FString::FromInt(this->MaxChildrenNodes)) + .Append("") + .Append(" Children Nodes!"); - // const FString TextReturn = - // FString(NodeTitle.ToString()). - // Append(": Has more than ").Append(FString::FromInt(MaxChildrenNodes)).Append(" Children Nodes!"); - // - // ValidationsMessages.Add(FText::FromString(RichFormat ? RichTextReturn : TextReturn)); - //} + const FString TextReturn = FString(this->NodeTitle.ToString()) + .Append(": Has more than ").Append(FString::FromInt(MaxChildrenNodes)).Append(" Children Nodes!"); + + ValidationsMessages.Add(FText::FromString(RichFormat ? RichTextReturn : TextReturn)); + } //const FString Context; //const FDialogueRow* SelectedRow = DataTable!=nullptr ? DataTable->FindRow(RowName, Context) : nullptr; @@ -217,15 +215,15 @@ void UComboActionGraphNode_ActionNodeBase::PostEditChangeProperty(FPropertyChang if (PropertyChangedEvent.GetPropertyName() == GET_MEMBER_NAME_CHECKED(UComboActionGraphNode_ActionNodeBase, DataTable)) { - RowName = FName(""); - Preview.Empty(); - PreviewsUpdated.ExecuteIfBound(); + this->RowName = FName(""); + this->Preview.Empty(); + this->PreviewsUpdated.ExecuteIfBound(); } if (PropertyChangedEvent.GetPropertyName() == GET_MEMBER_NAME_CHECKED(UComboActionGraphNode_ActionNodeBase, RowName)) { - UpdatePreviews(); - PreviewsUpdated.ExecuteIfBound(); + this->UpdatePreviews(); + this->PreviewsUpdated.ExecuteIfBound(); } } @@ -256,11 +254,14 @@ TArray UComboActionGraphNode_ActionNodeBase::GetPreviews() const void UComboActionGraphNode_ActionNodeBase::UpdatePreviews() { - if (!DataTable) Preview.Empty(); + if (!this->DataTable) + { + this->Preview.Empty(); + } - Preview.Empty(); + this->Preview.Empty(); - Preview = GetPreviews(); + this->Preview = this->GetPreviews(); } #endif diff --git a/Source/ComboInput/Private/Nodes/ComboActionGraphNode_StartNode.cpp b/Source/ComboInput/Private/Nodes/ComboActionGraphNode_StartNode.cpp index a2a7b61..a1449ae 100644 --- a/Source/ComboInput/Private/Nodes/ComboActionGraphNode_StartNode.cpp +++ b/Source/ComboInput/Private/Nodes/ComboActionGraphNode_StartNode.cpp @@ -24,7 +24,7 @@ UComboActionGraphNode_StartNode::UComboActionGraphNode_StartNode() #endif // TODO: Once there are Conditional Decorators, this will be replaced - MaxChildrenNodes = 1; + this->MaxChildrenNodes = -1; } #if WITH_EDITOR diff --git a/Source/ComboInput/Public/Nodes/ComboActionGraphEdge.h b/Source/ComboInput/Public/Nodes/ComboActionGraphEdge.h index 02fa357..d64816e 100644 --- a/Source/ComboInput/Public/Nodes/ComboActionGraphEdge.h +++ b/Source/ComboInput/Public/Nodes/ComboActionGraphEdge.h @@ -17,24 +17,26 @@ class COMBOINPUT_API UComboActionGraphEdge : public UObject { GENERATED_BODY() -#pragma region Variables public: + UFUNCTION(BlueprintCallable, Category="Combo Input|Action") + void SetGraph(class UComboActionGraph *InGraph) { this->Graph = InGraph; } + UFUNCTION(BlueprintCallable, Category="Combo Input|Action") + void SetStartNode(class UComboActionGraphNode *InNode) { this->StartNode = InNode; } + UFUNCTION(BlueprintCallable, Category="Combo Input|Action") + void SetEndNode(class UComboActionGraphNode *InNode) { this->EndNode = InNode; } + + UFUNCTION(BlueprintPure, Category="Combo Input|Action") + class UComboActionGraph *GetGraph() const { return this->Graph; } + UFUNCTION(BlueprintPure, Category="Combo Input|Action") + class UComboActionGraphNode *GetStartNode() const { return this->StartNode; } + UFUNCTION(BlueprintPure, Category="Combo Input|Action") + class UComboActionGraphNode *GetEndNode() const { return this->EndNode; } +private: UPROPERTY(VisibleAnywhere, Category="Combo Input|Action") - UComboActionGraph *Graph = nullptr; - - UPROPERTY(BlueprintReadOnly, Category="Combo Input|Action") - UComboActionGraphNode *StartNode = nullptr; - - UPROPERTY(BlueprintReadOnly, Category="Combo Input|Action") - UComboActionGraphNode *EndNode = nullptr; - -#pragma endregion - -#pragma region Functions -public: - //UFUNCTION(BlueprintPure, Category="Combo Input|Action") - UComboActionGraph *GetGraph() const { return Graph; } - -#pragma endregion + class UComboActionGraph *Graph = nullptr; + UPROPERTY(BlueprintReadOnly, Category="Combo Input|Action", meta=(AllowPrivateAccess="true")) + class UComboActionGraphNode *StartNode = nullptr; + UPROPERTY(BlueprintReadOnly, Category="Combo Input|Action", meta=(AllowPrivateAccess="true")) + class UComboActionGraphNode *EndNode = nullptr; }; diff --git a/Source/ComboInput/Public/Nodes/ComboActionGraphNode.h b/Source/ComboInput/Public/Nodes/ComboActionGraphNode.h index c4c9e3d..2a9a9a0 100644 --- a/Source/ComboInput/Public/Nodes/ComboActionGraphNode.h +++ b/Source/ComboInput/Public/Nodes/ComboActionGraphNode.h @@ -138,8 +138,8 @@ public: UFUNCTION(BlueprintCallable, BlueprintPure, Category="Combo Input|Action") virtual bool DoesAutoStart() const { return bAutoStarts; } - virtual void PreProcessNode(){} - virtual void ProcessNode(); + virtual void PreProcessNode(const TScriptInterface &Manager){} + virtual void ProcessNode(const TScriptInterface &Manager); /** * Gets the decorators for this Dialogue Graph Node. *❔ Returns only Valid decorators! diff --git a/Source/ComboInput/Public/Nodes/ComboActionGraphNode_ActionNode.h b/Source/ComboInput/Public/Nodes/ComboActionGraphNode_ActionNode.h new file mode 100644 index 0000000..3783d1c --- /dev/null +++ b/Source/ComboInput/Public/Nodes/ComboActionGraphNode_ActionNode.h @@ -0,0 +1,33 @@ +// 2023 Batty Bovine Productions, LLC. All Rights Reserved. + +#pragma once + +#include "CoreMinimal.h" +#include "Nodes/ComboActionGraphNode_ActionNodeBase.h" +#include "UObject/Object.h" + +#include "ComboActionGraphNode_ActionNode.generated.h" + + +/** + * Combo Action node. + * + * This Node represents Player's combo actions. + */ +UCLASS(ClassGroup=("Combo Input|Action"), DisplayName="Action Node", meta=(ToolTip="Combo Action Tree: Action Node")) +class COMBOINPUT_API UComboActionGraphNode_ActionNode : public UComboActionGraphNode_ActionNodeBase +{ + GENERATED_BODY() + + UComboActionGraphNode_ActionNode(); + +public: + + virtual void PreProcessNode(const TScriptInterface &Manager) override; + virtual void ProcessNode(const TScriptInterface &Manager) override; + +#if WITH_EDITOR + virtual FText GetDescription_Implementation() const override; + virtual FText GetNodeCategory_Implementation() const override; +#endif +}; diff --git a/Source/ComboInput/Public/Nodes/ComboActionGraphNode_ActionNodeBase.h b/Source/ComboInput/Public/Nodes/ComboActionGraphNode_ActionNodeBase.h index bade51e..30828e8 100644 --- a/Source/ComboInput/Public/Nodes/ComboActionGraphNode_ActionNodeBase.h +++ b/Source/ComboInput/Public/Nodes/ComboActionGraphNode_ActionNodeBase.h @@ -25,8 +25,8 @@ class COMBOINPUT_API UComboActionGraphNode_ActionNodeBase : public UComboActionG public: UComboActionGraphNode_ActionNodeBase(); - virtual void ProcessNode() override; - virtual void PreProcessNode() override; + virtual void ProcessNode(const TScriptInterface &Manager) override; + virtual void PreProcessNode(const TScriptInterface &Manager) override; /** * Returns the Dialogue Data Table for this graph node. diff --git a/Source/ComboInputEditor/Private/Ed/EdComboActionGraph.cpp b/Source/ComboInputEditor/Private/Ed/EdComboActionGraph.cpp index d7a90c6..66a4d98 100644 --- a/Source/ComboInputEditor/Private/Ed/EdComboActionGraph.cpp +++ b/Source/ComboInputEditor/Private/Ed/EdComboActionGraph.cpp @@ -88,11 +88,11 @@ void UEdComboActionGraph::RebuildComboActionGraph() this->EdgeMap.Add(Edge, EdgeNode); - Edge->Graph = Graph; + Edge->SetGraph(Graph); Edge->Rename(nullptr, Graph, REN_DontCreateRedirectors | REN_DoNotDirty); - Edge->StartNode = StartNode->ComboActionGraphNode; - Edge->EndNode = EndNode->ComboActionGraphNode; - Edge->StartNode->Edges.Add(Edge->EndNode, Edge); + StartNode->ComboActionGraphNode->Edges.Add(EndNode->ComboActionGraphNode, Edge); + Edge->SetStartNode(StartNode->ComboActionGraphNode); + Edge->SetEndNode(EndNode->ComboActionGraphNode); } } diff --git a/Source/ComboInputEditor/Private/Search/SComboActionSearch.cpp b/Source/ComboInputEditor/Private/Search/SComboActionSearch.cpp index d912acc..e6154db 100644 --- a/Source/ComboInputEditor/Private/Search/SComboActionSearch.cpp +++ b/Source/ComboInputEditor/Private/Search/SComboActionSearch.cpp @@ -108,7 +108,7 @@ void SComboActionSearch::FocusForUse(const FComboActionSearchFilter &SearchFilte if (!SearchFilter.SearchString.IsEmpty()) { SearchTextBoxWidget->SetText(FText::FromString(SearchFilter.SearchString)); - MakeSearchQuery(SearchFilter); + this->MakeSearchQuery(SearchFilter); if (bSelectFirstResult && this->ItemsFound.Num()) { @@ -210,7 +210,7 @@ void SComboActionSearch::HandleSearchTextCommitted(const FText& Text, ETextCommi if (CommitType == ETextCommit::OnEnter) { this->CurrentFilter.SearchString = Text.ToString(); - MakeSearchQuery(this->CurrentFilter); + this->MakeSearchQuery(this->CurrentFilter); } } @@ -249,7 +249,7 @@ TSharedRef SComboActionSearch::HandleGenerateRow(TSharedPtrCreateIcon() @@ -258,7 +258,7 @@ TSharedRef SComboActionSearch::HandleGenerateRow(TSharedPtr SComboActionSearch::HandleGenerateRow(TSharedPtr SComboActionSearch::FillFilterEntries() FExecuteAction::CreateLambda([this]() { this->CurrentFilter.bIncludeNodeTitle = !this->CurrentFilter.bIncludeNodeTitle; - MakeSearchQuery(this->CurrentFilter); + this->MakeSearchQuery(this->CurrentFilter); }), FCanExecuteAction(), FIsActionChecked::CreateLambda([this]() -> bool @@ -327,7 +327,7 @@ TSharedRef SComboActionSearch::FillFilterEntries() FExecuteAction::CreateLambda([this]() { this->CurrentFilter.bIncludeNodeType = !this->CurrentFilter.bIncludeNodeType; - MakeSearchQuery(this->CurrentFilter); + this->MakeSearchQuery(this->CurrentFilter); }), FCanExecuteAction(), FIsActionChecked::CreateLambda([this]() -> bool @@ -347,7 +347,7 @@ TSharedRef SComboActionSearch::FillFilterEntries() FExecuteAction::CreateLambda([this]() { this->CurrentFilter.bIncludeNodeDecoratorsTypes = !this->CurrentFilter.bIncludeNodeDecoratorsTypes; - MakeSearchQuery(this->CurrentFilter); + this->MakeSearchQuery(this->CurrentFilter); }), FCanExecuteAction(), FIsActionChecked::CreateLambda([this]() -> bool @@ -367,7 +367,7 @@ TSharedRef SComboActionSearch::FillFilterEntries() FExecuteAction::CreateLambda([this]() { this->CurrentFilter.bIncludeNodeData = !this->CurrentFilter.bIncludeNodeData; - MakeSearchQuery(this->CurrentFilter); + this->MakeSearchQuery(this->CurrentFilter); }), FCanExecuteAction(), FIsActionChecked::CreateLambda([this]() -> bool @@ -387,7 +387,7 @@ TSharedRef SComboActionSearch::FillFilterEntries() FExecuteAction::CreateLambda([this]() { this->CurrentFilter.bIncludeNodeGUID = !this->CurrentFilter.bIncludeNodeGUID; - MakeSearchQuery(this->CurrentFilter); + this->MakeSearchQuery(this->CurrentFilter); }), FCanExecuteAction(), FIsActionChecked::CreateLambda([this]() -> bool