mirror of
https://github.com/NuclearPowered/Reactor.git
synced 2026-10-19 15:51:54 +00:00
Simplify ShowRegionText patch and fix a exception that didn't allow you to connect to lobbies through list
This commit is contained in:
2 files changed
+25
-32
No files matched your search
@@ -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;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -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;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user