mirror of
https://github.com/ClassiCube/ClassiCube.git
synced 2025-09-15 10:35:11 -04:00
Left clicking outside table in block select screen should close it, also improve picking for map borders when outside the map.
This commit is contained in:
parent
2cb3322c34
commit
17f87dbbbb
@ -91,7 +91,7 @@ namespace ClassicalSharp {
|
||||
blockSize = (int)(50 * Math.Sqrt(game.GuiInventoryScale));
|
||||
selBlockExpand = (float)(25 * Math.Sqrt(game.GuiInventoryScale));
|
||||
game.Events.BlockPermissionsChanged += BlockPermissionsChanged;
|
||||
|
||||
|
||||
RecreateBlockTable();
|
||||
SetBlockTo( game.Inventory.HeldBlock );
|
||||
game.Keyboard.KeyRepeat = true;
|
||||
@ -254,8 +254,11 @@ namespace ClassicalSharp {
|
||||
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];
|
||||
} else if( button == MouseButton.Left ) {
|
||||
if( selIndex != -1 )
|
||||
game.Inventory.HeldBlock = blocksTable[selIndex];
|
||||
else if( Contains( TableX, TableY, TableWidth, TableHeight, mouseX, mouseY ) )
|
||||
return true;
|
||||
game.SetNewScreen( null );
|
||||
}
|
||||
return true;
|
||||
|
@ -169,19 +169,33 @@ namespace ClassicalSharp {
|
||||
}
|
||||
}
|
||||
|
||||
const byte border = (byte)Block.Bedrock;
|
||||
static byte GetBlock( Map map, int x, int y, int z, Vector3 origin ) {
|
||||
if( x >= 0 && z >= 0 && x < map.Width && z < map.Length ) {
|
||||
if( y >= map.Height ) return 0;
|
||||
if( y >= 0 ) return map.GetBlock( x, y, z );
|
||||
if( map.SidesBlock != Block.Air && y == -1 )
|
||||
return (byte)Block.Bedrock;
|
||||
}
|
||||
if( map.SidesBlock == Block.Air ) return 0;
|
||||
bool sides = map.SidesBlock != Block.Air;
|
||||
int height = Math.Max( 1, map.SidesHeight );
|
||||
bool insideMap = map.IsValidPos( Vector3I.Floor( origin ) );
|
||||
|
||||
// handling of blocks inside the map, above, and on borders
|
||||
if( x >= 0 && z >= 0 && x < map.Width && z < map.Length ) {
|
||||
if( y >= map.Height ) return 0;
|
||||
if( sides && y == -1 && insideMap ) return border;
|
||||
if( sides && y == 0 && origin.Y < 0 ) return border;
|
||||
|
||||
if( sides && x == 0 && y >= 0 && y < height && origin.X < 0 ) return border;
|
||||
if( sides && z == 0 && y >= 0 && y < height && origin.Z < 0 ) return border;
|
||||
if( sides && x == (map.Width - 1) && y >= 0 && y < height && origin.X >= map.Width )
|
||||
return border;
|
||||
if( sides && z == (map.Length - 1) && y >= 0 && y < height && origin.Z >= map.Length )
|
||||
return border;
|
||||
if( y >= 0 ) return map.GetBlock( x, y, z );
|
||||
}
|
||||
|
||||
// pick blocks on the map boundaries (when inside the map)
|
||||
if( !sides || !insideMap ) return 0;
|
||||
if( y == 0 && origin.Y < 0 ) return border;
|
||||
bool validX = (x == -1 || x == map.Width) && (z >= 0 && z < map.Length);
|
||||
bool validZ = (z == -1 || z == map.Length) && (x >= 0 && x < map.Width);
|
||||
if( y >= 0 && y < Math.Max( 1, map.SidesHeight ) && (validX || validZ) )
|
||||
return (byte)Block.Bedrock;
|
||||
if( y >= 0 && y < height && (validX || validZ) ) return border;
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user