InventoryView.unbind()
This commit is contained in:
@@ -16,6 +16,7 @@
|
|||||||
#include "../content/Content.h"
|
#include "../content/Content.h"
|
||||||
#include "../items/ItemDef.h"
|
#include "../items/ItemDef.h"
|
||||||
#include "../items/Inventory.h"
|
#include "../items/Inventory.h"
|
||||||
|
#include "../items/Inventories.h"
|
||||||
#include "../maths/voxmaths.h"
|
#include "../maths/voxmaths.h"
|
||||||
#include "../objects/Player.h"
|
#include "../objects/Player.h"
|
||||||
#include "../voxels/Block.h"
|
#include "../voxels/Block.h"
|
||||||
@@ -337,6 +338,12 @@ void InventoryView::bind(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void InventoryView::unbind() {
|
||||||
|
if (inventory->isVirtual()) {
|
||||||
|
frontend->getLevel()->inventories->remove(inventory->getId());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void InventoryView::setSelected(int index) {
|
void InventoryView::setSelected(int index) {
|
||||||
for (int i = 0; i < int(slots.size()); i++) {
|
for (int i = 0; i < int(slots.size()); i++) {
|
||||||
auto slot = slots[i];
|
auto slot = slots[i];
|
||||||
|
|||||||
@@ -113,6 +113,8 @@ public:
|
|||||||
LevelFrontend* frontend,
|
LevelFrontend* frontend,
|
||||||
InventoryInteraction* interaction
|
InventoryInteraction* interaction
|
||||||
);
|
);
|
||||||
|
|
||||||
|
void unbind();
|
||||||
|
|
||||||
std::shared_ptr<SlotView> addSlot(SlotLayout layout);
|
std::shared_ptr<SlotView> addSlot(SlotLayout layout);
|
||||||
|
|
||||||
|
|||||||
+4
-10
@@ -409,20 +409,11 @@ void Hud::openPermanent(UiDocument* doc) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void Hud::closeInventory() {
|
void Hud::closeInventory() {
|
||||||
auto level = frontend->getLevel();
|
|
||||||
|
|
||||||
inventoryOpen = false;
|
inventoryOpen = false;
|
||||||
ItemStack& grabbed = interaction->getGrabbedItem();
|
ItemStack& grabbed = interaction->getGrabbedItem();
|
||||||
grabbed.clear();
|
grabbed.clear();
|
||||||
inventoryView = nullptr;
|
inventoryView = nullptr;
|
||||||
if (blockUI) {
|
blockUI = nullptr;
|
||||||
auto blockinv = blockUI->getInventory();
|
|
||||||
// todo: do it automatically
|
|
||||||
if (blockinv->isVirtual()) {
|
|
||||||
level->inventories->remove(blockinv->getId());
|
|
||||||
}
|
|
||||||
blockUI = nullptr;
|
|
||||||
}
|
|
||||||
secondUI = nullptr;
|
secondUI = nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -458,6 +449,9 @@ void Hud::remove(HudElement& element) {
|
|||||||
inventory = invview->getInventory().get();
|
inventory = invview->getInventory().get();
|
||||||
}
|
}
|
||||||
scripting::on_ui_close(document, inventory);
|
scripting::on_ui_close(document, inventory);
|
||||||
|
if (invview) {
|
||||||
|
invview->unbind();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
gui->remove(element.getNode());
|
gui->remove(element.getNode());
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user