mousewheel split/use dialogs

This commit is contained in:
Tyfon
2024-09-16 00:32:22 -07:00
parent 69f250263c
commit 28143b07be
2 changed files with 74 additions and 0 deletions

73
Patches/SliderPatch.cs Normal file
View File

@@ -0,0 +1,73 @@
using EFT.UI;
using HarmonyLib;
using SPT.Reflection.Patching;
using System.Reflection;
using UnityEngine;
using UnityEngine.UI;
namespace UIFixes;
public static class SliderPatches
{
public static void Enable()
{
new IntSliderPatch().Enable();
new StepSliderPatch().Enable();
}
public class IntSliderPatch : ModulePatch
{
protected override MethodBase GetTargetMethod()
{
return AccessTools.Method(typeof(IntSlider), nameof(IntSlider.Awake));
}
[PatchPostfix]
public static void Postfix(Slider ____slider)
{
____slider.GetOrAddComponent<SliderMouseListener>().Init(____slider);
}
}
public class StepSliderPatch : ModulePatch
{
protected override MethodBase GetTargetMethod()
{
return AccessTools.Method(typeof(StepSlider), nameof(StepSlider.Awake));
}
[PatchPostfix]
public static void Postfix(Slider ____slider)
{
____slider.GetOrAddComponent<SliderMouseListener>().Init(____slider);
}
}
public class SliderMouseListener : MonoBehaviour
{
private Slider slider;
public void Init(Slider slider)
{
this.slider = slider;
}
public void Update()
{
if (slider == null)
{
return;
}
if (Input.mouseScrollDelta.y > float.Epsilon)
{
slider.value = Mathf.Min(slider.value + 1, slider.maxValue);
}
else if (Input.mouseScrollDelta.y < -float.Epsilon)
{
slider.value = Mathf.Max(slider.value - 1, slider.minValue);
}
}
}
}

View File

@@ -79,6 +79,7 @@ public class Plugin : BaseUnityPlugin
TacticalBindsPatches.Enable();
AddOfferContextMenuPatches.Enable();
new OperationQueuePatch().Enable();
SliderPatches.Enable();
}
public static bool InRaid()