| 1975 | |
| 1976 | // MARK: GAME LAUNCH |
| 1977 | const gameLauncher = () => { |
| 1978 | const launchLog = serveIPC.log.group('game-launcher') |
| 1979 | const currentVersion = prefs.ver() |
| 1980 | const gameArgs = prefs.verGet('game_args', currentVersion).trim() |
| 1981 | const progPath = prefs.verGet('game_path', currentVersion).trim() |
| 1982 | |
| 1983 | if ( progPath !== '' && fs.existsSync(progPath) ) { |
| 1984 | serveIPC.loadWindow.open('launch') |
| 1985 | serveIPC.loadWindow.noCount() |
| 1986 | serveIPC.loadWindow.hide(3500) |
| 1987 | |
| 1988 | try { |
| 1989 | const child = require('node:child_process').spawn(progPath, gameArgs.split(' '), { detached : true, stdio : ['ignore', 'ignore', 'ignore'] }) |
| 1990 | |
| 1991 | child.on('error', (err) => { launchLog.danger('Game launch failed', err) }) |
| 1992 | child.unref() |
| 1993 | } catch (err) { |
| 1994 | launchLog.danger('Game launch failed', err) |
| 1995 | } |
| 1996 | } else { |
| 1997 | const dialogOpts = { |
| 1998 | type : 'info', |
| 1999 | title : serveIPC.__('launcher_error_title'), |
| 2000 | message : serveIPC.__('launcher_error_message'), |
| 2001 | } |
| 2002 | dialog.showMessageBox(null, dialogOpts) |
| 2003 | launchLog.danger('Game path not set or invalid!') |
| 2004 | } |
| 2005 | } |
| 2006 | |
| 2007 | const inputManage = { |
| 2008 | isInit : false, |