mirror of
https://github.com/dscalzi/HeliosLauncher.git
synced 2024-12-22 11:42:14 -08:00
ConfigManager improvements. v0.0.1-alpha.1
Added new configuration option, launchDetached. Added validation function to ConfigManager to add missing keys (due to updates). Updated westeroscraft.json Game process can now be detached from the launcher.
This commit is contained in:
parent
f1a98f2d45
commit
d33476bcf9
@ -1562,6 +1562,7 @@ class AssetGuard extends EventEmitter {
|
||||
if(concurrentDlQueue.length === 0){
|
||||
return false
|
||||
} else {
|
||||
console.debug('DLQueue', concurrentDlQueue)
|
||||
async.eachLimit(concurrentDlQueue, limit, (asset, cb) => {
|
||||
let count = 0;
|
||||
mkpath.sync(path.join(asset.to, ".."))
|
||||
|
@ -38,7 +38,8 @@ const DEFAULT_CONFIG = {
|
||||
resWidth: 1280,
|
||||
resHeight: 720,
|
||||
fullscreen: false,
|
||||
autoConnect: true
|
||||
autoConnect: true,
|
||||
launchDetached: true
|
||||
},
|
||||
launcher: {}
|
||||
},
|
||||
@ -78,9 +79,36 @@ exports.load = function(){
|
||||
exports.save()
|
||||
} else {
|
||||
config = JSON.parse(fs.readFileSync(filePath, 'UTF-8'))
|
||||
config = validateKeySet(DEFAULT_CONFIG, config)
|
||||
exports.save()
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Validate that the destination object has at least every field
|
||||
* present in the source object. Assign a default value otherwise.
|
||||
*
|
||||
* @param {Object} srcObj The source object to reference against.
|
||||
* @param {Object} destObj The destination object.
|
||||
* @returns {Object} A validated destination object.
|
||||
*/
|
||||
function validateKeySet(srcObj, destObj){
|
||||
if(srcObj == null){
|
||||
srcObj = {}
|
||||
}
|
||||
const validationBlacklist = ['authenticationDatabase']
|
||||
const keys = Object.keys(srcObj)
|
||||
console.log(keys)
|
||||
for(let i=0; i<keys.length; i++){
|
||||
if(typeof destObj[keys[i]] === 'undefined'){
|
||||
destObj[keys[i]] = srcObj[keys[i]]
|
||||
} else if(typeof srcObj[keys[i]] === 'object' && srcObj[keys[i]] != null && !(srcObj[keys[i]] instanceof Array) && validationBlacklist.indexOf(keys[i]) === -1){
|
||||
destObj[keys[i]] = validateKeySet(srcObj[keys[i]], destObj[keys[i]])
|
||||
}
|
||||
}
|
||||
return destObj
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieve the absolute path of the launcher directory.
|
||||
*
|
||||
@ -444,3 +472,22 @@ exports.isAutoConnect = function(def = false){
|
||||
exports.setAutoConnect = function(autoConnect){
|
||||
config.settings.game.autoConnect = autoConnect
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if the game should launch as a detached process.
|
||||
*
|
||||
* @param {boolean} def Optional. If true, the default value will be returned.
|
||||
* @returns {boolean} Whether or not the game will launch as a detached process.
|
||||
*/
|
||||
exports.isLaunchDetached = function(def = false){
|
||||
return !def ? config.settings.game.launchDetached : DEFAULT_CONFIG.settings.game.launchDetached
|
||||
}
|
||||
|
||||
/**
|
||||
* Change the status of whether or not the game should launch as a detached process.
|
||||
*
|
||||
* @param {boolean} launchDetached Whether or not the game should launch as a detached process.
|
||||
*/
|
||||
exports.setLaunchDetached = function(launchDetached){
|
||||
config.settings.game.launchDetached = launchDetached
|
||||
}
|
@ -44,9 +44,14 @@ class ProcessBuilder {
|
||||
console.log(args)
|
||||
|
||||
const child = child_process.spawn(ConfigManager.getJavaExecutable(), args, {
|
||||
cwd: ConfigManager.getGameDirectory()
|
||||
cwd: ConfigManager.getGameDirectory(),
|
||||
detached: ConfigManager.isLaunchDetached()
|
||||
})
|
||||
|
||||
if(ConfigManager.isLaunchDetached()){
|
||||
child.unref()
|
||||
}
|
||||
|
||||
child.stdout.on('data', (data) => {
|
||||
console.log('Minecraft:', data.toString('utf8'))
|
||||
})
|
||||
|
@ -72,7 +72,7 @@ function showMainUI(){
|
||||
$('#loadingContainer').fadeOut(500, () => {
|
||||
$('#loadSpinnerImage').removeClass('rotating')
|
||||
})
|
||||
}, 500)
|
||||
}, 250)
|
||||
|
||||
}, 750)
|
||||
initNews()
|
||||
@ -160,6 +160,12 @@ async function validateSelectedAccount(){
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Temporary function to update the selected account along
|
||||
* with the relevent UI elements.
|
||||
*
|
||||
* @param {string} uuid The UUID of the account.
|
||||
*/
|
||||
function setSelectedAccount(uuid){
|
||||
const authAcc = ConfigManager.setSelectedAccount(uuid)
|
||||
ConfigManager.save()
|
||||
|
@ -15,7 +15,7 @@
|
||||
"name": "WesterosCraft Production Server",
|
||||
"description": "Main WesterosCraft server. Connect to enter the Realm.",
|
||||
"icon_url": "http://mc.westeroscraft.com/WesterosCraftLauncher/files/server-prod.png",
|
||||
"revision": "3.7.1",
|
||||
"revision": "3.7.2",
|
||||
"server_ip": "mc.westeroscraft.com",
|
||||
"mc_version": "1.11.2",
|
||||
"discord": {
|
||||
@ -238,12 +238,12 @@
|
||||
]
|
||||
},
|
||||
{
|
||||
"id": "net.optifine:optifine:1.11.2_HD_U_C3",
|
||||
"name": "Optifine (1.11.2_HD_U_C3)",
|
||||
"id": "net.optifine:optifine:1.11.2_HD_U_C7",
|
||||
"name": "Optifine (1.11.2_HD_U_C7)",
|
||||
"type": "forgemod",
|
||||
"artifact": {
|
||||
"size": 2106193,
|
||||
"MD5": "82f495594cd50e1fda7a8aa0246239fc",
|
||||
"size": 2254712,
|
||||
"MD5": "0dd7761e908f9b245bb0dc0fac5649f5",
|
||||
"extension": ".jar",
|
||||
"url": "http://mc.westeroscraft.com/WesterosCraftLauncher/prod-1.11.2/mods/OptiFine.jar"
|
||||
}
|
||||
|
@ -17,14 +17,6 @@
|
||||
<span id="accountSelectHeader">Select an Account</span>
|
||||
<div id="accountSelectList">
|
||||
<div id="accountSelectListScrollable">
|
||||
<button class="accountListing" uuid="fead86af28284e4e90d4cc5b9eb3ae84">
|
||||
<img src="https://crafatar.com/renders/head/fead86af28284e4e90d4cc5b9eb3ae84?scale=2&default=MHF_Steve&overlay">
|
||||
<div class="accountListingName">TheKraken7</div>
|
||||
</button>
|
||||
<button class="accountListing" uuid="48f0a3d02ae14ca4aa0011bb8bc4f39e">
|
||||
<img src="https://crafatar.com/renders/head/48f0a3d02ae14ca4aa0011bb8bc4f39e?scale=2&default=MHF_Steve&overlay">
|
||||
<div class="accountListingName">iPepsiHD</div>
|
||||
</button>
|
||||
<!-- Accounts populated here. -->
|
||||
</div>
|
||||
</div>
|
||||
|
Loading…
Reference in New Issue
Block a user