Decompiled source of Cosmo Bums Pizdec v1.0.2

Emblem.dll

Decompiled 8 months ago
using System;
using System.Collections;
using System.Diagnostics;
using System.IO;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Runtime.Versioning;
using System.Text.RegularExpressions;
using BepInEx;
using BepInEx.Configuration;
using BepInEx.Logging;
using Emblem;
using Emblem.Components;
using Emblem.Managers;
using HarmonyLib;
using TMPro;
using UnityEngine;
using UnityEngine.EventSystems;
using UnityEngine.Events;
using UnityEngine.SceneManagement;
using UnityEngine.UI;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: AssemblyTitle("Emblem")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("Emblem")]
[assembly: AssemblyCopyright("Copyright ©  2024")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: Guid("e4927ee1-3a47-4f93-8784-804356949316")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: TargetFramework(".NETFramework,Version=v4.7.2", FrameworkDisplayName = ".NET Framework 4.7.2")]
[assembly: AssemblyVersion("1.0.0.0")]
[BepInPlugin("Darkbrewery.Emblem", "Emblem", "1.1.0")]
public class EmblemPlugin : BaseUnityPlugin
{
	private UIComponent uiComponent;

	private ImageReplacementComponent imageReplacementComponent;

	private Boardwalk boardwalk;

	private LoadingTextComponent loadingTextComponent;

	private MenuMoodSetter menuMoodSetter;

	private Harmony harmony;

	private Configurator configManager;

	private CustomImageManager customImageManager;

	private SceneManagerHelper sceneManagerHelper;

	private InterfaceDecorator interfaceDecorator;

	private void Awake()
	{
		//IL_001b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0025: Expected O, but got Unknown
		LogWarden.Initialize(((BaseUnityPlugin)this).Logger);
		LogWarden.LogInfo("Stirring from darkness...");
		try
		{
			harmony = new Harmony("com.darkbrewery.emblem.harmony");
			configManager = new Configurator(((BaseUnityPlugin)this).Config);
			customImageManager = new CustomImageManager();
			uiComponent = new UIComponent(configManager);
			imageReplacementComponent = new ImageReplacementComponent(configManager, uiComponent, customImageManager);
			boardwalk = new Boardwalk(configManager);
			loadingTextComponent = ((Component)this).gameObject.AddComponent<LoadingTextComponent>();
			loadingTextComponent.Initialize(configManager);
			menuMoodSetter = new MenuMoodSetter(configManager);
			interfaceDecorator = new InterfaceDecorator(uiComponent, imageReplacementComponent, boardwalk, loadingTextComponent, menuMoodSetter);
			sceneManagerHelper = new SceneManagerHelper(interfaceDecorator);
			harmony.PatchAll();
			LogWarden.LogInfo("Successfully deployed, its intent shrouded");
		}
		catch (Exception arg)
		{
			LogWarden.LogError($"Error initializing Emblem plugin: {arg}");
		}
	}
}
public class DelayHelper : MonoBehaviour
{
	public static void StartDelayedAction(float delayInSeconds, Action action)
	{
		//IL_0005: Unknown result type (might be due to invalid IL or missing references)
		new GameObject("DelayHelperObject").AddComponent<DelayHelper>().DelayedAction(delayInSeconds, action);
	}

	private void DelayedAction(float delayInSeconds, Action action)
	{
		((MonoBehaviour)this).StartCoroutine(DelayCoroutine(delayInSeconds, action));
	}

	private IEnumerator DelayCoroutine(float delayInSeconds, Action action)
	{
		yield return (object)new WaitForSeconds(delayInSeconds);
		action?.Invoke();
		Object.Destroy((Object)(object)((Component)this).gameObject);
	}
}
namespace Emblem
{
	public static class ColorParser
	{
		public static Color ParseColor(string colorString)
		{
			//IL_0071: 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)
			string[] array = colorString.Split(new char[1] { ',' });
			if (array.Length != 4)
			{
				return Color.white;
			}
			float num = Mathf.Clamp01((float)int.Parse(array[0]) / 255f);
			float num2 = Mathf.Clamp01((float)int.Parse(array[1]) / 255f);
			float num3 = Mathf.Clamp01((float)int.Parse(array[2]) / 255f);
			float num4 = Mathf.Clamp01(float.Parse(array[3]));
			return new Color(num, num2, num3, num4);
		}
	}
	public static class LogWarden
	{
		private static ManualLogSource loggerInstance;

		public static void Initialize(ManualLogSource logger)
		{
			loggerInstance = logger;
		}

		public static void LogError(string message)
		{
			ManualLogSource obj = loggerInstance;
			if (obj != null)
			{
				obj.LogError((object)message);
			}
		}

		public static void LogWarning(string message)
		{
			ManualLogSource obj = loggerInstance;
			if (obj != null)
			{
				obj.LogWarning((object)message);
			}
		}

		public static void LogInfo(string message)
		{
			ManualLogSource obj = loggerInstance;
			if (obj != null)
			{
				obj.LogInfo((object)message);
			}
		}
	}
	public static class PathFinder
	{
		public static Transform Probe(string path)
		{
			Transform val = null;
			string[] array = path.Split(new char[1] { '/' });
			foreach (string text in array)
			{
				if ((Object)(object)val == (Object)null)
				{
					GameObject obj = GameObject.Find(text);
					val = ((obj != null) ? obj.transform : null);
				}
				else
				{
					val = val.Find(text);
				}
				if ((Object)(object)val == (Object)null)
				{
					GameObject[] array2 = Resources.FindObjectsOfTypeAll<GameObject>();
					foreach (GameObject val2 in array2)
					{
						if (((Object)val2).name == text)
						{
							val = val2.transform;
							break;
						}
					}
				}
				if ((Object)(object)val == (Object)null)
				{
					LogWarden.LogError("Element '" + text + "' not found in path '" + path + "'.");
					return null;
				}
			}
			return val;
		}
	}
	public static class UI
	{
		public const string MainMenu = "MainMenu";

		public const string MenuCont = "MenuContainer";

		public const string LoadScreen = "LoadingScreen";

		public const string LoadTextCont = "LoadingTextContainer";

		public const string LoadText = "LoadingText";

		public const string HeaderImg = "HeaderImage";

		public const string MainBtns = "MainButtons";

		public const string CustBgImg = "CustomBackgroundImage";

		public const string MenuBdr = "MenuBorder";
	}
}
namespace Emblem.Managers
{
	public class Configurator
	{
		public readonly ConfigFile config;

		public ConfigEntry<bool> replaceHeaderImageConfig { get; private set; }

		public ConfigEntry<float> HeaderYOffset { get; private set; }

		public ConfigEntry<int> headerImageScaleConfig { get; private set; }

		public ConfigEntry<int> headerImageTransparencyConfig { get; private set; }

		public ConfigEntry<bool> useMainMenuBackgroundConfig { get; private set; }

		public ConfigEntry<bool> enableCanvasRecoloring { get; private set; }

		public ConfigEntry<string> menuContainerColorConfig { get; private set; }

		public ConfigEntry<bool> replaceLoadingImageConfig { get; private set; }

		public ConfigEntry<float> LoadingYOffset { get; private set; }

		public ConfigEntry<bool> stretchLoadingImageConfig { get; private set; }

		public ConfigEntry<string> headerImageFilePathConfig { get; private set; }

		public ConfigEntry<string> loadingImageFilePathConfig { get; private set; }

		public ConfigEntry<string> mainMenuBackgroundPathConfig { get; private set; }

		public ConfigEntry<bool> hideMainMenuBorderConfig { get; private set; }

		public ConfigEntry<string> borderColorConfig { get; private set; }

		public ConfigEntry<bool> enableLoadingTextChange { get; private set; }

		public ConfigEntry<string> loadingTextConfig { get; private set; }

		public ConfigEntry<string> fontColorConfig { get; private set; }

		public ConfigEntry<float> fontSizeConfig { get; private set; }

		public ConfigEntry<bool> wrapTextConfig { get; private set; }

		public ConfigEntry<bool> centerTextVerticallyConfig { get; private set; }

		public ConfigEntry<bool> enableMenuColorChange { get; private set; }

		public ConfigEntry<string> MenuFontColor { get; private set; }

		public ConfigEntry<string> MenuRolloverBGColor { get; private set; }

		public ConfigEntry<string> MenuRolloverFontColor { get; private set; }

		public Configurator(ConfigFile config)
		{
			this.config = config;
			Initialize();
		}

		private void Initialize()
		{
			replaceHeaderImageConfig = BindConfig("1. Main Menu Logo", "ReplaceHeaderImage", defaultValue: false, "Enable or disable header image replacement. This is the main menu logo");
			headerImageFilePathConfig = BindConfig("1. Main Menu Logo", "HeaderImageFilePath", "config/Emblem/Header", "Relative to BepInEx folder: Specify a .png file, or a directory to randomly select an image starting with the prefix 'Header'.");
			HeaderYOffset = BindConfig("1. Main Menu Logo", "HeaderYOffset", -1f, "Vertical offset percentage from the top for the header image. Set to -1 to indicate no adjustment.");
			headerImageScaleConfig = BindConfig("1. Main Menu Logo", "HeaderImageScale", 100, "Scale of the header image. This will maintain aspect ratio.");
			headerImageTransparencyConfig = BindConfig("1. Main Menu Logo", "HeaderImageTransparency", 100, "Transparency of the header image. 0 for completely transparent and 100 for completely opaque.");
			useMainMenuBackgroundConfig = BindConfig("2. Main Menu Background", "UseMainMenuBackground", defaultValue: true, "Enable or disable the custom main menu background.");
			mainMenuBackgroundPathConfig = BindConfig("2. Main Menu Background", "MainMenuBackgroundPath", "config/Emblem/Background", "Relative to BepInEx folder: Specify a .png file, or a directory to randomly select an image starting with the prefix 'Background'.");
			enableCanvasRecoloring = BindConfig("2. Main Menu Background", "EnableCanvasRecoloring", defaultValue: false, "Enable or disable canvas recoloring. This allows you to change the color of the entire canvas.");
			menuContainerColorConfig = BindConfig("2. Main Menu Background", "MenuContainerColor", "0,0,0,1", "Canvas Color behind the background image. Specify the color in RGBA format (ex: '255,255,255,1' for white).");
			replaceLoadingImageConfig = BindConfig("3. Loading Screen Image", "ReplaceLoadingImage", defaultValue: false, "Enable or disable loading image replacement.");
			loadingImageFilePathConfig = BindConfig("3. Loading Screen Image", "LoadingImageFilePath", "config/Emblem/Loading", "Relative to BepInEx folder: Specify a .png file, or a directory to randomly select an image starting with the prefix 'Loading'.");
			LoadingYOffset = BindConfig("3. Loading Screen Image", "LoadingYOffset", -1f, "Vertical offset percentage from the top for the loading image. Set to -1 for no adjustment.");
			stretchLoadingImageConfig = BindConfig("3. Loading Screen Image", "StretchLoadingImage", defaultValue: false, "Stretch the loading image to fit the screen vertically while maintaining aspect ratio.");
			enableLoadingTextChange = BindConfig("4. Loading Screen Text", "EnableLoadingTextChange", defaultValue: false, "Enable or disable the custom loading text feature.");
			loadingTextConfig = BindConfig("4. Loading Screen Text", "LoadingText", "Loading...", "Text displayed on the loading screen if the custom text feature is enabled. Separate multiple texts with '|' to choose one at random");
			fontColorConfig = BindConfig("4. Loading Screen Text", "FontColor", "255,139,0,1", "Color of the font in RGBA format.");
			fontSizeConfig = BindConfig("4. Loading Screen Text", "FontSize", 19.6f, "Size of the font used in the loading text.");
			wrapTextConfig = BindConfig("4. Loading Screen Text", "WrapText", defaultValue: false, "Enable or disable text wrapping. If disabled, the text container size will auto-adjust to fit the text.");
			centerTextVerticallyConfig = BindConfig("4. Loading Screen Text", "CenterTextVertically", defaultValue: false, "Enable or disable vertical centering of the loading text.");
			hideMainMenuBorderConfig = BindConfig("5. Borders", "HideMainMenuBorder", defaultValue: false, "Enable or disable the main menu border.");
			borderColorConfig = BindConfig("5. Borders", "BorderColor", "115,59,0,1", "The color of the border.");
			enableMenuColorChange = BindConfig("6. Menu Colors", "EnableMenuColorChange", defaultValue: false, "Do you even want to mess with menu colors?");
			MenuFontColor = BindConfig("6. Menu Colors", "MenuFontColor", "230,100,65,1", "Color of menu font.");
			MenuRolloverBGColor = BindConfig("6. Menu Colors", "MenuRolloverBGColor", "230,100,65,1", "Background color of a menu items on rollover.");
			MenuRolloverFontColor = BindConfig("6. Menu Colors", "MenuRolloverFontColor", "0,0,0,1", "Font color of menu items on rollover.");
		}

		private ConfigEntry<T> BindConfig<T>(string section, string key, T defaultValue, string description)
		{
			return config.Bind<T>(section, key, defaultValue, description);
		}
	}
	public class InterfaceDecorator
	{
		private readonly UIComponent uiComponent;

		private readonly ImageReplacementComponent imageReplacementComponent;

		private readonly Boardwalk boardwalk;

		private readonly LoadingTextComponent loadingTextComponent;

		private readonly MenuMoodSetter menuMoodSetter;

		public InterfaceDecorator(UIComponent uiComponent, ImageReplacementComponent imageReplacementComponent, Boardwalk boardwalk, LoadingTextComponent loadingTextComponent, MenuMoodSetter menuMoodSetter)
		{
			this.uiComponent = uiComponent;
			this.imageReplacementComponent = imageReplacementComponent;
			this.boardwalk = boardwalk;
			this.loadingTextComponent = loadingTextComponent;
			this.menuMoodSetter = menuMoodSetter;
		}

		public void ApplyMainMenuCustomizations()
		{
			uiComponent.ResetRectTransformProperties("MainButtons");
			uiComponent.ResetRectTransformProperties("LoadingScreen");
			imageReplacementComponent.ApplyCustomBackground();
			imageReplacementComponent.CustomizeHeaderImage();
			imageReplacementComponent.ReplaceLoadingScreenImage();
			uiComponent.StretchLoadingImage();
			uiComponent.CustomizeMenuContainer();
			loadingTextComponent.ApplyLoadingCustomizations();
			boardwalk.ToggleBorder("MainButtons");
			boardwalk.ToggleBorder("LoadingScreen");
			DelayHelper.StartDelayedAction(0.5f, menuMoodSetter.HarmonizeMenuHues);
		}
	}
	public class SceneManagerHelper
	{
		private readonly InterfaceDecorator interfaceDecorator;

		public SceneManagerHelper(InterfaceDecorator interfaceDecorator)
		{
			this.interfaceDecorator = interfaceDecorator;
			SceneManager.sceneLoaded += OnSceneLoaded;
		}

		private void OnSceneLoaded(Scene scene, LoadSceneMode mode)
		{
			if (((Scene)(ref scene)).name == "MainMenu")
			{
				LogWarden.LogInfo("[SceneManager] Applying customizations to MainMenu.");
				interfaceDecorator.ApplyMainMenuCustomizations();
			}
		}

		public void Unsubscribe()
		{
			SceneManager.sceneLoaded -= OnSceneLoaded;
		}
	}
}
namespace Emblem.Components
{
	public class Boardwalk
	{
		private readonly Configurator configManager;

		public Boardwalk(Configurator configManager)
		{
			this.configManager = configManager;
		}

		public void ToggleBorder(string borderName)
		{
			//IL_0036: Unknown result type (might be due to invalid IL or missing references)
			Transform val = PathFinder.Probe(borderName);
			if ((Object)(object)val == (Object)null)
			{
				LogWarden.LogError("[Border] Border with name '" + borderName + "' not found.");
				return;
			}
			val.localScale = new Vector3(1.02f, 1.06f, 1.02f);
			HideOriginalBorder(val);
			if (!configManager.hideMainMenuBorderConfig.Value)
			{
				CreateBorderCopy(val);
			}
		}

		private void HideOriginalBorder(Transform borderTransform)
		{
			//IL_0012: 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_0028: Unknown result type (might be due to invalid IL or missing references)
			//IL_0037: Unknown result type (might be due to invalid IL or missing references)
			Image component = ((Component)borderTransform).GetComponent<Image>();
			if ((Object)(object)component != (Object)null)
			{
				((Graphic)component).color = new Color(((Graphic)component).color.r, ((Graphic)component).color.g, ((Graphic)component).color.b, 0f);
			}
			else
			{
				LogWarden.LogWarning("[Border] No Image component found on border. Proceeding without hiding.");
			}
		}

		private void CreateBorderCopy(Transform borderTransform)
		{
			//IL_001f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_0035: 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_0050: 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_0068: 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_0080: Unknown result type (might be due to invalid IL or missing references)
			//IL_008c: 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_00a4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b9: Unknown result type (might be due to invalid IL or missing references)
			//IL_00cd: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ea: Unknown result type (might be due to invalid IL or missing references)
			//IL_0111: Unknown result type (might be due to invalid IL or missing references)
			GameObject gameObject = ((Component)borderTransform).gameObject;
			Image component = gameObject.GetComponent<Image>();
			if ((Object)(object)component != (Object)null)
			{
				GameObject val = new GameObject("BorderClone");
				val.transform.SetParent(gameObject.transform);
				val.transform.SetSiblingIndex(1);
				RectTransform rectTransform = ((Graphic)component).rectTransform;
				RectTransform obj = val.AddComponent<RectTransform>();
				((Transform)obj).localPosition = ((Transform)rectTransform).localPosition;
				((Transform)obj).localRotation = ((Transform)rectTransform).localRotation;
				((Transform)obj).localScale = ((Transform)rectTransform).localScale;
				obj.anchorMin = rectTransform.anchorMin;
				obj.anchorMax = rectTransform.anchorMax;
				obj.anchoredPosition = rectTransform.anchoredPosition;
				obj.sizeDelta = rectTransform.sizeDelta;
				obj.pivot = rectTransform.pivot;
				obj.offsetMax = new Vector2(-22f, -33f);
				obj.offsetMin = new Vector2(22f, 33f);
				Image obj2 = val.AddComponent<Image>();
				obj2.sprite = component.sprite;
				obj2.type = component.type;
				obj2.fillCenter = component.fillCenter;
				((Graphic)obj2).color = ColorParser.ParseColor(configManager.borderColorConfig.Value);
				obj2.pixelsPerUnitMultiplier = component.pixelsPerUnitMultiplier;
				LogWarden.LogInfo("[Border] " + ((Object)borderTransform).name + " border cloned and color set to " + configManager.borderColorConfig.Value + ".");
			}
			else
			{
				LogWarden.LogWarning("[Border] No Image component found. Cannot clone.");
			}
		}
	}
	public class MenuMoodSetter
	{
		private readonly Configurator configManager;

		public MenuMoodSetter(Configurator configManager)
		{
			this.configManager = configManager;
		}

		public void HarmonizeMenuHues()
		{
			//IL_005f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0065: Expected O, but got Unknown
			if (!configManager.enableMenuColorChange.Value)
			{
				LogWarden.LogInfo("[MenuMoodSetter] Menu color change is disabled.");
				return;
			}
			LogWarden.LogInfo("[MenuMoodSetter] Harmonizing menu hues...");
			Transform val = PathFinder.Probe("MainButtons");
			if ((Object)(object)val == (Object)null)
			{
				LogWarden.LogError("[MenuMoodSetter] MainButtons object not found.");
				return;
			}
			LogWarden.LogInfo("[MenuMoodSetter] MainButtons object found. Processing children...");
			foreach (Transform item in val)
			{
				Transform val2 = item;
				if (!((Object)(object)((Component)val2).GetComponent<Button>() == (Object)null))
				{
					DisableAnimator(val2);
					SetupEventTriggers(val2);
					SetTextColor(val2, configManager.MenuFontColor.Value);
				}
			}
		}

		private void DisableAnimator(Transform buttonTransform)
		{
			Animator component = ((Component)buttonTransform).GetComponent<Animator>();
			if ((Object)(object)component != (Object)null)
			{
				((Behaviour)component).enabled = false;
			}
		}

		private void SetupEventTriggers(Transform buttonTransform)
		{
			EventTrigger orAddComponent = GetOrAddComponent<EventTrigger>(((Component)buttonTransform).gameObject);
			AddEventTrigger(orAddComponent, (EventTriggerType)0, delegate
			{
				OnMouseEnter(buttonTransform);
			});
			AddEventTrigger(orAddComponent, (EventTriggerType)1, delegate
			{
				OnMouseExit(buttonTransform);
			});
		}

		private void OnMouseEnter(Transform buttonTransform)
		{
			SetTextColor(buttonTransform, configManager.MenuRolloverFontColor.Value);
			SetSelectionHighlight(buttonTransform, enabled: true, configManager.MenuRolloverBGColor.Value);
		}

		private void OnMouseExit(Transform buttonTransform)
		{
			SetTextColor(buttonTransform, configManager.MenuFontColor.Value);
			SetSelectionHighlight(buttonTransform, enabled: false, "");
		}

		private void SetTextColor(Transform buttonTransform, string colorString)
		{
			//IL_001f: Unknown result type (might be due to invalid IL or missing references)
			TMP_Text componentInChildren = ((Component)buttonTransform).GetComponentInChildren<TMP_Text>();
			if (!((Object)(object)componentInChildren == (Object)null))
			{
				string text = RemoveColorTags(componentInChildren.text);
				string text2 = ColorUtility.ToHtmlStringRGBA(ColorParser.ParseColor(colorString));
				componentInChildren.text = "<color=#" + text2 + ">" + text + "</color>";
			}
		}

		private string RemoveColorTags(string text)
		{
			return Regex.Replace(text, "<color=#[0-9A-Fa-f]{6,8}>(.*?)</color>", "$1");
		}

		private void SetSelectionHighlight(Transform buttonTransform, bool enabled, string colorString)
		{
			//IL_002c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0031: 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)
			Transform val = buttonTransform.Find("SelectionHighlight");
			Image val2 = default(Image);
			if (!((Object)(object)val == (Object)null) && ((Component)val).TryGetComponent<Image>(ref val2))
			{
				((Behaviour)val2).enabled = enabled;
				if (enabled)
				{
					Color color = ColorParser.ParseColor(colorString);
					((Graphic)val2).color = color;
				}
			}
		}

		private T GetOrAddComponent<T>(GameObject obj) where T : Component
		{
			return obj.GetComponent<T>() ?? obj.AddComponent<T>();
		}

		private void AddEventTrigger(EventTrigger trigger, EventTriggerType type, UnityAction<BaseEventData> action)
		{
			//IL_0000: Unknown result type (might be due to invalid IL or missing references)
			//IL_0005: 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_0007: Unknown result type (might be due to invalid IL or missing references)
			//IL_000d: Expected O, but got Unknown
			Entry val = new Entry
			{
				eventID = type
			};
			((UnityEvent<BaseEventData>)(object)val.callback).AddListener(action);
			trigger.triggers.Add(val);
		}
	}
	public class CustomImageManager
	{
		public Sprite LoadCustomImage(string path, string imagePrefix)
		{
			//IL_0072: Unknown result type (might be due to invalid IL or missing references)
			//IL_0081: Unknown result type (might be due to invalid IL or missing references)
			string imagePath = GetImagePath(path, imagePrefix);
			if (imagePath == null)
			{
				LogWarden.LogError("[ImgManage] Failed to find image at path: " + path);
				return null;
			}
			try
			{
				byte[] imageBytes = File.ReadAllBytes(imagePath);
				Texture2D val = LoadTextureFromBytes(imageBytes);
				if ((Object)(object)val == (Object)null)
				{
					return null;
				}
				string logPathForBepInEx = GetLogPathForBepInEx(imagePath);
				LogWarden.LogInfo("[ImgManage] File ripped from " + logPathForBepInEx + ".");
				return Sprite.Create(val, new Rect(0f, 0f, (float)((Texture)val).width, (float)((Texture)val).height), new Vector2(0.5f, 0.5f));
			}
			catch (Exception ex)
			{
				LogWarden.LogError("[ImgManage] Failed to read image bytes from path: " + imagePath + ". Exception: " + ex.Message);
				return null;
			}
		}

		private Texture2D LoadTextureFromBytes(byte[] imageBytes)
		{
			//IL_0002: Unknown result type (might be due to invalid IL or missing references)
			//IL_0008: Expected O, but got Unknown
			//IL_002b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0030: Unknown result type (might be due to invalid IL or missing references)
			//IL_0037: Unknown result type (might be due to invalid IL or missing references)
			//IL_003f: Expected O, but got Unknown
			Texture2D val = new Texture2D(2, 2);
			if (!ImageConversion.LoadImage(val, imageBytes))
			{
				LogWarden.LogError("[ImgManage] Failed to load image data into temporary texture.");
				return null;
			}
			Texture2D val2 = new Texture2D(((Texture)val).width, ((Texture)val).height, (TextureFormat)4, false)
			{
				filterMode = (FilterMode)1,
				wrapMode = (TextureWrapMode)1
			};
			if (!ImageConversion.LoadImage(val2, imageBytes, false))
			{
				LogWarden.LogError("[ImgManage] Failed to load image data into final texture.");
				return null;
			}
			return val2;
		}

		private string GetLogPathForBepInEx(string fullPath)
		{
			int startIndex = fullPath.IndexOf("BepInEx") + "BepInEx".Length;
			return fullPath.Substring(startIndex).TrimStart(Path.DirectorySeparatorChar, Path.AltDirectorySeparatorChar);
		}

		private string GetImagePath(string path, string imagePrefix = null)
		{
			try
			{
				string text = Path.Combine(Paths.BepInExRootPath, path);
				if (File.Exists(text))
				{
					return text;
				}
				if (Directory.Exists(text) && !string.IsNullOrEmpty(imagePrefix))
				{
					return GetRandomNamedImageFile(text, imagePrefix);
				}
				LogWarden.LogError("[ImgManage] Path does not exist or is not a valid file/directory: " + path);
				return null;
			}
			catch (Exception arg)
			{
				LogWarden.LogError($"[ImgManage] Failed to retrieve image path: {arg}");
				return null;
			}
		}

		private string GetRandomNamedImageFile(string directory, string imagePrefix)
		{
			string[] files = Directory.GetFiles(directory, imagePrefix + "*.png");
			if (files.Length != 0)
			{
				return files[new Random().Next(files.Length)];
			}
			return GetRandomPngFile(directory);
		}

		private string GetRandomPngFile(string directory)
		{
			string[] files = Directory.GetFiles(directory, "*.png");
			if (files.Length == 0)
			{
				LogWarden.LogError("[ImgManage] No PNG files found in directory " + directory + ".");
				return null;
			}
			return files[new Random().Next(files.Length)];
		}
	}
	public class ImageReplacementComponent
	{
		private readonly Configurator configManager;

		private readonly CustomImageManager customImageManager;

		private readonly UIComponent uiComponent;

		private const string HeadImgPath = "MenuContainer/MainButtons/HeaderImage";

		private const string LoadImgPath = "MenuContainer/LoadingScreen/Image";

		public ImageReplacementComponent(Configurator configManager, UIComponent uiComponent, CustomImageManager customImageManager)
		{
			this.configManager = configManager;
			this.customImageManager = new CustomImageManager();
			this.uiComponent = uiComponent;
		}

		public void ApplyCustomBackground()
		{
			if (configManager.useMainMenuBackgroundConfig.Value)
			{
				Sprite customSprite = customImageManager.LoadCustomImage(configManager.mainMenuBackgroundPathConfig.Value, "Background");
				CreateBackgroundImage(customSprite);
			}
		}

		public void CustomizeHeaderImage()
		{
			//IL_008e: Unknown result type (might be due to invalid IL or missing references)
			Transform val = PathFinder.Probe("HeaderImage");
			if ((Object)(object)val == (Object)null)
			{
				LogWarden.LogError("[ImgReplace] HeaderImage UI element not found.");
				return;
			}
			RectTransform component = ((Component)val).GetComponent<RectTransform>();
			if (configManager.replaceHeaderImageConfig.Value)
			{
				ReplaceImage("MenuContainer/MainButtons/HeaderImage", customImageManager.LoadCustomImage(configManager.headerImageFilePathConfig.Value, "Header"));
			}
			AdjustRectTransform(component, isHeader: true);
			component.sizeDelta = new Vector2((float)configManager.headerImageScaleConfig.Value, (float)configManager.headerImageScaleConfig.Value);
			uiComponent.SetImageTransparency(((Component)val).GetComponent<Image>(), configManager.headerImageTransparencyConfig.Value, "Header Image");
		}

		public void ReplaceLoadingScreenImage()
		{
			if (configManager.replaceLoadingImageConfig.Value)
			{
				ReplaceImage("MenuContainer/LoadingScreen/Image", customImageManager.LoadCustomImage(configManager.loadingImageFilePathConfig.Value, "Loading"));
			}
		}

		private void CreateBackgroundImage(Sprite customSprite)
		{
			//IL_0038: Unknown result type (might be due to invalid IL or missing references)
			//IL_003d: 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_0079: Unknown result type (might be due to invalid IL or missing references)
			//IL_008e: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ae: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b8: Unknown result type (might be due to invalid IL or missing references)
			if ((Object)(object)customSprite == (Object)null)
			{
				LogWarden.LogError("[ImgReplace] No custom sprite provided for background image creation.");
				return;
			}
			Transform val = PathFinder.Probe("MenuContainer/MainButtons");
			if ((Object)(object)val == (Object)null)
			{
				LogWarden.LogError("[ImgReplace] Failed to find parent UI element for the background image.");
				return;
			}
			GameObject val2 = new GameObject("CustomBackgroundImage");
			val2.transform.SetParent(val, false);
			val2.transform.SetSiblingIndex(0);
			Image obj = val2.AddComponent<Image>();
			obj.sprite = customSprite;
			obj.preserveAspect = false;
			RectTransform component = ((Component)obj).GetComponent<RectTransform>();
			component.anchorMin = new Vector2(0f, 0f);
			component.anchorMax = new Vector2(1f, 1f);
			component.pivot = new Vector2(0.5f, 0.5f);
			component.offsetMin = Vector2.zero;
			component.offsetMax = Vector2.zero;
			Transform val3 = PathFinder.Probe("MenuContainer/MainButtons/HeaderImage");
			if ((Object)(object)val3 != (Object)null)
			{
				val3.SetSiblingIndex(1);
			}
			LogWarden.LogInfo("[ImgReplace] Background image added to the scene.");
		}

		private void ReplaceImage(string uiPath, Sprite customSprite)
		{
			if ((Object)(object)customSprite == (Object)null)
			{
				LogWarden.LogError("[ImgReplace] No custom sprite to replace with.");
				return;
			}
			Image imageComponent = GetImageComponent(uiPath);
			if (!((Object)(object)imageComponent == (Object)null))
			{
				imageComponent.sprite = customSprite;
				imageComponent.preserveAspect = true;
				LogWarden.LogInfo("[ImgReplace] " + uiPath + " image replaced successfully.");
				bool isHeader = uiPath.Contains("Header");
				AdjustRectTransform(((Graphic)imageComponent).rectTransform, isHeader);
			}
		}

		private Image GetImageComponent(string uiPath)
		{
			Transform val = PathFinder.Probe(uiPath);
			if ((Object)(object)val == (Object)null)
			{
				LogWarden.LogError("[ImgReplace] Failed to find UI element at path '" + uiPath + "'.");
				return null;
			}
			Image component = ((Component)val).GetComponent<Image>();
			if ((Object)(object)component == (Object)null)
			{
				LogWarden.LogError("[ImgReplace] Image component not found on UI element at path '" + uiPath + "'.");
				return null;
			}
			return component;
		}

		public void AdjustRectTransform(RectTransform rectTransform, bool isHeader)
		{
			if (isHeader && configManager.HeaderYOffset.Value != -1f)
			{
				if (!((Object)rectTransform).name.Contains("Adjusted"))
				{
					ApplyPositioning(rectTransform, configManager.HeaderYOffset.Value, isHeader: true);
					((Object)rectTransform).name = ((Object)rectTransform).name + " Adjusted";
				}
			}
			else if (!isHeader && configManager.LoadingYOffset.Value != -1f)
			{
				ApplyPositioning(rectTransform, configManager.LoadingYOffset.Value, isHeader: false);
			}
		}

		private void ApplyPositioning(RectTransform rectTransform, float yOffsetPercent, bool isHeader)
		{
			//IL_000d: Unknown result type (might be due to invalid IL or missing references)
			//IL_001c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0039: Unknown result type (might be due to invalid IL or missing references)
			//IL_003f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0050: Unknown result type (might be due to invalid IL or missing references)
			//IL_0065: Unknown result type (might be due to invalid IL or missing references)
			//IL_006a: Unknown result type (might be due to invalid IL or missing references)
			//IL_007d: 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_00ae: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c8: Unknown result type (might be due to invalid IL or missing references)
			float num = yOffsetPercent / 100f;
			Rect rect;
			if (isHeader)
			{
				rectTransform.sizeDelta = new Vector2(rectTransform.sizeDelta.x, 100f);
				Vector2 val = default(Vector2);
				((Vector2)(ref val))..ctor(0.5f, 1f);
				rectTransform.anchorMax = val;
				rectTransform.anchorMin = val;
				rectTransform.pivot = new Vector2(0.5f, 0.5f);
				Transform parent = ((Transform)rectTransform).parent;
				rect = ((RectTransform)((parent is RectTransform) ? parent : null)).rect;
				float num2 = ((Rect)(ref rect)).height * num;
				rectTransform.anchoredPosition = new Vector2(0f, 0f - num2);
			}
			else if (!isHeader && configManager.stretchLoadingImageConfig.Value)
			{
				Transform parent2 = ((Transform)rectTransform).parent;
				rect = ((RectTransform)((parent2 is RectTransform) ? parent2 : null)).rect;
				float height = ((Rect)(ref rect)).height;
				rectTransform.anchoredPosition = new Vector2(0f, height * (0.5f - num));
			}
			LogWarden.LogInfo(isHeader ? $"[UI] Header offset {yOffsetPercent}% from top." : $"[UI] Loading image offset {yOffsetPercent}% from top.");
		}
	}
	public class LoadingTextComponent : MonoBehaviour
	{
		private Configurator configManager;

		public void Initialize(Configurator configManager)
		{
			this.configManager = configManager;
		}

		public void ApplyLoadingCustomizations()
		{
			if (configManager.enableLoadingTextChange.Value)
			{
				SetLoadingText(configManager.loadingTextConfig.Value);
			}
			else
			{
				LogWarden.LogWarning("[LoadText] Loading text change is disabled by configuration.");
			}
		}

		private void SetLoadingText(string text)
		{
			string[] array = text.Split(new char[1] { '|' });
			string text2 = array[Random.Range(0, array.Length)];
			if (array.Length > 1)
			{
				LogWarden.LogInfo($"[LoadText] Found {array.Length} strings.");
			}
			RectTransform val = FindLoadingTextContainer();
			if ((Object)(object)val == (Object)null)
			{
				LogWarden.LogError("[LoadText] LoadingTextContainer not found.");
				return;
			}
			SetSiblingIndex((Transform)(object)val);
			if (configManager.enableLoadingTextChange.Value)
			{
				SetTextProperties((Transform)(object)val, text2);
			}
		}

		private RectTransform FindLoadingTextContainer()
		{
			Transform val = PathFinder.Probe("LoadingTextContainer");
			if ((Object)(object)val == (Object)null)
			{
				LogWarden.LogError("[LoadText] Loading text container not found at path: LoadingTextContainer.");
				return null;
			}
			return ((Component)val).GetComponent<RectTransform>();
		}

		private void SetSiblingIndex(Transform loadingTextContainer)
		{
			loadingTextContainer.SetSiblingIndex(3);
		}

		private void SetTextProperties(Transform loadingTextContainer, string text)
		{
			string text2 = "LoadingText";
			Transform val = PathFinder.Probe(((Object)loadingTextContainer).name + "/" + text2);
			TextMeshProUGUI val2 = default(TextMeshProUGUI);
			RectTransform loadingTextContainer2 = default(RectTransform);
			if ((Object)(object)val == (Object)null)
			{
				LogWarden.LogError("[LoadText] TextMeshProUGUI component not found at path '" + ((Object)loadingTextContainer).name + "/" + text2 + "'.");
			}
			else if (!((Component)val).TryGetComponent<TextMeshProUGUI>(ref val2))
			{
				LogWarden.LogError("[LoadText] TextMeshProUGUI component not found on object at path '" + ((Object)loadingTextContainer).name + "/" + text2 + "'.");
			}
			else if (!((Component)loadingTextContainer).TryGetComponent<RectTransform>(ref loadingTextContainer2))
			{
				LogWarden.LogError("[LoadText] RectTransform component not found on '" + ((Object)loadingTextContainer).name + "'.");
			}
			else
			{
				AdjustTextContainerAnchors(loadingTextContainer2);
				((TMP_Text)val2).text = text;
				((TMP_Text)val2).enableWordWrapping = configManager.wrapTextConfig.Value;
				((TMP_Text)val2).fontSize = configManager.fontSizeConfig.Value;
				SetTextColor(val2);
				LogWarden.LogInfo($"[LoadText] Set to: {text} with font size: {configManager.fontSizeConfig.Value}");
			}
		}

		private void SetTextColor(TextMeshProUGUI loadingTextTMP)
		{
			//IL_0010: Unknown result type (might be due to invalid IL or missing references)
			//IL_0015: 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)
			try
			{
				Color color = ColorParser.ParseColor(configManager.fontColorConfig.Value);
				((Graphic)loadingTextTMP).color = color;
				LogWarden.LogInfo("[LoadText] Font color set to: " + configManager.fontColorConfig.Value);
			}
			catch (Exception ex)
			{
				LogWarden.LogError("[LoadText] Error setting font color using ColorParser: " + ex.Message);
			}
		}

		private void AdjustTextContainerAnchors(RectTransform loadingTextContainer)
		{
			//IL_0026: Unknown result type (might be due to invalid IL or missing references)
			//IL_002c: 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_002e: 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)
			//IL_003b: Unknown result type (might be due to invalid IL or missing references)
			if (configManager.centerTextVerticallyConfig.Value)
			{
				Vector2 val = default(Vector2);
				((Vector2)(ref val))..ctor(0.5f, 0.5f);
				loadingTextContainer.pivot = val;
				Vector2 anchorMin = (loadingTextContainer.anchorMax = val);
				loadingTextContainer.anchorMin = anchorMin;
				loadingTextContainer.anchoredPosition = Vector2.zero;
				LogWarden.LogInfo("[LoadText] Centered vertically and horizontally.");
			}
		}
	}
	public class UIComponent
	{
		private readonly Configurator configManager;

		public UIComponent(Configurator configManager)
		{
			this.configManager = configManager;
		}

		public void ResetRectTransformProperties(string gameObjectName)
		{
			//IL_004d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0058: Unknown result type (might be due to invalid IL or missing references)
			//IL_0063: Unknown result type (might be due to invalid IL or missing references)
			//IL_006e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0083: Unknown result type (might be due to invalid IL or missing references)
			//IL_008e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0099: Unknown result type (might be due to invalid IL or missing references)
			Transform val = PathFinder.Probe(gameObjectName);
			if ((Object)(object)val == (Object)null)
			{
				LogWarden.LogError("[UI] " + gameObjectName + " Transform not found.");
				return;
			}
			RectTransform component = ((Component)val).GetComponent<RectTransform>();
			if ((Object)(object)component == (Object)null)
			{
				LogWarden.LogError("[UI] " + gameObjectName + " does not have a RectTransform component.");
				return;
			}
			component.anchorMin = Vector2.zero;
			component.anchorMax = Vector2.one;
			component.offsetMin = Vector2.zero;
			component.offsetMax = Vector2.zero;
			component.pivot = new Vector2(0.5f, 0.5f);
			component.anchoredPosition = Vector2.zero;
			val.localScale = Vector3.one;
			LogWarden.LogInfo("[UI] " + gameObjectName + " layout properties have been de-borked.");
		}

		public void StretchLoadingImage()
		{
			//IL_003b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0050: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00cc: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e1: Unknown result type (might be due to invalid IL or missing references)
			//IL_0077: Unknown result type (might be due to invalid IL or missing references)
			//IL_008c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0097: Unknown result type (might be due to invalid IL or missing references)
			Transform val = PathFinder.Probe("MenuContainer/LoadingScreen/Image");
			if ((Object)(object)val == (Object)null)
			{
				LogWarden.LogError("[UI] Loading image Transform not found.");
				return;
			}
			RectTransform component = ((Component)val).GetComponent<RectTransform>();
			if ((Object)(object)component == (Object)null)
			{
				LogWarden.LogError("[UI] Loading image does not have a RectTransform component.");
				return;
			}
			((Transform)component).localScale = Vector3.one;
			component.pivot = new Vector2(0.5f, 0.5f);
			if (configManager.stretchLoadingImageConfig.Value)
			{
				component.anchorMin = new Vector2(0f, 0f);
				component.anchorMax = new Vector2(1f, 1f);
				component.sizeDelta = Vector2.zero;
				LogWarden.LogInfo("[UI] Loading image stretched to fill screen vertically.");
			}
			else
			{
				component.anchorMin = new Vector2(0.5f, 0.5f);
				component.anchorMax = new Vector2(0.5f, 0.5f);
				component.sizeDelta = new Vector2(400f, 400f);
			}
		}

		public void CustomizeMenuContainer()
		{
			//IL_0063: Unknown result type (might be due to invalid IL or missing references)
			if (!configManager.enableCanvasRecoloring.Value)
			{
				LogWarden.LogInfo("[UI] Canvas recoloring is disabled.");
				return;
			}
			Transform val = PathFinder.Probe("MenuContainer");
			if ((Object)(object)val == (Object)null)
			{
				LogWarden.LogError("[UI] MenuContainer element not found.");
				return;
			}
			Image obj = ((Component)val).GetComponent<Image>() ?? ((Component)val).gameObject.AddComponent<Image>();
			string value = configManager.menuContainerColorConfig.Value;
			((Graphic)obj).color = ColorParser.ParseColor(value);
			LogWarden.LogInfo("[UI] Menu container color set to " + value + ".");
		}

		public void SetImageTransparency(Image image, int transparencyPercent, string imageName)
		{
			//IL_001e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0023: Unknown result type (might be due to invalid IL or missing references)
			//IL_0025: 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_0031: 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)
			if ((Object)(object)image == (Object)null)
			{
				LogWarden.LogError("[UI] Image component not found.");
				return;
			}
			float num = (float)transparencyPercent / 100f;
			Color color = ((Graphic)image).color;
			((Graphic)image).color = new Color(color.r, color.g, color.b, num);
			LogWarden.LogInfo($"[UI] {imageName} transparency set to {num * 100f}%.");
		}
	}
}