mirror of
https://github.com/All-Of-Us-Mods/MiraAPI.git
synced 2026-10-19 15:51:48 +00:00
fix server dropdown
This commit is contained in:
1 parent
b64bf7c9de
commit
c1d2868e77
1 file changed
+19
-8
@@ -1,4 +1,6 @@
|
||||
using HarmonyLib;
|
||||
using System.Linq;
|
||||
using HarmonyLib;
|
||||
using Reactor.Utilities;
|
||||
using UnityEngine;
|
||||
using UnityEngine.Events;
|
||||
using UnityEngine.SceneManagement;
|
||||
@@ -8,20 +10,29 @@ namespace MiraAPI.Patches;
|
||||
[HarmonyPatch(typeof(ServerDropdown), nameof(ServerDropdown.FillServerOptions))]
|
||||
public static class ServerDropdownPatch
|
||||
{
|
||||
public static bool RegionEquals(this IRegionInfo region, IRegionInfo other)
|
||||
{
|
||||
return region.Name == other.Name &&
|
||||
region.TranslateName == other.TranslateName &&
|
||||
region.PingServer == other.PingServer &&
|
||||
region.TargetServer == other.TargetServer &&
|
||||
region.Servers.All(s=>other.Servers.Any(x=>x.Equals(s)));
|
||||
}
|
||||
|
||||
public static bool Prefix(ServerDropdown __instance)
|
||||
{
|
||||
var num = 0;
|
||||
__instance.background.size = new Vector2(8.4f, 4.8f);
|
||||
|
||||
foreach (var regionInfo in DestroyableSingleton<ServerManager>.Instance.AvailableRegions)
|
||||
foreach (var regionInfo in ServerManager.Instance.AvailableRegions)
|
||||
{
|
||||
var findingGame = SceneManager.GetActiveScene().name is "FindAGame";
|
||||
|
||||
if (DestroyableSingleton<ServerManager>.Instance.CurrentRegion.Equals(regionInfo))
|
||||
if (ServerManager.Instance.CurrentRegion.RegionEquals(regionInfo))
|
||||
{
|
||||
__instance.defaultButtonSelected = __instance.firstOption;
|
||||
__instance.firstOption.ChangeButtonText(
|
||||
DestroyableSingleton<TranslationController>.Instance.GetStringWithDefault(
|
||||
TranslationController.Instance.GetStringWithDefault(
|
||||
regionInfo.TranslateName,
|
||||
regionInfo.Name));
|
||||
}
|
||||
@@ -34,11 +45,11 @@ public static class ServerDropdownPatch
|
||||
{
|
||||
x += 2;
|
||||
}
|
||||
var y = -0.55f * (num / 2);
|
||||
var y = -0.55f * (num / 2f);
|
||||
serverListButton.transform.localPosition = new Vector3(x, __instance.y_posButton + y, -1f);
|
||||
serverListButton.transform.localScale = Vector3.one;
|
||||
serverListButton.Text.text =
|
||||
DestroyableSingleton<TranslationController>.Instance.GetStringWithDefault(
|
||||
TranslationController.Instance.GetStringWithDefault(
|
||||
regionInfo.TranslateName,
|
||||
regionInfo.Name);
|
||||
serverListButton.Text.ForceMeshUpdate();
|
||||
@@ -47,9 +58,9 @@ public static class ServerDropdownPatch
|
||||
__instance.controllerSelectable.Add(serverListButton.Button);
|
||||
__instance.background.transform.localPosition = new Vector3(
|
||||
findingGame ? 2f : 0f,
|
||||
__instance.initialYPos + (-0.3f * (num / 2)),
|
||||
__instance.initialYPos + -0.3f * (num / 2f),
|
||||
0f);
|
||||
__instance.background.size = new Vector2(__instance.background.size.x, 1.2f + (0.6f * (num / 2)));
|
||||
__instance.background.size = new Vector2(__instance.background.size.x, 1.2f + 0.6f * (num / 2f));
|
||||
num++;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user