ComboInput/Source/ComboInput/Private/Nodes/ComboActionGraphNode_ActionNodeBase.cpp

160 lines
4.5 KiB
C++

// ©2023 Batty Bovine Productions, LLC. All Rights Reserved.
#include "Nodes/ComboActionGraphNode_ActionNodeBase.h"
#define LOCTEXT_NAMESPACE "ComboActionGraphNode_ActionNodeBase"
UComboActionGraphNode_ActionNodeBase::UComboActionGraphNode_ActionNodeBase()
{
#if WITH_EDITORONLY_DATA
this->NodeTitle = LOCTEXT("ComboActionGraphNode_ActionNodeBaseTitle", "Action Node Base");
this->NodeTypeName = LOCTEXT("ComboActionGraphNode_ActionNodeBaseInternalTitle", "Action Node Base");
this->ContextMenuName = LOCTEXT("ComboActionGraphNode_ActionNodeBaseContextMenu", "Action Node");
this->BackgroundColor = FLinearColor(FColor::Orange);
this->NodeTooltipText = LOCTEXT("ComboActionGraphNode_BaseTooltip", "* Abstract class, should not appear in graph editor.\n* Enhances 'ComboActionGraphNode' Base class with action data.");
#endif
this->bAutoStarts = false;
}
void UComboActionGraphNode_ActionNodeBase::ProcessNode(const TScriptInterface<IComboActionGraphManagerInterface> &Manager)
{
Super::ProcessNode(Manager);
}
void UComboActionGraphNode_ActionNodeBase::PreProcessNode(const TScriptInterface<IComboActionGraphManagerInterface> &Manager)
{
Super::PreProcessNode(Manager);
}
bool UComboActionGraphNode_ActionNodeBase::ValidateNodeRuntime_Implementation() const
{
if (!this->ComboInput)
{
return false;
}
if (this->TriggerEvent == EComboActionTriggerEvent::None)
{
return false;
}
if (this->MaxChildrenNodes > -1 && this->ChildrenNodes.Num() > this->MaxChildrenNodes)
{
return false;
}
return true;
}
#if WITH_EDITOR
bool UComboActionGraphNode_ActionNodeBase::ValidateNode(TArray<FText> &ValidationsMessages, const bool RichFormat)
{
bool bResult = Super::ValidateNode(ValidationsMessages, RichFormat);
if (!this->ComboInput)
{
bResult = false;
const FString RichTextReturn =
FString("* ").
Append("<RichTextBlock.Bold>").
Append(NodeTitle.ToString()).
Append("</>").
Append(": Does not reference a valid combo input!");
const FString TextReturn =
FString(NodeTitle.ToString()).
Append(": Does not reference a valid combo input!");
ValidationsMessages.Add(FText::FromString(RichFormat ? RichTextReturn : TextReturn));
}
if (this->TriggerEvent == EComboActionTriggerEvent::None)
{
bResult = false;
const FString RichTextReturn =
FString("* ").
Append("<RichTextBlock.Bold>").
Append(NodeTitle.ToString()).
Append("</>").
Append(": Does not reference a valid trigger event!");
const FString TextReturn =
FString(NodeTitle.ToString()).
Append(": Does not reference a valid trigger event!");
ValidationsMessages.Add(FText::FromString(RichFormat ? RichTextReturn : TextReturn));
}
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(" child nodes!");
const FString TextReturn = FString(this->NodeTitle.ToString())
.Append(": Has more than ").Append(FString::FromInt(this->MaxChildrenNodes)).Append(" child nodes!");
ValidationsMessages.Add(FText::FromString(RichFormat ? RichTextReturn : TextReturn));
}
return bResult;
}
void UComboActionGraphNode_ActionNodeBase::PostEditChangeProperty(FPropertyChangedEvent& PropertyChangedEvent)
{
Super::PostEditChangeProperty(PropertyChangedEvent);
if (PropertyChangedEvent.GetPropertyName() == GET_MEMBER_NAME_CHECKED(UComboActionGraphNode_ActionNodeBase, ComboInput))
{
this->Preview.Empty();
this->PreviewsUpdated.ExecuteIfBound();
}
if (PropertyChangedEvent.GetPropertyName() == GET_MEMBER_NAME_CHECKED(UComboActionGraphNode_ActionNodeBase, TriggerEvent))
{
this->UpdatePreviews();
this->PreviewsUpdated.ExecuteIfBound();
}
}
FText UComboActionGraphNode_ActionNodeBase::GetDescription_Implementation() const
{
return LOCTEXT("ComboActionGraphNode_BaseDescription", "Action base node has no logic tied to itself.");
}
TArray<FText> UComboActionGraphNode_ActionNodeBase::GetPreviews() const
{
TArray<FText> ReturnValues;
//const auto Row = UComboActionSystemBFC::GetDialogueRow( this );
//if (UComboActionSystemBFC::IsDialogueRowValid(Row))
//{
// for (auto Itr : Row.DialogueRowData.Array())
// {
// ReturnValues.Add( Itr.RowText );
// }
//}
//else
//{
// ReturnValues.Empty();
//}
return ReturnValues;
}
#endif
#undef LOCTEXT_NAMESPACE