using System; using System.Collections; using System.Collections.Generic; using System.Diagnostics; using System.Globalization; 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 BepInEx; using BepInEx.Bootstrap; using BepInEx.Configuration; using BepInEx.Logging; using HarmonyLib; using ModSettingsMenu.Api; using ModSettingsMenu.Configuration; using ModSettingsMenu.Localization; using ModSettingsMenu.Runtime; using SunkenlandLocalizationAPI.Api; using TMPro; using UnityEngine; using UnityEngine.EventSystems; using UnityEngine.Events; using UnityEngine.UI; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)] [assembly: AssemblyTitle("ModSettingsMenu")] [assembly: AssemblyDescription("Mod Settings Menu mod for Sunkenland by Ice Box Studio")] [assembly: AssemblyCompany("Ice Box Studio")] [assembly: AssemblyProduct("ModSettingsMenu")] [assembly: AssemblyCopyright("Copyright © 2026 Ice Box Studio All rights reserved.")] [assembly: ComVisible(false)] [assembly: Guid("6d512f55-e9ee-445c-9fb4-93ed6c1ef50a")] [assembly: AssemblyFileVersion("1.3.0.0")] [assembly: TargetFramework(".NETFramework,Version=v4.7.2", FrameworkDisplayName = ".NET Framework 4.7.2")] [assembly: AssemblyVersion("1.3.0.0")] namespace ModSettingsMenu { [BepInPlugin("IceBoxStudio.Sunkenland.ModSettingsMenu", "ModSettingsMenu", "1.3.0")] [BepInDependency("IceBoxStudio.Sunkenland.LocalizationAPI", "1.2.0")] public sealed class ModSettingsMenu : BaseUnityPlugin { private Harmony _harmony; internal static ManualLogSource Log { get; private set; } private void Awake() { //IL_0088: Unknown result type (might be due to invalid IL or missing references) //IL_0092: Expected O, but got Unknown Log = ((BaseUnityPlugin)this).Logger; ModSettingsRegistry.RefreshRequested += RefreshMenus; LocalizationApi.LanguageChanged += RefreshLocalizedText; try { Log.LogInfo((object)"============================================="); Log.LogInfo((object)("ModSettingsMenu " + I18n.Text("plugin.initializing"))); Log.LogInfo((object)(I18n.Text("plugin.author_prefix") + "Ice Box Studio(https://steamcommunity.com/id/ibox666/)")); _harmony = new Harmony("IceBoxStudio.Sunkenland.ModSettingsMenu"); _harmony.PatchAll(Assembly.GetExecutingAssembly()); Log.LogInfo((object)("ModSettingsMenu " + I18n.Text("plugin.initialized"))); Log.LogInfo((object)"============================================="); } catch (Exception arg) { Log.LogError((object)$"Failed to initialize Mod Settings Menu: {arg}"); } } private static void RefreshMenus() { ModSettingsMenuController.Refresh(); } private static void RefreshLocalizedText(string language) { ModSettingsMenuController.RefreshLocalizedText(); } } public static class PluginInfo { public const string PLUGIN_GUID = "IceBoxStudio.Sunkenland.ModSettingsMenu"; public const string PLUGIN_NAME = "ModSettingsMenu"; public const string PLUGIN_VERSION = "1.3.0"; } } namespace ModSettingsMenu.Runtime { internal sealed class ConfigRows { private readonly Transform _content; private readonly GameObject _row; private readonly GameObject _heading; private readonly GameObject _toggle; private readonly GameObject _dropdown; private readonly KeybindCapture _keybindCapture; private readonly ModInfoRow _info; private readonly List _createdRows = new List(); public ConfigRows(Transform content, GameObject row, GameObject heading, GameObject toggle, GameObject dropdown, KeybindCapture keybindCapture, ModInfoRow info) { _content = content; _row = row; _heading = heading; _toggle = toggle; _dropdown = dropdown; _keybindCapture = keybindCapture; _info = info; } public void Build(ModConfig mod) { ClearRows(); if (mod == null) { CreateHeading(I18n.Text("menu.no_configurable_mods")); } else { GameObject val = _info?.Create(mod); if ((Object)(object)val != (Object)null) { CompleteRow(val); } List list = (from entry in mod.ConfigFile.GetConfigEntries() orderby ModSettingsOrder.GetSectionOrder(mod, entry.Definition.Section) select entry).ThenBy((ConfigEntryBase entry) => entry.Definition.Section, StringComparer.OrdinalIgnoreCase).ThenBy((ConfigEntryBase entry) => ModSettingsOrder.GetEntryOrder(mod, entry)).ThenBy((ConfigEntryBase entry) => entry.Definition.Key, StringComparer.OrdinalIgnoreCase) .ToList(); string text = null; foreach (ConfigEntryBase item in list) { if (!string.Equals(text, item.Definition.Section, StringComparison.OrdinalIgnoreCase)) { text = item.Definition.Section; CreateHeading(SplitName(LocalizationApi.GetConfigSection(text, mod.ConfigFile))); } CreateEntryRow(mod, item); } } LayoutRebuild(); } public void Reset(ModConfig mod) { if (mod != null) { ConfigEntryBase[] configEntries = mod.ConfigFile.GetConfigEntries(); foreach (ConfigEntryBase obj in configEntries) { ConfigValues.TrySetValue(obj, obj.DefaultValue); } Build(mod); } } private void ClearRows() { foreach (GameObject createdRow in _createdRows) { if ((Object)(object)createdRow != (Object)null) { Object.Destroy((Object)(object)createdRow); } } _createdRows.Clear(); } private void CreateHeading(string text) { GameObject val = Object.Instantiate(_heading, _content); ((Object)val).name = "Mod Settings Section - " + text; val.SetActive(false); NativeUi.DisableLocalization(val); NativeUi.SetText(val, text); CompleteRow(val); } private void CreateEntryRow(ModConfig mod, ConfigEntryBase entry) { Type settingType = entry.SettingType; ConfigDescription description = entry.Description; AcceptableValueBase acceptable = ((description != null) ? description.AcceptableValues : null); IReadOnlyList values; float min; float max; if (settingType == typeof(bool)) { CreateBoolRow(entry); } else if (settingType == typeof(KeyCode)) { CreateKeybindRow(entry); } else if (settingType.IsEnum) { CreateDropdownRow(entry, Enum.GetValues(settingType).Cast().ToList()); } else if (ConfigValues.TryGetAcceptableValues(acceptable, out values)) { CreateDropdownRow(entry, values); } else if (ConfigValues.TryGetNumericRange(acceptable, out min, out max) && ConfigValues.IsSliderType(settingType)) { CreateSliderRow(mod, entry, min, max); } else { CreateInputRow(entry); } } private void CreateBoolRow(ConfigEntryBase entry) { //IL_0070: Unknown result type (might be due to invalid IL or missing references) //IL_007a: Expected O, but got Unknown GameObject val = Object.Instantiate(_toggle, _content); ((Object)val).name = GetRowName(entry); val.SetActive(false); NativeUi.DisableLocalization(val); Toggle toggle = val.GetComponent(); if ((Object)(object)toggle == (Object)null) { Object.Destroy((Object)(object)val); CreateInputRow(entry); return; } toggle.onValueChanged = new ToggleEvent(); toggle.SetIsOnWithoutNotify((bool)entry.BoxedValue); ((UnityEvent)(object)toggle.onValueChanged).AddListener((UnityAction)delegate(bool value) { if (!ConfigValues.TrySetValue(entry, value)) { toggle.SetIsOnWithoutNotify((bool)entry.BoxedValue); } }); NativeUi.SetText(val, GetSettingText(entry)); CompleteRow(val); } private void CreateKeybindRow(ConfigEntryBase entry) { //IL_00ac: Unknown result type (might be due to invalid IL or missing references) //IL_00b6: Expected O, but got Unknown //IL_00c8: Unknown result type (might be due to invalid IL or missing references) //IL_00d2: Expected O, but got Unknown GameObject val = NewRow(GetRowName(entry)); HideSlider(val); Transform val2 = NativeUi.FindValueBackground(val); SetValueLayout(val, val2, 0.65f, 20f); TMP_Text buttonText = NativeUi.FindValueText(val); Button button = (((Object)(object)val2 == (Object)null) ? null : (((Component)val2).GetComponent