diff --git a/Aetheria.Rts.Web/Client/aetheria-rts-contract.ts b/Aetheria.Rts.Web/Client/aetheria-rts-contract.ts index 428cf0671..d03470ee8 100644 --- a/Aetheria.Rts.Web/Client/aetheria-rts-contract.ts +++ b/Aetheria.Rts.Web/Client/aetheria-rts-contract.ts @@ -346,5 +346,6 @@ export type AetheriaRtsApi = { surfaceCatalog(): Promise; surfaceCatalogIndex(): Promise; mainMenuSurface(request: AetheriaMenuSurfaceRequest): Promise; + windowControl(action: "minimize" | "maximize" | "close"): Promise; health(): Promise; }; diff --git a/Aetheria.Rts.Web/Client/app.ts b/Aetheria.Rts.Web/Client/app.ts index 33612d055..e2ec71d47 100644 --- a/Aetheria.Rts.Web/Client/app.ts +++ b/Aetheria.Rts.Web/Client/app.ts @@ -131,6 +131,7 @@ function renderMainMenuSurface(surface: AetheriaMenuSurfaceDocument): void { } host.replaceChildren(lowerMenuComponent(surface.surface.root, surface)); + wireWindowControls(); } function lowerMenuComponent( @@ -151,7 +152,7 @@ function lowerMenuComponent( if (kind.startsWith("text")) { const label = document.createElement("div"); label.id = component.id; - label.className = kind === "text.title" ? "eve-text-title" : "eve-text"; + label.className = menuTextClasses(component, kind).join(" "); label.textContent = component.props.value ?? component.props.text ?? ""; return label; } @@ -181,6 +182,37 @@ function lowerMenuComponent( return element; } +function menuTextClasses(component: AetheriaMenuSurfaceComponent, kind: string): string[] { + const classes: string[] = []; + if (kind === "text.title") + classes.push("eve-text-title"); + if (kind === "text.subtitle") + classes.push("eve-text-subtitle"); + if (classes.length === 0) + classes.push("eve-text"); + if (component.id === "aetheria.main_menu.root.title") + classes.push("eve-root-title"); + if (component.id === "aetheria.main_menu.root.subtitle") + classes.push("eve-root-subtitle"); + return classes; +} + +function wireWindowControls(): void { + if (!mainMenuMode) + return; + + document.querySelectorAll("[data-window-control]").forEach(button => { + if (button.dataset.windowControlWired === "true") + return; + button.dataset.windowControlWired = "true"; + button.addEventListener("click", () => { + const action = button.dataset.windowControl as "minimize" | "maximize" | "close" | undefined; + if (action) + void window.aetheriaRts.windowControl(action); + }); + }); +} + function handleMenuCommand(command: string, surface: AetheriaMenuSurfaceDocument): void { switch (command) { case "aetheria.main_menu.root.show_settings": diff --git a/Aetheria.Rts.Web/Electron/main.ts b/Aetheria.Rts.Web/Electron/main.ts index 6622065ba..592be32a4 100644 --- a/Aetheria.Rts.Web/Electron/main.ts +++ b/Aetheria.Rts.Web/Electron/main.ts @@ -114,6 +114,7 @@ app.on("before-quit", () => { }); function createWindow(): BrowserWindow { + const isMainMenuWindow = rendererView === "main-menu"; const window = new BrowserWindow({ width: 1440, height: 900, @@ -122,6 +123,8 @@ function createWindow(): BrowserWindow { show: !electronSmoke, backgroundColor: "#0b1016", title: "Aetheria RTS", + frame: !isMainMenuWindow, + autoHideMenuBar: isMainMenuWindow, webPreferences: { contextIsolation: true, nodeIntegration: false, @@ -301,6 +304,28 @@ function registerIpc(): void { })); ipcMain.handle("aetheria-rts:main-menu-surface", async (_event, request) => requireClient().mainMenuSurface(request)); + ipcMain.handle("aetheria-rts:window-control", (event, action: string) => { + const window = BrowserWindow.fromWebContents(event.sender); + if (!window) + return; + + switch (action) { + case "minimize": + window.minimize(); + return; + case "maximize": + if (window.isMaximized()) + window.unmaximize(); + else + window.maximize(); + return; + case "close": + window.close(); + return; + default: + throw new Error(`Unknown window control '${action}'.`); + } + }); } function parseEndpointList(value: string | undefined): string[] { diff --git a/Aetheria.Rts.Web/Electron/preload.cjs b/Aetheria.Rts.Web/Electron/preload.cjs index 2b095b9c9..8971356d2 100644 --- a/Aetheria.Rts.Web/Electron/preload.cjs +++ b/Aetheria.Rts.Web/Electron/preload.cjs @@ -21,6 +21,7 @@ const channels = { surfaceCatalog: "aetheria-rts:surface-catalog", surfaceCatalogIndex: "aetheria-rts:surface-catalog-index", mainMenuSurface: "aetheria-rts:main-menu-surface", + windowControl: "aetheria-rts:window-control", health: "aetheria-rts:health", }; @@ -53,5 +54,6 @@ contextBridge.exposeInMainWorld("aetheriaRts", { surfaceCatalog: () => ipcRenderer.invoke(channels.surfaceCatalog), surfaceCatalogIndex: () => ipcRenderer.invoke(channels.surfaceCatalogIndex), mainMenuSurface: request => ipcRenderer.invoke(channels.mainMenuSurface, request), + windowControl: action => ipcRenderer.invoke(channels.windowControl, action), health: () => ipcRenderer.invoke(channels.health), }); diff --git a/Aetheria.Rts.Web/wwwroot/index.html b/Aetheria.Rts.Web/wwwroot/index.html index af5300ba5..f7212320a 100644 --- a/Aetheria.Rts.Web/wwwroot/index.html +++ b/Aetheria.Rts.Web/wwwroot/index.html @@ -46,6 +46,12 @@ + +
+ + + +
diff --git a/Aetheria.Rts.Web/wwwroot/styles.css b/Aetheria.Rts.Web/wwwroot/styles.css index bd69a6fd1..388fd45cc 100644 --- a/Aetheria.Rts.Web/wwwroot/styles.css +++ b/Aetheria.Rts.Web/wwwroot/styles.css @@ -24,6 +24,7 @@ body { } body.main-menu-mode { + -webkit-app-region: drag; background: radial-gradient(circle at 76% 66%, rgba(255, 213, 112, 0.74) 0, rgba(247, 121, 88, 0.36) 13%, transparent 31%), radial-gradient(circle at 61% 37%, rgba(240, 45, 201, 0.54) 0, rgba(176, 38, 174, 0.28) 19%, transparent 45%), @@ -36,11 +37,12 @@ body.main-menu-mode .shell { } body.main-menu-mode .main-menu-host { + -webkit-app-region: no-drag; display: flex; align-items: flex-start; justify-content: flex-start; min-height: 100%; - padding: 92px 96px; + padding: 128px 96px; background: radial-gradient(ellipse at 78% 64%, rgba(255, 194, 95, 0.36) 0, rgba(255, 148, 92, 0.18) 16%, transparent 35%), radial-gradient(ellipse at 59% 38%, rgba(238, 56, 216, 0.28) 0, rgba(164, 37, 160, 0.2) 22%, transparent 52%), @@ -54,7 +56,8 @@ body.main-menu-mode .eve-surface { align-items: flex-start; } -body.main-menu-mode .eve-text-title { +body.main-menu-mode .eve-text-title, +body.main-menu-mode .eve-text-subtitle { width: 720px; color: rgba(209, 242, 255, 0.96); font-family: "Montserrat", sans-serif; @@ -63,12 +66,12 @@ body.main-menu-mode .eve-text-title { text-align: right; } -body.main-menu-mode #aetheria\.main_menu\.root\.title { - margin: 0 0 -12px; +body.main-menu-mode .eve-root-title { + margin: 0 0 2px; font-size: 86px; } -body.main-menu-mode #aetheria\.main_menu\.root\.subtitle { +body.main-menu-mode .eve-root-subtitle { margin: 0 0 36px; font-size: 39px; } @@ -104,7 +107,7 @@ body.main-menu-mode .eve-control-button:hover, body.main-menu-mode .eve-control-button:focus-visible { background: transparent; color: white; - letter-spacing: 8px; + letter-spacing: 2px; outline: 0; } @@ -116,7 +119,7 @@ body.main-menu-mode .eve-metric { margin: 0 0 8px; } -body.main-menu-mode .eve-text:not(.eve-text-title) { +body.main-menu-mode .eve-text:not(.eve-text-title):not(.eve-text-subtitle) { width: 520px; margin: 0 0 14px; color: rgba(219, 250, 255, 0.9); @@ -124,6 +127,57 @@ body.main-menu-mode .eve-text:not(.eve-text-title) { line-height: 1.25; } +.window-controls { + display: none; +} + +body.main-menu-mode .window-drag-region { + -webkit-app-region: drag; + position: fixed; + top: 0; + right: 0; + left: 0; + z-index: 15; + display: block; + height: 44px; +} + +body.main-menu-mode .window-controls { + -webkit-app-region: no-drag; + position: fixed; + top: 8px; + right: 10px; + z-index: 20; + display: flex; + gap: 2px; +} + +body.main-menu-mode .window-control { + min-width: 0; + width: 30px; + height: 24px; + padding: 0; + border: 0; + border-radius: 0; + background: transparent; + color: rgba(219, 250, 255, 0.5); + font-family: "Ubuntu", system-ui, sans-serif; + font-size: 12px; + line-height: 24px; +} + +body.main-menu-mode .window-control:hover, +body.main-menu-mode .window-control:focus-visible { + background: rgba(219, 250, 255, 0.09); + color: rgba(240, 252, 255, 0.95); + outline: 0; +} + +body.main-menu-mode .window-control-close:hover, +body.main-menu-mode .window-control-close:focus-visible { + background: rgba(255, 88, 88, 0.28); +} + button { min-width: 36px; height: 32px;