bool CExpandableListViewBasicTest::init()
{
	CExpandableListViewTestSceneBase::init();
	setTitle("CExpandableListViewBasicTest");
	setDescription("click item to expand");
	
	pListView = CExpandableListView::create(CCSize(320, 390));
	pListView->setBackgroundImage("background2.png");
	pListView->setPosition(CCPoint(480, 320));
	m_pWindow->addChild(pListView);

	for( int i = 0; i < 10; i++ )
	{
		CExpandableNode* pExpandableNode = CExpandableNode::create();
		pExpandableNode->setContentSize(CCSize(320, 50));
		pListView->insertExpandableNodeAtLast(pExpandableNode);

		CImageViewScale9* pExpandableNodeBg = CImageViewScale9::create(CCSize(320, 45), "expandnodebg.png");
		pExpandableNodeBg->setPosition(CCPoint(320/2, 50/2));
		pExpandableNode->addChild(pExpandableNodeBg);

		CButton* pColBtn = CButton::createWith9Sprite(CCSize(35, 35), "sprite9_btn1.png", "sprite9_btn2.png");
		pColBtn->setPosition(ccp(320 - 30, 50 / 2));
		pColBtn->setText("-");
		pColBtn->setUserTag(i);
		pColBtn->setOnClickListener(this, ccw_click_selector(CExpandableListViewBasicTest::onClick));
		pExpandableNode->addChild(pColBtn);

		char buff[64] = {0};
		sprintf(buff, "ExpandableNode : %d", i);
		CLabel* pTitleLabel = CLabel::create(buff, "", 28);
		pTitleLabel->setPosition(CCPoint(10, 50/2));
		pTitleLabel->setAnchorPoint(CCPoint(0, 0.5));
		pExpandableNode->addChild(pTitleLabel);


		sprintf(buff, "Label %d - 1", i);
		pExpandableNode->insertItemNodeAtLast(CLabel::create(buff, "", 30));
		sprintf(buff, "Label %d - 2", i);
		pExpandableNode->insertItemNodeAtLast(CLabel::create(buff, "", 30));
		sprintf(buff, "Label %d - 3", i);
		pExpandableNode->insertItemNodeAtLast(CLabel::create(buff, "", 30));
		
		CButton* pButton = CButton::createWith9Sprite(CCSize(150, 38), "sprite9_btn1.png", "sprite9_btn2.png");
		pButton->setOnClickListener(this, ccw_click_selector(CExpandableListViewBasicTest::onClick));
		pButton->initText("collapse", "", 28);
		pButton->setUserTag(i);
		pButton->setPosition(CCPoint(100, 40/2));
		CLayout* pBtnLayout = CLayout::create(CCSize(320, 40));
		pBtnLayout->addChild(pButton);
		pExpandableNode->insertItemNodeAtLast(pBtnLayout);
	}

	pListView->reloadData();
	

	return true;
}
Esempio n. 2
0
void LoginLayerUC::initLogin()
{
	CCLOG("LoginLayerUC::initLogin");

	if(m_ui!=nullptr)
	{
		return;
	}

	//播放背景音乐
	PlayBackgroundMusic(BGM_Login,true);

	m_ui = LoadComponent("EnterGameUC.xaml");
	m_ui->setTag(1);
	m_ui->setPosition(VCENTER);
	m_LayoutRoot->addChild(m_ui, 2);

	//自己的登陆框隐藏
	m_pLoginLay = (CLayout *)m_ui->getChildByTag(10);
	m_pLoginLay->setVisible(false);

	//选择好的服务器列表
	m_pCurrentServerUI = (CLayout *)m_ui->findWidgetById("current_server");
	m_pCurrentServerUI->setVisible(true);


	//默认服务器
	updateSelectServer();

	//服务器选区
	CLayout* pLayout = (CLayout*)m_ui->findWidgetById("serverCell");
	pLayout->retain();
	m_ui->removeChild(pLayout);
	m_pCell = pLayout;

	//获取空的滑动列表Scroll
	m_pTableView = (CTableView*)m_ui->findWidgetById("serverScroll");
	m_pTableView->setDirection(eScrollViewDirectionVertical);
	m_pTableView->setSizeOfCell(m_pCell->getContentSize());
	m_pTableView->setCountOfCell(m_serverInfo.server_list().size());
	m_pTableView->setBounceable(true);
	m_pTableView->setDataSourceAdapter(this, ccw_datasource_adapter_selector(LoginLayerUC::tableviewDataSource));
	m_pTableView->reloadData();


	//按钮打开服务器列表
	CImageView* pBtnServer = (CImageView*)m_ui->findWidgetById("serverBtn");


	//快速登录按钮
	CButton * pQuickLogin = (CButton *)m_ui->getChildByTag(1);
	pQuickLogin->setOnClickListener(this,ccw_click_selector(LoginLayerUC::onQuickLogin));
	CCActionInterval *scaleSmall = CCScaleTo::create(0.9f,0.98f);
	CCFadeTo *out = CCFadeTo::create(0.9f,60);
	CCSpawn *spawn = CCSpawn::createWithTwoActions(scaleSmall,out);
	CCActionInterval *scaleBig = CCScaleTo::create(1.2f,1.0f);
	CCFadeTo *in = CCFadeTo::create(1.2f,255);
	CCSpawn *spawn1 = CCSpawn::createWithTwoActions(scaleBig,in);
	CCSequence *seque = CCSequence::createWithTwoActions(spawn,spawn1);
	CCRepeatForever *action = CCRepeatForever::create(seque);
	pQuickLogin->runAction(action);
	pQuickLogin->setVisible(true);

	//清除用户信息
	DataCenter::sharedData()->getUser()->clear();

	//版本做相对位置处理
	CLabel* pLabel = (CLabel *)m_ui->findWidgetById("version");
	pLabel->setAnchorPoint(ccp(1.0f, 0.0f));
	pLabel->setPosition(ccp(VRIGHT-20, VBOTTOM+20));
	CC_SAFE_RETAIN(pLabel);
	pLabel->removeFromParentAndCleanup(true);
	this->addChild(pLabel);
	CC_SAFE_RELEASE(pLabel);
	pLabel->setString(CCString::createWithFormat("Version:%s", m_serverInfo.game_version().c_str())->getCString());


	//隐藏服务器列表
	showServerList();
	hideServerList();


	//TODO
	//初始化UC_SDK?-放在最前面
	//还是点击登录再初始化?
	//点击登录再初始化吧
	//初始化完直接请求登录


	//先连接连接服务器
	const Server& gameServer = m_serverInfo.server_list().Get(m_iSelectServerIndex);

	//检查服务器是否可用
	if(!checkServerStatus(gameServer))	
	{
		return;
	}

	LinkedGameServer(gameServer);
}