75 lines
1.7 KiB
C++
75 lines
1.7 KiB
C++
// Copyright Ralpha Team. All Rights Reserved.
|
|
|
|
#include "RalphaEditor.h"
|
|
#include "RalphaEditorCommands.h"
|
|
#include "RalphaEditorStyle.h"
|
|
#include "ToolMenus.h"
|
|
#include "RalphaMCPServer.h"
|
|
|
|
#define LOCTEXT_NAMESPACE "FRalphaEditorModule"
|
|
|
|
void FRalphaEditorModule::StartupModule()
|
|
{
|
|
FRalphaEditorStyle::Initialize();
|
|
FRalphaEditorStyle::ReloadTextures();
|
|
|
|
FRalphaEditorCommands::Register();
|
|
|
|
PluginCommands = MakeShareable(new FUICommandList);
|
|
|
|
PluginCommands->MapAction(
|
|
FRalphaEditorCommands::Get().StartServer,
|
|
FExecuteAction::CreateLambda([]()
|
|
{
|
|
URalphaMCPServer* Server = URalphaMCPServer::Get();
|
|
if (Server)
|
|
{
|
|
if (!Server->IsRunning())
|
|
{
|
|
Server->Start();
|
|
}
|
|
else
|
|
{
|
|
Server->Stop();
|
|
}
|
|
}
|
|
}),
|
|
FCanExecuteAction()
|
|
);
|
|
|
|
UToolMenus::RegisterStartupCallback(FSimpleMulticastDelegate::FDelegate::CreateRaw(this, &FRalphaEditorModule::RegisterMenus));
|
|
|
|
UE_LOG(LogTemp, Log, TEXT("Ralpha Editor Module Started"));
|
|
}
|
|
|
|
void FRalphaEditorModule::ShutdownModule()
|
|
{
|
|
UToolMenus::UnRegisterStartupCallback(this);
|
|
UToolMenus::UnregisterOwner(this);
|
|
|
|
FRalphaEditorStyle::Shutdown();
|
|
FRalphaEditorCommands::Unregister();
|
|
|
|
UE_LOG(LogTemp, Log, TEXT("Ralpha Editor Module Shutdown"));
|
|
}
|
|
|
|
void FRalphaEditorModule::RegisterMenus()
|
|
{
|
|
FToolMenuOwnerScoped OwnerScoped(this);
|
|
|
|
{
|
|
UToolMenu* ToolbarMenu = UToolMenus::Get()->ExtendMenu("LevelEditor.LevelEditorToolBar.PlayToolBar");
|
|
{
|
|
FToolMenuSection& Section = ToolbarMenu->FindOrAddSection("Ralpha");
|
|
{
|
|
FToolMenuEntry& Entry = Section.AddEntry(FToolMenuEntry::InitToolBarButton(FRalphaEditorCommands::Get().StartServer));
|
|
Entry.SetCommandList(PluginCommands);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
#undef LOCTEXT_NAMESPACE
|
|
|
|
IMPLEMENT_MODULE(FRalphaEditorModule, RalphaEditor)
|