mirror of
https://github.com/All-Of-Us-Mods/MiraAPI.git
synced 2026-10-19 15:51:48 +00:00
Fix hidden local tabs breaking the menu
This commit is contained in:
1 parent
8c5aee4beb
commit
edee889ffe
2 files changed
+9
-4
No files matched your search
@@ -12,6 +12,7 @@ public static class LocalSettingsManager
|
|||||||
{
|
{
|
||||||
internal static readonly Dictionary<Type, LocalSettingsTab> TypeToTab = [];
|
internal static readonly Dictionary<Type, LocalSettingsTab> TypeToTab = [];
|
||||||
internal static readonly List<LocalSettingsTab> Tabs = [];
|
internal static readonly List<LocalSettingsTab> Tabs = [];
|
||||||
|
internal static readonly List<LocalSettingsTab> AvailableTabs = [];
|
||||||
|
|
||||||
internal static bool RegisterTab(Type type, BasePlugin pluginInfo)
|
internal static bool RegisterTab(Type type, BasePlugin pluginInfo)
|
||||||
{
|
{
|
||||||
@@ -27,6 +28,10 @@ public static class LocalSettingsManager
|
|||||||
}
|
}
|
||||||
|
|
||||||
Tabs.Add(tab);
|
Tabs.Add(tab);
|
||||||
|
if (tab.ShouldCreateButton)
|
||||||
|
{
|
||||||
|
AvailableTabs.Add(tab);
|
||||||
|
}
|
||||||
TypeToTab.Add(type, tab);
|
TypeToTab.Add(type, tab);
|
||||||
|
|
||||||
typeof(LocalSettingsTabSingleton<>).MakeGenericType(type)
|
typeof(LocalSettingsTabSingleton<>).MakeGenericType(type)
|
||||||
|
|||||||
@@ -69,7 +69,7 @@ public static class OptionsMenuPatches
|
|||||||
int i = 0;
|
int i = 0;
|
||||||
int tabIdx = 0;
|
int tabIdx = 0;
|
||||||
int page = 1;
|
int page = 1;
|
||||||
foreach (var settings in LocalSettingsManager.Tabs)
|
foreach (var settings in LocalSettingsManager.AvailableTabs)
|
||||||
{
|
{
|
||||||
var tab = settings.CreateTab(__instance);
|
var tab = settings.CreateTab(__instance);
|
||||||
if (settings.ShouldCreateButton)
|
if (settings.ShouldCreateButton)
|
||||||
@@ -164,12 +164,12 @@ public static class OptionsMenuPatches
|
|||||||
public static bool OpenTabGroupPrefix(OptionsMenuBehaviour __instance, ref int index)
|
public static bool OpenTabGroupPrefix(OptionsMenuBehaviour __instance, ref int index)
|
||||||
{
|
{
|
||||||
__instance.Tabs.ToList().ForEach(x => x.Close()); // Close all vanilla tabs
|
__instance.Tabs.ToList().ForEach(x => x.Close()); // Close all vanilla tabs
|
||||||
LocalSettingsManager.Tabs.ForEach(CustomClose); // Close all mod tabs
|
LocalSettingsManager.AvailableTabs.ForEach(CustomClose); // Close all mod tabs
|
||||||
|
|
||||||
// Tabs with index 10 and above are the mod settings tabs
|
// Tabs with index 10 and above are the mod settings tabs
|
||||||
if (index >= 10)
|
if (index >= 10)
|
||||||
{
|
{
|
||||||
CustomOpen(LocalSettingsManager.Tabs[index - 10]);
|
CustomOpen(LocalSettingsManager.AvailableTabs[index - 10]);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -183,7 +183,7 @@ public static class OptionsMenuPatches
|
|||||||
[HarmonyPatch(nameof(OptionsMenuBehaviour.Open))]
|
[HarmonyPatch(nameof(OptionsMenuBehaviour.Open))]
|
||||||
public static void OpenPostfix(OptionsMenuBehaviour __instance)
|
public static void OpenPostfix(OptionsMenuBehaviour __instance)
|
||||||
{
|
{
|
||||||
LocalSettingsManager.Tabs.ForEach(CustomClose);
|
LocalSettingsManager.AvailableTabs.ForEach(CustomClose);
|
||||||
currentPage = 1;
|
currentPage = 1;
|
||||||
UpdatePages();
|
UpdatePages();
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in new issue
Block a user