Files
UnrealEngineUWP/Engine/Source/Runtime/Experimental/InteractiveToolsFramework/Private/InteractiveToolActionSet.cpp
ryan durand 0f0464a30e Updating copyright for Engine Runtime.
#rnx
#rb none


#ROBOMERGE-OWNER: ryan.durand
#ROBOMERGE-AUTHOR: ryan.durand
#ROBOMERGE-SOURCE: CL 10869210 via CL 10869511 via CL 10869900
#ROBOMERGE-BOT: (v613-10869866)

[CL 10870549 by ryan durand in Main branch]
2019-12-26 14:45:42 -05:00

59 lines
1.5 KiB
C++

// Copyright Epic Games, Inc. All Rights Reserved.
#include "InteractiveToolActionSet.h"
#include "InteractiveTool.h"
void FInteractiveToolActionSet::RegisterAction(UInteractiveTool* Tool, int32 ActionID,
const FString& ActionName, const FText& ShortUIName, const FText& DescriptionText,
EModifierKey::Type Modifiers, const FKey& ShortcutKey,
TFunction<void()> ActionFunction )
{
checkf(FindActionByID(ActionID) == nullptr, TEXT("InteractiveToolActionSet::RegisterAction: Action ID is already registered!"));
FInteractiveToolAction NewAction;
NewAction.ClassType = Tool->GetClass();
NewAction.ActionID = ActionID;
NewAction.ActionName = ActionName;
NewAction.ShortName = ShortUIName;
NewAction.Description = DescriptionText;
NewAction.DefaultModifiers = Modifiers;
NewAction.DefaultKey = ShortcutKey;
NewAction.OnAction = ActionFunction;
Actions.Add(NewAction);
}
const FInteractiveToolAction* FInteractiveToolActionSet::FindActionByID(int32 ActionID) const
{
for (const FInteractiveToolAction& Action : Actions)
{
if (Action.ActionID == ActionID)
{
return &Action;
}
}
return nullptr;
}
void FInteractiveToolActionSet::CollectActions(TArray<FInteractiveToolAction>& OutActions) const
{
for (const FInteractiveToolAction& Action : Actions)
{
OutActions.Add(Action);
}
}
void FInteractiveToolActionSet::ExecuteAction(int32 ActionID) const
{
const FInteractiveToolAction* Found = FindActionByID(ActionID);
if (Found != nullptr)
{
Found->OnAction();
}
}