diff --git a/app/assets/css/launcher.css b/app/assets/css/launcher.css index 8df8ccf..2037221 100644 --- a/app/assets/css/launcher.css +++ b/app/assets/css/launcher.css @@ -1342,6 +1342,7 @@ input:checked + .toggleSwitchSlider:before { display: flex; flex-direction: column; border-bottom: 1px solid rgba(255, 255, 255, 0.50); + margin-bottom: 20px; } #settingsMemoryTitle { @@ -1413,6 +1414,85 @@ input:checked + .toggleSwitchSlider:before { font-size: 16px; } +#settingsJavaExecContainer { + display: flex; + flex-direction: column; + border-bottom: 1px solid rgba(255, 255, 255, 0.50); + margin-bottom: 20px; + width: 75%; +} + +#settingsJavaExecTitle { + margin-bottom: 10px; +} + +#settingsJavaExecDetails { + font-weight: bold; + color: grey; + font-size: 12px; +} + +#settingsJavaExecActions { + display: flex; +} + +#settingsJavaExecIcon { + display: flex; + align-items: center; + background: rgba(126, 126, 126, 0.57); + border-radius: 3px 0px 0px 3px; + padding: 5px; +} +#settingsJavaExecSVG { + width: 20px; + height: 20px; + fill: white; +} + +#settingsJavaExecVal { + border-radius: 0px !important; + width: 70%; + padding: 5px 10px; + font-size: 12px; +} + +#settingsJavaExecSel { + width: 0px; + height: 0px; + opacity: 0; +} +#settingsJavaExecSel::-webkit-file-upload-button { + display: none; +} + +#settingsJavaExecLabel { + border-left: 0px; + border-radius: 0px 3px 3px 0px; + font-size: 12px; + padding: 0px 5px; + cursor: pointer; + display: flex; + align-items: center; + background: rgba(126, 126, 126, 0.57); + transition: 0.25s ease; +} +#settingsJavaExecLabel:hover, +#settingsJavaExecLabel:focus, +#settingsJavaExecSel:focus ~ #settingsJavaExecLabel { + text-shadow: 0px 0px 20px white; +} + +#settingsJavaExecDesc { + font-size: 10px; + margin: 20px 0px; + color: lightgrey; + font-weight: bold; + width: 89%; +} +#settingsJavaExecDesc strong { + font-family: 'Avenir Medium'; +} + /******************************************************************************* * * * Landing View (Structural Styles) * diff --git a/app/assets/js/assetguard.js b/app/assets/js/assetguard.js index 07d9e4f..6def451 100644 --- a/app/assets/js/assetguard.js +++ b/app/assets/js/assetguard.js @@ -767,7 +767,9 @@ class AssetGuard extends EventEmitter { static _validateJavaBinary(binaryExecPath){ return new Promise((resolve, reject) => { - if(fs.existsSync(binaryExecPath)){ + if(!AssetGuard.isJavaExecPath(binaryExecPath)){ + resolve({valid: false}) + } else if(fs.existsSync(binaryExecPath)){ child_process.exec('"' + binaryExecPath + '" -XshowSettings:properties', (err, stdout, stderr) => { try { // Output is stored in stderr? diff --git a/app/assets/js/scripts/landing.js b/app/assets/js/scripts/landing.js index 7b027e6..c62b3a0 100644 --- a/app/assets/js/scripts/landing.js +++ b/app/assets/js/scripts/landing.js @@ -313,12 +313,16 @@ function asyncSystemScan(launchAfter = true){ }) toggleOverlay(true, true) - // TODO Add option to not install Java x64. - } else { // Java installation found, use this to launch the game. ConfigManager.setJavaExecutable(m.result) ConfigManager.save() + + // We need to make sure that the updated value is on the settings UI. + // Just incase the settings UI is already open. + settingsJavaExecVal.value = m.result + populateJavaExecDetails(settingsJavaExecVal.value) + if(launchAfter){ dlAsync() } diff --git a/app/assets/js/scripts/settings.js b/app/assets/js/scripts/settings.js index d82ad8f..e3958fa 100644 --- a/app/assets/js/scripts/settings.js +++ b/app/assets/js/scripts/settings.js @@ -17,6 +17,9 @@ const settingsMaxRAMLabel = document.getElementById('settingsMaxRAMLabel') const settingsMinRAMLabel = document.getElementById('settingsMinRAMLabel') const settingsMemoryTotal = document.getElementById('settingsMemoryTotal') const settingsMemoryAvail = document.getElementById('settingsMemoryAvail') +const settingsJavaExecDetails = document.getElementById('settingsJavaExecDetails') +const settingsJavaExecVal = document.getElementById('settingsJavaExecVal') +const settingsJavaExecSel = document.getElementById('settingsJavaExecSel') const settingsState = { invalid: new Set() @@ -74,6 +77,12 @@ function initSettingsValues(){ if(v.tagName === 'INPUT'){ if(v.type === 'number' || v.type === 'text'){ v.value = gFn() + + // Special Conditions + const cVal = v.getAttribute('cValue') + if(cVal === 'JavaExecutable'){ + populateJavaExecDetails(v.value) + } } else if(v.type === 'checkbox'){ v.checked = gFn() } @@ -414,6 +423,21 @@ settingsMaxRAMRange.onchange = (e) => { settingsMaxRAMLabel.innerHTML = sMaxV.toFixed(1) + 'G' } +settingsJavaExecSel.onchange = (e) => { + settingsJavaExecVal.value = settingsJavaExecSel.files[0].path + populateJavaExecDetails(settingsJavaExecVal.value) +} + +function populateJavaExecDetails(execPath){ + AssetGuard._validateJavaBinary(execPath).then(v => { + if(v.valid){ + settingsJavaExecDetails.innerHTML = `Selected: Java ${v.version.major} Update ${v.version.update} (x${v.arch})` + } else { + settingsJavaExecDetails.innerHTML = 'Invalid Selection' + } + }) +} + function calculateRangeSliderMeta(v){ const val = { max: Number(v.getAttribute('max')), diff --git a/app/settings.ejs b/app/settings.ejs index 84b1e2a..e214ddf 100644 --- a/app/settings.ejs +++ b/app/settings.ejs @@ -135,6 +135,32 @@ +