mirror of
https://github.com/ClassiCube/ClassiCube.git
synced 2025-09-15 18:45:23 -04:00
Fix using scroll wheel on last column past last valid item crashing the client. (Thanks nyxzimus)
This commit is contained in:
parent
31753e1f9e
commit
a5d91ca5cb
@ -23,16 +23,17 @@ namespace ClassicalSharp {
|
|||||||
public override bool HandlesMouseScroll( int delta ) {
|
public override bool HandlesMouseScroll( int delta ) {
|
||||||
bool bounds = Contains( TableX, TableY, TableWidth, TableHeight,
|
bool bounds = Contains( TableX, TableY, TableWidth, TableHeight,
|
||||||
game.Mouse.X, game.Mouse.Y );
|
game.Mouse.X, game.Mouse.Y );
|
||||||
if( !bounds ) return false;
|
if( !bounds || selIndex == -1 ) return false;
|
||||||
|
delta = -delta;
|
||||||
int startScrollY = scrollY;
|
int startScrollY = scrollY;
|
||||||
scrollY -= delta;
|
selIndex += delta * blocksPerRow;
|
||||||
ClampScrollY();
|
|
||||||
|
|
||||||
int diffY = scrollY - startScrollY;
|
if( selIndex >= blocksTable.Length || selIndex < 0 )
|
||||||
if( selIndex >= 0 ) {
|
selIndex -= delta * blocksPerRow;
|
||||||
selIndex += diffY * blocksPerRow;
|
Utils.Clamp( ref selIndex, 0, blocksTable.Length - 1 );
|
||||||
RecreateBlockInfoTexture();
|
int endScrollY = selIndex / blocksPerRow;
|
||||||
}
|
|
||||||
|
UpdateSelectedState();
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
int scrollY;
|
int scrollY;
|
||||||
|
@ -174,7 +174,7 @@ namespace ClassicalSharp {
|
|||||||
lastCreatedIndex = selIndex;
|
lastCreatedIndex = selIndex;
|
||||||
|
|
||||||
graphicsApi.DeleteTexture( ref blockInfoTexture );
|
graphicsApi.DeleteTexture( ref blockInfoTexture );
|
||||||
if( selIndex == -1 || selIndex >= blocksTable.Length ) return;
|
if( selIndex == -1 ) return;
|
||||||
|
|
||||||
Block block = blocksTable[selIndex];
|
Block block = blocksTable[selIndex];
|
||||||
UpdateBlockInfoString( block );
|
UpdateBlockInfoString( block );
|
||||||
|
Loading…
x
Reference in New Issue
Block a user