Decompiled source of For The Company Beta v3.0.0

plugins/Darkbrewery-Emblem/Emblem.dll

Decompiled 2 months ago
using System;
using System.Collections;
using System.Collections.Concurrent;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Runtime.Versioning;
using System.Text;
using System.Text.RegularExpressions;
using System.Threading;
using BepInEx;
using BepInEx.Bootstrap;
using BepInEx.Configuration;
using BepInEx.Logging;
using Emblem;
using Emblem.Components;
using Emblem.Managers;
using HarmonyLib;
using LethalConfig;
using LethalConfig.ConfigItems;
using TMPro;
using UnityEngine;
using UnityEngine.EventSystems;
using UnityEngine.Events;
using UnityEngine.InputSystem;
using UnityEngine.Rendering;
using UnityEngine.Rendering.HighDefinition;
using UnityEngine.SceneManagement;
using UnityEngine.UI;
using UnityEngine.Video;

[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.3.2")]
public class EmblemPlugin : BaseUnityPlugin
{
	private UIComponent uiComponent;

	private HeaderReplacement headerReplacement;

	private Boardwalk boardwalk;

	private BackgroundManager backgroundManager;

	private LoadingText loadingText;

	private MenuMoodSetter menuMoodSetter;

	private Harmony harmony;

	private CustomMediaManager customMediaManager;

	private SceneManagerHelper sceneManagerHelper;

	private InterfaceDecorator interfaceDecorator;

	private VersionStyler versionStyler;

	private Slideshow slideshow;

	private void Awake()
	{
		//IL_0075: Unknown result type (might be due to invalid IL or missing references)
		//IL_007f: Expected O, but got Unknown
		LogWarden.Initialize(((BaseUnityPlugin)this).Logger);
		LogWarden.LogInfo("   #####################################################################   ");
		LogWarden.LogInfo(" %%                                                                     %% ");
		LogWarden.LogInfo("#            EEEEE   M     M   BBBBB    L      EEEEE   M     M            #");
		LogWarden.LogInfo("   *    ==   E       MM   MM   B    B   L      E       MM   MM   ==    *   ");
		LogWarden.LogInfo(" *   *       EEEE    M M M M   BBBBB    L      EEEE    M M M M       *   * ");
		LogWarden.LogInfo("   *    ==   E       M  M  M   B    B   L      E       M  M  M   ==    *   ");
		LogWarden.LogInfo("#            EEEEE   M     M   BBBBB    LLLLL  EEEEE   M     M            #");
		LogWarden.LogInfo(" %%                                                                     %% ");
		LogWarden.LogInfo("   ######################### BY DARKBREWERY ############################   ");
		LogWarden.LogInfo("Stirring from darkness...");
		try
		{
			harmony = new Harmony("com.darkbrewery.emblem.harmony");
			Configurator.InitializeInstance(((BaseUnityPlugin)this).Config);
			customMediaManager = new CustomMediaManager();
			uiComponent = new UIComponent();
			backgroundManager = new BackgroundManager();
			headerReplacement = new HeaderReplacement();
			boardwalk = new Boardwalk();
			loadingText = new LoadingText();
			menuMoodSetter = new MenuMoodSetter();
			versionStyler = new VersionStyler();
			slideshow = new Slideshow(((Component)this).transform);
			interfaceDecorator = new InterfaceDecorator(uiComponent, backgroundManager, headerReplacement, boardwalk, loadingText, menuMoodSetter, versionStyler, slideshow);
			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
{
	private static DelayHelper instance;

	private Dictionary<string, Coroutine> coroutineDictionary = new Dictionary<string, Coroutine>();

	private Dictionary<TextMeshProUGUI, Coroutine> typingCoroutines = new Dictionary<TextMeshProUGUI, Coroutine>();

	private static DelayHelper GetInstance()
	{
		//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_0027: Expected O, but got Unknown
		if ((Object)(object)instance == (Object)null)
		{
			GameObject val = new GameObject("GlobalDelayHelper");
			instance = val.AddComponent<DelayHelper>();
			Object.DontDestroyOnLoad((Object)val);
		}
		return instance;
	}

	public static void StopAll()
	{
		foreach (Coroutine value in GetInstance().coroutineDictionary.Values)
		{
			((MonoBehaviour)GetInstance()).StopCoroutine(value);
		}
		GetInstance().coroutineDictionary.Clear();
	}

	public static void StartDelayedAction(float delayInSeconds, Action action)
	{
		GetInstance().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();
	}

	public static void StartRepeatingAction(string name, float intervalInSeconds, Action action)
	{
		StopRepeatingAction(name);
		Coroutine value = ((MonoBehaviour)GetInstance()).StartCoroutine(GetInstance().RepeatingActionCoroutine(intervalInSeconds, action));
		GetInstance().coroutineDictionary[name] = value;
	}

	public static void StopRepeatingAction(string name)
	{
		if ((Object)(object)instance != (Object)null && instance.coroutineDictionary.TryGetValue(name, out var value))
		{
			((MonoBehaviour)instance).StopCoroutine(value);
			instance.coroutineDictionary.Remove(name);
		}
	}

	private IEnumerator RepeatingActionCoroutine(float intervalInSeconds, Action action)
	{
		while (true)
		{
			yield return (object)new WaitForSeconds(intervalInSeconds);
			action?.Invoke();
		}
	}

	public static void StartFadeAction(Image image, float duration, Action onComplete = null)
	{
		GetInstance().FadeImageCoroutine(image, duration, onComplete);
	}

	private void FadeImageCoroutine(Image image, float duration, Action onComplete)
	{
		((MonoBehaviour)this).StartCoroutine(FadeImage(image, duration, onComplete));
	}

	private IEnumerator FadeImage(Image image, float duration, Action onComplete)
	{
		float currentTime = 0f;
		Color startColor = ((Graphic)image).color;
		Color endColor = new Color(startColor.r, startColor.g, startColor.b, 0f);
		while (currentTime < duration)
		{
			currentTime += Time.deltaTime;
			((Graphic)image).color = Color.Lerp(startColor, endColor, currentTime / duration);
			yield return null;
		}
		((Graphic)image).color = endColor;
		onComplete?.Invoke();
	}

	public static void StartTypingText(TextMeshProUGUI textComponent, string text, float typingSpeed, float flashDuration = 0.3f, int flashCount = 2)
	{
		GetInstance().TypingTextCoroutine(textComponent, text, typingSpeed, flashDuration, flashCount);
	}

	private void TypingTextCoroutine(TextMeshProUGUI textComponent, string text, float typingSpeed, float flashDuration, int flashCount)
	{
		if (typingCoroutines.TryGetValue(textComponent, out var value))
		{
			((MonoBehaviour)this).StopCoroutine(value);
			typingCoroutines.Remove(textComponent);
		}
		Coroutine value2 = ((MonoBehaviour)this).StartCoroutine(TypeTextWithCursorFlash(textComponent, text, typingSpeed, flashDuration, flashCount));
		typingCoroutines[textComponent] = value2;
	}

	private IEnumerator TypeTextWithCursorFlash(TextMeshProUGUI textComponent, string text, float typingSpeed, float flashDuration, int flashCount)
	{
		StringBuilder stringBuilder = new StringBuilder();
		for (int j = 0; j < flashCount; j++)
		{
			((TMP_Text)textComponent).text = "_";
			yield return (object)new WaitForSeconds(flashDuration);
			((TMP_Text)textComponent).text = "";
			yield return (object)new WaitForSeconds(flashDuration);
		}
		foreach (char value in text)
		{
			stringBuilder.Append(value);
			((TMP_Text)textComponent).text = stringBuilder.ToString() + "_";
			yield return (object)new WaitForSeconds(typingSpeed);
			((TMP_Text)textComponent).text = stringBuilder.ToString();
		}
	}
}
public class EmblemFolder
{
	private readonly string basePluginsPath;

	private readonly Dictionary<string, string> fullPathCache = new Dictionary<string, string>();

	private readonly Dictionary<string, IEnumerable<string>> validPathsCache = new Dictionary<string, IEnumerable<string>>();

	private readonly Lazy<IEnumerable<string>> emblemDirectories;

	public EmblemFolder()
	{
		basePluginsPath = Path.Combine(Paths.BepInExRootPath, "plugins");
		emblemDirectories = new Lazy<IEnumerable<string>>(() => FindEmblemDirectories());
	}

	private IEnumerable<string> FindEmblemDirectories()
	{
		try
		{
			return (from dir in Directory.GetDirectories(basePluginsPath, "*", SearchOption.AllDirectories)
				where Path.GetFileName(dir).Equals("Emblem", StringComparison.OrdinalIgnoreCase)
				select dir).ToList();
		}
		catch (Exception ex)
		{
			LogWarden.LogError("[EmblemFolder] Error finding Emblem directories: " + ex.Message);
			return new List<string>();
		}
	}

	public string FindFullPath(string inputPath)
	{
		if (fullPathCache.TryGetValue(inputPath, out var value))
		{
			return value;
		}
		string path = ExtractRelativePathFromEmblem(inputPath);
		string[] directories = Directory.GetDirectories(basePluginsPath, "*", SearchOption.AllDirectories);
		foreach (string text in directories)
		{
			if (text.EndsWith("Emblem", StringComparison.OrdinalIgnoreCase))
			{
				string text2 = Path.Combine(text, path);
				if (File.Exists(text2) || Directory.Exists(text2))
				{
					fullPathCache[inputPath] = text2;
					return text2;
				}
			}
		}
		LogWarden.LogError("[EmblemFolder] Could not find a valid path for: " + inputPath);
		return null;
	}

	public IEnumerable<string> FindAllValidPaths(string inputPathPattern)
	{
		if (validPathsCache.TryGetValue(inputPathPattern, out var value))
		{
			return value;
		}
		string path = ExtractRelativePathFromEmblem(inputPathPattern);
		string[] directories = Directory.GetDirectories(basePluginsPath, "*", SearchOption.AllDirectories);
		List<string> list = new List<string>();
		string[] array = directories;
		foreach (string text in array)
		{
			if (text.EndsWith("Emblem", StringComparison.OrdinalIgnoreCase))
			{
				string searchPattern = Path.Combine(text, path);
				list.AddRange(Directory.GetFiles(text, searchPattern, SearchOption.AllDirectories));
			}
		}
		validPathsCache[inputPathPattern] = list;
		return list;
	}

	private string ExtractRelativePathFromEmblem(string path)
	{
		string[] array = path.Split(new char[2]
		{
			Path.DirectorySeparatorChar,
			Path.AltDirectorySeparatorChar
		}, StringSplitOptions.RemoveEmptyEntries);
		int num = Array.FindIndex(array, (string segment) => segment.Equals("Emblem", StringComparison.OrdinalIgnoreCase));
		if (num != -1 && num < array.Length - 1)
		{
			return Path.Combine(array.Skip(num + 1).ToArray());
		}
		return path;
	}
}
public class ImageFilters
{
	private readonly Configurator configManager;

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

	public void Blend(string targetImagePath, Color vignetteColor)
	{
		//IL_0091: Unknown result type (might be due to invalid IL or missing references)
		//IL_0097: Expected O, but got Unknown
		//IL_00b6: Unknown result type (might be due to invalid IL or missing references)
		//IL_00bb: Unknown result type (might be due to invalid IL or missing references)
		//IL_00ca: Unknown result type (might be due to invalid IL or missing references)
		//IL_00cf: Unknown result type (might be due to invalid IL or missing references)
		//IL_00d8: Unknown result type (might be due to invalid IL or missing references)
		//IL_011d: 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_0151: Unknown result type (might be due to invalid IL or missing references)
		Transform val = PathFinder.Probe(targetImagePath);
		if ((Object)(object)val == (Object)null)
		{
			LogWarden.LogError("ImageFilters.Blend: Image with path '" + targetImagePath + "' not found.");
			return;
		}
		GameObject gameObject = ((Component)val).gameObject;
		Transform val2 = gameObject.transform.Find("VignetteOverlay");
		if (!configManager.enableRadiantTaper.Value)
		{
			if ((Object)(object)val2 != (Object)null)
			{
				Object.Destroy((Object)(object)((Component)val2).gameObject);
				LogWarden.LogInfo("ImageFilters.Blend: Vignette effect removed from '" + targetImagePath + "'.");
			}
			return;
		}
		GameObject val3;
		if ((Object)(object)val2 != (Object)null)
		{
			val3 = ((Component)val2).gameObject;
		}
		else
		{
			val3 = new GameObject("VignetteOverlay");
			RectTransform obj = val3.AddComponent<RectTransform>();
			((Transform)obj).SetParent(gameObject.transform, false);
			((Transform)obj).SetAsLastSibling();
			Rect rect = gameObject.GetComponent<RectTransform>().rect;
			float width = ((Rect)(ref rect)).width;
			rect = gameObject.GetComponent<RectTransform>().rect;
			obj.sizeDelta = new Vector2(width, ((Rect)(ref rect)).height);
		}
		Image obj2 = val3.GetComponent<Image>() ?? val3.AddComponent<Image>();
		Texture2D val4 = CreateVignetteTexture(((Texture)gameObject.GetComponent<Image>().sprite.texture).width, ((Texture)gameObject.GetComponent<Image>().sprite.texture).height, vignetteColor);
		obj2.sprite = Sprite.Create(val4, new Rect(0f, 0f, (float)((Texture)val4).width, (float)((Texture)val4).height), new Vector2(0.5f, 0.5f));
		((Graphic)obj2).raycastTarget = false;
	}

	private Texture2D CreateVignetteTexture(int width, int height, Color vignetteColor)
	{
		//IL_0004: Unknown result type (might be due to invalid IL or missing references)
		//IL_000a: Expected O, but got Unknown
		//IL_005b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0061: Unknown result type (might be due to invalid IL or missing references)
		//IL_0067: 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)
		Texture2D val = new Texture2D(width, height, (TextureFormat)4, false);
		Color val2 = default(Color);
		for (int i = 0; i < height; i++)
		{
			for (int j = 0; j < width; j++)
			{
				float distance2 = j;
				float distance3 = width - j;
				float distance4 = height - i;
				float distance5 = i;
				float num = Mathf.Max(CalculateExponentialBlend(distance2, width), CalculateExponentialBlend(distance3, width));
				float num2 = Mathf.Max(CalculateExponentialBlend(distance4, height), CalculateExponentialBlend(distance5, height));
				float num3 = Mathf.Max(num, num2);
				((Color)(ref val2))..ctor(vignetteColor.r, vignetteColor.g, vignetteColor.b, num3);
				val.SetPixel(j, i, val2);
			}
		}
		val.Apply();
		return val;
		static float CalculateExponentialBlend(float distance, float totalDistance)
		{
			float num4 = 0.97f * totalDistance;
			if (distance > num4)
			{
				return Mathf.Clamp01(Mathf.Pow((distance - num4) / (totalDistance - num4), 2f));
			}
			return 0f;
		}
	}
}
public class HotLoad
{
	private GameObject mainButtons;

	private GameObject loadingScreen;

	private InputAction toggleAction;

	public static HotLoad Instance { get; private set; }

	public static void Initialize()
	{
		if (Instance == null)
		{
			Instance = new HotLoad();
		}
	}

	private HotLoad()
	{
		//IL_0033: Unknown result type (might be due to invalid IL or missing references)
		//IL_003d: Expected O, but got Unknown
		mainButtons = FindObject("Canvas/MenuContainer/MainButtons");
		loadingScreen = FindObject("Canvas/MenuContainer/LoadingScreen");
		toggleAction = new InputAction((string)null, (InputActionType)0, "<Keyboard>/backslash", (string)null, (string)null, (string)null);
		toggleAction.performed += delegate
		{
			ToggleUI();
		};
		toggleAction.Enable();
	}

	public void OnDestroy()
	{
		InputAction obj = toggleAction;
		if (obj != null)
		{
			obj.Disable();
		}
		InputAction obj2 = toggleAction;
		if (obj2 != null)
		{
			obj2.Dispose();
		}
		Instance = null;
	}

	private GameObject FindObject(string path)
	{
		Transform val = PathFinder.Probe(path);
		if ((Object)(object)val != (Object)null)
		{
			return ((Component)val).gameObject;
		}
		Debug.LogError((object)("[HotLoad] '" + path + "' not found."));
		return null;
	}

	private void ToggleUI()
	{
		if ((Object)(object)mainButtons != (Object)null && (Object)(object)loadingScreen != (Object)null)
		{
			bool activeSelf = mainButtons.activeSelf;
			mainButtons.SetActive(!activeSelf);
			loadingScreen.SetActive(activeSelf);
		}
	}
}
namespace Emblem
{
	internal static class LethalConfigCompat
	{
		public const string GUID = "ainavt.lc.lethalconfig";

		public static bool IsAvailable => Chainloader.PluginInfos.ContainsKey("ainavt.lc.lethalconfig");

		[MethodImpl(MethodImplOptions.NoInlining | MethodImplOptions.NoOptimization)]
		public static void AddIntSlider(ConfigEntry<int> entry, bool restartRequired)
		{
			//IL_000a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0014: Expected O, but got Unknown
			if (IsAvailable)
			{
				LethalConfigManager.AddConfigItem((BaseConfigItem)new IntSliderConfigItem(entry, restartRequired));
			}
		}
	}
	public class CRTEffect : MonoBehaviour
	{
		private Volume volume;

		public void SetupVolume(GameObject gameObject)
		{
			volume = gameObject.GetComponent<Volume>() ?? gameObject.AddComponent<Volume>();
			if ((Object)(object)volume == (Object)null)
			{
				LogWarden.LogError("[CRT] Failed to add or get Volume component on gameObject.");
				return;
			}
			volume.isGlobal = true;
			volume.priority = 2.1474836E+09f;
			if ((Object)(object)volume.profile == (Object)null)
			{
				volume.profile = ScriptableObject.CreateInstance<VolumeProfile>();
				if ((Object)(object)volume.profile == (Object)null)
				{
					LogWarden.LogError("[CRT] Failed to create a new VolumeProfile.");
					return;
				}
			}
			((Behaviour)volume).enabled = true;
			LogWarden.LogInfo("[CRT] Volume component for CRT effects has been enabled.");
			SetupCRTEffects();
		}

		private void SetupCRTEffects()
		{
			if ((Object)(object)volume.profile == (Object)null)
			{
				LogWarden.LogError("[CRT] VolumeProfile is null in SetupCRTEffects.");
				return;
			}
			ConfigureChromaticAberration();
			ConfigureFilmGrain();
			ConfigureVignette();
			ConfigureLensDistortion();
		}

		private T GetOrAddEffect<T>(bool overrides = true) where T : VolumeComponent, new()
		{
			VolumeComponent? obj = volume.profile.components.Find((VolumeComponent x) => x is T);
			return ((T)(object)((obj is T) ? obj : null)) ?? volume.profile.Add<T>(overrides);
		}

		public void DisableCRTEffects()
		{
			DisableEffect<ChromaticAberration>();
			DisableEffect<FilmGrain>();
			DisableEffect<Vignette>();
			DisableEffect<LensDistortion>();
		}

		private void DisableEffect<T>() where T : VolumeComponent
		{
			if (!((Object)(object)volume == (Object)null) && !((Object)(object)volume.profile == (Object)null))
			{
				VolumeComponent? obj = volume.profile.components.Find((VolumeComponent x) => x is T);
				T val = (T)(object)((obj is T) ? obj : null);
				if ((Object)(object)val != (Object)null && ((VolumeComponent)val).active)
				{
					((VolumeComponent)val).active = false;
				}
				else
				{
					LogWarden.LogWarning("[CRT] Attempted to disable a non-existent or inactive effect.");
				}
			}
		}

		private void ConfigureChromaticAberration()
		{
			ChromaticAberration orAddEffect = GetOrAddEffect<ChromaticAberration>(overrides: true);
			((VolumeComponent)orAddEffect).active = true;
			((VolumeParameter<float>)(object)orAddEffect.intensity).value = 0.04f;
		}

		private void ConfigureFilmGrain()
		{
			FilmGrain orAddEffect = GetOrAddEffect<FilmGrain>(overrides: true);
			((VolumeComponent)orAddEffect).active = true;
			((VolumeParameter<float>)(object)orAddEffect.intensity).value = 0.4f;
			((VolumeParameter<FilmGrainLookup>)(object)orAddEffect.type).value = (FilmGrainLookup)2;
			((VolumeParameter<float>)(object)orAddEffect.response).value = 0.2f;
		}

		private void ConfigureVignette()
		{
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_003e: Unknown result type (might be due to invalid IL or missing references)
			Vignette orAddEffect = GetOrAddEffect<Vignette>(overrides: true);
			((VolumeComponent)orAddEffect).active = true;
			((VolumeParameter<float>)(object)orAddEffect.intensity).value = 0.4f;
			((VolumeParameter<Color>)(object)orAddEffect.color).value = Color.black;
			((VolumeParameter<Vector2>)(object)orAddEffect.center).value = new Vector2(0.5f, 0.5f);
			((VolumeParameter<float>)(object)orAddEffect.roundness).value = 1f;
			((VolumeParameter<float>)(object)orAddEffect.smoothness).value = 0.5f;
		}

		private void ConfigureLensDistortion()
		{
			LensDistortion orAddEffect = GetOrAddEffect<LensDistortion>(overrides: true);
			((VolumeComponent)orAddEffect).active = true;
			((VolumeParameter<float>)(object)orAddEffect.intensity).value = 0.2f;
			((VolumeParameter<float>)(object)orAddEffect.scale).value = 1f;
		}
	}
	public class ScanlineEffectApplier : MonoBehaviour
	{
		private static Material scanlineMaterial;

		private void LoadMaterialFromAssetBundle(string bundleResourceName, string materialName)
		{
			AssetBundle val = LoadAssetBundleFromEmbeddedResource(bundleResourceName);
			if ((Object)(object)val != (Object)null)
			{
				scanlineMaterial = val.LoadAsset<Material>(materialName);
				val.Unload(false);
			}
			else
			{
				LogWarden.LogError("[Scanlines] Failed to load the scanline material from the asset bundle.");
			}
		}

		private AssetBundle LoadAssetBundleFromEmbeddedResource(string resourceName)
		{
			using Stream stream = Assembly.GetExecutingAssembly().GetManifestResourceStream(resourceName);
			if (stream == null)
			{
				LogWarden.LogError("[Scanlines] Embedded resource not found.");
				return null;
			}
			byte[] array = new byte[stream.Length];
			stream.Read(array, 0, array.Length);
			return AssetBundle.LoadFromMemory(array);
		}

		private void Awake()
		{
			if ((Object)(object)scanlineMaterial == (Object)null)
			{
				LoadMaterialFromAssetBundle("Emblem.Assets.scanlines", "Scanlines");
			}
		}

		public void ApplyScanlines(string targetGameObjectName)
		{
			//IL_0059: 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)
			//IL_00a4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00af: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ba: Unknown result type (might be due to invalid IL or missing references)
			if (!((Object)(object)scanlineMaterial == (Object)null))
			{
				GameObject val = GameObject.Find(targetGameObjectName);
				if ((Object)(object)val == (Object)null)
				{
					LogWarden.LogError("[Scanlines] GameObject with name '" + targetGameObjectName + "' not found.");
					return;
				}
				Transform obj = val.transform.Find("Scanlines");
				GameObject val2 = (GameObject)(((object)((obj != null) ? ((Component)obj).gameObject : null)) ?? ((object)new GameObject("Scanlines")));
				val2.transform.SetParent(val.transform, false);
				Image obj2 = val2.GetComponent<Image>() ?? val2.AddComponent<Image>();
				((Graphic)obj2).material = scanlineMaterial;
				((Graphic)obj2).raycastTarget = false;
				RectTransform component = val2.GetComponent<RectTransform>();
				component.anchorMin = Vector2.zero;
				component.anchorMax = Vector2.one;
				component.sizeDelta = Vector2.zero;
				((Transform)component).localPosition = Vector3.zero;
				((Transform)component).SetAsLastSibling();
			}
		}

		public void RemoveScanlines(string targetGameObjectName)
		{
			GameObject val = GameObject.Find(targetGameObjectName);
			if ((Object)(object)val == (Object)null)
			{
				LogWarden.LogError("[Scanlines] GameObject with name '" + targetGameObjectName + "' not found to remove scanlines.");
				return;
			}
			Transform val2 = val.transform.Find("Scanlines");
			if ((Object)(object)val2 != (Object)null)
			{
				Object.Destroy((Object)(object)((Component)val2).gameObject);
			}
			else
			{
				LogWarden.LogInfo("[Scanlines] No scanlines effect found to remove.");
			}
		}
	}
	public class ConfigWatcher : IDisposable
	{
		private readonly FileSystemWatcher _watcher;

		public event Action OnConfigChanged;

		public ConfigWatcher(string filePath)
		{
			_watcher = new FileSystemWatcher
			{
				Path = Path.GetDirectoryName(filePath),
				Filter = Path.GetFileName(filePath),
				NotifyFilter = NotifyFilters.LastWrite
			};
			_watcher.Changed += ConfigChanged;
			_watcher.EnableRaisingEvents = true;
		}

		private void ConfigChanged(object sender, FileSystemEventArgs e)
		{
			if (File.Exists(e.FullPath))
			{
				_watcher.EnableRaisingEvents = false;
				Thread.Sleep(1000);
				_watcher.EnableRaisingEvents = true;
				this.OnConfigChanged?.Invoke();
			}
		}

		public void Dispose()
		{
			if (_watcher != null)
			{
				_watcher.EnableRaisingEvents = false;
				_watcher.Changed -= ConfigChanged;
				_watcher.Dispose();
			}
		}
	}
	public static class ColorParser
	{
		public static Color RGBA(string rgbaString)
		{
			//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 = rgbaString.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 Color RGB(string rgbString)
		{
			//IL_001e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0069: Unknown result type (might be due to invalid IL or missing references)
			string[] array = rgbString.Split(new char[1] { ',' });
			if (array.Length < 3 || 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);
			return new Color(num, num2, num3, 1f);
		}
	}
	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 class MainThreadDispatcher : MonoBehaviour
	{
		private static readonly ConcurrentQueue<Action> _queue = new ConcurrentQueue<Action>();

		private static MainThreadDispatcher _instance;

		public static MainThreadDispatcher EnsureInstance()
		{
			//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_0027: Expected O, but got Unknown
			if ((Object)(object)_instance == (Object)null)
			{
				GameObject val = new GameObject("MainThreadDispatcher");
				_instance = val.AddComponent<MainThreadDispatcher>();
				Object.DontDestroyOnLoad((Object)val);
				Debug.Log((object)"[Emblem][MainThreadDispatcher] Instance created and set to DontDestroyOnLoad.");
			}
			return _instance;
		}

		public static void Enqueue(Action action)
		{
			EnsureInstance();
			Debug.Log((object)"[Emblem][MainThreadDispatcher] Action enqueued.");
			_queue.Enqueue(action);
		}

		private void Update()
		{
			Action result;
			while (_queue.TryDequeue(out result))
			{
				try
				{
					result();
				}
				catch (Exception arg)
				{
					Debug.LogError((object)$"[MainThreadDispatcher] Exception during action execution: {arg}");
				}
			}
		}
	}
	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("[Pathfinder] Element '" + text + "' not found in path '" + path + "'.");
					return null;
				}
			}
			return val;
		}
	}
	public class Configurator
	{
		private static Configurator _instance;

		private static readonly object _lock = new object();

		private ConfigWatcher _configWatcher;

		public ConfigFile Config { get; private set; }

		public static Configurator Instance
		{
			get
			{
				if (_instance == null)
				{
					throw new Exception("Configurator must be initialized with a ConfigFile before use.");
				}
				return _instance;
			}
		}

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

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

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

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

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

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

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

		public ConfigEntry<string> mainBackgroundColor { 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 ConfigEntry<bool> enableReplaceLoadHeader { get; private set; }

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

		private Configurator(ConfigFile config)
		{
			Config = config;
			_configWatcher = new ConfigWatcher(config.ConfigFilePath);
			_configWatcher.OnConfigChanged += ApplyConfigChanges;
			Initialize();
		}

		private void ApplyConfigChanges()
		{
			MainThreadDispatcher.Enqueue(delegate
			{
				Config.Reload();
				LogWarden.LogInfo("[ConfigWatcher] Detected change in configuration file.");
			});
		}

		public static Configurator InitializeInstance(ConfigFile config)
		{
			lock (_lock)
			{
				if (_instance == null)
				{
					_instance = new Configurator(config);
				}
				return _instance;
			}
		}

		private void Initialize()
		{
			enableReplaceMainHeader = BindConfig("1. Main Logo", "Enable", defaultValue: false, "Enable or disable header image replacement.");
			mainHeaderPath = BindConfig("1. Main Logo", "Path", "Defaults/Header/HeaderWhite.png", "Relative to your /Emblem/ folder: Specify a .png file. A folder will randomly select an image starting with the prefix 'Header'. Leave blank to use nothing.");
			mainHeaderYOffset = BindConfig("1. Main Logo", "Offset", 20f, "Vertical Y offset percentage from top. Set to -1 for no adjustment.");
			mainHeaderScale = BindConfig("1. Main Logo", "Scale", 60, "Image scale. This will maintain aspect ratio. 100 for apx original size");
			mainHeaderAlpha = BindConfig("1. Main Logo", "Alpha", 100, "Image transparency. 0 for invisible and 100 for completely opaque.");
			enableMainBackground = BindConfig("2. Main Background", "Enable", defaultValue: true, "Enable or disable the custom main menu background.");
			mainBackgroundPath = BindConfig("2. Main Background", "Path", "Defaults/Background", "Relative to your /Emblem/ folder: Specify a .png, .mp4. A folder will randomly select an image starting with the prefix 'Background'. Separate multiple mp4 paths with a | to pick one randomly");
			mainBackgroundColor = BindConfig("2. Main Background", "Color", "0,0,0", "Background color for Main Menu Screen in RGB format (ex: '0,0,0' for black). No alpha value as this is the bottom layer");
			enableMenuColorChange = BindConfig("3. Menu Colors", "Enable", defaultValue: false, "Do you even want to mess with menu colors?");
			menuFontColor = BindConfig("3. Menu Colors", "Color", "230,100,65,1", "Color of menu font.");
			menuRolloverBGColor = BindConfig("3. Menu Colors", "Highlight BG Color", "230,100,65,1", "Background color of a menu items on rollover.");
			menuRolloverFontColor = BindConfig("3. Menu Colors", "Highlight Font Color", "0,0,0,1", "Font color of menu items on rollover.");
			enableReplaceLoadHeader = BindConfig("4. Loading Image", "Enable", defaultValue: false, "Enable or disable loading image replacement.");
			loadHeaderPath = BindConfig("4. Loading Image", "Path", "Defaults/Loading", "Relative to your /Emblem/ folder: Specify a .png file. A folder will randomly select an image starting with the prefix 'Loading'. Leave blank to use nothing");
			loadHeaderYOffset = BindConfig("4. Loading Image", "Offset", 50f, "Vertical Y offset percentage from top. Set to -1 for no adjustment.");
			loadHeaderScale = BindConfig("4. Loading Image", "Scale", 60, "Image scale. This will maintain aspect ratio.");
			loadHeaderAlpha = BindConfig("4. Loading Image", "Alpha", 100, "Image transparency. 0 for invisible and 100 for completely opaque.");
			loadHeaderStretch = BindConfig("4. Loading Image", "Stretch", defaultValue: false, "Stretch the loading image to fit the screen vertically. This will override scale and offset");
			enableLoadBackground = BindConfig("5. Loading Background", "Enable", defaultValue: false, "Enable or disable the loading screen background.");
			loadBackgroundPath = BindConfig("5. Loading Background", "Path", "Defaults/Background", "Relative to your /Emblem/ folder: Specify a .png, .mp4. A folder will randomly select an image starting with the prefix 'LoadBackground'. Separate multiple mp4 paths with a | to pick one randomly");
			loadBackgroundColor = BindConfig("5. Loading Background", "Color", "0,0,0,1", "Background color for Loading Screen in RGBA format (ex: '255,255,255,1' for white).");
			enableLoadingTextChange = BindConfig("6. Loading Text", "Enable", defaultValue: false, "Enable or disable the custom loading text feature.");
			loadTextString = BindConfig("6. Loading Text", "Text", "Loading...", "Text displayed on the loading screen. Separate multiple texts with '|' to choose one at random. Use \\n for linebreaks");
			loadTextColor = BindConfig("6. Loading Text", "Color", "255,139,0,1", "Color of the font in RGBA format (ex: '0,0,0,1' for blue).");
			loadTextSize = BindConfig("6. Loading Text", "Font Size", 40f, "Size of the font used in the loading text.");
			loadTextYOffset = BindConfig("6. Loading Text", "Offset", 50f, "Vertical Y offset percentage from top.");
			enableReplaceBorder = BindConfig("7. Borders", "Hide", defaultValue: false, "Enable or disable the corner borders.");
			borderColor = BindConfig("7. Borders", "Color", "115,59,0,1", "The color of the border in RGBA format (ex: '0,255,0,1' for green).");
			borderPadding = BindConfig("7. Borders", "Padding", 10f, "How far should the border be from corners of the screen.");
			enableCustomVersion = BindConfig("8. Version Number", "Enable", defaultValue: false, "Play around in version styling? This will disable word wrapping");
			versionTextString = BindConfig("8. Version Number", "Text", "[ %VERSION% ]", "Format string for the version text. Use %VERSION% for the original string. Use \\n for linebreaks");
			versionColor = BindConfig("8. Version Number", "Color", "230,100,65,0.45", "The color of the text in RGBA format (ex: '255,0,0,1' for red)..");
			versionFontSize = BindConfig("8. Version Number", "Font Size", 16f, "Font size of the version text.");
			versionYOffset = BindConfig("8. Version Number", "Offset", 95.8f, "Vertical Y offset percentage from top.");
			versionAlign = BindConfig("8. Version Number", "Alignment", "Center", "Text Position \nOptions: Left, Center, Right");
			enableRadiantTaper = BindConfig("9. Experimental", "Radiant Taper", defaultValue: false, "Use the vignette blending effect on background images and their background color");
			enableCRT = BindConfig("9. Experimental", "Retro TV Style", defaultValue: false, "Make the entire menu scene look like a CRT monitor");
			enableScanlines = BindConfig("9. Experimental", "Scanline Shader", defaultValue: false, "Add subtle scanlines to the entire scene");
			enableTypedLoadText = BindConfig("9. Experimental", "Typed Loading Text", defaultValue: false, "Enable the typing effect on the load text This requires multiple strings and slideshow enabled");
			enableGlitchyLogo = BindConfig("9. Experimental", "Glitchy Logo", defaultValue: false, "Add fancy effects to the main logo");
			enableSlideshow = BindConfig("Slideshow", "Enable", defaultValue: false, "Use the slideshow feature. Each path section must be using image prefixs.");
			slideshowSections = BindConfig("Slideshow", "Apply To", "", "Specify which sections the slideshow applies to. Separate multiple sections with commas.\nOptions: Header, Background, Loading, LoadBackground, LoadText.");
			slideshowDelay = BindConfig("Slideshow", "Timer", 10f, "Set the delay timer in seconds for the slideshow feature. Range: 0.1 - 30 seconds.");
			slideTransTime = BindConfig("Slideshow", "Transition Length", 2f, "How many seconds the transition should take to fade.");
		}

		private ConfigEntry<T> BindConfig<T>(string section, string key, T defaultValue, string description)
		{
			return Config.Bind<T>(section, key, defaultValue, description);
		}
	}
	public class LoadingText
	{
		private string[] textOptions;

		private int lastIndex = -1;

		private Configurator ConfigManager => Configurator.Instance;

		public LoadingText()
		{
			ConfigManager.enableLoadingTextChange.SettingChanged += delegate
			{
				ToggleLoadText();
			};
			ConfigManager.loadTextString.SettingChanged += delegate
			{
				UpdateTextOptions();
			};
			ConfigManager.loadTextString.SettingChanged += delegate
			{
				UpdateTextProperties();
			};
			ConfigManager.loadTextSize.SettingChanged += delegate
			{
				UpdateTextProperties();
			};
			ConfigManager.loadTextColor.SettingChanged += delegate
			{
				UpdateTextProperties();
			};
			ConfigManager.loadTextYOffset.SettingChanged += delegate
			{
				UpdateTextProperties();
			};
			ConfigManager.enableTypedLoadText.SettingChanged += delegate
			{
				StartTextUpdates();
			};
			ConfigManager.slideshowSections.SettingChanged += delegate
			{
				StartTextUpdates();
			};
		}

		public void ToggleLoadText()
		{
			RectTransform val = FindLoadingTextContainer();
			if ((Object)(object)val == (Object)null)
			{
				LogWarden.LogError("[LoadText] LoadingTextContainer not found.");
				return;
			}
			TextMeshProUGUI componentInChildren = ((Component)val).GetComponentInChildren<TextMeshProUGUI>(true);
			Transform obj = ((Transform)val).Find("LoadMessage");
			TextMeshProUGUI val2 = ((obj != null) ? ((Component)obj).GetComponent<TextMeshProUGUI>() : null);
			if ((Object)(object)componentInChildren == (Object)null || (Object)(object)val2 == (Object)null)
			{
				LogWarden.LogError("[LoadText] Could not find the original or cloned LoadingText components.");
				return;
			}
			bool value = ConfigManager.enableLoadingTextChange.Value;
			((Component)componentInChildren).gameObject.SetActive(!value);
			((Component)val2).gameObject.SetActive(value);
			LogWarden.LogInfo("[LoadText] ToggleLoadText: Original is " + (value ? "inactive" : "active") + ", cloned is " + (value ? "active" : "inactive") + ".");
		}

		public void ApplyLoadingCustomizations()
		{
			//IL_003b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0040: Unknown result type (might be due to invalid IL or missing references)
			//IL_004c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0052: 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_0084: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a8: Unknown result type (might be due to invalid IL or missing references)
			//IL_00bf: Unknown result type (might be due to invalid IL or missing references)
			RectTransform val = FindLoadingTextContainer();
			if ((Object)(object)val == (Object)null)
			{
				LogWarden.LogError("[LoadText] LoadingTextContainer not found.");
				return;
			}
			TextMeshProUGUI componentInChildren = ((Component)val).GetComponentInChildren<TextMeshProUGUI>();
			if ((Object)(object)componentInChildren == (Object)null)
			{
				LogWarden.LogError("[LoadText] Original TextMeshProUGUI component not found.");
				return;
			}
			GameObject val2 = new GameObject("LoadMessage");
			val2.transform.SetParent((Transform)(object)val);
			val2.transform.localScale = Vector3.one;
			TextMeshProUGUI val3 = val2.AddComponent<TextMeshProUGUI>();
			((TMP_Text)val3).rectTransform.sizeDelta = ((TMP_Text)componentInChildren).rectTransform.sizeDelta;
			((TMP_Text)val3).rectTransform.anchoredPosition = ((TMP_Text)componentInChildren).rectTransform.anchoredPosition;
			((TMP_Text)val3).text = ((TMP_Text)componentInChildren).text;
			((TMP_Text)val3).font = ((TMP_Text)componentInChildren).font;
			((TMP_Text)val3).fontStyle = ((TMP_Text)componentInChildren).fontStyle;
			((TMP_Text)val3).fontSize = ((TMP_Text)componentInChildren).fontSize;
			((Graphic)val3).color = Color.white;
			((TMP_Text)val3).alignment = (TextAlignmentOptions)514;
			SetTextProperties(val3, ConfigManager.loadTextString.Value);
			AdjustTextContainerAnchors(((TMP_Text)val3).rectTransform);
			((Transform)val).SetAsLastSibling();
			ToggleLoadText();
			StartTextUpdates();
		}

		public void StartTextUpdates()
		{
			if (ShouldStartUpdates())
			{
				float value = ConfigManager.slideshowDelay.Value;
				DelayHelper.StartRepeatingAction("textUpdates", value, UpdateLoadingText);
			}
		}

		private bool ShouldStartUpdates()
		{
			if (!(from s in ConfigManager.slideshowSections.Value.Split(new char[1] { ',' })
				select s.Trim().ToLower()).Contains("loadtext") || !ConfigManager.enableLoadingTextChange.Value)
			{
				return false;
			}
			return true;
		}

		private TextMeshProUGUI GetTextComponent()
		{
			RectTransform val = FindLoadingTextContainer();
			if ((Object)(object)val == (Object)null)
			{
				return null;
			}
			Transform val2 = ((Transform)val).Find("LoadMessage");
			if ((Object)(object)val2 == (Object)null)
			{
				LogWarden.LogError("[LoadText] 'LoadMessage' GameObject not found.");
				return null;
			}
			TextMeshProUGUI component = ((Component)val2).GetComponent<TextMeshProUGUI>();
			if ((Object)(object)component == (Object)null)
			{
				LogWarden.LogError("[LoadText] TextMeshProUGUI component not found on 'LoadMessage'.");
				return null;
			}
			return component;
		}

		public void UpdateLoadingText()
		{
			TextMeshProUGUI textComponent = GetTextComponent();
			if (!((Object)(object)textComponent == (Object)null) && ConfigManager.enableLoadingTextChange.Value)
			{
				string randomLoadingText = GetRandomLoadingText(ConfigManager.loadTextString.Value);
				if (ConfigManager.enableTypedLoadText.Value)
				{
					DelayHelper.StartTypingText(textComponent, randomLoadingText, 0.05f, 0.5f);
				}
				else
				{
					((TMP_Text)textComponent).text = randomLoadingText;
				}
				LogWarden.LogInfo("[LoadText] Updated loading text to: " + randomLoadingText);
			}
		}

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

		private void EnsureFullScreenContainer(RectTransform container)
		{
			//IL_0001: 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_0017: 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)
			container.anchorMin = Vector2.zero;
			container.anchorMax = Vector2.one;
			container.offsetMin = Vector2.zero;
			container.offsetMax = Vector2.zero;
		}

		private string GetRandomLoadingText(string allTexts)
		{
			if (textOptions == null || textOptions.Length == 0)
			{
				textOptions = allTexts.Split(new char[1] { '|' });
			}
			if (textOptions.Length == 1)
			{
				return textOptions[0];
			}
			int num;
			do
			{
				num = Random.Range(0, textOptions.Length);
			}
			while (num == lastIndex && textOptions.Length > 1);
			lastIndex = num;
			return textOptions[num];
		}

		public void UpdateTextProperties()
		{
			TextMeshProUGUI textComponent = GetTextComponent();
			if ((Object)(object)textComponent == (Object)null)
			{
				LogWarden.LogError("[LoadText] Text component not found.");
			}
			else
			{
				SetTextProperties(textComponent, ConfigManager.loadTextString.Value);
			}
		}

		private void UpdateTextOptions()
		{
			string value = ConfigManager.loadTextString.Value;
			textOptions = value.Split(new char[1] { '|' });
			LogWarden.LogInfo("[LoadText] Text options updated.");
		}

		private void SetTextProperties(TextMeshProUGUI textComponent, string text)
		{
			if ((Object)(object)textComponent != (Object)null)
			{
				string arg = (((TMP_Text)textComponent).text = GetRandomLoadingText(text));
				((TMP_Text)textComponent).enableWordWrapping = false;
				((TMP_Text)textComponent).fontSize = ConfigManager.loadTextSize.Value;
				SetTextColor(textComponent);
				AdjustTextContainerAnchors(((TMP_Text)textComponent).rectTransform);
				LogWarden.LogInfo($"[LoadText] Text properties updated: Text set to '{arg}' with size {ConfigManager.loadTextSize.Value} and color.");
			}
		}

		private void SetTextColor(TextMeshProUGUI textComponent)
		{
			//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)
			//IL_0022: Unknown result type (might be due to invalid IL or missing references)
			//IL_0032: 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_003d: 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_0044: Unknown result type (might be due to invalid IL or missing references)
			//IL_0045: 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)
			try
			{
				Color val2 = (((Graphic)textComponent).color = ColorParser.RGBA(ConfigManager.loadTextColor.Value));
				LogWarden.LogInfo($"[LoadText] Font color set to: {val2}");
				Color val3 = Color.Lerp(Color.black, val2, 0.3f);
				((TMP_Text)textComponent).outlineColor = Color32.op_Implicit(val3);
				((TMP_Text)textComponent).outlineWidth = 1f;
				((TMP_Text)textComponent).enableVertexGradient = false;
				((TMP_Text)textComponent).ForceMeshUpdate(false, false);
				LogWarden.LogInfo($"[LoadText] Outline color set to: {val3}");
			}
			catch (Exception ex)
			{
				LogWarden.LogError("[LoadText] Error setting font color using ColorParser: " + ex.Message);
			}
		}

		private void AdjustTextContainerAnchors(RectTransform rectTransform)
		{
			//IL_0041: Unknown result type (might be due to invalid IL or missing references)
			//IL_0052: 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_0078: Unknown result type (might be due to invalid IL or missing references)
			float value = ConfigManager.loadTextYOffset.Value;
			float num = Mathf.Lerp(-44f, 144f, value / 100f);
			float num2 = 1f - num / 100f;
			rectTransform.pivot = new Vector2(0.5f, 0.5f);
			rectTransform.anchorMin = new Vector2(0.5f, num2);
			rectTransform.anchorMax = new Vector2(0.5f, num2);
			rectTransform.anchoredPosition = new Vector2(0f, 0f);
		}
	}
	public static class UI
	{
		public const string MenuCont = "Canvas/MenuContainer";

		public const string MainBtns = "Canvas/MenuContainer/MainButtons";

		public const string MainImg = "Canvas/MenuContainer/MainButtons/HeaderImage";

		public const string MainHeader = "Canvas/MenuContainer/MainButtons/MainHeader";

		public const string CustBgImg = "Canvas/MenuContainer/MainButtons/Background";

		public const string LoadScreen = "Canvas/MenuContainer/LoadingScreen";

		public const string LoadImg = "Canvas/MenuContainer/LoadingScreen/Image";

		public const string LoadHeader = "Canvas/MenuContainer/LoadingScreen/LoadHeader";

		public const string LoadTextCont = "Canvas/MenuContainer/LoadingScreen/LoadingTextContainer";

		public const string LoadText = "Canvas/MenuContainer/LoadingScreen/LoadingTextContainer/LoadingText";
	}
}
namespace Emblem.Managers
{
	public class InterfaceDecorator
	{
		private readonly UIComponent uiComponent;

		private readonly BackgroundManager backgroundManager;

		private readonly HeaderReplacement headerReplacement;

		private readonly Boardwalk boardwalk;

		private readonly LoadingText loadingText;

		private readonly MenuMoodSetter menuMoodSetter;

		private readonly VersionStyler versionStyler;

		private readonly Slideshow slideshow;

		public InterfaceDecorator(UIComponent uiComponent, BackgroundManager backgroundManager, HeaderReplacement headerReplacement, Boardwalk boardwalk, LoadingText loadingText, MenuMoodSetter menuMoodSetter, VersionStyler versionStyler, Slideshow slideshow)
		{
			this.uiComponent = uiComponent;
			this.backgroundManager = backgroundManager;
			this.headerReplacement = headerReplacement;
			this.boardwalk = boardwalk;
			this.loadingText = loadingText;
			this.menuMoodSetter = menuMoodSetter;
			this.versionStyler = versionStyler;
			this.slideshow = slideshow;
		}

		public void ApplyInitCustomizations()
		{
			uiComponent.SetVolumeLayerMaskOnAllCameras(-1);
			uiComponent.ToggleCRTEffect();
		}

		public void ApplyMainMenuCustomizations()
		{
			uiComponent.SetVolumeLayerMaskOnAllCameras(-1);
			headerReplacement.InitializeAndReplaceHeaders();
			backgroundManager.ApplyMainMenuBackground();
			uiComponent.SetMainBackgroundColor();
			uiComponent.ResetRectTransformProperties();
			uiComponent.ToggleCRTEffect();
			uiComponent.ToggleScanlines();
			uiComponent.CreateBackgrounds();
			menuMoodSetter.HarmonizeMenuHues("Canvas/MenuContainer/MainButtons");
			boardwalk.ToggleBorder();
			versionStyler.InitializeVersionStyling();
			loadingText.ApplyLoadingCustomizations();
			backgroundManager.ApplyLoadingBackground();
			DelayHelper.StartDelayedAction(0.3f, delegate
			{
				menuMoodSetter.HarmonizeMenuHues("Canvas/MenuContainer/MainButtons");
			});
		}
	}
	public class SceneManagerHelper
	{
		private readonly InterfaceDecorator interfaceDecorator;

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

		private void OnSceneLoaded(Scene scene, LoadSceneMode mode)
		{
			DelayHelper.StopAll();
			HotLoad.Instance?.OnDestroy();
			if (((Scene)(ref scene)).name == "InitSceneLaunchOptions" || ((Scene)(ref scene)).name == "InitScene" || ((Scene)(ref scene)).name == "InitSceneLANMode")
			{
				LogWarden.LogInfo("[SceneManager] Applying customizations to Init.");
				interfaceDecorator.ApplyInitCustomizations();
			}
			if (((Scene)(ref scene)).name == "MainMenu")
			{
				MainThreadDispatcher.EnsureInstance();
				LogWarden.LogInfo("[SceneManager] Applying customizations to MainMenu.");
				interfaceDecorator.ApplyMainMenuCustomizations();
				HotLoad.Initialize();
			}
		}

		public void Unsubscribe()
		{
			SceneManager.sceneLoaded -= OnSceneLoaded;
		}
	}
}
namespace Emblem.Components
{
	public class BackgroundManager
	{
		private readonly ImageFilters imageFilters;

		private Configurator ConfigManager => Configurator.Instance;

		private CustomMediaManager MediaManager => CustomMediaManager.Instance;

		public BackgroundManager()
		{
			imageFilters = new ImageFilters(ConfigManager);
			ConfigManager.enableMainBackground.SettingChanged += delegate
			{
				ToggleBackground("main");
			};
			ConfigManager.enableLoadBackground.SettingChanged += delegate
			{
				ToggleBackground("load");
			};
			ConfigManager.mainBackgroundPath.SettingChanged += delegate
			{
				RefreshBackgroundPath("main");
			};
			ConfigManager.loadBackgroundPath.SettingChanged += delegate
			{
				RefreshBackgroundPath("load");
			};
			ConfigManager.mainBackgroundColor.SettingChanged += delegate
			{
				ApplyMainMenuBackground();
			};
			ConfigManager.loadBackgroundColor.SettingChanged += delegate
			{
				ApplyLoadingBackground();
			};
			ConfigManager.enableSlideshow.SettingChanged += delegate
			{
				ToggleBackgroundSlideshow();
			};
			ConfigManager.slideshowSections.SettingChanged += delegate
			{
				ToggleBackgroundSlideshow();
			};
			ConfigManager.slideshowDelay.SettingChanged += delegate
			{
				ToggleBackgroundSlideshow();
			};
			ConfigManager.slideTransTime.SettingChanged += delegate
			{
				ToggleBackgroundSlideshow();
			};
		}

		private void ToggleBackground(string type)
		{
			if (!(type == "main"))
			{
				if (type == "load")
				{
					bool value = ConfigManager.enableLoadBackground.Value;
					DestroyBackground("LoadingScreen/LoadBackground");
					if (value)
					{
						ApplyLoadingBackground();
					}
				}
			}
			else
			{
				bool value2 = ConfigManager.enableMainBackground.Value;
				DestroyBackground("MenuContainer/MainBackground");
				if (value2)
				{
					ApplyMainMenuBackground();
				}
			}
		}

		private void DestroyBackground(string path)
		{
			GameObject val = GameObject.Find(path);
			if ((Object)(object)val != (Object)null)
			{
				Object.Destroy((Object)(object)val);
			}
		}

		private void RefreshBackgroundPath(string type)
		{
			if (!(type == "main"))
			{
				if (type == "load" && ConfigManager.enableLoadBackground.Value)
				{
					ApplyLoadingBackground();
				}
			}
			else if (ConfigManager.enableMainBackground.Value)
			{
				ApplyMainMenuBackground();
			}
		}

		public void ApplyMainMenuBackground()
		{
			//IL_0031: Unknown result type (might be due to invalid IL or missing references)
			ApplyBackground(ConfigManager.enableMainBackground.Value, ConfigManager.mainBackgroundPath.Value, ColorParser.RGB(ConfigManager.mainBackgroundColor.Value), "MenuContainer", "MainBackground");
			StartBackgroundSlideshow("main");
		}

		public void ApplyLoadingBackground()
		{
			//IL_0031: Unknown result type (might be due to invalid IL or missing references)
			ApplyBackground(ConfigManager.enableLoadBackground.Value, ConfigManager.loadBackgroundPath.Value, ColorParser.RGB(ConfigManager.loadBackgroundColor.Value), "LoadingScreen", "LoadBackground");
			StartBackgroundSlideshow("load");
		}

		private void ApplyBackground(bool isEnabled, string backgroundPath, Color backgroundColor, string parentObjectName, string backgroundObjectName)
		{
			//IL_005e: Unknown result type (might be due to invalid IL or missing references)
			if (isEnabled && !string.IsNullOrEmpty(backgroundPath))
			{
				Transform obj = PathFinder.Probe(parentObjectName);
				GameObject val = ((obj != null) ? ((Component)obj).gameObject : null);
				if ((Object)(object)val == (Object)null)
				{
					LogWarden.LogError("[Background] " + parentObjectName + " not found in the scene.");
				}
				else if (backgroundPath.EndsWith(".mp4", StringComparison.OrdinalIgnoreCase))
				{
					HandleVideoBackground(val, backgroundPath, backgroundObjectName);
				}
				else
				{
					HandleImageBackground(val, backgroundPath, backgroundObjectName, backgroundColor);
				}
			}
		}

		private void HandleVideoBackground(GameObject parentObject, string backgroundPath, string videoObjectName)
		{
			string text = MediaManager.LoadCustomVideoPath(backgroundPath);
			if (text != null)
			{
				(parentObject.GetComponent<BackgroundVideoManager>() ?? parentObject.AddComponent<BackgroundVideoManager>()).InitializeVideo(parentObject, text, videoObjectName);
			}
		}

		public void HandleImageBackground(GameObject parentObject, string backgroundPath, string backgroundObjectName, Color backgroundColor)
		{
			//IL_0029: Unknown result type (might be due to invalid IL or missing references)
			Sprite customSprite = MediaManager.LoadCustomImage(backgroundPath, backgroundObjectName);
			GameObject val = CreateBackgroundImage(parentObject.transform, customSprite, backgroundObjectName);
			imageFilters.Blend(((Object)val).name, backgroundColor);
			if (ConfigManager.enableSlideshow.Value)
			{
				float value = ConfigManager.slideTransTime.Value;
				if (val.GetComponent<DelayHelper>() == null)
				{
					val.AddComponent<DelayHelper>();
				}
				new Slideshow(val.transform).StartFade(value);
			}
		}

		private GameObject CreateBackgroundImage(Transform parentTransform, Sprite customSprite, string objectName)
		{
			if ((Object)(object)customSprite == (Object)null)
			{
				LogWarden.LogError("[Background] No custom sprite provided for background image creation.");
				return null;
			}
			GameObject orCreateBackgroundObject = GetOrCreateBackgroundObject(parentTransform, objectName);
			Image val = SetImageComponent(orCreateBackgroundObject, customSprite);
			AdjustImageToFit(parentTransform, ((Component)val).GetComponent<RectTransform>(), customSprite);
			return orCreateBackgroundObject;
		}

		private GameObject GetOrCreateBackgroundObject(Transform parentTransform, string objectName)
		{
			//IL_0026: Unknown result type (might be due to invalid IL or missing references)
			//IL_002c: Expected O, but got Unknown
			Transform val = parentTransform.Find(objectName);
			GameObject val2;
			if ((Object)(object)val != (Object)null)
			{
				val2 = ((Component)val).gameObject;
				val2.transform.SetAsFirstSibling();
			}
			else
			{
				val2 = new GameObject(objectName);
				val2.transform.SetParent(parentTransform, false);
				val2.transform.SetAsFirstSibling();
			}
			return val2;
		}

		private Image SetImageComponent(GameObject backgroundImageObject, Sprite customSprite)
		{
			Image val = backgroundImageObject.GetComponent<Image>();
			if ((Object)(object)val == (Object)null)
			{
				val = backgroundImageObject.AddComponent<Image>();
			}
			val.sprite = customSprite;
			val.preserveAspect = true;
			return val;
		}

		private void AdjustImageToFit(Transform parentTransform, RectTransform rectTransform, Sprite customSprite)
		{
			//IL_000b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0020: 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_0045: 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_0053: 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_005b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0072: 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_007a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0092: Unknown result type (might be due to invalid IL or missing references)
			rectTransform.anchorMin = new Vector2(0.5f, 0f);
			rectTransform.anchorMax = new Vector2(0.5f, 1f);
			rectTransform.pivot = new Vector2(0.5f, 0.5f);
			Rect rect = ((Component)parentTransform).GetComponent<RectTransform>().rect;
			float height = ((Rect)(ref rect)).height;
			Bounds bounds = customSprite.bounds;
			float num = ((Bounds)(ref bounds)).size.y * customSprite.pixelsPerUnit;
			float num2 = height / num;
			bounds = customSprite.bounds;
			rectTransform.sizeDelta = new Vector2(((Bounds)(ref bounds)).size.x * customSprite.pixelsPerUnit * num2, 0f);
		}

		public void ToggleBackgroundSlideshow()
		{
			if (ConfigManager.enableSlideshow.Value)
			{
				StartBackgroundSlideshow("main");
				StartBackgroundSlideshow("load");
			}
			else
			{
				DelayHelper.StopRepeatingAction("background");
				DelayHelper.StopRepeatingAction("loadbackground");
			}
		}

		public void StartBackgroundSlideshow(string type)
		{
			if (!ConfigManager.enableSlideshow.Value)
			{
				return;
			}
			string[] array = ConfigManager.slideshowSections.Value.Split(new char[1] { ',' });
			float value = ConfigManager.slideshowDelay.Value;
			string[] array2 = array;
			for (int i = 0; i < array2.Length; i++)
			{
				string text = array2[i].Trim().ToLower();
				if (type == "main" && text == "background")
				{
					DelayHelper.StartRepeatingAction("background", value, delegate
					{
						ApplyMainMenuBackground();
					});
				}
				else if (type == "load" && text == "loadbackground")
				{
					DelayHelper.StartRepeatingAction("loadbackground", value, delegate
					{
						ApplyLoadingBackground();
					});
				}
			}
		}
	}
	public class BackgroundVideoManager : MonoBehaviour
	{
		private VideoPlayer videoPlayer;

		public string VideoPath { get; set; }

		public void InitializeVideo(GameObject targetGameObject, string videoPath, string videoObjectName)
		{
			VideoPath = videoPath;
			if ((Object)(object)targetGameObject == (Object)null)
			{
				LogWarden.LogError("[Video] Target GameObject not found in the scene.");
			}
			else
			{
				CreateBackgroundVideo(targetGameObject, videoObjectName);
			}
		}

		private void CreateBackgroundVideo(GameObject targetGameObject, string backgroundObjectName)
		{
			if (!string.IsNullOrEmpty(VideoPath))
			{
				string text = (VideoPath.StartsWith("file://", StringComparison.OrdinalIgnoreCase) ? VideoPath : ("file://" + VideoPath));
				string text2 = text.Replace(Paths.BepInExRootPath, "");
				text2 = text2.TrimStart(new char[1] { Path.DirectorySeparatorChar });
				LogWarden.LogInfo("[Video] Initializing video with relative path: " + text2);
				GameObject orCreateBackgroundObject = GetOrCreateBackgroundObject(targetGameObject.transform, backgroundObjectName);
				RawImage rawImage = orCreateBackgroundObject.GetComponent<RawImage>() ?? orCreateBackgroundObject.AddComponent<RawImage>();
				videoPlayer = orCreateBackgroundObject.GetComponent<VideoPlayer>() ?? orCreateBackgroundObject.AddComponent<VideoPlayer>();
				AudioSource audioSource = orCreateBackgroundObject.GetComponent<AudioSource>() ?? orCreateBackgroundObject.AddComponent<AudioSource>();
				ConfigureVideoPlayer(text, audioSource, rawImage);
				AdjustRawImage(rawImage);
				LogWarden.LogInfo("[Video] Background video added to the scene.");
			}
		}

		private GameObject GetOrCreateBackgroundObject(Transform parentTransform, string objectName)
		{
			//IL_0026: Unknown result type (might be due to invalid IL or missing references)
			//IL_002c: Expected O, but got Unknown
			Transform val = parentTransform.Find(objectName);
			GameObject val2;
			if ((Object)(object)val != (Object)null)
			{
				val2 = ((Component)val).gameObject;
				val2.transform.SetAsFirstSibling();
			}
			else
			{
				val2 = new GameObject(objectName);
				val2.transform.SetParent(parentTransform, false);
				val2.transform.SetAsFirstSibling();
			}
			return val2;
		}

		private void ConfigureVideoPlayer(string fullPath, AudioSource audioSource, RawImage rawImage)
		{
			//IL_006c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0072: Expected O, but got Unknown
			//IL_0092: Unknown result type (might be due to invalid IL or missing references)
			//IL_009c: Expected O, but got Unknown
			//IL_00a9: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b3: Expected O, but got Unknown
			videoPlayer.playOnAwake = true;
			videoPlayer.isLooping = true;
			videoPlayer.renderMode = (VideoRenderMode)2;
			videoPlayer.audioOutputMode = (VideoAudioOutputMode)1;
			videoPlayer.SetTargetAudioSource((ushort)0, audioSource);
			videoPlayer.source = (VideoSource)1;
			videoPlayer.url = fullPath;
			videoPlayer.aspectRatio = (VideoAspectRatio)1;
			RenderTexture val = new RenderTexture(1920, 1080, 0);
			videoPlayer.targetTexture = val;
			rawImage.texture = (Texture)(object)val;
			videoPlayer.errorReceived += new ErrorEventHandler(OnVideoErrorReceived);
			videoPlayer.prepareCompleted += new EventHandler(OnVideoPrepared);
			videoPlayer.Prepare();
		}

		private void AdjustRawImage(RawImage rawImage)
		{
			//IL_0011: Unknown result type (might be due to invalid IL or missing references)
			//IL_0026: 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)
			//IL_0046: 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)
			RectTransform component = ((Component)rawImage).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;
		}

		private void OnVideoErrorReceived(VideoPlayer source, string message)
		{
			LogWarden.LogError("Video Error: " + message);
		}

		private void OnVideoPrepared(VideoPlayer source)
		{
			//IL_0008: Unknown result type (might be due to invalid IL or missing references)
			//IL_0012: Expected O, but got Unknown
			source.prepareCompleted -= new EventHandler(OnVideoPrepared);
			LogWarden.LogInfo("[Video] Prepared and ready to play.");
			source.Play();
		}
	}
	public class Boardwalk
	{
		private RectTransform cloneRectTransform;

		private Image originalImage;

		private Image cloneImage;

		private Configurator ConfigManager => Configurator.Instance;

		public Boardwalk()
		{
			ConfigManager.enableReplaceBorder.SettingChanged += delegate
			{
				ToggleBorderVisibility();
			};
			ConfigManager.borderPadding.SettingChanged += delegate
			{
				SetBorderPadding();
			};
			ConfigManager.borderColor.SettingChanged += delegate
			{
				SetBorderColor();
			};
		}

		public void ToggleBorder()
		{
			foreach (string item in new List<string> { "MainButtons", "LobbyHostSettings", "DeleteFileConfirmation", "NewsPanel", "MenuNotification", "LANWarning", "LobbyList", "CreditsPanel" })
			{
				Transform val = PathFinder.Probe(item);
				if ((Object)(object)val != (Object)null)
				{
					HideOriginalBorder(val);
					if (item == "MainButtons" && !ConfigManager.enableReplaceBorder.Value)
					{
						CreateBorderCopy(val);
					}
				}
				else
				{
					LogWarden.LogWarning("[Border] " + item + " not found.");
				}
			}
		}

		private void ToggleBorderVisibility()
		{
			//IL_003c: Unknown result type (might be due to invalid IL or missing references)
			//IL_004c: 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_00c0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e0: Unknown result type (might be due to invalid IL or missing references)
			//IL_0084: Unknown result type (might be due to invalid IL or missing references)
			//IL_0108: Unknown result type (might be due to invalid IL or missing references)
			if ((Object)(object)cloneRectTransform == (Object)null || (Object)(object)cloneImage == (Object)null)
			{
				ToggleBorder();
			}
			if ((Object)(object)originalImage != (Object)null)
			{
				((Graphic)originalImage).color = new Color(((Graphic)originalImage).color.r, ((Graphic)originalImage).color.g, ((Graphic)originalImage).color.b, ConfigManager.enableReplaceBorder.Value ? 1f : 0f);
				LogWarden.LogInfo("[Border] Border visibility has been toggled");
			}
			if ((Object)(object)cloneRectTransform != (Object)null && (Object)(object)cloneImage != (Object)null)
			{
				((Graphic)cloneImage).color = new Color(((Graphic)cloneImage).color.r, ((Graphic)cloneImage).color.g, ((Graphic)cloneImage).color.b, ConfigManager.enableReplaceBorder.Value ? 0f : 1f);
			}
		}

		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 " + ((Object)borderTransform).name);
			}
		}

		private void CreateBorderCopy(Transform borderTransform)
		{
			//IL_0048: Unknown result type (might be due to invalid IL or missing references)
			//IL_004e: Expected O, but got Unknown
			GameObject gameObject = ((Component)borderTransform).gameObject;
			Image component = gameObject.GetComponent<Image>();
			if ((Object)(object)component == (Object)null)
			{
				LogWarden.LogWarning("[Border] No Image component found on " + ((Object)borderTransform).name + ". Cannot clone.");
			}
			else if ((Object)(object)cloneRectTransform == (Object)null)
			{
				GameObject val = new GameObject("Corners");
				val.transform.SetParent(gameObject.transform.parent);
				val.transform.SetSiblingIndex(3);
				cloneRectTransform = val.AddComponent<RectTransform>();
				CopyRectTransformSettings(((Graphic)component).rectTransform, cloneRectTransform);
				float value = ConfigManager.borderPadding.Value;
				SetBorderPadding();
				cloneImage = val.AddComponent<Image>();
				SetImageProperties(cloneImage, component);
				SetBorderColor();
				LogWarden.LogInfo("[Border] Updated with padding " + value + " and color set to " + ConfigManager.borderColor.Value);
			}
		}

		private void CopyRectTransformSettings(RectTransform original, RectTransform clone)
		{
			//IL_0002: 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_001a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0026: Unknown result type (might be due to invalid IL or missing references)
			//IL_0032: Unknown result type (might be due to invalid IL or missing references)
			//IL_003e: 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_0056: Unknown result type (might be due to invalid IL or missing references)
			((Transform)clone).localPosition = ((Transform)original).localPosition;
			((Transform)clone).localRotation = ((Transform)original).localRotation;
			((Transform)clone).localScale = ((Transform)original).localScale;
			clone.anchorMin = original.anchorMin;
			clone.anchorMax = original.anchorMax;
			clone.anchoredPosition = original.anchoredPosition;
			clone.sizeDelta = original.sizeDelta;
			clone.pivot = original.pivot;
		}

		private void SetBorderPadding()
		{
			//IL_001b: 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)
			float value = ConfigManager.borderPadding.Value;
			cloneRectTransform.offsetMax = new Vector2(0f - value, 0f - value);
			cloneRectTransform.offsetMin = new Vector2(value, value);
			LogWarden.LogInfo("[Border] Padding set to " + value);
		}

		private void SetBorderColor()
		{
			//IL_0018: Unknown result type (might be due to invalid IL or missing references)
			string value = ConfigManager.borderColor.Value;
			((Graphic)cloneImage).color = ColorParser.RGBA(value);
			LogWarden.LogInfo("[Border] Color set to " + value);
		}

		private void SetImageProperties(Image cloneImage, Image originalImage)
		{
			//IL_000e: Unknown result type (might be due to invalid IL or missing references)
			cloneImage.sprite = originalImage.sprite;
			cloneImage.type = originalImage.type;
			cloneImage.fillCenter = originalImage.fillCenter;
			cloneImage.pixelsPerUnitMultiplier = originalImage.pixelsPerUnitMultiplier;
			((Graphic)cloneImage).raycastTarget = false;
		}
	}
	public class MenuMoodSetter
	{
		private static readonly HashSet<string> loggedMessages = new HashSet<string>();

		private Configurator ConfigManager => Configurator.Instance;

		public MenuMoodSetter()
		{
			ConfigManager.enableMenuColorChange.SettingChanged += delegate
			{
				ToggleMenuHues();
			};
			ConfigManager.menuFontColor.SettingChanged += delegate
			{
				HarmonizeMenuHues("MainButtons");
			};
			ConfigManager.menuRolloverFontColor.SettingChanged += delegate
			{
				HarmonizeMenuHues("MainButtons");
			};
			ConfigManager.menuRolloverBGColor.SettingChanged += delegate
			{
				HarmonizeMenuHues("MainButtons");
			};
		}

		private void ToggleMenuHues()
		{
			if (!ConfigManager.enableMenuColorChange.Value)
			{
				RemoveAllColorCustomizations("Canvas/MenuContainer/MainButtons");
				LogWarden.LogInfo("[MoodSetter] Menu color change is disabled. All color tags removed.");
			}
			else
			{
				HarmonizeMenuHues("Canvas/MenuContainer/MainButtons");
			}
		}

		private void RemoveAllColorCustomizations(string gameObject)
		{
			//IL_0074: Unknown result type (might be due to invalid IL or missing references)
			Transform val = PathFinder.Probe(gameObject);
			if ((Object)(object)val == (Object)null)
			{
				LogWarden.LogError("[MoodSetter] " + gameObject + " object not found. Cannot remove customizations.");
				return;
			}
			TMP_Text[] componentsInChildren = ((Component)val).GetComponentsInChildren<TMP_Text>();
			foreach (TMP_Text val2 in componentsInChildren)
			{
				val2.text = RemoveColorTags(val2.text);
			}
			Button[] componentsInChildren2 = ((Component)val).GetComponentsInChildren<Button>();
			for (int i = 0; i < componentsInChildren2.Length; i++)
			{
				Image component = ((Component)componentsInChildren2[i]).GetComponent<Image>();
				if ((Object)(object)component != (Object)null)
				{
					((Graphic)component).color = Color.white;
				}
			}
			LogWarden.LogInfo("[MoodSetter] All color customizations have been removed from " + gameObject);
		}

		public void HarmonizeMenuHues(string gameObject)
		{
			//IL_00d3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d9: Expected O, but got Unknown
			if (!ConfigManager.enableMenuColorChange.Value)
			{
				LogWarden.LogInfo("[MoodSetter] Menu color change is disabled.");
				return;
			}
			LogOnce("[MoodSetter] Harmonizing menu hues...");
			Transform val = PathFinder.Probe(gameObject);
			if ((Object)(object)val == (Object)null)
			{
				LogWarden.LogError("[MoodSetter] " + gameObject + " object not found.");
				return;
			}
			LogOnce("[MoodSetter] " + gameObject + " object found. Processing children...");
			LogOnce("[MoodSetter] Painting menu font color: " + ConfigManager.menuFontColor.Value);
			LogOnce("[MoodSetter] Painting menu rollover font color: " + ConfigManager.menuRolloverFontColor.Value);
			LogOnce("[MoodSetter] Painting menu rollover background: " + ConfigManager.menuRolloverBGColor.Value);
			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 LogOnce(string message)
		{
			if (!loggedMessages.Contains(message))
			{
				LogWarden.LogInfo(message);
				loggedMessages.Add(message);
			}
		}

		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);
			});
			AddEventTrigger(orAddComponent, (EventTriggerType)4, delegate
			{
				ResetButtonState(buttonTransform);
			});
		}

		private void OnMouseEnter(Transform buttonTransform)
		{
			if (ConfigManager.enableMenuColorChange.Value)
			{
				SetTextColor(buttonTransform, ConfigManager.menuRolloverFontColor.Value);
				SetSelectionHighlight(buttonTransform, enabled: true, ConfigManager.menuRolloverBGColor.Value);
			}
			else
			{
				SetTextColor(buttonTransform, "0,0,0,1");
				SetSelectionHighlight(buttonTransform, enabled: true, "230,100,65,1");
			}
		}

		private void OnMouseExit(Transform buttonTransform)
		{
			if (ConfigManager.enableMenuColorChange.Value)
			{
				SetTextColor(buttonTransform, ConfigManager.menuFontColor.Value);
				SetSelectionHighlight(buttonTransform, enabled: false, "");
			}
			else
			{
				SetTextColor(buttonTransform, "230,100,65,1");
				SetSelectionHighlight(buttonTransform, enabled: false, "");
			}
		}

		private void ResetButtonState(Transform buttonTransform)
		{
			if (ConfigManager.enableMenuColorChange.Value)
			{
				SetTextColor(buttonTransform, ConfigManager.menuFontColor.Value);
				SetSelectionHighlight(buttonTransform, enabled: false, "");
			}
			else
			{
				SetTextColor(buttonTransform, "230,100,65,1");
				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)
			//IL_0024: 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_0037: 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)
			TMP_Text componentInChildren = ((Component)buttonTransform).GetComponentInChildren<TMP_Text>();
			if (!((Object)(object)componentInChildren == (Object)null))
			{
				string text = RemoveColorTags(componentInChildren.text);
				Color val = ColorParser.RGBA(colorString);
				string text2 = ColorUtility.ToHtmlStringRGB(new Color(val.r, val.g, val.b));
				componentInChildren.text = "<color=#" + text2 + ">" + text + "</color>";
				componentInChildren.alpha = val.a;
			}
		}

		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.RGBA(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 Slideshow
	{
		private readonly Transform parentTransform;

		private Configurator ConfigManager => Configurator.Instance;

		public Slideshow(Transform parentTransform)
		{
			this.parentTransform = parentTransform;
		}

		public void StartFade(float duration)
		{
			if (!ConfigManager.enableSlideshow.Value)
			{
				return;
			}
			GameObject orCreateSlideObject = GetOrCreateSlideObject("FrameFlipper");
			Image slideImage = orCreateSlideObject.GetComponent<Image>();
			Image backgroundImage = ((Component)parentTransform).GetComponentInChildren<Image>();
			DelayHelper.StartFadeAction(slideImage, duration, delegate
			{
				//IL_002a: Unknown result type (might be due to invalid IL or missing references)
				if ((Object)(object)backgroundImage != (Object)null)
				{
					slideImage.sprite = backgroundImage.sprite;
					((Graphic)slideImage).color = Color.white;
				}
			});
		}

		private GameObject GetOrCreateSlideObject(string objectName)
		{
			//IL_0023: Unknown result type (might be due to invalid IL or missing references)
			//IL_0029: Expected O, but got Unknown
			//IL_0086: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c1: 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_00d6: 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)
			Transform val = parentTransform.Find(objectName);
			GameObject val2;
			if ((Object)(object)val != (Object)null)
			{
				val2 = ((Component)val).gameObject;
			}
			else
			{
				val2 = new GameObject(objectName);
				val2.transform.SetParent(parentTransform, false);
				Image val3 = val2.AddComponent<Image>();
				val3.preserveAspect = false;
				Image componentInChildren = ((Component)parentTransform).GetComponentInChildren<Image>();
				if ((Object)(object)componentInChildren != (Object)null && (Object)(object)componentInChildren.sprite != (Object)null)
				{
					val3.sprite = componentInChildren.sprite;
					((Graphic)val3).color = Color.white;
				}
				else
				{
					((Graphic)val3).color = Color.clear;
				}
				RectTransform component = val2.GetComponent<RectTransform>();
				component.anchorMin = new Vector2(0f, 0f);
				component.anchorMax = new Vector2(1f, 1f);
				component.sizeDelta = Vector2.zero;
				component.offsetMin = Vector2.zero;
				component.offsetMax = Vector2.zero;
			}
			val2.transform.SetAsFirstSibling();
			return val2;
		}
	}
	public class VersionStyler
	{
		private GameObject versionStyled;

		private Configurator ConfigManager => Configurator.Instance;

		public VersionStyler()
		{
			ConfigManager.enableCustomVersion.SettingChanged += delegate
			{
				ToggleVersionStyling();
			};
			ConfigManager.versionTextString.SettingChanged += delegate
			{
				ApplyVersionStyling(versionStyled.transform);
			};
			ConfigManager.versionColor.SettingChanged += delegate
			{
				ApplyVersionStyling(versionStyled.transform);
			};
			ConfigManager.versionFontSize.SettingChanged += delegate
			{
				ApplyVersionStyling(versionStyled.transform);
			};
			ConfigManager.versionYOffset.SettingChanged += delegate
			{
				ApplyVersionStyling(versionStyled.transform);
			};
			ConfigManager.versionAlign.SettingChanged += delegate
			{
				ApplyVersionStyling(versionStyled.transform);
			};
		}

		public void InitializeVersionStyling()
		{
			if (!((Object)(object)versionStyled != (Object)null))
			{
				Transform val = PathFinder.Probe("Canvas/MenuContainer/VersionNum");
				if ((Object)(object)val == (Object)null)
				{
					LogWarden.LogError("[Version] Original version number GameObject not found.");
					return;
				}
				versionStyled = Object.Instantiate<GameObject>(((Component)val).gameObject, val.parent);
				((Object)versionStyled).name = "VersionStyled";
				ApplyVersionStyling(versionStyled.transform);
				((Component)val).gameObject.SetActive(!ConfigManager.enableCustomVersion.Value);
				versionStyled.SetActive(ConfigManager.enableCustomVersion.Value);
			}
		}

		private void ToggleVersionStyling()
		{
			InitializeVersionStyling();
			bool value = ConfigManager.enableCustomVersion.Value;
			versionStyled.SetActive(value);
			((Component)PathFinder.Probe("Canvas/MenuContainer/VersionNum")).gameObject.SetActive(!value);
			string text = (value ? "enabled" : "disabled");
			LogWarden.LogInfo("[Version] Custom version styling is now " + text + ".");
		}

		private void ApplyVersionStyling(Transform versionTextTransform)
		{
			//IL_0072: 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_008a: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b2: 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)
			//IL_0124: Unknown result type (might be due to invalid IL or missing references)
			//IL_013a: Unknown result type (might be due to invalid IL or missing references)
			//IL_014d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0157: Unknown result type (might be due to invalid IL or missing references)
			//IL_016d: Unknown result type (might be due to invalid IL or missing references)
			Transform val = PathFinder.Probe("Canvas/MenuContainer/VersionNum");
			TextMeshProUGUI val2 = default(TextMeshProUGUI);
			if ((Object)(object)val == (Object)null || !((Component)val).TryGetComponent<TextMeshProUGUI>(ref val2))
			{
				LogWarden.LogError("[Version] Original TextMeshPro component not found on version number GameObject.");
				return;
			}
			TextMeshProUGUI val3 = default(TextMeshProUGUI);
			if (!((Component)versionTextTransform).TryGetComponent<TextMeshProUGUI>(ref val3))
			{
				LogWarden.LogError("[Version] TextMeshPro component not found on styled version GameObject.");
				return;
			}
			string value = ConfigManager.versionTextString.Value;
			string text = ((TMP_Text)val2).text;
			string text2 = value.Replace("%VERSION%", text);
			Color val4 = ColorParser.RGBA(ConfigManager.versionColor.Value);
			((TMP_Text)val3).text = "<color=#" + ColorUtility.ToHtmlStringRGB(val4) + ">" + text2 + "</color>";
			((TMP_Text)val3).alpha = val4.a;
			((TMP_Text)val3).fontSize = ConfigManager.versionFontSize.Value;
			((TMP_Text)val3).enableWordWrapping = false;
			AdjustTextAlignment(val3);
			float num = 1f - ConfigManager.versionYOffset.Value / 100f;
			RectTransform component = ((Component)val3).GetComponent<RectTransform>();
			component.anchorMin = new Vector2(0f, num);
			component.anchorMax = new Vector2(1f, num);
			component.pivot = new Vector2(0.5f, 0.5f);
			component.sizeDelta = new Vector2(0f, component.sizeDelta.y);
			component.anchoredPosition = new Vector2(0f, 0f);
		}

		private void AdjustTextAlignment(TextMeshProUGUI versionText)
		{
			string value = ConfigManager.versionAlign.Value;
			switch (value)
			{
			case "Left":
				((TMP_Text)versionText).alignment = (TextAlignmentOptions)513;
				break;
			case "Center":
				((TMP_Text)versionText).alignment = (TextAlignmentOptions)514;
				break;
			case "Right":
				((TMP_Text)versionText).alignment = (TextAlignmentOptions)516;
				break;
			default:
				LogWarden.LogWarning("[Version] Invalid alignment option '" + value + "' specified. Defaulting to 'Center'.");
				((TMP_Text)versionText).alignment = (TextAlignmentOptions)514;
				break;
			}
		}
	}
	public class GlitchyLogo : MonoBehaviour
	{
		private RectTransform logoTransform;

		private Image logoImage;

		private Vector3 originalScale;

		private Vector3 originalPosition;

		private Quaternion originalRotation;

		private Color originalColor;

		private Vector2 originalSizeDelta;

		private Vector2 originalAnchorMin;

		private Vector2 originalAnchorMax;

		private Configurator ConfigManager => Configurator.Instance;

		private void Awake()
		{
			logoTransform = ((Component)this).GetComponent<RectTransform>();
			logoImage = ((Component)this).GetComponent<Image>();
			if ((Object)(object)logoTransform == (Object)null || (Object)(object)logoImage == (Object)null)
			{
				LogWarden.LogError("GlitchyLogo: Required components (RectTransform, Image) are missing from this GameObject.");
			}
			else
			{
				StoreOriginalProperties();
				LogWarden.LogInfo("GlitchyLogo: Components successfully initialized and properties stored.");
			}
			SceneManager.sceneLoaded += OnSceneLoaded;
			ConfigManager.mainHeaderAlpha.SettingChanged += OnSettingsChanged;
			ConfigManager.mainHeaderScale.SettingChanged += OnSettingsChanged;
			ConfigManager.mainHeaderYOffset.SettingChanged += OnSettingsChanged;
		}

		private void OnEnable()
		{
			StartGlitchEffect();
			LogWarden.LogInfo("GlitchyLogo: Glitch effect resumed due to GameObject being enabled.");
		}

		private void OnDestroy()
		{
			SceneManager.sceneLoaded -= OnSceneLoaded;
			ConfigManager.mainHeaderAlpha.SettingChanged -= OnSettingsChanged;
			ConfigManager.mainHeaderScale.SettingChanged -= OnSettingsChanged;
			ConfigManager.mainHeaderYOffset.SettingChanged -= OnSettingsChanged;
		}

		private void OnSettingsChanged(object sender, EventArgs e)
		{
			((MonoBehaviour)this).StopAllCoroutines();
			StoreOriginalProperties();
			StartGlitchEffect();
		}

		private void StoreOriginalProperties()
		{
			//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_0018: 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_0029: 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_003a: 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_004b: 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_0061: Unknown result type (might be due to invalid IL or missing references)
			//IL_006d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0072: Unknown result type (might be due to invalid IL or missing references)
			originalScale = ((Transform)logoTransform).localScale;
			originalPosition = ((Transform)logoTransform).localPosition;
			originalRotation = ((Transform)logoTransform).localRotation;
			originalColor = ((Graphic)logoImage).color;
			originalSizeDelta = logoTransform.sizeDelta;
			originalAnchorMin = logoTransform.anchorMin;
			originalAnchorMax = logoTransform.anchorMax;
		}

		public void StartGlitchEffect()
		{
			((MonoBehaviour)this).StartCoroutine(GlitchCycle());
		}

		private IEnumerator GlitchCycle()
		{
			while (true)
			{
				yield return (object)new WaitForSeconds(Random.Range(0.5f, 5f));
				int numberOfWaves = Random.Range(2, 7);
				for (int wave = 0; wave < numberOfWaves; wave++)
				{
					int num = Random.Range(1, 7);
					List<IEnumerator> list = new List<IEnumerator>();
					for (int i = 0; i < num; i++)
					{
						list.Add(ApplyRandomEffect());
					}
					foreach (IEnumerator item in list)
					{
						((MonoBehaviour)this).StartCoroutine(item);
					}
					yield return (object)new WaitForSeconds(0.04f);
					RestoreOriginalProperties();
				}
			}
		}

		private IEnumerator ApplyRandomEffect()
		{
			switch (Random.Range(0, 9))
			{
			case 0:
				yield return ApplyPositionShiftEffect();
				break;
			case 1:
				yield return ApplyRotationEffect();
				break;
			case 2:
				yield return ApplyColorShiftEffect();
				break;
			case 3:
				yield return ApplyScaleJitterEffect();
				break;
			case 4:
				yield return ApplyOpacityFlickerEffect();
				break;
			case 5:
				yield return ApplyHueShiftEffect();
				break;
			case 6:
				yield return ApplyMirrorFlipEffect();
				break;
			case 7:
				yield return ApplyVerticalMirrorFlipEffect();
				break;
			case 8:
				yield return ApplyRectStretchEffect();
				break;
			}
		}

		private IEnumerator ApplyPositionShiftEffect()
		{
			RectTransform obj = logoTransform;
			((Transform)obj).localPosition = ((Transform)obj).localPosition + new Vector3((float)Random.Range(-25, 25), (float)Random.Range(-25, 25), 0f);
			yield return null;
		}

		private IEnumerator ApplyRotationEffect()
		{
			((Transform)logoTransform).localRotation = Quaternion.Euler(0f, 0f, (float)Random.Range(-1, 1));
			yield return null;
		}

		private IEnumerator ApplyColorShiftEffect()
		{
			((Graphic)logoImage).color = new Color(Random.Range(0f, 1f), Random.Range(0f, 1f), Random.Range(0f, 1f), originalColor.a);
			yield return null;
		}

		private IEnumerator ApplyScaleJitterEffect()
		{
			float num = Random.Range(0.6f, 1.4f);
			((Transform)logoTransform).localScale = new Vector3(originalScale.x * num, originalScale.y * num, originalScale.z);
			yield return null;
		}

		private IEnumerator ApplyOpacityFlickerEffect()
		{
			float num = Random.Range(0.3f, 1f);
			((Graphic)logoImage).color = new Color(originalColor.r, originalColor.g, originalColor.b, num);
			yield return null;
		}

		private IEnumerator ApplyHueShiftEffect()
		{
			float duration = 0.03f;
			float elapsed = 0.01f;
			while (elapsed < duration)
			{
				elapsed += Time.deltaTime;
				float num = Mathf.Lerp(0f, 1f, elapsed / duration);
				((Graphic)logoImage).color = Color.HSVToRGB(num, 1f, 1f);
				yield return null;
			}
		}

		private IEnumerator ApplyMirrorFlipEffect()
		{
			((Transform)logoTransform).localScale = new Vector3(0f - ((Transform)logoTransform).localScale.x, ((Transform)logoTransform).localScale.y, ((Transform)logoTransform).localScale.z);
			yield return null;
		}

		private IEnumerator ApplyVerticalMirrorFlipEffect()
		{
			((Transform)logoTransform).localScale = new Vector3(((Transform)logoTransform).localScale.x, 0f - ((Transform)logoTransform).localScale.y, ((Transform)logoTransform).localScale.z);
			yield return null;
		}

		private IEnumerator ApplyRectStretchEffect()
		{
			logoTransform.sizeDelta = new Vector2(originalSizeDelta.x * Random.Range(0.8f, 1.2f), originalSizeDelta.y * Random.Range(0.8f, 1.2f));
			yield return null;
		}

		public void StopGlitchEffect()
		{
			((MonoBehaviour)this).StopAllCoroutines();
			RestoreOriginalProperties();
			LogWarden.LogInfo("GlitchyLogo: Glitch effects stopped and properties restored.");
		}

		private void OnSceneLoaded(Scene scene, LoadSceneMode mode)
		{
			if (((Scene)(ref scene)).name != "MainMenu")
			{
				StopGlitchEffect();
			}
		}

		private void RestoreOriginalProperties()
		{
			//IL_0007: 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_0029: Unknown result type (might be due to invalid IL or missing references)
			//IL_003a: Unknown result type (might be due to invalid IL or missing references)
			//IL_004b: 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_006d: Unknown result type (might be due to invalid IL or missing references)
			((Transform)logoTransform).localScale = originalScale;
			((Transform)logoTransform).localPosition = originalPosition;
			((Transform)logoTransform).localRotation = originalRotation;
			((Graphic)logoImage).color = originalColor;
			logoTransform.sizeDelta = originalSizeDelta;
			logoTransform.anchorMin = originalAnchorMin;
			logoTransform.anchorMax = originalAnchorMax;
		}
	}
	public class CustomMediaManager
	{
		private static CustomMediaManager _instance;

		private static readonly object _lock = new object();

		private readonly EmblemFolder emblemFolder;

		private Dictionary<string, string> lastSelectedImages = new Dictionary<string, string>();

		public static CustomMediaManager Instance
		{
			get
			{
				if (_instance == null)
				{
					lock (_lock)
					{
						if (_instance == null)
						{
							_instance = new CustomMediaManager();
						}
					}
				}
				return _instance;
			}
		}

		public CustomMediaManager()
		{
			emblemFolder = new EmblemFolder();
		}

		public string LoadCustomVideoPath(string path)
		{
			string text = path;
			if (path.Contains("|"))
			{
				string[] array = path.Split(new char[1] { '|' });
				text = array[Ra