When zooming using the mousewheel, zoom towards the pointer location.

This commit is contained in:
Andre Mohren
2020-07-14 17:17:05 +02:00
committed by Oliver Brakmann
parent b417b267dd
commit 914950c4a5
3 changed files with 10 additions and 2 deletions

View File

@@ -97,6 +97,14 @@ namespace OpenRA.Graphics
Zoom = (zoom * (float)Math.Exp(dz)).Clamp(unlockMinZoom ? unlockedMinZoom : minZoom, maxZoom);
}
public void AdjustZoom(float dz, int2 center)
{
var oldCenter = worldRenderer.Viewport.ViewToWorldPx(center);
AdjustZoom(dz);
var newCenter = worldRenderer.Viewport.ViewToWorldPx(center);
CenterLocation += oldCenter - newCenter;
}
public void ToggleZoom()
{
// Unlocked zooms always reset to the default zoom