diff options
author | elioat <elioat@tilde.institute> | 2024-12-28 10:06:59 -0500 |
---|---|---|
committer | elioat <elioat@tilde.institute> | 2024-12-28 10:06:59 -0500 |
commit | 4979fbe8595ae0a0e8bd436d4633fa5e4755707f (patch) | |
tree | 935133b334e913820dc928b22272e2eea088f880 /html/rogue | |
parent | 17f514449e90f321b967ef770d16032577749e36 (diff) | |
download | tour-4979fbe8595ae0a0e8bd436d4633fa5e4755707f.tar.gz |
*
Diffstat (limited to 'html/rogue')
-rw-r--r-- | html/rogue/js/inventory-ui.js | 31 |
1 files changed, 20 insertions, 11 deletions
diff --git a/html/rogue/js/inventory-ui.js b/html/rogue/js/inventory-ui.js index 0970e71..c7ce63c 100644 --- a/html/rogue/js/inventory-ui.js +++ b/html/rogue/js/inventory-ui.js @@ -24,30 +24,39 @@ const InventoryUI = { ctx.fillStyle = Config.colors.UI.INVENTORY.BACKGROUND; ctx.fillRect(0, 0, state.canvas.width, state.canvas.height); - // Draw inventory window - const padding = 20; - const width = 300; - const height = 400; - const x = (state.canvas.width - width) / 2; - const y = (state.canvas.height - height) / 2; + // Calculate positions ensuring integer values + const padding = Config.ui.inventory.PADDING; + const width = Config.ui.inventory.WIDTH; + const height = Config.ui.inventory.HEIGHT; + const x = Math.round((state.canvas.width - width) / 2); + const y = Math.round((state.canvas.height - height) / 2); // Draw window background ctx.fillStyle = Config.colors.UI.INVENTORY.WINDOW; ctx.fillRect(x, y, width, height); + // Set text rendering properties for sharper text + ctx.textBaseline = 'top'; + ctx.textAlign = 'left'; + ctx.imageSmoothingEnabled = false; + // Draw title ctx.fillStyle = Config.colors.UI.INVENTORY.TEXT; - ctx.font = '20px Arial'; - ctx.fillText('Inventory', x + padding, y + padding + 20); + ctx.font = Config.ui.inventory.TITLE_FONT; + const titleX = Math.round(x + padding); + const titleY = Math.round(y + padding); + ctx.fillText('Inventory', titleX, titleY); // Get item counts and draw items with quantities const itemCounts = this.getItemCounts(); let index = 0; itemCounts.forEach((count, itemName) => { - const itemY = y + padding + 60 + (index * 30); - ctx.font = '16px Arial'; - ctx.fillText(`${itemName} x${count}`, x + padding, itemY); + const itemX = Math.round(x + padding); + const itemY = Math.round(y + Config.ui.inventory.ITEMS_START_OFFSET + + (index * Config.ui.inventory.ITEM_SPACING)); + ctx.font = Config.ui.inventory.ITEM_FONT; + ctx.fillText(`${itemName} x${count}`, itemX, itemY); index++; }); } |