Some mods target the Mono version of the game, which is available by opting into the Steam beta branch "alternate"
Decompiled source of ModsApp v1.0.1
ModsApp.dll
Decompiled 2 days ago
The result has been truncated due to the large size, download it to view full contents!
using System; using System.Collections; using System.Collections.Generic; using System.Diagnostics; using System.Drawing; using System.Globalization; using System.IO; using System.Linq; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.Versioning; using System.Security; using System.Security.Permissions; using System.Text.RegularExpressions; using MelonLoader; using MelonLoader.Preferences; using MelonLoader.Utils; using Microsoft.CodeAnalysis; using ModsApp; using ModsApp.Helpers; using ModsApp.Managers; using ModsApp.UI.Input; using ModsApp.UI.Input.FieldFactories; using ModsApp.UI.Input.Handlers; using ModsApp.UI.Panels; using Mono.Cecil; using Mono.Collections.Generic; using Newtonsoft.Json; using Newtonsoft.Json.Linq; using S1API.Input; using S1API.Internal.Abstraction; using S1API.Internal.Utils; using S1API.PhoneApp; using S1API.UI; using Tomlet; using Tomlet.Models; using UnityEngine; using UnityEngine.EventSystems; using UnityEngine.Events; 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: MelonInfo(typeof(global::ModsApp.ModsApp), "ModsApp", "1.0.0", "k073l", null)] [assembly: MelonColor(1, 255, 0, 0)] [assembly: MelonGame("TVGS", "Schedule I")] [assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")] [assembly: AssemblyCompany("ModsApp")] [assembly: AssemblyConfiguration("Release Mono")] [assembly: AssemblyFileVersion("1.0.0.0")] [assembly: AssemblyInformationalVersion("1.0.0+c0d4f53c56c508551276c05c7ab2f2cd27c90dff")] [assembly: AssemblyProduct("ModsApp")] [assembly: AssemblyTitle("ModsApp")] [assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)] [assembly: AssemblyVersion("1.0.0.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 ModsApp { public class App : PhoneApp { public static App Instance; private static Instance _logger = Melon<ModsApp>.Logger; private UIManager _uiManager; private ModManager _modManager; protected override string AppName => "Mods"; protected override string AppTitle => "Mods"; protected override string IconLabel => "Mods"; protected override string IconFileName => Path.Combine(MelonEnvironment.UserDataDirectory, "ModsApp", "appicon.png"); protected override void OnCreated() { if ((Object)(object)ModsApp.AppIconSprite == (Object)null) { ModsApp.AppIconSprite = ModsApp.LoadEmbeddedPNG("ModsApp.assets.appicon.png"); } if (!((PhoneApp)this).SetIconSprite(ModsApp.AppIconSprite)) { _logger.Error("[Pre-base] Failed to set app icon sprite"); } ((PhoneApp)this).OnCreated(); Instance = this; _modManager = new ModManager(_logger); _logger.Msg($"ModsApp initialized with {_modManager.ModCount} mods"); } protected override void OnCreatedUI(GameObject container) { try { _uiManager = new UIManager(container, _modManager, _logger); _uiManager.Initialize(); } catch (Exception ex) { _logger.Error("UI initialization failed: " + ex.Message); _logger.Error(ex.StackTrace); } } protected override void OnPhoneClosed() { Controls.IsTyping = false; if ((Object)(object)ColorInputHandler.ColorPickerCanvas != (Object)null) { Object.Destroy((Object)(object)ColorInputHandler.ColorPickerCanvas); } ((PhoneApp)this).OnPhoneClosed(); } } public static class BuildInfo { public const string Name = "ModsApp"; public const string Description = "In-game app to manage mods' preferences"; public const string Author = "k073l"; public const string Version = "1.0.0"; } public class ModsApp : MelonMod { private static Instance Logger; public static Sprite AppIconSprite; public override void OnInitializeMelon() { Logger = ((MelonBase)this).LoggerInstance; Logger.Msg("ModsApp initialized"); AppIconSprite = LoadEmbeddedPNG("ModsApp.assets.appicon.png"); } public static Sprite LoadEmbeddedPNG(string resourceName) { Assembly executingAssembly = Assembly.GetExecutingAssembly(); using Stream stream = executingAssembly.GetManifestResourceStream(resourceName); if (stream == null) { return null; } byte[] array = new byte[stream.Length]; stream.Read(array, 0, array.Length); return ImageUtils.LoadImageRaw(array); } public override void OnUpdate() { if (App.Instance != null && ((PhoneApp)App.Instance).IsOpen() && Input.GetKeyDown((KeyCode)27)) { Controls.IsTyping = false; } if ((Object)(object)ColorInputHandler.ColorPickerCanvas != (Object)null && Input.GetKeyDown((KeyCode)27)) { Controls.IsTyping = false; Object.Destroy((Object)(object)ColorInputHandler.ColorPickerCanvas); } } } public class UITheme { public readonly Color BgPrimary = new Color(0.12f, 0.12f, 0.15f, 1f); public readonly Color BgSecondary = new Color(0.16f, 0.16f, 0.2f, 1f); public readonly Color BgCard = new Color(0.2f, 0.2f, 0.24f, 1f); public readonly Color AccentPrimary = new Color(0.26f, 0.59f, 0.98f, 1f); public readonly Color AccentSecondary = new Color(0.15f, 0.15f, 0.18f, 1f); public readonly Color TextPrimary = new Color(0.95f, 0.95f, 0.95f, 1f); public readonly Color TextSecondary = new Color(0.7f, 0.7f, 0.7f, 1f); public readonly Color SuccessColor = new Color(0.2f, 0.8f, 0.2f, 1f); public readonly Color WarningColor = new Color(0.95f, 0.75f, 0.2f, 1f); } } namespace ModsApp.UI.Panels { public class JsonConfigUI { private readonly UITheme _theme; private readonly Instance _logger; private readonly JsonConfigManager _configManager; private InputField _jsonFileInput; private InputField _jsonEditor; private Button _saveButton; private Button _revertButton; private Button _formatButton; private string _currentJsonContent = ""; private string _lastValidJsonContent = ""; private string _originalJsonContent = ""; private string _currentFilename = ""; private Action onConfigSaved; public JsonConfigUI(UITheme theme, Instance logger, JsonConfigManager configManager) { _theme = theme; _logger = logger; _configManager = configManager; } public void ResetState() { _currentJsonContent = ""; _lastValidJsonContent = ""; _originalJsonContent = ""; _currentFilename = ""; _jsonFileInput = null; _jsonEditor = null; _saveButton = null; _revertButton = null; _formatButton = null; } public void CreateJsonConfigSection(MelonMod mod, GameObject card, Action onLayoutRefresh, Action onConfigSaved) { //IL_0022: 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) Text val = UIFactory.Text("JsonConfigHeader", "No MelonPreferences", card.transform, 16, (TextAnchor)0, (FontStyle)1); ((Graphic)val).color = _theme.TextPrimary; Text val2 = UIFactory.Text("JsonConfigDesc", "No MelonPreferences were found; though they might exist. If the mod uses JSON files, you can specify the path manually. Long files may not display correctly.", card.transform, 12, (TextAnchor)0, (FontStyle)0); ((Graphic)val2).color = _theme.TextSecondary; CreateJsonFileInputSection(mod, card, onLayoutRefresh); this.onConfigSaved = onConfigSaved; } private void CreateJsonFileInputSection(MelonMod mod, GameObject parent, Action onLayoutRefresh) { //IL_0033: Unknown result type (might be due to invalid IL or missing references) //IL_0097: Unknown result type (might be due to invalid IL or missing references) //IL_00ad: Unknown result type (might be due to invalid IL or missing references) //IL_02a0: Unknown result type (might be due to invalid IL or missing references) //IL_02b1: Unknown result type (might be due to invalid IL or missing references) //IL_036e: Unknown result type (might be due to invalid IL or missing references) //IL_0378: Unknown result type (might be due to invalid IL or missing references) GameObject val = UIFactory.Panel("FileInputContainer", parent.transform, Color.clear, (Vector2?)null, (Vector2?)null, false); VerticalLayoutGroup val2 = val.AddComponent<VerticalLayoutGroup>(); ((HorizontalOrVerticalLayoutGroup)val2).spacing = 4f; ((HorizontalOrVerticalLayoutGroup)val2).childControlWidth = true; ((HorizontalOrVerticalLayoutGroup)val2).childForceExpandHeight = false; Text val3 = UIFactory.Text("PathLabel", "JSON file path (relative to UserData/):", val.transform, 12, (TextAnchor)0, (FontStyle)0); ((Graphic)val3).color = _theme.TextSecondary; GameObject val4 = UIFactory.Panel("InputRow", val.transform, Color.clear, (Vector2?)null, (Vector2?)null, false); HorizontalLayoutGroup val5 = val4.AddComponent<HorizontalLayoutGroup>(); ((HorizontalOrVerticalLayoutGroup)val5).spacing = 8f; ((HorizontalOrVerticalLayoutGroup)val5).childForceExpandWidth = false; ((HorizontalOrVerticalLayoutGroup)val5).childControlWidth = true; string text = _configManager.GetSavedFilename(((MelonBase)mod).Info.Name); if (string.IsNullOrEmpty(text)) { string text2 = _configManager.FindFileForMod(((MelonBase)mod).Info.Name, MelonEnvironment.UserDataDirectory); if (!string.IsNullOrEmpty(text2)) { text = text2; _logger.Msg("[JSON] Guessed config file for " + ((MelonBase)mod).Info.Name + ": " + text2); } else { text2 = _configManager.FindFileForMod(((MelonBase)mod).Info.Name, Path.Combine(MelonEnvironment.UserDataDirectory, "..", "Mods")); if (!string.IsNullOrEmpty(text2)) { text = text2; _logger.Msg("[JSON] Guessed config file for " + ((MelonBase)mod).Info.Name + ": " + text2); } } if (!string.IsNullOrEmpty(text2)) { string text3 = Path.Combine(MelonEnvironment.UserDataDirectory, text2); if (File.Exists(text3) && new FileInfo(text3).Length > 16000) { text = ""; _logger.Msg("[JSON] Skipping auto-load of guessed large config file: " + text3 + " (>16kB)"); } } } _jsonFileInput = InputFieldFactory.CreateInputField(val4, "JsonFileInput", text, (ContentType)0, 200); var (val6, val7, _) = UIFactory.RoundedButtonWithLabel("LoadJsonButton", "Load", val4.transform, _theme.AccentPrimary, 60f, 25f, 12, Color.white); EventHelper.AddListener((Action)delegate { LoadJsonFile(mod); if (!string.IsNullOrEmpty(_currentJsonContent)) { CreateJsonEditorSection(mod, parent); } onLayoutRefresh?.Invoke(); }, (UnityEvent)(object)val7.onClick); if (!string.IsNullOrEmpty(text)) { LoadJsonFile(mod); if (!string.IsNullOrEmpty(_currentJsonContent)) { CreateJsonEditorSection(mod, parent); } onLayoutRefresh?.Invoke(); } string userDataDirectory = MelonEnvironment.UserDataDirectory; Text val8 = UIFactory.Text("UserDataPath", "UserData path: " + userDataDirectory, val.transform, 10, (TextAnchor)0, (FontStyle)0); ((Graphic)val8).color = _theme.TextSecondary * 0.7f; } private void CreateJsonEditorSection(MelonMod mod, GameObject parent) { //IL_000c: 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_00c0: Unknown result type (might be due to invalid IL or missing references) //IL_00cf: Unknown result type (might be due to invalid IL or missing references) GameObject val = UIFactory.Panel("JsonEditorContainer", parent.transform, Color.clear, (Vector2?)null, (Vector2?)null, false); VerticalLayoutGroup val2 = val.AddComponent<VerticalLayoutGroup>(); ((HorizontalOrVerticalLayoutGroup)val2).spacing = 4f; ((HorizontalOrVerticalLayoutGroup)val2).childControlWidth = true; ((HorizontalOrVerticalLayoutGroup)val2).childForceExpandHeight = false; Text val3 = UIFactory.Text("JsonEditorLabel", "JSON Content:", val.transform, 12, (TextAnchor)0, (FontStyle)1); ((Graphic)val3).color = _theme.TextPrimary; _jsonEditor = InputFieldFactory.CreateInputField(val, "JsonEditor", "", (ContentType)0, 400); _jsonEditor.lineType = (LineType)2; _jsonEditor.contentType = (ContentType)0; RectTransform component = ((Component)_jsonEditor).GetComponent<RectTransform>(); component.sizeDelta = new Vector2(component.sizeDelta.x, 400f); LayoutElement component2 = ((Component)_jsonEditor).GetComponent<LayoutElement>(); component2.minHeight = 200f; component2.preferredHeight = 200f; Text textComponent = _jsonEditor.textComponent; textComponent.fontSize = 12; textComponent.alignment = (TextAnchor)0; textComponent.horizontalOverflow = (HorizontalWrapMode)0; textComponent.verticalOverflow = (VerticalWrapMode)1; textComponent.supportRichText = false; Graphic placeholder = _jsonEditor.placeholder; Text val4 = (Text)(object)((placeholder is Text) ? placeholder : null); if ((Object)(object)val4 != (Object)null) { val4.alignment = (TextAnchor)0; val4.horizontalOverflow = (HorizontalWrapMode)0; val4.verticalOverflow = (VerticalWrapMode)1; } _jsonEditor.text = _currentJsonContent; ((Graphic)textComponent).SetAllDirty(); if ((Object)(object)val4 != (Object)null) { ((Graphic)val4).SetAllDirty(); } _jsonEditor.ForceLabelUpdate(); Canvas.ForceUpdateCanvases(); EventHelper.AddListener<string>((Action<string>)delegate(string str) { OnJsonContentChanged(str); }, (UnityEvent<string>)(object)_jsonEditor.onValueChanged); CreateJsonActionButtons(mod, val); } private void CreateJsonActionButtons(MelonMod mod, GameObject parent) { //IL_000c: Unknown result type (might be due to invalid IL or missing references) //IL_009c: Unknown result type (might be due to invalid IL or missing references) //IL_00ad: Unknown result type (might be due to invalid IL or missing references) //IL_00fc: Unknown result type (might be due to invalid IL or missing references) //IL_010d: Unknown result type (might be due to invalid IL or missing references) //IL_015d: Unknown result type (might be due to invalid IL or missing references) //IL_016e: Unknown result type (might be due to invalid IL or missing references) GameObject val = UIFactory.Panel("JsonButtonContainer", parent.transform, Color.clear, (Vector2?)null, (Vector2?)null, false); LayoutElement orAddComponent = val.GetOrAddComponent<LayoutElement>(); orAddComponent.preferredHeight = 35f; orAddComponent.flexibleHeight = 0f; HorizontalLayoutGroup val2 = val.AddComponent<HorizontalLayoutGroup>(); ((HorizontalOrVerticalLayoutGroup)val2).spacing = 8f; ((LayoutGroup)val2).childAlignment = (TextAnchor)4; ((HorizontalOrVerticalLayoutGroup)val2).childForceExpandWidth = false; ((HorizontalOrVerticalLayoutGroup)val2).childForceExpandHeight = false; ((HorizontalOrVerticalLayoutGroup)val2).childControlWidth = true; ((HorizontalOrVerticalLayoutGroup)val2).childControlHeight = true; ValueTuple<GameObject, Button, Text> valueTuple = UIFactory.RoundedButtonWithLabel("SaveJsonButton", "Save JSON", val.transform, _theme.AccentPrimary, 100f, 30f, 14, Color.white); GameObject item = valueTuple.Item1; Button val3 = (_saveButton = valueTuple.Item2); EventHelper.AddListener((Action)delegate { SaveJsonFile(); }, (UnityEvent)(object)val3.onClick); ValueTuple<GameObject, Button, Text> valueTuple2 = UIFactory.RoundedButtonWithLabel("RevertJsonButton", "Revert", val.transform, _theme.WarningColor, 80f, 30f, 14, Color.white); GameObject item2 = valueTuple2.Item1; Button val4 = (_revertButton = valueTuple2.Item2); EventHelper.AddListener((Action)delegate { RevertJsonChanges(); }, (UnityEvent)(object)val4.onClick); ValueTuple<GameObject, Button, Text> valueTuple3 = UIFactory.RoundedButtonWithLabel("FormatJsonButton", "Format", val.transform, _theme.TextSecondary, 80f, 30f, 14, Color.white); GameObject item3 = valueTuple3.Item1; Button val5 = (_formatButton = valueTuple3.Item2); EventHelper.AddListener((Action)delegate { FormatJsonContent(); }, (UnityEvent)(object)val5.onClick); UpdateJsonButtonStates(); } private void LoadJsonFile(MelonMod mod) { string text = _jsonFileInput.text.Trim(); JsonLoadResult jsonLoadResult = _configManager.LoadJsonFile(text); if (jsonLoadResult.Success) { _currentJsonContent = CleanJsonContent(jsonLoadResult.Content); _lastValidJsonContent = _currentJsonContent; _originalJsonContent = CleanJsonContent(jsonLoadResult.OriginalContent); _currentFilename = text; _configManager.SaveFilename(((MelonBase)mod).Info.Name, text); FormatJsonContent(); } else { _logger.Warning(jsonLoadResult.ErrorMessage); } } private string CleanJsonContent(string content) { return content.Replace("\r\n", "\n").Replace("\r", "\n").Trim() .Replace("\u00a0", " ") .Replace("\t", " "); } private void SaveJsonFile() { if (string.IsNullOrEmpty(_currentFilename)) { _logger.Error("No JSON file loaded"); return; } JsonSaveResult jsonSaveResult = _configManager.SaveJsonFile(_currentFilename, _currentJsonContent); if (jsonSaveResult.Success) { _originalJsonContent = _currentJsonContent; _lastValidJsonContent = _currentJsonContent; onConfigSaved?.Invoke(); UpdateJsonButtonStates(); } else { _logger.Error(jsonSaveResult.ErrorMessage); } } private void RevertJsonChanges() { if ((Object)(object)_jsonEditor != (Object)null) { _jsonEditor.text = _originalJsonContent; _currentJsonContent = _originalJsonContent; _lastValidJsonContent = _originalJsonContent; UpdateJsonButtonStates(); _logger.Msg("Reverted JSON changes"); } } private void FormatJsonContent() { string content = _configManager.FormatJson(_currentJsonContent); string text = CleanJsonContent(content); if ((Object)(object)_jsonEditor != (Object)null && text != _currentJsonContent) { _jsonEditor.text = text; _currentJsonContent = text; _lastValidJsonContent = text; _logger.Msg("JSON formatted successfully"); } else if (text == _currentJsonContent) { _logger.Warning("JSON is already formatted or invalid"); } } private void OnJsonContentChanged(string newContent) { _currentJsonContent = newContent; if (_configManager.IsValidJson(newContent)) { _lastValidJsonContent = newContent; } UpdateJsonButtonStates(); } private void UpdateJsonButtonStates() { //IL_0062: Unknown result type (might be due to invalid IL or missing references) //IL_0067: Unknown result type (might be due to invalid IL or missing references) //IL_00b1: Unknown result type (might be due to invalid IL or missing references) //IL_00a4: Unknown result type (might be due to invalid IL or missing references) //IL_00f3: Unknown result type (might be due to invalid IL or missing references) //IL_0104: Unknown result type (might be due to invalid IL or missing references) //IL_011e: 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_016b: Unknown result type (might be due to invalid IL or missing references) //IL_015e: Unknown result type (might be due to invalid IL or missing references) //IL_01ad: Unknown result type (might be due to invalid IL or missing references) //IL_01be: Unknown result type (might be due to invalid IL or missing references) //IL_01e5: Unknown result type (might be due to invalid IL or missing references) //IL_01ea: Unknown result type (might be due to invalid IL or missing references) //IL_0233: Unknown result type (might be due to invalid IL or missing references) //IL_0226: Unknown result type (might be due to invalid IL or missing references) //IL_0244: Unknown result type (might be due to invalid IL or missing references) if (!((Object)(object)_saveButton == (Object)null) && !((Object)(object)_revertButton == (Object)null)) { bool flag = _currentJsonContent != _originalJsonContent; bool flag2 = _configManager.IsValidJson(_currentJsonContent); ((Selectable)_saveButton).interactable = flag && flag2; ColorBlock colors = ((Selectable)_saveButton).colors; ((ColorBlock)(ref colors)).normalColor = (Color)((flag && flag2) ? _theme.AccentPrimary : new Color(_theme.AccentPrimary.r, _theme.AccentPrimary.g, _theme.AccentPrimary.b, 0.5f)); ((ColorBlock)(ref colors)).disabledColor = new Color(_theme.AccentPrimary.r, _theme.AccentPrimary.g, _theme.AccentPrimary.b, 0.3f); ((Selectable)_saveButton).colors = colors; ((Selectable)_revertButton).interactable = flag; ColorBlock colors2 = ((Selectable)_revertButton).colors; ((ColorBlock)(ref colors2)).normalColor = (Color)(flag ? _theme.WarningColor : new Color(_theme.WarningColor.r, _theme.WarningColor.g, _theme.WarningColor.b, 0.5f)); ((ColorBlock)(ref colors2)).disabledColor = new Color(_theme.WarningColor.r, _theme.WarningColor.g, _theme.WarningColor.b, 0.3f); ((Selectable)_revertButton).colors = colors2; ((Selectable)_formatButton).interactable = !string.IsNullOrEmpty(_currentJsonContent); ColorBlock colors3 = ((Selectable)_formatButton).colors; ((ColorBlock)(ref colors3)).normalColor = (Color)(flag2 ? _theme.TextSecondary : new Color(_theme.WarningColor.r, _theme.WarningColor.g, _theme.WarningColor.b, 0.8f)); ((Selectable)_formatButton).colors = colors3; } } private static Font GetBestMonospaceFont() { string[] array = new string[5] { "Consolas", "Courier New", "Courier", "Monaco", "Menlo" }; string[] array2 = array; foreach (string text in array2) { Font builtinResource = Resources.GetBuiltinResource<Font>(text.Replace(" ", "") + ".ttf"); if ((Object)(object)builtinResource != (Object)null) { return builtinResource; } } Font builtinResource2 = Resources.GetBuiltinResource<Font>("Arial.ttf"); if ((Object)(object)builtinResource2 == (Object)null) { MelonLogger.Msg("[UI][WARN] Arial font missing!"); } return builtinResource2; } } public class ModDetailsPanel { private readonly Transform _parent; private readonly ModManager _modManager; private readonly UITheme _theme; private readonly Instance _logger; private readonly PreferenceInputFactory _inputFactory; private RectTransform _detailsContent; private Dictionary<string, object> _modifiedPreferences = new Dictionary<string, object>(); private HashSet<string> _modifiedMods = new HashSet<string>(); private Text _modifiedLabel; private Button _applyButton; private Button _resetButton; private JsonConfigManager _jsonConfigManager; private JsonConfigUI _jsonConfigUI; public ModDetailsPanel(Transform parent, ModManager modManager, UITheme theme, Instance logger) { _parent = parent; _modManager = modManager; _theme = theme; _logger = logger; _inputFactory = new PreferenceInputFactory(theme, logger); _jsonConfigManager = new JsonConfigManager(logger); _jsonConfigUI = new JsonConfigUI(theme, logger, _jsonConfigManager); } public void Initialize() { //IL_0012: Unknown result type (might be due to invalid IL or missing references) //IL_0021: 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) //IL_0056: Unknown result type (might be due to invalid IL or missing references) //IL_0065: Unknown result type (might be due to invalid IL or missing references) //IL_006a: Unknown result type (might be due to invalid IL or missing references) //IL_0074: 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_00bd: Unknown result type (might be due to invalid IL or missing references) //IL_00c2: Unknown result type (might be due to invalid IL or missing references) //IL_00c7: Unknown result type (might be due to invalid IL or missing references) //IL_00d1: Unknown result type (might be due to invalid IL or missing references) //IL_00e5: Unknown result type (might be due to invalid IL or missing references) //IL_010a: Unknown result type (might be due to invalid IL or missing references) //IL_0114: Expected O, but got Unknown //IL_0144: Unknown result type (might be due to invalid IL or missing references) //IL_014e: Expected O, but got Unknown GameObject val = UIFactory.Panel("ModDetailsPanel", _parent, _theme.BgCard, (Vector2?)new Vector2(0.36f, 0.05f), (Vector2?)new Vector2(0.98f, 0.82f), false); UIHelper.ForceRectToAnchors(val.GetComponent<RectTransform>(), new Vector2(0.36f, 0.05f), new Vector2(0.98f, 0.82f), Vector2.zero, Vector2.zero); UIHelper.AddBorderEffect(val, _theme.AccentPrimary); ScrollRect val2 = default(ScrollRect); _detailsContent = UIFactory.ScrollableVerticalList("ModDetailsContent", val.transform, ref val2); UIHelper.ForceRectToAnchors(_detailsContent, Vector2.zero, Vector2.one, (Vector2?)Vector2.zero, (Vector2?)Vector2.zero, (Vector2?)new Vector2(0.5f, 1f)); UIHelper.SetupLayoutGroup(((Component)_detailsContent).gameObject, 6, fitContent: true, new RectOffset(12, 12, 12, 12)); VerticalLayoutGroup component = ((Component)_detailsContent).GetComponent<VerticalLayoutGroup>(); if ((Object)(object)component != (Object)null) { ((HorizontalOrVerticalLayoutGroup)component).spacing = 6f; ((LayoutGroup)component).padding = new RectOffset(12, 12, 12, 12); ((HorizontalOrVerticalLayoutGroup)component).childControlWidth = true; ((HorizontalOrVerticalLayoutGroup)component).childForceExpandHeight = false; } UIFactory.FitContentHeight(_detailsContent); UIHelper.DumpRect("ModDetailsPanel", val.GetComponent<RectTransform>()); UIHelper.DumpRect("ModDetailsContent", _detailsContent); } public void ShowWelcome() { if (!((Object)(object)_detailsContent == (Object)null)) { UIFactory.ClearChildren((Transform)(object)_detailsContent); GameObject card = CreateInfoCard("WelcomeCard"); CreateWelcomeContent(card); GameObject card2 = CreateInfoCard("StatsCard"); CreateStatsContent(card2); UIHelper.RefreshLayout(_detailsContent); } } public void ShowModDetails(MelonMod mod) { if ((Object)(object)_detailsContent == (Object)null) { return; } UIFactory.ClearChildren((Transform)(object)_detailsContent); _modifiedPreferences.Clear(); _jsonConfigUI.ResetState(); GameObject card = CreateInfoCard(UIHelper.SanitizeName(((MelonBase)mod).Info.Name) + "_HeaderCard"); CreateModHeader(mod, card); List<MelonPreferences_Category> list = _modManager.GetPreferencesForMod(mod).ToList(); if (list.Count > 0) { GameObject card2 = CreateInfoCard(UIHelper.SanitizeName(((MelonBase)mod).Info.Name) + "_PrefsCard"); CreatePreferencesSection(mod, card2); GameObject card3 = CreateInfoCard(UIHelper.SanitizeName(((MelonBase)mod).Info.Name) + "_ActionsCard"); CreateActionButtons(mod, card3); } else { GameObject card4 = CreateInfoCard(UIHelper.SanitizeName(((MelonBase)mod).Info.Name) + "_JsonCard"); _jsonConfigUI.CreateJsonConfigSection(mod, card4, delegate { UIHelper.RefreshLayout(_detailsContent); }, delegate { _modifiedMods.Add(((MelonBase)mod).Info.Name); _modifiedLabel.text = "Changes applied, restart may be required"; ((Component)_modifiedLabel).gameObject.SetActive(true); }); } UIHelper.RefreshLayout(_detailsContent); } private GameObject CreateInfoCard(string name) { //IL_000e: Unknown result type (might be due to invalid IL or missing references) //IL_0048: Unknown result type (might be due to invalid IL or missing references) //IL_0052: Expected O, but got Unknown GameObject val = UIFactory.Panel(name, (Transform)(object)_detailsContent, _theme.BgSecondary, (Vector2?)null, (Vector2?)null, false); VerticalLayoutGroup orAddComponent = val.GetOrAddComponent<VerticalLayoutGroup>(); ((HorizontalOrVerticalLayoutGroup)orAddComponent).spacing = 8f; ((LayoutGroup)orAddComponent).padding = new RectOffset(12, 12, 8, 8); ((HorizontalOrVerticalLayoutGroup)orAddComponent).childControlWidth = true; ((HorizontalOrVerticalLayoutGroup)orAddComponent).childForceExpandHeight = false; ((LayoutGroup)orAddComponent).childAlignment = (TextAnchor)0; ContentSizeFitter orAddComponent2 = val.GetOrAddComponent<ContentSizeFitter>(); orAddComponent2.verticalFit = (FitMode)2; orAddComponent2.horizontalFit = (FitMode)0; LayoutElement orAddComponent3 = val.GetOrAddComponent<LayoutElement>(); orAddComponent3.preferredHeight = -1f; orAddComponent3.minHeight = 0f; orAddComponent3.flexibleHeight = 0f; orAddComponent3.flexibleWidth = 1f; return val; } private void CreateWelcomeContent(GameObject card) { //IL_0022: 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) Text val = UIFactory.Text("WelcomeTitle", "Mods Manager", card.transform, 20, (TextAnchor)0, (FontStyle)1); ((Graphic)val).color = _theme.TextPrimary; Text val2 = UIFactory.Text("WelcomeDesc", "Select a mod from the list to view its details and preferences.", card.transform, 14, (TextAnchor)0, (FontStyle)0); ((Graphic)val2).color = _theme.TextSecondary; } private void CreateStatsContent(GameObject card) { //IL_0022: Unknown result type (might be due to invalid IL or missing references) //IL_0063: Unknown result type (might be due to invalid IL or missing references) Text val = UIFactory.Text("StatsTitle", "Statistics", card.transform, 16, (TextAnchor)0, (FontStyle)1); ((Graphic)val).color = _theme.TextPrimary; Text val2 = UIFactory.Text("ModCount", $"Total Mods: {_modManager.ModCount}", card.transform, 14, (TextAnchor)0, (FontStyle)0); ((Graphic)val2).color = _theme.TextSecondary; } private void CreateModHeader(MelonMod mod, GameObject card) { //IL_000c: Unknown result type (might be due to invalid IL or missing references) //IL_00ad: Unknown result type (might be due to invalid IL or missing references) //IL_00f3: Unknown result type (might be due to invalid IL or missing references) //IL_00e6: Unknown result type (might be due to invalid IL or missing references) //IL_0104: Unknown result type (might be due to invalid IL or missing references) //IL_0157: Unknown result type (might be due to invalid IL or missing references) //IL_015e: Expected O, but got Unknown //IL_01cd: Unknown result type (might be due to invalid IL or missing references) //IL_0260: Unknown result type (might be due to invalid IL or missing references) //IL_029e: Unknown result type (might be due to invalid IL or missing references) GameObject val = UIFactory.Panel("HeaderContainer", card.transform, Color.clear, (Vector2?)null, (Vector2?)null, false); LayoutElement orAddComponent = val.GetOrAddComponent<LayoutElement>(); orAddComponent.preferredHeight = 28f; orAddComponent.flexibleHeight = 0f; HorizontalLayoutGroup val2 = val.AddComponent<HorizontalLayoutGroup>(); ((HorizontalOrVerticalLayoutGroup)val2).spacing = 8f; ((LayoutGroup)val2).childAlignment = (TextAnchor)3; ((HorizontalOrVerticalLayoutGroup)val2).childForceExpandWidth = false; ((HorizontalOrVerticalLayoutGroup)val2).childForceExpandHeight = false; ((HorizontalOrVerticalLayoutGroup)val2).childControlWidth = true; ((HorizontalOrVerticalLayoutGroup)val2).childControlHeight = true; Text val3 = UIFactory.Text("ModTitle", ((MelonBase)mod).Info.Name, val.transform, 20, (TextAnchor)3, (FontStyle)1); ((Graphic)val3).color = _theme.TextPrimary; string backend = ""; bool flag = _modManager.isCompatible(mod, ref backend); var (val4, val5, val6) = UIFactory.RoundedButtonWithLabel("BackendBadge", backend, val.transform, flag ? _theme.SuccessColor : _theme.WarningColor, 70f, 22f, 12, Color.white); ((Selectable)val5).transition = (Transition)0; ((Selectable)val5).interactable = true; ((Behaviour)val5).enabled = false; val6.fontStyle = (FontStyle)1; val6.alignment = (TextAnchor)4; GameObject val7 = new GameObject("Spacer"); val7.transform.SetParent(val.transform, false); LayoutElement val8 = val7.AddComponent<LayoutElement>(); val8.flexibleWidth = 1f; val8.flexibleHeight = 0f; val8.minWidth = 10f; _modifiedLabel = UIFactory.Text("ModifiedLabel", "", val.transform, 12, (TextAnchor)5, (FontStyle)2); ((Graphic)_modifiedLabel).color = _theme.WarningColor; if (_modifiedMods.Contains(((MelonBase)mod).Info.Name)) { _modifiedLabel.text = "Changes applied, restart may be required"; ((Component)_modifiedLabel).gameObject.SetActive(true); } else { ((Component)_modifiedLabel).gameObject.SetActive(false); } Text val9 = UIFactory.Text("ModAuthor", "by: " + ((MelonBase)mod).Info.Author, card.transform, 14, (TextAnchor)0, (FontStyle)0); ((Graphic)val9).color = _theme.TextSecondary; Text val10 = UIFactory.Text("ModVersion", "v. " + ((MelonBase)mod).Info.Version, card.transform, 14, (TextAnchor)0, (FontStyle)0); ((Graphic)val10).color = _theme.TextSecondary; } private void CreatePreferencesSection(MelonMod mod, GameObject card) { //IL_0022: Unknown result type (might be due to invalid IL or missing references) //IL_006e: Unknown result type (might be due to invalid IL or missing references) Text val = UIFactory.Text("PrefsHeader", "Preferences", card.transform, 16, (TextAnchor)0, (FontStyle)1); ((Graphic)val).color = _theme.TextPrimary; List<MelonPreferences_Category> list = _modManager.GetPreferencesForMod(mod).ToList(); if (list.Count == 0) { Text val2 = UIFactory.Text("NoPrefs", "No preferences available for this mod :( (that we know of)", card.transform, 12, (TextAnchor)0, (FontStyle)2); ((Graphic)val2).color = _theme.TextSecondary; return; } foreach (MelonPreferences_Category item in list) { CreateCategorySection(item, card); } } private void CreateCategorySection(MelonPreferences_Category category, GameObject parent) { //IL_0063: Unknown result type (might be due to invalid IL or missing references) //IL_009b: Unknown result type (might be due to invalid IL or missing references) //IL_00a5: Expected O, but got Unknown //IL_0185: Unknown result type (might be due to invalid IL or missing references) GameObject val = UIFactory.Panel(UIHelper.SanitizeName(category.Identifier) + "_Category", parent.transform, new Color(_theme.BgCard.r - 0.02f, _theme.BgCard.g - 0.02f, _theme.BgCard.b - 0.02f, 1f), (Vector2?)null, (Vector2?)null, false); VerticalLayoutGroup orAddComponent = val.GetOrAddComponent<VerticalLayoutGroup>(); ((HorizontalOrVerticalLayoutGroup)orAddComponent).spacing = 4f; ((LayoutGroup)orAddComponent).padding = new RectOffset(8, 8, 6, 6); ((HorizontalOrVerticalLayoutGroup)orAddComponent).childControlWidth = true; ((HorizontalOrVerticalLayoutGroup)orAddComponent).childForceExpandHeight = false; ((LayoutGroup)orAddComponent).childAlignment = (TextAnchor)0; ContentSizeFitter orAddComponent2 = val.GetOrAddComponent<ContentSizeFitter>(); orAddComponent2.verticalFit = (FitMode)2; orAddComponent2.horizontalFit = (FitMode)0; LayoutElement orAddComponent3 = val.GetOrAddComponent<LayoutElement>(); orAddComponent3.preferredHeight = -1f; orAddComponent3.flexibleHeight = 0f; orAddComponent3.flexibleWidth = 1f; string text = (string.IsNullOrWhiteSpace(category.DisplayName) ? category.Identifier : category.DisplayName); Text val2 = UIFactory.Text(UIHelper.SanitizeName(category.Identifier) + "_Title", text ?? "", val.transform, 14, (TextAnchor)0, (FontStyle)1); ((Graphic)val2).color = new Color(_theme.AccentPrimary.r, _theme.AccentPrimary.g, _theme.AccentPrimary.b, 0.9f); List<MelonPreferences_Entry> entries = category.Entries; if (entries == null || entries.Count <= 0) { return; } foreach (MelonPreferences_Entry entry in category.Entries) { CreatePreferenceEntry(entry, val, category.Identifier); } } private void CreatePreferenceEntry(MelonPreferences_Entry entry, GameObject parent, string categoryId) { //IL_004e: Unknown result type (might be due to invalid IL or missing references) //IL_00a6: Unknown result type (might be due to invalid IL or missing references) //IL_00b0: Expected O, but got Unknown //IL_00f4: Unknown result type (might be due to invalid IL or missing references) //IL_0185: Unknown result type (might be due to invalid IL or missing references) //IL_01fd: Unknown result type (might be due to invalid IL or missing references) //IL_02c4: Unknown result type (might be due to invalid IL or missing references) //IL_02ce: Unknown result type (might be due to invalid IL or missing references) //IL_0367: Unknown result type (might be due to invalid IL or missing references) //IL_0371: Unknown result type (might be due to invalid IL or missing references) string text = entry.DisplayName ?? entry.Identifier ?? "Entry"; string text2 = categoryId + "." + entry.Identifier; GameObject val = UIFactory.Panel(UIHelper.SanitizeName(categoryId) + "_" + UIHelper.SanitizeName(text) + "_Container", parent.transform, Color.clear, (Vector2?)null, (Vector2?)null, false); VerticalLayoutGroup val2 = val.AddComponent<VerticalLayoutGroup>(); ((HorizontalOrVerticalLayoutGroup)val2).spacing = 4f; ((LayoutGroup)val2).childAlignment = (TextAnchor)0; ((HorizontalOrVerticalLayoutGroup)val2).childForceExpandHeight = false; ((HorizontalOrVerticalLayoutGroup)val2).childForceExpandWidth = true; ((HorizontalOrVerticalLayoutGroup)val2).childControlHeight = true; ((LayoutGroup)val2).padding = new RectOffset(0, 0, 4, 0); LayoutElement orAddComponent = val.GetOrAddComponent<LayoutElement>(); orAddComponent.flexibleWidth = 1f; orAddComponent.flexibleHeight = 0f; GameObject val3 = UIFactory.Panel(UIHelper.SanitizeName(categoryId) + "_" + UIHelper.SanitizeName(text) + "_MainRow", val.transform, Color.clear, (Vector2?)null, (Vector2?)null, false); HorizontalLayoutGroup val4 = val3.AddComponent<HorizontalLayoutGroup>(); ((HorizontalOrVerticalLayoutGroup)val4).spacing = 8f; ((LayoutGroup)val4).childAlignment = (TextAnchor)3; ((HorizontalOrVerticalLayoutGroup)val4).childForceExpandWidth = false; ((HorizontalOrVerticalLayoutGroup)val4).childForceExpandHeight = false; ((HorizontalOrVerticalLayoutGroup)val4).childControlHeight = true; Text val5 = UIFactory.Text(UIHelper.SanitizeName(categoryId) + "_" + UIHelper.SanitizeName(text) + "_Label", text, val3.transform, 14, (TextAnchor)3, (FontStyle)0); ((Graphic)val5).color = _theme.TextPrimary; LayoutElement orAddComponent2 = ((Component)val5).gameObject.GetOrAddComponent<LayoutElement>(); orAddComponent2.minWidth = 80f; orAddComponent2.flexibleWidth = 0f; Text val6 = UIFactory.Text(UIHelper.SanitizeName(categoryId) + "_" + UIHelper.SanitizeName(text) + "_TypeHint", TypeNameHelper.GetFriendlyTypeName(entry.BoxedValue.GetType()), val3.transform, 12, (TextAnchor)3, (FontStyle)0); ((Graphic)val6).color = _theme.TextSecondary; LayoutElement orAddComponent3 = ((Component)val6).gameObject.GetOrAddComponent<LayoutElement>(); orAddComponent3.minWidth = 50f; orAddComponent3.flexibleWidth = 0f; object currentValue = (_modifiedPreferences.ContainsKey(text2) ? _modifiedPreferences[text2] : entry.BoxedValue); _inputFactory.CreatePreferenceInput(entry, val3, text2, currentValue, OnPreferenceValueChanged); if (!string.IsNullOrEmpty(entry.Description)) { Text val7 = UIFactory.Text(UIHelper.SanitizeName(categoryId) + "_" + UIHelper.SanitizeName(text) + "_Description", entry.Description, val.transform, 12, (TextAnchor)0, (FontStyle)0); ((Graphic)val7).color = _theme.TextSecondary * 0.9f; LayoutElement orAddComponent4 = ((Component)val7).gameObject.GetOrAddComponent<LayoutElement>(); orAddComponent4.flexibleWidth = 1f; ContentSizeFitter val8 = ((Component)val7).gameObject.AddComponent<ContentSizeFitter>(); val8.horizontalFit = (FitMode)0; val8.verticalFit = (FitMode)2; } if (!string.IsNullOrEmpty(entry.Comment)) { Text val9 = UIFactory.Text(UIHelper.SanitizeName(categoryId) + "_" + UIHelper.SanitizeName(text) + "_Comment", entry.Comment, val.transform, 11, (TextAnchor)0, (FontStyle)0); ((Graphic)val9).color = _theme.TextSecondary * 0.8f; LayoutElement orAddComponent5 = ((Component)val9).gameObject.GetOrAddComponent<LayoutElement>(); orAddComponent5.flexibleWidth = 1f; ContentSizeFitter val10 = ((Component)val9).gameObject.AddComponent<ContentSizeFitter>(); val10.horizontalFit = (FitMode)0; val10.verticalFit = (FitMode)2; } } private void OnPreferenceValueChanged(string entryKey, object newValue) { _modifiedPreferences[entryKey] = newValue; UpdateButtonStates(); } private void CreateActionButtons(MelonMod mod, GameObject card) { //IL_0020: Unknown result type (might be due to invalid IL or missing references) //IL_00b0: Unknown result type (might be due to invalid IL or missing references) //IL_00c1: Unknown result type (might be due to invalid IL or missing references) //IL_0111: Unknown result type (might be due to invalid IL or missing references) //IL_0122: Unknown result type (might be due to invalid IL or missing references) GameObject val = UIFactory.Panel("ButtonContainer", card.transform, Color.clear, (Vector2?)null, (Vector2?)null, false); LayoutElement orAddComponent = val.GetOrAddComponent<LayoutElement>(); orAddComponent.preferredHeight = 35f; orAddComponent.flexibleHeight = 0f; HorizontalLayoutGroup val2 = val.AddComponent<HorizontalLayoutGroup>(); ((HorizontalOrVerticalLayoutGroup)val2).spacing = 8f; ((LayoutGroup)val2).childAlignment = (TextAnchor)4; ((HorizontalOrVerticalLayoutGroup)val2).childForceExpandWidth = false; ((HorizontalOrVerticalLayoutGroup)val2).childForceExpandHeight = false; ((HorizontalOrVerticalLayoutGroup)val2).childControlWidth = true; ((HorizontalOrVerticalLayoutGroup)val2).childControlHeight = true; ValueTuple<GameObject, Button, Text> valueTuple = UIFactory.RoundedButtonWithLabel("ApplyButton", "Apply Changes", val.transform, _theme.AccentPrimary, 120f, 30f, 14, Color.white); GameObject item = valueTuple.Item1; Button val3 = (_applyButton = valueTuple.Item2); EventHelper.AddListener((Action)delegate { ApplyPreferenceChanges(mod); }, (UnityEvent)(object)val3.onClick); ValueTuple<GameObject, Button, Text> valueTuple2 = UIFactory.RoundedButtonWithLabel("ResetButton", "Reset", val.transform, _theme.WarningColor, 80f, 30f, 14, Color.white); GameObject item2 = valueTuple2.Item1; Button val4 = (_resetButton = valueTuple2.Item2); EventHelper.AddListener((Action)delegate { ResetPreferenceChanges(mod); }, (UnityEvent)(object)val4.onClick); UpdateButtonStates(); } private void ApplyPreferenceChanges(MelonMod mod) { foreach (KeyValuePair<string, object> modifiedPreference in _modifiedPreferences) { string[] array = modifiedPreference.Key.Split('.'); if (array.Length != 2) { continue; } string categoryId = array[0]; string entryId = array[1]; List<MelonPreferences_Category> source = _modManager.GetPreferencesForMod(mod).ToList(); MelonPreferences_Entry val = ((IEnumerable<MelonPreferences_Category>)source).FirstOrDefault((Func<MelonPreferences_Category, bool>)((MelonPreferences_Category c) => c.Identifier == categoryId))?.Entries?.FirstOrDefault((Func<MelonPreferences_Entry, bool>)((MelonPreferences_Entry e) => e.Identifier == entryId)); if (val == null) { continue; } try { Type type = val.BoxedValue.GetType(); if (modifiedPreference.Value.GetType() == type) { val.BoxedValue = modifiedPreference.Value; } else if (type.IsEnum) { val.BoxedValue = Enum.Parse(type, modifiedPreference.Value.ToString()); } else { val.BoxedValue = Convert.ChangeType(modifiedPreference.Value, type); } _logger.Msg($"Applied preference change: {modifiedPreference.Key} = {modifiedPreference.Value}"); } catch (Exception ex) { _logger.Error("Failed to apply preference " + modifiedPreference.Key + ": " + ex.Message); } } MelonPreferences.Save(); _modifiedPreferences.Clear(); ShowModDetails(mod); _logger.Msg("Preferences applied and saved successfully"); _modifiedMods.Add(((MelonBase)mod).Info.Name); _modifiedLabel.text = "Changes applied, restart may be required"; ((Component)_modifiedLabel).gameObject.SetActive(true); } private void ResetPreferenceChanges(MelonMod mod) { _modifiedPreferences.Clear(); ShowModDetails(mod); _logger.Msg("Preference changes reset"); } private void UpdateButtonStates() { //IL_0049: 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) //IL_0096: 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_00d8: Unknown result type (might be due to invalid IL or missing references) //IL_00e9: Unknown result type (might be due to invalid IL or missing references) //IL_0103: Unknown result type (might be due to invalid IL or missing references) //IL_0108: 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_0143: Unknown result type (might be due to invalid IL or missing references) //IL_0192: Unknown result type (might be due to invalid IL or missing references) //IL_01a3: Unknown result type (might be due to invalid IL or missing references) if (!((Object)(object)_applyButton == (Object)null) && !((Object)(object)_resetButton == (Object)null)) { bool flag = _modifiedPreferences.Count > 0; ((Selectable)_applyButton).interactable = flag; ColorBlock colors = ((Selectable)_applyButton).colors; ((ColorBlock)(ref colors)).normalColor = (Color)(flag ? _theme.AccentPrimary : new Color(_theme.AccentPrimary.r, _theme.AccentPrimary.g, _theme.AccentPrimary.b, 0.5f)); ((ColorBlock)(ref colors)).disabledColor = new Color(_theme.AccentPrimary.r, _theme.AccentPrimary.g, _theme.AccentPrimary.b, 0.3f); ((Selectable)_applyButton).colors = colors; ((Selectable)_resetButton).interactable = flag; ColorBlock colors2 = ((Selectable)_resetButton).colors; ((ColorBlock)(ref colors2)).normalColor = (Color)(flag ? _theme.WarningColor : new Color(_theme.WarningColor.r, _theme.WarningColor.g, _theme.WarningColor.b, 0.5f)); ((ColorBlock)(ref colors2)).disabledColor = new Color(_theme.WarningColor.r, _theme.WarningColor.g, _theme.WarningColor.b, 0.3f); ((Selectable)_resetButton).colors = colors2; } } } public class ModListPanel { private readonly Transform _parent; private readonly ModManager _modManager; private readonly UITheme _theme; private readonly Instance _logger; private RectTransform _listContent; private readonly Dictionary<string, GameObject> _modButtons = new Dictionary<string, GameObject>(); private Dictionary<string, Text> _modLabels = new Dictionary<string, Text>(); private string _selectedModName; public event Action<MelonMod> OnModSelected; public ModListPanel(Transform parent, ModManager modManager, UITheme theme, Instance logger) { _parent = parent; _modManager = modManager; _theme = theme; _logger = logger; } public void Initialize() { //IL_0012: Unknown result type (might be due to invalid IL or missing references) //IL_0021: 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) //IL_0056: Unknown result type (might be due to invalid IL or missing references) //IL_0065: Unknown result type (might be due to invalid IL or missing references) //IL_006a: Unknown result type (might be due to invalid IL or missing references) //IL_0074: 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_00bd: Unknown result type (might be due to invalid IL or missing references) //IL_00c2: Unknown result type (might be due to invalid IL or missing references) //IL_00c7: Unknown result type (might be due to invalid IL or missing references) //IL_00d1: Unknown result type (might be due to invalid IL or missing references) //IL_00e5: Unknown result type (might be due to invalid IL or missing references) //IL_0106: Unknown result type (might be due to invalid IL or missing references) //IL_0110: Expected O, but got Unknown GameObject val = UIFactory.Panel("ModListPanel", _parent, _theme.BgSecondary, (Vector2?)new Vector2(0.02f, 0.05f), (Vector2?)new Vector2(0.35f, 0.82f), false); UIHelper.ForceRectToAnchors(val.GetComponent<RectTransform>(), new Vector2(0.02f, 0.05f), new Vector2(0.35f, 0.82f), Vector2.zero, Vector2.zero); UIHelper.AddBorderEffect(val, _theme.AccentPrimary); ScrollRect val2 = default(ScrollRect); _listContent = UIFactory.ScrollableVerticalList("ModListContent", val.transform, ref val2); UIHelper.ForceRectToAnchors(_listContent, Vector2.zero, Vector2.one, (Vector2?)Vector2.zero, (Vector2?)Vector2.zero, (Vector2?)new Vector2(0.5f, 1f)); UIHelper.SetupLayoutGroup(((Component)_listContent).gameObject, 4, fitContent: false, new RectOffset(8, 8, 8, 8)); UIHelper.DumpRect("ModListPanel", val.GetComponent<RectTransform>()); UIHelper.DumpRect("ModListContent", _listContent); } public void PopulateList() { if ((Object)(object)_listContent == (Object)null) { return; } UIFactory.ClearChildren((Transform)(object)_listContent); _modButtons.Clear(); foreach (MelonMod allMod in _modManager.GetAllMods()) { CreateModButton(allMod); } UIHelper.RefreshLayout(_listContent); } private void CreateModButton(MelonMod mod) { //IL_0040: Unknown result type (might be due to invalid IL or missing references) //IL_00d7: Unknown result type (might be due to invalid IL or missing references) //IL_00f2: Unknown result type (might be due to invalid IL or missing references) //IL_0101: Unknown result type (might be due to invalid IL or missing references) //IL_0172: Unknown result type (might be due to invalid IL or missing references) //IL_018e: Unknown result type (might be due to invalid IL or missing references) //IL_019d: Unknown result type (might be due to invalid IL or missing references) GameObject val = UIFactory.Panel(UIHelper.SanitizeName(((MelonBase)mod).Info.Name) + "_Button", (Transform)(object)_listContent, _theme.AccentSecondary, (Vector2?)null, (Vector2?)null, false); Button orAddComponent = val.GetOrAddComponent<Button>(); UIHelper.SetupButton(orAddComponent, _theme, delegate { SelectMod(mod); }); UIHelper.ConfigureButtonLayout(val.GetComponent<RectTransform>(), 48f); Text val2 = UIFactory.Text(UIHelper.SanitizeName(((MelonBase)mod).Info.Name) + "_Label", ((MelonBase)mod).Info.Name, val.transform, 14, (TextAnchor)3, (FontStyle)0); ((Graphic)val2).color = _theme.TextPrimary; UIHelper.ConfigureButtonText(((Graphic)val2).rectTransform, new Vector2(0f, 0f), new Vector2(0.7f, 1f), 16f, -8f, 4f, -4f); Text val3 = UIFactory.Text(UIHelper.SanitizeName(((MelonBase)mod).Info.Name) + "_Version", "v" + ((MelonBase)mod).Info.Version, val.transform, 10, (TextAnchor)5, (FontStyle)0); ((Graphic)val3).color = _theme.TextSecondary; UIHelper.ConfigureButtonText(((Graphic)val3).rectTransform, new Vector2(0.7f, 0f), new Vector2(1f, 1f), 4f, -12f, 4f, -4f); _modButtons[((MelonBase)mod).Info.Name] = val; _modLabels[((MelonBase)mod).Info.Name] = val2; } private void SelectMod(MelonMod mod) { _selectedModName = ((MelonBase)mod).Info.Name; UpdateButtonHighlights(); this.OnModSelected?.Invoke(mod); } private void UpdateButtonHighlights() { //IL_0060: Unknown result type (might be due to invalid IL or missing references) //IL_0053: Unknown result type (might be due to invalid IL or missing references) //IL_00a7: Unknown result type (might be due to invalid IL or missing references) //IL_00a0: Unknown result type (might be due to invalid IL or missing references) foreach (KeyValuePair<string, GameObject> modButton in _modButtons) { bool flag = modButton.Key == _selectedModName; Image component = modButton.Value.GetComponent<Image>(); if ((Object)(object)component != (Object)null) { ((Graphic)component).color = (flag ? _theme.AccentPrimary : _theme.AccentSecondary); } if (_modLabels.TryGetValue(modButton.Key, out var value)) { value.fontStyle = (FontStyle)(flag ? 1 : 0); ((Graphic)value).color = (flag ? Color.white : _theme.TextPrimary); } } } } } namespace ModsApp.UI.Input { public class PreferenceInputFactory { private readonly List<IPreferenceInputHandler> _handlers; private readonly UITheme _theme; public PreferenceInputFactory(UITheme theme, Instance logger) { _theme = theme; _handlers = new List<IPreferenceInputHandler> { new BooleanInputHandler(theme, logger), new NumericInputHandler(theme, logger), new StringInputHandler(theme, logger), new KeyCodeInputHandler(theme, logger), new ColorInputHandler(theme, logger), new EnumInputHandler(theme, logger), new VectorHandler(theme, logger), new FallbackInputHandler(theme, logger) }; } public void CreatePreferenceInput(MelonPreferences_Entry entry, GameObject parent, string entryKey, object currentValue, Action<string, object> onValueChanged) { Type valueType = entry.BoxedValue?.GetType(); foreach (IPreferenceInputHandler handler in _handlers) { if (handler.CanHandle(valueType)) { handler.CreateInput(entry, parent, entryKey, currentValue, onValueChanged); break; } } } public void RegisterHandler(IPreferenceInputHandler handler) { _handlers.Insert(_handlers.Count - 1, handler); } } } namespace ModsApp.UI.Input.Handlers { public class BooleanInputHandler : IPreferenceInputHandler { private readonly UITheme _theme; private readonly Instance _logger; public BooleanInputHandler(UITheme theme, Instance logger) { _theme = theme; _logger = logger; } public bool CanHandle(Type valueType) { return valueType == typeof(bool); } public void CreateInput(MelonPreferences_Entry entry, GameObject parent, string entryKey, object currentValue, Action<string, object> onValueChanged) { //IL_003a: Unknown result type (might be due to invalid IL or missing references) //IL_0040: Expected O, but got Unknown //IL_005b: 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_0099: Unknown result type (might be due to invalid IL or missing references) //IL_00a0: Expected O, but got Unknown //IL_00bf: Unknown result type (might be due to invalid IL or missing references) //IL_00df: Unknown result type (might be due to invalid IL or missing references) //IL_00f6: Unknown result type (might be due to invalid IL or missing references) //IL_0105: Unknown result type (might be due to invalid IL or missing references) //IL_010a: Unknown result type (might be due to invalid IL or missing references) //IL_010b: Unknown result type (might be due to invalid IL or missing references) //IL_0113: Unknown result type (might be due to invalid IL or missing references) bool boolValue = (bool)currentValue; GameObject val = new GameObject(entryKey + "_Toggle"); val.transform.SetParent(parent.transform, false); Image val2 = val.AddComponent<Image>(); ((Graphic)val2).color = Color.white; Toggle val3 = val.AddComponent<Toggle>(); ((Selectable)val3).targetGraphic = (Graphic)(object)val2; RectTransform component = val.GetComponent<RectTransform>(); component.sizeDelta = new Vector2(20f, 20f); GameObject val4 = new GameObject("Checkmark"); val4.transform.SetParent(val.transform, false); Image val5 = val4.AddComponent<Image>(); ((Graphic)val5).color = Color.black; RectTransform component2 = val4.GetComponent<RectTransform>(); component2.anchorMin = new Vector2(0.2f, 0.2f); component2.anchorMax = new Vector2(0.8f, 0.8f); Vector2 offsetMin = (component2.offsetMax = Vector2.zero); component2.offsetMin = offsetMin; ToggleUtils.SetGraphic(val3, (Graphic)(object)val5); val3.isOn = boolValue; ToggleUtils.AddListener(val3, (Action<bool>)delegate(bool value) { if (value != boolValue) { onValueChanged(entryKey, value); _logger.Msg($"Modified preference {entryKey}: {value}"); } }); LayoutElement orAddComponent = val.GetOrAddComponent<LayoutElement>(); orAddComponent.minWidth = 20f; orAddComponent.minHeight = 20f; orAddComponent.preferredWidth = 20f; orAddComponent.preferredHeight = 20f; } } public class ColorInputHandler : IPreferenceInputHandler { private readonly UITheme _theme; private readonly Instance _logger; public static GameObject ColorPickerCanvas; public ColorInputHandler(UITheme theme, Instance logger) { _theme = theme; _logger = logger; } public bool CanHandle(Type valueType) { return valueType == typeof(Color); } public void CreateInput(MelonPreferences_Entry entry, GameObject parent, string entryKey, object currentValue, Action<string, object> onValueChanged) { //IL_0031: 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_002e: Unknown result type (might be due to invalid IL or missing references) //IL_0039: 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) //IL_0054: Expected O, but got Unknown //IL_007a: Unknown result type (might be due to invalid IL or missing references) //IL_0038: Unknown result type (might be due to invalid IL or missing references) Color colorValue = ((currentValue is Color val) ? val : Color.white); GameObject val2 = new GameObject(entryKey + "_ColorButton"); val2.transform.SetParent(parent.transform, false); Image buttonImage = val2.AddComponent<Image>(); ((Graphic)buttonImage).color = colorValue; Button val3 = val2.AddComponent<Button>(); EventHelper.AddListener((Action)delegate { //IL_0008: Unknown result type (might be due to invalid IL or missing references) ShowColorPickerWheel(colorValue, delegate(Color newColor) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0003: Unknown result type (might be due to invalid IL or missing references) //IL_0014: Unknown result type (might be due to invalid IL or missing references) //IL_0015: Unknown result type (might be due to invalid IL or missing references) //IL_0021: Unknown result type (might be due to invalid IL or missing references) //IL_0039: Unknown result type (might be due to invalid IL or missing references) //IL_0065: Unknown result type (might be due to invalid IL or missing references) if (!(newColor == colorValue)) { colorValue = newColor; ((Graphic)buttonImage).color = colorValue; onValueChanged(entryKey, colorValue); _logger.Msg("Modified preference " + entryKey + ": " + ColorUtility.ToHtmlStringRGBA(colorValue)); } }); }, (UnityEvent)(object)val3.onClick); LayoutElement val4 = val2.AddComponent<LayoutElement>(); val4.minWidth = 50f; val4.minHeight = 20f; val2.AddComponent<RectTransform>(); } private void ShowColorPickerWheel(Color initialColor, Action<Color> onColorSelected) { //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_0008: Unknown result type (might be due to invalid IL or missing references) //IL_001a: Unknown result type (might be due to invalid IL or missing references) //IL_0024: Expected O, but got Unknown //IL_0052: Unknown result type (might be due to invalid IL or missing references) //IL_0058: Expected O, but got Unknown //IL_0081: 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_00a7: Unknown result type (might be due to invalid IL or missing references) //IL_00b0: Unknown result type (might be due to invalid IL or missing references) //IL_00d9: Unknown result type (might be due to invalid IL or missing references) //IL_00e9: Unknown result type (might be due to invalid IL or missing references) //IL_00f0: Expected O, but got Unknown //IL_0119: Unknown result type (might be due to invalid IL or missing references) //IL_0130: Unknown result type (might be due to invalid IL or missing references) //IL_014f: Unknown result type (might be due to invalid IL or missing references) //IL_01a0: 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) //IL_01d2: Unknown result type (might be due to invalid IL or missing references) //IL_0208: Unknown result type (might be due to invalid IL or missing references) //IL_0217: Unknown result type (might be due to invalid IL or missing references) ColorPickerCanvas = new GameObject("ColorPickerCanvas"); Canvas val = ColorPickerCanvas.AddComponent<Canvas>(); val.renderMode = (RenderMode)0; ColorPickerCanvas.AddComponent<CanvasScaler>(); ColorPickerCanvas.AddComponent<GraphicRaycaster>(); GameObject val2 = new GameObject("ColorPickerPanel"); val2.transform.SetParent(ColorPickerCanvas.transform, false); RectTransform val3 = val2.AddComponent<RectTransform>(); val3.sizeDelta = new Vector2(350f, 450f); Vector2 val4 = default(Vector2); ((Vector2)(ref val4))..ctor(0.5f, 0.5f); val3.anchorMax = val4; val3.anchorMin = val4; val3.anchoredPosition = Vector2.zero; Image val5 = val2.AddComponent<Image>(); ((Graphic)val5).color = new Color(0.1f, 0.1f, 0.1f, 0.95f); GameObject val6 = new GameObject("Preview"); val6.transform.SetParent(val2.transform, false); RectTransform val7 = val6.AddComponent<RectTransform>(); val7.sizeDelta = new Vector2(100f, 50f); val7.anchoredPosition = new Vector2(0f, 180f); Image previewImage = val6.AddComponent<Image>(); ((Graphic)previewImage).color = initialColor; Controls.IsTyping = true; CreateColorWheel(val2.transform, 200f, delegate(Color color) { //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_0018: 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_003b: Unknown result type (might be due to invalid IL or missing references) initialColor.r = color.r; initialColor.g = color.g; initialColor.b = color.b; ((Graphic)previewImage).color = initialColor; }); CreateSlider(val2.transform, "A", initialColor.a, new Vector2(0f, -130f), delegate(float value) { //IL_0014: Unknown result type (might be due to invalid IL or missing references) initialColor.a = value; ((Graphic)previewImage).color = initialColor; }); CreateButton(val2.transform, "Cancel", Color.red, new Vector2(-100f, -180f), delegate { Object.Destroy((Object)(object)ColorPickerCanvas); Controls.IsTyping = false; }); CreateButton(val2.transform, "Apply", Color.green, new Vector2(100f, -180f), delegate { //IL_0008: Unknown result type (might be due to invalid IL or missing references) onColorSelected(initialColor); Object.Destroy((Object)(object)ColorPickerCanvas); Controls.IsTyping = false; }); } private void CreateColorWheel(Transform parent, float size, Action<Color> onColorChanged) { //IL_001a: Unknown result type (might be due to invalid IL or missing references) //IL_0020: Expected O, but got Unknown //IL_004c: 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_0082: Expected O, but got Unknown //IL_00aa: Unknown result type (might be due to invalid IL or missing references) //IL_00d7: Unknown result type (might be due to invalid IL or missing references) //IL_00e7: Unknown result type (might be due to invalid IL or missing references) //IL_00ee: Expected O, but got Unknown //IL_011d: Unknown result type (might be due to invalid IL or missing references) //IL_0141: Unknown result type (might be due to invalid IL or missing references) //IL_015d: Unknown result type (might be due to invalid IL or missing references) GameObject val = new GameObject("ColorWheel"); val.transform.SetParent(parent, false); RectTransform wheelRT = val.AddComponent<RectTransform>(); wheelRT.sizeDelta = new Vector2(size, size); RawImage val2 = val.AddComponent<RawImage>(); val2.texture = (Texture)(object)GenerateColorWheelTexture((int)size); GameObject knobGO = new GameObject("Knob"); knobGO.transform.SetParent(val.transform, false); Image val3 = knobGO.AddComponent<Image>(); val3.sprite = GenerateCircleSprite(16, Color.white); val3.type = (Type)0; knobGO.GetComponent<RectTransform>().sizeDelta = new Vector2(16f, 16f); GameObject val4 = new GameObject("Fill"); val4.transform.SetParent(knobGO.transform, false); Image knobFill = val4.AddComponent<Image>(); knobFill.sprite = GenerateCircleSprite(10, Color.white); knobFill.type = (Type)0; val4.GetComponent<RectTransform>().anchoredPosition = Vector2.zero; val4.GetComponent<RectTransform>().sizeDelta = new Vector2(10f, 10f); EventTrigger val5 = val.AddComponent<EventTrigger>(); EventHelper.AddEventTrigger(val5, (EventTriggerType)2, (Action<BaseEventData>)delegate(BaseEventData e) { //IL_0020: Unknown result type (might be due to invalid IL or missing references) //IL_0025: 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_002b: Unknown result type (might be due to invalid IL or missing references) //IL_003b: Expected O, but got Unknown PointerEventData val10 = (PointerEventData)(object)((e is PointerEventData) ? e : null); if (val10 != null) { HandleEvent(val10); } else { HandleEvent(new PointerEventData(EventSystem.current) { position = Vector2.op_Implicit(Input.mousePosition) }); } }); EventHelper.AddEventTrigger(val5, (EventTriggerType)5, (Action<BaseEventData>)delegate(BaseEventData e) { //IL_0020: Unknown result type (might be due to invalid IL or missing references) //IL_0025: 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_002b: Unknown result type (might be due to invalid IL or missing references) //IL_003b: Expected O, but got Unknown PointerEventData val9 = (PointerEventData)(object)((e is PointerEventData) ? e : null); if (val9 != null) { HandleEvent(val9); } else { HandleEvent(new PointerEventData(EventSystem.current) { position = Vector2.op_Implicit(Input.mousePosition) }); } }); void HandleEvent(PointerEventData eventData) { //IL_0002: 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) //IL_000e: Unknown result type (might be due to invalid IL or missing references) //IL_0032: Unknown result type (might be due to invalid IL or missing references) //IL_0034: Unknown result type (might be due to invalid IL or missing references) //IL_0039: 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_0050: Unknown result type (might be due to invalid IL or missing references) //IL_0055: Unknown result type (might be due to invalid IL or missing references) //IL_00a4: Unknown result type (might be due to invalid IL or missing references) //IL_00a9: Unknown result type (might be due to invalid IL or missing references) //IL_00b7: Unknown result type (might be due to invalid IL or missing references) //IL_00ca: Unknown result type (might be due to invalid IL or missing references) //IL_00cc: Unknown result type (might be due to invalid IL or missing references) //IL_00dd: Unknown result type (might be due to invalid IL or missing references) Vector2 position = eventData.position; Vector2 val6 = default(Vector2); if (RectTransformUtility.ScreenPointToLocalPointInRectangle(wheelRT, position, (Camera)null, ref val6)) { float num = size / 2f; Vector2 val7 = val6 / num; if (((Vector2)(ref val7)).magnitude > 1f) { val7 = ((Vector2)(ref val7)).normalized; } float num2 = Mathf.Atan2(val7.y, val7.x) / (MathF.PI * 2f); if (num2 < 0f) { num2 += 1f; } float num3 = Mathf.Min(((Vector2)(ref val7)).magnitude, 1f); Color val8 = Color.HSVToRGB(num2, num3, 1f); onColorChanged?.Invoke(val8); knobGO.GetComponent<RectTransform>().anchoredPosition = val7 * num; ((Graphic)knobFill).color = val8; } } } private Texture2D GenerateColorWheelTexture(int size) { //IL_0003: Unknown result type (might be due to invalid IL or missing references) //IL_0009: Expected O, but got Unknown //IL_0038: 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_003e: 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_0071: 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_0064: Unknown result type (might be due to invalid IL or missing references) //IL_00b6: Unknown result type (might be due to invalid IL or missing references) Texture2D val = new Texture2D(size, size); ((Texture)val).wrapMode = (TextureWrapMode)1; float num = (float)size / 2f; Vector2 val2 = default(Vector2); ((Vector2)(ref val2))..ctor(num, num); for (int i = 0; i < size; i++) { for (int j = 0; j < size; j++) { Vector2 val3 = new Vector2((float)j, (float)i) - val2; float num2 = ((Vector2)(ref val3)).magnitude / num; if (num2 > 1f) { val.SetPixel(j, i, Color.clear); continue; } float num3 = Mathf.Atan2(val3.y, val3.x) / (MathF.PI * 2f); if (num3 < 0f) { num3 += 1f; } float num4 = num2; val.SetPixel(j, i, Color.HSVToRGB(num3, num4, 1f)); } } val.Apply(); return val; } private Sprite GenerateCircleSprite(int size, Color color) { //IL_0005: Unknown result type (might be due to invalid IL or missing references) //IL_000b: Expected O, but got Unknown //IL_008e: Unknown result type (might be due to invalid IL or missing references) //IL_009d: Unknown result type (might be due to invalid IL or missing references) //IL_0034: Unknown result type (might be due to invalid IL or missing references) //IL_0039: 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_004a: Unknown result type (might be due to invalid IL or missing references) Texture2D val = new Texture2D(size, size, (TextureFormat)4, false); ((Texture)val).filterMode = (FilterMode)1; float num = (float)size / 2f; Vector2 val2 = default(Vector2); ((Vector2)(ref val2))..ctor(num, num); for (int i = 0; i < size; i++) { for (int j = 0; j < size; j++) { float num2 = Vector2.Distance(new Vector2((float)j, (float)i), val2); val.SetPixel(j, i, (num2 <= num) ? color : Color.clear); } } val.Apply(); return Sprite.Create(val, new Rect(0f, 0f, (float)size, (float)size), new Vector2(0.5f, 0.5f)); } private void CreateSlider(Transform parent, string label, float initialValue, Vector2 anchoredPosition, Action<float> onChanged) { //IL_001a: Unknown result type (might be due to invalid IL or missing references) //IL_0020: Expected O, but got Unknown //IL_0040: Unknown result type (might be due to invalid IL or missing references) //IL_004c: Unknown result type (might be due to invalid IL or missing references) //IL_0098: Unknown result type (might be due to invalid IL or missing references) //IL_009f: Expected O, but got Unknown //IL_00d2: 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_00f5: 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_010f: Unknown result type (might be due to invalid IL or missing references) //IL_0128: Unknown result type (might be due to invalid IL or missing references) //IL_012f: Expected O, but got Unknown //IL_014e: 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_0172: 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_0199: Unknown result type (might be due to invalid IL or missing references) //IL_01a0: Expected O, but got Unknown //IL_01c0: Unknown result type (might be due to invalid IL or missing references) //IL_01e4: Unknown result type (might be due to invalid IL or missing references) //IL_01f1: Unknown result type (might be due to invalid IL or missing references) //IL_01fe: Unknown result type (might be due to invalid IL or missing references) //IL_020b: Unknown result type (might be due to invalid IL or missing references) //IL_021b: Unknown result type (might be due to invalid IL or missing references) //IL_0222: Expected O, but got Unknown //IL_0241: Unknown result type (might be due to invalid IL or missing references) //IL_0273: Unknown result type (might be due to invalid IL or missing references) //IL_0289: Unknown result type (might be due to invalid IL or missing references) //IL_0290: Expected O, but got Unknown //IL_02b9: Unknown result type (might be due to invalid IL or missing references) //IL_02d0: Unknown result type (might be due to invalid IL or missing references) //IL_0301: Unknown result type (might be due to invalid IL or missing references) GameObject val = new GameObject(label + "Slider"); val.transform.SetParent(parent, false); RectTransform val2 = val.AddComponent<RectTransform>(); val2.sizeDelta = new Vector2(200f, 20f); val2.anchoredPosition = anchoredPosition; Slider val3 = val.AddComponent<Slider>(); val3.minValue = 0f; val3.maxValue = 1f; val3.value = initialValue; EventHelper.AddListener<float>((Action<float>)delegate(float v) { onChanged(v); }, (UnityEvent<float>)(object)val3.onValueChanged); GameObject val4 = new GameObject("Background"); val4.transform.SetParent(val.transform, false); Image val5 = val4.AddComponent<Image>(); ((Graphic)val5).color = new Color(0.3f, 0.3f, 0.3f, 1f); RectTransform component = val4.GetComponent<RectTransform>(); component.anchorMin = Vector2.zero; component.anchorMax = Vector2.one; component.offsetMin = Vector2.zero; component.offsetMax = Vector2.zero; ((Selectable)val3).targetGraphic = (Graphic)(object)val5; GameObject val6 = new GameObject("Fill Area"); val6.transform.SetParent(val.transform, false); RectTransform val7 = val6.AddComponent<RectTransform>(); val7.anchorMin = Vector2.zero; val7.anchorMax = Vector2.one; val7.offsetMin = new Vector2(5f, 0f); val7.offsetMax = new Vector2(-5f, 0f); GameObject val8 = new GameObject("Fill"); val8.transform.SetParent(val6.transform, false); Image val9 = val8.AddComponent<Image>(); ((Graphic)val9).color = Color.green; val3.fillRect = ((Component)val9).GetComponent<RectTransform>(); RectTransform component2 = val8.GetComponent<RectTransform>(); component2.anchorMin = Vector2.zero; component2.anchorMax = Vector2.one; component2.offsetMin = Vector2.zero; component2.offsetMax = Vector2.zero; GameObject val10 = new GameObject("Handle"); val10.transform.SetParent(val.transform, false); Image val11 = val10.AddComponent<Image>(); ((Graphic)val11).color = Color.white; val3.handleRect = ((Component)val11).GetComponent<RectTransform>(); val3.direction = (Direction)0; val10.GetComponent<RectTransform>().sizeDelta = new Vector2(20f, 20f); GameObject val12 = new GameObject(label + "Label"); val12.transform.SetParent(val.transform, false); RectTransform val13 = val12.AddComponent<RectTransform>(); val13.sizeDelta = new Vector2(40f, 20f); val13.anchoredPosition = new Vector2(-120f, 0f); Text val14 = val12.AddComponent<Text>(); val14.text = label; val14.font = Resources.GetBuiltinResource<Font>("Arial.ttf"); ((Graphic)val14).color = Color.white; val14.alignment = (TextAnchor)3; val14.fontSize = 14; } private void CreateButton(Transform parent, string label, Color color, Vector2 anchoredPosition, Action onClick) { //IL_001a: Unknown result type (might be due to invalid IL or missing references) //IL_0020: Expected O, but got Unknown //IL_0040: Unknown result type (might be due to invalid IL or missing references) //IL_004c: 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_0089: Unknown result type (might be due to invalid IL or missing references) //IL_0090: Expected O, but got Unknown //IL_00af: Unknown result type (might be due to invalid IL or missing references) //IL_00bc: Unknown result type (might be due to invalid IL or missing references) //IL_00c9: Unknown result type (might be due to invalid IL or missing references) //IL_00d6: Unknown result type (might be due to invalid IL or missing references) //IL_0107: Unknown result type (might be due to invalid IL or missing references) GameObject val = new GameObject(label + "Button"); val.transform.SetParent(parent, false); RectTransform val2 = val.AddComponent<RectTransform>(); val2.sizeDelta = new Vector2(80f, 30f); val2.anchoredPosition = anchoredPosition; Image val3 = val.AddComponent<Image>(); ((Graphic)val3).color = color; Button val4 = val.AddComponent<Button>(); EventHelper.AddListener((Action)delegate { onClick(); }, (UnityEvent)(object)val4.onClick); GameObject val5 = new GameObject("Text"); val5.transform.SetParent(val.transform, false); RectTransform val6 = val5.AddComponent<RectTransform>(); val6.anchorMin = Vector2.zero; val6.anchorMax = Vector2.one; val6.offsetMin = Vector2.zero; val6.offsetMax = Vector2.zero; Text val7 = val5.AddComponent<Text>(); val7.text = label; val7.font = Resources.GetBuiltinResource<Font>("Arial.ttf"); ((Graphic)val7).color = Color.black; val7.alignment = (TextAnchor)4; val7.fontSize = 14; } } public class EnumInputHandler : IPreferenceInputHandler { private readonly UITheme _theme; private readonly Instance _logger; public EnumInputHandler(UITheme theme, Instance logger) { _theme = theme; _logger = logger; } public bool CanHandle(Type valueType) { return valueType.IsEnum; } public void CreateInput(MelonPreferences_Entry entry, GameObject parent, string entryKey, object currentValue, Action<string, object> onValueChanged) { //IL_0077: 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) Type enumType = currentValue.GetType(); object[] enumValues = Enum.GetValues(enumType).Cast<object>().ToArray(); DropdownInputComponent<object> dropdownInputComponent = DropdownFactory.CreateDropdownInput(parent, entryKey, currentValue, (object val) => val.ToString(), new Vector2(150f, 20f), 120, new Vector2(150f, 110f), 6, _logger); dropdownInputComponent.OnFilterItems += (string filter) => enumValues; dropdownInputComponent.OnValidateInput += delegate(string input) { if (TryParseEnum(enumType, input, out var result)) { return result; } if (!string.IsNullOrEmpty(input)) { object obj = enumValues.FirstOrDefault((object e) => e.ToString().StartsWith(input, StringComparison.OrdinalIgnoreCase)); if (obj != null) { return obj; } } return null; }; dropdownInputComponent.OnValueChanged += delegate(object selectedValue) { onValueChanged(entryKey, selectedValue); }; MelonDebug.Msg($"[{entryKey}] Enum input created with {enumValues.Length} options"); } private bool TryParseEnum(Type enumType, string value, out object result) { try { result = Enum.Parse(enumType, value, ignoreCase: true); return true; } catch { result = null; return false; } } } public class FallbackInputHandler : IPreferenceInputHandler { private readonly UITheme _theme; private readonly Instance _logger; private readonly TomlParser _parser = new TomlParser(); public FallbackInputHandler(UITheme theme, Instance logger) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_000b: Expected O, but got Unknown _theme = theme; _logger = logger; } public bool CanHandle(Type valueType) { return true; } public void CreateInput(MelonPreferences_Entry entry, GameObject parent, string entryKey, object currentValue, Action<string, object> onValueChanged) { //IL_0085: Unknown result type (might be due to invalid IL or missing references) string text = NormalizeValue(entry.GetReflectedType(), currentValue); InputField input = InputFieldFactory.CreateInputField(parent, entryKey + "_Input", text, (ContentType)0, 100); Text val = UIFactory.Text(entryKey + "_Label", "(Fallback, might not work properly)", parent.transform, 10, (TextAnchor)0, (FontStyle)0); ((Graphic)val).color = _theme.TextSecondary; val.fontStyle = (FontStyle)2; string lastValid = text; EventHelper.AddListener<string>((Action<string>)delegate(string raw) { if (raw == lastValid) { return; } try { string text2 = "Temp = " + raw; TomlDocument val2 = _parser.Parse(text2); TomlValue value = ((TomlTable)val2).GetValue("Temp"); object obj = TomletMain.To(entry.GetReflectedType(), value, (TomlSerializerOptions)null); onValueChanged(entryKey, obj); lastValid = NormalizeValue(entry.GetReflectedType(), obj); input.text = lastValid; _logger.Msg($"Modified preference {entryKey}: {obj}"); } catch (Exception arg) { _logger.Error($"Failed to parse edited value for {entryKey}: {arg}"); input.text = lastValid; } }, (UnityEvent<string>)(object)input.onEndEdit); } private string NormalizeValue(Type targetType, object value) { if (value == null) { return "null"; } try { TomlValue val = ((value is string text) ? TomletMain.ValueFrom<object>(TomletMain.To(targetType, ((TomlTable)_parser.Parse("Temp = " + text)).GetValue("Temp"), (TomlSerializerOptions)null), (TomlSerializerOptions)null) : TomletMain.ValueFrom<object>(value, (TomlSerializerOptions)null)); return val.SerializedValue; } catch { return value.ToString(); } } } public interface IPreferenceInputHandler { bool CanHandle(Type valueType); void CreateInput(MelonPreferences_Entry entry, GameObject parent, string entryKey, object currentValue, Action<string, object> onValueChanged); } public class KeyCodeInputHandler : IPreferenceInputHandler { private readonly UITheme _theme; private readonly Instance _logger; private static KeyCodeRebindManager _rebindManager; public KeyCodeInputHandler(UITheme theme, Instance logger) { _theme = theme; _logger = logger; if (_rebindManager == null) { _rebindManager = new KeyCodeRebindManager(); } } public bool CanHandle(Type valueType) { return valueType == typeof(KeyCode); } public void CreateInput(MelonPreferences_Entry entry, GameObject parent, string entryKey, object currentValue, Action<string, object> onValueChanged) { //IL_0018: Unknown result type (might be due to invalid IL or missing references) //IL_001d: Unknown result type (might be due to invalid IL or missing references) //IL_0025: Unknown result type (might be due to invalid IL or missing references) KeyCode initialValue = (KeyCode)currentValue; KeyCodeRebindInput keyCodeRebindInput = new KeyCodeRebindInput(parent, entryKey, initialValue, _theme, _logger, _rebindManager); keyCodeRebindInput.OnValueChanged += delegate(KeyCode newKeyCode) { //IL_000d: Unknown result type (might be due to invalid IL or missing references) onValueChanged(entryKey, newKeyCode); }; MelonDebug.Msg("[" + entryKey + "] KeyCode rebind input created"); } } public class KeyCodeRebindInput { private readonly GameObject _container; private readonly Text _labelText; private readonly Button _rebindButton; private readonly Button _confirmButton; private readonly Button _cancelButton; private readonly UITheme _theme; private readonly Instance _logger; private readonly KeyCodeRebindManager _rebindManager; private KeyCode _currentValue; private KeyCode? _pendingValue; private bool _isRebinding; public event Action<KeyCode> OnValueChanged; public KeyCodeRebindInput(GameObject parent, string entryKey, KeyCode initialValue, UITheme theme, Instance logger, KeyCodeRebindManager rebindManager) { //IL_0009: 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) //IL_0033: Unknown result type (might be due to invalid IL or missing references) //IL_003d: Expected O, but got Unknown //IL_00b6: Unknown result type (might be due to invalid IL or missing references) //IL_00bc: Expected O, but got Unknown //IL_010c: Unknown result type (might be due to invalid IL or missing references) //IL_0178: Unknown result type (might be due to invalid IL or missing references) //IL_01c4: Unknown result type (might be due to invalid IL or missing references) //IL_0222: Unknown result type (might be due to invalid IL or missing references) _currentValue = initialValue; _theme = theme; _logger = logger; _rebindManager = rebindManager; _container = new GameObject("KeyCodeRebind_" + entryKey); _container.transform.SetParent(parent.transform, false); HorizontalLayoutGroup val = _container.AddComponent<HorizontalLayoutGroup>(); ((HorizontalOrVerticalLayoutGroup)val).spacing = 5f; ((HorizontalOrVerticalLayoutGroup)val).childControlWidth = false; ((HorizontalOrVerticalLayoutGroup)val).childControlHeight = true; ((HorizontalOrVerticalLayoutGroup)val).childForceExpandWidth = false; ((HorizontalOrVerticalLayoutGroup)val).childForceExpandHeight = false; LayoutElement val2 = _container.AddComponent<LayoutElement>(); val2.minHeight = 25f; val2.preferredHeight = 25f; GameObject val3 = new GameObject("Label"); val3.transform.SetParent(_container.transform, false); _labelText = val3.AddComponent<Text>(); _labelText.font = Resources.GetBuiltinResource<Font>("Arial.ttf"); _labelText.fontSize = 12; ((Graphic)_labelText).color = theme.TextPrimary; _labelText.text = ((object)(KeyCode)(ref _currentValue)).ToString(); _labelText.alignment = (TextAnchor)3; LayoutElement val4 = val3.AddComponent<LayoutElement>(); val4.minWidth = 120f; val4.preferredWidth = 120f; val4.minHeight = 25f; _rebindButton = CreateButton("RebindButton", "Rebind", Color.gray, 80f); EventHelper.AddListener((Action)delegate { BeginRebind(); }, (UnityEvent)(object)_rebindButton.onClick); _confirmButton = CreateButton("ConfirmButton", "Confirm", new Color(0.1f, 0.4f, 0.1f), 80f); EventHelper.AddListener((Action)delegate { ConfirmRebind(); }, (UnityEvent)(object)_confirmButton.onClick); ((Component)_confirmButton).gameObject.SetActive(false); _cancelButton = CreateButton("CancelButton", "Cancel", new Color(0.4f, 0.1f, 0.1f), 80f); EventHelper.AddListener((Action)CancelRebind, (UnityEvent)(object)_cancelButton.onClick); ((Component)_cancelButton).gameObject.SetActive(false); } private Button CreateButton(string name, string text, Color color, float width) { //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_0008: Expected O, but got Unknown //IL_0028: 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_0044: Unknown result type (might be due to invalid IL or missing references) //IL_0047: Unknown result type (might be due to invalid IL or missing references) //IL_0050: 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_0068: Unknown result type (might be due to invalid IL or missing references) //IL_0074: Unknown result type (might be due to invalid IL or missing references) //IL_0081: Unknown result type (might be due to invalid IL or missing references) //IL_008d: Unknown result type (might be due to invalid IL or missing references) //IL_0099: 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_00c1: Unknown result type (might be due to invalid IL or missing references) //IL_00cd: 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_0109: Expected O, but got Unknown //IL_014a: Unknown result type (might be due to invalid IL or missing references) //IL_0172: Unknown result type (might be due to invalid IL or missing references) //IL_017f: Unknown result type (might be due to invalid IL or missing references) //IL_018c: Unknown result type (might be due to invalid IL or missing references) //IL_0199: Unknown result type (might be due to invalid IL or missing references) GameObject val = new GameObject(name); val.transform.SetParent(_container.transform, false); Image val2 = val.AddComponent<Image>(); ((Graphic)val2).color = color; Button val3 = val.AddComponent<Button>(); ((Selectable)val3).targetGraphic = (Graphic)(object)val2; ColorBlock colors = ((Selectable)val3).colors; ((ColorBlock)(ref colors)).normalColor = color; ((ColorBlock)(ref colors)).highlightedColor = new Color(color.r * 1.2f, color.g * 1.2f, color.b * 1.2f); ((ColorBlock)(ref colors)).pressedColor = new Color(color.r * 0.8f, color.g * 0.8f, color.b * 0.8f); ((ColorBlock)(ref colors)).disabledColor = new Color(0.3f, 0.3f, 0.3f); ((Selectable)val3).colors = colors; LayoutElement val4 = val.AddComponent<LayoutElement>(); val4.minWidth = width; val4.preferredWidth = width; val4.minHeight = 25f; GameObject val5 = new GameObject("Text"); val5.transform.SetParent(val.transform, false); Text val6 = val5.AddComponent<Text>(); val6.font = Resources.GetBuiltinResource<Font>("Arial.ttf"); val6.fontSize = 11; ((Graphic)val6).color = _theme.TextPrimary; val6.text = text; val6.alignment = (TextAnchor)4; RectTransform component = val5.GetComponent<RectTransform>(); component.anchorMin = Vector2.zero; component.anchorMax = Vector2.one; component.sizeDelta = Vector2.zero; component.anchoredPosition = Vector2.zero; return val3; } private void BeginRebind() { if (!_isRebinding) { _isRebinding = true; _pendingValue = null; Controls.IsTyping = true; ((Component)_rebindButton).gameObject.SetActive(false); ((Component)_confirmButton).gameObject.SetActive(true); ((Selectable)_confirmButton).interactable = false; ((Component)_cancelButton).gameObject.SetActive(true); _labelText.text = "<i>Press a key...</i>"; _rebindManager.StartRebind(OnKeyPressed); MelonDebug.Msg("Started key rebind"); } } private void OnKeyPressed(KeyCode keyCode) { //IL_0011: Unknown result type (might be due to invalid IL or missing references) //IL_0027: Unknown result type (might be due to invalid IL or missing references) //IL_004a: Unknown result type (might be due to invalid IL or missing references) if (_isRebinding) { _pendingValue = keyCode; _labelText.text = $"<i>{keyCode}</i>"; ((Selectable)_confirmButton).interactable = true; MelonDebug.Msg($"Key pressed: {keyCode}"); } } private void ConfirmRebind() { //IL_0027: Unknown result type (might be due to invalid IL or missing references) //IL_002c: Unknown result type (might be due to invalid IL or missing references) //IL_003e: Unknown result type (might be due to invalid IL or missing references) //IL_005d: Unknown result type (might be due to invalid IL or missing references) if (_isRebinding && _pendingValue.HasValue) { _currentValue = _pendingValue.Value; this.OnValueChanged?.Invoke(_currentValue); EndRebind(); RefreshDisplay(); MelonDebug.Msg($"Key rebind confirmed: {_currentValue}"); } } private void CancelRebind() { if (_isRebinding) { EndRebind(); RefreshDisplay(); MelonDebug.Msg("Key rebind cancelled"); } } private void EndRebind() { _isRebinding = false; _pendingValue = null; _rebindManager.StopRebind(); Controls.IsTyping = false; ((Component)_rebindButton).gameObject.SetActive(true); ((Component)_confirmButton).gameObject.SetActive(false); ((Component)_cancelButton).gameObject.SetActive(false); } private void RefreshDisplay() { _labelText.text = ((object)(KeyCode)(ref _currentValue)).ToString(); } } public class KeyCodeRebindManager { [CompilerGenerated] private sealed class <InputCheckCoroutine>d__6 : IEnumerator<object>, IEnumerator, IDisposable { private int <>1__state; private object <>2__current; public KeyCodeRebindManager <>4__this; private IEnumerator <>s__1; private KeyCode <keyCode>5__2; object IEnumerator<object>.Current { [DebuggerHidden] get { return <>2__current; } } object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } [DebuggerHidden] public <InputCheckCoroutine>d__6(int <>1__state) { this.<>1__state = <>1__state; } [DebuggerHidden] void IDisposable.Dispose() { <>s__1 = null; <>1__state = -2; } private bool MoveNext() { //IL_0052: Unknown result type (might be due to invalid IL or missing references) //IL_0057: Unknown result type (might be due to invalid IL or missing references) //IL_0063: Unknown result type (might be due to invalid IL or missing references) //IL_0074: Unknown result type (might be due to invalid IL or missing references) //IL_0095: Unknown result type (might be due to invalid IL or missing references) switch (<>1__state) { default: return false; case 0: <>1__state = -1; break; case 1: <>1__state = -1; break; } if (<>4__this._isListening) { <>s__1 = Enum.GetValues(typeof(KeyCode)).GetEnumerator(); try { while (<>s__1.MoveNext()) { <keyCode>5__2 = (KeyCode)<>s__1.Current; if (_ignoredKeys.Contains(<keyCode>5__2) || !Input.GetKeyDown(<keyCode>5__2)) { continue; } <>4__this._onKeyPressed?.Invoke(<keyCode>5__2); return false; } } finally { if (<>s__1 is IDisposable disposable) { disposable.Dispose(); } } <>s__1 = null; <>2__current = null; <>1__state = 1; return true; } return false; } bool IEnumerator.MoveNext() { //ILSpy generated this explicit interface implementation from .override directive in MoveNext return this.MoveNext(); } [DebuggerHidden] void IEnumerator.Reset() { throw new NotSupportedException(); } } private Action<KeyCode> _onKeyPressed; private bool _isListening; private object _inputCheckCoroutine; private static readonly KeyCode[] _ignoredKeys; public void StartRebind(Action<KeyCode> onKeyPressed) { if (!_isListening) { _onKeyPressed = onKeyPressed; _isListening = true; _inputCheckCoroutine = MelonCoroutines.Start(InputCheckCoroutine()); } } public void StopRebind() { _isListening = false; _onKeyPressed = null; if (_inputCheckCoroutine != null) { MelonCoroutines.Stop(_inputCheckCoroutine); _inputCheckCoroutine = null; } } [IteratorStateMachine(typeof(<InputCheckCoroutine>d__6))] private IEnumerator InputCheckCoroutine() { //yield-return decompiler failed: Unexpected instruction in Iterator.Dispose() return new <InputCheckCoroutine>d__6(0) { <>4__this = this }; } static KeyCodeRebindManager() { KeyCode[] array = new KeyCode[8]; RuntimeHelpers.InitializeArray(array, (RuntimeFieldHandle)/*OpCode not supported: LdMemberToken*/); _ignoredKeys = (KeyCode[])(object)array; } } public class NumericInputHandler : IPreferenceInputHandler { private readonly UITheme _theme; private readonly Instance _logger; private static readonly HashSet<Type> SupportedTypes = new HashSet<Type> { typeof(byte), typeof(sbyte), typeof(short), typeof(ushort), typeof(int), typeof(uint), typeof(long), typeof(ulong), typeof(float), typeof(double), typeof(decimal) }; public NumericInputHandler(UITheme theme, Instance logger) { _theme = theme; _logger = logger; } public bool CanHandle(Type valueType) { return SupportedTypes.Contains(valueType); } public void CreateInput(MelonPreferences_Entry entry, GameObject parent, string entryKey, object currentValue, Action<string, object> onValueChanged) { //IL_007b: 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) Type type = currentValue.GetType(); string stringValue = Convert.ToString(currentValue, CultureInfo.InvariantCulture); Func<string, bool> validator = delegate(string value) { try { object obj3 = Convert.ChangeType(value, type, CultureInfo.InvariantCulture); ValueValidator validator2 = entry.Validator; return validator2 == null || validator2.IsValid(obj3); } catch { return false; } }; ContentType contentType = (ContentType)((type == typeof(int)) ? 2 : 3); InputField input = InputFieldFactory.CreateInputField(parent, entryKey + "_Input", stringValue, contentType, 60, validator); EventHelper.AddListener<string>((Action<string>)delegate(string value) { try { object obj = Convert.ChangeType(value, type, CultureInfo.InvariantCulture); if (!obj.Equals(currentValue)) { onValueChanged(entryKey, obj); _logger.Msg($"Modified preference {entryKey}: {obj}"); } } catch { input.text = stringValue; } }, (UnityEvent<string>)(object)input.onEndEdit); } } public class StringInputHandler :