Decompiled source of MessageCopy v1.0.3

plugins/MessageCopy/MessageCopy.dll

Decompiled a day ago
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using BepInEx;
using BepInEx.Logging;
using BepInEx.NET.Common;
using BepInExResoniteShim;
using Elements.Core;
using FrooxEngine;
using FrooxEngine.UIX;
using HarmonyLib;
using SkyFrost.Base;

[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("1.0.3.0")]
[assembly: AssemblyInformationalVersion("1.0.3+4eed556d2b856b38ea6925062f484893a7afb89c")]
[assembly: AssemblyProduct("MessageCopy")]
[assembly: AssemblyTitle("MessageCopy")]
[assembly: AssemblyMetadata("RepositoryUrl", "https://github.com/art0007i/MessageCopy")]
[assembly: AssemblyVersion("1.0.3.0")]
[module: RefSafetyRules(11)]
namespace MessageCopy;

[ResonitePlugin("art0007i.MessageCopy", "MessageCopy", "1.0.3", "art0007i", "https://github.com/art0007i/MessageCopy")]
[BepInDependency(/*Could not decode attribute arguments.*/)]
public class Plugin : BasePlugin
{
	[HarmonyPatch(typeof(ContactsDialog), "AddMessage")]
	private class MessageCopyPatch
	{
		public static void Postfix(Image __result, UIBuilder ___messagesUi, Message message)
		{
			//IL_0012: Unknown result type (might be due to invalid IL or missing references)
			//IL_0017: 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_0034: Expected I4, but got Unknown
			//IL_00b1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ed: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f7: Expected O, but got Unknown
			//IL_00f8: Unknown result type (might be due to invalid IL or missing references)
			//IL_00fe: Invalid comparison between Unknown and I4
			//IL_0102: Unknown result type (might be due to invalid IL or missing references)
			//IL_0108: Invalid comparison between Unknown and I4
			//IL_008c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0091: 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_0191: Unknown result type (might be due to invalid IL or missing references)
			//IL_0196: Unknown result type (might be due to invalid IL or missing references)
			//IL_019c: Unknown result type (might be due to invalid IL or missing references)
			//IL_01a1: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ba: Unknown result type (might be due to invalid IL or missing references)
			//IL_012c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0131: Unknown result type (might be due to invalid IL or missing references)
			//IL_0137: 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)
			//IL_0142: Unknown result type (might be due to invalid IL or missing references)
			//IL_0147: Unknown result type (might be due to invalid IL or missing references)
			//IL_0160: Unknown result type (might be due to invalid IL or missing references)
			string copyText = "";
			MessageType messageType = message.MessageType;
			switch ((int)messageType)
			{
			case 0:
				return;
			case 1:
			case 2:
			{
				Record val2 = message.ExtractContent<Record>();
				copyText = val2.AssetURI;
				break;
			}
			case 3:
			{
				SessionInfo val = message.ExtractContent<SessionInfo>();
				copyText = val.SessionId + "\n" + string.Join("\n", (global::System.Collections.Generic.IEnumerable<string>)val.SessionURLs);
				break;
			}
			case 4:
				return;
			default:
				Log.LogWarning((object)("Unknown message type: " + ((object)message.MessageType/*cast due to .constrained prefix*/).ToString()));
				return;
			}
			Slot val3 = Enumerable.Last<Slot>((global::System.Collections.Generic.IEnumerable<Slot>)(object)((Component)__result).Slot.Children).AddSlot("Copy", true);
			___messagesUi.NestInto(val3);
			Button val4 = ___messagesUi.Button(Inspector.Duplicate);
			___messagesUi.NestOut();
			val4.LocalPressed += (ButtonEventHandler)delegate
			{
				Engine.Current.InputInterface.Clipboard.SetText(copyText);
			};
			bool flag = (int)message.MessageType == 3;
			bool flag2 = (int)message.MessageType == 2;
			if (message.IsSent && !flag && !flag2)
			{
				float2 val5 = default(float2);
				((float2)(ref val5))..ctor(2f, 0f);
				float2 one = float2.One;
				float2 val6 = (ref one) * 24;
				Rect val7 = new Rect(ref val5, ref val6);
				float2 val8 = default(float2);
				((float2)(ref val8))..ctor(0f, 0f);
				((UIComponent)val4).RectTransform.SetFixedRect(val7, ref val8);
			}
			else
			{
				float2 val9 = default(float2);
				((float2)(ref val9))..ctor(-26f, flag ? (-26f) : 0f);
				float2 one2 = float2.One;
				float2 val10 = (ref one2) * 24;
				Rect val11 = new Rect(ref val9, ref val10);
				float2 val12 = default(float2);
				((float2)(ref val12))..ctor(1f, (float)(flag ? 1 : 0));
				((UIComponent)val4).RectTransform.SetFixedRect(val11, ref val12);
			}
			HoverArea component = ((ContainerWorker<Component>)(object)((Component)__result).Slot).GetComponent<HoverArea>((Predicate<HoverArea>)null, false);
			ValueCopyExtensions.DriveFrom<bool>((IField<bool>)(object)val3.ActiveSelf_Field, (IField<bool>)(object)component.IsHovering, false, false, true);
		}
	}

	internal static ManualLogSource Log;

	public override void Load()
	{
		Log = ((BasePlugin)this).Log;
		((BasePlugin)this).HarmonyInstance.PatchAll();
	}
}
public static class PluginMetadata
{
	public const string GUID = "art0007i.MessageCopy";

	public const string NAME = "MessageCopy";

	public const string VERSION = "1.0.3";

	public const string AUTHORS = "art0007i";

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