fix discord rp & character allowance patch

This commit is contained in:
Gurge44 committed 2026-06-28 20:38:33 +02:00
1 parent 9eeddae0b9
commit 3bdc76dd88
8 files changed
+106 -33

No files matched your search

+28 -3
View File
@@ -16,20 +16,45 @@ public static class TextBoxPatch
private static TextMeshPro AdditionalInfoText;
public static bool IsInvalidCommand;
private static int CurrentCharPos;
public static bool Pasting;
// from https://github.com/scp222thj/MalumMenu/blob/main/src/Patches/TextBoxTMPPatches.cs
// Well I guess cheat menus sometimes have useful code too....
[HarmonyPatch(typeof(TextBoxTMP), nameof(TextBoxTMP.IsCharAllowed))]
[HarmonyPrefix]
public static bool AllowAllCharacters(TextBoxTMP __instance, [HarmonyArgument(0)] char i, ref bool __result)
public static bool AllowAllCharacters(TextBoxTMP __instance, ref bool __result)
{
if (!__instance.IpMode && i is '\'' or '"' or '’' or '`' or '-' or '–' or '—' or '‐' or '.' or ',' or ':' or ';' or '!' or '?' or '(' or ')' or '[' or ']' or '{' or '}' or '<' or '>' or '+' or '=' or '~' or '^' or '*' or '%' or '&' or '|' or '$' or '€' or '£' or '¥' or '₽' or >= '\u0100' and <= '\u024F' or >= '\u0370' and <= '\u03FF')
string compositionString = Input.compositionString;
if (compositionString.Length > 0)
{
__result = true;
return false;
}
return true;
var input = Pasting ? GUIUtility.systemCopyBuffer.Trim() : Input.inputString;
Pasting = false;
if (input.Length == 0)
{
__result = true;
return false;
}
string currentText = __instance.text ?? string.Empty;
int caretPos = Mathf.Clamp(__instance.caretPos, 0, currentText.Length);
string text = currentText.Insert(caretPos, input);
CurrentCharPos = Mathf.Clamp(CurrentCharPos, 0, text.Length - 1);
char currentChar = text[CurrentCharPos];
if (CurrentCharPos >= text.Length - 1) CurrentCharPos = 0;
else CurrentCharPos++;
__result = currentChar is not ('\b' or '\r' or '[');
return false;
}
[HarmonyPatch(typeof(TextBoxTMP), nameof(TextBoxTMP.SetText))]
[HarmonyPostfix]
public static void ShowCommandHelp(TextBoxTMP __instance)