Allow toggling minimap icons in game

This commit is contained in:
D1GQ committed 2026-03-20 11:39:36 -05:00
1 parent bbe4de6a45
commit 7865e71b40
2 files changed
+27 -18

No files matched your search

@@ -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)
@@ -65,6 +65,22 @@ internal static class MiniMapBehaviourPatch
private static Transform? _icons; // Container for all custom map icons
/// <summary>
/// Clears all map icons to be regenerated
/// </summary>
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)