/** * 展示基本数值 */ void PropBaseShow::show(PropDialog *propDialog,UIBase *base) { GET_UI_BYNAME(propDialog,UIEditField,ex,"x"); if (ex) { std::stringstream xstr; xstr << base->x; ex->setContent(xstr.str().c_str()); } GET_UI_BYNAME(propDialog,UIEditField,ey,"y"); if (ey) { std::stringstream ystr; ystr << base->y; ey->setContent(ystr.str().c_str()); } GET_UI_BYNAME(propDialog,UIEditField,ew,"w"); if (ew) { std::stringstream wstr; wstr << base->w; ew->setContent(wstr.str().c_str()); } GET_UI_BYNAME(propDialog,UIEditField,eh,"h"); if (eh) { std::stringstream hstr; hstr << base->h; eh->setContent(hstr.str().c_str()); } }
void SavePanelDialog::doInitEvent() { do{ GET_UI_BYNAME(this,UIButton,cancelBtn,"canel"); if (cancelBtn) { cancelBtn->bind(UIBase::EVENT_CLICK_DOWN,new stClosePanel()); } GET_UI_BYNAME(this,UIButton,sureBtn,"sure"); if (sureBtn) { sureBtn->bind(UIBase::EVENT_CLICK_DOWN,new stSurePanel(this)); // 确定保存 } }while(false); }
/** * 创建的属性界面 */ void PropDialog::doInitEvent() { GET_UI_BYNAME(this,UIButton,closeBtn,"close"); if (closeBtn) { closeBtn->bind(UIBase::EVENT_CLICK_DOWN,new stClosePanel()); } }
void callback(UIBase *base) { // 尝试读取系统中的 登录名 登录密码 并发送到网络 // 在Request.cpp 中创建场景 // 创建等待动画 GET_UI_BYNAME(dialog,UIEditField,uiName,"name"); std::string userName,userPwd; if (uiName) { userName = uiName->getContent(); } GET_UI_BYNAME(dialog,UIEditField,pwdName,"pwd"); if (pwdName) { userPwd = pwdName->getContent(); } }
void callback(UIBase *base) { if (base && base->getParent()) { base->getParent()->setVisible(false); GET_UI_BYNAME(saveDialog,UIEditField,txtField,"filename"); if (txtField) { saveDialog->savePanel(txtField->getContent()); } } }
/** * 隐藏属性 */ void PropDialog::hideProps() { GET_UI_BYNAME(this,UILabel,lbtn_up_img,"1btn_up_name"); if (lbtn_up_img) { lbtn_up_img->setVisible(false); } GET_UI_BYNAME(this,UILabel,lbtn_down_img,"lbtn_down_name"); if (lbtn_down_img) { lbtn_down_img->setVisible(false); } GET_UI_BYNAME(this,UIEditField,ebtn_up_img,"btn_up_name"); if (ebtn_up_img) { ebtn_up_img->setVisible(false); } GET_UI_BYNAME(this,UIEditField,ebtn_down_img,"btn_down_name"); if (ebtn_down_img) { ebtn_down_img->setVisible(false); } }
/** * 展示Button的属性 设定应该展示的属性 */ void PropButtonShow::show(PropDialog *propDialog,UIButton *button) { PropBaseShow::show(propDialog,button); GET_UI_BYNAME(propDialog,UILabel,lbtn_up_img,"1btn_up_name"); if (lbtn_up_img) { lbtn_up_img->setVisible(true); } GET_UI_BYNAME(propDialog,UILabel,lbtn_down_img,"lbtn_down_name"); if (lbtn_down_img) { lbtn_down_img->setVisible(true); } GET_UI_BYNAME(propDialog,UIEditField,ebtn_up_img,"btn_up_name"); if (ebtn_up_img) { ebtn_up_img->setVisible(true); } GET_UI_BYNAME(propDialog,UIEditField,ebtn_down_img,"btn_down_name"); if (ebtn_down_img) { ebtn_down_img->setVisible(true); } }
void MainDialog::doInitEvent() { do{ GET_UI_BYNAME(this,UIButton,closeBtn,"close"); if (closeBtn) { closeBtn->bind(UIBase::EVENT_CLICK_DOWN,new stClosePanel()); } GET_UI_BYNAME(this,UIButton,crtBtnBtn,"button"); if (crtBtnBtn) { crtBtnBtn->bind(UIBase::EVENT_CLICK_DOWN,new stCreateButton(this,this->window)); } GET_UI_BYNAME(this,UIButton,crtImageBtn,"image"); if (crtImageBtn) { crtImageBtn->bind(UIBase::EVENT_CLICK_DOWN,new stCreateImage(this,this->window)); crtImageBtn->bind(UIBase::EVENT_EDIT_DOWN,new stEditDown(this,this->window)); } GET_UI_BYNAME(this,UIButton,crtTextBtn,"text"); if (crtTextBtn) { crtTextBtn->bind(UIBase::EVENT_CLICK_DOWN,new stCreateText(this,this->window)); } GET_UI_BYNAME(this,UIButton,crtEditBtn,"editfield"); if (crtEditBtn) { crtEditBtn->bind(UIBase::EVENT_CLICK_DOWN,new stCreateEditField(this,this->window)); } GET_UI_BYNAME(this,UIButton,crtPanelBtn,"panel"); if (crtPanelBtn) { crtPanelBtn->bind(UIBase::EVENT_CLICK_DOWN,new stCreatePanel(this,this->window)); } GET_UI_BYNAME(this,UIButton,saveBtn,"save"); if (saveBtn) { saveBtn->bind(UIBase::EVENT_CLICK_DOWN,new stSavePanel(this,this->window)); } }while(false); }
NS_CC_BEGIN void StartDialog::doInitEvent() { CCSize s = CCDirector::sharedDirector()->getWinSize(); do{ GET_UI_BYNAME(this,UIButton,reqLoginBtn,"login"); if (reqLoginBtn) { struct stReqLogin:public UICallback{ void callback(UIBase *base) { // 尝试读取系统中的 登录名 登录密码 并发送到网络 // 在Request.cpp 中创建场景 // 创建等待动画 GET_UI_BYNAME(dialog,UIEditField,uiName,"name"); std::string userName,userPwd; if (uiName) { userName = uiName->getContent(); } GET_UI_BYNAME(dialog,UIEditField,pwdName,"pwd"); if (pwdName) { userPwd = pwdName->getContent(); } } stReqLogin(UIWindow *window,StartDialog *dialog):window(window),dialog(dialog) { } UIWindow *window; StartDialog *dialog; }; } } while (false); }
/** * 设置选择框 */ int UILib::panel_p_choice(UIStub *stub,script::tixmlCodeNode * node) { if (stub && stub->base) { UIPanel *panel = stub->base->getPanel(); if (panel) { GET_UI_BYNAME(panel,UIChoice,choice,node->getAttr("name")); if (choice) { std::string choiceName = node->getAttr("choice"); if (choiceName == "true") { choice->setChoiced(true); } if (choiceName == "false") { choice->setChoiced(false); } } } } return 1; }
void StartDialog::doInitEvent() { CCSize s = CCDirector::sharedDirector()->getWinSize(); /* CCProgressTo *to1 = CCProgressTo::create(2, 100); showLoad = CCProgressTimer::create(CCSprite::create("build05.png")); showLoad->setType( kCCProgressTimerTypeBar ); showLoad->setBarChangeRate(ccp(1,0)); showLoad->setMidpoint(ccp(0,0)); window->addChild(showLoad); showLoad->setPosition(CCPointMake(100, s.height/2)); showLoad->setPercentage(10); //show->runAction( CCRepeatForever::create(to1)); showLoad->retain(); */ do{ GET_UI_BYNAME(mainDialog,UIButton,startButton,"1"); if (startButton) { struct stStartDone:public UICallback{ void callback(UIBase *base) { CCDirector::sharedDirector()->resume(); CCTextureCache::sharedTextureCache()->removeAllTextures(); CCDirector::sharedDirector()->replaceScene( CCTransitionFlipY::create(0.5,RpgGame::scene()) ); } stStartDone(UIWindow *window):window(window) { } UIWindow *window; }; startButton->bind(UIBase::EVENT_CLICK_DOWN,new stStartDone(window)); } GET_UI_BYNAME(mainDialog,UIButton,startTFButton,"2"); if (startTFButton) { struct stStartDone:public UICallback{ void callback(UIBase *base) { CCDirector::sharedDirector()->resume(); // CCDirector::sharedDirector()->replaceScene( CCTransitionFlipY::create(0.5,TFGame::scene()) ); } }; startTFButton->bind(UIBase::EVENT_CLICK_DOWN,new stStartDone()); } GET_UI_BYNAME(mainDialog,UIButton,startMtButton,"startmt"); if (startMtButton) { struct stStartMtDone:public UICallback{ void callback(UIBase *base) { CCDirector::sharedDirector()->resume(); // CCDirector::sharedDirector()->replaceScene( CCTransitionFlipX::create(0.5,MTNewLevelScene::scene()) ); } }; startMtButton->bind(UIBase::EVENT_CLICK_DOWN,new stStartMtDone()); } GET_UI_BYNAME(mainDialog,UIButton,exitButton,"exit"); if (exitButton) { struct stExitDone:public UICallback{ void callback(UIBase *base) { // CCDirector::sharedDirector()->end(); } }; exitButton->bind(UIBase::EVENT_CLICK_DOWN,new stExitDone()); } GET_UI_BYNAME(mainDialog,UIButton,backButton,"help"); if (backButton) { } } while (false); }