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 CursedUITheme v1.0.0
CursedUI.dll
Decompiled 9 months agousing System; using System.Collections; using System.Collections.Generic; using System.Diagnostics; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.Versioning; using System.Security; using System.Security.Permissions; using System.Text.RegularExpressions; using BepInEx; using BepInEx.Logging; using HarmonyLib; using Microsoft.CodeAnalysis; using TMPro; using UnityEngine; 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(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")] [assembly: IgnoresAccessChecksTo("")] [assembly: AssemblyCompany("Omniscye")] [assembly: AssemblyConfiguration("Debug")] [assembly: AssemblyFileVersion("1.0.0.0")] [assembly: AssemblyInformationalVersion("1.0.0")] [assembly: AssemblyProduct("CursedUI")] [assembly: AssemblyTitle("CursedUI")] [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.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 Repo.DarkMode { public static class DarkModeConfig { public static bool Enabled = true; public static bool CursedText = true; public static Color TextColor = new Color(0.85f, 0.1f, 0.1f, 1f); public static Color BackgroundColor = new Color(0f, 0f, 0f, 0.6f); public static Vector2 BackgroundMinSize = new Vector2(600f, 300f); public static float MaxLengthInflation = 1.15f; public static int AutoFitMin = 14; public static int AutoFitMax = 36; public static ColorBlock ButtonTint; public static readonly Dictionary<string, string> CursedMapPreferred; public static readonly Dictionary<string, string> CursedMapCompact; public static bool HideTextUntilThemed; public static int PreRenderSweeps; public static int MaxPerSweep; static DarkModeConfig() { //IL_0020: Unknown result type (might be due to invalid IL or missing references) //IL_0025: Unknown result type (might be due to invalid IL or missing references) //IL_003e: Unknown result type (might be due to invalid IL or missing references) //IL_0043: Unknown result type (might be due to invalid IL or missing references) //IL_0052: Unknown result type (might be due to invalid IL or missing references) //IL_0057: Unknown result type (might be due to invalid IL or missing references) //IL_0076: Unknown result type (might be due to invalid IL or missing references) //IL_0092: 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_00d4: Unknown result type (might be due to invalid IL or missing references) //IL_00f5: Unknown result type (might be due to invalid IL or missing references) //IL_0116: Unknown result type (might be due to invalid IL or missing references) //IL_013b: Unknown result type (might be due to invalid IL or missing references) //IL_013c: Unknown result type (might be due to invalid IL or missing references) ColorBlock buttonTint = default(ColorBlock); ((ColorBlock)(ref buttonTint)).normalColor = new Color(0.25f, 0f, 0f, 1f); ((ColorBlock)(ref buttonTint)).highlightedColor = new Color(0.5f, 0.05f, 0.05f, 1f); ((ColorBlock)(ref buttonTint)).pressedColor = new Color(0.7f, 0.1f, 0.1f, 1f); ((ColorBlock)(ref buttonTint)).selectedColor = new Color(0.4f, 0.05f, 0.05f, 1f); ((ColorBlock)(ref buttonTint)).disabledColor = new Color(0.2f, 0.2f, 0.2f, 0.6f); ((ColorBlock)(ref buttonTint)).colorMultiplier = 1f; ((ColorBlock)(ref buttonTint)).fadeDuration = 0.05f; ButtonTint = buttonTint; CursedMapPreferred = new Dictionary<string, string>(StringComparer.OrdinalIgnoreCase) { { "play", "SUFFER" }, { "start", "AWAKEN THE PAIN" }, { "continue", "CONTINUE THE TORMENT" }, { "load", "SUMMON RELICS" }, { "new", "FRESH SACRIFICE" }, { "options", "HEXES" }, { "settings", "RITUALS" }, { "graphics", "VISIONS" }, { "audio", "WHISPERS" }, { "sound", "ECHOES" }, { "controls", "BINDINGS" }, { "keybinds", "BLOOD OATHS" }, { "resume", "UNPAUSE THE CURSE" }, { "pause", "BREACH" }, { "quit", "EMBRACE THE VOID" }, { "exit", "EXILE SELF" }, { "back", "RETREAT" }, { "ok", "SO BE IT" }, { "confirm", "SEAL FATE" }, { "cancel", "DEFY FATE" }, { "apply", "INSCRIBE SIGIL" }, { "multiplayer", "COVEN" }, { "lobby", "CIRCLE" } }; CursedMapCompact = new Dictionary<string, string>(StringComparer.OrdinalIgnoreCase) { { "play", "SLAY" }, { "start", "RITES" }, { "continue", "ENDURE" }, { "load", "RAISE" }, { "new", "HEX" }, { "options", "OMENS" }, { "settings", "RITUALS" }, { "graphics", "VISIONS" }, { "audio", "ECHOES" }, { "sound", "ECHO" }, { "controls", "BINDINGS" }, { "keybinds", "OATHS" }, { "resume", "RETURN" }, { "pause", "HUSH" }, { "quit", "VOID" }, { "exit", "EXILE" }, { "back", "FLEE" }, { "ok", "AYE" }, { "confirm", "SEAL" }, { "cancel", "DENY" }, { "apply", "BRAND" }, { "multiplayer", "COVEN" }, { "lobby", "CIRCLE" } }; HideTextUntilThemed = true; PreRenderSweeps = 12; MaxPerSweep = 4096; } } public static class DarkModePatcher { private static Harmony _harmony; internal static readonly HashSet<int> ThemedTexts = new HashSet<int>(4096); private static readonly Dictionary<int, string> OriginalTextCache = new Dictionary<int, string>(4096); private static readonly Dictionary<char, char> GlyphMap = new Dictionary<char, char> { { 'A', 'Å' }, { 'a', 'ᵃ' }, { 'E', 'Ė' }, { 'e', 'ė' }, { 'I', 'Į' }, { 'i', 'į' }, { 'O', 'Ø' }, { 'o', 'ø' }, { 'U', 'Ů' }, { 'u', 'ů' }, { 'Y', 'Ɏ' }, { 'y', 'ɏ' }, { 'S', 'Ƨ' }, { 's', 'ʂ' }, { 'T', 'Ŧ' }, { 't', 'ŧ' }, { 'R', 'Я' }, { 'N', 'И' }, { 'H', 'Ħ' }, { 'h', 'ħ' }, { 'C', 'Ɔ' }, { 'c', 'ƈ' }, { 'D', 'Đ' }, { 'd', 'đ' }, { 'L', 'Ł' }, { 'l', 'ł' }, { 'P', 'Ᵽ' }, { 'p', 'ᵖ' }, { 'V', '∨' }, { 'M', 'Ϻ' }, { 'B', 'Ƀ' }, { 'b', 'Ь' }, { 'G', 'Ǥ' }, { 'g', 'ɠ' }, { 'K', 'Ҝ' }, { 'k', 'ʞ' }, { 'X', '✕' } }; [RuntimeInitializeOnLoadMethod(/*Could not decode attribute arguments.*/)] private static void EarlyInit() { //IL_0014: Unknown result type (might be due to invalid IL or missing references) //IL_001e: Expected O, but got Unknown try { if (_harmony == null) { _harmony = new Harmony("repo.darkmode.patch"); _harmony.PatchAll(typeof(DarkModePatcher).Assembly); } CreateRunner(); RenderCatcher.Subscribe(); Debug.Log((object)"[Repo.DarkMode] EarlyInit complete (text interception armed)"); } catch (Exception arg) { Debug.LogError((object)$"[Repo.DarkMode] EarlyInit failed: {arg}"); } } [RuntimeInitializeOnLoadMethod(/*Could not decode attribute arguments.*/)] public static void Init() { //IL_0014: Unknown result type (might be due to invalid IL or missing references) //IL_001e: Expected O, but got Unknown try { if (_harmony == null) { _harmony = new Harmony("repo.darkmode.patch"); _harmony.PatchAll(typeof(DarkModePatcher).Assembly); } if (!Object.op_Implicit((Object)(object)GameObject.Find("Repo.DarkMode.Runner"))) { CreateRunner(); } ThemedTexts.Clear(); OriginalTextCache.Clear(); RenderCatcher.Subscribe(); Debug.Log((object)"[Repo.DarkMode] Harmony patches applied & runner active"); } catch (Exception arg) { Debug.LogError((object)$"[Repo.DarkMode] Failed to initialize: {arg}"); } } private static void CreateRunner() { //IL_000c: Unknown result type (might be due to invalid IL or missing references) //IL_0012: Expected O, but got Unknown GameObject val = new GameObject("Repo.DarkMode.Runner"); Object.DontDestroyOnLoad((Object)(object)val); DarkModeRunner runner = val.AddComponent<DarkModeRunner>(); runner.ApplyNowAndDelayed(); SceneManager.activeSceneChanged += delegate { ThemedTexts.Clear(); OriginalTextCache.Clear(); runner.ApplyNowAndDelayed(); RenderCatcher.Subscribe(); }; SceneManager.sceneLoaded += delegate { ThemedTexts.Clear(); OriginalTextCache.Clear(); runner.ApplyNowAndDelayed(); RenderCatcher.Subscribe(); }; } internal static string InterceptTextAssignment(TMP_Text tmpText, string newText) { //IL_004f: Unknown result type (might be due to invalid IL or missing references) if (!DarkModeConfig.Enabled || (Object)(object)tmpText == (Object)null || string.IsNullOrWhiteSpace(newText)) { return newText; } int instanceID = ((Object)tmpText).GetInstanceID(); if (!OriginalTextCache.ContainsKey(instanceID)) { OriginalTextCache[instanceID] = newText; } try { ForceTmpColor(tmpText, DarkModeConfig.TextColor); } catch { } string result = newText; if (DarkModeConfig.CursedText) { result = CurseifySmart(newText); } ThemedTexts.Add(instanceID); return result; } public static void ApplyTheme(Transform root) { //IL_003b: Unknown result type (might be due to invalid IL or missing references) //IL_0040: Unknown result type (might be due to invalid IL or missing references) //IL_0200: Unknown result type (might be due to invalid IL or missing references) //IL_0205: Unknown result type (might be due to invalid IL or missing references) //IL_020e: Unknown result type (might be due to invalid IL or missing references) //IL_0220: Unknown result type (might be due to invalid IL or missing references) //IL_0232: Unknown result type (might be due to invalid IL or missing references) //IL_0244: Unknown result type (might be due to invalid IL or missing references) //IL_0256: Unknown result type (might be due to invalid IL or missing references) //IL_0287: Unknown result type (might be due to invalid IL or missing references) //IL_004e: Unknown result type (might be due to invalid IL or missing references) //IL_0053: Unknown result type (might be due to invalid IL or missing references) //IL_0064: Unknown result type (might be due to invalid IL or missing references) //IL_0069: Unknown result type (might be due to invalid IL or missing references) //IL_013d: Unknown result type (might be due to invalid IL or missing references) //IL_0080: Unknown result type (might be due to invalid IL or missing references) //IL_0085: Unknown result type (might be due to invalid IL or missing references) //IL_00b9: Unknown result type (might be due to invalid IL or missing references) //IL_00eb: Unknown result type (might be due to invalid IL or missing references) if (!DarkModeConfig.Enabled || (Object)(object)root == (Object)null) { return; } Image[] componentsInChildren = ((Component)root).GetComponentsInChildren<Image>(true); foreach (Image val in componentsInChildren) { try { RectTransform rectTransform = ((Graphic)val).rectTransform; bool flag = rectTransform.anchorMin == Vector2.zero && rectTransform.anchorMax == Vector2.one; Rect rect = rectTransform.rect; int num; if (((Rect)(ref rect)).width >= DarkModeConfig.BackgroundMinSize.x) { rect = rectTransform.rect; num = ((((Rect)(ref rect)).height >= DarkModeConfig.BackgroundMinSize.y) ? 1 : 0); } else { num = 0; } bool flag2 = (byte)num != 0; if (flag || flag2) { float num2 = Mathf.Max(DarkModeConfig.BackgroundColor.a, ((Graphic)val).color.a); ((Graphic)val).color = new Color(DarkModeConfig.BackgroundColor.r, DarkModeConfig.BackgroundColor.g, DarkModeConfig.BackgroundColor.b, num2); } } catch { } } TMP_Text[] componentsInChildren2 = ((Component)root).GetComponentsInChildren<TMP_Text>(true); foreach (TMP_Text val2 in componentsInChildren2) { try { if ((Object)(object)val2 == (Object)null) { continue; } ForceTmpColor(val2, DarkModeConfig.TextColor); if (DarkModeConfig.CursedText && !ThemedTexts.Contains(((Object)val2).GetInstanceID())) { string text = val2.text; if (!string.IsNullOrWhiteSpace(text)) { string text2 = CurseifySmart(text); if (!string.Equals(text, text2, StringComparison.Ordinal)) { val2.text = text2; } } } FitToRect(val2); ThemedTexts.Add(((Object)val2).GetInstanceID()); } catch { } } Selectable[] componentsInChildren3 = ((Component)root).GetComponentsInChildren<Selectable>(true); foreach (Selectable val3 in componentsInChildren3) { try { ColorBlock colors = val3.colors; ((ColorBlock)(ref colors)).normalColor = ((ColorBlock)(ref DarkModeConfig.ButtonTint)).normalColor; ((ColorBlock)(ref colors)).highlightedColor = ((ColorBlock)(ref DarkModeConfig.ButtonTint)).highlightedColor; ((ColorBlock)(ref colors)).pressedColor = ((ColorBlock)(ref DarkModeConfig.ButtonTint)).pressedColor; ((ColorBlock)(ref colors)).selectedColor = ((ColorBlock)(ref DarkModeConfig.ButtonTint)).selectedColor; ((ColorBlock)(ref colors)).disabledColor = ((ColorBlock)(ref DarkModeConfig.ButtonTint)).disabledColor; ((ColorBlock)(ref colors)).colorMultiplier = ((ColorBlock)(ref DarkModeConfig.ButtonTint)).colorMultiplier; ((ColorBlock)(ref colors)).fadeDuration = ((ColorBlock)(ref DarkModeConfig.ButtonTint)).fadeDuration; val3.colors = colors; } catch { } } } private static void ForceTmpColor(TMP_Text tmp, Color c) { //IL_000a: Unknown result type (might be due to invalid IL or missing references) //IL_0010: Unknown result type (might be due to invalid IL or missing references) //IL_0016: Unknown result type (might be due to invalid IL or missing references) //IL_0021: Unknown result type (might be due to invalid IL or missing references) //IL_005e: Unknown result type (might be due to invalid IL or missing references) //IL_0064: Unknown result type (might be due to invalid IL or missing references) //IL_006a: Unknown result type (might be due to invalid IL or missing references) //IL_0075: Unknown result type (might be due to invalid IL or missing references) //IL_00b7: Unknown result type (might be due to invalid IL or missing references) tmp.enableVertexGradient = false; ((Graphic)tmp).color = new Color(c.r, c.g, c.b, 1f); tmp.overrideColorTags = true; try { Material fontMaterial = tmp.fontMaterial; if ((Object)(object)fontMaterial != (Object)null && fontMaterial.HasProperty(ShaderUtilities.ID_FaceColor)) { fontMaterial.SetColor(ShaderUtilities.ID_FaceColor, new Color(c.r, c.g, c.b, 1f)); } if ((Object)(object)fontMaterial != (Object)null && fontMaterial.HasProperty(ShaderUtilities.ID_OutlineColor)) { fontMaterial.SetColor(ShaderUtilities.ID_OutlineColor, new Color(0f, 0f, 0f, 0.85f)); if (fontMaterial.HasProperty(ShaderUtilities.ID_OutlineWidth)) { fontMaterial.SetFloat(ShaderUtilities.ID_OutlineWidth, Mathf.Max(0.1f, fontMaterial.GetFloat(ShaderUtilities.ID_OutlineWidth))); } } } catch { } } private static void FitToRect(TMP_Text tmp) { //IL_003b: Unknown result type (might be due to invalid IL or missing references) //IL_0040: Unknown result type (might be due to invalid IL or missing references) tmp.enableWordWrapping = true; tmp.overflowMode = (TextOverflowModes)1; RectTransform rectTransform = tmp.rectTransform; if (!Object.op_Implicit((Object)(object)rectTransform)) { return; } tmp.ForceMeshUpdate(false, false); float preferredWidth = tmp.preferredWidth; Rect rect = rectTransform.rect; float num = Mathf.Abs(((Rect)(ref rect)).width); if (num > 1f && preferredWidth > num * 1.02f) { tmp.enableAutoSizing = true; if (tmp.fontSizeMax <= 0f) { tmp.fontSizeMax = DarkModeConfig.AutoFitMax; } if (tmp.fontSizeMin <= 0f) { tmp.fontSizeMin = DarkModeConfig.AutoFitMin; } tmp.ForceMeshUpdate(false, false); } } private static string CurseifySmart(string s) { string text = s; foreach (KeyValuePair<string, string> item in DarkModeConfig.CursedMapPreferred) { text = ReplaceWordBoundary(text, item.Key, item.Value, allowInflation: true); } foreach (KeyValuePair<string, string> item2 in DarkModeConfig.CursedMapPreferred) { text = ReplaceContainsLengthAware(text, item2.Key, item2.Value); } foreach (KeyValuePair<string, string> item3 in DarkModeConfig.CursedMapCompact) { text = ReplaceContainsLengthAware(text, item3.Key, item3.Value); } return CorruptLetters(text); } private static string ReplaceWordBoundary(string input, string key, string val, bool allowInflation) { string val2 = val; return Regex.Replace(input, "\\b" + Regex.Escape(key) + "\\b", (Match m) => allowInflation ? val2 : ((val2.Length <= (int)((float)m.Value.Length * DarkModeConfig.MaxLengthInflation)) ? val2 : m.Value), RegexOptions.IgnoreCase); } private static string ReplaceContainsLengthAware(string input, string key, string val) { int num = 0; while (num < input.Length) { int num2 = input.IndexOf(key, num, StringComparison.OrdinalIgnoreCase); if (num2 < 0) { break; } int length = key.Length; if (val.Length <= Mathf.CeilToInt((float)length * DarkModeConfig.MaxLengthInflation)) { string text = input.Substring(0, num2); string text2 = input; int num3 = num2 + length; input = text + val + text2.Substring(num3, text2.Length - num3); num = num2 + val.Length; } else { num = num2 + length; } } return input; } private static string CorruptLetters(string s) { List<char> list = new List<char>(s.Length); bool flag = false; foreach (char c in s) { switch (c) { case '<': flag = true; list.Add(c); continue; case '>': flag = false; list.Add(c); continue; } if (!flag && GlyphMap.TryGetValue(c, out var value)) { list.Add(value); } else { list.Add(c); } } return new string(list.ToArray()); } } internal sealed class DarkModeRunner : MonoBehaviour { [CompilerGenerated] private sealed class <DelayedApply>d__1 : IEnumerator<object>, IEnumerator, IDisposable { private int <>1__state; private object <>2__current; public float delay; public DarkModeRunner <>4__this; object IEnumerator<object>.Current { [DebuggerHidden] get { return <>2__current; } } object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } [DebuggerHidden] public <DelayedApply>d__1(int <>1__state) { this.<>1__state = <>1__state; } [DebuggerHidden] void IDisposable.Dispose() { <>1__state = -2; } private bool MoveNext() { //IL_0027: Unknown result type (might be due to invalid IL or missing references) //IL_0031: Expected O, but got Unknown switch (<>1__state) { default: return false; case 0: <>1__state = -1; <>2__current = (object)new WaitForSecondsRealtime(delay); <>1__state = 1; return true; case 1: <>1__state = -1; <>4__this.ApplyAllCanvases(); return false; } } bool IEnumerator.MoveNext() { //ILSpy generated this explicit interface implementation from .override directive in MoveNext return this.MoveNext(); } [DebuggerHidden] void IEnumerator.Reset() { throw new NotSupportedException(); } } public void ApplyNowAndDelayed() { ApplyAllCanvases(); ((MonoBehaviour)this).StopAllCoroutines(); ((MonoBehaviour)this).StartCoroutine(DelayedApply(0.05f)); ((MonoBehaviour)this).StartCoroutine(DelayedApply(0.1f)); ((MonoBehaviour)this).StartCoroutine(DelayedApply(0.25f)); ((MonoBehaviour)this).StartCoroutine(DelayedApply(0.5f)); ((MonoBehaviour)this).StartCoroutine(DelayedApply(1f)); } [IteratorStateMachine(typeof(<DelayedApply>d__1))] private IEnumerator DelayedApply(float delay) { //yield-return decompiler failed: Unexpected instruction in Iterator.Dispose() return new <DelayedApply>d__1(0) { <>4__this = this, delay = delay }; } private void ApplyAllCanvases() { if (!DarkModeConfig.Enabled) { return; } Canvas[] array = Object.FindObjectsOfType<Canvas>(true); foreach (Canvas val in array) { try { DarkModePatcher.ApplyTheme(((Component)val).transform); } catch { } } } } internal static class RenderCatcher { [CompilerGenerated] private static class <>O { public static WillRenderCanvases <0>__OnWillRenderCanvases; } private static bool _subscribed; private static int _sweepsRemaining; public static void Subscribe() { //IL_002c: Unknown result type (might be due to invalid IL or missing references) //IL_0031: Unknown result type (might be due to invalid IL or missing references) //IL_0037: Expected O, but got Unknown _sweepsRemaining = Mathf.Max(1, DarkModeConfig.PreRenderSweeps); if (!_subscribed) { object obj = <>O.<0>__OnWillRenderCanvases; if (obj == null) { WillRenderCanvases val = OnWillRenderCanvases; <>O.<0>__OnWillRenderCanvases = val; obj = (object)val; } Canvas.willRenderCanvases += (WillRenderCanvases)obj; _subscribed = true; } } private static void Unsubscribe() { //IL_001f: Unknown result type (might be due to invalid IL or missing references) //IL_0024: Unknown result type (might be due to invalid IL or missing references) //IL_002a: Expected O, but got Unknown if (_subscribed) { object obj = <>O.<0>__OnWillRenderCanvases; if (obj == null) { WillRenderCanvases val = OnWillRenderCanvases; <>O.<0>__OnWillRenderCanvases = val; obj = (object)val; } Canvas.willRenderCanvases -= (WillRenderCanvases)obj; _subscribed = false; } } private static void OnWillRenderCanvases() { //IL_006f: Unknown result type (might be due to invalid IL or missing references) //IL_0074: Unknown result type (might be due to invalid IL or missing references) //IL_0076: Unknown result type (might be due to invalid IL or missing references) //IL_008c: Unknown result type (might be due to invalid IL or missing references) //IL_0093: Unknown result type (might be due to invalid IL or missing references) //IL_009a: Unknown result type (might be due to invalid IL or missing references) //IL_00a6: Unknown result type (might be due to invalid IL or missing references) try { if (!DarkModeConfig.Enabled) { return; } if (DarkModeConfig.HideTextUntilThemed) { int maxPerSweep = DarkModeConfig.MaxPerSweep; TMP_Text[] array = Object.FindObjectsOfType<TMP_Text>(true); for (int i = 0; i < array.Length; i++) { if (maxPerSweep-- <= 0) { break; } TMP_Text val = array[i]; if ((Object)(object)val == (Object)null) { continue; } int instanceID = ((Object)val).GetInstanceID(); if (!DarkModePatcher.ThemedTexts.Contains(instanceID)) { Color color = ((Graphic)val).color; if (color.a > 0f) { ((Graphic)val).color = new Color(color.r, color.g, color.b, 0f); } } } } int maxPerSweep2 = DarkModeConfig.MaxPerSweep; Canvas[] array2 = Object.FindObjectsOfType<Canvas>(true); foreach (Canvas val2 in array2) { if (maxPerSweep2-- <= 0) { break; } try { DarkModePatcher.ApplyTheme(((Component)val2).transform); } catch { } } } finally { _sweepsRemaining = Mathf.Max(0, _sweepsRemaining - 1); if (_sweepsRemaining <= 0) { Unsubscribe(); } } } } [HarmonyPatch(/*Could not decode attribute arguments.*/)] internal static class TMP_Text_TextSetter_Patch { private static bool Prefix(TMP_Text __instance, ref string value) { try { value = DarkModePatcher.InterceptTextAssignment(__instance, value); return true; } catch (Exception arg) { Debug.LogError((object)$"[Repo.DarkMode] TMP_Text setter patch error: {arg}"); return true; } } } [HarmonyPatch] internal static class MenuPage_PageStateSet_Patch { private static MethodBase TargetMethod() { Type type = AccessTools.TypeByName("MenuPage"); if (type == null) { return null; } return AccessTools.Method(type, "PageStateSet", (Type[])null, (Type[])null); } private static void Postfix(object __instance) { try { Type type = __instance.GetType(); FieldInfo fieldInfo = AccessTools.Field(type, "currentPageState"); if (fieldInfo == null) { return; } string text = fieldInfo.GetValue(__instance)?.ToString() ?? string.Empty; if (text == "Active" || text == "Activating") { Component val = (Component)((__instance is Component) ? __instance : null); if (val != null) { DarkModePatcher.ApplyTheme(val.transform); } } } catch (Exception arg) { Debug.LogError((object)$"[Repo.DarkMode] MenuPage_PageStateSet Postfix error: {arg}"); } } } [HarmonyPatch] internal static class MenuManager_OpenMenu_Patch { private static MethodBase TargetMethod() { Type type = AccessTools.TypeByName("MenuManager"); if (type == null) { return null; } return AccessTools.Method(type, "PageOpen", (Type[])null, (Type[])null) ?? AccessTools.Method(type, "OpenMenu", (Type[])null, (Type[])null) ?? AccessTools.Method(type, "PageReactivatePageUnderThisPage", (Type[])null, (Type[])null) ?? AccessTools.Method(type, "MenuEffectPageIntro", (Type[])null, (Type[])null); } private static void Postfix(object __instance) { try { Component val = (Component)((__instance is Component) ? __instance : null); if (val != null) { DarkModePatcher.ApplyTheme(val.transform); } } catch { } } } } namespace CursedUI { [BepInPlugin("Omniscye.CursedUI", "CursedUI", "1.0")] public class CursedUI : BaseUnityPlugin { internal static CursedUI Instance { get; private set; } internal static ManualLogSource Logger => Instance._logger; private ManualLogSource _logger => ((BaseUnityPlugin)this).Logger; internal Harmony? Harmony { get; set; } private void Awake() { Instance = this; ((Component)this).gameObject.transform.parent = null; ((Object)((Component)this).gameObject).hideFlags = (HideFlags)61; Patch(); Logger.LogInfo((object)$"{((BaseUnityPlugin)this).Info.Metadata.GUID} v{((BaseUnityPlugin)this).Info.Metadata.Version} has loaded!"); } internal void Patch() { //IL_001a: Unknown result type (might be due to invalid IL or missing references) //IL_001f: Unknown result type (might be due to invalid IL or missing references) //IL_0021: Expected O, but got Unknown //IL_0026: Expected O, but got Unknown if (Harmony == null) { Harmony val = new Harmony(((BaseUnityPlugin)this).Info.Metadata.GUID); Harmony val2 = val; Harmony = val; } Harmony.PatchAll(); } internal void Unpatch() { Harmony? harmony = Harmony; if (harmony != null) { harmony.UnpatchSelf(); } } private void Update() { } } }