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.
This commit is contained in:
ErzengelLichtes
2021-12-29 15:51:59 -08:00
parent b578e09986
commit 8f3da16ecf
3 changed files with 30 additions and 5 deletions
+15
View File
@@ -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<HTMLInputElement>): void {
setUseIEC60027_2(event.target.checked);
Settings.UseIEC60027_2 = event.target.checked;
}
function handleDisableTextEffectsChange(event: React.ChangeEvent<HTMLInputElement>): void {
setDisableTextEffects(event.target.checked);
@@ -513,6 +518,16 @@ export function GameOptionsRoot(props: IProps): React.ReactElement {
}
/>
</ListItem>
<ListItem>
<FormControlLabel
control={<Switch checked={useIEC60027_2} onChange={handleUseIEC60027_2Change} />}
label={
<Tooltip title={<Typography>If this is set all references to memory will use GiB instead of GB, in accordance with IEC 60027-2.</Typography>}>
<Typography>Use GiB instead of GB</Typography>
</Tooltip>
}
/>
</ListItem>
<ListItem>
<Tooltip
title={