From 7865e71b4052bbfaf9fbc30efa532ce3769983ae Mon Sep 17 00:00:00 2001 From: D1GQ Date: Fri, 20 Mar 2026 11:39:36 -0500 Subject: [PATCH] Allow toggling minimap icons in game --- .../Client/OptionsMenuBehaviourPatch.cs | 21 +++------------- .../Gameplay/UI/MiniMapBehaviourPatch.cs | 24 +++++++++++++++++++ 2 files changed, 27 insertions(+), 18 deletions(-) diff --git a/src/Patches/Client/OptionsMenuBehaviourPatch.cs b/src/Patches/Client/OptionsMenuBehaviourPatch.cs index 33776c3..eed3675 100644 --- a/src/Patches/Client/OptionsMenuBehaviourPatch.cs +++ b/src/Patches/Client/OptionsMenuBehaviourPatch.cs @@ -5,6 +5,7 @@ using BetterAmongUs.Helpers; using BetterAmongUs.Managers; using BetterAmongUs.Modules; using BetterAmongUs.Mono; +using BetterAmongUs.Patches.Gameplay.UI; using BetterAmongUs.Patches.Gameplay.UI.Chat; using HarmonyLib; using System.Diagnostics; @@ -52,24 +53,8 @@ internal static class OptionsMenuBehaviourPatch ClientOptionItem.CreateToggle(Translator.GetString("BetterOption.UnlockFPS"), BAUConfigs.UnlockFPS, 1, __instance, UpdateFrameRate); ClientOptionItem.CreateToggle(Translator.GetString("BetterOption.ShowFPS"), BAUConfigs.ShowFPS, 1, __instance); - ClientOptionItem.CreateToggle(Translator.GetString("BetterOption.VentColorGroups"), BAUConfigs.VentColorGroups, 2, __instance, toggleCheck: () => - { - bool cannotToggle = GameState.IsInGame && !GameState.IsLobby; - if (cannotToggle) - { - BetterNotificationManager.Notify($"Unable to toggle while in gameplay!", 2.5f); - } - return !cannotToggle; - }); - ClientOptionItem.CreateToggle(Translator.GetString("BetterOption.MinimapIcons"), BAUConfigs.MinimapIcons, 2, __instance, toggleCheck: () => - { - bool cannotToggle = GameState.IsInGame && !GameState.IsLobby; - if (cannotToggle) - { - BetterNotificationManager.Notify($"Unable to toggle while in gameplay!", 2.5f); - } - return !cannotToggle; - }); + ClientOptionItem.CreateToggle(Translator.GetString("BetterOption.VentColorGroups"), BAUConfigs.VentColorGroups, 2, __instance, MiniMapBehaviourPatch.ClearMapIcons); + ClientOptionItem.CreateToggle(Translator.GetString("BetterOption.MinimapIcons"), BAUConfigs.MinimapIcons, 2, __instance, MiniMapBehaviourPatch.ClearMapIcons); // Button options (no toggle) if (!ModInfo.Starlight) diff --git a/src/Patches/Gameplay/UI/MiniMapBehaviourPatch.cs b/src/Patches/Gameplay/UI/MiniMapBehaviourPatch.cs index 382e207..6c5c93d 100644 --- a/src/Patches/Gameplay/UI/MiniMapBehaviourPatch.cs +++ b/src/Patches/Gameplay/UI/MiniMapBehaviourPatch.cs @@ -65,6 +65,22 @@ internal static class MiniMapBehaviourPatch private static Transform? _icons; // Container for all custom map icons + /// + /// Clears all map icons to be regenerated + /// + internal static void ClearMapIcons() + { + if (_icons != null) + { + UnityEngine.Object.Destroy(_icons.gameObject); + } + + if (MapBehaviour.Instance != null && MapBehaviour.Instance.IsOpen) + { + MapBehaviour.Instance.Close(); + } + } + [HarmonyPatch(typeof(MapBehaviour), nameof(MapBehaviour.Show))] [HarmonyPostfix] private static void MapBehaviour_Show_Postfix(MapBehaviour __instance) @@ -73,7 +89,15 @@ internal static class MiniMapBehaviourPatch return; if (!BAUConfigs.MinimapIcons.Value) + { + // Reset infected overlay buttons + foreach (var button in __instance.infectedOverlay.allButtons) + { + button.spriteRenderer.color = new Color(1f, 1f, 1f, 1f); + button.transform.localScale = new Vector3(0.8f, 0.8f, 1f); + } return; + } // Make infected overlay buttons semi-transparent and smaller foreach (var button in __instance.infectedOverlay.allButtons)