diff --git a/Patches/ClientPatch.cs b/Patches/ClientPatch.cs index 1a5940c..3699485 100644 --- a/Patches/ClientPatch.cs +++ b/Patches/ClientPatch.cs @@ -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 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); + } + } + } }