diff --git a/src/engine.jsx b/src/engine.jsx index 1a2d3af1b..0581649d7 100644 --- a/src/engine.jsx +++ b/src/engine.jsx @@ -61,7 +61,6 @@ import { Sleeve } from "./PersonObjects/Sleeve/Sleeve"; import { createStatusText } from "./ui/createStatusText"; import { CharacterInfo } from "./ui/CharacterInfo"; import { Page, routing } from "./ui/navigationTracking"; -import { setSettingsLabels } from "./ui/setSettingsLabels"; import { Money } from "./ui/React/Money"; import { Hashes } from "./ui/React/Hashes"; import { Reputation } from "./ui/React/Reputation"; @@ -72,7 +71,6 @@ import { MainMenuLinks } from "./ui/MainMenu/Links"; import { createPopup } from "./ui/React/createPopup"; import { dialogBoxCreate } from "../utils/DialogBox"; -import { gameOptionsBoxClose, gameOptionsBoxOpen } from "../utils/GameOptions"; import { exceptionAlert } from "../utils/helpers/exceptionAlert"; import { removeLoadingScreen } from "../utils/uiHelpers/removeLoadingScreen"; import "./Exploits/tampering"; @@ -857,7 +855,6 @@ const Engine = { ReactDOM.render(, document.getElementById("sidebar")); // Initialize labels on game settings - setSettingsLabels(); Terminal.resetTerminalInput(); }, diff --git a/src/ui/setSettingsLabels.js b/src/ui/setSettingsLabels.js deleted file mode 100644 index 7a9fc599f..000000000 --- a/src/ui/setSettingsLabels.js +++ /dev/null @@ -1,132 +0,0 @@ -import { Engine } from "../engine"; -import { Settings } from "../Settings/Settings"; -import { numeralWrapper } from "./numeralFormat"; - -function setSettingsLabels() { - 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 suppressBladeburnerPopup = document.getElementById("settingsSuppressBladeburnerPopup"); - const autosaveInterval = document.getElementById("settingsAutosaveIntervalValLabel"); - const disableHotkeys = document.getElementById("settingsDisableHotkeys"); - const disableASCIIArt = document.getElementById("settingsDisableASCIIArt"); - const disableTextEffects = document.getElementById("settingsDisableTextEffects"); - const locale = document.getElementById("settingsLocale"); - - //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; - suppressTravelConfirmation.checked = Settings.SuppressTravelConfirmation; - suppressBuyAugmentationConfirmation.checked = Settings.SuppressBuyAugmentationConfirmation; - suppressHospitalizationPopup.checked = Settings.SuppressHospitalizationPopup; - suppressBladeburnerPopup.checked = Settings.SuppressBladeburnerPopup; - setAutosaveLabel(autosaveInterval); - disableHotkeys.checked = Settings.DisableHotkeys; - disableASCIIArt.checked = Settings.CityListView; - disableTextEffects.checked = Settings.DisableTextEffects; - locale.value = Settings.Locale; - numeralWrapper.updateLocale(Settings.Locale); //Initialize locale - - //Set handlers for when input changes for sliders - const nsExecTimeInput = document.getElementById("settingsNSExecTimeRangeVal"); - const nsLogRangeInput = document.getElementById("settingsNSLogRangeVal"); - const nsPortRangeInput = document.getElementById("settingsNSPortRangeVal"); - const nsAutosaveIntervalInput = document.getElementById("settingsAutosaveIntervalVal"); - nsExecTimeInput.value = Settings.CodeInstructionRunTime; - nsLogRangeInput.value = Settings.MaxLogCapacity; - nsPortRangeInput.value = Settings.MaxPortCapacity; - nsAutosaveIntervalInput.value = Settings.AutosaveInterval; - - nsExecTimeInput.oninput = function () { - nsExecTime.innerHTML = this.value + "ms"; - Settings.CodeInstructionRunTime = this.value; - }; - - nsLogRangeInput.oninput = function () { - nsLogLimit.innerHTML = this.value; - Settings.MaxLogCapacity = this.value; - }; - - nsPortRangeInput.oninput = function () { - nsPortLimit.innerHTML = this.value; - Settings.MaxPortCapacity = this.value; - }; - - nsAutosaveIntervalInput.oninput = function () { - Settings.AutosaveInterval = Number(this.value); - setAutosaveLabel(autosaveInterval); - if (Number(this.value) === 0) { - Engine.Counters.autoSaveCounter = Infinity; - } else { - Engine.Counters.autoSaveCounter = Number(this.value) * 5; - } - }; - - //Set handlers for when settings change on checkboxes - suppressMsgs.onclick = function () { - Settings.SuppressMessages = this.checked; - }; - - suppressFactionInv.onclick = function () { - Settings.SuppressFactionInvites = this.checked; - }; - - suppressTravelConfirmation.onclick = function () { - Settings.SuppressTravelConfirmation = this.checked; - }; - - suppressBuyAugmentationConfirmation.onclick = function () { - Settings.SuppressBuyAugmentationConfirmation = this.checked; - }; - - suppressHospitalizationPopup.onclick = function () { - Settings.SuppressHospitalizationPopup = this.checked; - }; - - suppressBladeburnerPopup.onclick = function () { - Settings.SuppressBladeburnerPopup = this.checked; - }; - - disableHotkeys.onclick = function () { - Settings.DisableHotkeys = this.checked; - }; - - disableASCIIArt.onclick = function () { - Settings.DisableASCIIArt = this.checked; - }; - - disableTextEffects.onclick = function () { - Settings.DisableTextEffects = this.checked; - }; - - //Locale selector - locale.onchange = function () { - if (!numeralWrapper.updateLocale(locale.value)) { - console.warn(`Invalid locale for numeral: ${locale.value}`); - - let defaultValue = "en"; - Settings.Locale = defaultValue; - locale.value = defaultValue; - return; - } - Settings.Locale = locale.value; - }; -} - -export { setSettingsLabels }; diff --git a/utils/GameOptions.js b/utils/GameOptions.js deleted file mode 100644 index ec5fc3c7e..000000000 --- a/utils/GameOptions.js +++ /dev/null @@ -1,50 +0,0 @@ -/* GameOptions.js */ -import { Player } from "../src/Player"; - -//Close box when clicking outside -$(document).click(function (event) { - if (gameOptionsOpened) { - if ($(event.target).closest(".game-options-box").get(0) == null) { - gameOptionsBoxClose(); - } - } -}); - -var gameOptionsOpened = false; -function gameOptionsBoxInit() { - return; - //Menu link button - document.getElementById("options-menu-link").addEventListener("click", function () { - gameOptionsBoxOpen(); - return false; - }); - - //Close button - var closeButton = document.getElementById("game-options-close-button"); - closeButton.addEventListener("click", function () { - gameOptionsBoxClose(); - return false; - }); -} - -document.addEventListener("DOMContentLoaded", gameOptionsBoxInit, false); - -function gameOptionsBoxClose() { - gameOptionsOpened = false; - var box = document.getElementById("game-options-container"); - box.style.display = "none"; -} - -function gameOptionsBoxOpen() { - var box = document.getElementById("game-options-container"); - box.style.display = "flex"; - - // special exception for bladeburner popup because it's only visible later. - document.getElementById("settingsSuppressBladeburnerPopup").closest("fieldset").style.display = - Player.canAccessBladeburner() ? "block" : "none"; - setTimeout(function () { - gameOptionsOpened = true; - }, 500); -} - -export { gameOptionsBoxOpen, gameOptionsBoxClose };