// ----------------------------------------------------------------- // Name : showStatus // ----------------------------------------------------------------- void StatusDlg::showStatus(char * sMessage) { deleteAllComponents(); guiLabel * pLbl = new guiLabel(); pLbl->init(sMessage, TEXT_FONT, TEXT_COLOR, "", 0, 0, 400, 0, getDisplay()); addComponent(pLbl); setDimensions(pLbl->getWidth(), pLbl->getHeight()); guiFrame * pFrm = m_pLocalClient->getInterface()->findFrameFromDoc(this); pFrm->updateSizeFit(); pFrm->moveTo(m_pLocalClient->getClientParameters()->screenXSize / 2 - pFrm->getWidth() / 2, 0); pFrm->setVisible(true); }
// ----------------------------------------------------------------- // Name : setCurrentAvatar // ----------------------------------------------------------------- void LevelUpDlg::setCurrentAvatar(AvatarData * pAvatar) { m_pCurrentAvatar = pAvatar; short iSpecialLevels[MAX_LEVELS] = { 0, 1, -1, 2, -1, -1, 3, -1, -1, -1, -1, -1, -1, -1, -1 }; deleteAllComponents(); // Init position for components int iWidth = getWidth(); int yPxl = 10; // Top label char sText[LABEL_MAX_CHARS]; i18n->getText("LEVEL_UP", sText, LABEL_MAX_CHARS); guiLabel * pLbl = new guiLabel(); pLbl->init(sText, H1_FONT, H1_COLOR, "TopLabe", 0, 0, iWidth - 10, 0, m_pLocalClient->getDisplay()); pLbl->moveTo((iWidth - pLbl->getWidth()) / 2, yPxl); addComponent(pLbl); // Text yPxl += pLbl->getHeight() + 15; u16 uLevel = pAvatar->getRealLevel() + 1; assert(uLevel > 1); char sBuf[256]; i18n->getText("(s)_LEVELED_UP_AND_IS_(d)", sBuf, 256); snprintf(sText, LABEL_MAX_CHARS, sBuf, pAvatar->m_sCustomName, (int)uLevel); pLbl = new guiLabel(); pLbl->init(sText, TEXT_FONT, TEXT_COLOR, "CenterLabe", 0, 0, iWidth - 10, 0, m_pLocalClient->getDisplay()); pLbl->moveTo(5, yPxl); addComponent(pLbl); Edition * pEdition = m_pLocalClient->getDataFactory()->findEdition(pAvatar->m_sEdition); assert(pEdition != NULL); m_iSpecialLevel = iSpecialLevels[uLevel-1]; if (m_iSpecialLevel >= 0) { u8 uTreeType = -1; char sPhraseKey[128] = ""; switch (m_iSpecialLevel) { case 1: uTreeType = PROGRESSION_MAGIC; wsafecpy(sPhraseKey, 128, "CHOOSE_MAGIC_PATH"); break; case 2: case 3: uTreeType = PROGRESSION_TRAIT; wsafecpy(sPhraseKey, 128, "CHOOSE_CHARACTER_TRAIT"); break; } assert(uTreeType >= 0); // Text i18n->getText(sPhraseKey, sText, LABEL_MAX_CHARS); yPxl += pLbl->getHeight() + 2 * SPACING; pLbl = new guiLabel(); pLbl->init(sText, TEXT_FONT, TEXT_COLOR, "", SPACING, yPxl, iWidth - 2 * SPACING, 0, getDisplay()); addComponent(pLbl); // Open tree combo yPxl += pLbl->getHeight() + SPACING; guiComboBox * pCombo = guiComboBox::createDefaultComboBox("OpenTreeCombo", m_pLocalClient->getInterface(), getDisplay()); pCombo->moveTo(SPACING, yPxl); addComponent(pCombo); ObjectList * pTrees = new ObjectList(false); pEdition->getAllTreesByType(pTrees, uTreeType); ProgressionTree * pTree = (ProgressionTree*) pTrees->getFirst(0); while (pTree != NULL) { pTree->findLocalizedElement(sText, LABEL_MAX_CHARS, i18n->getCurrentLanguageName(), "name"); guiButton * pBtn = pCombo->addString(sText, "OpenTreeButton"); pBtn->setAttachment(pTree); pTree->getDescription(sText, LABEL_MAX_CHARS, m_pLocalClient); pBtn->setTooltipText(sText); pTree = (ProgressionTree*) pTrees->getNext(0); } delete pTrees; yPxl += pCombo->getHeight() + SPACING; } else { int xTree = SPACING; int btnSize = 64; int treeWidth = 2 * btnSize + btnSize / 3; int treeTop = yPxl + pLbl->getHeight() + 2 * SPACING; // Trees for (int i = 0; i < NB_PROGRESSION_TREES; i++) { if (strcmp(pAvatar->m_pProgression[i].sTreeName, "") == 0) continue; ProgressionTree * pTree = pEdition->findProgressionTree(pAvatar->m_pProgression[i].sTreeName); assert(pTree != NULL); // Top label yPxl = treeTop; pTree->findLocalizedElement(sText, LABEL_MAX_CHARS, i18n->getCurrentLanguageName(), "name"); pLbl = new guiLabel(); pLbl->init(sText, H2_FONT, H2_COLOR, "", 0, 0, 0, 0, getDisplay()); pLbl->moveTo(xTree + treeWidth / 2 - pLbl->getWidth() / 2, yPxl); addComponent(pLbl); // Choices s32 iTexChoice = m_pLocalClient->getDisplay()->getTextureEngine()->loadTexture("progression_choice"); s32 iTexChoiceLeft = m_pLocalClient->getDisplay()->getTextureEngine()->loadTexture("progression_choice_"); s32 iTexChoiceRight = m_pLocalClient->getDisplay()->getTextureEngine()->loadTexture("progression_choice_r"); int iChoiceWidth = m_pLocalClient->getDisplay()->getTextureEngine()->getTexture(iTexChoice)->m_iWidth; // image is centered on texture, so we take its width bool bLastChosenLeft = true; // branch image yPxl += pLbl->getHeight() + SPACING; guiImage * pImg = new guiImage(); pImg->init(iTexChoice, "", xTree + treeWidth / 2 - iChoiceWidth / 2, yPxl, -1, -1, getDisplay()); addComponent(pImg); // Get tree root choices yPxl += pImg->getHeight(); int xPxl = xTree; bool bFirstCol = true; ProgressionElement * pChosen = getChosenElementAtLevel(pTree, i, 0); ProgressionElement * pElt = (ProgressionElement*) pTree->m_pElements[0]->getFirst(0); while (pElt != NULL) { addChoiceButton(xPxl, yPxl, btnSize, pElt, pChosen == NULL ? 2 : (pChosen == pElt ? 1 : 0)); if (pChosen == pElt) bLastChosenLeft = bFirstCol; if (bFirstCol) xPxl += btnSize + btnSize / 3; else { xPxl = xTree; yPxl += btnSize + SPACING; } bFirstCol = !bFirstCol; pElt = (ProgressionElement*) pTree->m_pElements[0]->getNext(0); } if (!bFirstCol) yPxl += btnSize + SPACING; int iLevel = 1; while (pChosen != NULL) { // branch image pImg = new guiImage(); pImg->init(bLastChosenLeft ? iTexChoiceLeft : iTexChoiceRight, "", xTree + treeWidth / 2 - iChoiceWidth / 2, yPxl, -1, -1, getDisplay()); addComponent(pImg); yPxl += pImg->getHeight(); xPxl = xTree; bFirstCol = true; ProgressionElement * pPrevChosen = pChosen; pChosen = getChosenElementAtLevel(pTree, i, iLevel++); pElt = (ProgressionElement*) pPrevChosen->m_pChildren->getFirst(0); while (pElt != NULL) { addChoiceButton(xPxl, yPxl, btnSize, pElt, pChosen == NULL ? 2 : (pChosen == pElt ? 1 : 0)); if (pChosen == pElt) bLastChosenLeft = bFirstCol; if (bFirstCol) xPxl += btnSize + btnSize / 3; else { xPxl = xTree; yPxl += btnSize + SPACING; } bFirstCol = !bFirstCol; pElt = (ProgressionElement*) pPrevChosen->m_pChildren->getNext(0); } if (!bFirstCol) yPxl += btnSize + SPACING; } xTree += treeWidth + SPACING; } } // Create button "Do it later" yPxl += SPACING; float fx = getWidth() / 8; guiButton * pBtn = guiButton::createDefaultNormalButton(i18n->getText("DO_IT_LATER", sText, 256), "DoItLaterButton", m_pLocalClient->getDisplay()); pBtn->moveTo((int)fx, yPxl); pBtn->setWidth(2*fx); pBtn->setTooltipText(i18n->getText("DO_IT_LATER_EXP", sText, 256)); addComponent(pBtn); // Create button "Ok" pBtn = (guiButton*) pBtn->clone(); pBtn->setText(i18n->getText1stUp("OK", sText, 256)); pBtn->setId("OkButton"); pBtn->moveBy((int)(4 * fx), 0); pBtn->setEnabled(false); addComponent(pBtn); // Size setHeight(yPxl + pBtn->getHeight() + SPACING); // Show frame m_pLocalClient->getInterface()->setUniqueDialog(this); }
ComponentManager::~ComponentManager() { //dtor deleteAllComponents(); delete cmpList; }