4 * Copyright 2020 Elias Fleckenstein <eliasfleckenstein@web.de>
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2 of the License, or
9 * (at your option) any later version.
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
24 dragonblocks.InventoryGroup = class
28 this.id = dragonblocks.getToken();
33 let display = dragonblocks.addInventoryMenuDisplay(document.createElement("div"));
34 display.id = "dragonblocks.inventoryGroup[" + this.id + "]";
35 display.style.position = "fixed";
36 display.style.backgroundColor = "#535353";
37 display.style.visibility = "hidden";
44 document.getElementById("dragonblocks.inventoryGroup[" + this.id + "]").style.visibility = "hidden";
45 dragonblocks.outStack.getDisplay().style.visibility = "hidden";
50 this.onNextClose = null;
57 document.getElementById("dragonblocks.inventoryGroup[" + this.id + "]").style.visibility = "inherit";
58 dragonblocks.outStack.getDisplay().style.visibility = "visible";
63 this.opened ? this.close() : this.open();
66 set elements(elements)
68 for (let element of this.elements)
71 this._elements = elements;
73 let container = document.getElementById("dragonblocks.inventoryGroup[" + this.id + "]");
78 for (let element of this.elements) {
79 element.draw(container, 0, height);
80 height += element.calculateHeight();
81 width = Math.max(width, element.calculateWidth());
85 container.style.width = width + "px";
86 container.style.height = height + "px";
88 dblib.center(container);
89 dblib.centerVertical(container);
94 return this._elements;