New, subsystem style
This commit is contained in:
parent
1df4e9b848
commit
2d2f0192fa
8 changed files with 51 additions and 266 deletions
|
@ -17,7 +17,7 @@
|
|||
{
|
||||
"Name": "SkyPortal",
|
||||
"Type": "Runtime",
|
||||
"LoadingPhase": "Default"
|
||||
"LoadingPhase": "PostDefault"
|
||||
}
|
||||
],
|
||||
"IsExperimentalVersion": false,
|
||||
|
|
|
@ -1,13 +1,6 @@
|
|||
// 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"
|
||||
|
||||
//TODO: Need to make a raw input viewer
|
||||
//maybe even a view of the different objects detected
|
||||
|
@ -18,24 +11,8 @@ static const FName SkyPortalTabName("Portal Input Viewer");
|
|||
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
|
||||
//SkyPortalSubsystem = GEngine->GetEngineSubsystem();
|
||||
|
||||
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()
|
||||
|
@ -43,69 +20,10 @@ 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)
|
||||
|
||||
|
|
|
@ -1,12 +0,0 @@
|
|||
// Copyright Epic Games, Inc. All Rights Reserved.
|
||||
|
||||
#include "SkyPortalCommands.h"
|
||||
|
||||
#define LOCTEXT_NAMESPACE "FSkyPortalModule"
|
||||
|
||||
void FSkyPortalCommands::RegisterCommands()
|
||||
{
|
||||
UI_COMMAND(OpenPluginWindow, "SkyPortal", "Bring up SkyPortal window", EUserInterfaceActionType::Button, FInputChord());
|
||||
}
|
||||
|
||||
#undef LOCTEXT_NAMESPACE
|
|
@ -1,60 +0,0 @@
|
|||
// Copyright Epic Games, Inc. All Rights Reserved.
|
||||
|
||||
#include "SkyPortalStyle.h"
|
||||
#include "Styling/SlateStyleRegistry.h"
|
||||
#include "Framework/Application/SlateApplication.h"
|
||||
#include "Slate/SlateGameResources.h"
|
||||
#include "Interfaces/IPluginManager.h"
|
||||
#include "Styling/SlateStyleMacros.h"
|
||||
|
||||
#define RootToContentDir Style->RootToContentDir
|
||||
|
||||
TSharedPtr<FSlateStyleSet> FSkyPortalStyle::StyleInstance = nullptr;
|
||||
|
||||
void FSkyPortalStyle::Initialize()
|
||||
{
|
||||
if (!StyleInstance.IsValid())
|
||||
{
|
||||
StyleInstance = Create();
|
||||
FSlateStyleRegistry::RegisterSlateStyle(*StyleInstance);
|
||||
}
|
||||
}
|
||||
|
||||
void FSkyPortalStyle::Shutdown()
|
||||
{
|
||||
FSlateStyleRegistry::UnRegisterSlateStyle(*StyleInstance);
|
||||
ensure(StyleInstance.IsUnique());
|
||||
StyleInstance.Reset();
|
||||
}
|
||||
|
||||
FName FSkyPortalStyle::GetStyleSetName()
|
||||
{
|
||||
static FName StyleSetName(TEXT("SkyPortalStyle"));
|
||||
return StyleSetName;
|
||||
}
|
||||
|
||||
const FVector2D Icon16x16(16.0f, 16.0f);
|
||||
const FVector2D Icon20x20(20.0f, 20.0f);
|
||||
|
||||
TSharedRef< FSlateStyleSet > FSkyPortalStyle::Create()
|
||||
{
|
||||
TSharedRef< FSlateStyleSet > Style = MakeShareable(new FSlateStyleSet("SkyPortalStyle"));
|
||||
Style->SetContentRoot(IPluginManager::Get().FindPlugin("SkyPortal")->GetBaseDir() / TEXT("Resources"));
|
||||
|
||||
Style->Set("SkyPortal.OpenPluginWindow", new IMAGE_BRUSH_SVG(TEXT("PlaceholderButtonIcon"), Icon20x20));
|
||||
|
||||
return Style;
|
||||
}
|
||||
|
||||
void FSkyPortalStyle::ReloadTextures()
|
||||
{
|
||||
if (FSlateApplication::IsInitialized())
|
||||
{
|
||||
FSlateApplication::Get().GetRenderer()->ReloadTextureResources();
|
||||
}
|
||||
}
|
||||
|
||||
const ISlateStyle& FSkyPortalStyle::Get()
|
||||
{
|
||||
return *StyleInstance;
|
||||
}
|
|
@ -1,12 +1,11 @@
|
|||
// Copyright Epic Games, Inc. All Rights Reserved.
|
||||
|
||||
// This plugin will try to make a complete plug n play subsystem for skylanders portals
|
||||
#pragma once
|
||||
|
||||
#include "CoreMinimal.h"
|
||||
#include "Modules/ModuleManager.h"
|
||||
|
||||
class FToolBarBuilder;
|
||||
class FMenuBuilder;
|
||||
|
||||
class FSkyPortalModule : public IModuleInterface
|
||||
{
|
||||
|
@ -16,15 +15,7 @@ public:
|
|||
virtual void StartupModule() override;
|
||||
virtual void ShutdownModule() override;
|
||||
|
||||
/** This function will be bound to Command (by default it will bring up plugin window) */
|
||||
void PluginButtonClicked();
|
||||
|
||||
private:
|
||||
|
||||
void RegisterMenus();
|
||||
|
||||
TSharedRef<class SDockTab> OnSpawnPluginTab(const class FSpawnTabArgs& SpawnTabArgs);
|
||||
|
||||
private:
|
||||
TSharedPtr<class FUICommandList> PluginCommands;
|
||||
};
|
||||
|
||||
|
|
|
@ -1,23 +0,0 @@
|
|||
// Copyright Epic Games, Inc. All Rights Reserved.
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "CoreMinimal.h"
|
||||
#include "Framework/Commands/Commands.h"
|
||||
#include "SkyPortalStyle.h"
|
||||
|
||||
class FSkyPortalCommands : public TCommands<FSkyPortalCommands>
|
||||
{
|
||||
public:
|
||||
|
||||
FSkyPortalCommands()
|
||||
: TCommands<FSkyPortalCommands>(TEXT("SkyPortal"), NSLOCTEXT("Contexts", "SkyPortal", "SkyPortal Plugin"), NAME_None, FSkyPortalStyle::GetStyleSetName())
|
||||
{
|
||||
}
|
||||
|
||||
// TCommands<> interface
|
||||
virtual void RegisterCommands() override;
|
||||
|
||||
public:
|
||||
TSharedPtr< FUICommandInfo > OpenPluginWindow;
|
||||
};
|
|
@ -1,32 +0,0 @@
|
|||
// Copyright Epic Games, Inc. All Rights Reserved.
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "CoreMinimal.h"
|
||||
#include "Styling/SlateStyle.h"
|
||||
|
||||
/** */
|
||||
class FSkyPortalStyle
|
||||
{
|
||||
public:
|
||||
|
||||
static void Initialize();
|
||||
|
||||
static void Shutdown();
|
||||
|
||||
/** reloads textures used by slate renderer */
|
||||
static void ReloadTextures();
|
||||
|
||||
/** @return The Slate style set for the Shooter game */
|
||||
static const ISlateStyle& Get();
|
||||
|
||||
static FName GetStyleSetName();
|
||||
|
||||
private:
|
||||
|
||||
static TSharedRef< class FSlateStyleSet > Create();
|
||||
|
||||
private:
|
||||
|
||||
static TSharedPtr< class FSlateStyleSet > StyleInstance;
|
||||
};
|
|
@ -26,6 +26,8 @@ public class SkyPortal : ModuleRules
|
|||
new string[]
|
||||
{
|
||||
"Core",
|
||||
"CoreUObject",
|
||||
"Engine",
|
||||
// ... add other public dependencies that you statically link with here ...
|
||||
}
|
||||
);
|
||||
|
@ -36,6 +38,7 @@ public class SkyPortal : ModuleRules
|
|||
{
|
||||
"Projects",
|
||||
"InputCore",
|
||||
"EditorSubsystem",
|
||||
"EditorFramework",
|
||||
"UnrealEd",
|
||||
"ToolMenus",
|
||||
|
|
Loading…
Reference in a new issue