コード例 #1
0
ファイル: TableViewTest.cpp プロジェクト: Kudoo/Tui-x
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
ファイル: StrengthenItem.cpp プロジェクト: 54993306/Classes
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
ファイル: TableView.cpp プロジェクト: 110440/Tui-x
void CTableView::reloadData()
{
#if USING_LUA
	CCAssert(
		(m_nDataSourceAdapterScriptHandler != 0) ||
		(m_pDataSourceAdapterListener && m_pDataSourceAdapterHandler), "reloadData");
#else
	CCAssert(m_pDataSourceAdapterListener && m_pDataSourceAdapterHandler, "reloadData");
#endif
	CCAssert((int)m_tCellsSize.width != 0 && (int)m_tCellsSize.height != 0, "reloadData");
    CCAssert(m_eDirection != eScrollViewDirectionBoth, "reloadData");

	vector<CTableViewCell*>::iterator itr = m_vCellsUsed.begin();
	vector<CTableViewCell*>::iterator end = m_vCellsUsed.end();

	for(; itr != end; ++itr )
	{
		CTableViewCell* pCell = (*itr);
		m_vCellsFreed.pushBack(pCell);
		m_pContainer->removeChild(pCell, true);
		pCell->reset();
	}

	m_vCellsUsed.clear();

	m_sIndices.clear();
	m_vPositions.clear();
	this->updatePositions();
	this->setContentOffsetToTop();
    this->onScrolling();

	relocateContainer();
}
コード例 #4
0
ファイル: TableViewTest.cpp プロジェクト: Kudoo/Tui-x
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;
}
コード例 #5
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;
}
コード例 #6
0
ファイル: StrengthenItem.cpp プロジェクト: 54993306/Classes
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));
	}
}
コード例 #7
0
ファイル: SharpTollgate.cpp プロジェクト: 54993306/Classes
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)));
}
コード例 #8
0
ファイル: Bagui.cpp プロジェクト: 110440/Tui-x
Ref* Bagui::event_adapt_tblBag(Ref* pConvertCell, unsigned int uIdx)
{
	CTableViewCell* pCell = (CTableViewCell*)pConvertCell;
	if (!pCell)
	{
		pCell = new CTableViewCell();
		pCell->autorelease();

		TuiManager::getInstance()->parseCell(pCell, "cell_grid", PATH_BAG);
	}else{

	}
	return pCell;
}
コード例 #9
0
ファイル: TableView.cpp プロジェクト: 110440/Tui-x
CTableViewCell* CTableView::dequeueCell()
{
	CTableViewCell* pCell = NULL;
    if( m_vCellsFreed.empty() )
    {
        return NULL;
    }
    else
    {
		pCell = m_vCellsFreed.back();
		m_vCellsFreed.popBack();
        pCell->autorelease();
    }
    return pCell;
}
コード例 #10
0
ファイル: HandBookHero.cpp プロジェクト: 54993306/Classes
CCObject* CHandBookHeroLayer::tableviewDataSource( CCObject* pConvertCell, unsigned int uIdx )
{
	CTableViewCell *pCell = (CTableViewCell*)(pConvertCell);
	if (!pCell)
	{
		pCell = new CTableViewCell;
		pCell->autorelease();
		addTableCell(uIdx, pCell);
	}
	else
	{
		pCell->removeAllChildren();
		addTableCell(uIdx, pCell);
	}
	return pCell;
}
コード例 #11
0
ファイル: TableView.cpp プロジェクト: 110440/Tui-x
void CTableView::updateCellAtIndex(unsigned int idx)
{
	CTableViewCell* pCell = (CTableViewCell*)(executeDataSourceAdapterHandler(dequeueCell(), idx));
#if 1
    CCAssert(pCell != NULL, "cell can not be nil");
#endif

	pCell->setIdx(idx);

	switch(m_eDirection)
	{
	case eScrollViewDirectionHorizontal:
		pCell->setAnchorPoint(Vec2::ZERO);
		break;
	default:
		pCell->setAnchorPoint(Vec2(0, 1));
		break;
	}
	
	pCell->setContentSize(m_tCellsSize);
	pCell->setPosition(cellPositionFromIndex(idx));

    m_pContainer->addChild(pCell);
	insertSortableCell(pCell, idx);
    pCell->retain();

	m_sIndices.insert(idx);
}
コード例 #12
0
ファイル: SharpTollgate.cpp プロジェクト: 54993306/Classes
void CSharpTollgate::setStageList(const vector<CStage>& stageList, int chapter, int openChapter)
{
	m_stageList = stageList;
	m_chapter = chapter;	
	m_openChapter = openChapter;
	m_tableView->setCountOfCell(stageList.size());
	m_tableView->reloadData();

	CTableViewCell *cell = m_tableView->cellAtIndex(3);
	cell->setPositionX(cell->getPositionX()+115);

	CImageView *name = (CImageView*)(m_ui->findWidgetById("name"));
	CCTexture2D *texture = CCTextureCache::sharedTextureCache()->addImage(CCString::createWithFormat("tollgate/chapter_%d.png",chapter)->getCString());
	if(!texture)
	{
		texture = CCTextureCache::sharedTextureCache()->addImage("tollgate/chapter_1.png");
	}
	name->setTexture(texture);
	name->setTextureRect(CCRectMake(0,0,texture->getContentSize().width,texture->getContentSize().height));
}
コード例 #13
0
ファイル: StrengthenItem.cpp プロジェクト: 54993306/Classes
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);
}
コード例 #14
0
ファイル: TableView.cpp プロジェクト: 110440/Tui-x
void CTableView::onScrolling()
{
	if( m_uCellsCount == 0 )
		return;

    unsigned uBeginIdx = 0, uEndIdx = 0;

	uBeginIdx = cellBeginIndexFromOffset( getContentOffset() );
	uEndIdx = cellEndIndexFromOffset( getContentOffset() );
	
#if 0
	CCLOG("cell begin %u  end %u", uBeginIdx, uEndIdx);
#endif

	while( !m_vCellsUsed.empty() )
    {
        CTableViewCell* pCell = m_vCellsUsed.front();
		unsigned int uIdx = pCell->getIdx();

        if( uIdx < uBeginIdx )
        {
			m_sIndices.erase(uIdx);
			m_vCellsUsed.erase(m_vCellsUsed.begin());
            m_vCellsFreed.pushBack(pCell);
            pCell->reset();
            m_pContainer->removeChild(pCell, true);
        }
        else
        {
            break;
        }
    }

	while( !m_vCellsUsed.empty() )
    {
        CTableViewCell* pCell = m_vCellsUsed.back();
		unsigned int uIdx = pCell->getIdx();

        if( uIdx > uEndIdx && uIdx < m_uCellsCount )
        {
			m_sIndices.erase(uIdx);
			m_vCellsUsed.popBack();
            m_vCellsFreed.pushBack(pCell);
            pCell->reset();
            m_pContainer->removeChild(pCell, true);
        }
        else
        {
            break;
        }
    }
    
    for( unsigned int idx = uBeginIdx; idx <= uEndIdx && idx < m_uCellsCount; ++idx )
    {
		if( m_sIndices.find(idx) != m_sIndices.end() )
		{
			continue;
		}
		updateCellAtIndex(idx);
    }
}