diff --git a/Reactor/Patches/BetterGuestPatch.cs b/Reactor/Patches/BetterGuestPatch.cs
index f6b3615..8c32db5 100644
--- a/Reactor/Patches/BetterGuestPatch.cs
+++ b/Reactor/Patches/BetterGuestPatch.cs
@@ -15,25 +15,5 @@ namespace Reactor.Patches
return false;
}
}
-
- [HarmonyPatch(typeof(AccountTab), nameof(AccountTab.Open))]
- public static class EditNamePatch
- {
- public static void Prefix(AccountTab __instance)
- {
- Fix(__instance, __instance.guestMode);
- Fix(__instance, __instance.offlineMode);
- }
-
- private static void Fix(AccountTab __instance, GameObject mode)
- {
- var randomizeName = mode.transform.Find("RandomizeName").gameObject;
- if (!randomizeName.active)
- return;
-
- randomizeName.active = false;
- Object.Instantiate(__instance.loggedInMode.editNameButton, mode.transform);
- }
- }
}
}
diff --git a/Reactor/Patches/CursorPosPatch.cs b/Reactor/Patches/CursorPosPatch.cs
new file mode 100644
index 0000000..3ebe3af
--- /dev/null
+++ b/Reactor/Patches/CursorPosPatch.cs
@@ -0,0 +1,25 @@
+using System.Linq;
+using HarmonyLib;
+using TMPro;
+using UnityEngine;
+
+namespace Reactor.Patches
+{
+ ///
+ /// "Fixes" an issue where empty TextBoxes have wrong cursor positions
+ ///
+ [HarmonyPatch(typeof(TextMeshProExtensions), nameof(TextMeshProExtensions.CursorPos))]
+ internal static class CursorPosPatch
+ {
+ public static bool Prefix(TextMeshPro self, ref Vector2 __result)
+ {
+ if (self.textInfo == null || self.textInfo.lineCount == 0 || self.textInfo.lineInfo[0].characterCount <= 0)
+ {
+ __result = self.GetTextInfo(" ").lineInfo.First().lineExtents.max;
+ return false;
+ }
+
+ return true;
+ }
+ }
+}
diff --git a/Reactor/Patches/FreeNamePatch.cs b/Reactor/Patches/FreeNamePatch.cs
new file mode 100644
index 0000000..9e749ed
--- /dev/null
+++ b/Reactor/Patches/FreeNamePatch.cs
@@ -0,0 +1,49 @@
+using System;
+using HarmonyLib;
+using TMPro;
+using UnityEngine;
+using UnityEngine.UI;
+
+namespace Reactor.Patches
+{
+ internal static class FreeNamePatch
+ {
+ [HarmonyPatch(typeof(SetNameText), nameof(SetNameText.Start))]
+ public static class NameInputPatch
+ {
+ public static void Postfix(SetNameText __instance)
+ {
+ if (!__instance)
+ {
+ return;
+ }
+
+ var nameText = __instance.gameObject;
+
+ var textBox = nameText.AddComponent();
+ textBox.Background = nameText.GetComponentInChildren();
+ textBox.OnChange = textBox.OnEnter = textBox.OnFocusLost = new Button.ButtonClickedEvent();
+ textBox.characterLimit = 10;
+
+ var textMeshPro = nameText.GetComponentInChildren();
+ textBox.outputText = textMeshPro;
+ textBox.SetText(SaveManager.PlayerName);
+
+ textBox.OnChange.AddListener((Action) (() =>
+ {
+ SaveManager.PlayerName = textBox.text;
+ }));
+
+ var pipeGameObject = GameObject.Find("Pipe");
+ if (!pipeGameObject)
+ {
+ return;
+ }
+
+ var pipe = UnityEngine.Object.Instantiate(pipeGameObject, textMeshPro.transform);
+ pipe.GetComponent().fontSize = 4f;
+ textBox.Pipe = pipe.GetComponent();
+ }
+ }
+ }
+}