mirror of
https://github.com/dscalzi/HeliosLauncher.git
synced 2024-12-22 11:42:14 -08:00
Mod config bug fixes, electron upgrade.
If the instance mods directory does not exist when the 'Add Drop-In Mod' button is clicked, it will be created. The update selected server code has been modified. Previously, the server would be updated before the mod config was saved. This has been fixed so that the mod config is saved before the server is switched. Updated electron to v3.0.10.
This commit is contained in:
parent
79d1d59451
commit
684e884d9c
@ -1,4 +1,5 @@
|
||||
const fs = require('fs')
|
||||
const mkpath = require('mkdirp')
|
||||
const path = require('path')
|
||||
const { shell } = require('electron')
|
||||
|
||||
@ -8,6 +9,18 @@ const { shell } = require('electron')
|
||||
const MOD_REGEX = /^(.+(jar|zip|litemod))(?:\.(disabled))?$/
|
||||
const DISABLED_EXT = '.disabled'
|
||||
|
||||
/**
|
||||
* Validate that the given mods directory exists. If not,
|
||||
* it is created.
|
||||
*
|
||||
* @param {string} modsDir The path to the mods directory.
|
||||
*/
|
||||
exports.validateModsDir = function(modsDir) {
|
||||
if(!fs.existsSync(modsDir)) {
|
||||
mkpath.sync(modsDir)
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Scan for drop-in mods in both the mods folder and version
|
||||
* safe mods folder.
|
||||
|
@ -136,17 +136,20 @@ function updateSelectedAccount(authUser){
|
||||
updateSelectedAccount(ConfigManager.getSelectedAccount())
|
||||
|
||||
// Bind selected server
|
||||
function updateSelectedServer(serverName){
|
||||
if(serverName == null){
|
||||
serverName = 'No Server Selected'
|
||||
function updateSelectedServer(serv){
|
||||
if(getCurrentView() === VIEWS.settings){
|
||||
saveAllModConfigurations()
|
||||
}
|
||||
server_selection_button.innerHTML = '\u2022 ' + serverName
|
||||
ConfigManager.setSelectedServer(serv != null ? serv.getID() : null)
|
||||
ConfigManager.save()
|
||||
server_selection_button.innerHTML = '\u2022 ' + (serv != null ? serv.getName() : 'No Server Selected')
|
||||
if(getCurrentView() === VIEWS.settings){
|
||||
animateModsTabRefresh()
|
||||
}
|
||||
setLaunchEnabled(serv != null)
|
||||
}
|
||||
// Real text is set in uibinder.js on distributionIndexDone.
|
||||
updateSelectedServer('Loading..')
|
||||
server_selection_button.innerHTML = '\u2022 Loading..'
|
||||
server_selection_button.onclick = (e) => {
|
||||
e.target.blur()
|
||||
toggleServerSelection(true)
|
||||
|
@ -176,10 +176,7 @@ document.getElementById('serverSelectConfirm').addEventListener('click', () => {
|
||||
for(let i=0; i<listings.length; i++){
|
||||
if(listings[i].hasAttribute('selected')){
|
||||
const serv = DistroManager.getDistribution().getServer(listings[i].getAttribute('servid'))
|
||||
ConfigManager.setSelectedServer(serv != null ? serv.getID() : null)
|
||||
ConfigManager.save()
|
||||
updateSelectedServer(serv != null ? serv.getName() : null)
|
||||
setLaunchEnabled(serv != null)
|
||||
updateSelectedServer(serv)
|
||||
refreshServerStatus(true)
|
||||
toggleOverlay(false)
|
||||
return
|
||||
@ -187,9 +184,8 @@ document.getElementById('serverSelectConfirm').addEventListener('click', () => {
|
||||
}
|
||||
// None are selected? Not possible right? Meh, handle it.
|
||||
if(listings.length > 0){
|
||||
ConfigManager.setSelectedServer(listings[0].getAttribute('servid'))
|
||||
ConfigManager.save()
|
||||
updateSelectedServer()
|
||||
const serv = DistroManager.getDistribution().getServer(listings[i].getAttribute('servid'))
|
||||
updateSelectedServer(serv)
|
||||
toggleOverlay(false)
|
||||
}
|
||||
})
|
||||
|
@ -552,7 +552,7 @@ function saveModConfiguration(){
|
||||
* @param {Object} modConf Mod config object to save.
|
||||
*/
|
||||
function _saveModConfiguration(modConf){
|
||||
for(m of Object.entries(modConf)){
|
||||
for(let m of Object.entries(modConf)){
|
||||
const tSwitch = settingsModsContainer.querySelectorAll(`[formod='${m[0]}']`)
|
||||
if(!tSwitch[0].hasAttribute('dropin')){
|
||||
if(typeof m[1] === 'boolean'){
|
||||
@ -640,6 +640,7 @@ function bindDropinModsRemoveButton(){
|
||||
function bindDropinModFileSystemButton(){
|
||||
const fsBtn = document.getElementById('settingsDropinFileSystemButton')
|
||||
fsBtn.onclick = () => {
|
||||
DropinModUtil.validateModsDir(CACHE_SETTINGS_MODS_DIR)
|
||||
shell.openItem(CACHE_SETTINGS_MODS_DIR)
|
||||
}
|
||||
}
|
||||
@ -720,15 +721,21 @@ document.getElementById('settingsSwitchServerButton').addEventListener('click',
|
||||
toggleServerSelection(true)
|
||||
})
|
||||
|
||||
/**
|
||||
* Save mod configuration for the current selected server.
|
||||
*/
|
||||
function saveAllModConfigurations(){
|
||||
saveModConfiguration()
|
||||
ConfigManager.save()
|
||||
saveDropinModConfiguration()
|
||||
}
|
||||
|
||||
/**
|
||||
* Function to refresh the mods tab whenever the selected
|
||||
* server is changed.
|
||||
*/
|
||||
function animateModsTabRefresh(){
|
||||
$('#settingsTabMods').fadeOut(500, () => {
|
||||
saveModConfiguration()
|
||||
ConfigManager.save()
|
||||
saveDropinModConfiguration()
|
||||
prepareModsTab()
|
||||
$('#settingsTabMods').fadeIn(500)
|
||||
})
|
||||
|
@ -61,7 +61,7 @@ function showMainUI(data){
|
||||
ipcRenderer.send('autoUpdateAction', 'initAutoUpdater', ConfigManager.getAllowPrerelease())
|
||||
}
|
||||
|
||||
updateSelectedServer(data.getServer(ConfigManager.getSelectedServer()).getName())
|
||||
updateSelectedServer(data.getServer(ConfigManager.getSelectedServer()))
|
||||
refreshServerStatus()
|
||||
setTimeout(() => {
|
||||
document.getElementById('frameBar').style.backgroundColor = 'rgba(0, 0, 0, 0.5)'
|
||||
@ -126,7 +126,7 @@ function showFatalStartupError(){
|
||||
* @param {Object} data The distro index object.
|
||||
*/
|
||||
function onDistroRefresh(data){
|
||||
updateSelectedServer(data.getServer(ConfigManager.getSelectedServer()).getName())
|
||||
updateSelectedServer(data.getServer(ConfigManager.getSelectedServer()))
|
||||
refreshServerStatus()
|
||||
initNews()
|
||||
syncModConfigurations(data)
|
||||
|
12
package-lock.json
generated
12
package-lock.json
generated
@ -31,9 +31,9 @@
|
||||
}
|
||||
},
|
||||
"@types/node": {
|
||||
"version": "8.10.37",
|
||||
"resolved": "https://registry.npmjs.org/@types/node/-/node-8.10.37.tgz",
|
||||
"integrity": "sha512-Jp39foY8Euv/PG4OGPyzxis82mnjcUtXLEMA8oFMCE4ilmuJgZPdV2nZNV1moz+99EJTtcpOSgDCgATUwABKig==",
|
||||
"version": "8.10.38",
|
||||
"resolved": "https://registry.npmjs.org/@types/node/-/node-8.10.38.tgz",
|
||||
"integrity": "sha512-EibsnbJerd0hBFaDjJStFrVbVBAtOy4dgL8zZFw0uOvPqzBAX59Ci8cgjg3+RgJIWhsB5A4c+pi+D4P9tQQh/A==",
|
||||
"dev": true
|
||||
},
|
||||
"acorn": {
|
||||
@ -936,9 +936,9 @@
|
||||
}
|
||||
},
|
||||
"electron": {
|
||||
"version": "3.0.9",
|
||||
"resolved": "https://registry.npmjs.org/electron/-/electron-3.0.9.tgz",
|
||||
"integrity": "sha512-OoSoeUWo9PzbArgrwS1yTfTRSlpXmIgrFGWUuUZCjKAk4DGR70elHDNeRnnBJ9NTwXXZVifChcfx73Ah3GnlVQ==",
|
||||
"version": "3.0.10",
|
||||
"resolved": "https://registry.npmjs.org/electron/-/electron-3.0.10.tgz",
|
||||
"integrity": "sha512-I39IeQP3NOlbjKzTDK8uK2JdiHDfhV5SruCS2Gttkn2MaKCY+yIzQ6Wr4DyBXLeTEkL1sbZxbqQVhCavAliv5w==",
|
||||
"dev": true,
|
||||
"requires": {
|
||||
"@types/node": "^8.0.24",
|
||||
|
@ -42,7 +42,7 @@
|
||||
},
|
||||
"devDependencies": {
|
||||
"cross-env": "^5.2.0",
|
||||
"electron": "^3.0.9",
|
||||
"electron": "^3.0.10",
|
||||
"electron-builder": "^20.36.2",
|
||||
"eslint": "^5.9.0"
|
||||
},
|
||||
|
Loading…
Reference in New Issue
Block a user