diff --git a/Config.cs b/Config.cs index ccf4460..9ad5ade 100644 --- a/Config.cs +++ b/Config.cs @@ -18,7 +18,6 @@ namespace DiamondTimeViewer { private const string CONFIG_FILE_NAME = "config.json"; - public static bool Enabled = true; public static DisplayMode Mode = DisplayMode.Diamond; public static bool HideSilver = false; @@ -46,9 +45,6 @@ namespace DiamondTimeViewer return; } - if (data["enabled"] != null) - Enabled = data["enabled"].AsBool; - if (data["mode"] != null) { string mode = data["mode"].Value.ToLower(); @@ -77,7 +73,6 @@ namespace DiamondTimeViewer public static void SaveConfig() { JSONNode node = new JSONClass(); - node.Add("enabled", Enabled ? "true" : "false"); switch(Mode) { case DisplayMode.Never: diff --git a/ConsoleCommands.cs b/ConsoleCommands.cs index 9196961..bb524aa 100644 --- a/ConsoleCommands.cs +++ b/ConsoleCommands.cs @@ -15,12 +15,6 @@ namespace DiamondTimeViewer MIU.Console.Instance.Write(""); MIU.Console.Instance.Write(" hideSilver Hide silver when showing diamond"); MIU.Console.Instance.Write(" showSilver Show silver always"); - MIU.Console.Instance.Write(""); - MIU.Console.Instance.Write(" enable Enable the mod"); - 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]")] @@ -34,42 +28,42 @@ namespace DiamondTimeViewer string value = args[0]; + string message; + switch (value) { case "never": Config.Mode = DisplayMode.Never; - return "mode set to: never"; + message = "mode set to: never"; + break; case "diamond": Config.Mode = DisplayMode.Diamond; - return "mode set to: diamond"; + message = "mode set to: diamond"; + break; case "gold": Config.Mode = DisplayMode.Gold; - return "mode set to: gold"; + message = "mode set to: gold"; + break; case "always": Config.Mode = DisplayMode.Always; - return "mode set to: always"; + message = "mode set to: always"; + break; case "hideSilver": Config.HideSilver = true; - return "Hiding silver time"; + message = "Hiding silver time"; + break; case "showSilver": Config.HideSilver = false; - return "Showing silver time"; - case "enable": - Config.Enabled = true; - return "Mod enabled"; - case "disable": - Config.Enabled = false; - return "Mod disabled"; - case "save": - Config.SaveConfig(); - return "Config file saved"; - case "load": - Config.ReadConfig(); - return "Config file loaded"; + message = "Showing silver time"; + break; default: printUsage(); + // Return early (no auto save) return ""; } + + Config.SaveConfig(); + return message; } } } diff --git a/Patches/GamePlayManagerPatches.cs b/Patches/GamePlayManagerPatches.cs index 9824622..2512928 100644 --- a/Patches/GamePlayManagerPatches.cs +++ b/Patches/GamePlayManagerPatches.cs @@ -8,7 +8,7 @@ namespace DiamondTimeViewer.Patches { static void Postfix(GamePlayManager __instance, MarbleController marble) { - if (!Config.Enabled) + if (Config.Mode == DisplayMode.Never) return; if ((__instance.PlayType == PlayType.Normal || __instance.PlayType == PlayType.Ghost) && !MarbleManager.usedRewind && LevelSelect.instance != null) diff --git a/Patches/MedalsDisplayPatches.cs b/Patches/MedalsDisplayPatches.cs index e595cf6..14b3776 100644 --- a/Patches/MedalsDisplayPatches.cs +++ b/Patches/MedalsDisplayPatches.cs @@ -8,7 +8,7 @@ namespace DiamondTimeViewer.Patches { static bool Prefix(MedalsDisplay __instance, float silver, float gold, List eggUnlock) { - if (!Config.Enabled) + if (Config.Mode == DisplayMode.Never) return true; // Get diamond time (since it is not passed in as a parameter) @@ -28,9 +28,6 @@ namespace DiamondTimeViewer.Patches case DisplayMode.Gold: showDiamondTime = LevelSelect.instance.bestScore > 0f && LevelSelect.instance.bestScore <= gold; break; - case DisplayMode.Never: - showDiamondTime = false; - break; } } diff --git a/README.md b/README.md index f5df3be..f42d39b 100644 --- a/README.md +++ b/README.md @@ -16,17 +16,15 @@ This is a mod of [Marble It Up! Ultra](https://marbleitup.com/) which allows you All of these options can be configured by editing `config.json` or using the `dtv` console command. There are a few modes which I felt made sense as a way to show diamond times. They are as follows, in order of most to least restrictive: -* Never show diamond times. This should be the same as not having the mod installed, unless I made a mistake somewhere. -* Only show the diamond time after you have achieved it. **This is the default mode.** -* Show the diamond time after you have achieved the gold time. This is to help players who can achieve gold times, but might not want to commit to grinding a diamond time unless they think they can achieve it. -* Always show diamond times no matter what. +* `never`: Never show diamond times. This option disables the mod and lets the original code run. +* `diamond`: Only show the diamond time after you have achieved it. **This is the default mode.** +* `gold`: Show the diamond time after you have achieved the gold time. This is to help players who can achieve gold times, but might not want to commit to grinding a diamond time unless they think they can achieve it. +* `always`: Always show diamond times no matter what. When showing the diamond time, it will show three times instead of two, making things slightly more cluttered. If this is bothersome, I added some additonal options: * Show silver time no matter what. **This is the default mode.** * Hide the silver time when showing the diamond time. This means that no matter what, you will always see exactly two times in the menu. When the diamond time is being displayed, it will not display the silver time, so it will only show the gold and diamond time and retain a similar layout to the vanilla game. -For some reason, I also felt the need to include the ability to disable the mod entirely. The mod being completely disabled _should be_ the same as selecting the mode "never". But if I made any mistakes, there could be differences, and if there are, please report them! - ## Build If you just want to use the mod, refer to the Usage section above. These instructions are if you want to compile the mod itself.