11const { platform } = require ( 'os' )
22const { app, ipcMain } = require ( 'electron' )
3- const { openWindow } = require ( './gui/gui' ) ;
4- const { exit } = require ( 'process' ) ;
5- const electronIsDev = require ( 'electron-is-dev' ) ;
6- const { getSimpleClientVersions, launch } = require ( './minecraft' ) ;
7- const { openAuthWindow, getAccounts } = require ( './auth' ) ;
8- const { checkForUpdates, update } = require ( './updater' ) ;
9- const { spawn } = require ( 'child_process' ) ;
10- const { join } = require ( 'path' ) ;
11- const { path } = require ( 'app-root-path' ) ;
12-
13- checkForUpdates ( async ( ) => {
14- if ( platform ( ) == 'win32' ) {
15- spawn ( 'cscript' , [
16- '//nologo' ,
17- join ( path , 'src' , 'yesno.vbs' ) ,
18- 'SimpleClient' ,
19- 'An update for SimpleLauncher is available.\nShould it be downloaded in the background?'
20- ] ) . stdout . on ( 'data' , data => { if ( data . toString ( ) . includes ( '6' ) ) update ( ) } )
21- }
22- } )
3+ const { openWindow } = require ( './gui/gui' )
4+ const { exit } = require ( 'process' )
5+ const { getSimpleClientVersions } = require ( './minecraft' )
6+ const { openAuthWindow, getAccounts } = require ( './auth' )
7+ const { checkForUpdates, update } = require ( './updater' )
238
249if ( platform ( ) == 'win32' || platform ( ) == 'linux' ) {
2510 app . disableHardwareAcceleration ( )
2611 app . whenReady ( ) . then ( ( ) => {
2712 const window = openWindow ( )
28- window . on ( 'ready-to-show' , ( ) => {
13+ window . on ( 'ready-to-show' , async ( ) => {
14+ if ( await checkForUpdates ( ) ) {
15+ window . webContents . send ( 'confirm' , { channel : 'update' , message : 'An update for SimpleLauncher is available.\nShould it be downloaded in the background?' } )
16+ }
2917 window . webContents . setZoomFactor ( 1 )
3018 getSimpleClientVersions ( versions => window . webContents . send ( 'simpleclient_versions' , versions ) )
3119 window . webContents . send ( 'accounts' , getAccounts ( ) , 0 )
3220 } )
21+ ipcMain . on ( 'update' , ( event , shouldUpdate ) => { if ( shouldUpdate ) update ( ) } )
3322 ipcMain . on ( 'login' , event => {
3423 openAuthWindow ( ( status , selectedAccount ) => {
3524 window . webContents . send ( 'auth' , status )
@@ -44,7 +33,9 @@ if (platform() == 'win32' || platform() == 'linux') {
4433 getSimpleClientVersions ( versions => {
4534 versions . forEach ( version => {
4635 if ( version . id == versionId ) {
47- launch ( version , getAccounts ( ) . find ( account => account . uuid == uuid ) , status => window . webContents . send ( 'launch' , status ) )
36+ require ( './launch' ) . launch ( version ,
37+ getAccounts ( ) . find ( account => account . uuid == uuid ) ,
38+ status => window . webContents . send ( 'launch' , status ) )
4839 }
4940 } ) ;
5041 } )
0 commit comments