mirror of
https://github.com/bitburner-official/bitburner-src.git
synced 2026-04-21 00:32:51 +02:00
Locale setting implemented. Has numeral error when switching locales
This commit is contained in:
@@ -1,6 +1,8 @@
|
||||
import {Engine} from "../engine";
|
||||
import {Settings} from "../Settings";
|
||||
|
||||
import numeral from "numeral/min/numeral.min";
|
||||
|
||||
function setSettingsLabels() {
|
||||
var nsExecTime = document.getElementById("settingsNSExecTimeRangeValLabel");
|
||||
var nsLogLimit = document.getElementById("settingsNSLogRangeValLabel");
|
||||
@@ -12,6 +14,7 @@ function setSettingsLabels() {
|
||||
var suppressHospitalizationPopup = document.getElementById("settingsSuppressHospitalizationPopup");
|
||||
var autosaveInterval = document.getElementById("settingsAutosaveIntervalValLabel");
|
||||
var disableHotkeys = document.getElementById("settingsDisableHotkeys");
|
||||
var locale = document.getElementById("settingsLocale");
|
||||
|
||||
//Initialize values on labels
|
||||
nsExecTime.innerHTML = Settings.CodeInstructionRunTime + "ms";
|
||||
@@ -24,8 +27,9 @@ function setSettingsLabels() {
|
||||
suppressHospitalizationPopup.checked = Settings.SuppressHospitalizationPopup;
|
||||
autosaveInterval.innerHTML = Settings.AutosaveInterval;
|
||||
disableHotkeys.checked = Settings.DisableHotkeys;
|
||||
locale.value = Settings.Locale;
|
||||
|
||||
//Set handlers for when input changes
|
||||
//Set handlers for when input changes for sliders
|
||||
var nsExecTimeInput = document.getElementById("settingsNSExecTimeRangeVal");
|
||||
var nsLogRangeInput = document.getElementById("settingsNSLogRangeVal");
|
||||
var nsPortRangeInput = document.getElementById("settingsNSPortRangeVal");
|
||||
@@ -60,6 +64,7 @@ function setSettingsLabels() {
|
||||
}
|
||||
};
|
||||
|
||||
//Set handlers for when settings change on checkboxes
|
||||
suppressMsgs.onclick = function() {
|
||||
Settings.SuppressMessages = this.checked;
|
||||
};
|
||||
@@ -75,7 +80,7 @@ function setSettingsLabels() {
|
||||
suppressBuyAugmentationConfirmation.onclick = function() {
|
||||
Settings.SuppressBuyAugmentationConfirmation = this.checked;
|
||||
};
|
||||
|
||||
|
||||
suppressHospitalizationPopup.onclick = function() {
|
||||
Settings.SuppressHospitalizationPopup = this.checked;
|
||||
}
|
||||
@@ -84,6 +89,21 @@ function setSettingsLabels() {
|
||||
Settings.DisableHotkeys = this.checked;
|
||||
}
|
||||
|
||||
//Locale selector
|
||||
locale.onchange = function() {
|
||||
if (numeral.locale(locale.value) == null) {
|
||||
console.warn(`Invalid locale for numeral: ${locale.value}`);
|
||||
|
||||
let defaultValue = 'en';
|
||||
numeral.locale(defaultValue);
|
||||
Settings.Locale = defaultValue;
|
||||
locale.value = defaultValue;
|
||||
return;
|
||||
}
|
||||
|
||||
Settings.Locale = locale.value;
|
||||
}
|
||||
|
||||
//Theme
|
||||
if (Settings.ThemeHighlightColor == null || Settings.ThemeFontColor == null || Settings.ThemeBackgroundColor == null) {
|
||||
console.log("ERROR: Cannot find Theme Settings");
|
||||
|
||||
Reference in New Issue
Block a user