Render main menu surface in Electron
This commit is contained in:
parent
eb0760c81f
commit
b4f7be9df2
7 changed files with 466 additions and 7 deletions
|
|
@ -70,6 +70,46 @@ export type AetheriaCultMeshClientOptions = {
|
|||
snapshotTimeoutMs?: number;
|
||||
};
|
||||
|
||||
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<string, string>;
|
||||
children: AetheriaMenuSurfaceComponent[];
|
||||
};
|
||||
|
||||
export type AetheriaMenuStyleToken = {
|
||||
name: string;
|
||||
value: string;
|
||||
};
|
||||
|
||||
export type AetheriaMenuSurfaceCommand = {
|
||||
command: string;
|
||||
label: string;
|
||||
transport: string;
|
||||
};
|
||||
|
||||
export type {
|
||||
BodyView,
|
||||
EntityStatus,
|
||||
|
|
@ -232,6 +272,13 @@ export class AetheriaCultMeshClient {
|
|||
return this.aetheria.daemon.assetManifest();
|
||||
}
|
||||
|
||||
public async mainMenuSurface(request: AetheriaMenuSurfaceRequest = {}): Promise<AetheriaMenuSurfaceDocument> {
|
||||
return buildMainMenuSurface(
|
||||
request.surfaceId || "aetheria.main_menu.root",
|
||||
request.canOpenRuntimeInputScreen === true,
|
||||
request.inGame === true);
|
||||
}
|
||||
|
||||
public queryDiagnostics(): Readonly<Record<string, AetheriaRuntimeRtsQueryDiagnostic>> {
|
||||
return describeAetheriaRuntimeRtsQueryHandles(this.queries);
|
||||
}
|
||||
|
|
@ -449,6 +496,141 @@ export class AetheriaCultMeshClient {
|
|||
}
|
||||
}
|
||||
|
||||
function buildMainMenuSurface(
|
||||
surfaceId: string,
|
||||
canOpenRuntimeInputScreen: boolean,
|
||||
inGame: boolean,
|
||||
): AetheriaMenuSurfaceDocument {
|
||||
const updatedAtUtc = new Date().toISOString();
|
||||
if (surfaceId === "aetheria.main_menu.settings") {
|
||||
return surfaceDocument(
|
||||
surfaceId,
|
||||
"Aetheria Settings",
|
||||
updatedAtUtc,
|
||||
[
|
||||
command("aetheria.main_menu.settings.show_player_settings", "Player Settings"),
|
||||
command("aetheria.main_menu.settings.show_verse_settings", "Verse"),
|
||||
command("aetheria.main_menu.settings.show_input_settings", "Input"),
|
||||
command("aetheria.main_menu.settings.back_to_main", "Back"),
|
||||
],
|
||||
text("aetheria.mainMenu.settings.title", "SETTINGS", "text.title"),
|
||||
buttonColumn(
|
||||
"aetheria.mainMenu.settings.actions",
|
||||
button("aetheria.mainMenu.settings.playerSettings", "Player Settings", "aetheria.main_menu.settings.show_player_settings"),
|
||||
button("aetheria.mainMenu.settings.verse", "Verse", "aetheria.main_menu.settings.show_verse_settings"),
|
||||
button("aetheria.mainMenu.settings.input", "Input", "aetheria.main_menu.settings.show_input_settings"),
|
||||
button("aetheria.mainMenu.settings.back", "Back", "aetheria.main_menu.settings.back_to_main"),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
if (surfaceId === "aetheria.main_menu.input_settings") {
|
||||
const children = [
|
||||
text("aetheria.mainMenu.input.title", "INPUT", "text.title"),
|
||||
metric("aetheria.mainMenu.input.bindingOverrides", "Binding Overrides", "0"),
|
||||
metric("aetheria.mainMenu.input.actionBarInputs", "Action-Bar Inputs", "0"),
|
||||
text(
|
||||
"aetheria.mainMenu.input.note",
|
||||
canOpenRuntimeInputScreen && inGame
|
||||
? "The runtime Eve input screen owns low-level InputSystem rebinding and action-bar input edits."
|
||||
: "This title shell reports typed player-settings state. Launch a run to open the runtime Eve input screen that owns low-level InputSystem rebinding."),
|
||||
buttonColumn(
|
||||
"aetheria.mainMenu.input.actions",
|
||||
button("aetheria.mainMenu.input.back", "Back", "aetheria.main_menu.settings.back_to_settings"),
|
||||
),
|
||||
];
|
||||
return surfaceDocument(
|
||||
surfaceId,
|
||||
"Aetheria Input Settings",
|
||||
updatedAtUtc,
|
||||
[command("aetheria.main_menu.settings.back_to_settings", "Back")],
|
||||
...children);
|
||||
}
|
||||
|
||||
const actionButtons = [
|
||||
...(!inGame ? [button("aetheria.main_menu.root.continue", "Continue", "aetheria.main_menu.root.continue")] : []),
|
||||
button("aetheria.main_menu.root.newGame", "New Game", "aetheria.main_menu.root.new_game"),
|
||||
button("aetheria.main_menu.root.settings", "Settings", "aetheria.main_menu.root.show_settings"),
|
||||
button("aetheria.main_menu.root.quit", "Quit", "aetheria.main_menu.root.quit"),
|
||||
];
|
||||
return surfaceDocument(
|
||||
"aetheria.main_menu.root",
|
||||
"Aetheria Terminus",
|
||||
updatedAtUtc,
|
||||
[
|
||||
...(!inGame ? [command("aetheria.main_menu.root.continue", "Continue")] : []),
|
||||
command("aetheria.main_menu.root.new_game", "New Game"),
|
||||
command("aetheria.main_menu.root.show_settings", "Settings"),
|
||||
command("aetheria.main_menu.root.quit", "Quit"),
|
||||
],
|
||||
text("aetheria.main_menu.root.title", "AETHERIA", "text.title"),
|
||||
text("aetheria.main_menu.root.subtitle", "TERMINUS", "text.subtitle"),
|
||||
buttonColumn("aetheria.main_menu.root.actions", ...actionButtons),
|
||||
);
|
||||
}
|
||||
|
||||
function surfaceDocument(
|
||||
surfaceId: string,
|
||||
title: string,
|
||||
updatedAtUtc: string,
|
||||
commands: AetheriaMenuSurfaceCommand[],
|
||||
...children: AetheriaMenuSurfaceComponent[]
|
||||
): AetheriaMenuSurfaceDocument {
|
||||
return {
|
||||
providerId: "aetheria",
|
||||
providerKind: "game.menu",
|
||||
title,
|
||||
version: 1,
|
||||
updatedAtUtc,
|
||||
surface: {
|
||||
id: surfaceId,
|
||||
root: node(`${surfaceId}.root`, "surface", {}, ...children),
|
||||
styles: [
|
||||
{ name: "font.title.family", value: "Montserrat" },
|
||||
{ name: "font.title.style", value: "Thin" },
|
||||
{ name: "font.title.weight", value: "100" },
|
||||
{ name: "font.body.family", value: "Ubuntu" },
|
||||
{ name: "font.body.style", value: "Regular" },
|
||||
{ name: "font.body.weight", value: "400" },
|
||||
{
|
||||
name: "font.web.google",
|
||||
value: "https://fonts.googleapis.com/css2?family=Montserrat:wght@100&family=Ubuntu:wght@400&display=swap",
|
||||
},
|
||||
],
|
||||
},
|
||||
commands,
|
||||
};
|
||||
}
|
||||
|
||||
function command(commandId: string, label: string): AetheriaMenuSurfaceCommand {
|
||||
return { command: commandId, label, transport: "cultmesh" };
|
||||
}
|
||||
|
||||
function node(
|
||||
id: string,
|
||||
kind: string,
|
||||
props: Record<string, string>,
|
||||
...children: AetheriaMenuSurfaceComponent[]
|
||||
): AetheriaMenuSurfaceComponent {
|
||||
return { id, kind, props, children };
|
||||
}
|
||||
|
||||
function text(id: string, value: string, kind = "text"): AetheriaMenuSurfaceComponent {
|
||||
return node(id, kind, { value });
|
||||
}
|
||||
|
||||
function metric(id: string, label: string, value: string): AetheriaMenuSurfaceComponent {
|
||||
return node(id, "metric", { label, value });
|
||||
}
|
||||
|
||||
function button(id: string, label: string, commandId: string): AetheriaMenuSurfaceComponent {
|
||||
return node(id, "control.button", { label, command: commandId });
|
||||
}
|
||||
|
||||
function buttonColumn(id: string, ...children: AetheriaMenuSurfaceComponent[]): AetheriaMenuSurfaceComponent {
|
||||
return node(id, "column", {}, ...children);
|
||||
}
|
||||
|
||||
function stableToken(value: string): string {
|
||||
return value
|
||||
.replace(/[^a-zA-Z0-9]+/gu, "-")
|
||||
|
|
|
|||
|
|
@ -27,6 +27,7 @@ const rtsCultMeshAdvertiseHost = process.env.AETHERIA_RTS_CULTMESH_ADVERTISE_HOS
|
|||
const peerCultMeshEndpoints = parseEndpointList(process.env.AETHERIA_RTS_PEER_CULTMESH_ENDPOINTS);
|
||||
const electronSmoke = process.env.AETHERIA_RTS_ELECTRON_SMOKE === "1";
|
||||
const electronSmokeResultPath = process.env.AETHERIA_RTS_ELECTRON_SMOKE_RESULT;
|
||||
const rendererView = process.env.AETHERIA_RTS_VIEW?.trim() ?? "";
|
||||
|
||||
let daemonProcess: ChildProcessWithoutNullStreams | null = null;
|
||||
let mainWindow: BrowserWindow | null = null;
|
||||
|
|
@ -39,7 +40,10 @@ app.whenReady().then(async () => {
|
|||
showStartup("Preparing Aetheria RTS", "Building daemon if needed.");
|
||||
|
||||
try {
|
||||
if (launchLocalDaemon) {
|
||||
if (rendererView === "main-menu") {
|
||||
showStartup("Launching Aetheria Menu", "Lowering the CultUI main-menu surface.");
|
||||
mkdirSync(runtimeRoot, { recursive: true });
|
||||
} else if (launchLocalDaemon) {
|
||||
await ensureDotnetBuild();
|
||||
showStartup("Launching Aetheria RTS", "Starting the Aetheria daemon.");
|
||||
mkdirSync(runtimeRoot, { recursive: true });
|
||||
|
|
@ -73,9 +77,13 @@ app.whenReady().then(async () => {
|
|||
"aetheria-rts-electron",
|
||||
{ publicationMode: launchLocalDaemon ? "local" : "remote" });
|
||||
|
||||
showStartup("Launching Aetheria RTS", "Waiting for the daemon CultMesh frame.");
|
||||
await rtsClient.waitForFrame(30000);
|
||||
await mainWindow.loadFile(rendererIndex);
|
||||
if (rendererView === "main-menu") {
|
||||
await mainWindow.loadFile(rendererIndex, { hash: "main-menu" });
|
||||
} else {
|
||||
showStartup("Launching Aetheria RTS", "Waiting for the daemon CultMesh frame.");
|
||||
await rtsClient.waitForFrame(30000);
|
||||
await mainWindow.loadFile(rendererIndex);
|
||||
}
|
||||
if (electronSmoke) {
|
||||
const result = await runElectronSmoke(mainWindow);
|
||||
writeElectronSmokeResult({ ok: true, result });
|
||||
|
|
@ -291,6 +299,8 @@ function registerIpc(): void {
|
|||
daemonRunning: daemonProcess != null && !daemonProcess.killed,
|
||||
daemonMode: launchLocalDaemon ? "local" : "remote",
|
||||
}));
|
||||
ipcMain.handle("aetheria-rts:main-menu-surface", async (_event, request) =>
|
||||
requireClient().mainMenuSurface(request));
|
||||
}
|
||||
|
||||
function parseEndpointList(value: string | undefined): string[] {
|
||||
|
|
|
|||
|
|
@ -20,6 +20,7 @@ const channels = {
|
|||
setTarget: "aetheria-rts:set-target",
|
||||
surfaceCatalog: "aetheria-rts:surface-catalog",
|
||||
surfaceCatalogIndex: "aetheria-rts:surface-catalog-index",
|
||||
mainMenuSurface: "aetheria-rts:main-menu-surface",
|
||||
health: "aetheria-rts:health",
|
||||
};
|
||||
|
||||
|
|
@ -51,5 +52,6 @@ contextBridge.exposeInMainWorld("aetheriaRts", {
|
|||
setTarget: request => ipcRenderer.invoke(channels.setTarget, request),
|
||||
surfaceCatalog: () => ipcRenderer.invoke(channels.surfaceCatalog),
|
||||
surfaceCatalogIndex: () => ipcRenderer.invoke(channels.surfaceCatalogIndex),
|
||||
mainMenuSurface: request => ipcRenderer.invoke(channels.mainMenuSurface, request),
|
||||
health: () => ipcRenderer.invoke(channels.health),
|
||||
});
|
||||
|
|
|
|||
Loading…
Reference in a new issue