2018-06-26 18:34:11 +02:00
|
|
|
import {Engine} from "./engine";
|
2018-01-20 05:47:57 +01:00
|
|
|
|
2017-07-22 00:54:55 +02:00
|
|
|
/* Settings.js */
|
2017-08-30 19:44:29 +02:00
|
|
|
let Settings = {
|
2018-06-21 19:32:21 +02:00
|
|
|
CodeInstructionRunTime: 50,
|
|
|
|
MaxLogCapacity: 50,
|
|
|
|
MaxPortCapacity: 50,
|
|
|
|
SuppressMessages: false,
|
|
|
|
SuppressFactionInvites: false,
|
|
|
|
SuppressTravelConfirmation: false,
|
|
|
|
SuppressBuyAugmentationConfirmation: false,
|
|
|
|
AutosaveInterval: 60,
|
|
|
|
DisableHotkeys: false,
|
|
|
|
ThemeHighlightColor: "#ffffff",
|
|
|
|
ThemeFontColor: "#66ff33",
|
|
|
|
ThemeBackgroundColor: "#000000",
|
|
|
|
EditorTheme: "Monokai",
|
|
|
|
EditorKeybinding: "ace",
|
2017-07-25 16:39:56 +02:00
|
|
|
}
|
|
|
|
|
2017-08-30 19:44:29 +02:00
|
|
|
function loadSettings(saveString) {
|
|
|
|
Settings = JSON.parse(saveString);
|
|
|
|
}
|
|
|
|
|
2017-07-25 16:39:56 +02:00
|
|
|
function initSettings() {
|
2017-09-07 07:45:14 +02:00
|
|
|
Settings.CodeInstructionRunTime = 50;
|
2017-07-25 16:39:56 +02:00
|
|
|
Settings.MaxLogCapacity = 50;
|
|
|
|
Settings.MaxPortCapacity = 50;
|
2017-07-27 04:56:14 +02:00
|
|
|
Settings.SuppressMessages = false;
|
|
|
|
Settings.SuppressFactionInvites = false;
|
2018-06-01 20:09:40 +02:00
|
|
|
Settings.SuppressTravelConfirmation = false;
|
2018-06-27 04:04:45 +02:00
|
|
|
Settings.SuppressBuyAugmentationConfirmation = false;
|
2018-01-20 05:47:57 +01:00
|
|
|
Settings.AutosaveInterval = 60;
|
2018-05-06 22:27:47 +02:00
|
|
|
Settings.DisableHotkeys = false;
|
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-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");
|
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-01-20 05:47:57 +01:00
|
|
|
autosaveInterval.innerHTML = Settings.AutosaveInterval;
|
2018-05-06 22:27:47 +02:00
|
|
|
disableHotkeys.checked = Settings.DisableHotkeys;
|
2017-08-30 19:44:29 +02:00
|
|
|
|
|
|
|
//Set handlers for when input changes
|
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-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;
|
|
|
|
console.log('sup buy: '+Settings.SuppressBuyAugmentationConfirmation);
|
|
|
|
};
|
|
|
|
|
2018-05-06 22:27:47 +02:00
|
|
|
disableHotkeys.onclick = function() {
|
|
|
|
Settings.DisableHotkeys = this.checked;
|
|
|
|
}
|
|
|
|
|
2018-02-15 05:26:43 +01:00
|
|
|
//Theme
|
|
|
|
if (Settings.ThemeHighlightColor == null || Settings.ThemeFontColor == null || Settings.ThemeBackgroundColor == null) {
|
|
|
|
console.log("ERROR: Cannot find Theme Settings");
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
if (/^#[0-9a-f]{3}(?:[0-9a-f]{3})?$/i.test(Settings.ThemeHighlightColor) &&
|
|
|
|
/^#[0-9a-f]{3}(?:[0-9a-f]{3})?$/i.test(Settings.ThemeFontColor) &&
|
|
|
|
/^#[0-9a-f]{3}(?:[0-9a-f]{3})?$/i.test(Settings.ThemeBackgroundColor)) {
|
|
|
|
document.body.style.setProperty('--my-highlight-color', Settings.ThemeHighlightColor);
|
|
|
|
document.body.style.setProperty('--my-font-color', Settings.ThemeFontColor);
|
|
|
|
document.body.style.setProperty('--my-background-color', Settings.ThemeBackgroundColor);
|
|
|
|
}
|
2017-07-25 16:39:56 +02:00
|
|
|
}
|
2017-08-30 19:44:29 +02:00
|
|
|
|
|
|
|
export {Settings, initSettings, setSettingsLabels, loadSettings};
|