Decompiled source of ModsApp v1.2.1

ModsApp.dll

Decompiled 3 days ago
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.Linq.Expressions;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using System.Text;
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 ModsApp.UI.Themes;
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.2.1", "k073l", null)]
[assembly: MelonColor(1, 255, 0, 0)]
[assembly: MelonGame("TVGS", "Schedule I")]
[assembly: MelonPriority(-2147483548)]
[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+941dc96e2965f58e951da2fb5bb9768daba0411b")]
[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.2.1";
	}
	public class ModsApp : MelonMod
	{
		private static Instance Logger;

		public static Sprite AppIconSprite;

		public static Sprite WarningIconSprite;

		public static Sprite ScrollIconSprite;

		public static MelonPreferences_Category AccessibilityCategory;

		public static MelonPreferences_Entry<TextSizeProfile> TextSizeProfileEntry;

		public static MelonPreferences_Category ThemesCategory;

		public static MelonPreferences_Entry<ThemeOption> ThemeOptionEntry;

		public static MelonPreferences_Entry<Color> BackgroundPrimaryEntry;

		public static MelonPreferences_Entry<Color> BackgroundSecondaryEntry;

		public static MelonPreferences_Entry<Color> BackgroundCardEntry;

		public static MelonPreferences_Entry<Color> BackgroundCategoryEntry;

		public static MelonPreferences_Entry<Color> BackgroundInputEntry;

		public static MelonPreferences_Entry<Color> AccentPrimaryEntry;

		public static MelonPreferences_Entry<Color> AccentSecondaryEntry;

		public static MelonPreferences_Entry<Color> TextPrimaryEntry;

		public static MelonPreferences_Entry<Color> TextSecondaryEntry;

		public static MelonPreferences_Entry<Color> InputPrimaryEntry;

		public static MelonPreferences_Entry<Color> InputSecondaryEntry;

		public static MelonPreferences_Entry<Color> SuccessColorEntry;

		public static MelonPreferences_Entry<Color> WarningColorEntry;

		public static MelonPreferences_Entry<Color> ErrorColorEntry;

		public override void OnInitializeMelon()
		{
			//IL_00d3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00fb: 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_014b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0173: Unknown result type (might be due to invalid IL or missing references)
			//IL_019b: 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_01eb: Unknown result type (might be due to invalid IL or missing references)
			//IL_0213: Unknown result type (might be due to invalid IL or missing references)
			//IL_023b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0263: Unknown result type (might be due to invalid IL or missing references)
			//IL_028b: Unknown result type (might be due to invalid IL or missing references)
			//IL_02b3: Unknown result type (might be due to invalid IL or missing references)
			//IL_02db: Unknown result type (might be due to invalid IL or missing references)
			LogManager.Instance.WireEvents();
			Logger = ((MelonBase)this).LoggerInstance;
			Logger.Msg("ModsApp initialized");
			AppIconSprite = LoadEmbeddedPNG("ModsApp.assets.appicon.png");
			WarningIconSprite = LoadEmbeddedPNG("ModsApp.assets.triangle-alert.png");
			ScrollIconSprite = LoadEmbeddedPNG("ModsApp.assets.scroll-text.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);
			ThemesCategory = MelonPreferences.CreateCategory("ModsApp_Themes", "Themes");
			ThemeOptionEntry = ThemesCategory.CreateEntry<ThemeOption>("ModsAppThemeOption", ThemeOption.Slate, "Theme Preset", "Predefined theme presets. Set to Custom to use custom colors defined below - Custom may require game restart to apply fully, but changing presets should apply immediately", false, false, (ValueValidator)null, (string)null);
			Slate slate = new Slate();
			BackgroundPrimaryEntry = ThemesCategory.CreateEntry<Color>("ModsAppBackgroundPrimary", slate.BgPrimary, "Background Primary", "Primary background color. Set Theme Preset to Custom to use this color", false, false, (ValueValidator)null, (string)null);
			BackgroundSecondaryEntry = ThemesCategory.CreateEntry<Color>("ModsAppBackgroundSecondary", slate.BgSecondary, "Background Secondary", "Secondary background color. Set Theme Preset to Custom to use this color", false, false, (ValueValidator)null, (string)null);
			BackgroundCardEntry = ThemesCategory.CreateEntry<Color>("ModsAppBackgroundCard", slate.BgCard, "Background Card", "Card background color. Set Theme Preset to Custom to use this color", false, false, (ValueValidator)null, (string)null);
			BackgroundCategoryEntry = ThemesCategory.CreateEntry<Color>("ModsAppBackgroundCategory", slate.BgCategory, "Background Category", "Category background color. Set Theme Preset to Custom to use this color", false, false, (ValueValidator)null, (string)null);
			BackgroundInputEntry = ThemesCategory.CreateEntry<Color>("ModsAppBackgroundInput", slate.BgInput, "Background Input", "Input background color. Set Theme Preset to Custom to use this color", false, false, (ValueValidator)null, (string)null);
			AccentPrimaryEntry = ThemesCategory.CreateEntry<Color>("ModsAppAccentPrimary", slate.AccentPrimary, "Accent Primary", "Primary accent color. Set Theme Preset to Custom to use this color", false, false, (ValueValidator)null, (string)null);
			AccentSecondaryEntry = ThemesCategory.CreateEntry<Color>("ModsAppAccentSecondary", slate.AccentSecondary, "Accent Secondary", "Secondary accent color. Set Theme Preset to Custom to use this color", false, false, (ValueValidator)null, (string)null);
			TextPrimaryEntry = ThemesCategory.CreateEntry<Color>("ModsAppTextPrimary", slate.TextPrimary, "Text Primary", "Primary text color. Set Theme Preset to Custom to use this color", false, false, (ValueValidator)null, (string)null);
			TextSecondaryEntry = ThemesCategory.CreateEntry<Color>("ModsAppTextSecondary", slate.TextSecondary, "Text Secondary", "Secondary text color. Set Theme Preset to Custom to use this color", false, false, (ValueValidator)null, (string)null);
			InputPrimaryEntry = ThemesCategory.CreateEntry<Color>("ModsAppInputPrimary", slate.InputPrimary, "Input Primary", "Primary input color. Set Theme Preset to Custom to use this color", false, false, (ValueValidator)null, (string)null);
			InputSecondaryEntry = ThemesCategory.CreateEntry<Color>("ModsAppInputSecondary", slate.InputSecondary, "Input Secondary", "Secondary input color. Set Theme Preset to Custom to use this color", false, false, (ValueValidator)null, (string)null);
			SuccessColorEntry = ThemesCategory.CreateEntry<Color>("ModsAppSuccessColor", slate.SuccessColor, "Success Color", "Color used to indicate success. Set Theme Preset to Custom to use this color", false, false, (ValueValidator)null, (string)null);
			WarningColorEntry = ThemesCategory.CreateEntry<Color>("ModsAppWarningColor", slate.WarningColor, "Warning Color", "Color used to indicate warnings. Set Theme Preset to Custom to use this color", false, false, (ValueValidator)null, (string)null);
			ErrorColorEntry = ThemesCategory.CreateEntry<Color>("ModsAppErrorColor", slate.ErrorColor, "Error Color", "Color used to indicate errors. Set Theme Preset to Custom to use this color", false, false, (ValueValidator)null, (string)null);
			CategoryState.Load();
		}

		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);
			Sprite val = ImageUtils.LoadImageRaw(array);
			if ((Object)(object)val != (Object)null)
			{
				((Object)val).name = resourceName;
			}
			return val;
		}

		public override void OnUpdate()
		{
			if (App.Instance != null && ((PhoneApp)App.Instance).IsOpen() && Input.GetKeyDown((KeyCode)27))
			{
				FloatingPanelComponent.Cleanup();
				Controls.IsTyping = false;
			}
			if ((Object)(object)ColorInputHandler.ColorPickerCanvas != (Object)null && Input.GetKeyDown((KeyCode)27))
			{
				Controls.IsTyping = false;
				Object.Destroy((Object)(object)ColorInputHandler.ColorPickerCanvas);
			}
		}

		public override void OnApplicationQuit()
		{
			CategoryState.Save();
		}
	}
}
namespace ModsApp.UI
{
	public enum TextSizeProfile
	{
		ExtraSmall,
		Small,
		Normal,
		Large,
		ExtraLarge
	}
	public class UITheme
	{
		private ITheme _theme;

		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 Color BgPrimary => _theme.BgPrimary;

		public Color BgSecondary => _theme.BgSecondary;

		public Color BgCard => _theme.BgCard;

		public Color BgCategory => _theme.BgCategory;

		public Color BgInput => _theme.BgInput;

		public Color AccentPrimary => _theme.AccentPrimary;

		public Color AccentSecondary => _theme.AccentSecondary;

		public Color TextPrimary => _theme.TextPrimary;

		public Color TextSecondary => _theme.TextSecondary;

		public Color InputPrimary => _theme.InputPrimary;

		public Color InputSecondary => _theme.InputSecondary;

		public Color SuccessColor => _theme.SuccessColor;

		public Color WarningColor => _theme.WarningColor;

		public Color ErrorColor => _theme.ErrorColor;

		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 void SetTheme(ThemeOption theme)
		{
			if (1 == 0)
			{
			}
			ITheme theme2 = theme switch
			{
				ThemeOption.Forest => new Forest(), 
				ThemeOption.Metal => new Metal(), 
				ThemeOption.Neon => new Neon(), 
				ThemeOption.Ocean => new Ocean(), 
				ThemeOption.Slate => new Slate(), 
				ThemeOption.Solar => new Solar(), 
				ThemeOption.Twilight => new Twilight(), 
				ThemeOption.Custom => new Custom(), 
				_ => new Slate(), 
			};
			if (1 == 0)
			{
			}
			_theme = theme2;
		}

		public UITheme()
		{
			SetTextScale(ModsApp.TextSizeProfileEntry.Value);
			SetTheme(ModsApp.ThemeOptionEntry.Value);
		}
	}
}
namespace ModsApp.UI.Themes
{
	public class Custom : ITheme
	{
		public Color BgPrimary => ModsApp.BackgroundPrimaryEntry.Value;

		public Color BgSecondary => ModsApp.BackgroundSecondaryEntry.Value;

		public Color BgCard => ModsApp.BackgroundCardEntry.Value;

		public Color BgCategory => ModsApp.BackgroundCategoryEntry.Value;

		public Color BgInput => ModsApp.BackgroundInputEntry.Value;

		public Color AccentPrimary => ModsApp.AccentPrimaryEntry.Value;

		public Color AccentSecondary => ModsApp.AccentSecondaryEntry.Value;

		public Color TextPrimary => ModsApp.TextPrimaryEntry.Value;

		public Color TextSecondary => ModsApp.TextSecondaryEntry.Value;

		public Color InputPrimary => ModsApp.InputPrimaryEntry.Value;

		public Color InputSecondary => ModsApp.InputSecondaryEntry.Value;

		public Color SuccessColor => ModsApp.SuccessColorEntry.Value;

		public Color WarningColor => ModsApp.WarningColorEntry.Value;

		public Color ErrorColor => ModsApp.ErrorColorEntry.Value;
	}
	public class Forest : ITheme
	{
		public Color BgPrimary => new Color(0.05f, 0.2f, 0.1f, 1f);

		public Color BgSecondary => new Color(0.1f, 0.25f, 0.15f, 1f);

		public Color BgCard => new Color(0.12f, 0.3f, 0.18f, 1f);

		public Color BgCategory => new Color(0.08f, 0.22f, 0.12f, 1f);

		public Color BgInput => new Color(0.95f, 0.98f, 0.95f, 1f);

		public Color AccentPrimary => new Color(0.15f, 0.7f, 0.3f, 1f);

		public Color AccentSecondary => new Color(0.1f, 0.5f, 0.2f, 1f);

		public Color TextPrimary => new Color(0.9f, 0.95f, 0.9f, 1f);

		public Color TextSecondary => new Color(0.65f, 0.75f, 0.65f, 0.75f);

		public Color InputPrimary => new Color(0.1f, 0.15f, 0.1f, 1f);

		public Color InputSecondary => new Color(0.45f, 0.5f, 0.45f, 1f);

		public Color SuccessColor => new Color(0.25f, 0.85f, 0.25f, 1f);

		public Color WarningColor => new Color(0.95f, 0.85f, 0.2f, 1f);

		public Color ErrorColor => new Color(0.9f, 0.25f, 0.2f, 1f);
	}
	public interface ITheme
	{
		Color BgPrimary { get; }

		Color BgSecondary { get; }

		Color BgCard { get; }

		Color BgCategory { get; }

		Color BgInput { get; }

		Color AccentPrimary { get; }

		Color AccentSecondary { get; }

		Color TextPrimary { get; }

		Color TextSecondary { get; }

		Color InputPrimary { get; }

		Color InputSecondary { get; }

		Color SuccessColor { get; }

		Color WarningColor { get; }

		Color ErrorColor { get; }
	}
	public class Metal : ITheme
	{
		public Color BgPrimary => new Color(0.18f, 0.18f, 0.2f, 1f);

		public Color BgSecondary => new Color(0.22f, 0.22f, 0.25f, 1f);

		public Color BgCard => new Color(0.25f, 0.25f, 0.28f, 1f);

		public Color BgCategory => new Color(0.2f, 0.2f, 0.23f, 1f);

		public Color BgInput => new Color(0.95f, 0.95f, 0.95f, 1f);

		public Color AccentPrimary => new Color(0.6f, 0.6f, 0.65f, 1f);

		public Color AccentSecondary => new Color(0.4f, 0.4f, 0.45f, 1f);

		public Color TextPrimary => new Color(0.95f, 0.95f, 0.95f, 1f);

		public Color TextSecondary => new Color(0.7f, 0.7f, 0.7f, 0.75f);

		public Color InputPrimary => new Color(0.1f, 0.1f, 0.12f, 1f);

		public Color InputSecondary => new Color(0.5f, 0.5f, 0.55f, 1f);

		public Color SuccessColor => new Color(0.2f, 0.8f, 0.2f, 1f);

		public Color WarningColor => new Color(0.95f, 0.75f, 0.2f, 1f);

		public Color ErrorColor => new Color(0.95f, 0.2f, 0.2f, 1f);
	}
	public class Neon : ITheme
	{
		public Color BgPrimary => new Color(0.05f, 0.05f, 0.1f, 1f);

		public Color BgSecondary => new Color(0.08f, 0.08f, 0.15f, 1f);

		public Color BgCard => new Color(0.1f, 0.1f, 0.2f, 1f);

		public Color BgCategory => new Color(0.06f, 0.06f, 0.12f, 1f);

		public Color BgInput => new Color(0.98f, 0.98f, 0.98f, 1f);

		public Color AccentPrimary => new Color(0f, 1f, 0.9f, 1f);

		public Color AccentSecondary => new Color(1f, 0.1f, 0.8f, 1f);

		public Color TextPrimary => new Color(0.95f, 0.95f, 0.95f, 1f);

		public Color TextSecondary => new Color(0.7f, 0.7f, 0.7f, 0.75f);

		public Color InputPrimary => new Color(0.05f, 0.05f, 0.05f, 1f);

		public Color InputSecondary => new Color(0.5f, 0.5f, 0.5f, 1f);

		public Color SuccessColor => new Color(0f, 1f, 0.4f, 1f);

		public Color WarningColor => new Color(1f, 0.8f, 0f, 1f);

		public Color ErrorColor => new Color(1f, 0.05f, 0.2f, 1f);
	}
	public class Ocean : ITheme
	{
		public Color BgPrimary => new Color(0.05f, 0.2f, 0.3f, 1f);

		public Color BgSecondary => new Color(0.08f, 0.25f, 0.35f, 1f);

		public Color BgCard => new Color(0.1f, 0.3f, 0.4f, 1f);

		public Color BgCategory => new Color(0.07f, 0.22f, 0.32f, 1f);

		public Color BgInput => new Color(0.9f, 0.95f, 0.98f, 1f);

		public Color AccentPrimary => new Color(0f, 0.6f, 0.9f, 1f);

		public Color AccentSecondary => new Color(0f, 0.4f, 0.7f, 1f);

		public Color TextPrimary => new Color(0.95f, 0.95f, 0.95f, 1f);

		public Color TextSecondary => new Color(0.7f, 0.8f, 0.85f, 0.75f);

		public Color InputPrimary => new Color(0.05f, 0.1f, 0.15f, 1f);

		public Color InputSecondary => new Color(0.45f, 0.55f, 0.65f, 1f);

		public Color SuccessColor => new Color(0.2f, 0.8f, 0.5f, 1f);

		public Color WarningColor => new Color(0.95f, 0.85f, 0.2f, 1f);

		public Color ErrorColor => new Color(0.9f, 0.25f, 0.2f, 1f);
	}
	public class Slate : ITheme
	{
		public Color BgPrimary => new Color(0.12f, 0.12f, 0.15f, 1f);

		public Color BgSecondary => new Color(0.16f, 0.16f, 0.2f, 1f);

		public Color BgCard => new Color(0.2f, 0.2f, 0.24f, 1f);

		public Color BgCategory => new Color(0.18f, 0.18f, 0.22f, 1f);

		public Color BgInput => new Color(0.98f, 0.98f, 0.98f, 1f);

		public Color AccentPrimary => new Color(0.26f, 0.59f, 0.98f, 1f);

		public Color AccentSecondary => new Color(0.15f, 0.15f, 0.18f, 1f);

		public Color TextPrimary => new Color(0.95f, 0.95f, 0.95f, 1f);

		public Color TextSecondary => new Color(0.7f, 0.7f, 0.7f, 0.75f);

		public Color InputPrimary => new Color(0.05f, 0.05f, 0.05f, 1f);

		public Color InputSecondary => new Color(0.5f, 0.5f, 0.5f, 1f);

		public Color SuccessColor => new Color(0.2f, 0.8f, 0.2f, 1f);

		public Color WarningColor => new Color(0.95f, 0.75f, 0.2f, 1f);

		public Color ErrorColor => new Color(0.95f, 0.2f, 0.2f, 1f);
	}
	public class Solar : ITheme
	{
		public Color BgPrimary => new Color(1f, 0.95f, 0.85f, 1f);

		public Color BgSecondary => new Color(0.98f, 0.9f, 0.75f, 1f);

		public Color BgCard => new Color(1f, 0.85f, 0.6f, 1f);

		public Color BgCategory => new Color(1f, 0.88f, 0.65f, 1f);

		public Color BgInput => new Color(1f, 1f, 1f, 1f);

		public Color AccentPrimary => new Color(1f, 0.6f, 0.1f, 1f);

		public Color AccentSecondary => new Color(0.85f, 0.45f, 0.05f, 1f);

		public Color TextPrimary => new Color(0.15f, 0.1f, 0.05f, 1f);

		public Color TextSecondary => new Color(0.35f, 0.25f, 0.15f, 0.75f);

		public Color InputPrimary => new Color(0.95f, 0.9f, 0.8f, 1f);

		public Color InputSecondary => new Color(0.7f, 0.6f, 0.5f, 1f);

		public Color SuccessColor => new Color(0.2f, 0.6f, 0.1f, 1f);

		public Color WarningColor => new Color(0.95f, 0.6f, 0.05f, 1f);

		public Color ErrorColor => new Color(0.85f, 0.1f, 0.05f, 1f);
	}
	public enum ThemeOption
	{
		Forest,
		Metal,
		Neon,
		Ocean,
		Slate,
		Solar,
		Twilight,
		Custom
	}
	public class Twilight : ITheme
	{
		public Color BgPrimary => new Color(0.1f, 0.05f, 0.25f, 1f);

		public Color BgSecondary => new Color(0.12f, 0.08f, 0.3f, 1f);

		public Color BgCard => new Color(0.15f, 0.1f, 0.35f, 1f);

		public Color BgCategory => new Color(0.11f, 0.07f, 0.28f, 1f);

		public Color BgInput => new Color(0.95f, 0.95f, 0.98f, 1f);

		public Color AccentPrimary => new Color(0.7f, 0.4f, 0.95f, 1f);

		public Color AccentSecondary => new Color(0.5f, 0.25f, 0.8f, 1f);

		public Color TextPrimary => new Color(0.95f, 0.95f, 0.95f, 1f);

		public Color TextSecondary => new Color(0.7f, 0.7f, 0.85f, 0.75f);

		public Color InputPrimary => new Color(0.08f, 0.05f, 0.12f, 1f);

		public Color InputSecondary => new Color(0.45f, 0.35f, 0.55f, 1f);

		public Color SuccessColor => new Color(0.2f, 0.8f, 0.2f, 1f);

		public Color WarningColor => new Color(0.95f, 0.75f, 0.2f, 1f);

		public Color ErrorColor => new Color(0.95f, 0.2f, 0.25f, 1f);
	}
}
namespace ModsApp.UI.Panels
{
	public class FloatingPanelComponent
	{
		private static GameObject _panelObject;

		private RectTransform _rectTransform;

		private UITheme _theme;

		private static Button _closeBtn;

		public GameObject ContentPanel;

		private const float topBarHeight = 65f;

		public FloatingPanelComponent(float width, float height, string title)
		{
			//IL_0054: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f1: Unknown result type (might be due to invalid IL or missing references)
			_theme = UIManager._theme;
			Transform val = UIManager.MainPanel.transform.Find("FloatingPanel");
			if ((Object)(object)val != (Object)null)
			{
				Object.Destroy((Object)(object)((Component)val).gameObject);
			}
			_panelObject = UIFactory.Panel("FloatingPanel", UIManager.MainPanel.transform, _theme.BgPrimary, (Vector2?)null, (Vector2?)null, false);
			_panelObject.transform.SetParent(UIManager.MainPanel.transform, false);
			_panelObject.transform.SetAsLastSibling();
			_panelObject.GetComponent<Image>()?.MakeRounded(12, 48);
			_rectTransform = _panelObject.GetComponent<RectTransform>();
			_rectTransform.sizeDelta = new Vector2(width, height);
			AddTopBar(title);
			UIHelper.AddBorderEffect(_panelObject, _theme.AccentPrimary);
			ContentPanel = AddContentPanel();
		}

		private void AddTopBar(string title)
		{
			//IL_0048: 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_0074: Unknown result type (might be due to invalid IL or missing references)
			//IL_008a: 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_011d: Unknown result type (might be due to invalid IL or missing references)
			//IL_013d: 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_0182: 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_01b0: Unknown result type (might be due to invalid IL or missing references)
			GameObject val = UIFactory.TopBar("FloatingPanelTopBar", _panelObject.transform, title, 0.99f, 8, 8, 4, 4);
			val.GetComponent<Image>()?.MakeRounded(12, 48);
			RectTransform component = val.GetComponent<RectTransform>();
			component.anchorMin = new Vector2(0f, 1f);
			component.anchorMax = new Vector2(1f, 1f);
			component.pivot = new Vector2(0.5f, 1f);
			component.sizeDelta = new Vector2(0f, 65f);
			component.anchoredPosition = new Vector2(0f, 0f);
			HorizontalLayoutGroup component2 = val.GetComponent<HorizontalLayoutGroup>();
			if ((Object)(object)component2 != (Object)null)
			{
				((HorizontalOrVerticalLayoutGroup)component2).childForceExpandHeight = false;
			}
			Transform obj = val.transform.Find("TopBarTitle");
			Text val2 = ((obj != null) ? ((Component)obj).GetComponent<Text>() : null);
			if ((Object)(object)val2 != (Object)null)
			{
				val2.fontSize = _theme.SizeMedium;
			}
			ValueTuple<GameObject, Button, Text> valueTuple = UIFactory.RoundedButtonWithLabel("CloseButton", "X", val.transform, _theme.WarningColor, 48.75f, 48.75f, _theme.SizeMedium, _theme.TextPrimary);
			GameObject item = valueTuple.Item1;
			Button item2 = valueTuple.Item2;
			RectTransform component3 = item.GetComponent<RectTransform>();
			component3.anchorMin = new Vector2(1f, 0.5f);
			component3.anchorMax = new Vector2(1f, 0.5f);
			component3.pivot = new Vector2(0.5f, 0.5f);
			component3.anchoredPosition = new Vector2(-20f, 0f);
			EventHelper.AddListener((Action)Cleanup, (UnityEvent)(object)item2.onClick);
			_closeBtn = item2;
			item.transform.SetAsLastSibling();
		}

		private GameObject AddContentPanel()
		{
			//IL_0016: Unknown result type (might be due to invalid IL or missing references)
			//IL_0046: 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_0072: 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)
			GameObject val = UIFactory.Panel("ContentPanel", _panelObject.transform, _theme.BgSecondary, (Vector2?)null, (Vector2?)null, false);
			RectTransform component = val.GetComponent<RectTransform>();
			component.anchorMin = new Vector2(0f, 0f);
			component.anchorMax = new Vector2(1f, 1f);
			component.offsetMin = new Vector2(8f, 8f);
			component.offsetMax = new Vector2(-8f, -73f);
			val.GetComponent<Image>()?.MakeRounded(8, 48);
			return val;
		}

		public static void Cleanup()
		{
			if ((Object)(object)_closeBtn != (Object)null)
			{
				EventHelper.RemoveListener((Action)Cleanup, (UnityEvent)(object)_closeBtn.onClick);
			}
			if (!((Object)(object)_panelObject == (Object)null))
			{
				Object.Destroy((Object)(object)_panelObject);
				Transform val = _panelObject.transform.parent.Find(((Object)_panelObject).name + "_Border");
				if ((Object)(object)val != (Object)null)
				{
					Object.Destroy((Object)(object)((Component)val).gameObject);
				}
			}
		}
	}
	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_0075: Unknown result type (might be due to invalid IL or missing references)
			//IL_0085: Unknown result type (might be due to invalid IL or missing references)
			//IL_0095: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c4: 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_00e4: 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_012f: Unknown result type (might be due to invalid IL or missing references)
			//IL_013f: 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_015e: Unknown result type (might be due to invalid IL or missing references)
			//IL_017e: 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_019e: 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_01f7: Unknown result type (might be due to invalid IL or missing references)
			//IL_0207: 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)
			//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 LogExplorerPanel
	{
		private readonly UITheme _theme;

		private readonly MelonMod _mod;

		private bool _modOnly;

		private bool _issuesOnly;

		private ScrollableTextFactory _scrollable;

		private string _accentSecondaryHex;

		private string _accentPrimaryHex;

		private string _errorHex;

		private string _warningHex;

		private string _inputHex;

		public LogExplorerPanel(MelonMod mod)
		{
			//IL_0032: 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_005e: 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_008a: Unknown result type (might be due to invalid IL or missing references)
			_theme = UIManager._theme;
			_mod = mod;
			_modOnly = mod != null;
			_issuesOnly = true;
			_accentSecondaryHex = ColorUtility.ToHtmlStringRGB(_theme.AccentSecondary);
			_accentPrimaryHex = ColorUtility.ToHtmlStringRGB(_theme.AccentPrimary);
			_errorHex = ColorUtility.ToHtmlStringRGB(_theme.ErrorColor);
			_warningHex = ColorUtility.ToHtmlStringRGB(_theme.WarningColor);
			_inputHex = ColorUtility.ToHtmlStringRGB(_theme.InputPrimary);
			FloatingPanelComponent floatingPanelComponent = new FloatingPanelComponent(1100f, 600f, (mod != null) ? (((MelonBase)mod).Info.Name + " - Log Explorer") : "Log Explorer - All Mods");
			BuildFilterBar(floatingPanelComponent.ContentPanel.transform);
			BuildLogView(floatingPanelComponent.ContentPanel.transform);
		}

		private void BuildFilterBar(Transform parent)
		{
			//IL_0014: Unknown result type (might be due to invalid IL or missing references)
			//IL_0046: 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_0072: 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)
			//IL_0094: 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_00c1: Expected O, but got Unknown
			//IL_0208: Unknown result type (might be due to invalid IL or missing references)
			//IL_020f: Expected O, but got Unknown
			//IL_015b: Unknown result type (might be due to invalid IL or missing references)
			GameObject val2 = UIFactory.Panel("LogFilterBar", parent, Color.clear, (Vector2?)null, (Vector2?)null, false);
			RectTransform component = val2.GetComponent<RectTransform>();
			component.anchorMin = new Vector2(0f, 1f);
			component.anchorMax = new Vector2(1f, 1f);
			component.pivot = new Vector2(0.5f, 1f);
			component.sizeDelta = new Vector2(0f, 36f);
			component.anchoredPosition = Vector2.zero;
			HorizontalLayoutGroup val3 = val2.AddComponent<HorizontalLayoutGroup>();
			((HorizontalOrVerticalLayoutGroup)val3).spacing = 16f;
			((LayoutGroup)val3).padding = new RectOffset(8, 8, 6, 6);
			((LayoutGroup)val3).childAlignment = (TextAnchor)3;
			((HorizontalOrVerticalLayoutGroup)val3).childForceExpandWidth = false;
			((HorizontalOrVerticalLayoutGroup)val3).childForceExpandHeight = false;
			((HorizontalOrVerticalLayoutGroup)val3).childControlWidth = false;
			((HorizontalOrVerticalLayoutGroup)val3).childControlHeight = true;
			if (_mod != null)
			{
				Toggle val4 = CreateLabelledToggle(val2.transform, "ModOnlyToggle", "Selected mod only", _modOnly);
				ToggleUtils.AddListener(val4, (Action<bool>)delegate(bool val)
				{
					_modOnly = val;
					RefreshText();
				});
				Text val5 = UIFactory.Text("FilterSep", "|", val2.transform, _theme.SizeSmall, (TextAnchor)4, (FontStyle)0);
				((Graphic)val5).color = _theme.TextSecondary;
				((Component)val5).gameObject.GetOrAddComponent<LayoutElement>().preferredWidth = 12f;
			}
			Toggle issuesToggle = null;
			Toggle allLogsToggle = null;
			issuesToggle = CreateLabelledToggle(val2.transform, "IssuesOnlyToggle", "Warns & Errors", _issuesOnly);
			allLogsToggle = CreateLabelledToggle(val2.transform, "AllLogsToggle", "All messages", !_issuesOnly);
			ToggleUtils.AddListener(issuesToggle, (Action<bool>)delegate(bool val)
			{
				if (val)
				{
					_issuesOnly = true;
					if (allLogsToggle.isOn)
					{
						allLogsToggle.isOn = false;
					}
					RefreshText();
				}
			});
			ToggleUtils.AddListener(allLogsToggle, (Action<bool>)delegate(bool val)
			{
				if (val)
				{
					_issuesOnly = false;
					if (issuesToggle.isOn)
					{
						issuesToggle.isOn = false;
					}
					RefreshText();
				}
			});
			GameObject val6 = new GameObject("FilterSpacer");
			val6.transform.SetParent(val2.transform, false);
			val6.AddComponent<LayoutElement>().flexibleWidth = 1f;
		}

		private void BuildLogView(Transform parent)
		{
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			//IL_000c: Expected O, but got Unknown
			//IL_002c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0042: Unknown result type (might be due to invalid IL or missing references)
			//IL_0058: 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)
			//IL_0097: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a2: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c3: 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_00db: 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)
			GameObject val = new GameObject("LogContainer");
			val.transform.SetParent(parent, false);
			RectTransform val2 = val.AddComponent<RectTransform>();
			val2.anchorMin = new Vector2(0f, 0f);
			val2.anchorMax = new Vector2(1f, 1f);
			val2.offsetMin = new Vector2(6f, 6f);
			val2.offsetMax = new Vector2(-6f, -42f);
			_scrollable = new ScrollableTextFactory(val.transform, BuildText(), _theme.SizeStandard, _theme.TextPrimary, _theme.BgInput);
			RectTransform component = _scrollable.Root.GetComponent<RectTransform>();
			component.anchorMin = Vector2.zero;
			component.anchorMax = Vector2.one;
			component.offsetMin = Vector2.zero;
			component.offsetMax = Vector2.zero;
			Canvas.ForceUpdateCanvases();
			LayoutRebuilder.ForceRebuildLayoutImmediate(_scrollable.ContentRect);
		}

		private void RefreshText()
		{
			_scrollable.SetText(BuildText());
			Canvas.ForceUpdateCanvases();
			LayoutRebuilder.ForceRebuildLayoutImmediate(_scrollable.ContentRect);
		}

		private string BuildText()
		{
			List<LogEntry> list = GetFilteredEntries().ToList();
			if (list.Count == 0)
			{
				return BuildEmptyText();
			}
			StringBuilder stringBuilder = new StringBuilder();
			foreach (LogEntry item in list)
			{
				stringBuilder.Append($"<color=#{_accentSecondaryHex}>[{item.Time:HH:mm:ss}]</color> ");
				if (_mod == null || !_modOnly)
				{
					string text = item.ModName ?? item.Section;
					stringBuilder.Append("<color=#" + _accentPrimaryHex + ">[" + text + "]</color> ");
				}
				switch (item.Level)
				{
				case LogLevel.Warning:
					stringBuilder.Append("<color=#" + _warningHex + ">[WARN]</color> ");
					break;
				case LogLevel.Error:
					stringBuilder.Append("<color=#" + _errorHex + ">[ERR]</color> ");
					break;
				case LogLevel.Msg:
					stringBuilder.Append("<color=#" + _accentSecondaryHex + ">[MSG]</color> ");
					break;
				}
				stringBuilder.AppendLine("<color=#" + _inputHex + ">" + item.Message + "</color>");
			}
			return stringBuilder.ToString().TrimEnd();
		}

		private string BuildEmptyText()
		{
			if (_mod != null && _modOnly)
			{
				return _issuesOnly ? ("<color=#" + _inputHex + ">No warnings or errors recorded for " + ((MelonBase)_mod).Info.Name + ".</color>") : ("<color=#" + _inputHex + ">No log entries recorded for " + ((MelonBase)_mod).Info.Name + ".</color>");
			}
			return _issuesOnly ? ("<color=#" + _inputHex + ">No warnings or errors recorded.</color>") : ("<color=#" + _inputHex + ">No log entries recorded.</color>");
		}

		private IEnumerable<LogEntry> GetFilteredEntries()
		{
			IEnumerable<LogEntry> enumerable = ((_mod != null && _modOnly) ? LogManager.Instance.GetLogsForMod(((MelonBase)_mod).Info.Name) : LogManager.Instance.GetAllLogs());
			if (_issuesOnly)
			{
				enumerable = enumerable.Where((LogEntry e) => e.Level == LogLevel.Warning || e.Level == LogLevel.Error);
			}
			return enumerable;
		}

		private Toggle CreateLabelledToggle(Transform parent, string name, string labelText, bool initialValue)
		{
			//IL_0002: Unknown result type (might be due to invalid IL or missing references)
			//IL_0008: Expected O, but got Unknown
			//IL_006d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0073: Expected O, but got Unknown
			//IL_0094: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c4: Unknown result type (might be due to invalid IL or missing references)
			//IL_0110: Unknown result type (might be due to invalid IL or missing references)
			//IL_0117: Expected O, but got Unknown
			//IL_013c: Unknown result type (might be due to invalid IL or missing references)
			//IL_015c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0173: Unknown result type (might be due to invalid IL or missing references)
			//IL_0182: Unknown result type (might be due to invalid IL or missing references)
			//IL_0187: Unknown result type (might be due to invalid IL or missing references)
			//IL_0188: Unknown result type (might be due to invalid IL or missing references)
			//IL_0190: Unknown result type (might be due to invalid IL or missing references)
			//IL_01da: Unknown result type (might be due to invalid IL or missing references)
			GameObject val = new GameObject(name);
			val.transform.SetParent(parent, false);
			HorizontalLayoutGroup val2 = val.AddComponent<HorizontalLayoutGroup>();
			((HorizontalOrVerticalLayoutGroup)val2).spacing = 6f;
			((LayoutGroup)val2).childAlignment = (TextAnchor)3;
			((HorizontalOrVerticalLayoutGroup)val2).childForceExpandWidth = false;
			((HorizontalOrVerticalLayoutGroup)val2).childForceExpandHeight = false;
			((HorizontalOrVerticalLayoutGroup)val2).childControlWidth = false;
			((HorizontalOrVerticalLayoutGroup)val2).childControlHeight = true;
			val.AddComponent<LayoutElement>().preferredHeight = 24f;
			GameObject val3 = new GameObject(name + "_Box");
			val3.transform.SetParent(val.transform, false);
			Image val4 = val3.AddComponent<Image>();
			((Graphic)val4).color = _theme.BgInput;
			Toggle val5 = val3.AddComponent<Toggle>();
			((Selectable)val5).targetGraphic = (Graphic)(object)val4;
			RectTransform component = val3.GetComponent<RectTransform>();
			component.sizeDelta = new Vector2(20f, 20f);
			LayoutElement val6 = val3.AddComponent<LayoutElement>();
			val6.minWidth = 20f;
			val6.minHeight = 20f;
			val6.preferredWidth = 20f;
			val6.preferredHeight = 20f;
			GameObject val7 = new GameObject("Checkmark");
			val7.transform.SetParent(val3.transform, false);
			Image val8 = val7.AddComponent<Image>();
			((Graphic)val8).color = _theme.BgCard;
			RectTransform component2 = val7.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(val5, (Graphic)(object)val8);
			val5.isOn = initialValue;
			Text val9 = UIFactory.Text(name + "_Label", labelText, val.transform, _theme.SizeSmall, (TextAnchor)3, (FontStyle)0);
			((Graphic)val9).color = _theme.TextPrimary;
			((Component)val9).gameObject.AddComponent<LayoutElement>().preferredWidth = val9.preferredWidth;
			return val5;
		}
	}
	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_006c: Unknown result type (might be due to invalid IL or missing references)
			//IL_007b: 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)
			//IL_008a: Unknown result type (might be due to invalid IL or missing references)
			//IL_00aa: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ec: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f1: 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_0100: Unknown result type (might be due to invalid IL or missing references)
			//IL_0114: Unknown result type (might be due to invalid IL or missing references)
			//IL_0139: Unknown result type (might be due to invalid IL or missing references)
			//IL_0143: Expected O, but got Unknown
			//IL_0173: Unknown result type (might be due to invalid IL or missing references)
			//IL_017d: 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);
			val.GetComponent<Image>()?.MakeRounded(12, 48);
			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);
			if ((Object)(object)val2 != (Object)null)
			{
				val2.scrollSensitivity = 15f;
			}
			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_0090: 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_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;
			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;
			_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);
			}
			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_005d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0067: Expected O, but got Unknown
			GameObject val = UIFactory.Panel(name, (Transform)(object)_detailsContent, _theme.BgSecondary, (Vector2?)null, (Vector2?)null, false);
			val.GetComponent<Image>()?.MakeRounded();
			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_00cb: Unknown result type (might be due to invalid IL or missing references)
			//IL_0111: Unknown result type (might be due to invalid IL or missing references)
			//IL_0104: Unknown result type (might be due to invalid IL or missing references)
			//IL_0131: 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_0199: Expected O, but got Unknown
			//IL_0211: Unknown result type (might be due to invalid IL or missing references)
			//IL_02ad: Unknown result type (might be due to invalid IL or missing references)
			//IL_02f4: Unknown result type (might be due to invalid IL or missing references)
			//IL_0342: Unknown result type (might be due to invalid IL or missing references)
			//IL_039f: 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);
			val.GetComponent<Image>()?.MakeRounded();
			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, _theme.TextPrimary);
			((Selectable)val5).transition = (Transition)0;
			((Selectable)val5).interactable = true;
			((Behaviour)val5).enabled = false;
			val6.fontStyle = (FontStyle)1;
			val6.alignment = (TextAnchor)4;
			CheckAndCreateChangelogButton(mod, val.transform);
			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;
			string text = CheckAndFormatDependencies(mod);
			if (!string.IsNullOrEmpty(text))
			{
				Text val11 = UIFactory.Text("ModDependencies", text, card.transform, _theme.SizeSmall, (TextAnchor)0, (FontStyle)0);
				((Graphic)val11).color = _theme.TextSecondary;
				val11.supportRichText = true;
			}
			if (LogManager.Instance.HasErrorsForMod(((MelonBase)mod).Info.Name))
			{
				Text val12 = UIFactory.Text("ModErrors", "This mod has logged errors - click the Logs button for details", card.transform, _theme.SizeSmall, (TextAnchor)0, (FontStyle)0);
				((Graphic)val12).color = _theme.ErrorColor;
			}
		}

		private string CheckAndFormatDependencies(MelonMod mod)
		{
			//IL_0027: 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)
			ModDependencyInfo dependencies = _modManager.GetModDependencies(mod);
			string successColor = ColorUtility.ToHtmlStringRGB(_theme.SuccessColor);
			string errorColor = ColorUtility.ToHtmlStringRGB(_theme.ErrorColor);
			List<string> list = new List<string>();
			if (dependencies.Required.Count != 0)
			{
				IEnumerable<string> enumerable = from x in dependencies.Required.Select(delegate(string dep)
					{
						MelonMod modByAssemblyName2 = _modManager.GetModByAssemblyName(dep);
						if (modByAssemblyName2 != null)
						{
							return "<color=#" + successColor + ">" + ((MelonBase)modByAssemblyName2).Info.Name + " (" + ((MelonBase)modByAssemblyName2).Info.Version + ")</color>";
						}
						return (!dependencies.Missing.Contains(dep)) ? ("<color=#" + successColor + ">" + dep + " (found)</color>") : null;
					})
					where x != null
					select x;
				if (enumerable.Any())
				{
					list.Add("Depends on: " + string.Join(", ", enumerable));
				}
			}
			if (dependencies.Missing.Count != 0)
			{
				IEnumerable<string> values = dependencies.Missing.Select((string dep) => "<color=#" + errorColor + ">" + dep + " (missing)</color>");
				list.Add(string.Join(", ", values));
			}
			if (dependencies.Optional.Count != 0)
			{
				IEnumerable<string> values2 = dependencies.Optional.Select(delegate(string dep)
				{
					MelonMod modByAssemblyName = _modManager.GetModByAssemblyName(dep);
					return (modByAssemblyName != null) ? (((MelonBase)modByAssemblyName).Info.Name + " (" + ((MelonBase)modByAssemblyName).Info.Version + ")") : (dep + " (not found)");
				});
				list.Add("Optional dependencies: " + string.Join(", ", values2));
			}
			return string.Join(". ", list) + ((list.Count > 0) ? "." : "");
		}

		private void CheckAndCreateChangelogButton(MelonMod mod, Transform headerContainer)
		{
			//IL_0077: 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)
			string filepath;
			string changelog = _modManager.GetChangelog(mod, out filepath);
			if (!string.IsNullOrEmpty(changelog))
			{
				if ((Object)(object)ModsApp.ScrollIconSprite == (Object)null)
				{
					ModsApp.ScrollIconSprite = ModsApp.LoadEmbeddedPNG("ModsApp.assets.scroll-text.png");
				}
				(GameObject, Button, Image) tuple = UIHelper.RoundedButtonWithIcon("ChangelogButton", ModsApp.ScrollIconSprite, headerContainer, _theme.AccentSecondary, 25f, 25f, _theme.SizeSmall);
				Button item = tuple.Item2;
				Image item2 = tuple.Item3;
				((Graphic)item2).color = _theme.TextPrimary;
				EventHelper.AddListener((Action)delegate
				{
					//IL_006f: Unknown result type (might be due to invalid IL or missing references)
					//IL_008c: Unknown result type (might be due to invalid IL or missing references)
					//IL_00a2: 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_00ce: Unknown result type (might be due to invalid IL or missing references)
					//IL_00e4: Unknown result type (might be due to invalid IL or missing references)
					//IL_011b: Unknown result type (might be due to invalid IL or missing references)
					//IL_012b: 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_0166: Unknown result type (might be due to invalid IL or missing references)
					//IL_017d: Unknown result type (might be due to invalid IL or missing references)
					//IL_0194: Unknown result type (might be due to invalid IL or missing references)
					FloatingPanelComponent floatingPanelComponent = new FloatingPanelComponent(1000f, 500f, ((MelonBase)mod).Info.Name + " Changelog");
					Text val = UIFactory.Text("FilepathText", "Source: " + filepath, floatingPanelComponent.ContentPanel.transform, _theme.SizeSmall, (TextAnchor)3, (FontStyle)0);
					((Graphic)val).color = _theme.TextPrimary;
					RectTransform component = ((Component)val).GetComponent<RectTransform>();
					component.anchorMin = new Vector2(0f, 1f);
					component.anchorMax = new Vector2(1f, 1f);
					component.pivot = new Vector2(0.5f, 1f);
					component.sizeDelta = new Vector2(0f, 28f);
					component.anchoredPosition = new Vector2(2f, -8f);
					ScrollableTextFactory scrollableTextFactory = new ScrollableTextFactory(floatingPanelComponent.ContentPanel.transform, changelog, _theme.SizeStandard, _theme.InputPrimary, _theme.BgInput);
					RectTransform component2 = scrollableTextFactory.Root.GetComponent<RectTransform>();
					component2.anchorMin = new Vector2(0f, 0f);
					component2.anchorMax = new Vector2(1f, 1f);
					component2.offsetMin = new Vector2(6f, 6f);
					component2.offsetMax = new Vector2(-6f, -44f);
					Canvas.ForceUpdateCanvases();
					LayoutRebuilder.ForceRebuildLayoutImmediate(scrollableTextFactory.ContentRect);
				}, (UnityEvent)(object)item.onClick);
			}
		}

		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_003c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0097: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a1: Expected O, but got Unknown
			//IL_013c: Unknown result type (might be due to invalid IL or missing references)
			//IL_01f7: Unknown result type (might be due to invalid IL or missing references)
			//IL_0207: 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)
			//IL_0226: Unknown result type (might be due to invalid IL or missing references)
			GameObject categoryPanel = UIFactory.Panel(UIHelper.SanitizeName(category.Identifier) + "_Category", parent.transform, _theme.BgCategory, (Vector2?)null, (Vector2?)null, false);
			categoryPanel.GetComponent<Image>()?.MakeRounded();
			VerticalLayoutGroup orAddComponent = categoryPanel.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 = categoryPanel.GetOrAddComponent<ContentSizeFitter>();
			orAddComponent2.verticalFit = (FitMode)2;
			orAddComponent2.horizontalFit = (FitMode)0;
			LayoutElement orAddComponent3 = categoryPanel.GetOrAddComponent<LayoutElement>();
			orAddComponent3.preferredHeight = -1f;
			orAddComponent3.flexibleHeight = 0f;
			orAddComponent3.flexibleWidth = 1f;
			string categoryTitle = (string.IsNullOrWhiteSpace(category.DisplayName) ? category.Identifier : category.DisplayName);
			string text = ColorUtility.ToHtmlStringRGB(_theme.TextSecondary);
			string text2 = "<color=#" + text + ">▼</color>";
			string text3 = "<color=#" + text + ">▶</color>";
			Text title = UIFactory.Text(UIHelper.SanitizeName(category.Identifier) + "_Title", CategoryState.IsExpanded(category) ? (text2 + " " + categoryTitle) : (text3 + " " + categoryTitle), categoryPanel.transform, _theme.SizeStandard, (TextAnchor)0, (FontStyle)1);
			title.supportRichText = true;
			((Graphic)title).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;
			}
			Button val = ((Component)title).gameObject.AddComponent<Button>();
			EventHelper.AddListener((Action)delegate
			{
				//IL_0018: Unknown result type (might be due to invalid IL or missing references)
				CategoryState.Toggle(category);
				string text4 = ColorUtility.ToHtmlStringRGB(_theme.TextSecondary);
				string text5 = "<color=#" + text4 + ">▼</color>";
				string text6 = "<color=#" + text4 + ">▶</color>";
				title.text = (CategoryState.IsExpanded(category) ? (text5 + " " + categoryTitle) : (text6 + " " + categoryTitle));
				UpdateCategoryVisibility();
			}, (UnityEvent)(object)val.onClick);
			foreach (MelonPreferences_Entry entry in category.Entries)
			{
				CreatePreferenceEntry(entry, categoryPanel, category.Identifier);
			}
			UpdateCategoryVisibility();
			void UpdateCategoryVisibility()
			{
				for (int i = 0; i < categoryPanel.transform.childCount; i++)
				{
					Transform child = categoryPanel.transform.GetChild(i);
					if ((Object)(object)((Component)child).gameObject != (Object)(object)((Component)title).gameObject)
					{
						((Component)child).gameObject.SetActive(CategoryState.IsExpanded(category));
					}
				}
				RectTransform component = ((Component)categoryPanel.transform.parent).GetComponent<RectTransform>();
				if ((Object)(object)component != (Object)null)
				{
					UIHelper.RefreshLayout(component);
				}
			}
		}

		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_00bb: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c5: Expected O, but got Unknown
			//IL_0109: 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)
			//IL_0224: Unknown result type (might be due to invalid IL or missing references)
			//IL_02f4: Unknown result type (might be due to invalid IL or missing references)
			//IL_02fe: Unknown result type (might be due to invalid IL or missing references)
			//IL_03a0: Unknown result type (might be due to invalid IL or missing references)
			//IL_03aa: 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);
			val.GetComponent<Image>()?.MakeRounded(4, 16);
			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_00cb: Unknown result type (might be due to invalid IL or missing references)
			//IL_011b: 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)
			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, _theme.TextPrimary);
			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, _theme.TextPrimary);
			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));
			Controls.IsTyping = false;
			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));
			}
			Controls.IsTyping = false;
			_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_005a: 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_007a: 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_00a9: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b9: 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)
			//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_0114: Unknown result type (might be due to invalid IL or missing references)
			//IL_0124: Unknown result type (might be due to invalid IL or missing references)
			//IL_0134: 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_0163: Unknown result type (might be due to invalid IL or missing references)
			//IL_0173: Unknown result type (might be due to invalid IL or missing references)
			//IL_0183: 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 static Dictionary<MelonMod, Image> WarningIcons = new Dictionary<MelonMod, Image>();

		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_006c: Unknown result type (might be due to invalid IL or missing references)
			//IL_007b: 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)
			//IL_008a: Unknown result type (might be due to invalid IL or missing references)
			//IL_00aa: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ce: 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)
			//IL_0121: Unknown result type (might be due to invalid IL or missing references)
			//IL_0126: 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_0180: Unknown result type (might be due to invalid IL or missing references)
			//IL_0185: Unknown result type (might be due to invalid IL or missing references)
			//IL_018a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0194: Unknown result type (might be due to invalid IL or missing references)
			//IL_01a8: Unknown result type (might be due to invalid IL or missing references)
			//IL_01c9: Unknown result type (might be due to invalid IL or missing references)
			//IL_01d3: 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);
			val.GetComponent<Image>()?.MakeRounded(12, 48);
			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);
			val2.GetComponent<Image>()?.MakeRounded(12, 48);
			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);
			if ((Object)(object)val3 != (Object)null)
			{
				val3.scrollSensitivity = 15f;
			}
			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)