more docs
This commit is contained in:
+12
-10
@@ -33,6 +33,9 @@ std::shared_ptr<PagesControl> GUI::getMenu() {
|
|||||||
return menu;
|
return menu;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** Mouse related input and logic handling
|
||||||
|
* @param delta delta time
|
||||||
|
*/
|
||||||
void GUI::actMouse(float delta) {
|
void GUI::actMouse(float delta) {
|
||||||
auto hover = container->getAt(Events::cursor, nullptr);
|
auto hover = container->getAt(Events::cursor, nullptr);
|
||||||
if (this->hover && this->hover != hover) {
|
if (this->hover && this->hover != hover) {
|
||||||
@@ -77,6 +80,9 @@ void GUI::actMouse(float delta) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** Processing user input and UI logic
|
||||||
|
* @param delta delta time
|
||||||
|
*/
|
||||||
void GUI::act(float delta) {
|
void GUI::act(float delta) {
|
||||||
container->setSize(glm::vec2(Window::width, Window::height));
|
container->setSize(glm::vec2(Window::width, Window::height));
|
||||||
container->act(delta);
|
container->act(delta);
|
||||||
@@ -133,23 +139,19 @@ bool GUI::isFocusCaught() const {
|
|||||||
return focus && focus->isFocuskeeper();
|
return focus && focus->isFocuskeeper();
|
||||||
}
|
}
|
||||||
|
|
||||||
void GUI::addBack(std::shared_ptr<UINode> panel) {
|
void GUI::add(std::shared_ptr<UINode> node) {
|
||||||
container->addBack(panel);
|
container->add(node);
|
||||||
}
|
}
|
||||||
|
|
||||||
void GUI::add(std::shared_ptr<UINode> panel) {
|
void GUI::remove(std::shared_ptr<UINode> node) noexcept {
|
||||||
container->add(panel);
|
container->remove(node);
|
||||||
}
|
|
||||||
|
|
||||||
void GUI::remove(std::shared_ptr<UINode> panel) {
|
|
||||||
container->remove(panel);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void GUI::store(std::string name, std::shared_ptr<UINode> node) {
|
void GUI::store(std::string name, std::shared_ptr<UINode> node) {
|
||||||
storage[name] = node;
|
storage[name] = node;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::shared_ptr<UINode> GUI::get(std::string name) {
|
std::shared_ptr<UINode> GUI::get(std::string name) noexcept {
|
||||||
auto found = storage.find(name);
|
auto found = storage.find(name);
|
||||||
if (found == storage.end()) {
|
if (found == storage.end()) {
|
||||||
return nullptr;
|
return nullptr;
|
||||||
@@ -157,7 +159,7 @@ std::shared_ptr<UINode> GUI::get(std::string name) {
|
|||||||
return found->second;
|
return found->second;
|
||||||
}
|
}
|
||||||
|
|
||||||
void GUI::remove(std::string name) {
|
void GUI::remove(std::string name) noexcept {
|
||||||
storage.erase(name);
|
storage.erase(name);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+39
-5
@@ -63,21 +63,55 @@ namespace gui {
|
|||||||
GUI();
|
GUI();
|
||||||
~GUI();
|
~GUI();
|
||||||
|
|
||||||
|
/** Get the main menu (PagesControl) node */
|
||||||
std::shared_ptr<PagesControl> getMenu();
|
std::shared_ptr<PagesControl> getMenu();
|
||||||
|
|
||||||
|
/** Get current focused node
|
||||||
|
* @return focused node or nullptr */
|
||||||
std::shared_ptr<UINode> getFocused() const;
|
std::shared_ptr<UINode> getFocused() const;
|
||||||
|
|
||||||
|
/** Check if all user input is caught by some element like TextBox */
|
||||||
bool isFocusCaught() const;
|
bool isFocusCaught() const;
|
||||||
|
|
||||||
|
/** Main input handling and logic update method
|
||||||
|
* @param delta delta time */
|
||||||
void act(float delta);
|
void act(float delta);
|
||||||
|
|
||||||
|
/** Draw all visible elements on main container
|
||||||
|
* @param pctx parent graphics context
|
||||||
|
* @param assets active assets storage */
|
||||||
void draw(const GfxContext* pctx, Assets* assets);
|
void draw(const GfxContext* pctx, Assets* assets);
|
||||||
void addBack(std::shared_ptr<UINode> panel);
|
|
||||||
void add(std::shared_ptr<UINode> panel);
|
/** Add node to the main container */
|
||||||
void remove(std::shared_ptr<UINode> panel);
|
void add(std::shared_ptr<UINode> node);
|
||||||
|
|
||||||
|
/** Remove node from the main container */
|
||||||
|
void remove(std::shared_ptr<UINode> node) noexcept;
|
||||||
|
|
||||||
|
/** Store node in the GUI nodes dictionary
|
||||||
|
* (does not add node to the main container)
|
||||||
|
* @param name node key
|
||||||
|
* @param node target node
|
||||||
|
*/
|
||||||
void store(std::string name, std::shared_ptr<UINode> node);
|
void store(std::string name, std::shared_ptr<UINode> node);
|
||||||
std::shared_ptr<UINode> get(std::string name);
|
|
||||||
void remove(std::string name);
|
/** Get node from the GUI nodes dictionary
|
||||||
|
* @param name node key
|
||||||
|
* @return stored node or nullptr
|
||||||
|
*/
|
||||||
|
std::shared_ptr<UINode> get(std::string name) noexcept;
|
||||||
|
|
||||||
|
/** Remove node from the GUI nodes dictionary
|
||||||
|
* @param name node key
|
||||||
|
*/
|
||||||
|
void remove(std::string name) noexcept;
|
||||||
|
|
||||||
|
/** Set node as focused
|
||||||
|
* @param node new focused node or nullptr to remove focus
|
||||||
|
*/
|
||||||
void setFocus(std::shared_ptr<UINode> node);
|
void setFocus(std::shared_ptr<UINode> node);
|
||||||
|
|
||||||
|
/** Get the main container */
|
||||||
std::shared_ptr<Container> getContainer() const;
|
std::shared_ptr<Container> getContainer() const;
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -294,8 +294,8 @@ Hud::Hud(Engine* engine, LevelFrontend* frontend)
|
|||||||
|
|
||||||
debugPanel->setZIndex(2);
|
debugPanel->setZIndex(2);
|
||||||
|
|
||||||
gui->addBack(darkOverlay);
|
gui->add(darkOverlay);
|
||||||
gui->addBack(hotbarView);
|
gui->add(hotbarView);
|
||||||
gui->add(debugPanel);
|
gui->add(debugPanel);
|
||||||
gui->add(contentAccessPanel);
|
gui->add(contentAccessPanel);
|
||||||
gui->add(grabbedItemView);
|
gui->add(grabbedItemView);
|
||||||
@@ -425,6 +425,7 @@ void Hud::openInventory(glm::ivec3 block, UiDocument* doc, std::shared_ptr<Inven
|
|||||||
blockinv = level->inventories->createVirtual(blockUI->getSlotsCount());
|
blockinv = level->inventories->createVirtual(blockUI->getSlotsCount());
|
||||||
}
|
}
|
||||||
blockUI->bind(blockinv, frontend, interaction.get());
|
blockUI->bind(blockinv, frontend, interaction.get());
|
||||||
|
currentblock = block;
|
||||||
add(HudElement(hud_element_mode::inventory_bound, doc, blockUI, false));
|
add(HudElement(hud_element_mode::inventory_bound, doc, blockUI, false));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user