//! ---|> Component void Connector::doLayout(){ Geometry::Vec2 parentsAbsPos=hasParent()?getParent()->getAbsPosition():Geometry::Vec2(); Geometry::Rect r; r.invalidate(); // std::cout << r.getX(); if( getFirstComponent() ) r.include( getFirstComponent()->getAbsRect().getCenter()-parentsAbsPos ); // std::cout << (getFirstComponent()->getAbsRect().getCenter()-parentsAbsPos).getX(); if( getSecondComponent() ) r.include( getSecondComponent()->getAbsRect().getCenter()-parentsAbsPos ); if(getContentsCount()>2){ // TODO!!!!! } setPosition(Geometry::Vec2(r.getX(),r.getY())); setSize(r.getWidth(),r.getHeight()); Geometry::Vec2 myAbsPos=getAbsPosition(); if(getFirstChild() && getFirstComponent()){ getFirstChild()->setPosition( getFirstComponent()->getAbsRect().getCenter()-myAbsPos ); } if(getLastChild() && getSecondComponent()){ getLastChild()->setPosition( getSecondComponent()->getAbsRect().getCenter()-myAbsPos ); // getLastChild()->setPosition(Vec2(r.getWidth(),r.getHeight())); } if(getContentsCount()>2){ // TODO!!!!! } }
// ----------------------------------------------------------------- // Name : onButtonEvent // ----------------------------------------------------------------- bool LevelUpDlg::onButtonEvent(ButtonAction * pEvent, guiComponent * pCpnt) { if (strcmp(pCpnt->getId(), "OkButton") == 0) { // Update avatar progression assert(m_pCurrentAvatar != NULL); if (m_pSelectedElement != NULL) { int iTree = -1; // find selected tree for (int i = 0; i < NB_PROGRESSION_TREES; i++) { if (strcmp(m_pSelectedElement->m_pTree->m_sObjectId, m_pCurrentAvatar->m_pProgression[i].sTreeName) == 0) { iTree = i; break; } } assert(m_pCurrentAvatar->m_pOwner != NULL); m_pCurrentAvatar->m_pOwner->applyAvatarProgression(m_pCurrentAvatar, iTree, m_pSelectedElement); // Hide frame m_pLocalClient->getInterface()->setUniqueDialog(m_pCaller); return false; } else { // Should be opening a tree guiComboBox * pBox = (guiComboBox*) getComponent("OpenTreeCombo"); assert(pBox != NULL); guiButton * pBtn = pBox->getSelectedItem(); assert(pBtn != NULL); assert(m_pCurrentAvatar->m_pOwner != NULL); m_pCurrentAvatar->m_pOwner->openAvatarProgressionTree(m_pCurrentAvatar, (u8)m_iSpecialLevel, (ProgressionTree*) pBtn->getAttachment()); // Hide frame m_pLocalClient->getInterface()->setUniqueDialog(m_pCaller); return false; } } else if (strcmp(pCpnt->getId(), "DoItLaterButton") == 0) { // Hide frame m_pLocalClient->getInterface()->setUniqueDialog(m_pCaller); return false; } else if (strcmp(pCpnt->getId(), "OpenTreeButton") == 0) { getComponent("OkButton")->setEnabled(true); } else if (strcmp(pCpnt->getId(), "ChoiceButton") == 0) { if (((guiToggleButton*)pCpnt)->getClickState()) { m_pSelectedElement = (ProgressionElement*) pCpnt->getAttachment(); assert(m_pSelectedElement != NULL); getComponent("OkButton")->setEnabled(true); guiComponent * pCpnt2 = getFirstComponent(); while (pCpnt2 != NULL) { if (strcmp(pCpnt2->getId(), "ChoiceButton") == 0 && pCpnt2 != pCpnt && pCpnt2->isEnabled()) ((guiToggleButton*)pCpnt2)->setClickState(false); pCpnt2 = getNextComponent(); } } else { m_pSelectedElement = NULL; getComponent("OkButton")->setEnabled(false); } } return true; }