bool OnPlayerShopShowGoodsInfo(const CEGUI::EventArgs& e) { CEGUI::Window* wnd = WEArgs(e).window; if(!wnd) return false; CGoods* goods = static_cast<CGoods*>(wnd->getUserData()); if (!goods) return false; CEGUI::DefaultWindow* iconWnd = WDefaultWindow(GetWndMgr().getWindow("PlayerShop/backgrond/GoodsInfo/Icon")); CEGUI::Window* nameWnd = GetWndMgr().getWindow("PlayerShop/backgrond/GoodsInfo/Name"); CEGUI::Window* oneGroupNumWnd = GetWndMgr().getWindow("PlayerShop/backgrond/GoodsInfo/OneGroupNum"); CEGUI::Window* priceWnd = GetWndMgr().getWindow("PlayerShop/backgrond/GoodsInfo/Price"); CEGUI::Window* averagePriceWnd = GetWndMgr().getWindow("PlayerShop/backgrond/GoodsInfo/AveragePrice"); if (!iconWnd || !nameWnd || !oneGroupNumWnd || !priceWnd || !averagePriceWnd) return false; char tempText[256]; char strImageFilePath[128] = ""; char strImageFileName[128] = ""; PlayerShop::tagGoodsItem* pGoodsItem = GetPlayerShop().FindtagGoods(goods); if (pGoodsItem!=NULL) { // 物品名字 DWORD dwNameSize = (DWORD)strlen(pGoodsItem->strGoodsName.c_str()); if (dwNameSize>20) { _snprintf(tempText,21,"%s", pGoodsItem->strGoodsName.c_str()); sprintf((tempText+20),"..."); }else sprintf(tempText,"%s", pGoodsItem->strGoodsName.c_str()); nameWnd->setText(ToCEGUIString(tempText)); // 物品图片 const char *strIconPath = GetGame()->GetPicList()->GetPicFilePathName(CPicList::PT_GOODS_ICON, pGoodsItem->goodsIconId); GetFilePath(strIconPath,strImageFilePath); GetFileName(strIconPath,strImageFileName); CEGUI::String strImagesetName = "GoodIcon/"; strImagesetName += strImageFileName; SetBackGroundImage(iconWnd,strImagesetName.c_str(),strImageFilePath,strImageFileName); // 物品单组个数 sprintf(tempText,"%d",pGoodsItem->oneGroupNum); oneGroupNumWnd->setText(ToCEGUIString(tempText)); // 物品售价 sprintf(tempText,"%d", pGoodsItem->price); priceWnd->setText(ToCEGUIString(tempText)); // 物品单个均价 char strGoodsPrice[64] = "",strNumLen[64] = ""; sprintf(strNumLen,"%d",pGoodsItem->price/pGoodsItem->oneGroupNum); float fPrice = static_cast<float>(pGoodsItem->price)/static_cast<float>(pGoodsItem->oneGroupNum); sprintf(strGoodsPrice,"%*.2f",(int)strlen(strNumLen)+2,fPrice); averagePriceWnd->setText(ToCEGUIString(strGoodsPrice)); } return true; }
bool OnPlayerShopUpdateMoneyInfo(const CEGUI::EventArgs& e) { // 目前个人商店只支持金币一种货币类型@todo CEGUI::Window* wnd = WEArgs(e).window; if(!wnd) return false; CPlayer* pPlayer = GetGame()->GetMainPlayer(); if (!pPlayer) return false; CEGUI::Window* tradeGoldsWnd = wnd->getChildRecursive("PlayerShop/backgrond/SumUp/TradeGolds"); CEGUI::Window* haveGoldsWnd = wnd->getChildRecursive("PlayerShop/backgrond/SumUp/HaveGolds"); if (!tradeGoldsWnd || !haveGoldsWnd) return false; int curShopState = GetPlayerShop().GetCurShopState(); ulonglong tradeGolds = GetPlayerShop().GetTradeGold(); char str[256]; if(curShopState==PlayerShop::SET_SHOP || curShopState==PlayerShop::OPEN_SHOP) { // 获得金币 if (tradeGolds>=2000000000) { wsprintf(str,"+ %d",2000000000); }else wsprintf(str,"+ %d",tradeGolds); tradeGoldsWnd->setText(ToCEGUIString(str)); // 持有金币 if (pPlayer->GetMoney()>=2000000000) { wsprintf(str,"%d",2000000000); }else wsprintf(str,"%d",pPlayer->GetMoney()); haveGoldsWnd->setText(ToCEGUIString(str)); } else if(curShopState==PlayerShop::SHOPPING_SHOP) { // 花费金币 if (tradeGolds>=2000000000) { wsprintf(str,"- %d",2000000000); }else wsprintf(str,"- %d",tradeGolds); tradeGoldsWnd->setText(ToCEGUIString(str)); // 持有金币 if (pPlayer->GetMoney()>=2000000000) { wsprintf(str,"%d",2000000000); }else wsprintf(str,"%d",pPlayer->GetMoney()); haveGoldsWnd->setText(ToCEGUIString(str)); } return true; }
//更新右搜索(筛选)菜单 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; }
//新品推荐 bool OnUpdateTwitter(const CEGUI::EventArgs& e) { CEGUI::Window* twitter = WEArgs(e).window; CEGUI::Listbox* lb = WListBox(twitter->getChildRecursive(SHOPCITY_TWITTER_CHILDLISTBOX_NAME)); #ifdef _DEBUG OutputDebugStr(lb->getName().c_str()); OutputDebugStr("\n"); OutputDebugStr(twitter->getChildAtIdx(0)->getName().c_str()); OutputDebugStr("n"); #endif //清空 lb->resetList(); //由索引关联商城类型 SCGData::eSCType eCityType = GetShopCityTypeByTabContentSelIndex(); SCGData* dt = GetInst(ShopCityMsgMgr).GetShopCityGoodsData(); //新品推荐显示 SCGData::MapNewestA& resdta = dt->GetNewestVec(); SCGData::VecGDPTA& vecDTA = resdta[eCityType]; for(uint i = 0 ; i < vecDTA.size() ; ++i) { CGoodsList::tagGoods2* ptg2 = CGoodsList::GetProperty(vecDTA[i].index); if(ptg2) { string str = ptg2->BaseProperty.strName.c_str(); //CEGUI::ListboxTextItem* lti = new CEGUI::ListboxTextItem(str.c_str(),vecDTA[i].index);//索引关联Item ID CEGUI::ListboxTextItem* lti = new CEGUI::ListboxTextItem(ToCEGUIString(str.c_str()),vecDTA[i].index);//索引关联Item ID lti->setSelectionBrushImage(IMAGES_FILE_NAME,BRUSH_NAME); lb->addItem(lti); } } return true; }
bool UpdateCanSaleMCLDate(const CEGUI::EventArgs& e) { AHdata& ah = GetInst(AHdata); AHdata::vecOrderRaw listOR = ah.m_CanSaleOrder;//可出售列表 CEGUI::MultiColumnList* mcl = WMCL(WEArgs(e).window); if(!mcl) return false; mcl->resetList(); AHdata::vecOrderRaw::iterator it = listOR.begin(); for (uint i = 0 ; i < listOR.size() ; ++i,++it) { mcl->addRow(); CEGUI::ListboxTextItem* lti = new CEGUI::ListboxTextItem(ToCEGUIString(AppFrame::GetText("AU_104")),it->id);//第二个参数与订单ID关联 lti->setSelectionBrushImage(IMAGES_FILE_NAME,BRUSH_NAME); mcl->setItem(lti,0,i); lti = new CEGUI::ListboxTextItem(CEGUI::PropertyHelper::intToString(it->price)); lti->setSelectionBrushImage(IMAGES_FILE_NAME,BRUSH_NAME); mcl->setItem(lti,1,i); lti = new CEGUI::ListboxTextItem(CEGUI::PropertyHelper::intToString(it->cnt)); lti->setSelectionBrushImage(IMAGES_FILE_NAME,BRUSH_NAME); mcl->setItem(lti,2,i); } return true; }
bool OnPlayerShopBuyNumChange(const CEGUI::EventArgs& e) { CEGUI::Window* wnd = WEArgs(e).window; if(!wnd) return false; CEGUI::String buyNum = wnd->getText(); char str[32] = ""; CEGUI::Window* goodsWnd = wnd->getParent(); if (goodsWnd) { CGoods* goods = static_cast<CGoods*>(goodsWnd->getUserData()); if (!goods) return false; PlayerShop::tagGoodsItem* pGoodsItem = GetPlayerShop().FindtagGoods(goods); if (pGoodsItem!=NULL) { ulong num = atoi(buyNum.c_str()); if (num>=pGoodsItem->groupNum) { sprintf(str,"%d",pGoodsItem->groupNum); } else if (num<=0) { sprintf(str,"%d",0); } sprintf(str,"%d",num); wnd->setText(ToCEGUIString(str)); pGoodsItem->readyTradeNum = num; } } return true; }
bool UpdatePerMCLDate(const CEGUI::EventArgs& e) { AHdata& ah = GetInst(AHdata); //AHdata::listSubOrderRaw listSubOR = ah.m_AgentOrder; AHdata::MapSubOrderRaw mapSubOR = ah.m_AgentOrder; CEGUI::MultiColumnList* mcl = WMCL(WEArgs(e).window); if(!mcl) return false; mcl->resetList(); AHdata::MapSubOrderRaw::iterator it = mapSubOR.begin(); for (int i = 0 ; it != mapSubOR.end(); ++it,++i) { mcl->addRow(); CEGUI::ListboxTextItem* lti = NULL; lti = new CEGUI::ListboxTextItem(CEGUI::PropertyHelper::intToString(it->first),it->first);//控件ID与订单ID关联 lti->setSelectionBrushImage(IMAGES_FILE_NAME,BRUSH_NAME); mcl->setItem(lti,0,i); AH::SubOrderRaw& mapOr = it->second; if(mapOr.type == AH::OT_BUY) lti = new CEGUI::ListboxTextItem(ToCEGUIString(AppFrame::GetText("AU_104"))); else if(mapOr.type == AH::OT_SELL) lti = new CEGUI::ListboxTextItem(ToCEGUIString(AppFrame::GetText("AU_105"))); lti->setSelectionBrushImage(IMAGES_FILE_NAME,BRUSH_NAME); mcl->setItem(lti,1,i); lti = new CEGUI::ListboxTextItem(CEGUI::PropertyHelper::intToString(mapOr.cnt)); lti->setSelectionBrushImage(IMAGES_FILE_NAME,BRUSH_NAME); mcl->setItem(lti,2,i); lti = new CEGUI::ListboxTextItem(CEGUI::PropertyHelper::intToString(mapOr.price)); lti->setSelectionBrushImage(IMAGES_FILE_NAME,BRUSH_NAME); mcl->setItem(lti,3,i); ///////////////////////////////////////////////// // zhaohang 2010/5/12 // 时间UI未处理 ///////////////////////////////////////////////// uint subtime = mapOr.gentime / 60 / 60; lti = new CEGUI::ListboxTextItem(CEGUI::PropertyHelper::intToString(subtime)); lti->setSelectionBrushImage(IMAGES_FILE_NAME,BRUSH_NAME); mcl->setItem(lti,4,i); } return false; }
void LoginEvent::OnPageLoad(GamePage *pPage) { pPage->LoadPageWindow(); CEGUI::Window *pLoginWindow = pPage->GetPageWindow(); ///////////////////////////////////////////////// // zhaohang 2010/6/4 // 添加选服的修改 //首次打开显示选择登陆服务器界面 FireUIEvent("SelectLS",EVENT_OPEN); //设置密码编辑框掩码 CEGUI::Editbox *pPwdEdit = static_cast<CEGUI::Editbox*>(pLoginWindow->getChild("LoginPage/PassWord")); pPwdEdit->setTextMasked(true); pPwdEdit->subscribeEvent(CEGUI::Editbox::EventTextAccepted ,CEGUI::Event::Subscriber(&LoginEvent::HandleLogin, this)); //设置相应事件处理函数 CEGUI::PushButton *pEnterBtn = static_cast<CEGUI::PushButton*>(pLoginWindow->getChild("LoginPage/Enter")); pEnterBtn->setText(ToCEGUIString(AppFrame::GetText("Login_1"))); //pEnterBtn->setText(ToCEGUIString("[ROLL Speed:1 Dir:Left Text:nihao]")); pEnterBtn->subscribeEvent(CEGUI::PushButton::EventClicked,CEGUI::Event::Subscriber(&LoginEvent::HandleLogin, this)); CEGUI::PushButton *pExitBtn = static_cast<CEGUI::PushButton*>(pLoginWindow->getChild("LoginPage/Exit")); pExitBtn->setText(ToCEGUIString(AppFrame::GetText("Login_2"))); pExitBtn->subscribeEvent(CEGUI::PushButton::EventClicked,CEGUI::Event::Subscriber(&LoginEvent::HandleExitBtn, this)); CEGUI::PushButton *pRegistBtn = static_cast<CEGUI::PushButton*>(pLoginWindow->getChild("LoginPage/Register")); pRegistBtn->setText(ToCEGUIString(AppFrame::GetText("Login_3"))); CEGUI::PushButton *pForgetPwdBtn = static_cast<CEGUI::PushButton*>(pLoginWindow->getChild("LoginPage/ForgetPwd")); pForgetPwdBtn->setText(ToCEGUIString(AppFrame::GetText("Login_4"))); CEGUI::PushButton* serverInfo = static_cast<CEGUI::PushButton*>(pLoginWindow->getChild("Login/ServerInfo")); serverInfo->setText(ToCEGUIString(AppFrame::GetText("Login_5"))); serverInfo->subscribeEvent(CEGUI::PushButton::EventClicked,CEGUI::Event::Subscriber(HandleEnterSelectLS)); }
bool OnPlayerShopSubBuyNum(const CEGUI::EventArgs& e) { CEGUI::Window* wnd = WEArgs(e).window; if(!wnd) return false; CEGUI::Window* goodsWnd = wnd->getParent(); if (goodsWnd) { CGoods* goods = static_cast<CGoods*>(goodsWnd->getUserData()); if (!goods) return false; PlayerShop::tagGoodsItem* pGoodsItem = GetPlayerShop().FindtagGoods(goods); if (pGoodsItem!=NULL) { char str[32]; // 取得输入框控件名 CEGUI::String name = wnd->getName(); name.assign(name, 0, name.find_last_of("/")); name += "/BuyNum"; CEGUI::Window* buyNumWnd = GetWndMgr().getWindow(name); int num = atoi(buyNumWnd->getText().c_str()); if (num<=0) { sprintf(str,"%d",0); wnd->disable(); } else sprintf(str,"%d",num--); buyNumWnd->setText(ToCEGUIString(str)); pGoodsItem->readyTradeNum = num; } } return true; }
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); } }
// 添加货物列表 void SetPlayerShopGoodsItemInfo(PlayerShop::tagGoodsItem& tgGoodsItem, int index) { /// 项目背景图 CEGUI::Window* wnd; char tempText[256]; char strImageFilePath[128] = ""; char strImageFileName[128] = ""; sprintf(tempText, "PlayerShop/backgrond/Goods%d", index+1); CEGUI::Window* goodsWnd = GetWndMgr().getWindow(tempText); goodsWnd->setUserData(tgGoodsItem.pItemGoods); goodsWnd->setVisible(true); //根据商店状态设置UI排列 int shopState = GetPlayerShop().GetCurShopState(); if(shopState >= 0 && shopState < PlayerShop::SHOP_STATE) { //设置商店 if(shopState == PlayerShop::SET_SHOP) { sprintf(tempText, "PlayerShop/backgrond/Goods%d/BuyNum", index+1); wnd = GetWndMgr().getWindow(tempText); wnd->setVisible(false); sprintf(tempText, "PlayerShop/backgrond/Goods%d/AddBuyNum", index+1); wnd = GetWndMgr().getWindow(tempText); wnd->setVisible(false); sprintf(tempText, "PlayerShop/backgrond/Goods%d/SubBuyNum", index+1); wnd = GetWndMgr().getWindow(tempText); wnd->setVisible(false); sprintf(tempText, "PlayerShop/backgrond/Goods%d/Text", index+1); wnd = GetWndMgr().getWindow(tempText); wnd->setText(ToCEGUIString("双击重新设置价格")); } //开店 else if(shopState == PlayerShop::OPEN_SHOP) { sprintf(tempText, "PlayerShop/backgrond/Goods%d/BuyNum", index+1); wnd = GetWndMgr().getWindow(tempText); wnd->setVisible(false); sprintf(tempText, "PlayerShop/backgrond/Goods%d/AddBuyNum", index+1); wnd = GetWndMgr().getWindow(tempText); wnd->setVisible(false); sprintf(tempText, "PlayerShop/backgrond/Goods%d/SubBuyNum", index+1); wnd = GetWndMgr().getWindow(tempText); wnd->setVisible(false); sprintf(tempText, "PlayerShop/backgrond/Goods%d/Text", index+1); wnd = GetWndMgr().getWindow(tempText); wnd->setVisible(false); } // 逛商店页面 else if( shopState == PlayerShop::SHOPPING_SHOP) { sprintf(tempText, "PlayerShop/backgrond/Goods%d/Text", index+1); wnd = GetWndMgr().getWindow(tempText); wnd->setVisible(false); } } // 设置物品上架信息 // 物品图片 sprintf(tempText, "PlayerShop/backgrond/Goods%d/Icon", index+1); CEGUI::DefaultWindow* iconWnd = WDefaultWindow(GetWndMgr().getWindow(tempText)); if(iconWnd && tgGoodsItem.goodsIconId != 0) { // 获得当前背包栏对应的物品图标数据,并将该图标设置成对应背包组件的额外图片。 const char *strIconPath = GetGame()->GetPicList()->GetPicFilePathName(CPicList::PT_GOODS_ICON, tgGoodsItem.goodsIconId); GetFilePath(strIconPath,strImageFilePath); GetFileName(strIconPath,strImageFileName); CEGUI::String strImagesetName = "GoodIcon/"; strImagesetName += strImageFileName; SetBackGroundImage(iconWnd,strImagesetName.c_str(),strImageFilePath,strImageFileName); // 当物品数大于1的时候才显示数量 if(tgGoodsItem.tradeType==PlayerShop::TT_GROUP && tgGoodsItem.oneGroupNum>=1) { char strGoodsNum[32]; sprintf_s(strGoodsNum,"%4d",tgGoodsItem.oneGroupNum); iconWnd->setText(strGoodsNum); } } // 物品数 sprintf(tempText, "PlayerShop/backgrond/Goods%d/Num", index+1); wnd = GetWndMgr().getWindow(tempText); if (wnd) { if (tgGoodsItem.tradeType==PlayerShop::TT_SINGLE) { sprintf_s(tempText,"剩%d件",tgGoodsItem.groupNum); }else if (tgGoodsItem.tradeType==PlayerShop::TT_GROUP) { sprintf_s(tempText,"剩%d组",tgGoodsItem.groupNum); } wnd->setText(ToCEGUIString(tempText)); } // 物品名 sprintf(tempText, "PlayerShop/backgrond/Goods%d/Name", index+1); wnd = GetWndMgr().getWindow(tempText); if (wnd) { char strGoodsName[32] = ""; DWORD dwNameSize = (DWORD)strlen(tgGoodsItem.strGoodsName.c_str()); if (tgGoodsItem.tradeType==PlayerShop::TT_SINGLE&&dwNameSize>18) { _snprintf(strGoodsName,19,"%s",tgGoodsItem.strGoodsName.c_str()); sprintf((strGoodsName+18),"..."); }else if (tgGoodsItem.tradeType==PlayerShop::TT_GROUP&&dwNameSize>10) { _snprintf(strGoodsName,11,"%s",tgGoodsItem.strGoodsName.c_str()); sprintf((strGoodsName+10),"..."); } else sprintf(strGoodsName,"%s",tgGoodsItem.strGoodsName.c_str()); wnd->setText(ToCEGUIString(strGoodsName)); wnd->setTooltipText(tgGoodsItem.strGoodsName); } // 交易方式 sprintf(tempText, "PlayerShop/backgrond/Goods%d/TradeType", index+1); wnd = GetWndMgr().getWindow(tempText); if (wnd) { if (tgGoodsItem.tradeType==PlayerShop::TT_SINGLE) { wnd->setText(ToCEGUIString("单个贩卖")); //CEGUI::FreeTypeFont * font = static_cast<CEGUI::FreeTypeFont*>( wnd->getFont() ); //font->setPointSize(8); } else if (tgGoodsItem.tradeType==PlayerShop::TT_GROUP) { wnd->setText(ToCEGUIString("成组贩卖")); } } // 价格 sprintf(tempText, "PlayerShop/backgrond/Goods%d/Price", index+1); wnd = GetWndMgr().getWindow(tempText); if (wnd) { sprintf(tempText,"%d",tgGoodsItem.price); wnd->setText(tempText); } }
// 更新界面操作按钮状态 bool OnPlayerShopOperBtnUpdate(const CEGUI::EventArgs& e) { CEGUI::Window* mainPage = WEArgs(e).window; if(!mainPage) return false; CEGUI::Window* messageBoardBtn = mainPage->getChildRecursive("PlayerShop/backgrond/Messageboard"); CEGUI::Window* HideShowBtn = mainPage->getChildRecursive("PlayerShop/backgrond/HideShowBtn"); CEGUI::Window* beginStopBtn = mainPage->getChildRecursive("PlayerShop/backgrond/BeginStopBtn"); CEGUI::Window* closeBtn = mainPage->getChildRecursive("PlayerShop/backgrond/CloseBtn"); if (!messageBoardBtn || !HideShowBtn || !beginStopBtn || !closeBtn) return false; PlayerShop& playerShop = GetPlayerShop(); int shopState = playerShop.GetCurShopState(); bool shopSetSure = playerShop.GetbSetTrue(); if(shopState < 0 || shopState >= PlayerShop::SHOP_STATE) return false; vector<PlayerShop::tagGoodsItem>& myShopGoods = playerShop.GetMyShopGoods(); // 设置商店 if(shopState == PlayerShop::SET_SHOP) { if (!myShopGoods.empty()) { // 如果商店中有物品就把开始摆摊显示出来 beginStopBtn->setVisible(true); beginStopBtn->enable(); beginStopBtn->setText(ToCEGUIString(AppFrame::GetText("开始贩卖"))); }else { // 如果商店中有物品就让开始摆摊不显示出来 beginStopBtn->setVisible(false); } HideShowBtn->setVisible(false); } // 打开商店 else if(shopState == PlayerShop::OPEN_SHOP) { // 停止摆摊 & 隐藏商店显示出来 beginStopBtn->setVisible(true); beginStopBtn->enable(); beginStopBtn->setText(ToCEGUIString(AppFrame::GetText("停止贩卖"))); HideShowBtn->setVisible(true); HideShowBtn->enable(); HideShowBtn->setText(ToCEGUIString(AppFrame::GetText("隐藏商店"))); } // 购买状态 else if(shopState == PlayerShop::SHOPPING_SHOP) { if (shopSetSure) { // 重设 & 购买显示出来 beginStopBtn->setVisible(true); beginStopBtn->enable(); beginStopBtn->setText(ToCEGUIString(AppFrame::GetText("购买"))); HideShowBtn->setVisible(true); HideShowBtn->enable(); HideShowBtn->setText(ToCEGUIString(AppFrame::GetText("重设"))); } else { // 确定 & 购买显示出来 beginStopBtn->setVisible(true); beginStopBtn->disable(); beginStopBtn->setText(ToCEGUIString(AppFrame::GetText("购买"))); HideShowBtn->setVisible(true); HideShowBtn->enable(); HideShowBtn->setText(ToCEGUIString(AppFrame::GetText("确定"))); } } return true; }
CEGUI::String LinkButtonParser::Parse(const CEGUI::String &str) { std::string szStr = CEGUIStringToAnsiChar( str ); size_t parentWinPos,IDPos,TextPos,ColorPos,endPos; parentWinPos = IDPos = TextPos = ColorPos = endPos = CEGUI::String::npos; char ParentWinName[128] = ""; char LinkID[32] = ""; char LinkText[128] = ""; char ColorVal[32] = ""; parentWinPos = str.find("WIN:"); IDPos = str.find("ID:"); TextPos = str.find("TEXT:"); ColorPos = str.find("COLOR:"); std::string wndName("LinkBtn_"),temp; static DWORD LinkWndCounter = 0; wndName += CEGUI::PropertyHelper::intToString(LinkWndCounter++).c_str(); CEGUI::Window *linkWnd = 0; if (CEGUI::WindowManager::getSingleton().isWindowPresent(wndName) == false) { linkWnd = CEGUI::WindowManager::getSingleton().createWindow("TaharezLook/Button",wndName); linkWnd->subscribeEvent(CEGUI::PushButton::EventClicked,CEGUI::Event::Subscriber(&LinkButtonParser::OnLinkBtnClicked,this)); //解析父窗口 if (parentWinPos != CEGUI::String::npos) { temp = szStr.substr(parentWinPos+5); endPos = temp.find("'"); strcpy_s<128>(ParentWinName,temp.substr(0,endPos).c_str()); CEGUI::Window *pParentWnd = CEGUI::WindowManager::getSingleton().getWindow(ParentWinName); pParentWnd->addChildWindow(linkWnd); } //解析ID if (IDPos != CEGUI::String::npos) { temp = szStr.substr(IDPos+3); endPos = temp.find(" "); strcpy_s<32>(LinkID,temp.substr(0,endPos).c_str()); LinkMap[linkWnd] = LinkID; } //解析链接按钮文本 if (TextPos != CEGUI::String::npos) { temp = szStr.substr(TextPos+6); endPos = temp.find("'"); strcpy_s<128>(LinkText,temp.substr(0,endPos).c_str()); float fWidth = linkWnd->getFont()->getTextExtent(LinkText); float fheight = linkWnd->getFont()->getFontHeight(); linkWnd->setSize(CEGUI::UVector2(cegui_absdim(fWidth),cegui_absdim(fheight))); //解析链接按钮文本的颜色 if (ColorPos != CEGUI::String::npos) { temp = szStr.substr(ColorPos+6); endPos = temp.find(" "); strcpy_s(ColorVal,temp.substr(0,endPos).c_str()); temp = "[COLOR "; temp += ColorVal; temp += "]"; temp += CEGUI::String(LinkText).c_str(); linkWnd->setText(ToCEGUIString(temp.c_str())); } else linkWnd->setText(ToCEGUIString(LinkText)); } } return wndName; }