using System; using System.Collections.Generic; using System.Diagnostics; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.Versioning; using System.Security; using System.Security.Permissions; using BepInEx; using BepInEx.Configuration; using BepInEx.Logging; using HarmonyLib; using Microsoft.CodeAnalysis; using TMPro; using UnityEngine; using UnityEngine.AddressableAssets; using UnityEngine.Events; using UnityEngine.Localization; using UnityEngine.Localization.PropertyVariants.TrackedProperties; using UnityEngine.Localization.Settings; using UnityEngine.Localization.Tables; using UnityEngine.ResourceManagement.AsyncOperations; using UnityEngine.SceneManagement; using UnityEngine.UI; using VGFunctions; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)] [assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")] [assembly: AssemblyCompany("PaApi")] [assembly: AssemblyConfiguration("Debug")] [assembly: AssemblyDescription("Example Custom Trigger")] [assembly: AssemblyFileVersion("1.0.0.0")] [assembly: AssemblyInformationalVersion("1.0.0+29e3d864d1e26c05821547854e6da04b5d1fa8cd")] [assembly: AssemblyProduct("PaApi")] [assembly: AssemblyTitle("PaApi")] [assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)] [assembly: AssemblyVersion("1.0.0.0")] [module: UnverifiableCode] [module: RefSafetyRules(11)] namespace Microsoft.CodeAnalysis { [CompilerGenerated] [Embedded] internal sealed class EmbeddedAttribute : Attribute { } } namespace System.Runtime.CompilerServices { [CompilerGenerated] [Embedded] [AttributeUsage(AttributeTargets.Module, AllowMultiple = false, Inherited = false)] internal sealed class RefSafetyRulesAttribute : Attribute { public readonly int Version; public RefSafetyRulesAttribute(int P_0) { Version = P_0; } } } namespace PaApi { public static class EventHelper { public static T GetEvent(this object target, string eventName) where T : Delegate { Type type = target.GetType(); FieldInfo field = type.GetField(eventName, BindingFlags.Instance | BindingFlags.NonPublic); return (T)field.GetValue(target); } public static HitDelegate GetHitEvent(this VGPlayer player) { return ((object)player).GetEvent("HitEvent"); } public static DeathDelegate GetDeathEvent(this VGPlayer player) { return ((object)player).GetEvent("DeathEvent"); } } public class PaApiTableProvider : ITableProvider { public AsyncOperationHandle ProvideTableAsync(string tableCollectionName, Locale locale) where TTable : LocalizationTable { //IL_0086: 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_008d: 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_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_0090: Unknown result type (might be due to invalid IL or missing references) if (typeof(TTable) == typeof(StringTable) && (tableCollectionName == "me.ytarame.PaApi" || SettingsHelper.ModSettingsDefinitions.ContainsKey(tableCollectionName))) { StringTable val = ScriptableObject.CreateInstance(); ((LocalizationTable)val).SharedData = ScriptableObject.CreateInstance(); ((LocalizationTable)val).SharedData.TableCollectionName = tableCollectionName; ((LocalizationTable)val).LocaleIdentifier = locale.Identifier; return Addressables.ResourceManager.CreateCompletedOperation((TTable)(object)((val is TTable) ? val : null), (string)null); } return default(AsyncOperationHandle); } } [HarmonyPatch(typeof(SettingsManager))] internal static class SettingsPatch { [HarmonyPatch("UpdateSettingsFile")] [HarmonyPostfix] private static void PostSave() { SettingsHelper.Save(); } } [HarmonyPatch(typeof(UI_Slider))] internal static class SliderPatch { [HarmonyPatch("GetWidthOfBar")] [HarmonyPrefix] private static bool PreGetWidth(UI_Slider __instance, ref int __result) { //IL_001b: Unknown result type (might be due to invalid IL or missing references) //IL_0021: Invalid comparison between Unknown and I4 if (__instance.Values.Length != 0) { __result = __instance.Values.Length; if ((int)__instance.Type == 1) { __result--; } return false; } float num = __instance.VisualRange.y - __instance.VisualRange.x; __result = (((double)num > 1.0) ? Mathf.RoundToInt(num) : Mathf.RoundToInt(num * 10f)); return false; } [HarmonyPatch("UpdateTextValue")] [HarmonyPrefix] private static bool PreUpdateValueText(UI_Slider __instance) { //IL_0047: Unknown result type (might be due to invalid IL or missing references) //IL_004d: Invalid comparison between Unknown and I4 //IL_010e: 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) ((Component)__instance.ValueText).gameObject.SetActive(__instance.ShowValue); if (!__instance.ShowValue) { return false; } if (__instance.Values.Length != 0) { int num = __instance.GetWidthOfBar(); if ((int)__instance.Type == 0) { num--; } int num2 = Mathf.CeilToInt(Mathf.Clamp(LSMath.SuperLerp(__instance.Range.x, __instance.Range.y, 0f, (float)num, __instance.Value), 0f, (float)(__instance.Values.Length - 1))); if (num2 < 0) { num2 = 0; } if (num2 >= __instance.Values.Length) { num2 = __instance.Values.Length - 1; } string text = __instance.Values[num2]; if (text.Contains("$")) { try { text = text.Replace("$", ""); text = LocalizationSettings.StringDatabase.GetLocalizedString(TableReference.op_Implicit("General UI"), TableEntryReference.op_Implicit(text), LocalizationSettings.SelectedLocale, (FallbackBehavior)0, Array.Empty()); } catch { text = text.Replace("$", ""); } } SingletonBase.Inst.RefreshTextCache(__instance.ValueText, text); } else { SingletonBase.Inst.RefreshTextCache(__instance.ValueText, __instance.Value.ToString("f1")); } return false; } } [BepInPlugin("me.ytarame.PaApi", "PaApi", "1.0.4")] internal class Plugin : BaseUnityPlugin { internal static ManualLogSource Logger; private Harmony _harmony; public const string Guid = "me.ytarame.PaApi"; private const string Name = "PaApi"; private const string Version = "1.0.4"; private void Awake() { //IL_0012: Unknown result type (might be due to invalid IL or missing references) //IL_001c: Expected O, but got Unknown Logger = ((BaseUnityPlugin)this).Logger; _harmony = new Harmony("me.ytarame.PaApi"); _harmony.PatchAll(); SceneManager.sceneLoaded += delegate(Scene scene, LoadSceneMode mode) { if (((Scene)(ref scene)).name == "Menu") { SettingsHelper.SetupMenu(); } }; ((LocalizedDatabase)(object)LocalizationSettings.StringDatabase).TableProvider = (ITableProvider)(object)new PaApiTableProvider(); Logger.LogInfo((object)"Plugin me.ytarame.PaApi is loaded!"); } } public static class SettingsHelper { public class SettingsBuilder { private Transform _settingsPanel; private int _itemCount; private int _pageCount; public SettingsBuilder(string guid, Transform settingsPanel, Color color, int residingPage) { //IL_0008: Unknown result type (might be due to invalid IL or missing references) //IL_0009: Unknown result type (might be due to invalid IL or missing references) P = guid; P = color; P = residingPage; _settingsPanel = settingsPanel; _itemCount = 0; _pageCount = 0; base..ctor(); } public void EndPage() { //IL_0062: 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: 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_00a6: Unknown result type (might be due to invalid IL or missing references) if (_itemCount != 0) { if (_pageCount == 0) { RectTransform val = AddPageSwapButtons(_settingsPanel.parent.GetChild(0), _settingsBook, _modPage, null, P + " page 1"); val.pivot = new Vector2(0f, 0.5f); val.anchorMin = Vector2.zero; val.anchorMax = Vector2.up; val.anchoredPosition = new Vector2(0f, -135f); val.sizeDelta = new Vector2(372f, 80f); } else { SetupSwapPageButtons($"{P} page {_pageCount - 1}", $"{P} page {_pageCount + 1}"); } _itemCount = 0; CreateNewModSettingsPage(_settingsPanel.parent, ++_pageCount); } } private void CheckPageEnd() { if (_itemCount >= 10) { EndPage(); } _itemCount++; } internal void Finished() { if (_pageCount != 0) { SetupSwapPageButtons($"{P} page {_pageCount - 1}", null); } } public void Label(string label) { CheckPageEnd(); TextMeshProUGUI componentInChildren = Object.Instantiate(_labelPrefab, _settingsPanel).GetComponentInChildren(); UI_Text component = ((Component)((TMP_Text)componentInChildren).transform.parent).GetComponent(); _modPage.SubElements.Add((UIElement)(object)component); ((TMP_Text)componentInChildren).text = label; SingletonBase.Inst.RefreshTextCache(componentInChildren, label); ((UIElement)(object)component).SetLocalization(componentInChildren, P, label, label); } public void Spacer() { CheckPageEnd(); Object.Instantiate(_spacerPrefab, _settingsPanel); } public void Toggle(string label, ConfigEntry config, Action callback = null) { Toggle(label, null, null, config, callback); } public void Toggle(string label, string onDescription, string offDescription, ConfigEntry config, Action callback = null) { //IL_0228: 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) CheckPageEnd(); UI_Toggle toggle = Object.Instantiate(_togglePrefab, _settingsPanel).GetComponent(); toggle.Value = config.Value; toggle.DataID = null; toggle.OnValueChanged.AddListener((UnityAction)delegate(bool x) { config.Value = x; callback?.Invoke(x); }); TextMeshProUGUI val = null; Graphic[] subGraphics = ((UIElement)toggle).multiGraphics.subGraphics; foreach (Graphic val2 in subGraphics) { TextMeshProUGUI val3 = ((val2 != null) ? ((Component)val2).GetComponent() : null); if ((Object)(object)val3 != (Object)null) { val = val3; break; } } if ((Object)(object)val == (Object)null) { Plugin.Logger.LogFatal((object)"Could not find text for Toggle"); return; } ((TMP_Text)val).text = label; SingletonBase.inst.RefreshTextCache(val, label); if (!string.IsNullOrEmpty(onDescription) && !string.IsNullOrEmpty(offDescription)) { toggle.OnValueChanged.AddListener((UnityAction)delegate(bool x) { toggle.RefreshToggleDescription(); if (Object.op_Implicit((Object)(object)toggle.Description)) { SingletonBase.Inst.RefreshTextCache(toggle.Description, x ? onDescription : offDescription); } }); } else if (Object.op_Implicit((Object)(object)toggle.Description)) { ((Behaviour)toggle.Description).enabled = false; } if (Object.op_Implicit((Object)(object)toggle.Description)) { string text = (toggle.Value ? onDescription : offDescription); if (string.IsNullOrEmpty(text)) { text = "Missing"; } ((TMP_Text)toggle.Description).text = text; SingletonBase.inst.RefreshTextCache(toggle.Description, text); } _modPage.SubElements.Add((UIElement)(object)toggle); ((UIElement)(object)toggle).SetLocalization(val, P, label, label); toggle.OverrideNormalColor = P; callback?.Invoke(config.Value); } public void Slider(string label, ConfigEntry config, VisualType visualType, params string[] values) { //IL_002d: Unknown result type (might be due to invalid IL or missing references) Slider(label, config.Value, 1f, delegate(float f) { config.Value = (int)f; }, visualType, values); } public void Slider(string label, float changeAmount, ConfigEntry config, VisualType visualType, params string[] values) { //IL_0028: Unknown result type (might be due to invalid IL or missing references) Slider(label, config.Value, changeAmount, delegate(float f) { config.Value = f; }, visualType, values); } public void Slider(string label, ConfigEntry config, VisualType visualType, Vector2 range) { //IL_002d: 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) Slider(label, config.Value, 1f, delegate(float f) { config.Value = (int)f; }, visualType, range); } public void Slider(string label, float changeAmount, ConfigEntry config, VisualType visualType, Vector2 range) { //IL_0028: 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) Slider(label, config.Value, changeAmount, delegate(float f) { config.Value = f; }, visualType, range); } public void Slider(string label, float value, float changeAmount, UnityAction callback, VisualType visualType, params string[] values) { //IL_0033: 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_003f: Unknown result type (might be due to invalid IL or missing references) //IL_0044: Unknown result type (might be due to invalid IL or missing references) //IL_0050: Unknown result type (might be due to invalid IL or missing references) CheckPageEnd(); UI_Slider component = Object.Instantiate(_sliderPrefab, _settingsPanel).GetComponent(); component.Values = values; component.Range = new Vector2(0f, (float)(values.Length - 1)); component.VisualRange = component.Range; Internal_InstantiateSlider(component, label, value, changeAmount, callback, visualType); } public void Slider(string label, float value, float changeAmount, UnityAction callback, VisualType visualType, Vector2 range) { //IL_001f: 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_0027: 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_0035: Unknown result type (might be due to invalid IL or missing references) CheckPageEnd(); UI_Slider component = Object.Instantiate(_sliderPrefab, _settingsPanel).GetComponent(); component.Range = range; component.VisualRange = range; Internal_InstantiateSlider(component, label, value, changeAmount, callback, visualType); } private void Internal_InstantiateSlider(UI_Slider slider, string label, float value, float changeAmount, UnityAction callback, VisualType visualType) { //IL_000a: 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_002e: 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) slider.DataID = null; slider.DataIDType = (DataType)3; slider.Value = value; ((TMP_Text)slider.Label).text = label; slider.ChangeAmount = changeAmount; slider.Type = visualType; slider.OnValueChanged.AddListener(callback); ((UIElement)slider).originalNonLocalizedText.Clear(); SingletonBase.inst.RefreshTextCache(slider.Label, label); _modPage.SubElements.Add((UIElement)(object)slider); ((UIElement)(object)slider).SetLocalization(slider.Label, P, label, label); ((Graphic)slider.CenterText).color = P; callback?.Invoke(value); } private void CreateNewModSettingsPage(Transform panel, int page) { //IL_007d: 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_009e: 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_00e3: Unknown result type (might be due to invalid IL or missing references) //IL_00e4: Unknown result type (might be due to invalid IL or missing references) //IL_00ee: Expected O, but got Unknown //IL_00ee: 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_00fe: 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_010d: Expected O, but got Unknown //IL_0112: Expected O, but got Unknown //IL_01a7: Unknown result type (might be due to invalid IL or missing references) //IL_01b1: Expected O, but got Unknown _settingsPanel = Object.Instantiate(panel, ((Component)_settingsBook).transform).Find("Right"); ((Object)_settingsPanel.parent).name = $"{P} page {page}"; for (int i = 0; i < _settingsPanel.childCount; i++) { Object.Destroy((Object)(object)((Component)_settingsPanel.GetChild(i)).gameObject); } _modPage = new Page { _ID = $"{P} page {page}", PageContainer = ((Component)_settingsPanel.parent).gameObject, SubElements = new List(1) { (UIElement)(object)((Component)_settingsPanel.parent.GetChild(0).GetChild(0)).GetComponent() }, BottomTitleLocalized = new LocalizedString(), TitleLocalized = new LocalizedString(TableReference.op_Implicit("me.ytarame.PaApi"), TableEntryReference.op_Implicit("ModSettings")) }; _settingsBook.Pages.Add(_modPage); UI_Text component = ((Component)_settingsPanel.parent.GetChild(0).GetChild(1)).GetComponent(); _modPage.SubElements.Add((UIElement)(object)component); UI_Text component2 = ((Component)_settingsPanel.parent.GetChild(2)).GetComponent(); _modPage.SubElements.Add((UIElement)(object)component2); MultiElementButton component3 = ((Component)_settingsPanel.parent.GetChild(0).GetChild(0)).GetComponent(); ((UnityEvent)((Button)component3).onClick).AddListener((UnityAction)delegate { _settingsBook.ForceSwapPage($"PaApi.ModSettings.{P}"); }); } private void SetupSwapPageButtons(string leftPage, string rightPage) { //IL_00aa: Unknown result type (might be due to invalid IL or missing references) //IL_00b4: Expected O, but got Unknown //IL_00c2: Unknown result type (might be due to invalid IL or missing references) //IL_00cc: Expected O, but got Unknown //IL_00ed: Unknown result type (might be due to invalid IL or missing references) //IL_00f7: Expected O, but got Unknown //IL_0105: Unknown result type (might be due to invalid IL or missing references) //IL_010f: Expected O, but got Unknown Transform child = _settingsPanel.parent.GetChild(0).GetChild(2); MultiElementButton component = ((Component)child.GetChild(0)).GetComponent(); MultiElementButton component2 = ((Component)child.GetChild(1)).GetComponent(); UI_Button item = (UI_Button)(object)(component.uiElement = (UIElement)(object)((Component)component).GetComponent()); UI_Button item2 = (UI_Button)(object)(component2.uiElement = (UIElement)(object)((Component)component2).GetComponent()); _modPage.SubElements.Add((UIElement)(object)item); _modPage.SubElements.Add((UIElement)(object)item2); if (string.IsNullOrEmpty(leftPage)) { component.LockButtonState(true); } else { ((Button)component).onClick = new ButtonClickedEvent(); ((UnityEvent)((Button)component).onClick).AddListener((UnityAction)delegate { _settingsBook.ForceSwapPage(leftPage); }); } if (string.IsNullOrEmpty(rightPage)) { component2.LockButtonState(true); return; } ((Button)component2).onClick = new ButtonClickedEvent(); ((UnityEvent)((Button)component2).onClick).AddListener((UnityAction)delegate { _settingsBook.ForceSwapPage(rightPage); }); } } internal struct SettingsDefinition { public string Name; public Color Color; public ConfigFile File; public Action SettingsBuilder; public SettingsDefinition(string name, Color color, ConfigFile file, Action settingsBuilder) { //IL_0008: Unknown result type (might be due to invalid IL or missing references) //IL_0009: Unknown result type (might be due to invalid IL or missing references) Name = name; Color = color; File = file; SettingsBuilder = settingsBuilder; } } [Serializable] [CompilerGenerated] private sealed class <>c { public static readonly <>c <>9 = new <>c(); public static UnityAction <>9__16_0; internal void b__16_0() { _settingsBook.ForceSwapPage("Blank"); } } private static Page _modSettingsPage; private static Page _modPage; private static UI_Book _settingsBook; private static Transform _settingTabButtonPrefab; private static GameObject _sliderPrefab; private static GameObject _togglePrefab; private static GameObject _labelPrefab; private static GameObject _spacerPrefab; internal static readonly Dictionary ModSettingsDefinitions = new Dictionary(); private static readonly Color DefaultColor = new Color(0f, 0.6824f, 0.9373f, 1f); private static Transform _blankPage; public static void RegisterModSettings(string modGuid, string SettingsName, Color? color, ConfigFile file, Action SettingsBuilder) { //IL_0049: 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) if (ModSettingsDefinitions.ContainsKey(modGuid)) { Plugin.Logger.LogFatal((object)("Tried to register mod with GUID " + modGuid + " more than once! This is not necessary.")); } else { ModSettingsDefinitions.Add(modGuid, new SettingsDefinition(SettingsName, (Color)(((??)color) ?? DefaultColor), file, SettingsBuilder)); } } internal static void SetupMenu() { //IL_010f: Unknown result type (might be due to invalid IL or missing references) //IL_0119: Expected O, but got Unknown //IL_0133: Unknown result type (might be due to invalid IL or missing references) //IL_013d: Expected O, but got Unknown _settingTabButtonPrefab = GameObject.Find("Canvas/Window/Content/Settings/Blank").transform.GetChild(0).GetChild(0); if (!Object.op_Implicit((Object)(object)_settingTabButtonPrefab)) { Plugin.Logger.LogError((object)"No settings tab found, SetupMenu was called at a incorrect time or scene changed"); return; } _settingsBook = ((Component)_settingTabButtonPrefab.parent.parent.parent).GetComponent(); Transform val = ((Component)_settingsBook).transform.Find("Accessibility/Right"); _sliderPrefab = ((Component)((Component)_settingsBook).transform.Find("Audio/Right/Music")).gameObject; _togglePrefab = ((Component)val.Find("High Contrast")).gameObject; _labelPrefab = ((Component)val.Find("General Title")).gameObject; _spacerPrefab = ((Component)val.Find("spacer")).gameObject; GameObject val2 = Object.Instantiate(((Component)_settingTabButtonPrefab.GetChild(1)).gameObject, _settingTabButtonPrefab); ((Object)val2).name = "Mod Settings"; MultiElementButton component = val2.GetComponent(); ((Button)component).onClick = new ButtonClickedEvent(); UI_Button modUiButton = val2.GetComponent(); ((UnityEvent)((Button)component).onClick).AddListener((UnityAction)delegate { _settingsBook.ForceSwapPage("PaApi.ModSettings.0"); modUiButton.OnClick(); }); ((TMP_Text)modUiButton.Text).text = "Mod Settings"; SingletonBase.Inst.RefreshTextCache(modUiButton.Text, "Mod Settings"); ((UIElement)(object)modUiButton).SetLocalization(modUiButton.Text, "me.ytarame.PaApi", "ModSettings", "Mod Settings"); ((Component)((Component)_settingsBook).transform.parent.parent.parent).GetComponent().Pages[6].SubElements.Add((UIElement)(object)modUiButton); _blankPage = ((Component)_settingsBook).transform.Find("Blank"); UI_Text component2 = ((Component)_blankPage.GetChild(3)).GetComponent(); ((TMP_Text)component2.Text).text = "▒\n▒▒▒\n▒▓▒▒▒▒\n▒▒▒▒\n▒▒▒▒\n▒▒▓▒▒▒\n▒▒▒▒▓▒▒\n▒▒▒▒▒▒\n▓▒▒▓▒▒▒▒▒▒▒"; Transform val3 = CreateSettingsListPage(0); int num = 0; int num2 = 0; foreach (KeyValuePair modSettingsDefinition in ModSettingsDefinitions) { num++; SetupModSettings(modSettingsDefinition, val3, num2); if (num % 5 == 0 && num + 1 <= ModSettingsDefinitions.Count) { if (num2 == 0) { AddPageSwapButtons(val3, _settingsBook, _modSettingsPage, null, "PaApi.ModSettings.1"); } else if (num + 5 < ModSettingsDefinitions.Count) { AddPageSwapButtons(val3, _settingsBook, _modSettingsPage, $"PaApi.ModSettings.{num2 - 1}", $"PaApi.ModSettings.{num2 + 1}"); } else { AddPageSwapButtons(val3, _settingsBook, _modSettingsPage, $"PaApi.ModSettings.{num2 - 1}", null); } num2++; val3 = CreateSettingsListPage(num2); } } } private static void SetupModSettings(KeyValuePair setting, Transform modSettingsButtonList, int page) { //IL_0094: Unknown result type (might be due to invalid IL or missing references) //IL_0099: Unknown result type (might be due to invalid IL or missing references) //IL_00b4: 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_00ef: Unknown result type (might be due to invalid IL or missing references) //IL_00f0: Unknown result type (might be due to invalid IL or missing references) //IL_00fa: Expected O, but got Unknown //IL_00fa: Unknown result type (might be due to invalid IL or missing references) //IL_0100: Unknown result type (might be due to invalid IL or missing references) //IL_010a: Unknown result type (might be due to invalid IL or missing references) //IL_010f: Unknown result type (might be due to invalid IL or missing references) //IL_0119: Expected O, but got Unknown //IL_011e: Expected O, but got Unknown //IL_014c: Unknown result type (might be due to invalid IL or missing references) //IL_0156: Expected O, but got Unknown //IL_0164: Unknown result type (might be due to invalid IL or missing references) //IL_016e: Expected O, but got Unknown //IL_0226: Unknown result type (might be due to invalid IL or missing references) //IL_0266: Unknown result type (might be due to invalid IL or missing references) //IL_0270: Expected O, but got Unknown //IL_028c: Unknown result type (might be due to invalid IL or missing references) //IL_0296: Expected O, but got Unknown //IL_0342: Unknown result type (might be due to invalid IL or missing references) Transform val = Object.Instantiate(((Component)_settingsBook).transform.Find("Audio"), ((Component)_settingsBook).transform).Find("Right"); ((Object)val.parent).name = setting.Key + " page 0"; for (int i = 0; i < val.childCount; i++) { Object.Destroy((Object)(object)((Component)val.GetChild(i)).gameObject); } _modPage = new Page { _ID = setting.Key + " page 0", PageContainer = ((Component)val.parent).gameObject, SubElements = new List(1) { (UIElement)(object)((Component)val.parent.GetChild(0).GetChild(0)).GetComponent() }, BottomTitleLocalized = new LocalizedString(), TitleLocalized = new LocalizedString(TableReference.op_Implicit("me.ytarame.PaApi"), TableEntryReference.op_Implicit("ModSettings")) }; _settingsBook.Pages.Add(_modPage); MultiElementButton component = ((Component)val.parent.GetChild(0).GetChild(0)).GetComponent(); ((Button)component).onClick = new ButtonClickedEvent(); ((UnityEvent)((Button)component).onClick).AddListener((UnityAction)delegate { _settingsBook.ForceSwapPage($"PaApi.ModSettings.{page}"); }); string text = ASCII.Get2HighASCII(setting.Value.Name + " Settings", 80, 3); UI_Text component2 = ((Component)val.parent.GetChild(0).GetChild(1)).GetComponent(); component2.Text = ((Component)component2).GetComponent(); ((TMP_Text)component2.Text).text = text; SingletonBase.Inst.RefreshTextCache(component2.Text, text); ((UIElement)component2).originalNonLocalizedText[component2.Text] = text; _modPage.SubElements.Add((UIElement)(object)component2); UI_Text component3 = ((Component)val.parent.GetChild(2)).GetComponent(); ((Graphic)component3.Text).color = setting.Value.Color; _modPage.SubElements.Add((UIElement)(object)component3); GameObject val2 = Object.Instantiate(((Component)_settingTabButtonPrefab.GetChild(1)).gameObject, modSettingsButtonList); MultiElementButton component4 = val2.GetComponent(); ((Button)component4).onClick = new ButtonClickedEvent(); UI_Button uiButton = val2.GetComponent(); ((UnityEvent)((Button)component4).onClick).AddListener((UnityAction)delegate { _settingsBook.ForceSwapPage(setting.Key + " page 0"); uiButton.OnClick(); }); ((TMP_Text)uiButton.Text).text = setting.Value.Name; SingletonBase.Inst.RefreshTextCache(uiButton.Text, setting.Value.Name); ((UIElement)(object)uiButton).SetLocalization(uiButton.Text, setting.Key, "PaApi Setting Tab Button", setting.Value.Name); _modSettingsPage.SubElements.Add((UIElement)(object)uiButton); SettingsBuilder settingsBuilder = new SettingsBuilder(setting.Key, val, setting.Value.Color, page); setting.Value.SettingsBuilder?.Invoke(settingsBuilder); settingsBuilder.Finished(); } private static Transform CreateSettingsListPage(int page) { //IL_0079: Unknown result type (might be due to invalid IL or missing references) //IL_0083: Expected O, but got Unknown //IL_00af: 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_00ca: Unknown result type (might be due to invalid IL or missing references) //IL_00d6: Unknown result type (might be due to invalid IL or missing references) //IL_0108: Unknown result type (might be due to invalid IL or missing references) //IL_0109: Unknown result type (might be due to invalid IL or missing references) //IL_0113: Expected O, but got Unknown //IL_0113: Unknown result type (might be due to invalid IL or missing references) //IL_0119: Unknown result type (might be due to invalid IL or missing references) //IL_0123: Unknown result type (might be due to invalid IL or missing references) //IL_0128: Unknown result type (might be due to invalid IL or missing references) //IL_0132: Expected O, but got Unknown //IL_0137: Expected O, but got Unknown //IL_009e: 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_00a9: Expected O, but got Unknown Transform val = Object.Instantiate(_blankPage, ((Component)_settingsBook).transform); Transform child = val.GetChild(0).GetChild(0); ((Object)((Component)val).gameObject).name = $"PaApi Mod Settings {page}"; for (int i = 1; i < child.childCount; i++) { Object.Destroy((Object)(object)((Component)child.GetChild(i)).gameObject); } MultiElementButton component = ((Component)child.GetChild(0)).GetComponent(); ((Button)component).onClick = new ButtonClickedEvent(); ButtonClickedEvent onClick = ((Button)component).onClick; object obj = <>c.<>9__16_0; if (obj == null) { UnityAction val2 = delegate { _settingsBook.ForceSwapPage("Blank"); }; <>c.<>9__16_0 = val2; obj = (object)val2; } ((UnityEvent)onClick).AddListener((UnityAction)obj); _modSettingsPage = new Page { _ID = $"PaApi.ModSettings.{page}", PageContainer = ((Component)val).gameObject, SubElements = new List(2) { (UIElement)(object)((Component)child.GetChild(0)).GetComponent(), (UIElement)(object)((Component)val.GetChild(3)).GetComponent() }, BottomTitleLocalized = new LocalizedString(), TitleLocalized = new LocalizedString(TableReference.op_Implicit("me.ytarame.PaApi"), TableEntryReference.op_Implicit("ModSettings")) }; _settingsBook.Pages.Add(_modSettingsPage); return child; } private static RectTransform AddPageSwapButtons(Transform buttonList, UI_Book containingBook, Page containingPage, string leftPage, string rightPage) { //IL_001d: Unknown result type (might be due to invalid IL or missing references) //IL_0023: 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_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_0082: 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_0129: 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_0199: Expected O, but got Unknown //IL_01a8: Unknown result type (might be due to invalid IL or missing references) //IL_01b2: Expected O, but got Unknown //IL_01d5: Unknown result type (might be due to invalid IL or missing references) //IL_01df: Expected O, but got Unknown //IL_01ee: Unknown result type (might be due to invalid IL or missing references) //IL_01f8: Expected O, but got Unknown GameObject val = new GameObject(); val.transform.SetParent(buttonList, false); ((Object)val).name = "Page Swap PaApi"; FlexibleGridLayout val2 = val.AddComponent(); val2.spacing = new Vector2(10f, 0f); ((LayoutGroup)val2).childAlignment = (TextAnchor)4; Transform transform = ((Component)val2).transform; RectTransform val3 = (RectTransform)(object)((transform is RectTransform) ? transform : null); Vector2 sizeDelta = val3.sizeDelta; sizeDelta.y = 160f; val3.sizeDelta = sizeDelta; MultiElementButton component = Object.Instantiate(((Component)_settingTabButtonPrefab.GetChild(1)).gameObject, val.transform).GetComponent(); MultiElementButton component2 = Object.Instantiate(((Component)_settingTabButtonPrefab.GetChild(1)).gameObject, val.transform).GetComponent(); UI_Button val4 = (UI_Button)(object)(component.uiElement = (UIElement)(object)((Component)component).GetComponent()); UI_Button val5 = (UI_Button)(object)(component2.uiElement = (UIElement)(object)((Component)component2).GetComponent()); ((Component)val4).transform.localScale = Vector3.one; ((UIElement)(object)val4).SetLocalization(val4.Text, "me.ytarame.PaApi", "PrevPage", "prev"); ((Component)val5).transform.localScale = Vector3.one; ((UIElement)(object)val5).SetLocalization(val5.Text, "me.ytarame.PaApi", "NextPage", "next"); containingPage.SubElements.Add((UIElement)(object)val4); containingPage.SubElements.Add((UIElement)(object)val5); if (string.IsNullOrEmpty(leftPage)) { component.LockButtonState(true); } else { ((Button)component).onClick = new ButtonClickedEvent(); ((UnityEvent)((Button)component).onClick).AddListener((UnityAction)delegate { containingBook.ForceSwapPage(leftPage); }); } if (string.IsNullOrEmpty(rightPage)) { component2.LockButtonState(true); } else { ((Button)component2).onClick = new ButtonClickedEvent(); ((UnityEvent)((Button)component2).onClick).AddListener((UnityAction)delegate { containingBook.ForceSwapPage(rightPage); }); } return val3; } internal static void Save() { foreach (KeyValuePair modSettingsDefinition in ModSettingsDefinitions) { ConfigFile file = modSettingsDefinition.Value.File; if (file != null && !file.SaveOnConfigSet) { file.Save(); } } } } public static class UIElementExtension { public static void SetLocalization(this UIElement element, TextMeshProUGUI text, string table, string entry, string value) { //IL_0043: 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_004e: Unknown result type (might be due to invalid IL or missing references) //IL_0058: Expected O, but got Unknown //IL_005f: Unknown result type (might be due to invalid IL or missing references) element.InitGraphics(); if (element.localizers.TryGetValue(text, out var value2)) { ITrackedProperty obj = value2.TrackedObjects[0].TrackedProperties[0]; LocalizedStringProperty val = (LocalizedStringProperty)(object)((obj is LocalizedStringProperty) ? obj : null); if (val != null) { val.LocalizedString = new LocalizedString(TableReference.op_Implicit(table), TableEntryReference.op_Implicit(entry)); ((DetailedLocalizationTable)(object)((LocalizedDatabase)(object)LocalizationSettings.StringDatabase).GetTable(TableReference.op_Implicit(table), (Locale)null)).AddEntry(entry, value); return; } } Plugin.Logger.LogWarning((object)("Tried to set invalid locale for object [" + ((Object)element).name + "], entry [" + entry + "]")); } } public static class MyPluginInfo { public const string PLUGIN_GUID = "PaApi"; public const string PLUGIN_NAME = "PaApi"; public const string PLUGIN_VERSION = "1.0.0"; } }