Reduce BlockSelectScreen slightly, fix snow height.

This commit is contained in:
UnknownShadow200 2015-02-04 19:47:25 +11:00
parent f278af2aed
commit 617e8725e8
2 changed files with 22 additions and 34 deletions

View File

@ -1,7 +1,6 @@
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Drawing; using System.Drawing;
using System.Text;
using OpenTK.Input; using OpenTK.Input;
namespace ClassicalSharp { namespace ClassicalSharp {
@ -19,14 +18,6 @@ namespace ClassicalSharp {
Texture = texture; Texture = texture;
BlockId = block; BlockId = block;
} }
public int X1 {
get { return Texture.X1; }
}
public int Y1 {
get { return Texture.Y1; }
}
} }
BlockDrawInfo[] blocksTable; BlockDrawInfo[] blocksTable;
Texture selectedBlock, blockInfoTexture; Texture selectedBlock, blockInfoTexture;
@ -45,10 +36,10 @@ namespace ClassicalSharp {
texture.RenderNoBind( GraphicsApi ); texture.RenderNoBind( GraphicsApi );
} }
if( selectedIndex != -1 ) { if( selectedIndex != -1 ) {
int rowIndex = selectedIndex % blocksPerRow; int col = selectedIndex % blocksPerRow;
int colIndex = selectedIndex / blocksPerRow; int row = selectedIndex / blocksPerRow;
selectedBlock.X1 = startX + blockSize * rowIndex; selectedBlock.X1 = startX + blockSize * col;
selectedBlock.Y1 = startY + blockSize * colIndex; selectedBlock.Y1 = startY + blockSize * row;
selectedBlock.Render( GraphicsApi ); selectedBlock.Render( GraphicsApi );
} }
if( blockInfoTexture.IsValid ) { if( blockInfoTexture.IsValid ) {
@ -101,7 +92,7 @@ namespace ClassicalSharp {
RecreateBlockInfoTexture(); RecreateBlockInfoTexture();
} }
Color backColour = Color.FromArgb( 120, 60, 60, 60 ); static readonly Color backColour = Color.FromArgb( 120, 60, 60, 60 );
string GetBlockInfo( Block block ) { string GetBlockInfo( Block block ) {
return String.Format( return String.Format(
@ -178,12 +169,11 @@ namespace ClassicalSharp {
public override bool HandlesMouseMove( int mouseX, int mouseY ) { public override bool HandlesMouseMove( int mouseX, int mouseY ) {
selectedIndex = -1; selectedIndex = -1;
if( Utils2D.Contains( startX, startY, blocksPerRow * blockSize, rows * blockSize, mouseX, mouseY ) ) { 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++ ) { for( int i = 0; i < blocksTable.Length; i++ ) {
int rowIndex = i % blocksPerRow; int col = i % blocksPerRow;
int colIndex = i / blocksPerRow; int row = i / blocksPerRow;
int x = startX + blockSize * rowIndex; int x = startX + blockSize * col;
int y = startY + blockSize * colIndex; int y = startY + blockSize * row;
if( Utils2D.Contains( x, y, blockSize, blockSize, mouseX, mouseY ) ) { if( Utils2D.Contains( x, y, blockSize, blockSize, mouseX, mouseY ) ) {
selectedIndex = i; selectedIndex = i;
@ -196,15 +186,13 @@ namespace ClassicalSharp {
} }
public override bool HandlesMouseClick( int mouseX, int mouseY, MouseButton button ) { public override bool HandlesMouseClick( int mouseX, int mouseY, MouseButton button ) {
if( button == MouseButton.Left ) { if( button == MouseButton.Left && selectedIndex != -1 ) {
if( selectedIndex != -1 ) {
BlockDrawInfo info = blocksTable[selectedIndex]; BlockDrawInfo info = blocksTable[selectedIndex];
try { try {
Window.HeldBlock = info.BlockId; Window.HeldBlock = info.BlockId;
} catch( InvalidOperationException ) { } catch( InvalidOperationException ) {
Window.AddChat( "&e/client: &cThe server has forbidden you from changing your held block." ); Window.AddChat( "&e/client: &cThe server has forbidden you from changing your held block." );
} }
}
Window.SetNewScreen( new NormalScreen( Window ) ); Window.SetNewScreen( new NormalScreen( Window ) );
} }
return true; return true;

View File

@ -27,7 +27,7 @@ namespace ClassicalSharp {
Block.Dandelion, Block.Slab ); Block.Dandelion, Block.Slab );
SetIsSprite( Block.Rose, Block.Sapling, Block.Dandelion, SetIsSprite( Block.Rose, Block.Sapling, Block.Dandelion,
Block.BrownMushroom, Block.RedMushroom ); Block.BrownMushroom, Block.RedMushroom );
SetBlockHeight( 0.5f, Block.Slab ); SetBlockHeight( 8 / 16f, Block.Slab );
SetBlocksLight( false, Block.Glass, Block.Leaves, Block.Sapling, SetBlocksLight( false, Block.Glass, Block.Leaves, Block.Sapling,
Block.RedMushroom, Block.BrownMushroom, Block.Rose, Block.RedMushroom, Block.BrownMushroom, Block.Rose,
Block.Dandelion ); Block.Dandelion );
@ -37,8 +37,8 @@ namespace ClassicalSharp {
SetBlocksLight( false, Block.Fire, Block.Rope ); SetBlocksLight( false, Block.Fire, Block.Rope );
SetIsTranslucent( Block.Ice ); SetIsTranslucent( Block.Ice );
SetIsSprite( Block.Rope, Block.Fire ); SetIsSprite( Block.Rope, Block.Fire );
SetBlockHeight( 0.5f, Block.CobblestoneSlab ); SetBlockHeight( 8 / 16f, Block.CobblestoneSlab );
SetBlockHeight( 0.2f, Block.Snow ); SetBlockHeight( 2 / 16f, Block.Snow );
SetupCullingCache(); SetupCullingCache();
} }