Decompiled source of ModSettingsMenu v1.0.6
BepInEx/plugins/ModSettingsMenu.dll
Decompiled a day ago
The result has been truncated due to the large size, download it to view full contents!
using System; using System.Collections.Generic; using System.Diagnostics; using System.Globalization; using System.IO; using System.Linq; using System.Net; using System.Net.Http; using System.Net.Sockets; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.InteropServices; using System.Runtime.Versioning; using System.Text; using System.Text.Json; using System.Threading; using System.Threading.Tasks; using BepInEx; using BepInEx.Bootstrap; using BepInEx.Configuration; using BepInEx.Core.Logging.Interpolation; using BepInEx.Logging; using BepInEx.NET.Common; using Candide; using Candide.CandideUI; using Candide.CandideUI.Components; using Candide.CandideUI.Components.Buttons; using Candide.CandideUI.Containers; using Candide.CandideUI.Input; using Candide.CandideUI.PauseMenuUi; using Candide.CandideUI.Windows; using Candide.Database; using Candide.Input; using Candide.MainMenu.Ui; using Candide.Sound; using Candide.Toolkit; using Candide.UserSettings; using CandideCreator.Shared; using CandideCreator.Shared.Graphics; using FontStashSharp.RichText; using HarmonyLib; using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; using Microsoft.Xna.Framework.Input; using ModSettingsMenu.Api; using ModSettingsMenu.Localization; using ModSettingsMenu.Metadata; using ModSettingsMenu.Ui; using ModSettingsMenu.Update; using Shared.Text; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)] [assembly: AssemblyTitle("Mod Settings Menu")] [assembly: AssemblyDescription("Mod Settings Menu for Romestead by Ice Box Studio")] [assembly: AssemblyCompany("Ice Box Studio")] [assembly: AssemblyProduct("Mod Settings Menu")] [assembly: AssemblyCopyright("Copyright © 2026 Ice Box Studio All rights reserved.")] [assembly: ComVisible(false)] [assembly: Guid("A59CDBF0-FC3E-4DD6-B514-8479E0FC91A6")] [assembly: AssemblyFileVersion("1.0.6.0")] [assembly: TargetFramework(".NETCoreApp,Version=v8.0", FrameworkDisplayName = ".NET 8.0")] [assembly: AssemblyVersion("1.0.6.0")] [module: RefSafetyRules(11)] namespace ModSettingsMenu { [BepInPlugin("IceBoxStudio.Romestead.ModSettingsMenu", "Mod Settings Menu", "1.0.6")] public sealed class ModSettingsMenu : BasePlugin { private Harmony _harmony; public static ModSettingsMenu Instance { get; private set; } internal static ManualLogSource Logger { get; private set; } public override void Load() { //IL_00f4: Unknown result type (might be due to invalid IL or missing references) //IL_00fa: Expected O, but got Unknown //IL_002a: Unknown result type (might be due to invalid IL or missing references) //IL_0030: Expected O, but got Unknown //IL_0059: Unknown result type (might be due to invalid IL or missing references) //IL_005f: Expected O, but got Unknown //IL_008f: Unknown result type (might be due to invalid IL or missing references) //IL_0099: Expected O, but got Unknown //IL_00b3: Unknown result type (might be due to invalid IL or missing references) //IL_00b9: Expected O, but got Unknown Instance = this; Logger = ((BasePlugin)this).Log; bool flag = default(bool); try { Logger.LogInfo((object)"============================================="); ManualLogSource logger = Logger; BepInExInfoLogInterpolatedStringHandler val = new BepInExInfoLogInterpolatedStringHandler(16, 1, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>("Mod Settings Menu"); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral(" initializing..."); } logger.LogInfo(val); ManualLogSource logger2 = Logger; val = new BepInExInfoLogInterpolatedStringHandler(48, 1, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val).AppendLiteral("Author: "); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>("Ice Box Studio"); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral("(https://steamcommunity.com/id/ibox666/)"); } logger2.LogInfo(val); _harmony = new Harmony("IceBoxStudio.Romestead.ModSettingsMenu"); _harmony.PatchAll(Assembly.GetExecutingAssembly()); ManualLogSource logger3 = Logger; val = new BepInExInfoLogInterpolatedStringHandler(13, 1, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>("Mod Settings Menu"); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral(" initialized."); } logger3.LogInfo(val); Logger.LogInfo((object)"============================================="); } catch (Exception ex) { ManualLogSource logger4 = Logger; BepInExErrorLogInterpolatedStringHandler val2 = new BepInExErrorLogInterpolatedStringHandler(24, 3, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val2).AppendFormatted<string>("Mod Settings Menu"); ((BepInExLogInterpolatedStringHandler)val2).AppendLiteral(" initialization error: "); ((BepInExLogInterpolatedStringHandler)val2).AppendFormatted<string>(ex.Message); ((BepInExLogInterpolatedStringHandler)val2).AppendLiteral("\n"); ((BepInExLogInterpolatedStringHandler)val2).AppendFormatted<string>(ex.StackTrace); } logger4.LogError(val2); } } } public static class PluginInfo { public const string PLUGIN_GUID = "IceBoxStudio.Romestead.ModSettingsMenu"; public const string PLUGIN_NAME = "Mod Settings Menu"; public const string PLUGIN_VERSION = "1.0.6"; public const string PLUGIN_AUTHOR = "Ice Box Studio"; } } namespace ModSettingsMenu.Update { internal static class ModUpdateChecker { private const int MaxManifestBytes = 16384; private static readonly TimeSpan Timeout = TimeSpan.FromSeconds(4.0); private static readonly Dictionary<string, ModUpdateCheckResult> Results = new Dictionary<string, ModUpdateCheckResult>(StringComparer.OrdinalIgnoreCase); private static readonly HashSet<string> StartedChecks = new HashSet<string>(StringComparer.OrdinalIgnoreCase); private static readonly object Sync = new object(); private static readonly HttpClient Client = new HttpClient(new HttpClientHandler { AllowAutoRedirect = false }) { Timeout = Timeout }; public static ModUpdateCheckResult GetOrStart(ModSettingsRegistration registration) { if (registration == null || string.IsNullOrWhiteSpace(registration.UpdateManifestUrl)) { return ModUpdateCheckResult.NotConfigured(); } lock (Sync) { if (Results.TryGetValue(registration.PluginGuid, out var value)) { return value; } if (StartedChecks.Add(registration.PluginGuid)) { Results[registration.PluginGuid] = ModUpdateCheckResult.Checking(); CheckAsync(registration.PluginGuid, registration.Version, registration.UpdateManifestUrl); } return Results[registration.PluginGuid]; } } private static async Task CheckAsync(string pluginGuid, string currentVersion, string manifestUrl) { ModUpdateCheckResult value = await CheckCoreAsync(currentVersion, manifestUrl).ConfigureAwait(continueOnCapturedContext: false); lock (Sync) { Results[pluginGuid] = value; } } private static async Task<ModUpdateCheckResult> CheckCoreAsync(string currentVersion, string manifestUrl) { _ = 4; try { if (!TryValidateHttpsUri(manifestUrl, out var uri)) { return Failed(); } IPAddress[] array = await Dns.GetHostAddressesAsync(uri.Host).ConfigureAwait(continueOnCapturedContext: false); if (array.Length == 0 || array.Any(IsUnsafeAddress)) { return Failed(); } using (CancellationTokenSource cts = new CancellationTokenSource(Timeout)) { using HttpResponseMessage response = await Client.GetAsync(uri, HttpCompletionOption.ResponseHeadersRead, cts.Token).ConfigureAwait(continueOnCapturedContext: false); if (response.StatusCode != HttpStatusCode.OK) { return Failed(); } string text = response.Content.Headers.ContentType?.MediaType; if (!string.IsNullOrWhiteSpace(text) && !text.Equals("application/json", StringComparison.OrdinalIgnoreCase) && !text.Equals("text/json", StringComparison.OrdinalIgnoreCase) && !text.Equals("text/plain", StringComparison.OrdinalIgnoreCase)) { return Failed(); } long? contentLength = response.Content.Headers.ContentLength; if (contentLength.HasValue && contentLength.Value > 16384) { return Failed(); } ModUpdateCheckResult result; await using (Stream stream = await response.Content.ReadAsStreamAsync(cts.Token).ConfigureAwait(continueOnCapturedContext: false)) { result = ParseManifest(await ReadLimitedStringAsync(stream, cts.Token).ConfigureAwait(continueOnCapturedContext: false), currentVersion); } return result; } IL_0475: ModUpdateCheckResult result2; return result2; } catch (OperationCanceledException) { return Failed(); } catch (Exception ex2) { ManualLogSource logger = ModSettingsMenu.Logger; if (logger != null) { bool flag = default(bool); BepInExWarningLogInterpolatedStringHandler val = new BepInExWarningLogInterpolatedStringHandler(21, 1, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val).AppendLiteral("Update check failed: "); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>(ex2.Message); } logger.LogWarning(val); } return Failed(); } } private static ModUpdateCheckResult ParseManifest(string json, string currentVersion) { using JsonDocument jsonDocument = JsonDocument.Parse(json); JsonElement rootElement = jsonDocument.RootElement; if (rootElement.ValueKind != JsonValueKind.Object) { return Failed(); } string text = GetString(rootElement, "version") ?? GetString(rootElement, "latestVersion"); if (string.IsNullOrWhiteSpace(text) || text.Length > 64) { return Failed(); } bool flag = IsRemoteVersionNewer(currentVersion, text); return new ModUpdateCheckResult { Status = (flag ? ModUpdateCheckStatus.UpdateAvailable : ModUpdateCheckStatus.UpToDate), LatestVersion = text }; } private static string GetString(JsonElement root, string propertyName) { if (!root.TryGetProperty(propertyName, out var value) || value.ValueKind != JsonValueKind.String) { return null; } return value.GetString(); } private static async Task<string> ReadLimitedStringAsync(Stream stream, CancellationToken cancellationToken) { using MemoryStream memory = new MemoryStream(); byte[] buffer = new byte[1024]; while (true) { int num = await stream.ReadAsync(buffer, 0, buffer.Length, cancellationToken).ConfigureAwait(continueOnCapturedContext: false); if (num == 0) { break; } if (memory.Length + num > 16384) { throw new InvalidOperationException("Manifest too large."); } memory.Write(buffer, 0, num); } string text = Encoding.UTF8.GetString(memory.ToArray()); return (text.Length > 0 && text[0] == '\ufeff') ? text.Substring(1) : text; } private static bool TryValidateHttpsUri(string url, out Uri uri) { uri = null; if (string.IsNullOrWhiteSpace(url) || url.Length > 2048 || !Uri.TryCreate(url, UriKind.Absolute, out uri)) { return false; } if (!uri.Scheme.Equals(Uri.UriSchemeHttps, StringComparison.OrdinalIgnoreCase)) { return false; } if (uri.UserInfo.Length > 0 || uri.IsFile || uri.IsLoopback || uri.HostNameType == UriHostNameType.Unknown) { return false; } return true; } private static bool IsUnsafeAddress(IPAddress address) { if (IPAddress.IsLoopback(address)) { return true; } if (address.AddressFamily == AddressFamily.InterNetwork) { byte[] addressBytes = address.GetAddressBytes(); if (addressBytes[0] != 10 && addressBytes[0] != 127 && addressBytes[0] != 0 && (addressBytes[0] != 169 || addressBytes[1] != 254) && (addressBytes[0] != 172 || addressBytes[1] < 16 || addressBytes[1] > 31)) { if (addressBytes[0] == 192) { return addressBytes[1] == 168; } return false; } return true; } if (address.AddressFamily == AddressFamily.InterNetworkV6) { if (!address.IsIPv6LinkLocal && !address.IsIPv6SiteLocal && !address.IsIPv6Multicast && !address.Equals(IPAddress.IPv6None) && !address.Equals(IPAddress.IPv6Any)) { return address.Equals(IPAddress.IPv6Loopback); } return true; } return true; } private static bool IsRemoteVersionNewer(string currentVersion, string latestVersion) { int[] array = ParseVersionParts(currentVersion); int[] array2 = ParseVersionParts(latestVersion); int num = Math.Max(array.Length, array2.Length); for (int i = 0; i < num; i++) { int num2 = ((i < array.Length) ? array[i] : 0); int num3 = ((i < array2.Length) ? array2[i] : 0); if (num3 > num2) { return true; } if (num3 < num2) { return false; } } return false; } private static int[] ParseVersionParts(string version) { if (string.IsNullOrWhiteSpace(version)) { return Array.Empty<int>(); } int result; return (from part in version.Split(new char[3] { '.', '-', '_' }, StringSplitOptions.RemoveEmptyEntries) select int.TryParse(new string(part.TakeWhile(char.IsDigit).ToArray()), out result) ? result : 0).ToArray(); } private static ModUpdateCheckResult Failed() { return new ModUpdateCheckResult { Status = ModUpdateCheckStatus.Failed }; } } internal enum ModUpdateCheckStatus { NotConfigured, Checking, UpToDate, UpdateAvailable, Failed } internal sealed class ModUpdateCheckResult { public ModUpdateCheckStatus Status { get; set; } public string LatestVersion { get; set; } public static ModUpdateCheckResult NotConfigured() { return new ModUpdateCheckResult { Status = ModUpdateCheckStatus.NotConfigured }; } public static ModUpdateCheckResult Checking() { return new ModUpdateCheckResult { Status = ModUpdateCheckStatus.Checking }; } } } namespace ModSettingsMenu.Ui { internal sealed class ModConfigEntryEditor : CandideVerticalStackPanel { private readonly ConfigEntryBase _entry; private readonly bool _keybind; private object _originalValue; public ModConfigEntryEditor(ConfigEntryBase entry, Action onChanged, ModSettingsEntryOptions options = null) { //IL_0044: 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_00ae: Unknown result type (might be due to invalid IL or missing references) //IL_00b5: Unknown result type (might be due to invalid IL or missing references) //IL_00bc: 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_00c9: 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_00e9: Expected O, but got Unknown _entry = entry; _keybind = options != null && options.Keybind && ModKeybindValue.IsSupportedType(entry.SettingType); _originalValue = entry.BoxedValue; ((CandideUiElement)this).HorizontalAlignment = (HorizontalAlignment)3; ((CandideUiElement)this).Margin = new CandideThickness(0, 0, 0, 7); ((CandideUiContainerMultipleItems)this).AddChild(CreateHeader(entry, options), false); if (_keybind) { ((CandideUiContainerMultipleItems)this).AddChild(CreateKeybindInfo(entry), false); return; } object obj; if (!string.IsNullOrWhiteSpace(options?.Description)) { obj = options.Description; } else { ConfigDescription description = entry.Description; obj = ((description != null) ? description.Description : null); } string text = (string)obj; if (!string.IsNullOrWhiteSpace(text)) { ((CandideUiContainerMultipleItems)this).AddChild((CandideUiElement)new CandideTextLabel { Text = text, Wrap = true, TextStyle = (CandideTextStyle)9, Margin = new CandideThickness(0, 1, 0, 3), MaxWidth = 290 }, false); } ((CandideUiContainerMultipleItems)this).AddChild(CreateControl(entry, onChanged, options), false); } public bool HasChanges() { if (_keybind) { return false; } return !object.Equals(_originalValue, _entry.BoxedValue); } public void Undo() { if (!_keybind) { _entry.BoxedValue = _originalValue; } } private static CandideUiElement CreateHeader(ConfigEntryBase entry, ModSettingsEntryOptions options) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0005: Unknown result type (might be due to invalid IL or missing references) //IL_0031: Unknown result type (might be due to invalid IL or missing references) //IL_0038: Unknown result type (might be due to invalid IL or missing references) //IL_0039: Unknown result type (might be due to invalid IL or missing references) //IL_003e: Unknown result type (might be due to invalid IL or missing references) //IL_0043: Unknown result type (might be due to invalid IL or missing references) //IL_0053: Unknown result type (might be due to invalid IL or missing references) //IL_005b: Expected O, but got Unknown return (CandideUiElement)new CandideTextLabel { Text = (string.IsNullOrWhiteSpace(options?.DisplayName) ? entry.Definition.Key : options.DisplayName), TextStyle = (CandideTextStyle)0, TextColor = Color.White, MaxWidth = 300, Wrap = true }; } private static CandideUiElement CreateControl(ConfigEntryBase entry, Action onChanged, ModSettingsEntryOptions options) { //IL_003e: Unknown result type (might be due to invalid IL or missing references) //IL_0043: Unknown result type (might be due to invalid IL or missing references) //IL_005d: Unknown result type (might be due to invalid IL or missing references) //IL_0062: 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_0087: Unknown result type (might be due to invalid IL or missing references) //IL_009f: Expected O, but got Unknown Type settingType = entry.SettingType; if (settingType == typeof(bool)) { CandideCheckboxLabel val = new CandideCheckboxLabel((CheckboxType)1, (int?)210, false) { Text = LocalizationManager.Instance.GetText("entry.bool_label"), Margin = new CandideThickness(0, 2, 0, 0) }; val.Checkbox.IsToggledOn = (bool)entry.BoxedValue; val.Checkbox.Toggled += delegate(object _, bool value) { entry.BoxedValue = value; onChanged(); }; return (CandideUiElement)val; } ConfigDescription description = entry.Description; if (((description != null) ? description.AcceptableValues : null) != null && TryCreateRangeSliderControl(entry, onChanged, options, out var control)) { return control; } ConfigDescription description2 = entry.Description; if (((description2 != null) ? description2.AcceptableValues : null) != null && TryCreateValueListControl(entry, onChanged, out var control2)) { return control2; } if (settingType.IsEnum) { return CreateEnumControl(entry, onChanged); } if (settingType == typeof(int)) { return CreateIntControl(entry, onChanged); } if (settingType == typeof(string)) { return CreateTextControl(entry, onChanged, isString: true); } return CreateTextControl(entry, onChanged, isString: false); } public void Commit() { if (!_keybind) { _originalValue = _entry.BoxedValue; } } private static CandideUiElement CreateKeybindInfo(ConfigEntryBase entry) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0005: Unknown result type (might be due to invalid IL or missing references) //IL_000c: Unknown result type (might be due to invalid IL or missing references) //IL_0011: Unknown result type (might be due to invalid IL or missing references) //IL_001c: Expected O, but got Unknown //IL_001d: Unknown result type (might be due to invalid IL or missing references) //IL_0022: Unknown result type (might be due to invalid IL or missing references) //IL_003c: Unknown result type (might be due to invalid IL or missing references) //IL_0043: Unknown result type (might be due to invalid IL or missing references) //IL_004b: Unknown result type (might be due to invalid IL or missing references) //IL_005b: 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) //IL_0065: 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_007a: Unknown result type (might be due to invalid IL or missing references) //IL_008a: Expected O, but got Unknown //IL_008b: Unknown result type (might be due to invalid IL or missing references) //IL_0091: Expected O, but got Unknown CandideVerticalStackPanel val = new CandideVerticalStackPanel { HorizontalAlignment = (HorizontalAlignment)3, Margin = new CandideThickness(0, 1, 0, 0) }; ((CandideUiContainerMultipleItems)val).AddChild((CandideUiElement)new CandideTextLabel { Text = LocalizationManager.Instance.GetText("entry.keybind_configure_hint"), Wrap = true, TextStyle = (CandideTextStyle)9, TextColor = new Color(255, 224, 161), MaxWidth = 290, Margin = new CandideThickness(0, 0, 0, 2) }, false); CandideTextLabel val2 = new CandideTextLabel(); val2.Text = LocalizationManager.Instance.GetText("entry.keybind_current", ModKeybindValue.FromEntry(entry).ToDisplayString()); val2.Wrap = true; val2.TextStyle = (CandideTextStyle)9; ((CandideUiElement)val2).MaxWidth = 290; ((CandideUiContainerMultipleItems)val).AddChild((CandideUiElement)(object)val2, false); return (CandideUiElement)(object)val; } private static bool TryCreateValueListControl(ConfigEntryBase entry, Action onChanged, out CandideUiElement control) { control = null; AcceptableValueBase acceptableValues = entry.Description.AcceptableValues; if (!(((object)acceptableValues).GetType().GetProperty("AcceptableValues")?.GetValue(acceptableValues) is Array { Length: not 0 } array)) { return false; } ValueSpinnerValue<object>[] array2 = new ValueSpinnerValue<object>[array.Length]; object boxedValue = entry.BoxedValue; ValueSpinnerValue<object> val = null; for (int i = 0; i < array.Length; i++) { object value = array.GetValue(i); ValueSpinnerValue<object> val2 = (array2[i] = new ValueSpinnerValue<object> { Value = value, Name = (value?.ToString() ?? string.Empty) }); if (object.Equals(value, boxedValue)) { val = val2; } } CandideValueSpinner<object> obj = new CandideValueSpinner<object>((IReadOnlyCollection<ValueSpinnerValue<object>>)(object)array2); ((CandideUiElement)obj).Width = 180; obj.OnClickLeftOrRightSoundEvent = "event:/interface/main menu/ui_mainmenu_click"; CandideValueSpinner<object> val3 = obj; if (val != null) { val3.Value = val; } val3.OnValueChanged += delegate(object _, ValueSpinnerValue<object> val4) { entry.BoxedValue = val4.Value; onChanged(); }; control = (CandideUiElement)(object)val3; return true; } private static bool TryCreateRangeSliderControl(ConfigEntryBase entry, Action onChanged, ModSettingsEntryOptions options, out CandideUiElement control) { //IL_00ee: Unknown result type (might be due to invalid IL or missing references) //IL_00f3: Unknown result type (might be due to invalid IL or missing references) //IL_0103: Unknown result type (might be due to invalid IL or missing references) //IL_0113: Unknown result type (might be due to invalid IL or missing references) //IL_011a: 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_012a: Expected O, but got Unknown //IL_018c: Unknown result type (might be due to invalid IL or missing references) //IL_0191: Unknown result type (might be due to invalid IL or missing references) //IL_019c: 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_01b3: Unknown result type (might be due to invalid IL or missing references) //IL_01d7: Unknown result type (might be due to invalid IL or missing references) //IL_01e9: Expected O, but got Unknown //IL_01e9: Unknown result type (might be due to invalid IL or missing references) //IL_01ee: Unknown result type (might be due to invalid IL or missing references) //IL_01f7: Expected O, but got Unknown //IL_0201: Unknown result type (might be due to invalid IL or missing references) //IL_0206: Unknown result type (might be due to invalid IL or missing references) //IL_0219: Unknown result type (might be due to invalid IL or missing references) //IL_0220: Unknown result type (might be due to invalid IL or missing references) //IL_022d: Unknown result type (might be due to invalid IL or missing references) //IL_0234: 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_0240: Unknown result type (might be due to invalid IL or missing references) //IL_024f: Expected O, but got Unknown control = null; AcceptableValueBase acceptableValues = entry.Description.AcceptableValues; if (acceptableValues == null || !((object)acceptableValues).GetType().IsGenericType || ((object)acceptableValues).GetType().GetGenericTypeDefinition() != typeof(AcceptableValueRange<>)) { return false; } Type settingType = entry.SettingType; if (!IsSupportedSliderRangeType(settingType)) { return false; } if (!TryGetDouble(((object)acceptableValues).GetType().GetProperty("MinValue")?.GetValue(acceptableValues), out var min) || !TryGetDouble(((object)acceptableValues).GetType().GetProperty("MaxValue")?.GetValue(acceptableValues), out var max) || !TryGetDouble(entry.BoxedValue, out var result) || max <= min) { return false; } CandideGrid val = new CandideGrid { ColumnsProportions = { Proportion.Auto }, ColumnsProportions = { Proportion.Auto }, HorizontalAlignment = (HorizontalAlignment)0, Margin = new CandideThickness(0, 2, 0, 0) }; double step = GetRangeStep(settingType, min, max, options); result = SnapRangeValue(result, min, max, step); object value = ConvertRangeValue(result, settingType); float sliderStepCount = GetSliderStepCount(min, max, step); CandideHorizontalSlider val2 = new CandideHorizontalSlider { Minimum = 0f, Maximum = sliderStepCount, StepValue = 1f, Value = GetSliderStepIndex(result, min, max, step, sliderStepCount), Width = 210 }; HorizontalBar val3 = new HorizontalBar { GridColumn = 0 }; ((CandideUiContainerSingleItem)val3).SetChild((CandideUiElement)(object)val2); CandideTextLabel valueText = new CandideTextLabel { Text = FormatRangeValue(value, settingType), GridColumn = 1, Width = 70, TextAlign = (TextHorizontalAlignment)2, VerticalAlignment = (VerticalAlignment)1, Margin = new CandideThickness(6, 0, 0, 0) }; val2.ValueChangedByUser += delegate(object _, float sliderValue) { object rangeValue = GetRangeValue(sliderValue, min, max, step, sliderStepCount, settingType); entry.BoxedValue = rangeValue; valueText.Text = FormatRangeValue(rangeValue, settingType); onChanged(); }; ((CandideUiContainerMultipleItems)val).AddChild((CandideUiElement)(object)val3, false); ((CandideUiContainerMultipleItems)val).AddChild((CandideUiElement)(object)valueText, false); control = (CandideUiElement)(object)val; return true; } private static double GetRangeStep(Type settingType, double min, double max, ModSettingsEntryOptions options) { double? num = options?.SliderStep; if (num.HasValue) { double valueOrDefault = num.GetValueOrDefault(); if (valueOrDefault > 0.0) { return Math.Min(valueOrDefault, max - min); } } if (!IsIntegerType(settingType)) { return 0.1; } return 1.0; } private static float GetSliderStepCount(double min, double max, double step) { if (step <= 0.0 || max <= min) { return 1f; } double num = (max - min) / step; double num2 = Math.Round(num); double num3 = ((Math.Abs(num - num2) < 1E-06) ? num2 : Math.Ceiling(num)); if (num3 < 1.0) { return 1f; } if (num3 > 3.4028234663852886E+38) { return float.MaxValue; } return (float)num3; } private static float GetSliderStepIndex(double value, double min, double max, double step, float sliderStepCount) { if (step <= 0.0 || sliderStepCount <= 0f) { return 0f; } if (value >= max) { return sliderStepCount; } double num = Math.Round((value - min) / step); if (num < 0.0) { return 0f; } if (num > (double)sliderStepCount) { return sliderStepCount; } return (float)num; } private static object GetRangeValue(float sliderValue, double min, double max, double step, float sliderStepCount, Type settingType) { return ConvertRangeValue(SnapRangeValue((sliderValue >= sliderStepCount) ? max : (min + step * (double)sliderValue), min, max, step), settingType); } private static object ConvertRangeValue(double value, Type settingType) { if (settingType == typeof(int)) { return (int)Math.Round(value); } if (settingType == typeof(long)) { return (long)Math.Round(value); } if (settingType == typeof(short)) { return (short)Math.Round(value); } if (settingType == typeof(byte)) { return (byte)Math.Round(value); } if (settingType == typeof(float)) { return (float)value; } if (settingType == typeof(double)) { return value; } if (settingType == typeof(decimal)) { return (decimal)value; } return value; } private static double SnapRangeValue(double value, double min, double max, double step) { if (value <= min) { return min; } if (value >= max) { return max; } if (step > 0.0) { value = min + Math.Round((value - min) / step) * step; } if (value < min) { value = min; } if (value > max) { value = max; } return value; } private static bool TryGetDouble(object value, out double result) { try { result = Convert.ToDouble(value, CultureInfo.InvariantCulture); return true; } catch { result = 0.0; return false; } } private static bool IsSupportedSliderRangeType(Type type) { if (!IsIntegerType(type) && !(type == typeof(float)) && !(type == typeof(double))) { return type == typeof(decimal); } return true; } private static bool IsIntegerType(Type type) { if (!(type == typeof(int)) && !(type == typeof(long)) && !(type == typeof(short))) { return type == typeof(byte); } return true; } private static string FormatRangeValue(object value, Type settingType) { if (IsIntegerType(settingType)) { return Convert.ToInt64(value, CultureInfo.InvariantCulture).ToString(CultureInfo.InvariantCulture); } return Convert.ToDouble(value, CultureInfo.InvariantCulture).ToString("G5", CultureInfo.InvariantCulture); } private static CandideUiElement CreateEnumControl(ConfigEntryBase entry, Action onChanged) { Array values = Enum.GetValues(entry.SettingType); ValueSpinnerValue<object>[] array = new ValueSpinnerValue<object>[values.Length]; object boxedValue = entry.BoxedValue; ValueSpinnerValue<object> val = null; for (int i = 0; i < values.Length; i++) { object value = values.GetValue(i); ValueSpinnerValue<object> val2 = (array[i] = new ValueSpinnerValue<object> { Value = value, Name = value.ToString() }); if (object.Equals(value, boxedValue)) { val = val2; } } CandideValueSpinner<object> obj = new CandideValueSpinner<object>((IReadOnlyCollection<ValueSpinnerValue<object>>)(object)array); ((CandideUiElement)obj).Width = 180; obj.OnClickLeftOrRightSoundEvent = "event:/interface/main menu/ui_mainmenu_click"; CandideValueSpinner<object> val3 = obj; if (val != null) { val3.Value = val; } val3.OnValueChanged += delegate(object _, ValueSpinnerValue<object> val4) { entry.BoxedValue = val4.Value; onChanged(); }; return (CandideUiElement)(object)val3; } private static CandideUiElement CreateIntControl(ConfigEntryBase entry, Action onChanged) { //IL_0014: Unknown result type (might be due to invalid IL or missing references) //IL_0019: Unknown result type (might be due to invalid IL or missing references) //IL_0024: Unknown result type (might be due to invalid IL or missing references) //IL_0029: Unknown result type (might be due to invalid IL or missing references) //IL_0033: Unknown result type (might be due to invalid IL or missing references) //IL_003f: Unknown result type (might be due to invalid IL or missing references) //IL_005a: Unknown result type (might be due to invalid IL or missing references) //IL_0072: Expected O, but got Unknown CandideIntSpinnerLabel val = new CandideIntSpinnerLabel { Text = "", Margin = new CandideThickness(0, 2, 0, 0) }; val.IntSpinner.AllowPlayerInput = true; val.IntSpinner.Value = (int)entry.BoxedValue; val.IntSpinner.ValueChangedByUser += delegate(object _, int value) { entry.BoxedValue = value; onChanged(); }; return (CandideUiElement)val; } private static CandideUiElement CreateTextControl(ConfigEntryBase entry, Action onChanged, bool isString) { //IL_001b: Unknown result type (might be due to invalid IL or missing references) //IL_0020: Unknown result type (might be due to invalid IL or missing references) //IL_0030: Unknown result type (might be due to invalid IL or missing references) //IL_0040: Unknown result type (might be due to invalid IL or missing references) //IL_0047: Unknown result type (might be due to invalid IL or missing references) //IL_0057: Unknown result type (might be due to invalid IL or missing references) //IL_005c: 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_006c: 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_00a7: 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_00c4: Unknown result type (might be due to invalid IL or missing references) //IL_00c7: Unknown result type (might be due to invalid IL or missing references) //IL_00d1: Unknown result type (might be due to invalid IL or missing references) //IL_00dd: 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_00f8: Expected O, but got Unknown //IL_011a: 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_0139: Unknown result type (might be due to invalid IL or missing references) //IL_0140: Unknown result type (might be due to invalid IL or missing references) //IL_0145: Unknown result type (might be due to invalid IL or missing references) //IL_014f: Unknown result type (might be due to invalid IL or missing references) //IL_0152: 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_0168: Expected O, but got Unknown //IL_017a: 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_0190: Expected O, but got Unknown CandideGrid val = new CandideGrid { ColumnsProportions = { Proportion.Fill }, ColumnsProportions = { Proportion.Auto }, HorizontalAlignment = (HorizontalAlignment)3, MaxWidth = 300, Margin = new CandideThickness(0, 2, 0, 0) }; CandideTextInputBox input = new CandideTextInputBox { Text = (isString ? (((string)entry.BoxedValue) ?? string.Empty) : entry.GetSerializedValue()), SelectAllWhenSelected = true, Width = 220, Height = 18, Padding = new CandideThickness(4, 2), Background = new Color(22, 19, 15, 190), GridColumn = 0 }; input.TextChangedByUser += delegate(object _, ValueChangedEventArgs<string> args) { if (isString) { entry.BoxedValue = args.NewValue ?? string.Empty; } else { entry.SetSerializedValue(args.NewValue ?? string.Empty); } onChanged(); }; CandideLabelButton val2 = new CandideLabelButton(48, (int?)null) { Text = LocalizationManager.Instance.GetText("entry.reset"), GridColumn = 1, Margin = new CandideThickness(5, 0, 0, 0), Padding = new CandideThickness(4, 2), OnClickedSoundEvent = "event:/interface/navigate" }; ((CandideButtonBase)val2).OnClickAction = delegate { string text = entry.DefaultValue?.ToString() ?? string.Empty; input.Text = text; if (isString) { entry.BoxedValue = text; } else { entry.SetSerializedValue(text); } onChanged(); }; ((CandideUiContainerMultipleItems)val).AddChild((CandideUiElement)(object)input, false); ((CandideUiContainerMultipleItems)val).AddChild((CandideUiElement)(object)val2, false); return (CandideUiElement)val; } } internal sealed class ModConfigIconLabel : CandideGrid { private readonly CandideIcon _builtinIcon; private readonly ModIconImage _customIcon; private readonly CandideTextLabel _label; private bool _hideIcon; public string Icon { get { return _builtinIcon.Icon; } set { _builtinIcon.Icon = value; UpdateIconVisibility(); } } public string IconPath { get { return _customIcon.IconPath; } set { _customIcon.IconPath = value; UpdateIconVisibility(); } } public string Text { get { return _label.Text; } set { if (!(_label.Text == value)) { _label.Text = value; ((CandideUiElement)_label).Visible = !string.IsNullOrWhiteSpace(value); ((CandideUiElement)this).InvalidateMeasure(); } } } public Color TextColor { get { //IL_0006: Unknown result type (might be due to invalid IL or missing references) return _label.TextColor; } set { //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_0007: Unknown result type (might be due to invalid IL or missing references) _label.TextColor = value; } } public bool HideIcon { get { return _hideIcon; } set { _hideIcon = value; UpdateIconVisibility(); } } public ModConfigIconLabel(IconFlag sizeFlags, bool flipOrientation = false, int? labelWidth = null, bool useTranslationCenteredText = false) { //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_0008: Unknown result type (might be due to invalid IL or missing references) //IL_000d: Unknown result type (might be due to invalid IL or missing references) //IL_001c: Expected O, but got Unknown //IL_001d: 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_009a: Unknown result type (might be due to invalid IL or missing references) //IL_00a1: Unknown result type (might be due to invalid IL or missing references) //IL_003e: Unknown result type (might be due to invalid IL or missing references) //IL_0043: Unknown result type (might be due to invalid IL or missing references) //IL_004a: Unknown result type (might be due to invalid IL or missing references) //IL_00b4: 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_005d: Unknown result type (might be due to invalid IL or missing references) //IL_0052: Unknown result type (might be due to invalid IL or missing references) //IL_00be: Unknown result type (might be due to invalid IL or missing references) //IL_00c5: Unknown result type (might be due to invalid IL or missing references) //IL_0067: 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_00d2: Unknown result type (might be due to invalid IL or missing references) //IL_00d9: Unknown result type (might be due to invalid IL or missing references) //IL_00e3: 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_0082: 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_00ef: Expected O, but got Unknown _builtinIcon = new CandideIcon(sizeFlags) { GridColumn = (flipOrientation ? 1 : 0) }; ModIconImage modIconImage = new ModIconImage(sizeFlags); ((CandideUiElement)modIconImage).GridColumn = (flipOrientation ? 1 : 0); ((CandideUiElement)modIconImage).Visible = false; _customIcon = modIconImage; _label = (CandideTextLabel)(useTranslationCenteredText ? new TranslationCenteredTextLayout { Width = labelWidth, Margin = (flipOrientation ? new CandideThickness(0, 0, 4, 0) : new CandideThickness(4, 0, 0, 0)), VerticalAlignment = (VerticalAlignment)1, TextAlign = (TextHorizontalAlignment)(flipOrientation ? 2 : 0), HorizontalAlignment = (HorizontalAlignment)3, GridColumn = ((!flipOrientation) ? 1 : 0), Visible = false } : new CandideTextLabel { Width = labelWidth, Margin = (flipOrientation ? new CandideThickness(0, 0, 4, 0) : new CandideThickness(4, 0, 0, 0)), VerticalAlignment = (VerticalAlignment)1, TextAlign = (TextHorizontalAlignment)(flipOrientation ? 2 : 0), HorizontalAlignment = (HorizontalAlignment)3, GridColumn = ((!flipOrientation) ? 1 : 0), Visible = false }); if (flipOrientation) { base.ColumnsProportions.Add(Proportion.Fill); base.ColumnsProportions.Add(Proportion.Auto); ((CandideUiContainerMultipleItems)this).AddChild((CandideUiElement)(object)_label, false); ((CandideUiContainerMultipleItems)this).AddChild((CandideUiElement)(object)_builtinIcon, false); ((CandideUiContainerMultipleItems)this).AddChild((CandideUiElement)(object)_customIcon, false); } else { base.ColumnsProportions.Add(Proportion.Auto); base.ColumnsProportions.Add(Proportion.Fill); ((CandideUiContainerMultipleItems)this).AddChild((CandideUiElement)(object)_builtinIcon, false); ((CandideUiContainerMultipleItems)this).AddChild((CandideUiElement)(object)_customIcon, false); ((CandideUiContainerMultipleItems)this).AddChild((CandideUiElement)(object)_label, false); } } private void UpdateIconVisibility() { bool flag = !_hideIcon && _customIcon.HasTexture; ((CandideUiElement)_customIcon).Visible = flag; ((CandideUiElement)_builtinIcon).Visible = !_hideIcon && !flag; ((CandideUiElement)this).InvalidateMeasure(); } } internal static class ModConfigInfoBlock { internal static CandideUiElement Create(ModPluginConfig pluginConfig) { //IL_0056: Unknown result type (might be due to invalid IL or missing references) //IL_005b: Unknown result type (might be due to invalid IL or missing references) //IL_0062: 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_0082: 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_008f: 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_009e: 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_00bb: Expected O, but got Unknown //IL_00da: Unknown result type (might be due to invalid IL or missing references) //IL_00df: Unknown result type (might be due to invalid IL or missing references) //IL_00eb: 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_00f4: Unknown result type (might be due to invalid IL or missing references) //IL_00f9: Unknown result type (might be due to invalid IL or missing references) //IL_00fe: 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_0115: 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_0131: Expected O, but got Unknown ModSettingsRegistration registration = pluginConfig.Registration; if (registration == null) { return null; } string text = BuildMetaText(registration); bool flag = !string.IsNullOrWhiteSpace(registration.Description); bool hasValue = registration.NexusModsId.HasValue; bool flag2 = !string.IsNullOrWhiteSpace(registration.UpdateManifestUrl); if (string.IsNullOrWhiteSpace(text) && !flag && !hasValue && !flag2) { return null; } CandideVerticalStackPanel val = new CandideVerticalStackPanel { HorizontalAlignment = (HorizontalAlignment)3, Width = 300, MaxWidth = 300, Padding = new CandideThickness(7, 6), Margin = new CandideThickness(0, 0, 0, 8), Background = new Color(26, 18, 12, 190) }; CandideUiElement val2 = CreateHeader(registration, text, hasValue, flag2); if (val2 != null) { ((CandideUiContainerMultipleItems)val).AddChild(val2, false); } if (flag) { ((CandideUiContainerMultipleItems)val).AddChild((CandideUiElement)new CandideTextLabel { Text = registration.Description, TextStyle = (CandideTextStyle)9, TextColor = Color.White, Wrap = true, MaxWidth = 286, Margin = new CandideThickness(0, (val2 != null) ? 4 : 0, 0, 0) }, false); } return (CandideUiElement)(object)val; } internal static string GetNexusModsUrl(int nexusModsId) { if (nexusModsId <= 0) { return null; } return "https://www.nexusmods.com/romestead/mods/" + nexusModsId; } private static CandideUiElement CreateHeader(ModSettingsRegistration registration, string meta, bool hasNexusModsLink, bool hasUpdateCheck) { //IL_0016: Unknown result type (might be due to invalid IL or missing references) //IL_001b: Unknown result type (might be due to invalid IL or missing references) //IL_0022: Unknown result type (might be due to invalid IL or missing references) //IL_0032: Unknown result type (might be due to invalid IL or missing references) //IL_0042: Unknown result type (might be due to invalid IL or missing references) //IL_0052: Unknown result type (might be due to invalid IL or missing references) //IL_0062: Unknown result type (might be due to invalid IL or missing references) //IL_0073: Expected O, but got Unknown //IL_007c: Unknown result type (might be due to invalid IL or missing references) //IL_0081: Unknown result type (might be due to invalid IL or missing references) //IL_0088: 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_00a0: Unknown result type (might be due to invalid IL or missing references) //IL_00a5: Unknown result type (might be due to invalid IL or missing references) //IL_00aa: 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_00c8: Unknown result type (might be due to invalid IL or missing references) //IL_00d5: Expected O, but got Unknown CandideUiElement val = CreateLinksPanel(registration, hasNexusModsLink, hasUpdateCheck); if (string.IsNullOrWhiteSpace(meta) && val == null) { return null; } CandideGrid val2 = new CandideGrid { HorizontalAlignment = (HorizontalAlignment)3, Width = 286, MaxWidth = 286, ColumnsProportions = { Proportion.Fill }, ColumnsProportions = { Proportion.Auto }, RowsProportions = { Proportion.Auto } }; if (!string.IsNullOrWhiteSpace(meta)) { ((CandideUiContainerMultipleItems)val2).AddChild((CandideUiElement)new CandideTextLabel { Text = meta, TextStyle = (CandideTextStyle)9, TextColor = new Color(226, 207, 177), Wrap = true, MaxWidth = ((val == null) ? 286 : 110), GridColumn = 0 }, false); } if (val != null) { ((CandideUiContainerMultipleItems)val2).AddChild(val, false); } return (CandideUiElement)(object)val2; } private static CandideUiElement CreateLinksPanel(ModSettingsRegistration registration, bool hasNexusModsLink, bool hasUpdateCheck) { //IL_0008: Unknown result type (might be due to invalid IL or missing references) //IL_000d: Unknown result type (might be due to invalid IL or missing references) //IL_0014: Unknown result type (might be due to invalid IL or missing references) //IL_001b: Unknown result type (might be due to invalid IL or missing references) //IL_0022: Unknown result type (might be due to invalid IL or missing references) //IL_0032: Unknown result type (might be due to invalid IL or missing references) //IL_0037: Unknown result type (might be due to invalid IL or missing references) //IL_0042: Expected O, but got Unknown if (!hasNexusModsLink && !hasUpdateCheck) { return null; } CandideHorizontalStackPanel val = new CandideHorizontalStackPanel { GridRow = 0, GridColumn = 1, HorizontalAlignment = (HorizontalAlignment)2, MaxWidth = 190, Margin = new CandideThickness(6, 0, 0, 4) }; if (hasNexusModsLink) { ((CandideUiContainerMultipleItems)val).AddChild(CreateTextLink(LocalizationManager.Instance.GetText("button.nexusmods"), GetNexusModsUrl(registration.NexusModsId.Value)), false); } if (hasUpdateCheck) { ((CandideUiContainerMultipleItems)val).AddChild((CandideUiElement)(object)new ModUpdateStatusLabel(registration), false); } return (CandideUiElement)(object)val; } private static CandideUiElement CreateTextLink(string text, string url) { //IL_000d: Unknown result type (might be due to invalid IL or missing references) //IL_0012: Unknown result type (might be due to invalid IL or missing references) //IL_0019: 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_0031: Unknown result type (might be due to invalid IL or missing references) //IL_0036: Unknown result type (might be due to invalid IL or missing references) //IL_003b: Unknown result type (might be due to invalid IL or missing references) //IL_0042: Unknown result type (might be due to invalid IL or missing references) //IL_0049: Unknown result type (might be due to invalid IL or missing references) //IL_0056: Unknown result type (might be due to invalid IL or missing references) //IL_005b: Unknown result type (might be due to invalid IL or missing references) //IL_0065: Unknown result type (might be due to invalid IL or missing references) //IL_0070: Unknown result type (might be due to invalid IL or missing references) //IL_0083: Expected O, but got Unknown CandideTextLabel val = new CandideTextLabel { Text = text, TextStyle = (CandideTextStyle)9, TextColor = new Color(226, 207, 177), TextAlign = (TextHorizontalAlignment)2, HorizontalAlignment = (HorizontalAlignment)2, MaxWidth = 105, Margin = new CandideThickness(0, 0, 7, 0), OnClickedSoundEvent = "event:/interface/navigate" }; ((CandideUiElement)val).Clicked += delegate { UrlHelper.OpenUrl(url, false); }; return (CandideUiElement)val; } private static string BuildMetaText(ModSettingsRegistration registration) { if (!string.IsNullOrWhiteSpace(registration.Version) && !string.IsNullOrWhiteSpace(registration.Author)) { return registration.Version + " - " + registration.Author; } if (!string.IsNullOrWhiteSpace(registration.Version)) { return registration.Version; } if (!string.IsNullOrWhiteSpace(registration.Author)) { return registration.Author; } return null; } } internal sealed class ModConfigListItem : CandideListBase { private readonly ModConfigIconLabel _iconLabel; public string Icon { get { return _iconLabel.Icon; } set { _iconLabel.Icon = value; } } public string IconPath { get { return _iconLabel.IconPath; } set { _iconLabel.IconPath = value; } } public string Text { get { return _iconLabel.Text; } set { _iconLabel.Text = value; } } public Color TextColor { get { //IL_0006: Unknown result type (might be due to invalid IL or missing references) return _iconLabel.TextColor; } set { //IL_0006: Unknown result type (might be due to invalid IL or missing references) _iconLabel.TextColor = value; } } public ModConfigListItem(string iconId, string iconPath, IconFlag sizeFlag, int labelWidth) { //IL_000b: Unknown result type (might be due to invalid IL or missing references) //IL_0023: Unknown result type (might be due to invalid IL or missing references) //IL_0028: Unknown result type (might be due to invalid IL or missing references) //IL_0030: Expected O, but got Unknown //IL_0031: Unknown result type (might be due to invalid IL or missing references) ((CandideUiElement)this).Padding = new CandideThickness(2, 2, 6, 3); ((CandideUiElement)this).HorizontalAlignment = (HorizontalAlignment)3; ((CandideToggleButton)this).LockWhenToggledOn = true; CandidePanel val = new CandidePanel { HorizontalAlignment = (HorizontalAlignment)3 }; _iconLabel = new ModConfigIconLabel(sizeFlag, flipOrientation: false, labelWidth, useTranslationCenteredText: true) { Icon = iconId, IconPath = iconPath }; ((CandideUiContainerMultipleItems)val).AddChild((CandideUiElement)(object)_iconLabel, false); ((CandideUiContainerSingleItem)this).SetChild((CandideUiElement)(object)val); } } internal sealed class ModConfigPanel : CandideUiContainerSingleItem, ISettingsCategoryUi { private readonly ModConfigIconLabel _titleIconLabel; private readonly CandidePanelSingleChild _contentPanel; private readonly CandideHorizontalStackPanel _buttonPanel; private readonly YesButton _yesButton; private readonly NoIconLabelButton _noButton; private readonly List<ModConfigEntryEditor> _editors; private ConfigFile _currentConfigFile; private ModPluginConfig _currentPluginConfig; private bool _currentConfigFileOriginalSaveOnConfigSet; private bool _hasCurrentConfigFileOriginalSaveOnConfigSet; public string CurrentPluginGuid => _currentPluginConfig?.Guid; public ModConfigPanel() { //IL_002a: Unknown result type (might be due to invalid IL or missing references) //IL_0041: Unknown result type (might be due to invalid IL or missing references) //IL_006f: 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_0084: 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_00a4: Unknown result type (might be due to invalid IL or missing references) //IL_00b4: 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_00cb: Unknown result type (might be due to invalid IL or missing references) //IL_00d3: Expected O, but got Unknown //IL_00d4: Unknown result type (might be due to invalid IL or missing references) //IL_00d9: Unknown result type (might be due to invalid IL or missing references) //IL_00de: Unknown result type (might be due to invalid IL or missing references) //IL_00e8: Unknown result type (might be due to invalid IL or missing references) //IL_00ef: Unknown result type (might be due to invalid IL or missing references) //IL_00fb: Expected O, but got Unknown //IL_00fc: Unknown result type (might be due to invalid IL or missing references) //IL_0101: Unknown result type (might be due to invalid IL or missing references) //IL_0108: Unknown result type (might be due to invalid IL or missing references) //IL_010d: Unknown result type (might be due to invalid IL or missing references) //IL_0117: 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_012a: Expected O, but got Unknown //IL_012d: Unknown result type (might be due to invalid IL or missing references) //IL_0132: Unknown result type (might be due to invalid IL or missing references) //IL_0138: Unknown result type (might be due to invalid IL or missing references) //IL_0142: Unknown result type (might be due to invalid IL or missing references) //IL_0154: Unknown result type (might be due to invalid IL or missing references) //IL_015f: 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_016b: Unknown result type (might be due to invalid IL or missing references) //IL_0175: Unknown result type (might be due to invalid IL or missing references) //IL_0178: Unknown result type (might be due to invalid IL or missing references) //IL_0187: Expected O, but got Unknown //IL_018a: Unknown result type (might be due to invalid IL or missing references) //IL_018f: Unknown result type (might be due to invalid IL or missing references) //IL_0195: Unknown result type (might be due to invalid IL or missing references) //IL_019f: Unknown result type (might be due to invalid IL or missing references) //IL_01b1: Unknown result type (might be due to invalid IL or missing references) //IL_01bc: 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_01c8: Unknown result type (might be due to invalid IL or missing references) //IL_01d2: Unknown result type (might be due to invalid IL or missing references) //IL_01d5: Unknown result type (might be due to invalid IL or missing references) //IL_01e4: Expected O, but got Unknown //IL_0223: Unknown result type (might be due to invalid IL or missing references) //IL_0228: Unknown result type (might be due to invalid IL or missing references) //IL_022f: Unknown result type (might be due to invalid IL or missing references) //IL_0236: 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_024b: Expected O, but got Unknown ModConfigIconLabel obj = new ModConfigIconLabel((IconFlag)1) { Text = "Mod Settings", Icon = "cog" }; ((CandideUiElement)obj).Padding = new CandideThickness(6); ((CandideUiElement)obj).HorizontalAlignment = (HorizontalAlignment)3; ((CandideUiElement)obj).Margin = new CandideThickness(6, 0, 0, 12); _titleIconLabel = obj; _editors = new List<ModConfigEntryEditor>(); ((CandideUiContainerSingleItem)this)..ctor(); ((CandideUiElement)this).HorizontalAlignment = (HorizontalAlignment)3; ((CandideUiElement)this).VerticalAlignment = (VerticalAlignment)3; CandideGrid val = new CandideGrid { RowsProportions = { Proportion.Auto }, RowsProportions = { Proportion.Fill }, RowsProportions = { Proportion.Auto }, RowsProportions = { Proportion.Auto }, ColumnsProportions = { Proportion.Fill }, VerticalAlignment = (VerticalAlignment)3, HorizontalAlignment = (HorizontalAlignment)3 }; _contentPanel = new CandidePanelSingleChild { Padding = new CandideThickness(8, 0, 0, 0), GridRow = 1, HorizontalAlignment = (HorizontalAlignment)3 }; _buttonPanel = new CandideHorizontalStackPanel { GridRow = 3, Padding = new CandideThickness(8, 8, 0, 0), HorizontalAlignment = (HorizontalAlignment)1, ControllerUseDefaultNavigation = true }; _yesButton = new YesButton(60) { StringId = StringId.op_Implicit("Ui_Apply"), OnClickAction = Save, OnClickedSoundEvent = "event:/interface/navigate", Enabled = false, Margin = new CandideThickness(3, 0, 3, 3), Padding = new CandideThickness(6, 4) }; _noButton = new NoIconLabelButton(60) { StringId = StringId.op_Implicit("Ui_Cancel"), OnClickAction = Reset, OnClickedSoundEvent = "event:/interface/navigate", Enabled = false, Margin = new CandideThickness(3, 0, 3, 3), Padding = new CandideThickness(6, 4) }; ((CandideUiContainerMultipleItems)_buttonPanel).AddChild((CandideUiElement)(object)_yesButton, false); ((CandideUiContainerMultipleItems)_buttonPanel).AddChild((CandideUiElement)(object)_noButton, false); ((CandideUiContainerMultipleItems)val).AddChild((CandideUiElement)(object)_titleIconLabel, false); ((CandideUiContainerMultipleItems)val).AddChild((CandideUiElement)(object)_contentPanel, false); ((CandideUiContainerMultipleItems)val).AddChild((CandideUiElement)new CandideHorizontalSeparator { HorizontalAlignment = (HorizontalAlignment)3, GridRow = 2, Padding = new CandideThickness(0, 1, 0, 0) }, false); ((CandideUiContainerMultipleItems)val).AddChild((CandideUiElement)(object)_buttonPanel, false); ((CandideUiContainerSingleItem)this).SetChild((CandideUiElement)(object)val); } public void ShowPlugin(ModPluginConfig pluginConfig) { //IL_012f: 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_013b: Unknown result type (might be due to invalid IL or missing references) //IL_014c: Expected O, but got Unknown //IL_0177: Unknown result type (might be due to invalid IL or missing references) //IL_017c: Unknown result type (might be due to invalid IL or missing references) //IL_0196: Unknown result type (might be due to invalid IL or missing references) //IL_019d: Unknown result type (might be due to invalid IL or missing references) //IL_01a5: Unknown result type (might be due to invalid IL or missing references) //IL_01b5: Unknown result type (might be due to invalid IL or missing references) //IL_01bc: Unknown result type (might be due to invalid IL or missing references) //IL_01c1: Unknown result type (might be due to invalid IL or missing references) //IL_01d1: Expected O, but got Unknown //IL_0237: Unknown result type (might be due to invalid IL or missing references) //IL_023c: Unknown result type (might be due to invalid IL or missing references) //IL_0259: Unknown result type (might be due to invalid IL or missing references) //IL_0269: Unknown result type (might be due to invalid IL or missing references) //IL_026e: Unknown result type (might be due to invalid IL or missing references) //IL_0273: Unknown result type (might be due to invalid IL or missing references) //IL_0278: Unknown result type (might be due to invalid IL or missing references) //IL_0288: Expected O, but got Unknown //IL_0215: Unknown result type (might be due to invalid IL or missing references) //IL_021a: Unknown result type (might be due to invalid IL or missing references) //IL_0221: 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_0236: Expected O, but got Unknown LocalizationManager.Instance.RefreshLanguage(forceNotify: false); ConfigFile configFile = pluginConfig.ConfigFile; if (_currentConfigFile != null && _currentConfigFile != configFile) { EndEditing(undo: true); } BeginEditing(configFile); _currentPluginConfig = pluginConfig; _editors.Clear(); _titleIconLabel.Text = pluginConfig.Name; _titleIconLabel.Icon = pluginConfig.Icon; _titleIconLabel.IconPath = pluginConfig.IconPath; ((CandideUiElement)_buttonPanel).Visible = true; ConfigEntryBase[] array = (from entry in configFile.Values where !ModSettingsMetadataResolver.IsEntryHidden(pluginConfig, entry) orderby ModSettingsMetadataResolver.GetSectionOrder(pluginConfig, entry.Definition.Section), ModSettingsMetadataResolver.GetEntryOrder(pluginConfig, entry), entry.Definition.Section, entry.Definition.Key select entry).ToArray(); CandideVerticalStackPanel val = new CandideVerticalStackPanel { HorizontalAlignment = (HorizontalAlignment)3, MaxWidth = 306 }; CandideUiElement val2 = ModConfigInfoBlock.Create(pluginConfig); if (val2 != null) { ((CandideUiContainerMultipleItems)val).AddChild(val2, false); } if (array.Length == 0) { ((CandideUiElement)_buttonPanel).Visible = false; ((CandideUiContainerMultipleItems)val).AddChild((CandideUiElement)new CandideTextLabel { Text = LocalizationManager.Instance.GetText("panel.no_public_entries"), Wrap = true, TextStyle = (CandideTextStyle)9, MaxWidth = 290, HorizontalAlignment = (HorizontalAlignment)3, Margin = new CandideThickness(0, 4, 0, 0) }, false); ((CandideUiContainerSingleItem)_contentPanel).SetChild((CandideUiElement)(object)CreateScroll((CandideUiElement)(object)val)); return; } string text = null; ConfigEntryBase[] array2 = array; foreach (ConfigEntryBase val3 in array2) { if (text != val3.Definition.Section) { if (text != null) { ((CandideUiContainerMultipleItems)val).AddChild((CandideUiElement)new CandideHorizontalSeparator { HorizontalAlignment = (HorizontalAlignment)3, Margin = new CandideThickness(0, 3, 0, 6) }, false); } ((CandideUiContainerMultipleItems)val).AddChild((CandideUiElement)new CandideTextLabel { Text = ModSettingsMetadataResolver.GetSectionDisplayName(pluginConfig, val3.Definition.Section), TextColor = new Color(255, 224, 161), Margin = new CandideThickness(0, 0, 0, 4) }, false); text = val3.Definition.Section; } ModConfigEntryEditor modConfigEntryEditor = new ModConfigEntryEditor(val3, UpdateButtons, ModSettingsMetadataResolver.GetEntryOptions(pluginConfig, val3)); _editors.Add(modConfigEntryEditor); ((CandideUiContainerMultipleItems)val).AddChild((CandideUiElement)(object)modConfigEntryEditor, false); } ((CandideUiContainerSingleItem)_contentPanel).SetChild((CandideUiElement)(object)CreateScroll((CandideUiElement)(object)val)); UpdateButtons(); } public bool HasChanges() { return _editors.Any((ModConfigEntryEditor editor) => editor.HasChanges()); } public void Undo() { Reset(); } public void UserSave() { Save(); } public override void Update(GameTime gameTime) { ((CandideUiContainerSingleItem)this).Update(gameTime); if (_currentPluginConfig == null) { _titleIconLabel.Text = LocalizationManager.Instance.GetText("panel.title"); _titleIconLabel.Icon = "cog"; _titleIconLabel.IconPath = null; } UpdateButtons(); } private void Save() { ConfigFile currentConfigFile = _currentConfigFile; if (currentConfigFile != null) { currentConfigFile.Save(); } foreach (ModConfigEntryEditor editor in _editors) { editor.Commit(); } ((CandideUiElement)_yesButton).Enabled = false; ((CandideUiElement)_noButton).Enabled = false; } private void Reset() { UndoEditors(); if (_currentConfigFile != null && _currentPluginConfig != null) { ShowPlugin(_currentPluginConfig); } } private void UpdateButtons() { bool enabled = HasChanges(); ((CandideUiElement)_yesButton).Enabled = enabled; ((CandideUiElement)_noButton).Enabled = enabled; } public void EndEditing(bool undo) { if (undo) { UndoEditors(); } RestoreSaveOnConfigSet(); _editors.Clear(); _currentConfigFile = null; _currentPluginConfig = null; } private void BeginEditing(ConfigFile configFile) { if (_currentConfigFile != configFile) { _currentConfigFile = configFile; _currentConfigFileOriginalSaveOnConfigSet = configFile.SaveOnConfigSet; _hasCurrentConfigFileOriginalSaveOnConfigSet = true; configFile.SaveOnConfigSet = false; } } private void RestoreSaveOnConfigSet() { if (_currentConfigFile != null && _hasCurrentConfigFileOriginalSaveOnConfigSet) { _currentConfigFile.SaveOnConfigSet = _currentConfigFileOriginalSaveOnConfigSet; _hasCurrentConfigFileOriginalSaveOnConfigSet = false; } } private void UndoEditors() { foreach (ModConfigEntryEditor editor in _editors) { editor.Undo(); } } private static CandideVerticalScrollViewer CreateScroll(CandideUiElement child) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0005: Unknown result type (might be due to invalid IL or missing references) //IL_0015: Unknown result type (might be due to invalid IL or missing references) //IL_0025: Unknown result type (might be due to invalid IL or missing references) //IL_002c: Unknown result type (might be due to invalid IL or missing references) //IL_0034: Expected O, but got Unknown CandideVerticalScrollViewer val = new CandideVerticalScrollViewer { Width = 316, Height = 340, ShowVerticalScrollBar = true }; ((CandideUiContainerSingleItem)val).SetChild(child); return val; } } internal sealed class ModConfigWindow : CandideExtendedCustomGraphicsWindow { private readonly CandideGrid _panel = new CandideGrid { HorizontalAlignment = (HorizontalAlignment)3, VerticalAlignment = (VerticalAlignment)3, Padding = new CandideThickness(5), DefaultColumnProportion = Proportion.Auto }; private readonly CandideListView _listView = new CandideListView { Width = 109, Height = 438, Padding = new CandideThickness(0, 6), GridColumn = 0, ShowVerticalScrollBar = false, ControllerAutoSelectHovered = false }; private readonly ModConfigPanel _settingsPanel; private readonly Action _onBack; private readonly CandideIconLabelButton _backButton; private readonly Dictionary<string, ModConfigListItem> _listItemsByGuid; private bool _isInitialized; private string _lastLocale; public ModConfigWindow(Action onBack) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_000d: Unknown result type (might be due to invalid IL or missing references) //IL_0014: Unknown result type (might be due to invalid IL or missing references) //IL_0016: Unknown result type (might be due to invalid IL or missing references) //IL_0020: Unknown result type (might be due to invalid IL or missing references) //IL_0030: Expected O, but got Unknown //IL_0031: Unknown result type (might be due to invalid IL or missing references) //IL_0036: Unknown result type (might be due to invalid IL or missing references) //IL_0043: Unknown result type (might be due to invalid IL or missing references) //IL_0053: Unknown result type (might be due to invalid IL or missing references) //IL_0056: Unknown result type (might be due to invalid IL or missing references) //IL_0060: 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_006e: Unknown result type (might be due to invalid IL or missing references) //IL_007a: Expected O, but got Unknown //IL_00ad: 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_00e6: 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_0155: Unknown result type (might be due to invalid IL or missing references) //IL_015b: Unknown result type (might be due to invalid IL or missing references) //IL_0165: Unknown result type (might be due to invalid IL or missing references) //IL_0177: Unknown result type (might be due to invalid IL or missing references) //IL_017c: Unknown result type (might be due to invalid IL or missing references) //IL_0186: Unknown result type (might be due to invalid IL or missing references) //IL_018d: Unknown result type (might be due to invalid IL or missing references) //IL_0199: Expected O, but got Unknown ModConfigPanel modConfigPanel = new ModConfigPanel(); ((CandideUiElement)modConfigPanel).Width = 336; ((CandideUiElement)modConfigPanel).Height = 438; ((CandideUiElement)modConfigPanel).GridColumn = 1; ((CandideUiElement)modConfigPanel).Padding = new CandideThickness(10, 0, 0, 0); _settingsPanel = modConfigPanel; _listItemsByGuid = new Dictionary<string, ModConfigListItem>(StringComparer.OrdinalIgnoreCase); ((CandideExtendedCustomGraphicsWindow)this)..ctor(new CustomBackgroundArgs { SpriteSheet = Content.SpriteSheet("media/interface/new_ui_parts/ui_pause_menu") }); _onBack = onBack; SoundPlayer.PlayEventOneShot("event:/interface/open_window", 1f, 1f); base.ExitButton.OnClickAction = ((CandideWindow)this).Close; ((CandideWindow)this).Closing += delegate { _settingsPanel.EndEditing(undo: true); }; ((CandideWindow)this).Closed += delegate { SoundPlayer.PlayEventOneShot("event:/interface/close_window", 1f, 1f); _onBack?.Invoke(); }; _backButton = new CandideIconLabelButton("arrow:left", (IconFlag)1, (int?)69) { StringId = StringId.op_Implicit("Ui_Back"), OnClickAction = ((CandideWindow)this).Close, Margin = new CandideThickness(1, 0, 1, 2), HorizontalAlignment = (HorizontalAlignment)0, VerticalAlignment = (VerticalAlignment)2 }; RebuildPanelChildren(); ((CandideUiContainerSingleItem)this).SetChild((CandideUiElement)(object)_panel); BuildUi(); _lastLocale = LocalizationManager.Instance.CurrentLocale; } private void BuildUi() { //IL_0046: Unknown result type (might be due to invalid IL or missing references) //IL_004b: Unknown result type (might be due to invalid IL or missing references) //IL_0065: 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_0073: Unknown result type (might be due to invalid IL or missing references) //IL_0078: Unknown result type (might be due to invalid IL or missing references) //IL_0087: Expected O, but got Unknown //IL_009c: Unknown result type (might be due to invalid IL or missing references) //IL_00a1: 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_00c2: 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_00ce: Unknown result type (might be due to invalid IL or missing references) //IL_00dd: Expected O, but got Unknown //IL_0135: Unknown result type (might be due to invalid IL or missing references) //IL_013c: Unknown result type (might be due to invalid IL or missing references) LocalizationManager.Instance.RefreshLanguage(forceNotify: false); ModSettingsRegistry.RequestRefresh(); _listView.ClearAllItems(); _listItemsByGuid.Clear(); CandideThickness padding = default(CandideThickness); ((CandideThickness)(ref padding))..ctor(2, 2, 6, 3); CandideThickness margin = default(CandideThickness); ((CandideThickness)(ref margin))..ctor(1, 0, 1, 2); _listView.AddNonItem((CandideUiElement)new TranslationCenteredTextLayout(109, 18) { Text = LocalizationManager.Instance.GetText("window.mod_list_title"), TextAlign = (TextHorizontalAlignment)1, HorizontalAlignment = (HorizontalAlignment)3, Margin = new CandideThickness(0, 0, 0, 4) }); ModPluginConfig[] array = ModPluginConfigSource.GetPluginConfigs().ToArray(); if (array.Length == 0) { _listView.AddNonItem((CandideUiElement)new CandideTextLabel { Text = LocalizationManager.Instance.GetText("window.no_configs"), TextAlign = (TextHorizontalAlignment)1, HorizontalAlignment = (HorizontalAlignment)3, Margin = new CandideThickness(0, 4, 0, 0) }); return; } ModPluginConfig[] array2 = array; foreach (ModPluginConfig config in array2) { ModConfigListItem obj = new ModConfigListItem(config.Icon, config.IconPath, (IconFlag)0, 92) { Text = config.Name }; ((CandideUiElement)obj).Padding = padding; ((CandideUiElement)obj).Margin = margin; ((CandideToggleButton)obj).OnToggledSoundEvent = "event:/interface/main menu/ui_mainmenu_click"; ((CandideToggleButton)obj).OnToggledOnAction = delegate { _settingsPanel.ShowPlugin(config); }; ModConfigListItem modConfigListItem = obj; _listItemsByGuid[config.Guid] = modConfigListItem; _listView.AddItem((CandideToggleButton)(object)modConfigListItem, false); } } private void RebuildPanelChildren() { _panel.ClearChildren(); ((CandideUiContainerMultipleItems)_panel).AddChild((CandideUiElement)(object)_listView, false); ((CandideUiContainerMultipleItems)_panel).AddChild((CandideUiElement)(object)_settingsPanel, false); ((CandideUiContainerMultipleItems)_panel).AddChild((CandideUiElement)(object)_backButton, false); } public override bool OnUiClosePressed() { if (((CandideUiContainerSingleItem)this).OnUiClosePressed()) { return true; } ((CandideWindow)this).Close(); return true; } public override void Update(GameTime gameTime) { ((CandideWindow)this).Update(gameTime); LocalizationManager.Instance.RefreshLanguage(forceNotify: false); if (_lastLocale != LocalizationManager.Instance.CurrentLocale) { _lastLocale = LocalizationManager.Instance.CurrentLocale; string currentPluginGuid = _settingsPanel.CurrentPluginGuid; RebuildPanelChildren(); _isInitialized = false; BuildUi(); if (!string.IsNullOrWhiteSpace(currentPluginGuid) && SelectPlugin(currentPluginGuid)) { _isInitialized = true; } } if (!_isInitialized && _listView.Items.Count > 0) { _listView.Items[0].IsToggled = true; _isInitialized = true; } } private bool SelectPlugin(string pluginGuid) { if (_listItemsByGuid.TryGetValue(pluginGuid, out var value)) { ((CandideToggleButton)value).IsToggled = true; return true; } ModPluginConfig modPluginConfig = ModPluginConfigSource.GetPluginConfigs().ToArray().FirstOrDefault((ModPluginConfig item) => item.Guid == pluginGuid); if (modPluginConfig == null) { return false; } _settingsPanel.ShowPlugin(modPluginConfig); return true; } } internal sealed class ModIconImage : CandideUiComponent { private IconFlag _iconFlags; private string _iconPath; public string IconPath { get { return _iconPath; } set { if (!(_iconPath == value)) { _iconPath = value; ((CandideUiElement)this).InvalidateMeasure(); } } } public IconFlag IconFlags { get { //IL_0001: Unknown result type (might be due to invalid IL or missing references) return _iconFlags; } set { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0002: Unknown result type (might be due to invalid IL or missing references) _iconFlags = value; ((CandideUiElement)this).InvalidateMeasure(); } } public bool DrawSmooth { get; set; } = true; public bool HasTexture => ModIconLoader.TryLoad(_iconPath) != null; public ModIconImage(IconFlag iconFlags = (IconFlag)1) { //IL_000e: Unknown result type (might be due to invalid IL or missing references) IconFlags = iconFlags; } public override void Update(GameTime gameTime) { } protected override void InternalDraw(UiRenderContext context) { //IL_0011: Unknown result type (might be due to invalid IL or missing references) //IL_0016: Unknown result type (might be due to invalid IL or missing references) //IL_001b: Unknown result type (might be due to invalid IL or missing references) //IL_001c: Unknown result type (might be due to invalid IL or missing references) //IL_002a: Unknown result type (might be due to invalid IL or missing references) //IL_004c: Unknown result type (might be due to invalid IL or missing references) //IL_0052: 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_0062: Unknown result type (might be due to invalid IL or missing references) //IL_0063: Unknown result type (might be due to invalid IL or missing references) //IL_006a: Unknown result type (might be due to invalid IL or missing references) //IL_006f: Unknown result type (might be due to invalid IL or missing references) //IL_0072: Unknown result type (might be due to invalid IL or missing references) //IL_0077: Unknown result type (might be due to invalid IL or missing references) //IL_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_0084: 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_008b: 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_0096: Unknown result type (might be due to invalid IL or missing references) //IL_009b: Unknown result type (might be due to invalid IL or missing references) //IL_00a0: Unknown result type (might be due to invalid IL or missing references) //IL_00a3: Unknown result type (might be due to invalid IL or missing references) //IL_00a8: Unknown result type (might be due to invalid IL or missing references) //IL_00c5: Unknown result type (might be due to invalid IL or missing references) //IL_00c8: 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) Texture2D val = ModIconLoader.TryLoad(_iconPath); if (val != null) { Vector2 iconSizeForFlags = CandideIcon.GetIconSizeForFlags(_iconFlags); float num = MathHelper.Min(iconSizeForFlags.X / (float)val.Width, iconSizeForFlags.Y / (float)val.Height); Vector2 val2 = new Vector2((float)val.Width, (float)val.Height) * num * (float)CandideUiSystem.Scale; Vector2 val3 = iconSizeForFlags * (float)CandideUiSystem.Scale; Rectangle actualBounds = ((CandideUiElement)this).ActualBounds; Point location = ((Rectangle)(ref actualBounds)).Location; Vector2 val4 = ((Point)(ref location)).ToVector2() + (val3 - val2) / 2f; TextureFiltering textureFiltering = context.GetTextureFiltering(); if (DrawSmooth) { context.SetTextureFiltering((TextureFiltering)1); } context.DrawSprite(val, (Rectangle?)null, val4, new Vector2(num), 0f); context.SetTextureFiltering(textureFiltering); } } protected override Vector2 InternalMeasure(Vector2 availableSize) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_0011: Unknown result type (might be due to invalid IL or missing references) return CandideIcon.GetIconSizeForFlags(_iconFlags) * (float)CandideUiSystem.Scale; } } internal static class ModIconLoader { private static readonly Dictionary<string, Texture2D> Cache = new Dictionary<string, Texture2D>(StringComparer.OrdinalIgnoreCase); private static readonly HashSet<string> FailedPaths = new HashSet<string>(StringComparer.OrdinalIgnoreCase); public static Texture2D TryLoad(string path) { string text = NormalizePath(path); if (string.IsNullOrWhiteSpace(text)) { return null; } if (Cache.TryGetValue(text, out var value)) { return value; } if (FailedPaths.Contains(text)) { return null; } try { if (Globals.GraphicsDevice == null) { return null; } if (!File.Exists(text)) { FailedPaths.Add(text); return null; } using (FileStream fileStream = File.OpenRead(text)) { value = Texture2D.FromStream(Globals.GraphicsDevice, (Stream)fileStream); } Cache[text] = value; return value; } catch { FailedPaths.Add(text); return null; } } private static string NormalizePath(string path) { if (string.IsNullOrWhiteSpace(path)) { return null; } try { return Path.GetFullPath(path.Trim().Trim('"')); } catch { return path.Trim().Trim('"'); } } } internal sealed class ModPluginConfig { public string Name { get; set; } public string Guid { get; set; } public ConfigFile ConfigFile { get; set; } public ModSettingsRegistration Registration { get; set; } public string Icon => Registration?.Icon ?? "cog"; public string IconPath => Registration?.IconPath; public int Order => Registration?.Order ?? 1000; } internal static class ModPluginConfigSource { public static IEnumerable<ModPluginConfig> GetPluginConfigs() { NetChainloader chainloader = NetChainloader.Instance; if (chainloader == null) { yield break; } HashSet<string> registeredGuids = new HashSet<string>(StringComparer.OrdinalIgnoreCase); foreach (ModSettingsRegistration item in from item in ModSettingsRegistry.GetRegistrations() orderby item.Order, item.DisplayName select item) { registeredGuids.Add(item.PluginGuid); if (!item.HideWhenEmpty || item.ConfigFile.Values.Count != 0) { yield return new ModPluginConfig { Name = item.DisplayName, Guid = item.PluginGuid, ConfigFile = item.ConfigFile, Registration = item }; } } foreach (PluginInfo item2 in ((BaseChainloader<BasePlugin>)(object)chainloader).Plugins.Values.OrderBy((PluginInfo plugin) => plugin.Metadata.Name)) { if (!registeredGuids.Contains(item2.Metadata.GUID)) { object instance = item2.Instance; BasePlugin val = (BasePlugin)((instance is BasePlugin) ? instance : null); if (val != null && val.Config != null && val.Config.Values.Count != 0) { yield return new ModPluginConfig { Name = item2.Metadata.Name, Guid = item2.Metadata.GUID, ConfigFile = val.Config }; } } } } } internal static class ModSettingsIconRegistry { public const string IconId = "mod_settings_menu:settings"; private const string ResourceName = "ModSettingsMenu.Assets.mod_settings_icon.png"; private static bool _registered; public static void Register() { //IL_0125: Unknown result type (might be due to invalid IL or missing references) //IL_012c: Expected O, but got Unknown //IL_0070: Unknown result type (might be due to invalid IL or missing references) //IL_0076: Unknown result type (might be due to invalid IL or missing references) //IL_0078: Unknown result type (might be due to invalid IL or missing references) //IL_0083: Expected O, but got Unknown //IL_007e: Unknown result type (might be due to invalid IL or missing references) //IL_0083: Unknown result type (might be due to invalid IL or missing references) //IL_008b: 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_009d: Unknown result type (might be due to invalid IL or missing references) //IL_00a6: Unknown result type (might be due to invalid IL or missing references) //IL_00af: 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_00d9: 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_00f5: Unknown result type (might be due to invalid IL or missing references) if ((_registered && IconDataBase.IconDataMap.ContainsKey("mod_settings_menu:settings")) || Globals.GraphicsDevice == null || Content.DefaultNormalMap == null || Content.DefaultMetalMap == null) { return; } try { using Stream stream = Assembly.GetExecutingAssembly().GetManifestResourceStream("ModSettingsMenu.Assets.mod_settings_icon.png"); if (stream != null) { Texture2D val = Texture2D.FromStream(Globals.GraphicsDevice, stream); ((GraphicsResource)val).Name = "mod_settings_menu:settings"; Icon value = new Icon(new SpriteSheet(val, Content.DefaultNormalMap, Content.DefaultMetalMap, 24, 24, default(Vector2)), 0); Dictionary<IconFlag, Icon> variations = new Dictionary<IconFlag, Icon> { [(IconFlag)1] = value, [(IconFlag)9] = value, [(IconFlag)17] = value, [(IconFlag)33] = value, [(IconFlag)25] = value, [(IconFlag)36] = value }; IconDataBase.IconDataMap.Remove("mod_settings_menu:settings"); IconDataBase.AddIcons((IEnumerable<IconData>)(object)new IconData[1] { new IconData { Id = "mod_settings_menu:settings", Variations = variations } }); _registered = true; } } catch (Exception ex) { ManualLogSource logger = ModSettingsMenu.Logger; if (logger != null) { bool flag = default(bool); BepInExWarningLogInterpolatedStringHandler val2 = new BepInExWarningLogInterpolatedStringHandler(46, 1, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val2).AppendLiteral("Failed to register mod settings toolbar icon: "); ((BepInExLogInterpolatedStringHandler)val2).AppendFormatted<string>(ex.Message); } logger.LogWarning(val2); } } } } internal sealed class ModUpdateStatusLabel : CandideTextLabel { private readonly ModSettingsRegistration _registration; private ModUpdateCheckStatus _lastStatus; private string _lastVersion; public ModUpdateStatusLabel(ModSettingsRegistration registration) { //IL_0016: Unknown result type (might be due to invalid IL or missing references) //IL_001b: Unknown result type (might be due to invalid IL or missing references) _registration = registration; ((CandideTextLabel)this).TextStyle = (CandideTextStyle)9; base.TextColor = Color.LightGray; ((CandideTextLabel)this).TextAlign = (TextHorizontalAlignment)2; ((CandideUiElement)this).HorizontalAlignment = (HorizontalAlignment)2; ((CandideTextLabel)this).Wrap = false; ((CandideUiElement)this).MaxWidth = 78; UpdateText(force: true); } public override void Update(GameTime gameTime) { ((CandideTextLabel)this).Update(gameTime); UpdateText(force: false); } private void UpdateText(bool force) { //IL_0050: Unknown result type (might be due to invalid IL or missing references) //IL_0055: Unknown result type (might be due to invalid IL or missing references) ModUpdateCheckResult orStart = ModUpdateChecker.GetOrStart(_registration); if (force || _lastStatus != orStart.Status || !(_lastVersion == orStart.LatestVersion)) { _lastStatus = orStart.Status; _lastVersion = orStart.LatestVersion; base.TextColor = GetStatusColor(orStart.Status); ((CandideUiElement)this).Visible = orStart.Status == ModUpdateCheckStatus.UpdateAvailable || orStart.Status == ModUpdateCheckStatus.UpToDate || orStart.Status == ModUpdateCheckStatus.Failed; ((CandideTextLabel)this).Text = GetStatusText(orStart); } } private static string GetStatusText(ModUpdateCheckResult result) { LocalizationManager instance = LocalizationManager.Instance; return result.Status switch { ModUpdateCheckStatus.UpToDate => instance.GetText("update.up_to_date"), ModUpdateCheckStatus.UpdateAvailable => instance.GetText("update.available", result.LatestVersion), ModUpdateCheckStatus.Failed => instance.GetText("update.failed"), _ => string.Empty, }; } private static Color GetStatusColor(ModUpdateCheckStatus status) { //IL_001f: Unknown result type (might be due to invalid IL or missing references) //IL_002e: Unknown result type (might be due to invalid IL or missing references) //IL_0043: 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) return (Color)(status switch { ModUpdateCheckStatus.UpToDate => new Color(104, 205, 112), ModUpdateCheckStatus.UpdateAvailable => new Color(255, 72, 72), ModUpdateCheckStatus.Failed => new Color(196, 170, 132), _ => new Color(226, 207, 177), }); } } } namespace ModSettingsMenu.Patches { [HarmonyPatch(typeof(CandideControlsSettings), "BuildUi")] internal static class ControlsSettingsBuildUiPatch { private static readonly FieldInfo SettingsPanelField = AccessTools.Field(typeof(CandideControlsSettings), "_settingsPanel"); private static readonly FieldInfo IsGamePadField = AccessTools.Field(typeof(CandideControlsSettings), "_isGamePad"); private static readonly FieldInfo SettingsField = AccessTools.Field(typeof(CandideControlsSettings), "_settings"); private static readonly ConditionalWeakTable<CandideControlsSettings, ModControlsState> States = new ConditionalWeakTable<CandideControlsSettings, ModControlsState>(); private static readonly ConditionalWeakTable<ControlsUserSettings, ModControlsState> StatesBySettings = new ConditionalWeakTable<ControlsUserSettings, ModControlsState>(); private static void Postfix(CandideControlsSettings __instance) { //IL_00da: Unknown result type (might be due to invalid IL or missing references) //IL_00e1: Expected O, but got Unknown try { object? obj = SettingsPanelField?.GetValue(__instance); CandideVerticalStackPanel val = (CandideVerticalStackPanel)((obj is CandideVerticalStackPanel) ? obj : null); if (val != null) { ModControlsState value = States.GetValue(__instance, (CandideControlsSettings _) => new ModControlsState()); object? obj2 = SettingsField?.GetValue(__instance); ControlsUserSettings val2 = (ControlsUserSettings)((obj2 is ControlsUserSettings) ? obj2 : null); if (val2 != null) { StatesBySettings.Remove(val2); StatesBySettings.Add(val2, value); } value.Rebuild(FindKeybinds()); if (value.Editors.Count != 0) { object obj3 = IsGamePadField?.GetValue(__instance); AddModKeybinds(val, value, obj3 is bool && (bool)obj3); } } } catch (Exception ex) { ManualLogSource logger = ModSettingsMenu.Logger; if (logger != null) { bool flag = default(bool); BepInExErrorLogInterpolatedStringHandler val3 = new BepInExErrorLogInterpolatedStringHandler(39, 2, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val3).AppendLiteral("Failed to build mod keybind controls: "); ((BepInExLogInterpolatedStringHandler)val3).AppendFormatted<string>(ex.Message); ((BepInExLogInterpolatedStringHandler)val3).AppendLiteral("\n"); ((BepInExLogInterpolatedStringHandler)val3).AppendFormatted<string>(ex.StackTrace); } logger.LogError(val3); } } } internal static bool HasChanges(CandideControlsSettings instance) { if (States.TryGetValue(instance, out var value)) { return value.HasChanges(); } return false; } internal static void Save(CandideControlsSettings instance) { if (States.TryGetValue(instance, out var value)) { value.Save(); } } internal static void Undo(CandideControlsSettings instance) { if (States.TryGetValue(instance, out var value)) { value.Undo(); } } internal static void ResetToDefaults(ControlsUserSettings settings) { if (StatesBySettings.TryGetValue(settings, out var value)) { value.ResetToDefaults(); } } private static List<ModKeybindDescriptor> FindKeybinds() { ModSettingsRegistry.RequestRefresh(); return (from config in ModPluginConfigSource.GetPluginConfigs() orderby config.Order, config.Name select config).SelectMany(GetKeybinds).ToList(); } private static IEnumerable<ModKeybindDescriptor> GetKeybinds(ModPluginConfig pluginConfig) { return from item in pluginConfig.ConfigFile.Values.Select((ConfigEntryBase entry) => new { Entry = entry, Options = ModSettingsMetadataResolver.GetEntryOptions(pluginConfig, entry) }).Where(item => { ModSettingsEntryOptions options = item.Options; return options != null && options.Keybind && ModKeybindValue.IsSupportedType(item.Entry.SettingType) && !ModSettingsMetadataResolver.IsEntryHiddenByMetadata(pluginConfig, item.Entry); }) orderby ModSettingsMetadataResolver.GetSectionOrder(pluginConfig, item.Entry.Definition.Section), ModSettingsMetadataResolver.GetEntryOrder(pluginConfig, item.Entry), item.Entry.Definition.Section, item.Entry.Definition.Key select new ModKeybindDescriptor(pluginConfig, item.Entry, item.Options); } private static void AddModKeybinds(CandideVerticalStackPanel settingsPanel, ModControlsState state, bool isGamePad) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_000d: Unknown result type (might be due to invalid IL or missing references) //IL_0012: Unknown result type (might be due to invalid IL or missing references) //IL_0022: Expected O, but got Unknown //IL_004f: Unknown result type (might be due to invalid IL or missing references) //IL_0054: Unknown result type (might be due to invalid IL or missing references) //IL_0060: Unknown result type (might be due to invalid IL or missing references) //IL_0070: Unknown result type (might be due to invalid IL or missing references) //IL_0075: 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_0081: 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_008f: 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_00a6: Unknown result type (might be due to invalid IL or missing references) //IL_00b3: 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_00c3: Unknown result type (might be due to invalid IL or missing references) //IL_00c8: Unknown result type (might be due to invalid IL or missing references) //IL_00d8: Expected O, but got Unknown ((CandideUiContainerMultipleItems)settingsPanel).AddChild((CandideUiElement)new CandideHorizontalSeparator { HorizontalAlignment = (HorizontalAlignment)3, Margin = new CandideThickness(0, 8, 0, 3) }, false); string a = null; foreach (ModKeybindEditor editor in state.Editors) { if (!string.Equals(a, editor.PluginGuid, StringComparison.OrdinalIgnoreCase)) { ((CandideUiContainerMultipleItems)settingsPanel).AddChild((CandideUi