diff --git a/Aetheria.Rts.Web/Client/aetheria-rts-contract.ts b/Aetheria.Rts.Web/Client/aetheria-rts-contract.ts index 136fa2185..f7ee623ed 100644 --- a/Aetheria.Rts.Web/Client/aetheria-rts-contract.ts +++ b/Aetheria.Rts.Web/Client/aetheria-rts-contract.ts @@ -10,46 +10,6 @@ import type { export type Viewport = CultMeshViewportRequest; -export type AetheriaMenuSurfaceRequest = { - surfaceId?: string; - inGame?: boolean; - canOpenRuntimeInputScreen?: boolean; -}; - -export type AetheriaMenuSurfaceDocument = { - providerId: string; - providerKind: string; - title: string; - version: number; - updatedAtUtc: string; - surface: AetheriaMenuSurfaceTree; - commands: AetheriaMenuSurfaceCommand[]; -}; - -export type AetheriaMenuSurfaceTree = { - id: string; - root: AetheriaMenuSurfaceComponent; - styles: AetheriaMenuStyleToken[]; -}; - -export type AetheriaMenuSurfaceComponent = { - id: string; - kind: string; - props: Record; - children: AetheriaMenuSurfaceComponent[]; -}; - -export type AetheriaMenuStyleToken = { - name: string; - value: string; -}; - -export type AetheriaMenuSurfaceCommand = { - command: string; - label: string; - transport: string; -}; - export type AetheriaRuntimeSetMoveVectorRequest = { actorEntityKey: string; directionX: number; @@ -327,9 +287,50 @@ export type BodyView = { y: number; radius: number; isAsteroidBelt: boolean; + iconAsset: AssetRef; }; +export type AetheriaMenuSurfaceRequest = { + surfaceId?: string; + inGame?: boolean; + canOpenRuntimeInputScreen?: boolean; +}; + +export type AetheriaMenuSurfaceDocument = { + providerId: string; + providerKind: string; + title: string; + version: number; + updatedAtUtc: string; + surface: AetheriaMenuSurfaceTree; + commands: AetheriaMenuSurfaceCommand[]; +}; + +export type AetheriaMenuSurfaceTree = { + id: string; + root: AetheriaMenuSurfaceComponent; + styles: AetheriaMenuStyleToken[]; +}; + +export type AetheriaMenuSurfaceComponent = { + id: string; + kind: string; + props: Record; + children: AetheriaMenuSurfaceComponent[]; +}; + +export type AetheriaMenuStyleToken = { + name: string; + value: string; +}; + +export type AetheriaMenuSurfaceCommand = { + command: string; + label: string; + transport: string; +}; + export type AetheriaRtsApi = { mapViewport(request: Viewport): Promise; objectsViewport(request: Viewport): Promise; diff --git a/Aetheria.Rts.Web/Electron/aetheria-rts-generated-bindings.ts b/Aetheria.Rts.Web/Electron/aetheria-rts-generated-bindings.ts index 610a19b9f..08fbf22d3 100644 --- a/Aetheria.Rts.Web/Electron/aetheria-rts-generated-bindings.ts +++ b/Aetheria.Rts.Web/Electron/aetheria-rts-generated-bindings.ts @@ -116,6 +116,12 @@ export const AetheriaRtsIpcChannels = { setTarget: "aetheria-rts:set-target", surfaceCatalog: "aetheria-rts:surface-catalog", surfaceCatalogIndex: "aetheria-rts:surface-catalog-index", + mainMenuSurface: "aetheria-rts:main-menu-surface", + debugSurface: "aetheria-rts:debug-surface", + debugSurfaceWatch: "aetheria-rts:debug-surface-watch", + debugSurfaceWatchStop: "aetheria-rts:debug-surface-watch-stop", + debugSurfaceChanged: "aetheria-rts:debug-surface-changed", + windowControl: "aetheria-rts:window-control", health: "aetheria-rts:health", } as const; @@ -1193,7 +1199,8 @@ export type AetheriaRuntimeRtsBodyViewSlot = | "y" | "radius" | "isAsteroidBelt" - | "body"; + | "body" + | "iconAsset"; export const aetheriaRuntimeRtsBodyViewSlots: Record = { bodyKey: 0, @@ -1205,6 +1212,7 @@ export const aetheriaRuntimeRtsBodyViewSlots: Record 0 diff --git a/Aetheria.Rts.Web/Electron/preload.cjs b/Aetheria.Rts.Web/Electron/preload.cjs index 0bf445335..f93b959e0 100644 --- a/Aetheria.Rts.Web/Electron/preload.cjs +++ b/Aetheria.Rts.Web/Electron/preload.cjs @@ -73,6 +73,6 @@ contextBridge.exposeInMainWorld("aetheriaRts", { void ipcRenderer.invoke(channels.debugSurfaceWatchStop, subscriptionId); }; }, - windowControl: action => ipcRenderer.invoke(channels.windowControl, action), + windowControl: request => ipcRenderer.invoke(channels.windowControl, request), health: () => ipcRenderer.invoke(channels.health), }); diff --git a/Aetheria.Rts.Web/scripts/generate-rts-bindings.mjs b/Aetheria.Rts.Web/scripts/generate-rts-bindings.mjs index 24f6eb727..7f8a86408 100644 --- a/Aetheria.Rts.Web/scripts/generate-rts-bindings.mjs +++ b/Aetheria.Rts.Web/scripts/generate-rts-bindings.mjs @@ -37,6 +37,12 @@ const ipcChannels = [ ["setTarget", "aetheria-rts:set-target"], ["surfaceCatalog", "aetheria-rts:surface-catalog"], ["surfaceCatalogIndex", "aetheria-rts:surface-catalog-index"], + ["mainMenuSurface", "aetheria-rts:main-menu-surface"], + ["debugSurface", "aetheria-rts:debug-surface"], + ["debugSurfaceWatch", "aetheria-rts:debug-surface-watch"], + ["debugSurfaceWatchStop", "aetheria-rts:debug-surface-watch-stop"], + ["debugSurfaceChanged", "aetheria-rts:debug-surface-changed"], + ["windowControl", "aetheria-rts:window-control"], ["health", "aetheria-rts:health"], ]; @@ -1030,6 +1036,46 @@ export type AetheriaRuntimeViewportFeedSnapshot = { ${renderRtsDocumentTypes("Viewport")} +export type AetheriaMenuSurfaceRequest = { + surfaceId?: string; + inGame?: boolean; + canOpenRuntimeInputScreen?: boolean; +}; + +export type AetheriaMenuSurfaceDocument = { + providerId: string; + providerKind: string; + title: string; + version: number; + updatedAtUtc: string; + surface: AetheriaMenuSurfaceTree; + commands: AetheriaMenuSurfaceCommand[]; +}; + +export type AetheriaMenuSurfaceTree = { + id: string; + root: AetheriaMenuSurfaceComponent; + styles: AetheriaMenuStyleToken[]; +}; + +export type AetheriaMenuSurfaceComponent = { + id: string; + kind: string; + props: Record; + children: AetheriaMenuSurfaceComponent[]; +}; + +export type AetheriaMenuStyleToken = { + name: string; + value: string; +}; + +export type AetheriaMenuSurfaceCommand = { + command: string; + label: string; + transport: string; +}; + export type AetheriaRtsApi = { mapViewport(request: Viewport): Promise; objectsViewport(request: Viewport): Promise; @@ -1045,6 +1091,10 @@ export type AetheriaRtsApi = { setTarget(request: AetheriaRuntimeSetTargetRequest): Promise; surfaceCatalog(): Promise; surfaceCatalogIndex(): Promise; + mainMenuSurface(request: AetheriaMenuSurfaceRequest): Promise; + debugSurface(): Promise; + watchDebugSurface(callback: (surface: AetheriaMenuSurfaceDocument) => void): () => void; + windowControl(action: "minimize" | "maximize" | "close"): Promise; health(): Promise; }; `; @@ -1289,6 +1339,7 @@ export type BodyView = { y: number; radius: number; isAsteroidBelt: boolean; + iconAsset: AssetRef; }; `; } @@ -1302,7 +1353,11 @@ function renderIpcChannelLines() { function renderPreload() { const channelLines = renderIpcChannelLines(); const apiLines = ipcChannels - .filter(([name]) => name !== "viewportFeedUpdate" && name !== "viewportFeedStop") + .filter(([name]) => name !== "viewportFeedUpdate" && + name !== "viewportFeedStop" && + name !== "debugSurfaceWatch" && + name !== "debugSurfaceWatchStop" && + name !== "debugSurfaceChanged") .map(([name]) => { if (name === "viewportFeed") { return ` watchViewportFeed: (request, callback) => { @@ -1318,6 +1373,23 @@ function renderPreload() { ipcRenderer.off(channels.viewportFeedUpdate, listener); void ipcRenderer.invoke(channels.viewportFeedStop, subscriptionId); }; + },`; + } + if (name === "debugSurface") { + return ` debugSurface: () => ipcRenderer.invoke(channels.debugSurface), + watchDebugSurface: callback => { + const subscriptionId = \`debug-surface-\${Date.now().toString(36)}-\${Math.random().toString(36).slice(2)}\`; + const listener = (_event, message) => { + if (message?.subscriptionId === subscriptionId) { + callback(message.surface); + } + }; + ipcRenderer.on(channels.debugSurfaceChanged, listener); + void ipcRenderer.invoke(channels.debugSurfaceWatch, subscriptionId); + return () => { + ipcRenderer.off(channels.debugSurfaceChanged, listener); + void ipcRenderer.invoke(channels.debugSurfaceWatchStop, subscriptionId); + }; },`; } const hasNoArguments = name === "health" ||