Polyphase Game Engine
Loading...
Searching...
No Matches
EditorUIHooks.h
Go to the documentation of this file.
1#pragma once
2
14#if EDITOR
15
16#include <stddef.h>
17#include <stdint.h>
18
19// ===== Callback Types =====
20
25typedef void (*MenuCallback)(void* userData);
26
31typedef void (*WindowDrawCallback)(void* userData);
32
38typedef void (*InspectorDrawCallback)(void* node, void* userData);
39
44typedef void (*EventCallback)(void* userData);
45
51typedef void (*StringEventCallback)(const char* str, void* userData);
52
58typedef void (*PlatformEventCallback)(int32_t platform, void* userData);
59
66typedef void (*PackageFinishedCallback)(int32_t platform, bool success, void* userData);
67
73typedef void (*PlayModeCallback)(int32_t state, void* userData);
74
81typedef void (*TopLevelMenuDrawCallback)(void* userData);
82
89typedef void (*ToolbarDrawCallback)(void* userData);
90
96typedef bool (*MenuValidationCallback)(void* userData);
97
103typedef void (*MenuSectionDrawCallback)(void* parentNode, void* userData);
104
113typedef void (*ViewportOverlayCallback)(float viewportX, float viewportY, float viewportW, float viewportH, void* userData);
114
119typedef void (*PreferencesPanelDrawCallback)(void* userData);
120
125typedef void (*PreferencesLoadCallback)(void* userData);
126typedef void (*PreferencesSaveCallback)(void* userData);
127
132typedef void (*ShortcutCallback)(void* userData);
133
142typedef bool (*PropertyDrawCallback)(const char* propertyName, void* propertyOwner, int32_t propertyType, void* userData);
143
153typedef void (*HierarchyItemGUICallback)(void* node, float rowX, float rowY, float rowW, float rowH, void* userData);
154
165typedef void (*AssetItemGUICallback)(const char* assetName, const char* assetType, float rowX, float rowY, float rowW, float rowH, void* userData);
166
173typedef void (*HierarchyChangedCallback)(int32_t changeType, void* node, void* userData);
174
183typedef bool (*DragDropHandlerCallback)(const char* payloadType, const void* payloadData, int32_t payloadSize, void* userData);
184
192typedef bool (*AssetImportCallback)(const char* filePath, const char* extension, void* userData);
193
200typedef bool (*PreImportCallback)(const char* filePath, void* userData);
201
208typedef bool (*PreBuildCallback)(int32_t platform, void* userData);
209
215typedef void (*EditorModeCallback)(int32_t newMode, void* userData);
216
222typedef void (*GizmoToolDrawCallback)(void* selectedNode, void* userData);
223
228typedef void (*PlayTargetCallback)(void* userData);
229
240typedef void (*SceneCreationCallback)(const char* sceneName, void* rootNode, void* userData);
241
242// ===== Controller Server Hooks =====
243
253typedef void (*ControllerRouteCallback)(const char* method, const char* path, const char* body, char* responseBuffer, int32_t bufferSize, void* userData);
254
260typedef void (*ControllerServerEventCallback)(int32_t state, void* userData);
261
270typedef void (*TargetOptionsDrawCallback)(const struct PolyphaseBuildContext* ctx, void* userData);
271
278typedef bool (*ModalDrawCallback)(void* userData);
279// EditorUIHooks has OpenModal / CloseModal / IsModalOpen (addons that also build against
280// older engines test this before using them)
281#define POLYPHASE_EDITOR_HOOKS_HAS_MODALS 1
282
289typedef uint64_t HookId;
290
297struct EditorUIHooks
298{
299 // ===== Menu Extensions =====
300
311 void (*AddMenuItem)(
312 HookId hookId,
313 const char* menuPath,
314 const char* itemPath,
315 MenuCallback callback,
316 void* userData,
317 const char* shortcut
318 );
319
326 void (*AddMenuSeparator)(HookId hookId, const char* menuPath);
327
335 void (*RemoveMenuItem)(HookId hookId, const char* menuPath, const char* itemPath);
336
337 // ===== Custom Windows =====
338
348 void (*RegisterWindow)(
349 HookId hookId,
350 const char* windowName,
351 const char* windowId,
352 WindowDrawCallback drawFunc,
353 void* userData
354 );
355
362 void (*UnregisterWindow)(HookId hookId, const char* windowId);
363
368 void (*OpenWindow)(const char* windowId);
369
374 void (*CloseWindow)(const char* windowId);
375
381 bool (*IsWindowOpen)(const char* windowId);
382
383 // ===== Inspector Extensions =====
384
393 void (*RegisterInspector)(
394 HookId hookId,
395 const char* nodeTypeName,
396 InspectorDrawCallback drawFunc,
397 void* userData
398 );
399
406 void (*UnregisterInspector)(HookId hookId, const char* nodeTypeName);
407
408 // ===== Context Menu Extensions =====
409
418 void (*AddNodeContextItem)(
419 HookId hookId,
420 const char* itemPath,
421 MenuCallback callback,
422 void* userData
423 );
424
434 void (*AddAssetContextItem)(
435 HookId hookId,
436 const char* itemPath,
437 const char* assetTypeFilter,
438 MenuCallback callback,
439 void* userData
440 );
441
442 // ===== Top-Level Menus =====
443
455 void (*AddTopLevelMenuItem)(HookId hookId, const char* menuName,
456 TopLevelMenuDrawCallback drawFunc, void* userData);
457
463 void (*RemoveTopLevelMenuItem)(HookId hookId, const char* menuName);
464
465 // ===== Toolbar =====
466
474 void (*AddToolbarItem)(HookId hookId, const char* itemName,
475 ToolbarDrawCallback drawFunc, void* userData);
476
482 void (*RemoveToolbarItem)(HookId hookId, const char* itemName);
483
484 // ===== Project Lifecycle Events =====
485
487 void (*RegisterOnProjectOpen)(HookId hookId, StringEventCallback cb, void* userData);
488
490 void (*RegisterOnProjectClose)(HookId hookId, StringEventCallback cb, void* userData);
491
493 void (*RegisterOnProjectSave)(HookId hookId, StringEventCallback cb, void* userData);
494
495 // ===== Scene Lifecycle Events =====
496
498 void (*RegisterOnSceneOpen)(HookId hookId, StringEventCallback cb, void* userData);
499
501 void (*RegisterOnSceneClose)(HookId hookId, StringEventCallback cb, void* userData);
502
503 // ===== Packaging/Build Events =====
504
506 void (*RegisterOnPackageStarted)(HookId hookId, PlatformEventCallback cb, void* userData);
507
509 void (*RegisterOnPackageFinished)(HookId hookId, PackageFinishedCallback cb, void* userData);
510
511 // ===== Editor State Events =====
512
514 void (*RegisterOnSelectionChanged)(HookId hookId, EventCallback cb, void* userData);
515
517 void (*RegisterOnPlayModeChanged)(HookId hookId, PlayModeCallback cb, void* userData);
518
520 void (*RegisterOnEditorShutdown)(HookId hookId, EventCallback cb, void* userData);
521
522 // ===== Asset Pipeline Events =====
523
525 void (*RegisterOnAssetImported)(HookId hookId, StringEventCallback cb, void* userData);
526
528 void (*RegisterOnAssetDeleted)(HookId hookId, StringEventCallback cb, void* userData);
529
531 void (*RegisterOnAssetSaved)(HookId hookId, StringEventCallback cb, void* userData);
532
533 // ===== Asset Open Events =====
534
536 void (*RegisterOnAssetOpen)(HookId hookId, StringEventCallback cb, void* userData);
537
539 void (*RegisterOnAssetOpened)(HookId hookId, StringEventCallback cb, void* userData);
540
541 // ===== Undo/Redo =====
542
544 void (*RegisterOnUndoRedo)(HookId hookId, EventCallback cb, void* userData);
545
546 // ===== Drag-and-Drop Events =====
547
549 void (*RegisterOnAssetDropHierarchy)(HookId hookId, StringEventCallback cb, void* userData);
550
552 void (*RegisterOnAssetDropViewport)(HookId hookId, StringEventCallback cb, void* userData);
553
554 // ===== Batch 1: Menu Positioning & Top-Level Menu Control =====
555
564 void (*AddTopLevelMenuItemEx)(
565 HookId hookId,
566 const char* menuName,
567 TopLevelMenuDrawCallback drawFunc,
568 void* userData,
569 int32_t position
570 );
571
582 void (*AddMenuItemEx)(
583 HookId hookId,
584 const char* menuPath,
585 const char* itemPath,
586 MenuCallback callback,
587 void* userData,
588 const char* shortcut,
589 MenuValidationCallback validateFunc
590 );
591
592 // ===== Batch 2: Create/Spawn Menu Extensions =====
593
601 void (*AddNodeMenuItems)(HookId hookId, const char* category, MenuSectionDrawCallback drawFunc, void* userData);
602
604 void (*RemoveNodeMenuItems)(HookId hookId, const char* category);
605
612 void (*AddCreateAssetItems)(HookId hookId, MenuSectionDrawCallback drawFunc, void* userData);
613
615 void (*RemoveCreateAssetItems)(HookId hookId);
616
623 void (*AddSpawnBasic3dItems)(HookId hookId, MenuSectionDrawCallback drawFunc, void* userData);
624
631 void (*AddSpawnBasicWidgetItems)(HookId hookId, MenuSectionDrawCallback drawFunc, void* userData);
632
633 // ===== Scene Type Registration =====
634
646 void (*RegisterSceneType)(HookId hookId, const char* typeName, SceneCreationCallback createFunc, void* userData);
647
649 void (*UnregisterSceneType)(HookId hookId, const char* typeName);
650
651 // ===== Batch 3: Viewport Context Menu & Overlay Drawing =====
652
660 void (*AddViewportContextItem)(HookId hookId, const char* itemPath, MenuCallback callback, void* userData);
661
663 void (*RemoveViewportContextItem)(HookId hookId, const char* itemPath);
664
672 void (*RegisterViewportOverlay)(HookId hookId, const char* overlayName, ViewportOverlayCallback drawFunc, void* userData);
673
675 void (*UnregisterViewportOverlay)(HookId hookId, const char* overlayName);
676
677 // ===== Batch 4: Custom Preferences/Settings Pages =====
678
689 void (*RegisterPreferencesPanel)(
690 HookId hookId,
691 const char* panelName,
692 const char* panelCategory,
693 PreferencesPanelDrawCallback drawFunc,
694 PreferencesLoadCallback loadFunc,
695 PreferencesSaveCallback saveFunc,
696 void* userData
697 );
698
700 void (*UnregisterPreferencesPanel)(HookId hookId, const char* panelName);
701
702 // ===== Batch 5: Custom Keyboard Shortcuts =====
703
713 void (*RegisterShortcut)(
714 HookId hookId,
715 const char* shortcutId,
716 const char* displayName,
717 const char* defaultBinding,
718 ShortcutCallback callback,
719 void* userData
720 );
721
723 void (*UnregisterShortcut)(HookId hookId, const char* shortcutId);
724
725 // ===== Batch 6: Property Drawer System =====
726
734 void (*RegisterPropertyDrawer)(HookId hookId, const char* propertyTypeName, PropertyDrawCallback drawFunc, void* userData);
735
737 void (*UnregisterPropertyDrawer)(HookId hookId, const char* propertyTypeName);
738
739 // ===== Batch 7: Hierarchy & Asset Browser Extensions =====
740
745 void (*RegisterHierarchyItemGUI)(HookId hookId, HierarchyItemGUICallback drawFunc, void* userData);
746
748 void (*UnregisterHierarchyItemGUI)(HookId hookId);
749
754 void (*RegisterAssetItemGUI)(HookId hookId, AssetItemGUICallback drawFunc, void* userData);
755
757 void (*UnregisterAssetItemGUI)(HookId hookId);
758
763 void (*RegisterOnHierarchyChanged)(HookId hookId, HierarchyChangedCallback cb, void* userData);
764
765 // ===== Batch 8: Additional Context Menus =====
766
768 void (*AddSceneTabContextItem)(HookId hookId, const char* itemPath, MenuCallback callback, void* userData);
769
771 void (*AddDebugLogContextItem)(HookId hookId, const char* itemPath, MenuCallback callback, void* userData);
772
774 void (*AddImportMenuItem)(HookId hookId, const char* itemPath, MenuCallback callback, void* userData);
775
777 void (*AddAddonsMenuItem)(HookId hookId, const char* itemPath, MenuCallback callback, void* userData);
778
787 void (*AddPlayTarget)(HookId hookId, const char* targetName, const char* iconText, PlayTargetCallback callback, void* userData);
788
790 void (*RemovePlayTarget)(HookId hookId, const char* targetName);
791
792 // ===== Batch 9: Drag-Drop Enhancement & Asset Pipeline =====
793
801 void (*RegisterDragDropHandler)(HookId hookId, const char* targetArea, DragDropHandlerCallback handler, void* userData);
802
810 void (*RegisterAssetImporter)(HookId hookId, const char* extension, AssetImportCallback importFunc, void* userData);
811
813 void (*UnregisterAssetImporter)(HookId hookId, const char* extension);
814
816 void (*RegisterOnPreAssetImport)(HookId hookId, PreImportCallback cb, void* userData);
817
819 void (*RegisterOnPostAssetImport)(HookId hookId, StringEventCallback cb, void* userData);
820
821 // ===== Batch 10: Build Pipeline & Editor State =====
822
824 void (*RegisterOnPreBuild)(HookId hookId, PreBuildCallback cb, void* userData);
825
827 void (*RegisterOnPostBuild)(HookId hookId, PackageFinishedCallback cb, void* userData);
828
830 void (*RegisterOnEditorModeChanged)(HookId hookId, EditorModeCallback cb, void* userData);
831
841 void (*RegisterGizmoTool)(
842 HookId hookId,
843 const char* toolName,
844 const char* iconText,
845 const char* tooltip,
846 GizmoToolDrawCallback drawFunc,
847 void* userData
848 );
849
851 void (*UnregisterGizmoTool)(HookId hookId, const char* toolName);
852
853 // ===== Game Preview Resolution Presets =====
854
862 void (*AddGamePreviewResolution)(HookId hookId, const char* name, uint32_t width, uint32_t height);
863
869 void (*RemoveGamePreviewResolution)(HookId hookId, const char* name);
870
871 // ===== Controller Server Extension =====
872
881 void (*RegisterControllerRoute)(HookId hookId, const char* method, const char* path, ControllerRouteCallback callback, void* userData);
882
888 void (*UnregisterControllerRoute)(HookId hookId, const char* path);
889
896 void (*RegisterOnControllerServerStateChanged)(HookId hookId, ControllerServerEventCallback callback, void* userData);
897
898 // ===== Profiling Window Extension =====
899
908 void (*RegisterProfilingStat)(HookId hookId, const char* statName, const char* category, float maxValue, bool showAsBar);
909
915 void (*UnregisterProfilingStat)(HookId hookId, const char* statName);
916
923 void (*SetProfilingStatValue)(const char* statName, float value);
924
929 typedef void (*ProfilingSectionDrawCallback)(void* userData);
930
939 void (*RegisterProfilingSection)(HookId hookId, const char* sectionName, void (*drawFunc)(void*), void* userData);
940
946 void (*UnregisterProfilingSection)(HookId hookId, const char* sectionName);
947
948 // ===== Cleanup =====
949
957 void (*RemoveAllHooks)(HookId hookId);
958
959 // ===== Late additions (appended to preserve ABI) ====================
960 //
961 // New function pointers must go AT THE END of this struct so prebuilt
962 // plugins compiled against older headers keep finding existing hooks
963 // at their original offsets. Plugin loaders must check each function
964 // pointer for nullptr before calling it — older engine binaries will
965 // leave fields they don't know about as nullptr.
966
991 void (*AddCreateAssetItem)(HookId hookId, const char* itemPath,
992 MenuCallback callback, void* userData);
993
994 // ===== Batch 11: Build Targets =====
995 //
996 // Lets an addon register an entire build/packaging target — compile,
997 // cook, finalize, run. See PolyphaseBuildTargetAPI.h for the descriptor
998 // shape. The descriptor is deep-copied; the addon may free its source
999 // strings immediately after this returns. The registration is scoped to
1000 // hookId and is automatically cleared by RemoveAllHooks(hookId), so
1001 // hot-reload is safe.
1002 //
1003 // Registering twice with the same targetId replaces the previous entry;
1004 // this is what makes addon hot-reload swap in fresh function pointers
1005 // without leaving stale ones in the registry.
1006
1008 void (*RegisterBuildTarget)(HookId hookId, const struct PolyphaseBuildTargetDesc* desc);
1009
1011 void (*UnregisterBuildTarget)(HookId hookId, const char* targetId);
1012
1013 // ===== Batch 12: Viewport input polling for addons =====
1014 //
1015 // Poll-style helpers for tools (e.g. Level Builder) that want to react
1016 // to mouse hover and clicks inside the 3D viewport. There is no HookId
1017 // because nothing is allocated — old engines simply leave these fields
1018 // null and addons must null-check before calling.
1019 //
1020 // Both calls are intended to be invoked from inside a
1021 // RegisterViewportOverlay callback (which fires mid-frame with the
1022 // viewport rect already laid out).
1023 //
1024 // Screen coordinates are unscaled ImGui pixels (i.e. ImGui::GetIO().MousePos);
1025 // the implementation multiplies by EngineConfig::mEditorInterfaceScale
1026 // internally to match Renderer pixel space.
1027
1047 bool (*Viewport_RaycastUnderMouse)(float screenX, float screenY,
1048 float fallbackPlaneY,
1049 float* outHitX, float* outHitY, float* outHitZ,
1050 float* outNormalX, float* outNormalY, float* outNormalZ,
1051 void** outHitNode);
1052
1062 void (*Viewport_GetMouseState)(float* outViewportX, float* outViewportY,
1063 float* outViewportW, float* outViewportH,
1064 float* outMouseX, float* outMouseY,
1065 int* outHovered, int* outLeftClicked,
1066 int* outLeftDown, int* outRightClicked);
1067
1068 // ===== Batch 13: Selection control (additive — safe for older addons) =====
1069
1086 void (*Viewport_SuppressNextSelectionClick)();
1087
1098 void (*Selection_Clear)();
1099
1100 // ===== Batch 14: File dialogs + OS file-drop dispatch ==================
1101 //
1102 // Thin wrappers over the existing SYS_OpenFileDialog / SYS_SaveFileDialog
1103 // / SYS_SelectFolderDialog calls + the SYS_DrainDroppedFiles polling
1104 // mechanism, exposed so plugins (Level Builder share UI, asset importers,
1105 // settings panels) don't have to vendor their own platform code.
1106 //
1107 // All dialogs are SYNCHRONOUS — the call blocks until the user picks or
1108 // cancels. UI threads call them from a button click; no callback needed.
1109 // The file-drop hook IS callback-based since drops can land any frame.
1110
1126 int (*ShowOpenFileDialog)(const char* title,
1127 const char* filter,
1128 const char* initialDir,
1129 char* outPath, int outPathSize);
1130
1142 int (*ShowSaveFileDialog)(const char* title,
1143 const char* filter,
1144 const char* defaultName,
1145 char* outPath, int outPathSize);
1146
1156 int (*ShowSelectFolderDialog)(const char* title,
1157 char* outPath, int outPathSize);
1158
1171 typedef bool (*FileDropCallback)(int count, const char** paths, void* userData);
1172 void (*RegisterFileDropHandler)(HookId hookId, FileDropCallback cb, void* userData);
1173 void (*UnregisterFileDropHandler)(HookId hookId);
1174
1175 // ===== Batch 15: Viewport Mode dropdown ============================
1176 //
1177 // Lets a native addon contribute a new entry to the top-of-editor mode
1178 // dropdown (Scene / 2D / 3D / Paint Colors / Paint Instances / Voxel /
1179 // Terrain / Tile Paint). When the user picks an addon mode the editor:
1180 // - switches EditorMode to Scene3D (and clears any built-in PaintMode)
1181 // - records the active addon mode id on EditorState
1182 // - fires OnActivate(userData)
1183 // Switching to a built-in entry (or another addon entry) fires
1184 // OnDeactivate(userData) on the previously-active addon mode first.
1185 //
1186 // While the addon mode is active the engine calls:
1187 // - Tick(deltaTime, userData) every frame inside the viewport update
1188 // - DrawPanel(userData) every frame in the mode-properties strip
1189 //
1190 // Hot-reload safety: re-registering with the same modeId replaces the
1191 // entry's callbacks (so a freshly reloaded DLL's function pointers
1192 // overwrite the stale ones). RemoveAllHooks(hookId) deactivates the
1193 // mode first if it's currently active, then erases the registration.
1194 //
1195 // All callbacks are optional — pass nullptr to skip. CanActivate is a
1196 // gating check: if it returns false the dropdown entry greys out and
1197 // the editor refuses to switch into the mode. Null CanActivate = always
1198 // available.
1199
1204 typedef bool (*ViewportModeCanActivateCallback)(void* userData);
1205
1207 typedef void (*ViewportModeActivateCallback)(void* userData);
1208
1210 typedef void (*ViewportModeDeactivateCallback)(void* userData);
1211
1213 typedef void (*ViewportModeTickCallback)(float deltaTime, void* userData);
1214
1216 typedef void (*ViewportModeDrawPanelCallback)(void* userData);
1217
1234 void (*AddViewportMode)(
1235 HookId hookId,
1236 const char* modeId,
1237 const char* displayName,
1238 int32_t sortOrder,
1239 ViewportModeCanActivateCallback canActivate,
1240 ViewportModeActivateCallback onActivate,
1241 ViewportModeDeactivateCallback onDeactivate,
1242 ViewportModeTickCallback tick,
1243 ViewportModeDrawPanelCallback drawPanel,
1244 void* userData
1245 );
1246
1254 void (*RemoveViewportMode)(HookId hookId, const char* modeId);
1255
1264 int (*GetActiveViewportMode)(char* outBuffer, int outBufferSize);
1265
1266 // ===== Batch 15 / v8: viewport math for plugin gizmos ==================
1267 //
1268 // Mouse → world ray. `mx`/`my` are window-space pixels (same units
1269 // Viewport_GetMouseState returns). `outOrigin` is the ray's starting
1270 // point in world space; `outDir` is the normalized direction.
1271 //
1272 // Used by plugins that need to roll their own scene intersection —
1273 // axis-constrained transform gizmos, arbitrary plane intersection,
1274 // line-to-line distance for rotation rings, etc. The simpler
1275 // Viewport_RaycastUnderMouse stays for the common "give me the
1276 // hit point on the scene OR a fallback Y plane" case.
1277 void (*Viewport_GetMouseWorldRay)(float mx, float my,
1278 float* outOriginX,
1279 float* outOriginY,
1280 float* outOriginZ,
1281 float* outDirX,
1282 float* outDirY,
1283 float* outDirZ);
1284
1285 // World → editor-viewport screen pixels. Returns 1 if the point
1286 // projects in front of the camera (sx/sy are usable window-space
1287 // coords); returns 0 if behind (sx/sy still filled but the caller
1288 // probably wants to skip drawing). The output coordinate system
1289 // matches Viewport_GetMouseState — i.e. the same window-space
1290 // pixels you'd hover-test against.
1291 //
1292 // Used by plugins that want to overlay ImGui labels / billboards
1293 // on top of scene objects (e.g. "Socket: Left" text floating
1294 // over the socket gizmo).
1295 int (*Viewport_WorldToScreen)(float wx, float wy, float wz,
1296 float* outSx, float* outSy);
1297
1298 // ===== Batch 16 / v9: shared editor image (thumbnail) cache ===========
1299 //
1300 // A path-keyed image -> ImGui-texture cache owned by the EDITOR, not by
1301 // the addon. This exists because the engine's Vulkan types (class Image,
1302 // class DestroyQueue, DeviceWaitIdle, GetDestroyQueue) carry no
1303 // POLYPHASE_API annotation and so are absent from Polyphase.lib — an addon
1304 // that rolls its own loader gets LNK2019 on every one of them. Rather than
1305 // exporting Vulkan internals, the engine does the decode and the upload
1306 // and hands back an opaque handle.
1307 //
1308 // The handle is `void*` and is bit-identical to ImTextureID; cast it:
1309 //
1310 // ImTextureID tex = (ImTextureID)hooks->EditorImage_Load(absPath);
1311 // if (tex != 0) ImGui::Image(tex, ImVec2(96, 96));
1312 //
1313 // Backend: Vulkan only. On other editor backends these return nullptr / 0
1314 // and callers should fall back to a text placeholder — which they already
1315 // do for the "file missing" case.
1316 //
1317 // OWNERSHIP — read this before wiring an addon:
1318 // The engine owns every texture for the whole editor session. There is
1319 // deliberately NO per-addon and NO per-HookId release entry point, and
1320 // RemoveAllHooks(hookId) does NOT drop images this addon loaded.
1321 // Reasons: (a) descriptor-set removal is immediate, not deferred through
1322 // the engine's DestroyQueue, and addon unload happens mid-frame, so an
1323 // unload-time release would free a descriptor the current ImGui draw
1324 // list still points at; (b) sibling addons routinely resolve the SAME
1325 // absolute path (shared kit icons), so a per-owner release would blank
1326 // another addon's UI. Hold nothing across frames — call
1327 // EditorImage_Load every frame; the lookup is a hash-map hit.
1328
1341 void* (*EditorImage_Load)(const char* absPath);
1342
1353 int (*EditorImage_GetSize)(const char* absPath, int* outWidth, int* outHeight);
1354
1366 void (*EditorImage_Invalidate)(const char* absPath);
1367
1368 // ===== Build profile options for any target =====
1369 //
1370 // DrawProfileOptions (PolyphaseBuildTargetAPI.h) only exists for targets an
1371 // addon registers itself. These let an addon add settings to every target's
1372 // profile, e.g. a step its OnPreBuild hook runs for the built-in Windows/Wii
1373 // targets. Values live in the profile's per-target options map (same JSON),
1374 // so prefix keys with the addon name ("myaddon.someOption").
1375
1383 void (*AddTargetOptions)(HookId hookId, const char* sectionName,
1384 TargetOptionsDrawCallback drawFunc, void* userData);
1385
1387 void (*RemoveTargetOptions)(HookId hookId, const char* sectionName);
1388
1397 int32_t (*GetBuildSetting)(const char* key, char* outVal, size_t cap);
1398
1399 // ===== Modal dialogs =====
1400
1409 void (*OpenModal)(HookId hookId, const char* title, ModalDrawCallback drawFunc, void* userData);
1410
1412 void (*CloseModal)(HookId hookId, const char* title);
1413
1415 bool (*IsModalOpen)(HookId hookId, const char* title);
1416};
1417
1427HookId GenerateHookId(const char* identifier);
1428
1429#endif // EDITOR