From 8f3da16ecf7cd0e011572201ca909fa6fb663f82 Mon Sep 17 00:00:00 2001 From: ErzengelLichtes Date: Wed, 29 Dec 2021 15:51:59 -0800 Subject: [PATCH] Use numeral.js to format memory, allow use of GiB with an option numeral.js has a formatter for both kilobyte and kibibyte, so why use a custom formatter that only goes up to exabyte? Also added a setting to allow people who really want to see GiB to enable that, even if it doesn't make sense. --- src/Settings/Settings.ts | 7 +++++++ src/ui/React/GameOptionsRoot.tsx | 15 +++++++++++++++ src/ui/numeralFormat.ts | 13 ++++++++----- 3 files changed, 30 insertions(+), 5 deletions(-) diff --git a/src/Settings/Settings.ts b/src/Settings/Settings.ts index 3654a87a5..09ff446c9 100644 --- a/src/Settings/Settings.ts +++ b/src/Settings/Settings.ts @@ -113,6 +113,11 @@ interface IDefaultSettings { * Theme colors */ theme: ITheme; + + /* + * Use GiB instead of GB + */ + UseIEC60027_2: boolean; } /** @@ -160,6 +165,7 @@ export const defaultSettings: IDefaultSettings = { SuppressBladeburnerPopup: false, SuppressTIXPopup: false, SuppressSavedGameToast: false, + UseIEC60027_2: false, theme: defaultTheme, }; @@ -192,6 +198,7 @@ export const Settings: ISettings & ISelfInitializer & ISelfLoading = { SuppressBladeburnerPopup: defaultSettings.SuppressBladeburnerPopup, SuppressTIXPopup: defaultSettings.SuppressTIXPopup, SuppressSavedGameToast: defaultSettings.SuppressSavedGameToast, + UseIEC60027_2: defaultSettings.UseIEC60027_2, MonacoTheme: "monokai", MonacoInsertSpaces: false, MonacoFontSize: 20, diff --git a/src/ui/React/GameOptionsRoot.tsx b/src/ui/React/GameOptionsRoot.tsx index 24443de42..dbed71e20 100644 --- a/src/ui/React/GameOptionsRoot.tsx +++ b/src/ui/React/GameOptionsRoot.tsx @@ -78,6 +78,7 @@ export function GameOptionsRoot(props: IProps): React.ReactElement { const [enableBashHotkeys, setEnableBashHotkeys] = useState(Settings.EnableBashHotkeys); const [timestampFormat, setTimestampFormat] = useState(Settings.TimestampsFormat); const [saveGameOnFileSave, setSaveGameOnFileSave] = useState(Settings.SaveGameOnFileSave); + const [useIEC60027_2, setUseIEC60027_2] = useState(Settings.UseIEC60027_2); const [locale, setLocale] = useState(Settings.Locale); const [diagnosticOpen, setDiagnosticOpen] = useState(false); @@ -154,6 +155,10 @@ export function GameOptionsRoot(props: IProps): React.ReactElement { setDisableASCIIArt(event.target.checked); Settings.DisableASCIIArt = event.target.checked; } + function handleUseIEC60027_2Change(event: React.ChangeEvent): void { + setUseIEC60027_2(event.target.checked); + Settings.UseIEC60027_2 = event.target.checked; + } function handleDisableTextEffectsChange(event: React.ChangeEvent): void { setDisableTextEffects(event.target.checked); @@ -513,6 +518,16 @@ export function GameOptionsRoot(props: IProps): React.ReactElement { } /> + + } + label={ + If this is set all references to memory will use GiB instead of GB, in accordance with IEC 60027-2.}> + Use GiB instead of GB + + } + /> +