Decompiled source of HihCntpany v1.0.0

plugins/WatermarkRemover.dll

Decompiled 8 months ago
using System;
using System.Diagnostics;
using System.IO;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using BepInEx;
using BepInEx.Configuration;
using Microsoft.CodeAnalysis;
using MonoMod.Cil;
using MonoMod.RuntimeDetour;
using UnityEngine;
using UnityEngine.UI;
using Utils;

[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: AssemblyCompany("WatermarkRemover")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0+46fb932dc12bb82847bbcfeae00bd3ebb19e2de7")]
[assembly: AssemblyProduct("WatermarkRemover")]
[assembly: AssemblyTitle("WatermarkRemover")]
[assembly: AssemblyVersion("1.0.0.0")]
[module: RefSafetyRules(11)]
internal class <Module>
{
	static <Module>()
	{
	}
}
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;
		}
	}
}
internal static class ToolModules
{
	private static Hook? menuManagerUpdateHook;

	private static Hook? menuManagerStartHook;

	private static Transform? loadingScreenImageTransform;

	private static Transform? headerImageTransform;

	private static Transform? loadingImageTransform;

	private static Sprite OriginalLogo;

	public static void InitHooks()
	{
		menuManagerUpdateHook = HookUtils.NewHook<MenuManager>("Update", typeof(ToolModules), "OnMenuManagerUpdate");
		menuManagerUpdateHook = HookUtils.NewHook<MenuManager>("Start", typeof(ToolModules), "OnMenuManagerStart");
	}

	private static void OnMenuManagerUpdate(Action<MenuManager> orig, MenuManager self)
	{
		//IL_0074: Unknown result type (might be due to invalid IL or missing references)
		//IL_0127: Unknown result type (might be due to invalid IL or missing references)
		orig(self);
		try
		{
			if (loadingScreenImageTransform == null)
			{
				loadingScreenImageTransform = ((Component)self).transform.parent.Find("MenuContainer/LoadingScreen/Image");
			}
			if (loadingScreenImageTransform != null)
			{
				Graphic[] componentsInChildren = ((Component)loadingScreenImageTransform).GetComponentsInChildren<Graphic>();
				foreach (Graphic val in componentsInChildren)
				{
					if (!((Object)(object)((Component)val).transform == (Object)(object)loadingScreenImageTransform))
					{
						val.color = Color.clear;
					}
				}
			}
			if (headerImageTransform == null)
			{
				headerImageTransform = ((Component)self).transform.parent.Find("MenuContainer/MainButtons/HeaderImage");
			}
			if (loadingImageTransform == null)
			{
				loadingImageTransform = ((Component)self).transform.parent.Find("MenuContainer/LoadingScreen/Image");
			}
			if (headerImageTransform != null)
			{
				Graphic[] componentsInChildren2 = ((Component)headerImageTransform).GetComponentsInChildren<Graphic>();
				foreach (Graphic val2 in componentsInChildren2)
				{
					if (!((Object)(object)((Component)val2).transform == (Object)(object)headerImageTransform))
					{
						val2.color = Color.clear;
					}
				}
			}
			if (WatermarkRemoverPlugin.disableLogoChanges.Value)
			{
				try
				{
					((Component)headerImageTransform).GetComponent<Image>().sprite = WatermarkRemoverPlugin.logo2;
				}
				catch (Exception)
				{
				}
				try
				{
					((Component)loadingImageTransform).GetComponent<Image>().sprite = WatermarkRemoverPlugin.logo2;
					return;
				}
				catch (Exception)
				{
					throw;
				}
			}
		}
		catch (Exception)
		{
		}
	}

	private static void OnMenuManagerStart(Action<MenuManager> orig, MenuManager self)
	{
		orig(self);
		loadingScreenImageTransform = null;
		headerImageTransform = null;
		loadingImageTransform = null;
	}
}
[BepInPlugin("flowerwater.watermarkremover", "Watermark Remover", "1.1.4")]
public class WatermarkRemoverPlugin : BaseUnityPlugin
{
	public const string ModGuid = "flowerwater.watermarkremover";

	public const string ModName = "Watermark Remover";

	public const string ModVersion = "1.1.4";

	public static ConfigEntry<bool> disableLogoChanges;

	public static byte[] logo;

	public static Sprite logo2;

	private void Awake()
	{
		//IL_00c2: Unknown result type (might be due to invalid IL or missing references)
		//IL_00d1: Unknown result type (might be due to invalid IL or missing references)
		//IL_00f1: Unknown result type (might be due to invalid IL or missing references)
		disableLogoChanges = ((BaseUnityPlugin)this).Config.Bind<bool>("Settings", "Disable Logo Changes", false, "Prevents the Logo from being changed aswell. (Technically this pulls a random image from the Folder™\ufe0f and uses that for the logo so this can be used to have random logos if you want to.)");
		ToolModules.InitHooks();
		string path = Path.Combine(Path.GetDirectoryName(((BaseUnityPlugin)this).Info.Location), "Folder");
		int num = Random.Range(0, Directory.GetFiles(path).Length);
		int num2 = 0;
		string[] files = Directory.GetFiles(path);
		foreach (string path2 in files)
		{
			if (num2 == num)
			{
				logo = File.ReadAllBytes(path2);
			}
			num2++;
		}
		Texture2D val = LoadTexture(logo, 545, 249);
		logo2 = Sprite.Create(val, new Rect(0f, 0f, (float)((Texture)val).width, (float)((Texture)val).height), new Vector2(272.5f, 124.5f), 100f, 1u, (SpriteMeshType)1, new Vector4(0f, 0f, 0f, 0f), true);
	}

	public static Texture2D LoadTexture(byte[] bytes, int width, int height)
	{
		//IL_0006: Unknown result type (might be due to invalid IL or missing references)
		//IL_000c: Expected O, but got Unknown
		Texture2D val = new Texture2D(width, height, (TextureFormat)5, false, false);
		ImageConversion.LoadImage(val, bytes);
		((Texture)val).filterMode = (FilterMode)0;
		return val;
	}
}
namespace Utils
{
	internal static class HookUtils
	{
		private const BindingFlags DefaultFlags = BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic;

		private const BindingFlags StaticFlags = BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic;

		public static Hook NewHook<TTarget, TDest>(string targetMethodName, string destMethodName, TDest instance)
		{
			//IL_002f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0035: Expected O, but got Unknown
			MethodInfo method = typeof(TTarget).GetMethod(targetMethodName, BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic);
			MethodInfo method2 = typeof(TDest).GetMethod(destMethodName, BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic);
			return new Hook((MethodBase)method, method2, (object)instance);
		}

		public static Hook NewHook<TTarget>(string targetMethodName, MethodInfo destMethod)
		{
			//IL_0016: Unknown result type (might be due to invalid IL or missing references)
			//IL_001c: Expected O, but got Unknown
			MethodInfo method = typeof(TTarget).GetMethod(targetMethodName, BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic);
			return new Hook((MethodBase)method, destMethod);
		}

		public static Hook NewHook<TTarget>(string targetMethodName, Type destType, string destMethodName)
		{
			//IL_0020: Unknown result type (might be due to invalid IL or missing references)
			//IL_0026: Expected O, but got Unknown
			MethodInfo method = typeof(TTarget).GetMethod(targetMethodName, BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic);
			MethodInfo method2 = destType.GetMethod(destMethodName, BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic);
			return new Hook((MethodBase)method, method2);
		}

		public static ILHook NewILHook<TTarget>(string targetMethodName, Manipulator manipulator)
		{
			//IL_0016: Unknown result type (might be due to invalid IL or missing references)
			//IL_001c: Expected O, but got Unknown
			MethodInfo method = typeof(TTarget).GetMethod(targetMethodName, BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic);
			return new ILHook((MethodBase)method, manipulator);
		}
	}
}