From 16e2c25c2dacb27002f6e169d70dff8eb2f572e1 Mon Sep 17 00:00:00 2001 From: neilmjain <69025896+neilmjain@users.noreply.github.com> Date: Thu, 22 Oct 2026 18:35:59 -0400 Subject: [PATCH 01/18] fix match info guide scroller bounds cutting off content and only spawn scroller if needed to --- MiraAPI/Utilities/Helpers.cs | 52 ++++++++++++++---------------------- 1 file changed, 20 insertions(+), 32 deletions(-) diff --git a/MiraAPI/Utilities/Helpers.cs b/MiraAPI/Utilities/Helpers.cs index 94fea9f2..76107a04 100644 --- a/MiraAPI/Utilities/Helpers.cs +++ b/MiraAPI/Utilities/Helpers.cs @@ -1040,7 +1040,6 @@ public static class Helpers } } - var contentBottom = float.PositiveInfinity; var previousGroup = (AbstractOptionGroup?)null; var rowIndex = 0; var column = 0; @@ -1155,12 +1154,6 @@ public static class Helpers renderer.maskInteraction = SpriteMaskInteraction.VisibleInsideMask; renderer.material.SetInt(PlayerMaterial.MaskLayer, 50); renderer.sortingOrder = contentSortingOrder; - if (renderer.enabled && renderer.sprite) - { - contentBottom = Mathf.Min( - contentBottom, - inner.InverseTransformPoint(renderer.bounds.min).y); - } } foreach (var text in header.GetComponentsInChildren(true)) @@ -1171,9 +1164,6 @@ public static class Helpers if (text.enabled) { text.ForceMeshUpdate(); - contentBottom = Mathf.Min( - contentBottom, - inner.InverseTransformPoint(text.bounds.min).y); } } @@ -1238,27 +1228,6 @@ public static class Helpers renderer.maskInteraction = SpriteMaskInteraction.VisibleInsideMask; renderer.material.SetInt(PlayerMaterial.MaskLayer, 50); renderer.sortingOrder = contentSortingOrder; - if (renderer.enabled && - renderer.sprite && - renderer.transform != row.PlusBtn.transform && - !renderer.transform.IsChildOf(row.PlusBtn.transform) && - renderer.transform != row.MinusBtn.transform && - !renderer.transform.IsChildOf(row.MinusBtn.transform)) - { - contentBottom = Mathf.Min( - contentBottom, - inner.InverseTransformPoint(renderer.bounds.min).y); - } - } - - foreach (var text in row.GetComponentsInChildren(true)) - { - if (text.enabled) - { - contentBottom = Mathf.Min( - contentBottom, - inner.InverseTransformPoint(text.bounds.min).y); - } } row.gameObject.SetActive(true); @@ -1277,6 +1246,26 @@ public static class Helpers } } + page.SetActive(true); + var contentBottom = float.PositiveInfinity; + foreach (var text in page.GetComponentsInChildren(true)) + { + if (text.enabled && text.gameObject.activeInHierarchy) + { + text.ForceMeshUpdate(); + } + } + + foreach (var renderer in page.GetComponentsInChildren(true)) + { + if (renderer.enabled && renderer.gameObject.activeInHierarchy) + { + contentBottom = Mathf.Min( + contentBottom, + inner.InverseTransformPoint(renderer.bounds.min).y); + } + } + var maskArea = parent.transform.FindChild("MaskArea")?.GetComponent(); var maskBottom = maskArea ? inner.InverseTransformPoint(maskArea!.bounds.min).y @@ -1288,7 +1277,6 @@ public static class Helpers ? contentOverflow + 0.05f : 0f; parent.SetYBoundsMax(Mathf.Clamp(scrollRange, 0f, 999f)); - page.SetActive(true); return page; } From 5f6ac17e52b957d13dba9e95e6c9d090de821072 Mon Sep 17 00:00:00 2001 From: neilmjain <69025896+neilmjain@users.noreply.github.com> Date: Thu, 22 Oct 2026 18:37:17 -0400 Subject: [PATCH 02/18] reset scrollbar when switching between optionmenutabs --- MiraAPI/Patches/Options/RoleSettingMenuPatches.cs | 1 + 1 file changed, 1 insertion(+) diff --git a/MiraAPI/Patches/Options/RoleSettingMenuPatches.cs b/MiraAPI/Patches/Options/RoleSettingMenuPatches.cs index a7bfb166..aed5a5df 100644 --- a/MiraAPI/Patches/Options/RoleSettingMenuPatches.cs +++ b/MiraAPI/Patches/Options/RoleSettingMenuPatches.cs @@ -362,6 +362,7 @@ public static class RoleSettingMenuPatches } roleMenu.SetScrollBounds(); + roleMenu.scrollBar.ScrollToTop(); _quotaTabCoroutine = null; } From 6deaae350ea4d68667f1ebd6c620a0d673230011 Mon Sep 17 00:00:00 2001 From: neilmjain <69025896+neilmjain@users.noreply.github.com> Date: Thu, 22 Oct 2026 19:04:39 -0400 Subject: [PATCH 03/18] increase localsettings scroller bounds --- MiraAPI/LocalSettings/LocalSettingsTab.cs | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/MiraAPI/LocalSettings/LocalSettingsTab.cs b/MiraAPI/LocalSettings/LocalSettingsTab.cs index ebc5c030..8c2d4f5f 100644 --- a/MiraAPI/LocalSettings/LocalSettingsTab.cs +++ b/MiraAPI/LocalSettings/LocalSettingsTab.cs @@ -118,11 +118,13 @@ public abstract class LocalSettingsTab(ConfigFile config) tab.transform.DestroyChildren(); tab.gameObject.SetActive(false); - if (Scroller == null) + if (Scroller == null || Scroller.transform.parent != tab.transform) { Scroller = Helpers.CreateScroller(tab.transform, OptionsMenuPatches.MaskCollider); } + Labels.Clear(); + if (TabButton != null) { TabButton.Content = tab.gameObject; @@ -216,7 +218,11 @@ public abstract class LocalSettingsTab(ConfigFile config) contentIndex++; } - Scroller.SetBounds(new FloatRange(0, (Settings.Count + Buttons.Count) * 0.5f - 5f), new FloatRange(0, 0)); + var estimatedScrollRange = (Settings.Count + Buttons.Count) * 0.5f - 5f; + var layoutScrollRange = contentOffset - 5f; + var scrollRange = Mathf.Max(0f, estimatedScrollRange, layoutScrollRange); + Scroller.SetBounds(new FloatRange(0, scrollRange), new FloatRange(0, 0)); + Scroller.ScrollToTop(); return tab; } From 7632e543c8798131773bcd7cd8628b9670929b30 Mon Sep 17 00:00:00 2001 From: neilmjain <69025896+neilmjain@users.noreply.github.com> Date: Thu, 22 Oct 2026 19:08:26 -0400 Subject: [PATCH 04/18] decrease scroller bounds to be more precise. --- MiraAPI/LocalSettings/LocalSettingsTab.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/MiraAPI/LocalSettings/LocalSettingsTab.cs b/MiraAPI/LocalSettings/LocalSettingsTab.cs index 8c2d4f5f..ab0bed34 100644 --- a/MiraAPI/LocalSettings/LocalSettingsTab.cs +++ b/MiraAPI/LocalSettings/LocalSettingsTab.cs @@ -219,7 +219,7 @@ public abstract class LocalSettingsTab(ConfigFile config) } var estimatedScrollRange = (Settings.Count + Buttons.Count) * 0.5f - 5f; - var layoutScrollRange = contentOffset - 5f; + var layoutScrollRange = contentOffset - 4.75f; var scrollRange = Mathf.Max(0f, estimatedScrollRange, layoutScrollRange); Scroller.SetBounds(new FloatRange(0, scrollRange), new FloatRange(0, 0)); Scroller.ScrollToTop(); From f8c9045517cac230a6cd04542236e21a4858f806 Mon Sep 17 00:00:00 2001 From: neilmjain <69025896+neilmjain@users.noreply.github.com> Date: Thu, 22 Oct 2026 19:13:27 -0400 Subject: [PATCH 05/18] adjust options header sizes and spacing --- MiraAPI/Utilities/Helpers.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/MiraAPI/Utilities/Helpers.cs b/MiraAPI/Utilities/Helpers.cs index 76107a04..e107a95f 100644 --- a/MiraAPI/Utilities/Helpers.cs +++ b/MiraAPI/Utilities/Helpers.cs @@ -936,7 +936,7 @@ public static class Helpers { const float contentTop = 0.95f; const float horizontalOffset = -0.2f; - const float headerContentGap = 0.2f; + const float headerContentGap = 0.05f; const int contentSortingOrder = 151; columns = Mathf.Clamp(columns, 1, 6); @@ -1088,7 +1088,7 @@ public static class Helpers if (headerSource) { - const float headerScale = 0.46f; + const float headerScale = 0.42f; var headerWidth = groupsAsColumns ? columnWidth / headerScale : (columns * columnWidth + (columns - 1) * columnGap) / headerScale; From 13864b8fd98df66877b2b9f16dcf3ae3b9b57b98 Mon Sep 17 00:00:00 2001 From: neilmjain <69025896+neilmjain@users.noreply.github.com> Date: Thu, 22 Oct 2026 19:15:43 -0400 Subject: [PATCH 06/18] clean up --- MiraAPI/LocalSettings/LocalSettingsTab.cs | 10 ++++++---- MiraAPI/Utilities/Helpers.cs | 14 +++++++------- 2 files changed, 13 insertions(+), 11 deletions(-) diff --git a/MiraAPI/LocalSettings/LocalSettingsTab.cs b/MiraAPI/LocalSettings/LocalSettingsTab.cs index ab0bed34..0b8557c6 100644 --- a/MiraAPI/LocalSettings/LocalSettingsTab.cs +++ b/MiraAPI/LocalSettings/LocalSettingsTab.cs @@ -218,10 +218,12 @@ public abstract class LocalSettingsTab(ConfigFile config) contentIndex++; } - var estimatedScrollRange = (Settings.Count + Buttons.Count) * 0.5f - 5f; - var layoutScrollRange = contentOffset - 4.75f; - var scrollRange = Mathf.Max(0f, estimatedScrollRange, layoutScrollRange); - Scroller.SetBounds(new FloatRange(0, scrollRange), new FloatRange(0, 0)); + const float visibleHeight = 5f; + const float extraPadding = 0.25f; + var itemRange = (Settings.Count + Buttons.Count) * 0.5f - visibleHeight; + var offsetRange = contentOffset - visibleHeight + extraPadding; + var maxScroll = Mathf.Max(0f, itemRange, offsetRange); + Scroller.SetBounds(new FloatRange(0, maxScroll), new FloatRange(0, 0)); Scroller.ScrollToTop(); return tab; } diff --git a/MiraAPI/Utilities/Helpers.cs b/MiraAPI/Utilities/Helpers.cs index e107a95f..75c2164d 100644 --- a/MiraAPI/Utilities/Helpers.cs +++ b/MiraAPI/Utilities/Helpers.cs @@ -936,7 +936,7 @@ public static class Helpers { const float contentTop = 0.95f; const float horizontalOffset = -0.2f; - const float headerContentGap = 0.05f; + const float groupHeaderContentGap = 0.05f; const int contentSortingOrder = 151; columns = Mathf.Clamp(columns, 1, 6); @@ -1024,7 +1024,7 @@ public static class Helpers groupColumns[group] = i % columns; bandHeights[band] = Mathf.Max( bandHeights[band], - rowPitch * (groupedSettings[i].Count() + 1) + headerContentGap + 0.25f); + rowPitch * (groupedSettings[i].Count() + 1) + groupHeaderContentGap + 0.25f); } var bandOffset = 0f; @@ -1088,12 +1088,12 @@ public static class Helpers if (headerSource) { - const float headerScale = 0.42f; + const float groupHeaderScale = 0.42f; var headerWidth = groupsAsColumns - ? columnWidth / headerScale - : (columns * columnWidth + (columns - 1) * columnGap) / headerScale; + ? columnWidth / groupHeaderScale + : (columns * columnWidth + (columns - 1) * columnGap) / groupHeaderScale; var header = Object.Instantiate(headerSource!, page.transform, false); - header.transform.localScale = Vector3.one * headerScale; + header.transform.localScale = Vector3.one * groupHeaderScale; if (groupsAsColumns) { var totalWidth = columns * columnWidth + (columns - 1) * columnGap; @@ -1181,7 +1181,7 @@ public static class Helpers horizontalOffset; var centerY = groupsAsColumns && settings[i].Group is { } rowGroup ? contentTop - groupTopOffsets[rowGroup] - - (rowPitch * (groupRows[rowGroup] + 1)) - headerContentGap - (rowHeight / 2f) + (rowPitch * (groupRows[rowGroup] + 1)) - groupHeaderContentGap - (rowHeight / 2f) : contentTop - (rowHeight / 2f) - (rowIndex * rowPitch) - groupSpacing; var row = Object.Instantiate(rowPrefab, page.transform); row.enabled = false; From 0596278b7808b5fa8bc181088b2c8a7f333edd48 Mon Sep 17 00:00:00 2001 From: neilmjain <69025896+neilmjain@users.noreply.github.com> Date: Thu, 22 Oct 2026 19:26:07 -0400 Subject: [PATCH 07/18] move scroller bounds to be set in Open() --- MiraAPI/LocalSettings/LocalSettingsTab.cs | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/MiraAPI/LocalSettings/LocalSettingsTab.cs b/MiraAPI/LocalSettings/LocalSettingsTab.cs index 0b8557c6..310c2c08 100644 --- a/MiraAPI/LocalSettings/LocalSettingsTab.cs +++ b/MiraAPI/LocalSettings/LocalSettingsTab.cs @@ -74,6 +74,7 @@ public abstract class LocalSettingsTab(ConfigFile config) protected int TabIndex => LocalSettingsManager.Tabs.IndexOf(this) + 10; private Scroller? Scroller { get; set; } + private float MaxScroll { get; set; } /// /// Invoked when an option value is changed. @@ -104,6 +105,12 @@ public abstract class LocalSettingsTab(ConfigFile config) label.Key.text = $"{label.Value.Translate()}"; } + + if (Scroller != null) + { + Scroller.SetBounds(new FloatRange(0, MaxScroll), new FloatRange(0, 0)); + Scroller.ScrollToTop(); + } } /// @@ -222,9 +229,7 @@ public abstract class LocalSettingsTab(ConfigFile config) const float extraPadding = 0.25f; var itemRange = (Settings.Count + Buttons.Count) * 0.5f - visibleHeight; var offsetRange = contentOffset - visibleHeight + extraPadding; - var maxScroll = Mathf.Max(0f, itemRange, offsetRange); - Scroller.SetBounds(new FloatRange(0, maxScroll), new FloatRange(0, 0)); - Scroller.ScrollToTop(); + MaxScroll = Mathf.Max(0f, itemRange, offsetRange); return tab; } From 7c09dbdaaa4c67a5f50154cbc6042034adaf1bd6 Mon Sep 17 00:00:00 2001 From: neilmjain <69025896+neilmjain@users.noreply.github.com> Date: Thu, 22 Oct 2026 20:24:20 -0400 Subject: [PATCH 08/18] add corountimes for setting scroller bounds on options menus --- MiraAPI/LocalSettings/LocalSettingsTab.cs | 11 ++++++++--- .../LocalSettings/OptionsMenuPatches.cs | 18 ++++++++++++++++-- 2 files changed, 24 insertions(+), 5 deletions(-) diff --git a/MiraAPI/LocalSettings/LocalSettingsTab.cs b/MiraAPI/LocalSettings/LocalSettingsTab.cs index 310c2c08..25eabf30 100644 --- a/MiraAPI/LocalSettings/LocalSettingsTab.cs +++ b/MiraAPI/LocalSettings/LocalSettingsTab.cs @@ -105,12 +105,17 @@ public abstract class LocalSettingsTab(ConfigFile config) label.Key.text = $"{label.Value.Translate()}"; } + } - if (Scroller != null) + internal void RefreshScrollBounds() + { + if (Scroller == null) { - Scroller.SetBounds(new FloatRange(0, MaxScroll), new FloatRange(0, 0)); - Scroller.ScrollToTop(); + return; } + + Scroller.SetBounds(new FloatRange(0, MaxScroll), new FloatRange(0, 0)); + Scroller.ScrollToTop(); } /// diff --git a/MiraAPI/Patches/LocalSettings/OptionsMenuPatches.cs b/MiraAPI/Patches/LocalSettings/OptionsMenuPatches.cs index 6b64159e..38fb9895 100644 --- a/MiraAPI/Patches/LocalSettings/OptionsMenuPatches.cs +++ b/MiraAPI/Patches/LocalSettings/OptionsMenuPatches.cs @@ -1,6 +1,8 @@ -using System.Collections.Generic; +using System.Collections; +using System.Collections.Generic; using System.Diagnostics.CodeAnalysis; using System.Linq; +using BepInEx.Unity.IL2CPP.Utils.Collections; using HarmonyLib; using Il2CppInterop.Runtime.InteropTypes.Arrays; using MiraAPI.LocalSettings; @@ -183,7 +185,9 @@ public static class OptionsMenuPatches // Tabs with index 10 and above are the mod settings tabs if (index >= 10) { - CustomOpen(LocalSettingsManager.AvailableTabs[index - 10]); + var tab = LocalSettingsManager.AvailableTabs[index - 10]; + CustomOpen(tab); + __instance.StartCoroutine(RefreshScrollBoundsAfterOpen(__instance, tab).WrapToIl2Cpp()); return false; } @@ -229,6 +233,16 @@ public static class OptionsMenuPatches tab.Open(); } + private static IEnumerator RefreshScrollBoundsAfterOpen(OptionsMenuBehaviour menu, LocalSettingsTab tab) + { + yield return new WaitForEndOfFrame(); + + if (menu && tab.TabButton?.Content && tab.TabButton.Content.activeInHierarchy) + { + tab.RefreshScrollBounds(); + } + } + private static void CustomClose(LocalSettingsTab tab) { if (tab.TabButton?.Button) From af255c3e64465c991d95afc1891f8fe45fa5af87 Mon Sep 17 00:00:00 2001 From: neilmjain <69025896+neilmjain@users.noreply.github.com> Date: Sun, 25 Oct 2026 14:27:59 -0400 Subject: [PATCH 09/18] Hide Nameplates for menus in meetings --- .../Utilities/MeetingVoteAreaVisibility.cs | 74 +++++++++++++++++++ 1 file changed, 74 insertions(+) create mode 100644 MiraAPI/Utilities/MeetingVoteAreaVisibility.cs diff --git a/MiraAPI/Utilities/MeetingVoteAreaVisibility.cs b/MiraAPI/Utilities/MeetingVoteAreaVisibility.cs new file mode 100644 index 00000000..eeffe511 --- /dev/null +++ b/MiraAPI/Utilities/MeetingVoteAreaVisibility.cs @@ -0,0 +1,74 @@ +using System.Collections.Generic; +using UnityEngine; + +namespace MiraAPI.Utilities; + +internal static class MeetingVoteAreaVisibility +{ + private static readonly Dictionary originalRendererStates = []; + private static readonly HashSet activeOwners = []; + + internal static void HideNameplates(UnityEngine.Object owner) + { + var meetingHud = MeetingHud.Instance; + if (!owner || + !meetingHud || + meetingHud.state is not (MeetingHud.MeetingStates.Discussion or + MeetingHud.MeetingStates.NotVoted or + MeetingHud.MeetingStates.Voted)) + { + return; + } + + activeOwners.Add(owner.GetInstanceID()); + foreach (var playerVoteArea in meetingHud.playerStates) + { + if (!playerVoteArea) + { + continue; + } + + var buttons = playerVoteArea.Buttons; + foreach (var renderer in playerVoteArea.GetComponentsInChildren(true)) + { + if (!renderer || + (buttons && + (renderer.transform == buttons.transform || renderer.transform.IsChildOf(buttons.transform)))) + { + continue; + } + + if (!originalRendererStates.ContainsKey(renderer)) + { + originalRendererStates.Add(renderer, renderer.enabled); + } + + renderer.enabled = false; + } + } + } + + internal static void Restore(UnityEngine.Object owner) + { + if (!owner || !activeOwners.Remove(owner.GetInstanceID()) || activeOwners.Count > 0) + { + return; + } + + RestoreAll(); + } + + internal static void RestoreAll() + { + activeOwners.Clear(); + foreach (var rendererState in originalRendererStates) + { + if (rendererState.Key) + { + rendererState.Key.enabled = rendererState.Value; + } + } + + originalRendererStates.Clear(); + } +} From 29e9f9c8b55d0f597e4d43e8ff18b538bcb63b2c Mon Sep 17 00:00:00 2001 From: neilmjain <69025896+neilmjain@users.noreply.github.com> Date: Sun, 25 Oct 2026 14:28:29 -0400 Subject: [PATCH 10/18] Wire up phone menus to hide player nameplates --- MiraAPI/Hud/CustomMultiSelectMenu.cs | 4 ++++ MiraAPI/Hud/CustomPaginableMenu.cs | 1 + MiraAPI/Hud/CustomPhoneMenu.cs | 2 ++ 3 files changed, 7 insertions(+) diff --git a/MiraAPI/Hud/CustomMultiSelectMenu.cs b/MiraAPI/Hud/CustomMultiSelectMenu.cs index 50e2ff58..511c7741 100644 --- a/MiraAPI/Hud/CustomMultiSelectMenu.cs +++ b/MiraAPI/Hud/CustomMultiSelectMenu.cs @@ -3,6 +3,7 @@ using System.Collections.Generic; using System.Diagnostics.CodeAnalysis; using System.Linq; using MiraAPI.Patches.Stubs; +using MiraAPI.Utilities; using MiraAPI.Utilities.Assets; using UnityEngine; using UnityEngine.Events; @@ -106,6 +107,7 @@ public abstract class CustomMultiSelectMenu : CustomPhoneMenu entries, Action?> onClick, int totalSelections, bool shouldConfirm, bool canRepeat = false) { MinigameStubs.Begin(Component, null); + MeetingVoteAreaVisibility.HideNameplates(Component); this.totalSelections = totalSelections; this.shouldConfirm = shouldConfirm; @@ -116,6 +118,7 @@ public abstract class CustomMultiSelectMenu : CustomPhoneMenu { selectedEntries.Clear(); + MeetingVoteAreaVisibility.Restore(Component); onClick(null); })); @@ -177,6 +180,7 @@ public abstract class CustomMultiSelectMenu : CustomPhoneMenu Date: Sun, 25 Oct 2026 14:28:49 -0400 Subject: [PATCH 11/18] Wire Up match info guide --- MiraAPI/Patches/RoleGuidePatches.cs | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/MiraAPI/Patches/RoleGuidePatches.cs b/MiraAPI/Patches/RoleGuidePatches.cs index 1310bbd4..be0843e8 100644 --- a/MiraAPI/Patches/RoleGuidePatches.cs +++ b/MiraAPI/Patches/RoleGuidePatches.cs @@ -278,6 +278,8 @@ public static class RoleGuidePatches MapBehaviour.Instance.Close(); } + MeetingVoteAreaVisibility.HideNameplates(__instance); + if (HudManager.InstanceExists) { ConsoleJoystick.SetMode_MenuAdditive(); @@ -389,6 +391,13 @@ public static class RoleGuidePatches return false; } + [HarmonyPostfix] + [HarmonyPatch(typeof(MatchInfoGuide), nameof(MatchInfoGuide.Close))] + private static void ClosePostfix(MatchInfoGuide __instance) + { + MeetingVoteAreaVisibility.Restore(__instance); + } + private static void SetUpTabGrids(MatchInfoTabPos position) { tabButtonContainer.startCorner = GridLayoutGroup.Corner.UpperLeft; From 89e8870e351126ff20b5ad41830f6528c92cb83b Mon Sep 17 00:00:00 2001 From: neilmjain <69025896+neilmjain@users.noreply.github.com> Date: Sun, 25 Oct 2026 14:29:09 -0400 Subject: [PATCH 12/18] Account for Voting Time Ending --- MiraAPI/Patches/Voting/MeetingHudPatches.cs | 2 ++ 1 file changed, 2 insertions(+) diff --git a/MiraAPI/Patches/Voting/MeetingHudPatches.cs b/MiraAPI/Patches/Voting/MeetingHudPatches.cs index 1239ac7c..2d68e67c 100644 --- a/MiraAPI/Patches/Voting/MeetingHudPatches.cs +++ b/MiraAPI/Patches/Voting/MeetingHudPatches.cs @@ -106,6 +106,7 @@ internal static class MeetingHudPatches [HarmonyPatch(nameof(MeetingHud.OnDestroy))] public static void OnDestroyPatch(MeetingHud __instance) { + MeetingVoteAreaVisibility.RestoreAll(); MiraEventManager.InvokeEvent(new EndMeetingEvent(__instance)); } @@ -113,6 +114,7 @@ internal static class MeetingHudPatches [HarmonyPatch(nameof(MeetingHud.VotingComplete))] public static void VotingCompletePatch(MeetingHud __instance) { + MeetingVoteAreaVisibility.RestoreAll(); foreach (var meetingAbility in MeetingButtonManager.UntargetedButtons.Where(x => x.Enabled(PlayerControl.LocalPlayer.Data.Role) && (x.DisableUponVoting || x.HideUponWrapUp))) { From 1c44653a8d752c194f3256064f22a18786512e1d Mon Sep 17 00:00:00 2001 From: Az <56699741+AlchlcDvl@users.noreply.github.com> Date: Wed, 4 Nov 2026 14:12:06 -0500 Subject: [PATCH 13/18] slight project cleanup --- MiraAPI/GameModes/GameModeOption.cs | 2 +- .../Attributes/ModdedOptionAttribute.cs | 6 ++-- .../OptionList/ModdedOptionListAttribute.cs | 2 +- .../LocalSettings/OptionsMenuPatches.cs | 13 ++----- .../Patches/Menu/MainMenuManagerPatches.cs | 5 ++- .../Roles/RoleOptionsCollectionPatch.cs | 34 ++++++++----------- MiraAPI/Voting/PlayerVoteData.cs | 2 +- 7 files changed, 27 insertions(+), 37 deletions(-) diff --git a/MiraAPI/GameModes/GameModeOption.cs b/MiraAPI/GameModes/GameModeOption.cs index 79fccb28..254c043c 100644 --- a/MiraAPI/GameModes/GameModeOption.cs +++ b/MiraAPI/GameModes/GameModeOption.cs @@ -18,7 +18,7 @@ namespace MiraAPI.GameModes; /// [HarmonyPatch] [SuppressMessage("Critical Code Smell", "S2223:Non-constant static fields should not be visible", Justification = "Internal behaviour that does not need property-level validation.")] -[SuppressMessage("StyleCop.CSharp.MaintainabilityRules", "SA1401:Fields should be private", Justification = "Read above.")] // why so many warnings??? +[SuppressMessage("StyleCop.CSharp.MaintainabilityRules", "SA1401:Fields should be private", Justification = "Read above.")] public static class GameModeOption { /// diff --git a/MiraAPI/GameOptions/Attributes/ModdedOptionAttribute.cs b/MiraAPI/GameOptions/Attributes/ModdedOptionAttribute.cs index 2a77afa6..79d5a3c3 100644 --- a/MiraAPI/GameOptions/Attributes/ModdedOptionAttribute.cs +++ b/MiraAPI/GameOptions/Attributes/ModdedOptionAttribute.cs @@ -12,7 +12,7 @@ namespace MiraAPI.GameOptions.Attributes; /// Optional parameter to specify a game mode Type. [AttributeUsage(AttributeTargets.Property)] [SuppressMessage("Critical Code Smell", "S2223:Non-constant static fields should not be visible", Justification = "Internal behaviour that does not need property-level validation.")] -[SuppressMessage("StyleCop.CSharp.MaintainabilityRules", "SA1401:Fields should be private", Justification = "Read above.")] // why so many warnings??? +[SuppressMessage("StyleCop.CSharp.MaintainabilityRules", "SA1401:Fields should be private", Justification = "Read above.")] public abstract class ModdedOptionAttribute(string title, Type? roleType = null, Type? modeType = null) : PropertyOptionAttribute { internal IModdedOption? HolderOption; @@ -26,12 +26,12 @@ public abstract class ModdedOptionAttribute(string title, Type? roleType = null, /// /// Gets the role type of the option. /// - protected Type? RoleType { get; private set; } = roleType; + protected Type? RoleType => roleType; /// /// Gets the game mode type of the option. /// - protected Type? ModeType { get; private set; } = modeType; + protected Type? ModeType => modeType; internal abstract IModdedOption? CreateOption(object? value, PropertyInfo property); } diff --git a/MiraAPI/GameOptions/Attributes/OptionList/ModdedOptionListAttribute.cs b/MiraAPI/GameOptions/Attributes/OptionList/ModdedOptionListAttribute.cs index f4d6933e..6881fcb3 100644 --- a/MiraAPI/GameOptions/Attributes/OptionList/ModdedOptionListAttribute.cs +++ b/MiraAPI/GameOptions/Attributes/OptionList/ModdedOptionListAttribute.cs @@ -13,7 +13,7 @@ namespace MiraAPI.GameOptions.Attributes; /// The title of the options. [AttributeUsage(AttributeTargets.Property)] [SuppressMessage("Critical Code Smell", "S2223:Non-constant static fields should not be visible", Justification = "Internal behaviour that does not need property-level validation.")] -[SuppressMessage("StyleCop.CSharp.MaintainabilityRules", "SA1401:Fields should be private", Justification = "Read above.")] // why so many warnings??? +[SuppressMessage("StyleCop.CSharp.MaintainabilityRules", "SA1401:Fields should be private", Justification = "Read above.")] public abstract class ModdedOptionListAttribute(string title) : PropertyOptionAttribute { internal IModdedOptionList? HolderOptionList; diff --git a/MiraAPI/Patches/LocalSettings/OptionsMenuPatches.cs b/MiraAPI/Patches/LocalSettings/OptionsMenuPatches.cs index 6b64159e..9e043cf6 100644 --- a/MiraAPI/Patches/LocalSettings/OptionsMenuPatches.cs +++ b/MiraAPI/Patches/LocalSettings/OptionsMenuPatches.cs @@ -12,21 +12,14 @@ using UnityEngine.UI; namespace MiraAPI.Patches.LocalSettings; [HarmonyPatch(typeof(OptionsMenuBehaviour))] +[SuppressMessage("Critical Code Smell", "S2223:Non-constant static fields should not be visible", Justification = "Internal behaviour that does not need property-level validation.")] +[SuppressMessage("StyleCop.CSharp.MaintainabilityRules", "SA1401:Fields should be private", Justification = "Read above.")] public static class OptionsMenuPatches { private static readonly Dictionary> TabButtons = []; private static int _currentPage = 1; - internal static OptionsMenuBehaviour? Instance { get; private set; } - - [SuppressMessage( - "Critical Code Smell", - "S2223:Non-constant static fields should not be visible", - Justification = "Internal behaviour that does not need property-level validation.")] - [SuppressMessage( - "StyleCop.CSharp.MaintainabilityRules", - "SA1401:Fields should be private", - Justification = "Read above.")] + internal static OptionsMenuBehaviour? Instance; internal static BoxCollider2D MaskCollider = null!; private static SpriteRenderer? background; diff --git a/MiraAPI/Patches/Menu/MainMenuManagerPatches.cs b/MiraAPI/Patches/Menu/MainMenuManagerPatches.cs index aff0906a..379bdcb6 100644 --- a/MiraAPI/Patches/Menu/MainMenuManagerPatches.cs +++ b/MiraAPI/Patches/Menu/MainMenuManagerPatches.cs @@ -1,5 +1,6 @@ using System; using System.Collections; +using System.Diagnostics.CodeAnalysis; using HarmonyLib; using MiraAPI.LocalSettings; using Reactor.Utilities; @@ -13,7 +14,9 @@ namespace MiraAPI.Patches.Menu; [HarmonyPatch(typeof(MainMenuManager))] public static class MainMenuManagerPatches { - internal static bool NeedsDeepDestroy { get; private set; } + [SuppressMessage("Critical Code Smell", "S2223:Non-constant static fields should not be visible", Justification = "Internal behaviour that does not need property-level validation.")] + [SuppressMessage("StyleCop.CSharp.MaintainabilityRules", "SA1401:Fields should be private", Justification = "Read above.")] + internal static bool NeedsDeepDestroy; /// /// A postfix on to load all the addressables registered. diff --git a/MiraAPI/Patches/Roles/RoleOptionsCollectionPatch.cs b/MiraAPI/Patches/Roles/RoleOptionsCollectionPatch.cs index 0e856eff..84265321 100644 --- a/MiraAPI/Patches/Roles/RoleOptionsCollectionPatch.cs +++ b/MiraAPI/Patches/Roles/RoleOptionsCollectionPatch.cs @@ -1,6 +1,6 @@ using System; +using System.Collections.Generic; using System.Linq; -using System.Reflection; using AmongUs.GameOptions; using HarmonyLib; using MiraAPI.Roles; @@ -12,24 +12,14 @@ namespace MiraAPI.Patches.Roles; /// public static class RoleOptionsCollectionPatch { - internal static Assembly BaseAssembly { get; private set; } - internal static Type[] BaseTypes { get; private set; } - internal static Type CollectionsType { get; private set; } public static void PatchRoleMethods(Harmony harmony) { - var assembly = Array.Find( - AppDomain.CurrentDomain.GetAssemblies(), - ass => ass.GetName().Name == "Assembly-CSharp"); - - if (assembly == null) - return; - - var compatType = typeof(RoleOptionsCollectionPatch); - BaseAssembly = assembly; - BaseTypes = AccessTools.GetTypesFromAssembly(assembly); - var collections = BaseTypes.Where(x => x.Name.Contains("RoleOptionsCollectionV")).ToArray(); - var pairings = new System.Collections.Generic.Dictionary(); + var baseAssembly = typeof(RoleBehaviour).Assembly; + var baseTypes = AccessTools.GetTypesFromAssembly(baseAssembly); + var collections = baseTypes.Where(x => x.Name.Contains("RoleOptionsCollectionV")).ToArray(); + var pairings = new Dictionary(); var newestId = 0; + foreach (var collection in collections) { var remainder = collection.Name.Replace("RoleOptionsCollectionV", string.Empty); @@ -45,22 +35,26 @@ public static class RoleOptionsCollectionPatch } } + Type? collectionsType = null; + if (pairings.TryGetValue(newestId, out var typeToGet)) { - CollectionsType = typeToGet; + collectionsType = typeToGet; } - var anyRolesEnabledMethod = AccessTools.Method(CollectionsType, "AnyRolesEnabled"); + var compatType = typeof(RoleOptionsCollectionPatch); + + var anyRolesEnabledMethod = AccessTools.Method(collectionsType, "AnyRolesEnabled"); harmony.Patch( anyRolesEnabledMethod, new HarmonyMethod(AccessTools.Method(compatType, nameof(AnyRolesEnabledPrefix)))); - var chancePerGameMethod = AccessTools.Method(CollectionsType, "GetChancePerGame"); + var chancePerGameMethod = AccessTools.Method(collectionsType, "GetChancePerGame"); harmony.Patch( chancePerGameMethod, new HarmonyMethod(AccessTools.Method(compatType, nameof(GetChancePrefix)))); - var numPerGameMethod = AccessTools.Method(CollectionsType, "GetNumPerGame"); + var numPerGameMethod = AccessTools.Method(collectionsType, "GetNumPerGame"); harmony.Patch( numPerGameMethod, new HarmonyMethod(AccessTools.Method(compatType, nameof(GetNumPrefix)))); diff --git a/MiraAPI/Voting/PlayerVoteData.cs b/MiraAPI/Voting/PlayerVoteData.cs index 5fe32ee7..ad07aeb1 100644 --- a/MiraAPI/Voting/PlayerVoteData.cs +++ b/MiraAPI/Voting/PlayerVoteData.cs @@ -23,7 +23,7 @@ public class PlayerVoteData(nint cppPtr) : MonoBehaviour(cppPtr) /// Gets the list of s the owner has. /// [HideFromIl2Cpp] - public List Votes { get; private set; } = []; + public List Votes { get; } = []; /// /// Gets or sets the amount of votes the owner has left. From 1bd96041eeb04555a57c2f232f4fb53963432587 Mon Sep 17 00:00:00 2001 From: Az <56699741+AlchlcDvl@users.noreply.github.com> Date: Wed, 4 Nov 2026 15:00:54 -0500 Subject: [PATCH 14/18] complete two todos + minor improvements --- .../Patches/GameModes/CreateOptionsPatch.cs | 19 ------- .../LocalSettings/OptionsMenuPatches.cs | 39 ++++++++------ .../Patches/Options/RoleSettingMenuPatches.cs | 51 ++++++++----------- MiraAPI/PluginLoading/MiraPluginManager.cs | 4 +- .../Components/RoleSettingsMenuUpdater.cs | 49 ++++++++++++++++++ 5 files changed, 95 insertions(+), 67 deletions(-) delete mode 100644 MiraAPI/Patches/GameModes/CreateOptionsPatch.cs create mode 100644 MiraAPI/Utilities/Components/RoleSettingsMenuUpdater.cs diff --git a/MiraAPI/Patches/GameModes/CreateOptionsPatch.cs b/MiraAPI/Patches/GameModes/CreateOptionsPatch.cs deleted file mode 100644 index b33c1fd3..00000000 --- a/MiraAPI/Patches/GameModes/CreateOptionsPatch.cs +++ /dev/null @@ -1,19 +0,0 @@ -using HarmonyLib; -using GameModesEnum = AmongUs.GameOptions.GameModes; - -namespace MiraAPI.Patches.GameModes; - -[HarmonyPatch(typeof(CreateOptionsPicker), nameof(CreateOptionsPicker.SetGameMode))] -internal static class CreateOptionsPatch -{ - public static bool Prefix(CreateOptionsPicker __instance, GameModesEnum mode) - { - if (mode <= GameModesEnum.SeekFools) - { - return true; - } - - // TODO: finish this - return false; - } -} diff --git a/MiraAPI/Patches/LocalSettings/OptionsMenuPatches.cs b/MiraAPI/Patches/LocalSettings/OptionsMenuPatches.cs index 9e043cf6..074afd4e 100644 --- a/MiraAPI/Patches/LocalSettings/OptionsMenuPatches.cs +++ b/MiraAPI/Patches/LocalSettings/OptionsMenuPatches.cs @@ -1,4 +1,5 @@ -using System.Collections.Generic; +using System; +using System.Collections.Generic; using System.Diagnostics.CodeAnalysis; using System.Linq; using HarmonyLib; @@ -70,7 +71,7 @@ public static class OptionsMenuPatches _currentPage = 1; TabButtons.Clear(); - float yOffset = 0; + var yOffset = 0f; var i = 0; var tabIdx = 0; var page = 1; @@ -144,9 +145,9 @@ public static class OptionsMenuPatches UpdatePages(); })); button.OnMouseOver = new UnityEvent(); - button.OnMouseOver.AddListener((UnityAction)(() => rollover.DoMouseOver())); + button.OnMouseOver.AddListener((Action)rollover.DoMouseOver); button.OnMouseOut = new UnityEvent(); - button.OnMouseOut.AddListener((UnityAction)(() => rollover.DoMouseOut())); + button.OnMouseOut.AddListener((Action)rollover.DoMouseOut); } private static void ChangePage(int increase) @@ -207,14 +208,17 @@ public static class OptionsMenuPatches private static void CustomOpen(LocalSettingsTab tab) { - if (tab.TabButton?.Button) - tab.TabButton!.Button.color = tab.TabAppearance.TabButtonHoverColor; + if (tab.TabButton) + { + if (tab.TabButton!.Button) + tab.TabButton.Button.color = tab.TabAppearance.TabButtonHoverColor; - if (tab.TabButton?.Rollover) - tab.TabButton!.Rollover.OutColor = tab.TabAppearance.TabButtonHoverColor; + if (tab.TabButton.Rollover) + tab.TabButton.Rollover.OutColor = tab.TabAppearance.TabButtonHoverColor; - if (tab.TabButton?.Content) - tab.TabButton!.Content.SetActive(true); + if (tab.TabButton.Content) + tab.TabButton.Content.SetActive(true); + } if (background != null) background.color = tab.TabAppearance.TabColor; @@ -224,14 +228,17 @@ public static class OptionsMenuPatches private static void CustomClose(LocalSettingsTab tab) { - if (tab.TabButton?.Button) - tab.TabButton!.Button.color = tab.TabAppearance.TabButtonColor; + if (tab.TabButton) + { + if (tab.TabButton!.Button) + tab.TabButton.Button.color = tab.TabAppearance.TabButtonColor; - if (tab.TabButton?.Rollover) - tab.TabButton!.Rollover.OutColor = tab.TabAppearance.TabButtonColor; + if (tab.TabButton.Rollover) + tab.TabButton.Rollover.OutColor = tab.TabAppearance.TabButtonColor; - if (tab.TabButton?.Content) - tab.TabButton!.Content.SetActive(false); + if (tab.TabButton.Content) + tab.TabButton.Content.SetActive(false); + } if (background != null) background.color = Color.white; diff --git a/MiraAPI/Patches/Options/RoleSettingMenuPatches.cs b/MiraAPI/Patches/Options/RoleSettingMenuPatches.cs index 3d2ed2ec..3106adba 100644 --- a/MiraAPI/Patches/Options/RoleSettingMenuPatches.cs +++ b/MiraAPI/Patches/Options/RoleSettingMenuPatches.cs @@ -1,6 +1,7 @@ using System; using System.Collections; using System.Collections.Generic; +using System.Diagnostics.CodeAnalysis; using System.Linq; using AmongUs.GameOptions; using BepInEx.Unity.IL2CPP.Utils.Collections; @@ -12,6 +13,7 @@ using MiraAPI.Roles; using MiraAPI.Translation; using MiraAPI.Utilities; using MiraAPI.Utilities.Assets; +using MiraAPI.Utilities.Components; using Reactor.Networking.Rpc; using Reactor.Utilities.Extensions; using TMPro; @@ -23,15 +25,24 @@ using Object = UnityEngine.Object; namespace MiraAPI.Patches.Options; [HarmonyPatch(typeof(RolesSettingsMenu))] +[SuppressMessage("Critical Code Smell", "S2223:Non-constant static fields should not be visible", Justification = "Is internal code. Property-level protections are not required.")] +[SuppressMessage("StyleCop.CSharp.MaintainabilityRules", "SA1401:Fields should be private", Justification = "Read above.")] public static class RoleSettingMenuPatches { private static readonly Dictionary RoleGroupHidden = []; - private static RoleBehaviour? currentRole; - private static List? currentRoleOptions; + internal static RoleBehaviour? CurrentRole; + internal static List? CurrentRoleOptions; private static float scrollerNum = 0.522f; + [HarmonyPostfix] + [HarmonyPatch(nameof(RolesSettingsMenu.Awake))] + public static void OnAwake(RolesSettingsMenu __instance) + { + __instance.gameObject.AddComponent(); + } + [HarmonyPostfix] [HarmonyPatch(nameof(RolesSettingsMenu.OnEnable))] public static void OpenPatch() @@ -41,8 +52,8 @@ public static class RoleSettingMenuPatches private static IEnumerator CoQuotaTabPatch(RolesSettingsMenu roleMenu) { - currentRole = null; - currentRoleOptions = null; + CurrentRole = null; + CurrentRoleOptions = null; roleMenu.QuotaTabSelectables.Clear(); roleMenu.roleChances.Clear(); @@ -91,7 +102,7 @@ public static class RoleSettingMenuPatches Object.Destroy(child.gameObject); } - yield return new WaitForEndOfFrame(); + yield return null; MenuState.Instance.QueuedRoleMenuRefresh[MenuState.Instance.CurrentModIdx] = false; } @@ -186,7 +197,7 @@ public static class RoleSettingMenuPatches Object.Destroy(child.gameObject); } - yield return new WaitForEndOfFrame(); + yield return null; var roleGroups = MenuState.Instance.CurrentMod.InternalRoles.Values.OfType() .ToLookup(x => x.RoleOptionsGroup); @@ -431,32 +442,12 @@ public static class RoleSettingMenuPatches scroller.SetYBoundsMax(-scrollerNum - 2); } - // TODO: turn this into a fixed update + // Completed: turn this into a fixed update [HarmonyPrefix] [HarmonyPatch(nameof(RolesSettingsMenu.Update))] public static bool UpdatePatch(RolesSettingsMenu __instance) { - if (MenuState.Instance.CurrentModIdx == 0) return true; - if (currentRole == null || currentRoleOptions == null) return false; - - var hasImage = currentRole.RoleScreenshot != null; - var num = hasImage ? -0.872f : -1; - foreach (var opt in currentRoleOptions) - { - if (opt.OptionBehaviour == null) continue; - - if (!opt.Visible.Invoke()) - { - opt.OptionBehaviour.gameObject.SetActive(false); - continue; - } - - opt.OptionBehaviour.transform.localPosition = new Vector3(hasImage ? 2.17f : 1.1f, num, -2f); - opt.OptionBehaviour.gameObject.SetActive(true); - num += -0.45f; - } - - __instance.scrollBar.SetYBoundsMax(-num - 3); + // See RoleSettingsMenuUpdater.FixedUpdate in Utilities/Components/RoleSettingsMenuUpdater.cs return false; } @@ -508,7 +499,7 @@ public static class RoleSettingMenuPatches optBehaviour.gameObject.Destroy(); } - currentRole = role; + CurrentRole = role; __instance.advancedSettingChildren.Clear(); // TODO: create sub groups under the role settings. @@ -547,7 +538,7 @@ public static class RoleSettingMenuPatches newOpt.Initialize(); } - currentRoleOptions = filteredOptions; + CurrentRoleOptions = filteredOptions; } [HarmonyPrefix] diff --git a/MiraAPI/PluginLoading/MiraPluginManager.cs b/MiraAPI/PluginLoading/MiraPluginManager.cs index c2f1caed..840d8926 100644 --- a/MiraAPI/PluginLoading/MiraPluginManager.cs +++ b/MiraAPI/PluginLoading/MiraPluginManager.cs @@ -68,7 +68,7 @@ public sealed class MiraPluginManager MiraApiPluginInfo = info; registrationTimer.Stop(); - Info($"Registering Mira API as mod in {registrationTimer.ElapsedMilliseconds}ms."); + Info($"Registered Mira API as mod in {registrationTimer.ElapsedMilliseconds}ms."); } IL2CPPChainloader.Instance.PluginLoad += (pluginInfo, assembly, plugin) => @@ -81,7 +81,7 @@ public sealed class MiraPluginManager var registrationTimer = Stopwatch.StartNew(); RegisterPlugin(assembly, miraPlugin, pluginInfo, plugin, false); registrationTimer.Stop(); - Info($"Registering mod {pluginInfo.Metadata.Name} with Mira API in {registrationTimer.ElapsedMilliseconds}ms."); + Info($"Registered mod {pluginInfo.Metadata.Name} with Mira API in {registrationTimer.ElapsedMilliseconds}ms."); }; IL2CPPChainloader.Instance.Finished += () => diff --git a/MiraAPI/Utilities/Components/RoleSettingsMenuUpdater.cs b/MiraAPI/Utilities/Components/RoleSettingsMenuUpdater.cs new file mode 100644 index 00000000..219e4f28 --- /dev/null +++ b/MiraAPI/Utilities/Components/RoleSettingsMenuUpdater.cs @@ -0,0 +1,49 @@ +using System.Diagnostics.CodeAnalysis; +using MiraAPI.Patches.Options; +using Reactor.Utilities.Attributes; +using UnityEngine; + +namespace MiraAPI.Utilities.Components; + +/// +/// Updates the visuals of the in a fixed update loop. +/// +/// The C++ pointer to the object. +[RegisterInIl2Cpp] +[SuppressMessage("Style", "IDE0051:Remove unused private members", Justification = "Unity convention.")] +public sealed class RoleSettingsMenuUpdater(nint cppPtr) : MonoBehaviour(cppPtr) +{ + private RolesSettingsMenu menu; + + private void Awake() + { + menu = GetComponent(); + } + + private void FixedUpdate() + { + if (MenuState.Instance.CurrentModIdx == 0) return; + if (menu == null || RoleSettingMenuPatches.CurrentRole == null || RoleSettingMenuPatches.CurrentRoleOptions == null) return; + + var hasImage = RoleSettingMenuPatches.CurrentRole.RoleScreenshot != null; + var num = hasImage ? -0.872f : -1; + foreach (var opt in RoleSettingMenuPatches.CurrentRoleOptions) + { + var behaviour = opt.OptionBehaviour; + + if (behaviour == null) continue; + + if (!opt.Visible()) + { + behaviour.gameObject.SetActive(false); + continue; + } + + behaviour.transform.localPosition = new Vector3(hasImage ? 2.17f : 1.1f, num, -2f); + behaviour.gameObject.SetActive(true); + num += -0.45f; + } + + menu.scrollBar.SetYBoundsMax(-num - 3); + } +} From fbeb610cb504f7b44fcd43482ead2a86781c5d33 Mon Sep 17 00:00:00 2001 From: Az <56699741+AlchlcDvl@users.noreply.github.com> Date: Wed, 4 Nov 2026 21:21:12 -0500 Subject: [PATCH 15/18] some more code cleanup + undoing a todo it is a miracle the game mod option worked the way it did. i would like to have a word with the one who was using a dictionary like a list. prepare to meet your maker --- MiraAPI/GameModes/AbstractGameMode.cs | 2 + MiraAPI/GameModes/CustomGameModeManager.cs | 24 ++-- MiraAPI/GameModes/GameModeOption.cs | 108 +++++------------- MiraAPI/Hud/CustomMultiSelectMenu.cs | 7 +- .../LocalSettings/OptionsMenuPatches.cs | 8 +- .../Patches/Options/GameOptionsMenuPatch.cs | 40 +++---- .../Patches/Options/RoleSettingMenuPatches.cs | 7 +- MiraAPI/Patches/Voting/MeetingHudPatches.cs | 2 +- MiraAPI/Utilities/Extensions.cs | 2 +- MiraAPI/Utilities/Helpers.cs | 2 +- 10 files changed, 71 insertions(+), 131 deletions(-) diff --git a/MiraAPI/GameModes/AbstractGameMode.cs b/MiraAPI/GameModes/AbstractGameMode.cs index 83448394..8f90de2b 100644 --- a/MiraAPI/GameModes/AbstractGameMode.cs +++ b/MiraAPI/GameModes/AbstractGameMode.cs @@ -77,6 +77,8 @@ public abstract class AbstractGameMode : IOptionable /// public virtual float DefaultImpostorKillCooldown => GameOptionsManager.Instance.CurrentGameOptions.GetFloat(FloatOptionNames.KillCooldown); + internal StringNames StringName { get; set; } + /// /// Called on GameManager.GetBodyType(). /// diff --git a/MiraAPI/GameModes/CustomGameModeManager.cs b/MiraAPI/GameModes/CustomGameModeManager.cs index d5678012..acb0f51b 100644 --- a/MiraAPI/GameModes/CustomGameModeManager.cs +++ b/MiraAPI/GameModes/CustomGameModeManager.cs @@ -44,9 +44,10 @@ public static class CustomGameModeManager if (mode.HideMode) return true; - IdToModeMap.Add(GetNextId(), mode); - pluginInfo.GameModes.Add(lastId, mode); - mode.ID = lastId; + var id = GetNextId(); + mode.ID = id; + IdToModeMap.Add(id, mode); + pluginInfo.GameModes.Add(id, mode); GameModeOption.AddOption(mode); return true; } @@ -107,34 +108,31 @@ public static class CustomGameModeManager internal static void RegisterDefaultMode() { - var defaultMode = new ClassicMode(); + var defaultMode = new ClassicMode { ID = 0 }; IdToModeMap.Add(0, defaultMode); + GameModeOption.AddOption(defaultMode); - // no need to add to game mode option as it already contains it - // because we cannot have the option be created with no values - defaultMode.ID = 0; - var hnsMode = new HideAndSeekMode(); + var hnsMode = new HideAndSeekMode() { ID = 1 }; if (hnsMode.HideMode) return; IdToModeMap.Add(1, hnsMode); - hnsMode.ID = 1; GameModeOption.AddOption(hnsMode); lastId++; } internal static void GetAndSetGameMode() { - var id = (uint)GameModeOption.Value; + var index = GameModeOption.Value; - if (IdToModeMap.TryGetValue(id, out var mode)) + if ((uint)index < (uint)GameModeOption.Values.Count) { - ActiveMode = mode; + ActiveMode = GameModeOption.Values[index]; return; } ActiveMode = IdToModeMap[0]; - Warning($"Unable to find game mode of id {id}!"); + Warning($"Unable to find game mode at index {index}!"); } } diff --git a/MiraAPI/GameModes/GameModeOption.cs b/MiraAPI/GameModes/GameModeOption.cs index 254c043c..a9c3bcbb 100644 --- a/MiraAPI/GameModes/GameModeOption.cs +++ b/MiraAPI/GameModes/GameModeOption.cs @@ -1,6 +1,5 @@ using System.Collections.Generic; using System.Diagnostics.CodeAnalysis; -using System.Linq; using HarmonyLib; using MiraAPI.GameOptions; using MiraAPI.Networking; @@ -27,113 +26,63 @@ public static class GameModeOption /// public static int Value { - get => - OptionBehaviour != null - ? OptionBehaviour.GetInt() - : LastValue; + get => OptionBehaviour != null + ? OptionBehaviour.GetInt() + : LastValue; private set { LastValue = value; + if (OptionBehaviour == null) return; + OptionBehaviour.Value = value; OptionBehaviour.UpdateValue(); - LastValue = value; } } internal static readonly StringNames GamemodeName = MiraLocaleManager.GetOrCreateLocaleString("MiraApi.Gamemode"); internal static readonly StringNames CustomName = MiraLocaleManager.GetOrCreateLocaleString("Custom"); - internal static readonly Dictionary Values = new() - { - [0] = MiraLocaleManager.GetOrCreateLocaleString("MiraApi.Gamemode.Classic"), - }; + internal static readonly List Values = []; internal static StringOption OptionBehaviour = null!; internal static int LastValue; internal static void AddOption(AbstractGameMode mode) { - if (!Values.ContainsKey(mode.ID)) - Values.Add(mode.ID, MiraLocaleManager.GetOrCreateLocaleString(mode.Name)); + mode.StringName = MiraLocaleManager.GetOrCreateLocaleString(mode.Name); + Values.Add(mode); } - /*[HarmonyPatch(typeof(GameOptionsMenu), nameof(GameOptionsMenu.CreateSettings))] - [HarmonyPostfix] - private static void CreateSettingsPatch(GameOptionsMenu __instance) - { - if (MenuState.Instance.CurrentModIdx != 0 || GameManager.Instance.IsHideAndSeek() || CustomGameModeManager.ActiveMode == null) - { - return; - } - - var num = 0.713f; - - foreach (var category in __instance.settingsContainer.GetComponentsInChildren()) - { - if (category) - category.gameObject.transform.localPosition -= new Vector3(0, 1.3f, 0); - } - CategoryHeaderMasked categoryHeaderMasked = Object.Instantiate(__instance.categoryHeaderOrigin, Vector3.zero, Quaternion.identity, __instance.settingsContainer); - categoryHeaderMasked.SetHeader(CustomName, 20); - categoryHeaderMasked.transform.localScale = Vector3.one * 0.63f; - categoryHeaderMasked.transform.localPosition = new Vector3(-0.903f, num, -2f); - OptionBehaviour = Object.Instantiate( - __instance.stringOptionOrigin, - Vector3.zero, - Quaternion.identity, - __instance.settingsContainer); - num -= 0.63f; - OptionBehaviour.transform.localPosition = new Vector3(0.952f, num, -2f); - OptionBehaviour.SetClickMask(__instance.ButtonClickMask); - StringGameSetting setting = ScriptableObject.CreateInstance(); - setting.Type = OptionTypes.MultipleChoice; - setting.Title = GamemodeName; - setting.Index = _lastValue; - setting.Values = new Il2CppStructArray([Values[0]]); - OptionBehaviour.SetUpFromData(setting, 20); - Set(_lastValue); - OptionBehaviour.TitleText.fontSize = 3; - foreach (var optionBehaviour in __instance.Children.ToArray().Skip(1)) - { - optionBehaviour.gameObject.transform.localPosition -= new Vector3(0, 1.3f, 0); - } - __instance.Children.Add(OptionBehaviour); - for (var i = 1; i < Values.Count; i++) - OptionBehaviour.Values = (Il2CppStructArray)OptionBehaviour.Values.Add(Values.ElementAt(i).Value); - __instance.scrollBar.SetYBoundsMax(__instance.scrollBar.GetYBounds().max + 1); - }*/ - internal static void Set(int val) { Value = val; var previousMode = CustomGameModeManager.ActiveMode; CustomGameModeManager.GetAndSetGameMode(); - HudPatches.SetGameModeText(CustomGameModeManager.GetMode(Values.ElementAt(LastValue).Key).ColoredName); + HudPatches.SetGameModeText(Values[LastValue].ColoredName); var gm = CustomGameModeManager.ActiveMode!; - if (gm != previousMode) - { - ModdedOptionsManager.AddSettingsChangeMessage( - HudManager.Instance.Notifier, - GamemodeName, - gm.ColoredName, - new Color(0.7333f, 0.7333f, 0.7333f, 1), - gm.TmpIcon); - if (MenuState.Instance) - { - // should force reset roles for gamemodes properly - foreach (var roleMenu in MenuState.Instance.QueuedRoleMenuRefresh) - { - MenuState.Instance.QueuedRoleMenuRefresh[roleMenu.Key] = true; - } - } + if (gm == previousMode) + return; - GameOptionsMenuPatch.RefreshForGameMode(); - RoleGuidePatches.RefreshSettingsForGameMode(); + ModdedOptionsManager.AddSettingsChangeMessage( + HudManager.Instance.Notifier, + GamemodeName, + gm.ColoredName, + new Color(0.7333f, 0.7333f, 0.7333f, 1), + gm.TmpIcon); + + if (MenuState.Instance) + { + // should force reset roles for gamemodes properly + foreach (var roleMenu in MenuState.Instance.QueuedRoleMenuRefresh) + { + MenuState.Instance.QueuedRoleMenuRefresh[roleMenu.Key] = true; + } } - // TODO: could make Values a dict of AbstractGameMode too + GameOptionsMenuPatch.RefreshForGameMode(); + RoleGuidePatches.RefreshSettingsForGameMode(); } [HarmonyPatch(typeof(GameOptionsMenu), nameof(GameOptionsMenu.ValueChanged))] @@ -150,8 +99,7 @@ public static class GameModeOption } [MethodRpc((uint)MiraRpc.SyncGamemodeOption)] - [SuppressMessage("Style", "IDE0060:Remove unused parameter", Justification = "Intentionally unused because the main intent is for it to be used by dependent mods to add to a blacklist.")] - internal static void RpcSyncGamemode(PlayerControl host, int data) + internal static void RpcSyncGamemode(PlayerControl _, int data) { Set(data); } diff --git a/MiraAPI/Hud/CustomMultiSelectMenu.cs b/MiraAPI/Hud/CustomMultiSelectMenu.cs index 50e2ff58..5b405053 100644 --- a/MiraAPI/Hud/CustomMultiSelectMenu.cs +++ b/MiraAPI/Hud/CustomMultiSelectMenu.cs @@ -29,12 +29,7 @@ public abstract class CustomMultiSelectMenu : CustomPhoneMenu>? onSelection; /// diff --git a/MiraAPI/Patches/LocalSettings/OptionsMenuPatches.cs b/MiraAPI/Patches/LocalSettings/OptionsMenuPatches.cs index 074afd4e..39b84870 100644 --- a/MiraAPI/Patches/LocalSettings/OptionsMenuPatches.cs +++ b/MiraAPI/Patches/LocalSettings/OptionsMenuPatches.cs @@ -175,13 +175,13 @@ public static class OptionsMenuPatches LocalSettingsManager.AvailableTabs.ForEach(CustomClose); // Close all mod tabs // Tabs with index 10 and above are the mod settings tabs - if (index >= 10) + if (index < 10) { - CustomOpen(LocalSettingsManager.AvailableTabs[index - 10]); - return false; + return true; } - return true; + CustomOpen(LocalSettingsManager.AvailableTabs[index - 10]); + return false; } /// diff --git a/MiraAPI/Patches/Options/GameOptionsMenuPatch.cs b/MiraAPI/Patches/Options/GameOptionsMenuPatch.cs index 9dacf030..0799bf2f 100644 --- a/MiraAPI/Patches/Options/GameOptionsMenuPatch.cs +++ b/MiraAPI/Patches/Options/GameOptionsMenuPatch.cs @@ -4,7 +4,6 @@ using System.Collections.Generic; using System.Linq; using BepInEx.Unity.IL2CPP.Utils.Collections; using HarmonyLib; -using Il2CppInterop.Runtime.InteropTypes.Arrays; using MiraAPI.GameModes; using MiraAPI.GameOptions; using MiraAPI.Modifiers; @@ -16,7 +15,6 @@ using Reactor.Utilities.Extensions; using TMPro; using UnityEngine; using UnityEngine.Events; -using UnityEngine.ProBuilder; using UnityEngine.UI; using Object = UnityEngine.Object; @@ -218,7 +216,7 @@ internal static class GameOptionsMenuPatch { if (!option || !option.gameObject.activeInHierarchy || option == menu.MapPicker || - (GameModeOption.OptionBehaviour && option == GameModeOption.OptionBehaviour) || + option == GameModeOption.OptionBehaviour || !option.Data) { continue; @@ -250,7 +248,6 @@ internal static class GameOptionsMenuPatch private static void CreateSettings(GameOptionsMenu instance, Transform container) { - var num = 0.713f; VanillaHeaders.Clear(); VanillaOptions.Clear(); MainOptions.Clear(); @@ -258,35 +255,36 @@ internal static class GameOptionsMenuPatch GameModeOptions.Clear(); GameModeGroups.Clear(); - var gmCategory = Object.Instantiate(instance.categoryHeaderOrigin, Vector3.zero, Quaternion.identity, container); + var num = 0.713f; + + var gmCategory = Object.Instantiate(instance.categoryHeaderOrigin, container); gmCategory.SetHeader(GameModeOption.CustomName, 20); gmCategory.transform.localScale = Vector3.one * 0.63f; gmCategory.transform.localPosition = new Vector3(-0.903f, num, -2f); - GameModeOption.OptionBehaviour = Object.Instantiate(instance.stringOptionOrigin, container); + num -= 0.63f; + + GameModeOption.OptionBehaviour = Object.Instantiate(instance.stringOptionOrigin, container); GameModeOption.OptionBehaviour.transform.localPosition = new Vector3(0.952f, num, -2f); GameModeOption.OptionBehaviour.SetClickMask(instance.ButtonClickMask); + var setting = ScriptableObject.CreateInstance(); setting.Type = OptionTypes.MultipleChoice; setting.Title = GameModeOption.GamemodeName; setting.Index = GameModeOption.LastValue; - setting.Values = new Il2CppStructArray([GameModeOption.Values[0]]); + setting.Values = GameModeOption.Values.Select(x => x.StringName).ToArray(); + GameModeOption.OptionBehaviour.SetUpFromData(setting, 20); GameModeOption.Set(GameModeOption.LastValue); GameModeOption.OptionBehaviour.TitleText.fontSize = 3; + instance.Children.Add(GameModeOption.OptionBehaviour); + foreach (var optionBehaviour in instance.Children) { MainOptions.Add(optionBehaviour); } - for (var i = 1; i < GameModeOption.Values.Count; i++) - { - GameModeOption.OptionBehaviour.Values = - (Il2CppStructArray)GameModeOption.OptionBehaviour.Values.Add( - GameModeOption.Values.ElementAt(i).Value); - } - var modeInfoHolder = new GameObject("GamemodeInfo") { transform = @@ -298,7 +296,7 @@ internal static class GameOptionsMenuPatch layer = container.gameObject.layer, }.transform; - var gamemodeBg = Object.Instantiate(GameModeOption.OptionBehaviour.transform.GetChild(0).gameObject, Vector3.zero, Quaternion.identity, modeInfoHolder); + var gamemodeBg = Object.Instantiate(GameModeOption.OptionBehaviour.transform.GetChild(0).gameObject, modeInfoHolder); gamemodeBg.transform.localPosition = Vector3.zero; gamemodeBg.transform.localScale = new Vector3(1.35f, 0.85f, 1); gamemodeBg.name = "Background"; @@ -317,7 +315,7 @@ internal static class GameOptionsMenuPatch _modIcon.sprite = MiraAssets.BlankSprite.LoadAsset(); _modIcon.material = gamemodeBg.gameObject.GetComponent().material; - var gamemodeTextObj = Object.Instantiate(GameModeOption.OptionBehaviour.transform.GetChild(1).gameObject, Vector3.zero, Quaternion.identity, modeInfoHolder); + var gamemodeTextObj = Object.Instantiate(GameModeOption.OptionBehaviour.transform.GetChild(1).gameObject, modeInfoHolder); gamemodeTextObj.transform.localPosition = new Vector3(0.3f, 0, -0.01f); gamemodeTextObj.transform.localScale = new Vector3(2.12f, 2.12f, 1); _gamemodeDescription = gamemodeTextObj.GetComponentInChildren(); @@ -469,11 +467,7 @@ internal static class GameOptionsMenuPatch private static void CreateGroup(GameOptionsMenu menu, AbstractOptionGroup group, Transform container, ref float num, ref List optionBehaviours, ref List categoryHeaders) { - var categoryHeaderMasked = Object.Instantiate( - menu.categoryHeaderOrigin, - Vector3.zero, - Quaternion.identity, - container); + var categoryHeaderMasked = Object.Instantiate(menu.categoryHeaderOrigin, container); categoryHeaderMasked.transform.localPosition = new Vector3(-0.903f, num + 1, -2f); categoryHeaderMasked.transform.localScale = Vector3.one * 0.63f; categoryHeaders.Add(categoryHeaderMasked); @@ -510,12 +504,14 @@ internal static class GameOptionsMenuPatch foreach (var newOpt in options) { newOpt.SetClickMask(menu.ButtonClickMask); - SpriteRenderer[] componentsInChildren = newOpt.GetComponentsInChildren(true); + var componentsInChildren = newOpt.GetComponentsInChildren(true); + foreach (var renderer in componentsInChildren) { if (group.GroupColor != MiraApiPlugin.DefaultHeaderColor) { renderer.color = group.GroupColor.FindAlternateColor(); + if (renderer.transform.parent.TryGetComponent(out var btn)) { btn.interactableColor = group.GroupColor.FindAlternateColor(); diff --git a/MiraAPI/Patches/Options/RoleSettingMenuPatches.cs b/MiraAPI/Patches/Options/RoleSettingMenuPatches.cs index 3106adba..36c3735a 100644 --- a/MiraAPI/Patches/Options/RoleSettingMenuPatches.cs +++ b/MiraAPI/Patches/Options/RoleSettingMenuPatches.cs @@ -32,7 +32,7 @@ public static class RoleSettingMenuPatches private static readonly Dictionary RoleGroupHidden = []; internal static RoleBehaviour? CurrentRole; - internal static List? CurrentRoleOptions; + internal static IModdedOption[]? CurrentRoleOptions; private static float scrollerNum = 0.522f; @@ -503,10 +503,11 @@ public static class RoleSettingMenuPatches __instance.advancedSettingChildren.Clear(); // TODO: create sub groups under the role settings. + var type = role.GetType(); var filteredOptions = MenuState.Instance.CurrentMod.InternalOptionGroups - .Where(x => x.GroupVisible() && x.OptionableType == role.GetType()) + .Where(x => x.OptionableType == type && x.GroupVisible()) .SelectMany(x => x.Options) - .ToList(); + .ToArray(); foreach (var option in filteredOptions) { diff --git a/MiraAPI/Patches/Voting/MeetingHudPatches.cs b/MiraAPI/Patches/Voting/MeetingHudPatches.cs index d0f02fbb..a41b7e41 100644 --- a/MiraAPI/Patches/Voting/MeetingHudPatches.cs +++ b/MiraAPI/Patches/Voting/MeetingHudPatches.cs @@ -269,7 +269,7 @@ internal static class MeetingHudPatches [HarmonyPrefix] [HarmonyPatch(nameof(MeetingHud.PopulateResults))] - public static bool PopulateResultsPatch(ref Il2CppStructArray states) + public static bool PopulateResultsPatch(Il2CppStructArray states) { var votes = states.Select(x => new CustomVote(x.VoterId, x.VotedForId)).ToList(); diff --git a/MiraAPI/Utilities/Extensions.cs b/MiraAPI/Utilities/Extensions.cs index 868bef17..0446e84f 100644 --- a/MiraAPI/Utilities/Extensions.cs +++ b/MiraAPI/Utilities/Extensions.cs @@ -682,7 +682,7 @@ public static class Extensions /// if the is for a custom options, otherwise. public static bool IsCustom(this OptionBehaviour optionBehaviour) { - return ModdedOptionsManager.ModdedOptions.Values.Any(opt => opt.OptionBehaviour && opt.OptionBehaviour == optionBehaviour) || optionBehaviour.Equals(GameModeOption.OptionBehaviour); + return ModdedOptionsManager.ModdedOptions.Values.Any(opt => opt.OptionBehaviour == optionBehaviour) || optionBehaviour.Equals(GameModeOption.OptionBehaviour); } /// diff --git a/MiraAPI/Utilities/Helpers.cs b/MiraAPI/Utilities/Helpers.cs index fe3b5020..6caa973c 100644 --- a/MiraAPI/Utilities/Helpers.cs +++ b/MiraAPI/Utilities/Helpers.cs @@ -370,7 +370,7 @@ public static class Helpers public static LobbyNotificationMessage CreateAndShowNotification(string text, Color color, Vector3 localPos, AudioClip? clip = null, Sprite? spr = null) { var popper = HudManager.Instance.Notifier; - var newMessage = Object.Instantiate(popper.notificationMessageOrigin, Vector3.zero, Quaternion.identity, popper.transform); + var newMessage = Object.Instantiate(popper.notificationMessageOrigin, popper.transform); newMessage.transform.localPosition = localPos; newMessage.SetUp(text, spr ?? null, color, new Action(() => popper.OnMessageDestroy(newMessage))); popper.lastMessageKey = -1; From 5dd5f33ae4bec93613adca1bba4963d3eb22bb44 Mon Sep 17 00:00:00 2001 From: Az <56699741+AlchlcDvl@users.noreply.github.com> Date: Thu, 5 Nov 2026 02:55:40 -0500 Subject: [PATCH 16/18] lol new warnings --- MiraAPI/GameModes/HideAndSeekMode.cs | 4 ++-- MiraAPI/Hud/CustomPaginableMenu.cs | 15 +++++++----- MiraAPI/Hud/MultiTargetButton.cs | 9 ++++--- .../SettingTypes/LocalEnumSetting.cs | 11 +++++---- MiraAPI/Patches/Roles/SelectRolesPatch.cs | 4 ++-- MiraAPI/Utilities/GuideOptionsPatches.cs | 24 ++++++++++++------- 6 files changed, 41 insertions(+), 26 deletions(-) diff --git a/MiraAPI/GameModes/HideAndSeekMode.cs b/MiraAPI/GameModes/HideAndSeekMode.cs index 71146fe6..6e0666ac 100644 --- a/MiraAPI/GameModes/HideAndSeekMode.cs +++ b/MiraAPI/GameModes/HideAndSeekMode.cs @@ -92,9 +92,9 @@ public class HideAndSeekMode : AbstractGameMode runOriginal = false; CppCollections.List list = new(); AmongUsClient.Instance.GetAllClients(list); - List list2 = [.. list.ToArray() + var list2 = list.ToArray() .Where(c => c.Character != null && c.Character.Data != null && !c.Character.Data.Disconnected && - !c.Character.Data.IsDead).OrderBy(c => c.Id).Select(c => c.Character.Data),]; + !c.Character.Data.IsDead).OrderBy(c => c.Id).Select(c => c.Character.Data).ToList(); foreach (var networkedPlayerInfo in GameData.Instance.AllPlayers) { diff --git a/MiraAPI/Hud/CustomPaginableMenu.cs b/MiraAPI/Hud/CustomPaginableMenu.cs index 0654c9d0..159f7166 100644 --- a/MiraAPI/Hud/CustomPaginableMenu.cs +++ b/MiraAPI/Hud/CustomPaginableMenu.cs @@ -108,12 +108,15 @@ public abstract class CustomPaginableMenu : CustomPhoneMenu e.SortKey.Contains(query, StringComparison.OrdinalIgnoreCase)) - .OrderByDescending(e => e.SortKey.Equals(query, StringComparison.OrdinalIgnoreCase)) - .ThenByDescending(e => e.SortKey.StartsWith(query, StringComparison.OrdinalIgnoreCase)) - .ThenByDescending(e => e.SortKey.Contains(query, StringComparison.OrdinalIgnoreCase)) - .ThenBy(e => e.SortKey, StringComparer.OrdinalIgnoreCase),]; + return + [ + .. MenuEntries + .Where(e => e.SortKey.Contains(query, StringComparison.OrdinalIgnoreCase)) + .OrderByDescending(e => e.SortKey.Equals(query, StringComparison.OrdinalIgnoreCase)) + .ThenByDescending(e => e.SortKey.StartsWith(query, StringComparison.OrdinalIgnoreCase)) + .ThenByDescending(e => e.SortKey.Contains(query, StringComparison.OrdinalIgnoreCase)) + .ThenBy(e => e.SortKey, StringComparer.OrdinalIgnoreCase), + ]; } private static int GetTotalPages(int itemCount) diff --git a/MiraAPI/Hud/MultiTargetButton.cs b/MiraAPI/Hud/MultiTargetButton.cs index 83c28000..6f931e7e 100644 --- a/MiraAPI/Hud/MultiTargetButton.cs +++ b/MiraAPI/Hud/MultiTargetButton.cs @@ -55,9 +55,12 @@ public abstract class MultiTargetButton : CustomActionButton } } - Targets = [.. newTargets - .Where(IsTargetValid) - .Take(MaxTargets),]; + Targets = + [ + .. newTargets + .Where(IsTargetValid) + .Take(MaxTargets), + ]; Targets.Do(t => SetOutline(t, true)); return base.CanUse() && Targets.Length > 0; diff --git a/MiraAPI/LocalSettings/SettingTypes/LocalEnumSetting.cs b/MiraAPI/LocalSettings/SettingTypes/LocalEnumSetting.cs index 91d2eeb1..5fcbb081 100644 --- a/MiraAPI/LocalSettings/SettingTypes/LocalEnumSetting.cs +++ b/MiraAPI/LocalSettings/SettingTypes/LocalEnumSetting.cs @@ -36,10 +36,13 @@ public class LocalEnumSetting( /// /// Gets the values. /// - public string[] Values { get; } = values ?? [.. Enum - .GetValues(configEntry.SettingType) - .Cast() - .Select(x => x.ToDisplayString()),]; + public string[] Values { get; } = values ?? + [ + .. Enum + .GetValues(configEntry.SettingType) + .Cast() + .Select(x => x.ToDisplayString()), + ]; private SpriteRenderer _highlight; private TextMeshPro _btnText; diff --git a/MiraAPI/Patches/Roles/SelectRolesPatch.cs b/MiraAPI/Patches/Roles/SelectRolesPatch.cs index 204e1f9e..630402e3 100644 --- a/MiraAPI/Patches/Roles/SelectRolesPatch.cs +++ b/MiraAPI/Patches/Roles/SelectRolesPatch.cs @@ -45,9 +45,9 @@ public static class SelectRolesPatch CppCollections.List list = new(); AmongUsClient.Instance.GetAllClients(list); - List list2 = [.. list.ToArray() + var list2 = list.ToArray() .Where(c => c.Character != null && c.Character.Data != null && !c.Character.Data.Disconnected && - !c.Character.Data.IsDead).OrderBy(c => c.Id).Select(c => c.Character.Data),]; + !c.Character.Data.IsDead).OrderBy(c => c.Id).Select(c => c.Character.Data).ToList(); foreach (var networkedPlayerInfo in GameData.Instance.AllPlayers) { diff --git a/MiraAPI/Utilities/GuideOptionsPatches.cs b/MiraAPI/Utilities/GuideOptionsPatches.cs index 4d4b046d..f44626a4 100644 --- a/MiraAPI/Utilities/GuideOptionsPatches.cs +++ b/MiraAPI/Utilities/GuideOptionsPatches.cs @@ -142,12 +142,15 @@ internal static class GuideOptionPages } } - return [.. pages - .OrderBy(page => page.MenuOrder) - .ThenBy(page => page.GroupPriority) - .ThenBy(page => page.Order) - .ThenBy(page => page.Group.GroupName, StringComparer.OrdinalIgnoreCase) - .ThenBy(page => page.ModAbbreviation, StringComparer.OrdinalIgnoreCase),]; + return + [ + .. pages + .OrderBy(page => page.MenuOrder) + .ThenBy(page => page.GroupPriority) + .ThenBy(page => page.Order) + .ThenBy(page => page.Group.GroupName, StringComparer.OrdinalIgnoreCase) + .ThenBy(page => page.ModAbbreviation, StringComparer.OrdinalIgnoreCase), + ]; } private static int GetMenuOrder(MenuCategory menu) @@ -184,12 +187,15 @@ internal static class GuideOptionPages return [.. matchingModPages.SelectMany(page => page.Entries)]; } - return [.. pageList - .SelectMany(page => page.Entries + return + [ + .. pageList + .SelectMany(page => page.Entries .Select(entry => (Entry: entry, Rank: Rank(entry, query, cmp))) .Where(result => result.Rank < int.MaxValue) .OrderBy(result => result.Rank) - .Select(result => result.Entry)),]; + .Select(result => result.Entry)), + ]; } private static string[] GetModSearchTerms(MiraPluginInfo plugin, AbstractOptionGroup group) From af6a486ce80a102c32e216f3f0acc035d1d038c3 Mon Sep 17 00:00:00 2001 From: Az <56699741+AlchlcDvl@users.noreply.github.com> Date: Thu, 5 Nov 2026 03:10:50 -0500 Subject: [PATCH 17/18] remove null check skip --- MiraAPI/Patches/LocalSettings/OptionsMenuPatches.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/MiraAPI/Patches/LocalSettings/OptionsMenuPatches.cs b/MiraAPI/Patches/LocalSettings/OptionsMenuPatches.cs index 9208b4ea..f6aaaf45 100644 --- a/MiraAPI/Patches/LocalSettings/OptionsMenuPatches.cs +++ b/MiraAPI/Patches/LocalSettings/OptionsMenuPatches.cs @@ -234,7 +234,7 @@ public static class OptionsMenuPatches { yield return new WaitForEndOfFrame(); - if (menu && tab.TabButton?.Content && tab.TabButton.Content.activeInHierarchy) + if (menu && tab.TabButton && tab.TabButton!.Content && tab.TabButton.Content.activeInHierarchy) { tab.RefreshScrollBounds(); } From 852b464ff8b0a845ff2773963b32690811a2dee9 Mon Sep 17 00:00:00 2001 From: Az <56699741+AlchlcDvl@users.noreply.github.com> Date: Thu, 5 Nov 2026 13:26:00 -0500 Subject: [PATCH 18/18] remove warnings --- .../Utilities/MeetingVoteAreaVisibility.cs | 22 +++++++++---------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/MiraAPI/Utilities/MeetingVoteAreaVisibility.cs b/MiraAPI/Utilities/MeetingVoteAreaVisibility.cs index eeffe511..9262485d 100644 --- a/MiraAPI/Utilities/MeetingVoteAreaVisibility.cs +++ b/MiraAPI/Utilities/MeetingVoteAreaVisibility.cs @@ -5,10 +5,10 @@ namespace MiraAPI.Utilities; internal static class MeetingVoteAreaVisibility { - private static readonly Dictionary originalRendererStates = []; - private static readonly HashSet activeOwners = []; + private static readonly Dictionary OriginalRendererStates = []; + private static readonly HashSet ActiveOwners = []; - internal static void HideNameplates(UnityEngine.Object owner) + internal static void HideNameplates(Object owner) { var meetingHud = MeetingHud.Instance; if (!owner || @@ -20,7 +20,7 @@ internal static class MeetingVoteAreaVisibility return; } - activeOwners.Add(owner.GetInstanceID()); + ActiveOwners.Add(owner.GetInstanceID()); foreach (var playerVoteArea in meetingHud.playerStates) { if (!playerVoteArea) @@ -38,9 +38,9 @@ internal static class MeetingVoteAreaVisibility continue; } - if (!originalRendererStates.ContainsKey(renderer)) + if (!OriginalRendererStates.ContainsKey(renderer)) { - originalRendererStates.Add(renderer, renderer.enabled); + OriginalRendererStates.Add(renderer, renderer.enabled); } renderer.enabled = false; @@ -48,9 +48,9 @@ internal static class MeetingVoteAreaVisibility } } - internal static void Restore(UnityEngine.Object owner) + internal static void Restore(Object owner) { - if (!owner || !activeOwners.Remove(owner.GetInstanceID()) || activeOwners.Count > 0) + if (!owner || !ActiveOwners.Remove(owner.GetInstanceID()) || ActiveOwners.Count > 0) { return; } @@ -60,8 +60,8 @@ internal static class MeetingVoteAreaVisibility internal static void RestoreAll() { - activeOwners.Clear(); - foreach (var rendererState in originalRendererStates) + ActiveOwners.Clear(); + foreach (var rendererState in OriginalRendererStates) { if (rendererState.Key) { @@ -69,6 +69,6 @@ internal static class MeetingVoteAreaVisibility } } - originalRendererStates.Clear(); + OriginalRendererStates.Clear(); } }