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,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 ) );
}

View File

@ -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();
}