diff --git a/app/assets/css/launcher.css b/app/assets/css/launcher.css index 28775080..1c59a755 100644 --- a/app/assets/css/launcher.css +++ b/app/assets/css/launcher.css @@ -1331,6 +1331,86 @@ input:checked + .toggleSwitchSlider:before { width: 75px; } +/* * * +* Settings View (Java Tab) +* * */ + +#settingsMemoryContainer { + width: 75%; + display: flex; + flex-direction: column; + border-bottom: 1px solid rgba(255, 255, 255, 0.50); +} + +#settingsMemoryTitle { + margin-bottom: 10px; + padding-bottom: 5px; + border-bottom: 1px solid rgba(255, 255, 255, 0.5); +} + +#settingsMemoryContent { + display: flex; + justify-content: space-between; + width: 100%; +} +#settingsMemoryContentLeft { + width: 69%; +} +#settingsMemoryContentRight { + display: flex; + align-items: center; + margin-right: 10%; +} + +.settingsMemoryHeader { + font-size: 14px; +} + +.settingsMemoryActionContainer { + display: flex; + align-items: center; + justify-content: space-between; +} + +.settingsMemoryLabel { + font-size: 14px; + margin-right: 3%; +} + +#settingsMemoryDesc { + font-size: 10px; + margin: 20px 0px; + color: lightgrey; + font-weight: bold; +} + +#settingsMaxRAMRange, +#settingsMinRAMRange { + width: 85%; +} + +#settingsMemoryStatus { + display: flex; + flex-direction: column; +} +#settingsMemoryStatus > .settingsMemoryStatusContainer:not(:last-child){ + margin-bottom: 50%; +} +.settingsMemoryStatusContainer { + display: flex; + flex-direction: column; + align-items: center; +} +.settingsMemoryStatusTitle { + font-size: 12px; + color: grey; + font-weight: bold; +} +.settingsMemoryStatusValue { + color: lightgrey; + font-size: 16px; +} + /******************************************************************************* * * * Landing View (Structural Styles) * diff --git a/app/assets/js/scripts/settings.js b/app/assets/js/scripts/settings.js index 690baa38..1c91e50f 100644 --- a/app/assets/js/scripts/settings.js +++ b/app/assets/js/scripts/settings.js @@ -1,3 +1,5 @@ +const os = require('os') + const settingsNavDone = document.getElementById('settingsNavDone') // Account Management Tab @@ -11,6 +13,10 @@ const settingsGameHeight = document.getElementById('settingsGameHeight') // Java Tab const settingsMaxRAMRange = document.getElementById('settingsMaxRAMRange') const settingsMinRAMRange = document.getElementById('settingsMinRAMRange') +const settingsMaxRAMLabel = document.getElementById('settingsMaxRAMLabel') +const settingsMinRAMLabel = document.getElementById('settingsMinRAMLabel') +const settingsMemoryTotal = document.getElementById('settingsMemoryTotal') +const settingsMemoryAvail = document.getElementById('settingsMemoryAvail') const settingsState = { invalid: new Set() @@ -73,7 +79,20 @@ function initSettingsValues(){ } } else if(v.tagName === 'DIV'){ if(v.classList.contains('rangeSlider')){ - v.setAttribute('value', Number.parseFloat(gFn())) + // Special Conditions + const cVal = v.getAttribute('cValue') + if(cVal === 'MinRAM' || cVal === 'MaxRAM'){ + let val = gFn() + if(val.endsWith('M')){ + val = Number(val.substring(0, val.length-1))/1000 + } else { + val = Number.parseFloat(val) + } + + v.setAttribute('value', val) + } else { + v.setAttribute('value', Number.parseFloat(gFn())) + } } } } @@ -100,6 +119,23 @@ function saveSettingsValues(){ changeAllowPrerelease(v.checked) } } + } else if(v.tagName === 'DIV'){ + if(v.classList.contains('rangeSlider')){ + // Special Conditions + const cVal = v.getAttribute('cValue') + if(cVal === 'MinRAM' || cVal === 'MaxRAM'){ + let val = Number(v.getAttribute('value')) + if(val%1 > 0){ + val = val*1000 + 'M' + } else { + val = val + 'G' + } + + sFn(val) + } else { + sFn(v.getAttribute('value')) + } + } } } }) @@ -343,14 +379,21 @@ settingsMinRAMRange.onchange = (e) => { const sliderMeta = calculateRangeSliderMeta(settingsMaxRAMRange) updateRangedSlider(settingsMaxRAMRange, sMinV, (1+(sMinV-sliderMeta.min)/sliderMeta.step)*sliderMeta.inc) + settingsMaxRAMLabel.innerHTML = sMinV.toFixed(1) + 'G' } + settingsMinRAMLabel.innerHTML = sMinV.toFixed(1) + 'G' } + settingsMaxRAMRange.onchange = (e) => { const sMaxV = Number(settingsMaxRAMRange.getAttribute('value')) const sMinV = Number(settingsMinRAMRange.getAttribute('value')) if(sMaxV < sMinV){ - e.preventDefault() + const sliderMeta = calculateRangeSliderMeta(settingsMaxRAMRange) + updateRangedSlider(settingsMinRAMRange, sMaxV, + (1+(sMaxV-sliderMeta.min)/sliderMeta.step)*sliderMeta.inc) + settingsMinRAMLabel.innerHTML = sMaxV.toFixed(1) + 'G' } + settingsMaxRAMLabel.innerHTML = sMaxV.toFixed(1) + 'G' } function calculateRangeSliderMeta(v){ @@ -387,7 +430,7 @@ function bindRangeSlider(){ const perc = (diff/v.offsetWidth)*100 const notch = Number(perc/sliderMeta.inc).toFixed(0)*sliderMeta.inc - + console.log(notch, perc) if(Math.abs(perc-notch) < sliderMeta.inc/2){ updateRangedSlider(v, sliderMeta.min+(sliderMeta.step*((notch/sliderMeta.inc)-1)), notch) } @@ -417,8 +460,14 @@ function updateRangedSlider(element, value, notch){ } } +function bindMemoryStatus(){ + settingsMemoryTotal.innerHTML = Number((os.totalmem()-1000000000)/1000000000).toFixed(1) + 'G' + settingsMemoryAvail.innerHTML = Number(os.freemem()/1000000000).toFixed(1) + 'G' +} + function prepareJavaTab(){ bindRangeSlider() + bindMemoryStatus() } diff --git a/app/settings.ejs b/app/settings.ejs index cd2b549b..84b1e2a3 100644 --- a/app/settings.ejs +++ b/app/settings.ejs @@ -95,13 +95,45 @@ Java Settings Manage the Java configuration (advanced). -