mirror of
https://github.com/ClassiCube/ClassiCube.git
synced 2025-09-15 02:25:32 -04:00
Add scrolling in block hotbar.
This commit is contained in:
parent
81ae1012ee
commit
c7bfbc8567
@ -18,7 +18,8 @@ namespace ClassicalSharp {
|
|||||||
public virtual void Tick( double elapsed ) {
|
public virtual void Tick( double elapsed ) {
|
||||||
}
|
}
|
||||||
|
|
||||||
public virtual void MouseZoom( MouseWheelEventArgs e ) {
|
public virtual bool MouseZoom( MouseWheelEventArgs e ) {
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
public abstract void RegrabMouse();
|
public abstract void RegrabMouse();
|
||||||
@ -104,9 +105,10 @@ namespace ClassicalSharp {
|
|||||||
}
|
}
|
||||||
|
|
||||||
float distance = 3;
|
float distance = 3;
|
||||||
public override void MouseZoom( MouseWheelEventArgs e ) {
|
public override bool MouseZoom( MouseWheelEventArgs e ) {
|
||||||
distance -= e.DeltaPrecise;
|
distance -= e.DeltaPrecise;
|
||||||
if( distance < 2 ) distance = 2;
|
if( distance < 2 ) distance = 2;
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
public override Matrix4 GetView() {
|
public override Matrix4 GetView() {
|
||||||
|
@ -61,7 +61,13 @@ namespace ClassicalSharp {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void MouseWheelChanged( object sender, MouseWheelEventArgs e ) {
|
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 ) {
|
void KeyPressHandler( object sender, KeyPressEventArgs e ) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user