using System; using System.Collections; using System.Diagnostics; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.Versioning; using System.Security; using System.Security.Permissions; using BepInEx; using HarmonyLib; using Microsoft.CodeAnalysis; using TMPro; using UnityEngine; using UnityEngine.Events; using UnityEngine.UI; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)] [assembly: IgnoresAccessChecksTo("Assembly-CSharp")] [assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")] [assembly: AssemblyCompany("gnomesko")] [assembly: AssemblyConfiguration("Release")] [assembly: AssemblyFileVersion("0.1.0.0")] [assembly: AssemblyInformationalVersion("0.1.0")] [assembly: AssemblyProduct("Gnome Main Menu Confirm")] [assembly: AssemblyTitle("MainMenuConfirm")] [assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)] [assembly: AssemblyVersion("0.1.0.0")] [module: UnverifiableCode] [module: RefSafetyRules(11)] namespace Microsoft.CodeAnalysis { [CompilerGenerated] [Embedded] internal sealed class EmbeddedAttribute : Attribute { } } namespace System.Runtime.CompilerServices { [CompilerGenerated] [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 MainMenuConfirm { [BepInPlugin("gnomesko.MainMenuConfirm", "MainMenuConfirm", "0.1.0")] public class Plugin : BaseUnityPlugin { [HarmonyPatch(typeof(MenuController), "SetStatusText")] private static class CaptureStyle { private static void Postfix(MenuController __instance) { //IL_0030: 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) if (!Object.op_Implicit((Object)(object)_font)) { if (Object.op_Implicit((Object)(object)__instance.statusText)) { _font = ((TMP_Text)__instance.statusText).font; _textColor = ((Graphic)__instance.statusText).color; } _panelSprite = FirstSprite(__instance.statusUpdatePanel); if (Object.op_Implicit((Object)(object)__instance.closeStatusButton)) { Image component = __instance.closeStatusButton.GetComponent(); _buttonSprite = ((component != null) ? component.sprite : null); } } } } [HarmonyPatch(typeof(PlayerController), "GoToMainMenu")] private static class MainMenuPatch { [HarmonyPriority(800)] private static bool Prefix(PlayerController __instance) { return Gate("Return to the Main Menu?", "Main Menu", delegate { _bypass = true; __instance.GoToMainMenu(); }); } } [HarmonyPatch(typeof(PlayerController), "CloseGame")] private static class QuitPatch { [HarmonyPriority(800)] private static bool Prefix(PlayerController __instance) { return Gate("Quit to desktop?", "Quit", delegate { _bypass = true; __instance.CloseGame(); }); } } private const string ModGuid = "gnomesko.MainMenuConfirm"; private static Plugin _instance; private static bool _bypass; private static Action _onConfirm; private static TMP_FontAsset _font; private static Sprite _panelSprite; private static Sprite _buttonSprite; private static Color _textColor = Color.white; private static GameObject _root; private static TextMeshProUGUI _promptText; private static TextMeshProUGUI _confirmText; private void Awake() { //IL_000b: Unknown result type (might be due to invalid IL or missing references) _instance = this; new Harmony("gnomesko.MainMenuConfirm").PatchAll(); } private static bool Gate(string prompt, string confirmLabel, Action onConfirm) { if (_bypass) { _bypass = false; return true; } try { EnsureUI(); _onConfirm = onConfirm; ((TMP_Text)_promptText).text = prompt; ((TMP_Text)_confirmText).text = confirmLabel; _root.SetActive(true); return false; } catch (Exception arg) { ((BaseUnityPlugin)_instance).Logger.LogError((object)$"Confirm dialog failed, allowing action: {arg}"); return true; } } private static void Cancel() { if (Object.op_Implicit((Object)(object)_root)) { _root.SetActive(false); } _onConfirm = null; } private static void Confirm() { Action onConfirm = _onConfirm; Cancel(); ((MonoBehaviour)_instance).StartCoroutine(Run(onConfirm)); } private static IEnumerator Run(Action action) { yield return null; try { action(); } catch (Exception arg) { ((BaseUnityPlugin)_instance).Logger.LogError((object)$"Confirmed action failed: {arg}"); } } private static void EnsureUI() { //IL_0012: Unknown result type (might be due to invalid IL or missing references) //IL_001c: Expected O, but got Unknown //IL_005d: 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_00e8: Unknown result type (might be due to invalid IL or missing references) //IL_0102: Unknown result type (might be due to invalid IL or missing references) //IL_013b: Unknown result type (might be due to invalid IL or missing references) //IL_0146: Unknown result type (might be due to invalid IL or missing references) //IL_015b: Unknown result type (might be due to invalid IL or missing references) //IL_016f: Unknown result type (might be due to invalid IL or missing references) //IL_0189: Unknown result type (might be due to invalid IL or missing references) //IL_01c3: Unknown result type (might be due to invalid IL or missing references) if (!Object.op_Implicit((Object)(object)_root)) { _root = new GameObject("GnomeConfirmCanvas"); Object.DontDestroyOnLoad((Object)(object)_root); Canvas obj = _root.AddComponent(); obj.renderMode = (RenderMode)0; obj.sortingOrder = 30000; CanvasScaler obj2 = _root.AddComponent(); obj2.uiScaleMode = (ScaleMode)1; obj2.referenceResolution = new Vector2(1920f, 1080f); obj2.matchWidthOrHeight = 0.5f; _root.AddComponent(); Image obj3 = NewImage("Blocker", _root.transform); Stretch(((Graphic)obj3).rectTransform); ((Graphic)obj3).color = new Color(0f, 0f, 0f, 0.6f); Image val = NewImage("Panel", _root.transform); ApplySprite(val, _panelSprite, new Color(0.12f, 0.12f, 0.12f, 0.95f)); ((Graphic)val).rectTransform.sizeDelta = new Vector2(680f, 300f); _promptText = NewText("Prompt", ((Component)val).transform, 36f); RectTransform rectTransform = ((TMP_Text)_promptText).rectTransform; rectTransform.anchorMin = new Vector2(0f, 0.38f); rectTransform.anchorMax = Vector2.one; rectTransform.offsetMin = new Vector2(40f, 0f); rectTransform.offsetMax = new Vector2(-40f, -30f); _confirmText = NewButton(((Component)val).transform, new Vector2(-150f, 60f), Confirm); ((TMP_Text)NewButton(((Component)val).transform, new Vector2(150f, 60f), Cancel)).text = "Cancel"; _root.SetActive(false); } } private static TextMeshProUGUI NewButton(Transform parent, Vector2 anchoredPos, Action onClick) { //IL_0033: 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) //IL_006d: 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_0094: Unknown result type (might be due to invalid IL or missing references) //IL_009e: Expected O, but got Unknown Image val = NewImage("Button", parent); ApplySprite(val, _buttonSprite, new Color(0.25f, 0.25f, 0.25f, 1f)); RectTransform rectTransform = ((Graphic)val).rectTransform; Vector2 val2 = default(Vector2); ((Vector2)(ref val2))..ctor(0.5f, 0f); rectTransform.anchorMax = val2; rectTransform.anchorMin = val2; rectTransform.sizeDelta = new Vector2(250f, 80f); rectTransform.anchoredPosition = anchoredPos; ((UnityEvent)((Component)val).gameObject.AddComponent