mirror of
https://github.com/ClassiCube/ClassiCube.git
synced 2025-09-17 11:35:08 -04:00
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:
parent
bbc0ed8edc
commit
736f17001f
@ -245,17 +245,15 @@ namespace ClassicalSharp {
|
|||||||
if( key == game.Mapping( KeyBinding.PauseOrExit ) )
|
if( key == game.Mapping( KeyBinding.PauseOrExit ) )
|
||||||
textInput.Clear();
|
textInput.Clear();
|
||||||
textInput.SendTextInBufferAndReset();
|
textInput.SendTextInBufferAndReset();
|
||||||
|
|
||||||
|
chatIndex = game.Chat.Log.Count - chatLines;
|
||||||
|
ResetIndex();
|
||||||
} else if( key == Key.PageUp ) {
|
} else if( key == Key.PageUp ) {
|
||||||
chatIndex -= chatLines;
|
chatIndex -= chatLines;
|
||||||
int minIndex = Math.Min( 0, game.Chat.Log.Count - chatLines );
|
ResetIndex();
|
||||||
if( chatIndex < minIndex )
|
|
||||||
chatIndex = minIndex;
|
|
||||||
ResetChat();
|
|
||||||
} else if( key == Key.PageDown ) {
|
} else if( key == Key.PageDown ) {
|
||||||
chatIndex += chatLines;
|
chatIndex += chatLines;
|
||||||
if( chatIndex > game.Chat.Log.Count - chatLines )
|
ResetIndex();
|
||||||
chatIndex = game.Chat.Log.Count - chatLines;
|
|
||||||
ResetChat();
|
|
||||||
} else if( key == game.Mapping( KeyBinding.HideGui ) ) {
|
} else if( key == game.Mapping( KeyBinding.HideGui ) ) {
|
||||||
game.HideGui = !game.HideGui;
|
game.HideGui = !game.HideGui;
|
||||||
} else {
|
} else {
|
||||||
@ -276,12 +274,16 @@ namespace ClassicalSharp {
|
|||||||
|
|
||||||
public override bool HandlesMouseScroll( int delta ) {
|
public override bool HandlesMouseScroll( int delta ) {
|
||||||
if( !HandlesAllInput ) return false;
|
if( !HandlesAllInput ) return false;
|
||||||
chatIndex += -delta;
|
chatIndex -= delta;
|
||||||
|
ResetIndex();
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
void ResetIndex() {
|
||||||
int maxIndex = game.Chat.Log.Count - chatLines;
|
int maxIndex = game.Chat.Log.Count - chatLines;
|
||||||
int minIndex = Math.Min( 0, maxIndex );
|
int minIndex = Math.Min( 0, maxIndex );
|
||||||
Utils.Clamp( ref chatIndex, minIndex, maxIndex );
|
Utils.Clamp( ref chatIndex, minIndex, maxIndex );
|
||||||
ResetChat();
|
ResetChat();
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -15,7 +15,7 @@ namespace ClassicalSharp {
|
|||||||
|
|
||||||
int hotbarCount;
|
int hotbarCount;
|
||||||
Texture selectedBlock, background;
|
Texture selectedBlock, background;
|
||||||
int blockSize;
|
int blockSize, borderSize;
|
||||||
|
|
||||||
public override bool HandlesKeyDown( Key key ) {
|
public override bool HandlesKeyDown( Key key ) {
|
||||||
if( key >= Key.Number1 && key <= Key.Number9 ) {
|
if( key >= Key.Number1 && key <= Key.Number9 ) {
|
||||||
@ -29,10 +29,12 @@ namespace ClassicalSharp {
|
|||||||
static FastColour outlineCol = new FastColour( 169, 143, 192 );
|
static FastColour outlineCol = new FastColour( 169, 143, 192 );
|
||||||
static FastColour selCol = new FastColour( 213, 200, 223 );
|
static FastColour selCol = new FastColour( 213, 200, 223 );
|
||||||
public override void Init() {
|
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;
|
int width = blockSize * hotbarCount;
|
||||||
X = game.Width / 2 - width / 2;
|
X = game.Width / 2 - width / 2;
|
||||||
Y = game.Height - blockSize;
|
Y = game.Height - blockSize;
|
||||||
|
|
||||||
Width = width;
|
Width = width;
|
||||||
Height = blockSize;
|
Height = blockSize;
|
||||||
MakeBackgroundTexture( width );
|
MakeBackgroundTexture( width );
|
||||||
@ -47,7 +49,7 @@ namespace ClassicalSharp {
|
|||||||
|
|
||||||
for( int i = 0; i < hotbarCount; i++ ) {
|
for( int i = 0; i < hotbarCount; i++ ) {
|
||||||
int x = X + i * blockSize;
|
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 );
|
x + 1 + blockSize / 2, game.Height - blockSize / 2 );
|
||||||
if( i == game.Inventory.HeldBlockIndex )
|
if( i == game.Inventory.HeldBlockIndex )
|
||||||
selectedBlock.X1 = x;
|
selectedBlock.X1 = x;
|
||||||
@ -65,8 +67,6 @@ namespace ClassicalSharp {
|
|||||||
public override void MoveTo( int newX, int newY ) {
|
public override void MoveTo( int newX, int newY ) {
|
||||||
int diffX = newX - X, diffY = newY - Y;
|
int diffX = newX - X, diffY = newY - Y;
|
||||||
X = newX; Y = newY;
|
X = newX; Y = newY;
|
||||||
|
|
||||||
blockSize = (int)(40 * Utils.GuiScale( game.Width, game.Height ));
|
|
||||||
Dispose();
|
Dispose();
|
||||||
Init();
|
Init();
|
||||||
}
|
}
|
||||||
@ -78,7 +78,8 @@ namespace ClassicalSharp {
|
|||||||
drawer.SetBitmap( bmp );
|
drawer.SetBitmap( bmp );
|
||||||
drawer.Clear( backCol );
|
drawer.Clear( backCol );
|
||||||
for( int xx = 0; xx < hotbarCount; xx++ ) {
|
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 );
|
background = drawer.Make2DTexture( bmp, size, X, Y );
|
||||||
}
|
}
|
||||||
@ -90,7 +91,7 @@ namespace ClassicalSharp {
|
|||||||
using( Bitmap bmp = IDrawer2D.CreatePow2Bitmap( size ) ) {
|
using( Bitmap bmp = IDrawer2D.CreatePow2Bitmap( size ) ) {
|
||||||
using( IDrawer2D drawer = game.Drawer2D ) {
|
using( IDrawer2D drawer = game.Drawer2D ) {
|
||||||
drawer.SetBitmap( bmp );
|
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 );
|
selectedBlock = drawer.Make2DTexture( bmp, size, 0, Y );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -28,7 +28,7 @@ namespace ClassicalSharp {
|
|||||||
bool IsHidden( byte tile, byte block ) {
|
bool IsHidden( byte tile, byte block ) {
|
||||||
return
|
return
|
||||||
((tile == block || (IsOpaque[block] && !IsLiquid[block])) && !IsSprite[tile]) ||
|
((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 ) {
|
void SetHidden( byte tile, byte block, int tileSide, bool value ) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user