mirror of
https://github.com/All-Of-Us-Mods/MiraAPI.git
synced 2026-10-20 01:46:15 +00:00
50 lines
1.5 KiB
C#
50 lines
1.5 KiB
C#
using HarmonyLib;
|
|
using MiraAPI.Utilities;
|
|
|
|
namespace MiraAPI.Patches.Options;
|
|
|
|
[HarmonyPatch(typeof(GameSettingMenu))]
|
|
internal static class GameSettingMenuPatches
|
|
{
|
|
/// <summary>
|
|
/// Prefix for the <see cref="GameSettingMenu.OnEnable"/> method. Sets up the custom options.
|
|
/// </summary>
|
|
/// <param name="__instance">The <see cref="GameSettingMenu"/> instance.</param>
|
|
[HarmonyPrefix]
|
|
[HarmonyPatch(nameof(GameSettingMenu.OnEnable))]
|
|
public static void OnEnablePrefix(GameSettingMenu __instance)
|
|
{
|
|
if (__instance.GameSettingsTab && __instance.GameSettingsTab.numberOptionOrigin)
|
|
{
|
|
Helpers.CacheAdvancedSettingsRowPrefab(__instance.GameSettingsTab.numberOptionOrigin);
|
|
}
|
|
|
|
// Add Menu State object
|
|
if (!__instance.gameObject.GetComponent<MenuState>())
|
|
{
|
|
__instance.gameObject.AddComponent<MenuState>();
|
|
Info("MenuState component added to GameSettingMenu.");
|
|
}
|
|
else
|
|
{
|
|
Info("MenuState component already added to GameSettingMenu.");
|
|
}
|
|
}
|
|
|
|
[HarmonyPrefix]
|
|
[HarmonyPatch(nameof(GameSettingMenu.ChangeTab))]
|
|
public static bool ChangeTabPrefix(GameSettingMenu __instance, int tabNum, bool previewOnly)
|
|
{
|
|
if (MenuState.Instance)
|
|
{
|
|
MenuState.Instance.ChangeTabPatch(__instance, tabNum, previewOnly);
|
|
}
|
|
else
|
|
{
|
|
Error("MenuState instance is null. Cannot change tab.");
|
|
}
|
|
|
|
return false;
|
|
}
|
|
}
|