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,
23 dragonblocks.InventoryGroup = class{
25 this.id = dragonblocks.getToken();
28 var display = document.createElement("div");
29 display.id = "dragonblocks.inventoryGroup[" + this.id + "]";
30 display.style.position = "fixed";
31 display.style.backgroundColor = "#535353";
32 display.style.visibility = "hidden";
33 dragonblocks.Inventory.insertElement(display);
37 document.getElementById("dragonblocks.inventoryGroup[" + this.id + "]").style.visibility = "hidden";
38 dragonblocks.Inventory.getStackDisplay(dragonblocks.Inventory.out.id).style.visibility = "hidden";
41 this.onNextInventoryClose = null;
45 document.getElementById("dragonblocks.inventoryGroup[" + this.id + "]").style.visibility = "visible";
46 dragonblocks.Inventory.getStackDisplay(dragonblocks.Inventory.out.id).style.visibility = "visible";
49 this.opened ? this.close() : this.open();
51 set elements(elements){
52 for(let element of this.elements)
54 this._elements = elements;
57 let container = document.getElementById("dragonblocks.inventoryGroup[" + this.id + "]");
58 for(let element of this.elements){
59 element.draw(container, 0, height);
60 height += element.calculateHeight();
61 width = Math.max(width, element.calculateWidth());
64 container.style.width = width + "px";
65 container.style.height = height + "px";
66 dblib.center(container);
67 dblib.centerVertical(container);
70 return this._elements;