The BepInEx console will not appear when launching like it does for other games on Thunderstore (you can turn it back on in your BepInEx.cfg file). If your PEAK crashes on startup, add -dx12 to your launch parameters.
Decompiled source of SettingsExtenderForked v0.1.6
BepInEx/plugins/pharmacomaniac-SettingsExtenderForked/SettingsExtender.dll
Decompiled 3 weeks agousing 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 BepInEx; using BepInEx.Logging; using HarmonyLib; using Microsoft.CodeAnalysis; using TMPro; using UnityEngine; using UnityEngine.Localization; using UnityEngine.SceneManagement; using Zorro.Core; using Zorro.Settings; using Zorro.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("SettingsExtender")] [assembly: AssemblyConfiguration("Release")] [assembly: AssemblyFileVersion("0.1.6.0")] [assembly: AssemblyInformationalVersion("0.1.6")] [assembly: AssemblyProduct("SettingsExtender")] [assembly: AssemblyTitle("SettingsExtenderForked")] [assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)] [assembly: AssemblyVersion("0.1.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] internal sealed class IsUnmanagedAttribute : Attribute { } [CompilerGenerated] [Microsoft.CodeAnalysis.Embedded] [AttributeUsage(AttributeTargets.Class | AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Event | AttributeTargets.Parameter | AttributeTargets.ReturnValue | AttributeTargets.GenericParameter, AllowMultiple = false, Inherited = false)] internal sealed class NullableAttribute : Attribute { public readonly byte[] NullableFlags; public NullableAttribute(byte P_0) { NullableFlags = new byte[1] { P_0 }; } public NullableAttribute(byte[] P_0) { NullableFlags = P_0; } } [CompilerGenerated] [Microsoft.CodeAnalysis.Embedded] [AttributeUsage(AttributeTargets.Class | AttributeTargets.Struct | AttributeTargets.Method | AttributeTargets.Interface | AttributeTargets.Delegate, AllowMultiple = false, Inherited = false)] internal sealed class NullableContextAttribute : Attribute { public readonly byte Flag; public NullableContextAttribute(byte P_0) { Flag = P_0; } } [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; } } } public static class SettingsHandlerExtensions { public static T AddSetting<T>(this SettingsHandler handler) where T : Setting, new() { T val = new T(); handler.AddSetting((Setting)(object)val); return val; } } namespace BepInEx { [AttributeUsage(AttributeTargets.Class, Inherited = false, AllowMultiple = false)] [Conditional("CodeGeneration")] internal sealed class BepInAutoPluginAttribute : Attribute { public BepInAutoPluginAttribute(string? id = null, string? name = null, string? version = null) { } } } namespace BepInEx.Preloader.Core.Patching { [AttributeUsage(AttributeTargets.Class, Inherited = false, AllowMultiple = false)] [Conditional("CodeGeneration")] internal sealed class PatcherAutoPluginAttribute : Attribute { public PatcherAutoPluginAttribute(string? id = null, string? name = null, string? version = null) { } } } namespace SettingsExtender { internal static class ExtenderHelper { internal static (string pageId, string display) GetMeta(Type t) { ExtenderSettingAttribute customAttribute = t.GetCustomAttribute<ExtenderSettingAttribute>(); string name = customAttribute?.Page ?? "General"; string item = customAttribute?.DisplayName ?? t.Name; SettingsRegistry.Register(name); return (SettingsRegistry.GetPageId(name), item); } } public abstract class ExtenderBoolSetting : BoolSetting, IExposedSetting { private readonly string _pageId; private readonly string _display; protected readonly Action<bool>? _onChanged; public override LocalizedString OnString => null; public override LocalizedString OffString => null; protected ExtenderBoolSetting() { (_pageId, _display) = ExtenderHelper.GetMeta(((object)this).GetType()); } public string GetCategory() { return _pageId; } public string GetDisplayName() { return _display; } protected ExtenderBoolSetting(Action<bool> cb) : this() { _onChanged = cb; } protected override bool GetDefaultValue() { return false; } public override void ApplyValue() { _onChanged?.Invoke(((BoolSetting)this).Value); } } public abstract class ExtenderFloatSetting : FloatSetting, IExposedSetting { private readonly string _pageId; private readonly string _display; protected readonly Action<float>? _onChanged; protected ExtenderFloatSetting() { (_pageId, _display) = ExtenderHelper.GetMeta(((object)this).GetType()); } public string GetCategory() { return _pageId; } public string GetDisplayName() { return _display; } protected ExtenderFloatSetting(Action<float> cb) : this() { _onChanged = cb; } public override void ApplyValue() { _onChanged?.Invoke(((FloatSetting)this).Value); } } public abstract class ExtenderIntEnumSetting : IntSetting, IEnumSetting, IExposedSetting { private readonly string _pageId; private readonly string _display; protected readonly Action<int>? _onChanged; protected ExtenderIntEnumSetting() { (_pageId, _display) = ExtenderHelper.GetMeta(((object)this).GetType()); } public string GetCategory() { return _pageId; } public string GetDisplayName() { return _display; } protected ExtenderIntEnumSetting(Action<int> cb) : this() { _onChanged = cb; } public virtual List<LocalizedString>? GetLocalizedChoices() { return null; } public abstract List<string> GetUnlocalizedChoices(); public virtual GameObject GetSettingUICell() { return SingletonAsset<InputCellMapper>.Instance.EnumSettingCell; } public int GetValue() { return ((IntSetting)this).Value; } public void SetValue(int v, ISettingHandler h, bool ui) { ((IntSetting)this).SetValue(v, h); } public override void ApplyValue() { _onChanged?.Invoke(((IntSetting)this).Value); } } public abstract class ExtenderButtonSetting : ButtonSetting, IExposedSetting { private readonly string _pageId; private readonly string _display; protected ExtenderButtonSetting() { (_pageId, _display) = ExtenderHelper.GetMeta(((object)this).GetType()); } public string GetCategory() { return _pageId; } public string GetDisplayName() { return _display; } } public abstract class ExtenderStringSetting : StringSetting, IExposedSetting { private readonly string _pageId; private readonly string _display; protected readonly Action<string>? _onChanged; protected ExtenderStringSetting(Action<string>? cb = null) { (string, string) meta = ExtenderHelper.GetMeta(((object)this).GetType()); _pageId = meta.Item1; _display = meta.Item2; _onChanged = cb; } public string GetCategory() { return _pageId; } public string GetDisplayName() { return _display; } public override void ApplyValue() { _onChanged?.Invoke(((StringSetting)this).Value); } } public abstract class ExtenderIntSetting : IntSetting, IExposedSetting { private readonly string _pageId; private readonly string _display; protected readonly Action<int>? _onChanged; protected ExtenderIntSetting(Action<int>? cb = null) { (string, string) meta = ExtenderHelper.GetMeta(((object)this).GetType()); _pageId = meta.Item1; _display = meta.Item2; _onChanged = cb; } public string GetCategory() { return _pageId; } public string GetDisplayName() { return _display; } public override void ApplyValue() { _onChanged?.Invoke(((IntSetting)this).Value); } } public abstract class ExtenderKeyCodeSetting : KeyCodeSetting, IExposedSetting { private readonly string _pageId; private readonly string _display; protected readonly Action<KeyCode>? _onChanged; protected ExtenderKeyCodeSetting(Action<KeyCode>? cb = null) { (string, string) meta = ExtenderHelper.GetMeta(((object)this).GetType()); _pageId = meta.Item1; _display = meta.Item2; _onChanged = cb; } public string GetCategory() { return _pageId; } public string GetDisplayName() { return _display; } public override void ApplyValue() { //IL_000c: Unknown result type (might be due to invalid IL or missing references) _onChanged?.Invoke(((KeyCodeSetting)this).Keycode()); } } public abstract class ExtenderEnumSetting<T> : EnumSetting<T>, IExposedSetting where T : unmanaged, Enum { private readonly string _pageId; private readonly string _display; protected readonly Action<T>? _onChanged; protected ExtenderEnumSetting(Action<T>? cb = null) { (string, string) meta = ExtenderHelper.GetMeta(((object)this).GetType()); _pageId = meta.Item1; _display = meta.Item2; _onChanged = cb; } public string GetCategory() { return _pageId; } public string GetDisplayName() { return _display; } public override List<string> GetUnlocalizedChoices() { return new List<string>(Enum.GetNames(typeof(T))); } public override void ApplyValue() { _onChanged?.Invoke(base.Value); } } [AttributeUsage(AttributeTargets.Class, Inherited = false)] public sealed class ExtenderSettingAttribute : Attribute { public readonly string Page; public readonly string? DisplayName; public ExtenderSettingAttribute(string page, string? displayName = null) { Page = page; DisplayName = displayName; } } public static class PluginInfo { public const string PLUGIN_GUID = "com.pharmacomaniac.settingsextenderforked"; public const string PLUGIN_NAME = "Settings Extender Forked"; public const string PLUGIN_VERSION = "0.1.4"; } [BepInPlugin("com.pharmacomaniac.settingsextenderforked", "Settings Extender Forked", "0.1.4")] public class Plugin : BaseUnityPlugin { private static bool hasInitialized; internal static ManualLogSource Logger; private GameObject? buttonSrc; private Coroutine? updateTabsRoutine; private void Awake() { //IL_0042: Unknown result type (might be due to invalid IL or missing references) Logger = ((BaseUnityPlugin)this).Logger; if (hasInitialized) { Logger.LogWarning((object)"Duplicate instance of SettingsExtender detected. Destroying this instance to prevent conflicts."); Object.Destroy((Object)(object)this); } else { hasInitialized = true; Logger.LogInfo((object)"Plugin com.pharmacomaniac.settingsextenderforked is loaded!"); new Harmony("com.pharmacomaniac.settingsextenderforked").PatchAll(); } } private void Start() { } private void OnEnable() { SceneManager.sceneLoaded += OnSceneLoaded; } private void OnDisable() { SceneManager.sceneLoaded -= OnSceneLoaded; if (updateTabsRoutine != null) { ((MonoBehaviour)this).StopCoroutine(updateTabsRoutine); updateTabsRoutine = null; } } private void OnSceneLoaded(Scene scene, LoadSceneMode mode) { //IL_0025: Unknown result type (might be due to invalid IL or missing references) buttonSrc = null; if (updateTabsRoutine != null) { ((MonoBehaviour)this).StopCoroutine(updateTabsRoutine); updateTabsRoutine = null; } updateTabsRoutine = ((MonoBehaviour)this).StartCoroutine(UpdateTabs(scene)); } private IEnumerator UpdateTabs(Scene scene) { //IL_000e: 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) Logger.LogInfo((object)("Scene loadeeeed: " + ((Scene)(ref scene)).name)); while ((Object)(object)buttonSrc == (Object)null) { List<SettingsTABSButton> list = FindAllInScene(scene); if (list.Count != 0) { buttonSrc = ((Component)list[0]).gameObject; } yield return (object)new WaitForSeconds(0.05f); } if (!((Object)(object)buttonSrc != (Object)null)) { yield break; } Logger.LogInfo((object)"Found TABS/General"); foreach (var (text2, val2) in SettingsRegistry.GetPages()) { Logger.LogInfo((object)$"Creating {text2} with category {val2}"); GameObject val3 = Object.Instantiate<GameObject>(buttonSrc, buttonSrc.transform.parent); LocalizedText componentInChildren = val3.GetComponentInChildren<LocalizedText>(); if ((Object)(object)componentInChildren != (Object)null) { Object.Destroy((Object)(object)componentInChildren); } SettingsTABSButton component = val3.GetComponent<SettingsTABSButton>(); component.category = val2; ((TMP_Text)((TAB_Button)component).text).text = text2.ToUpperInvariant(); } } public static List<SettingsTABSButton> FindAllInScene(Scene scene) { List<SettingsTABSButton> list = new List<SettingsTABSButton>(); GameObject[] rootGameObjects = ((Scene)(ref scene)).GetRootGameObjects(); foreach (GameObject val in rootGameObjects) { SettingsTABSButton[] componentsInChildren = val.GetComponentsInChildren<SettingsTABSButton>(); list.AddRange(componentsInChildren); } return list; } } public class SettingsRegistry { internal static Dictionary<string, SettingsCategory> nameToCategoryId = new Dictionary<string, SettingsCategory>(); public static void Register(string name) { //IL_0021: 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_0049: 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_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) if (!nameToCategoryId.ContainsKey(name)) { SettingsCategory val = Enum.GetValues(typeof(SettingsCategory)).Cast<SettingsCategory>().Max(); if (nameToCategoryId.Count != 0) { val = nameToCategoryId.Values.Max(); } nameToCategoryId[name] = (SettingsCategory)(val + 1); } } public static string GetPageId(string name) { //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_000b: Unknown result type (might be due to invalid IL or missing references) SettingsCategory val = nameToCategoryId[name]; return ((object)(SettingsCategory)(ref val)).ToString(); } public static Dictionary<string, SettingsCategory> GetPages() { return nameToCategoryId; } } [HarmonyPatch(typeof(LocalizedText), "GetText", new Type[] { typeof(string), typeof(bool) })] internal static class GetTextPrefixPatch { private static bool Prefix(string id, bool printDebug, ref string __result) { string text = id.ToUpperInvariant(); if (LocalizedText.mainTable.TryGetValue(text, out var _)) { return true; } __result = text; return false; } } } namespace System.Runtime.CompilerServices { [AttributeUsage(AttributeTargets.Assembly, AllowMultiple = true)] internal sealed class IgnoresAccessChecksToAttribute : Attribute { public IgnoresAccessChecksToAttribute(string assemblyName) { } } }