Please disclose if any significant portion of your mod was created using AI tools by adding the 'AI Generated' category. Failing to do so may result in the mod being removed from Thunderstore.
Decompiled source of RecipeScrollFix v1.0.0
RecipeScrollFix.dll
Decompiled 2 weeks agousing System.Reflection; using System.Runtime.CompilerServices; using BepInEx; using BepInEx.Configuration; using BepInEx.Logging; using HarmonyLib; using UnityEngine; using UnityEngine.EventSystems; using UnityEngine.UI; [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: AssemblyVersion("0.0.0.0")] namespace RecipeScrollFix; internal sealed class ConfigurationManagerAttributes { public int? Order; public bool? IsAdvanced; public string DispName; } [BepInPlugin("r4b2.RecipeScrollFix", "Recipe Scroll Fix", "1.0.0")] public class RecipeScrollFixPlugin : BaseUnityPlugin { public const string PluginGuid = "r4b2.RecipeScrollFix"; public const string PluginName = "Recipe Scroll Fix"; public const string PluginVersion = "1.0.0"; internal static ConfigEntry<bool> Enabled; internal static ConfigEntry<float> RowsPerNotch; internal static ConfigEntry<bool> DebugLog; internal static ManualLogSource Log; internal static ScrollRect RecipeScroll; internal static InventoryGui Gui; private void Awake() { //IL_0049: Unknown result type (might be due to invalid IL or missing references) //IL_0053: Expected O, but got Unknown //IL_00a8: Unknown result type (might be due to invalid IL or missing references) //IL_00b2: Expected O, but got Unknown //IL_0101: Unknown result type (might be due to invalid IL or missing references) //IL_010b: Expected O, but got Unknown //IL_0115: Unknown result type (might be due to invalid IL or missing references) Log = ((BaseUnityPlugin)this).Logger; Enabled = ((BaseUnityPlugin)this).Config.Bind<bool>("1 - General", "Enabled", true, new ConfigDescription("Use a fixed scroll step for the crafting / upgrade recipe list. Turn off to get the vanilla behaviour back.", (AcceptableValueBase)null, new object[1] { new ConfigurationManagerAttributes { Order = 3, DispName = "Enabled" } })); RowsPerNotch = ((BaseUnityPlugin)this).Config.Bind<float>("1 - General", "Rows per mouse wheel notch", 2f, new ConfigDescription("How many recipe rows the list moves per mouse wheel notch. Changes apply immediately.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0.25f, 10f), new object[1] { new ConfigurationManagerAttributes { Order = 2, DispName = "Rows per mouse wheel notch" } })); DebugLog = ((BaseUnityPlugin)this).Config.Bind<bool>("2 - Debug", "Log scroll values", false, new ConfigDescription("Log the raw scroll values the game sends to the recipe list (useful for tuning / bug reports).", (AcceptableValueBase)null, new object[1] { new ConfigurationManagerAttributes { Order = 1, IsAdvanced = true, DispName = "Log scroll values" } })); new Harmony("r4b2.RecipeScrollFix").PatchAll(); } } [HarmonyPatch(typeof(InventoryGui), "Awake")] internal static class InventoryGui_Awake_Patch { private static void Postfix(InventoryGui __instance) { RecipeScrollFixPlugin.Gui = __instance; RecipeScrollFixPlugin.RecipeScroll = ((!((Object)(object)__instance.m_recipeListRoot != (Object)null)) ? null : ((Component)__instance.m_recipeListRoot).GetComponentInParent<ScrollRect>()); if ((Object)(object)RecipeScrollFixPlugin.RecipeScroll == (Object)null) { RecipeScrollFixPlugin.Log.LogWarning((object)"Could not find the recipe list ScrollRect - nothing will be changed."); return; } RecipeScrollFixPlugin.Log.LogInfo((object)("Recipe list ScrollRect found: sensitivity=" + RecipeScrollFixPlugin.RecipeScroll.scrollSensitivity + ", rowSpace=" + __instance.m_recipeListSpace)); } } [HarmonyPatch(typeof(ScrollRect), "OnScroll")] internal static class ScrollRect_OnScroll_Patch { private static void Prefix(ScrollRect __instance, PointerEventData data) { //IL_0037: 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_0126: 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) if (!RecipeScrollFixPlugin.Enabled.Value || data == null || (Object)(object)__instance != (Object)(object)RecipeScrollFixPlugin.RecipeScroll || (Object)(object)RecipeScrollFixPlugin.Gui == (Object)null) { return; } Vector2 scrollDelta = data.scrollDelta; float num = ((!(Mathf.Abs(scrollDelta.y) >= Mathf.Abs(scrollDelta.x))) ? scrollDelta.x : scrollDelta.y); if (num != 0f) { float num2 = Mathf.Max(RecipeScrollFixPlugin.Gui.m_recipeListSpace, 1f); float num3 = num2 * RecipeScrollFixPlugin.RowsPerNotch.Value; float num4 = Mathf.Max(__instance.scrollSensitivity, 0.0001f); if (RecipeScrollFixPlugin.DebugLog.Value) { RecipeScrollFixPlugin.Log.LogInfo((object)string.Concat("raw scrollDelta=", scrollDelta, " -> ", Mathf.Sign(num) * num3, "px (sens ", num4, ")")); } data.scrollDelta = new Vector2(0f, Mathf.Sign(num) * num3 / num4); } } }