Skip to content

Commit

Permalink
Debug flag
Browse files Browse the repository at this point in the history
This flag will impact the corresponding menu item.
  • Loading branch information
Mathias Oberson committed Apr 22, 2017
1 parent 6e393ac commit cbaeb7a
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 18 deletions.
12 changes: 6 additions & 6 deletions app/lib/windows-manager.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ const electron = require('electron')
const BrowserWindow = electron.BrowserWindow
const path = require('path')
const url = require('url')
const MenuItems = require(path.join(__dirname, 'get-menu-item.js'))
const AppMenuItems = require(path.join(__dirname, 'get-menu-item.js'))

// Global references to the windows created
const wins = {}
Expand Down Expand Up @@ -91,12 +91,12 @@ function toggleSpectatorView() {
if (wins.spectator.isVisible()) {
wins.spectator.isFullScreen() && spectatorViewFullScreen(false)
wins.spectator.hide()
MenuItems.switchSpectatorView(false)
MenuItems.enableSpectatorViewItems(false)
AppMenuItems.switchSpectatorView(false)
AppMenuItems.enableSpectatorViewItems(false)
} else {
wins.spectator.show()
MenuItems.switchSpectatorView(true)
MenuItems.enableSpectatorViewItems(true)
AppMenuItems.switchSpectatorView(true)
AppMenuItems.enableSpectatorViewItems(true)
}
}

Expand All @@ -110,7 +110,7 @@ function toggleSpectatorView() {
*/
function spectatorViewFullScreen(state) {
wins.spectator.setFullScreen(state)
MenuItems.switchFullScreen(state)
AppMenuItems.switchFullScreen(state)
}

/**
Expand Down
29 changes: 17 additions & 12 deletions app/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,18 @@ const electron = require('electron')
const app = electron.app
const BrowserWindow = electron.BrowserWindow
const Menu = electron.Menu
const MenuItem = electron.MenuItem
const globalShortcut = electron.globalShortcut
const ipc = electron.ipcMain
const path = require('path')
const url = require('url')
const events = require(path.join(__dirname, 'lib', 'event-service.js'))
const MenuItems = require(path.join(__dirname, 'lib', 'get-menu-item.js'))
const AppMenuItems = require(path.join(__dirname, 'lib', 'get-menu-item.js'))
const WindowsManager = require(path.join(__dirname, 'lib', 'windows-manager.js'))
const Settings = require(path.join(__dirname, 'lib', 'settings-constants.js'))

const DEBUG = false

// Keep a global reference of the window object, if you don't, the window will
// be closed automatically when the JavaScript object is garbage collected.
let wins = WindowsManager.repository
Expand Down Expand Up @@ -58,9 +61,9 @@ ipc.on(events.nbPlayerSelected, (event, args) => {
wins.spectator.webContents.send(events.nbPlayerSelected, args)
})

ipc.on(events.enableNewPlayerMenuItem, () => MenuItems.addNewPlayer().enabled = true)
ipc.on(events.enableNewPlayerMenuItem, () => AppMenuItems.addNewPlayer().enabled = true)

ipc.on(events.disableNewPlayerMenuItem, () => MenuItems.addNewPlayer().enabled = false)
ipc.on(events.disableNewPlayerMenuItem, () => AppMenuItems.addNewPlayer().enabled = false)

ipc.on(events.updatePlayerName, (event, args) => wins.spectator.webContents.send(events.updatePlayerName, args))
ipc.on(events.updatePlayerScore, (event, args) => wins.spectator.webContents.send(events.updatePlayerScore, args))
Expand Down Expand Up @@ -176,18 +179,20 @@ function AppMenu() {
]
}
]
}, {
role: 'quit',
label: 'Fermer'
}, {
}
]
const AppMenu = Menu.buildFromTemplate(menuTemplate)
if (DEBUG) {
const debugMenuItem = new MenuItem({
label: 'Debug',
submenu: [
{ role: 'toggledevtools' },
{ role: 'reload' }
]
}
]
const AppMenu = Menu.buildFromTemplate(menuTemplate)
})

AppMenu.append(debugMenuItem)
}
return AppMenu
}

Expand All @@ -202,14 +207,14 @@ function addNewPlayer() {
function setVerticalDisplay() {
if (wins.spectator.isVisible()) {
changeDisplayType(Settings.VERTICAL_VIEW_TYPE)
MenuItems.verticalDisplay().checked = true
AppMenuItems.verticalDisplay().checked = true
}
}

function setHorizontalDisplay() {
if (wins.spectator.isVisible()) {
changeDisplayType(Settings.HORIZONTAL_VIEW_TYPE)
MenuItems.horizontalDisplay().checked = true
AppMenuItems.horizontalDisplay().checked = true
}
}

Expand Down

0 comments on commit cbaeb7a

Please sign in to comment.