Exemplo n.º 1
0
bool CCheckBoxBasicTest::init()
{
	CCheckBoxTestSceneBase::init();
	setTitle("CCheckBoxBasicTest");
	setDescription("checkbox face, click it");

	CCheckBox* pCheckBox = CCheckBox::create();
	pCheckBox->setNormalImage("ckb_normal_01.png");
	pCheckBox->setNormalPressImage("ckb_normal_02.png");
	pCheckBox->setCheckedImage("ckb_selected_01.png");
	pCheckBox->setCheckedPressImage("ckb_selected_02.png");
	pCheckBox->setDisabledNormalImage("ckb_disable_01.png");
	pCheckBox->setDisabledCheckedImage("ckb_disable_02.png");
	pCheckBox->setOnClickListener(this, ccw_click_selector(CCheckBoxBasicTest::onClick));
	pCheckBox->setPosition(CCPoint(480, 320));
	m_pWindow->addChild(pCheckBox);

	CCheckBox* pCheckBox2 = CCheckBox::create();
	pCheckBox2->setNormalImage("ckb_normal_01.png");
	pCheckBox2->setCheckedImage("ckb_selected_01.png");
	pCheckBox2->setOnClickListener(this, ccw_click_selector(CCheckBoxBasicTest::onClick));
	pCheckBox2->setPosition(CCPoint(560, 320));
	m_pWindow->addChild(pCheckBox2);

	m_pText = CLabel::create();
	m_pText->setAnchorPoint(CCPoint(0, 0.5));
	m_pText->setPosition(CCPoint(380, 400));
	m_pText->setFontSize(35.0f);
	m_pText->setString("none");
	m_pWindow->addChild(m_pText);

	return true;
}
Exemplo n.º 2
0
NS_MAIN_BEGIN

void Mainui::onLoadScene()
{
	setAutoRemoveUnusedTexture(true);
	TuiManager::getInstance()->parseScene(this,"panel_main",PATH_MAIN);

	//注册事件
	CControlView *ctlv = (CControlView*)this->getControl(PANEL_MAIN,CTLV_LEFT);
	ctlv->setOnControlListener(this,ccw_control_selector(Mainui::event_ctlv_left));

	CButton *pBtnOk = (CButton*)this->getControl(PANEL_MAIN,BTN_OK);
	pBtnOk->setOnClickListener(this,ccw_click_selector(Mainui::event_btn_ok));

	CButton *pBtnGo = (CButton*)this->getControl(PANEL_MAIN,BTN_GO);
	pBtnGo->setOnClickListener(this,ccw_click_selector(Mainui::event_btn_go));

	CButton *pShowPhone = (CButton*)this->getControl(PANEL_MAIN, BTN_SHOWPHONE);
	pShowPhone->setOnClickListener(this, ccw_click_selector(Mainui::event_btn_showphone));

	CToggleView *pTgvA = (CToggleView*)this->getControl(PANEL_MAIN, TGV_A);
	pTgvA->setOnCheckListener(this, ccw_check_selector(Mainui::event_tgvA_check));

	CToggleView *pTgvB = (CToggleView*)this->getControl(PANEL_MAIN, TGV_B);
	pTgvB->setOnCheckListener(this, ccw_check_selector(Mainui::event_tgvB_check));

	MovieView *pMovie = (MovieView*)this->getControl(PANEL_MAIN, MOVIE_TEST);
	map<string, function<void()>> m;
	m["finish"] = bind(&Mainui::event_movie_finish, this);
	pMovie->setCallBack(m);

	//播放骨骼动画(默认不播放)
	Armature *armature = (Armature*)this->getControl(PANEL_MAIN,ARMATURE_BOSS1);
	armature->getAnimation()->play("live",-1,1);
}
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;
}
Exemplo n.º 4
0
void CCommandLayer::onEnter()
{ 
	BaseLayer::onEnter();

	CButton *btn= (CButton *)m_ui->findWidgetById("close");
	btn->setOnClickListener(this,ccw_click_selector(CCommandLayer::onClose));

	m_cell = (CLayout*)(m_ui->findWidgetById("Cell"));
	m_cell->retain();
	m_ui->removeChild(m_cell);

	m_comLayer = (CLayout*)(m_ui->findWidgetById("pose"));
	m_garrsionLayer = (CLayout*)(m_ui->findWidgetById("garrsion"));

	m_tableView = (CTableView *)(m_ui->findWidgetById("scroll"));
	m_tableView->setDirection(eScrollViewDirectionVertical);
	m_tableView->setSizeOfCell(m_cell->getContentSize());
	m_tableView->setCountOfCell(0);
	m_tableView->setBounceable(false);
	m_tableView->setDataSourceAdapter(this,ccw_datasource_adapter_selector(CCommandLayer::tableviewDataSource));
	m_tableView->reloadData();

	m_selectCellImg = (CCSprite*)(m_ui->findWidgetById("selectImg"));
	m_selectCellImg->retain();

	CSceneManager::sharedSceneManager()->addMsgObserver("updateHero",this, GameMsghandler_selector(CCommandLayer::updateHero));

	CRadioBtnGroup *radioGroup = (CRadioBtnGroup *)m_ui->getChildByTag(10);
	for (int i = 0; i < 2; i++)
	{
		CRadioButton *radioBtn= (CRadioButton*)(radioGroup->getChildByTag(i+1));
		radioBtn->setOnCheckListener(this,ccw_check_selector(CCommandLayer::onSwitchBtn));
	}

	CButton *compose = (CButton *)(m_comLayer->findWidgetById("strengthen"));
	compose->setOnClickListener(this,ccw_click_selector(CCommandLayer::onComposeButton));
	compose->setDisabledImageColor();

	m_ui->setScale(0.0f);
	CCScaleTo *big = CCScaleTo::create(0.2f,1.0f);
	m_ui->runAction(big);

	GetTcpNet->registerMsgHandler(BuildInfo,this,CMsgHandler_selector(CCommandLayer::recBuildInfo));
	GetTcpNet->registerMsgHandler(CommanderMsg,this,CMsgHandler_selector(CCommandLayer::processNetMsg));
	//GetTcpNet->registerMsgHandler(ComposeItemMsg,this,CMsgHandler_selector(CCommandLayer::processNetMsg));
	GetTcpNet->registerMsgHandler(LevelUpMsg,this,CMsgHandler_selector(CCommandLayer::processNetMsg));

	for (int i=1; i<=3; ++i)
	{
		CButton *btn = dynamic_cast<CButton*>(m_garrsionLayer->getChildByTag(i));
		btn->setOnClickListener(this,ccw_click_selector(CCommandLayer::onGarrsion));
	}

	showSelectRadioImg(2);

}
Exemplo n.º 5
0
bool ViewScene::init(string unitid, string ziid, string curChar){
	CCLog("ViewScene init");
	if (!CCLayerColor::initWithColor(ccc4(255,255,255,255)))
	{
		return false;
	}

	this->unit_id = unitid;
	this->zi_id = ziid;
	this->currentChar = curChar;
 	Notes = SQLiteData::getNote(unit_id,zi_id);

	CCSize winSize = CCDirector::sharedDirector()->getWinSize();
	CCSize visiableSize = CCDirector::sharedDirector()->getVisibleSize();

	CCSprite* titlebar = CCSprite::create("strangedesign/title bar_background.png");
	addChild(titlebar);
	titlebar->setPosition(ccp(visiableSize.width/2,visiableSize.height-titlebar->getContentSize().height/2));

	CWidgetWindow* m_pWindow = CWidgetWindow::create();
	m_pWindow->setMultiTouchEnabled(true);
	addChild(m_pWindow);

	CButton* backBtn = CButton::create("strangedesign/back_button.png", "strangedesign/back_button_down.png");
	backBtn->setOnClickListener(this,ccw_click_selector(ViewScene::back));
	backBtn->setPosition(ccp(backBtn->getContentSize().width/2+10, visiableSize.height -backBtn->getContentSize().height/2-50));
	m_pWindow->addChild(backBtn);

	CButton* deleteBtn = CButton::create("strangedesign/Free_writting_delete_button_up.png","strangedesign/Free_writting_delete_button_down.png");
	deleteBtn->setOnClickListener(this, ccw_click_selector(ViewScene::deleteBtnClick));
	deleteBtn->setPosition(ccp(winSize.width-deleteBtn->getContentSize().width/2, winSize.height-deleteBtn->getContentSize().height/2));
	m_pWindow->addChild(deleteBtn);

	CCSize visualSize = CCSizeMake(winSize.width,winSize.height-titlebar->getContentSize().height-10);
	CCSize gridcellSize = CCSizeMake(360 , 350);
	writingCount = Notes.size();
	pGridView = CGridView::create(visualSize,
		gridcellSize,
		writingCount,
		this,
		ccw_datasource_adapter_selector(ViewScene::gridViewDataSource));
	pGridView->setColumns(2);
	pGridView->setPosition(CCSize(winSize.width/2,(winSize.height-titlebar->getContentSize().height)/2));
	pGridView->setAutoRelocate(true);
	pGridView->reloadData();
	m_pWindow->addChild(pGridView);
	return true;
}
Exemplo n.º 6
0
bool SetPanel::init()
{
	bool res = CCNode::init();
	do 
	{
		if(!res)break;
		CWidgetWindow* layout = CWidgetWindow::create();
		layout->setTag(1);
		layout->setTouchPriority(-4);
		addChild(layout);
		m_panel = LoadComponent("SetPanel.xaml");
		
		if(!m_panel) break;
		m_panel->retain();
		m_panel->setPosition(CCSizeCenter(m_panel->getContentSize()));
		this->setContentSize(m_panel->getContentSize());
		this->setAnchorPoint(CCPointCenter);
		layout->addChild(m_panel);
		for(int i = 1; i <=5; ++i)
		{
			CButton* button = (CButton*)m_panel->getChildByTag(i);
			button->setOnClickListener(this,ccw_click_selector(SetPanel::onClick));
		}
		res = true;
	} while (0);
	return res;
}
Exemplo n.º 7
0
bool CButtonChangeSizeTest::init()
{
	CButtonTestSceneBase::init();
	setTitle("CButtonChangeSizeTest");
	setDescription("click the button for change anothor one");

	m_lData.push_back("a");
	m_lData.push_back("ab");
	m_lData.push_back("abc");
	m_lData.push_back("abcd");
	m_lData.push_back("abcde");
	m_lData.push_back("abcdef");
	m_lData.push_back("abcdefg");
	m_lData.push_back("abcdefgi");
	m_lData.push_back("abcdefgj");
	m_lData.push_back("hahahahaha\nhehehehehe");
	m_lData.push_back("hahahahaha\nhehehehehe\nkukukukukukukuku");

	m_pButton = CButton::create();
	m_pButton->setScale9Enabled(true);
	m_pButton->setNormalImage("sprite9_btn1.png");
	m_pButton->setSelectedImage("sprite9_btn2.png");
	m_pButton->initText("none", "", 30.0f);
	m_pButton->setCascadeTextSizeEnabled(true, CCSize(50, 30));
	m_pButton->setPosition(CCPoint(480, 320));
	m_pWindow->addChild(m_pButton);

	CButton* pBtn = CButton::createWith9Sprite(CCSizeMake(150, 50), "sprite9_btn1.png", "sprite9_btn2.png");
	pBtn->setPosition(CCPoint(250, 320));
	pBtn->initText("click me", "", 27.0f);
	pBtn->setOnClickListener(this, ccw_click_selector(CButtonChangeSizeTest::onClick));
	m_pWindow->addChild(pBtn);

	return true;
}
Exemplo n.º 8
0
bool CButtonLongClickTest::init()
{
	CButtonTestSceneBase::init();
	setTitle("CButtonLongClickTest");
	setDescription("drag the 2s button after long click\n (the touch event will back to WidgetWindow after long click)");

	CButton* pButton1 = CButton::create("btn1_1.png", "btn1_2.png", "btn1_3.png");
	pButton1->setOnClickListener(this, ccw_click_selector(CButtonLongClickTest::onClick));
	pButton1->setOnLongClickListener(this, ccw_longclick_selector(CButtonLongClickTest::onButton1LongClick));
	pButton1->setPosition(CCPoint(350, 320));
	m_pWindow->addChild(pButton1);

	m_pText1 = CLabel::create();
	m_pText1->setAnchorPoint(CCPoint(0, 0.5));
	m_pText1->setPosition(CCPoint(260, 430));
	m_pText1->setFontSize(35.0f);
	m_pText1->setString("none");
	m_pWindow->addChild(m_pText1);

	m_pWindow->setOnTouchMovedAfterLongClickListener(this, ccw_afterlongclick_selector(CButtonLongClickTest::onLayoutTouchMovedAfterLongClick));

	m_pText2 = CLabel::create();
	m_pText2->setAnchorPoint(CCPoint(0, 0.5));
	m_pText2->setPosition(CCPoint(520, 430));
	m_pText2->setFontSize(35.0f);
	m_pText2->setString("drag after long click!");
	m_pWindow->addChild(m_pText2);

	pButton2 = CButton::create("btn1_1.png", "btn1_2.png", "btn1_3.png");
	pButton2->setOnLongClickListener(this, ccw_longclick_selector(CButtonLongClickTest::onButton2LongClick));
	pButton2->setPosition(CCPoint(610, 320));
	m_pWindow->addChild(pButton2);

	return true;
}
Exemplo n.º 9
0
Ref* CTableViewBindingDataAndVertical::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->setOnClickListener(this, ccw_click_selector(CTableViewBindingDataAndVertical::onClick));
		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;
}
Exemplo n.º 10
0
void CHeroExpItem::addTableCell(unsigned int uIdx, CTableViewCell * pCell)
{
	CLayout *lay = UICloneMgr::cloneLayout(m_cell);

	const CEvolQuest &evol = m_evolInfo.questsList.at(uIdx);
	const TaskData *task = DataCenter::sharedData()->getTask(Evole_Task)->getCfg(evol.id);
	for (int i = 1; i <=4; i++)
	{
		CCNode *child = lay->getChildByTag(i);
		lay->removeChild(child);
		pCell->addChild(child);

		if (i==1)
		{
			CImageView *bgView= (CImageView*)child;
			bgView->setTouchEnabled(true);
		    bgView->setUserData(&m_evolInfo.questsList.at(uIdx));
			bgView->setOnClickListener(this, ccw_click_selector(CHeroExpItem::onRecvTask));
		}
		else if (i==2)
		{
			CLabel *taskName = (CLabel*)child;
			taskName->setString(task->taskName.c_str());
		}
		else if (i==3)
		{
			CLabel *taskDesc = (CLabel*)child;
			taskDesc->setString(task->taskDesc.c_str());
		}
		else if (i==4)
		{
			child->setVisible(evol.pass);
		}
	}
}
Exemplo n.º 11
0
bool NumericStepper::init() {

    m_btnLeft = CButton::create();
    m_btnRight = CButton::create();
    m_bg = CImageView::create();
    m_labNum = CLabel::createWithSystemFont("15","",m_bg->getContentSize().height-2,m_bg->getContentSize(),TextHAlignment::CENTER);

    m_btnLeft->setOnClickListener(this,ccw_click_selector(NumericStepper::event_btn_left));
    m_btnRight->setOnClickListener(this,ccw_click_selector(NumericStepper::event_btn_right));

    this->addChild(m_btnLeft);
    this->addChild(m_btnRight);
    this->addChild(m_bg);
    this->addChild(m_labNum);
    return true;
}
Exemplo n.º 12
0
bool CQuickProduct::init()
{
	if (CCNode::init())
	{
// 		CPopTip *tip = CPopTip::create("tips/bg.png");
// 		tip->addBeforeImage("tips/blackbg.png",0,20);
// 		tip->addButton("public/btn_yellow_befor.png","public/btn_yellow_after.png",nullptr,1,1);
// 		tip->addButton("public/btn_yellow_befor.png","public/btn_yellow_after.png",nullptr,2,1);//font_kuaisushengchan
// 		tip->addBeforeImage("public/font_kuaisushengchan.png",0,145);
// 
// 		tip->setBottomOffset(-10);
// 		tip->setTouchEnabled(true);
// 		tip->setTouchPriority(-100);
// 
// 		tip->buttonAddImage("public/font_queiding.png",1);
// 		tip->buttonAddImage("public/font_quxiao.png",2);
// 
// 		//tip->addContentTip("使用一粒鑽石,可以即時獲得2小時內的資源,確定要使用鑽石嗎?",ccRED,"Arail",50.0f,18.0f);
// 		tip->addTextRichTip("使用一粒",ccWHITE,"Arail",18.0f);
// 		tip->addRichImage("mainCity/icon_17.png");
// 		tip->addTextRichTip(",可以即時獲得2小時內的資源,",ccWHITE,"Arail",18.0f);
// 		tip->addTextRichTip("\n確定要使用嗎?",ccWHITE,"Arail",18.0f);
// 		tip->reloadTextRich(ccp(VCENTER.x,VCENTER.y+30));
// 		tip->setButtonLisener(this,ccw_click_selector(CQuickProduct::onUserStone));
// 		this->addChild(tip,10,1);
// 
// 		tip->runScaleAction();
		ShowConfirmTextTip(GETLANGSTR(111),this,ccw_click_selector(CQuickProduct::onUserStone));
		return true;
	}
	return false;
}
Exemplo n.º 13
0
void CVipCard::onEnter()
{
	BaseLayer::onEnter();
	//确定
	CButton* pConfirm = (CButton*)m_ui->findWidgetById("confirm");
	pConfirm->setOnClickListener(this, ccw_click_selector(CVipCard::onConfirm));

	CButton* cancel = (CButton*)m_ui->findWidgetById("cancel");
	cancel->setOnClickListener(this, ccw_click_selector(CVipCard::onCancel));

	CButton* pClose = CButton::create("common/back.png", "common/back.png");
	pClose->getSelectedImage()->setScale(1.1f);
	pClose->setPosition(VLEFT+50, VTOP-50);
	pClose->setOnClickListener(this,ccw_click_selector(CVipCard::onClose));
	this->addChild(pClose, 999);
	
	CImageViewScale9* pRect1 = (CImageViewScale9*)m_ui->findWidgetById("rect1");
	m_cardText = CursorTextField::textFieldWithPlaceHolder("", FONT_NAME, 29, CCSize(690, 110), ccBLACK);
	m_cardText->setPriority(this->getTouchPriority());
	m_cardText->setLimitNum(17);
	m_cardText->setAnchorPoint(ccp(0, 0.5f));
	m_cardText->setPosition( ccp(pRect1->getPositionX()-440, pRect1->getPositionY()));
	m_ui->addChild(m_cardText, 999);

	//展示区图片
	CLayout *pShowInfo = CLayout::create();

	CScrollView *pScroll = (CScrollView*)m_ui->findWidgetById("scroll_info");
	pScroll->setDirection(eScrollViewDirectionVertical);
	pScroll->setBounceable(false);
	pScroll->getContainer()->addChild(pShowInfo);

	CCSize size = CCSize(957, 471);
	pShowInfo->setContentSize(size);
	pScroll->setContainerSize(size);
	pShowInfo->setPosition(ccp(pScroll->getContainerSize().width*0.5f, pScroll->getContainerSize().height*0.5f));
	pScroll->setContentOffsetToTop();

	//嫁接内容
	CLayout* pLayout = (CLayout*)findWidgetById("layer_info");
	pLayout->retain();
	pLayout->removeFromParent();
	pShowInfo->addChild(pLayout);
	pLayout->release();
	pLayout->setPosition(ccp(size.width/2, size.height/2+10));

}
Exemplo n.º 14
0
void CHandBookHeroLayer::initCellIconByData( AData *pAData, CLayout *pCell )
{
	//message AData{
	//	optional int32 type = 1;		//类型 1英雄,2装备,3怪物
	//	optional int32 thumb = 2;		
	//	optional int32 color = 3;		//边框颜色
	//	optional int32 process = 4;		//英雄、装备代表进阶数,怪物代表击杀数
	//	optional int32 max_process = 5;
	//	optional int32 param = 6;
	//}


	Prize *prize = new Prize; 
	//获取数据
	int iType = 1;
	if ( pAData->type()==1 || pAData->type()==3 )
	{
		iType = 2;
	}
	int iColor = pAData->color();
	int iIconId = pAData->thumb();
	int iRank = pAData->process();

	string str = GetImageName(iType, iColor, iIconId);

	//图标
	CImageView* pBgRect = (CImageView *)pCell->findWidgetById("headBg");
	CImageView *itemSpr = CImageView::create(str.c_str());
	if (!itemSpr)
	{
		itemSpr = CImageView::create("prop/32003.png");
		CCLOG("[ ERROR ] CPopItem::addTableCell Lost Image = %d");
	}
	pBgRect->addChild(itemSpr);
	NodeFillParent(itemSpr);

	//品质+事件
	CImageView *mask= (CImageView *)pCell->findWidgetById("head");
	mask->setTexture(setItemQualityTexture(iColor));
	mask->setUserData(pAData);
	mask->setTag(iType);
	mask->setTouchEnabled(true);
	mask->setOnClickListener(this, ccw_click_selector(CHandBookHeroLayer::onShowRankUp));

	//进阶
	for ( int i=0; i<5; i++)
	{
		CImageView *pStar = (CImageView *)pCell->getChildByTag(i+3);
		//阶级到,点亮
		if (i<iRank)
		{
			pStar->setShaderProgram(ShaderDataMgr->getShaderByType(ShaderDefault));
		}
		else
		{
			pStar->setShaderProgram(ShaderDataMgr->getShaderByType(ShaderStone));
		}
	}
}
Exemplo n.º 15
0
bool CListViewOperateTest::init()
{
	CListViewTestSceneBase::init();
	setTitle("CListViewOperateTest");
	setDescription("Add or Remove operate");

	m_pListView = CListView::create(Size(480, 320));
	m_pListView->setBackgroundImage("background.png");
	m_pListView->setPosition(Vec2(480, 320));
	m_pListView->setDirection(eScrollViewDirectionVertical);
	m_pWindow->addChild(m_pListView);

	CButton* pButton = CButton::createWith9Sprite(Size(150, 50),
		"sprite9_btn1.png", "sprite9_btn2.png");
	pButton->setPosition(Vec2(150, 450));
	pButton->setUserTag(1);
	pButton->setOnClickListener(this, ccw_click_selector(CListViewOperateTest::onClick));
	pButton->initText("Add Last", "", 30);
	m_pWindow->addChild(pButton);

	CButton* pButton2 = CButton::createWith9Sprite(Size(150, 50),
		"sprite9_btn1.png", "sprite9_btn2.png");
	pButton2->setPosition(Vec2(150, 380));
	pButton2->setUserTag(2);
	pButton2->setOnClickListener(this, ccw_click_selector(CListViewOperateTest::onClick));
	pButton2->initText("Add Front", "", 30);
	m_pWindow->addChild(pButton2);

	CButton* pButton3 = CButton::createWith9Sprite(Size(150, 50),
		"sprite9_btn1.png", "sprite9_btn2.png");
	pButton3->setPosition(Vec2(150, 310));
	pButton3->setUserTag(3);
	pButton3->setOnClickListener(this, ccw_click_selector(CListViewOperateTest::onClick));
	pButton3->initText("Remove Last", "", 30);
	m_pWindow->addChild(pButton3);

	CButton* pButton4 = CButton::createWith9Sprite(Size(150, 50),
		"sprite9_btn1.png", "sprite9_btn2.png");
	pButton4->setPosition(Vec2(150, 240));
	pButton4->setUserTag(4);
	pButton4->setOnClickListener(this, ccw_click_selector(CListViewOperateTest::onClick));
	pButton4->initText("Remove Front", "", 30);
	m_pWindow->addChild(pButton4);

	return true;
}
Exemplo n.º 16
0
bool NumericStepper::init(const char *lnormal,const char *lselet,const char *ldisable,
                          const char *rnormal,const char *rselet,const char *rdisable,const char* bg) {

    m_btnLeft = CButton::create(lnormal,lselet,ldisable);
    m_btnRight = CButton::create(rnormal,rselet,rdisable);
    m_bg = CImageView::create(bg);
    m_labNum = CLabel::createWithSystemFont("15","",m_bg->getContentSize().height-2,m_bg->getContentSize(),TextHAlignment::CENTER);

    m_btnLeft->setOnClickListener(this,ccw_click_selector(NumericStepper::event_btn_left));
    m_btnRight->setOnClickListener(this,ccw_click_selector(NumericStepper::event_btn_right));

    this->addChild(m_btnLeft);
    this->addChild(m_btnRight);
    this->addChild(m_bg);
    this->addChild(m_labNum);
    resetSelf();
    return true;
}
Exemplo n.º 17
0
NS_STORE_BEGIN

void Storeui::onLoadScene()
{
	setAutoRemoveUnusedTexture(true);
	TuiManager::getInstance()->parseScene(this,"panel_store",PATH_STORE);

	CListView *pListGoods = (CListView*)this->getControl(PANEL_STORE, LIST_GOODS);
	Vector<Node*> vet = pListGoods->getContainer()->getChildren();
	for (Node *pNode : vet){
		CButton *pBtnPay = dynamic_cast<CButton*>(pNode->getChildByTag(BTN_PAY));
		pBtnPay->setOnClickListener(this, ccw_click_selector(Storeui::event_btn_pay));
	}

	ArmatureBtn *pBtn = (ArmatureBtn*)this->getControl(PANEL_STORE,ARMBTN_TEST2);
	pBtn->setOnClickListener(this,ccw_click_selector(Storeui::event_btn_test));

}
Exemplo n.º 18
0
NS_SHOWPHONE_BEGIN

void ShowPhoneui::onLoadScene()
{
    SpriteFrameCache::getInstance()->addSpriteFramesWithFile("showphone/showphoneui.plist");
    TuiManager::getInstance()->parseScene(this, "panel_showphone", PATH_SHOWPHONE);

    CircleMenu *menu = (CircleMenu*)this->getControl(PANEL_SHOWPHONE, CIRCLEMENU_SHOWPHONE);
    menu->setOnClickListener(this, ccw_click_selector(ShowPhoneui::event_menu_phone));
}
Exemplo n.º 19
0
NS_STORE_BEGIN

void Storeui::onLoadScene()
{
	setAutoRemoveUnusedTexture(true);
	TuiManager::getInstance()->parseScene(this,"panel_store");

	ArmatureBtn *pBtn = (ArmatureBtn*)this->getControl(PANEL_STORE,ARMBTN_TEST2);
	pBtn->setOnClickListener(this,ccw_click_selector(Storeui::event_btn_test));
}
Exemplo n.º 20
0
void Mapui::onLoadScene()
{
	TuiManager::getInstance()->parseScene(this,"panel_map",PATH_MAP);

    CMapView* pMapView = (CMapView*)this->getControl(PANEL_MAP,MAP_TEST);
	pMapView->setRole(Sprite::create("map/img_icon.png"),Vec2(0,0),5);
    
    CButton* pBtnBack = (CButton*)this->getControl(PANEL_MAP,BTN_BACK);
    pBtnBack->setOnClickListener(this, ccw_click_selector(Mapui::event_btn_back));
}
Exemplo n.º 21
0
bool CTableViewReloadTest::init()
{
	CTableViewTestSceneBase::init();
	setTitle("CTableViewReloadTest");
	setDescription("click button will pop a string into vector and reload\n table with auto relocate");

	m_lDataQueue.push_back("B");
	m_lDataQueue.push_back("C");
	m_lDataQueue.push_back("D");
	m_lDataQueue.push_back("E");
	m_lDataQueue.push_back("F");
	m_lDataQueue.push_back("G");
	m_lDataQueue.push_back("H");
	m_lDataQueue.push_back("I");
	m_lDataQueue.push_back("J");
	m_lDataQueue.push_back("K");
	m_lDataQueue.push_back("L");
	m_lDataQueue.push_back("M");
	m_lDataQueue.push_back("N");
	m_lDataQueue.push_back("O");
	m_lDataQueue.push_back("P");
	m_lDataQueue.push_back("Q");
	m_lDataQueue.push_back("R");
	m_lDataQueue.push_back("S");
	m_lDataQueue.push_back("T");
	m_lDataQueue.push_back("U");
	m_lDataQueue.push_back("V");
	m_lDataQueue.push_back("W");
	m_lDataQueue.push_back("X");
	m_lDataQueue.push_back("Y");
	m_lDataQueue.push_back("Z");

	m_vDatas.push_back("A");

	pTable = CTableView::create(
		Size(150.0f, 54.0f * 5),
		Size(150.0f, 54.0f),
		m_vDatas.size(), this, 
		ccw_datasource_adapter_selector(CTableViewReloadTest::tableviewDataSource));
	pTable->setDirection(eScrollViewDirectionVertical);
	pTable->setAutoRelocate(true);
	pTable->setPosition(Vec2(480, 320));
	m_pWindow->addChild(pTable);
	pTable->reloadData();

	CButton* pButton = CButton::createWith9Sprite(Size(150, 50), "sprite9_btn1.png", "sprite9_btn2.png");
	pButton->setOnClickListener(this, ccw_click_selector(CTableViewReloadTest::onClick));
	pButton->setPosition(Vec2(200, 320));
	//pButton->getLabel()->setFontSize(25.0f);
	pButton->getLabel()->setString("reloadData");
	m_pWindow->addChild(pButton);

	return true;
}
Exemplo n.º 22
0
void Recomebineui::onLoadScene()
{
	SpriteFrameCache::getInstance()->addSpriteFramesWithFile("recombine/recombineui.plist");
	TuiManager::getInstance()->parseScene(this, "panel_recombine", PATH_RECOMBINEUI);

	CGridPageView *pGpvBag = (CGridPageView*)this->getControl(PANEL_RECOMBINE, GPV_BAG);
	pGpvBag->setDataSourceAdapter(this,ccw_datasource_adapter_selector(Recomebineui::adapt_gpv_bag));
	pGpvBag->reloadData();

	CButton *pBtnBack = (CButton*)this->getControl(PANEL_RECOMBINE, BTN_BACK);
	pBtnBack->setOnClickListener(this, ccw_click_selector(Recomebineui::event_btn_back));
}
Exemplo n.º 23
0
NS_MAIN_BEGIN

void MsgBox::onLoadScene()
{
	SpriteFrameCache::getInstance()->addSpriteFramesWithFile("main/mainui.plist");
	TuiManager::getInstance()->parseScene(this,"panel_msgbox",PATH_MAIN);
	//注册事件
	CButton *pBtnClose = (CButton*)getControl(PANEL_MSGBOX, BTN_CLOSE);
	pBtnClose->setOnClickListener(this,ccw_click_selector(MsgBox::event_btn_close));
	
	CSlider *pSlider = (CSlider*)getControl(PANEL_MSGBOX,SLIDER_TEST);
	pSlider->setOnValueChangedListener(this,ccw_valuechanged_selector(MsgBox::event_slider_test));
}
Exemplo n.º 24
0
void CStrengthenItem::onEnter()
{
	BaseLayer::onEnter();

	m_cell = (CLayout*)(m_ui->findWidgetById("Cell"));
	m_cell->retain();
	m_ui->removeChild(m_cell);

	m_tableView = (CTableView *)(m_ui->findWidgetById("scroll"));
	m_tableView->setDirection(eScrollViewDirectionVertical);
	m_tableView->setSizeOfCell(m_cell->getContentSize());
	m_tableView->setCountOfCell(0);
	m_tableView->setBounceable(false);
	m_tableView->setDataSourceAdapter(this,ccw_datasource_adapter_selector(CStrengthenItem::tableviewDataSource));
	m_tableView->reloadData();

	CButton *select = (CButton*)(m_ui->findWidgetById("select"));
	select->setOnClickListener(this,ccw_click_selector(CStrengthenItem::onSelectItem));

	CButton *filter = (CButton*)(m_ui->findWidgetById("filter"));
	filter->setOnClickListener(this,ccw_click_selector(CStrengthenItem::onFilterItem));

	//退出
	CButton* pClose = CButton::create("common/back.png", "common/back.png");
	pClose->getSelectedImage()->setScale(1.1f);
	pClose->setPosition(VLEFT+50, VTOP-50);
	pClose->setOnClickListener(this,ccw_click_selector(CStrengthenItem::onClose));
	this->addChild(pClose, 999);

    m_selectCellImg = (CCSprite*)m_ui->findWidgetById("selimg");
	m_selectCellImg->retain();

	GetTcpNet->registerMsgHandler(RoleBag,this,CMsgHandler_selector(CStrengthenItem::recItemData));
	GetTcpNet->registerMsgHandler(ArmorListMsg,this,CMsgHandler_selector(CStrengthenItem::processNetMessage));

	CSceneManager::sharedSceneManager()->addMsgObserver("updateFilter",this,GameMsghandler_selector(CStrengthenItem::onSetFilter));
}
Exemplo n.º 25
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.º 26
0
bool MainScene::init(){
	CCLog("mainScene init enter");
	if (!CCLayerColor::initWithColor(ccc4(255,255,255,255)))
	{
		return false;
	}
	unit_count = SQLiteData::getUnitCount();
	unit_ids = SQLiteData::getUnitIDs();
	setKeypadEnabled(true);

	CWidgetWindow* m_pWindow = CWidgetWindow::create();
	m_pWindow->setMultiTouchEnabled(true);
	addChild(m_pWindow,4);
	
	CCSize winSize = CCDirector::sharedDirector()->getWinSize();
	CCSize visiableSize = CCDirector::sharedDirector()->getVisibleSize();

	CCSprite* titlebar = CCSprite::create("strangedesign/title bar_background.png");
	addChild(titlebar,1);
	titlebar->setPosition(ccp(visiableSize.width/2,visiableSize.height-titlebar->getContentSize().height/2));

	CCSprite* selectionMode = CCSprite::create("strangedesign/main_selection_unit.png");
	addChild(selectionMode,2);
	selectionMode->setPosition(titlebar->getPosition());
	
	CButton* add_btn = CButton::create("strangedesign/Main_add_button.png","strangedesign/Main_add_button_down.png");
	add_btn->setPosition(ccp(winSize.width -50, winSize.height- titlebar->getContentSize().height/2));
	add_btn->setOnClickListener(this,ccw_click_selector(MainScene::addButtonCallback));
	m_pWindow->addChild(add_btn,4);

	CCLog("unit count %d",unit_count);

	CCSize visualSize = CCSizeMake(winSize.width,winSize.height-titlebar->getContentSize().height-10);
	CCSize gridcellSize = CCSizeMake(360 , 350);
	pGridView = CGridView::create(
		visualSize,
		gridcellSize,
		unit_count, this,
		ccw_datasource_adapter_selector(MainScene::gridviewDataSource));
	pGridView->setColumns(2);
	pGridView->setPosition(CCSize(winSize.width/2,(winSize.height-titlebar->getContentSize().height)/2));
	m_pWindow->addChild(pGridView);
	pGridView->setAutoRelocate(true);
	pGridView->reloadData();
	
	return true;
}
Exemplo n.º 27
0
NS_MAIN_BEGIN


void MsgBox::onLoadScene()
{
	//setAutoRemoveUnusedTexture(true);
	TuiManager::getInstance()->parseScene(this,"panel_msgbox",PATH_MAIN);
	//注册事件
	CButton *pBtnClose = (CButton*)getControl(PANEL_MSGBOX,BTN_CLOSE);
	pBtnClose->setOnClickListener(this,ccw_click_selector(MsgBox::event_btn_close));
	
	CSlider *pSlider = (CSlider*)getControl(PANEL_MSGBOX,SLIDER_TEST);
	pSlider->setOnValueChangedListener(this,ccw_valuechanged_selector(MsgBox::event_slider_test));

	CProgressBar *pProg = (CProgressBar*)this->getControl(PANEL_MSGBOX,PROG_HP);
	pProg->setShowValueLabel(true);
}
Exemplo n.º 28
0
bool CCheckBoxExclusionTest::init()
{
	CCheckBoxTestSceneBase::init();
	setTitle("CCheckBoxExclusionTest");
	setDescription("checkbox exclusion test");

	CREATE_CHECKBOX(pCheckBox1, CCPoint(480, 490));
	pCheckBox1->setTag(1);
	pCheckBox1->setExclusion(1);
	pCheckBox1->setChecked(true);
	pCheckBox1->setEnabled(false);
	m_pWindow->addChild(pCheckBox1);

	CREATE_CHECKBOX(pCheckBox2, CCPoint(480, 425));
	pCheckBox2->setExclusion(1);
	m_pWindow->addChild(pCheckBox2);
	
	CREATE_CHECKBOX(pCheckBox3, CCPoint(480, 360));
	pCheckBox3->setExclusion(1);
	m_pWindow->addChild(pCheckBox3);

	CREATE_CHECKBOX(pCheckBox4, CCPoint(480, 295));
	pCheckBox4->setExclusion(1);
	m_pWindow->addChild(pCheckBox4);

	CREATE_CHECKBOX(pCheckBox5, CCPoint(480, 230));
	pCheckBox5->setExclusion(1);
	m_pWindow->addChild(pCheckBox5);

	CREATE_CHECKBOX(pCheckBox6, CCPoint(480, 165));
	pCheckBox6->setExclusion(1);
	m_pWindow->addChild(pCheckBox6);

	CButton* pButton = CButton::createWith9Sprite(CCSize(280, 60),
		"sprite9_btn1.png", "sprite9_btn2.png");
	pButton->setPosition(CCPoint(200, 450));
	pButton->setUserTag(1);
	pButton->setOnClickListener(this, ccw_click_selector(CCheckBoxExclusionTest::onClick));
	pButton->initText("set true for first", "", 30);
	m_pWindow->addChild(pButton);

	return true;
}
Exemplo n.º 29
0
Ref* Bagui::event_adapt_gvBag(Ref* pConvertCell, unsigned int uIdx)
{
	CGridViewCell* pCell = (CGridViewCell*)pConvertCell;
	CButton *btn = nullptr;
	if (!pCell)
	{
		pCell = new CGridViewCell();
		pCell->autorelease();

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

		btn = (CButton*)pCell->getChildByTag(BTN_GRID);
		btn->setOnClickListener(this, ccw_click_selector(Bagui::event_btn_gv));
	}else{
		btn = (CButton*)pCell->getChildByTag(BTN_GRID);
	}
	btn->setUserTag(uIdx);
	return pCell;
}
Exemplo n.º 30
0
void CDownloadPackage::showHelpTips( const char *str , bool bShowOkOnly )
{
	if( CCDirector::sharedDirector()->getRunningScene()->getChildByTag(4562) != nullptr )
	{
		return;
	}
	CPopTip *pop = CPopTip::create();
	LayerManager::instance()->pop();
	pop->setVisible(true);
	pop->addContentTip(str);
	pop->setTouchEnabled(true);
	pop->setTouchPriority(-100);
	if(bShowOkOnly)
	{
		pop->showConfirmOnly();
	}
	pop->setButtonLisener(this, ccw_click_selector(CDownloadPackage::showHelpTipsClick));
	CCDirector::sharedDirector()->getRunningScene()->addChild(pop, 4562);
}