Decompiled source of ProperKorean v1.3.0

ProperKorean.dll

Decompiled 2 weeks ago
using System;
using System.CodeDom.Compiler;
using System.Collections.Generic;
using System.ComponentModel;
using System.Diagnostics;
using System.Globalization;
using System.Reflection;
using System.Resources;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using System.Text;
using BepInEx;
using BepInEx.Logging;
using Microsoft.CodeAnalysis;
using Newtonsoft.Json;
using Newtonsoft.Json.Linq;
using On.RoR2.UI;
using ProperKorean.Properties;
using R2API.Utils;
using RoR2;
using RoR2.UI;
using TMPro;
using UnityEngine;
using UnityEngine.TextCore;

[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("ProperKorean")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0+1192fea8f36bad9652b7db7e1f444d8b70524fa5")]
[assembly: AssemblyProduct("ProperKorean")]
[assembly: AssemblyTitle("ProperKorean")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.0.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.Module, AllowMultiple = false, Inherited = false)]
	internal sealed class RefSafetyRulesAttribute : Attribute
	{
		public readonly int Version;

		public RefSafetyRulesAttribute(int P_0)
		{
			Version = P_0;
		}
	}
}
namespace ProperKorean
{
	internal static class Log
	{
		internal static ManualLogSource _logSource;

		internal static void Init(ManualLogSource logSource)
		{
			_logSource = logSource;
		}

		internal static void LogDebug(object data)
		{
			_logSource.LogDebug(data);
		}

		internal static void LogError(object data)
		{
			_logSource.LogError(data);
		}

		internal static void LogFatal(object data)
		{
			_logSource.LogFatal(data);
		}

		internal static void LogInfo(object data)
		{
			_logSource.LogInfo(data);
		}

		internal static void LogMessage(object data)
		{
			_logSource.LogMessage(data);
		}

		internal static void LogWarning(object data)
		{
			_logSource.LogWarning(data);
		}
	}
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	[BepInPlugin("DVRP.ProperKorean", "ProperKorean", "1.3.0")]
	[NetworkCompatibility(/*Could not decode attribute arguments.*/)]
	public class ProperKorean : BaseUnityPlugin
	{
		[CompilerGenerated]
		private static class <>O
		{
			public static hook_OnCurrentLanguageChanged <0>__HGTextMeshProUGUI_OnCurrentLanguageChanged;
		}

		public const string PluginGUID = "DVRP.ProperKorean";

		public const string PluginAuthor = "DVRP";

		public const string PluginName = "ProperKorean";

		public const string PluginVersion = "1.3.0";

		private static AssetBundle properBundle = AssetBundle.LoadFromMemory(Resources.properkorean);

		private static TMP_FontAsset properFont;

		private void Awake()
		{
			//IL_0031: Unknown result type (might be due to invalid IL or missing references)
			//IL_0036: Unknown result type (might be due to invalid IL or missing references)
			//IL_003c: Expected O, but got Unknown
			Log.Init(((BaseUnityPlugin)this).Logger);
			properFont = properBundle.LoadAsset<TMP_FontAsset>("Assets/properkorean/NotoSansCJKsc-Regular SDF (Korean).asset");
			object obj = <>O.<0>__HGTextMeshProUGUI_OnCurrentLanguageChanged;
			if (obj == null)
			{
				hook_OnCurrentLanguageChanged val = HGTextMeshProUGUI_OnCurrentLanguageChanged;
				<>O.<0>__HGTextMeshProUGUI_OnCurrentLanguageChanged = val;
				obj = (object)val;
			}
			HGTextMeshProUGUI.OnCurrentLanguageChanged += (hook_OnCurrentLanguageChanged)obj;
		}

		private static void FixLocalization()
		{
			JObject val = JObject.Parse(Encoding.UTF8.GetString(Resources.output_korean));
			Dictionary<string, string> dictionary = JsonConvert.DeserializeObject<Dictionary<string, string>>(((object)val["strings"]).ToString());
			foreach (KeyValuePair<string, string> item in dictionary)
			{
				if (Language.currentLanguage.GetLocalizedStringByToken(item.Key) != item.Value)
				{
					Language.currentLanguage.SetStringByToken(item.Key, item.Value);
				}
			}
			Log.LogInfo("ProperKorean :: Fixed localization");
		}

		private static void FixFont()
		{
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			//IL_000b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0041: Unknown result type (might be due to invalid IL or missing references)
			//IL_0046: Unknown result type (might be due to invalid IL or missing references)
			//IL_0054: Unknown result type (might be due to invalid IL or missing references)
			TMP_FontAsset val = LegacyResourcesAPI.LoadAsync<TMP_FontAsset>("TmpFonts/Bombardier/tmpBombDropshadow").WaitForCompletion();
			Glyph val2 = val.glyphTable.Find((Glyph x) => x.index == 95);
			GlyphMetrics metrics = val2.metrics;
			((GlyphMetrics)(ref metrics)).horizontalBearingY = 40f;
			val2.metrics = metrics;
			properFont.fallbackFontAssets.Add(val);
			if (((Object)TMP_Settings.fallbackFontAssets[0]).name != "tmpBombDropshadow")
			{
				TMP_Settings.fallbackFontAssets.Insert(0, val);
			}
			HGTextMeshProUGUI.defaultLanguageFont = properFont;
			Log.LogInfo("ProperKorean :: Fixed font");
		}

		private static void HGTextMeshProUGUI_OnCurrentLanguageChanged(orig_OnCurrentLanguageChanged orig)
		{
			orig.Invoke();
			if (Language.currentLanguageName == "ko")
			{
				FixFont();
				FixLocalization();
			}
		}
	}
}
namespace ProperKorean.Properties
{
	[GeneratedCode("System.Resources.Tools.StronglyTypedResourceBuilder", "17.0.0.0")]
	[DebuggerNonUserCode]
	[CompilerGenerated]
	internal class Resources
	{
		private static ResourceManager resourceMan;

		private static CultureInfo resourceCulture;

		[EditorBrowsable(EditorBrowsableState.Advanced)]
		internal static ResourceManager ResourceManager
		{
			get
			{
				if (resourceMan == null)
				{
					ResourceManager resourceManager = new ResourceManager("ProperKorean.Properties.Resources", typeof(Resources).Assembly);
					resourceMan = resourceManager;
				}
				return resourceMan;
			}
		}

		[EditorBrowsable(EditorBrowsableState.Advanced)]
		internal static CultureInfo Culture
		{
			get
			{
				return resourceCulture;
			}
			set
			{
				resourceCulture = value;
			}
		}

		internal static byte[] output_korean
		{
			get
			{
				object @object = ResourceManager.GetObject("output_korean", resourceCulture);
				return (byte[])@object;
			}
		}

		internal static byte[] properkorean
		{
			get
			{
				object @object = ResourceManager.GetObject("properkorean", resourceCulture);
				return (byte[])@object;
			}
		}

		internal Resources()
		{
		}
	}
}