diff --git a/apps/launcher/resources/icon.ico b/apps/launcher/resources/icon.ico new file mode 100644 index 0000000..d2b6b17 Binary files /dev/null and b/apps/launcher/resources/icon.ico differ diff --git a/apps/launcher/resources/icon.png b/apps/launcher/resources/icon.png new file mode 100644 index 0000000..b9efe32 Binary files /dev/null and b/apps/launcher/resources/icon.png differ diff --git a/apps/launcher/src/main/services/main-window.ts b/apps/launcher/src/main/services/main-window.ts index f08ae2e..7a7a03a 100644 --- a/apps/launcher/src/main/services/main-window.ts +++ b/apps/launcher/src/main/services/main-window.ts @@ -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 { 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 { } 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, diff --git a/apps/launcher/src/main/services/resources/resource-paths.ts b/apps/launcher/src/main/services/resources/resource-paths.ts index 70f9857..ca43202 100644 --- a/apps/launcher/src/main/services/resources/resource-paths.ts +++ b/apps/launcher/src/main/services/resources/resource-paths.ts @@ -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'), }; } diff --git a/assets/icon.svg b/assets/icon.svg new file mode 100644 index 0000000..8c27ee4 --- /dev/null +++ b/assets/icon.svg @@ -0,0 +1,24 @@ + + WTOffline + Square WTOffline application icon with red WT monogram above light OFFLINE wordmark on a chamfered charcoal plate. + + + + + + + + + + + + + + + + + + + + + diff --git a/scripts/build-windows-installer.ts b/scripts/build-windows-installer.ts index ea38ca8..b5067ec 100644 --- a/scripts/build-windows-installer.ts +++ b/scripts/build-windows-installer.ts @@ -64,6 +64,10 @@ async function stageInstaller(stage: string, manifest: LauncherManifest): Promis const resources = join(stage, 'installer-resources'); await mkdir(join(resources, 'native'), { recursive: true }); + await mkdir(join(stage, 'build'), { recursive: true }); + await cp(join(launcher, 'resources', 'icon.ico'), join(stage, 'build', 'icon.ico')); + await cp(join(launcher, 'resources', 'icon.ico'), join(resources, 'icon.ico')); + await cp(join(launcher, 'resources', 'icon.png'), join(resources, 'icon.png')); await cp(join(repository, 'LICENSE'), join(resources, 'LICENSE-WTOffline')); await cp(join(native, 'wto_ws.dll'), join(resources, 'native', 'wto_ws.dll')); for (const folder of ['exe', 'gui', 'native', 'versions']) { @@ -140,10 +144,19 @@ async function main(): Promise { { from: 'installer-modules', to: 'node_modules', filter: ['**/*'] }, ], win: { + icon: join(stage, 'build', 'icon.ico'), artifactName, signExecutable: false, }, - nsis: { oneClick: false, perMachine: false, allowToChangeInstallationDirectory: true, runAfterFinish: false }, + nsis: { + oneClick: false, + perMachine: false, + allowToChangeInstallationDirectory: true, + runAfterFinish: false, + installerIcon: join(stage, 'build', 'icon.ico'), + uninstallerIcon: join(stage, 'build', 'icon.ico'), + installerHeaderIcon: join(stage, 'build', 'icon.ico'), + }, }, }); for (const artifact of artifacts) console.info(artifact);