MCPcopy Create free account
hub / github.com/FSGModding/FSG_Mod_Assistant / trayContextMenu

Method trayContextMenu

lib/modAssist_window_lib.js:364–416  ·  view source on GitHub ↗

* Run the tray icon context menu * MARK: trayContext * @returns null

()

Source from the content-addressed store, hash-verified

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 /**

Callers 6

modAssist_main.jsFile · 0.80
constructorMethod · 0.80
sendModListMethod · 0.80
loadSettingsMethod · 0.80
changeThemeMethod · 0.80

Calls 8

getCurVerCollectionsMethod · 0.80
syncStringLookupMethod · 0.80
#getNativeIconMethod · 0.80
getCurCollectSafeMethod · 0.80
#getNativeImageMethod · 0.80
closeMethod · 0.80
getMethod · 0.45
showMethod · 0.45

Tested by

no test coverage detected