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)