mirror of
https://github.com/ClassiCube/ClassiCube.git
synced 2025-09-14 18:15:28 -04:00
Can drag scrollbar in block select screen.
This commit is contained in:
parent
5d65eca0b8
commit
0f95d6d92f
@ -1,4 +1,5 @@
|
||||
using System;
|
||||
using OpenTK.Input;
|
||||
|
||||
namespace ClassicalSharp {
|
||||
|
||||
@ -11,8 +12,8 @@ namespace ClassicalSharp {
|
||||
graphicsApi.Draw2DQuad( TableX, TableY, scrollbarWidth,
|
||||
TableHeight, scrollCol );
|
||||
float scale = TableHeight / (float)rows;
|
||||
int yOffset = (int)Math.Ceiling(scrollY * scale);
|
||||
int height = (int)Math.Ceiling(maxRows * scale);
|
||||
int yOffset = (int)Math.Ceiling( scrollY * scale );
|
||||
int height = (int)Math.Ceiling( maxRows * scale );
|
||||
|
||||
if( yOffset + height > TableHeight )
|
||||
height = TableHeight - yOffset;
|
||||
@ -53,5 +54,12 @@ namespace ClassicalSharp {
|
||||
scrollY = (int)(mouseY / scale);
|
||||
ClampScrollY();
|
||||
}
|
||||
|
||||
bool draggingMouse = false;
|
||||
|
||||
public override bool HandlesMouseUp( int mouseX, int mouseY, MouseButton button ) {
|
||||
draggingMouse = false;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -218,6 +218,11 @@ namespace ClassicalSharp {
|
||||
}
|
||||
|
||||
public override bool HandlesMouseMove( int mouseX, int mouseY ) {
|
||||
if( draggingMouse ) {
|
||||
ScrollbarClick( mouseY );
|
||||
return true;
|
||||
}
|
||||
|
||||
selIndex = -1;
|
||||
if( Contains( startX, startY, blocksPerRow * blockSize,
|
||||
maxRows * blockSize, mouseX, mouseY ) ) {
|
||||
@ -236,10 +241,11 @@ namespace ClassicalSharp {
|
||||
}
|
||||
|
||||
public override bool HandlesMouseClick( int mouseX, int mouseY, MouseButton button ) {
|
||||
if( game.hudScreen.hotbar.HandlesMouseClick( mouseX, mouseY, button ) )
|
||||
if( draggingMouse || game.hudScreen.hotbar.HandlesMouseClick( mouseX, mouseY, button ) )
|
||||
return true;
|
||||
if( button == MouseButton.Left && mouseX >= TableX && mouseX < TableX + scrollbarWidth ) {
|
||||
ScrollbarClick( mouseY );
|
||||
draggingMouse = true;
|
||||
} else if( button == MouseButton.Left && selIndex != -1 ) {
|
||||
game.Inventory.HeldBlock = blocksTable[selIndex];
|
||||
game.SetNewScreen( null );
|
||||
|
Loading…
x
Reference in New Issue
Block a user