diff --git a/src/editor/engine/InventoryUI.js b/src/editor/engine/InventoryUI.js index 0a49359..86620cf 100644 --- a/src/editor/engine/InventoryUI.js +++ b/src/editor/engine/InventoryUI.js @@ -64,7 +64,7 @@ export class InventoryUI { add(itemId, count = 1) { const def = this._def(itemId); let left = count; - // 1) долить в существующие стаки (grid, потом hotbar) + // 1) долить в существующие стаки (сначала hotbar — он на виду, потом grid) const fill = (arr) => { for (let i = 0; i < arr.length && left > 0; i++) { const s = arr[i]; @@ -75,14 +75,14 @@ export class InventoryUI { } } }; - fill(this.grid); fill(this.hotbar); - // 2) в пустые слоты (grid, потом hotbar) + fill(this.hotbar); fill(this.grid); + // 2) в пустые слоты (сначала hotbar — собранное видно сразу, потом grid) const place = (arr) => { for (let i = 0; i < arr.length && left > 0; i++) { if (!arr[i]) { const take = Math.min(def.maxStack, left); arr[i] = { itemId, count: take }; left -= take; } } }; - place(this.grid); place(this.hotbar); + place(this.hotbar); place(this.grid); const added = count - left; if (added > 0) { this._emit('added', { itemId, count: added }); this._changed(); } return { added, overflow: left }; @@ -194,7 +194,7 @@ export class InventoryUI { mountHotbar() { if (this.hotbarRoot) return; const r = document.createElement('div'); - r.style.cssText = 'position:absolute;left:50%;bottom:14px;transform:translateX(-50%);z-index:48;display:flex;gap:6px;pointer-events:auto;font-family:Inter,system-ui,sans-serif'; + r.style.cssText = 'position:absolute;left:50%;bottom:64px;transform:translateX(-50%);z-index:48;display:flex;gap:6px;pointer-events:auto;font-family:Inter,system-ui,sans-serif'; this._parent().appendChild(r); this.hotbarRoot = r; this._renderHotbar(); }