more accurate sync progress report
This commit is contained in:
parent
8e3512b5cd
commit
c0f6e802ed
12 changed files with 390 additions and 63 deletions
41
src/main.js
41
src/main.js
|
|
@ -93,10 +93,16 @@ function trayIconPath() {
|
|||
|
||||
function createTray() {
|
||||
const { Tray, Menu } = require('electron')
|
||||
const icon = trayIconPath()
|
||||
try {
|
||||
tray = new Tray(trayIconPath())
|
||||
} catch {
|
||||
return // no icon available; window still works normally
|
||||
tray = new Tray(icon)
|
||||
} catch (err) {
|
||||
// never fatal (the window keeps working), but say why the icon is missing
|
||||
// instead of failing silently - a missing tray looks like a hung app when
|
||||
// the launcher runs in the background
|
||||
console.error(`[tray] could not create the tray icon (${icon || 'no icon file found'}): ${(err && err.message) || err}`)
|
||||
tray = null
|
||||
return
|
||||
}
|
||||
tray.setToolTip('PLWL')
|
||||
rebuildTrayMenu()
|
||||
|
|
@ -233,16 +239,25 @@ app.whenReady().then(async () => {
|
|||
const { games } = registerIpc({ getWindow, onGamesChanged: rebuildTrayMenu })
|
||||
gamesService = games
|
||||
|
||||
// LAN sync runs whenever the launcher runs - that is what makes this
|
||||
// device show up on the other machines' client lists
|
||||
lansync.start({
|
||||
onDevices: devices => sendToWindow(win, 'lansync:devices', devices),
|
||||
onApplied: info => sendToWindow(win, 'lansync:applied', info),
|
||||
isBusy: () => !!(gamesService && gamesService.listRunning().length)
|
||||
})
|
||||
|
||||
// the tray comes first: nothing (least of all the network) may keep it from
|
||||
// coming up - a launcher without a tray icon looks simply broken
|
||||
createTray()
|
||||
|
||||
// LAN sync runs whenever the launcher runs - that is what makes this
|
||||
// device show up on the other machines' client lists
|
||||
const lanHooks = {
|
||||
onDevices: devices => sendToWindow(win, 'lansync:devices', devices),
|
||||
onApplied: info => sendToWindow(win, 'lansync:applied', info),
|
||||
onReceive: info => sendToWindow(win, 'lansync:receiving', info),
|
||||
isBusy: () => !!(gamesService && gamesService.listRunning().length)
|
||||
}
|
||||
try {
|
||||
Promise.resolve(lansync.start(lanHooks)).catch(err => {
|
||||
console.error(`[lansync] start failed: ${(err && err.message) || err}`)
|
||||
})
|
||||
} catch (err) {
|
||||
console.error(`[lansync] start failed: ${(err && err.message) || err}`)
|
||||
}
|
||||
if (headless) {
|
||||
// shortcut boot: run the game without opening the launcher window
|
||||
launchGame(autoLaunchId)
|
||||
|
|
@ -259,5 +274,7 @@ app.whenReady().then(async () => {
|
|||
|
||||
app.on('before-quit', () => {
|
||||
quitting = true
|
||||
lansync.stop()
|
||||
try {
|
||||
lansync.stop()
|
||||
} catch {}
|
||||
})
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue