grabbed item fix

This commit is contained in:
MihailRis 2024-01-26 05:19:57 +03:00
parent 32e6ec2fb8
commit d4999901c2
2 changed files with 15 additions and 3 deletions

View File

@ -317,7 +317,7 @@ void HudRenderer::update(bool visible) {
menu->visible(pause);
if (!visible && inventoryOpen) {
inventoryOpen = false;
closeInventory();
}
if (pause && menu->current().panel == nullptr) {
pause = false;
@ -327,7 +327,7 @@ void HudRenderer::update(bool visible) {
pause = false;
menu->reset();
} else if (inventoryOpen) {
inventoryOpen = false;
closeInventory();
} else {
pause = true;
menu->set("pause");
@ -335,7 +335,11 @@ void HudRenderer::update(bool visible) {
}
if (visible && Events::jactive(BIND_HUD_INVENTORY)) {
if (!pause) {
inventoryOpen = !inventoryOpen;
if (inventoryOpen) {
closeInventory();
} else {
inventoryOpen = true;
}
}
}
if ((pause || inventoryOpen) == Events::_cursor_locked) {
@ -366,6 +370,12 @@ void HudRenderer::update(bool visible) {
}
}
void HudRenderer::closeInventory() {
inventoryOpen = false;
ItemStack& grabbed = interaction->getGrabbedItem();
grabbed.clear();
}
void HudRenderer::drawOverlay(const GfxContext& ctx) {
if (pause) {
Shader* uishader = assets->getShader("ui");

View File

@ -63,6 +63,8 @@ public:
bool isInventoryOpen() const;
bool isPause() const;
void closeInventory();
};
#endif /* SRC_HUD_H_ */