Skip to content

Commit b19fb06

Browse files
authored
feat: add re-build and codegen menu items (#8)
1 parent 3e5e2f6 commit b19fb06

File tree

2 files changed

+46
-0
lines changed

2 files changed

+46
-0
lines changed

Source/EcsactEditor/Private/EcsactEditor.cpp

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,15 @@
55
#include "ISettingsModule.h"
66
#include "ISettingsSection.h"
77
#include "ISettingsContainer.h"
8+
#include "LevelEditor.h"
89
#include "HAL/PlatformFileManager.h"
910
#include "HAL/FileManagerGeneric.h"
1011
#include "FileHelpers.h"
1112
#include "DirectoryWatcherModule.h"
1213
#include "IDirectoryWatcher.h"
1314
#include "Json.h"
15+
#include "Framework/MultiBox/MultiBoxBuilder.h"
16+
#include "Framework/MultiBox/MultiBoxExtender.h"
1417
#include "EcsactSettings.h"
1518

1619
#define LOCTEXT_NAMESPACE "FEcsactEditorModule"
@@ -127,6 +130,18 @@ auto FEcsactEditorModule::StartupModule() -> void {
127130
&FEcsactEditorModule::OnEcsactSettingsModified
128131
);
129132

133+
auto& level_editor_module =
134+
FModuleManager::LoadModuleChecked<FLevelEditorModule>("LevelEditor");
135+
TSharedPtr<FExtender> menu_extender = MakeShareable(new FExtender());
136+
menu_extender->AddMenuExtension(
137+
"Tools",
138+
EExtensionHook::After,
139+
nullptr,
140+
FMenuExtensionDelegate::CreateRaw(this, &FEcsactEditorModule::AddMenuEntry)
141+
);
142+
143+
level_editor_module.GetMenuExtensibilityManager()->AddExtender(menu_extender);
144+
130145
auto* watcher = GetDirectoryWatcher();
131146
watcher->RegisterDirectoryChangedCallback_Handle(
132147
SourceDir(),
@@ -155,6 +170,36 @@ auto FEcsactEditorModule::ShutdownModule() -> void {
155170
FEditorDelegates::OnEditorInitialized.RemoveAll(this);
156171
}
157172

173+
auto FEcsactEditorModule::AddMenuEntry(FMenuBuilder& MenuBuilder) -> void {
174+
MenuBuilder.BeginSection(
175+
"EcsactTools",
176+
LOCTEXT("EcsactToolsSectionTitle", "Ecsact")
177+
);
178+
{
179+
MenuBuilder.AddMenuEntry(
180+
LOCTEXT("EcsactRunCodegen", "Re-run codegen"),
181+
LOCTEXT(
182+
"EcsactRunCodegenTooltip",
183+
"Re-runs the ecsact codegen. This usually happens automatically and is "
184+
"not necessary to run manually from the menu."
185+
),
186+
FSlateIcon(),
187+
FUIAction(FExecuteAction::CreateLambda([this] { RunCodegen(); }))
188+
);
189+
MenuBuilder.AddMenuEntry(
190+
LOCTEXT("EcsactRebuild", "Rebuild runtime"),
191+
LOCTEXT(
192+
"EcsactRebuildTooltip",
193+
"Rebuild the Ecsact runtime. This usually happens automatically and is "
194+
"not necessary to run manually from the menu."
195+
),
196+
FSlateIcon(),
197+
FUIAction(FExecuteAction::CreateLambda([this] { RunBuild(); }))
198+
);
199+
}
200+
MenuBuilder.EndSection();
201+
}
202+
158203
auto FEcsactEditorModule::OnProjectSourcesChanged(
159204
const TArray<FFileChangeData>& FileChanges
160205
) -> void {

Source/EcsactEditor/Public/EcsactEditor.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ class FEcsactEditorModule : public IModuleInterface {
1919
const TArray<struct FFileChangeData>& FileChanges
2020
) -> void;
2121
auto OnReceiveEcsactCliJsonMessage(FString Json) -> void;
22+
auto AddMenuEntry(class FMenuBuilder& MenuBuilder) -> void;
2223

2324
public:
2425
auto SpawnEcsactCli( //

0 commit comments

Comments
 (0)