using System; using System.Collections.Generic; using System.Diagnostics; using System.Globalization; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.Versioning; using BepInEx; using HarmonyLib; using TMPro; using UnityEngine; using UnityEngine.Events; using UnityEngine.UI; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)] [assembly: TargetFramework(".NETFramework,Version=v4.7.2", FrameworkDisplayName = ".NET Framework 4.7.2")] [assembly: AssemblyVersion("0.0.0.0")] namespace ItemDotSize; [BepInPlugin("com.pulsion.howtofish.itemdotsize", "Item Dot Size", "1.0.2")] public class ItemDotSizePlugin : BaseUnityPlugin { public const string DotSizePrefKey = "ItemDotSize"; public const float DefaultScale = 2f; public const float MinScale = 0.5f; public const float MaxScale = 5f; private Harmony _harmony; public static ItemDotSizePlugin Instance { get; private set; } public static float CurrentScale => PlayerPrefs.GetFloat("ItemDotSize", 2f); private void Awake() { //IL_000c: Unknown result type (might be due to invalid IL or missing references) //IL_0016: Expected O, but got Unknown Instance = this; _harmony = new Harmony("com.pulsion.howtofish.itemdotsize"); _harmony.PatchAll(); ((BaseUnityPlugin)this).Logger.LogInfo((object)"Loaded Item Dot Size v1.0.2"); } private void OnDestroy() { Harmony harmony = _harmony; if (harmony != null) { harmony.UnpatchSelf(); } _harmony = null; } public static void SetScale(float value) { value = Mathf.Clamp(value, 0.5f, 5f); PlayerPrefs.SetFloat("ItemDotSize", value); PlayerPrefs.Save(); DotSizeController.ApplyScale(value); } public static void Log(string message) { ItemDotSizePlugin instance = Instance; if (instance != null) { ((BaseUnityPlugin)instance).Logger.LogInfo((object)message); } } public static void LogWarning(string message) { ItemDotSizePlugin instance = Instance; if (instance != null) { ((BaseUnityPlugin)instance).Logger.LogWarning((object)message); } } } internal static class PluginInfo { public const string PLUGIN_GUID = "com.pulsion.howtofish.itemdotsize"; public const string PLUGIN_NAME = "Item Dot Size"; public const string PLUGIN_VERSION = "1.0.2"; } internal static class DotSizeController { private static readonly FieldInfo _dotsField = typeof(CloseItemsUI).GetField("_closeItemsDots", BindingFlags.Instance | BindingFlags.NonPublic); public static void ApplyScale(float scale) { //IL_0075: Unknown result type (might be due to invalid IL or missing references) if (_dotsField == null) { Debug.LogWarning((object)"[ItemDotSize] Could not find CloseItemsUI._closeItemsDots field."); return; } CloseItemsUI[] array = Object.FindObjectsByType(); Vector3 localScale = default(Vector3); foreach (CloseItemsUI val in array) { if ((Object)(object)val == (Object)null || !(_dotsField.GetValue(val) is List list)) { continue; } ((Vector3)(ref localScale))..ctor(scale, scale, 1f); foreach (Image item in list) { if ((Object)(object)item != (Object)null) { ((Component)item).transform.localScale = localScale; } } } } } [HarmonyPatch(typeof(CloseItemsUI), "InitializeLocal")] internal static class CloseItemsUI_InitializeLocal_Patch { private static void Postfix() { DotSizeController.ApplyScale(ItemDotSizePlugin.CurrentScale); } } [HarmonyPatch(typeof(ButtonManager), "SetupUI")] internal static class ButtonManager_SetupUI_Patch { private static void Postfix(ButtonManager __instance) { SettingsSliderInjector.Inject(__instance); } } internal static class SettingsSliderInjector { private const string RowObjectName = "ItemDotSizeRow"; private static readonly FieldInfo _sensitivitySliderField = typeof(ButtonManager).GetField("_sensitivitySlider", BindingFlags.Instance | BindingFlags.NonPublic); public static void Inject(ButtonManager instance) { //IL_0171: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)instance == (Object)null) { return; } if (_sensitivitySliderField == null) { ItemDotSizePlugin.LogWarning("[ItemDotSize] _sensitivitySlider field not found."); return; } object? value = _sensitivitySliderField.GetValue(instance); Slider val = (Slider)((value is Slider) ? value : null); if (val == null || (Object)(object)val == (Object)null) { ItemDotSizePlugin.LogWarning("[ItemDotSize] Sensitivity slider not found."); return; } Transform parent = ((Component)val).transform.parent; if ((Object)(object)parent == (Object)null) { return; } Transform parent2 = parent.parent; if ((Object)(object)parent2 == (Object)null) { return; } Transform val2 = parent2.Find("ItemDotSizeRow"); if ((Object)(object)val2 != (Object)null) { Slider componentInChildren = ((Component)val2).GetComponentInChildren(true); TMP_InputField componentInChildren2 = ((Component)val2).GetComponentInChildren(true); if ((Object)(object)componentInChildren != (Object)null) { ConfigureSlider(componentInChildren, componentInChildren2); } return; } GameObject val3 = Object.Instantiate(((Component)parent).gameObject, parent2); ((Object)val3).name = "ItemDotSizeRow"; Slider componentInChildren3 = val3.GetComponentInChildren(true); if ((Object)(object)componentInChildren3 == (Object)null) { Object.Destroy((Object)(object)val3); ItemDotSizePlugin.LogWarning("[ItemDotSize] Cloned row has no Slider."); return; } TextMeshProUGUI val4 = FindLabel(val3.transform); if ((Object)(object)val4 != (Object)null) { DisableLocalization(val4); ((TMP_Text)val4).text = "Dot Size"; } else { val4 = CreateFallbackLabel(val3.transform); } TMP_InputField componentInChildren4 = val3.GetComponentInChildren(true); ConfigureSlider(componentInChildren3, componentInChildren4); ConfigureInputField(componentInChildren4, componentInChildren3); val3.transform.SetSiblingIndex(parent.GetSiblingIndex() + 1); Transform transform = val3.transform; RectTransform val5 = (RectTransform)(object)((transform is RectTransform) ? transform : null); if ((Object)(object)val5 != (Object)null) { val5.anchoredPosition = Vector2.zero; } RebuildLayouts(parent, parent2, val3); ItemDotSizePlugin.Log("[ItemDotSize] Injected 'Dot Size' row under panel '" + ((Object)parent2).name + "'."); } private static void ConfigureSlider(Slider slider, TMP_InputField input) { //IL_0024: Unknown result type (might be due to invalid IL or missing references) //IL_002e: Expected O, but got Unknown slider.minValue = 0.5f; slider.maxValue = 5f; slider.onValueChanged = new SliderEvent(); slider.value = ItemDotSizePlugin.CurrentScale; ((UnityEvent)(object)slider.onValueChanged).AddListener((UnityAction)delegate(float value) { ItemDotSizePlugin.SetScale(value); if ((Object)(object)input != (Object)null) { input.SetTextWithoutNotify(FormatScale(value)); } }); if ((Object)(object)input != (Object)null) { input.SetTextWithoutNotify(FormatScale(slider.value)); } } private static void ConfigureInputField(TMP_InputField input, Slider slider) { //IL_0029: Unknown result type (might be due to invalid IL or missing references) //IL_0033: Expected O, but got Unknown //IL_0039: Unknown result type (might be due to invalid IL or missing references) //IL_0043: Expected O, but got Unknown if ((Object)(object)input == (Object)null) { return; } input.onEndEdit = new SubmitEvent(); input.onValueChanged = new OnChangeEvent(); input.contentType = (ContentType)3; input.SetTextWithoutNotify(FormatScale(ItemDotSizePlugin.CurrentScale)); ((UnityEvent)(object)input.onEndEdit).AddListener((UnityAction)delegate(string text) { if (TryParseScale(text, out var value)) { value = Mathf.Clamp(value, 0.5f, 5f); slider.value = value; } else { input.SetTextWithoutNotify(FormatScale(ItemDotSizePlugin.CurrentScale)); } }); } private static string FormatScale(float value) { return value.ToString("0.00", CultureInfo.InvariantCulture); } private static bool TryParseScale(string text, out float value) { if (!float.TryParse(text, NumberStyles.Float, CultureInfo.InvariantCulture, out value)) { return float.TryParse(text, NumberStyles.Float, CultureInfo.CurrentCulture, out value); } return true; } private static void RebuildLayouts(Transform row, Transform panel, GameObject cloneRow) { //IL_005f: Unknown result type (might be due to invalid IL or missing references) //IL_0064: Unknown result type (might be due to invalid IL or missing references) //IL_0068: 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_008d: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)cloneRow.GetComponent() != (Object)null) { Transform transform = cloneRow.transform; LayoutRebuilder.ForceRebuildLayoutImmediate((RectTransform)(object)((transform is RectTransform) ? transform : null)); } if ((Object)(object)((Component)panel).GetComponent() != (Object)null) { LayoutRebuilder.ForceRebuildLayoutImmediate((RectTransform)(object)((panel is RectTransform) ? panel : null)); } else { Transform transform2 = cloneRow.transform; RectTransform val = (RectTransform)(object)((transform2 is RectTransform) ? transform2 : null); RectTransform val2 = (RectTransform)(object)((row is RectTransform) ? row : null); if ((Object)(object)val != (Object)null && (Object)(object)val2 != (Object)null) { Vector2 anchoredPosition = val.anchoredPosition; float y = val2.anchoredPosition.y; Rect rect = val2.rect; anchoredPosition.y = y - (((Rect)(ref rect)).height + 8f); val.anchoredPosition = anchoredPosition; } } Canvas.ForceUpdateCanvases(); } private static TextMeshProUGUI FindLabel(Transform row) { TMP_InputField componentInChildren = ((Component)row).GetComponentInChildren(true); TextMeshProUGUI[] componentsInChildren = ((Component)row).GetComponentsInChildren(true); if (componentsInChildren == null || componentsInChildren.Length == 0) { return null; } TextMeshProUGUI[] array = componentsInChildren; foreach (TextMeshProUGUI val in array) { if (!((Object)(object)componentInChildren != (Object)null) || !((TMP_Text)val).transform.IsChildOf(((Component)componentInChildren).transform)) { return val; } } return null; } private static TextMeshProUGUI CreateFallbackLabel(Transform clone) { //IL_003d: 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_004f: 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_00a2: 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_00cc: Unknown result type (might be due to invalid IL or missing references) //IL_00e1: 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) TMP_FontAsset val = TMP_Settings.defaultFontAsset; if ((Object)(object)val == (Object)null) { TextMeshProUGUI val2 = Object.FindAnyObjectByType(); if ((Object)(object)val2 != (Object)null) { val = ((TMP_Text)val2).font; } } GameObject val3 = new GameObject("Label", new Type[1] { typeof(RectTransform) }); val3.transform.SetParent(clone, false); TextMeshProUGUI val4 = val3.AddComponent(); if ((Object)(object)val != (Object)null) { ((TMP_Text)val4).font = val; } ((TMP_Text)val4).fontSize = 22f; ((Graphic)val4).color = Color.white; ((TMP_Text)val4).alignment = (TextAlignmentOptions)513; ((TMP_Text)val4).text = "Dot Size"; RectTransform component = val3.GetComponent(); component.anchorMin = new Vector2(0f, 0.5f); component.anchorMax = new Vector2(0f, 0.5f); component.pivot = new Vector2(0f, 0.5f); component.anchoredPosition = new Vector2(-160f, 0f); component.sizeDelta = new Vector2(150f, 30f); return val4; } private static void DisableLocalization(TextMeshProUGUI label) { MonoBehaviour[] components = ((Component)label).GetComponents(); foreach (MonoBehaviour val in components) { if (!((Object)(object)val == (Object)null)) { string name = ((object)val).GetType().Name; if (name.IndexOf("Localize", StringComparison.OrdinalIgnoreCase) >= 0 || name.IndexOf("Localized", StringComparison.OrdinalIgnoreCase) >= 0) { ((Behaviour)val).enabled = false; } } } } }