Files
UnrealEngineUWP/Engine/Source/Editor/LevelEditor/Private/LevelEditorModesActions.cpp
aditya ravichandran 9c09a76984 Reskin the Level Editor Main Toolbar,
Move Editor Modes to a Combo Button,
Combine Content and Create into one dropdown,
Reorder items in the Content Browser add and context menu to be more meaningful
#jira UETOOL-3814
#preflight 61434322599fd8000190b8bf
#rb Louise.Rasmussen, brooke.hubert

#ROBOMERGE-AUTHOR: aditya.ravichandran
#ROBOMERGE-SOURCE: CL 17538574 in //UE5/Main/...
#ROBOMERGE-BOT: STARSHIP (Main -> Release-Engine-Test) (v870-17433530)

[CL 17538604 by aditya ravichandran in ue5-release-engine-test branch]
2021-09-16 10:15:01 -04:00

65 lines
2.1 KiB
C++

// Copyright Epic Games, Inc. All Rights Reserved.
#include "LevelEditorModesActions.h"
#include "Subsystems/AssetEditorSubsystem.h"
#include "Editor.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;
static const TArray<FKey, TInlineAllocator<9>> EdModeKeys = { EKeys::One, EKeys::Two, EKeys::Three, EKeys::Four, EKeys::Five, EKeys::Six, EKeys::Seven, EKeys::Eight, EKeys::Nine };
for ( const FEditorModeInfo& Mode : GEditor->GetEditorSubsystem<UAssetEditorSubsystem>()->GetEditorModeInfoOrderedByPriority())
{
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;
FText ModeName = Mode.Name;
if (ModeName.IsEmpty())
{
ModeName = FText::FromName(Mode.ID);
}
Args.Add(TEXT("Mode"), ModeName);
const FText Tooltip = FText::Format( NSLOCTEXT("LevelEditor", "ModeTooltipF", "Activate {Mode} Editing Mode"), Args );
FInputChord DefaultKeyBinding;
if (Mode.IsVisible() && editorMode < EdModeKeys.Num())
{
DefaultKeyBinding = FInputChord(EModifierKey::Shift, EdModeKeys[editorMode]);
++editorMode;
}
FSlateIcon ModeIcon = (Mode.IconBrush != FSlateIcon()) ? Mode.IconBrush : FSlateIcon(FAppStyle::Get().GetStyleSetName(), "LevelEditor.Tabs.EditorModes");
FUICommandInfo::MakeCommandInfo(
this->AsShared(),
EditorModeCommand,
EditorModeCommandName,
ModeName,
Tooltip,
ModeIcon,
EUserInterfaceActionType::CollapsedButton,
DefaultKeyBinding);
EditorModeCommands.Add(EditorModeCommand);
}
}
}
PRAGMA_ENABLE_OPTIMIZATION
#undef LOCTEXT_NAMESPACE