add corountimes for setting scroller bounds on options menus

This commit is contained in:
neilmjain committed 2026-10-22 20:24:20 -04:00
1 parent 0596278b78
commit 7c09dbdaaa
2 files changed
+24 -5

No files matched your search

+8 -3
View File
@@ -105,12 +105,17 @@ public abstract class LocalSettingsTab(ConfigFile config)
label.Key.text =
$"<font=\"LiberationSans SDF\" material=\"LiberationSans SDF - Chat Message Masked\"><b>{label.Value.Translate()}</b></font>";
}
}
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();
}
/// <summary>
@@ -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)