// 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)); // Auto-start the MCP server URalphaMCPServer* Server = URalphaMCPServer::Get(); if (Server && !Server->IsRunning()) { Server->Start(); UE_LOG(LogTemp, Log, TEXT("Ralpha MCP Server auto-started on port 30010")); } 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)