mirror of
https://github.com/ClassiCube/ClassiCube.git
synced 2025-09-16 02:56:09 -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
@ -254,8 +254,11 @@ namespace ClassicalSharp {
|
|||||||
if( button == MouseButton.Left && mouseX >= TableX && mouseX < TableX + scrollbarWidth ) {
|
if( button == MouseButton.Left && mouseX >= TableX && mouseX < TableX + scrollbarWidth ) {
|
||||||
ScrollbarClick( mouseY );
|
ScrollbarClick( mouseY );
|
||||||
draggingMouse = true;
|
draggingMouse = true;
|
||||||
} else if( button == MouseButton.Left && selIndex != -1 ) {
|
} else if( button == MouseButton.Left ) {
|
||||||
|
if( selIndex != -1 )
|
||||||
game.Inventory.HeldBlock = blocksTable[selIndex];
|
game.Inventory.HeldBlock = blocksTable[selIndex];
|
||||||
|
else if( Contains( TableX, TableY, TableWidth, TableHeight, mouseX, mouseY ) )
|
||||||
|
return true;
|
||||||
game.SetNewScreen( null );
|
game.SetNewScreen( null );
|
||||||
}
|
}
|
||||||
return true;
|
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 ) {
|
static byte GetBlock( Map map, int x, int y, int z, Vector3 origin ) {
|
||||||
|
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( x >= 0 && z >= 0 && x < map.Width && z < map.Length ) {
|
||||||
if( y >= map.Height ) return 0;
|
if( y >= map.Height ) return 0;
|
||||||
if( y >= 0 ) return map.GetBlock( x, y, z );
|
if( sides && y == -1 && insideMap ) return border;
|
||||||
if( map.SidesBlock != Block.Air && y == -1 )
|
if( sides && y == 0 && origin.Y < 0 ) return border;
|
||||||
return (byte)Block.Bedrock;
|
|
||||||
}
|
|
||||||
if( map.SidesBlock == Block.Air ) return 0;
|
|
||||||
|
|
||||||
|
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 validX = (x == -1 || x == map.Width) && (z >= 0 && z < map.Length);
|
||||||
bool validZ = (z == -1 || z == map.Length) && (x >= 0 && x < map.Width);
|
bool validZ = (z == -1 || z == map.Length) && (x >= 0 && x < map.Width);
|
||||||
if( y >= 0 && y < Math.Max( 1, map.SidesHeight ) && (validX || validZ) )
|
if( y >= 0 && y < height && (validX || validZ) ) return border;
|
||||||
return (byte)Block.Bedrock;
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user