Skip to content

Commit

Permalink
新功能 退出游戏返回管理器界面 fixed#28
Browse files Browse the repository at this point in the history
  • Loading branch information
iamapig120 committed Feb 6, 2019
1 parent 3053f74 commit 236b108
Show file tree
Hide file tree
Showing 6 changed files with 1,109 additions and 81 deletions.
24 changes: 24 additions & 0 deletions .eslintrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
{
"extends": "eslint:recommended",
"env": {
"browser": true,
"commonjs": true,
"es6": true,
"node": true
},
"parserOptions": {
"ecmaVersion": 2018
},
"rules": {
"indent": [
"error",
2,
{
"SwitchCase": 1
}
],
"linebreak-style": ["error", "windows"],
"quotes": ["error", "single"],
"semi": ["error", "never"]
}
}
3 changes: 2 additions & 1 deletion configs-user.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@
"zoomFactor": 1,
"renderingMultiple": 100,
"isKioskModeOn": false,
"isNoBorder": false
"isNoBorder": false,
"isManagerHide": false
},
"update": {
"prerelease": false
Expand Down
19 changes: 18 additions & 1 deletion index.js
Original file line number Diff line number Diff line change
Expand Up @@ -307,6 +307,11 @@ const windowControl = {
})
gameWindow.on('closed', () => {
Util.shutoffPlayer()
sererHttps.close()
if (userConfigs.window.isManagerHide) {
const managerWindow = windowControl.windowMap['manager']
managerWindow && managerWindow.show()
}
})
Util.initPlayer()
gameWindow.webContents.on('crashed', () =>
Expand Down Expand Up @@ -344,6 +349,14 @@ const windowControl = {
managerWindow && managerWindow.close()
},

hideManagerWindow: () => {
/**
* @type {Electron.BrowserWindow}
*/
const managerWindow = windowControl.windowMap['manager']
managerWindow && managerWindow.hide()
},

addAppListener: () => {
ipcMain.on('application-message', (evt, ...args) => {
if (args && args.length > 0) {
Expand All @@ -353,7 +366,11 @@ const windowControl = {
.initLocalMirrorServer(sererHttps, configs.SERVER_PORT)
.then(() => {
windowControl.initGameWindow(configs.GAME_WINDOW_CONFIG)
windowControl.closeManagerWindow()
if (userConfigs.window.isManagerHide) {
windowControl.hideManagerWindow()
} else {
windowControl.closeManagerWindow()
}
})
break
}
Expand Down
15 changes: 10 additions & 5 deletions manager/manager.js
Original file line number Diff line number Diff line change
Expand Up @@ -999,7 +999,8 @@ const getKeyText = key => {
'使用AppData存储扩展资源(Use AppData dir to storage resources)',
userLibPath: '用户库目录',
programName: '雀魂Plus(Majsoul Plus)',
localVersion: '版本(Version)'
localVersion: '版本(Version)',
isManagerHide: '退出游戏后回到管理器界面(Exit back to manager panel)'
}
return lang[key] ? lang[key] : key
}
Expand Down Expand Up @@ -1108,13 +1109,17 @@ userConfigInit()
aboutPageInit()

const saveConfigsBtn = document.getElementById('saveConfigs')
const saveUserConfigs = () => {
const saveUserConfigs = (alertMsg = true) => {
try {
fs.writeFileSync(configs.USER_CONFIG_PATH, JSON.stringify(userConfig))
ipcRenderer.send('application-message', 'update-user-config')
alert('保存成功')
if (alertMsg === true) {
alert('保存成功')
}
} catch (error) {
alert('保存失败\n' + error)
if (alertMsg === true) {
alert('保存失败\n' + error)
}
}
}
saveConfigsBtn.addEventListener('click', saveUserConfigs)
Expand Down Expand Up @@ -1152,7 +1157,7 @@ setTimeout(() => {
*/
const startGame = () => {
saveSettings()
saveUserConfigs()
saveUserConfigs(false)
ipcRenderer.send('application-message', 'start-game')
}

Expand Down
Loading

0 comments on commit 236b108

Please sign in to comment.