Files
UnrealEngineUWP/Engine/Source/Runtime/InteractiveToolsFramework/Public/InteractiveToolActionSet.h
michael balzer 2b10993563 Move InteractiveToolsFramework and GeometryFramework out of Experimental
#jira UETOOL-3823
#rb brooke.hubert
#preflight 6109d1e9b4288d0001acb7ef

[CL 17055606 by michael balzer in ue5-main branch]
2021-08-04 13:58:55 -04:00

115 lines
2.8 KiB
C++

// Copyright Epic Games, Inc. All Rights Reserved.
#pragma once
#include "CoreMinimal.h"
#include "GenericPlatform/GenericApplication.h"
#include "InputCoreTypes.h"
class UInteractiveTool;
/**
* Standard Actions that can be shared across multiple Tools.
* The enum values are used as FInteractiveToolAction.ActionID.
* If you need to define your own values, start at BaseClientDefinedActionID
*/
enum class EStandardToolActions
{
IncreaseBrushSize = 100,
DecreaseBrushSize = 101,
ToggleWireframe = 102,
BaseClientDefinedActionID = 10000
};
/**
* FInteractiveToolAction is returned by a UInteractiveTool to represent
* an "Action" the Tool can execute.
*/
struct INTERACTIVETOOLSFRAMEWORK_API FInteractiveToolAction
{
/** Which type of UInteractiveTool this Action can be applied to*/
const UClass* ClassType;
/** Identifier for this Action */
int32 ActionID;
/** Internal name for this Action */
FString ActionName;
/** Short name for this Action */
FText ShortName;
/** Descriptive name for this Action */
FText Description;
/** Suggested modifier keys for this Action */
EModifierKey::Type DefaultModifiers;
/** Suggested keybinding for this Action. */
FKey DefaultKey;
/** Call this function to execute the Action */
TFunction<void()> OnAction;
FInteractiveToolAction()
{
ClassType = nullptr;
ActionID = 0;
}
FInteractiveToolAction(const UClass* ClassTypeIn, int32 ActionIDIn,
const FString& ActionNameIn, const FText& ShortNameIn, const FText& DescriptionIn,
EModifierKey::Type DefaultModifiersIn, const FKey& DefaultKeyIn )
{
ClassType = ClassTypeIn;
ActionID = ActionIDIn;
ActionName = ActionNameIn;
ShortName = ShortNameIn;
Description = DescriptionIn;
DefaultModifiers = DefaultModifiersIn;
DefaultKey = DefaultKeyIn;
}
};
/**
* FInteractiveToolActionSet maintains a list of FInteractiveToolAction.
* Each UInteractiveTool contains an instance of this class.
*/
class INTERACTIVETOOLSFRAMEWORK_API FInteractiveToolActionSet
{
public:
/**
* Register an Action with the ActionSet. This function is intended to be called by
* UInteractiveTool::RegisterActions() implementations
*/
void RegisterAction(UInteractiveTool* Tool, int32 ActionID,
const FString& ActionName, const FText& ShortUIName, const FText& DescriptionText,
EModifierKey::Type Modifiers, const FKey& ShortcutKey,
TFunction<void()> ActionFunction );
/**
* Find an existing Action by ID
* @return located Action, or nullptr if not found
*/
const FInteractiveToolAction* FindActionByID(int32 ActionID) const;
/**
* Return the internal list of registered Actions by adding to the OutActions array
*/
void CollectActions(TArray<FInteractiveToolAction>& OutActions) const;
/**
* Execute the action identified by ActionID
*/
void ExecuteAction(int32 ActionID) const;
protected:
TArray<FInteractiveToolAction> Actions;
};