Decompiled source of ClassicLegacyUI v0.2.6

plugins/ClassicLegacyUI.dll

Decompiled 3 hours ago
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Reflection.Emit;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Text;
using BepInEx;
using BepInEx.Configuration;
using BepInEx.Core.Logging.Interpolation;
using BepInEx.Logging;
using BepInEx.NET.Common;
using BepInExResoniteShim;
using BepisResoniteWrapper;
using Elements.Core;
using FrooxEngine;
using HarmonyLib;
using Renderite.Shared;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(/*Could not decode attribute arguments.*/)]
[assembly: TargetFramework(".NETCoreApp,Version=v10.0", FrameworkDisplayName = ".NET 10.0")]
[assembly: AssemblyCompany("markn2000")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyFileVersion("0.2.6.0")]
[assembly: AssemblyInformationalVersion("0.2.6+39cf308e5d1ec7b38242d976993462d9f64dc792")]
[assembly: AssemblyProduct("ClassicLegacyUI")]
[assembly: AssemblyTitle("ClassicLegacyUI")]
[assembly: InternalsVisibleTo("ClassicLegacyUI.Checks")]
[assembly: AssemblyVersion("0.2.6.0")]
[module: RefSafetyRules(11)]
[CompilerGenerated]
internal sealed class <>z__ReadOnlyArray<T> : global::System.Collections.IEnumerable, global::System.Collections.ICollection, global::System.Collections.IList, global::System.Collections.Generic.IEnumerable<T>, global::System.Collections.Generic.IReadOnlyCollection<T>, global::System.Collections.Generic.IReadOnlyList<T>, global::System.Collections.Generic.ICollection<T>, global::System.Collections.Generic.IList<T>
{
	int global::System.Collections.ICollection.Count => _items.Length;

	bool global::System.Collections.ICollection.IsSynchronized => false;

	object global::System.Collections.ICollection.SyncRoot => this;

	object? global::System.Collections.IList.this[int index]
	{
		get
		{
			return _items[index];
		}
		set
		{
			//IL_0000: Unknown result type (might be due to invalid IL or missing references)
			throw new NotSupportedException();
		}
	}

	bool global::System.Collections.IList.IsFixedSize => true;

	bool global::System.Collections.IList.IsReadOnly => true;

	int global::System.Collections.Generic.IReadOnlyCollection<T>.Count => _items.Length;

	T global::System.Collections.Generic.IReadOnlyList<T>.this[int index] => _items[index];

	int global::System.Collections.Generic.ICollection<T>.Count => _items.Length;

	bool global::System.Collections.Generic.ICollection<T>.IsReadOnly => true;

	T global::System.Collections.Generic.IList<T>.this[int index]
	{
		get
		{
			return _items[index];
		}
		set
		{
			//IL_0000: Unknown result type (might be due to invalid IL or missing references)
			throw new NotSupportedException();
		}
	}

	public <>z__ReadOnlyArray(T[] items)
	{
		_items = items;
	}

	global::System.Collections.IEnumerator global::System.Collections.IEnumerable.GetEnumerator()
	{
		return ((global::System.Collections.IEnumerable)(object)_items).GetEnumerator();
	}

	void global::System.Collections.ICollection.CopyTo(global::System.Array array, int index)
	{
		((global::System.Collections.ICollection)(object)_items).CopyTo(array, index);
	}

	int global::System.Collections.IList.Add(object? value)
	{
		//IL_0000: Unknown result type (might be due to invalid IL or missing references)
		throw new NotSupportedException();
	}

	void global::System.Collections.IList.Clear()
	{
		//IL_0000: Unknown result type (might be due to invalid IL or missing references)
		throw new NotSupportedException();
	}

	bool global::System.Collections.IList.Contains(object? value)
	{
		return ((global::System.Collections.IList)(object)_items).Contains(value);
	}

	int global::System.Collections.IList.IndexOf(object? value)
	{
		return ((global::System.Collections.IList)(object)_items).IndexOf(value);
	}

	void global::System.Collections.IList.Insert(int index, object? value)
	{
		//IL_0000: Unknown result type (might be due to invalid IL or missing references)
		throw new NotSupportedException();
	}

	void global::System.Collections.IList.Remove(object? value)
	{
		//IL_0000: Unknown result type (might be due to invalid IL or missing references)
		throw new NotSupportedException();
	}

	void global::System.Collections.IList.RemoveAt(int index)
	{
		//IL_0000: Unknown result type (might be due to invalid IL or missing references)
		throw new NotSupportedException();
	}

	global::System.Collections.Generic.IEnumerator<T> global::System.Collections.Generic.IEnumerable<T>.GetEnumerator()
	{
		return ((global::System.Collections.Generic.IEnumerable<T>)_items).GetEnumerator();
	}

	void global::System.Collections.Generic.ICollection<T>.Add(T item)
	{
		//IL_0000: Unknown result type (might be due to invalid IL or missing references)
		throw new NotSupportedException();
	}

	void global::System.Collections.Generic.ICollection<T>.Clear()
	{
		//IL_0000: Unknown result type (might be due to invalid IL or missing references)
		throw new NotSupportedException();
	}

	bool global::System.Collections.Generic.ICollection<T>.Contains(T item)
	{
		return ((global::System.Collections.Generic.ICollection<T>)_items).Contains(item);
	}

	void global::System.Collections.Generic.ICollection<T>.CopyTo(T[] array, int arrayIndex)
	{
		((global::System.Collections.Generic.ICollection<T>)_items).CopyTo(array, arrayIndex);
	}

	bool global::System.Collections.Generic.ICollection<T>.Remove(T item)
	{
		//IL_0000: Unknown result type (might be due to invalid IL or missing references)
		throw new NotSupportedException();
	}

	int global::System.Collections.Generic.IList<T>.IndexOf(T item)
	{
		return ((global::System.Collections.Generic.IList<T>)_items).IndexOf(item);
	}

	void global::System.Collections.Generic.IList<T>.Insert(int index, T item)
	{
		//IL_0000: Unknown result type (might be due to invalid IL or missing references)
		throw new NotSupportedException();
	}

	void global::System.Collections.Generic.IList<T>.RemoveAt(int index)
	{
		//IL_0000: Unknown result type (might be due to invalid IL or missing references)
		throw new NotSupportedException();
	}
}
namespace ClassicLegacyUI;

[ResonitePlugin("markn2000.ClassicLegacyUI", "ClassicLegacyUI", "0.2.6", "markn2000", "https://github.com/MarkN2000/ClassicLegacyUI")]
[BepInDependency(/*Could not decode attribute arguments.*/)]
[BepInDependency(/*Could not decode attribute arguments.*/)]
public sealed class Plugin : BasePlugin
{
	internal sealed record Settings(ConfigEntry<bool> Enabled, Dictionary<global::System.Type, ValueTuple<ConfigEntry<bool>, ConfigEntry<colorX>, ConfigEntry<float>?, ConfigEntry<colorX>?>> Styles)
	{
		[CompilerGenerated]
		private global::System.Type EqualityContract
		{
			[CompilerGenerated]
			get
			{
				return typeof(Settings);
			}
		}

		[CompilerGenerated]
		public override string ToString()
		{
			//IL_0000: Unknown result type (might be due to invalid IL or missing references)
			//IL_0006: Expected O, but got Unknown
			StringBuilder val = new StringBuilder();
			val.Append("Settings");
			val.Append(" { ");
			if (PrintMembers(val))
			{
				val.Append(' ');
			}
			val.Append('}');
			return ((object)val).ToString();
		}

		[CompilerGenerated]
		private bool PrintMembers(StringBuilder builder)
		{
			RuntimeHelpers.EnsureSufficientExecutionStack();
			builder.Append("Enabled = ");
			builder.Append((object)Enabled);
			builder.Append(", Styles = ");
			builder.Append((object)Styles);
			return true;
		}

		[CompilerGenerated]
		public bool Equals(Settings? other)
		{
			if ((object)this != other)
			{
				if ((object)other != null && EqualityContract == other.EqualityContract && EqualityComparer<ConfigEntry<bool>>.Default.Equals(Enabled, other.Enabled))
				{
					return EqualityComparer<Dictionary<global::System.Type, ValueTuple<ConfigEntry<bool>, ConfigEntry<colorX>, ConfigEntry<float>, ConfigEntry<colorX>>>>.Default.Equals(Styles, other.Styles);
				}
				return false;
			}
			return true;
		}
	}

	private static Plugin? instance;

	private Settings? settings;

	private volatile Dictionary<global::System.Type, ValueTuple<colorX?, float?, colorX?>> styles = new Dictionary<global::System.Type, ValueTuple<colorX?, float?, colorX?>>();

	internal static readonly colorX CommonColor = new colorX(1f, 0.73f, 0.09f, 0.8f, (ColorProfile)1);

	internal static readonly colorX PanelColor = new colorX(1f, 0.88f, 0.6f, 0.8f, (ColorProfile)1);

	public override void Load()
	{
		//IL_000d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0017: Expected O, but got Unknown
		instance = this;
		ResoniteHooks.OnEngineReady += new Action(OnEngineReady);
	}

	private void OnEngineReady()
	{
		//IL_0007: Unknown result type (might be due to invalid IL or missing references)
		//IL_0011: Expected O, but got Unknown
		//IL_0126: Unknown result type (might be due to invalid IL or missing references)
		//IL_012c: Expected O, but got Unknown
		//IL_00cc: Unknown result type (might be due to invalid IL or missing references)
		//IL_00d8: Expected O, but got Unknown
		//IL_00ac: Unknown result type (might be due to invalid IL or missing references)
		ResoniteHooks.OnEngineReady -= new Action(OnEngineReady);
		try
		{
			bool num = !File.Exists(((BasePlugin)this).Config.ConfigFilePath);
			settings = RegisterSettings(((BasePlugin)this).Config);
			styles = ReadStyles(settings, [CompilerGenerated] (string message) =>
			{
				((BasePlugin)this).Log.LogWarning((object)message);
			});
			if (num)
			{
				((BasePlugin)this).Config.Save();
			}
			MethodInfo val = AccessTools.DeclaredMethod(typeof(DevCreateNewForm), "RunAction", new global::System.Type[3]
			{
				typeof(IButton),
				typeof(ButtonEventData),
				typeof(string)
			}, (global::System.Type[])null) ?? throw new MissingMethodException("DevCreateNewForm.RunAction was not found.");
			((BasePlugin)this).HarmonyInstance.Patch((MethodBase)(object)val, (HarmonyMethod)null, (HarmonyMethod)null, new HarmonyMethod(typeof(Plugin), "Transpile", (global::System.Type[])null), (HarmonyMethod)null, (HarmonyMethod)null);
			((BasePlugin)this).Config.SettingChanged += OnSettingChanged;
			((BasePlugin)this).Log.LogInfo((object)"ClassicLegacyUI loaded. Settings changes apply to newly created UI.");
		}
		catch (global::System.Exception ex)
		{
			((BasePlugin)this).HarmonyInstance.UnpatchSelf();
			styles = new Dictionary<global::System.Type, ValueTuple<colorX?, float?, colorX?>>();
			ManualLogSource log = ((BasePlugin)this).Log;
			bool flag = default(bool);
			BepInExErrorLogInterpolatedStringHandler val2 = new BepInExErrorLogInterpolatedStringHandler(50, 1, ref flag);
			if (flag)
			{
				((BepInExLogInterpolatedStringHandler)val2).AppendLiteral("Initialization failed; styling has been disabled: ");
				((BepInExLogInterpolatedStringHandler)val2).AppendFormatted<global::System.Exception>(ex);
			}
			log.LogError(val2);
		}
	}

	public override bool Unload()
	{
		//IL_0007: Unknown result type (might be due to invalid IL or missing references)
		//IL_0011: Expected O, but got Unknown
		ResoniteHooks.OnEngineReady -= new Action(OnEngineReady);
		((BasePlugin)this).Config.SettingChanged -= OnSettingChanged;
		((BasePlugin)this).HarmonyInstance.UnpatchSelf();
		instance = null;
		return true;
	}

	private void OnSettingChanged(object? sender, SettingChangedEventArgs args)
	{
		styles = ReadStyles(settings, [CompilerGenerated] (string message) =>
		{
			((BasePlugin)this).Log.LogWarning((object)message);
		});
	}

	internal static Settings RegisterSettings(ConfigFile config)
	{
		//IL_004f: 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_0098: Unknown result type (might be due to invalid IL or missing references)
		//IL_00bd: Unknown result type (might be due to invalid IL or missing references)
		//IL_00e2: 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_0140: Unknown result type (might be due to invalid IL or missing references)
		//IL_0164: 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)
		config.SaveOnConfigSet = false;
		Settings settings = new Settings(config.Bind<bool>("General", "Enabled", true, "Enable styling for newly created UI."), new Dictionary<global::System.Type, ValueTuple<ConfigEntry<bool>, ConfigEntry<colorX>, ConfigEntry<float>, ConfigEntry<colorX>>>());
		Add(typeof(LegacyButton), "Button", CommonColor, 22.5f);
		Add(typeof(LegacyCheckbox), "Checkbox", CommonColor);
		Add(typeof(LegacyHorizontalChoiceBar), "HorizontalChoiceBar", CommonColor, 22.5f);
		Add(typeof(LegacyNumericUpDown), "NumericUpDown", CommonColor, 22.5f);
		Add(typeof(LegacyCanvasPanel), "Panel", PanelColor);
		Add(typeof(LegacyProgressBar), "ProgressBar", new colorX(1f, 0.73f, 0.09f, 1f, (ColorProfile)1), 22.5f);
		Add(typeof(LegacyRadio), "Radio", CommonColor);
		Add(typeof(LegacySlider), "Slider", CommonColor, 22.5f);
		Add(typeof(LegacyTextField), "TextField", CommonColor, 22.5f);
		return settings;
		[CompilerGenerated]
		void Add(global::System.Type type, string section, colorX defaultColor, float? defaultSlant = null)
		{
			//IL_0041: Unknown result type (might be due to invalid IL or missing references)
			//IL_0060: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a9: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b3: Expected O, but got Unknown
			//IL_00c7: Unknown result type (might be due to invalid IL or missing references)
			ConfigEntry<bool> val = config.Bind<bool>(section, "Enabled", true, "Enable styling for this UI type.");
			bool flag = type == typeof(LegacyProgressBar);
			ConfigEntry<colorX> val2 = config.Bind<colorX>(section, flag ? "BarColor" : "Color", defaultColor, "Color in sRGB or Linear, with each channel from 0 to 1. Alpha blends with the default color. Applies to newly created UI.");
			ConfigEntry<colorX> val3 = (flag ? config.Bind<colorX>(section, "ContainerColor", PanelColor, "Color in sRGB or Linear, with each channel from 0 to 1. Alpha blends with the default color. Applies to newly created UI.") : null);
			ConfigEntry<float> val4 = (defaultSlant.HasValue ? config.Bind<float>(section, "Slant", defaultSlant.Value, new ConfigDescription("Slant in degrees, from -90 to 90. Applies to newly created UI.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(-90f, 90f), global::System.Array.Empty<object>())) : null);
			settings.Styles.Add(type, new ValueTuple<ConfigEntry<bool>, ConfigEntry<colorX>, ConfigEntry<float>, ConfigEntry<colorX>>(val, val2, val4, val3));
		}
	}

	internal static Dictionary<global::System.Type, ValueTuple<colorX?, float?, colorX?>> ReadStyles(Settings settings, Action<string> warn)
	{
		//IL_0026: Unknown result type (might be due to invalid IL or missing references)
		//IL_002b: Unknown result type (might be due to invalid IL or missing references)
		//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_0048: 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)
		//IL_004b: Unknown result type (might be due to invalid IL or missing references)
		//IL_005d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0084: Unknown result type (might be due to invalid IL or missing references)
		//IL_00ab: Unknown result type (might be due to invalid IL or missing references)
		//IL_00d9: Unknown result type (might be due to invalid IL or missing references)
		Dictionary<global::System.Type, ValueTuple<colorX?, float?, colorX?>> val = new Dictionary<global::System.Type, ValueTuple<colorX?, float?, colorX?>>(settings.Styles.Count);
		if (!settings.Enabled.Value)
		{
			return val;
		}
		Enumerator<global::System.Type, ValueTuple<ConfigEntry<bool>, ConfigEntry<colorX>, ConfigEntry<float>, ConfigEntry<colorX>>> enumerator = settings.Styles.GetEnumerator();
		try
		{
			global::System.Type type = default(global::System.Type);
			ValueTuple<ConfigEntry<bool>, ConfigEntry<colorX>, ConfigEntry<float>, ConfigEntry<colorX>> val2 = default(ValueTuple<ConfigEntry<bool>, ConfigEntry<colorX>, ConfigEntry<float>, ConfigEntry<colorX>>);
			ValueTuple<colorX?, float?, colorX?> val4 = default(ValueTuple<colorX?, float?, colorX?>);
			while (enumerator.MoveNext())
			{
				enumerator.Current.Deconstruct(ref type, ref val2);
				global::System.Type type2 = type;
				ValueTuple<ConfigEntry<bool>, ConfigEntry<colorX>, ConfigEntry<float>, ConfigEntry<colorX>> val3 = val2;
				if (val3.Item1.Value)
				{
					val4..ctor(Read<colorX>(val3.Item2, warn, (Func<colorX, bool>)ValidColor), Read<float>(val3.Item3, warn, (Func<float, bool>)ValidSlant), Read<colorX>(val3.Item4, warn, (Func<colorX, bool>)ValidColor));
					val.Add(type2, val4);
				}
			}
			return val;
		}
		finally
		{
			((global::System.IDisposable)enumerator/*cast due to .constrained prefix*/).Dispose();
		}
	}

	private static T? Read<T>(ConfigEntry<T>? entry, Action<string> warn, Func<T, bool> validate) where T : struct
	{
		if (entry == null)
		{
			return null;
		}
		T value = entry.Value;
		if (!validate.Invoke(value))
		{
			warn.Invoke($"[{((ConfigEntryBase)entry).Definition.Section}] {((ConfigEntryBase)entry).Definition.Key} was not applied: value is outside the supported range.");
			return null;
		}
		return value;
	}

	internal static bool ValidColor(colorX value)
	{
		//IL_0002: Unknown result type (might be due to invalid IL or missing references)
		//IL_0008: Invalid comparison between Unknown and I4
		//IL_000c: Unknown result type (might be due to invalid IL or missing references)
		if (((int)((colorX)(ref value)).Profile == 1 || (int)((colorX)(ref value)).Profile == 0) && Unit(((colorX)(ref value)).r) && Unit(((colorX)(ref value)).g) && Unit(((colorX)(ref value)).b))
		{
			return Unit(((colorX)(ref value)).a);
		}
		return false;
	}

	private static bool Unit(float value)
	{
		if (float.IsFinite(value) && value >= 0f)
		{
			return value <= 1f;
		}
		return false;
	}

	internal static bool ValidSlant(float value)
	{
		if (float.IsFinite(value) && value >= -90f)
		{
			return value <= 90f;
		}
		return false;
	}

	internal static bool IsTargetCategory(string? category)
	{
		return string.Equals(category?.Replace('\\', '/').Trim('/'), "Object/Legacy UI", (StringComparison)4);
	}

	internal static global::System.Collections.Generic.IEnumerable<CodeInstruction> Transpile(global::System.Collections.Generic.IEnumerable<CodeInstruction> instructions)
	{
		//IL_009e: Unknown result type (might be due to invalid IL or missing references)
		//IL_00d3: Unknown result type (might be due to invalid IL or missing references)
		//IL_00d9: Unknown result type (might be due to invalid IL or missing references)
		//IL_00e0: Expected O, but got Unknown
		//IL_0109: Unknown result type (might be due to invalid IL or missing references)
		//IL_0124: Unknown result type (might be due to invalid IL or missing references)
		//IL_012a: Expected O, but got Unknown
		//IL_00cd: Unknown result type (might be due to invalid IL or missing references)
		List<CodeInstruction> val = Enumerable.ToList<CodeInstruction>(instructions);
		MethodInfo invoke = AccessTools.Method(typeof(Action<Slot>), "Invoke", (global::System.Type[])null, (global::System.Type[])null);
		ValueTuple<CodeInstruction, int>[] array = Enumerable.ToArray<ValueTuple<CodeInstruction, int>>(Enumerable.Where<ValueTuple<CodeInstruction, int>>(Enumerable.Select<CodeInstruction, ValueTuple<CodeInstruction, int>>((global::System.Collections.Generic.IEnumerable<CodeInstruction>)val, (Func<CodeInstruction, int, ValueTuple<CodeInstruction, int>>)((CodeInstruction instruction, int index) => new ValueTuple<CodeInstruction, int>(instruction, index))), (Func<ValueTuple<CodeInstruction, int>, bool>)((ValueTuple<CodeInstruction, int> pair) => CodeInstructionExtensions.Calls(pair.Item1, invoke))));
		if (array.Length != 1)
		{
			throw new InvalidOperationException($"Expected exactly one creation action call; found {array.Length}.");
		}
		int item = array[0].Item2;
		CodeInstruction val2 = val[item];
		if (val2.blocks.Count != 0)
		{
			throw new InvalidOperationException("The creation action has an unexpected exception block structure.");
		}
		CodeInstruction val3 = new CodeInstruction(OpCodes.Ldarg_3, (object)null);
		val3.labels.AddRange((global::System.Collections.Generic.IEnumerable<Label>)val2.labels);
		val.RemoveAt(item);
		val.InsertRange(item, (global::System.Collections.Generic.IEnumerable<CodeInstruction>)new <>z__ReadOnlyArray<CodeInstruction>((CodeInstruction[])(object)new CodeInstruction[2]
		{
			val3,
			new CodeInstruction(OpCodes.Call, (object)AccessTools.Method(typeof(Plugin), "CreateAndStyle", (global::System.Type[])null, (global::System.Type[])null))
		}));
		return (global::System.Collections.Generic.IEnumerable<CodeInstruction>)val;
	}

	internal static void CreateAndStyle(Action<Slot> create, Slot slot, string category)
	{
		//IL_00a7: Unknown result type (might be due to invalid IL or missing references)
		//IL_00ae: Expected O, but got Unknown
		//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_005c: 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_0068: Unknown result type (might be due to invalid IL or missing references)
		create.Invoke(slot);
		try
		{
			Plugin? plugin = instance;
			Dictionary<global::System.Type, ValueTuple<colorX?, float?, colorX?>> val = ((plugin != null) ? plugin.styles : null);
			if (val == null || val.Count == 0 || !IsTargetCategory(category))
			{
				return;
			}
			Enumerator<Component> enumerator = ((ContainerWorker<Component>)(object)slot).GetComponents<Component>((Predicate<Component>)null, false).GetEnumerator();
			try
			{
				ValueTuple<colorX?, float?, colorX?> val2 = default(ValueTuple<colorX?, float?, colorX?>);
				while (enumerator.MoveNext())
				{
					Component current = enumerator.Current;
					if (val.TryGetValue(((object)current).GetType(), ref val2))
					{
						Apply(current, val2.Item1, val2.Item2, val2.Item3);
					}
				}
			}
			finally
			{
				((global::System.IDisposable)enumerator/*cast due to .constrained prefix*/).Dispose();
			}
		}
		catch (global::System.Exception ex)
		{
			Plugin plugin2 = instance;
			if (plugin2 != null)
			{
				ManualLogSource log = ((BasePlugin)plugin2).Log;
				bool flag = default(bool);
				BepInExErrorLogInterpolatedStringHandler val3 = new BepInExErrorLogInterpolatedStringHandler(49, 1, ref flag);
				if (flag)
				{
					((BepInExLogInterpolatedStringHandler)val3).AppendLiteral("Failed to apply styling to the newly created UI: ");
					((BepInExLogInterpolatedStringHandler)val3).AppendFormatted<global::System.Exception>(ex);
				}
				log.LogError(val3);
			}
		}
	}

	private static void Apply(Component component, colorX? color, float? slant, colorX? container)
	{
		//IL_007a: Unknown result type (might be due to invalid IL or missing references)
		//IL_00ad: Unknown result type (might be due to invalid IL or missing references)
		//IL_011a: 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_00f3: Unknown result type (might be due to invalid IL or missing references)
		//IL_016b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0182: Unknown result type (might be due to invalid IL or missing references)
		//IL_01b1: Unknown result type (might be due to invalid IL or missing references)
		//IL_01c9: Unknown result type (might be due to invalid IL or missing references)
		LegacyButton val = (LegacyButton)(object)((component is LegacyButton) ? component : null);
		if (val == null)
		{
			LegacyCheckbox val2 = (LegacyCheckbox)(object)((component is LegacyCheckbox) ? component : null);
			if (val2 == null)
			{
				LegacyHorizontalChoiceBar val3 = (LegacyHorizontalChoiceBar)(object)((component is LegacyHorizontalChoiceBar) ? component : null);
				if (val3 == null)
				{
					LegacyFieldBase val4 = (LegacyFieldBase)(object)((component is LegacyFieldBase) ? component : null);
					if (val4 == null)
					{
						LegacyCanvasPanel val5 = (LegacyCanvasPanel)(object)((component is LegacyCanvasPanel) ? component : null);
						if (val5 == null)
						{
							LegacyProgressBar val6 = (LegacyProgressBar)(object)((component is LegacyProgressBar) ? component : null);
							if (val6 == null)
							{
								LegacyRadio val7 = (LegacyRadio)(object)((component is LegacyRadio) ? component : null);
								if (val7 == null)
								{
									LegacySlider val8 = (LegacySlider)(object)((component is LegacySlider) ? component : null);
									if (val8 != null)
									{
										if (color.HasValue)
										{
											val8.OverrideColor = color.Value;
										}
										if (slant.HasValue)
										{
											val8.Slant = slant.Value;
										}
									}
								}
								else if (color.HasValue)
								{
									val7.OverrideColor = color.Value;
								}
							}
							else
							{
								if (color.HasValue)
								{
									val6.BarColor = color.Value;
								}
								if (container.HasValue)
								{
									val6.ContainerColor = container.Value;
								}
								if (slant.HasValue)
								{
									val6.Slant = slant.Value;
								}
							}
						}
						else if (color.HasValue)
						{
							val5.Panel.Color = color.Value;
						}
					}
					else
					{
						if (color.HasValue)
						{
							val4.OverrideColor = color.Value;
						}
						if (slant.HasValue)
						{
							val4.Slant = slant.Value;
						}
					}
					return;
				}
				if (slant.HasValue)
				{
					((SyncField<float>)(object)val3.Slant).Value = slant.Value;
				}
				if (color.HasValue)
				{
					for (int i = 0; i < val3.ItemCount; i++)
					{
						((SyncField<colorX>)(object)val3.GetItem(i).OverrideColor).Value = color.Value;
					}
				}
			}
			else if (color.HasValue)
			{
				val2.OverrideColor = color.Value;
			}
		}
		else
		{
			if (color.HasValue)
			{
				val.Color = color.Value;
			}
			if (slant.HasValue)
			{
				val.Slant = slant.Value;
			}
		}
	}
}