misc: rename launcher>->server event

This commit is contained in:
jean-emmanuel 2022-11-26 18:33:53 +01:00
parent b2dced4cda
commit 924b3c924e
3 changed files with 12 additions and 12 deletions

View file

@ -25,7 +25,7 @@ class Settings {
this.create()
this.write(true)
ipcRenderer.on('server-started', ()=>{
ipcRenderer.on('server-starting', ()=>{
this.disable()
})
ipcRenderer.on('server-stopped', ()=>{

View file

@ -6,13 +6,13 @@ var {ipcRenderer} = require('electron'),
settings = require('./settings'),
keyboardJS = require('keyboardjs/dist/keyboard.min.js'),
{midilist, openDocs} = remote.getGlobal('launcherSharedGlobals'),
serverStarted = false,
serverStarting = false,
serverStart = ()=>{
if (serverStarted) return
if (serverStarting) return
ipcRenderer.send('start')
},
serverStop = ()=>{
if (!serverStarted) return
if (!serverStarting) return
ipcRenderer.send('stop')
}
@ -176,9 +176,9 @@ class Toolbar {
this.container.addEventListener('click', (e)=>{
this.container.classList.add('on')
start.visible = !serverStarted
stop.visible = !!serverStarted
newWindow.visible = !!serverStarted
start.visible = !serverStarting
stop.visible = !!serverStarting
newWindow.visible = !!serverStarting
menu.popup({window: remote.getCurrentWindow(), x: parseInt(PXSCALE), y: parseInt(40 * PXSCALE)})
})
@ -187,16 +187,16 @@ class Toolbar {
})
this.startButton.addEventListener('click', (e)=>{
if (!serverStarted) serverStart()
if (!serverStarting) serverStart()
else serverStop()
})
ipcRenderer.on('server-started', ()=>{
serverStarted = true
ipcRenderer.on('server-starting', ()=>{
serverStarting = true
this.startButton.classList.add('started')
})
ipcRenderer.on('server-stopped', ()=>{
serverStarted = false
serverStarting = false
this.startButton.classList.remove('started')
})

View file

@ -141,7 +141,7 @@ function startServerProcess() {
serverProcess.on('close', (code) => {
if (!launcher.isDestroyed()) launcher.webContents.send('server-stopped')
})
launcher.webContents.send('server-started')
launcher.webContents.send('server-starting')
}
}