From d33476bcf91d0e10ee06145833d13f1b5c4f5bf9 Mon Sep 17 00:00:00 2001 From: Daniel Scalzi Date: Thu, 10 May 2018 00:01:38 -0400 Subject: [PATCH] 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. --- app/assets/js/assetguard.js | 1 + app/assets/js/configmanager.js | 49 ++++++++++++++++++++++++++++++- app/assets/js/processbuilder.js | 7 ++++- app/assets/js/scripts/uibinder.js | 8 ++++- app/assets/westeroscraft.json | 10 +++---- app/overlay.ejs | 8 ----- 6 files changed, 67 insertions(+), 16 deletions(-) diff --git a/app/assets/js/assetguard.js b/app/assets/js/assetguard.js index f75ea8a..aca6e98 100644 --- a/app/assets/js/assetguard.js +++ b/app/assets/js/assetguard.js @@ -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, "..")) diff --git a/app/assets/js/configmanager.js b/app/assets/js/configmanager.js index 9b98737..59c848c 100644 --- a/app/assets/js/configmanager.js +++ b/app/assets/js/configmanager.js @@ -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 { console.log('Minecraft:', data.toString('utf8')) }) diff --git a/app/assets/js/scripts/uibinder.js b/app/assets/js/scripts/uibinder.js index 1b74c72..7d23cce 100644 --- a/app/assets/js/scripts/uibinder.js +++ b/app/assets/js/scripts/uibinder.js @@ -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() diff --git a/app/assets/westeroscraft.json b/app/assets/westeroscraft.json index 5f50db8..6b55dee 100644 --- a/app/assets/westeroscraft.json +++ b/app/assets/westeroscraft.json @@ -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" } diff --git a/app/overlay.ejs b/app/overlay.ejs index bfbe486..f413874 100644 --- a/app/overlay.ejs +++ b/app/overlay.ejs @@ -17,14 +17,6 @@ Select an Account
- -