Please disclose if any significant portion of your mod was created using AI tools by adding the 'AI Generated' category. Failing to do so may result in the mod being removed from Thunderstore.
Decompiled source of ChineseInput v1.0.0
ChineseInput.dll
Decompiled 4 months agousing System; using System.Diagnostics; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.Versioning; using BepInEx; using BepInEx.Configuration; using BepInEx.Logging; using HarmonyLib; using TMPro; using UnityEngine; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)] [assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")] [assembly: AssemblyCompany("ChineseInput")] [assembly: AssemblyConfiguration("Debug")] [assembly: AssemblyFileVersion("1.0.0.0")] [assembly: AssemblyInformationalVersion("1.0.0")] [assembly: AssemblyProduct("ChineseInput")] [assembly: AssemblyTitle("ChineseInput")] [assembly: AssemblyVersion("1.0.0.0")] namespace ChineseInput; [BepInPlugin("com.wc.chineseinput", "REPO Chinese Input Support", "1.0.0")] public class ChineseInputPlugin : BaseUnityPlugin { public static ManualLogSource Log; public static ConfigEntry<bool> EnableChineseInput; private void Awake() { //IL_0055: Unknown result type (might be due to invalid IL or missing references) //IL_005b: Expected O, but got Unknown Log = ((BaseUnityPlugin)this).Logger; EnableChineseInput = ((BaseUnityPlugin)this).Config.Bind<bool>("General", "EnableChineseInput", true, "是否启用中文输入支持 (默认开启)"); if (!EnableChineseInput.Value) { Log.LogInfo((object)"中文输入支持已在配置中禁用。"); return; } Harmony val = new Harmony("com.chinese.inputsupport"); val.PatchAll(); Log.LogInfo((object)"REPO 中文输入支持 Mod 加载成功!"); } } [HarmonyPatch(typeof(MenuTextInput))] internal class MenuTextInputPatch { private static readonly FieldRef<MenuTextInput, string> TextCurrentRef = AccessTools.FieldRefAccess<MenuTextInput, string>("textCurrent"); private static readonly FieldRef<MenuTextInput, string> TextPreviousRef = AccessTools.FieldRefAccess<MenuTextInput, string>("textPrevious"); [HarmonyPostfix] [HarmonyPatch("Start")] private static void PostfixStart(MenuTextInput __instance) { __instance.upperOnly = false; if ((Object)(object)__instance.textMain != (Object)null) { ((TMP_Text)__instance.textMain).fontStyle = (FontStyles)0; } } [HarmonyPrefix] [HarmonyPatch("InputTextSet")] private static void PrefixInputTextSet(MenuTextInput __instance) { __instance.upperOnly = false; if ((Object)(object)__instance.textMain != (Object)null) { ((TMP_Text)__instance.textMain).fontStyle = (FontStyles)0; } } [HarmonyPrefix] [HarmonyPatch("Update")] private static bool PrefixUpdate(MenuTextInput __instance) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0007: Invalid comparison between Unknown and I4 //IL_0033: Unknown result type (might be due to invalid IL or missing references) //IL_0038: Unknown result type (might be due to invalid IL or missing references) //IL_003a: Unknown result type (might be due to invalid IL or missing references) //IL_0047: Unknown result type (might be due to invalid IL or missing references) //IL_004f: Unknown result type (might be due to invalid IL or missing references) if ((int)Input.imeCompositionMode != 1) { Input.imeCompositionMode = (IMECompositionMode)1; } if ((Object)(object)__instance.textMain != (Object)null) { Vector3 position = ((TMP_Text)__instance.textMain).transform.position; Input.compositionCursorPos = new Vector2(position.x, (float)Screen.height - position.y); } __instance.upperOnly = false; if (__instance.maxLength < 100) { __instance.maxLength = 100; } MenuManager.instance.TextInputActive(); string text = TextCurrentRef.Invoke(__instance); if (Input.GetKeyDown((KeyCode)8) && text.Length > 0) { text = text.Substring(0, text.Length - 1); } if (string.IsNullOrEmpty(Input.compositionString)) { string inputString = Input.inputString; for (int i = 0; i < inputString.Length; i++) { char c = inputString[i]; if (c != '\b' && c != '\n' && c != '\r' && text.Length < __instance.maxLength) { text += c; } } } if ((Input.GetKey((KeyCode)306) || Input.GetKey((KeyCode)305)) && Input.GetKeyDown((KeyCode)118)) { string systemCopyBuffer = GUIUtility.systemCopyBuffer; if (!string.IsNullOrEmpty(systemCopyBuffer)) { text += systemCopyBuffer; text = text.Replace("\n", "").Replace("\r", ""); if (text.Length > __instance.maxLength) { text = text.Substring(0, __instance.maxLength); } } } TextCurrentRef.Invoke(__instance) = text; AccessTools.Method(typeof(MenuTextInput), "InputTextSet", (Type[])null, (Type[])null).Invoke(__instance, null); string text2 = TextPreviousRef.Invoke(__instance); if (text2 != text) { MenuManager.instance.MenuEffectClick((MenuClickEffectType)4, (MenuPage)null, 2f, 0.2f, true); } TextPreviousRef.Invoke(__instance) = text; return false; } } [HarmonyPatch(typeof(ChatManager))] internal class ChatManagerPatch { private static readonly FieldRef<ChatManager, string> ChatMessageRef = AccessTools.FieldRefAccess<ChatManager, string>("chatMessage"); [HarmonyPrefix] [HarmonyPatch("Update")] private static bool PrefixUpdate(ChatManager __instance) { //IL_0113: Unknown result type (might be due to invalid IL or missing references) //IL_0119: Invalid comparison between Unknown and I4 //IL_000f: Unknown result type (might be due to invalid IL or missing references) //IL_0015: Invalid comparison between Unknown and I4 //IL_0036: Unknown result type (might be due to invalid IL or missing references) if (__instance.StateIsActive()) { if ((int)Input.imeCompositionMode != 1) { Input.imeCompositionMode = (IMECompositionMode)1; } Input.compositionCursorPos = new Vector2(100f, (float)(Screen.height - 200)); if (ChineseInputPlugin.EnableChineseInput.Value && (Input.GetKey((KeyCode)306) || Input.GetKey((KeyCode)305)) && Input.GetKeyDown((KeyCode)118)) { string systemCopyBuffer = GUIUtility.systemCopyBuffer; if (!string.IsNullOrEmpty(systemCopyBuffer)) { string text = ChatMessageRef.Invoke(__instance); text += systemCopyBuffer; if (text.Length > 100) { text = text.Substring(0, 100); } ChatMessageRef.Invoke(__instance) = text; if ((Object)(object)__instance.chatText != (Object)null) { ((TMP_Text)__instance.chatText).text = text; } } } if (!string.IsNullOrEmpty(Input.compositionString)) { HandleChatInputReplacement(__instance); return false; } } else if ((int)Input.imeCompositionMode > 0) { Input.imeCompositionMode = (IMECompositionMode)0; } return true; } private static void HandleChatInputReplacement(ChatManager instance) { string text = ChatMessageRef.Invoke(instance); if (string.IsNullOrEmpty(Input.compositionString)) { string inputString = Input.inputString; for (int i = 0; i < inputString.Length; i++) { char c = inputString[i]; if (c != '\b' && c != '\n' && c != '\r' && text.Length < 50) { text += c; } } } ChatMessageRef.Invoke(instance) = text; if ((Object)(object)instance.chatText != (Object)null) { ((TMP_Text)instance.chatText).text = text; } } }