void CChangeHeadImg::onEnter() { BaseLayer::onEnter(); ////退出 //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(CChangeHeadImg::onClose)); //this->addChild(pClose, 999); m_cell = (CLayout*)(m_ui->findWidgetById("Cell")); m_cell->retain(); m_ui->removeChild(m_cell); m_gridView = (CGridView*)m_ui->findWidgetById("scroll"); m_gridView->setDirection(eScrollViewDirectionVertical); m_gridView->setCountOfCell(0); m_gridView->setSizeOfCell(m_cell->getContentSize()); m_gridView->setAnchorPoint(ccp(0,0)); m_gridView->setColumns(5); m_gridView->setAutoRelocate(true); m_gridView->setDeaccelerateable(false); m_gridView->setDataSourceAdapter(this,ccw_datasource_adapter_selector(CChangeHeadImg::gridviewDataSource)); m_gridView->reloadData(); GetTcpNet->registerMsgHandler(HeadImgListMsg,this, CMsgHandler_selector(CChangeHeadImg::ProcessMsg)); NOTIFICATION->postNotification(HIDE_ROLE_INFO); }
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); }
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; }
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)); }
bool CTableViewBindingDataAndVertical::init() { CTableViewTestSceneBase::init(); setTitle("CTableViewBindingDataAndVertical"); setDescription("binding data with vector<string>"); m_vDatas.push_back("A"); m_vDatas.push_back("B"); m_vDatas.push_back("C"); m_vDatas.push_back("D"); m_vDatas.push_back("E"); m_vDatas.push_back("F"); m_vDatas.push_back("G"); m_vDatas.push_back("H"); m_vDatas.push_back("I"); m_vDatas.push_back("J"); m_vDatas.push_back("K"); m_vDatas.push_back("L"); m_vDatas.push_back("M"); m_vDatas.push_back("N"); m_vDatas.push_back("O"); m_vDatas.push_back("P"); m_vDatas.push_back("Q"); m_vDatas.push_back("R"); m_vDatas.push_back("S"); m_vDatas.push_back("T"); m_vDatas.push_back("U"); m_vDatas.push_back("V"); m_vDatas.push_back("W"); m_vDatas.push_back("X"); m_vDatas.push_back("Y"); m_vDatas.push_back("Z"); CTableView* pTable = CTableView::create( CCSize(150.0f, 54.0f * 5), CCSize(150.0f, 54.0f), m_vDatas.size(), this, ccw_datasource_adapter_selector(CTableViewBindingDataAndVertical::tableviewDataSource)); pTable->setDirection(eScrollViewDirectionVertical); pTable->setPosition(CCPoint(480, 320)); m_pWindow->addChild(pTable); pTable->reloadData(); pText = CLabel::create(); pText->setAnchorPoint(CCPoint(0, 0.5)); pText->setPosition(CCPoint(200, 320)); pText->setFontSize(35.0f); pText->setString("click button"); m_pWindow->addChild(pText); return true; }
NS_BAG_BEGIN void Bagui::onLoadScene() { SpriteFrameCache::getInstance()->addSpriteFramesWithFile("bag/bagui.plist"); TuiManager::getInstance()->parseScene(this, "panel_bag", PATH_BAG); CGridView* pGridView = (CGridView*)this->getControl(PANEL_BAG, GV_BAG); pGridView->setDataSourceAdapter(this, ccw_datasource_adapter_selector(Bagui::event_adapt_gvBag)); pGridView->reloadData(); CTableView* pTblView = (CTableView*)this->getControl(PANEL_BAG, TBL_BAG); pTblView->setDataSourceAdapter(this, ccw_datasource_adapter_selector(Bagui::event_adapt_tblBag)); pTblView->reloadData(); CPageView* pPageView = (CPageView*)this->getControl(PANEL_BAG, PV_BAG); pPageView->setDataSourceAdapter(this, ccw_datasource_adapter_selector(Bagui::event_adapt_pageBag)); pPageView->reloadData(); CButton* pBtnView = (CButton*)this->getControl(PANEL_BAG, BTN_BACK); pBtnView->setOnClickListener(this, ccw_click_selector(Bagui::event_btn_back)); }
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; }
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; }
void CHeroExpItem::onEnter() { BaseLayer::onEnter(); m_cell = (CLayout *)(m_ui->findWidgetById("Cell")); m_cell->retain(); m_cell->removeFromParent(); 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(CHeroExpItem::tableviewDataSource)); m_tableView->reloadData(); }
bool CTableViewBasicTest::init() { CTableViewTestSceneBase::init(); setTitle("CTableViewBasicTest"); setDescription("TableView basic test"); CTableView* pTable = CTableView::create( Size(74.0f * 5, 70.0f), Size(74.0f, 70.0f), 50, this, ccw_datasource_adapter_selector(CTableViewBasicTest::tableviewDataSource)); pTable->setPosition(Vec2(480, 320)); pTable->setBackgroundColor(Color4B::GRAY); m_pWindow->addChild(pTable); pTable->reloadData(); return true; }
bool CHandBookHeroLayer::init() { if(BaseLayer::init()) { CCSize winSize = CCDirector::sharedDirector()->getWinSize(); //内容 m_ui = LoadComponent("handBookHero.xaml"); m_ui->setPosition(VCENTER); this->addChild(m_ui); setIsShowBlack(false); //保存Cell m_pCell = (CLayout*)findWidgetById("Cell"); m_pCell->retain(); m_pCell->removeFromParent(); m_pCellBlank = (CLayout*)m_ui->findWidgetById("CellBg"); m_pCellBlank->retain(); m_pCellBlank->removeFromParent(); //获取空的滑动列表Scroll m_pTableView = (CTableView*)m_ui->findWidgetById("scroll"); m_pTableView->setDirection(eScrollViewDirectionVertical); m_pTableView->setSizeOfCell(m_pCellBlank->getContentSize()); m_pTableView->setCountOfCell(0); m_pTableView->setBounceable(true); m_pTableView->setDataSourceAdapter(this, ccw_datasource_adapter_selector(CHandBookHeroLayer::tableviewDataSource)); setVisible(false); return true; } return false; }
bool CGridViewBasicTest::init() { CGridViewTestSceneBase::init(); setTitle("CGridViewBasicTest"); setDescription("GridView basic test (only work in vertical)"); Sprite* pBg = Sprite::create("background.png"); pBg->setPosition(Point(480, 320)); m_pWindow->addChild(pBg); CGridView* pGridView = CGridView::create( Size(480, 320), Size(480 / 5, 320 / 4), 96, this, ccw_datasource_adapter_selector(CGridViewBasicTest::gridviewDataSource)); pGridView->setColumns(5); pGridView->setPosition(Point(480, 320)); m_pWindow->addChild(pGridView); pGridView->setAutoRelocate(true); pGridView->reloadData(); return true; }
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)); }