block ui on block break fix
This commit is contained in:
parent
086bcec9c2
commit
164d6400d9
@ -1,5 +1,7 @@
|
|||||||
#include "hud.h"
|
#include "hud.h"
|
||||||
|
|
||||||
|
// TODO: refactor this garbage
|
||||||
|
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
#include <sstream>
|
#include <sstream>
|
||||||
#include <memory>
|
#include <memory>
|
||||||
@ -365,11 +367,17 @@ void Hud::update(bool visible) {
|
|||||||
Events::toggleCursor();
|
Events::toggleCursor();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (blockUI) {
|
||||||
|
voxel* vox = level->chunks->get(currentblock.x, currentblock.y, currentblock.z);
|
||||||
|
if (vox == nullptr || vox->id != currentblockid) {
|
||||||
|
closeInventory();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
glm::vec2 invSize = contentAccessPanel->getSize();
|
glm::vec2 invSize = contentAccessPanel->getSize();
|
||||||
contentAccessPanel->setVisible(inventoryOpen);
|
contentAccessPanel->setVisible(inventoryOpen);
|
||||||
contentAccessPanel->setSize(glm::vec2(invSize.x, Window::height));
|
contentAccessPanel->setSize(glm::vec2(invSize.x, Window::height));
|
||||||
contentAccess->setMinSize(glm::vec2(1, Window::height));
|
contentAccess->setMinSize(glm::vec2(1, Window::height));
|
||||||
// hotbarView->setVisible(visible && !inventoryOpen);
|
|
||||||
|
|
||||||
for (int i = keycode::NUM_1; i <= keycode::NUM_9; i++) {
|
for (int i = keycode::NUM_1; i <= keycode::NUM_9; i++) {
|
||||||
if (Events::jpressed(i)) {
|
if (Events::jpressed(i)) {
|
||||||
@ -437,6 +445,7 @@ void Hud::openInventory(glm::ivec3 block, UiDocument* doc, std::shared_ptr<Inven
|
|||||||
}
|
}
|
||||||
blockUI->bind(blockinv, frontend, interaction.get());
|
blockUI->bind(blockinv, frontend, interaction.get());
|
||||||
currentblock = block;
|
currentblock = block;
|
||||||
|
currentblockid = level->chunks->get(block.x, block.y, block.z)->id;
|
||||||
add(HudElement(hud_element_mode::inventory_bound, doc, blockUI, false));
|
add(HudElement(hud_element_mode::inventory_bound, doc, blockUI, false));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -90,6 +90,7 @@ class Hud {
|
|||||||
std::shared_ptr<InventoryView> inventoryView = nullptr;
|
std::shared_ptr<InventoryView> inventoryView = nullptr;
|
||||||
std::shared_ptr<InventoryView> blockUI = nullptr;
|
std::shared_ptr<InventoryView> blockUI = nullptr;
|
||||||
glm::ivec3 currentblock {};
|
glm::ivec3 currentblock {};
|
||||||
|
blockid_t currentblockid = 0;
|
||||||
|
|
||||||
std::shared_ptr<gui::UINode> createDebugPanel(Engine* engine);
|
std::shared_ptr<gui::UINode> createDebugPanel(Engine* engine);
|
||||||
std::shared_ptr<InventoryView> createContentAccess();
|
std::shared_ptr<InventoryView> createContentAccess();
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user