2018-07-31 05:02:12 +02:00
|
|
|
import {Engine} from "../engine";
|
2019-01-27 23:08:45 +01:00
|
|
|
import {Settings} from "../Settings/Settings";
|
2017-07-25 16:39:56 +02:00
|
|
|
|
2018-09-16 05:12:48 +02:00
|
|
|
import {numeralWrapper} from "./numeralFormat";
|
2018-09-12 17:53:08 +02:00
|
|
|
|
2018-09-12 05:05:13 +02:00
|
|
|
|
2017-07-25 16:39:56 +02:00
|
|
|
function setSettingsLabels() {
|
2021-03-10 05:22:05 +01:00
|
|
|
function setAutosaveLabel(elem) {
|
|
|
|
if(Settings.AutosaveInterval === 0) {
|
|
|
|
elem.innerHTML = `disabled`;
|
|
|
|
} else {
|
|
|
|
elem.innerHTML = `every ${Settings.AutosaveInterval}s`;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
const nsExecTime = document.getElementById("settingsNSExecTimeRangeValLabel");
|
|
|
|
const nsLogLimit = document.getElementById("settingsNSLogRangeValLabel");
|
|
|
|
const nsPortLimit = document.getElementById("settingsNSPortRangeValLabel");
|
|
|
|
const suppressMsgs = document.getElementById("settingsSuppressMessages");
|
|
|
|
const suppressFactionInv = document.getElementById("settingsSuppressFactionInvites")
|
|
|
|
const suppressTravelConfirmation = document.getElementById("settingsSuppressTravelConfirmation");
|
|
|
|
const suppressBuyAugmentationConfirmation = document.getElementById("settingsSuppressBuyAugmentationConfirmation");
|
|
|
|
const suppressHospitalizationPopup = document.getElementById("settingsSuppressHospitalizationPopup");
|
|
|
|
const autosaveInterval = document.getElementById("settingsAutosaveIntervalValLabel");
|
|
|
|
const disableHotkeys = document.getElementById("settingsDisableHotkeys");
|
|
|
|
const locale = document.getElementById("settingsLocale");
|
2017-08-30 19:44:29 +02:00
|
|
|
|
|
|
|
//Initialize values on labels
|
|
|
|
nsExecTime.innerHTML = Settings.CodeInstructionRunTime + "ms";
|
|
|
|
nsLogLimit.innerHTML = Settings.MaxLogCapacity;
|
|
|
|
nsPortLimit.innerHTML = Settings.MaxPortCapacity;
|
|
|
|
suppressMsgs.checked = Settings.SuppressMessages;
|
|
|
|
suppressFactionInv.checked = Settings.SuppressFactionInvites;
|
2018-06-14 21:51:06 +02:00
|
|
|
suppressTravelConfirmation.checked = Settings.SuppressTravelConfirmation;
|
2018-06-21 19:32:21 +02:00
|
|
|
suppressBuyAugmentationConfirmation.checked = Settings.SuppressBuyAugmentationConfirmation;
|
2018-08-12 07:39:37 +02:00
|
|
|
suppressHospitalizationPopup.checked = Settings.SuppressHospitalizationPopup;
|
2021-03-10 05:22:05 +01:00
|
|
|
setAutosaveLabel(autosaveInterval);
|
2018-05-06 22:27:47 +02:00
|
|
|
disableHotkeys.checked = Settings.DisableHotkeys;
|
2018-09-12 05:05:13 +02:00
|
|
|
locale.value = Settings.Locale;
|
2018-09-12 17:53:08 +02:00
|
|
|
numeralWrapper.updateLocale(Settings.Locale); //Initialize locale
|
2017-08-30 19:44:29 +02:00
|
|
|
|
2018-09-12 05:05:13 +02:00
|
|
|
//Set handlers for when input changes for sliders
|
2021-03-10 05:22:05 +01:00
|
|
|
const nsExecTimeInput = document.getElementById("settingsNSExecTimeRangeVal");
|
|
|
|
const nsLogRangeInput = document.getElementById("settingsNSLogRangeVal");
|
|
|
|
const nsPortRangeInput = document.getElementById("settingsNSPortRangeVal");
|
|
|
|
const nsAutosaveIntervalInput = document.getElementById("settingsAutosaveIntervalVal");
|
2018-01-20 05:47:57 +01:00
|
|
|
nsExecTimeInput.value = Settings.CodeInstructionRunTime;
|
|
|
|
nsLogRangeInput.value = Settings.MaxLogCapacity;
|
|
|
|
nsPortRangeInput.value = Settings.MaxPortCapacity;
|
|
|
|
nsAutosaveIntervalInput.value = Settings.AutosaveInterval;
|
|
|
|
|
|
|
|
nsExecTimeInput.oninput = function() {
|
2017-08-30 19:44:29 +02:00
|
|
|
nsExecTime.innerHTML = this.value + 'ms';
|
|
|
|
Settings.CodeInstructionRunTime = this.value;
|
|
|
|
};
|
|
|
|
|
2018-01-20 05:47:57 +01:00
|
|
|
nsLogRangeInput.oninput = function() {
|
2017-08-30 19:44:29 +02:00
|
|
|
nsLogLimit.innerHTML = this.value;
|
|
|
|
Settings.MaxLogCapacity = this.value;
|
|
|
|
};
|
|
|
|
|
2018-01-20 05:47:57 +01:00
|
|
|
nsPortRangeInput.oninput = function() {
|
2017-08-30 19:44:29 +02:00
|
|
|
nsPortLimit.innerHTML = this.value;
|
|
|
|
Settings.MaxPortCapacity = this.value;
|
|
|
|
};
|
|
|
|
|
2018-01-20 05:47:57 +01:00
|
|
|
nsAutosaveIntervalInput.oninput = function() {
|
|
|
|
Settings.AutosaveInterval = Number(this.value);
|
2021-03-10 05:22:05 +01:00
|
|
|
setAutosaveLabel(autosaveInterval)
|
2018-01-20 05:47:57 +01:00
|
|
|
if (Number(this.value) === 0) {
|
|
|
|
Engine.Counters.autoSaveCounter = Infinity;
|
|
|
|
} else {
|
|
|
|
Engine.Counters.autoSaveCounter = Number(this.value) * 5;
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2018-09-12 05:05:13 +02:00
|
|
|
//Set handlers for when settings change on checkboxes
|
2018-05-06 22:27:47 +02:00
|
|
|
suppressMsgs.onclick = function() {
|
2017-08-30 19:44:29 +02:00
|
|
|
Settings.SuppressMessages = this.checked;
|
|
|
|
};
|
|
|
|
|
2018-05-06 22:27:47 +02:00
|
|
|
suppressFactionInv.onclick = function() {
|
2017-08-30 19:44:29 +02:00
|
|
|
Settings.SuppressFactionInvites = this.checked;
|
|
|
|
};
|
2018-02-15 05:26:43 +01:00
|
|
|
|
2018-06-13 09:37:21 +02:00
|
|
|
suppressTravelConfirmation.onclick = function() {
|
|
|
|
Settings.SuppressTravelConfirmation = this.checked;
|
|
|
|
};
|
|
|
|
|
2018-06-21 19:32:21 +02:00
|
|
|
suppressBuyAugmentationConfirmation.onclick = function() {
|
|
|
|
Settings.SuppressBuyAugmentationConfirmation = this.checked;
|
|
|
|
};
|
2018-09-12 05:05:13 +02:00
|
|
|
|
2018-08-12 07:39:37 +02:00
|
|
|
suppressHospitalizationPopup.onclick = function() {
|
|
|
|
Settings.SuppressHospitalizationPopup = this.checked;
|
|
|
|
}
|
2018-06-21 19:32:21 +02:00
|
|
|
|
2018-05-06 22:27:47 +02:00
|
|
|
disableHotkeys.onclick = function() {
|
|
|
|
Settings.DisableHotkeys = this.checked;
|
|
|
|
}
|
|
|
|
|
2018-09-12 05:05:13 +02:00
|
|
|
//Locale selector
|
|
|
|
locale.onchange = function() {
|
2018-09-12 17:53:08 +02:00
|
|
|
if (!numeralWrapper.updateLocale(locale.value)) {
|
2018-09-12 05:05:13 +02:00
|
|
|
console.warn(`Invalid locale for numeral: ${locale.value}`);
|
|
|
|
|
|
|
|
let defaultValue = 'en';
|
|
|
|
Settings.Locale = defaultValue;
|
|
|
|
locale.value = defaultValue;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
Settings.Locale = locale.value;
|
|
|
|
}
|
2017-07-25 16:39:56 +02:00
|
|
|
}
|
2017-08-30 19:44:29 +02:00
|
|
|
|
2018-07-31 05:02:12 +02:00
|
|
|
export { setSettingsLabels };
|