diff --git a/MiraAPI/GameOptions/UI/ModdedOptionsTab.cs b/MiraAPI/GameOptions/UI/ModdedOptionsTab.cs index b00ccaf..a4492ae 100644 --- a/MiraAPI/GameOptions/UI/ModdedOptionsTab.cs +++ b/MiraAPI/GameOptions/UI/ModdedOptionsTab.cs @@ -7,6 +7,8 @@ using UnityEngine.Events; using Object = UnityEngine.Object; namespace MiraAPI.GameOptions.UI; + +/* public static class ModdedOptionsTab { public static readonly List CustomTabs = []; @@ -151,4 +153,4 @@ public static class ModdedOptionsTab return newSettings; } -} \ No newline at end of file +}*/ \ No newline at end of file diff --git a/MiraAPI/Patches/HudManagerPatches.cs b/MiraAPI/Patches/HudManagerPatches.cs index 07d7464..8fcf456 100644 --- a/MiraAPI/Patches/HudManagerPatches.cs +++ b/MiraAPI/Patches/HudManagerPatches.cs @@ -18,7 +18,8 @@ namespace MiraAPI.Patches /// Custom role tab private static TaskPanelBehaviour _roleTab; - [HarmonyPostfix, HarmonyPatch("Update")] + [HarmonyPostfix] + [HarmonyPatch(nameof(HudManager.Update))] public static void UpdatePostfix(HudManager __instance) { var local = PlayerControl.LocalPlayer; @@ -69,7 +70,8 @@ namespace MiraAPI.Patches /// /// Create custom buttons parent /// - [HarmonyPostfix, HarmonyPatch("Start")] + [HarmonyPostfix] + [HarmonyPatch(nameof(HudManager.Start))] public static void StartPostfix(HudManager __instance) { if (!_bottomLeft) @@ -104,7 +106,8 @@ namespace MiraAPI.Patches /// /// Make sure all launchpad hud elements are inactive/active when appropriate /// - [HarmonyPostfix, HarmonyPatch("SetHudActive", typeof(PlayerControl), typeof(RoleBehaviour), typeof(bool))] + [HarmonyPostfix] + [HarmonyPatch(nameof(HudManager.SetHudActive), typeof(PlayerControl), typeof(RoleBehaviour), typeof(bool))] public static void SetHudActivePostfix(HudManager __instance, [HarmonyArgument(0)] PlayerControl player, [HarmonyArgument(1)] RoleBehaviour roleBehaviour, [HarmonyArgument(2)] bool isActive) { if (player.Data == null) diff --git a/MiraAPI/Patches/Options/GameOptionsMenuPatch.cs b/MiraAPI/Patches/Options/GameOptionsMenuPatch.cs index 167fcf5..03891e3 100644 --- a/MiraAPI/Patches/Options/GameOptionsMenuPatch.cs +++ b/MiraAPI/Patches/Options/GameOptionsMenuPatch.cs @@ -7,13 +7,14 @@ using Object = UnityEngine.Object; namespace MiraAPI.Patches.Options; +/* [HarmonyPatch(typeof(GameOptionsMenu))] public static class GameOptionsMenuPatch { /// /// Change the OnValueChanged action for all custom game options /// - [HarmonyPostfix, HarmonyPatch("Start")] + [HarmonyPostfix, HarmonyPatch(nameof(GameOptionsMenu.Start))] public static void StartPostfix(GameOptionsMenu __instance) { foreach (var customOption in ModdedOptionsManager.Options) @@ -26,26 +27,25 @@ public static class GameOptionsMenuPatch customOption.OptionBehaviour.OnValueChanged = (Action)customOption.ValueChanged; } } - - private static GameSettingMenu menu; - + /// /// Set the position and offset of all custom game options /// - [HarmonyPostfix, HarmonyPatch("Update")] + [HarmonyPostfix, HarmonyPatch(nameof(GameOptionsMenu.Update))] public static void UpdatePostfix(GameOptionsMenu __instance) { - if (!menu) - { - menu = Object.FindObjectsOfType().First(); - } - - if (menu.RegularGameSettings.active || menu.RolesSettings.gameObject.active || menu.HideNSeekSettings.active) + if (!GameSettingMenu.Instance) { return; } + if (GameSettingMenu.Instance.GameSettingsTab.gameObject.active || GameSettingMenu.Instance.RoleSettingsTab.gameObject.active) + { + return; + } + + var startOffset = 2.5f; __instance.GetComponentInParent().ContentYBounds.max = startOffset + __instance.Children.Count * 0.5f; @@ -106,4 +106,4 @@ public static class GameOptionsMenuPatch } } } -} \ No newline at end of file +}*/ \ No newline at end of file diff --git a/MiraAPI/Patches/Options/GameSettingMenuPatches.cs b/MiraAPI/Patches/Options/GameSettingMenuPatches.cs new file mode 100644 index 0000000..4837dd4 --- /dev/null +++ b/MiraAPI/Patches/Options/GameSettingMenuPatches.cs @@ -0,0 +1,37 @@ +using HarmonyLib; +using MiraAPI.GameOptions; +using Reactor.Utilities; +using Reactor.Utilities.Extensions; +using System.Collections.Generic; +using System.Linq; +using MiraAPI.GameOptions.UI; +using UnityEngine; + +namespace MiraAPI.Patches.Options; + +[HarmonyPatch(typeof(GameSettingMenu))] +public static class GameSettingMenuPatches +{ + + [HarmonyPrefix] + [HarmonyPatch(nameof(GameSettingMenu.Start))] + public static void StartPrefix(GameSettingMenu __instance) + { + __instance.MenuDescriptionText.transform.parent.gameObject.SetActive(false); + } + + /*public static void CreateOptionsFor(GameSettingMenu __instance, ToggleOption togglePrefab, NumberOption numberPrefab, StringOption stringPrefab, Transform container, + List options) + { + foreach (IModdedOption option in options) + { + if (option.AdvancedRole is not null || option.OptionBehaviour) + { + continue; + } + + OptionBehaviour newOption = option.CreateOption(togglePrefab, numberPrefab, stringPrefab, container); + __instance.AllItems = __instance.AllItems.AddItem(newOption.transform).ToArray(); + } + }*/ +} diff --git a/MiraAPI/Patches/Options/GameSettingsMenuPatches.cs b/MiraAPI/Patches/Options/GameSettingsMenuPatches.cs deleted file mode 100644 index 0bf8465..0000000 --- a/MiraAPI/Patches/Options/GameSettingsMenuPatches.cs +++ /dev/null @@ -1,68 +0,0 @@ -using HarmonyLib; -using MiraAPI.GameOptions; -using Reactor.Utilities; -using Reactor.Utilities.Extensions; -using System.Collections.Generic; -using System.Linq; -using MiraAPI.GameOptions.UI; -using UnityEngine; -using Object = UnityEngine.Object; - -namespace MiraAPI.Patches.Options; - -[HarmonyPatch(typeof(GameSettingMenu))] -public static class GameSettingsMenuPatches -{ - private static GameObject _gameBtn; - private static GameObject _roleBtn; - - [HarmonyPrefix, HarmonyPatch("Start")] - public static void StartPrefix(GameSettingMenu __instance) - { - foreach (var tab in ModdedOptionsTab.CustomTabs) tab.gameObject.Destroy(); - foreach (var screen in ModdedOptionsTab.CustomScreens) screen.gameObject.Destroy(); - - ModdedOptionsTab.CustomScreens.Clear(); - ModdedOptionsTab.CustomTabs.Clear(); - - _gameBtn = __instance.transform.FindChild("Header/Tabs/GameTab").gameObject; - _roleBtn = __instance.transform.FindChild("Header/Tabs/RoleTab").gameObject; - - var numberOpt = __instance.RegularGameSettings.GetComponentInChildren(); - var toggleOpt = Object.FindObjectOfType(); - var stringOpt = __instance.RegularGameSettings.GetComponentInChildren(); - - foreach (var pair in ModdedOptionsManager.RegisteredMods) - { - var container = ModdedOptionsTab.InitializeForMod(pair.Value, __instance).transform; - - foreach (var group in ModdedOptionsManager.Groups.Where(group => group.AdvancedRole == null && group.ParentMod == pair.Value)) - { - group.Header = ModdedOptionsTab.CreateHeader(toggleOpt, container, group.GroupName, group.GroupColor); - CreateOptionsFor(__instance, toggleOpt, numberOpt, stringOpt, container, ModdedOptionsManager.Options.Where(x => x.Group == group).ToList()); - } - - CreateOptionsFor(__instance, toggleOpt, numberOpt, stringOpt, container, ModdedOptionsManager.Options.Where(x => x.Group is null).ToList()); - } - - if (!numberOpt || !toggleOpt || !stringOpt) - { - Logger.Error("OPTION PREFABS MISSING"); - } - } - - public static void CreateOptionsFor(GameSettingMenu __instance, ToggleOption togglePrefab, NumberOption numberPrefab, StringOption stringPrefab, Transform container, - List options) - { - foreach (IModdedOption option in options) - { - if (option.AdvancedRole is not null || option.OptionBehaviour) - { - continue; - } - - OptionBehaviour newOption = option.CreateOption(togglePrefab, numberPrefab, stringPrefab, container); - __instance.AllItems = __instance.AllItems.AddItem(newOption.transform).ToArray(); - } - } -} diff --git a/MiraAPI/Patches/Roles/GameStartupPatch.cs b/MiraAPI/Patches/Roles/GameStartupPatch.cs index c7a38cc..13ea698 100644 --- a/MiraAPI/Patches/Roles/GameStartupPatch.cs +++ b/MiraAPI/Patches/Roles/GameStartupPatch.cs @@ -12,7 +12,7 @@ public static class GameStartupPatch /// This is used for registering roles when the game opens, might be a janky solution, but it works /// [HarmonyPostfix] - [HarmonyPatch("Start")] + [HarmonyPatch(nameof(MainMenuManager.Start))] public static void StartPostfix() { if (_runOnce) diff --git a/MiraAPI/Patches/Roles/NameTagPatch.cs b/MiraAPI/Patches/Roles/NameTagPatch.cs index 86eeba3..d74a88c 100644 --- a/MiraAPI/Patches/Roles/NameTagPatch.cs +++ b/MiraAPI/Patches/Roles/NameTagPatch.cs @@ -9,7 +9,8 @@ namespace MiraAPI.Patches.Roles; [HarmonyPatch(typeof(PlayerNameColor))] public static class NameTagPatch { - [HarmonyPrefix, HarmonyPatch("Get", typeof(RoleBehaviour))] + [HarmonyPrefix] + [HarmonyPatch(nameof(PlayerNameColor.Get), typeof(RoleBehaviour))] public static bool GetPatch([HarmonyArgument(0)] RoleBehaviour otherPlayerRole, ref Color __result) { if (PlayerControl.LocalPlayer.Data.IsDead) diff --git a/MiraAPI/Patches/Roles/RoleBehaviourPatches.cs b/MiraAPI/Patches/Roles/RoleBehaviourPatches.cs index 3169c3a..5879df8 100644 --- a/MiraAPI/Patches/Roles/RoleBehaviourPatches.cs +++ b/MiraAPI/Patches/Roles/RoleBehaviourPatches.cs @@ -10,7 +10,8 @@ public static class RoleBehaviourPatches /// /// Update TeamColor text for Launchpad roles /// - [HarmonyPrefix, HarmonyPatch("TeamColor", MethodType.Getter)] + [HarmonyPrefix] + [HarmonyPatch(nameof(RoleBehaviour.TeamColor), MethodType.Getter)] public static bool PrefixTeamColorGetter(RoleBehaviour __instance, ref Color __result) { if (__instance is not ICustomRole behaviour) diff --git a/MiraAPI/Patches/Roles/RoleManagerPatches.cs b/MiraAPI/Patches/Roles/RoleManagerPatches.cs index 953b9bb..a7cd867 100644 --- a/MiraAPI/Patches/Roles/RoleManagerPatches.cs +++ b/MiraAPI/Patches/Roles/RoleManagerPatches.cs @@ -8,7 +8,8 @@ namespace MiraAPI.Patches.Roles; [HarmonyPatch(typeof(RoleManager))] public static class RoleManagerPatches { - [HarmonyPrefix, HarmonyPatch("AssignRoleOnDeath")] + [HarmonyPrefix] + [HarmonyPatch(nameof(RoleManager.AssignRoleOnDeath))] public static bool AssignRoleOnDeath(RoleManager __instance, [HarmonyArgument(0)] PlayerControl plr) { if (plr == null || !plr.Data.IsDead) diff --git a/MiraAPI/Patches/Roles/RoleOptionSettingPatch.cs b/MiraAPI/Patches/Roles/RoleOptionSettingPatch.cs index 6104869..7ad8500 100644 --- a/MiraAPI/Patches/Roles/RoleOptionSettingPatch.cs +++ b/MiraAPI/Patches/Roles/RoleOptionSettingPatch.cs @@ -2,7 +2,7 @@ using MiraAPI.Roles; namespace MiraAPI.Patches.Roles; - +/* [HarmonyPatch(typeof(RoleOptionSetting))] public static class RoleOptionSettingPatch { @@ -21,4 +21,4 @@ public static class RoleOptionSettingPatch } return true; } -} \ No newline at end of file +}*/ \ No newline at end of file diff --git a/MiraAPI/Patches/Roles/RoleOptionsCollectionPatch.cs b/MiraAPI/Patches/Roles/RoleOptionsCollectionPatch.cs index 4b2d1bc..bb64f64 100644 --- a/MiraAPI/Patches/Roles/RoleOptionsCollectionPatch.cs +++ b/MiraAPI/Patches/Roles/RoleOptionsCollectionPatch.cs @@ -5,13 +5,14 @@ using Reactor.Utilities; namespace MiraAPI.Patches.Roles; -[HarmonyPatch(typeof(RoleOptionsCollectionV07))] +[HarmonyPatch(typeof(RoleOptionsCollectionV08))] public static class RoleOptionsCollectionPatch { /// /// Set the role chance for custom Launchpad roles based on config /// - [HarmonyPrefix, HarmonyPatch("GetChancePerGame")] + [HarmonyPrefix] + [HarmonyPatch(nameof(RoleOptionsCollectionV08.GetChancePerGame))] public static bool GetChancePrefix([HarmonyArgument(0)] RoleTypes roleType, ref int __result) { if (CustomRoleManager.GetCustomRoleBehaviour(roleType, out var customRole)) @@ -32,7 +33,8 @@ public static class RoleOptionsCollectionPatch /// /// Set the amount for custom Launchpad roles based on config /// - [HarmonyPrefix, HarmonyPatch("GetNumPerGame")] + [HarmonyPrefix] + [HarmonyPatch(nameof(RoleOptionsCollectionV08.GetNumPerGame))] public static bool GetNumPrefix([HarmonyArgument(0)] RoleTypes roleType, ref int __result) { if (CustomRoleManager.GetCustomRoleBehaviour(roleType, out var customRole)) diff --git a/MiraAPI/Patches/Roles/RolesSettingsMenuPatches.cs b/MiraAPI/Patches/Roles/RolesSettingsMenuPatches.cs index 374ea35..e39a1a7 100644 --- a/MiraAPI/Patches/Roles/RolesSettingsMenuPatches.cs +++ b/MiraAPI/Patches/Roles/RolesSettingsMenuPatches.cs @@ -10,7 +10,7 @@ using UnityEngine; using Object = UnityEngine.Object; namespace MiraAPI.Patches.Roles; - +/* [HarmonyPatch(typeof(RolesSettingsMenu))] public static class RolesSettingsMenuPatches { @@ -71,7 +71,7 @@ public static class RolesSettingsMenuPatches break; } } - }*/ + }*\/ var tmp = newTab.GetComponentInChildren(); tmp.defaultStr = role.NiceName; @@ -102,7 +102,7 @@ public static class RolesSettingsMenuPatches { customOption.OptionBehaviour.OnValueChanged = (Action)customOption.ValueChanged; } - }*/ + }*\/ var scroll = __instance.GetComponentInChildren(); scroll.active = true; @@ -144,4 +144,5 @@ public static class RolesSettingsMenuPatches GameOptionsManager.Instance.GameHostOptions = GameOptionsManager.Instance.CurrentGameOptions; return false; } -} \ No newline at end of file +} +*/ \ No newline at end of file diff --git a/MiraAPI/Patches/Roles/TaskAdderPatch.cs b/MiraAPI/Patches/Roles/TaskAdderPatch.cs index 3984517..ccb5c34 100644 --- a/MiraAPI/Patches/Roles/TaskAdderPatch.cs +++ b/MiraAPI/Patches/Roles/TaskAdderPatch.cs @@ -56,7 +56,8 @@ public static class TaskAdderPatch } // yes it might be crazy patching the entire method, but i tried so many other methods and only this works :cry: - [HarmonyPrefix, HarmonyPatch(typeof(TaskAdderGame), nameof(TaskAdderGame.ShowFolder))] + [HarmonyPrefix] + [HarmonyPatch(typeof(TaskAdderGame), nameof(TaskAdderGame.ShowFolder))] public static bool ShowPatch(TaskAdderGame __instance, [HarmonyArgument(0)] TaskFolder taskFolder) { var stringBuilder = new StringBuilder(64); diff --git a/MiraAPI/Resources/Menu_Button.png b/MiraAPI/Resources/Menu_Button.png new file mode 100644 index 0000000..f8d1566 Binary files /dev/null and b/MiraAPI/Resources/Menu_Button.png differ