From 314e108d0e95a815a360ffd44a46d9f7cb9c7cea Mon Sep 17 00:00:00 2001 From: Az <56699741+AlchlcDvl@users.noreply.github.com> Date: Tue, 17 Nov 2026 00:04:10 -0500 Subject: [PATCH] hail mary fix for `s` showing up uninvited --- MiraAPI/Patches/Options/SettingPatches.cs | 48 ++++++++++++++++++++++ MiraAPI/PluginLoading/MiraPluginManager.cs | 2 +- 2 files changed, 49 insertions(+), 1 deletion(-) diff --git a/MiraAPI/Patches/Options/SettingPatches.cs b/MiraAPI/Patches/Options/SettingPatches.cs index 6a0115b4..88a22655 100644 --- a/MiraAPI/Patches/Options/SettingPatches.cs +++ b/MiraAPI/Patches/Options/SettingPatches.cs @@ -60,4 +60,52 @@ public static class SettingPatches __result = result; return false; } + + /// + /// Prefix for the method. Adds support for custom number suffixes. + /// + /// The instance. + /// The result of the method. + /// The value. + /// to skip original method. + [HarmonyPrefix] + [HarmonyPatch(typeof(IntGameSetting), nameof(IntGameSetting.GetValueString))] + public static bool ValueStringPatch( + IntGameSetting __instance, + ref string __result, + [HarmonyArgument(0)] float value) + { + string result; + var suffix = (MiraNumberSuffixes)__instance.SuffixType; + + var custom = + ModdedOptionsManager.ModdedOptions.Values.FirstOrDefault(opt => + opt.OptionBehaviour != null && opt.OptionBehaviour.Data == __instance); + if (custom is ModdedNumberOption moddedNumberOption) + { + if (moddedNumberOption.NegativeWordValue != "#" && (int)value == -1) + { + result = $"{moddedNumberOption.NegativeWordValue}"; + } + else if (moddedNumberOption.ZeroWordValue != "#" && Mathf.Abs(value) < 0.0001f) + { + result = $"{moddedNumberOption.ZeroWordValue}"; + } + else + { + result = Helpers.FormatValue(value, suffix, __instance.FormatString); + } + } + else if (__instance.ZeroIsInfinity && Mathf.Abs(value) < 0.0001f) + { + result = "∞"; + } + else + { + result = Helpers.FormatValue(value, suffix, __instance.FormatString); + } + + __result = result; + return false; + } } diff --git a/MiraAPI/PluginLoading/MiraPluginManager.cs b/MiraAPI/PluginLoading/MiraPluginManager.cs index 245e9ec5..83c467cb 100644 --- a/MiraAPI/PluginLoading/MiraPluginManager.cs +++ b/MiraAPI/PluginLoading/MiraPluginManager.cs @@ -167,7 +167,7 @@ public sealed class MiraPluginManager foreach (var type in AccessTools.GetTypesFromAssembly(assembly)) { - if (type.IsDefined()) + if (type.IsDefined() || type.IsDefined()) continue; foreach (var (logContext, handler) in RegistrationHandlers)