Decompiled source of IntroTweaks v1.0.0

IntroTweaks.dll

Decompiled 9 months ago
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using System.Threading.Tasks;
using BepInEx;
using BepInEx.Bootstrap;
using BepInEx.Configuration;
using BepInEx.Logging;
using HarmonyLib;
using IntroTweaks.Data;
using IntroTweaks.Utils;
using Microsoft.CodeAnalysis;
using TMPro;
using UnityEngine;
using UnityEngine.Rendering;
using UnityEngine.SceneManagement;
using UnityEngine.UI;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: TargetFramework(".NETFramework,Version=v4.6", FrameworkDisplayName = ".NET Framework 4.6")]
[assembly: AssemblyCompany("IntroTweaks")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyDescription("Seamless skipping of Lethal Company intro/menu screens.")]
[assembly: AssemblyFileVersion("1.4.6.0")]
[assembly: AssemblyInformationalVersion("1.4.6+c371b8980c312aad7cfb9667bb62afd8e83c0acc")]
[assembly: AssemblyProduct("IntroTweaks")]
[assembly: AssemblyTitle("IntroTweaks")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.4.6.0")]
[module: UnverifiableCode]
[module: RefSafetyRules(11)]
namespace Microsoft.CodeAnalysis
{
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	internal sealed class EmbeddedAttribute : Attribute
	{
	}
}
namespace System.Runtime.CompilerServices
{
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	[AttributeUsage(AttributeTargets.Module, AllowMultiple = false, Inherited = false)]
	internal sealed class RefSafetyRulesAttribute : Attribute
	{
		public readonly int Version;

		public RefSafetyRulesAttribute(int P_0)
		{
			Version = P_0;
		}
	}
}
namespace IntroTweaks
{
	[BepInPlugin("mrov.IntroTweaks", "IntroTweaks", "1.4.7")]
	public class Plugin : BaseUnityPlugin
	{
		internal static string SelectedMode;

		private Harmony patcher;

		private static bool menuLoaded;

		internal static ManualLogSource Logger { get; private set; }

		public static Config Config { get; private set; }

		public static bool ModInstalled(string name)
		{
			name = name.ToLower();
			return Chainloader.PluginInfos.Values.Any((PluginInfo p) => p.Metadata.GUID.ToLower().Contains(name) || p.Metadata.Name.ToLower() == name);
		}

		private void Awake()
		{
			//IL_0095: Unknown result type (might be due to invalid IL or missing references)
			//IL_009f: Expected O, but got Unknown
			Logger = ((BaseUnityPlugin)this).Logger;
			Config = new Config(((BaseUnityPlugin)this).Config);
			if (!PluginEnabled(logDisabled: true))
			{
				return;
			}
			SceneManager.sceneLoaded += SceneLoaded;
			if (Config.SKIP_SPLASH_SCREENS.Value)
			{
				Task.Run((Action)SkipSplashScreen);
			}
			Config.InitBindings();
			SelectedMode = Config.AUTO_SELECT_MODE.Value.ToLower();
			try
			{
				patcher = new Harmony("mrov.IntroTweaks");
				patcher.PatchAll();
				Logger.LogInfo((object)"Plugin loaded.");
			}
			catch (Exception ex)
			{
				Logger.LogError((object)ex);
			}
		}

		public bool PluginEnabled(bool logDisabled = false)
		{
			bool value = Config.PLUGIN_ENABLED.Value;
			if (!value && logDisabled)
			{
				Logger.LogInfo((object)"IntroTweaks disabled globally.");
			}
			return value;
		}

		private void SkipSplashScreen()
		{
			Logger.LogDebug((object)"Skipping splash screens. Ew.");
			while (!menuLoaded)
			{
				SplashScreen.Stop((StopBehavior)0);
			}
		}

		private void SceneLoaded(Scene scene, LoadSceneMode _)
		{
			switch (((Scene)(ref scene)).name)
			{
			case "InitScene":
			case "InitSceneLaunchOptions":
			case "MainMenu":
				menuLoaded = true;
				break;
			}
		}
	}
	public static class PluginInfo
	{
		public const string PLUGIN_GUID = "IntroTweaks";

		public const string PLUGIN_NAME = "IntroTweaks";

		public const string PLUGIN_VERSION = "1.4.6";
	}
}
namespace IntroTweaks.Utils
{
	internal class DisplayUtil
	{
		public static List<DisplayInfo> Displays { get; private set; } = new List<DisplayInfo>();


		internal static void Move(int displayIndex)
		{
			//IL_0011: Unknown result type (might be due to invalid IL or missing references)
			Screen.GetDisplayLayout(Displays);
			int num = Displays.IndexOf(Screen.mainWindowDisplayInfo);
			if (displayIndex != num)
			{
				MoveWindowAsync(displayIndex);
			}
		}

		private static async void MoveWindowAsync(int index)
		{
			await MoveWindowTask(index);
		}

		private static async Task MoveWindowTask(int index)
		{
			if (index >= Displays.Count)
			{
				await Task.CompletedTask;
				Plugin.Logger.LogDebug((object)"Display index out of bounds for current layout!");
				return;
			}
			DisplayInfo display = Displays[index];
			Vector2Int screenPos = Vector2Int.zero;
			if ((int)Screen.fullScreenMode != 3)
			{
				((Vector2Int)(ref screenPos)).x = ((Vector2Int)(ref screenPos)).x + display.width / 2;
				((Vector2Int)(ref screenPos)).y = ((Vector2Int)(ref screenPos)).y + display.height / 2;
			}
			AsyncOperation operation = Screen.MoveMainWindowTo(ref display, screenPos);
			while (operation.progress < 1f)
			{
				await Task.Yield();
			}
			Plugin.Logger.LogDebug((object)("Game moved to display: " + Displays[index].name));
		}
	}
	internal static class Extensions
	{
		internal static GameObject FindInParent(this GameObject obj, string name)
		{
			Transform parent = obj.transform.parent;
			try
			{
				return ((Component)parent.Find(name)).gameObject;
			}
			catch (Exception arg)
			{
				Plugin.Logger.LogError((object)$"Error finding '{name}' in: {((Object)parent).name}\n{arg}");
				return null;
			}
		}

		internal static bool IsAbove(this Transform cur, Transform target)
		{
			//IL_0002: Unknown result type (might be due to invalid IL or missing references)
			//IL_000d: Unknown result type (might be due to invalid IL or missing references)
			return cur.localPosition.y > target.localPosition.y;
		}

		internal static void ResetAnchoredPos(this RectTransform rect)
		{
			//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)
			rect.anchoredPosition = Vector2.zero;
			rect.anchoredPosition3D = Vector3.zero;
		}

		internal static void ResetPivot(this RectTransform rect)
		{
			//IL_0002: Unknown result type (might be due to invalid IL or missing references)
			rect.pivot = Vector2.zero;
		}

		internal static void ResetSizeDelta(this RectTransform rect)
		{
			//IL_0002: Unknown result type (might be due to invalid IL or missing references)
			rect.sizeDelta = Vector2.zero;
		}

		internal static void EditOffsets(this RectTransform rect, Vector2 max, Vector2 min)
		{
			//IL_0002: Unknown result type (might be due to invalid IL or missing references)
			//IL_000a: Unknown result type (might be due to invalid IL or missing references)
			rect.offsetMax = max;
			rect.offsetMin = min;
		}

		internal static void EditAnchors(this RectTransform rect, Vector2 max, Vector2 min)
		{
			//IL_0002: Unknown result type (might be due to invalid IL or missing references)
			//IL_000a: Unknown result type (might be due to invalid IL or missing references)
			rect.anchorMax = max;
			rect.anchorMin = min;
		}

		internal static void AnchorToBottomRight(this RectTransform rect)
		{
			//IL_0013: 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_003d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0049: Unknown result type (might be due to invalid IL or missing references)
			rect.ResetAnchoredPos();
			rect.EditAnchors(new Vector2(1f, 0f), new Vector2(1f, 0f));
			((Transform)rect).localPosition = new Vector3(432f, -222f, 0f);
			((Transform)rect).localRotation = Quaternion.identity;
		}

		internal static void AnchorToBottom(this RectTransform rect)
		{
			//IL_001a: 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_003f: Unknown result type (might be due to invalid IL or missing references)
			//IL_004e: Unknown result type (might be due to invalid IL or missing references)
			rect.ResetSizeDelta();
			rect.ResetAnchoredPos();
			rect.EditAnchors(new Vector2(0.5f, 0f), new Vector2(0.5f, 0f));
			rect.EditOffsets(new Vector2(0f, 0f), new Vector2(0f, 0f));
			rect.RefreshPosition();
		}

		internal static void RefreshPosition(this RectTransform rect)
		{
			//IL_0023: Unknown result type (might be due to invalid IL or missing references)
			//IL_002f: Unknown result type (might be due to invalid IL or missing references)
			float value = Plugin.Config.VERSION_TEXT_OFFSET.Value;
			((Transform)rect).localPosition = new Vector3(0f, -205f + value, 0f);
			((Transform)rect).localRotation = Quaternion.identity;
		}

		internal static void SetLocalX(this RectTransform rect, float newX)
		{
			//IL_0004: Unknown result type (might be due to invalid IL or missing references)
			//IL_000f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0019: Unknown result type (might be due to invalid IL or missing references)
			((Transform)rect).localPosition = new Vector3(newX, ((Transform)rect).localPosition.y, ((Transform)rect).localPosition.z);
		}

		internal static void FixScale(this Transform transform)
		{
			//IL_0011: Unknown result type (might be due to invalid IL or missing references)
			transform.localScale = new Vector3(1.02f, 1.06f, 1.02f);
		}

		internal static float ClampedValue(this ConfigEntry<float> entry, float min, float max)
		{
			return Mathf.Clamp(entry.Value, min, max);
		}
	}
}
namespace IntroTweaks.Patches
{
	[HarmonyPatch(typeof(InitializeGame))]
	internal class InitializeGamePatch
	{
		[HarmonyPrefix]
		[HarmonyPatch("Start")]
		private static void DisableBootAnimation(ref bool __runOriginal)
		{
			int value = Plugin.Config.GAME_STARTUP_DISPLAY.Value;
			if (value >= 0)
			{
				DisplayUtil.Move(value);
			}
			if (!Plugin.Config.SKIP_BOOT_ANIMATION.Value)
			{
				__runOriginal = true;
			}
			InitializeGame val = Object.FindObjectOfType<InitializeGame>();
			if (!((Object)(object)val == (Object)null))
			{
				Plugin.Logger.LogInfo((object)"Skipping boot animation");
				val.runBootUpScreen = false;
				val.bootUpAnimation = null;
				val.bootUpAudio = null;
			}
		}
	}
	[HarmonyPatch(typeof(MenuManager))]
	internal class MenuManagerPatch
	{
		internal static GameObject VersionNum = null;

		internal static Transform MenuContainer = null;

		internal static Transform MenuPanel = null;

		public static Color32 DARK_ORANGE = new Color32((byte)175, (byte)115, (byte)0, byte.MaxValue);

		private static MenuManager Instance;

		public static int realVer { get; internal set; }

		public static int gameVer { get; private set; }

		public static TextMeshProUGUI versionText { get; private set; }

		public static RectTransform versionTextRect { get; private set; }

		private static Config Cfg => Plugin.Config;

		[HarmonyPostfix]
		[HarmonyPatch("Start")]
		private static void Init(MenuManager __instance)
		{
			Instance = __instance;
			((MonoBehaviour)Instance).StartCoroutine(PatchMenuDelayed());
		}

		private static IEnumerator PatchMenuDelayed()
		{
			yield return (object)new WaitUntil((Func<bool>)(() => !GameNetworkManager.Instance.firstTimeInMenu));
			GameObject obj = GameObject.Find("MenuContainer");
			MenuContainer = ((obj != null) ? obj.transform : null);
			Transform menuContainer = MenuContainer;
			MenuPanel = ((menuContainer != null) ? menuContainer.Find("MainButtons") : null);
			Transform menuContainer2 = MenuContainer;
			object versionNum;
			if (menuContainer2 == null)
			{
				versionNum = null;
			}
			else
			{
				Transform obj2 = menuContainer2.Find("VersionNum");
				versionNum = ((obj2 != null) ? ((Component)obj2).gameObject : null);
			}
			VersionNum = (GameObject)versionNum;
			PatchMenu();
		}

		private static void PatchMenu()
		{
			Cfg.ALWAYS_SHORT_VERSION.SettingChanged += delegate
			{
				SetVersion();
			};
			Cfg.VERSION_TEXT_SIZE.SettingChanged += delegate
			{
				((TMP_Text)versionText).fontSize = Cfg.VERSION_TEXT_SIZE.ClampedValue(10f, 40f);
			};
			Cfg.VERSION_TEXT_OFFSET.SettingChanged += delegate
			{
				versionTextRect.RefreshPosition();
			};
			try
			{
				if (Cfg.FIX_MENU_PANELS.Value)
				{
					FixPanelAlignment(MenuPanel);
					FixPanelAlignment(MenuContainer.Find("LobbyHostSettings"));
					FixPanelAlignment(MenuContainer.Find("LobbyList"));
					FixPanelAlignment(MenuContainer.Find("LoadingScreen"));
					Plugin.Logger.LogDebug((object)"Fixed menu panel alignment.");
				}
				IEnumerable<GameObject> buttons = from b in ((Component)MenuPanel).GetComponentsInChildren<Button>(true)
					select ((Component)b).gameObject;
				if (Cfg.ALIGN_MENU_BUTTONS.Value)
				{
					AlignButtons(buttons);
				}
				if (Cfg.REMOVE_CREDITS_BUTTON.Value)
				{
					RemoveCreditsButton(buttons);
				}
				bool changeRenderMode = Cfg.FIX_MENU_CANVAS.Value;
				bool flag = Plugin.ModInstalled("AdvancedCompany");
				bool flag2 = Plugin.ModInstalled("MoreCompany");
				if (flag || flag2)
				{
					changeRenderMode = false;
				}
				if (Cfg.FIX_MORE_COMPANY.Value && flag2 && !flag)
				{
					string text = (FixMoreCompany() ? ". Edits have been made to its UI elements." : " but its UI elements do not exist!");
					Plugin.Logger.LogDebug((object)("MoreCompany found" + text));
				}
				TweakCanvasSettings(Instance.menuButtons, changeRenderMode);
			}
			catch (Exception arg)
			{
				Plugin.Logger.LogError((object)$"An error occurred patching the menu. SAJ.\n{arg}");
			}
			if (Cfg.REMOVE_NEWS_PANEL.Value)
			{
				GameObject newsPanel = Instance.NewsPanel;
				if (newsPanel != null)
				{
					newsPanel.SetActive(false);
				}
			}
			if (Cfg.REMOVE_LAN_WARNING.Value)
			{
				GameObject lanWarningContainer = Instance.lanWarningContainer;
				if (lanWarningContainer != null)
				{
					lanWarningContainer.SetActive(false);
				}
			}
			if (Cfg.REMOVE_LAUNCHED_IN_LAN.Value)
			{
				TextMeshProUGUI launchedInLanModeText = Instance.launchedInLanModeText;
				GameObject val = ((launchedInLanModeText != null) ? ((Component)launchedInLanModeText).gameObject : null);
				if (Object.op_Implicit((Object)(object)val))
				{
					val.SetActive(false);
				}
			}
			if (Cfg.AUTO_SELECT_HOST.Value)
			{
				Instance.ClickHostButton();
			}
		}

		[HarmonyPostfix]
		[HarmonyPatch("Update")]
		private static void UpdatePatch(MenuManager __instance)
		{
			bool activeSelf = __instance.menuButtons.activeSelf;
			if ((Object)(object)versionText == (Object)null)
			{
				TryReplaceVersionText();
				return;
			}
			((TMP_Text)versionText).text = Cfg.VERSION_TEXT.Value.Replace("$VERSION", $"{gameVer}");
			GameObject gameObject = ((Component)versionText).gameObject;
			if (!gameObject.activeSelf && activeSelf)
			{
				gameObject.SetActive(true);
			}
		}

		[HarmonyPrefix]
		[HarmonyPatch("ClickHostButton")]
		private static void DisableMenuOnHost()
		{
			Transform menuPanel = MenuPanel;
			if (menuPanel != null)
			{
				((Component)menuPanel).gameObject.SetActive(false);
			}
		}

		private static bool FixMoreCompany()
		{
			//IL_006c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0087: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f9: Unknown result type (might be due to invalid IL or missing references)
			//IL_0135: Unknown result type (might be due to invalid IL or missing references)
			//IL_0144: Unknown result type (might be due to invalid IL or missing references)
			//IL_0150: Unknown result type (might be due to invalid IL or missing references)
			//IL_0165: Unknown result type (might be due to invalid IL or missing references)
			GameObject val = GameObject.Find("GlobalScale");
			if (!Object.op_Implicit((Object)(object)val))
			{
				return false;
			}
			GameObject gameObject = ((Component)val.transform.Find("CosmeticsScreen")).gameObject;
			val.GetComponentInParent<Canvas>().pixelPerfect = true;
			Transform transform = ((Component)gameObject.transform.Find("SpinAreaButton")).transform;
			transform.localScale = new Vector3(0.48f, 0.55f, 0.46f);
			transform.position = new Vector3(421.65f, 245.7f, 200f);
			RectTransform component = gameObject.FindInParent("ActivateButton").GetComponent<RectTransform>();
			RectTransform component2 = ((Component)gameObject.transform.Find("ExitButton")).GetComponent<RectTransform>();
			component.AnchorToBottomRight();
			component2.AnchorToBottomRight();
			((Transform)component2).SetAsLastSibling();
			Transform transform2 = ((Component)gameObject.transform.Find("CosmeticsHolderBorder")).transform;
			transform2.localScale = new Vector3(2.4f, 2.1f, 1f);
			Transform transform3 = ((Component)Instance.menuButtons.transform.Find("HeaderImage")).transform;
			transform3.localScale = new Vector3(4.9f, 4.9f, 4.9f);
			transform3.localPosition = new Vector3(transform3.localPosition.x, transform3.localPosition.y + 35f, 0f);
			return (Object)(object)val != (Object)null;
		}

		private static void RemoveCreditsButton(IEnumerable<GameObject> buttons)
		{
			//IL_007d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0082: Unknown result type (might be due to invalid IL or missing references)
			GameObject val = buttons.First((GameObject b) => ((Object)b).name == "QuitButton");
			GameObject creditsButton = buttons.First((GameObject b) => ((Object)b).name == "Credits");
			creditsButton.SetActive(false);
			RectTransform creditsRect = creditsButton.GetComponent<RectTransform>();
			Rect rect = creditsRect.rect;
			float creditsHeight = ((Rect)(ref rect)).height * 1.3f;
			CollectionExtensions.Do<GameObject>(buttons, (Action<GameObject>)delegate(GameObject obj)
			{
				//IL_0026: 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_0043: Unknown result type (might be due to invalid IL or missing references)
				//IL_0049: 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)
				//IL_005c: Unknown result type (might be due to invalid IL or missing references)
				if (Object.op_Implicit((Object)(object)obj) && !((Object)(object)obj == (Object)(object)creditsButton))
				{
					Transform transform = obj.transform;
					Vector3 localPosition = transform.localPosition;
					if (obj.transform.IsAbove((Transform)(object)creditsRect))
					{
						transform.localPosition = new Vector3(localPosition.x, localPosition.y - creditsHeight, localPosition.z);
					}
				}
			});
			Plugin.Logger.LogDebug((object)"Removed credits button.");
		}

		private static void AlignButtons(IEnumerable<GameObject> buttons)
		{
			//IL_002e: 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)
			//IL_009f: Unknown result type (might be due to invalid IL or missing references)
			//IL_00aa: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b5: 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)
			//IL_0123: Unknown result type (might be due to invalid IL or missing references)
			//IL_0132: Unknown result type (might be due to invalid IL or missing references)
			RectTransform component = buttons.First((GameObject b) => ((Object)b).name == "HostButton").GetComponent<RectTransform>();
			component.SetLocalX(((Transform)component).localPosition.x + 15f);
			foreach (GameObject button in buttons)
			{
				if (!Object.op_Implicit((Object)(object)button))
				{
					Plugin.Logger.LogDebug((object)("Could not align button " + ((Object)button).name));
					continue;
				}
				RectTransform component2 = button.GetComponent<RectTransform>();
				component2.sizeDelta = component.sizeDelta;
				((Transform)component2).localPosition = new Vector3(((Transform)component).localPosition.x, ((Transform)component2).localPosition.y, ((Transform)component).localPosition.z);
				TextMeshProUGUI componentInChildren = button.GetComponentInChildren<TextMeshProUGUI>(true);
				((TMP_Text)componentInChildren).transform.FixScale();
				TweakTextSettings(componentInChildren);
				((TMP_Text)componentInChildren).fontSize = 15f;
				((TMP_Text)componentInChildren).wordSpacing = ((TMP_Text)componentInChildren).wordSpacing - 25f;
				RectTransform component3 = ((Component)componentInChildren).gameObject.GetComponent<RectTransform>();
				component3.ResetAnchoredPos();
				component3.EditOffsets(Vector2.zero, new Vector2(5f, 0f));
			}
			Plugin.Logger.LogDebug((object)"Aligned menu buttons.");
		}

		internal static void TryReplaceVersionText()
		{
			if (Cfg.CUSTOM_VERSION_TEXT.Value && !((Object)(object)VersionNum == (Object)null) && !((Object)(object)MenuPanel == (Object)null))
			{
				GameObject val = Object.Instantiate<GameObject>(VersionNum, MenuPanel);
				((Object)val).name = "VersionNumberText";
				versionText = InitTextMesh(val.GetComponent<TextMeshProUGUI>());
				versionTextRect = ((Component)versionText).gameObject.GetComponent<RectTransform>();
				versionTextRect.AnchorToBottom();
				VersionNum.SetActive(false);
			}
		}

		private static void SetVersion()
		{
			bool value = Cfg.ALWAYS_SHORT_VERSION.Value;
			int num = Math.Abs(GameNetworkManager.Instance.gameVersionNum);
			gameVer = (value ? realVer : ((num != realVer) ? num : realVer));
		}

		private static TextMeshProUGUI InitTextMesh(TextMeshProUGUI tmp)
		{
			SetVersion();
			((TMP_Text)tmp).text = Cfg.VERSION_TEXT.Value;
			((TMP_Text)tmp).fontSize = Cfg.VERSION_TEXT_SIZE.ClampedValue(10f, 40f);
			((TMP_Text)tmp).alignment = (TextAlignmentOptions)514;
			TweakTextSettings(tmp);
			return tmp;
		}

		private static void TweakTextSettings(TextMeshProUGUI tmp, bool overflow = true, bool wordWrap = false)
		{
			//IL_0017: Unknown result type (might be due to invalid IL or missing references)
			if (overflow)
			{
				((TMP_Text)tmp).overflowMode = (TextOverflowModes)0;
			}
			((TMP_Text)tmp).enableWordWrapping = wordWrap;
			((TMP_Text)tmp).faceColor = DARK_ORANGE;
		}

		private static void TweakCanvasSettings(GameObject panel, bool changeRenderMode)
		{
			Canvas componentInParent = panel.GetComponentInParent<Canvas>();
			componentInParent.pixelPerfect = true;
			if (changeRenderMode)
			{
				componentInParent.renderMode = (RenderMode)0;
			}
		}

		private static void FixPanelAlignment(Transform panel)
		{
			//IL_0026: 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)
			RectTransform component = ((Component)panel).gameObject.GetComponent<RectTransform>();
			component.ResetSizeDelta();
			component.ResetAnchoredPos();
			component.EditOffsets(new Vector2(-20f, -25f), new Vector2(20f, 25f));
			panel.FixScale();
		}
	}
	[HarmonyPatch(typeof(GameNetworkManager))]
	internal class NetworkManagerPatch
	{
		[HarmonyPrefix]
		[HarmonyPatch("Awake")]
		private static void SetRealVersion(GameNetworkManager __instance)
		{
			MenuManagerPatch.realVer = __instance.gameVersionNum;
		}
	}
	[HarmonyPatch(typeof(PreInitSceneScript))]
	internal class PreInitScenePatch
	{
		[HarmonyPostfix]
		[HarmonyPatch("Start")]
		private static void FinishedFirstLaunch()
		{
			IngamePlayerSettings instance = IngamePlayerSettings.Instance;
			if (instance != null)
			{
				instance.SetPlayerFinishedLaunchOptions();
			}
		}

		[HarmonyPostfix]
		[HarmonyPatch("SkipToFinalSetting")]
		internal static void SkipToSelectedMode(PreInitSceneScript __instance, ref bool ___choseLaunchOption)
		{
			string selectedMode = Plugin.SelectedMode;
			if (!(selectedMode != "online") || !(selectedMode != "lan"))
			{
				CollectionExtensions.Do<GameObject>((IEnumerable<GameObject>)__instance.LaunchSettingsPanels, (Action<GameObject>)delegate(GameObject panel)
				{
					panel.SetActive(false);
				});
				__instance.currentLaunchSettingPanel = 0;
				((TMP_Text)__instance.headerText).text = "";
				((Component)__instance.blackTransition).gameObject.SetActive(false);
				__instance.continueButton.gameObject.SetActive(false);
				___choseLaunchOption = true;
				__instance.mainAudio.PlayOneShot(__instance.selectSFX);
				string text = ((Plugin.SelectedMode == "online") ? "InitScene" : "InitSceneLANMode");
				if (Plugin.ModInstalled("LethalLevelLoader"))
				{
					Plugin.Logger.LogWarning((object)"Detected LLL, chaning nothing.");
				}
				SceneManager.LoadSceneAsync(text, (LoadSceneMode)1);
			}
		}
	}
	[HarmonyPatch(typeof(StartMatchLever))]
	internal class StartMatchLeverPatch
	{
		[HarmonyPostfix]
		[HarmonyPatch("Start")]
		public static void StartMatch(StartMatchLever __instance)
		{
			if (Plugin.Config.AUTO_START_GAME.Value && !__instance.leverHasBeenPulled)
			{
				((MonoBehaviour)__instance).StartCoroutine(PullLeverAnim(__instance));
			}
		}

		private static IEnumerator PullLeverAnim(StartMatchLever instance)
		{
			yield return (object)new WaitForSeconds(1.5f);
			instance.leverAnimatorObject.SetBool("pullLever", true);
			instance.leverHasBeenPulled = true;
			instance.triggerScript.interactable = false;
			instance.PullLever();
		}
	}
	[HarmonyPatch(typeof(StartOfRound))]
	internal class StartOfRoundPatch
	{
		[HarmonyPostfix]
		[HarmonyPatch("firstDayAnimation")]
		private static IEnumerator DisableFirstDaySFX(IEnumerator result, StartOfRound __instance)
		{
			while (result.MoveNext())
			{
				yield return result.Current;
			}
			if (Plugin.Config.DISABLE_FIRST_DAY_SFX.Value)
			{
				StopSpeaker(__instance.speakerAudioSource);
			}
		}

		private static void StopSpeaker(AudioSource source)
		{
			if (source.isPlaying)
			{
				source.Stop();
			}
		}
	}
}
namespace IntroTweaks.Data
{
	public class Config
	{
		private readonly ConfigFile configFile;

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

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

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

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

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

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

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

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

		public ConfigEntry<bool> FIX_MORE_COMPANY { get; internal set; }

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

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

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

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

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

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

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

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

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

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

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

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

		public Config(ConfigFile cfg)
		{
			configFile = cfg;
			PLUGIN_ENABLED = NewEntry("bEnabled", defaultVal: true, "Enable or disable the plugin globally.");
			SKIP_SPLASH_SCREENS = NewEntry(Category.INTRO_TWEAKS, "bSkipSplashScreens", defaultVal: true, "Skips those pesky Unity and Zeekers startup logos!");
		}

		private ConfigEntry<T> NewEntry<T>(string key, T defaultVal, string desc)
		{
			return NewEntry(Category.GENERAL, key, defaultVal, desc);
		}

		private ConfigEntry<T> NewEntry<T>(Category category, string key, T defaultVal, string desc)
		{
			return configFile.Bind<T>(category.Value, key, defaultVal, desc);
		}

		public void InitBindings()
		{
			SKIP_BOOT_ANIMATION = NewEntry(Category.INTRO_TWEAKS, "bSkipBootAnimation", defaultVal: true, "If the loading animation (booting OS) should be skipped.");
			AUTO_SELECT_MODE = NewEntry(Category.INTRO_TWEAKS, "sAutoSelectMode", "OFF", "Which mode to automatically enter into after the splash screen.\nValid options: ONLINE, LAN, OFF");
			AUTO_SELECT_HOST = NewEntry(Category.INTRO_TWEAKS, "bAutoSelectHost", defaultVal: false, "Whether the 'Host' button is automatically selected when the Online/LAN menu loads.");
			ALIGN_MENU_BUTTONS = NewEntry(Category.MENU_TWEAKS, "bAlignMenuButtons", defaultVal: true, "If the main menu buttons should align with each other.");
			FIX_MENU_CANVAS = NewEntry(Category.MENU_TWEAKS, "bFixMenuCanvas", defaultVal: false, "Whether the main menu canvas should have its settings corrected.\nMay cause overlapping issues, only enable it if you don't use other mods that edit the menu.");
			FIX_MENU_PANELS = NewEntry(Category.MENU_TWEAKS, "bFixMenuPanels", defaultVal: false, "The main menu panels (host, servers, loading screen) all have anchoring, offset and sizing issues.\nThis option helps solve them and improve the look of the menu.\n\nMAY BREAK SOME MODS.");
			FIX_MORE_COMPANY = NewEntry(Category.MENU_TWEAKS, "bFixMoreCompany", defaultVal: true, "Whether to apply fixes to MoreCompany UI elements.\nFixes include: button placement, header positioning & scaling of cosmetics border.\n\nPRONE TO INCOMPATIBILITIES! TURN THIS OFF IF YOU ENCOUNTER BREAKING BUGS.");
			REMOVE_LAN_WARNING = NewEntry(Category.MENU_TWEAKS, "bRemoveLanWarning", defaultVal: true, "Hides the warning popup when hosting a LAN session.");
			REMOVE_LAUNCHED_IN_LAN = NewEntry(Category.MENU_TWEAKS, "bRemoveLaunchedInLanText", defaultVal: true, "Hides the 'Launched in LAN mode' text below the Quit button.");
			REMOVE_NEWS_PANEL = NewEntry(Category.MENU_TWEAKS, "bRemoveNewsPanel", defaultVal: false, "Hides the panel that displays news such as game updates.");
			REMOVE_CREDITS_BUTTON = NewEntry(Category.MENU_TWEAKS, "bRemoveCreditsButton", defaultVal: true, "Hides the 'Credits' button on the main menu. The other buttons are automatically adjusted.");
			CUSTOM_VERSION_TEXT = NewEntry(Category.VERSION_TEXT, "bCustomVersionText", defaultVal: true, "Whether to replace the game's version text with a custom alternative.");
			VERSION_TEXT = NewEntry(Category.VERSION_TEXT, "sVersionText", "v$VERSION\n[MODDED]", "Replace the game's version text with this custom text in the main menu.\nTo insert the version number, use the $VERSION syntax. E.g. Ver69 would be Ver$VERSION");
			VERSION_TEXT_SIZE = NewEntry(Category.VERSION_TEXT, "fVersionTextSize", 20f, "The font size of the version text. Min = 10, Max = 40.");
			VERSION_TEXT_OFFSET = NewEntry(Category.VERSION_TEXT, "fVersionTextOffset", 0f, "Use this option to adjust the Y position of the version text if it's out of place.\nFor example, when using 3 lines of text, a small positive value would move it back up.");
			ALWAYS_SHORT_VERSION = NewEntry(Category.VERSION_TEXT, "bAlwaysShortVersion", defaultVal: true, "If the custom version text should always show the short 'real' version.\nThis will ignore mods like LC_API and MoreCompany that change the game version.");
			AUTO_START_GAME = NewEntry(Category.MISC, "bAutoStartGame", defaultVal: false, "If enabled, the lever will be pulled automatically to begin the landing sequence.");
			DISABLE_FIRST_DAY_SFX = NewEntry(Category.MISC, "bDisableFirstDaySFX", defaultVal: false, "Toggles the first day ship speaker SFX.");
			GAME_STARTUP_DISPLAY = NewEntry(Category.MISC, "iGameStartupDisplay", 0, "The index of the monitor to display the game on when starting.\nYou can find these indexes in your Windows display settings.\nDefaults to 0 (main monitor).");
		}
	}
	public struct Category
	{
		public static Category GENERAL => new Category("0 >> General << 0");

		public static Category INTRO_TWEAKS => new Category("1 >> Intro << 1");

		public static Category MENU_TWEAKS => new Category("2 >> Main Menu << 2");

		public static Category VERSION_TEXT => new Category("3 >> Custom Version Text << 3");

		public static Category MISC => new Category("4 >> Miscellaneous << 4");

		public string Value { get; private set; }

		public Category(string value)
		{
			Value = value;
		}
	}
}
namespace IntroTweaks.Core
{
	internal static class Metadata
	{
		public const string GUID = "mrov.IntroTweaks";

		public const string NAME = "IntroTweaks";

		public const string VERSION = "1.4.7";
	}
}