diff --git a/src/frontend/hud.cpp b/src/frontend/hud.cpp index 88114661a..d40ab3b8e 100644 --- a/src/frontend/hud.cpp +++ b/src/frontend/hud.cpp @@ -385,12 +385,15 @@ void Hud::update(bool visible) { /// @brief Show inventory on the screen and turn on inventory mode blocking movement void Hud::openInventory() { auto& content = frontend.getLevel().content; + showExchangeSlot(); + inventoryOpen = true; auto inventory = player.getInventory(); auto inventoryDocument = assets.get("core:inventory"); inventoryView = std::dynamic_pointer_cast(inventoryDocument->getRoot()); inventoryView->bind(inventory, &content); add(HudElement(HudElementMode::INVENTORY, inventoryDocument, inventoryView, false)); + add(HudElement(HudElementMode::INVENTORY, nullptr, exchangeSlot, false)); } std::shared_ptr Hud::openInventory( @@ -411,10 +414,9 @@ std::shared_ptr Hud::openInventory( if (playerInventory) { openInventory(); + } else { + inventoryOpen = true; } - showExchangeSlot(); - inventoryOpen = true; - if (inv == nullptr) { inv = level.inventories->createVirtual(secondInvView->getSlotsCount()); } @@ -444,10 +446,9 @@ void Hud::openInventory( secondUI = blockUI; if (playerInventory) { openInventory(); + } else { + inventoryOpen = true; } - showExchangeSlot(); - inventoryOpen = true; - if (blockinv == nullptr) { blockinv = level.inventories->createVirtual(blockUI->getSlotsCount()); } @@ -476,7 +477,6 @@ void Hud::showExchangeSlot() { exchangeSlot->setInteractive(false); exchangeSlot->setZIndex(1); gui.store(SlotView::EXCHANGE_SLOT_NAME, exchangeSlot); - add(HudElement(HudElementMode::INVENTORY, nullptr, exchangeSlot, false)); } void Hud::showOverlay( @@ -488,10 +488,10 @@ void Hud::showOverlay( secondUI = doc->getRoot(); if (playerInventory) { openInventory(); + } else { + showExchangeSlot(); + inventoryOpen = true; } - showExchangeSlot(); - inventoryOpen = true; - add(HudElement(HudElementMode::INVENTORY, doc, secondUI, false), args); }