feat(launcher): add WTOffline logo application and installer icons

This commit is contained in:
N0VAN0M4LY committed 2026-11-30 19:38:32 +08:00
1 parent cae69a6446
commit c65308c477
6 files changed
+49 -3

No files matched your search

@@ -1,6 +1,7 @@
import { join } from 'node:path';
import { app, BrowserWindow, Menu, shell, Tray } from 'electron';
import { app, BrowserWindow, Menu, nativeImage, shell, Tray } from 'electron';
import { getSettings } from './config/settings-store.ts';
import { bundledResourcePaths } from './resources/resource-paths.ts';
/**
* The launcher's single window: a fixed size without the system frame, like the game's own
@@ -25,7 +26,9 @@ export function beginWindowQuit(): void {
async function hideToTray(window: BrowserWindow): Promise<void> {
if (!tray) {
tray = new Tray(await app.getFileIcon(process.execPath, { size: 'small' }));
const customIcon = nativeImage.createFromPath(bundledResourcePaths().appIcon);
const icon = customIcon.isEmpty() ? await app.getFileIcon(process.execPath, { size: 'small' }) : customIcon;
tray = new Tray(icon);
tray.setToolTip(app.getName());
tray.setContextMenu(Menu.buildFromTemplate([{ role: 'quit' }]));
tray.on('click', () => showMainWindow());
@@ -34,6 +37,7 @@ async function hideToTray(window: BrowserWindow): Promise<void> {
}
export function createMainWindow(): BrowserWindow {
const appIcon = nativeImage.createFromPath(bundledResourcePaths().appIcon);
const window = new BrowserWindow({
width: CONTENT_WIDTH,
height: CONTENT_HEIGHT,
@@ -44,6 +48,7 @@ export function createMainWindow(): BrowserWindow {
frame: false,
backgroundColor: BACKGROUND,
show: false,
...(!appIcon.isEmpty() ? { icon: appIcon } : {}),
webPreferences: {
preload: join(import.meta.dirname, '../preload/index.cjs'),
sandbox: true,
@@ -15,6 +15,8 @@ export interface ResourcePaths {
readonly patches: string;
/** wto_ws.dll, built by native/wto-net/build.ps1. */
readonly networkHookLibrary: string;
/** Multi-resolution Windows icon for the window and system tray. */
readonly appIcon: string;
}
export function resourcePaths(): ResourcePaths {
@@ -29,6 +31,7 @@ export function bundledResourcePaths(): ResourcePaths {
return {
patches: join(process.resourcesPath, 'patches'),
networkHookLibrary: join(process.resourcesPath, 'native', 'wto_ws.dll'),
appIcon: join(process.resourcesPath, 'icon.ico'),
};
}
// The app path is apps/launcher; the repository is two levels up.
@@ -36,6 +39,7 @@ export function bundledResourcePaths(): ResourcePaths {
return {
patches: join(repository, 'patches'),
networkHookLibrary: join(repository, 'build', 'native', 'wto_ws.dll'),
appIcon: join(repository, 'apps', 'launcher', 'resources', 'icon.ico'),
};
}