void AdvanceModePopularPackagesLayer::resultHttpRequestCompleted(cs::JsonDictionary* pJsonDict, std::string sKey) { this->removeChildByTag(_TAG_ICON_LOADING_); String sTag = "GetPackagePopular"; sTag.appendWithFormat("_%d", m_iConnectServer); if (sKey == sTag.getCString()) { if (pJsonDict != NULL) { cs::JsonDictionary* jsonData = pJsonDict->getSubDictionary("data"); if(jsonData != NULL) { if (jsonData->getItemBoolvalue("result", false)) { m_iTotalPackage = jsonData->getArrayItemCount("list"); m_maxHeight = m_iTotalPackage*120.0f; for(int iIndex=0; iIndex < m_iTotalPackage; iIndex++) { cs::JsonDictionary* pJsonItem = jsonData->getSubItemFromArray("list", iIndex); CSPackageInfo csPackageInfo; csPackageInfo.sPackageName = pJsonItem->getItemStringValue("WordListName"); csPackageInfo.sPackageCode = pJsonItem->getItemStringValue("PackageCode"); csPackageInfo.sCreatedBy = pJsonItem->getItemStringValue("Author"); csPackageInfo.iTotalWord = pJsonItem->getItemIntValue("TotalWords", 0); csPackageInfo.iTotalWordUnlock = 0; m_csPackageInfos.push_back(csPackageInfo); LabelBMFont *pLabelPackageName = LabelBMFont::create(csPackageInfo.sPackageName.c_str(), "fonts/font_small_alert.fnt", 310.0f); pLabelPackageName->setAnchorPoint(Point(0.0f, 0.5f)); pLabelPackageName->setPosition(Point(0.0f, -iIndex*120 - 10)); m_pSlideShow->addChild(pLabelPackageName); LabelTTF* pLabelTCreatedBy = LabelTTF::create(csPackageInfo.sCreatedBy.c_str(), "Arial", 28, Size(310.0f, 30.0f), TextHAlignment::LEFT, TextVAlignment::TOP); pLabelTCreatedBy->setColor(ccc3(255.0f, 255.0f, 255.0f)); pLabelTCreatedBy->setAnchorPoint(Point(0.0f, 0.5f)); pLabelTCreatedBy->setPosition(Point(0.0f, -iIndex*120 - 55)); m_pSlideShow->addChild(pLabelTCreatedBy); LabelBMFont *pLabelPackageCode = LabelBMFont::create(csPackageInfo.sPackageCode.c_str(), "fonts/font_score.fnt"); pLabelPackageCode->setAnchorPoint(Point(1.0f, 0.5f)); pLabelPackageCode->setPosition(Point(440.0f, -iIndex*120 - 10)); m_pSlideShow->addChild(pLabelPackageCode); char sTotalWord[20]; sprintf(sTotalWord, "%d Words", csPackageInfo.iTotalWord); LabelTTF* pLabelTotalWord = LabelTTF::create(sTotalWord, "Arial", 28); pLabelTotalWord->setColor(ccc3(255.0f, 255.0f, 255.0f)); pLabelTotalWord->setAnchorPoint(Point(1.0f, 0.5f)); pLabelTotalWord->setPosition(Point(420.0f, -iIndex*120 - 55)); m_pSlideShow->addChild(pLabelTotalWord); Sprite* pButtonPlayPackageImage = Sprite::create("AdvanceMode/download-icon.png"); ButtonNode* pButtonPlayPackage = ButtonNode::createButtonSprite(pButtonPlayPackageImage, CC_CALLBACK_1(AdvanceModePopularPackagesLayer::clickDownloadPackage, this)); pButtonPlayPackage->setTag(iIndex); pButtonPlayPackage->setPosition(Point(460.0f, -iIndex*120 - 35)); m_pSlideShow->addButtonNode(pButtonPlayPackage); Sprite* pLineImage = Sprite::create("AdvanceMode/line.png"); pLineImage->setPosition(Point(245.0f, -iIndex*120 -90.0f)); m_pSlideShow->addChild(pLineImage, 5); } } } } } }
bool FlashCardCollectionLayer::init() { if(!Layer::init()) { return false; } Sprite* pBackground = Sprite::create("FlashCard/background.png"); pBackground->setPosition(Point(320.0f, 480.0f)); this->addChild(pBackground); ButtonManagerNode* pButtonManagerNode = ButtonManagerNode::create(); this->addChild(pButtonManagerNode); Sprite* pIconFlashCard = Sprite::create("FlashCard/flashcard_icon_btn.png"); pIconFlashCard->setPosition(Point(-140.0f, 45.0f)); Sprite* pButtonMiniGameSprite = Sprite::create("FlashCard/minigame-countdown.png"); pButtonMiniGameSprite->addChild(pIconFlashCard); pButtonMiniGameSprite->setPosition(Point(154.0f, 0.0f)); ButtonNode* pButtonMiniGame = ButtonNode::createButtonSprite(pButtonMiniGameSprite, CC_CALLBACK_1(FlashCardCollectionLayer::clickPlayMiniGame, this)); pButtonMiniGame->setPosition(Point(320.0f, 810.0f)); pButtonManagerNode->addButtonNode(pButtonMiniGame); m_iWordNew = WordTable::getInstance()->getNumberWordNew(); m_iWordPlayMiniGame = WordTable::getInstance()->getNumberWordPlayMiniGame(getTimeLocalCurrent()); m_pLabelMiniGame = LabelTTF::create("MINI GAME", "Arial", 30); m_pLabelMiniGame->setColor(ccc3(255.0f, 255.0f, 255.0f)); m_pLabelMiniGame->setPosition(Point(148.0f, 47.0f)); pButtonMiniGameSprite->addChild(m_pLabelMiniGame); m_iTimeCountDown = 0; if (m_iWordPlayMiniGame < 1 && m_iWordNew > 0) { unsigned long uMinTime = WordTable::getInstance()->getMinTimeNextPlayMiniGame(); m_iTimeCountDown = uMinTime + _SECONDS_NEXT_PLAY_MINI_GAME_ - getTimeLocalCurrent(); if (m_iTimeCountDown > 0) { m_pLabelMiniGame->setString(formatHMSToDisplay(m_iTimeCountDown).getCString()); this->scheduleUpdate(); } } if (m_iWordNew > 0) { Sprite* pIconNew = Sprite::create("FlashCard/noitify_msg.png"); pIconNew->setPosition(Point(240.0f, 85.0f)); pButtonMiniGameSprite->addChild(pIconNew); char sNumberNew[10]; sprintf(sNumberNew, "%d", m_iWordNew); LabelTTF* pLabelNumber = LabelTTF::create(sNumberNew, "Arial", 25); pLabelNumber->setColor(ccc3(255.0f, 255.0f, 255.0f)); pLabelNumber->setPosition(Point(22.0f, 20.0f)); pIconNew->addChild(pLabelNumber); } Sprite* pBackgroundFlashcard = Sprite::create("FlashCard/panel-level_popup.png"); pBackgroundFlashcard->setPosition(Point(320.0f, 415.0f)); this->addChild(pBackgroundFlashcard); LabelBMFont *pLabelTitle = LabelBMFont::create("Flashcard Collection", "fonts/font-bechic.fnt"); pLabelTitle->setAnchorPoint(Point(0.5f, 0.5f)); pLabelTitle->setPosition(Point(320.0f, 673.0f)); this->addChild(pLabelTitle); m_pFooterNode = FooterNode::create(); m_pFooterNode->changeStatusButtonFlashcard(StatusButtonFlashcard::eNoClick); m_pFooterNode->removeBackground(); this->addChild(m_pFooterNode); HeaderNode* pHeaderNode = HeaderNode::create(); this->addChild(pHeaderNode); m_pSlideShow = ButtonManagerNode::create(); m_pSlideShow->AllowSwipingBackground(true); m_pSlideShow->setPosition(Point(245.0f, 300.0f)); ClipMaskNode* pClipMaskNode = ClipMaskNode::create(); pClipMaskNode->setPosition(Point(75.0f, 155.0f)); pClipMaskNode->setContentSize(Size(560.0f, 460.0f)); pClipMaskNode->addChild(m_pSlideShow); pBackgroundFlashcard->addChild(pClipMaskNode); ChapterTable::getInstance()->refreshChapters(); m_chapters = ChapterTable::getInstance()->getChaptersInfo(); WordlMapConfig worlMapConfig = GameConfigManager::getInstance()->GetWordlMapConfig(); int iCountIndex=0; for (int iIndex=0; iIndex<m_chapters.size(); iIndex++) { ChapterInfo chapterInfo = m_chapters[iIndex]; if(chapterInfo.bIsUnlock) { int iTotalFlashcardUnlock = chapterInfo.iTotalFlashCardUnlock; if (iTotalFlashcardUnlock > 0) { Sprite* pBackgroundItem = Sprite::create("FlashCard/panel_flashcard_chapter.png"); pBackgroundItem->setPosition(Point(0.0f, -iIndex*190)); m_pSlideShow->addChild(pBackgroundItem); int iIndexChapter = worlMapConfig.m_WorlMapChapterConfigMap[chapterInfo.sChapterId]; std::string sPath = worlMapConfig.m_WorlMapChapterConfigs[iIndexChapter].m_sPathData; sPath.append("/Flash-Card-icon.png"); Sprite* pIconChapter = Sprite::create(sPath.c_str()); ButtonNode* pButtonItem = ButtonNode::createButtonSprite(pIconChapter, CC_CALLBACK_1(FlashCardCollectionLayer::clickOpenFlashCard, this)); pButtonItem->setTag(iIndex); pButtonItem->setPosition(Point(-140.0f, -15 -iIndex*190)); m_pSlideShow->addButtonNode(pButtonItem); LabelBMFont* pLabelChapterName = LabelBMFont::create(worlMapConfig.m_WorlMapChapterConfigs[iIndexChapter].m_sChapterName.c_str(), "fonts/font_small_alert.fnt"); pLabelChapterName->setPosition(Point(90.0f, 18 -iIndex*190)); m_pSlideShow->addChild(pLabelChapterName); char sTotalFlashCard[10]; sprintf(sTotalFlashCard, "(%d/%d)", iTotalFlashcardUnlock, chapterInfo.iTotalFlashCard); LabelTTF* pLabelTotalFlashCard = LabelTTF::create(sTotalFlashCard, "Arial", 25); pLabelTotalFlashCard->setColor(ccc3(0.0f, 0.0f, 0.0f)); pLabelTotalFlashCard->setPosition(Point(90.0f, -18 -iIndex*190)); m_pSlideShow->addChild(pLabelTotalFlashCard); if (iTotalFlashcardUnlock >= 0) { Sprite* pButtonPlayReviseGameImage = Sprite::create("AdvanceMode/btn-play-advance-mode.png"); ButtonNode* pButtonPlayReviseGame = ButtonNode::createButtonSprite(pButtonPlayReviseGameImage, CC_CALLBACK_1(FlashCardCollectionLayer::clickPlayReviseGame, this)); pButtonPlayReviseGame->setTag(iIndex); pButtonPlayReviseGame->setPosition(Point(235.0f, -iIndex*190)); m_pSlideShow->addButtonNode(pButtonPlayReviseGame); } iCountIndex++; m_maxHeight = iCountIndex*190; } } } Breadcrumb::getInstance()->addSceneMode(SceneMode::kFlashCardCollection); this->setTouchEnabled(true); this->setTouchMode(Touch::DispatchMode::ONE_BY_ONE); m_pScrollManager = new ScrollManager(); return true; }