Decompiled source of MoreRevamp v1.0.4

MoreRevamp.dll

Decompiled a week ago
using System;
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using BepInEx;
using BepInEx.Logging;
using HarmonyLib;
using Microsoft.CodeAnalysis;
using TMPro;
using UnityEngine;
using UnityEngine.AddressableAssets;
using UnityEngine.UI;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")]
[assembly: AssemblyCompany("MoreRevamp")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0+81e6a2062cefcaa2dc724dc0f00869c02e0502cf")]
[assembly: AssemblyProduct("MoreRevamp")]
[assembly: AssemblyTitle("MoreRevamp")]
[assembly: AssemblyVersion("1.0.0.0")]
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;
		}
	}
}
namespace MoreRevamp
{
	[BepInPlugin("com.github.end-4.moreRevamp", "MoreRevamp", "1.0.4")]
	public class Plugin : BaseUnityPlugin
	{
		internal static ManualLogSource Log;

		private static Sprite _largeBorderSprite = Addressables.LoadAssetAsync<Sprite>((object)"Assets/Textures/UI/Controls/Round_BorderLarge.png").WaitForCompletion();

		private static Sprite _smallBorderSprite = Addressables.LoadAssetAsync<Sprite>((object)"Assets/Textures/UI/Controls/Round_BorderSmall.png").WaitForCompletion();

		private static Sprite _largeFillSprite = Addressables.LoadAssetAsync<Sprite>((object)"Assets/Textures/UI/Controls/Round_FillLarge.png").WaitForCompletion();

		private static Sprite _smallFillSprite = Addressables.LoadAssetAsync<Sprite>((object)"Assets/Textures/UI/Controls/Round_FillSmall.png").WaitForCompletion();

		private static Sprite _crossSprite = Addressables.LoadAssetAsync<Sprite>((object)"Assets/Textures/UI/Controls/Check.png").WaitForCompletion();

		private static Sprite _dropdownBorderSprite = Addressables.LoadAssetAsync<Sprite>((object)"Assets/Textures/UI/Controls/Round_DropdownPanel.png").WaitForCompletion();

		private static readonly float PixelsPerUnitMultiplier = 5.4f;

		public static string GetObjectPath(GameObject g)
		{
			string text = ((Object)g).name;
			while ((Object)(object)g.transform.parent != (Object)null)
			{
				g = ((Component)g.transform.parent).gameObject;
				text = ((Object)g).name + "/" + text;
			}
			return text;
		}

		private void Awake()
		{
			//IL_0010: Unknown result type (might be due to invalid IL or missing references)
			Log = ((BaseUnityPlugin)this).Logger;
			new Harmony("MoreRevamp").PatchAll();
			Log.LogInfo((object)"Patches applied");
		}

		private static void ApplyImageSprite(Image image, Sprite sourceSprite)
		{
			//IL_0007: 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_000e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0013: Unknown result type (might be due to invalid IL or missing references)
			//IL_002d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0034: Unknown result type (might be due to invalid IL or missing references)
			RectTransform rectTransform = ((Graphic)image).rectTransform;
			Vector2 sizeDelta = rectTransform.sizeDelta;
			Color color = ((Graphic)image).color;
			image.sprite = sourceSprite;
			image.type = (Type)1;
			image.pixelsPerUnitMultiplier = PixelsPerUnitMultiplier;
			rectTransform.sizeDelta = sizeDelta;
			((Graphic)image).color = color;
		}

		public static void ApplyLargeBorder(Image image)
		{
			ApplyImageSprite(image, _largeBorderSprite);
		}

		public static void ApplySmallBorder(Image image)
		{
			ApplyImageSprite(image, _smallBorderSprite);
		}

		public static void ApplyLargeFill(Image image)
		{
			ApplyImageSprite(image, _largeFillSprite);
		}

		public static void ApplySmallFill(Image image)
		{
			ApplyImageSprite(image, _smallFillSprite);
		}

		public static void ApplyDropdownBorder(Image image)
		{
			ApplyImageSprite(image, _dropdownBorderSprite);
		}

		public static void ApplyCross(Image image)
		{
			ApplyImageSprite(image, _crossSprite);
		}

		public static void ForceUIColor(Image image)
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			((Graphic)image).color = Color.white;
		}

		public static void ChangeSize(Image image, float width, float height)
		{
			//IL_0008: Unknown result type (might be due to invalid IL or missing references)
			((Graphic)image).rectTransform.sizeDelta = new Vector2(width, height);
		}

		public static void ChangeAnchor(Image image, float x, float y)
		{
			//IL_0008: Unknown result type (might be due to invalid IL or missing references)
			((Graphic)image).rectTransform.anchoredPosition = new Vector2(x, y);
		}

		public static void ApplyUIComponentColors(Selectable d)
		{
			//IL_0001: 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_001d: 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_0042: Unknown result type (might be due to invalid IL or missing references)
			//IL_0047: Unknown result type (might be due to invalid IL or missing references)
			//IL_005f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0064: 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)
			ColorBlock colors = d.colors;
			((ColorBlock)(ref colors)).normalColor = Color32.op_Implicit(new Color32(byte.MaxValue, byte.MaxValue, byte.MaxValue, byte.MaxValue));
			((ColorBlock)(ref colors)).selectedColor = Color32.op_Implicit(new Color32((byte)130, (byte)130, (byte)130, byte.MaxValue));
			((ColorBlock)(ref colors)).pressedColor = Color32.op_Implicit(new Color32(byte.MaxValue, (byte)0, (byte)0, byte.MaxValue));
			d.colors = colors;
		}

		public static void ForceRGBAmount(Image image, float amount, float hasColorThreshold = 0f)
		{
			//IL_0001: 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)
			//IL_002f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0046: Unknown result type (might be due to invalid IL or missing references)
			//IL_0056: Unknown result type (might be due to invalid IL or missing references)
			float num = ((((Graphic)image).color.r > hasColorThreshold) ? amount : 0f);
			float num2 = ((((Graphic)image).color.g > hasColorThreshold) ? amount : 0f);
			float num3 = ((((Graphic)image).color.b > hasColorThreshold) ? amount : 0f);
			float a = ((Graphic)image).color.a;
			((Graphic)image).color = new Color(num, num2, num3, a);
		}

		public static void HideImage(Image image)
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			((Graphic)image).color = Color.clear;
		}
	}
	[HarmonyPatch(typeof(Image), "OnEnable")]
	public static class ImagePatch
	{
		[HarmonyPostfix]
		public static void Postfix(Image __instance)
		{
			//IL_065e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0672: Unknown result type (might be due to invalid IL or missing references)
			string objectPath = Plugin.GetObjectPath(((Component)__instance).gameObject);
			string text = ((Object)__instance).name.ToLower();
			bool flag = (Object)(object)((Component)__instance).GetComponent<Button>() != (Object)null;
			bool flag2 = (Object)(object)((Component)__instance).GetComponent<TMP_Dropdown>() != (Object)null;
			bool flag3 = (Object)(object)((Component)__instance).GetComponent<Dropdown>() != (Object)null;
			bool flag4 = (Object)(object)((Component)__instance).GetComponent<TMP_InputField>() != (Object)null;
			bool flag5 = ((Object)((Graphic)__instance).mainTexture).name == "Background" || ((Object)((Graphic)__instance).mainTexture).name == "UISprite";
			bool flag6 = objectPath.Contains("Skippables");
			bool flag7 = objectPath.Contains("ConcretePanel(Clone)") || objectPath.Contains("PresetPanel(Clone)") || objectPath.Contains("PluginConfigField");
			bool flag8 = objectPath.Contains("AngryLeaderboardNotification");
			bool flag9 = objectPath.Contains("FinishCanvas") && (Object)(object)((Graphic)__instance).mainTexture != (Object)null && flag5;
			bool flag10 = ((Object)__instance).name == "Border" && (objectPath.Contains("ConfigurationMenu(Clone)") || objectPath.Contains("UI_Button_Image"));
			bool flag11 = ((Object)((Graphic)__instance).mainTexture).name == "UISprite";
			bool flag12 = ((Object)__instance).name == "PresetButton(Clone)";
			bool flag13 = flag7 && ((Object)__instance).name == "InputField";
			bool flag14 = ((Object)__instance).name == "Dropdown";
			bool flag15 = ((Object)__instance).name == "Dropdown" || ((Object)__instance).name == "DifficultyDropdown" || ((Object)__instance).name == "GamemodeDropdown";
			bool flag16 = objectPath.Contains("Viewport") && ((Object)__instance).name == "Item Background";
			bool flag17 = (objectPath.Contains("DropdownField(Clone)/Dropdown/") || objectPath.Contains("Dropdown/Dropdown") || ((Object)__instance).name == "Dropdown List") && !text.Contains("checkmark");
			bool flag18 = (objectPath.Contains("DropdownField") || objectPath.Contains("GamemodeDropdown") || objectPath.Contains("DifficultyDropdown")) && ((Object)__instance).name == "Arrow";
			bool flag19 = flag7 && objectPath.Contains("Toggle") && ((Object)__instance).name == "Background";
			bool flag20 = flag7 && objectPath.Contains("Toggle/Background") && ((Object)__instance).name == "Checkmark";
			bool flag21 = flag7 && objectPath.Contains("ColorField(Clone)") && ((Object)__instance).name == "Image";
			bool flag22 = flag7 && objectPath.Contains("ColorField(Clone)") && objectPath.Contains("Button/Slider") && ((Object)__instance).name == "Background";
			bool flag23 = flag7 && objectPath.Contains("ColorField(Clone)") && objectPath.Contains("Slider/Fill Area") && ((Object)__instance).name == "Fill";
			bool flag24 = flag7 && objectPath.Contains("ColorField(Clone)") && objectPath.Contains("Slider/Handle Slide Area") && ((Object)__instance).name == "Handle";
			bool flag25 = flag7 && objectPath.Contains("Slider") && ((Object)__instance).name == "Background";
			bool flag26 = flag7 && objectPath.Contains("Slider/Fill Area") && ((Object)__instance).name == "Fill";
			bool flag27 = flag7 && objectPath.Contains("Handle Slide Area") && ((Object)__instance).name == "Handle";
			bool flag28 = text.Contains("upvote") || text.Contains("downvote");
			bool flag29 = text.Contains("thumbnail");
			bool flag30 = ((Object)__instance).name.StartsWith("FavButton");
			bool flag31 = (text.StartsWith("button") || text.StartsWith("frame")) && objectPath.Contains("BundleSortField");
			bool flag32 = text.StartsWith("bg") && objectPath.Contains("BundleSortField");
			bool flag33 = ((Object)__instance).name == "SearchBar(Clone)";
			bool flag34 = ((Object)__instance).name == "RankIcon(Clone)";
			bool flag35 = ((Object)__instance).name == "Dropdown" && objectPath.Contains("FilterColumnsRoot/FilterLeftColumn");
			if ((!((Object)(object)((Component)__instance).GetComponent<HudOpenEffect>() != (Object)null) || ((Object)(object)((Component)__instance).GetComponent<Button>() != (Object)null && flag6) || flag9) && !(flag28 || flag29 || flag30 || flag35))
			{
				if (flag10 || (flag && (flag7 || flag6 || flag8 || flag12)) || (flag2 && flag14) || (flag3 && flag15) || (flag4 && flag13) || flag22 || flag33 || flag34 || flag31 || flag25)
				{
					Plugin.ApplyLargeBorder(__instance);
				}
				else if (flag18 || flag19)
				{
					Plugin.ApplySmallBorder(__instance);
				}
				else if (flag20)
				{
					Plugin.ApplyCross(__instance);
				}
				else if (flag11 || flag9 || flag5)
				{
					Plugin.ApplyLargeFill(__instance);
				}
				else if (flag21 || flag23 || flag24 || flag27 || flag32 || flag26)
				{
					Plugin.ApplySmallFill(__instance);
				}
				else if (flag17)
				{
					Plugin.ApplyDropdownBorder(__instance);
				}
				if (flag14 || flag15 || flag18 || flag19 || flag20 || flag13 || flag17)
				{
					Plugin.ForceUIColor(__instance);
				}
				if (flag19)
				{
					Plugin.ChangeSize(__instance, -10f, -10f);
				}
				else if (flag20)
				{
					Plugin.ChangeSize(__instance, -10f, -10f);
				}
				else if (flag14 || (flag4 && flag13) || flag3)
				{
					Plugin.ApplyUIComponentColors(((Component)__instance).GetComponent<Selectable>());
				}
				else if (flag18)
				{
					Plugin.ChangeSize(__instance, 11f, 20f);
					Plugin.ChangeAnchor(__instance, -10f, 0f);
				}
				else if (flag22 || flag25)
				{
					Plugin.ChangeSize(__instance, 0f, 10f);
					Plugin.ForceRGBAmount(__instance, 0.67f, 0.27f);
				}
				else if (flag23 || flag26)
				{
					Plugin.ChangeAnchor(__instance, 5f, 0f);
					Plugin.ForceRGBAmount(__instance, 0.33f, 0.27f);
				}
				else if (flag24 || flag27)
				{
					Plugin.ChangeSize(__instance, 10f, -10f);
					Plugin.ForceRGBAmount(__instance, 1f, 0.27f);
				}
				else if (flag17)
				{
					RectTransform rectTransform = ((Graphic)__instance).rectTransform;
					rectTransform.pivot = new Vector2(0f, 1f);
					rectTransform.sizeDelta = new Vector2(-7f, 148f);
				}
				else if (flag16)
				{
					Plugin.HideImage(__instance);
				}
				else if (flag32)
				{
					Plugin.ChangeSize(__instance, -4f, -4f);
				}
			}
		}
	}
}