diff --git a/src/frontend/InventoryView.cpp b/src/frontend/InventoryView.cpp index dab7325f..c4a07835 100644 --- a/src/frontend/InventoryView.cpp +++ b/src/frontend/InventoryView.cpp @@ -438,6 +438,7 @@ static void readSlotsGrid(InventoryView* view, gui::UiXmlReader& reader, xml::xm void InventoryView::createReaders(gui::UiXmlReader& reader) { reader.add("inventory", [=](gui::UiXmlReader& reader, xml::xmlelement element) { auto view = std::make_shared(); + view->setColor(glm::vec4(0.122f, 0.122f, 0.122f, 0.878f)); // todo: fixme reader.addIgnore("slots-grid"); reader.readUINode(reader, element, *view); diff --git a/src/frontend/hud.cpp b/src/frontend/hud.cpp index 49898ecc..4696dee5 100644 --- a/src/frontend/hud.cpp +++ b/src/frontend/hud.cpp @@ -420,6 +420,9 @@ void Hud::openInventory() { * In case of nullptr a new virtual inventory will be created */ void Hud::openInventory(glm::ivec3 block, UiDocument* doc, std::shared_ptr blockinv) { + if (isInventoryOpen()) { + closeInventory(); + } auto level = frontend->getLevel(); blockUI = std::dynamic_pointer_cast(doc->getRoot()); if (blockUI == nullptr) { @@ -570,10 +573,24 @@ void Hud::draw(const GfxContext& ctx){ contentAccessPanel->setCoord(glm::vec2(width-caWidth, 0)); glm::vec2 invSize = inventoryView->getSize(); - inventoryView->setCoord(glm::vec2( - glm::min(width/2-invSize.x/2, width-caWidth-10-invSize.x), - height/2-invSize.y/2 - )); + if (blockUI == nullptr) { + inventoryView->setCoord(glm::vec2( + glm::min(width/2-invSize.x/2, width-caWidth-10-invSize.x), + height/2-invSize.y/2 + )); + } else { + glm::vec2 blockInvSize = blockUI->getSize(); + int interval = 5; + float totalHeight = invSize.y + blockInvSize.y + interval; + inventoryView->setCoord(glm::vec2( + glm::min(width/2-invSize.x/2, width-caWidth-10-invSize.x), + height/2+totalHeight/2-invSize.y + )); + blockUI->setCoord(glm::vec2( + glm::min(width/2-invSize.x/2, width-caWidth-10-invSize.x), + height/2-totalHeight/2 + )); + } } grabbedItemView->setCoord(glm::vec2(Events::cursor)); batch->render(); diff --git a/src/logic/scripting/lua/api_lua.cpp b/src/logic/scripting/lua/api_lua.cpp index 2d9f9dd3..1049e633 100644 --- a/src/logic/scripting/lua/api_lua.cpp +++ b/src/logic/scripting/lua/api_lua.cpp @@ -433,9 +433,7 @@ int l_set_block_rotation(lua_State* L) { lua::luaint x = lua_tointeger(L, 1); lua::luaint y = lua_tointeger(L, 2); lua::luaint z = lua_tointeger(L, 3); - lua::luaint value = lua_tointeger(L, 4); - voxel* vox = scripting::level->chunks->get(x, y, z); if (vox == nullptr) { return 0; diff --git a/src/logic/scripting/lua/libhud.cpp b/src/logic/scripting/lua/libhud.cpp index f709ed90..207daa6f 100644 --- a/src/logic/scripting/lua/libhud.cpp +++ b/src/logic/scripting/lua/libhud.cpp @@ -60,7 +60,7 @@ int l_hud_open_block(lua_State* L) { x, y, z ); } - + scripting::hud->openInventory( glm::ivec3(x, y, z), layout, scripting::level->inventories->get(id) );