using System; using System.Collections.Generic; using System.Reflection; using System.Runtime.CompilerServices; using BepInEx; using BepInEx.Configuration; using BepInEx.Logging; using HarmonyLib; using TMPro; using UnityEngine; using UnityEngine.Events; using UnityEngine.UI; [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: AssemblyVersion("0.0.0.0")] namespace ScaleUI; public static class ConfigManager { private const float SENTINEL_NO_OVERRIDE = -1f; private static ConfigFile cfg; private static ConfigEntry everything; private static readonly Dictionary> overrides = new Dictionary>(); public static void Init(ConfigFile configFile) { cfg = configFile; everything = cfg.Bind("ScaleUI", "EverythingScale", 1f, "Global UI scale multiplier (0.2 - 3.0) applied to every UI that has no custom override."); UIType[] allScalableTypes = UIManager.AllScalableTypes; foreach (UIType uIType in allScalableTypes) { overrides[uIType] = cfg.Bind("ScaleUI", string.Concat(uIType, "Scale"), -1f, string.Concat("Custom scale for ", uIType, ". -1 means 'use EverythingScale'.")); } } public static float GetEverything() { return everything.Value; } public static void SetEverything(float value) { everything.Value = value; cfg.Save(); } public static float? GetOverride(UIType type) { if (!overrides.ContainsKey(type)) { return null; } float value = overrides[type].Value; if (value < 0f) { return null; } return value; } public static void SetOverride(UIType type, float value) { if (overrides.ContainsKey(type)) { overrides[type].Value = value; cfg.Save(); } } public static void ClearOverride(UIType type) { if (overrides.ContainsKey(type)) { overrides[type].Value = -1f; cfg.Save(); } } } public static class GUIManager { private static ScrollSettings typeRow; private static SliderSetting scaleRow; private static Button resetButton; private static UIType selectedType = UIType.Everything; private static bool suppressSliderCallback; private static readonly string[] typeNames = BuildTypeNames(); private static string[] BuildTypeNames() { UIType[] array = (UIType[])Enum.GetValues(typeof(UIType)); string[] array2 = new string[array.Length]; for (int i = 0; i < array.Length; i++) { array2[i] = UIManager.DisplayName(array[i]); } return array2; } public static void Inject(Settings settings) { try { if ((Object)(object)settings.music == (Object)null) { throw new Exception("Settings.music is missing"); } Transform parent = ((Component)settings.music).transform.parent; if ((Object)(object)parent.Find("ScaleUI_ScaleRow") != (Object)null) { RefreshRows(); return; } BuildRows(settings, parent); RefreshRows(); Plugin.Log.LogInfo((object)"ScaleUI: rows added to this Settings screen."); } catch (Exception ex) { Plugin.Log.LogWarning((object)("ScaleUI: could not add Scale UI to this Settings screen (" + ex.Message + "). The mod will stay inactive for this screen.")); } } private static void BuildRows(Settings settings, Transform container) { //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_0174: Unknown result type (might be due to invalid IL or missing references) //IL_0151: Unknown result type (might be due to invalid IL or missing references) //IL_015b: Expected O, but got Unknown //IL_00b4: Unknown result type (might be due to invalid IL or missing references) //IL_00ba: Unknown result type (might be due to invalid IL or missing references) //IL_00bf: Unknown result type (might be due to invalid IL or missing references) //IL_0254: Unknown result type (might be due to invalid IL or missing references) //IL_02ed: Unknown result type (might be due to invalid IL or missing references) //IL_02ca: Unknown result type (might be due to invalid IL or missing references) //IL_02d4: Expected O, but got Unknown if ((Object)(object)settings.volume == (Object)null) { throw new Exception("Settings.volume is missing"); } if ((Object)(object)settings.shadowQuality == (Object)null) { throw new Exception("Settings.shadowQuality is missing"); } if ((Object)(object)settings.backBtn == (Object)null) { throw new Exception("Settings.backBtn is missing"); } if ((Object)(object)settings.fov == (Object)null) { throw new Exception("Settings.fov is missing"); } LayoutGroup component = ((Component)container).GetComponent(); RectTransform component2 = ((Component)settings.music).GetComponent(); RectTransform component3 = ((Component)settings.volume).GetComponent(); Vector2 step = ((!((Object)(object)component == (Object)null) || !((Object)(object)component2 != (Object)null) || !((Object)(object)component3 != (Object)null)) ? Vector2.zero : (component2.anchoredPosition - component3.anchoredPosition)); GameObject val = Object.Instantiate(((Component)settings.shadowQuality).gameObject); val.transform.SetParent(container, false); ((Object)val).name = "ScaleUI_TypeRow"; typeRow = val.GetComponent(); typeRow.SetSettings(typeNames, (int)selectedType); KillPersistentListeners((UnityEventBase)(object)((Setting)typeRow).onClick); ((UnityEventBase)((Setting)typeRow).onClick).RemoveAllListeners(); ((UnityEvent)((Setting)typeRow).onClick).AddListener(new UnityAction(OnTypeChanged)); SetRowLabel(val, "UI Type"); PlaceRow(val, component2, step, 1, component); GameObject val2 = Object.Instantiate(((Component)settings.fov).gameObject); val2.transform.SetParent(container, false); ((Object)val2).name = "ScaleUI_ScaleRow"; scaleRow = val2.GetComponent(); scaleRow.slider.minValue = 20f; scaleRow.slider.maxValue = 300f; scaleRow.slider.wholeNumbers = true; KillPersistentListeners((UnityEventBase)(object)scaleRow.slider.onValueChanged); ((UnityEventBase)scaleRow.slider.onValueChanged).RemoveAllListeners(); ((UnityEvent)(object)scaleRow.slider.onValueChanged).AddListener((UnityAction)OnSliderChanged); SetRowLabel(val2, "UI Scale"); PlaceRow(val2, component2, step, 2, component); GameObject val3 = Object.Instantiate(((Component)settings.backBtn).gameObject); val3.transform.SetParent(container, false); ((Object)val3).name = "ScaleUI_ResetRow"; resetButton = val3.GetComponent