worldbox-observer-mod/IdleSpectator/CameraZoomPatches.cs

34 lines
977 B
C#

using HarmonyLib;
namespace IdleSpectator;
/// <summary>
/// WorldBox zooms on mouse wheel even over UI while a unit is focused
/// (<c>!isOverUI || MoveCamera.inSpectatorMode()</c>). Absorb wheel zoom when
/// the cursor is over Lore or the dossier so ScrollRect history can scroll.
/// </summary>
[HarmonyPatch]
internal static class CameraZoomPatches
{
/// <summary>Harness: force the zoom block without needing a real mouse position.</summary>
public static bool ForceAbsorbForHarness;
private static bool Absorb()
{
return ForceAbsorbForHarness || ChronicleHud.ShouldAbsorbScrollZoom();
}
[HarmonyPatch(typeof(MoveCamera), nameof(MoveCamera.zoomInWheel))]
[HarmonyPrefix]
private static bool PrefixZoomInWheel()
{
return !Absorb();
}
[HarmonyPatch(typeof(MoveCamera), nameof(MoveCamera.zoomOutWheel))]
[HarmonyPrefix]
private static bool PrefixZoomOutWheel()
{
return !Absorb();
}
}