Example #1
0
CCTableViewCell* TanSuoLayer::tableCellAtIndex(CCTableView *table, unsigned int idx)
{
	CCTableViewCell *cell = table->dequeueCell();
	if (cell != NULL)
	{
		cell->removeAllChildren();
	}
	else 
	{
		cell = new CCTableViewCell();
		cell->autorelease();
	}

	if (table->getParent() != NULL)
	{
		CCSize cellSize = tableCellSizeForIndex(table, idx);
		Profession profId = mHeros.at(idx)->getCurrentProperty().profession;

		//head  Profession 1-10
		BaseSprite *headImg = BaseSprite::create(ImageManager::getManager()->getImageData_ProfessionHead(profId).getCurrentImageFile());
		cell->addChild(headImg);
		headImg->setPosition(ccp(cellSize.width/2, 92));

		//menu
		FXScrollMenu *menu = FXScrollMenu::create(
			table->getParent()->convertToWorldSpace(table->getPosition()), table->getViewSize());
		cell->addChild(menu, 1);
		menu->setPosition(ccp(0,0));
		CCMenuItemImage *item = CCMenuItemImage::create(
			"renxing_renwu_touxiang.png",
			"renxing_renwu_touxiang_select.png", 
			"renxing_renwu_touxiang_select.png", 
			this, menu_selector(TanSuoLayer::menuItemClicked_JieFenHeroSelect));
		menu->addChild(item, 0, profId);

		m_lMenuItemList.push_back(item);

		item->setPosition(headImg->getPosition());
		//name
		CCLabelTTF *nameLabel = CCLabelTTF::create(BaseActorPropertyParser::getParser()->getExtraProerty(profId).nameInChinese.c_str()
			, fontStr_kaiti, m_nFontSize);
		cell->addChild(nameLabel);
		nameLabel->setPosition(ccp(headImg->getPositionX()
			, headImg->getPositionY()-headImg->getContentSize().height/2-nameLabel->getContentSize().height/2));
		nameLabel->setColor(ccc3(195, 145, 96));
	}

	return cell;
}
Example #2
0
CCTableViewCell* RankingScene::tableCellAtIndex(CCTableView *table, unsigned int idx) {
	CCSize size = CCDirector::sharedDirector()->getWinSize();
    CCTableViewCell *cell = table->dequeueCell();
    cell = new CCTableViewCell();
    cell->autorelease();
    
    // Player Point
    Player * p = (Player*)players->objectAtIndex(idx);
    CCString *string = CCString::createWithFormat("%d",p->getPoint());

    CCLabelTTF *Pointlabel = CCLabelTTF::create(string->getCString(), "Helvetica", 40);
    Pointlabel->setAnchorPoint(ccp(1, 0));
    Pointlabel->setPosition(ccp(600,0));
    Pointlabel->setTag(123);
    cell->addChild(Pointlabel);
    
    // Player Name
    std::string name = p->getName();

    CCLabelTTF *Namelabel = CCLabelTTF::create(p->getName().c_str(), "Helvetica", 40);
    Namelabel->setAnchorPoint(CCPointZero);
    Namelabel->setPosition(ccp(60, 0));
    cell->addChild(Namelabel);
    
    // Player Rank
    char rankBuf[3];
    sprintf(rankBuf, "Numbers/%i.png", idx+1);
    CCSprite *rank = CCSprite::create(rankBuf);
    rank->setAnchorPoint(CCPointZero);
    rank->setPosition(CCPointZero);
    cell->addChild(rank);
    
    if (idx == 0) {
        int rewardLocal = GameManager::sharedGameManager()->getReward();
        std::string nameLocal = GameManager::sharedGameManager()->getName();
        int pointMax = CCUserDefault::sharedUserDefault()->getIntegerForKey("pointMax");
        if (p->getReward() != 0 && rewardLocal != 0 &&
            p->getName() == nameLocal && p->getPoint() == pointMax) {
            CCMenuItemImage *bt_send_email =
                CCMenuItemImage::create("Present.png","PresentOnClicked.png",
                                        this, menu_selector(RankingScene::reward));
            CCMenu * menu = CCMenu::create(bt_send_email, NULL);
            menu->setPosition(ccp(550, 30));
            cell->addChild(menu);
        }
    }
    return cell;
}
Example #3
0
CCTableViewCell* ListViewLayer::tableCellAtIndex(CCTableView *table, unsigned int idx)
{
	CCTableViewCell *cell = table->dequeueCell();
	if (cell == NULL) {
		cell = new CCTableViewCell();
		cell->autorelease();

		if (mSource.creator)
		{
			CCNode* item = mSource.creator->getItemContentByIndex(idx);

			// 包裹
			CCNode* wraped = CCNode::create();
			wraped->setContentSize(item->getContentSize());
			wraped->addChild(item,0);

			// 有个0.5,0.5的偏移
			wraped->setPosition(ccp(wraped->getContentSize().width/2,wraped->getContentSize().height/2));

			cell->addChild(wraped,0,TAG_LIST_CELL_ITEM_WRAP);
		}else
		{
			CCAssert(false,"");
		}

		CCLog("ListViewLayer::tableCellAtIndex ---> create!");
	}
	else
	{
		CCLog("ListViewLayer::tableCellAtIndex ---> refesh!");

		CCNode* warped = cell->getChildByTag(TAG_LIST_CELL_ITEM_WRAP);
		CCNode* item = (CCNode*)warped->getChildren()->objectAtIndex(0);

		if (mSource.creator)
		{
			mSource.creator->refreshItem(item,idx);
		}else
		{
			CCAssert(false,"");
		}
	}

	return cell;
}
Example #4
0
CCTableViewCell * equipmentRoom:: tableCellAtIndex (CCTableView * table, unsigned int idx)
{
    CCString* string;
    char tc_label[30];
    int contentID = 0;
    
        sprintf(tc_label,"%s", equipmentList[idx]->m_name.c_str());
        //string = CCString::create(m_buttons[idx].label);
        string = CCString::create(tc_label);
        
        //cout << idx << "script name = " << string->getCString() << endl;
       //cout << "author1 = " << scriptVector[idx]->authorNames[0] << endl;
    
   
    CCTableViewCell *cell;// = table->dequeueCell();
    //if (!cell) {
        cell = new CustomTableViewCell();
        cell->autorelease();
        CCSprite *sprite = CCSprite::create("grey_cell.png");
        sprite->setAnchorPoint(CCPointZero);
        sprite->setPosition(ccp(0, 0));
        sprite->setScaleX(sfx);
        sprite->setScaleY(sfy);
        sprite->setTag(4);
        cell->addChild(sprite);
        cell->setObjectID(idx);
        CCLabelTTF *label = CCLabelTTF::create(string->getCString(), "Helvetica", 12.0);
        label->setPosition(ccp(sprite->boundingBox().size.width/2, sprite->boundingBox().size.height/2));
		label->setAnchorPoint(ccp(0.5, 0.5));
        //label->setPosition(CCPointZero);
		//label->setAnchorPoint(CCPointZero);
        label->setTag(123);
        cell->addChild(label);
    //}
    /*else
    {
        CCLabelTTF *label = (CCLabelTTF*)cell->getChildByTag(123);
        label->setString(string->getCString());
    }*/
    cout << "cell # " << idx << "title = " << string->getCString() << endl;
    return cell;
    
    
}
Example #5
0
CCTableViewCell* IOSStoreLayer::tableCellAtIndex(CCTableView *table, unsigned int idx)
{
	CCTableViewCell *cell = table->dequeueCell();
	if (cell)
	{
		cell->removeAllChildren();
	}
	else
	{
		cell = new CCTableViewCell;
		cell->autorelease();
	}

	//根据标签来初创建不同的cell
	CCSprite* pDaoju = NULL;
	if (table->getTag() == kaibaoxiang_node_tableview_tag)
	{
		if (idx >= 0 && (int)idx < m_iBaoxiangCellCount)
		{
			pDaoju = this->createCellSpr(idx, &m_baoxiangInfoVector.at(idx));
		}
	}
	else
	{
		if (idx >= 0 && (int)idx < m_iBuyStarCellCount)
		{
			pDaoju = this->createCellSpr(idx, &m_buystarInfoVector.at(idx));
		}
	}

	if (pDaoju)
	{
		pDaoju->setPosition(CCPointZero);
		if (idx == 0)
		{
			pDaoju->setPosition(ccp(10, 0));
		}
		pDaoju->setAnchorPoint(ccp(0,0));
		cell->addChild(pDaoju);
	}

	return cell;
}
CCTableViewCell* EXMainMenuScene::tableCellAtIndex(CCTableView *table, unsigned int idx)
{
    CCString *string = (CCString*)m_listData->objectAtIndex(idx);
    CCTableViewCell *cell = table->dequeueCell();
    if (!cell) {
        cell = new CCTableViewCell();
        cell->autorelease();
        CCLabelTTF *label = CCLabelTTF::create(string->getCString(), "Helvetica", 20.0);
        label->setPosition(ccp(m_winSize.width * .5, 30));
        label->setTag(123);
        cell->addChild(label);
    }
    else
    {
        CCLabelTTF *label = (CCLabelTTF*)cell->getChildByTag(123);
        label->setString(string->getCString());
    }
    
    
    return cell;
}
CCTableViewCell* MainLayerZhuangBeiBaseBody::tableCellAtIndex(CCTableView *table, unsigned int idx)
{
    CCString *string = CCString::createWithFormat("%d", idx);
    CCTableViewCell *cell = table->dequeueCell();
    if (cell == NULL)
    {
        cell = new CCTableViewCell();
        cell->autorelease();
    }
    else
    {
        cell->removeAllChildren();
    }

    if (table != mTableView) return cell;

    cell->addChild(getItemContentByIndex(idx),0,TAG_EquipBaseBody_TABLE_ITEM);

    return cell;

}
Example #8
0
CCTableViewCell* RPGBattleMenu::tableCellAtIndex(CCTableView *tableView, unsigned int idx)
{
    CCTableViewCell *cell = tableView->dequeueCell();
    if (!cell)
    {
        cell = new CCTableViewCell();
        cell->autorelease();
    }
    else
        cell->removeAllChildrenWithCleanup(true);
    
    if(dynamic_cast<RPGSkillBtnData*>(this->m_tableItems->objectAtIndex(idx)) != NULL)
    {
        //点击了技能项
        RPGSkillBtnData *itemsData = (RPGSkillBtnData*)this->m_tableItems->objectAtIndex(idx);
        
        CCControlButton *itemBtn = CCControlButton::create(CCString::createWithFormat("%s (%i)", itemsData->m_name.c_str(), itemsData->m_MP)->getCString(), "Arial", 22);
        itemBtn->setPosition(ccp(tableView->getContentSize().width / 2, 0));
        itemBtn->setTag(itemsData->m_dataId);
        itemBtn->addTargetWithActionForControlEvents(this, cccontrol_selector(RPGBattleMenu::onButton), CCControlEventTouchUpInside);
        cell->addChild(itemBtn);
        
    }
    else if(dynamic_cast<RPGExistingItems*>(this->m_tableItems->objectAtIndex(idx)) != NULL)
    {
        //点击了道具项
        
        RPGExistingItems *itemsData = (RPGExistingItems*)this->m_tableItems->objectAtIndex(idx);
        
        CCControlButton *itemBtn = CCControlButton::create(CCString::createWithFormat("%s (%i)", itemsData->m_name.c_str(), itemsData->m_total)->getCString(), "Arial", 22);
        itemBtn->setPosition(ccp(tableView->getContentSize().width / 2, 0));
        itemBtn->setTag(itemsData->m_dataId);
        itemBtn->addTargetWithActionForControlEvents(this, cccontrol_selector(RPGBattleMenu::onButton), CCControlEventTouchUpInside);
        cell->addChild(itemBtn);
        
    }
    
    return cell;
}
Example #9
0
CCTableViewCell* MainScene::tableCellAtIndex(CCTableView *table, unsigned int idx)
{
    CCString *string = CCString::createWithFormat("%d", idx);
    CCTableViewCell *cell = table->dequeueCell();
    if (!cell) {
        cell = new CCTableViewCell();
        cell->autorelease();
        CCSprite *sprite = CCSprite::create("Icon-144.png");
        sprite->setAnchorPoint(CCPointZero);
        sprite->setPosition(ccp(0, 0));
        sprite->setScaleX(2);
        cell->addChild(sprite);
        
        CCLabelTTF *label = CCLabelTTF::create(string->getCString(), "Helvetica", 20.0);
        label->setPosition(CCPointZero);
        label->setAnchorPoint(CCPointZero);
        label->setTag(123);
        cell->addChild(label);
        
        CCMenuItemImage *pBtn = CCMenuItemImage::create(
                                                        "CloseNormal.png",
                                                        "CloseSelected.png",
                                                        this,
                                                        menu_selector(MainScene::tableViewSubBtnCallback));
        CCMenu* pMenu = CCMenu::create(pBtn, NULL);
        pBtn->setPosition(ccp(pBtn->getContentSize().width/2,pBtn->getContentSize().height/2));
        pMenu->setPosition(CCPointZero);
        cell->addChild(pMenu, 1);
        cell->setTag(idx);
    }
    else
    {
        CCLabelTTF *label = (CCLabelTTF*)cell->getChildByTag(123);
        label->setString(string->getCString());
    }

    
    return cell;
}
Example #10
0
CCTableViewCell* S3PracticeScene::tableCellAtIndex(CCTableView *table, unsigned int idx)
{
//    CCString *strCell = CCString::createWithFormat("Practice %d",idx);
    CCString *strCell = CCString::create(aVectorCellValue[idx].c_str());
    CCTableViewCell *pCell = table->dequeueCell();
    if (!pCell) {
        pCell = new CCTableViewCell();
        pCell->autorelease();
        CCSprite *pSprite = CCSprite::create();//("cellLine.png");
        pSprite->setAnchorPoint(CCPointZero);
		pSprite->setPosition(CCPointZero);
        pCell->addChild(pSprite);
        
        {
            CCLabelTTF *pLabel = CCLabelTTF::create(strCell->getCString(), "Arial", s3FontSize3_macro, s3Size2_macro(aCell), kCCTextAlignmentLeft, kCCVerticalTextAlignmentCenter);
            pLabel->setPosition(ccp(s3Less2_macro,0));
            pLabel->setAnchorPoint(CCPointZero);
            pLabel->setColor(ccc3(0,0,0));
            pLabel->setTag(10);
            pCell->addChild(pLabel,1);
        }
        
        {
            CCLabelTTF *pLabel = CCLabelTTF::create("Locked", "Arial",s3FontSize3_macro, s3SizeCellLaterLabel_macro, kCCTextAlignmentRight, kCCVerticalTextAlignmentCenter);
            pLabel->setPosition(s3Position8_macro(aItem));
            pLabel->setAnchorPoint(CCPointZero);
            pLabel->setColor(ccc3(0,0,255));
            pLabel->setTag(10);
            pCell->addChild(pLabel,1);
        }
        
    }
    
    CCLabelTTF *pLabel = (CCLabelTTF*)pCell->getChildByTag(10);
    pLabel->setString(strCell->getCString());
    
    return pCell;
}
Example #11
0
CCTableViewCell* HelloWorld::tableCellAtIndex(CCTableView *table, unsigned int idx)
{
    CCDictionary* pRecipe = (CCDictionary*)m_pRecipes->objectAtIndex(idx);
    CCString* pName = (CCString*)pRecipe->objectForKey("name");
    CCString* pNo   = (CCString*)pRecipe->objectForKey("recipe");
    CCString* pStep = (CCString*)pRecipe->objectForKey("step");
    
    CCString* string;
    if (pStep!=NULL) {
        string = CCString::createWithFormat("レシピ %s (ステップ%s): %s", pNo->getCString(), pStep->getCString(), pName->getCString());
    } else if (pNo->isEqual(CCString::create("0"))) {
        string = pName;
    } else {
        string = CCString::createWithFormat("レシピ %s : %s", pNo->getCString(), pName->getCString());
    }
    CCTableViewCell *cell = table->dequeueCell();
    if (!cell) {
        cell = new CCTableViewCell();
        cell->autorelease();
        
        CCSize visibleSize = CCDirector::sharedDirector()->getVisibleSize();
        
        int fontSize = CCEGLView::sharedOpenGLView()->getDesignResolutionSize().height/320.0f * 20;
        CCLabelTTF *label = CCLabelTTF::create(string->getCString(), "Helvetica", fontSize, CCSizeMake(visibleSize.width, visibleSize.height/5), kCCTextAlignmentCenter);
        label->setPosition(CCPointZero);
		label->setAnchorPoint(CCPointZero);
        label->setTag(123);
        cell->addChild(label);
    }
    else
    {
        CCLabelTTF *label = (CCLabelTTF*)cell->getChildByTag(123);
        label->setString(string->getCString());
    }
    
    
    return cell;
}
Example #12
0
CCTableViewCell* AchieveLayer::tableCellAtIndex(CCTableView *table, unsigned int idx){
    CCTableViewCell *cell = table->dequeueCell();
    if (true){
        cell = new CCTableViewCell();
        cell->autorelease();
        
        CCSprite* bar=CCSprite::createWithSpriteFrameName("achieve_hengtiao2.png");
        bar->setPosition(ccp(291, 53));
        
        float barHeight=bar->getContentSize().height;
        if (idx>=kAchieveXZDW&&idx<=kAchieveCSJJ) {
            CCSprite* huizhang=CCSprite::createWithSpriteFrameName("achieve_huizhang.png");
            huizhang->setPosition(S_RM->getRelativePosition("achieve_huizhang", barHeight));
            bar->addChild(huizhang);
            
            CCString* str=CCString::createWithFormat("%s.png",achieveStruts[idx].text.c_str());
            CCSprite* text=CCSprite::createWithSpriteFrameName(str->getCString());
            text->setPosition(S_RM->getRelativePosition("achieve_text", barHeight));
            bar->addChild(text);
            
            for (int i=1; i<6; i++) {
                CCString* str;
                if (i<S_AEM->achieveLevel((AchieveKey)idx)+1) {
                    str=CCString::createWithFormat("%s_%d.png",achieveStruts[idx].icon.c_str(),i);
                }else{
                    str=CCString::createWithFormat("%s_yinying.png",achieveStruts[idx].icon.c_str());
                }
                CCSprite* item=CCSprite::createWithSpriteFrameName(str->getCString());
                CCString* point=CCString::createWithFormat("achieve_item%d",i);
                item->setPosition(S_RM->getRelativePosition(point->getCString(), barHeight));
                bar->addChild(item);
            }
            
        }
        cell->addChild(bar);
    }
    return cell;
}
CCTableViewCell* MessageTableLayer::tableCellAtIndex(CCTableView *table, unsigned int idx){
    CCTableViewCell *cell = table->dequeueCell();
    if (true){
        cell = new CCTableViewCell();
        cell->autorelease();
        
        float cellHeight=S_RM->getSizeWithName("dialog_table_cell_size").height;
        CCPoint middlePoint=S_RM->getRelativePosition("dialog_table_middle", cellHeight);
        if (m_messageVector->size()==0) {
            CCSprite* jiazai=CCSprite::createWithSpriteFrameName("jiazai.png");
            jiazai->setPosition(middlePoint);
            jiazai->runAction(CCRepeatForever::create(CCRotateBy::create(2, 360)));
            cell->addChild(jiazai);
        }else{
            Message* message=(*m_messageVector)[idx];
            
            float cellHeight=S_RM->getSizeWithName("dialog_table_cell_size").height;
            
            CCSprite* bg=CCSprite::createWithSpriteFrameName("rank_bg.png");
            bg->setPosition(middlePoint);
            
            CCLabelTTF* title=CCLabelTTF::create(message->gettitle().c_str(), "KaiTi.ttf",25,S_RM->getSizeWithName("dialog_table_message_title"),kCCTextAlignmentLeft,kCCVerticalTextAlignmentCenter);
            if (message->getisReaded()==1) {
                title->setColor(ccGRAY);
            }else{
                title->setColor(ccBLUE);
                title->setFontSize(27);
                title->enableShadow(CCSizeMake(2, 2), 1, 1);
            }
            
            title->setPosition(S_RM->getRelativePosition("dialog_table_message_title", cellHeight));
            bg->addChild(title);
            
            cell->addChild(bg);
        }
    }
    return cell;
}
CCTableViewCell* TableViewTestLayer::tableCellAtIndex(CCTableView *table, unsigned int idx)
{
    CCString *string = CCString::createWithFormat("%d", idx);
    CCTableViewCell *cell = table->dequeueCell();
    if (!cell) {
        cell = new CCTableViewCell();
        cell->autorelease();
        CCSprite *sprite = CCSprite::create("HelloWorld.png");
		sprite->setScale(0.2f);
        sprite->setPosition(ccp(60, 60));
		sprite->setTag(123);
        cell->addChild(sprite);
        CCLabelTTF *label = CCLabelTTF::create(string->getCString(), "Arial", 20.0);
        label->setPosition(ccp(60,10));
        label->setTag(456);
        cell->addChild(label);
    }
    else
    {
        CCLabelTTF *label = (CCLabelTTF*)cell->getChildByTag(456);
        label->setString(string->getCString());
    }
    return cell;
}
Example #15
0
CCTableViewCell* MallMarkets::tableCellAtIndex(cocos2d::extension::CCTableView *table, unsigned int idx)
{
    
    //CCSize winSize = CCDirector::sharedDirector()->getWinSize();
    CCSize tableCellSize = CCSizeMake(1136, 100);
    CCTableViewCell *pCell = table->dequeueCell();
    
    string temp = this->coinImageName[idx];
    string imagePath = writablePathLocal+temp;
    
    
    CCSprite *prizePicture = CCSprite::create(imagePath.c_str());
    prizePicture->setAnchorPoint(CCPointZero);
    prizePicture->setPosition(ccp(20, 60));
    prizePicture->setScale(1);
    prizePicture->setTag(122);
    //pCell->addChild(prizePicture);
    
    if (!pCell) {
        
        pCell = new CCTableViewCell();
        pCell->autorelease();
        
        
        //1.表格背景ZF_Shoot_Button_gridItem
        CCSprite *pSprite = CCSprite::create("ZF_Shoot_Button_gridItem.png");
        pSprite->setAnchorPoint(CCPointZero);
        pSprite->setPosition(CCPointZero);
        pSprite->setScale(1);
        pCell->addChild(pSprite);
        
        
        //2.prizePicture
        
        pCell->removeChildByTag(122);
        pCell->addChild(prizePicture);
        
        
        //3.coinName
        CCLabelTTF *pLabeName = CCLabelTTF::create(this->coinName[idx].c_str(), "Arial", 28);
        pLabeName->setPosition(ccp(20, 10));
        pLabeName->setColor(ccc3(88, 88, 88));
        pLabeName->setAnchorPoint(CCPointZero);
        pLabeName->setTag(123);
        pCell->addChild(pLabeName);
        
        
        
        //4.prizePrice
        char priceChar[11];
        sprintf(priceChar, "%d",this->coinListPrice[idx]);
        string t1 = "¥";
        t1 = t1 + priceChar;
        CCLabelTTF *pLabelPrice = CCLabelTTF::create(t1.c_str(), "Arial", 28);
        pLabelPrice->setPosition(ccp(tableCellSize.width*0.37, tableCellSize.height*0.8));
        pLabelPrice->setAnchorPoint(CCPointZero);
        pLabelPrice->setTag(124);
        pLabelPrice->setColor(ccc3(250, 131, 26));
        pCell->addChild(pLabelPrice);
        
        
        //5.购买
        CCMenuItemImage *itemImage = CCMenuItemImage::create("ZF_Shoot_button_coinList_buy1.png", "ZF_Shoot_button_coinList_buy2.png", this, menu_selector(MallMarkets::menuItemCall2));
        if (itemImage->getTag() == -1) {
            itemImage->setTag(idx);
        }
        itemImage->setPosition(ccp(tableCellSize.width*0.4, tableCellSize.height*0.42));
        CCMenu *menu = CCMenu::create(itemImage,NULL);
        menu->setPosition(CCPointZero);
        pCell->addChild(menu, 1);
        
        
    }else{
        
        
        pCell->removeChildByTag(122);
        pCell->addChild(prizePicture);
        
        
        CCLabelTTF *pLabeName = (CCLabelTTF*)pCell->getChildByTag(123);
        pLabeName->setString(this->coinName[idx].c_str());
        
        
        char priceChar[11];
        sprintf(priceChar, "%d",this->coinListPrice[idx]);
        string t1 = "¥";
        //string t2 = "元人民币";
        //t1 = t1 + priceChar + t2;
        t1 = t1 + priceChar;
        CCLabelTTF *pLabelPrice = (CCLabelTTF*)pCell->getChildByTag(124);
        pLabelPrice->setString(t1.c_str());
        
        
    }
    return pCell;
}
Example #16
0
CCTableViewCell* RequestList::tableCellAtIndex(CCTableView *table, unsigned int idx)
{
    int index = idx;    
    EziFBIncomingRequest* fbRequest = (EziFBIncomingRequest*)_fbIncomingRequestList->objectAtIndex(index);
    EziFacebookFriend* sender       = fbRequest->getSender();
    
    const char* senderName = sender->getName();
    
    // Create the fancy test.
    EziSocialWrapperNS::FB_REQUEST::TYPE requestType = fbRequest->getRequestType();
    std::string messageToDisplay = "";
    
    switch (requestType)
    {
        case EziSocialWrapperNS::FB_REQUEST::REQUEST_INVITE:
            messageToDisplay.append(senderName).append(" has sent invitation to you.");
            break;

        case EziSocialWrapperNS::FB_REQUEST::REQUEST_GIFT:
            messageToDisplay.append(senderName).append(" has sent gift to you.");
            break;

        case EziSocialWrapperNS::FB_REQUEST::REQUEST_CHALLENGE:
            messageToDisplay.append(senderName).append(" has challenged to you.");
            break;
            
        default:
            messageToDisplay.append("Unknown message");
            break;
    }
    
    // Means users have already used this request.
    bool requestConsumed = fbRequest->isConsumed();
    
    CCSprite* profilePic            = NULL;
    ccColor4B bgColor = ccc4(20, 0, 40, 255);
    
    if (requestConsumed == false)
    {
        bgColor = ccc4(50, 50, 20, 255);
    }

    
    // Build the table cell.
    CCTableViewCell *cell = table->dequeueCell();
    
    if (cell == NULL)
    {
        cell = new CCTableViewCell();
        cell->autorelease();

                
        // Create the back layer of the cell.
        CCLayerColor* colorLayer = CCLayerColor::create(bgColor, SCREEN_WIDTH, CELL_HEIGHT);
        colorLayer->setTag(BACKGROUND_TAG);
        
        cell->addChild(colorLayer);
        
        // Get the sender profile picture path. Create it if path is available.
        if (sender != NULL && strcmp(sender->getPhotoPath(), "") != 0)
        {
            const char*  picPath = sender->getPhotoPath();
            profilePic = CCSprite::create(picPath);
        }
        else
        {
            profilePic = CCSprite::create(FB_DEFAULT_PHOTO);
        }

        // Add the profile pic to the cell row.
        profilePic->setAnchorPoint(ccp(0, 0.5));
        profilePic->setPosition(ccp(20, CELL_HEIGHT/2));
        cell->addChild(profilePic);
        profilePic->setTag(FRIEND_PHOTO_TAG);
        
        // Set the message.
        CCLabelTTF *messageLabel = CCLabelTTF::create(messageToDisplay.c_str(), "Helvetica", 20.0 * MENU_FONT_SCALE);
        messageLabel->setAnchorPoint(ccp(0, 0.5));
        messageLabel->setPosition(ccp(20 + 20 + profilePic->getContentSize().width, CELL_HEIGHT/2));
        messageLabel->setTag(REQUEST_MESSAGE_LABEL_TAG);
        messageLabel->setDimensions(CCSizeMake(SCREEN_WIDTH - (profilePic->getContentSize().width * 2) - 60, CELL_HEIGHT-5));
        messageLabel->setHorizontalAlignment(kCCTextAlignmentLeft);
        cell->addChild(messageLabel);

        CCMenuItemImage* constumeItemButton = NULL;
        constumeItemButton = CCMenuItemImage::create("use.png", "use_pressed.png");
        

        constumeItemButton->setTag(idx);
        constumeItemButton->setTarget(this, menu_selector(RequestList::useItem));
        constumeItemButton->setScale(SCALE_FACTOR * 0.8);
        constumeItemButton->setTag(FRIEND_CONSUME_BUTTON_TAG);
        
        CCMenu* consumeMenu = CCMenu::create(constumeItemButton, NULL);
        consumeMenu->setTag(FRIEND_CONSUME_MENU_TAG);
        consumeMenu->setPosition(ccp(SCREEN_WIDTH - (constumeItemButton->getContentSize().width*SCALE_FACTOR*0.4),
                                       (CELL_HEIGHT - (constumeItemButton->getContentSize().height)*SCALE_FACTOR*0.4)));
        
        
        cell->addChild(consumeMenu);
        
        
    }
    else
    {
        // Refresh the cell data based upon idx.
        
        // 1. Refresh the profile picture.
        CCSprite* cellProfilePic = (CCSprite*)cell->getChildByTag(FRIEND_PHOTO_TAG);
        
        if (strcmp("", sender->getPhotoPath()) != 0 )
        {
            const char*  picPath = sender->getPhotoPath();
            profilePic = CCSprite::create(picPath);
            
        }
        else
        {
            profilePic = CCSprite::create(FB_DEFAULT_PHOTO);
        }
        
        cellProfilePic->setTexture(profilePic->getTexture());
        
        // Update the message Label.
        CCLabelTTF *messageLabel = (CCLabelTTF*)cell->getChildByTag(REQUEST_MESSAGE_LABEL_TAG);
        messageLabel->setString(messageToDisplay.c_str());
        
        CCMenu* consumeMenu = (CCMenu*)cell->getChildByTag(FRIEND_CONSUME_MENU_TAG);
        
        CCArray* children = consumeMenu->getChildren();
        
        if (children)
        {
            CCMenuItemImage* consumenButton = (CCMenuItemImage*)children->objectAtIndex(0);
            
            if (consumenButton)
            {
                consumenButton->setTag(index);
            }
            else
            {
                CCLOG("No Consume Button");
            }
            
        }
        
        CCLayerColor* bgLayer = (CCLayerColor*)cell->getChildByTag(BACKGROUND_TAG);
        bgLayer->setColor(ccc3(bgColor.r, bgColor.g, bgColor.b));
    }
    
    return cell;
    
}
Example #17
0
CCTableViewCell* KapianTableLayer::tableCellAtIndex(CCTableView *table, unsigned int idx)
{
    if (m_kapianVector->size()==0) {
        //没有元素
        CCTableViewCell* cell = new CCTableViewCell();
        cell->autorelease();
        CCLabelTTF* txtLabel = CCLabelTTF::create("还没有收集到卡片哦~", "KaiTi.ttf", 40.0);
        txtLabel->setColor(ccc3(0, 0, 0));
        txtLabel->setPosition(ccp(500,0));
        cell->addChild(txtLabel);
        return cell;
    }
    
    CCTableViewCell *cell = table->dequeueCell();
    if (true){
//  if (!cell){
        cell = new CCTableViewCell();
        cell->autorelease();
        
        for (int i=0; i<COLUMN_NUMBER; i++) {
            int index=idx*COLUMN_NUMBER+i;
            if (index>=m_kapianVector->size()) {
                break;//最后一行判断
            }
            
            CCSprite* gridCell=CCSprite::create();
            
            //设置卡片
            CCPoint cardPoint=S_RM->getRelativePosition("kapiankuang_in_cell",m_gridSize.height);
            
            Kapian* kapian=(*m_kapianVector)[index];
            switch (m_dataMode) {
                case kHanzi:{
                    CCSprite* wenzikuang=CCSprite::createWithSpriteFrameName("wenzikuang_1.png");
                    wenzikuang->setPosition(cardPoint);//相对于cell设置坐标
                    gridCell->addChild(wenzikuang);
                    
                    CCLabelTTF* txtLabel = CCLabelTTF::create(kapian->getText().c_str(), "KaiTi.ttf", 80.0);
                    if (kapian->getisCollected()) {
                        txtLabel->setColor(ccc3(0, 0, 0));
                    }else{
                        txtLabel->setColor(ccc3(200, 200, 200));
                    }
                    txtLabel->setPosition(cardPoint);
                    txtLabel->setTag(CARD_CONTENT_TAG);
                    gridCell->addChild(txtLabel);
                    
                    CCPoint midPoint=S_RM->getRelativePosition("kapian_jindu_in_cell",m_gridSize.height);
                    Hanzi* hanzi=(Hanzi*)kapian;
                    int starCount=hanzi->getwriteCount();
                    if (starCount>3) {
                        CCSprite* star=CCSprite::createWithSpriteFrameName("kapian_xingxing_1.png");
                        star->setPosition(ccpAdd(midPoint, ccp(-40, 0)));
                        gridCell->addChild(star);
                        
                        CCLabelTTF* x = CCLabelTTF::create("X", "Helvetica", 20.0);
                        x->setColor(ccc3(255,165,0));
                        x->setPosition(midPoint);
                        gridCell->addChild(x);
                        
                        CCLabelTTF *label = CCLabelTTF::create(CCString::createWithFormat("%d",starCount)->getCString(), "Helvetica", 30.0);
                        label->setColor(ccc3(255,100,0));
                        label->setPosition(ccpAdd(midPoint, ccp(40, 0)));
                        gridCell->addChild(label);
                        
                    }else{
                        for (int i=0; i<3; i++) {
                            CCSprite* star;
                            if (i+1<=starCount) {
                                star=CCSprite::createWithSpriteFrameName("kapian_xingxing_1.png");
                            }else{
                                star=CCSprite::createWithSpriteFrameName("kapian_xingxing_2.png");
                            }
                            star->setPosition(ccpAdd(midPoint, ccp((i-1)*40, 0)));
                            star->setScale(0.9);
                            gridCell->addChild(star);
                        }
                    }
                    
                    
                    if (hanzi->getisReward()>0) {
                        CCSprite* badge=CCSprite::createWithSpriteFrameName("badge.png");
                        badge->setPosition(S_RM->getRelativePosition("kapian_badge_in_gridcell",m_gridSize.height));
                        gridCell->addChild(badge);
                    }
                    
                    //设置进度
//                    CCSprite* pProgressBg1=CCSprite::createWithSpriteFrameName("card-learnedprogressbar-bg.png");
//                    CCPoint processPoint=S_RM->getRelativePosition("kapianjindu_in_cell",S_RM->getSizeWithName("kapian_grid_cell_size").height);
//                    pProgressBg1->setPosition(processPoint);
//                    gridCell->addChild(pProgressBg1);
//                    CCSprite* pProgressBg2=CCSprite::createWithSpriteFrameName("card-learnedprogressbar.png");
//                    CCProgressTimer* progressTimer = CCProgressTimer::create(pProgressBg2);
//                    progressTimer->setType(kCCProgressTimerTypeBar);
//                    progressTimer->setMidpoint(ccp(0, 0));
//                    progressTimer->setBarChangeRate(ccp(1, 0));
//                    progressTimer->setPercentage(kapian->getProgress()*100);
//                    progressTimer->setPosition(processPoint);
//                    progressTimer->setTag(CARD_PROGRESS_TAG);
//                    gridCell->addChild(progressTimer);
                }
                    break;
                    
                case kTupian:{
                    string path=FileUtils::getContentFilePath(kapian->getPath());
                    CCSize cellSize=S_RM->getSizeWithName("kapian_table_cell_thumb_size");
                    
                    CCPoint thumbPoint=S_RM->getRelativePosition("kapian_in_cell",m_gridSize.height);
                    CCSprite* tupianSprite;
                    if (kapian->getisCollected()) {
                        tupianSprite=CCSprite::create(path.c_str());
                    }else{
                        tupianSprite=GraySprite::create(path.c_str());
                    }
                    
                    if (tupianSprite!=NULL) {
                        CCSize size=tupianSprite->getContentSize();
                        tupianSprite->setScale(cellSize.width/size.width);//缩放
                        
                        tupianSprite->setPosition(thumbPoint);
                        tupianSprite->setTag(CARD_CONTENT_TAG);
                        gridCell->addChild(tupianSprite);
                        
                        if (!kapian->getisCollected()) {
                            CCSprite* huise=CCSprite::createWithSpriteFrameName("huise.png");
                            huise->setPosition(thumbPoint);
                            huise->setScale(cellSize.width/huise->getContentSize().width);//缩放
                            gridCell->addChild(huise);
                        }
                        
                        CCSprite* tupiankuangzi_1=CCSprite::createWithSpriteFrameName("tupiankuang_1.png");
                        tupiankuangzi_1->setPosition(cardPoint);
                        gridCell->addChild(tupiankuangzi_1);
                    }
                    
                }
                    
                    break;
            }
            
            //添加gridcell,设置坐标
            gridCell->setPosition(ccp(i*m_gridSize.width,0));
            cell->addChild(gridCell);
        }
    }
    else{
//        CCArray* gridCells=cell->getChildren();
//        for (int i=0; i<gridCells->count(); i++) {
//            int index=idx*COLUMN_NUMBER+i;
//            CCSprite* gridCellSprite=(CCSprite*)gridCells->objectAtIndex(i);
//            
//            Kapian* kapian=(*m_kapianVector)[index];
//            switch (m_dataMode) {
//                case kHanzi:{
//                    CCLabelTTF *label = (CCLabelTTF*)gridCellSprite->getChildByTag(CARD_CONTENT_TAG);
//                    label->setString(kapian->getText().c_str());
//                }
//                    break;
//                    
//                case kTupian:{
//                    string path=CCFileUtils::sharedFileUtils()->getWritablePath()+kapian->getPath();
//                    CCSprite* tupian=(CCSprite*)gridCellSprite->getChildByTag(CARD_CONTENT_TAG);
//                    CCSize cellSize=S_RM->getSizeWithName("Tupian_table_cell_thumb_size");
//                    tupian->setDisplayFrame(CCSpriteFrame::create(path.c_str(),CCRectMake(0, 0, cellSize.width, cellSize.height)));
//                }
//                    
//                    break;
//            }
//        }
    }
    return cell;
}
Example #18
0
CCTableViewCell* FriendList::tableCellAtIndex(CCTableView *table, unsigned int idx)
{
    EziFacebookFriend* friendDetails = (EziFacebookFriend*)mFriendList->objectAtIndex(idx);
    std::string friendID            = friendDetails->getFBID();
    std::string friendName          = friendDetails->getName();
    std::string installed           = "";
    std::string score               = "";
    CCSprite* profilePic            = NULL;
    
    // Set the score.
    long mylong = friendDetails->getScore();
    std::stringstream mystream;
    mystream << mylong;
    score = mystream.str();
    
    // Set the install status
    if (friendDetails->isInstalled())
    {
        installed = "Installed";
    }
    else
    {
        installed = "Not Installed";
    }
    
    
    CCTableViewCell *cell = table->dequeueCell();
    
    
    if (!cell) // Creation of Cell.
    {
        cell = new CCTableViewCell();
        cell->autorelease();
        
        CCLayerColor* colorLayer = CCLayerColor::create(ccc4(20, 0, 40, 255), SCREEN_WIDTH, CELL_HEIGHT);
        cell->addChild(colorLayer);
        
        CCSprite *sprite = NULL;
        
        if (strcmp(friendDetails->getPhotoPath(), "") != 0)
        {
            const char*  picPath = friendDetails->getPhotoPath();
            sprite = CCSprite::create(picPath);
        }
        else
        {
            sprite = CCSprite::create(FB_DEFAULT_PHOTO);
        }
        
        if (sprite == NULL)
        {
            CCLOG("Sprite is NULL");
        }
        
        sprite->setAnchorPoint(ccp(0, 0.5));
        sprite->setPosition(ccp(20, CELL_HEIGHT/2));
        cell->addChild(sprite);
        //sprite->setScale(0.9);
        sprite->setTag(FRIEND_PHOTO_TAG);
        
        // Friend Facebook ID
        CCLabelTTF *friendIDLabel = CCLabelTTF::create(friendID.c_str(), "Helvetica", 20.0 * MENU_FONT_SCALE);
        
        float gapY =  (CELL_HEIGHT - (friendIDLabel->getContentSize().height * 2)) / 3;
        
        if (sprite)
        {
            friendIDLabel->setPosition(ccp(sprite->getPositionX() + sprite->getContentSize().width + 20, CELL_HEIGHT - gapY));
        }
        
		friendIDLabel->setAnchorPoint(ccp(0, 1));
        friendIDLabel->setTag(FRIEND_ID_LABEL_TAG);
        cell->addChild(friendIDLabel);
        
        // Friend Facebook Name
        CCLabelTTF *friendNameLabel = CCLabelTTF::create(friendName.c_str(), "Helvetica", 20.0 * MENU_FONT_SCALE);
        friendNameLabel->setPosition(ccp(friendIDLabel->getPositionX(),
                                         friendIDLabel->getPositionY() - friendIDLabel->getContentSize().height - gapY));
        
		friendNameLabel->setAnchorPoint(ccp(0, 1));
        friendNameLabel->setTag(FRIEND_NAME_LABEL_TAG);
        cell->addChild(friendNameLabel);
        
        
        // High Score
        CCLabelTTF *scoreLabel = CCLabelTTF::create(score.c_str(), "Helvetica", 20.0 * MENU_FONT_SCALE);
        scoreLabel->setPosition(ccp(SCREEN_WIDTH - 20, friendIDLabel->getPositionY()));
        
        scoreLabel->setAnchorPoint(ccp(1, 1));
        scoreLabel->setTag(FRIEND_SCORE_LABEL_TAG);
        cell->addChild(scoreLabel);
        
        // Installed String
        CCLabelTTF *installedLabel = CCLabelTTF::create(installed.c_str(), "Helvetica", 20.0 * MENU_FONT_SCALE);
        installedLabel->setPosition(ccp(SCREEN_WIDTH - 20, friendNameLabel->getPositionY()));
        
        installedLabel->setAnchorPoint(ccp(1, 1));
        installedLabel->setTag(FRIEND_INSTALLED_LABEL_TAG);
        cell->addChild(installedLabel);
        
    }
    else
    {
        
        // Set the Friend ID
        CCLabelTTF *friendIDLabel = (CCLabelTTF*)cell->getChildByTag(FRIEND_ID_LABEL_TAG);
        friendIDLabel->setString(friendID.c_str());
        
        // Set the Friend Name
        CCLabelTTF *friendNameLabel = (CCLabelTTF*)cell->getChildByTag(FRIEND_NAME_LABEL_TAG);
        friendNameLabel->setString(friendName.c_str());
        
        
        CCLabelTTF *highScoreLabel = (CCLabelTTF*)cell->getChildByTag(FRIEND_SCORE_LABEL_TAG);
        if (highScoreLabel != NULL)
        {
            highScoreLabel->setString(score.c_str());
        }
        
        highScoreLabel->setVisible(mEnableHighScoreDisplay);
        
        
        CCLabelTTF *installedLabel = (CCLabelTTF*)cell->getChildByTag(FRIEND_INSTALLED_LABEL_TAG);
        if (installedLabel != NULL)
        {
            installedLabel->setString(installed.c_str());
        }
        installedLabel->setVisible(mEnableInstalledDisplay);
        
        
        CCSprite* cellProfilePic = (CCSprite*)cell->getChildByTag(FRIEND_PHOTO_TAG);
        
        if (strcmp("", friendDetails->getPhotoPath()) != 0 )
        {
            const char*  picPath = friendDetails->getPhotoPath();
            profilePic = CCSprite::create(picPath);
            
        }
        else
        {
            profilePic = CCSprite::create(FB_DEFAULT_PHOTO);
        }
        
        
        cellProfilePic->setTexture(profilePic->getTexture());
    }
    
    
    return cell;
}
Example #19
0
CCTableViewCell* S2TestMain::tableCellAtIndex(CCTableView *table, unsigned int idx)
{
    int tableTag = table->getTag();
    if (tableTag==11) {//PracticeList TableView
        
        CCString *strCell = CCString::create(aVectorCellSmallValue[idx]);
        
        CCTableViewCell *pCell = table->dequeueCell();
        if (!pCell) {
            pCell = new CCTableViewCell();
            pCell->autorelease();
            CCSprite *pSprite = CCSprite::create("cellLine.png");
            pSprite->setPosition(CCPointZero);
            pSprite->setAnchorPoint(CCPointZero);
            pCell->addChild(pSprite,1);
            
            {
                CCLabelTTF *pLabel = CCLabelTTF::create(strCell->getCString(), "Arial", s2FontSize3_macro, s2Size2_macro(aCell), kCCTextAlignmentLeft, kCCVerticalTextAlignmentCenter);
                pLabel->setPosition(ccp(s2Less3_macro,0));
                pLabel->setAnchorPoint(CCPointZero);
                pLabel->setColor(ccc3(0,0,0));
                pLabel->setTag(s2Tag1);
                pCell->addChild(pLabel,1);
            }
        }
        
        CCLabelTTF *pLabel = (CCLabelTTF*)pCell->getChildByTag(s2Tag1);
        pLabel->setString(strCell->getCString());
        
        
        return pCell;
        
    }else if (tableTag==12){//TableView
        
        CCString *strCell = CCString::create(aVectorCellValue[idx]);
        
        CCTableViewCell *pCell = table->dequeueCell();
        if (!pCell) {
            pCell = new CCTableViewCell();
            pCell->autorelease();
            CCSprite *pSprite = CCSprite::create("cellLine.png");
            pSprite->setPosition(CCPointZero);
            pSprite->setAnchorPoint(CCPointZero);
            pCell->addChild(pSprite,1);
            
            {
                CCLabelTTF *pLabel = CCLabelTTF::create(strCell->getCString(), "Arial", s2FontSize3_macro, s2Size4_macro(aCell), kCCTextAlignmentLeft, kCCVerticalTextAlignmentCenter);
                pLabel->setPosition(ccp(s2Less3_macro,0));
                pLabel->setAnchorPoint(CCPointZero);
                pLabel->setColor(ccc3(0,0,0));
                pLabel->setTag(s2Tag1);
                pCell->addChild(pLabel,1);
            }
            
            {
                CCLabelTTF *pLabel = CCLabelTTF::create("Completed", "Arial",s2FontSize3_macro, s2Size5_macro(aItem), kCCTextAlignmentRight, kCCVerticalTextAlignmentCenter);
                pLabel->setPosition(s2PositionC7_macro(aItem));
                pLabel->setAnchorPoint(CCPointZero);
                pLabel->setColor(ccc3(0,0,255));
                pLabel->setTag(s2Tag1);
                pCell->addChild(pLabel,1);
            }
            
        }
        
        CCLabelTTF *pLabel = (CCLabelTTF*)pCell->getChildByTag(10);
        pLabel->setString(strCell->getCString());
        
        
        return pCell;
    }
    
    
    return NULL;
}
Example #20
0
CCTableViewCell* EnergyRecharge::tableCellAtIndex(CCTableView *table, unsigned int idx)
{
    //if(read.parse(str->getCString(), root))
    //{
        energy=root["energy"];
        CCLog("%d",idx);
        rl->rid=energy[idx]["id"].asInt();
        CCLog("%d",rl->rid);
        //CCLog("%d",idx);
        rl->rmb=energy[idx]["rmb"].asInt();
        //CCLog("%d",rl->rmb);
        //CCLog("%d",idx);
        rl->obtain=energy[idx]["obtain"].asInt();
        //CCLog("%d",rl->obtain);
        rl->present=energy[idx]["present"].asString();
        //CCLog("%s",rl->present.c_str());
    //}
    CCTableViewCell *tableViewCell;//=table->dequeueCell();
    //if (!tableViewCell)
    //{
        tableViewCell=new CCTableViewCell();
        tableViewCell->autorelease();
        CCScale9Sprite *cellSprite=CCScale9Sprite::create("Recharge_item.png");
        cellSprite->setAnchorPoint(CCPointZero);
        cellSprite->setPosition(CCPointZero);
        
        sprintf(mstring, "%d",rl->rmb);
        //CCLog("%s",mstring);
        //CCLog("%s",moneyDesc.c_str());
        CCLabelTTF *rmbText=CCLabelTTF::create(mstring, "hycc.ttf", 20);
        rmbText->setAnchorPoint(CCPointZero);
        rmbText->setPosition(ccp(cellSprite->getContentSize().width/2-75,cellSprite->getContentSize().height/2-15));
        rmbText->setColor(lColor);
        cellSprite->addChild(rmbText);
        
        sprintf(ostring, "%d",rl->obtain);
        //CCLog("%s",sObtain.c_str());
        CCLabelTTF *obtainText=CCLabelTTF::create(ostring, "hycc.ttf", 20);
        obtainText->setAnchorPoint(CCPointZero);
        obtainText->setPosition(ccp(cellSprite->getContentSize().width/2+100,cellSprite->getContentSize().height/2+3));
        obtainText->setColor(lColor);
        cellSprite->addChild(obtainText);
        
        CCLabelTTF *presentText=CCLabelTTF::create(rl->present.c_str(), "hycc.ttf", 20);
        //CCLog("%s",rl->present.c_str());
        presentText->setAnchorPoint(CCPointZero);
        presentText->setPosition(ccp(cellSprite->getContentSize().width/2+100,cellSprite->getContentSize().height/2-32));
        presentText->setColor(lColor);
        cellSprite->addChild(presentText);
        
        tableViewCell->addChild(cellSprite);
    //}
//    else
//    {
//        CCScale9Sprite *cellSprite=CCScale9Sprite::create("Recharge_item.png");
//        cellSprite->setAnchorPoint(CCPointZero);
//        cellSprite->setPosition(CCPointZero);
//        
//        sprintf(mstring, "%d",rl->rmb);
//        //CCLog("%s",mstring);
//        //CCLog("%s",moneyDesc.c_str());
//        CCLabelTTF *rmbText=CCLabelTTF::create(mstring, "hycc.ttf", 20);
//        rmbText->setAnchorPoint(CCPointZero);
//        rmbText->setPosition(ccp(cellSprite->getContentSize().width/2-75,cellSprite->getContentSize().height/2-15));
//        rmbText->setColor(lColor);
//        cellSprite->addChild(rmbText);
//        
//        sprintf(ostring, "%d",rl->obtain);
//        //CCLog("%s",sObtain.c_str());
//        CCLabelTTF *obtainText=CCLabelTTF::create(ostring, "hycc.ttf", 20);
//        obtainText->setAnchorPoint(CCPointZero);
//        obtainText->setPosition(ccp(cellSprite->getContentSize().width/2+100,cellSprite->getContentSize().height/2+3));
//        obtainText->setColor(lColor);
//        cellSprite->addChild(obtainText);
//        
//        CCLabelTTF *presentText=CCLabelTTF::create(rl->present.c_str(), "hycc.ttf", 20);
//        //CCLog("%s",rl->present.c_str());
//        presentText->setAnchorPoint(CCPointZero);
//        presentText->setPosition(ccp(cellSprite->getContentSize().width/2+100,cellSprite->getContentSize().height/2-32));
//        presentText->setColor(lColor);
//        cellSprite->addChild(presentText);
//        
//        tableViewCell->addChild(cellSprite);
//    }
    return tableViewCell;
}
Example #21
0
CCTableViewCell* MailListScene::tableCellAtIndex(CCTableView *table, unsigned int idx)
{
	CCString *string = (CCString *)mArrayList->objectAtIndex(idx);
    CCSize size = this->tableCellSizeForIndex(table, idx);
	CCTableViewCell *cell = table->dequeueCell();
	if (!cell) {
		cell = new CCTableViewCell();
		cell->autorelease();

		CCSprite *sState = CCSprite::createWithSpriteFrame(CCSpriteFrameCache::sharedSpriteFrameCache()->spriteFrameByName("mail_state_read.png"));
		sState->setAnchorPoint(CCPointMake(0, 0.5));
		sState->setPosition(ccp(10,size.height * 0.5));
		sState->setTag(120);
		cell->addChild(sState);

		CCLabelTTF *lblName = CCLabelTTF::create(string->getCString(), "Arial", 14.0);
		lblName->setPosition(ccp(65,size.height * 0.5));
        lblName->setColor(ccc3(255, 255, 204));
        //lblName->enableStroke(ccc3(51, 0, 0), 0.6);
		lblName->setTag(121);
		lblName->setHorizontalAlignment(kCCTextAlignmentLeft);
        lblName->setString(string->getCString());
		cell->addChild(lblName);

		CCLabelTTF *lblSubject = CCLabelTTF::create("100", "Arial", 14.0);
		lblSubject->setPosition(ccp(130,size.height * 0.5));
        lblSubject->setColor(ccc3(255, 255, 204));
        //lblSubject->enableStroke(ccc3(51, 0, 0), 0.6);
        lblSubject->setTag(122);
        lblSubject->setString(string->getCString());
		cell->addChild(lblSubject);
        
        CCScale9Sprite *sline = CCScale9Sprite::createWithSpriteFrame(CCSpriteFrameCache::sharedSpriteFrameCache()->spriteFrameByName("mail_line.png"));
        sline->setPreferredSize(CCSizeMake(310, 1));
        sline->setPosition(ccp(0,size.height-2));
        sline->setAnchorPoint(CCPointZero);
        cell->addChild(sline);
        
        CCMenu *menuCheck = this->generateCheckBox();
        cell->addChild(menuCheck);
        CCMenuItemToggle *toggle= (CCMenuItemToggle *)menuCheck->getChildByTag(1);
        toggle->setUserData(&vUserData[idx]);
		if (vUserData[idx] == 1) {
			toggle->setSelectedIndex(1);
		} else {
			toggle->setSelectedIndex(0);
		}

        menuCheck->setTag(123);
        menuCheck->setAnchorPoint(CCPointMake(0, 0.5));
        menuCheck->setPosition(CCPointMake(280, size.height * 0.5));
	}
	else
	{
		CCLabelTTF *lblName = (CCLabelTTF*)cell->getChildByTag(121);
		lblName->setString(string->getCString());
        
        CCLabelTTF *lblSubject = (CCLabelTTF*)cell->getChildByTag(122);
		lblSubject->setString(string->getCString());
        
        CCMenu *menuCheck = (CCMenu *)cell->getChildByTag(123);
        CCMenuItemToggle *toggle= (CCMenuItemToggle *)menuCheck->getChildByTag(1);
		toggle->setUserData(&vUserData[idx]);

        if (vUserData[idx] == 1) {
			toggle->setSelectedIndex(1);
        } else {
            toggle->setSelectedIndex(0);
        }
	}

	return cell;
}