mirror of
https://github.com/dscalzi/HeliosLauncher.git
synced 2024-12-22 11:42:14 -08:00
v0.0.1-alpha.12 - Completed Java Settings Tab.
Added JVM Options to the Java tab. Small clean up for the Java tab's styles and bindings.
This commit is contained in:
parent
109c24bc79
commit
e7752b4374
@ -1337,6 +1337,21 @@ input:checked + .toggleSwitchSlider:before {
|
|||||||
* Settings View (Java Tab)
|
* Settings View (Java Tab)
|
||||||
* * */
|
* * */
|
||||||
|
|
||||||
|
/* Style links on the Java tab. */
|
||||||
|
#settingsTabJava a {
|
||||||
|
color: rgba(202, 202, 202, 0.75);
|
||||||
|
transition: 0.25s ease;
|
||||||
|
outline: none;
|
||||||
|
}
|
||||||
|
#settingsTabJava a:hover,
|
||||||
|
#settingsTabJava a:focus {
|
||||||
|
color: rgba(255, 255, 255, 0.75);
|
||||||
|
}
|
||||||
|
#settingsTabJava a:active {
|
||||||
|
color: rgba(165, 165, 165, 0.75);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Main container for memory management. */
|
||||||
#settingsMemoryContainer {
|
#settingsMemoryContainer {
|
||||||
width: 75%;
|
width: 75%;
|
||||||
display: flex;
|
display: flex;
|
||||||
@ -1345,12 +1360,14 @@ input:checked + .toggleSwitchSlider:before {
|
|||||||
margin-bottom: 20px;
|
margin-bottom: 20px;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Memory management title. */
|
||||||
#settingsMemoryTitle {
|
#settingsMemoryTitle {
|
||||||
margin-bottom: 10px;
|
margin-bottom: 10px;
|
||||||
padding-bottom: 5px;
|
padding-bottom: 5px;
|
||||||
border-bottom: 1px solid rgba(255, 255, 255, 0.5);
|
border-bottom: 1px solid rgba(255, 255, 255, 0.5);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Memory management content. */
|
||||||
#settingsMemoryContent {
|
#settingsMemoryContent {
|
||||||
display: flex;
|
display: flex;
|
||||||
justify-content: space-between;
|
justify-content: space-between;
|
||||||
@ -1365,33 +1382,31 @@ input:checked + .toggleSwitchSlider:before {
|
|||||||
margin-right: 10%;
|
margin-right: 10%;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Header for memory sliders. */
|
||||||
.settingsMemoryHeader {
|
.settingsMemoryHeader {
|
||||||
font-size: 14px;
|
font-size: 14px;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Wrapper container for a memory slider and label. */
|
||||||
.settingsMemoryActionContainer {
|
.settingsMemoryActionContainer {
|
||||||
display: flex;
|
display: flex;
|
||||||
align-items: center;
|
align-items: center;
|
||||||
justify-content: space-between;
|
justify-content: space-between;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Label which displays a memory slider's value. */
|
||||||
.settingsMemoryLabel {
|
.settingsMemoryLabel {
|
||||||
font-size: 14px;
|
font-size: 14px;
|
||||||
margin-right: 3%;
|
margin-right: 3%;
|
||||||
}
|
}
|
||||||
|
|
||||||
#settingsMemoryDesc {
|
/* Range sliders for min and max memory settings. */
|
||||||
font-size: 10px;
|
|
||||||
margin: 20px 0px;
|
|
||||||
color: lightgrey;
|
|
||||||
font-weight: bold;
|
|
||||||
}
|
|
||||||
|
|
||||||
#settingsMaxRAMRange,
|
#settingsMaxRAMRange,
|
||||||
#settingsMinRAMRange {
|
#settingsMinRAMRange {
|
||||||
width: 85%;
|
width: 85%;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Memory status elements. */
|
||||||
#settingsMemoryStatus {
|
#settingsMemoryStatus {
|
||||||
display: flex;
|
display: flex;
|
||||||
flex-direction: column;
|
flex-direction: column;
|
||||||
@ -1414,6 +1429,15 @@ input:checked + .toggleSwitchSlider:before {
|
|||||||
font-size: 16px;
|
font-size: 16px;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Description for memory management. */
|
||||||
|
#settingsMemoryDesc {
|
||||||
|
font-size: 10px;
|
||||||
|
margin: 20px 0px;
|
||||||
|
color: lightgrey;
|
||||||
|
font-weight: bold;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Main container for the Java executable setting. */
|
||||||
#settingsJavaExecContainer {
|
#settingsJavaExecContainer {
|
||||||
display: flex;
|
display: flex;
|
||||||
flex-direction: column;
|
flex-direction: column;
|
||||||
@ -1422,40 +1446,48 @@ input:checked + .toggleSwitchSlider:before {
|
|||||||
width: 75%;
|
width: 75%;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Java executable setting title. */
|
||||||
#settingsJavaExecTitle {
|
#settingsJavaExecTitle {
|
||||||
margin-bottom: 10px;
|
margin-bottom: 10px;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Status text which displays details on the selected executable. */
|
||||||
#settingsJavaExecDetails {
|
#settingsJavaExecDetails {
|
||||||
font-weight: bold;
|
font-weight: bold;
|
||||||
color: grey;
|
color: grey;
|
||||||
font-size: 12px;
|
font-size: 12px;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Wrapper container for the actionable elements. */
|
||||||
#settingsJavaExecActions {
|
#settingsJavaExecActions {
|
||||||
display: flex;
|
display: flex;
|
||||||
|
width: 90%;
|
||||||
}
|
}
|
||||||
|
|
||||||
#settingsJavaExecIcon {
|
/* Java icon settings. */
|
||||||
|
.settingsJavaIcon {
|
||||||
display: flex;
|
display: flex;
|
||||||
align-items: center;
|
align-items: center;
|
||||||
background: rgba(126, 126, 126, 0.57);
|
background: rgba(126, 126, 126, 0.57);
|
||||||
border-radius: 3px 0px 0px 3px;
|
border-radius: 3px 0px 0px 3px;
|
||||||
padding: 5px;
|
padding: 5px;
|
||||||
|
transition: 0.25s ease;
|
||||||
}
|
}
|
||||||
#settingsJavaExecSVG {
|
.settingsJavaIconSVG {
|
||||||
width: 20px;
|
width: 20px;
|
||||||
height: 20px;
|
height: 20px;
|
||||||
fill: white;
|
fill: white;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Disabled text field which stores the selected executable path. */
|
||||||
#settingsJavaExecVal {
|
#settingsJavaExecVal {
|
||||||
border-radius: 0px !important;
|
border-radius: 0px !important;
|
||||||
width: 70%;
|
width: 100%;
|
||||||
padding: 5px 10px;
|
padding: 5px 10px;
|
||||||
font-size: 12px;
|
font-size: 12px;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* File input for executable selection. */
|
||||||
#settingsJavaExecSel {
|
#settingsJavaExecSel {
|
||||||
width: 0px;
|
width: 0px;
|
||||||
height: 0px;
|
height: 0px;
|
||||||
@ -1465,6 +1497,7 @@ input:checked + .toggleSwitchSlider:before {
|
|||||||
display: none;
|
display: none;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Wrapper label to add a custom style to the file input. */
|
||||||
#settingsJavaExecLabel {
|
#settingsJavaExecLabel {
|
||||||
border-left: 0px;
|
border-left: 0px;
|
||||||
border-radius: 0px 3px 3px 0px;
|
border-radius: 0px 3px 3px 0px;
|
||||||
@ -1475,6 +1508,7 @@ input:checked + .toggleSwitchSlider:before {
|
|||||||
align-items: center;
|
align-items: center;
|
||||||
background: rgba(126, 126, 126, 0.57);
|
background: rgba(126, 126, 126, 0.57);
|
||||||
transition: 0.25s ease;
|
transition: 0.25s ease;
|
||||||
|
white-space: nowrap;
|
||||||
}
|
}
|
||||||
#settingsJavaExecLabel:hover,
|
#settingsJavaExecLabel:hover,
|
||||||
#settingsJavaExecLabel:focus,
|
#settingsJavaExecLabel:focus,
|
||||||
@ -1482,6 +1516,7 @@ input:checked + .toggleSwitchSlider:before {
|
|||||||
text-shadow: 0px 0px 20px white;
|
text-shadow: 0px 0px 20px white;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Description for the Java executable setting. */
|
||||||
#settingsJavaExecDesc {
|
#settingsJavaExecDesc {
|
||||||
font-size: 10px;
|
font-size: 10px;
|
||||||
margin: 20px 0px;
|
margin: 20px 0px;
|
||||||
@ -1493,6 +1528,42 @@ input:checked + .toggleSwitchSlider:before {
|
|||||||
font-family: 'Avenir Medium';
|
font-family: 'Avenir Medium';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Main container for the JVM options setting. */
|
||||||
|
#settingsJVMOptsContainer {
|
||||||
|
width: 75%;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* JVM options title. */
|
||||||
|
#settingsJVMOptsTitle {
|
||||||
|
margin-bottom: 10px;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Wrapper container for the actionable elements. */
|
||||||
|
#settingsJVMOptsContent {
|
||||||
|
display: flex;
|
||||||
|
width: 90%;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Text field to input the JVM options. */
|
||||||
|
#settingsJVMOptsVal {
|
||||||
|
border-radius: 0px 3px 3px 0px !important;
|
||||||
|
width: 100%;
|
||||||
|
padding: 5px 10px;
|
||||||
|
font-size: 12px;
|
||||||
|
}
|
||||||
|
#settingsJVMOptsContent:focus-within > .settingsJavaIcon {
|
||||||
|
background: rgba(126, 126, 126, 0.87);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Description for the JVM options setting. */
|
||||||
|
#settingsJVMOptsDesc {
|
||||||
|
font-size: 10px;
|
||||||
|
margin: 20px 0px;
|
||||||
|
color: lightgrey;
|
||||||
|
font-weight: bold;
|
||||||
|
width: 89%;
|
||||||
|
}
|
||||||
|
|
||||||
/*******************************************************************************
|
/*******************************************************************************
|
||||||
* *
|
* *
|
||||||
* Landing View (Structural Styles) *
|
* Landing View (Structural Styles) *
|
||||||
|
@ -17,9 +17,10 @@ const settingsMaxRAMLabel = document.getElementById('settingsMaxRAMLabel')
|
|||||||
const settingsMinRAMLabel = document.getElementById('settingsMinRAMLabel')
|
const settingsMinRAMLabel = document.getElementById('settingsMinRAMLabel')
|
||||||
const settingsMemoryTotal = document.getElementById('settingsMemoryTotal')
|
const settingsMemoryTotal = document.getElementById('settingsMemoryTotal')
|
||||||
const settingsMemoryAvail = document.getElementById('settingsMemoryAvail')
|
const settingsMemoryAvail = document.getElementById('settingsMemoryAvail')
|
||||||
const settingsJavaExecDetails = document.getElementById('settingsJavaExecDetails')
|
const settingsJavaExecDetails = document.getElementById('settingsJavaExecDetails')
|
||||||
const settingsJavaExecVal = document.getElementById('settingsJavaExecVal')
|
const settingsJavaExecVal = document.getElementById('settingsJavaExecVal')
|
||||||
const settingsJavaExecSel = document.getElementById('settingsJavaExecSel')
|
const settingsJavaExecSel = document.getElementById('settingsJavaExecSel')
|
||||||
|
const settingsJVMOptsVal = document.getElementById('settingsJVMOptsVal')
|
||||||
|
|
||||||
const settingsState = {
|
const settingsState = {
|
||||||
invalid: new Set()
|
invalid: new Set()
|
||||||
@ -76,12 +77,15 @@ function initSettingsValues(){
|
|||||||
if(typeof gFn === 'function'){
|
if(typeof gFn === 'function'){
|
||||||
if(v.tagName === 'INPUT'){
|
if(v.tagName === 'INPUT'){
|
||||||
if(v.type === 'number' || v.type === 'text'){
|
if(v.type === 'number' || v.type === 'text'){
|
||||||
v.value = gFn()
|
|
||||||
|
|
||||||
// Special Conditions
|
// Special Conditions
|
||||||
const cVal = v.getAttribute('cValue')
|
const cVal = v.getAttribute('cValue')
|
||||||
if(cVal === 'JavaExecutable'){
|
if(cVal === 'JavaExecutable'){
|
||||||
populateJavaExecDetails(v.value)
|
populateJavaExecDetails(v.value)
|
||||||
|
v.value = gFn()
|
||||||
|
} else if(cVal === 'JVMOptions'){
|
||||||
|
v.value = gFn().join(' ')
|
||||||
|
} else {
|
||||||
|
v.value = gFn()
|
||||||
}
|
}
|
||||||
} else if(v.type === 'checkbox'){
|
} else if(v.type === 'checkbox'){
|
||||||
v.checked = gFn()
|
v.checked = gFn()
|
||||||
@ -119,7 +123,13 @@ function saveSettingsValues(){
|
|||||||
if(typeof sFn === 'function'){
|
if(typeof sFn === 'function'){
|
||||||
if(v.tagName === 'INPUT'){
|
if(v.tagName === 'INPUT'){
|
||||||
if(v.type === 'number' || v.type === 'text'){
|
if(v.type === 'number' || v.type === 'text'){
|
||||||
sFn(v.value)
|
// Special Conditions
|
||||||
|
const cVal = v.getAttribute('cValue')
|
||||||
|
if(cVal === 'JVMOptions'){
|
||||||
|
sFn(v.value.split(' '))
|
||||||
|
} else {
|
||||||
|
sFn(v.value)
|
||||||
|
}
|
||||||
} else if(v.type === 'checkbox'){
|
} else if(v.type === 'checkbox'){
|
||||||
sFn(v.checked)
|
sFn(v.checked)
|
||||||
// Special Conditions
|
// Special Conditions
|
||||||
@ -348,6 +358,9 @@ function populateAuthAccounts(){
|
|||||||
settingsCurrentAccounts.innerHTML = authAccountStr
|
settingsCurrentAccounts.innerHTML = authAccountStr
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Prepare the accounts tab for display.
|
||||||
|
*/
|
||||||
function prepareAccountsTab() {
|
function prepareAccountsTab() {
|
||||||
populateAuthAccounts()
|
populateAuthAccounts()
|
||||||
bindAuthAccountSelect()
|
bindAuthAccountSelect()
|
||||||
@ -376,16 +389,29 @@ settingsGameHeight.addEventListener('keydown', (e) => {
|
|||||||
* Java Tab
|
* Java Tab
|
||||||
*/
|
*/
|
||||||
|
|
||||||
settingsMaxRAMRange.setAttribute('max', ConfigManager.getAbsoluteMaxRAM())
|
// Store maximum memory values.
|
||||||
settingsMaxRAMRange.setAttribute('min', ConfigManager.getAbsoluteMinRAM())
|
const SETTINGS_MAX_MEMORY = ConfigManager.getAbsoluteMaxRAM()
|
||||||
settingsMinRAMRange.setAttribute('max', ConfigManager.getAbsoluteMaxRAM())
|
const SETTINGS_MIN_MEMORY = ConfigManager.getAbsoluteMinRAM()
|
||||||
settingsMinRAMRange.setAttribute('min', ConfigManager.getAbsoluteMinRAM())
|
|
||||||
|
|
||||||
|
// Set the max and min values for the ranged sliders.
|
||||||
|
settingsMaxRAMRange.setAttribute('max', SETTINGS_MAX_MEMORY)
|
||||||
|
settingsMaxRAMRange.setAttribute('min', SETTINGS_MIN_MEMORY)
|
||||||
|
settingsMinRAMRange.setAttribute('max', SETTINGS_MAX_MEMORY)
|
||||||
|
settingsMinRAMRange.setAttribute('min', SETTINGS_MIN_MEMORY )
|
||||||
|
|
||||||
|
// Bind on change event for min memory container.
|
||||||
settingsMinRAMRange.onchange = (e) => {
|
settingsMinRAMRange.onchange = (e) => {
|
||||||
|
|
||||||
|
// Current range values
|
||||||
const sMaxV = Number(settingsMaxRAMRange.getAttribute('value'))
|
const sMaxV = Number(settingsMaxRAMRange.getAttribute('value'))
|
||||||
const sMinV = Number(settingsMinRAMRange.getAttribute('value'))
|
const sMinV = Number(settingsMinRAMRange.getAttribute('value'))
|
||||||
|
|
||||||
|
// Get reference to range bar.
|
||||||
const bar = e.target.getElementsByClassName('rangeSliderBar')[0]
|
const bar = e.target.getElementsByClassName('rangeSliderBar')[0]
|
||||||
|
// Calculate effective total memory.
|
||||||
const max = (os.totalmem()-1000000000)/1000000000
|
const max = (os.totalmem()-1000000000)/1000000000
|
||||||
|
|
||||||
|
// Change range bar color based on the selected value.
|
||||||
if(sMinV >= max/2){
|
if(sMinV >= max/2){
|
||||||
bar.style.background = '#e86060'
|
bar.style.background = '#e86060'
|
||||||
} else if(sMinV >= max/4) {
|
} else if(sMinV >= max/4) {
|
||||||
@ -393,20 +419,31 @@ settingsMinRAMRange.onchange = (e) => {
|
|||||||
} else {
|
} else {
|
||||||
bar.style.background = null
|
bar.style.background = null
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Increase maximum memory if the minimum exceeds its value.
|
||||||
if(sMaxV < sMinV){
|
if(sMaxV < sMinV){
|
||||||
const sliderMeta = calculateRangeSliderMeta(settingsMaxRAMRange)
|
const sliderMeta = calculateRangeSliderMeta(settingsMaxRAMRange)
|
||||||
updateRangedSlider(settingsMaxRAMRange, sMinV,
|
updateRangedSlider(settingsMaxRAMRange, sMinV,
|
||||||
((sMinV-sliderMeta.min)/sliderMeta.step)*sliderMeta.inc)
|
((sMinV-sliderMeta.min)/sliderMeta.step)*sliderMeta.inc)
|
||||||
settingsMaxRAMLabel.innerHTML = sMinV.toFixed(1) + 'G'
|
settingsMaxRAMLabel.innerHTML = sMinV.toFixed(1) + 'G'
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Update label
|
||||||
settingsMinRAMLabel.innerHTML = sMinV.toFixed(1) + 'G'
|
settingsMinRAMLabel.innerHTML = sMinV.toFixed(1) + 'G'
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Bind on change event for max memory container.
|
||||||
settingsMaxRAMRange.onchange = (e) => {
|
settingsMaxRAMRange.onchange = (e) => {
|
||||||
|
// Current range values
|
||||||
const sMaxV = Number(settingsMaxRAMRange.getAttribute('value'))
|
const sMaxV = Number(settingsMaxRAMRange.getAttribute('value'))
|
||||||
const sMinV = Number(settingsMinRAMRange.getAttribute('value'))
|
const sMinV = Number(settingsMinRAMRange.getAttribute('value'))
|
||||||
|
|
||||||
|
// Get reference to range bar.
|
||||||
const bar = e.target.getElementsByClassName('rangeSliderBar')[0]
|
const bar = e.target.getElementsByClassName('rangeSliderBar')[0]
|
||||||
|
// Calculate effective total memory.
|
||||||
const max = (os.totalmem()-1000000000)/1000000000
|
const max = (os.totalmem()-1000000000)/1000000000
|
||||||
|
|
||||||
|
// Change range bar color based on the selected value.
|
||||||
if(sMaxV >= max/2){
|
if(sMaxV >= max/2){
|
||||||
bar.style.background = '#e86060'
|
bar.style.background = '#e86060'
|
||||||
} else if(sMaxV >= max/4) {
|
} else if(sMaxV >= max/4) {
|
||||||
@ -414,6 +451,8 @@ settingsMaxRAMRange.onchange = (e) => {
|
|||||||
} else {
|
} else {
|
||||||
bar.style.background = null
|
bar.style.background = null
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Decrease the minimum memory if the maximum value is less.
|
||||||
if(sMaxV < sMinV){
|
if(sMaxV < sMinV){
|
||||||
const sliderMeta = calculateRangeSliderMeta(settingsMaxRAMRange)
|
const sliderMeta = calculateRangeSliderMeta(settingsMaxRAMRange)
|
||||||
updateRangedSlider(settingsMinRAMRange, sMaxV,
|
updateRangedSlider(settingsMinRAMRange, sMaxV,
|
||||||
@ -423,21 +462,12 @@ settingsMaxRAMRange.onchange = (e) => {
|
|||||||
settingsMaxRAMLabel.innerHTML = sMaxV.toFixed(1) + 'G'
|
settingsMaxRAMLabel.innerHTML = sMaxV.toFixed(1) + 'G'
|
||||||
}
|
}
|
||||||
|
|
||||||
settingsJavaExecSel.onchange = (e) => {
|
/**
|
||||||
settingsJavaExecVal.value = settingsJavaExecSel.files[0].path
|
* Calculate common values for a ranged slider.
|
||||||
populateJavaExecDetails(settingsJavaExecVal.value)
|
*
|
||||||
}
|
* @param {Element} v The range slider to calculate against.
|
||||||
|
* @returns {Object} An object with meta values for the provided ranged slider.
|
||||||
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){
|
function calculateRangeSliderMeta(v){
|
||||||
const val = {
|
const val = {
|
||||||
max: Number(v.getAttribute('max')),
|
max: Number(v.getAttribute('max')),
|
||||||
@ -449,30 +479,46 @@ function calculateRangeSliderMeta(v){
|
|||||||
return val
|
return val
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Binds functionality to the ranged sliders. They're more than
|
||||||
|
* just divs now :').
|
||||||
|
*/
|
||||||
function bindRangeSlider(){
|
function bindRangeSlider(){
|
||||||
Array.from(document.getElementsByClassName('rangeSlider')).map((v) => {
|
Array.from(document.getElementsByClassName('rangeSlider')).map((v) => {
|
||||||
|
|
||||||
|
// Reference the track (thumb).
|
||||||
const track = v.getElementsByClassName('rangeSliderTrack')[0]
|
const track = v.getElementsByClassName('rangeSliderTrack')[0]
|
||||||
|
|
||||||
|
// Set the initial slider value.
|
||||||
const value = v.getAttribute('value')
|
const value = v.getAttribute('value')
|
||||||
const sliderMeta = calculateRangeSliderMeta(v)
|
const sliderMeta = calculateRangeSliderMeta(v)
|
||||||
updateRangedSlider(v, value,
|
|
||||||
((value-sliderMeta.min)/sliderMeta.step)*sliderMeta.inc)
|
|
||||||
|
|
||||||
|
updateRangedSlider(v, value, ((value-sliderMeta.min)/sliderMeta.step)*sliderMeta.inc)
|
||||||
|
|
||||||
|
// The magic happens when we click on the track.
|
||||||
track.onmousedown = (e) => {
|
track.onmousedown = (e) => {
|
||||||
|
|
||||||
|
// Stop moving the track on mouse up.
|
||||||
document.onmouseup = (e) => {
|
document.onmouseup = (e) => {
|
||||||
document.onmousemove = null
|
document.onmousemove = null
|
||||||
document.onmouseup = null
|
document.onmouseup = null
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Move slider according to the mouse position.
|
||||||
document.onmousemove = (e) => {
|
document.onmousemove = (e) => {
|
||||||
|
|
||||||
|
// Distance from the beginning of the bar in pixels.
|
||||||
const diff = e.pageX - v.offsetLeft - track.offsetWidth/2
|
const diff = e.pageX - v.offsetLeft - track.offsetWidth/2
|
||||||
|
|
||||||
|
// Don't move the track off the bar.
|
||||||
if(diff >= 0 && diff <= v.offsetWidth-track.offsetWidth/2){
|
if(diff >= 0 && diff <= v.offsetWidth-track.offsetWidth/2){
|
||||||
|
|
||||||
|
// Convert the difference to a percentage.
|
||||||
const perc = (diff/v.offsetWidth)*100
|
const perc = (diff/v.offsetWidth)*100
|
||||||
|
// Calculate the percentage of the closest notch.
|
||||||
const notch = Number(perc/sliderMeta.inc).toFixed(0)*sliderMeta.inc
|
const notch = Number(perc/sliderMeta.inc).toFixed(0)*sliderMeta.inc
|
||||||
|
|
||||||
|
// If we're close to that notch, stick to it.
|
||||||
if(Math.abs(perc-notch) < sliderMeta.inc/2){
|
if(Math.abs(perc-notch) < sliderMeta.inc/2){
|
||||||
updateRangedSlider(v, sliderMeta.min+(sliderMeta.step*(notch/sliderMeta.inc)), notch)
|
updateRangedSlider(v, sliderMeta.min+(sliderMeta.step*(notch/sliderMeta.inc)), notch)
|
||||||
}
|
}
|
||||||
@ -482,18 +528,29 @@ function bindRangeSlider(){
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Update a ranged slider's value and position.
|
||||||
|
*
|
||||||
|
* @param {Element} element The ranged slider to update.
|
||||||
|
* @param {string | number} value The new value for the ranged slider.
|
||||||
|
* @param {number} notch The notch that the slider should now be at.
|
||||||
|
*/
|
||||||
function updateRangedSlider(element, value, notch){
|
function updateRangedSlider(element, value, notch){
|
||||||
const oldVal = element.getAttribute('value')
|
const oldVal = element.getAttribute('value')
|
||||||
const bar = element.getElementsByClassName('rangeSliderBar')[0]
|
const bar = element.getElementsByClassName('rangeSliderBar')[0]
|
||||||
const track = element.getElementsByClassName('rangeSliderTrack')[0]
|
const track = element.getElementsByClassName('rangeSliderTrack')[0]
|
||||||
|
|
||||||
element.setAttribute('value', value)
|
element.setAttribute('value', value)
|
||||||
|
|
||||||
const event = new MouseEvent('change', {
|
const event = new MouseEvent('change', {
|
||||||
target: element,
|
target: element,
|
||||||
type: 'change',
|
type: 'change',
|
||||||
bubbles: false,
|
bubbles: false,
|
||||||
cancelable: true
|
cancelable: true
|
||||||
})
|
})
|
||||||
|
|
||||||
let cancelled = !element.dispatchEvent(event)
|
let cancelled = !element.dispatchEvent(event)
|
||||||
|
|
||||||
if(!cancelled){
|
if(!cancelled){
|
||||||
track.style.left = notch + '%'
|
track.style.left = notch + '%'
|
||||||
bar.style.width = notch + '%'
|
bar.style.width = notch + '%'
|
||||||
@ -502,14 +559,42 @@ function updateRangedSlider(element, value, notch){
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function bindMemoryStatus(){
|
/**
|
||||||
|
* Display the total and available RAM.
|
||||||
|
*/
|
||||||
|
function populateMemoryStatus(){
|
||||||
settingsMemoryTotal.innerHTML = Number((os.totalmem()-1000000000)/1000000000).toFixed(1) + 'G'
|
settingsMemoryTotal.innerHTML = Number((os.totalmem()-1000000000)/1000000000).toFixed(1) + 'G'
|
||||||
settingsMemoryAvail.innerHTML = Number(os.freemem()/1000000000).toFixed(1) + 'G'
|
settingsMemoryAvail.innerHTML = Number(os.freemem()/1000000000).toFixed(1) + 'G'
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Bind the executable file input to the display text input.
|
||||||
|
settingsJavaExecSel.onchange = (e) => {
|
||||||
|
settingsJavaExecVal.value = settingsJavaExecSel.files[0].path
|
||||||
|
populateJavaExecDetails(settingsJavaExecVal.value)
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Validate the provided executable path and display the data on
|
||||||
|
* the UI.
|
||||||
|
*
|
||||||
|
* @param {string} execPath The executable path to populate against.
|
||||||
|
*/
|
||||||
|
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'
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Prepare the Java tab for display.
|
||||||
|
*/
|
||||||
function prepareJavaTab(){
|
function prepareJavaTab(){
|
||||||
bindRangeSlider()
|
bindRangeSlider()
|
||||||
bindMemoryStatus()
|
populateMemoryStatus()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -140,8 +140,8 @@
|
|||||||
<div id="settingsJavaExecContent">
|
<div id="settingsJavaExecContent">
|
||||||
<div id="settingsJavaExecDetails">Selected: Java 8 Update 172 (x64)</div>
|
<div id="settingsJavaExecDetails">Selected: Java 8 Update 172 (x64)</div>
|
||||||
<div id="settingsJavaExecActions">
|
<div id="settingsJavaExecActions">
|
||||||
<div id="settingsJavaExecIcon">
|
<div class="settingsJavaIcon">
|
||||||
<svg id="settingsJavaExecSVG" x="0px" y="0px" viewBox="0 0 305.001 305.001">
|
<svg class="settingsJavaIconSVG" x="0px" y="0px" viewBox="0 0 305.001 305.001">
|
||||||
<g>
|
<g>
|
||||||
<path d="M150.99,56.513c-14.093,9.912-30.066,21.147-38.624,39.734c-14.865,32.426,30.418,67.798,32.353,69.288c0.45,0.347,0.988,0.519,1.525,0.519c0.57,0,1.141-0.195,1.605-0.583c0.899-0.752,1.154-2.029,0.614-3.069c-0.164-0.316-16.418-31.888-15.814-54.539c0.214-7.888,11.254-16.837,22.942-26.312c10.705-8.678,22.839-18.514,29.939-30.02c15.586-25.327-1.737-50.231-1.914-50.479c-0.688-0.966-1.958-1.317-3.044-0.84c-1.085,0.478-1.686,1.652-1.438,2.811c0.035,0.164,3.404,16.633-5.97,33.6C169.301,43.634,160.816,49.603,150.99,56.513z"></path>
|
<path d="M150.99,56.513c-14.093,9.912-30.066,21.147-38.624,39.734c-14.865,32.426,30.418,67.798,32.353,69.288c0.45,0.347,0.988,0.519,1.525,0.519c0.57,0,1.141-0.195,1.605-0.583c0.899-0.752,1.154-2.029,0.614-3.069c-0.164-0.316-16.418-31.888-15.814-54.539c0.214-7.888,11.254-16.837,22.942-26.312c10.705-8.678,22.839-18.514,29.939-30.02c15.586-25.327-1.737-50.231-1.914-50.479c-0.688-0.966-1.958-1.317-3.044-0.84c-1.085,0.478-1.686,1.652-1.438,2.811c0.035,0.164,3.404,16.633-5.97,33.6C169.301,43.634,160.816,49.603,150.99,56.513z"></path>
|
||||||
<path d="M210.365,67.682c0.994-0.749,1.286-2.115,0.684-3.205c-0.602-1.09-1.913-1.571-3.077-1.129c-2.394,0.91-58.627,22.585-58.627,48.776c0,18.053,7.712,27.591,13.343,34.556c2.209,2.731,4.116,5.09,4.744,7.104c1.769,5.804-2.422,16.294-4.184,19.846c-0.508,1.022-0.259,2.259,0.605,3.005c0.467,0.403,1.05,0.607,1.634,0.607c0.497,0,0.996-0.148,1.427-0.448c0.967-0.673,23.63-16.696,19.565-36.001c-1.514-7.337-5.12-12.699-8.302-17.43c-4.929-7.329-8.489-12.624-3.088-22.403C181.419,89.556,210.076,67.899,210.365,67.682z"></path>
|
<path d="M210.365,67.682c0.994-0.749,1.286-2.115,0.684-3.205c-0.602-1.09-1.913-1.571-3.077-1.129c-2.394,0.91-58.627,22.585-58.627,48.776c0,18.053,7.712,27.591,13.343,34.556c2.209,2.731,4.116,5.09,4.744,7.104c1.769,5.804-2.422,16.294-4.184,19.846c-0.508,1.022-0.259,2.259,0.605,3.005c0.467,0.403,1.05,0.607,1.634,0.607c0.497,0,0.996-0.148,1.427-0.448c0.967-0.673,23.63-16.696,19.565-36.001c-1.514-7.337-5.12-12.699-8.302-17.43c-4.929-7.329-8.489-12.624-3.088-22.403C181.419,89.556,210.076,67.899,210.365,67.682z"></path>
|
||||||
@ -161,6 +161,27 @@
|
|||||||
</div>
|
</div>
|
||||||
<div id="settingsJavaExecDesc">The Java executable is validated before game launch. <strong>Requires Java 8 x64.</strong><br>The path should end with <strong>bin<%= process.platform === 'win32' ? '\\javaw.exe' : '/java' %></strong>.</div>
|
<div id="settingsJavaExecDesc">The Java executable is validated before game launch. <strong>Requires Java 8 x64.</strong><br>The path should end with <strong>bin<%= process.platform === 'win32' ? '\\javaw.exe' : '/java' %></strong>.</div>
|
||||||
</div>
|
</div>
|
||||||
|
<div id="settingsJVMOptsContainer">
|
||||||
|
<div id="settingsJVMOptsTitle">Additional JVM Options</div>
|
||||||
|
<div id="settingsJVMOptsContent">
|
||||||
|
<div class="settingsJavaIcon">
|
||||||
|
<svg class="settingsJavaIconSVG" x="0px" y="0px" viewBox="0 0 305.001 305.001">
|
||||||
|
<g>
|
||||||
|
<path d="M150.99,56.513c-14.093,9.912-30.066,21.147-38.624,39.734c-14.865,32.426,30.418,67.798,32.353,69.288c0.45,0.347,0.988,0.519,1.525,0.519c0.57,0,1.141-0.195,1.605-0.583c0.899-0.752,1.154-2.029,0.614-3.069c-0.164-0.316-16.418-31.888-15.814-54.539c0.214-7.888,11.254-16.837,22.942-26.312c10.705-8.678,22.839-18.514,29.939-30.02c15.586-25.327-1.737-50.231-1.914-50.479c-0.688-0.966-1.958-1.317-3.044-0.84c-1.085,0.478-1.686,1.652-1.438,2.811c0.035,0.164,3.404,16.633-5.97,33.6C169.301,43.634,160.816,49.603,150.99,56.513z"></path>
|
||||||
|
<path d="M210.365,67.682c0.994-0.749,1.286-2.115,0.684-3.205c-0.602-1.09-1.913-1.571-3.077-1.129c-2.394,0.91-58.627,22.585-58.627,48.776c0,18.053,7.712,27.591,13.343,34.556c2.209,2.731,4.116,5.09,4.744,7.104c1.769,5.804-2.422,16.294-4.184,19.846c-0.508,1.022-0.259,2.259,0.605,3.005c0.467,0.403,1.05,0.607,1.634,0.607c0.497,0,0.996-0.148,1.427-0.448c0.967-0.673,23.63-16.696,19.565-36.001c-1.514-7.337-5.12-12.699-8.302-17.43c-4.929-7.329-8.489-12.624-3.088-22.403C181.419,89.556,210.076,67.899,210.365,67.682z"></path>
|
||||||
|
<path d="M63.99,177.659c-0.964,2.885-0.509,5.75,1.315,8.283c6.096,8.462,27.688,13.123,60.802,13.123c0.002,0,0.003,0,0.004,0c4.487,0,9.224-0.088,14.076-0.262c52.943-1.896,72.58-18.389,73.39-19.09c0.883-0.764,1.119-2.037,0.57-3.067c-0.549-1.029-1.733-1.546-2.864-1.235c-18.645,5.091-53.463,6.898-77.613,6.898c-27.023,0-40.785-1.946-44.154-3.383c1.729-2.374,12.392-6.613,25.605-9.212c1.263-0.248,2.131-1.414,2.006-2.695c-0.125-1.281-1.201-2.258-2.488-2.258C106.893,164.762,68.05,165.384,63.99,177.659z"></path>
|
||||||
|
<path d="M241.148,160.673c-10.92,0-21.275,5.472-21.711,5.705c-1.01,0.541-1.522,1.699-1.245,2.811c0.278,1.111,1.277,1.892,2.423,1.893c0.232,0.001,23.293,0.189,25.382,13.365c1.85,11.367-21.82,29.785-31.097,35.923c-1.002,0.663-1.391,1.945-0.926,3.052c0.395,0.943,1.314,1.533,2.304,1.533c0.173,0,0.348-0.018,0.522-0.056c2.202-0.47,53.855-11.852,48.394-41.927C261.862,164.541,250.278,160.673,241.148,160.673z"></path>
|
||||||
|
<path d="M205.725,216.69c0.18-0.964-0.221-1.944-1.023-2.506l-12.385-8.675c-0.604-0.423-1.367-0.556-2.076-0.368c-0.129,0.034-13.081,3.438-31.885,5.526c-7.463,0.837-15.822,1.279-24.175,1.279c-18.799,0-31.091-2.209-32.881-3.829c-0.237-0.455-0.162-0.662-0.12-0.777c0.325-0.905,2.068-1.98,3.192-2.405c1.241-0.459,1.91-1.807,1.524-3.073c-0.385-1.266-1.69-2.012-2.978-1.702c-12.424,2.998-18.499,7.191-18.057,12.461c0.785,9.343,22.428,14.139,40.725,15.408c2.631,0.18,5.477,0.272,8.456,0.272c0.002,0,0.003,0,0.005,0c30.425,0,69.429-9.546,69.819-9.643C204.818,218.423,205.544,217.654,205.725,216.69z"></path>
|
||||||
|
<path d="M112.351,236.745c0.938-0.611,1.354-1.77,1.021-2.838c-0.332-1.068-1.331-1.769-2.453-1.755c-1.665,0.044-16.292,0.704-17.316,10.017c-0.31,2.783,0.487,5.325,2.37,7.556c5.252,6.224,19.428,9.923,43.332,11.31c2.828,0.169,5.7,0.254,8.539,0.254c30.39,0,50.857-9.515,51.714-9.92c0.831-0.393,1.379-1.209,1.428-2.127c0.049-0.917-0.409-1.788-1.193-2.267l-15.652-9.555c-0.543-0.331-1.193-0.441-1.813-0.314c-0.099,0.021-10.037,2.082-25.035,4.119c-2.838,0.385-6.392,0.581-10.562,0.581c-14.982,0-31.646-2.448-34.842-4.05C111.843,237.455,111.902,237.075,112.351,236.745z"></path>
|
||||||
|
<path d="M133.681,290.018c69.61-0.059,106.971-12.438,114.168-20.228c2.548-2.757,2.823-5.366,2.606-7.07c-0.535-4.194-4.354-6.761-4.788-7.04c-1.045-0.672-2.447-0.496-3.262,0.444c-0.813,0.941-0.832,2.314-0.016,3.253c0.439,0.565,0.693,1.51-0.591,2.795c-2.877,2.687-31.897,10.844-80.215,13.294c-6.619,0.345-13.561,0.519-20.633,0.52c-43.262,0-74.923-5.925-79.079-9.379c1.603-2.301,12.801-5.979,24.711-8.058c1.342-0.234,2.249-1.499,2.041-2.845c-0.208-1.346-1.449-2.273-2.805-2.096c-0.336,0.045-1.475,0.115-2.796,0.195c-19.651,1.2-42.36,3.875-43.545,13.999c-0.36,3.086,0.557,5.886,2.726,8.324c5.307,5.963,20.562,13.891,91.475,13.891C133.68,290.018,133.68,290.018,133.681,290.018z"></path>
|
||||||
|
<path d="M261.522,271.985c-0.984-0.455-2.146-0.225-2.881,0.567c-0.103,0.11-10.568,11.054-42.035,17.48c-12.047,2.414-34.66,3.638-67.211,3.638c-32.612,0-63.643-1.283-63.953-1.296c-1.296-0.063-2.405,0.879-2.581,2.155c-0.177,1.276,0.645,2.477,1.897,2.775c0.323,0.077,32.844,7.696,77.31,7.696c21.327,0,42.08-1.733,61.684-5.151c36.553-6.408,39.112-24.533,39.203-25.301C263.082,273.474,262.504,272.44,261.522,271.985z"></path>
|
||||||
|
</g>
|
||||||
|
</svg>
|
||||||
|
</div>
|
||||||
|
<input id="settingsJVMOptsVal" cValue="JVMOptions" type="text">
|
||||||
|
</div>
|
||||||
|
<div id="settingsJVMOptsDesc">Options to be provided to the JVM at runtime. <em>-Xms</em> and <em>-Xmx</em> should not be included.<br><a href="https://docs.oracle.com/javase/8/docs/technotes/tools/windows/java.html">Available Options for Java 8</a>.</div>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div id="settingsTabLauncher" class="settingsTab" style="display: none;">
|
<div id="settingsTabLauncher" class="settingsTab" style="display: none;">
|
||||||
<div class="settingsTabHeader">
|
<div class="settingsTabHeader">
|
||||||
|
Loading…
Reference in New Issue
Block a user