Skip to content

Commit 1c73c39

Browse files
Fix page scrolling
1 parent d962046 commit 1c73c39

File tree

4 files changed

+105
-87
lines changed

4 files changed

+105
-87
lines changed

Managers/FriendManager.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1188,7 +1188,7 @@ public static void ShowChatMessages(string friendTarget)
11881188
};
11891189

11901190
List<string> messages = new List<string>();
1191-
int messageCount = pageSize - 2;
1191+
int messageCount = PageSize - 2;
11921192

11931193
string messageDataPath = $"{PluginInfo.BaseDirectory}/Friends/Messages/{friendTarget}.json";
11941194
if (!File.Exists(messageDataPath))

Menu/Buttons.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -138,7 +138,7 @@ public static class Buttons
138138
new ButtonInfo { buttonText = "Scrolling Gradients", enableMethod =() => scrollingGradients = true, disableMethod =() => scrollingGradients = false, toolTip = "Scrolls the dynamic gradients over time."},
139139
new ButtonInfo { buttonText = "Dynamic Sounds", enableMethod =() => dynamicSounds = true, disableMethod =() => dynamicSounds = false, toolTip = "Adds more sounds to the menu, giving you a better sense of control."},
140140
new ButtonInfo { buttonText = "Disable Adaptive Buttons", enableMethod =() => adaptiveButtons = false, disableMethod =() => adaptiveButtons = true, toolTip = "Disables the rebinding of buttons to make your experience better based on what controllers you're using."},
141-
new ButtonInfo { buttonText = "Page Scrolling", enableMethod =() => pageScrolling = true, disableMethod =() => pageScrolling = false, toolTip = "Allows you to scroll through the mods with your joystick instead of flipping through pages."},
141+
new ButtonInfo { buttonText = "Page Scrolling", enableMethod =() => pageScrolling = true, disableMethod =() => { pageScrolling = false; pageOffset = 0; }, toolTip = "Allows you to scroll through the mods with your joystick instead of flipping through pages."},
142142
new ButtonInfo { buttonText = "Exclusive Page Sounds", enableMethod =() => exclusivePageSounds = true, disableMethod =() => exclusivePageSounds = false, toolTip = "Makes the sound that joystick menu makes when switching pages using the menu."},
143143
new ButtonInfo { buttonText = "Gradient Title", enableMethod =() => gradientTitle = true, disableMethod =() => gradientTitle = false, toolTip = "Gives a gradient to the title of the menu depending on your theme."},
144144
new ButtonInfo { buttonText = "Animated Title", enableMethod =() => animatedTitle = true, disableMethod =() => animatedTitle = false, toolTip = "Animates the title of the menu."},

Menu/Main.cs

Lines changed: 102 additions & 84 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121

2222
using BepInEx;
2323
using ExitGames.Client.Photon;
24+
using Fusion;
2425
using GorillaExtensions;
2526
using GorillaGameModes;
2627
using GorillaLocomotion;
@@ -1123,10 +1124,10 @@ public static void Prefix()
11231124
Vector2 js = leftJoystick;
11241125
if (Time.time > joystickDelay)
11251126
{
1126-
int lastPage = pageSize;
1127+
int lastButton = PageSize;
11271128

11281129
if (joystickMenuSearching)
1129-
lastPage++;
1130+
lastButton++;
11301131

11311132
if (js.x > 0.5f)
11321133
{
@@ -1152,7 +1153,7 @@ public static void Prefix()
11521153

11531154
joystickButtonSelected--;
11541155
if (joystickButtonSelected < 0)
1155-
joystickButtonSelected = lastPage - 1;
1156+
joystickButtonSelected = lastButton - 1;
11561157

11571158
ReloadMenu();
11581159
joystickDelay = Time.time + 0.2f;
@@ -1163,7 +1164,7 @@ public static void Prefix()
11631164
Play2DAudio(LoadSoundFromURL($"{PluginInfo.ServerResourcePath}/Audio/Menu/close.ogg", "Audio/Menu/down.ogg"), buttonClickVolume / 10f);
11641165

11651166
joystickButtonSelected++;
1166-
joystickButtonSelected %= lastPage;
1167+
joystickButtonSelected %= lastButton;
11671168

11681169
ReloadMenu();
11691170
joystickDelay = Time.time + 0.2f;
@@ -1197,21 +1198,17 @@ public static void Prefix()
11971198
Vector2 js = leftJoystick;
11981199
if (Time.time > scrollDelay)
11991200
{
1200-
int lastPage = pageSize;
1201-
1202-
if (joystickMenuSearching)
1203-
lastPage++;
1204-
12051201
if (js.y > 0.5f)
12061202
{
1207-
pageOffset = Mathf.Clamp(pageOffset - 1, 0, Buttons.buttons[currentCategoryIndex].Length - pageSize);
1203+
pageOffset = Mathf.Clamp(pageOffset - 1, 0, ItemCount - PageSize);
12081204

12091205
shouldReload = true;
12101206
scrollDelay = Time.time + 0.1f;
12111207
}
1208+
12121209
if (js.y < -0.5f)
12131210
{
1214-
pageOffset = Mathf.Clamp(pageOffset + 1, 0, Buttons.buttons[currentCategoryIndex].Length - pageSize);
1211+
pageOffset = Mathf.Clamp(pageOffset + 1, 0, ItemCount - PageSize);
12151212

12161213
shouldReload = true;
12171214
scrollDelay = Time.time + 0.1f;
@@ -1695,7 +1692,7 @@ private static void AddButton(float offset, int buttonIndex, ButtonInfo method)
16951692

16961693
buttonObject.transform.localScale = thinMenu ? new Vector3(0.09f, 0.9f, ButtonDistance * 0.8f) : new Vector3(0.09f, 1.3f, ButtonDistance * 0.8f);
16971694

1698-
if (longmenu && buttonIndex >= pageSize)
1695+
if (longmenu && buttonIndex >= PageSize)
16991696
{
17001697
menuBackground.transform.localScale += new Vector3(0f, 0f, 0.1f);
17011698
menuBackground.transform.localPosition += new Vector3(0f, 0f, -0.05f);
@@ -1923,7 +1920,7 @@ private static void AddSearchButton()
19231920
ColorChanger colorChanger = buttonObject.AddComponent<ColorChanger>();
19241921
colorChanger.colors = buttonColors[isSearching ^ !swapButtonColors ? 0 : 1];
19251922

1926-
if (joystickMenuSearching && joystickButtonSelected == pageSize)
1923+
if (joystickMenuSearching && joystickButtonSelected == PageSize)
19271924
{
19281925
joystickSelectedButton = "Search";
19291926

@@ -2849,8 +2846,8 @@ public static GameObject CreateMenu()
28492846

28502847
if (!longmenu)
28512848
renderButtons = renderButtons
2852-
.Skip(pageNumber * (pageSize - buttonIndexOffset) + pageOffset)
2853-
.Take(pageSize - buttonIndexOffset)
2849+
.Skip(pageNumber * (PageSize - buttonIndexOffset) + pageOffset)
2850+
.Take(PageSize - buttonIndexOffset)
28542851
.ToArray();
28552852

28562853
for (int i = 0; i < renderButtons.Length; i++)
@@ -5889,70 +5886,6 @@ public static int NoInvisLayerMask()
58895886

58905887
public static void Toggle(string buttonText, bool fromMenu = false, bool ignoreForce = false)
58915888
{
5892-
int lastPage = (Buttons.buttons[currentCategoryIndex].Length + pageSize - 1) / pageSize - 1;
5893-
if (currentCategoryName == "Favorite Mods")
5894-
lastPage = (favorites.Count + pageSize - 1) / pageSize - 1;
5895-
5896-
if (currentCategoryName == "Enabled Mods")
5897-
{
5898-
List<string> enabledMods = new List<string> { "Exit Enabled Mods" };
5899-
int categoryIndex = 0;
5900-
foreach (ButtonInfo[] buttonlist in Buttons.buttons)
5901-
{
5902-
enabledMods.AddRange(from v in buttonlist where v.enabled && (!hideSettings || !Buttons.categoryNames[categoryIndex].Contains("Settings")) && (!hideMacros || !Buttons.categoryNames[categoryIndex].Contains("Macro")) select v.buttonText);
5903-
categoryIndex++;
5904-
}
5905-
lastPage = (enabledMods.Count + pageSize - 1) / pageSize - 1;
5906-
}
5907-
5908-
if (isSearching)
5909-
{
5910-
List<ButtonInfo> searchedMods = new List<ButtonInfo>();
5911-
if (nonGlobalSearch && currentCategoryName != "Main")
5912-
{
5913-
foreach (ButtonInfo v in Buttons.buttons[currentCategoryIndex])
5914-
{
5915-
try
5916-
{
5917-
string buttonTextt = v.buttonText;
5918-
if (v.overlapText != null)
5919-
buttonTextt = v.overlapText;
5920-
5921-
if (buttonTextt.ClearTags().Replace(" ", "").ToLower().Contains(keyboardInput.Replace(" ", "").ToLower()))
5922-
searchedMods.Add(v);
5923-
}
5924-
catch { }
5925-
}
5926-
}
5927-
else
5928-
{
5929-
int categoryIndex = 0;
5930-
foreach (ButtonInfo[] buttonlist in Buttons.buttons)
5931-
{
5932-
foreach (ButtonInfo v in buttonlist)
5933-
{
5934-
try
5935-
{
5936-
if ((Buttons.categoryNames[categoryIndex].Contains("Admin") || Buttons.categoryNames[categoryIndex] == "Mod Givers") && !isAdmin)
5937-
continue;
5938-
5939-
string buttonTextt = v.buttonText;
5940-
if (v.overlapText != null)
5941-
buttonTextt = v.overlapText;
5942-
5943-
if (buttonTextt.Replace(" ", "").ToLower().Contains(keyboardInput.Replace(" ", "").ToLower()))
5944-
searchedMods.Add(v);
5945-
}
5946-
catch { }
5947-
}
5948-
categoryIndex++;
5949-
}
5950-
}
5951-
5952-
// ReSharper disable once PossibleLossOfFraction
5953-
lastPage = (int)Mathf.Ceil(searchedMods.ToArray().Length / (pageSize - 1));
5954-
}
5955-
59565889
switch (buttonText)
59575890
{
59585891
case "PreviousPage":
@@ -5962,7 +5895,7 @@ public static void Toggle(string buttonText, bool fromMenu = false, bool ignoreF
59625895

59635896
pageNumber--;
59645897
if (pageNumber < 0)
5965-
pageNumber = lastPage;
5898+
pageNumber = LastPage;
59665899
break;
59675900
}
59685901
case "NextPage":
@@ -5971,7 +5904,7 @@ public static void Toggle(string buttonText, bool fromMenu = false, bool ignoreF
59715904
lastClickedName = "NextPage";
59725905

59735906
pageNumber++;
5974-
pageNumber %= lastPage + 1;
5907+
pageNumber %= LastPage + 1;
59755908
break;
59765909
}
59775910
default:
@@ -6456,12 +6389,98 @@ _ _
64566389
public static bool oneHand;
64576390

64586391
public static int _pageSize = 8;
6459-
public static int pageSize
6392+
public static int PageSize
64606393
{
64616394
get => _pageSize - buttonOffset;
64626395
set => _pageSize = value;
64636396
}
64646397

6398+
public static int ItemCount
6399+
{
6400+
get
6401+
{
6402+
int count = Buttons.buttons[currentCategoryIndex].Length;
6403+
6404+
if (currentCategoryName == "Favorite Mods")
6405+
count = favorites.Count;
6406+
6407+
if (currentCategoryName == "Enabled Mods")
6408+
{
6409+
var enabledMods = new List<string> { "Exit Enabled Mods" };
6410+
6411+
for (int i = 0; i < Buttons.buttons.Length; i++)
6412+
{
6413+
var buttonList = Buttons.buttons[i];
6414+
var category = Buttons.categoryNames[i];
6415+
6416+
bool skipSettings = hideSettings && category.Contains("Settings");
6417+
bool skipMacros = hideMacros && category.Contains("Macro");
6418+
6419+
if (skipSettings || skipMacros)
6420+
continue;
6421+
6422+
foreach (var v in buttonList)
6423+
{
6424+
if (v.enabled)
6425+
enabledMods.Add(v.buttonText);
6426+
}
6427+
}
6428+
6429+
count = enabledMods.Count - 1;
6430+
}
6431+
6432+
if (isSearching)
6433+
{
6434+
List<ButtonInfo> searchedMods = new List<ButtonInfo>();
6435+
6436+
if (nonGlobalSearch && currentCategoryName != "Main")
6437+
{
6438+
foreach (ButtonInfo v in Buttons.buttons[currentCategoryIndex])
6439+
{
6440+
try
6441+
{
6442+
string buttonText = v.overlapText ?? v.buttonText;
6443+
6444+
if (buttonText.ClearTags().Replace(" ", "").ToLower().Contains(keyboardInput.Replace(" ", "").ToLower()))
6445+
searchedMods.Add(v);
6446+
}
6447+
catch { }
6448+
}
6449+
}
6450+
else
6451+
{
6452+
int categoryIndex = 0;
6453+
foreach (ButtonInfo[] buttonList in Buttons.buttons)
6454+
{
6455+
foreach (ButtonInfo v in buttonList)
6456+
{
6457+
try
6458+
{
6459+
if ((Buttons.categoryNames[categoryIndex].Contains("Admin") ||
6460+
Buttons.categoryNames[categoryIndex] == "Mod Givers") &&
6461+
!isAdmin)
6462+
continue;
6463+
6464+
string displayedText = v.overlapText ?? v.buttonText;
6465+
6466+
if (displayedText.Replace(" ", "").ToLower().Contains(keyboardInput.Replace(" ", "").ToLower()))
6467+
searchedMods.Add(v);
6468+
}
6469+
catch { }
6470+
}
6471+
categoryIndex++;
6472+
}
6473+
}
6474+
6475+
count = searchedMods.Count;
6476+
}
6477+
6478+
return count;
6479+
}
6480+
}
6481+
6482+
public static int LastPage => (ItemCount + PageSize - 1) / PageSize - 1;
6483+
64656484
public static int pageOffset;
64666485
public static int pageNumber;
64676486
public static bool pageScrolling;
@@ -6505,15 +6524,14 @@ public static string currentCategoryName
65056524
currentCategoryIndex = Buttons.GetCategory(value);
65066525
}
65076526

6508-
// Compatiblity
65096527
public static int buttonClickSound = 8;
65106528
public static int buttonClickIndex;
65116529
public static int buttonClickVolume = 4;
65126530
public static int buttonOffset = 2;
65136531
public static int menuButtonIndex = 1;
65146532
public static float ButtonDistance
65156533
{
6516-
get => 0.8f / (pageSize + buttonOffset);
6534+
get => 0.8f / (PageSize + buttonOffset);
65176535
}
65186536

65196537
public static bool doButtonsVibrate = true;

PluginInfo.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ public class PluginInfo
2626
public const string GUID = "org.iidk.gorillatag.iimenu";
2727
public const string Name = "ii's Stupid Menu";
2828
public const string Description = "Created by @crimsoncauldron with love <3";
29-
public const string BuildTimestamp = "2025-11-24T22:14:48Z";
29+
public const string BuildTimestamp = "2025-11-25T23:50:20Z";
3030
public const string Version = "7.8.0";
3131

3232
public const string BaseDirectory = "iisStupidMenu";

0 commit comments

Comments
 (0)