import { app , BrowserWindow } from "electron" ; import { GAME_CANVAS_HEIGHT , GAME_CANVAS_WIDTH } from "./constants" ; import path from "path" ; ( ( ) : void => { if ( app . commandLine . hasSwitch ( "version" ) ) { process . stdout . write ( `Friendly Fire v${ app . getVersion ( ) }\n` ) ; app . exit ( 0 ) ; } if ( require ( "electron-squirrel-startup" ) ) { return app . quit ( ) ; } if ( ! app . requestSingleInstanceLock ) { return app . quit ( ) ; } app . name = "Friendly Fire" ; const createWindow = ( ) => { let fullscreen = true ; if ( app . commandLine . hasSwitch ( "no-fullscreen" ) ) { fullscreen = false ; } else if ( app . commandLine . hasSwitch ( "fullscreen" ) ) { fullscreen = [ "" , "true" ] . includes ( app . commandLine . getSwitchValue ( "fullscreen" ) . toLowerCase ( ) ) ; } const mainWindow = new BrowserWindow ( { backgroundColor : "#202020" , width : GAME_CANVAS_WIDTH , height : GAME_CANVAS_HEIGHT , useContentSize : true , resizable : true , center : true , maximizable : true , fullscreen : fullscreen || undefined , title : "Friendly Fire" , icon : path . join ( __dirname , ".." , "renderer" , "assets" , "appicon.iconset" , "icon_256x256.png" ) , webPreferences : { contextIsolation : true , enableWebSQL : false , disableDialogs : true , spellcheck : false } } ) ; mainWindow . loadFile ( path . join ( __dirname , ".." , "renderer" , "index.html" ) ) ; if ( app . commandLine . hasSwitch ( "dev" ) ) { const devMode = [ "" , "true" ] . includes ( app . commandLine . getSwitchValue ( "dev" ) . toLowerCase ( ) ) ; if ( devMode ) { mainWindow . webContents . openDevTools ( ) ; } } mainWindow . setMenu ( null ) ; } ; app . on ( "ready" , createWindow ) ; app . on ( "window-all-closed" , ( ) => { app . quit ( ) ; } ) ; app . on ( "activate" , ( ) => { if ( BrowserWindow . getAllWindows ( ) . length === 0 ) { createWindow ( ) ; } } ) ; } ) ( ) ;