void SettingComboBox::Update() { CEGUI::Combobox* box = getComboBoxW(); if (settings.GetSize()) { csRef<Setting> setting = settings.Get(0); if (setting->IsValid()) { if (setting->IsDefault()) box->getEditbox()->setText("Default"); else box->getEditbox()->setText(GetKey(setting->GetAsString().c_str())); } } if (box->getItemCount() == 0) { Values::const_iterator it = values.begin(); for (size_t i = 0; it != values.end(); it++, i++) { CEGUI::ListboxTextItem* item = new CEGUI::ListboxTextItem(it->first.c_str(), (CEGUI::uint)i); item->setTextColours(CEGUI::colour(0.f, 0.f, 0.f)); box->getDropList()->addItem(item); } } }
//更新右搜索(筛选)菜单 bool OnSearchRightMenuUpdate(const CEGUI::EventArgs& e) { CEGUI::Combobox* cbbox = WComboBox(WEArgs(e).window); cbbox->clearAllSelections(); cbbox->resetList(); cbbox->getEditbox()->setText(""); //由索引关联商城类型 SCGData::eSCType eShopCityType = GetShopCityTypeByTabContentSelIndex(); //由索引关联商店类型,tabControl的索引0单独对应热销商品 SCGData::eSType shoptype = GetShopTypeByTabContentSelIndex(); if(shoptype == SCGData::TABTYPE_HOT)//热销没有筛选项 return true; //根据商城和商店类型获取筛选数据 SCGData* dt = GetInst(ShopCityMsgMgr).GetShopCityGoodsData(); SCGData::MapFLDTA& mapSel = dt->GetFilterList(); SCGData::MapUFLDTPA& mapUSel = mapSel[eShopCityType]; SCGData::MapStrFilDTPA& mapStrSel = mapUSel[shoptype]; SCGData::MapStrFilDTPA::iterator iter = mapStrSel.begin(); for( ; iter != mapStrSel.end() ; ++iter) { //初始化筛选菜单 string str = (*iter).first; //CEGUI::ListboxItem* lbi = new CEGUI::ListboxTextItem(str.c_str()); CEGUI::ListboxItem* lbi = new CEGUI::ListboxTextItem(ToCEGUIString(str.c_str())); lbi->setSelectionBrushImage(IMAGES_FILE_NAME,BRUSH_NAME); if(iter == mapStrSel.begin() )//默认让第一个为选中项 lbi->setSelected(true); cbbox->addItem(lbi); } return true; }
//更新左搜索(导购)菜单 bool OnSearchLeftMenuUpdate(const CEGUI::EventArgs& e) { CEGUI::Combobox* cbbox = WComboBox(WEArgs(e).window); cbbox->clearAllSelections(); cbbox->resetList(); cbbox->getEditbox()->setText(""); //由索引关联商城类型 SCGData::eSCType eCityType = GetShopCityTypeByTabContentSelIndex(); SCGData* dt = GetInst(ShopCityMsgMgr).GetShopCityGoodsData(); SCGData::MapGuideDataA& mapGuide = dt->GetGuideList(); //根据索引获取导购数据 SCGData::MapStrGGDTPA& mapGuideDTA = mapGuide[eCityType]; CEGUI::Combobox* cbboxRight = WComboBox(GetWndMgr().getWindow(SHOPCITY_SEARCH_RIGHTWND_NAME)); if(cbboxRight) { CEGUI::ListboxItem* lbi = cbboxRight->getSelectedItem(); size_t idx = 0; if(lbi) idx = cbboxRight->getItemIndex(lbi); SCGData::MapStrGGDTPA::iterator iter = mapGuideDTA.begin(); for(; iter != mapGuideDTA.end() ; ++iter) { //添加导购菜单 string menuStr = iter->first; //CEGUI::ListboxItem* lbi = new CEGUI::ListboxTextItem(menuStr.c_str()); CEGUI::ListboxItem* lbi = new CEGUI::ListboxTextItem(ToCEGUIString(menuStr.c_str())); lbi->setSelectionBrushImage(IMAGES_FILE_NAME,BRUSH_NAME); if(iter == mapGuideDTA.begin())//默认让第一个为选中 lbi->setSelected(true); cbbox->addItem(lbi); } } return true; }
void SettingComboBox::onSized(CEGUI::WindowEventArgs& e) { CEGUI::Window::onSized(e); CEGUI::Combobox* box = getComboBoxW(); box->getEditbox()->setReadOnly(true); // Calculate height. float h = box->getEditbox()->getPixelSize().d_height+5.0f; for (size_t i =0; i < box->getItemCount(); i++) { h += box->getListboxItemFromIndex(i)->getPixelSize().d_height; } box->setHeight(CEGUI::UDim(0.0f, h)); box->setClippedByParent(false); box->getDropList()->getVertScrollbar()->setEnabled(false); box->getDropList()->getVertScrollbar()->setAlpha(0.0f); }
bool OnShopCitySearch(const CEGUI::EventArgs& e) { //获取导购文本 CEGUI::Combobox* guide = WComboBox(GetWindow(SHOPCITY_SEARCH_LEFTWND_NAME)); if(guide && guide->getEditbox()->getText()=="") { return true;//文本为空直接返回 } ShopCityMsgMgr& msgMgr = GetInst(ShopCityMsgMgr); msgMgr.SetStateUpdateUIByType(2);//设为更新源为导购 //根据导购数据更新显示项目 FireUIEvent(SHOPCITY_ITEMSET_PAGE_NAME,SHOPCITY_ITEMSET_EVENT_UPDATE_BY_GUIDE); return true; }
void ResetDataBySexSelChanged() { CEGUI::WindowManager& mgr = GetWndMgr(); CEGUI::Combobox* SelFac = WComboBox(mgr.getWindow(CREATEROLE_SEL_FAC_CCB)); uint SelSex = (uint)CREvent::GetSelectSex(); if(SelFac) { SelFac->resetList(); //更改性别后,修改默认Face和HairStyle时,对应修改文本显示 SelFac->getEditbox()->setText(CEGUI::PropertyHelper::intToString(0)); for(short i = 0 ; i < CREvent::GetFaceNum(SelSex) ; ++i) { CEGUI::ListboxTextItem* lti = new CEGUI::ListboxTextItem(CEGUI::PropertyHelper::intToString(i)); lti->setSelectionBrushImage(IMAGES_FILE_NAME,BRUSH_NAME); lti->setID(i);//ID和FacIndex关联 if(0==i) //更改性别后,修改默认Face和HairStyle时,对应修改ItemList选中状态 lti->setSelected(true); SelFac->addItem(lti); } } CEGUI::Combobox* SelHair = WComboBox(mgr.getWindow(CREATEROLE_SEL_HAIR_CCB)); if(SelHair) { SelHair->resetList(); //更改性别后,修改默认Face和HairStyle时,对应修改文本显示 SelHair->getEditbox()->setText(CEGUI::PropertyHelper::intToString(0)); for(short i = 0 ; i < CREvent::GetHairNum(SelSex) ; ++i) { CEGUI::ListboxTextItem* lti = new CEGUI::ListboxTextItem(CEGUI::PropertyHelper::intToString(i)); lti->setSelectionBrushImage(IMAGES_FILE_NAME,BRUSH_NAME); lti->setID(i);// ID和HairIndex关联 if(0 == i)//更改性别后,修改默认Face和HairStyle时,对应修改ItemList选中状态 lti->setSelected(true); SelHair->addItem(lti); } } }
void ResetHairColorDateOnHairChanged() { CEGUI::WindowManager& mgr = GetWndMgr(); CEGUI::Combobox* hairColor = WComboBox(mgr.getWindow(CREATEROLE_SEL_HAIRCOLOR_CCB)); if(hairColor) { hairColor->resetList(); //清空发色类型文本 hairColor->getEditbox()->setText(""); for(short i = 0 ; i < CREvent::GetHairColorNum(CREvent::GetSelectSex(),(WORD)CREvent::GetHair()) ; ++i) { CEGUI::ListboxTextItem* lti = new CEGUI::ListboxTextItem(CEGUI::PropertyHelper::intToString(i)); lti->setSelectionBrushImage(IMAGES_FILE_NAME,BRUSH_NAME); lti->setID(i);//ID和HairColorIndex关联 hairColor->addItem(lti); } } }
void SetCreateRoleInitProperty(CEGUI::Window* pgWnd) { if(!pgWnd) return; CEGUI::Combobox* SelCountry = WComboBox(pgWnd->getChildRecursive(CREATEROLE_SEL_COUNTRY_CCB)); if(SelCountry) { SelCountry->subscribeEvent(CEGUI::Combobox::EventListSelectionAccepted,CEGUI::SubscriberSlot(OnCountryChanged)); SelCountry->setReadOnly(true); CCountryList::MapCountryList* mapCL = CCountryList::GetCountryList(); for(uint cnt = 0; cnt < mapCL->size(); ++cnt) { const char* ctName = CCountryList::GetCountryName((BYTE)cnt+1); if(ctName) { CEGUI::ListboxTextItem* lti = new CEGUI::ListboxTextItem(ToCEGUIString(ctName)); lti->setSelectionBrushImage(IMAGES_FILE_NAME,BRUSH_NAME); lti->setID(cnt+1);//ID和国家ID关联 if(cnt == 0) lti->setSelected(true);//设置国家默认值 SelCountry->addItem(lti); } } //根据国家默认值,设置显示文本 SelCountry->getEditbox()->setText(ToCEGUIString(CCountryList::GetCountryName(0+1)));//加一是因为data/CountryList.xml配置造成 /***********************************************************************/ /* zhaohang fix 2010-9-3 /***********************************************************************/ CREvent::SetSelectCountry(1);//逻辑上的国家默认值 } CEGUI::Combobox* selHair = WComboBox(pgWnd->getChildRecursive(CREATEROLE_SEL_HAIR_CCB)); if(selHair) { selHair->subscribeEvent(CEGUI::Combobox::EventListSelectionAccepted,CEGUI::SubscriberSlot(OnHairChanged)); selHair->setReadOnly(true); } CEGUI::Combobox* selHairColor = WComboBox(pgWnd->getChildRecursive(CREATEROLE_SEL_HAIRCOLOR_CCB)); if(selHairColor) { selHairColor->subscribeEvent(CEGUI::Combobox::EventListSelectionAccepted,CEGUI::SubscriberSlot(OnHairColorChanged)); selHairColor->setReadOnly(true); } CEGUI::Combobox* selFac = WComboBox(pgWnd->getChildRecursive(CREATEROLE_SEL_FAC_CCB)); if(selFac) { selFac->subscribeEvent(CEGUI::Combobox::EventListSelectionAccepted,CEGUI::SubscriberSlot(OnFacChanged)); selFac->setReadOnly(true); } CEGUI::Combobox* selSex = WComboBox(pgWnd->getChildRecursive(CREATEROLE_SEL_SEX_CCB)); if(selSex) { CEGUI::ListboxTextItem* itm1 = new CEGUI::ListboxTextItem(ToCEGUIString(CREATEROLE_SEX_MALE)); itm1->setSelectionBrushImage(IMAGES_FILE_NAME,BRUSH_NAME); itm1->setID(0);//用ID和性别关联 selSex->addItem(itm1); CEGUI::ListboxTextItem* itm2 = new CEGUI::ListboxTextItem(ToCEGUIString(CREATEROLE_SEX_FAMALE)); itm2->setSelectionBrushImage(IMAGES_FILE_NAME,BRUSH_NAME); itm2->setID(1);//用ID和性别关联 selSex->addItem(itm2); //注册事件 selSex->subscribeEvent(CEGUI::Combobox::EventListSelectionAccepted,CEGUI::SubscriberSlot(OnSexChanged)); selSex->setReadOnly(true); } }