From fde4e7ac38a8085b4312cf336cddbefb9dd7dd03 Mon Sep 17 00:00:00 2001 From: Olivier Gagnon Date: Fri, 23 Sep 2022 00:13:06 -0400 Subject: [PATCH] fix 2962 --- src/GameOptions/ui/InterfacePage.tsx | 6 ++++++ src/Settings/Settings.ts | 7 +++++++ src/utils/StringHelperFunctions.ts | 5 +++-- 3 files changed, 16 insertions(+), 2 deletions(-) diff --git a/src/GameOptions/ui/InterfacePage.tsx b/src/GameOptions/ui/InterfacePage.tsx index 1c6745df9..f6ef0c645 100644 --- a/src/GameOptions/ui/InterfacePage.tsx +++ b/src/GameOptions/ui/InterfacePage.tsx @@ -50,6 +50,12 @@ export const InterfacePage = (): React.ReactElement => { <>If this is set all references to memory will use GiB instead of GB, in accordance with IEC 60027-2. } /> + (Settings.ShowMiddleNullTimeUnit = newValue)} + text="Show all intermediary times unit, even when null." + tooltip={<>ex : 1 hours 13 seconds becomes 1 hours 0 minutes 13 seconds.} + /> diff --git a/src/Settings/Settings.ts b/src/Settings/Settings.ts index 29f7eef70..d477ba6e3 100644 --- a/src/Settings/Settings.ts +++ b/src/Settings/Settings.ts @@ -154,6 +154,11 @@ interface IDefaultSettings { */ UseIEC60027_2: boolean; + /* + * Display intermediary time unit when their value is null + */ + ShowMiddleNullTimeUnit: boolean; + /* * Character overview settings */ @@ -222,6 +227,7 @@ export const defaultSettings: IDefaultSettings = { SuppressSavedGameToast: false, SuppressAutosaveDisabledWarnings: false, UseIEC60027_2: false, + ShowMiddleNullTimeUnit: false, ExcludeRunningScriptsFromSave: false, IsSidebarOpened: true, @@ -265,6 +271,7 @@ export const Settings: ISettings & ISelfInitializer & ISelfLoading = { SuppressSavedGameToast: defaultSettings.SuppressSavedGameToast, SuppressAutosaveDisabledWarnings: defaultSettings.SuppressAutosaveDisabledWarnings, UseIEC60027_2: defaultSettings.UseIEC60027_2, + ShowMiddleNullTimeUnit: defaultSettings.ShowMiddleNullTimeUnit, ExcludeRunningScriptsFromSave: defaultSettings.ExcludeRunningScriptsFromSave, IsSidebarOpened: defaultSettings.IsSidebarOpened, diff --git a/src/utils/StringHelperFunctions.ts b/src/utils/StringHelperFunctions.ts index 60bc09d6e..47f0db0e5 100644 --- a/src/utils/StringHelperFunctions.ts +++ b/src/utils/StringHelperFunctions.ts @@ -1,3 +1,4 @@ +import { Settings } from "../Settings/Settings"; import { EqualityFunc } from "../types"; import { isString } from "./helpers/isString"; @@ -39,10 +40,10 @@ function convertTimeMsToTimeElapsedString(time: number, showMilli = false): stri if (days > 0) { res += `${days} days `; } - if (hours > 0) { + if (hours > 0 || (Settings.ShowMiddleNullTimeUnit && res != "")) { res += `${hours} hours `; } - if (minutes > 0) { + if (minutes > 0 || (Settings.ShowMiddleNullTimeUnit && res != "")) { res += `${minutes} minutes `; } res += `${seconds} seconds`;