fix(studio): инвентарь — собранное идёт сначала в hotbar (виден), hotbar поднят над подсказкой
1) add() заполняет сначала hotbar, потом grid → собранные предметы сразу видны в постоянном хотбаре (раньше уходили в скрытую сетку — хотбар казался пустым). 2) Хотбар поднят bottom 14→64px, не перекрывает подсказку внизу экрана. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
parent
42f1334908
commit
661ff60bdf
@ -64,7 +64,7 @@ export class InventoryUI {
|
|||||||
add(itemId, count = 1) {
|
add(itemId, count = 1) {
|
||||||
const def = this._def(itemId);
|
const def = this._def(itemId);
|
||||||
let left = count;
|
let left = count;
|
||||||
// 1) долить в существующие стаки (grid, потом hotbar)
|
// 1) долить в существующие стаки (сначала hotbar — он на виду, потом grid)
|
||||||
const fill = (arr) => {
|
const fill = (arr) => {
|
||||||
for (let i = 0; i < arr.length && left > 0; i++) {
|
for (let i = 0; i < arr.length && left > 0; i++) {
|
||||||
const s = arr[i];
|
const s = arr[i];
|
||||||
@ -75,14 +75,14 @@ export class InventoryUI {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
fill(this.grid); fill(this.hotbar);
|
fill(this.hotbar); fill(this.grid);
|
||||||
// 2) в пустые слоты (grid, потом hotbar)
|
// 2) в пустые слоты (сначала hotbar — собранное видно сразу, потом grid)
|
||||||
const place = (arr) => {
|
const place = (arr) => {
|
||||||
for (let i = 0; i < arr.length && left > 0; i++) {
|
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; }
|
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;
|
const added = count - left;
|
||||||
if (added > 0) { this._emit('added', { itemId, count: added }); this._changed(); }
|
if (added > 0) { this._emit('added', { itemId, count: added }); this._changed(); }
|
||||||
return { added, overflow: left };
|
return { added, overflow: left };
|
||||||
@ -194,7 +194,7 @@ export class InventoryUI {
|
|||||||
mountHotbar() {
|
mountHotbar() {
|
||||||
if (this.hotbarRoot) return;
|
if (this.hotbarRoot) return;
|
||||||
const r = document.createElement('div');
|
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._parent().appendChild(r); this.hotbarRoot = r;
|
||||||
this._renderHotbar();
|
this._renderHotbar();
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user