110 lines
3.2 KiB
C++
110 lines
3.2 KiB
C++
|
// Copyright Epic Games, Inc. All Rights Reserved.
|
||
|
|
||
|
#include "SkyPortal.h"
|
||
|
#include "SkyPortalStyle.h"
|
||
|
#include "SkyPortalCommands.h"
|
||
|
#include "LevelEditor.h"
|
||
|
#include "Widgets/Docking/SDockTab.h"
|
||
|
#include "Widgets/Layout/SBox.h"
|
||
|
#include "Widgets/Text/STextBlock.h"
|
||
|
#include "ToolMenus.h"
|
||
|
|
||
|
static const FName SkyPortalTabName("SkyPortal");
|
||
|
|
||
|
#define LOCTEXT_NAMESPACE "FSkyPortalModule"
|
||
|
|
||
|
void FSkyPortalModule::StartupModule()
|
||
|
{
|
||
|
// This code will execute after your module is loaded into memory; the exact timing is specified in the .uplugin file per-module
|
||
|
|
||
|
FSkyPortalStyle::Initialize();
|
||
|
FSkyPortalStyle::ReloadTextures();
|
||
|
|
||
|
FSkyPortalCommands::Register();
|
||
|
|
||
|
PluginCommands = MakeShareable(new FUICommandList);
|
||
|
|
||
|
PluginCommands->MapAction(
|
||
|
FSkyPortalCommands::Get().OpenPluginWindow,
|
||
|
FExecuteAction::CreateRaw(this, &FSkyPortalModule::PluginButtonClicked),
|
||
|
FCanExecuteAction());
|
||
|
|
||
|
UToolMenus::RegisterStartupCallback(FSimpleMulticastDelegate::FDelegate::CreateRaw(this, &FSkyPortalModule::RegisterMenus));
|
||
|
|
||
|
FGlobalTabmanager::Get()->RegisterNomadTabSpawner(SkyPortalTabName, FOnSpawnTab::CreateRaw(this, &FSkyPortalModule::OnSpawnPluginTab))
|
||
|
.SetDisplayName(LOCTEXT("FSkyPortalTabTitle", "SkyPortal"))
|
||
|
.SetMenuType(ETabSpawnerMenuType::Hidden);
|
||
|
}
|
||
|
|
||
|
void FSkyPortalModule::ShutdownModule()
|
||
|
{
|
||
|
// This function may be called during shutdown to clean up your module. For modules that support dynamic reloading,
|
||
|
// we call this function before unloading the module.
|
||
|
|
||
|
UToolMenus::UnRegisterStartupCallback(this);
|
||
|
|
||
|
UToolMenus::UnregisterOwner(this);
|
||
|
|
||
|
FSkyPortalStyle::Shutdown();
|
||
|
|
||
|
FSkyPortalCommands::Unregister();
|
||
|
|
||
|
FGlobalTabmanager::Get()->UnregisterNomadTabSpawner(SkyPortalTabName);
|
||
|
}
|
||
|
|
||
|
TSharedRef<SDockTab> FSkyPortalModule::OnSpawnPluginTab(const FSpawnTabArgs& SpawnTabArgs)
|
||
|
{
|
||
|
FText WidgetText = FText::Format(
|
||
|
LOCTEXT("WindowWidgetText", "Add code to {0} in {1} to override this window's contents"),
|
||
|
FText::FromString(TEXT("FSkyPortalModule::OnSpawnPluginTab")),
|
||
|
FText::FromString(TEXT("SkyPortal.cpp"))
|
||
|
);
|
||
|
|
||
|
return SNew(SDockTab)
|
||
|
.TabRole(ETabRole::NomadTab)
|
||
|
[
|
||
|
// Put your tab content here!
|
||
|
SNew(SBox)
|
||
|
.HAlign(HAlign_Center)
|
||
|
.VAlign(VAlign_Center)
|
||
|
[
|
||
|
SNew(STextBlock)
|
||
|
.Text(WidgetText)
|
||
|
]
|
||
|
];
|
||
|
}
|
||
|
|
||
|
void FSkyPortalModule::PluginButtonClicked()
|
||
|
{
|
||
|
FGlobalTabmanager::Get()->TryInvokeTab(SkyPortalTabName);
|
||
|
}
|
||
|
|
||
|
void FSkyPortalModule::RegisterMenus()
|
||
|
{
|
||
|
// Owner will be used for cleanup in call to UToolMenus::UnregisterOwner
|
||
|
FToolMenuOwnerScoped OwnerScoped(this);
|
||
|
|
||
|
{
|
||
|
UToolMenu* Menu = UToolMenus::Get()->ExtendMenu("LevelEditor.MainMenu.Window");
|
||
|
{
|
||
|
FToolMenuSection& Section = Menu->FindOrAddSection("WindowLayout");
|
||
|
Section.AddMenuEntryWithCommandList(FSkyPortalCommands::Get().OpenPluginWindow, PluginCommands);
|
||
|
}
|
||
|
}
|
||
|
|
||
|
{
|
||
|
UToolMenu* ToolbarMenu = UToolMenus::Get()->ExtendMenu("LevelEditor.LevelEditorToolBar");
|
||
|
{
|
||
|
FToolMenuSection& Section = ToolbarMenu->FindOrAddSection("Settings");
|
||
|
{
|
||
|
FToolMenuEntry& Entry = Section.AddEntry(FToolMenuEntry::InitToolBarButton(FSkyPortalCommands::Get().OpenPluginWindow));
|
||
|
Entry.SetCommandList(PluginCommands);
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
|
||
|
#undef LOCTEXT_NAMESPACE
|
||
|
|
||
|
IMPLEMENT_MODULE(FSkyPortalModule, SkyPortal)
|