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.1.0
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; 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.PhoneApp; using S1API.UI; using S1API.Utils; 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.1.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+47e671133a784025ef8aafb56e86359ab1acf983")] [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.1.0"; } public class ModsApp : MelonMod { private static Instance Logger; public static Sprite AppIconSprite; public static MelonPreferences_Category AccessibilityCategory; public static MelonPreferences_Entry<TextSizeProfile> TextSizeProfileEntry; public override void OnInitializeMelon() { Logger = ((MelonBase)this).LoggerInstance; Logger.Msg("ModsApp initialized"); AppIconSprite = LoadEmbeddedPNG("ModsApp.assets.appicon.png"); AccessibilityCategory = MelonPreferences.CreateCategory("ModsApp_Accessibility", "Accessibility"); TextSizeProfileEntry = AccessibilityCategory.CreateEntry<TextSizeProfile>("ModsAppTextSize", TextSizeProfile.Normal, "Text Size Setting", "Text size preset", false, false, (ValueValidator)null, (string)null); } 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); private const int _sizeTiny = 10; private const int _sizeSmall = 12; private const int _sizeStandard = 14; private const int _sizeMedium = 16; private const int _sizeLarge = 20; private float _textScale = 1f; public int SizeTiny => Mathf.RoundToInt(10f * _textScale); public int SizeSmall => Mathf.RoundToInt(12f * _textScale); public int SizeStandard => Mathf.RoundToInt(14f * _textScale); public int SizeMedium => Mathf.RoundToInt(16f * _textScale); public int SizeLarge => Mathf.RoundToInt(20f * _textScale); public void SetTextScale(TextSizeProfile profile) { if (1 == 0) { } float textScale = profile switch { TextSizeProfile.ExtraSmall => 0.75f, TextSizeProfile.Small => 0.85f, TextSizeProfile.Normal => 1f, TextSizeProfile.Large => 1.25f, TextSizeProfile.ExtraLarge => 1.5f, _ => 1f, }; if (1 == 0) { } _textScale = textScale; } public UITheme() { //IL_0015: 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_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_0053: Unknown result type (might be due to invalid IL or missing references) //IL_0058: Unknown result type (might be due to invalid IL or missing references) //IL_0072: Unknown result type (might be due to invalid IL or missing references) //IL_0077: Unknown result type (might be due to invalid IL or missing references) //IL_0091: 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_00b0: Unknown result type (might be due to invalid IL or missing references) //IL_00b5: 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) //IL_00d4: Unknown result type (might be due to invalid IL or missing references) //IL_00ee: 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_010d: Unknown result type (might be due to invalid IL or missing references) //IL_0112: Unknown result type (might be due to invalid IL or missing references) SetTextScale(ModsApp.TextSizeProfileEntry.Value); } } } namespace ModsApp.UI { public enum TextSizeProfile { ExtraSmall, Small, Normal, Large, ExtraLarge } } 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_002b: Unknown result type (might be due to invalid IL or missing references) //IL_0060: Unknown result type (might be due to invalid IL or missing references) Text val = UIFactory.Text("JsonConfigHeader", "No MelonPreferences", card.transform, _theme.SizeMedium, (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, _theme.SizeSmall, (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_00a0: 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) //IL_02a9: Unknown result type (might be due to invalid IL or missing references) //IL_02c3: Unknown result type (might be due to invalid IL or missing references) //IL_0389: Unknown result type (might be due to invalid IL or missing references) //IL_0393: 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, _theme.SizeSmall, (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, _theme.SizeSmall, 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, _theme.SizeTiny, (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_0079: 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_00d8: 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, _theme.SizeSmall, (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 = _theme.SizeSmall; 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_00b6: 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_011f: Unknown result type (might be due to invalid IL or missing references) //IL_016f: Unknown result type (might be due to invalid IL or missing references) //IL_0189: Unknown result type (might be due to invalid IL or missing references) 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, _theme.SizeStandard, 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, _theme.SizeStandard, 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, _theme.SizeStandard, 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 const string UnassignedModName = "Unassigned"; 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; } if (mod == null) { ShowUnassignedDetails(); 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 void ShowUnassignedDetails() { //IL_005b: Unknown result type (might be due to invalid IL or missing references) //IL_009a: 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_01c4: Unknown result type (might be due to invalid IL or missing references) UIFactory.ClearChildren((Transform)(object)_detailsContent); _modifiedPreferences.Clear(); _jsonConfigUI.ResetState(); GameObject val = CreateInfoCard("UnassignedHeaderCard"); Text val2 = UIFactory.Text("UnassignedTitle", "Unassigned Preferences", val.transform, _theme.SizeLarge, (TextAnchor)3, (FontStyle)1); ((Graphic)val2).color = _theme.TextPrimary; _modifiedLabel = UIFactory.Text("ModifiedLabel", "", val.transform, _theme.SizeSmall, (TextAnchor)5, (FontStyle)2); ((Graphic)_modifiedLabel).color = _theme.WarningColor; if (_modifiedMods.Contains("Unassigned")) { _modifiedLabel.text = "Changes applied, restart may be required"; ((Component)_modifiedLabel).gameObject.SetActive(true); } else { ((Component)_modifiedLabel).gameObject.SetActive(false); } Text val3 = UIFactory.Text("UnassignedSubtitle", "Preferences that don't belong to any mod", val.transform, _theme.SizeStandard, (TextAnchor)0, (FontStyle)0); ((Graphic)val3).color = _theme.TextSecondary; List<MelonPreferences_Category> list = _modManager.GetUnassignedPreferences().ToList(); if (list.Count > 0) { GameObject card = CreateInfoCard("UnassignedPrefsCard"); RenderPreferences(list, card, "Unassigned"); GameObject val4 = CreateInfoCard("UnassignedActionsCard"); CreateActionButtons("Unassigned", val4.transform); } else { GameObject val5 = CreateInfoCard("NoUnassignedPrefsCard"); Text val6 = UIFactory.Text("NoUnassignedPrefs", "No unassigned preferences found", val5.transform, _theme.SizeSmall, (TextAnchor)0, (FontStyle)2); ((Graphic)val6).color = _theme.TextSecondary; } 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_002b: Unknown result type (might be due to invalid IL or missing references) //IL_0060: Unknown result type (might be due to invalid IL or missing references) Text val = UIFactory.Text("WelcomeTitle", "Mods Manager", card.transform, _theme.SizeLarge, (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, _theme.SizeStandard, (TextAnchor)0, (FontStyle)0); ((Graphic)val2).color = _theme.TextSecondary; } private void CreateStatsContent(GameObject card) { //IL_002b: Unknown result type (might be due to invalid IL or missing references) //IL_0075: Unknown result type (might be due to invalid IL or missing references) Text val = UIFactory.Text("StatsTitle", "Statistics", card.transform, _theme.SizeMedium, (TextAnchor)0, (FontStyle)1); ((Graphic)val).color = _theme.TextPrimary; Text val2 = UIFactory.Text("ModCount", $"Total Mods: {_modManager.ModCount}", card.transform, _theme.SizeStandard, (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_00b6: 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_00ef: Unknown result type (might be due to invalid IL or missing references) //IL_0116: Unknown result type (might be due to invalid IL or missing references) //IL_0169: Unknown result type (might be due to invalid IL or missing references) //IL_0170: Expected O, but got Unknown //IL_01e8: Unknown result type (might be due to invalid IL or missing references) //IL_0284: Unknown result type (might be due to invalid IL or missing references) //IL_02cb: 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, _theme.SizeLarge, (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, _theme.SizeSmall, 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, _theme.SizeSmall, (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, _theme.SizeStandard, (TextAnchor)0, (FontStyle)0); ((Graphic)val9).color = _theme.TextSecondary; Text val10 = UIFactory.Text("ModVersion", "v. " + ((MelonBase)mod).Info.Version, card.transform, _theme.SizeStandard, (TextAnchor)0, (FontStyle)0); ((Graphic)val10).color = _theme.TextSecondary; } private void RenderPreferences(List<MelonPreferences_Category> categories, GameObject card, string modName) { //IL_002b: 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, _theme.SizeMedium, (TextAnchor)0, (FontStyle)1); ((Graphic)val).color = _theme.TextPrimary; if (categories.Count == 0) { Text val2 = UIFactory.Text("NoPrefs", "No preferences available", card.transform, _theme.SizeSmall, (TextAnchor)0, (FontStyle)2); ((Graphic)val2).color = _theme.TextSecondary; return; } foreach (MelonPreferences_Category category in categories) { CreateCategorySection(category, card); } } private void CreatePreferencesSection(MelonMod mod, GameObject card) { //IL_002b: Unknown result type (might be due to invalid IL or missing references) //IL_0080: Unknown result type (might be due to invalid IL or missing references) Text val = UIFactory.Text("PrefsHeader", "Preferences", card.transform, _theme.SizeMedium, (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, _theme.SizeSmall, (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_018e: 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, _theme.SizeStandard, (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_018e: Unknown result type (might be due to invalid IL or missing references) //IL_020f: Unknown result type (might be due to invalid IL or missing references) //IL_02df: Unknown result type (might be due to invalid IL or missing references) //IL_02e9: Unknown result type (might be due to invalid IL or missing references) //IL_038b: Unknown result type (might be due to invalid IL or missing references) //IL_0395: 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, _theme.SizeStandard, (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, _theme.SizeSmall, (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, _theme.SizeSmall, (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, _theme.SizeTiny, (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) { CreateActionButtons(((MelonBase)mod).Info.Name, card.transform); } private void CreateActionButtons(string modName, Transform parent) { //IL_001b: Unknown result type (might be due to invalid IL or missing references) //IL_00ab: Unknown result type (might be due to invalid IL or missing references) //IL_00c5: Unknown result type (might be due to invalid IL or missing references) //IL_0115: Unknown result type (might be due to invalid IL or missing references) //IL_012f: Unknown result type (might be due to invalid IL or missing references) GameObject val = UIFactory.Panel("ButtonContainer", parent, 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, _theme.SizeStandard, Color.white); GameObject item = valueTuple.Item1; Button val3 = (_applyButton = valueTuple.Item2); EventHelper.AddListener((Action)delegate { ApplyPreferenceChanges(modName); }, (UnityEvent)(object)val3.onClick); ValueTuple<GameObject, Button, Text> valueTuple2 = UIFactory.RoundedButtonWithLabel("ResetButton", "Reset", val.transform, _theme.WarningColor, 80f, 30f, _theme.SizeStandard, Color.white); GameObject item2 = valueTuple2.Item1; Button val4 = (_resetButton = valueTuple2.Item2); EventHelper.AddListener((Action)delegate { ResetPreferenceChanges(modName); }, (UnityEvent)(object)val4.onClick); UpdateButtonStates(); } private void ApplyPreferenceChanges(string modName) { bool flag = modName == "Unassigned"; MelonMod mod = (flag ? null : _modManager.GetMod(modName)); 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]; MelonPreferences_Category val = null; MelonPreferences_Entry val2 = null; if (flag) { List<MelonPreferences_Category> source = _modManager.GetUnassignedPreferences().ToList(); val = ((IEnumerable<MelonPreferences_Category>)source).FirstOrDefault((Func<MelonPreferences_Category, bool>)((MelonPreferences_Category c) => c.Identifier == categoryId)); } else { List<MelonPreferences_Category> source2 = _modManager.GetPreferencesForMod(mod).ToList(); val = ((IEnumerable<MelonPreferences_Category>)source2).FirstOrDefault((Func<MelonPreferences_Category, bool>)((MelonPreferences_Category c) => c.Identifier == categoryId)); } val2 = val?.Entries?.FirstOrDefault((Func<MelonPreferences_Entry, bool>)((MelonPreferences_Entry e) => e.Identifier == entryId)); if (val2 == null) { continue; } try { Type type = val2.BoxedValue.GetType(); if (modifiedPreference.Value.GetType() == type) { val2.BoxedValue = modifiedPreference.Value; } else if (type.IsEnum) { val2.BoxedValue = Enum.Parse(type, modifiedPreference.Value.ToString()); } else { val2.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(); if (flag) { ShowUnassignedDetails(); } else { ShowModDetails(mod); } _logger.Msg("Preferences applied and saved successfully"); _modifiedMods.Add(modName); _modifiedLabel.text = "Changes applied, restart may be required"; ((Component)_modifiedLabel).gameObject.SetActive(true); } private void ResetPreferenceChanges(string modName) { bool flag = modName == "Unassigned"; _modifiedPreferences.Clear(); if (flag) { ShowUnassignedDetails(); } else { ShowModDetails(_modManager.GetMod(modName)); } _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; private bool _isUnassignedSelected; public const string UnassignedButtonName = "Unassigned"; private IEnumerable<MelonMod> _allMods = Enumerable.Empty<MelonMod>(); private string _searchQuery = string.Empty; private InputField _searchInput; private Button _clearButton; 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_00b8: 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_00f5: Unknown result type (might be due to invalid IL or missing references) //IL_00fa: 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_013b: Unknown result type (might be due to invalid IL or missing references) //IL_0140: Unknown result type (might be due to invalid IL or missing references) //IL_0145: 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_0163: Unknown result type (might be due to invalid IL or missing references) //IL_0184: Unknown result type (might be due to invalid IL or missing references) //IL_018e: 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); InitializeSearchPanel(val); GameObject val2 = UIFactory.Panel("ListPanel", val.transform, _theme.BgPrimary, (Vector2?)null, (Vector2?)null, false); UIHelper.ForceRectToAnchors(val2.GetComponent<RectTransform>(), new Vector2(0f, 0f), new Vector2(1f, 0.87f), Vector2.zero, Vector2.zero); ScrollRect val3 = default(ScrollRect); _listContent = UIFactory.ScrollableVerticalList("ModListContent", val2.transform, ref val3); 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); } private void InitializeSearchPanel(GameObject leftPanel) { //IL_0012: Unknown result type (might be due to invalid IL or missing references) //IL_0040: Unknown result type (might be due to invalid IL or missing references) //IL_004f: Unknown result type (might be due to invalid IL or missing references) //IL_0054: Unknown result type (might be due to invalid IL or missing references) //IL_005e: Unknown result type (might be due to invalid IL or missing references) //IL_00a3: Unknown result type (might be due to invalid IL or missing references) //IL_00ad: Expected O, but got Unknown //IL_01fe: Unknown result type (might be due to invalid IL or missing references) //IL_021e: Unknown result type (might be due to invalid IL or missing references) GameObject val = UIFactory.Panel("SearchPanel", leftPanel.transform, _theme.BgCard, (Vector2?)null, (Vector2?)null, false); UIHelper.ForceRectToAnchors(val.GetComponent<RectTransform>(), new Vector2(0f, 0.85f), new Vector2(1f, 0.95f), Vector2.zero, Vector2.zero); HorizontalLayoutGroup val2 = val.GetComponent<HorizontalLayoutGroup>(); if ((Object)(object)val2 == (Object)null) { val2 = val.AddComponent<HorizontalLayoutGroup>(); } ((HorizontalOrVerticalLayoutGroup)val2).spacing = 4f; ((LayoutGroup)val2).padding = new RectOffset(8, 8, 0, 1); ((HorizontalOrVerticalLayoutGroup)val2).childControlWidth = true; ((HorizontalOrVerticalLayoutGroup)val2).childForceExpandWidth = false; ((HorizontalOrVerticalLayoutGroup)val2).childForceExpandHeight = false; ((LayoutGroup)val2).childAlignment = (TextAnchor)1; _searchInput = InputFieldFactory.CreateInputField(val, "SearchMods", "", (ContentType)0, 100); if ((Object)(object)_searchInput != (Object)null) { LayoutElement val3 = ((Component)_searchInput).GetComponent<LayoutElement>(); if ((Object)(object)val3 == (Object)null) { val3 = ((Component)_searchInput).gameObject.AddComponent<LayoutElement>(); } val3.preferredHeight = 28f; val3.flexibleHeight = 0f; val3.flexibleWidth = 1f; ProcessTextInChildren(((Component)_searchInput).transform, delegate(Text text) { if (((Object)((Component)text).gameObject).name.Contains("Placeholder")) { text.text = "Search mods..."; } }); string empty = ""; EventHelper.AddListener<string>((Action<string>)delegate(string text) { empty = empty; Controls.IsTyping = true; OnSearchTextChanged(text); }, (UnityEvent<string>)(object)_searchInput.onValueChanged); EventHelper.AddListener<string>((Action<string>)delegate { empty = empty; Controls.IsTyping = false; }, (UnityEvent<string>)(object)_searchInput.onEndEdit); } Button item = UIFactory.RoundedButtonWithLabel("SearchClear", "x", val.transform, new Color(1f, 1f, 1f, 0.2f), 30f, 30f, _theme.SizeStandard, _theme.WarningColor).Item2; ((Component)item).gameObject.SetActive(false); _clearButton = item; if ((Object)(object)item != (Object)null) { LayoutElement val4 = ((Component)item).gameObject.GetComponent<LayoutElement>(); if ((Object)(object)val4 == (Object)null) { val4 = ((Component)item).gameObject.AddComponent<LayoutElement>(); } val4.preferredHeight = 28f; val4.preferredWidth = 28f; val4.flexibleWidth = 0f; EventHelper.AddListener((Action)OnSearchClear, (UnityEvent)(object)item.onClick); } } private void OnSearchTextChanged(string text) { _searchQuery = text; if ((Object)(object)_clearButton != (Object)null) { ((Component)_clearButton).gameObject.SetActive(!string.IsNullOrWhiteSpace(text)); } PopulateList(); } private void OnSearchClear() { if ((Object)(object)_searchInput != (Object)null) { _searchInput.text = string.Empty; } _searchQuery = string.Empty; PopulateList(); } private static void ProcessTextInChildren(Transform root, Action<Text> action) { if (!((Object)(object)root == (Object)null)) { Text obj = default(Text); if (((Component)root).TryGetComponent<Text>(ref obj)) { action(obj); } for (int i = 0; i < root.childCount; i++) { ProcessTextInChildren(root.GetChild(i), action); } } } public void PopulateList() { //IL_0126: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)_listContent == (Object)null) { return; } if (!_allMods.Any()) { _allMods = _modManager.GetAllMods(); } UIFactory.ClearChildren((Transform)(object)_listContent); _modButtons.Clear(); if (_modManager.HasUnassignedPreferences()) { CreateModButton("Unassigned", "Unassigned", "0.0", isUnassigned: true); } IEnumerable<MelonMod> enumerable = FilterMods(_searchQuery); foreach (MelonMod item in enumerable) { CreateModButton(((MelonBase)item).Info.Name, ((MelonBase)item).Info.Name, "v" + ((MelonBase)item).Info.Version, isUnassigned: false); } if (!enumerable.Any()) { Text val = UIFactory.Text("NoSearchResults", "No mods found", (Transform)(object)_listContent, _theme.SizeSmall, (TextAnchor)4, (FontStyle)0); ((Graphic)val).color = _theme.TextSecondary; } UpdateButtonHighlights(); UIHelper.RefreshLayout(_listContent); } private IEnumerable<MelonMod> FilterMods(string query) { if (string.IsNullOrWhiteSpace(query)) { return _allMods; } return _allMods.Where((MelonMod mod) => ((MelonBase)mod).Info.Name.IndexOf(query, StringComparison.OrdinalIgnoreCase) >= 0); } private void CreateModButton(string internalName, string displayName, string version, bool isUnassigned) { //IL_003e: Unknown result type (might be due to invalid IL or missing references) //IL_00c5: Unknown result type (might be due to invalid IL or missing references) //IL_00e0: Unknown result type (might be due to invalid IL or missing references) //IL_00ef: Unknown result type (might be due to invalid IL or missing references) //IL_0146: Unknown result type (might be due to invalid IL or missing references) //IL_0162: Unknown result type (might be due to invalid IL or missing references) //IL_0171: Unknown result type (might be due to invalid IL or missing references) GameObject val = UIFactory.Panel(UIHelper.SanitizeName(internalName) + "_Button", (Transform)(object)_listContent, _theme.AccentSecondary, (Vector2?)null, (Vector2?)null, false); Button orAddComponent = val.GetOrAddComponent<Button>(); UIHelper.SetupButton(orAddComponent, _theme, delegate { SelectMod(internalName, isUnassigned); }); UIHelper.ConfigureButtonLayout(val.GetComponent<RectTransform>(), 48f); Text val2 = UIFactory.Text(UIHelper.SanitizeName(internalName) + "_Label", displayName, val.transform, _theme.SizeStandard, (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(internalName) + "_Version", version, val.transform, _theme.SizeTiny, (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[internalName] = val; _modLabels[internalName] = val2; } private void SelectMod(string modName, bool isUnassigned) { _selectedModName = modName; _isUnassignedSelected = isUnassigned; UpdateButtonHighlights(); this.OnModSelected?.Invoke(isUnassigned ? null : _modManager.GetMod(modName)); } 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 = _theme.SizeStandard; } 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 = _theme.SizeStandard; } } 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_008e: 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, _theme.SizeTiny, (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: Unknow