diff --git a/Camera.cs b/Camera.cs index ac86548ec..6f6a00a7f 100644 --- a/Camera.cs +++ b/Camera.cs @@ -18,7 +18,8 @@ namespace ClassicalSharp { public virtual void Tick( double elapsed ) { } - public virtual void MouseZoom( MouseWheelEventArgs e ) { + public virtual bool MouseZoom( MouseWheelEventArgs e ) { + return false; } public abstract void RegrabMouse(); @@ -104,9 +105,10 @@ namespace ClassicalSharp { } float distance = 3; - public override void MouseZoom( MouseWheelEventArgs e ) { + public override bool MouseZoom( MouseWheelEventArgs e ) { distance -= e.DeltaPrecise; if( distance < 2 ) distance = 2; + return true; } public override Matrix4 GetView() { diff --git a/Game/Game.InputHandling.cs b/Game/Game.InputHandling.cs index 9ba84f465..4eeaaeee8 100644 --- a/Game/Game.InputHandling.cs +++ b/Game/Game.InputHandling.cs @@ -61,7 +61,13 @@ namespace ClassicalSharp { } void MouseWheelChanged( object sender, MouseWheelEventArgs e ) { - Camera.MouseZoom( e ); + if( !Camera.MouseZoom( e ) && CanChangeHeldBlock ) { + int diffIndex = -e.Delta % BlocksHotbar.Length; + int newIndex = HeldBlockIndex + diffIndex; + if( newIndex < 0 ) newIndex += BlocksHotbar.Length; + if( newIndex >= BlocksHotbar.Length ) newIndex -= BlocksHotbar.Length; + HeldBlockIndex = newIndex; + } } void KeyPressHandler( object sender, KeyPressEventArgs e ) {