Skip to content

Commit

Permalink
SML 3.1.1
Browse files Browse the repository at this point in the history
  • Loading branch information
mircearoata committed May 14, 2021
2 parents b27aee9 + db10108 commit 87b5484
Show file tree
Hide file tree
Showing 19 changed files with 500 additions and 351 deletions.
2 changes: 1 addition & 1 deletion Plugins/Alpakit/Source/Alpakit/Alpakit.Build.cs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ public Alpakit(ReadOnlyTargetRules Target) : base(Target)
"CoreUObject",
"Engine",
"Slate",
"SlateCore"
"SlateCore",
});
}
}
150 changes: 75 additions & 75 deletions Plugins/Alpakit/Source/Alpakit/Private/Alpakit.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,95 +16,95 @@ static const FName AlpakitTabName("Alpakit");
DEFINE_LOG_CATEGORY(LogAlpakit)

void FAlpakitModule::StartupModule() {
//Register editor settings
RegisterSettings();
//Register editor settings
RegisterSettings();

//Initialize Slate stuff, including commands
FAlpakitStyle::Initialize();
FAlpakitStyle::ReloadTextures();
FAlpakitCommands::Register();
PluginCommands = MakeShareable(new FUICommandList);
PluginCommands->MapAction(
FAlpakitCommands::Get().OpenPluginWindow,
FExecuteAction::CreateLambda([](){
FGlobalTabmanager::Get()->InvokeTab(AlpakitTabName);
}),
FCanExecuteAction());
FLevelEditorModule& LevelEditorModule = FModuleManager::LoadModuleChecked<FLevelEditorModule>(TEXT("LevelEditor"));
//Register Alpakit Settings in Editor's Project Menu
TSharedPtr<FExtender> MenuExtender = MakeShareable(new FExtender());
MenuExtender->AddMenuExtension(TEXT("FileProject"), EExtensionHook::After, PluginCommands,
FMenuExtensionDelegate::CreateLambda([](FMenuBuilder& Builder){
Builder.AddMenuEntry(FAlpakitCommands::Get().OpenPluginWindow);
}));
LevelEditorModule.GetMenuExtensibilityManager()->AddExtender(MenuExtender);
//Register Alpakit Settings in Editor's Toolbar
TSharedPtr<FExtender> ToolbarExtender = MakeShareable(new FExtender);
ToolbarExtender->AddToolBarExtension(TEXT("Settings"), EExtensionHook::After, PluginCommands,
FToolBarExtensionDelegate::CreateLambda([](FToolBarBuilder& Builder) {
Builder.AddToolBarButton(FAlpakitCommands::Get().OpenPluginWindow);
}));
LevelEditorModule.GetToolBarExtensibilityManager()->AddExtender(ToolbarExtender);
//Initialize Slate stuff, including commands
FAlpakitStyle::Initialize();
FAlpakitStyle::ReloadTextures();
FAlpakitCommands::Register();
PluginCommands = MakeShareable(new FUICommandList);
PluginCommands->MapAction(
FAlpakitCommands::Get().OpenPluginWindow,
FExecuteAction::CreateLambda([](){
FGlobalTabmanager::Get()->InvokeTab(AlpakitTabName);
}),
FCanExecuteAction());
FLevelEditorModule& LevelEditorModule = FModuleManager::LoadModuleChecked<FLevelEditorModule>(TEXT("LevelEditor"));
//Register Alpakit Settings in Editor's Project Menu
TSharedPtr<FExtender> MenuExtender = MakeShareable(new FExtender());
MenuExtender->AddMenuExtension(TEXT("FileProject"), EExtensionHook::After, PluginCommands,
FMenuExtensionDelegate::CreateLambda([](FMenuBuilder& Builder){
Builder.AddMenuEntry(FAlpakitCommands::Get().OpenPluginWindow);
}));
LevelEditorModule.GetMenuExtensibilityManager()->AddExtender(MenuExtender);
//Register Alpakit Settings in Editor's Toolbar
TSharedPtr<FExtender> ToolbarExtender = MakeShareable(new FExtender);
ToolbarExtender->AddToolBarExtension(TEXT("Settings"), EExtensionHook::After, PluginCommands,
FToolBarExtensionDelegate::CreateLambda([](FToolBarBuilder& Builder) {
Builder.AddToolBarButton(FAlpakitCommands::Get().OpenPluginWindow);
}));
LevelEditorModule.GetToolBarExtensibilityManager()->AddExtender(ToolbarExtender);

//Register normal alpakit settings tab spawner
FGlobalTabmanager::Get()->RegisterNomadTabSpawner(AlpakitTabName,
FOnSpawnTab::CreateLambda([](const FSpawnTabArgs&){
const TSharedRef<SAlpakitWidget> AlpakitWidget = SNew(SAlpakitWidget);
return SNew(SDockTab)
.TabRole(NomadTab)
// TODO: Save settings when tab is closed automatically
//.OnTabClosed_Lambda([AlpakitWidget](TSharedRef<SDockTab>) { AlpakitWidget->SaveSettings(); })
[ AlpakitWidget ];
}))
.SetDisplayName(LOCTEXT("FAlpakitTabTitle", "Alpakit"))
.SetMenuType(ETabSpawnerMenuType::Hidden);
//Register normal alpakit settings tab spawner
FGlobalTabmanager::Get()->RegisterNomadTabSpawner(AlpakitTabName,
FOnSpawnTab::CreateLambda([](const FSpawnTabArgs&){
const TSharedRef<SAlpakitWidget> AlpakitWidget = SNew(SAlpakitWidget);
return SNew(SDockTab)
.TabRole(NomadTab)
// TODO: Save settings when tab is closed automatically
//.OnTabClosed_Lambda([AlpakitWidget](TSharedRef<SDockTab>) { AlpakitWidget->SaveSettings(); })
[ AlpakitWidget ];
}))
.SetDisplayName(LOCTEXT("FAlpakitTabTitle", "Alpakit"))
.SetMenuType(ETabSpawnerMenuType::Hidden);
}

void FAlpakitModule::ShutdownModule() {
if (UObjectInitialized()) {
UnregisterSettings();
}
FAlpakitStyle::Shutdown();
FAlpakitCommands::Unregister();
if (UObjectInitialized()) {
UnregisterSettings();
}
FAlpakitStyle::Shutdown();
FAlpakitCommands::Unregister();

FGlobalTabmanager::Get()->UnregisterNomadTabSpawner(AlpakitTabName);
FGlobalTabmanager::Get()->UnregisterNomadTabSpawner(AlpakitTabName);
}

void FAlpakitModule::RegisterSettings() const {
if (ISettingsModule* SettingsModule = FModuleManager::GetModulePtr<ISettingsModule>(TEXT("Settings"))) {
// Create the new category
ISettingsContainerPtr SettingsContainer = SettingsModule->GetContainer(TEXT("Project"));
SettingsContainer->DescribeCategory(TEXT("Alpakit Settings"),
LOCTEXT("RuntimeWDCategoryName", "Alpakit Settings"),
LOCTEXT("RuntimeWDCategoryDescription", "Alpakit Settings. Can also be edited in the Alpakit menu"));
if (ISettingsModule* SettingsModule = FModuleManager::GetModulePtr<ISettingsModule>(TEXT("Settings"))) {
// Create the new category
ISettingsContainerPtr SettingsContainer = SettingsModule->GetContainer(TEXT("Project"));
SettingsContainer->DescribeCategory(TEXT("Alpakit Settings"),
LOCTEXT("RuntimeWDCategoryName", "Alpakit Settings"),
LOCTEXT("RuntimeWDCategoryDescription", "Alpakit Settings. Can also be edited in the Alpakit menu"));

// Register the settings
ISettingsSectionPtr SettingsSection = SettingsModule->RegisterSettings(TEXT("Project"), TEXT("Alpakit"), TEXT("General"),
LOCTEXT("RuntimeGeneralSettingsName", "General"),
LOCTEXT("RuntimeGeneralSettingsDescription", "Alpakit Settings. Can also be edited in the Alpakit menu"),
UAlpakitSettings::Get()
);
// Register the save handler to your settings, you might want to use it to
// validate those or just act to settings changes.
if (SettingsSection.IsValid()) {
SettingsSection->OnModified().BindLambda([](){
UAlpakitSettings::Get()->SaveSettings();
return true;
});
}
}
// Register the settings
ISettingsSectionPtr SettingsSection = SettingsModule->RegisterSettings(TEXT("Project"), TEXT("Alpakit"), TEXT("General"),
LOCTEXT("RuntimeGeneralSettingsName", "General"),
LOCTEXT("RuntimeGeneralSettingsDescription", "Alpakit Settings. Can also be edited in the Alpakit menu"),
UAlpakitSettings::Get()
);
// Register the save handler to your settings, you might want to use it to
// validate those or just act to settings changes.
if (SettingsSection.IsValid()) {
SettingsSection->OnModified().BindLambda([](){
UAlpakitSettings::Get()->SaveSettings();
return true;
});
}
}
}

void FAlpakitModule::UnregisterSettings() const {
if (ISettingsModule* SettingsModule = FModuleManager::GetModulePtr<ISettingsModule>(TEXT("Settings"))) {
SettingsModule->UnregisterSettings(TEXT("Project"), TEXT("Alpakit"), TEXT("General"));
}
if (ISettingsModule* SettingsModule = FModuleManager::GetModulePtr<ISettingsModule>(TEXT("Settings"))) {
SettingsModule->UnregisterSettings(TEXT("Project"), TEXT("Alpakit"), TEXT("General"));
}
}

#undef LOCTEXT_NAMESPACE
IMPLEMENT_MODULE(FAlpakitModule, Alpakit)
10 changes: 5 additions & 5 deletions Plugins/Alpakit/Source/Alpakit/Private/AlpakitCommands.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,13 @@
#define LOCTEXT_NAMESPACE "FAlpakitModule"

FAlpakitCommands::FAlpakitCommands() : TCommands<FAlpakitCommands>(
TEXT("Alpakit"),
NSLOCTEXT("Contexts", "Alpakit", "Alpakit Plugin"),
NAME_None,
FAlpakitStyle::GetStyleSetName()) {}
TEXT("Alpakit"),
NSLOCTEXT("Contexts", "Alpakit", "Alpakit Plugin"),
NAME_None,
FAlpakitStyle::GetStyleSetName()) {}

void FAlpakitCommands::RegisterCommands() {
UI_COMMAND(OpenPluginWindow, "Alpakit", "Open the alpakit window", EUserInterfaceActionType::Button, FInputChord{});
UI_COMMAND(OpenPluginWindow, "Alpakit", "Open the alpakit window", EUserInterfaceActionType::Button, FInputChord{});
}

#undef LOCTEXT_NAMESPACE
Loading

0 comments on commit 87b5484

Please sign in to comment.