Files
UnrealEngineUWP/Engine/Source/Editor/LevelEditor/Private/LevelEditorModesActions.cpp
Chris Gagnon 8fc25ea18e Merging //UE4/Dev-Main to Dev-Editor (//UE4/Dev-Editor)
#rb none

[CL 4676797 by Chris Gagnon in Dev-Editor branch]
2019-01-02 14:54:39 -05:00

59 lines
1.7 KiB
C++

// Copyright 1998-2019 Epic Games, Inc. All Rights Reserved.
#include "LevelEditorModesActions.h"
#include "EditorModeRegistry.h"
DEFINE_LOG_CATEGORY_STATIC(LevelEditorModesActions, Log, All);
#define LOCTEXT_NAMESPACE "LevelEditorModesActions"
/** UI_COMMAND takes long for the compile to optimize */
PRAGMA_DISABLE_OPTIMIZATION
void FLevelEditorModesCommands::RegisterCommands()
{
EditorModeCommands.Empty();
int editorMode = 0;
FKey EdModeKeys[9] = { EKeys::One, EKeys::Two, EKeys::Three, EKeys::Four, EKeys::Five, EKeys::Six, EKeys::Seven, EKeys::Eight, EKeys::Nine };
for ( const FEditorModeInfo& Mode : FEditorModeRegistry::Get().GetSortedModeInfo() )
{
// If the mode isn't visible don't create a menu option for it.
if (!Mode.bVisible)
{
continue;
}
FName EditorModeCommandName = FName(*(FString("EditorMode.") + Mode.ID.ToString()));
TSharedPtr<FUICommandInfo> EditorModeCommand =
FInputBindingManager::Get().FindCommandInContext(GetContextName(), EditorModeCommandName);
// If a command isn't yet registered for this mode, we need to register one.
if ( !EditorModeCommand.IsValid() )
{
FFormatNamedArguments Args;
Args.Add( TEXT("Mode"), Mode.Name );
const FText Tooltip = FText::Format( NSLOCTEXT("LevelEditor", "ModeTooltipF", "Activate {Mode} Editing Mode"), Args );
FUICommandInfo::MakeCommandInfo(
this->AsShared(),
EditorModeCommand,
EditorModeCommandName,
Mode.Name,
Tooltip,
Mode.IconBrush,
EUserInterfaceActionType::ToggleButton,
editorMode < 9 ? FInputChord( EModifierKey::Shift, EdModeKeys[editorMode] ) : FInputChord() );
EditorModeCommands.Add(EditorModeCommand);
}
editorMode++;
}
}
PRAGMA_ENABLE_OPTIMIZATION
#undef LOCTEXT_NAMESPACE