more docs
This commit is contained in:
parent
38f9805ca7
commit
018f0affaa
@ -33,6 +33,9 @@ std::shared_ptr<PagesControl> GUI::getMenu() {
|
||||
return menu;
|
||||
}
|
||||
|
||||
/** Mouse related input and logic handling
|
||||
* @param delta delta time
|
||||
*/
|
||||
void GUI::actMouse(float delta) {
|
||||
auto hover = container->getAt(Events::cursor, nullptr);
|
||||
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) {
|
||||
container->setSize(glm::vec2(Window::width, Window::height));
|
||||
container->act(delta);
|
||||
@ -133,23 +139,19 @@ bool GUI::isFocusCaught() const {
|
||||
return focus && focus->isFocuskeeper();
|
||||
}
|
||||
|
||||
void GUI::addBack(std::shared_ptr<UINode> panel) {
|
||||
container->addBack(panel);
|
||||
void GUI::add(std::shared_ptr<UINode> node) {
|
||||
container->add(node);
|
||||
}
|
||||
|
||||
void GUI::add(std::shared_ptr<UINode> panel) {
|
||||
container->add(panel);
|
||||
}
|
||||
|
||||
void GUI::remove(std::shared_ptr<UINode> panel) {
|
||||
container->remove(panel);
|
||||
void GUI::remove(std::shared_ptr<UINode> node) noexcept {
|
||||
container->remove(node);
|
||||
}
|
||||
|
||||
void GUI::store(std::string name, std::shared_ptr<UINode> 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);
|
||||
if (found == storage.end()) {
|
||||
return nullptr;
|
||||
@ -157,7 +159,7 @@ std::shared_ptr<UINode> GUI::get(std::string name) {
|
||||
return found->second;
|
||||
}
|
||||
|
||||
void GUI::remove(std::string name) {
|
||||
void GUI::remove(std::string name) noexcept {
|
||||
storage.erase(name);
|
||||
}
|
||||
|
||||
|
||||
@ -63,21 +63,55 @@ namespace gui {
|
||||
GUI();
|
||||
~GUI();
|
||||
|
||||
/** Get the main menu (PagesControl) node */
|
||||
std::shared_ptr<PagesControl> getMenu();
|
||||
|
||||
/** Get current focused node
|
||||
* @return focused node or nullptr */
|
||||
std::shared_ptr<UINode> getFocused() const;
|
||||
|
||||
/** Check if all user input is caught by some element like TextBox */
|
||||
bool isFocusCaught() const;
|
||||
|
||||
/** Main input handling and logic update method
|
||||
* @param delta delta time */
|
||||
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 addBack(std::shared_ptr<UINode> panel);
|
||||
void add(std::shared_ptr<UINode> panel);
|
||||
void remove(std::shared_ptr<UINode> panel);
|
||||
|
||||
/** Add node to the main container */
|
||||
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);
|
||||
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);
|
||||
|
||||
/** Get the main container */
|
||||
std::shared_ptr<Container> getContainer() const;
|
||||
};
|
||||
}
|
||||
|
||||
@ -294,8 +294,8 @@ Hud::Hud(Engine* engine, LevelFrontend* frontend)
|
||||
|
||||
debugPanel->setZIndex(2);
|
||||
|
||||
gui->addBack(darkOverlay);
|
||||
gui->addBack(hotbarView);
|
||||
gui->add(darkOverlay);
|
||||
gui->add(hotbarView);
|
||||
gui->add(debugPanel);
|
||||
gui->add(contentAccessPanel);
|
||||
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());
|
||||
}
|
||||
blockUI->bind(blockinv, frontend, interaction.get());
|
||||
currentblock = block;
|
||||
add(HudElement(hud_element_mode::inventory_bound, doc, blockUI, false));
|
||||
}
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user