using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using BepInEx;
using BepInEx.Bootstrap;
using BepInEx.Configuration;
using BepInEx.Core.Logging.Interpolation;
using BepInEx.Logging;
using BepInEx.Unity.IL2CPP;
using HarmonyLib;
using Il2CppInterop.Runtime;
using Il2CppInterop.Runtime.Injection;
using Il2CppInterop.Runtime.InteropTypes;
using Il2CppSystem;
using MelonLoader;
using MelonLoader.Preferences;
using Microsoft.CodeAnalysis;
using QuitGame;
using TMPro;
using UnityEngine;
using UnityEngine.Events;
using UnityEngine.Localization.Components;
using UnityEngine.SceneManagement;
using UnityEngine.UI;
[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: MelonInfo(typeof(QuitGameMod), "Quit Game Button", "1.2.1", "Quit Game Button", null)]
[assembly: MelonGame("BoltBlasterGames", "TheSpellBrigade")]
[assembly: TargetFramework(".NETCoreApp,Version=v6.0", FrameworkDisplayName = ".NET 6.0")]
[assembly: AssemblyCompany("QuitGame")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyFileVersion("1.2.1.0")]
[assembly: AssemblyInformationalVersion("1.2.1")]
[assembly: AssemblyProduct("QuitGame")]
[assembly: AssemblyTitle("QuitGame")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.2.1.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 QuitGame
{
public class QuitGameMod : MelonMod
{
private const float PauseSpacing = 200f;
private const string QuitMessage = "Are you sure you want to close the game? All player progress and rewards are kept.";
internal static MelonLogger.Instance Log;
private static PauseMenuManager _pause;
private static int _lastPressFrame = -1;
private static bool _closeGame;
private static LocalizeStringEvent _message;
public override void OnInitializeMelon()
{
//IL_0049: Unknown result type (might be due to invalid IL or missing references)
//IL_0056: Expected O, but got Unknown
//IL_0094: Unknown result type (might be due to invalid IL or missing references)
//IL_00a2: Expected O, but got Unknown
Log = base.LoggerInstance;
try
{
MethodInfo methodInfo = AccessTools.Method(typeof(PauseMenuManager), "Start", (Type[])null, (Type[])null) ?? throw new MissingMethodException("PauseMenuManager.Start not found");
base.HarmonyInstance.Patch((MethodBase)methodInfo, (HarmonyMethod)null, new HarmonyMethod(typeof(QuitGameMod), "PauseStartPostfix", (Type[])null), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null);
MethodInfo methodInfo2 = AccessTools.Method(typeof(MenuModal), "Show", (Type[])null, (Type[])null) ?? throw new MissingMethodException("MenuModal.Show not found");
base.HarmonyInstance.Patch((MethodBase)methodInfo2, new HarmonyMethod(typeof(QuitGameMod), "MenuShowPrefix", (Type[])null), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null);
Patch(typeof(ConfirmQuitPanel), "Quit", "ConfirmPrefix");
Patch(typeof(ConfirmQuitPanel), "Close", null, "PanelClosedPostfix");
Patch(typeof(LeaveConfirmationPanel), "TryLeave", "ConfirmPrefix");
Patch(typeof(LeaveConfirmationPanel), "Leave", "ConfirmPrefix");
Patch(typeof(LeaveConfirmationPanel), "Close", null, "PanelClosedPostfix");
Log.Msg("ready — Quit Game in the pause menu, Quit in the lobby menu");
}
catch (Exception ex)
{
Log.Error("failed to hook the pause menu: " + ex.Message);
}
}
private void Patch(Type type, string method, string prefix = null, string postfix = null)
{
//IL_0043: 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)
MethodInfo methodInfo = AccessTools.Method(type, method, (Type[])null, (Type[])null) ?? throw new MissingMethodException(type.Name + "." + method + " not found");
base.HarmonyInstance.Patch((MethodBase)methodInfo, (prefix == null) ? ((HarmonyMethod)null) : new HarmonyMethod(typeof(QuitGameMod), prefix, (Type[])null), (postfix == null) ? ((HarmonyMethod)null) : new HarmonyMethod(typeof(QuitGameMod), postfix, (Type[])null), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null);
}
private static void PauseStartPostfix(PauseMenuManager __instance)
{
//IL_0061: Unknown result type (might be due to invalid IL or missing references)
//IL_0070: Unknown result type (might be due to invalid IL or missing references)
//IL_0075: Unknown result type (might be due to invalid IL or missing references)
try
{
_pause = ((__instance != null) ? ((Il2CppObjectBase)__instance).TryCast<PauseMenuManager>() : null);
PauseMenuManager pause = _pause;
Button val = ((pause != null) ? pause.quitButton : null);
if (!((Object)(object)val == (Object)null) && !((Object)(object)((Component)val).transform.parent.Find("Button_QuitGame") != (Object)null))
{
RectTransform component = ((Component)val).GetComponent<RectTransform>();
Add(val, "Button_QuitGame", "Quit Game", component.anchoredPosition - new Vector2(0f, 200f), "Closes the game. All player progress and rewards are kept.", OpenPauseConfirm);
LowerHoverText(((Component)val).transform, 200f);
}
}
catch (Exception value)
{
Log.Warning($"pause menu button: {value}");
}
}
private static void MenuShowPrefix(MenuModal __instance)
{
//IL_0083: Unknown result type (might be due to invalid IL or missing references)
//IL_008f: 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)
try
{
MenuModal val = ((__instance != null) ? ((Il2CppObjectBase)__instance).TryCast<MenuModal>() : null);
if ((Object)(object)val == (Object)null)
{
return;
}
Transform val2 = FindChild(((Component)val).transform, "LeaveButton");
if (!((Object)(object)val2 == (Object)null) && !((Object)(object)FindChild(((Component)val).transform, "QuitButton") != (Object)null))
{
Button component = ((Component)val2).GetComponent<Button>();
if (!((Object)(object)component == (Object)null))
{
RectTransform component2 = ((Component)val2).GetComponent<RectTransform>();
float num = StepAbove(val2, component2);
Button val3 = Add(component, "QuitButton", "Quit", component2.anchoredPosition - new Vector2(0f, num), null, OpenLobbyConfirm);
Navigation navigation = ((Selectable)component).navigation;
Navigation navigation2 = ((Selectable)val3).navigation;
navigation2.mode = (Mode)4;
navigation2.selectOnUp = (Selectable)(object)component;
navigation2.selectOnDown = navigation.selectOnDown;
((Selectable)val3).navigation = navigation2;
navigation.selectOnDown = (Selectable)(object)val3;
((Selectable)component).navigation = navigation;
}
}
}
catch (Exception value)
{
Log.Warning($"lobby menu button: {value}");
}
}
private static Transform FindChild(Transform parent, string name)
{
for (int i = 0; i < parent.childCount; i++)
{
Transform child = parent.GetChild(i);
if (((Object)child).name == name)
{
return child;
}
}
return null;
}
private static float StepAbove(Transform leave, RectTransform leaveRect)
{
//IL_00b7: Unknown result type (might be due to invalid IL or missing references)
//IL_0051: 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_0075: Unknown result type (might be due to invalid IL or missing references)
//IL_0080: Unknown result type (might be due to invalid IL or missing references)
float num = float.MaxValue;
Transform parent = leave.parent;
for (int i = 0; i < parent.childCount; i++)
{
Transform child = parent.GetChild(i);
if (((Il2CppObjectBase)child).Pointer == ((Il2CppObjectBase)leave).Pointer || (Object)(object)((Component)child).GetComponent<Button>() == (Object)null)
{
continue;
}
RectTransform component = ((Component)child).GetComponent<RectTransform>();
if (!((Object)(object)component == (Object)null) && !(Mathf.Abs(component.anchoredPosition.x - leaveRect.anchoredPosition.x) > 1f))
{
float num2 = component.anchoredPosition.y - leaveRect.anchoredPosition.y;
if (num2 > 1f && num2 < num)
{
num = num2;
}
}
}
if (!(num < float.MaxValue))
{
return leaveRect.sizeDelta.y * 2f;
}
return num;
}
private static Button Add(Button template, string name, string label, Vector2 position, string hint, Action onPressed)
{
//IL_004b: Unknown result type (might be due to invalid IL or missing references)
//IL_0089: Unknown result type (might be due to invalid IL or missing references)
//IL_0093: Expected O, but got Unknown
GameObject val = Object.Instantiate<GameObject>(((Component)template).gameObject, ((Component)template).transform.parent, false);
((Object)val).name = name;
val.transform.SetSiblingIndex(((Component)template).transform.GetSiblingIndex() + 1);
val.GetComponent<RectTransform>().anchoredPosition = position;
SetText(FindText(val.transform, "Text (TMP)"), label);
if (hint != null)
{
SetText(FindText(val.transform, "QuitHighlightPopup"), hint);
}
Button component = val.GetComponent<Button>();
component.onClick = new ButtonClickedEvent();
((UnityEvent)component.onClick).AddListener(UnityAction.op_Implicit((Action)delegate
{
if (_lastPressFrame == Time.frameCount)
{
return;
}
_lastPressFrame = Time.frameCount;
try
{
onPressed();
}
catch (Exception ex)
{
Log.Warning("quit confirmation: " + ex.Message);
}
}));
return component;
}
private static void OpenPauseConfirm()
{
ConfirmQuitPanel val = (((Object)(object)_pause != (Object)null) ? _pause.confirmQuitPanel : null);
if ((Object)(object)val == (Object)null)
{
Log.Warning("no quit panel found");
return;
}
_pause.OpenConfirmQuitPanel();
UseOurMessage(val.quitMessage);
}
private static void OpenLobbyConfirm()
{
//IL_0025: Unknown result type (might be due to invalid IL or missing references)
//IL_002a: Unknown result type (might be due to invalid IL or missing references)
LeaveConfirmationPanel val = null;
foreach (LeaveConfirmationPanel item in Resources.FindObjectsOfTypeAll<LeaveConfirmationPanel>())
{
if ((Object)(object)item != (Object)null)
{
Scene scene = ((Component)item).gameObject.scene;
if (((Scene)(ref scene)).IsValid())
{
val = item;
break;
}
}
}
if ((Object)(object)val == (Object)null)
{
Log.Warning("no leave panel found");
return;
}
((Panel)val).Open();
UseOurMessage(val.leaveWarningLocalizer);
}
private static void UseOurMessage(LocalizeStringEvent localizer)
{
_closeGame = true;
_message = localizer;
if (!((Object)(object)localizer == (Object)null))
{
((Behaviour)localizer).enabled = false;
TMP_Text component = ((Component)localizer).GetComponent<TMP_Text>();
if ((Object)(object)component != (Object)null)
{
component.text = "Are you sure you want to close the game? All player progress and rewards are kept.";
}
}
}
private static bool ConfirmPrefix()
{
if (!_closeGame)
{
return true;
}
Log.Msg("quitting the game");
Application.Quit();
return false;
}
private static void PanelClosedPostfix()
{
if (!_closeGame)
{
return;
}
_closeGame = false;
try
{
if ((Object)(object)_message != (Object)null && !((Il2CppObjectBase)_message).WasCollected)
{
((Behaviour)_message).enabled = true;
_message.RefreshString();
}
}
catch
{
}
_message = null;
}
private static void LowerHoverText(Transform button, float distance)
{
//IL_0095: Unknown result type (might be due to invalid IL or missing references)
//IL_00a5: 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_0078: Unknown result type (might be due to invalid IL or missing references)
//IL_0083: Unknown result type (might be due to invalid IL or missing references)
//IL_0088: Unknown result type (might be due to invalid IL or missing references)
TMP_Text val = FindText(button, "QuitHighlightPopup");
if ((Object)(object)val == (Object)null)
{
Log.Warning("no hover text under " + ((Object)button).name);
return;
}
Transform val2 = val.transform;
while ((Object)(object)val2.parent != (Object)null && ((Il2CppObjectBase)val2.parent).Pointer != ((Il2CppObjectBase)button).Pointer)
{
val2 = val2.parent;
}
RectTransform component = ((Component)val2).GetComponent<RectTransform>();
if ((Object)(object)component != (Object)null)
{
component.anchoredPosition -= new Vector2(0f, distance);
return;
}
Transform obj = val2;
obj.localPosition -= new Vector3(0f, distance, 0f);
}
private static TMP_Text FindText(Transform root, string name)
{
foreach (TMP_Text componentsInChild in ((Component)root).GetComponentsInChildren<TMP_Text>(true))
{
if (((Object)componentsInChild).name == name)
{
return componentsInChild;
}
}
return null;
}
private static void SetText(TMP_Text text, string value)
{
if (!((Object)(object)text == (Object)null))
{
LocalizeStringEvent component = ((Component)text).GetComponent<LocalizeStringEvent>();
if ((Object)(object)component != (Object)null)
{
Object.Destroy((Object)(object)component);
}
text.text = value;
}
}
}
}
namespace QuitGame.BepInExPlugin
{
[BepInPlugin("SpellBrigade.QuitGame", "Quit Game Button", "1.2.1")]
[BepInDependency(/*Could not decode attribute arguments.*/)]
public class Plugin : BasePlugin
{
public const string Guid = "SpellBrigade.QuitGame";
public override void Load()
{
MelonCompat.Start<QuitGameMod, Runner>((BasePlugin)(object)this, "SpellBrigade.QuitGame");
}
}
public class Runner : MonoBehaviour
{
public Runner(IntPtr ptr)
: base(ptr)
{
}
private void Update()
{
MelonCompat.Update();
}
}
}
namespace MelonLoader
{
[AttributeUsage(AttributeTargets.Assembly)]
public sealed class MelonInfoAttribute : Attribute
{
public MelonInfoAttribute(Type type, string name, string version, string author, string downloadLink = null)
{
}
}
[AttributeUsage(AttributeTargets.Assembly, AllowMultiple = true)]
public sealed class MelonGameAttribute : Attribute
{
public MelonGameAttribute(string developer = null, string name = null)
{
}
}
[AttributeUsage(AttributeTargets.Assembly)]
public sealed class MelonOptionalDependenciesAttribute : Attribute
{
public MelonOptionalDependenciesAttribute(params string[] names)
{
}
}
public abstract class MelonBase
{
public MelonLogger.Instance LoggerInstance { get; internal set; }
public Harmony HarmonyInstance { get; internal set; }
public static object FindMelon(string name, string author)
{
try
{
foreach (PluginInfo value in ((BaseChainloader<BasePlugin>)(object)IL2CPPChainloader.Instance).Plugins.Values)
{
if (((value != null) ? value.Metadata : null) != null && string.Equals(value.Metadata.Name, name, StringComparison.OrdinalIgnoreCase) && value.Instance != null)
{
return value;
}
}
}
catch
{
}
return null;
}
}
public abstract class MelonMod : MelonBase
{
public virtual void OnInitializeMelon()
{
}
public virtual void OnLateInitializeMelon()
{
}
public virtual void OnUpdate()
{
}
public virtual void OnLateUpdate()
{
}
public virtual void OnFixedUpdate()
{
}
public virtual void OnGUI()
{
}
public virtual void OnApplicationQuit()
{
}
public virtual void OnSceneWasLoaded(int buildIndex, string sceneName)
{
}
public virtual void OnSceneWasInitialized(int buildIndex, string sceneName)
{
}
public virtual void OnSceneWasUnloaded(int buildIndex, string sceneName)
{
}
}
public static class MelonLogger
{
public sealed class Instance
{
private readonly ManualLogSource _log;
public Instance(ManualLogSource log)
{
_log = log;
}
public void Msg(string text)
{
_log.LogInfo((object)text);
}
public void Msg(object value)
{
_log.LogInfo(value);
}
public void Msg(string format, params object[] args)
{
_log.LogInfo((object)string.Format(format, args));
}
public void Warning(string text)
{
_log.LogWarning((object)text);
}
public void Warning(object value)
{
_log.LogWarning(value);
}
public void Error(string text)
{
_log.LogError((object)text);
}
public void Error(object value)
{
_log.LogError(value);
}
public void Error(string text, Exception e)
{
//IL_000a: Unknown result type (might be due to invalid IL or missing references)
//IL_0010: Expected O, but got Unknown
ManualLogSource log = _log;
bool flag = default(bool);
BepInExErrorLogInterpolatedStringHandler val = new BepInExErrorLogInterpolatedStringHandler(1, 2, ref flag);
if (flag)
{
((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>(text);
((BepInExLogInterpolatedStringHandler)val).AppendLiteral("\n");
((BepInExLogInterpolatedStringHandler)val).AppendFormatted<Exception>(e);
}
log.LogError(val);
}
}
}
public static class MelonCompat
{
internal static ConfigFile Config;
private static MelonMod _mod;
private static bool _lateInit;
public static void Start<TMod, TRunner>(BasePlugin plugin, string harmonyId) where TMod : MelonMod, new() where TRunner : MonoBehaviour
{
//IL_002d: Unknown result type (might be due to invalid IL or missing references)
//IL_0037: Expected O, but got Unknown
//IL_006d: Unknown result type (might be due to invalid IL or missing references)
//IL_0073: Expected O, but got Unknown
Config = plugin.Config;
_mod = new TMod
{
LoggerInstance = new MelonLogger.Instance(plugin.Log),
HarmonyInstance = new Harmony(harmonyId)
};
try
{
_mod.HarmonyInstance.PatchAll(typeof(TMod).Assembly);
}
catch (Exception ex)
{
ManualLogSource log = plugin.Log;
bool flag = default(bool);
BepInExErrorLogInterpolatedStringHandler val = new BepInExErrorLogInterpolatedStringHandler(17, 1, ref flag);
if (flag)
{
((BepInExLogInterpolatedStringHandler)val).AppendLiteral("Harmony patches: ");
((BepInExLogInterpolatedStringHandler)val).AppendFormatted<Exception>(ex);
}
log.LogError(val);
}
_mod.OnInitializeMelon();
HookScenes();
ClassInjector.RegisterTypeInIl2Cpp<TRunner>();
plugin.AddComponent<TRunner>();
}
private static void HookScenes()
{
SceneManager.sceneLoaded += DelegateSupport.ConvertDelegate<UnityAction<Scene, LoadSceneMode>>((Delegate)new Action<Scene, LoadSceneMode>(OnSceneLoaded));
SceneManager.sceneUnloaded += DelegateSupport.ConvertDelegate<UnityAction<Scene>>((Delegate)new Action<Scene>(OnSceneUnloaded));
}
private static void OnSceneLoaded(Scene scene, LoadSceneMode mode)
{
//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)
Guard(delegate
{
_mod.OnSceneWasLoaded(((Scene)(ref scene)).buildIndex, ((Scene)(ref scene)).name);
});
Guard(delegate
{
_mod.OnSceneWasInitialized(((Scene)(ref scene)).buildIndex, ((Scene)(ref scene)).name);
});
}
private static void OnSceneUnloaded(Scene scene)
{
//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)
Guard(delegate
{
_mod.OnSceneWasUnloaded(((Scene)(ref scene)).buildIndex, ((Scene)(ref scene)).name);
});
}
public static void Update()
{
if (_mod != null)
{
if (!_lateInit)
{
_lateInit = true;
Guard(_mod.OnLateInitializeMelon);
}
_mod.OnUpdate();
}
}
public static void LateUpdate()
{
_mod?.OnLateUpdate();
}
public static void FixedUpdate()
{
_mod?.OnFixedUpdate();
}
public static void OnGUI()
{
_mod?.OnGUI();
}
public static void Quit()
{
_mod?.OnApplicationQuit();
}
private static void Guard(Action a)
{
try
{
a();
}
catch (Exception ex)
{
_mod.LoggerInstance.Error(ex.ToString());
}
}
}
public static class MelonPreferences
{
private static readonly Dictionary<string, MelonPreferences_Category> Categories = new Dictionary<string, MelonPreferences_Category>();
public static MelonPreferences_Category CreateCategory(string identifier, string displayName = null, bool is_hidden = false, bool is_inlined = false)
{
if (!Categories.TryGetValue(identifier, out var value))
{
value = (Categories[identifier] = new MelonPreferences_Category(identifier, displayName ?? identifier)
{
IsHidden = is_hidden
});
}
return value;
}
public static MelonPreferences_Category GetCategory(string identifier)
{
if (!Categories.TryGetValue(identifier, out var value))
{
return null;
}
return value;
}
public static void Save()
{
ConfigFile config = MelonCompat.Config;
if (config != null)
{
config.Save();
}
}
}
public sealed class MelonPreferences_Category
{
public readonly List<MelonPreferences_Entry> Entries = new List<MelonPreferences_Entry>();
public string Identifier { get; }
public string DisplayName { get; }
public bool IsHidden { get; internal set; }
internal MelonPreferences_Category(string identifier, string displayName)
{
Identifier = identifier;
DisplayName = displayName;
}
public MelonPreferences_Entry<T> CreateEntry<T>(string identifier, T default_value, string display_name = null, string description = null, bool is_hidden = false, bool dont_save_default = false, ValueValidator validator = null, string oldIdentifier = null)
{
//IL_008c: Unknown result type (might be due to invalid IL or missing references)
//IL_0096: Expected O, but got Unknown
ConfigurationManagerAttributes configurationManagerAttributes = new ConfigurationManagerAttributes
{
DispName = (display_name ?? identifier),
Browsable = (!is_hidden && !IsHidden),
Order = -Entries.Count,
Category = DisplayName
};
AcceptableValueBase val = validator?.ToAcceptable(typeof(T));
ConfigEntry<T> cfg = MelonCompat.Config.Bind<T>(Identifier, identifier, default_value, new ConfigDescription(description ?? "", val, new object[1] { configurationManagerAttributes }));
MelonPreferences_Entry<T> melonPreferences_Entry = new MelonPreferences_Entry<T>(this, cfg, identifier, display_name ?? identifier, description, is_hidden);
Entries.Add(melonPreferences_Entry);
return melonPreferences_Entry;
}
public MelonPreferences_Entry GetEntry(string identifier)
{
return Entries.Find((MelonPreferences_Entry e) => e.Identifier == identifier);
}
public MelonPreferences_Entry<T> GetEntry<T>(string identifier)
{
return GetEntry(identifier) as MelonPreferences_Entry<T>;
}
public bool HasEntry(string identifier)
{
return GetEntry(identifier) != null;
}
public void SaveToFile(bool printmsg = true)
{
ConfigFile config = MelonCompat.Config;
if (config != null)
{
config.Save();
}
}
public void LoadFromFile(bool printmsg = true)
{
ConfigFile config = MelonCompat.Config;
if (config != null)
{
config.Reload();
}
}
}
public abstract class MelonPreferences_Entry
{
public readonly MelonEvent<object, object> OnEntryValueChangedUntyped = new MelonEvent<object, object>();
public MelonPreferences_Category Category { get; protected set; }
public string Identifier { get; protected set; }
public string DisplayName { get; protected set; }
public string Description { get; protected set; }
public bool IsHidden { get; protected set; }
public abstract ConfigEntryBase Raw { get; }
public abstract object BoxedValue { get; set; }
public abstract void ResetToDefault();
}
public sealed class MelonPreferences_Entry<T> : MelonPreferences_Entry
{
private readonly ConfigEntry<T> _cfg;
private T _last;
public readonly MelonEvent<T, T> OnEntryValueChanged = new MelonEvent<T, T>();
public readonly MelonEvent<T, T> OnValueChanged;
public T Value
{
get
{
return _cfg.Value;
}
set
{
_cfg.Value = value;
}
}
public T DefaultValue => (T)((ConfigEntryBase)_cfg).DefaultValue;
public override ConfigEntryBase Raw => (ConfigEntryBase)(object)_cfg;
public override object BoxedValue
{
get
{
return ((ConfigEntryBase)_cfg).BoxedValue;
}
set
{
((ConfigEntryBase)_cfg).BoxedValue = value;
}
}
internal MelonPreferences_Entry(MelonPreferences_Category category, ConfigEntry<T> cfg, string identifier, string displayName, string description, bool hidden)
{
base.Category = category;
_cfg = cfg;
base.Identifier = identifier;
base.DisplayName = displayName;
base.Description = description;
base.IsHidden = hidden;
OnValueChanged = OnEntryValueChanged;
_last = cfg.Value;
cfg.SettingChanged += OnSettingChanged;
}
private void OnSettingChanged(object sender, EventArgs e)
{
T last = _last;
_last = _cfg.Value;
if (!EqualityComparer<T>.Default.Equals(last, _last))
{
OnEntryValueChanged.Invoke(last, _last);
OnEntryValueChangedUntyped.Invoke(last, _last);
}
}
public override void ResetToDefault()
{
_cfg.Value = DefaultValue;
}
}
public sealed class MelonEvent<T1, T2>
{
private readonly List<Action<T1, T2>> _handlers = new List<Action<T1, T2>>();
public void Subscribe(Action<T1, T2> handler, int priority = 0, bool unsubscribeOnFirstInvocation = false)
{
_handlers.Add(handler);
}
public void Unsubscribe(Action<T1, T2> handler)
{
_handlers.Remove(handler);
}
internal void Invoke(T1 a, T2 b)
{
Action<T1, T2>[] array = _handlers.ToArray();
foreach (Action<T1, T2> action in array)
{
try
{
action(a, b);
}
catch (Exception ex)
{
Debug.LogError(Object.op_Implicit(ex.ToString()));
}
}
}
}
public sealed class ConfigurationManagerAttributes
{
public string DispName;
public bool? Browsable;
public int? Order;
public string Category;
}
}
namespace MelonLoader.Preferences
{
public abstract class ValueValidator
{
public abstract AcceptableValueBase ToAcceptable(Type type);
}
public sealed class ValueRange<T> : ValueValidator where T : IComparable
{
public T MinValue { get; }
public T MaxValue { get; }
public ValueRange(T min, T max)
{
MinValue = min;
MaxValue = max;
}
public override AcceptableValueBase ToAcceptable(Type type)
{
if (!(type == typeof(T)))
{
return null;
}
return (AcceptableValueBase)(object)new AcceptableValueRange<T>(MinValue, MaxValue);
}
}
}
namespace Il2CppTMPro
{
internal static class NamespaceStandIn
{
}
}
namespace Il2Cpp
{
internal static class NamespaceStandIn
{
}
}