Exemplo n.º 1
0
void CChangeHeadImg::addGridCell(unsigned int uIdx, CGridViewCell* pCell)
{
	CLayout *lay = UICloneMgr::cloneLayout(m_cell);

	for (int i=1; i<=2; i++)
	{
		CCNode *child = lay->getChildByTag(i);
		lay->removeChild(child);
		pCell->addChild(child);

		if (i==1)
		{
			if (m_headIconList.at(uIdx)>0)
			{
				CImageView* pHead = CImageView::create(CCString::createWithFormat("headImg/%d.png", m_headIconList.at(uIdx))->getCString());
				if(!pHead)
				{
					pHead = CImageView::create("headImg/null.png");
					CCLOG("ERROR_____CChangeHeadImg::addGridCell");
				}
				child->addChild(pHead);
				NodeFillParent(pHead);
			}
			else
			{
				UserData *data = DataCenter::sharedData()->getUser()->getUserData();
				string fbName = data->getFbId() +".jpg";
				string fullName = CCFileUtils::sharedFileUtils()->fullPathForFilename(fbName.c_str());
				bool isFileExist = CCFileUtils::sharedFileUtils()->isFileExist(fullName);
				if(isFileExist)
				{
					CCSprite* spr =CCSprite::create(fullName.c_str());
					child->addChild(spr);
					NodeFillParent(spr);
				}
			}
			
		}
		else if(i==2)
		{
			CImageView* pBtn = (CImageView*)child;
			pBtn->setTouchEnabled(true);
			pBtn->setUserData(&m_headIconList.at(uIdx));
			pBtn->setOnClickListener(this,ccw_click_selector(CChangeHeadImg::onChangHeadImg));
		}
	}
}
Exemplo n.º 2
0
void CSignLayer::updateTotoalSign()
{
	//更新
	//已领取的,宝箱变灰,加对勾
	//未领取的,宝箱变亮,
	//将要领取的,加黄色标题突出

	for (int i = 0; i < m_signData.totalList.size()&&i<4; i++)
	{
		CSign &sign = m_signData.totalList.at(i);

		//宝箱
		CImageView *mask = (CImageView*)m_ui->findWidgetById(CCString::createWithFormat("mask%d",i+1)->getCString());
		mask->setVisible(true);
		//mask->setTexture(CCTextureCache::sharedTextureCache()->addImage(CCString::createWithFormat("sign/box_%d.png", i+1)->getCString()));
		mask->setUserData(&sign);
		mask->setTouchEnabled(true);
		mask->setOnPressListener(this, ccw_press_selector(CSignLayer::onPress));

		//天数
		CLabel *day = (CLabel*)(m_ui->findWidgetById(CCString::createWithFormat("day%d",i+1)->getCString()));
		day->setString(CCString::createWithFormat(GETLANGSTR(209),sign.day)->getCString());

		//获得字样
		CImageView *getspr = (CImageView*)(m_ui->findWidgetById(CCString::createWithFormat("get%d",i+1)->getCString()));

		//已领取
		if (sign.status==1)
		{
			//宝箱变灰
			mask->setShaderProgram(ShaderDataMgr->getShaderByType(ShaderStone));
			//加对勾
			getspr->setVisible(true);
		}
		//未领取
		else if(sign.status==2)
		{
			//宝箱变灰
			mask->setShaderProgram(ShaderDataMgr->getShaderByType(ShaderDefault));
			//加对勾
			getspr->setVisible(false);
		}
	}
}
Exemplo n.º 3
0
void CSignLayer::addGridCell(unsigned int uIdx, CGridViewCell* pCell)
{
// 	CHero *hero = m_currHeroList->at(uIdx);
	CSign &sign = m_signData.signList.at(uIdx);
	CLayout *lay = UICloneMgr::cloneLayout(m_cell);
	pCell->setScale(0.97f);

	for (int i = 1; i <=4; i++)
	{
		CCNode *child = lay->getChildByTag(i);
		lay->removeChild(child);
		pCell->addChild(child);
	}


	CImageView *imagView = (CImageView*)pCell->getChildByTag(1);	
	imagView->setTouchEnabled(true);
	imagView->setEnabled(true);
	imagView->setUserData(&m_signData.signList.at(uIdx));
	imagView->setOnPressListener(this, ccw_press_selector(CSignLayer::onPress));
	


	CCSprite *item = nullptr;
	if (sign.prize.thumb>=0)
	{
		CImageView * pMask = (CImageView*)pCell->getChildByTag(2);
		SmartSetRectPrizeColor(pMask, &sign.prize);
		item = CCSprite::create(GetImageName(sign.prize.type, sign.prize.color, sign.prize.thumb).c_str());
		if(!item)
		{
			item = CCSprite::create("headImg/101.png");
			CCLOG("CSignLayer::addGridCell  error load image %d", sign.prize.thumb);
		}
		item->setPosition(ccp(pMask->getContentSize().width/2, pMask->getContentSize().height/2));
		pMask->addChild(item, -1, 2);
		item->setScale(0.9f);
	

		//加数字
		CCLabelAtlas* haveNum = CCLabelAtlas::create("", "label/no_02.png", 9, 15, 46);
		haveNum->setAnchorPoint(ccp(1.0f, 0.0f));
		haveNum->setPosition(ccp(85, 5));
		pMask->addChild(haveNum, 99, 99);

		haveNum->setString(ToString(sign.prize.num));
		if(sign.prize.num<=1)
		{
			haveNum->setVisible(false);
		}

		//添加星星
		if(sign.prize.quality > 0)
		{
			CLayout* pStarLayout = SmartGetStarLayout(&sign.prize);
			pMask->addChild(pStarLayout, 211, 211);
		}
	}

	//vip icon
	CCSprite *vip = (CCSprite*)pCell->getChildByTag(3);
	if (sign.vip>0)
	{ 
		CCTexture2D *texture = CCTextureCache::sharedTextureCache()
											->addImage(CCString::createWithFormat("public/vip_%d.png",sign.vip)->getCString());
		vip->setVisible(true);
		vip->setTexture(texture);
	}
	else
	{
		vip->setVisible(false);
	}

	switch (sign.status)
	{
		//没签
	case 2:
		{
			//对勾
			pCell->getChildByTag(4)->setVisible(false);
			//考虑是否加个框标示为可签
			if(uIdx == m_signData.sign && 
				(m_signData.bCanSign || (m_signData.bCanResign && m_signData.resign>0) ) )
			{
				CImageView * pMask = (CImageView*)pCell->getChildByTag(2);
				CCSprite* pRect = CCSprite::create("common/box_light.png");
				pRect->setPosition(ccp(pMask->getPositionX()+pMask->getContentSize().width/2, pMask->getPositionY()+pMask->getContentSize().height/2));
				pCell->addChild(pRect, 100);
				pRect->runAction(CCRepeatForever::create(CCSequence::createWithTwoActions(CCScaleTo::create(0.3f, 1.03f), CCScaleTo::create(0.3f, 1.0f))));
			}
		}
		break;
		//已签
	case 1:
		{
			//对勾
			pCell->getChildByTag(4)->setVisible(true);
			//变黑
			pCell->getChildByTag(1)->setShaderProgram(ShaderDataMgr->getShaderByType(ShaderStone));
			pCell->getChildByTag(2)->setShaderProgram(ShaderDataMgr->getShaderByType(ShaderStone));
			pCell->getChildByTag(2)->getChildByTag(2)->setShaderProgram(ShaderDataMgr->getShaderByType(ShaderStone));
			pCell->getChildByTag(3)->setShaderProgram(ShaderDataMgr->getShaderByType(ShaderStone));
			//星星
			CLayout * pStarLay = (CLayout*)pCell->getChildByTag(2)->getChildByTag(211);
			if(pStarLay!=nullptr)
			{
				CCArray* pChildren = pStarLay->getChildren();
				for(int i=0; i<pChildren->count(); i++)
				{
					CCSprite* pStar = dynamic_cast<CCSprite*>(pChildren->objectAtIndex(i));
					if(pStar)
					{
						pStar->setShaderProgram(ShaderDataMgr->getShaderByType(ShaderStone));
					}
				}
			}
			////数字
			//CCLabelAtlas * pLabel = (CCLabelAtlas*)pCell->getChildByTag(2)->getChildByTag(211);
			//if(pLabel && pLabel->isVisible())
			//{
			//	pLabel->setShaderProgram(ShaderDataMgr->getShaderByType(ShaderStone));
			//}
		}
		break;
	default:
		break;
	}

}
Exemplo n.º 4
0
void CStrengthenItem::addTableCell(unsigned int uIdx, CTableViewCell * pCell)
{
	CLayout *lay = UICloneMgr::cloneLayout(m_cell);

	CItem &item =  *(m_itemList.at(uIdx));// m_itemData.itemList.at(uIdx);

	pCell->setTag(uIdx);

	const ItemData * itemData = DataCenter::sharedData()->getItemDesc()->getCfg(item.itemId);

	for (int i = 1; i <=11; i++)
	{
		CCNode *child = lay->getChildByTag(i);
		if (!child) continue;
		lay->removeChild(child);
		pCell->addChild(child);

		if (i==1)
		{
			CImageView *bgImg = (CImageView*)child;
			if (m_toHero>0)
			{
				if (!item.canUse&&item.armor.hero!=m_toHero)
				{
					CColorView *colorView = CColorView::create(ccc4(0,0,0,100));
					colorView->setContentSize(bgImg->getContentSize());
 					colorView->setPosition(bgImg->getPosition());
					pCell->addChild(colorView,1);
				}
				
				if(item.armor.hero<=0)
				{
					//记录库存
					m_iCountEquipStock++;
				}
			}
			
			bgImg->setTouchEnabled(true);
			bgImg->setUserData(m_itemList.at(uIdx));
			bgImg->setOnClickListener(this,ccw_click_selector(CStrengthenItem::onTouchItem));
		}
		else if (i==2)
		{
			((CButton*)child)->setEnabled(false);
			CCSprite *mask = CCSprite::createWithTexture(setItemQualityTexture(item.quality));
			mask->setPosition(ccp(child->getContentSize().width/2,child->getContentSize().height/2));
			child->addChild(mask, 10);

			CCSprite *prop = CCSprite::create(GetImageName(1, item.quality, item.iconId).c_str());
			if (!prop)
			{
				prop = CImageView::create("prop/32003.png");
			}
			prop->setPosition(ccp(child->getContentSize().width/2,child->getContentSize().height/2));
			child->addChild(prop);

			//添加星星
			CLayout* pStarLayout = getStarLayout(item.iStar);
			child->addChild(pStarLayout, 10);
		}
		else if (i==3)
		{
			CLabel *label = (CLabel*)child;
			if(itemData)
			{
				label->setString(itemData->itemName.c_str());
			}
		}
		else if (i==4)
		{
			CLabel *label = (CLabel*)child;
			
			if (item.itemLevel==0)
			{
				label->removeFromParent();
			}
			else
			{
				label->setString(CCString::createWithFormat("+%d",item.itemLevel)->getCString());
				label->setPositionX(pCell->getChildByTag(3)->getPositionX()+pCell->getChildByTag(3)->getContentSize().width+10);
			}
		}
		else if (i==5)
		{
			CLabel *label = (CLabel*)child;
			if (item.itemLevel==0)
			{
				label->setVisible(false);
			}
			else
			{
				label->setVisible(true);
				//if (item.itemLevel==item.armor.strenLv)
				//{
				//	label->setString(CCString::createWithFormat("Lv.%s",GETLANGSTR(229))->getCString());
				//}
				//else
				//{
				//	label->setString(CCString::createWithFormat("Lv.%d",item.itemLevel)->getCString());
				//}
				label->setString(CCString::createWithFormat("+%d",item.itemLevel)->getCString());
			}
		}
		else if (i==6)
		{
			CCSprite *head = (CCSprite*)child;
			if (item.armor.hero>0)
			{
				CCSprite *img = CCSprite::create(getImageName(&item.armor).c_str());
				if(!img)
				{
					img = CCSprite::create("headIcon/101.png");
					CCLOG("ERROR CStrengthenItem::addTableCell");
				}

				CCSprite *mask = (CCSprite*) lay->getChildByTag(7);
				lay->removeChild(mask);
				pCell->addChild(mask);

				img->setScale(0.53f);
				img->setPosition(ccp(head->getContentSize().width/2,head->getContentSize().height/2+14));
				head->addChild(img);
			}
			else
			{
				pCell->removeChild(child);
			}
		}
		else if (i==7)
		{
			pCell->removeChild(child);
		}
		else if (i==8)
		{
			child->setVisible(item.stren);
		}
		else if(i==9)
		{
			if (item.itemLevel==0)
			{
				child->setVisible(false);
			}
			else
			{
				child->setVisible(true);
			}
		}
		else if( i ==10)
		{
			CCNode* pCombatTip = (CCNode*)child;
			pCombatTip->setVisible(item.armor.armorType != 5);
		}
		else if (i==11)
		{
			CLabelAtlas* pLabel = (CLabelAtlas*)child;
			pLabel->setAnchorPoint(ccp(0, 0.5f));
			pLabel->setString(ToString(item.armor.combat));
			pLabel->setVisible(item.armor.armorType != 5);
		}
	}
}