Skip to content

Commit

Permalink
v1.4.0 - Added Shader Options, Electron v4.
Browse files Browse the repository at this point in the history
  • Loading branch information
dscalzi committed Dec 21, 2018
1 parent b98a4ec commit be533af
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 5 deletions.
12 changes: 7 additions & 5 deletions app/assets/js/dropinmodutil.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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)
Expand All @@ -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'})
Expand All @@ -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)

Expand Down
1 change: 1 addition & 0 deletions app/assets/js/scripts/settings.js
Original file line number Diff line number Diff line change
Expand Up @@ -817,6 +817,7 @@ function bindShaderpackButton() {
e.preventDefault()

DropinModUtil.addShaderpacks(e.dataTransfer.files, CACHE_SETTINGS_INSTANCE_DIR)
saveShaderpackSettings()
resolveShaderpacksForUI()
}
}
Expand Down

0 comments on commit be533af

Please sign in to comment.