void CSmeltArmor::checkMoney() { CCSprite *coin = (CCSprite *)(m_ui->findWidgetById("coin")); CCSprite *diamond = (CCSprite *)(m_ui->findWidgetById("diamond")); CLabel *money = (CLabel *)(m_ui->findWidgetById("money")); if(coin->isVisible()) { //检查货币数量 if(!CheckCoin(atoi(money->getString()))) { money->setColor(RGB_RED); } else { money->setColor(RGB_WHITE); } } if(diamond->isVisible()) { //检查货币数量 if(!CheckGold(atoi(money->getString()))) { money->setColor(RGB_RED); } else { money->setColor(RGB_WHITE); } } }
int CSmeltArmor::updateInfoToUIAndReturnCount( CLayout* pLayout[], int iNameId[], int iValue[], const char* sRange[], int iMax, const char* sTitle ) { int iMaxLineCount = 0; for(unsigned int i=0; i<iMax; i++) { //有值 if(iValue[i] > 0) { pLayout[iMaxLineCount]->setVisible(true); //设置名称 CLabel* pInfoType = (CLabel*)pLayout[iMaxLineCount]->findWidgetById("info_type"); pInfoType->setString(GETLANGSTR(iNameId[i])); //设置值大小 CLabel* pValue = (CLabel*)pLayout[iMaxLineCount]->findWidgetById("value"); if(atoi(pValue->getString())!=iValue[i]) { pValue->setString(ToString(iValue[i])); pValue->runAction(CCRollLabelAction::create(0.3f, 0, iValue[i], pValue)); } //目标值大小 CLabel* pAimValue = (CLabel*)pLayout[iMaxLineCount]->findWidgetById("aim_value"); pAimValue->setString(sRange[i]); //存ID CCheckBox* pCheck = (CCheckBox*)pLayout[iMaxLineCount]->findWidgetById("check"); pCheck->setTag(i+1); iMaxLineCount++; } //找到四个了,退出循环 if(iMaxLineCount>=4) { break; } } //隐藏掉没有数据填充的cell hideNoneValueCell(iMaxLineCount, pLayout); //如果一个都没有,隐藏标题 if(sTitle != nullptr) { CCNode* pNode = (CCNode*)m_ui->findWidgetById(sTitle); if(pNode) { pNode->setVisible(iMaxLineCount != 0); } } return iMaxLineCount; }
void CSmeltArmor::onRefineItem(CCObject* pSender) { //检查货币是否足够 CLabel *money = (CLabel *)(m_ui->findWidgetById("money")); int iCost = atoi(money->getString()); if(m_iStrengthType==0) { if(!CheckCoin(iCost)) { //ShowPopTextTip(GETLANGSTR(205)); CShowToBuyResource* pShow = CShowToBuyResource::create(); pShow->showToBuyResourceByType(ShowBuyResourceCoin); return; } } else { if(!CheckGold(iCost)) { //ShowPopTextTip(GETLANGSTR(203)); CShowToBuyResource* pShow = CShowToBuyResource::create(); pShow->showToBuyResourceByType(ShowBuyResourceGold); return; } } vector<int> checkVec; if(m_iStrengthType != 0) { for (unsigned int i=0; i<4; ++i) { CCheckBox* pCheckBtn = (CCheckBox*)(m_pBaseInfo[i]->findWidgetById("check")); if (pCheckBtn->isChecked()) { checkVec.push_back(pCheckBtn->getTag()); } } } if (m_armor.id>0) { CPlayerControl::getInstance().sendSmeltArmor(m_armor.id, checkVec); } }
void CSignLayer::showTipsOnNextTotalSign() { m_pYellowTip->setVisible(false); //遍历阶段签到 for (int i = 0; i < m_signData.totalList.size()&&i<4; i++) { CSign &sign = m_signData.totalList.at(i); //未领取 if(sign.status==2) { if(sign.day>m_signData.sign) { //当前底加高亮 CCSprite* pBg = (CCSprite*)m_ui->findWidgetById(CCString::createWithFormat("bg%d",i+1)->getCString()); //pBg->setShaderProgram(ShaderDataMgr->getShaderByType(ShaderStone)); pBg->setTexture(CCTextureCache::sharedTextureCache()->addImage("sign/arrival_02.png")); //pBg->setScale(0.85f); //拿到当前宝箱 CImageView *mask = (CImageView*)m_ui->findWidgetById(CCString::createWithFormat("mask%d",i+1)->getCString()); //隐藏自己的日期 CLabel *day = (CLabel*)(m_ui->findWidgetById(CCString::createWithFormat("day%d",i+1)->getCString())); day->setVisible(false); //加黄标提示 m_pYellowTip->setVisible(true); m_pYellowTip->setPosition(ccp(mask->getPositionX()+mask->getContentSize().width/2, mask->getPositionY()+mask->getContentSize().height-60)); m_pYellowTipText->setString(day->getString()); break; } } else { //当前底加高亮 CCSprite* pBg = (CCSprite*)m_ui->findWidgetById(CCString::createWithFormat("bg%d",i+1)->getCString()); //pBg->setShaderProgram(ShaderDataMgr->getShaderByType(ShaderDefault)); pBg->setTexture(CCTextureCache::sharedTextureCache()->addImage("sign/arrival_01.png")); //pBg->setScale(1.0f); //天数 CLabel *day = (CLabel*)(m_ui->findWidgetById(CCString::createWithFormat("day%d",i+1)->getCString())); day->setVisible(true); } } }
void CSmeltArmor::onCheckAttr(CCObject *pSender, bool bChecked) { int checknum =0; int iShowCount = 0; for (unsigned int i=0; i<4; ++i) { CCheckBox* pCheckBtn = (CCheckBox*)(m_pBaseInfo[i]->findWidgetById("check")); if (pCheckBtn->isChecked()) { checknum++; } if(m_pBaseInfo[i]->isVisible()) { iShowCount++; } setYellowBgState(pCheckBtn, pCheckBtn->isChecked()); } //如果选中了四个,则屏蔽掉一个,提示不能全选 if(checknum>=iShowCount && pSender!=nullptr) { CCheckBox* pCheck = (CCheckBox*)pSender; pCheck->setEnabled(false); pCheck->setChecked(false); pCheck->setEnabled(true); setYellowBgState(pCheck, false); ShowPopTextTip(GETLANGSTR(1182)); return; } if (checknum==0) { CCSprite *coin = (CCSprite *)(m_ui->findWidgetById("coin")); coin->setVisible(true); m_coin = 0; switch (m_armor.quality) { case 1: m_coin =10000; break; case 2: m_coin =20000; break; case 3: m_coin =40000; break; case 4: m_coin =80000; break; case 5: m_coin =160000; break; default: break; } m_diamond = 0; CCSprite *diamond = (CCSprite *)(m_ui->findWidgetById("diamond")); diamond->setVisible(false); CLabel *money = (CLabel *)(m_ui->findWidgetById("money")); money->setString(ToString(m_coin)); //检查货币数量 if(!CheckCoin(atoi(money->getString()))) { money->setColor(RGB_RED); } else { money->setColor(RGB_WHITE); } showFireWithType(0); } else { CCSprite *coin = (CCSprite *)(m_ui->findWidgetById("coin")); coin->setVisible(false); CCSprite *diamond = (CCSprite *)(m_ui->findWidgetById("diamond")); diamond->setVisible(true); CLabel *money = (CLabel *)(m_ui->findWidgetById("money")); money->setString(ToString(100*checknum)); //检查货币数量 if(!CheckGold(atoi(money->getString()))) { money->setColor(RGB_RED); } else { money->setColor(RGB_WHITE); } m_coin = 0; m_diamond = 100*checknum; showFireWithType(1); } }
void CTopLayer::updateRoleProperty(const TMessage& tMsg) { UserData *user = DataCenter::sharedData()->getUser()->getUserData(); CCScaleTo* sc1 = CCScaleTo::create(0.15f,1.3f); CCScaleTo* sc2 = CCScaleTo::create(0.35f,1.0f); CCSequence* sqes = CCSequence::create(sc1,sc2,nullptr); if (user->getCoin()!=atoi(m_coinLabel->getString())) { CProgressLabel *prolab = CProgressLabel::create(); prolab->setLabel(m_coinLabel); prolab->changeValueTo(user->getCoin(),0.5f); CCSequence* sqes1 = (CCSequence*)sqes->copy(); m_coinLabel->runAction(sqes1); this->addChild(prolab); CLabel *label = (CLabel*)m_ui->getChildByTag(130); int coin = user->getCoin()-atoi(m_coinLabel->getString()); changeLabel(label, coin); } if (user->getRoleGold()!=atoi(m_moneyLabel->getString())) { CProgressLabel *prolab = CProgressLabel::create(); prolab->setLabel(m_moneyLabel); prolab->changeValueTo(user->getRoleGold(),0.5f); CCSequence* sqes1 = (CCSequence*)sqes->copy(); m_moneyLabel->runAction(sqes1); this->addChild(prolab); CLabel *label = (CLabel*)m_ui->getChildByTag(140); int coin = user->getRoleGold()-atoi(m_moneyLabel->getString()); changeLabel(label, coin); } /* if (user->getRoleFood()!=atoi(m_foodLabel->getString())) { CProgressLabel *prolab = CProgressLabel::create(); prolab->setLabel(m_foodLabel); prolab->changeValueTo(user->getRoleFood(),0.5f); CCSequence* sqes1 = (CCSequence*)sqes->copy(); m_foodLabel->runAction(sqes1); this->addChild(prolab); CLabel *label = (CLabel*)m_ui->getChildByTag(170); int coin = user->getRoleFood()-atoi(m_foodLabel->getString()); changeLabel(label, coin); } */ if (user->getFriends()!=atoi(m_foodLabel->getString())) { CProgressLabel *prolab = CProgressLabel::create(); prolab->setLabel(m_foodLabel); prolab->changeValueTo(user->getFriends(),0.5f); CCSequence* sqes1 = (CCSequence*)sqes->copy(); m_foodLabel->runAction(sqes1); this->addChild(prolab); CLabel *label = (CLabel*)m_ui->getChildByTag(170); int coin = user->getFriends()-atoi(m_foodLabel->getString()); changeLabel(label, coin); } CLabel *action = (CLabel*)(m_ui->findWidgetById("action")); if (user->getRoleAction()!=atoi(action->getString())) { CCSequence* sqes2 = (CCSequence*)sqes->copy(); action->runAction(sqes2); action->setString(CCString::createWithFormat("%d/%d",user->getRoleAction(), user->getActionLimit())->getCString()); } }