* Run the tray icon context menu * MARK: trayContext * @returns null
()
| 362 | * @returns null |
| 363 | */ |
| 364 | trayContextMenu() { |
| 365 | if ( !this.tray || this.tray.isDestroyed() ) { return } |
| 366 | |
| 367 | const curCols = serveIPC.modCollect.getCurVerCollections(funcLib.prefs.ver()) |
| 368 | const colStart = curCols |
| 369 | .sort((a, b) => Intl.Collator().compare(b[3], a[3])) |
| 370 | .sort((a, b) => Intl.Collator().compare(b[4], a[4])) |
| 371 | .slice(0, 5) |
| 372 | .map((x) => ({ |
| 373 | arguments : `--start-game-with=${x[0]}`, |
| 374 | description : this.l10n.syncStringLookup('launch_game_with'), |
| 375 | iconIndex : 0, |
| 376 | iconPath : this.#getNativeIcon('ui-icon-launch-col'), |
| 377 | program : process.execPath, |
| 378 | title : x[2], |
| 379 | workingDirectory : process.cwd, |
| 380 | })) |
| 381 | app.setUserTasks([ |
| 382 | { |
| 383 | arguments : '--start-game', |
| 384 | description : this.l10n.syncStringLookup('launch_game__title'), |
| 385 | iconIndex : 0, |
| 386 | iconPath : this.#getNativeIcon(`ui-icon-launch-${serveIPC.storeSet?.get?.('game_version', 22) || 22}`, true), |
| 387 | program : process.execPath, |
| 388 | title : this.l10n.syncStringLookup('launch_game'), |
| 389 | }, |
| 390 | ...colStart, |
| 391 | ]) |
| 392 | |
| 393 | const curCollect = serveIPC.modCollect.getCurCollectSafe(serveIPC.gameSetOverride.folder) |
| 394 | const launchExt = curCollect === '' ? {} : { sublabel : curCollect } |
| 395 | this.tray.setContextMenu(Menu.buildFromTemplate([ |
| 396 | funcLib.menu.iconL10n('app_name', () => { this.win.main.show() }, 'fsgMA'), |
| 397 | funcLib.menu.sep, |
| 398 | { |
| 399 | click : () => { serveIPC.refFunc.gameLauncher() }, |
| 400 | icon : this.#getNativeImage(`ui-icon-launch-${serveIPC.storeSet?.get?.('game_version', 22) || 22}`, true), |
| 401 | label : this.l10n.syncStringLookup('launch_game'), |
| 402 | ...launchExt, |
| 403 | }, |
| 404 | { |
| 405 | icon : serveIPC.windowLib.contextIcons.depend, |
| 406 | label : this.l10n.syncStringLookup('launch_game_with'), |
| 407 | submenu : curCols.map((x) => ({ |
| 408 | click : () => { funcLib.gameSet.change(x[0]).then(() => { funcLib.gameLauncher() }) }, |
| 409 | icon : serveIPC.windowLib.contextIcons.active, |
| 410 | label : x[2], |
| 411 | })), |
| 412 | }, |
| 413 | funcLib.menu.iconL10n('mini_mode_button__title', () => { serveIPC.refFunc.toggleMiniWindow() }, 'mini'), |
| 414 | funcLib.menu.iconL10n('tray_quit', () => { this.win.main.close() }, 'quit'), |
| 415 | ])) |
| 416 | } |
| 417 | |
| 418 | // #region sanity & state |
| 419 | /** |
no test coverage detected