Chat position should be reset upon closing input, border in block hotbar should scale, slightly reduce size of blocks in block hotbar.

This commit is contained in:
UnknownShadow200 2015-11-10 11:29:38 +11:00
parent bbc0ed8edc
commit 736f17001f
3 changed files with 26 additions and 23 deletions

View File

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

View File

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

View File

@ -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 ) {