2018-07-31 05:02:12 +02:00
|
|
|
import {Engine} from "../engine";
|
|
|
|
import {Settings} from "../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() {
|
2017-08-30 19:44:29 +02:00
|
|
|
var nsExecTime = document.getElementById("settingsNSExecTimeRangeValLabel");
|
|
|
|
var nsLogLimit = document.getElementById("settingsNSLogRangeValLabel");
|
|
|
|
var nsPortLimit = document.getElementById("settingsNSPortRangeValLabel");
|
|
|
|
var suppressMsgs = document.getElementById("settingsSuppressMessages");
|
|
|
|
var suppressFactionInv = document.getElementById("settingsSuppressFactionInvites")
|
2018-06-13 09:37:21 +02:00
|
|
|
var suppressTravelConfirmation = document.getElementById("settingsSuppressTravelConfirmation");
|
2018-06-21 19:32:21 +02:00
|
|
|
var suppressBuyAugmentationConfirmation = document.getElementById("settingsSuppressBuyAugmentationConfirmation");
|
2018-08-12 07:39:37 +02:00
|
|
|
var suppressHospitalizationPopup = document.getElementById("settingsSuppressHospitalizationPopup");
|
2018-01-20 05:47:57 +01:00
|
|
|
var autosaveInterval = document.getElementById("settingsAutosaveIntervalValLabel");
|
2018-05-06 22:27:47 +02:00
|
|
|
var disableHotkeys = document.getElementById("settingsDisableHotkeys");
|
2018-09-12 05:05:13 +02:00
|
|
|
var 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;
|
2018-01-20 05:47:57 +01:00
|
|
|
autosaveInterval.innerHTML = Settings.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
|
2018-01-20 05:47:57 +01:00
|
|
|
var nsExecTimeInput = document.getElementById("settingsNSExecTimeRangeVal");
|
|
|
|
var nsLogRangeInput = document.getElementById("settingsNSLogRangeVal");
|
|
|
|
var nsPortRangeInput = document.getElementById("settingsNSPortRangeVal");
|
|
|
|
var nsAutosaveIntervalInput = document.getElementById("settingsAutosaveIntervalVal");
|
|
|
|
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() {
|
|
|
|
autosaveInterval.innerHTML = this.value;
|
|
|
|
Settings.AutosaveInterval = Number(this.value);
|
|
|
|
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 };
|