Decompiled source of UserKoreanTranslation v1.1.0

BepInEx/plugins/ATOKoreanMod/ATOKoreanMod.dll

Decompiled a day ago
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Cryptography;
using System.Security.Permissions;
using System.Text;
using System.Text.RegularExpressions;
using BepInEx;
using BepInEx.Logging;
using HarmonyLib;
using Microsoft.CodeAnalysis;
using TMPro;
using UnityEngine;
using UnityEngine.Events;
using UnityEngine.SceneManagement;
using UnityEngine.UI;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: TargetFramework(".NETFramework,Version=v4.7.2", FrameworkDisplayName = ".NET Framework 4.7.2")]
[assembly: AssemblyCompany("ATOKoreanMod")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyDescription("ATOKoreanMod")]
[assembly: AssemblyFileVersion("2026.5.16.0")]
[assembly: AssemblyInformationalVersion("2026.5.16+8bb2f613cccac8a4532e1703d958afe8b2b4f507")]
[assembly: AssemblyProduct("ATOKoreanMod")]
[assembly: AssemblyTitle("ATOKoreanMod")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("2026.5.16.0")]
[module: UnverifiableCode]
[module: RefSafetyRules(11)]
namespace Microsoft.CodeAnalysis
{
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	internal sealed class EmbeddedAttribute : Attribute
	{
	}
}
namespace System.Runtime.CompilerServices
{
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	[AttributeUsage(AttributeTargets.Class | AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Event | AttributeTargets.Parameter | AttributeTargets.ReturnValue | AttributeTargets.GenericParameter, AllowMultiple = false, Inherited = false)]
	internal sealed class NullableAttribute : Attribute
	{
		public readonly byte[] NullableFlags;

		public NullableAttribute(byte P_0)
		{
			NullableFlags = new byte[1] { P_0 };
		}

		public NullableAttribute(byte[] P_0)
		{
			NullableFlags = P_0;
		}
	}
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	[AttributeUsage(AttributeTargets.Class | AttributeTargets.Struct | AttributeTargets.Method | AttributeTargets.Interface | AttributeTargets.Delegate, AllowMultiple = false, Inherited = false)]
	internal sealed class NullableContextAttribute : Attribute
	{
		public readonly byte Flag;

		public NullableContextAttribute(byte P_0)
		{
			Flag = P_0;
		}
	}
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	[AttributeUsage(AttributeTargets.Module, AllowMultiple = false, Inherited = false)]
	internal sealed class RefSafetyRulesAttribute : Attribute
	{
		public readonly int Version;

		public RefSafetyRulesAttribute(int P_0)
		{
			Version = P_0;
		}
	}
}
namespace ATOKoreanMod
{
	[BepInPlugin("ATOKoreanMod", "ATOKoreanMod", "2026.5.16")]
	public class Plugin : BaseUnityPlugin
	{
		[Serializable]
		[CompilerGenerated]
		private sealed class <>c
		{
			public static readonly <>c <>9 = new <>c();

			public static UnityAction <>9__18_0;

			public static UnityAction <>9__21_0;

			public static UnityAction <>9__21_1;

			public static UnityAction<int> <>9__23_0;

			internal void <PatchLobbyDiscordButton>b__18_0()
			{
				Application.OpenURL("https://discord.gg/PJGBvtHsvr");
			}

			internal void <MainMenuUpdatePostfix>b__21_0()
			{
				Application.OpenURL("https://discord.gg/PJGBvtHsvr");
			}

			internal void <MainMenuUpdatePostfix>b__21_1()
			{
				Application.OpenURL("https://gall.dcinside.com/mgallery/board/lists/?id=acrosstheobelisk");
			}

			internal void <Start>b__23_0(int value)
			{
				if ((Object)(object)GameManager.Instance == (Object)null || !GameManager.Instance.PrefsLoaded)
				{
					return;
				}
				string text = (IsKoreanSelected() ? "ko" : "");
				if (!(text == selectedLanguage))
				{
					selectedLanguage = text;
					TextStrings = new Dictionary<string, Dictionary<string, string>>(StringComparer.OrdinalIgnoreCase);
					TextKeynotes = new Dictionary<string, Dictionary<string, string>>(StringComparer.OrdinalIgnoreCase);
					if (selectedLanguage != "")
					{
						TextStrings[selectedLanguage] = new Dictionary<string, string>();
						TextKeynotes[selectedLanguage] = new Dictionary<string, string>();
					}
					if ((Object)(object)AlertManager.Instance != (Object)null)
					{
						AlertManager.Instance.AlertConfirm(Texts.Instance.GetText("selectLanguageChanged", ""), "");
					}
				}
			}
		}

		internal static ManualLogSource Log = null;

		private static readonly string PluginDir = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location);

		private static Dictionary<string, Dictionary<string, string>> TextStrings;

		private static Dictionary<string, Dictionary<string, string>> TextKeynotes;

		private static string selectedLanguage = "";

		private static bool listenerRegistered = false;

		private static List<string> tips = new List<string>();

		private static TMP_FontAsset alternativeFont = null;

		private static string translationsDir = "";

		private static string _versionLabel = "";

		private static readonly byte[] _mk = new byte[6] { 79, 98, 101, 108, 105, 115 };

		private static readonly byte[] _b0 = new byte[32]
		{
			254, 251, 230, 130, 223, 87, 206, 68, 113, 62,
			84, 7, 145, 214, 34, 183, 184, 226, 135, 16,
			143, 122, 106, 163, 57, 43, 176, 247, 242, 120,
			185, 36
		};

		private static readonly byte[] _b1 = new byte[32]
		{
			214, 123, 200, 47, 136, 134, 1, 188, 33, 140,
			115, 168, 193, 73, 75, 152, 26, 45, 69, 54,
			31, 36, 1, 213, 10, 69, 172, 108, 10, 228,
			108, 156
		};

		private static readonly byte[] _b2 = new byte[32]
		{
			254, 251, 230, 130, 223, 87, 206, 68, 113, 62,
			84, 7, 145, 214, 34, 183, 184, 226, 135, 16,
			143, 122, 106, 163, 57, 43, 176, 247, 242, 120,
			185, 36
		};

		private const string KoreanDiscordUrl = "https://discord.gg/PJGBvtHsvr";

		private const string DCInsideUrl = "https://gall.dcinside.com/mgallery/board/lists/?id=acrosstheobelisk";

		private static bool _modVersionCreated = false;

		private static bool _discordButtonPatched = false;

		private void Awake()
		{
			Log = ((BaseUnityPlugin)this).Logger;
			Harmony.CreateAndPatchAll(typeof(Plugin), (string)null);
			SceneManager.sceneLoaded += OnSceneLoaded;
		}

		private static void OnSceneLoaded(Scene scene, LoadSceneMode mode)
		{
			if (((Scene)(ref scene)).name == "MainMenu")
			{
				_modVersionCreated = false;
				_discordButtonPatched = false;
			}
			else if (((Scene)(ref scene)).name == "Lobby" && selectedLanguage != "")
			{
				PatchLobbyDiscordButton();
			}
		}

		private static void PatchLobbyDiscordButton()
		{
			//IL_001d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0022: Unknown result type (might be due to invalid IL or missing references)
			//IL_0089: Unknown result type (might be due to invalid IL or missing references)
			//IL_0093: Expected O, but got Unknown
			//IL_00ae: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b9: Expected O, but got Unknown
			//IL_00f4: Unknown result type (might be due to invalid IL or missing references)
			Button val = null;
			Button[] array = Resources.FindObjectsOfTypeAll<Button>();
			foreach (Button val2 in array)
			{
				Scene scene = ((Component)val2).gameObject.scene;
				if (((Scene)(ref scene)).name == "Lobby" && ((Object)val2).name == "ButtonDiscord")
				{
					val = val2;
					break;
				}
			}
			if ((Object)(object)val == (Object)null)
			{
				Log.LogWarning((object)"Lobby Discord button not found");
				return;
			}
			val.onClick = new ButtonClickedEvent();
			ButtonClickedEvent onClick = val.onClick;
			object obj = <>c.<>9__18_0;
			if (obj == null)
			{
				UnityAction val3 = delegate
				{
					Application.OpenURL("https://discord.gg/PJGBvtHsvr");
				};
				<>c.<>9__18_0 = val3;
				obj = (object)val3;
			}
			((UnityEvent)onClick).AddListener((UnityAction)obj);
			Image component = ((Component)val).GetComponent<Image>();
			Sprite val4 = LoadSprite("discord_kr.png");
			if ((Object)(object)component != (Object)null && (Object)(object)val4 != (Object)null)
			{
				component.sprite = val4;
				((Graphic)component).color = Color.white;
			}
			Log.LogDebug((object)"Lobby Discord button patched");
		}

		[HarmonyPatch(typeof(MainMenuManager), "Update")]
		[HarmonyPostfix]
		private static void MainMenuUpdatePostfix()
		{
			//IL_021e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0228: Expected O, but got Unknown
			//IL_0244: Unknown result type (might be due to invalid IL or missing references)
			//IL_0249: Unknown result type (might be due to invalid IL or missing references)
			//IL_024f: Expected O, but got Unknown
			//IL_007a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0081: Expected O, but got Unknown
			//IL_00c6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d5: Unknown result type (might be due to invalid IL or missing references)
			//IL_0144: Unknown result type (might be due to invalid IL or missing references)
			//IL_0153: Unknown result type (might be due to invalid IL or missing references)
			//IL_0162: Unknown result type (might be due to invalid IL or missing references)
			//IL_0171: Unknown result type (might be due to invalid IL or missing references)
			//IL_017d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0189: Unknown result type (might be due to invalid IL or missing references)
			//IL_0194: Unknown result type (might be due to invalid IL or missing references)
			//IL_01a3: Unknown result type (might be due to invalid IL or missing references)
			//IL_02bd: Unknown result type (might be due to invalid IL or missing references)
			//IL_02c4: Expected O, but got Unknown
			//IL_02a3: Unknown result type (might be due to invalid IL or missing references)
			//IL_0316: Unknown result type (might be due to invalid IL or missing references)
			//IL_0346: Unknown result type (might be due to invalid IL or missing references)
			//IL_034b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0351: Expected O, but got Unknown
			//IL_0381: Unknown result type (might be due to invalid IL or missing references)
			//IL_0390: Unknown result type (might be due to invalid IL or missing references)
			//IL_039f: Unknown result type (might be due to invalid IL or missing references)
			//IL_03b6: Unknown result type (might be due to invalid IL or missing references)
			//IL_03c5: Unknown result type (might be due to invalid IL or missing references)
			//IL_03d1: Unknown result type (might be due to invalid IL or missing references)
			//IL_03e1: Unknown result type (might be due to invalid IL or missing references)
			//IL_0369: Unknown result type (might be due to invalid IL or missing references)
			if (selectedLanguage == "")
			{
				return;
			}
			if (!_modVersionCreated)
			{
				Translate[] array = Object.FindObjectsOfType<Translate>();
				foreach (Translate val in array)
				{
					if (((Object)val).name != "Version")
					{
						continue;
					}
					TMP_Text component = ((Component)val).GetComponent<TMP_Text>();
					if (!((Object)(object)component == (Object)null))
					{
						GameObject val2 = new GameObject("KoreanModVersion");
						val2.transform.SetParent(((Component)val).transform.parent, false);
						TextMeshProUGUI val3 = val2.AddComponent<TextMeshProUGUI>();
						((TMP_Text)val3).font = component.font;
						((TMP_Text)val3).fontSize = component.fontSize;
						((Graphic)val3).color = ((Graphic)component).color;
						((TMP_Text)val3).alignment = component.alignment;
						((TMP_Text)val3).text = _versionLabel;
						((TMP_Text)val3).enableWordWrapping = false;
						((TMP_Text)val3).overflowMode = (TextOverflowModes)0;
						if ((Object)(object)alternativeFont != (Object)null)
						{
							((TMP_Text)val3).font.fallbackFontAssetTable = new List<TMP_FontAsset> { alternativeFont };
						}
						RectTransform component2 = ((Component)val).GetComponent<RectTransform>();
						RectTransform component3 = val2.GetComponent<RectTransform>();
						component3.anchorMin = component2.anchorMin;
						component3.anchorMax = component2.anchorMax;
						component3.pivot = component2.pivot;
						component3.anchoredPosition = new Vector2(component2.anchoredPosition.x, component2.anchoredPosition.y - component2.sizeDelta.y);
						component3.sizeDelta = component2.sizeDelta;
						Log.LogDebug((object)"KoreanModVersion text box created");
						_modVersionCreated = true;
					}
					break;
				}
			}
			if (_discordButtonPatched)
			{
				return;
			}
			GameObject val4 = GameObject.Find("Canvas/MainMenu/Discord");
			if (!((Object)(object)val4 != (Object)null))
			{
				return;
			}
			Button component4 = val4.GetComponent<Button>();
			if ((Object)(object)component4 != (Object)null)
			{
				component4.onClick = new ButtonClickedEvent();
				ButtonClickedEvent onClick = component4.onClick;
				object obj = <>c.<>9__21_0;
				if (obj == null)
				{
					UnityAction val5 = delegate
					{
						Application.OpenURL("https://discord.gg/PJGBvtHsvr");
					};
					<>c.<>9__21_0 = val5;
					obj = (object)val5;
				}
				((UnityEvent)onClick).AddListener((UnityAction)obj);
				Log.LogDebug((object)"Discord button URL replaced");
			}
			Image component5 = val4.GetComponent<Image>();
			Sprite val6 = LoadSprite("discord_kr.png");
			if ((Object)(object)component5 != (Object)null && (Object)(object)val6 != (Object)null)
			{
				component5.sprite = val6;
				((Graphic)component5).color = Color.white;
			}
			RectTransform component6 = val4.GetComponent<RectTransform>();
			GameObject val7 = new GameObject("DCInsideButton");
			val7.transform.SetParent(val4.transform.parent, false);
			val7.AddComponent<CanvasRenderer>();
			Image val8 = val7.AddComponent<Image>();
			Sprite val9 = LoadSprite("dcinside_kr.png");
			if ((Object)(object)val9 != (Object)null)
			{
				val8.sprite = val9;
				((Graphic)val8).color = Color.white;
			}
			Button val10 = val7.AddComponent<Button>();
			ButtonClickedEvent onClick2 = val10.onClick;
			object obj2 = <>c.<>9__21_1;
			if (obj2 == null)
			{
				UnityAction val11 = delegate
				{
					Application.OpenURL("https://gall.dcinside.com/mgallery/board/lists/?id=acrosstheobelisk");
				};
				<>c.<>9__21_1 = val11;
				obj2 = (object)val11;
			}
			((UnityEvent)onClick2).AddListener((UnityAction)obj2);
			if ((Object)(object)component4 != (Object)null)
			{
				((Selectable)val10).colors = ((Selectable)component4).colors;
			}
			RectTransform component7 = val7.GetComponent<RectTransform>();
			component7.anchorMin = component6.anchorMin;
			component7.anchorMax = component6.anchorMax;
			component7.pivot = component6.pivot;
			component7.sizeDelta = new Vector2(300f, 70f);
			component7.anchoredPosition = new Vector2(component6.anchoredPosition.x, component6.anchoredPosition.y + 80f);
			Log.LogDebug((object)"DCInside button created");
			_discordButtonPatched = true;
		}

		[HarmonyPatch(typeof(TextMeshPro), "OnEnable")]
		[HarmonyPostfix]
		public static void FontPatchTMPText(TextMeshPro __instance)
		{
			if ((Object)(object)alternativeFont != (Object)null && (Object)(object)__instance != (Object)null && (Object)(object)((TMP_Text)__instance).font != (Object)null)
			{
				((TMP_Text)__instance).font.fallbackFontAssetTable = new List<TMP_FontAsset> { alternativeFont };
			}
		}

		[HarmonyPatch(typeof(GameManager), "Start")]
		[HarmonyPrefix]
		private static void Start()
		{
			if (listenerRegistered || !((Object)(object)SettingsManager.Instance?.languageDropdown != (Object)null))
			{
				return;
			}
			((UnityEvent<int>)(object)SettingsManager.Instance.languageDropdown.onValueChanged).AddListener((UnityAction<int>)delegate
			{
				if (!((Object)(object)GameManager.Instance == (Object)null) && GameManager.Instance.PrefsLoaded)
				{
					string text = (IsKoreanSelected() ? "ko" : "");
					if (!(text == selectedLanguage))
					{
						selectedLanguage = text;
						TextStrings = new Dictionary<string, Dictionary<string, string>>(StringComparer.OrdinalIgnoreCase);
						TextKeynotes = new Dictionary<string, Dictionary<string, string>>(StringComparer.OrdinalIgnoreCase);
						if (selectedLanguage != "")
						{
							TextStrings[selectedLanguage] = new Dictionary<string, string>();
							TextKeynotes[selectedLanguage] = new Dictionary<string, string>();
						}
						if ((Object)(object)AlertManager.Instance != (Object)null)
						{
							AlertManager.Instance.AlertConfirm(Texts.Instance.GetText("selectLanguageChanged", ""), "");
						}
					}
				}
			});
			listenerRegistered = true;
		}

		[HarmonyPatch(typeof(SettingsManager), "LoadPrefs")]
		[HarmonyPostfix]
		private static void LoadPrefsPostfix()
		{
			try
			{
				selectedLanguage = (IsKoreanSelected() ? "ko" : "");
				tips = new List<string>();
				TextStrings = new Dictionary<string, Dictionary<string, string>>(StringComparer.OrdinalIgnoreCase);
				TextKeynotes = new Dictionary<string, Dictionary<string, string>>(StringComparer.OrdinalIgnoreCase);
				if (selectedLanguage != "")
				{
					TextStrings[selectedLanguage] = new Dictionary<string, string>();
					TextKeynotes[selectedLanguage] = new Dictionary<string, string>();
					LoadFont();
					translationsDir = Path.Combine(PluginDir, "translation");
					if (!File.Exists(Path.Combine(translationsDir, "ko.txt")))
					{
						translationsDir = "";
					}
					_versionLabel = "";
					bool flag = false;
					if (translationsDir != "")
					{
						string path = Path.Combine(translationsDir, "ko_version.txt");
						if (File.Exists(path))
						{
							string[] array = File.ReadAllLines(path);
							if (array.Length != 0)
							{
								_versionLabel = array[0].Trim();
							}
							if (array.Length >= 2 && VerifyUrlHash(array[1].Trim(), _b0))
							{
								flag = true;
							}
						}
					}
					if (!flag)
					{
						Log.LogError((object)"Integrity check failed");
						selectedLanguage = "";
						translationsDir = "";
						_versionLabel = "";
						alternativeFont = null;
					}
					else if (!VerifyUrlHash("https://discord.gg/PJGBvtHsvr", _b1) || !VerifyUrlHash("https://gall.dcinside.com/mgallery/board/lists/?id=acrosstheobelisk", _b2))
					{
						Log.LogError((object)"URL integrity check failed");
						selectedLanguage = "";
						translationsDir = "";
						_versionLabel = "";
						alternativeFont = null;
					}
					else
					{
						if (_versionLabel == "")
						{
							_versionLabel = "한국어 모드";
						}
						Log.LogInfo((object)("Korean selected, loading translations. Version label: " + _versionLabel));
					}
				}
				else
				{
					Log.LogInfo((object)"Korean not selected, mod inactive");
				}
			}
			catch (Exception ex)
			{
				Log.LogError((object)("LoadPrefsPostfix error: " + ex.Message));
			}
		}

		private static bool IsKoreanSelected()
		{
			if ((Object)(object)SettingsManager.Instance == (Object)null)
			{
				return false;
			}
			TMP_Dropdown languageDropdown = SettingsManager.Instance.languageDropdown;
			if ((Object)(object)languageDropdown == (Object)null || languageDropdown.options.Count == 0)
			{
				return false;
			}
			return string.Equals(languageDropdown.options[languageDropdown.value].text.Trim(), "한국인", StringComparison.OrdinalIgnoreCase);
		}

		private static void LoadFont()
		{
			//IL_0056: Unknown result type (might be due to invalid IL or missing references)
			//IL_005c: Expected O, but got Unknown
			try
			{
				string path = Path.Combine(PluginDir, "font");
				if (!Directory.Exists(path))
				{
					return;
				}
				string[] files = Directory.GetFiles(path, "*.ttf");
				if (files.Length == 0)
				{
					files = Directory.GetFiles(path, "*.otf");
				}
				if (files.Length != 0)
				{
					Font val = new Font(files[0]);
					TMP_FontAsset val2 = TMP_FontAsset.CreateFontAsset(val);
					if ((Object)(object)val2 != (Object)null)
					{
						alternativeFont = val2;
					}
				}
			}
			catch (Exception ex)
			{
				Log.LogError((object)("LoadFont error: " + ex.Message));
			}
		}

		private static Sprite LoadSprite(string filename)
		{
			//IL_0044: Unknown result type (might be due to invalid IL or missing references)
			//IL_004a: Expected O, but got Unknown
			//IL_0078: Unknown result type (might be due to invalid IL or missing references)
			//IL_0087: Unknown result type (might be due to invalid IL or missing references)
			Assembly executingAssembly = Assembly.GetExecutingAssembly();
			using Stream stream = executingAssembly.GetManifestResourceStream("ATOKoreanMod.sprites." + filename);
			if (stream == null)
			{
				return null;
			}
			byte[] array = new byte[stream.Length];
			stream.Read(array, 0, array.Length);
			Texture2D val = new Texture2D(2, 2);
			if (!ImageConversion.LoadImage(val, array))
			{
				return null;
			}
			return Sprite.Create(val, new Rect(0f, 0f, (float)((Texture)val).width, (float)((Texture)val).height), new Vector2(0.5f, 0.5f));
		}

		private static bool VerifyUrlHash(string url, byte[] encoded)
		{
			using SHA256 sHA = SHA256.Create();
			byte[] array = sHA.ComputeHash(Encoding.UTF8.GetBytes(url));
			for (int i = 0; i < 32; i++)
			{
				if (array[i] != (byte)(encoded[i] ^ _mk[i % _mk.Length]))
				{
					return false;
				}
			}
			return true;
		}

		[HarmonyPatch(typeof(Texts), "GetText")]
		[HarmonyPrefix]
		private static bool GetTextPrefix(string _id, string _type, ref string __result)
		{
			__result = "";
			if ((Object)(object)Globals.Instance == (Object)null || (Object)(object)GameManager.Instance == (Object)null || !GameManager.Instance.PrefsLoaded)
			{
				__result = "";
				return false;
			}
			string text = _id.Replace(" ", "").ToLower();
			if (!(text != ""))
			{
				__result = "";
				return false;
			}
			if (TextStrings != null && TextStrings.ContainsKey(selectedLanguage))
			{
				if (_type != "")
				{
					text = _type.ToLower() + "_" + text.ToLower();
				}
				if (TextStrings[selectedLanguage].ContainsKey(text))
				{
					string text2 = TextStrings[selectedLanguage][text];
					if (text2 != "")
					{
						__result = text2;
						return false;
					}
				}
			}
			return true;
		}

		[HarmonyPatch(typeof(Texts), "LoadTranslationText")]
		[HarmonyPostfix]
		private static void LoadTranslationTextPostfix(string type)
		{
			if (tips.Count > 0)
			{
				Texts.Instance.TipsList.Clear();
				Texts.Instance.TipsList.AddRange(tips);
			}
		}

		[HarmonyPatch(typeof(Texts), "LoadTranslationText")]
		[HarmonyPrefix]
		private static void LoadTranslationTextPrefix(string type)
		{
			try
			{
				LoadTranslationTextPrefixImpl(type);
			}
			catch (Exception ex)
			{
				Log.LogError((object)("LoadTranslationTextPrefix error: " + ex.Message));
			}
		}

		private static void LoadTranslationTextPrefixImpl(string type)
		{
			if (!(selectedLanguage != "") || !(translationsDir != ""))
			{
				return;
			}
			string text = "";
			string[] array = null;
			switch (type.ToLower())
			{
			case "":
				text = Path.Combine(translationsDir, selectedLanguage + ".txt");
				if (File.Exists(text))
				{
					array = File.ReadAllLines(text);
				}
				break;
			case "keynotes":
				text = Path.Combine(translationsDir, selectedLanguage + "_keynotes.txt");
				if (File.Exists(text))
				{
					array = File.ReadAllLines(text);
				}
				break;
			case "traits":
				text = Path.Combine(translationsDir, selectedLanguage + "_traits.txt");
				if (File.Exists(text))
				{
					array = File.ReadAllLines(text);
				}
				break;
			case "auracurse":
				text = Path.Combine(translationsDir, selectedLanguage + "_auracurse.txt");
				if (File.Exists(text))
				{
					array = File.ReadAllLines(text);
				}
				break;
			case "events":
				text = Path.Combine(translationsDir, selectedLanguage + "_events.txt");
				if (File.Exists(text))
				{
					array = File.ReadAllLines(text);
				}
				break;
			case "nodes":
				text = Path.Combine(translationsDir, selectedLanguage + "_nodes.txt");
				if (File.Exists(text))
				{
					array = File.ReadAllLines(text);
				}
				break;
			case "cards":
				text = Path.Combine(translationsDir, selectedLanguage + "_cards.txt");
				if (File.Exists(text))
				{
					array = File.ReadAllLines(text);
				}
				break;
			case "fluff":
				text = Path.Combine(translationsDir, selectedLanguage + "_cardsfluff.txt");
				if (File.Exists(text))
				{
					array = File.ReadAllLines(text);
				}
				break;
			case "class":
				text = Path.Combine(translationsDir, selectedLanguage + "_class.txt");
				if (File.Exists(text))
				{
					array = File.ReadAllLines(text);
				}
				break;
			case "monsters":
				text = Path.Combine(translationsDir, selectedLanguage + "_monsters.txt");
				if (File.Exists(text))
				{
					array = File.ReadAllLines(text);
				}
				break;
			case "requirements":
				text = Path.Combine(translationsDir, selectedLanguage + "_requirements.txt");
				if (File.Exists(text))
				{
					array = File.ReadAllLines(text);
				}
				break;
			case "tips":
				text = Path.Combine(translationsDir, selectedLanguage + "_tips.txt");
				if (File.Exists(text))
				{
					array = File.ReadAllLines(text);
				}
				break;
			}
			if (array == null)
			{
				return;
			}
			List<string> list = new List<string>(array);
			int num = 0;
			StringBuilder stringBuilder = new StringBuilder();
			StringBuilder stringBuilder2 = new StringBuilder();
			for (int i = 0; i < list.Count; i++)
			{
				string text2 = list[i];
				if (text2 == "" || text2[0] == '#')
				{
					continue;
				}
				string[] array2 = text2.Trim().Split(new char[1] { '=' }, 2);
				if (array2 == null || array2.Length < 2)
				{
					continue;
				}
				array2[0] = array2[0].Trim().ToLower();
				array2[1] = Functions.SplitString("//", array2[1])[0].Trim();
				switch (type.ToLower())
				{
				case "keynotes":
					stringBuilder.Append("keynotes_");
					break;
				case "traits":
					stringBuilder.Append("traits_");
					break;
				case "auracurse":
					stringBuilder.Append("auracurse_");
					break;
				case "events":
					stringBuilder.Append("events_");
					break;
				case "nodes":
					stringBuilder.Append("nodes_");
					break;
				case "cards":
				case "fluff":
					stringBuilder.Append("cards_");
					break;
				case "class":
					stringBuilder.Append("class_");
					break;
				case "monsters":
					stringBuilder.Append("monsters_");
					break;
				case "requirements":
					stringBuilder.Append("requirements_");
					break;
				case "tips":
					stringBuilder.Append("tips_");
					break;
				}
				stringBuilder.Append(array2[0]);
				if (TextStrings[selectedLanguage].ContainsKey(stringBuilder.ToString()))
				{
					TextStrings[selectedLanguage][stringBuilder.ToString()] = array2[1];
				}
				else
				{
					TextStrings[selectedLanguage].Add(stringBuilder.ToString(), array2[1]);
				}
				if (type.ToLower() == "tips")
				{
					tips.Add(array2[1]);
				}
				bool flag = true;
				if (type == "")
				{
					if (array2[1].StartsWith("rptd_", StringComparison.OrdinalIgnoreCase))
					{
						stringBuilder2.Append(array2[1].Substring(5).ToLower());
						if (TextStrings[selectedLanguage].TryGetValue(stringBuilder2.ToString(), out string value))
						{
							TextStrings[selectedLanguage][stringBuilder.ToString()] = value;
						}
						flag = false;
						stringBuilder2.Clear();
					}
				}
				else if (type.ToLower() == "events")
				{
					if (array2[1].StartsWith("rptd_", StringComparison.OrdinalIgnoreCase))
					{
						stringBuilder2.Append("events_");
						stringBuilder2.Append(array2[1].Substring(5).ToLower());
						if (TextStrings[selectedLanguage].TryGetValue(stringBuilder2.ToString(), out string value2))
						{
							TextStrings[selectedLanguage][stringBuilder.ToString()] = value2;
						}
						flag = false;
						stringBuilder2.Clear();
					}
				}
				else if (type.ToLower() == "cards")
				{
					if (array2[1].StartsWith("rptd_", StringComparison.OrdinalIgnoreCase))
					{
						stringBuilder2.Append("cards_");
						stringBuilder2.Append(array2[1].Substring(5).ToLower());
						if (TextStrings[selectedLanguage].TryGetValue(stringBuilder2.ToString(), out string value3))
						{
							TextStrings[selectedLanguage][stringBuilder.ToString()] = value3;
						}
						flag = false;
						stringBuilder2.Clear();
					}
				}
				else if (type.ToLower() == "monsters" && array2[1].StartsWith("rptd_", StringComparison.OrdinalIgnoreCase))
				{
					stringBuilder2.Append("monsters_");
					stringBuilder2.Append(array2[1].Substring(5).ToLower());
					if (TextStrings[selectedLanguage].TryGetValue(stringBuilder2.ToString(), out string value4))
					{
						TextStrings[selectedLanguage][stringBuilder.ToString()] = value4;
					}
					flag = false;
					stringBuilder2.Clear();
				}
				if (flag)
				{
					string text3 = Regex.Replace(Regex.Replace(array2[1], "<(.*?)>", ""), "\\s+", " ");
					num += text3.Split(new char[1] { ' ' }).Length;
				}
				stringBuilder.Clear();
			}
		}
	}
	public static class PluginInfo
	{
		public const string PLUGIN_GUID = "ATOKoreanMod";

		public const string PLUGIN_NAME = "ATOKoreanMod";

		public const string PLUGIN_VERSION = "2026.5.16";
	}
}