Simplify ShowRegionText patch and fix a exception that didn't allow you to connect to lobbies through list

This commit is contained in:
js6pak committed 2021-05-09 21:22:38 +02:00
1 parent d2361d18de
commit 8219539f9b
2 files changed
+25 -32

No files matched your search

+25
View File
@@ -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<Object>(0));
__instance.text = name;
}
}
}
}
}
-32
View File
@@ -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<Transform>().parent; // Returns NormalMenu
var textmeshes = parent.GetComponentsInChildren<TextMeshPro>();
foreach (var textmesh in textmeshes)
{
if (textmesh.name == "RegionText_TMP")
{
var region = DestroyableSingleton<ServerManager>.Instance.CurrentRegion;
var name = DestroyableSingleton<TranslationController>.Instance.GetStringWithDefault(region.TranslateName, region.Name, Array.Empty<Il2CppSystem.Object>());
textmesh.text = name;
break;
}
}
}
}
}
}