Locale setting implemented. Has numeral error when switching locales

This commit is contained in:
danielyxie 2018-09-11 22:05:13 -05:00
parent 0229eda9ce
commit 5635b51659
4 changed files with 95 additions and 16 deletions

@ -926,7 +926,7 @@
<!-- Suppress faction invites --> <!-- Suppress faction invites -->
<fieldset> <fieldset>
<label for="settingsSuppressFactionInvites" class="tooltip">Suppress Faction Invites: <label for="settingsSuppressFactionInvites" class="tooltip">Suppress Faction Invites:
<span class="tooltiptext"> <span class="tooltiptexthigh">
If this is set, then any faction invites you receive will not appear as popups If this is set, then any faction invites you receive will not appear as popups
on the screen. Your outstanding faction invites can be viewed in the 'Factions' page. on the screen. Your outstanding faction invites can be viewed in the 'Factions' page.
</span> </span>
@ -937,7 +937,7 @@
<!-- Suppress travel confirmation --> <!-- Suppress travel confirmation -->
<fieldset> <fieldset>
<label for="settingsSuppressTravelConfirmation" class="tooltip">Suppress Travel Confirmation: <label for="settingsSuppressTravelConfirmation" class="tooltip">Suppress Travel Confirmation:
<span class="tooltiptext"> <span class="tooltiptexthigh">
If this is set, the confirmation message before traveling will not show up. You will automatically be deducted the travel cost as soon as you click. If this is set, the confirmation message before traveling will not show up. You will automatically be deducted the travel cost as soon as you click.
</span> </span>
</label> </label>
@ -948,7 +948,7 @@
<!-- Suppress buy aug confirmation --> <!-- Suppress buy aug confirmation -->
<fieldset> <fieldset>
<label for="settingsSuppressBuyAugmentationConfirmation" class="tooltip">Suppress buy augmentation confirmation: <label for="settingsSuppressBuyAugmentationConfirmation" class="tooltip">Suppress buy augmentation confirmation:
<span class="tooltiptext"> <span class="tooltiptexthigh">
If this is set, the confirmation message before buying augmentation will not show up. If this is set, the confirmation message before buying augmentation will not show up.
</span> </span>
</label> </label>
@ -958,7 +958,7 @@
<!-- Hospitalization Popup --> <!-- Hospitalization Popup -->
<fieldset> <fieldset>
<label for="settingsSuppressHospitalizationPopup" class="tooltip">Suppress Hospitalization popup: <label for="settingsSuppressHospitalizationPopup" class="tooltip">Suppress Hospitalization popup:
<span class="tooltiptext"> <span class="tooltiptexthigh">
If this is set, a popup message will no longer be shown when you are hospitalized after taking too much damage. If this is set, a popup message will no longer be shown when you are hospitalized after taking too much damage.
</span> </span>
</label> </label>
@ -968,7 +968,7 @@
<!-- Disable Terminal and Navigation Shortcuts --> <!-- Disable Terminal and Navigation Shortcuts -->
<fieldset> <fieldset>
<label for="settingsDisableHotkeys" class="tooltip">Disable Hotkeys: <label for="settingsDisableHotkeys" class="tooltip">Disable Hotkeys:
<span class="tooltiptext"> <span class="tooltiptexthigh">
If this is set, then most hotkeys (keyboard shortcuts) in the game are disabled. If this is set, then most hotkeys (keyboard shortcuts) in the game are disabled.
This includes Terminal commands, hotkeys to navigate between different parts of the game, This includes Terminal commands, hotkeys to navigate between different parts of the game,
and the "Save and Close (Ctrl + b)" hotkey in the Text Editor. and the "Save and Close (Ctrl + b)" hotkey in the Text Editor.
@ -977,6 +977,32 @@
<input type="checkbox" name="settingsDisableHotkeys" id="settingsDisableHotkeys"> <input type="checkbox" name="settingsDisableHotkeys" id="settingsDisableHotkeys">
</fieldset> </fieldset>
<!-- Locale for displaying numbers -->
<fieldset>
<label for="settingsLocale" class="tooltip">Locale:
<span class="tooltiptexthigh">
Sets the locale for displaying numbers. Defaults to 'en'
</span>
</label>
<select name="settingsLocale" id="settingsLocale">
<option value="en">en</option>
<option value="bg">bg</option>
<option value="cs">cs</option>
<option value="da-dk">da-dk</option>
<option value="de">de</option>
<option value="en-au">en-au</option>
<option value="en-gb">en-gb</option>
<option value="es">es</option>
<option value="fr">fr</option>
<option value="hu">hu</option>
<option value="it">it</option>
<option value="lv">lv</option>
<option value="no">no</option>
<option value="pl">pl</option>
<option value="ru">ru</option>
</select>
</fieldset>
<!-- Donate button --> <!-- Donate button -->
<form action="https://www.paypal.com/cgi-bin/webscr" method="post" target="_blank"> <form action="https://www.paypal.com/cgi-bin/webscr" method="post" target="_blank">
<input type="hidden" name="cmd" value="_s-xclick"> <input type="hidden" name="cmd" value="_s-xclick">
@ -997,14 +1023,14 @@
<a id="import-game-link" class="a-link-button" style="display:inline-block;width:46%;"> Import Game </a> <a id="import-game-link" class="a-link-button" style="display:inline-block;width:46%;"> Import Game </a>
<a id="debug-delete-scripts-link" class="a-link-button tooltip" style="display:block;width:46%;"> <a id="debug-delete-scripts-link" class="a-link-button tooltip" style="display:block;width:46%;">
(DEBUG) Delete Active Scripts (DEBUG) Delete Active Scripts
<span class="tooltiptext"> <span class="tooltiptextleft">
Debug option used to forcefully kill all active running scripts, in case there is a bug or some unexpected issue with the game. After Debug option used to forcefully kill all active running scripts, in case there is a bug or some unexpected issue with the game. After
using this, save the game and then reload the page. using this, save the game and then reload the page.
</span> </span>
</a> </a>
<a id="debug-soft-reset" class="a-link-button tooltip" style="display:block;width:46%;"> <a id="debug-soft-reset" class="a-link-button tooltip" style="display:block;width:46%;">
(DEBUG) Soft Reset (DEBUG) Soft Reset
<span class="tooltiptext"> <span class="tooltiptextleft">
Perform a soft reset. Resets everything as if you had just purchased an Augmentation. Perform a soft reset. Resets everything as if you had just purchased an Augmentation.
</span> </span>
</a> </a>

@ -19,6 +19,11 @@ interface IDefaultSettings {
*/ */
DisableHotkeys: boolean; DisableHotkeys: boolean;
/**
* Locale used for display numbers
*/
Locale: string;
/** /**
* Limit the number of log entries for each script being executed on each server. * Limit the number of log entries for each script being executed on each server.
*/ */
@ -91,6 +96,7 @@ const defaultSettings: IDefaultSettings = {
AutosaveInterval: 60, AutosaveInterval: 60,
CodeInstructionRunTime: 50, CodeInstructionRunTime: 50,
DisableHotkeys: false, DisableHotkeys: false,
Locale: "en",
MaxLogCapacity: 50, MaxLogCapacity: 50,
MaxPortCapacity: 50, MaxPortCapacity: 50,
SuppressBuyAugmentationConfirmation: false, SuppressBuyAugmentationConfirmation: false,
@ -110,6 +116,7 @@ export const Settings: ISettings & ISelfInitializer & ISelfLoading = {
DisableHotkeys: defaultSettings.DisableHotkeys, DisableHotkeys: defaultSettings.DisableHotkeys,
EditorKeybinding: "ace", EditorKeybinding: "ace",
EditorTheme: "Monokai", EditorTheme: "Monokai",
Locale: "en",
MaxLogCapacity: defaultSettings.MaxLogCapacity, MaxLogCapacity: defaultSettings.MaxLogCapacity,
MaxPortCapacity: defaultSettings.MaxPortCapacity, MaxPortCapacity: defaultSettings.MaxPortCapacity,
SuppressBuyAugmentationConfirmation: defaultSettings.SuppressBuyAugmentationConfirmation, SuppressBuyAugmentationConfirmation: defaultSettings.SuppressBuyAugmentationConfirmation,

@ -928,7 +928,7 @@ if (htmlWebpackPlugin.options.googleAnalytics.trackingId) { %>
<!-- Suppress faction invites --> <!-- Suppress faction invites -->
<fieldset> <fieldset>
<label for="settingsSuppressFactionInvites" class="tooltip">Suppress Faction Invites: <label for="settingsSuppressFactionInvites" class="tooltip">Suppress Faction Invites:
<span class="tooltiptext"> <span class="tooltiptexthigh">
If this is set, then any faction invites you receive will not appear as popups If this is set, then any faction invites you receive will not appear as popups
on the screen. Your outstanding faction invites can be viewed in the 'Factions' page. on the screen. Your outstanding faction invites can be viewed in the 'Factions' page.
</span> </span>
@ -939,7 +939,7 @@ if (htmlWebpackPlugin.options.googleAnalytics.trackingId) { %>
<!-- Suppress travel confirmation --> <!-- Suppress travel confirmation -->
<fieldset> <fieldset>
<label for="settingsSuppressTravelConfirmation" class="tooltip">Suppress Travel Confirmation: <label for="settingsSuppressTravelConfirmation" class="tooltip">Suppress Travel Confirmation:
<span class="tooltiptext"> <span class="tooltiptexthigh">
If this is set, the confirmation message before traveling will not show up. You will automatically be deducted the travel cost as soon as you click. If this is set, the confirmation message before traveling will not show up. You will automatically be deducted the travel cost as soon as you click.
</span> </span>
</label> </label>
@ -950,7 +950,7 @@ if (htmlWebpackPlugin.options.googleAnalytics.trackingId) { %>
<!-- Suppress buy aug confirmation --> <!-- Suppress buy aug confirmation -->
<fieldset> <fieldset>
<label for="settingsSuppressBuyAugmentationConfirmation" class="tooltip">Suppress buy augmentation confirmation: <label for="settingsSuppressBuyAugmentationConfirmation" class="tooltip">Suppress buy augmentation confirmation:
<span class="tooltiptext"> <span class="tooltiptexthigh">
If this is set, the confirmation message before buying augmentation will not show up. If this is set, the confirmation message before buying augmentation will not show up.
</span> </span>
</label> </label>
@ -960,7 +960,7 @@ if (htmlWebpackPlugin.options.googleAnalytics.trackingId) { %>
<!-- Hospitalization Popup --> <!-- Hospitalization Popup -->
<fieldset> <fieldset>
<label for="settingsSuppressHospitalizationPopup" class="tooltip">Suppress Hospitalization popup: <label for="settingsSuppressHospitalizationPopup" class="tooltip">Suppress Hospitalization popup:
<span class="tooltiptext"> <span class="tooltiptexthigh">
If this is set, a popup message will no longer be shown when you are hospitalized after taking too much damage. If this is set, a popup message will no longer be shown when you are hospitalized after taking too much damage.
</span> </span>
</label> </label>
@ -970,7 +970,7 @@ if (htmlWebpackPlugin.options.googleAnalytics.trackingId) { %>
<!-- Disable Terminal and Navigation Shortcuts --> <!-- Disable Terminal and Navigation Shortcuts -->
<fieldset> <fieldset>
<label for="settingsDisableHotkeys" class="tooltip">Disable Hotkeys: <label for="settingsDisableHotkeys" class="tooltip">Disable Hotkeys:
<span class="tooltiptext"> <span class="tooltiptexthigh">
If this is set, then most hotkeys (keyboard shortcuts) in the game are disabled. If this is set, then most hotkeys (keyboard shortcuts) in the game are disabled.
This includes Terminal commands, hotkeys to navigate between different parts of the game, This includes Terminal commands, hotkeys to navigate between different parts of the game,
and the "Save and Close (Ctrl + b)" hotkey in the Text Editor. and the "Save and Close (Ctrl + b)" hotkey in the Text Editor.
@ -979,6 +979,32 @@ if (htmlWebpackPlugin.options.googleAnalytics.trackingId) { %>
<input type="checkbox" name="settingsDisableHotkeys" id="settingsDisableHotkeys"> <input type="checkbox" name="settingsDisableHotkeys" id="settingsDisableHotkeys">
</fieldset> </fieldset>
<!-- Locale for displaying numbers -->
<fieldset>
<label for="settingsLocale" class="tooltip">Locale:
<span class="tooltiptexthigh">
Sets the locale for displaying numbers. Defaults to 'en'
</span>
</label>
<select name="settingsLocale" id="settingsLocale">
<option value="en">en</option>
<option value="bg">bg</option>
<option value="cs">cs</option>
<option value="da-dk">da-dk</option>
<option value="de">de</option>
<option value="en-au">en-au</option>
<option value="en-gb">en-gb</option>
<option value="es">es</option>
<option value="fr">fr</option>
<option value="hu">hu</option>
<option value="it">it</option>
<option value="lv">lv</option>
<option value="no">no</option>
<option value="pl">pl</option>
<option value="ru">ru</option>
</select>
</fieldset>
<!-- Donate button --> <!-- Donate button -->
<form action="https://www.paypal.com/cgi-bin/webscr" method="post" target="_blank"> <form action="https://www.paypal.com/cgi-bin/webscr" method="post" target="_blank">
<input type="hidden" name="cmd" value="_s-xclick"> <input type="hidden" name="cmd" value="_s-xclick">
@ -999,14 +1025,14 @@ if (htmlWebpackPlugin.options.googleAnalytics.trackingId) { %>
<a id="import-game-link" class="a-link-button" style="display:inline-block;width:46%;"> Import Game </a> <a id="import-game-link" class="a-link-button" style="display:inline-block;width:46%;"> Import Game </a>
<a id="debug-delete-scripts-link" class="a-link-button tooltip" style="display:block;width:46%;"> <a id="debug-delete-scripts-link" class="a-link-button tooltip" style="display:block;width:46%;">
(DEBUG) Delete Active Scripts (DEBUG) Delete Active Scripts
<span class="tooltiptext"> <span class="tooltiptextleft">
Debug option used to forcefully kill all active running scripts, in case there is a bug or some unexpected issue with the game. After Debug option used to forcefully kill all active running scripts, in case there is a bug or some unexpected issue with the game. After
using this, save the game and then reload the page. using this, save the game and then reload the page.
</span> </span>
</a> </a>
<a id="debug-soft-reset" class="a-link-button tooltip" style="display:block;width:46%;"> <a id="debug-soft-reset" class="a-link-button tooltip" style="display:block;width:46%;">
(DEBUG) Soft Reset (DEBUG) Soft Reset
<span class="tooltiptext"> <span class="tooltiptextleft">
Perform a soft reset. Resets everything as if you had just purchased an Augmentation. Perform a soft reset. Resets everything as if you had just purchased an Augmentation.
</span> </span>
</a> </a>

@ -1,6 +1,8 @@
import {Engine} from "../engine"; import {Engine} from "../engine";
import {Settings} from "../Settings"; import {Settings} from "../Settings";
import numeral from "numeral/min/numeral.min";
function setSettingsLabels() { function setSettingsLabels() {
var nsExecTime = document.getElementById("settingsNSExecTimeRangeValLabel"); var nsExecTime = document.getElementById("settingsNSExecTimeRangeValLabel");
var nsLogLimit = document.getElementById("settingsNSLogRangeValLabel"); var nsLogLimit = document.getElementById("settingsNSLogRangeValLabel");
@ -12,6 +14,7 @@ function setSettingsLabels() {
var suppressHospitalizationPopup = document.getElementById("settingsSuppressHospitalizationPopup"); var suppressHospitalizationPopup = document.getElementById("settingsSuppressHospitalizationPopup");
var autosaveInterval = document.getElementById("settingsAutosaveIntervalValLabel"); var autosaveInterval = document.getElementById("settingsAutosaveIntervalValLabel");
var disableHotkeys = document.getElementById("settingsDisableHotkeys"); var disableHotkeys = document.getElementById("settingsDisableHotkeys");
var locale = document.getElementById("settingsLocale");
//Initialize values on labels //Initialize values on labels
nsExecTime.innerHTML = Settings.CodeInstructionRunTime + "ms"; nsExecTime.innerHTML = Settings.CodeInstructionRunTime + "ms";
@ -24,8 +27,9 @@ function setSettingsLabels() {
suppressHospitalizationPopup.checked = Settings.SuppressHospitalizationPopup; suppressHospitalizationPopup.checked = Settings.SuppressHospitalizationPopup;
autosaveInterval.innerHTML = Settings.AutosaveInterval; autosaveInterval.innerHTML = Settings.AutosaveInterval;
disableHotkeys.checked = Settings.DisableHotkeys; 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 nsExecTimeInput = document.getElementById("settingsNSExecTimeRangeVal");
var nsLogRangeInput = document.getElementById("settingsNSLogRangeVal"); var nsLogRangeInput = document.getElementById("settingsNSLogRangeVal");
var nsPortRangeInput = document.getElementById("settingsNSPortRangeVal"); var nsPortRangeInput = document.getElementById("settingsNSPortRangeVal");
@ -60,6 +64,7 @@ function setSettingsLabels() {
} }
}; };
//Set handlers for when settings change on checkboxes
suppressMsgs.onclick = function() { suppressMsgs.onclick = function() {
Settings.SuppressMessages = this.checked; Settings.SuppressMessages = this.checked;
}; };
@ -75,7 +80,7 @@ function setSettingsLabels() {
suppressBuyAugmentationConfirmation.onclick = function() { suppressBuyAugmentationConfirmation.onclick = function() {
Settings.SuppressBuyAugmentationConfirmation = this.checked; Settings.SuppressBuyAugmentationConfirmation = this.checked;
}; };
suppressHospitalizationPopup.onclick = function() { suppressHospitalizationPopup.onclick = function() {
Settings.SuppressHospitalizationPopup = this.checked; Settings.SuppressHospitalizationPopup = this.checked;
} }
@ -84,6 +89,21 @@ function setSettingsLabels() {
Settings.DisableHotkeys = this.checked; 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 //Theme
if (Settings.ThemeHighlightColor == null || Settings.ThemeFontColor == null || Settings.ThemeBackgroundColor == null) { if (Settings.ThemeHighlightColor == null || Settings.ThemeFontColor == null || Settings.ThemeBackgroundColor == null) {
console.log("ERROR: Cannot find Theme Settings"); console.log("ERROR: Cannot find Theme Settings");