diff --git a/Mine2d/game/frontend/renderer/HudRenderer.cs b/Mine2d/game/frontend/renderer/HudRenderer.cs index 4d3a3ea..b4ccd02 100644 --- a/Mine2d/game/frontend/renderer/HudRenderer.cs +++ b/Mine2d/game/frontend/renderer/HudRenderer.cs @@ -53,9 +53,9 @@ public class HudRenderer : IRenderer } var texture = stack.GetTexture(); - renderer.DrawTexture(texture, (4 + i * 20) * uiScale, 4 * uiScale, 16 * uiScale, 16 * uiScale); - renderer.DrawText("" + stack.Count, (4 + i * 20) * uiScale, 14 * uiScale); - if (cursorPosition.X >= (4 + i * 20) * uiScale && cursorPosition.X <= (4 + i * 20 + 16) * uiScale && cursorPosition.Y >= 4 * uiScale && cursorPosition.Y <= (4 + 16) * uiScale) + renderer.DrawTexture(texture, (4 + (i * 24)) * uiScale, 4 * uiScale, 16 * uiScale, 16 * uiScale); + renderer.DrawText("" + stack.Count, (4 + (i * 24)) * uiScale, 14 * uiScale); + if (cursorPosition.X >= (4 + (i * 24)) * uiScale && cursorPosition.X <= (4 + (i * 24) + 16) * uiScale && cursorPosition.Y >= 4 * uiScale && cursorPosition.Y <= (4 + 16) * uiScale) { Context.Get().FrontendGameState.Tooltip = stack.GetName(); } diff --git a/Mine2d/game/frontend/renderer/InventoryRenderer.cs b/Mine2d/game/frontend/renderer/InventoryRenderer.cs index f16fd7a..925462e 100644 --- a/Mine2d/game/frontend/renderer/InventoryRenderer.cs +++ b/Mine2d/game/frontend/renderer/InventoryRenderer.cs @@ -1,19 +1,40 @@ using Mine2d.engine; +using Mine2d.game.core; using Mine2d.game.state; namespace Mine2d.game.frontend.renderer { public class InventoryRenderer : IRenderer { - public void Render() { + public void Render() + { var ctx = Context.Get(); var inventory = ctx.FrontendGameState.OpenInventory; - if(inventory == InventoryKind.None) return; + if (inventory == InventoryKind.None) return; ctx.Renderer.SetColor(0, 0, 0, 200); ctx.Renderer.SetDrawBlendMode(SDL_BlendMode.SDL_BLENDMODE_BLEND); ctx.Renderer.DrawRect(0, 0, ctx.FrontendGameState.WindowWidth, ctx.FrontendGameState.WindowHeight); var inventoryRenderer = ctx.InventoryRegistry.GetInventory(inventory); inventoryRenderer.Render(); + var player = PlayerEntity.GetSelf(); + if (player.Inventory.cursor != null) + { + var cursorPosition = ctx.FrontendGameState.CursorPosition; + var itemTexture = player.Inventory.cursor.GetTexture(); + var uiScale = ctx.FrontendGameState.Settings.UiScale; + ctx.Renderer.DrawTexture( + itemTexture, + (int)(cursorPosition.X + 2), + (int)(cursorPosition.Y + 2), + 16 * uiScale, + 16 * uiScale + ); + ctx.Renderer.DrawText( + "" + player.Inventory.cursor.Count, + (int)(cursorPosition.X + 2), + (int)(cursorPosition.Y + (12 * uiScale)) + ); + } } } } \ No newline at end of file