Add option to hide the silver time when showing diamond time

This commit is contained in:
Terry Hearst 2023-10-06 22:38:09 -04:00
parent 492c125b8c
commit 2a3c7a888d
3 changed files with 32 additions and 12 deletions

View file

@ -20,6 +20,7 @@ namespace DiamondTimeViewer
public static bool Enabled = true; public static bool Enabled = true;
public static DisplayMode Mode = DisplayMode.Diamond; public static DisplayMode Mode = DisplayMode.Diamond;
public static bool HideSilver = false;
public static void Init() public static void Init()
{ {
@ -68,6 +69,9 @@ namespace DiamondTimeViewer
break; break;
} }
} }
if (data["hideSilver"] != null)
HideSilver = data["hideSilver"].AsBool;
} }
public static void SaveConfig() public static void SaveConfig()
@ -89,6 +93,7 @@ namespace DiamondTimeViewer
node.Add("mode", "always"); node.Add("mode", "always");
break; break;
} }
node.Add("hideSilver", HideSilver ? "true" : "false");
File.WriteAllText(GetConfigPath(), node.ToString()); File.WriteAllText(GetConfigPath(), node.ToString());
} }

View file

@ -8,16 +8,19 @@ namespace DiamondTimeViewer
{ {
MIU.Console.Instance.Write("Usage: dtv [value]"); MIU.Console.Instance.Write("Usage: dtv [value]");
MIU.Console.Instance.Write("Possible values:"); MIU.Console.Instance.Write("Possible values:");
MIU.Console.Instance.Write(" never Never show diamond times"); MIU.Console.Instance.Write(" never Never show diamond times");
MIU.Console.Instance.Write(" diamond Show once you've achieved diamond time"); MIU.Console.Instance.Write(" diamond Show once you've achieved diamond time");
MIU.Console.Instance.Write(" gold Show once you've achieved gold time"); MIU.Console.Instance.Write(" gold Show once you've achieved gold time");
MIU.Console.Instance.Write(" always Always show diamond time"); MIU.Console.Instance.Write(" always Always show diamond time");
MIU.Console.Instance.Write(""); MIU.Console.Instance.Write("");
MIU.Console.Instance.Write(" enable Enable the mod"); MIU.Console.Instance.Write(" hideSilver Hide silver when showing diamond");
MIU.Console.Instance.Write(" disable Disable the mod entirely"); MIU.Console.Instance.Write(" showSilver Show silver always");
MIU.Console.Instance.Write(""); MIU.Console.Instance.Write("");
MIU.Console.Instance.Write(" save Saves the current config"); MIU.Console.Instance.Write(" enable Enable the mod");
MIU.Console.Instance.Write(" load Loads the config file"); MIU.Console.Instance.Write(" disable Disable the mod (should be the same as \"never\" unless I messed up)");
MIU.Console.Instance.Write("");
MIU.Console.Instance.Write(" save Saves the current config");
MIU.Console.Instance.Write(" load Loads the config file");
} }
[ConsoleCommand(description = "Configures the Diamond Time Viewer", paramsDescription = "[value]")] [ConsoleCommand(description = "Configures the Diamond Time Viewer", paramsDescription = "[value]")]
@ -45,6 +48,12 @@ namespace DiamondTimeViewer
case "always": case "always":
Config.Mode = DisplayMode.Always; Config.Mode = DisplayMode.Always;
return "mode set to: always"; return "mode set to: always";
case "hideSilver":
Config.HideSilver = true;
return "Hiding silver time";
case "showSilver":
Config.HideSilver = false;
return "Showing silver time";
case "enable": case "enable":
Config.Enabled = true; Config.Enabled = true;
return "Mod enabled"; return "Mod enabled";

View file

@ -35,14 +35,22 @@ namespace DiamondTimeViewer.Patches
} }
} }
string silverText = "<sprite=1> " + SegmentedTime.SPTimeText(silver);
string spacingText = "<space=0.5em> "; string spacingText = "<space=0.5em> ";
string diamondText = ""; string diamondText = "";
if (showDiamondTime) if (showDiamondTime)
{ {
spacingText = "<space=0.25em> "; if (Config.HideSilver)
silverText = "";
else
spacingText = "<space=0.25em> ";
diamondText = spacingText + "<sprite=3> " + SegmentedTime.SPTimeText(diamond, true); diamondText = spacingText + "<sprite=3> " + SegmentedTime.SPTimeText(diamond, true);
} }
if (silverText != "")
silverText += spacingText;
bool hasEgg = eggUnlock != null && eggUnlock.Count > 0; bool hasEgg = eggUnlock != null && eggUnlock.Count > 0;
bool gotEgg = hasEgg && UnlockManager.Get().IsUnlocked(eggUnlock[0]) && !CosmeticValues.WasPurchased(eggUnlock[0]); bool gotEgg = hasEgg && UnlockManager.Get().IsUnlocked(eggUnlock[0]) && !CosmeticValues.WasPurchased(eggUnlock[0]);
@ -52,9 +60,7 @@ namespace DiamondTimeViewer.Patches
__instance.MedalTimes.text = string.Concat(new string[] __instance.MedalTimes.text = string.Concat(new string[]
{ {
"<sprite=1> ", silverText,
SegmentedTime.SPTimeText(silver),
spacingText,
"<sprite=2> ", "<sprite=2> ",
SegmentedTime.SPTimeText(gold), SegmentedTime.SPTimeText(gold),
diamondText, diamondText,