예제 #1
0
Ref* CTableViewBasicTest::tableviewDataSource(Ref* pConvertView, unsigned int idx)
{
	CTableViewCell* pCell = (CTableViewCell*)pConvertView;
	CButton* pButton = NULL;

	if(!pCell)
	{
		pCell = new CTableViewCell();
		pCell->autorelease();

		pButton = CButton::createWith9Sprite(Size(70, 70), "sprite9_btn1.png", "sprite9_btn2.png");
		pButton->setPosition(Vec2(74.0f / 2, 70.0f / 2));
		//pButton->getLabel()->setFontSize(25.0f);
		pButton->setTag(1);
		pCell->addChild(pButton);
	}
	else
	{
		pButton = (CButton*) pCell->getChildByTag(1);
	}

	char buff[64];
	sprintf(buff, "%u", idx);
	pButton->getLabel()->setString(buff);
	pButton->setUserTag(idx);

	return pCell;
}
예제 #2
0
void CStrengthenItem::processNetMessage(int type, google::protobuf::Message *msg)
{
	this->setVisible(true);
	ArmorListRes * res = (ArmorListRes*)msg;
	for (int i = 0; i < res->armorlist_size(); i++)
	{
		CItem item;
		item.read(res->armorlist(i));
		//if (item.canUse)
		{
			m_itemData.itemList.push_back(item);
		}
	}

	for (int j = 0; j < m_itemData.itemList.size(); j++)
	{
		m_itemList.push_back(&(m_itemData.itemList.at(j)));
	}

	//排序
	std::sort(m_itemList.begin(), m_itemList.end(), SortItem);

	m_tableView->setCountOfCell(m_itemData.itemList.size());
	m_tableView->reloadData();

	if (m_itemList.size()>0)
	{
		CTableViewCell *cell = (CTableViewCell*)m_tableView->getCells()->objectAtIndex(0);
		onTouchItem(cell->getChildByTag(1));
		this->setVisible(true);
	}
}
예제 #3
0
Ref* CTableViewReloadTest::tableviewDataSource(Ref* pConvertView, unsigned int idx)
{
	CTableViewCell* pCell = (CTableViewCell*) pConvertView;
	CButton* pButton = NULL;

	if(!pCell)
	{
		pCell = new CTableViewCell();
		pCell->autorelease();

		pButton = CButton::createWith9Sprite(Size(150, 50), "sprite9_btn1.png", "sprite9_btn2.png");
		pButton->setPosition(Vec2(150.0f / 2, 54.0f / 2));
//		pButton->getLabel()->setFontSize(25.0f);
		pButton->setTag(1);
		pCell->addChild(pButton);
	}
	else
	{
		pButton = (CButton*) pCell->getChildByTag(1);
	}

	pButton->getLabel()->setString(m_vDatas[idx].c_str());
	pButton->setUserTag(idx);

	return pCell;
}
예제 #4
0
CCObject* CTableViewBindingDataAndVertical::tableviewDataSource(CCObject* pConvertView, unsigned int idx)
{
	CTableViewCell* pCell = (CTableViewCell*)pConvertView;
	CButton* pButton = NULL;

	if(!pCell)
	{
		pCell = new CTableViewCell();
		pCell->autorelease();

		pButton = CButton::createWith9Sprite(CCSizeMake(150, 50), "sprite9_btn1.png", "sprite9_btn2.png");
		pButton->setOnClickListener(this, ccw_click_selector(CTableViewBindingDataAndVertical::onClick));
		pButton->setPosition(CCPoint(150.0f / 2, 54.0f / 2));
		pButton->getLabel()->setFontSize(25.0f);
		pButton->setTag(1);
		pCell->addChild(pButton);
	}
	else
	{
		pButton = (CButton*) pCell->getChildByTag(1);
	}

	pButton->getLabel()->setString(m_vDatas[idx].c_str());
	pButton->setUserTag(idx);

	return pCell;
}
예제 #5
0
void CStrengthenItem::onSetFilter(const TMessage& tMsg)
{
	m_itemList.clear();

	vector<int> *filt = (vector<int> *)tMsg.lParam;

	m_filterVec = *filt;

	for (int i=0; i<m_itemData.itemList.size(); ++i)
	{
		CItem *item =(CItem*)(&m_itemData.itemList.at(i));

		bool isAdd = false;
		for (int j = 0; j < filt->size(); j++)
		{
			
			if (item->armor.armorType == filt->at(j))
			{
				if (tMsg.nMsg == 2)
				{
					isAdd = true;
				}
				else if (tMsg.nMsg == 0&&tMsg.nMsg==item->armor.hero)
				{
					isAdd = true;
				}
				else if (tMsg.nMsg == 1&& item->armor.hero>0)
				{  
					isAdd = true;
				}
				else
				{
					isAdd = false;
				}
				break;
			}
		}
		if (isAdd)
		{
			m_itemList.push_back(&m_itemData.itemList.at(i));
		}
	}

	//排序
	std::sort(m_itemList.begin(), m_itemList.end(), SortItem);
	m_tableView->setCountOfCell(m_itemList.size());
	m_tableView->reloadData();

	CLayout *attribute = (CLayout*)(m_ui->findWidgetById("attr"));
	attribute->setVisible(false);

	if (m_itemList.size()>0)
	{
		CTableViewCell *cell = (CTableViewCell*)m_tableView->getCells()->objectAtIndex(0);
		onTouchItem(cell->getChildByTag(1));
	}
}
예제 #6
0
void CSharpTollgate::heroCall(CCNode* pNode)
{
	CTableViewCell *node = (CTableViewCell*)pNode;
	CButton *btn = (CButton*)node->getChildByTag(1);
	//人物会动
	CCScaleTo *tobig = CCScaleTo::create(0.55f,1.0*btn->getScaleX(),1.0*btn->getScaleY());
	CCScaleTo *toSmall = CCScaleTo::create(0.55f,0.96*btn->getScaleX(), 0.96*btn->getScaleY());
	btn->runAction(CCRepeatForever::create(CCSequence::create(toSmall,tobig,nullptr)));
}
예제 #7
0
void CStrengthenItem::recItemData(int type, google::protobuf::Message *msg)
{
	if(!this->isVisible())
	{
		this->setVisible(true);
		NOTIFICATION->postNotification(HIDE_TOP_LAYER);
	}

	WareHouseResponse *res = (WareHouseResponse*)msg;
	m_itemData.read(*res);

	//1把可用的先加进来(其实不可用也应该加进来显示,因为引导的情况特殊,放在下面进行补加)
	for (int i=0; i<m_itemData.itemList.size(); ++i)
	{
		if (m_itemData.itemList.at(i).canUse)
		{
			m_itemList.push_back(&(m_itemData.itemList.at(i)));
		}
	}


	//2.引导有特殊处理的地方,并把不可用的补加进来
	bool isInsert = false;
	for (int i=0; i<m_itemData.itemList.size(); ++i)
	{
		if (!m_itemData.itemList.at(i).canUse)
		{
			if (CGuideManager::getInstance()->getIsRunGuide()&&(CGuideManager::getInstance()->getCurrTask()==5||CGuideManager::getInstance()->getCurrTask()==20)&&m_itemData.itemList.at(i).itemId==11011&&!isInsert)
			{
				m_itemList.insert(m_itemList.begin(),&(m_itemData.itemList.at(i)));
				isInsert =true;
			}
			else
			{
				m_itemList.push_back(&(m_itemData.itemList.at(i)));
			}
		}
	}

	//列表为空,弹窗告知
	if (m_itemList.size()<=0)
	{
		int iType = m_iAskType;

		LayerManager::instance()->pop();
		LayerManager::instance()->pop();

		switch (iType)
		{
		case CStrengthenItemTypeItemLevelUp:ShowPopTextTip(GETLANGSTR(1225));
			break;
		case CStrengthenItemTypeItemReset:ShowPopTextTip(GETLANGSTR(1226));
			break;
		case CStrengthenItemTypeItemStarUp:ShowPopTextTip(GETLANGSTR(1227));
			break;
		case CStrengthenItemTypeOthers:ShowPopTextTip(GETLANGSTR(220));
			break;
		default:
			break;
		}

		return;
	}

	//有引导的情况不排序
	if (!CGuideManager::getInstance()->getIsRunGuide())
	{
		std::sort(m_itemList.begin(), m_itemList.end(), SortItem);
	}
	m_tableView->setCountOfCell(m_itemData.itemList.size());
	bool isAutoRoll = autoRoll();

	if(!isAutoRoll)
	{
		m_tableView->reloadData();
		CTableViewCell *cell = (CTableViewCell*)m_tableView->getCells()->objectAtIndex(0);
		onTouchItem(cell->getChildByTag(1));
	}		
	
	this->setVisible(true);
}