From be533af38b17d202426b8a141b53baf731af9845 Mon Sep 17 00:00:00 2001 From: Daniel Scalzi Date: Fri, 21 Dec 2018 16:06:34 -0500 Subject: [PATCH] v1.4.0 - Added Shader Options, Electron v4. --- app/assets/js/dropinmodutil.js | 12 +++++++----- app/assets/js/scripts/settings.js | 1 + 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/app/assets/js/dropinmodutil.js b/app/assets/js/dropinmodutil.js index ebc8e88b6a..0a61012e3a 100644 --- a/app/assets/js/dropinmodutil.js +++ b/app/assets/js/dropinmodutil.js @@ -10,6 +10,8 @@ const DISABLED_EXT = '.disabled' const SHADER_REGEX = /^(.+)\.zip$/ const SHADER_OPTION = /shaderPack=(.+)/ +const SHADER_DIR = 'shaderpacks' +const SHADER_CONFIG = 'optionsshaders.txt' /** * Validate that the given directory exists. If not, it is @@ -145,10 +147,10 @@ exports.isDropinModEnabled = function(fullName){ * An array of objects storing metadata about each discovered shaderpack. */ exports.scanForShaderpacks = function(instanceDir){ - const shaderDir = path.join(instanceDir, 'shaderpacks') + const shaderDir = path.join(instanceDir, SHADER_DIR) const packsDiscovered = [{ fullName: 'OFF', - name: 'No Shaderpack' + name: 'Off (Default)' }] if(fs.existsSync(shaderDir)){ let modCandidates = fs.readdirSync(shaderDir) @@ -176,7 +178,7 @@ exports.scanForShaderpacks = function(instanceDir){ exports.getEnabledShaderpack = function(instanceDir){ exports.validateDir(instanceDir) - const optionsShaders = path.join(instanceDir, 'optionsshaders.txt') + const optionsShaders = path.join(instanceDir, SHADER_CONFIG) if(fs.existsSync(optionsShaders)){ const buf = fs.readFileSync(optionsShaders, {encoding: 'utf-8'}) const match = SHADER_OPTION.exec(buf) @@ -198,7 +200,7 @@ exports.getEnabledShaderpack = function(instanceDir){ exports.setEnabledShaderpack = function(instanceDir, pack){ exports.validateDir(instanceDir) - const optionsShaders = path.join(instanceDir, 'optionsshaders.txt') + const optionsShaders = path.join(instanceDir, SHADER_CONFIG) let buf if(fs.existsSync(optionsShaders)){ buf = fs.readFileSync(optionsShaders, {encoding: 'utf-8'}) @@ -217,7 +219,7 @@ exports.setEnabledShaderpack = function(instanceDir, pack){ */ exports.addShaderpacks = function(files, instanceDir) { - const p = path.join(instanceDir, 'shaderpacks') + const p = path.join(instanceDir, SHADER_DIR) exports.validateDir(p) diff --git a/app/assets/js/scripts/settings.js b/app/assets/js/scripts/settings.js index db9f28a75f..677451d5ad 100644 --- a/app/assets/js/scripts/settings.js +++ b/app/assets/js/scripts/settings.js @@ -817,6 +817,7 @@ function bindShaderpackButton() { e.preventDefault() DropinModUtil.addShaderpacks(e.dataTransfer.files, CACHE_SETTINGS_INSTANCE_DIR) + saveShaderpackSettings() resolveShaderpacksForUI() } }