Initial work on hotbar interface
This commit is contained in:
parent
da3e6ec241
commit
3b0271b771
@ -27,12 +27,63 @@ namespace TrueCraft.Client.Modules
|
||||
public void Draw(GameTime gameTime)
|
||||
{
|
||||
SpriteBatch.Begin(samplerState: SamplerState.PointClamp);
|
||||
|
||||
SpriteBatch.Draw(Icons, new Vector2(
|
||||
Game.GraphicsDevice.Viewport.Width / 2 - (8 * Game.ScaleFactor * 2),
|
||||
Game.GraphicsDevice.Viewport.Height / 2 - (8 * Game.ScaleFactor * 2)),
|
||||
new Rectangle(0, 0, 16, 16), CrosshairColor,
|
||||
0, Vector2.Zero, Game.ScaleFactor * 2, SpriteEffects.None, 1);
|
||||
|
||||
DrawHotbar(gameTime);
|
||||
|
||||
SpriteBatch.End();
|
||||
}
|
||||
|
||||
#region "Hotbar"
|
||||
|
||||
/// <summary>
|
||||
/// The dimensions of the hotbar background.
|
||||
/// </summary>
|
||||
private static readonly Rectangle HotbarBackgroundRect =
|
||||
new Rectangle(0, 0, 182, 22);
|
||||
|
||||
/// <summary>
|
||||
/// The dimensions of the hotbar selection.
|
||||
/// </summary>
|
||||
private static readonly Rectangle HotbarSelectionRect =
|
||||
new Rectangle(0, 22, 24, 24);
|
||||
|
||||
/// <summary>
|
||||
/// Draws the inventory hotbar.
|
||||
/// </summary>
|
||||
/// <param name="gameTime"></param>
|
||||
private void DrawHotbar(GameTime gameTime)
|
||||
{
|
||||
// Background
|
||||
SpriteBatch.Draw(GUI, new Vector2(
|
||||
Game.GraphicsDevice.Viewport.Width / 2 - Scale(HotbarBackgroundRect.Width / 2),
|
||||
Game.GraphicsDevice.Viewport.Height - Scale(HotbarBackgroundRect.Height + 5)),
|
||||
HotbarBackgroundRect, Color.White, 0, Vector2.Zero, Game.ScaleFactor * 2, SpriteEffects.None, 1);
|
||||
|
||||
// TODO: Icons
|
||||
|
||||
// Selection
|
||||
SpriteBatch.Draw(GUI, new Vector2(
|
||||
Game.GraphicsDevice.Viewport.Width / 2 - Scale(HotbarBackgroundRect.Width / 2) + Scale(Game.HotbarSelection * 20 - 1),
|
||||
Game.GraphicsDevice.Viewport.Height - Scale(HotbarBackgroundRect.Height + 6)),
|
||||
HotbarSelectionRect, Color.White, 0, Vector2.Zero, Game.ScaleFactor * 2, SpriteEffects.None, 1);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
/// <summary>
|
||||
/// Scales a float depending on the game's scale factor.
|
||||
/// </summary>
|
||||
/// <param name="value"></param>
|
||||
/// <returns></returns>
|
||||
private float Scale(float value)
|
||||
{
|
||||
return value * Game.ScaleFactor * 2;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -78,6 +78,42 @@ namespace TrueCraft.Client.Modules
|
||||
if (Math.Floor(Game.Client.Position.Y) == Game.Client.Position.Y)
|
||||
Game.Client.Velocity += TrueCraft.API.Vector3.Up * 0.3;
|
||||
return true;
|
||||
|
||||
case Keys.NumPad1:
|
||||
Game.HotbarSelection = 0;
|
||||
return true;
|
||||
|
||||
case Keys.NumPad2:
|
||||
Game.HotbarSelection = 1;
|
||||
return true;
|
||||
|
||||
case Keys.NumPad3:
|
||||
Game.HotbarSelection = 2;
|
||||
return true;
|
||||
|
||||
case Keys.NumPad4:
|
||||
Game.HotbarSelection = 3;
|
||||
return true;
|
||||
|
||||
case Keys.NumPad5:
|
||||
Game.HotbarSelection = 4;
|
||||
return true;
|
||||
|
||||
case Keys.NumPad6:
|
||||
Game.HotbarSelection = 5;
|
||||
return true;
|
||||
|
||||
case Keys.NumPad7:
|
||||
Game.HotbarSelection = 6;
|
||||
return true;
|
||||
|
||||
case Keys.NumPad8:
|
||||
Game.HotbarSelection = 7;
|
||||
return true;
|
||||
|
||||
case Keys.NumPad9:
|
||||
Game.HotbarSelection = 8;
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
@ -38,6 +38,7 @@ namespace TrueCraft.Client
|
||||
public DateTime StartDigging { get; set; }
|
||||
public DateTime EndDigging { get; set; }
|
||||
public Coordinates3D TargetBlock { get; set; }
|
||||
public int HotbarSelection { get; set; }
|
||||
|
||||
private List<IGameplayModule> Modules { get; set; }
|
||||
private SpriteBatch SpriteBatch { get; set; }
|
||||
|
Reference in New Issue
Block a user