std::shared_ptr<GUIElement> GUIManager::getElementByID(int id, std::shared_ptr<GUIElement> parent) { if(parent == nullptr) { for(std::vector<std::shared_ptr<GUIElement> >::iterator it = mGuiElements.begin(); it != mGuiElements.end(); ++it) { std::shared_ptr<GUIElement> elementWithID = getElementByID(id, *it); if(elementWithID != nullptr) return elementWithID; } } else { for(std::vector<std::shared_ptr<GUIElement> >::iterator it = parent->getChildVector().begin(); it != parent->getChildVector().end(); ++it) { std::shared_ptr<GUIElement> elementWithID = getElementByID(id, *it); if(elementWithID != nullptr) return elementWithID; } } if(parent->getElementID() == id) return parent; return nullptr; }
virtual void addLink(uint idFrom, uint idTo, Link * link) { Element * from = getElementByID(idFrom); Element * to = getElementByID(idTo); link->bindElements(from, to); }