reformatted hud.h, hud.cpp
This commit is contained in:
+10
-20
@@ -322,9 +322,7 @@ void Hud::drawDebug(int fps){
|
|||||||
fpsMax = max(fps, fpsMax);
|
fpsMax = max(fps, fpsMax);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/// @brief Remove all elements marked as removed
|
||||||
* Remove all elements marked as removed
|
|
||||||
*/
|
|
||||||
void Hud::cleanup() {
|
void Hud::cleanup() {
|
||||||
auto it = std::remove_if(elements.begin(), elements.end(), [](const HudElement& e) {
|
auto it = std::remove_if(elements.begin(), elements.end(), [](const HudElement& e) {
|
||||||
return e.isRemoved();
|
return e.isRemoved();
|
||||||
@@ -414,9 +412,7 @@ void Hud::update(bool visible) {
|
|||||||
cleanup();
|
cleanup();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/// @brief Show inventory on the screen and turn on inventory mode blocking movement
|
||||||
* Show inventory on the screen and turn on inventory mode blocking movement
|
|
||||||
*/
|
|
||||||
void Hud::openInventory() {
|
void Hud::openInventory() {
|
||||||
auto inventory = player->getInventory();
|
auto inventory = player->getInventory();
|
||||||
|
|
||||||
@@ -428,13 +424,11 @@ void Hud::openInventory() {
|
|||||||
add(HudElement(hud_element_mode::inventory_bound, inventoryDocument, inventoryView, false));
|
add(HudElement(hud_element_mode::inventory_bound, inventoryDocument, inventoryView, false));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/// @brief Show player inventory + block UI
|
||||||
* Show player inventory + block UI
|
/// @param block world position of the open block
|
||||||
* @param block world position of the open block
|
/// @param doc block UI document (root element must be an InventoryView)
|
||||||
* @param doc block UI document (root element must be an InventoryView)
|
/// @param blockinv block inventory.
|
||||||
* @param blockinv block inventory.
|
/// If blockinv is nullptr a new virtual inventory will be created
|
||||||
* In case of nullptr a new virtual inventory will be created
|
|
||||||
*/
|
|
||||||
void Hud::openInventory(glm::ivec3 block, UiDocument* doc, std::shared_ptr<Inventory> blockinv, bool playerInventory) {
|
void Hud::openInventory(glm::ivec3 block, UiDocument* doc, std::shared_ptr<Inventory> blockinv, bool playerInventory) {
|
||||||
if (isInventoryOpen()) {
|
if (isInventoryOpen()) {
|
||||||
closeInventory();
|
closeInventory();
|
||||||
@@ -459,10 +453,8 @@ void Hud::openInventory(glm::ivec3 block, UiDocument* doc, std::shared_ptr<Inven
|
|||||||
add(HudElement(hud_element_mode::inventory_bound, doc, blockUI, false));
|
add(HudElement(hud_element_mode::inventory_bound, doc, blockUI, false));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/// @brief Add element as permanent overlay
|
||||||
* Add element as permanent overlay
|
/// @param doc element layout document
|
||||||
* @param doc element layout document
|
|
||||||
*/
|
|
||||||
void Hud::openPermanent(UiDocument* doc) {
|
void Hud::openPermanent(UiDocument* doc) {
|
||||||
auto root = doc->getRoot();
|
auto root = doc->getRoot();
|
||||||
remove(root);
|
remove(root);
|
||||||
@@ -475,9 +467,7 @@ void Hud::openPermanent(UiDocument* doc) {
|
|||||||
add(HudElement(hud_element_mode::permanent, doc, doc->getRoot(), false));
|
add(HudElement(hud_element_mode::permanent, doc, doc->getRoot(), false));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/// @brief Hide inventory and turn off inventory mode
|
||||||
* Hide inventory and turn off inventory mode
|
|
||||||
*/
|
|
||||||
void Hud::closeInventory() {
|
void Hud::closeInventory() {
|
||||||
auto level = frontend->getLevel();
|
auto level = frontend->getLevel();
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user