From 145a2fe77b7d9f2077c94e54912a2526b24fd672 Mon Sep 17 00:00:00 2001 From: Daniel Scalzi Date: Sat, 23 Jun 2018 15:17:26 -0400 Subject: [PATCH] Added initial support for optional mods. Optional mods are stored by ID in the configuration. Their enabled state is stored here. The mod configurations are updated each time the distro index is refreshed. Configurations are stored by server id. If the id no longer exists (changed/removed), the mod configuration is removed. If new optional mods are added, they are added to the configuration. If they are removed, they are removed from the configuration. Currently only top level optional mods are supported. --- app/assets/js/assetguard.js | 14 ++++++ app/assets/js/configmanager.js | 55 +++++++++++++++++++++- app/assets/js/processbuilder.js | 46 +++++++++--------- app/assets/js/scripts/uibinder.js | 77 +++++++++++++++++++++++++++++++ 4 files changed, 166 insertions(+), 26 deletions(-) diff --git a/app/assets/js/assetguard.js b/app/assets/js/assetguard.js index 6def451..dde64c3 100644 --- a/app/assets/js/assetguard.js +++ b/app/assets/js/assetguard.js @@ -247,6 +247,20 @@ class AssetGuard extends EventEmitter { return cs.join('/') } + /** + * Resolves an artiface id without the version. For example, + * 'net.minecraftforge:forge:1.11.2-13.20.0.2282' becomes + * 'net.minecraftforge:forge'. + * + * @param {string} artifactid The artifact id string. + * @returns {string} The resolved identifier without the version. + */ + static _resolveWithoutVersion(artifactid){ + let ps = artifactid.split(':') + + return ps[0] + ':' + ps[1] + } + // #endregion // Static Hash Validation Functions diff --git a/app/assets/js/configmanager.js b/app/assets/js/configmanager.js index 138d28d..5a9bf47 100644 --- a/app/assets/js/configmanager.js +++ b/app/assets/js/configmanager.js @@ -69,7 +69,8 @@ const DEFAULT_CONFIG = { clientToken: uuidV4().replace(/-/g, ''), selectedServer: null, // Resolved selectedAccount: null, - authenticationDatabase: {} + authenticationDatabase: {}, + modConfigurations: [] } let config = null; @@ -92,7 +93,6 @@ exports.save = function(){ */ exports.load = function(){ // Determine the effective configuration. - //const EFFECTIVE_CONFIG = config == null ? DEFAULT_CONFIG : config const filePath = path.join(dataPath, 'config.json') if(!fs.existsSync(filePath)){ @@ -353,6 +353,57 @@ exports.setSelectedAccount = function(uuid){ return authAcc } +/** + * Get an array of each mod configuration currently stored. + * + * @returns {Array.} An array of each stored mod configuration. + */ +exports.getModConfigurations = function(){ + return config.modConfigurations +} + +/** + * Set the array of stored mod configurations. + * + * @param {Array.} configurations An array of mod configurations. + */ +exports.setModConfigurations = function(configurations){ + config.modConfigurations = configurations +} + +/** + * Get the mod configuration for a specific server. + * + * @param {string} serverid The id of the server. + * @returns {Object} The mod configuration for the given server. + */ +exports.getModConfiguration = function(serverid){ + const cfgs = config.modConfigurations + for(let i=0; i { if(data != null) { + syncModConfigurations(data) if(document.readyState === 'complete'){ showMainUI() } else {