mirror of
https://github.com/D1GQ/BetterAmongUs.git
synced 2026-10-20 01:46:19 +00:00
Support multiple regions on menu
This commit is contained in:
1 parent
d7d72aafe0
commit
729a47113f
1 file changed
+28
@@ -32,4 +32,32 @@ public class ClientPatch
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
[HarmonyPatch(typeof(RegionMenu))]
|
||||
public class RegionMenuPatch
|
||||
{
|
||||
[HarmonyPatch(nameof(RegionMenu.OnEnable))]
|
||||
[HarmonyPostfix]
|
||||
public static void AdjustButtonPositions_Postfix(RegionMenu __instance)
|
||||
{
|
||||
const int buttonsPerColumn = 6;
|
||||
float buttonSpacing = 0.6f;
|
||||
float buttonSpacingSide = 2.25f;
|
||||
|
||||
List<UiElement> buttons = __instance.controllerSelectable.ToArray().ToList();
|
||||
|
||||
int columnCount = (buttons.Count + buttonsPerColumn - 1) / buttonsPerColumn;
|
||||
float totalWidth = (columnCount - 1) * buttonSpacingSide;
|
||||
float totalHeight = (buttonsPerColumn - 1) * buttonSpacing;
|
||||
|
||||
Vector3 startPosition = new Vector3(-totalWidth / 2, totalHeight / 2, 0f);
|
||||
|
||||
for (int i = 0; i < buttons.Count; i++)
|
||||
{
|
||||
int col = i / buttonsPerColumn;
|
||||
int row = i % buttonsPerColumn;
|
||||
buttons[i].transform.localPosition = startPosition + new Vector3(col * buttonSpacingSide, -row * buttonSpacing, 0f);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user