using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using BepInEx;
using BepInEx.Core.Logging.Interpolation;
using BepInEx.Logging;
using BepInEx.Unity.IL2CPP;
using HarmonyLib;
using Il2CppInterop.Runtime.Injection;
using Il2CppInterop.Runtime.InteropTypes;
using Il2CppInterop.Runtime.InteropTypes.Arrays;
using Microsoft.CodeAnalysis;
using SmolMods.Core;
using UnityEngine;
using UnityEngine.UI;
[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: TargetFramework(".NETCoreApp,Version=v6.0", FrameworkDisplayName = ".NET 6.0")]
[assembly: AssemblyCompany("smolMods.DarkMenus")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0+a3231e664cf7d257a8601fb862a89ade69b41d83")]
[assembly: AssemblyProduct("smolMods.DarkMenus")]
[assembly: AssemblyTitle("smolMods.DarkMenus")]
[assembly: AssemblyVersion("1.0.0.0")]
[module: RefSafetyRules(11)]
namespace Microsoft.CodeAnalysis
{
[CompilerGenerated]
[Embedded]
internal sealed class EmbeddedAttribute : Attribute
{
}
}
namespace System.Runtime.CompilerServices
{
[CompilerGenerated]
[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 SmolMods.DarkMenus
{
internal static class MenuTheme
{
private static readonly Color DarkPaper = new Color(0.11f, 0.11f, 0.13f);
private static readonly Color LightInk = new Color(0.93f, 0.93f, 0.9f);
private static readonly Dictionary<int, (Graphic g, Color original)> Known = new Dictionary<int, (Graphic, Color)>();
private static readonly List<Transform> Panels = new List<Transform>();
private static Transform _mainMenuPanel;
private static GameObject _backdrop;
private static readonly Dictionary<int, bool> OwnershipSkip = new Dictionary<int, bool>();
private static int _colorRootsVersion = -1;
private const float DarkPaperAlpha = 0.31f;
private static readonly Vector3[] CornerBuffer = (Vector3[])(object)new Vector3[4];
internal static void TrackMenu(Transform menuTransform)
{
AddPanel(PanelRootOf(menuTransform));
}
private static void AddPanel(Transform panel)
{
//IL_008b: Unknown result type (might be due to invalid IL or missing references)
//IL_0091: Expected O, but got Unknown
if ((Object)(object)panel == (Object)null)
{
return;
}
for (int num = Panels.Count - 1; num >= 0; num--)
{
if ((Object)(object)Panels[num] == (Object)null)
{
Panels.RemoveAt(num);
}
}
foreach (Transform panel2 in Panels)
{
if ((Object)(object)panel2 == (Object)(object)panel)
{
return;
}
}
Panels.Add(panel);
ManualLogSource logger = Plugin.Logger;
bool flag = default(bool);
BepInExInfoLogInterpolatedStringHandler val = new BepInExInfoLogInterpolatedStringHandler(25, 1, ref flag);
if (flag)
{
((BepInExLogInterpolatedStringHandler)val).AppendLiteral("[theme] tracking panel '");
((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>(((Object)panel).name);
((BepInExLogInterpolatedStringHandler)val).AppendLiteral("'");
}
logger.LogInfo(val);
}
private static void TrackMainMenu()
{
//IL_00cc: Unknown result type (might be due to invalid IL or missing references)
//IL_00d3: Expected O, but got Unknown
try
{
if ((Object)(object)_mainMenuPanel != (Object)null)
{
return;
}
MainMenuManager val = null;
try
{
val = MainMenuManager.instance;
}
catch
{
}
if ((Object)(object)val == (Object)null)
{
return;
}
Transform val2 = null;
try
{
if ((Object)(object)val.titleMenu != (Object)null)
{
val2 = ((Component)val.titleMenu).transform;
}
}
catch
{
}
if ((Object)(object)val2 == (Object)null)
{
try
{
if ((Object)(object)val.settingsMenu != (Object)null)
{
val2 = ((Component)val.settingsMenu).transform;
}
}
catch
{
}
}
if (!((Object)(object)val2 == (Object)null))
{
Canvas componentInParent = ((Component)val2).GetComponentInParent<Canvas>();
if (!((Object)(object)componentInParent == (Object)null))
{
AddPanel(_mainMenuPanel = (((Object)(object)componentInParent.rootCanvas != (Object)null) ? ((Component)componentInParent.rootCanvas).transform : ((Component)componentInParent).transform));
}
}
}
catch (Exception ex)
{
ManualLogSource logger = Plugin.Logger;
bool flag = default(bool);
BepInExWarningLogInterpolatedStringHandler val3 = new BepInExWarningLogInterpolatedStringHandler(30, 1, ref flag);
if (flag)
{
((BepInExLogInterpolatedStringHandler)val3).AppendLiteral("[theme] TrackMainMenu failed: ");
((BepInExLogInterpolatedStringHandler)val3).AppendFormatted<string>(ex.Message);
}
logger.LogWarning(val3);
}
}
private static void EnsureBackdrop(bool enabled)
{
//IL_0133: Unknown result type (might be due to invalid IL or missing references)
//IL_0139: Expected O, but got Unknown
//IL_0059: 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_006f: 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_0081: 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_0096: Unknown result type (might be due to invalid IL or missing references)
//IL_00a0: Unknown result type (might be due to invalid IL or missing references)
//IL_00ca: Unknown result type (might be due to invalid IL or missing references)
//IL_00df: Expected O, but got Unknown
try
{
if ((Object)(object)_mainMenuPanel == (Object)null)
{
_backdrop = null;
return;
}
if (!enabled)
{
if ((Object)(object)_backdrop != (Object)null && _backdrop.activeSelf)
{
_backdrop.SetActive(false);
}
return;
}
if ((Object)(object)_backdrop == (Object)null)
{
GameObject val = new GameObject("BigDarkMenusBackdrop");
val.transform.SetParent(_mainMenuPanel, false);
RectTransform obj = val.AddComponent<RectTransform>();
obj.anchorMin = Vector2.zero;
obj.anchorMax = Vector2.one;
obj.offsetMin = Vector2.zero;
obj.offsetMax = Vector2.zero;
Image obj2 = val.AddComponent<Image>();
((Graphic)obj2).color = new Color(DarkPaper.r, DarkPaper.g, DarkPaper.b, 1f);
((Graphic)obj2).raycastTarget = false;
_backdrop = val;
Plugin.Logger.LogInfo((object)"[theme] main menu backdrop created");
}
if (_backdrop.transform.GetSiblingIndex() != 0)
{
_backdrop.transform.SetSiblingIndex(0);
}
if (!_backdrop.activeSelf)
{
_backdrop.SetActive(true);
}
}
catch (Exception ex)
{
ManualLogSource logger = Plugin.Logger;
bool flag = default(bool);
BepInExWarningLogInterpolatedStringHandler val2 = new BepInExWarningLogInterpolatedStringHandler(25, 1, ref flag);
if (flag)
{
((BepInExLogInterpolatedStringHandler)val2).AppendLiteral("[theme] backdrop failed: ");
((BepInExLogInterpolatedStringHandler)val2).AppendFormatted<string>(ex.Message);
}
logger.LogWarning(val2);
_backdrop = null;
}
}
private static Transform PanelRootOf(Transform t)
{
if ((Object)(object)t == (Object)null)
{
return null;
}
Canvas componentInParent = ((Component)t).GetComponentInParent<Canvas>();
if ((Object)(object)componentInParent == (Object)null)
{
return t;
}
Transform val = (((Object)(object)componentInParent.rootCanvas != (Object)null) ? ((Component)componentInParent.rootCanvas).transform : ((Component)componentInParent).transform);
Transform val2 = t;
while ((Object)(object)val2.parent != (Object)null && (Object)(object)val2.parent != (Object)(object)val)
{
val2 = val2.parent;
}
return val2;
}
internal static void Apply(bool enabled, bool force = true)
{
//IL_0083: Unknown result type (might be due to invalid IL or missing references)
//IL_0089: Expected O, but got Unknown
TrackMainMenu();
EnsureBackdrop(enabled);
if (!enabled)
{
if (Known.Count > 0)
{
RestoreForgotten();
Known.Clear();
}
return;
}
bool flag = default(bool);
for (int num = Panels.Count - 1; num >= 0; num--)
{
Transform val = Panels[num];
if ((Object)(object)val == (Object)null)
{
Panels.RemoveAt(num);
}
else
{
try
{
if (force || ((Component)val).gameObject.activeInHierarchy)
{
ApplyToPanel(val, enabled);
}
}
catch (Exception ex)
{
ManualLogSource logger = Plugin.Logger;
BepInExWarningLogInterpolatedStringHandler val2 = new BepInExWarningLogInterpolatedStringHandler(27, 1, ref flag);
if (flag)
{
((BepInExLogInterpolatedStringHandler)val2).AppendLiteral("[theme] panel pass failed: ");
((BepInExLogInterpolatedStringHandler)val2).AppendFormatted<string>(ex.Message);
}
logger.LogWarning(val2);
}
}
}
}
internal static bool IsInTrackedPanel(Transform t)
{
if ((Object)(object)t == (Object)null)
{
return false;
}
foreach (Transform panel in Panels)
{
if (!((Object)(object)panel == (Object)null) && ((Object)(object)t == (Object)(object)panel || t.IsChildOf(panel)))
{
return true;
}
}
return false;
}
internal static void ApplyToSubtree(Transform root, bool enabled)
{
//IL_001f: Unknown result type (might be due to invalid IL or missing references)
//IL_0025: Expected O, but got Unknown
if ((Object)(object)root == (Object)null)
{
return;
}
try
{
ApplyToPanel(root, enabled);
}
catch (Exception ex)
{
ManualLogSource logger = Plugin.Logger;
bool flag = default(bool);
BepInExWarningLogInterpolatedStringHandler val = new BepInExWarningLogInterpolatedStringHandler(29, 1, ref flag);
if (flag)
{
((BepInExLogInterpolatedStringHandler)val).AppendLiteral("[theme] subtree pass failed: ");
((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>(ex.Message);
}
logger.LogWarning(val);
}
}
private static void ApplyToPanel(Transform panel, bool enabled)
{
//IL_0116: Unknown result type (might be due to invalid IL or missing references)
//IL_011b: Unknown result type (might be due to invalid IL or missing references)
//IL_011d: Unknown result type (might be due to invalid IL or missing references)
//IL_0109: Unknown result type (might be due to invalid IL or missing references)
//IL_010e: Unknown result type (might be due to invalid IL or missing references)
//IL_012b: Unknown result type (might be due to invalid IL or missing references)
//IL_0154: Unknown result type (might be due to invalid IL or missing references)
//IL_0158: Unknown result type (might be due to invalid IL or missing references)
//IL_0150: Unknown result type (might be due to invalid IL or missing references)
//IL_0141: Unknown result type (might be due to invalid IL or missing references)
//IL_0143: Unknown result type (might be due to invalid IL or missing references)
//IL_0148: Unknown result type (might be due to invalid IL or missing references)
//IL_015d: Unknown result type (might be due to invalid IL or missing references)
//IL_0163: Unknown result type (might be due to invalid IL or missing references)
//IL_0165: Unknown result type (might be due to invalid IL or missing references)
//IL_0186: Unknown result type (might be due to invalid IL or missing references)
//IL_018b: Unknown result type (might be due to invalid IL or missing references)
//IL_0179: Unknown result type (might be due to invalid IL or missing references)
//IL_0195: Unknown result type (might be due to invalid IL or missing references)
bool isMainMenu = (Object)(object)_mainMenuPanel != (Object)null && (Object)(object)panel == (Object)(object)_mainMenuPanel;
if (_colorRootsVersion != ModSettingsApi.ColorRootsVersion)
{
_colorRootsVersion = ModSettingsApi.ColorRootsVersion;
OwnershipSkip.Clear();
}
foreach (Graphic componentsInChild in ((Component)panel).GetComponentsInChildren<Graphic>(true))
{
if ((Object)(object)componentsInChild == (Object)null)
{
continue;
}
int instanceID = ((Object)componentsInChild).GetInstanceID();
if (OwnershipSkip.TryGetValue(instanceID, out var value))
{
if (value)
{
Known.Remove(instanceID);
continue;
}
}
else
{
value = HudTintApi.IsHudOwned(componentsInChild) || ModSettingsApi.IsColorManaged(((Component)componentsInChild).transform);
OwnershipSkip[instanceID] = value;
if (value)
{
Known.Remove(instanceID);
continue;
}
}
if (Plugin.IsCursorOwned(componentsInChild) || ((Object)(object)_backdrop != (Object)null && ((Object)((Component)componentsInChild).gameObject).GetInstanceID() == ((Object)_backdrop).GetInstanceID()))
{
continue;
}
Color val;
bool flag;
if (Known.TryGetValue(instanceID, out (Graphic, Color) value2))
{
val = value2.Item2;
flag = true;
}
else
{
val = componentsInChild.color;
if (Saturation(val) >= 0.32f || val.a < 0.05f)
{
continue;
}
if (!IsLogoLettering(componentsInChild))
{
val = RecoverOriginal(val);
}
flag = false;
}
Color val2 = (enabled ? Invert(val, isMainMenu, componentsInChild) : val);
if (flag || !Approximately(val, val2))
{
if (!flag)
{
Known[instanceID] = (componentsInChild, val);
}
if (!Approximately(componentsInChild.color, val2))
{
componentsInChild.color = val2;
}
}
}
}
private static void RestoreForgotten()
{
//IL_0041: Unknown result type (might be due to invalid IL or missing references)
//IL_004d: Unknown result type (might be due to invalid IL or missing references)
//IL_0061: Unknown result type (might be due to invalid IL or missing references)
List<int> list = new List<int>();
foreach (KeyValuePair<int, (Graphic, Color)> item2 in Known)
{
Graphic item = item2.Value.Item1;
if ((Object)(object)item == (Object)null)
{
list.Add(item2.Key);
}
else if (!Approximately(item.color, item2.Value.Item2))
{
item.color = item2.Value.Item2;
}
}
foreach (int item3 in list)
{
Known.Remove(item3);
}
}
private static Color RecoverOriginal(Color c)
{
//IL_0000: Unknown result type (might be due to invalid IL or missing references)
//IL_0001: Unknown result type (might be due to invalid IL or missing references)
//IL_0028: Unknown result type (might be due to invalid IL or missing references)
//IL_0029: Unknown result type (might be due to invalid IL or missing references)
//IL_001c: 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_0050: Unknown result type (might be due to invalid IL or missing references)
//IL_0044: Unknown result type (might be due to invalid IL or missing references)
//IL_004a: Unknown result type (might be due to invalid IL or missing references)
if (IsThemeColor(c, DarkPaper))
{
return new Color(1f, 1f, 1f, c.a);
}
if (IsThemeColor(c, LightInk))
{
return new Color(0.09f, 0.09f, 0.09f, c.a);
}
return c;
}
private static bool IsThemeColor(Color c, Color theme)
{
//IL_0000: Unknown result type (might be due to invalid IL or missing references)
//IL_0006: Unknown result type (might be due to invalid IL or missing references)
//IL_0019: 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_0032: 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)
if (Mathf.Abs(c.r - theme.r) < 0.02f && Mathf.Abs(c.g - theme.g) < 0.02f)
{
return Mathf.Abs(c.b - theme.b) < 0.02f;
}
return false;
}
private static Color Invert(Color c, bool isMainMenu, Graphic g)
{
//IL_0000: 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_0098: Unknown result type (might be due to invalid IL or missing references)
//IL_0062: Unknown result type (might be due to invalid IL or missing references)
//IL_006e: 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_003e: Unknown result type (might be due to invalid IL or missing references)
//IL_0018: Unknown result type (might be due to invalid IL or missing references)
if (Luminance(c) > 0.5f)
{
if (isMainMenu)
{
if (!CoversMostOfScreen(g))
{
return c;
}
return new Color(DarkPaper.r, DarkPaper.g, DarkPaper.b, c.a);
}
return new Color(DarkPaper.r, DarkPaper.g, DarkPaper.b, c.a * 0.31f);
}
return new Color(LightInk.r, LightInk.g, LightInk.b, c.a);
}
private static bool IsLogoLettering(Graphic g)
{
try
{
Image val = ((Il2CppObjectBase)g).TryCast<Image>();
return (Object)(object)val != (Object)null && (Object)(object)val.sprite != (Object)null && ((Object)val.sprite).name == "BigWalkLogo";
}
catch
{
return false;
}
}
private static bool CoversMostOfScreen(Graphic g)
{
try
{
RectTransform component = ((Component)g).GetComponent<RectTransform>();
if ((Object)(object)component == (Object)null)
{
return false;
}
component.GetWorldCorners(Il2CppStructArray<Vector3>.op_Implicit(CornerBuffer));
float num = CornerBuffer[2].x - CornerBuffer[0].x;
float num2 = CornerBuffer[2].y - CornerBuffer[0].y;
return num >= (float)Screen.width * 0.6f && num2 >= (float)Screen.height * 0.6f;
}
catch
{
return false;
}
}
private static bool Approximately(Color a, Color b)
{
//IL_0000: Unknown result type (might be due to invalid IL or missing references)
//IL_0006: Unknown result type (might be due to invalid IL or missing references)
//IL_0019: 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_0032: 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_004b: Unknown result type (might be due to invalid IL or missing references)
//IL_0051: Unknown result type (might be due to invalid IL or missing references)
if (Mathf.Abs(a.r - b.r) < 0.004f && Mathf.Abs(a.g - b.g) < 0.004f && Mathf.Abs(a.b - b.b) < 0.004f)
{
return Mathf.Abs(a.a - b.a) < 0.004f;
}
return false;
}
internal static float Luminance(Color c)
{
//IL_0005: Unknown result type (might be due to invalid IL or missing references)
//IL_0011: Unknown result type (might be due to invalid IL or missing references)
//IL_001e: Unknown result type (might be due to invalid IL or missing references)
return 0.299f * c.r + 0.587f * c.g + 0.114f * c.b;
}
internal static float Saturation(Color c)
{
//IL_0000: Unknown result type (might be due to invalid IL or missing references)
//IL_0006: Unknown result type (might be due to invalid IL or missing references)
//IL_000c: Unknown result type (might be due to invalid IL or missing references)
//IL_001d: Unknown result type (might be due to invalid IL or missing references)
//IL_0023: Unknown result type (might be due to invalid IL or missing references)
//IL_0029: Unknown result type (might be due to invalid IL or missing references)
float num = Mathf.Max(c.r, Mathf.Max(c.g, c.b));
float num2 = Mathf.Min(c.r, Mathf.Min(c.g, c.b));
if (!(num <= 0.0001f))
{
return (num - num2) / num;
}
return 0f;
}
}
[BepInPlugin("com.smolmods.darkmenus", "smolMods.DarkMenus", "1.0.2")]
[BepInDependency(/*Could not decode attribute arguments.*/)]
public class Plugin : BasePlugin
{
public const string PluginGuid = "com.smolmods.darkmenus";
public const string PluginName = "smolMods.DarkMenus";
public const string PluginVersion = "1.0.2";
private const string HudClaimId = "darkmenus.icons";
internal static ManualLogSource Logger;
internal static ModRowDef MenuRow;
internal static ModRowDef HudDarkRow;
private static bool _flipping;
private static readonly Dictionary<int, (Graphic g, Color c)> CursorGraphics = new Dictionary<int, (Graphic, Color)>();
private static readonly List<Shadow> CursorShadows = new List<Shadow>();
private static NmouseObject[] _nmice;
internal static bool MenusEnabled
{
get
{
if (MenuRow != null)
{
return MenuRow.Value == 1;
}
return false;
}
}
public override void Load()
{
//IL_0101: Unknown result type (might be due to invalid IL or missing references)
//IL_0107: Expected O, but got Unknown
//IL_012e: Unknown result type (might be due to invalid IL or missing references)
//IL_0133: Unknown result type (might be due to invalid IL or missing references)
//IL_00db: Unknown result type (might be due to invalid IL or missing references)
//IL_00e0: Unknown result type (might be due to invalid IL or missing references)
//IL_00e6: Expected O, but got Unknown
//IL_00e6: Unknown result type (might be due to invalid IL or missing references)
//IL_0185: Unknown result type (might be due to invalid IL or missing references)
//IL_018c: Expected O, but got Unknown
Logger = ((BasePlugin)this).Log;
MenuRow = ModSettingsApi.AddArrayRow(400, "Dark menus", "settings_mod_darkMenus", 1, new int[2] { 0, 1 }, (Func<int, string>)((int v) => (v != 1) ? "Off" : "On"), (Action<int>)delegate(int v)
{
MenuTheme.Apply(v == 1);
}, (Func<int, Color?>)null);
HudDarkRow = ModSettingsApi.AddArrayRow(400, "Dark HUD icons", "settings_mod_darkHud", 0, new int[2] { 0, 1 }, (Func<int, string>)((int v) => (v != 1) ? "Off" : "On"), (Action<int>)delegate(int v)
{
if (!_flipping)
{
if (v == 1)
{
HudTintApi.Claim("darkmenus.icons", (Func<Color?>)(() => HudTintApi.DefaultDarkIcon), (Action)OnPreempted);
}
else
{
HudTintApi.Release("darkmenus.icons");
}
}
}, (Func<int, Color?>)null);
bool flag = default(bool);
try
{
ClassInjector.RegisterTypeInIl2Cpp<ThemeTicker>();
GameObject val = new GameObject("SmolModsDarkMenusTicker");
Object.DontDestroyOnLoad((Object)val);
((Object)val).hideFlags = (HideFlags)61;
val.AddComponent<ThemeTicker>();
}
catch (Exception ex)
{
ManualLogSource logger = Logger;
BepInExWarningLogInterpolatedStringHandler val2 = new BepInExWarningLogInterpolatedStringHandler(26, 1, ref flag);
if (flag)
{
((BepInExLogInterpolatedStringHandler)val2).AppendLiteral("Theme ticker unavailable: ");
((BepInExLogInterpolatedStringHandler)val2).AppendFormatted<string>(ex.Message);
}
logger.LogWarning(val2);
}
Harmony val3 = new Harmony("com.smolmods.darkmenus");
val3.PatchAll(typeof(Plugin).Assembly);
int num = 0;
foreach (MethodBase patchedMethod in val3.GetPatchedMethods())
{
_ = patchedMethod;
num++;
}
ManualLogSource logger2 = Logger;
BepInExInfoLogInterpolatedStringHandler val4 = new BepInExInfoLogInterpolatedStringHandler(27, 3, ref flag);
if (flag)
{
((BepInExLogInterpolatedStringHandler)val4).AppendFormatted<string>("smolMods.DarkMenus");
((BepInExLogInterpolatedStringHandler)val4).AppendLiteral(" ");
((BepInExLogInterpolatedStringHandler)val4).AppendFormatted<string>("1.0.2");
((BepInExLogInterpolatedStringHandler)val4).AppendLiteral(" loaded, ");
((BepInExLogInterpolatedStringHandler)val4).AppendFormatted<int>(num);
((BepInExLogInterpolatedStringHandler)val4).AppendLiteral(" methods patched.");
}
logger2.LogInfo(val4);
}
private static void OnPreempted()
{
_flipping = true;
try
{
HudDarkRow.SetValue(0, true);
ModSettingsApi.RefreshRows();
}
finally
{
_flipping = false;
}
}
internal static bool IsCursorOwned(Graphic g)
{
return CursorGraphics.ContainsKey(((Object)g).GetInstanceID());
}
internal static void ApplyCursor(bool enabled)
{
//IL_0269: Unknown result type (might be due to invalid IL or missing references)
//IL_0270: Expected O, but got Unknown
//IL_0035: Unknown result type (might be due to invalid IL or missing references)
//IL_0213: Unknown result type (might be due to invalid IL or missing references)
//IL_0218: Unknown result type (might be due to invalid IL or missing references)
//IL_0192: Unknown result type (might be due to invalid IL or missing references)
//IL_0226: Unknown result type (might be due to invalid IL or missing references)
//IL_01dd: Unknown result type (might be due to invalid IL or missing references)
//IL_01f3: Unknown result type (might be due to invalid IL or missing references)
try
{
if (!enabled)
{
foreach (var value in CursorGraphics.Values)
{
try
{
if ((Object)(object)value.g != (Object)null)
{
value.g.color = value.c;
}
}
catch
{
}
}
CursorGraphics.Clear();
foreach (Shadow cursorShadow in CursorShadows)
{
try
{
if ((Object)(object)cursorShadow != (Object)null)
{
((Behaviour)cursorShadow).enabled = false;
}
}
catch
{
}
}
CursorShadows.Clear();
_nmice = null;
return;
}
bool flag = _nmice == null || _nmice.Length == 0;
NmouseObject[] nmice;
if (!flag)
{
nmice = _nmice;
for (int i = 0; i < nmice.Length; i++)
{
if ((Object)(object)nmice[i] == (Object)null)
{
flag = true;
break;
}
}
}
if (flag)
{
_nmice = Il2CppArrayBase<NmouseObject>.op_Implicit(Object.FindObjectsOfType<NmouseObject>(true));
}
nmice = _nmice;
foreach (NmouseObject val in nmice)
{
if ((Object)(object)val == (Object)null)
{
continue;
}
GameObject cursor = val.cursor;
if ((Object)(object)cursor == (Object)null)
{
continue;
}
foreach (Graphic componentsInChild in cursor.GetComponentsInChildren<Graphic>(true))
{
int instanceID = ((Object)componentsInChild).GetInstanceID();
if (!CursorGraphics.ContainsKey(instanceID))
{
CursorGraphics[instanceID] = (componentsInChild, componentsInChild.color);
Shadow val2 = ((Component)componentsInChild).gameObject.GetComponent<Shadow>();
if ((Object)(object)val2 == (Object)null)
{
val2 = ((Component)componentsInChild).gameObject.AddComponent<Shadow>();
}
val2.effectColor = new Color(0f, 0f, 0f, 0.65f);
val2.effectDistance = new Vector2(3f, -3f);
((Behaviour)val2).enabled = true;
CursorShadows.Add(val2);
}
if (componentsInChild.color != Color.white)
{
componentsInChild.color = Color.white;
}
}
}
}
catch (Exception ex)
{
ManualLogSource logger = Logger;
bool flag2 = default(bool);
BepInExWarningLogInterpolatedStringHandler val3 = new BepInExWarningLogInterpolatedStringHandler(24, 1, ref flag2);
if (flag2)
{
((BepInExLogInterpolatedStringHandler)val3).AppendLiteral("Cursor recolour failed: ");
((BepInExLogInterpolatedStringHandler)val3).AppendFormatted<string>(ex.Message);
}
logger.LogWarning(val3);
}
}
}
public class ThemeTicker : MonoBehaviour
{
private float _next;
public ThemeTicker(IntPtr ptr)
: base(ptr)
{
}
private void Update()
{
if (Time.unscaledTime < _next)
{
return;
}
_next = Time.unscaledTime + 0.2f;
try
{
MenuTheme.Apply(Plugin.MenusEnabled, force: false);
}
catch
{
}
try
{
Plugin.ApplyCursor(Plugin.MenusEnabled);
}
catch
{
}
}
}
[HarmonyPatch]
internal static class MenuPatches
{
[HarmonyPostfix]
[HarmonyPatch(typeof(SettingsMenu), "OnEnable")]
private static void SettingsMenu_OnEnable(SettingsMenu __instance)
{
if (!__instance.isInMainMenu)
{
MenuTheme.TrackMenu(((Component)__instance).transform);
}
MenuTheme.Apply(Plugin.MenusEnabled);
}
[HarmonyPostfix]
[HarmonyPatch(typeof(SettingsMenu), "PressCatagoryButton")]
private static void SettingsMenu_PressCatagory()
{
MenuTheme.Apply(Plugin.MenusEnabled);
}
[HarmonyPostfix]
[HarmonyPatch(typeof(SettingsMenu), "SwapToCatagory")]
private static void SettingsMenu_SwapCatagory()
{
MenuTheme.Apply(Plugin.MenusEnabled);
}
[HarmonyPostfix]
[HarmonyPatch(typeof(SettingsRow), "Refresh")]
private static void SettingsRow_Refresh(SettingsRow __instance)
{
if (Plugin.MenusEnabled && MenuTheme.IsInTrackedPanel(((Component)__instance).transform))
{
MenuTheme.ApplyToSubtree(((Component)__instance).transform, enabled: true);
}
}
[HarmonyPostfix]
[HarmonyPatch(typeof(WorldMenuManager), "OpenMenu")]
private static void WorldMenu_OpenMenu(WorldMenuManager __instance)
{
if ((Object)(object)__instance.settingsMenu != (Object)null)
{
MenuTheme.TrackMenu(((Component)__instance.settingsMenu).transform);
}
if ((Object)(object)__instance.pauseMenuForCurrentMode != (Object)null)
{
MenuTheme.TrackMenu(((Component)__instance.pauseMenuForCurrentMode).transform);
}
MenuTheme.Apply(Plugin.MenusEnabled);
}
}
}