Decompiled source of ColorDrop v2.1.1

plugins/ColorDrop/ColorDrop.dll

Decompiled 3 weeks ago
using System;
using System.Diagnostics;
using System.Globalization;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using BepInEx;
using BepInEx.Configuration;
using BepInEx.Logging;
using BepInEx.NET.Common;
using BepInExResoniteShim;
using Elements.Core;
using FrooxEngine;
using FrooxEngine.UIX;
using HarmonyLib;

[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("art0007i")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyFileVersion("2.1.1.0")]
[assembly: AssemblyInformationalVersion("2.1.1+2aeac473445baca055a8920542bc38b803d184ca")]
[assembly: AssemblyProduct("ColorDrop")]
[assembly: AssemblyTitle("ColorDrop")]
[assembly: AssemblyMetadata("RepositoryUrl", "https://github.com/art0007i/ColorDrop")]
[assembly: AssemblyVersion("2.1.1.0")]
[module: RefSafetyRules(11)]
namespace ColorDrop;

[ResonitePlugin("art0007i.ColorDrop", "ColorDrop", "2.1.1", "art0007i", "https://github.com/art0007i/ColorDrop")]
[BepInDependency(/*Could not decode attribute arguments.*/)]
public class Plugin : BasePlugin
{
	[HarmonyPatch(typeof(PrimitiveTryParsers), "GetParser", new global::System.Type[] { typeof(string) })]
	private static class PrimitiveTryParsers_GetParser_Patch
	{
		private static readonly TryParser ColorParser = (TryParser)delegate(string str, out object parsed)
		{
			//IL_0015: Unknown result type (might be due to invalid IL or missing references)
			color val = default(color);
			if (color.TryParse(str, (NumberStyles)167, (IFormatProvider)(object)CultureInfo.InvariantCulture, ref val))
			{
				parsed = val;
				return true;
			}
			parsed = null;
			return false;
		};

		private static readonly TryParser ColorXParser = (TryParser)delegate(string str, out object parsed)
		{
			//IL_0015: Unknown result type (might be due to invalid IL or missing references)
			colorX val = default(colorX);
			if (colorX.TryParse(str, (NumberStyles)167, (IFormatProvider)(object)CultureInfo.InvariantCulture, ref val))
			{
				parsed = val;
				return true;
			}
			parsed = null;
			return false;
		};

		private static bool Prefix(string typename, ref TryParser __result)
		{
			if (!(typename == "color"))
			{
				if (typename == "colorX")
				{
					__result = ColorXParser;
					return false;
				}
				return true;
			}
			__result = ColorParser;
			return false;
		}
	}

	[HarmonyPatch(typeof(ColorMemberEditorBase), "BuildUI")]
	private static class ColorMemberEditor_BuildUI_Patch
	{
		private static readonly MethodInfo openColorPickerMethod = typeof(ColorMemberEditorBase).GetMethod("OpenColorPicker", AccessTools.allDeclared);

		private static bool Prefix(ColorMemberEditorBase __instance, UIBuilder ui, RelayRef<IField> ____target, Sync<string> ____path, FieldDrive<colorX> ____colorDrive, FieldDrive<colorX> ____colorDriveNoAlpha)
		{
			//IL_00b7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00bc: Unknown result type (might be due to invalid IL or missing references)
			//IL_0129: Unknown result type (might be due to invalid IL or missing references)
			//IL_012e: Unknown result type (might be due to invalid IL or missing references)
			//IL_019b: Unknown result type (might be due to invalid IL or missing references)
			//IL_01a0: Unknown result type (might be due to invalid IL or missing references)
			//IL_020d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0212: Unknown result type (might be due to invalid IL or missing references)
			//IL_0363: Unknown result type (might be due to invalid IL or missing references)
			//IL_036a: Expected O, but got Unknown
			//IL_037f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0386: Expected O, but got Unknown
			if (!Enabled.Value)
			{
				return true;
			}
			ButtonEventHandler val = AccessTools.MethodDelegate<ButtonEventHandler>(openColorPickerMethod, (object)__instance, true, (global::System.Type[])null);
			bool supressLayoutElement = ui.Style.SupressLayoutElement;
			if (((SyncField<bool>)(object)__instance.Vertical).Value)
			{
				ui.Style.SupressLayoutElement = true;
			}
			ui.HorizontalLayout(2f, 0f, (Alignment?)null);
			if (((SyncField<bool>)(object)__instance.Vertical).Value)
			{
				ui.VerticalLayout(2f, 0f, (Alignment?)null, (bool?)null, (bool?)null);
				ui.Style.SupressLayoutElement = supressLayoutElement;
			}
			if (((SyncField<bool>)(object)__instance.Labels).Value)
			{
				LocaleString val2 = LocaleString.op_Implicit("R");
				ui.Text(ref val2, true, (Alignment?)null, true, (string)null);
			}
			ui.Style.FlexibleWidth = 10f;
			UIBuilderEditors.PrimitiveMemberEditor(ui, ((SyncRef<IField>)(object)____target).Target, Sync<string>.op_Implicit(____path) + ".r", true, "0.##");
			ui.Style.FlexibleWidth = -1f;
			if (((SyncField<bool>)(object)__instance.Labels).Value)
			{
				LocaleString val2 = LocaleString.op_Implicit("G");
				ui.Text(ref val2, true, (Alignment?)null, true, (string)null);
			}
			ui.Style.FlexibleWidth = 10f;
			UIBuilderEditors.PrimitiveMemberEditor(ui, ((SyncRef<IField>)(object)____target).Target, Sync<string>.op_Implicit(____path) + ".g", true, "0.##");
			ui.Style.FlexibleWidth = -1f;
			if (((SyncField<bool>)(object)__instance.Labels).Value)
			{
				LocaleString val2 = LocaleString.op_Implicit("B");
				ui.Text(ref val2, true, (Alignment?)null, true, (string)null);
			}
			ui.Style.FlexibleWidth = 10f;
			UIBuilderEditors.PrimitiveMemberEditor(ui, ((SyncRef<IField>)(object)____target).Target, Sync<string>.op_Implicit(____path) + ".b", true, "0.##");
			ui.Style.FlexibleWidth = -1f;
			if (((SyncField<bool>)(object)__instance.Labels).Value)
			{
				LocaleString val2 = LocaleString.op_Implicit("A");
				ui.Text(ref val2, true, (Alignment?)null, true, (string)null);
			}
			ui.Style.FlexibleWidth = 10f;
			UIBuilderEditors.PrimitiveMemberEditor(ui, ((SyncRef<IField>)(object)____target).Target, Sync<string>.op_Implicit(____path) + ".a", true, "0.##");
			ui.Style.FlexibleWidth = -1f;
			if (((SyncField<bool>)(object)__instance.Vertical).Value)
			{
				ui.NestOut();
			}
			ui.Style.MinWidth = 64f;
			ui.PushStyle();
			ui.Panel();
			Button val3 = ui.Button((Uri)null, val);
			Text val4 = ((ContainerWorker<Component>)(object)((Component)val3).Slot).AttachComponent<Text>(true, (Action<Text>)null);
			((ComponentBase<Component>)(object)val4).Enabled = false;
			TextField val5 = ((ContainerWorker<Component>)(object)((Component)val3).Slot).AttachComponent<TextField>(true, (Action<TextField>)null);
			((ComponentBase<Component>)(object)val5).Enabled = false;
			val5.Text = val4;
			Traverse obj = Traverse.Create((object)((ContainerWorker<Component>)(object)((Component)val3).Slot).AttachComponent<PrimitiveMemberEditor>(true, (Action<PrimitiveMemberEditor>)null));
			obj.Field<SyncRef<TextEditor>>("_textEditor").Value.Target = SyncRef<TextEditor>.op_Implicit(val5.Editor);
			((SyncRef<IField>)(object)obj.Field<RelayRef<IField>>("_target").Value).Target = ((SyncRef<IField>)(object)____target).Target;
			((SyncRef<IField<string>>)(object)obj.Field<FieldDrive<string>>("_textDrive").Value).Target = (IField<string>)(object)val4.Content;
			ui.NestInto(((Component)val3).Slot);
			RectTransform val6 = default(RectTransform);
			RectTransform val7 = default(RectTransform);
			ui.SplitHorizontally(0.5f, ref val6, ref val7, 0f);
			UIBuilder val8 = new UIBuilder(val6);
			((LinkBase<IField<colorX>>)(object)____colorDriveNoAlpha).ForceLink((IField<colorX>)(object)val8.Image().Tint);
			UIBuilder val9 = new UIBuilder(val7);
			((SyncField<bool>)(object)((ImageBase)val9.Image(Backgrounds.TransparentLight64, (int?)null)).PreserveAspect).Value = false;
			((LinkBase<IField<colorX>>)(object)____colorDrive).ForceLink((IField<colorX>)(object)val9.Image().Tint);
			ui.NestOut();
			ui.NestOut();
			ui.NestOut();
			return false;
		}
	}

	internal static ManualLogSource Log;

	internal static ConfigEntry<bool> Enabled;

	public override void Load()
	{
		Log = ((BasePlugin)this).Log;
		Enabled = ((BasePlugin)this).Config.Bind<bool>("General", "Enabled", true, "Whether the mod is enabled.");
		((BasePlugin)this).HarmonyInstance.PatchAll();
	}
}
public static class PluginMetadata
{
	public const string GUID = "art0007i.ColorDrop";

	public const string NAME = "ColorDrop";

	public const string VERSION = "2.1.1";

	public const string AUTHORS = "art0007i";

	public const string REPOSITORY_URL = "https://github.com/art0007i/ColorDrop";
}