Skip to content
This repository was archived by the owner on Sep 15, 2020. It is now read-only.

Commit 0796f82

Browse files
committed
chore(gui): add bootstrap and update electron
1 parent 34eebe0 commit 0796f82

File tree

10 files changed

+625
-799
lines changed

10 files changed

+625
-799
lines changed

main.js

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ process.on('unhandledRejection', (reason, promise) => {
7171
function createWindow() {
7272
let args = process.argv.slice(2)
7373
let isDev = args.some(value => value === '--dev')
74-
if (!global.kioskMode) {
74+
if(!global.kioskMode) {
7575
global.kioskMode = args.some(value => value === '--kiosk')
7676
}
7777

@@ -116,11 +116,10 @@ function createWindow() {
116116
// Open the DevTools.
117117
if(isDev) {
118118
win.webContents.openDevTools()
119-
} else if (kioskMode) {
119+
} else if(kioskMode) {
120120
win.removeMenu()
121121
win.setMenu(null)
122-
}
123-
else {
122+
} else {
124123
win.removeMenu()
125124
win.setMenu(null)
126125
appUpdater()

package.json

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,8 @@
7878
},
7979
"dependencies": {
8080
"body-parser": "^1.19.0",
81-
"deep-equal": "^1.1.1",
81+
"bootstrap": "^4.4.1",
82+
"deep-equal": "^2.0.1",
8283
"electron-updater": "^4.2.0",
8384
"express": "^4.17.1",
8485
"gl-matrix": "^3.1.0",
@@ -87,6 +88,7 @@
8788
"portfinder": "^1.0.25",
8889
"promise-retry": "^1",
8990
"react": "^16.12.0",
91+
"react-bootstrap": "^1.0.0-beta.16",
9092
"react-dom": "^16.12.0",
9193
"react-photonkit": "git+https://github.com/octoth0rpe/react-photonkit.git",
9294
"request": "^2.88.0",
@@ -105,7 +107,7 @@
105107
"@types/react-dom": "^16.9.4",
106108
"@types/request": "^2.48.3",
107109
"@types/sax": "^1.2.0",
108-
"electron": "^5.0.12",
110+
"electron": "^7.1.7",
109111
"electron-builder": "^21.2.0",
110112
"jasmine": "^3.5.0",
111113
"jasmine-console-reporter": "^3.1.0",

socha

Submodule socha updated from a419ce1 to 8866759

src/gui/App.tsx

Lines changed: 31 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ export class App extends React.Component<any, State> {
5959

6060
constructor(props) {
6161
super(props)
62-
var remote = require('electron').remote
62+
let remote = require('electron').remote
6363
this.state = {
6464
menuRetracted: remote.getGlobal('kioskMode'),
6565
consoleRetracted: true,
@@ -89,38 +89,37 @@ export class App extends React.Component<any, State> {
8989

9090
private loadReplay() {
9191
dialog.showOpenDialog(
92+
remote.require('browser-window'),
9293
{
9394
title: 'Wähle ein Replay',
9495
properties: ['openFile'],
95-
},
96-
(filenames) => {
97-
// dialog returns undefined when user clicks cancel or an array of strings (paths) if user selected a file
98-
if (filenames && filenames.length > 0 && filenames[0]) {
99-
//window.localStorage[localStorageProgramPath] = filenames[0]
100-
console.log('Attempting to load ' + filenames[0])
101-
let liofs = filenames[0].lastIndexOf('/')
102-
if (liofs == -1) {
103-
liofs = filenames[0].lastIndexOf('\\')
104-
}
105-
let replayName = filenames[0]
106-
if (liofs != -1) {
107-
replayName = replayName.substring(liofs + 1)
108-
}
109-
const liofp = replayName.lastIndexOf('.')
110-
if (liofp != -1) {
111-
replayName = replayName.substring(0, liofp)
112-
}
113-
let gco: Replay = {
114-
gameId: Api.getGameManager().createGameId(replayName, true),
115-
gameName: replayName,
116-
kind: GameType.Replay,
117-
path: filenames[0],
118-
}
119-
//new GameCreationOptions(null, null, filenames[0], StartType.Replay, null, null, null, null, replayName)
120-
this.startGameWithOptions(gco)
96+
}).then(result => {
97+
// dialog returns undefined when user clicks cancel or an array of strings (paths) if user selected a file
98+
if (!result.canceled && result.filePaths.length > 0 && result.filePaths[0]) {
99+
//window.localStorage[localStorageProgramPath] = filenames[0]
100+
console.log('Attempting to load ' + result.filePaths[0])
101+
let liofs = result.filePaths[0].lastIndexOf('/')
102+
if (liofs == -1) {
103+
liofs = result.filePaths[0].lastIndexOf('\\')
121104
}
122-
},
123-
)
105+
let replayName = result.filePaths[0]
106+
if (liofs != -1) {
107+
replayName = replayName.substring(liofs + 1)
108+
}
109+
const liofp = replayName.lastIndexOf('.')
110+
if (liofp != -1) {
111+
replayName = replayName.substring(0, liofp)
112+
}
113+
let gco: Replay = {
114+
gameId: Api.getGameManager().createGameId(replayName, true),
115+
gameName: replayName,
116+
kind: GameType.Replay,
117+
path: result.filePaths[0],
118+
}
119+
//new GameCreationOptions(null, null, filenames[0], StartType.Replay, null, null, null, null, replayName)
120+
this.startGameWithOptions(gco)
121+
}
122+
})
124123
}
125124

126125
private startGameWithOptions(o: GameCreationOptions): Promise<GameInfo> {
@@ -186,8 +185,7 @@ export class App extends React.Component<any, State> {
186185
Api.getGameManager().deleteGame(id)
187186
if (require('electron').remote.getGlobal('kioskMode')) {
188187
this.show(AppContent.GameCreation)
189-
}
190-
else {
188+
} else {
191189
this.show(AppContent.Empty)
192190
}
193191
}
@@ -315,7 +313,7 @@ export class App extends React.Component<any, State> {
315313
{this.state.contentState == AppContent.GameLive ?
316314
<button title="Close Game" className="svg-button close-game"
317315
onClick={() => this.closeGame(this.state.activeGameId)}>
318-
<img className="svg-icon" src={'resources/x-circled.svg'}/>
316+
<img className="svg-icon" src={'resources/x-circled.svg'} alt="Close Game"/>
319317
</button> : null}
320318
<Button icon="doc-text" onClick={() => { this.toggleConsole() }} pullRight={true}/>
321319
</ToolbarActions>
@@ -336,7 +334,7 @@ export class App extends React.Component<any, State> {
336334
this.closeGame(t.id)
337335
e.stopPropagation()
338336
}}>
339-
<img className="svg-icon" src={'resources/x-circled.svg'}/></button></span></NavItem>
337+
<img className="svg-icon" src={'resources/x-circled.svg'} alt={"Close Game"}/></button></span></NavItem>
340338
))}
341339

342340
<NavTitle title="Informationen"/>

src/gui/Game.tsx

Lines changed: 10 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import { Logger } from '../api/Logger
88
import { MessageContent } from '../api/rules/Message'
99
import { AppSettings } from './App'
1010
import * as ReactDOM from 'react-dom'
11+
const ipc = require('electron').ipcRenderer
1112

1213
const dialog = remote.dialog
1314

@@ -129,7 +130,6 @@ export class Game extends React.Component<{ gameId: number, name: string, isRepl
129130
}
130131
})
131132
} else {
132-
const ipc = require('electron').ipcRenderer
133133
ipc.send('showGameErrorBox', 'Ungültiger Zug', this.props.gameId, 'Der Zug von ' + move.fromField + ' nach ' + move.toField + ' ist ungültig!')
134134
}
135135
})
@@ -220,19 +220,17 @@ export class Game extends React.Component<{ gameId: number, name: string, isRepl
220220
saveReplay() {
221221
if (!this.props.isReplay) {
222222
dialog.showSaveDialog(
223+
remote.require('browser-window'),
223224
{
224225
title: 'Wähle einen Ort zum Speichern des Replays',
225226
defaultPath: this.props.name + '.xml',
226227
filters: [{ name: 'Replay-Dateien', extensions: ['xml'] }],
227-
},
228-
filename => {
229-
// dialog returns undefined when user clicks cancel or an array of strings (paths) if user selected a file
230-
if (filename) {
231-
console.log('Attempting to save', filename)
232-
Api.getGameManager().saveReplayOfGame(this.props.gameId, filename)
233-
}
234-
},
235-
)
228+
}).then(result => {
229+
if (!result.canceled && result.filePath) {
230+
console.log('Attempting to save', result.filePath)
231+
Api.getGameManager().saveReplayOfGame(this.props.gameId, result.filePath)
232+
}
233+
})
236234
}
237235
}
238236

@@ -252,8 +250,7 @@ export class Game extends React.Component<{ gameId: number, name: string, isRepl
252250
`Gewinner: ${gameResult.winner.displayName} (${gameResult.winner.color == 'RED' ? 'Rot' : 'Blau'})` :
253251
'Unentschieden!'}</h2>
254252
<h5>
255-
<button className="green-button" onClick={e => {
256-
const ipc = require('electron').ipcRenderer
253+
<button className="green-button" onClick={() => {
257254
ipc.send('kioskGameOver', this.props.gameId)
258255
}}>Neues Spiel beginnen
259256
</button>
@@ -277,8 +274,7 @@ export class Game extends React.Component<{ gameId: number, name: string, isRepl
277274
value={turnActive}
278275
step="1"
279276
onChange={e => this.updateTurn(Number(e.target.value))}/>
280-
<button id="close-game" onClick={e => {
281-
const ipc = require('electron').ipcRenderer
277+
<button id="close-game" onClick={() => {
282278
ipc.send('kioskGameOver', this.props.gameId)
283279
}}>Spiel beenden
284280
</button>

0 commit comments

Comments
 (0)