Unofficial CardLife revival project, pronounced like "celery"
Vous ne pouvez pas sélectionner plus de 25 sujets Les noms de sujets doivent commencer par une lettre ou un nombre, peuvent contenir des tirets ('-') et peuvent comporter jusqu'à 35 caractères.

InventoryPanelScrollEngineFix.cs 1.8KB

123456789101112131415161718192021222324252627282930313233343536373839
  1. using System;
  2. using HarmonyLib;
  3. using System.Reflection;
  4. using UnityEngine;
  5. namespace CLre.Fixes
  6. {
  7. [Bugfix(name = "ScrollSpeedImprovement",
  8. description = "Improve mouse wheel scroll speed in inventory",
  9. more = "https://trello.com/c/elL8IVdn/4-scroll-menus-are-insensitive",
  10. component = BugfixType.HarmonyPatch, id = 5)]
  11. [HarmonyPatch]
  12. class InventoryPanelScrollEngine_ScrollPanelByMouseWheel_Patch
  13. {
  14. [HarmonyPrefix]
  15. public static bool BeforeMethodCall(ref object panelScrollComponent, ref float scrollValue)
  16. {
  17. if (panelScrollComponent == null) return true; // If it's null, we don't try to handle it.
  18. // We, perhaps dangerously, assume that we'll only get a panelScrollComponent.
  19. PropertyInfo scrollbar = panelScrollComponent.GetType().GetProperty("scrollbar", System.Reflection.BindingFlags.Public | System.Reflection.BindingFlags.NonPublic | System.Reflection.BindingFlags.Instance);
  20. UnityEngine.UI.Scrollbar sb = scrollbar.GetValue(panelScrollComponent) as UnityEngine.UI.Scrollbar;
  21. float num = -scrollValue * (sb.size * 0.3f);
  22. float num2 = sb.value;
  23. num2 = Mathf.Clamp01(num2 + num);
  24. sb.value = num2;
  25. return false; // Tell harmony not to invoke the original method
  26. }
  27. [HarmonyTargetMethod]
  28. public static MethodBase Target()
  29. {
  30. MethodInfo methodtopatch = AccessTools.Method("Game.UI.InventoryPanelScrollEngine:ScrollPanelByMouseWheel");
  31. if (null == methodtopatch) API.Utility.Logging.MetaLog("Intercepting Game.UI.InventoryPanelScrollEngine:ScrollPanelByMouseWheel() failed");
  32. return methodtopatch;
  33. }
  34. }
  35. }