Added mousewheel zooming

This commit is contained in:
Philipp Schärer
2016-01-25 18:28:06 +01:00
committed by Oliver Brakmann
parent 386acdcfc9
commit ea74499ec2
10 changed files with 198 additions and 30 deletions

View File

@@ -69,8 +69,29 @@ namespace OpenRA.Mods.Common.Widgets
tooltipContainer.Value.RemoveTooltip();
}
void Zoom(int amount)
{
var zoomSteps = worldRenderer.Viewport.AvailableZoomSteps;
var currentZoom = worldRenderer.Viewport.Zoom;
var nextIndex = zoomSteps.IndexOf(currentZoom) - amount;
if (nextIndex < 0 || nextIndex >= zoomSteps.Length)
return;
var zoom = zoomSteps[nextIndex];
Parent.Get<DropDownButtonWidget>("ZOOM_BUTTON").SelectedItem = zoom.ToString();
worldRenderer.Viewport.Zoom = zoom;
}
public override bool HandleMouseInput(MouseInput mi)
{
if (mi.Event == MouseInputEvent.Scroll &&
Game.Settings.Game.AllowZoom && mi.Modifiers.HasModifier(Game.Settings.Game.ZoomModifier))
{
Zoom(mi.ScrollDelta);
return true;
}
if (CurrentBrush.HandleMouseInput(mi))
return true;