Files
UnrealEngineUWP/Engine/Source/Runtime/InteractiveToolsFramework/Private/InteractiveToolActionSet.cpp
Chris Gagnon 930e33cb48 Copying //UE4/Dev-Editor to Dev-Main (//UE4/Dev-Main) for 4.23 From CL 6837861
#rb none

[CL 6838042 by Chris Gagnon in Main branch]
2019-06-04 15:42:48 -04:00

59 lines
1.5 KiB
C++

// Copyright 1998-2019 Epic Games, Inc. All Rights Reserved.
#include "InteractiveToolActionSet.h"
#include "InteractiveTool.h"
void FInteractiveToolActionSet::RegisterAction(UInteractiveTool* Tool, int32 ActionID,
const FString& ActionName, const FString& ShortUIName, const FString& 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();
}
}