From 617e8725e835f8e7fbe9ce00b4e461dd3a938972 Mon Sep 17 00:00:00 2001 From: UnknownShadow200 Date: Wed, 4 Feb 2015 19:47:25 +1100 Subject: [PATCH] Reduce BlockSelectScreen slightly, fix snow height. --- 2D/Screens/BlockSelectScreen.cs | 50 +++++++++++++-------------------- Blocks/BlockInfo.cs | 6 ++-- 2 files changed, 22 insertions(+), 34 deletions(-) diff --git a/2D/Screens/BlockSelectScreen.cs b/2D/Screens/BlockSelectScreen.cs index 5588766f4..bbc315159 100644 --- a/2D/Screens/BlockSelectScreen.cs +++ b/2D/Screens/BlockSelectScreen.cs @@ -1,8 +1,7 @@ -using System; -using System.Collections.Generic; -using System.Drawing; -using System.Text; -using OpenTK.Input; +using System; +using System.Collections.Generic; +using System.Drawing; +using OpenTK.Input; namespace ClassicalSharp { @@ -19,14 +18,6 @@ namespace ClassicalSharp { Texture = texture; BlockId = block; } - - public int X1 { - get { return Texture.X1; } - } - - public int Y1 { - get { return Texture.Y1; } - } } BlockDrawInfo[] blocksTable; Texture selectedBlock, blockInfoTexture; @@ -45,10 +36,10 @@ namespace ClassicalSharp { texture.RenderNoBind( GraphicsApi ); } if( selectedIndex != -1 ) { - int rowIndex = selectedIndex % blocksPerRow; - int colIndex = selectedIndex / blocksPerRow; - selectedBlock.X1 = startX + blockSize * rowIndex; - selectedBlock.Y1 = startY + blockSize * colIndex; + int col = selectedIndex % blocksPerRow; + int row = selectedIndex / blocksPerRow; + selectedBlock.X1 = startX + blockSize * col; + selectedBlock.Y1 = startY + blockSize * row; selectedBlock.Render( GraphicsApi ); } if( blockInfoTexture.IsValid ) { @@ -101,7 +92,7 @@ namespace ClassicalSharp { RecreateBlockInfoTexture(); } - Color backColour = Color.FromArgb( 120, 60, 60, 60 ); + static readonly Color backColour = Color.FromArgb( 120, 60, 60, 60 ); string GetBlockInfo( Block block ) { return String.Format( @@ -178,12 +169,11 @@ namespace ClassicalSharp { public override bool HandlesMouseMove( int mouseX, int mouseY ) { selectedIndex = -1; if( Utils2D.Contains( startX, startY, blocksPerRow * blockSize, rows * blockSize, mouseX, mouseY ) ) { - // clicking on the table. now find the intersecting cell. for( int i = 0; i < blocksTable.Length; i++ ) { - int rowIndex = i % blocksPerRow; - int colIndex = i / blocksPerRow; - int x = startX + blockSize * rowIndex; - int y = startY + blockSize * colIndex; + int col = i % blocksPerRow; + int row = i / blocksPerRow; + int x = startX + blockSize * col; + int y = startY + blockSize * row; if( Utils2D.Contains( x, y, blockSize, blockSize, mouseX, mouseY ) ) { selectedIndex = i; @@ -196,14 +186,12 @@ namespace ClassicalSharp { } public override bool HandlesMouseClick( int mouseX, int mouseY, MouseButton button ) { - if( button == MouseButton.Left ) { - if( selectedIndex != -1 ) { - BlockDrawInfo info = blocksTable[selectedIndex]; - try { - Window.HeldBlock = info.BlockId; - } catch( InvalidOperationException ) { - Window.AddChat( "&e/client: &cThe server has forbidden you from changing your held block." ); - } + if( button == MouseButton.Left && selectedIndex != -1 ) { + BlockDrawInfo info = blocksTable[selectedIndex]; + try { + Window.HeldBlock = info.BlockId; + } catch( InvalidOperationException ) { + Window.AddChat( "&e/client: &cThe server has forbidden you from changing your held block." ); } Window.SetNewScreen( new NormalScreen( Window ) ); } diff --git a/Blocks/BlockInfo.cs b/Blocks/BlockInfo.cs index 02204d52a..1d1191c41 100644 --- a/Blocks/BlockInfo.cs +++ b/Blocks/BlockInfo.cs @@ -27,7 +27,7 @@ namespace ClassicalSharp { Block.Dandelion, Block.Slab ); SetIsSprite( Block.Rose, Block.Sapling, Block.Dandelion, Block.BrownMushroom, Block.RedMushroom ); - SetBlockHeight( 0.5f, Block.Slab ); + SetBlockHeight( 8 / 16f, Block.Slab ); SetBlocksLight( false, Block.Glass, Block.Leaves, Block.Sapling, Block.RedMushroom, Block.BrownMushroom, Block.Rose, Block.Dandelion ); @@ -37,8 +37,8 @@ namespace ClassicalSharp { SetBlocksLight( false, Block.Fire, Block.Rope ); SetIsTranslucent( Block.Ice ); SetIsSprite( Block.Rope, Block.Fire ); - SetBlockHeight( 0.5f, Block.CobblestoneSlab ); - SetBlockHeight( 0.2f, Block.Snow ); + SetBlockHeight( 8 / 16f, Block.CobblestoneSlab ); + SetBlockHeight( 2 / 16f, Block.Snow ); SetupCullingCache(); }