mirror of
https://github.com/MihailRis/voxelcore.git
synced 2026-10-10 21:41:50 +00:00
fix: inventory interaction on "disablePlayerInventory = true"
This commit is contained in:
parent
a1549983f8
commit
dba10805f8
2 changed files with 20 additions and 26 deletions
|
|
@ -383,17 +383,18 @@ void Hud::update(bool visible) {
|
||||||
}
|
}
|
||||||
|
|
||||||
/// @brief Show inventory on the screen and turn on inventory mode blocking movement
|
/// @brief Show inventory on the screen and turn on inventory mode blocking movement
|
||||||
void Hud::openInventory() {
|
void Hud::openInventory(bool playerInventory) {
|
||||||
auto& content = frontend.getLevel().content;
|
|
||||||
showExchangeSlot();
|
showExchangeSlot();
|
||||||
|
|
||||||
inventoryOpen = true;
|
inventoryOpen = true;
|
||||||
auto inventory = player.getInventory();
|
|
||||||
auto inventoryDocument = assets.get<UiDocument>("core:inventory");
|
if (playerInventory) {
|
||||||
inventoryView = std::dynamic_pointer_cast<InventoryView>(inventoryDocument->getRoot());
|
auto& content = frontend.getLevel().content;
|
||||||
inventoryView->bind(inventory, &content);
|
auto inventory = player.getInventory();
|
||||||
add(HudElement(HudElementMode::INVENTORY, inventoryDocument, inventoryView, false));
|
auto inventoryDocument = assets.get<UiDocument>("core:inventory");
|
||||||
add(HudElement(HudElementMode::INVENTORY, nullptr, exchangeSlot, false));
|
inventoryView = std::dynamic_pointer_cast<InventoryView>(inventoryDocument->getRoot());
|
||||||
|
inventoryView->bind(inventory, &content);
|
||||||
|
add(HudElement(HudElementMode::INVENTORY, inventoryDocument, inventoryView, false));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
std::shared_ptr<Inventory> Hud::openInventory(
|
std::shared_ptr<Inventory> Hud::openInventory(
|
||||||
|
|
@ -412,11 +413,8 @@ std::shared_ptr<Inventory> Hud::openInventory(
|
||||||
}
|
}
|
||||||
secondUI = secondInvView;
|
secondUI = secondInvView;
|
||||||
|
|
||||||
if (playerInventory) {
|
openInventory(playerInventory);
|
||||||
openInventory();
|
|
||||||
} else {
|
|
||||||
inventoryOpen = true;
|
|
||||||
}
|
|
||||||
if (inv == nullptr) {
|
if (inv == nullptr) {
|
||||||
inv = level.inventories->createVirtual(secondInvView->getSlotsCount());
|
inv = level.inventories->createVirtual(secondInvView->getSlotsCount());
|
||||||
}
|
}
|
||||||
|
|
@ -444,11 +442,9 @@ void Hud::openInventory(
|
||||||
throw std::runtime_error("block UI root element must be 'inventory'");
|
throw std::runtime_error("block UI root element must be 'inventory'");
|
||||||
}
|
}
|
||||||
secondUI = blockUI;
|
secondUI = blockUI;
|
||||||
if (playerInventory) {
|
|
||||||
openInventory();
|
openInventory(playerInventory);
|
||||||
} else {
|
|
||||||
inventoryOpen = true;
|
|
||||||
}
|
|
||||||
if (blockinv == nullptr) {
|
if (blockinv == nullptr) {
|
||||||
blockinv = level.inventories->createVirtual(blockUI->getSlotsCount());
|
blockinv = level.inventories->createVirtual(blockUI->getSlotsCount());
|
||||||
}
|
}
|
||||||
|
|
@ -477,6 +473,7 @@ void Hud::showExchangeSlot() {
|
||||||
exchangeSlot->setInteractive(false);
|
exchangeSlot->setInteractive(false);
|
||||||
exchangeSlot->setZIndex(1);
|
exchangeSlot->setZIndex(1);
|
||||||
gui.store(SlotView::EXCHANGE_SLOT_NAME, exchangeSlot);
|
gui.store(SlotView::EXCHANGE_SLOT_NAME, exchangeSlot);
|
||||||
|
add(HudElement(HudElementMode::INVENTORY, nullptr, exchangeSlot, false));
|
||||||
}
|
}
|
||||||
|
|
||||||
void Hud::showOverlay(
|
void Hud::showOverlay(
|
||||||
|
|
@ -486,12 +483,9 @@ void Hud::showOverlay(
|
||||||
closeInventory();
|
closeInventory();
|
||||||
}
|
}
|
||||||
secondUI = doc->getRoot();
|
secondUI = doc->getRoot();
|
||||||
if (playerInventory) {
|
|
||||||
openInventory();
|
openInventory(playerInventory);
|
||||||
} else {
|
|
||||||
showExchangeSlot();
|
|
||||||
inventoryOpen = true;
|
|
||||||
}
|
|
||||||
add(HudElement(HudElementMode::INVENTORY, doc, secondUI, false), args);
|
add(HudElement(HudElementMode::INVENTORY, doc, secondUI, false), args);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -156,7 +156,7 @@ public:
|
||||||
void setPause(bool pause);
|
void setPause(bool pause);
|
||||||
|
|
||||||
/// @brief Show player inventory in inventory-mode
|
/// @brief Show player inventory in inventory-mode
|
||||||
void openInventory();
|
void openInventory(bool playerInventory = true);
|
||||||
|
|
||||||
/// @brief Show inventory in inventory-mode
|
/// @brief Show inventory in inventory-mode
|
||||||
/// @param doc ui layout
|
/// @param doc ui layout
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue