diff --git a/ClassicalSharp/2D/Screens/ChatScreen.cs b/ClassicalSharp/2D/Screens/ChatScreen.cs index 4eafcf06e..883f693ff 100644 --- a/ClassicalSharp/2D/Screens/ChatScreen.cs +++ b/ClassicalSharp/2D/Screens/ChatScreen.cs @@ -245,17 +245,15 @@ namespace ClassicalSharp { if( key == game.Mapping( KeyBinding.PauseOrExit ) ) textInput.Clear(); textInput.SendTextInBufferAndReset(); + + chatIndex = game.Chat.Log.Count - chatLines; + ResetIndex(); } else if( key == Key.PageUp ) { chatIndex -= chatLines; - int minIndex = Math.Min( 0, game.Chat.Log.Count - chatLines ); - if( chatIndex < minIndex ) - chatIndex = minIndex; - ResetChat(); + ResetIndex(); } else if( key == Key.PageDown ) { chatIndex += chatLines; - if( chatIndex > game.Chat.Log.Count - chatLines ) - chatIndex = game.Chat.Log.Count - chatLines; - ResetChat(); + ResetIndex(); } else if( key == game.Mapping( KeyBinding.HideGui ) ) { game.HideGui = !game.HideGui; } else { @@ -274,14 +272,18 @@ namespace ClassicalSharp { return true; } - public override bool HandlesMouseScroll( int delta ) { - if( !HandlesAllInput ) return false; - chatIndex += -delta; - int maxIndex = game.Chat.Log.Count - chatLines; - int minIndex = Math.Min( 0, maxIndex ); - Utils.Clamp( ref chatIndex, minIndex, maxIndex ); - ResetChat(); - return true; + public override bool HandlesMouseScroll( int delta ) { + if( !HandlesAllInput ) return false; + chatIndex -= delta; + ResetIndex(); + return true; + } + + void ResetIndex() { + int maxIndex = game.Chat.Log.Count - chatLines; + int minIndex = Math.Min( 0, maxIndex ); + Utils.Clamp( ref chatIndex, minIndex, maxIndex ); + ResetChat(); } } } \ No newline at end of file diff --git a/ClassicalSharp/2D/Widgets/BlockHotbarWidget.cs b/ClassicalSharp/2D/Widgets/BlockHotbarWidget.cs index 7550e23dc..93538e1ef 100644 --- a/ClassicalSharp/2D/Widgets/BlockHotbarWidget.cs +++ b/ClassicalSharp/2D/Widgets/BlockHotbarWidget.cs @@ -15,7 +15,7 @@ namespace ClassicalSharp { int hotbarCount; Texture selectedBlock, background; - int blockSize; + int blockSize, borderSize; public override bool HandlesKeyDown( Key key ) { if( key >= Key.Number1 && key <= Key.Number9 ) { @@ -29,10 +29,12 @@ namespace ClassicalSharp { static FastColour outlineCol = new FastColour( 169, 143, 192 ); static FastColour selCol = new FastColour( 213, 200, 223 ); public override void Init() { - blockSize = (int)(40 * Utils.GuiScale( game.Width, game.Height )); + blockSize = (int)(38 * Utils.GuiScale( game.Width, game.Height )); + borderSize = (int)(3 * Utils.GuiScale( game.Width, game.Height )); int width = blockSize * hotbarCount; X = game.Width / 2 - width / 2; Y = game.Height - blockSize; + Width = width; Height = blockSize; MakeBackgroundTexture( width ); @@ -47,7 +49,7 @@ namespace ClassicalSharp { for( int i = 0; i < hotbarCount; i++ ) { int x = X + i * blockSize; - IsometricBlockDrawer.Draw( game, (byte)game.Inventory.Hotbar[i], blockSize / 2 - 6, + IsometricBlockDrawer.Draw( game, (byte)game.Inventory.Hotbar[i], blockSize / 2 - borderSize - 2, x + 1 + blockSize / 2, game.Height - blockSize / 2 ); if( i == game.Inventory.HeldBlockIndex ) selectedBlock.X1 = x; @@ -65,8 +67,6 @@ namespace ClassicalSharp { public override void MoveTo( int newX, int newY ) { int diffX = newX - X, diffY = newY - Y; X = newX; Y = newY; - - blockSize = (int)(40 * Utils.GuiScale( game.Width, game.Height )); Dispose(); Init(); } @@ -78,7 +78,8 @@ namespace ClassicalSharp { drawer.SetBitmap( bmp ); drawer.Clear( backCol ); for( int xx = 0; xx < hotbarCount; xx++ ) { - drawer.DrawRectBounds( outlineCol, 3, xx * blockSize, 0, blockSize, blockSize ); + drawer.DrawRectBounds( outlineCol, borderSize, xx * blockSize, + 0, blockSize, blockSize ); } background = drawer.Make2DTexture( bmp, size, X, Y ); } @@ -90,7 +91,7 @@ namespace ClassicalSharp { using( Bitmap bmp = IDrawer2D.CreatePow2Bitmap( size ) ) { using( IDrawer2D drawer = game.Drawer2D ) { drawer.SetBitmap( bmp ); - drawer.DrawRectBounds( selCol, 3, 0, 0, blockSize, blockSize ); + drawer.DrawRectBounds( selCol, borderSize, 0, 0, blockSize, blockSize ); selectedBlock = drawer.Make2DTexture( bmp, size, 0, Y ); } } diff --git a/ClassicalSharp/Blocks/BlockInfo.Culling.cs b/ClassicalSharp/Blocks/BlockInfo.Culling.cs index ef5b4e63c..6b80ea9cf 100644 --- a/ClassicalSharp/Blocks/BlockInfo.Culling.cs +++ b/ClassicalSharp/Blocks/BlockInfo.Culling.cs @@ -28,7 +28,7 @@ namespace ClassicalSharp { bool IsHidden( byte tile, byte block ) { return ((tile == block || (IsOpaque[block] && !IsLiquid[block])) && !IsSprite[tile]) || - (IsLiquid[tile] && block == (byte)Block.Ice); + ((tile == (byte)Block.Water || tile == (byte)Block.StillWater) && block == (byte)Block.Ice); } void SetHidden( byte tile, byte block, int tileSide, bool value ) {