diff --git a/Reactor/Patches/FixRegionText.cs b/Reactor/Patches/FixRegionText.cs new file mode 100644 index 0000000..17f3dd3 --- /dev/null +++ b/Reactor/Patches/FixRegionText.cs @@ -0,0 +1,25 @@ +using HarmonyLib; +using TMPro; +using UnhollowerBaseLib; +using Object = Il2CppSystem.Object; + +namespace Reactor.Patches +{ + // 2021.4.12 does not properly set the region text, so we need to help it a bit. + internal static class FixRegionText + { + [HarmonyPatch(typeof(TextMeshPro), nameof(TextMeshPro.Awake))] + public static class MatchMakerPatch + { + public static void Prefix(TextMeshPro __instance) + { + if (__instance.name == "RegionText_TMP") + { + var region = ServerManager.Instance.CurrentRegion; + var name = TranslationController.Instance.GetStringWithDefault(region.TranslateName, region.Name, new Il2CppReferenceArray(0)); + __instance.text = name; + } + } + } + } +} diff --git a/Reactor/Patches/ShowRegionText.cs b/Reactor/Patches/ShowRegionText.cs deleted file mode 100644 index 3b9d3da..0000000 --- a/Reactor/Patches/ShowRegionText.cs +++ /dev/null @@ -1,32 +0,0 @@ -using HarmonyLib; -using UnityEngine; -using TMPro; -using System; - -namespace Reactor.Patches -{ - // 2021.4.12 does not properly set the region text, so we need to help it a bit. - // We're piggybacking on a completely unrelated method which was chosen because it was close to the element we needed to change - internal static class ShowRegionText - { - [HarmonyPatch(typeof(MatchMaker), nameof(MatchMaker.Start))] - public static class MatchMakerPatch - { - public static void Prefix(MatchMaker __instance) - { - var parent = __instance.GetComponentInParent().parent; // Returns NormalMenu - var textmeshes = parent.GetComponentsInChildren(); - foreach (var textmesh in textmeshes) - { - if (textmesh.name == "RegionText_TMP") - { - var region = DestroyableSingleton.Instance.CurrentRegion; - var name = DestroyableSingleton.Instance.GetStringWithDefault(region.TranslateName, region.Name, Array.Empty()); - textmesh.text = name; - break; - } - } - } - } - } -}