misc hud-related updates

This commit is contained in:
MihailRis
2024-02-15 14:43:03 +03:00
parent 1f3d1e2640
commit 11bb9e5926
23 changed files with 400 additions and 165 deletions
+38 -2
View File
@@ -25,8 +25,40 @@ namespace gui {
class GUI;
class UINode;
class Panel;
class Container;
}
enum class hud_element_mode {
// element is hidden if menu or inventory open
ingame,
// element is visible if hud is visible
permanent,
// element is visible in inventory mode
inventory_any,
// element will be removed on inventory close
inventory_bound
};
class HudElement {
hud_element_mode mode;
UiDocument* document;
std::shared_ptr<gui::UINode> node;
bool debug;
bool removed = false;
public:
HudElement(hud_element_mode mode, UiDocument* document, std::shared_ptr<gui::UINode> node, bool debug);
void update(bool pause, bool inventoryOpen, bool debug);
UiDocument* getDocument() const;
std::shared_ptr<gui::UINode> getNode() const;
bool isRemoved() const {
return removed;
}
};
class HudRenderer {
Assets* assets;
std::unique_ptr<Camera> uicamera;
@@ -38,7 +70,7 @@ class HudRenderer {
bool inventoryOpen = false;
bool pause = false;
std::shared_ptr<gui::Panel> contentAccessPanel;
std::shared_ptr<gui::Container> contentAccessPanel;
std::shared_ptr<InventoryView> contentAccess;
std::shared_ptr<InventoryView> hotbarView;
std::shared_ptr<gui::UINode> debugPanel;
@@ -48,8 +80,9 @@ class HudRenderer {
gui::GUI* gui;
LevelFrontend* frontend;
std::vector<HudElement> elements;
std::shared_ptr<InventoryView> inventoryView = nullptr;
UiDocument* inventoryDocument = nullptr;
std::shared_ptr<gui::UINode> createDebugPanel(Engine* engine);
std::shared_ptr<InventoryView> createContentAccess();
@@ -68,6 +101,9 @@ public:
void openInventory();
void closeInventory();
void add(HudElement element);
void remove(HudElement& element);
};
#endif /* SRC_HUD_H_ */