misc hud-related updates
This commit is contained in:
+38
-2
@@ -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_ */
|
||||
|
||||
Reference in New Issue
Block a user