feat: implement game launcher window functionality and enhance deep link handling

This commit is contained in:
Moyasee
2026-01-21 21:04:22 +02:00
parent 335f4d33b9
commit 9824f7a905
14 changed files with 554 additions and 14 deletions

View File

@@ -204,6 +204,9 @@ function onOpenGame(game: Game) {
lastSyncTick: now,
});
// Close the launcher window when game starts
WindowManager.closeGameLauncherWindow();
// Hide Hydra to tray on game startup if enabled
db.get<string, UserPreferences | null>(levelKeys.userPreferences, {
valueEncoding: "json",

View File

@@ -30,6 +30,7 @@ import { logger } from "./logger";
export class WindowManager {
public static mainWindow: Electron.BrowserWindow | null = null;
public static notificationWindow: Electron.BrowserWindow | null = null;
public static gameLauncherWindow: Electron.BrowserWindow | null = null;
private static readonly editorWindows: Map<string, BrowserWindow> = new Map();
@@ -516,6 +517,84 @@ export class WindowManager {
}
}
private static readonly GAME_LAUNCHER_WINDOW_WIDTH = 550;
private static readonly GAME_LAUNCHER_WINDOW_HEIGHT = 320;
public static async createGameLauncherWindow(shop: string, objectId: string) {
if (this.gameLauncherWindow) {
this.gameLauncherWindow.close();
this.gameLauncherWindow = null;
}
const display = screen.getPrimaryDisplay();
const { width: displayWidth, height: displayHeight } = display.bounds;
const x = Math.round((displayWidth - this.GAME_LAUNCHER_WINDOW_WIDTH) / 2);
const y = Math.round(
(displayHeight - this.GAME_LAUNCHER_WINDOW_HEIGHT) / 2
);
this.gameLauncherWindow = new BrowserWindow({
width: this.GAME_LAUNCHER_WINDOW_WIDTH,
height: this.GAME_LAUNCHER_WINDOW_HEIGHT,
x,
y,
resizable: false,
maximizable: false,
minimizable: false,
fullscreenable: false,
frame: false,
backgroundColor: "#1c1c1c",
icon,
skipTaskbar: false,
webPreferences: {
preload: path.join(__dirname, "../preload/index.mjs"),
sandbox: false,
},
show: false,
});
this.gameLauncherWindow.removeMenu();
this.loadWindowURL(
this.gameLauncherWindow,
`game-launcher?shop=${shop}&objectId=${objectId}`
);
this.gameLauncherWindow.on("closed", () => {
this.gameLauncherWindow = null;
});
if (!app.isPackaged || isStaging) {
this.gameLauncherWindow.webContents.openDevTools();
}
}
public static showGameLauncherWindow() {
if (this.gameLauncherWindow && !this.gameLauncherWindow.isDestroyed()) {
this.gameLauncherWindow.show();
}
}
public static closeGameLauncherWindow() {
if (this.gameLauncherWindow) {
this.gameLauncherWindow.close();
this.gameLauncherWindow = null;
}
}
public static openMainWindow() {
if (this.mainWindow) {
this.mainWindow.show();
if (this.mainWindow.isMinimized()) {
this.mainWindow.restore();
}
this.mainWindow.focus();
} else {
this.createMainWindow();
}
}
public static redirect(hash: string) {
if (!this.mainWindow) this.createMainWindow();
this.loadMainWindowURL(hash);