Added option to change the Java exec to the settings UI.

This commit is contained in:
Daniel Scalzi
2018-06-14 03:49:55 -04:00
parent 7cf0e1f049
commit 109c24bc79
7 changed files with 141 additions and 5 deletions

View File

@@ -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?

View File

@@ -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()
}

View File

@@ -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')),