Adding nodes finally works correctly. Now beginning work on nodes that fit our actual development needs.

This commit is contained in:
Jamie Greunbaum 2023-09-30 18:32:45 -04:00
parent 102927a690
commit af2b70227d
11 changed files with 216 additions and 111 deletions

View File

@ -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();

View File

@ -57,7 +57,7 @@ void UComboActionGraphNode::InitializeNode_Implementation(UWorld *InWorld)
}
}
void UComboActionGraphNode::ProcessNode()
void UComboActionGraphNode::ProcessNode(const TScriptInterface<IComboActionGraphManagerInterface> &Manager)
{
if (!this->GetWorld())
{

View File

@ -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<IComboActionGraphManagerInterface> &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<IComboActionGraphManagerInterface> &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

View File

@ -23,10 +23,10 @@ UComboActionGraphNode_ActionNodeBase::UComboActionGraphNode_ActionNodeBase()
this->bUseGameplayTags = true;
}
void UComboActionGraphNode_ActionNodeBase::ProcessNode()
void UComboActionGraphNode_ActionNodeBase::ProcessNode(const TScriptInterface<IComboActionGraphManagerInterface> &Manager)
{
if (Manager)
{
//if (Manager)
//{
//if (UComboActionContext *Context = Manager->GetDialogueContext())
//{
// this->GetWorld()->GetTimerManager().ClearTimer(Manager->GetDialogueRowTimerHandle());
@ -39,51 +39,51 @@ void UComboActionGraphNode_ActionNodeBase::ProcessNode()
// Manager->GetDialogueContextUpdatedEventHande().Broadcast(Context);
// }
//}
//}
Super::ProcessNode();
}
void UComboActionGraphNode_ActionNodeBase::PreProcessNode()
Super::ProcessNode(Manager);
}
void UComboActionGraphNode_ActionNodeBase::PreProcessNode(const TScriptInterface<IComboActionGraphManagerInterface> &Manager)
{
if (this->bUseGameplayTags)
{
// Switch Participants based on Tags
if (Manager.GetInterface())
{
//if (bUseGameplayTags)
//{
// // Switch Participants based on Tags
// if (Manager.GetInterface())
// {
//if (const auto TempContext = Manager->GetDialogueContext())
//{
// const TScriptInterface<IComboActionParticipantInterface> 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<FDialogueRow>(RowName, Context);
@ -128,7 +128,7 @@ bool UComboActionGraphNode_ActionNodeBase::ValidateNode(TArray<FText>& 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<FText>& Validatio
// ValidationsMessages.Add(FText::FromString(RichFormat ? RichTextReturn : TextReturn));
//}
//if (MaxChildrenNodes > -1 && ChildrenNodes.Num() > MaxChildrenNodes)
//{
// const FString RichTextReturn =
// FString("* ").
// Append("<RichTextBlock.Bold>").
// Append(NodeTitle.ToString()).
// Append("</>").
// Append(": Has more than ").
// Append("<RichTextBlock.Bold>").
// Append(FString::FromInt(MaxChildrenNodes)).
// Append("</>").
// Append(" Children Nodes!");
if (this->MaxChildrenNodes > -1 && this->ChildrenNodes.Num() > this->MaxChildrenNodes)
{
const FString RichTextReturn = FString("* ")
.Append("<RichTextBlock.Bold>")
.Append(this->NodeTitle.ToString())
.Append("</>")
.Append(": Has more than ")
.Append("<RichTextBlock.Bold>")
.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<FDialogueRow>(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<FText> 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

View File

@ -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

View File

@ -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;
};

View File

@ -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<class IComboActionGraphManagerInterface> &Manager){}
virtual void ProcessNode(const TScriptInterface<class IComboActionGraphManagerInterface> &Manager);
/**
* Gets the decorators for this Dialogue Graph Node.
* Returns only Valid decorators!

View File

@ -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<class IComboActionGraphManagerInterface> &Manager) override;
virtual void ProcessNode(const TScriptInterface<class IComboActionGraphManagerInterface> &Manager) override;
#if WITH_EDITOR
virtual FText GetDescription_Implementation() const override;
virtual FText GetNodeCategory_Implementation() const override;
#endif
};

View File

@ -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<class IComboActionGraphManagerInterface> &Manager) override;
virtual void PreProcessNode(const TScriptInterface<class IComboActionGraphManagerInterface> &Manager) override;
/**
* Returns the Dialogue Data Table for this graph node.

View File

@ -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);
}
}

View File

@ -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<ITableRow> SComboActionSearch::HandleGenerateRow(TSharedPtr<FComboAct
// Icon
+SHorizontalBox::Slot()
.VAlign(VAlign_Center)
.VAlign(EVerticalAlignment::VAlign_Center)
.AutoWidth()
[
InItem->CreateIcon()
@ -258,7 +258,7 @@ TSharedRef<ITableRow> SComboActionSearch::HandleGenerateRow(TSharedPtr<FComboAct
// Display text
+SHorizontalBox::Slot()
.AutoWidth()
.VAlign(VAlign_Center)
.VAlign(EVerticalAlignment::VAlign_Center)
.Padding(2,0)
[
SNew(STextBlock)
@ -270,8 +270,8 @@ TSharedRef<ITableRow> SComboActionSearch::HandleGenerateRow(TSharedPtr<FComboAct
// Comment Block
+SHorizontalBox::Slot()
.FillWidth(1)
.HAlign(HAlign_Right)
.VAlign(VAlign_Center)
.HAlign(EHorizontalAlignment::HAlign_Right)
.VAlign(EVerticalAlignment::VAlign_Center)
.Padding(2,0)
[
SNew(STextBlock)
@ -307,7 +307,7 @@ TSharedRef<SWidget> 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<SWidget> 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<SWidget> 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<SWidget> 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<SWidget> SComboActionSearch::FillFilterEntries()
FExecuteAction::CreateLambda([this]()
{
this->CurrentFilter.bIncludeNodeGUID = !this->CurrentFilter.bIncludeNodeGUID;
MakeSearchQuery(this->CurrentFilter);
this->MakeSearchQuery(this->CurrentFilter);
}),
FCanExecuteAction(),
FIsActionChecked::CreateLambda([this]() -> bool