diff --git a/public/css/building.css b/public/css/building.css index 30725db..d3ae2c1 100644 --- a/public/css/building.css +++ b/public/css/building.css @@ -505,6 +505,13 @@ body { transform: scale(1.1); } +#inv-left:disabled, +#inv-right:disabled { + opacity: 0.25; + cursor: not-allowed; + transform: none; +} + #inventory-nav { display: flex; align-items: center; diff --git a/public/js/buildings/wohnhaus.js b/public/js/buildings/wohnhaus.js index 12df154..d278b04 100644 --- a/public/js/buildings/wohnhaus.js +++ b/public/js/buildings/wohnhaus.js @@ -63,9 +63,16 @@ export async function loadWohnhaus() { `; + // Variablen zurücksetzen beim Öffnen + inventoryPage = 0; + totalInventoryPages = 1; + inventoryItems = []; + + // Buttons zuerst initialisieren + initInventoryButtons(); + await loadInventory(); await loadEquipment(); - initInventoryButtons(); initDrag(); initSlotDrag(); initDrop(); @@ -143,6 +150,13 @@ function renderInventory() { document.getElementById("inventory-page").innerText = "Seite " + (inventoryPage + 1) + " / " + totalInventoryPages; + // Buttons aktivieren/deaktivieren + const btnLeft = document.getElementById("inv-left"); + const btnRight = document.getElementById("inv-right"); + + if (btnLeft) btnLeft.disabled = inventoryPage === 0; + if (btnRight) btnRight.disabled = inventoryPage >= totalInventoryPages - 1; + initDrag(); }