add tray & creating shortcuts

This commit is contained in:
olcxja 2026-09-26 13:57:12 +02:00
commit 1097a1f441
11 changed files with 452 additions and 22 deletions

View file

@ -11,6 +11,7 @@ const prefixes = require('../prefixes')
const runner = require('../runner')
const { extractIconFromExe } = require('../icons')
const { createGamesService, sendToWindow } = require('./games')
const shortcuts = require('../shortcuts')
const ICON_EXTS = ['png', 'jpe?g', 'svg', 'ico', 'webp', 'gif', 'bmp']
@ -39,8 +40,8 @@ function extractGameIcon(id, exePath) {
// --- registration -----------------------------------------------------------
function registerIpc({ getWindow }) {
const games = createGamesService({ getWindow })
function registerIpc({ getWindow, onGamesChanged }) {
const games = createGamesService({ getWindow, onGamesChanged })
// i18n ---------------------------------------------------------------------
ipcMain.handle('i18n:list', async () => {
@ -93,7 +94,20 @@ function registerIpc({ getWindow }) {
ipcMain.handle('games:list', () => library.loadGames())
ipcMain.handle('games:get', (e, id) => library.getGame(id))
ipcMain.handle('games:update', (e, id, patch) => library.updateGame(id, patch))
ipcMain.handle('games:remove', (e, id) => library.removeGame(id))
ipcMain.handle('games:remove', (e, id) => {
shortcuts.removeShortcut(id)
return library.removeGame(id)
})
ipcMain.handle('games:createShortcut', (e, id) => {
const game = library.getGame(id)
if (!game) return { ok: false, error: 'game-not-found' }
try {
return shortcuts.createShortcut(game)
} catch (err) {
return errorResult(err)
}
})
ipcMain.handle('games:shortcutPaths', (e, id) => shortcuts.shortcutPaths(id))
ipcMain.handle('games:clearPlaytime', (e, id) => library.clearPlaytime(id))
// games: icons ---------------------------------------------------------------------