Display of current level now is a button that allows you to change between filtered levels. Also, the level of the currently selected actor is displayed above.

#rb Jason.Stasik
#rnx

#ROBOMERGE-OWNER: ryan.gerleve
#ROBOMERGE-AUTHOR: lauren.ridge
#ROBOMERGE-SOURCE: CL 4847639 via CL 4850448 via CL 4850505
#ROBOMERGE-BOT: ENGINE (Main -> Dev-Networking)

[CL 4850845 by lauren ridge in Dev-Networking branch]
This commit is contained in:
lauren ridge
2019-01-30 18:55:16 -05:00
parent 95aba5b1b5
commit c8fe08076c
6 changed files with 285 additions and 36 deletions

View File

@@ -15,12 +15,53 @@
#include "SWorldHierarchy.h"
#include "SWorldDetails.h"
#include "Tiles/SWorldComposition.h"
#include "Framework/MultiBox/MultiBoxExtender.h"
#include "LevelEditor.h"
#include "EditorLevelUtils.h"
IMPLEMENT_MODULE( FWorldBrowserModule, WorldBrowser );
#define LOCTEXT_NAMESPACE "WorldBrowser"
/**
* Fills the level menu with extra options
*/
TSharedRef<FExtender> FWorldBrowserModule::BindLevelMenu(const TSharedRef<FUICommandList> CommandList)
{
TSharedRef<FExtender> Extender(new FExtender());
Extender->AddMenuExtension("LevelListing", EExtensionHook::Before, CommandList, FMenuExtensionDelegate::CreateRaw(this, &FWorldBrowserModule::BuildLevelMenu));
return Extender;
}
void FWorldBrowserModule::BuildLevelMenu(FMenuBuilder& MenuBuilder)
{
UWorld* EditorWorld = GEditor->GetEditorWorldContext().World();
TSharedPtr<FLevelCollectionModel> Model = SharedWorldModel(EditorWorld);
if (Model.IsValid())
{
FLevelModelList ModelList = Model->GetFilteredLevels();
for (TSharedPtr<FLevelModel> LevelModel : ModelList)
{
FUIAction Action(FExecuteAction::CreateRaw(this, &FWorldBrowserModule::SetCurrentSublevel, LevelModel->GetLevelObject()),
FCanExecuteAction(),
FIsActionChecked::CreateRaw(this, &FWorldBrowserModule::IsCurrentSublevel, LevelModel->GetLevelObject()));
MenuBuilder.AddMenuEntry(FText::FromString(LevelModel->GetDisplayName()), FText::GetEmpty(), FSlateIcon(), Action, NAME_None, EUserInterfaceActionType::Button);
}
}
}
bool FWorldBrowserModule::IsCurrentSublevel(ULevel* InLevel)
{
return InLevel->IsCurrentLevel();
}
void FWorldBrowserModule::SetCurrentSublevel(ULevel* InLevel)
{
EditorLevelUtils::MakeLevelCurrent(InLevel);
}
void FWorldBrowserModule::StartupModule()
{
FLevelCollectionCommands::Register();
@@ -38,6 +79,19 @@ void FWorldBrowserModule::StartupModule()
UWorldComposition::WorldCompositionChangedEvent.AddRaw(this, &FWorldBrowserModule::OnWorldCompositionChanged);
// Have to check GIsEditor because right now editor modules can be loaded by the game
// Once LoadModule is guaranteed to return NULL for editor modules in game, this can be removed
// Without this check, loading the level editor in the game will crash
if (GIsEditor)
{
// Extend the level viewport levels menu
FLevelEditorModule& LevelEditorModule = FModuleManager::Get().LoadModuleChecked<FLevelEditorModule>("LevelEditor");
LevelMenuExtender = FLevelEditorModule::FLevelEditorMenuExtender::CreateRaw(this, &FWorldBrowserModule::BindLevelMenu);
auto& MenuExtenders = LevelEditorModule.GetAllLevelEditorLevelMenuExtenders();
MenuExtenders.Add(LevelMenuExtender);
LevelMenuExtenderHandle = MenuExtenders.Last().GetHandle();
}
FLevelFolders::Init();
}