bool SportLayer::initWidgets4PanelSportTop(Layout* _sportTopLay) { bool bRet = false; do { UIWidget* bgSportRule = _sportTopLay->getChildByName("bg_top"); UITextButton* txtBtnSportTopWinRatetag = dynamic_cast<UITextButton*>(bgSportRule->getChildByName("txtBtn_top_win_rate_tag")); txtBtnSportTopWinRatetag->addReleaseEvent(this, coco_releaseselector(SportLayer::panelSportTopCallback)); txtBtnSportTopWinRatetag->setWidgetTag(sportTopWinRateTagBtnTag); UITextButton* txtBtnSportTopWinCnttag = dynamic_cast<UITextButton*>(bgSportRule->getChildByName("txtBtn_top_win_cnt_tag")); txtBtnSportTopWinCnttag->addReleaseEvent(this, coco_releaseselector(SportLayer::panelSportTopCallback)); txtBtnSportTopWinCnttag->setWidgetTag(sportTopWinCntTagBtnTag); UITextButton* txtBtnSportTopScoreTag = dynamic_cast<UITextButton*>(bgSportRule->getChildByName("txtBtn_top_score_tag")); txtBtnSportTopScoreTag->addReleaseEvent(this, coco_releaseselector(SportLayer::panelSportTopCallback)); txtBtnSportTopScoreTag->setWidgetTag(sportTopScoreTagBtnTag); UITextButton* txtBtnSportTopBack = dynamic_cast<UITextButton*>(bgSportRule->getChildByName("txtBtn_top_back")); txtBtnSportTopBack->addReleaseEvent(this, coco_releaseselector(SportLayer::panelSportTopCallback)); txtBtnSportTopBack->setWidgetTag(sportTopBackBtnTag); UITextButton* txtBtnSportTopPlayerNicknameTag = dynamic_cast<UITextButton*>(bgSportRule->getChildByName("txtBtn_player_nickname_tag")); txtBtnSportTopPlayerNicknameTag->addReleaseEvent(this, coco_releaseselector(SportLayer::panelSportTopCallback)); txtBtnSportTopPlayerNicknameTag->setWidgetTag(sportTopPlayerNicknameBtnTag); //friend list UIScrollView* scvwTopList = dynamic_cast<UIScrollView*>(bgSportRule->getChildByName("scvw_top_list")); CC_BREAK_IF(! scvwTopList); int itemCount = 10; //listitem CCString* name = CCString::createWithFormat("ui/SportUI/%s.json",m_allListItemNames->valueForKey(topListItem)->getCString() ); Layout* pListItem = dynamic_cast<Layout*>(CCUIHELPER->createWidgetFromJsonFile(name->getCString() )); CC_BREAK_IF(! pListItem); pListItem->setPosition(CCPointZero); scvwTopList->addChild(pListItem); CCSize scvwSize = scvwTopList->getInnerContainerSize(); scvwTopList->setInnerContainerSize(CCSizeMake(scvwSize.width, pListItem->getContentSize().height * itemCount)); for(int i=1; i<itemCount; i++){ pListItem = dynamic_cast<Layout*>(CCUIHELPER->createWidgetFromJsonFile(name->getCString() )); CC_BREAK_IF(! pListItem); pListItem->setPosition(ccp(0,i*(pListItem->getContentSize().height))); scvwTopList->addChild(pListItem); } bRet = true; } while (0); return bRet; }
bool SportLayer::initWidgets4PanelSportFriend(Layout* _sportFriendLay) { bool bRet = false; do { UIWidget* bgSportFriend = _sportFriendLay->getChildByName("bg_friend"); UITextButton* txtBtnSportFriendBack = dynamic_cast<UITextButton*>(bgSportFriend->getChildByName("txtBtn_friend_back")); txtBtnSportFriendBack->addReleaseEvent(this, coco_releaseselector(SportLayer::panelSportFriendCallback)); txtBtnSportFriendBack->setWidgetTag(sportFriendBackBtnTag); UITextButton* txtBtnSportFriendOLPlayerTag = dynamic_cast<UITextButton*>(bgSportFriend->getChildByName("txtBtn_friend_olplayer_tag")); txtBtnSportFriendOLPlayerTag->addReleaseEvent(this, coco_releaseselector(SportLayer::panelSportFriendCallback)); txtBtnSportFriendOLPlayerTag->setWidgetTag(sportFriendOLPlayerTagBtnTag); UITextButton* txtBtnSportFriendClubTag = dynamic_cast<UITextButton*>(bgSportFriend->getChildByName("txtBtn_friend_club_tag")); txtBtnSportFriendClubTag->addReleaseEvent(this, coco_releaseselector(SportLayer::panelSportFriendCallback)); txtBtnSportFriendClubTag->setWidgetTag(sportFriendClubTagBtnTag); UITextButton* txtBtnSportFriendFriendTag = dynamic_cast<UITextButton*>(bgSportFriend->getChildByName("txtBtn_friend_friend_tag")); txtBtnSportFriendFriendTag->addReleaseEvent(this, coco_releaseselector(SportLayer::panelSportFriendCallback)); txtBtnSportFriendFriendTag->setWidgetTag(sportFriendFriendTagBtnTag); //friend list UIScrollView* scvwFriendList = dynamic_cast<UIScrollView*>(bgSportFriend->getChildByName("scvw_friend_list")); //scvwFriendList->scrollToTop(); //listitem int itemCount = 10; CCString* name = CCString::createWithFormat("ui/SportUI/%s.json",m_allListItemNames->valueForKey(friendListItem)->getCString() ); Layout* pListItem = dynamic_cast<Layout*>(CCUIHELPER->createWidgetFromJsonFile(name->getCString() )); CC_BREAK_IF(! pListItem); pListItem->setPosition(CCPointZero); scvwFriendList->addChild(pListItem); CCSize scvwSize = scvwFriendList->getInnerContainerSize(); scvwFriendList->setInnerContainerSize(CCSizeMake(scvwSize.width, pListItem->getContentSize().height * itemCount)); for(int i=1; i<itemCount; i++){ pListItem = dynamic_cast<Layout*>(CCUIHELPER->createWidgetFromJsonFile(name->getCString() )); CC_BREAK_IF(! pListItem); pListItem->setPosition(ccp(0,i*(pListItem->getContentSize().height))); scvwFriendList->addChild(pListItem); } bRet = true; } while (0); return bRet; }
bool SportLayer::initWidgets4PanelSport(Layout* _sportLay) { bool bRet = false; do { //btn back UIWidget* bgSport = _sportLay->getChildByName("bg_sport"); UITextButton* txtBtnSportBack = dynamic_cast<UITextButton*>(bgSport->getChildByName("txtBtn_sport_back")); txtBtnSportBack->addReleaseEvent(this, coco_releaseselector(SportLayer::closeBtnCallBack)); //btn rule UITextButton* txtBtnSportRule = dynamic_cast<UITextButton*>(bgSport->getChildByName("txtBtn_sport_rule")); txtBtnSportRule->addReleaseEvent(this, coco_releaseselector(SportLayer::panelSportCallback)); txtBtnSportRule->setWidgetTag(sportRuleBtnTag); //btn start UITextButton* txtBtnSportStart = dynamic_cast<UITextButton*>(bgSport->getChildByName("txtBtn_sport_start")); txtBtnSportStart->addReleaseEvent(this, coco_releaseselector(SportLayer::panelSportCallback)); txtBtnSportStart->setWidgetTag(sportStartBtnTag); //btn top UITextButton* txtBtnSportTop = dynamic_cast<UITextButton*>(bgSport->getChildByName("txtBtn_sport_top")); txtBtnSportTop->addReleaseEvent(this, coco_releaseselector(SportLayer::panelSportCallback)); txtBtnSportTop->setWidgetTag(sportTopBtnTag); //btn clear UITextButton* txtBtnSportClear = dynamic_cast<UITextButton*>(bgSport->getChildByName("txtBtn_sport_clear")); txtBtnSportClear->addReleaseEvent(this, coco_releaseselector(SportLayer::panelSportCallback)); txtBtnSportClear->setWidgetTag(sportClearBtnTag); //btn sport reward obtain UIWidget* bgSportReward = bgSport->getChildByName("bg_sport_reward"); UITextButton* txtBtnRewardObtain = dynamic_cast<UITextButton*>(bgSportReward->getChildByName("txtBtn_reward_obtain")); txtBtnRewardObtain->addReleaseEvent(this, coco_releaseselector(SportLayer::panelSportCallback)); txtBtnRewardObtain->setWidgetTag(sportRewardObtainBtnTag); //btn sport player seat invite UIWidget* bgSportPlayerSeat = bgSport->getChildByName("bg_sport_player_seat"); UIButton* txtBtnSeatInvite = dynamic_cast<UIButton*>(bgSportPlayerSeat->getChildByName("btn_seat_invite")); txtBtnSeatInvite->addReleaseEvent(this, coco_releaseselector(SportLayer::panelSportCallback)); txtBtnSeatInvite->setWidgetTag(sportPlayerSeatInivteBtnTag); bRet = true; } while (0); return bRet; }
bool SportLayer::initWidgets4PanelSportRule(Layout* _sportRuleLay) { bool bRet = false; do { UIWidget* bgSportRule = _sportRuleLay->getChildByName("bg_rule"); UITextButton* txtBtnSportRuleBack = dynamic_cast<UITextButton*>(bgSportRule->getChildByName("txtBtn_rule_back")); txtBtnSportRuleBack->addReleaseEvent(this, coco_releaseselector(SportLayer::panelSportRuleCallback)); txtBtnSportRuleBack->setWidgetTag(sportRuleBackBtnTag); bRet = true; } while (0); return bRet; }