From 867e204825ca0d63c0954ec4fe29cd3e1e74e5bf Mon Sep 17 00:00:00 2001 From: UnknownShadow200 Date: Tue, 5 Apr 2016 18:35:40 +1000 Subject: [PATCH] Inventory menu should use classic background colour when in classic mode, also bedrock should not be shown when in classic mode but hax is disabled. (Thanks FrostFox) --- .../2D/Screens/Inventory/InventoryScreen.cs | 8 ++++++-- Launcher2/Gui/Drawer2DExt.cs | 17 ++++++----------- Launcher2/LauncherWindow.Background.cs | 10 +++------- 3 files changed, 15 insertions(+), 20 deletions(-) diff --git a/ClassicalSharp/2D/Screens/Inventory/InventoryScreen.cs b/ClassicalSharp/2D/Screens/Inventory/InventoryScreen.cs index d21ab08d9..35d77f072 100644 --- a/ClassicalSharp/2D/Screens/Inventory/InventoryScreen.cs +++ b/ClassicalSharp/2D/Screens/Inventory/InventoryScreen.cs @@ -26,8 +26,10 @@ namespace ClassicalSharp.Gui { int TableWidth { get { return blocksPerRow * blockSize + 10 + 10; } } int TableHeight { get { return Math.Min( rows, maxRows ) * blockSize + 10 + 30; } } - static FastColour backCol = new FastColour( 30, 30, 30, 200 ); + static FastColour normBackCol = new FastColour( 30, 30, 30, 200 ); + static FastColour classicBackCol = new FastColour( 48, 48, 96, 192 ); public override void Render( double delta ) { + FastColour backCol = game.ClassicMode ? classicBackCol : normBackCol; api.Draw2DQuad( TableX, TableY, TableWidth, TableHeight, backCol ); if( rows > maxRows ) DrawScrollbar(); @@ -220,7 +222,9 @@ namespace ClassicalSharp.Gui { } bool ShowTile( int tile ) { - if( game.ClassicMode && (tile >= (byte)Block.Water && tile <= (byte)Block.StillLava) ) + bool hackBlocks = !game.ClassicMode || game.ClassicHacks; + if( !hackBlocks && (tile == (byte)Block.Bedrock || + tile >= (byte)Block.Water && tile <= (byte)Block.StillLava) ) return false; return tile < BlockInfo.CpeBlocksCount || game.BlockInfo.Name[tile] != "Invalid"; } diff --git a/Launcher2/Gui/Drawer2DExt.cs b/Launcher2/Gui/Drawer2DExt.cs index b74ffdcc9..76f017d87 100644 --- a/Launcher2/Gui/Drawer2DExt.cs +++ b/Launcher2/Gui/Drawer2DExt.cs @@ -36,13 +36,14 @@ namespace Launcher { public unsafe static void DrawTiledPixels( FastBitmap src, FastBitmap dst, Rectangle srcRect, Rectangle dstRect ) { - int srcWidth = srcRect.Width, dstWidth = dstRect.Width; - int srcHeight = srcRect.Height, dstHeight = dstRect.Height; - int srcX = srcRect.X, dstX = dstRect.X; - int srcY = srcRect.Y, dstY = dstRect.Y; + int srcX = srcRect.X, srcWidth = srcRect.Width, srcHeight = srcRect.Height; + int dstX, dstY, dstWidth, dstHeight; + if( !CheckCoords( dst, dstRect, out dstX, out dstY, out dstWidth, out dstHeight ) ) + return; for( int yy = 0; yy < dstHeight; yy++ ) { - int* srcRow = src.GetRowPtr( srcY + ((yy + dstY) % srcHeight) ); + // srcY is always 0 so we don't need to add + int* srcRow = src.GetRowPtr( ((yy + dstY) % srcHeight) ); int* dstRow = dst.GetRowPtr( dstY + yy ); for( int xx = 0; xx < dstWidth; xx++ ) @@ -100,11 +101,5 @@ namespace Launcher { if( dstWidth < 0 || dstHeight < 0 ) return false; return true; } - - static float Noise( int x, int y ) { - int n = x + y * 57; - n = (n << 13) ^ n; - return 1f - ((n * (n * n * 15731 + 789221) + 1376312589) & 0x7fffffff) / 1073741824f; - } } } \ No newline at end of file diff --git a/Launcher2/LauncherWindow.Background.cs b/Launcher2/LauncherWindow.Background.cs index 690029945..f8e0d4b56 100644 --- a/Launcher2/LauncherWindow.Background.cs +++ b/Launcher2/LauncherWindow.Background.cs @@ -120,13 +120,9 @@ namespace Launcher { } void ClearTile( int x, int y, int width, int height, int srcX, FastBitmap dst ) { - if( x >= Width || y >= Height ) return; - Rectangle srcRect = new Rectangle( srcX, 0, tileSize, tileSize ); - Size size = new Size( tileSize, tileSize ); - Rectangle area = new Rectangle( x, y, width, height ); - area.Width = Math.Min( area.X + area.Width, dst.Width ) - area.X; - area.Height = Math.Min( area.Y + area.Height, dst.Height ) - area.Y; - Drawer2DExt.DrawTiledPixels( terrainPixels, dst, srcRect, area ); + Rectangle srcRect = new Rectangle( srcX, 0, tileSize, tileSize ); + Drawer2DExt.DrawTiledPixels( terrainPixels, dst, srcRect, + new Rectangle( x, y, width, height ) ); } } }