void UpdatePetStrenthenWnd(CEGUI::Window* mainPage, long type) { if (!mainPage) return; char tempText[256]; CPlayer* player = GetGame()->GetMainPlayer(); map<CGUID, CPet*>* petList = player->GetPetList(); map<CGUID, CPet*>::iterator iterPet = petList->begin(); for (int i=0; iterPet!=petList->end(); ++iterPet,++i) { sprintf(tempText, "PetStrengthen/PetSelectWnd/Pet%d/DragContainer", i+1); CEGUI::Window* dragItem = mainPage->getChildRecursive(tempText); if (dragItem) { CEGUI::GUISheet* childImg = WGUISheet(dragItem->getChildAtIdx(0)); if(!childImg) return; SetBackGroundImage(childImg,"PetID","pictures\\Pet\\PetIcon","pet.jpg"); } if (i>=PET_SELECT_WND_CNT-1) break; } }
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 OnUpdateLatestBuy(const CEGUI::EventArgs& e) { CEGUI::Window* wnd = WEArgs(e).window; //先把图片清掉 ,默认为十个条目 char name[256] = ""; for(uint i = 0 ; i < 10 ; ++i) { sprintf(name,SHOPCITY_LATESTBUY_ITME_NAME_D,i); CEGUI::Window* temp = wnd->getChild(name); if(temp) { temp->setProperty("Image",""); OutputDebugStr(temp->getName().c_str()); OutputDebugStr("\n"); } } //由索引关联商城类型 SCGData::eSCType eCityType = GetShopCityTypeByTabContentSelIndex(); SCGData* dt = GetInst(ShopCityMsgMgr).GetShopCityGoodsData(); SCGData::MapSBT10& personal = dt->GetSelfBuyTop10(); SCGData::VecGDPTA perDTA = personal[eCityType]; size_t count = perDTA.size(); for(size_t i = 0 ; i < count ; ++i) { char name[256] = ""; sprintf(name,SHOPCITY_LATESTBUY_ITME_NAME_D,i); CEGUI::Window* temp = wnd->getChild(name); if(temp) { CGoodsList::tagGoods2* tg2 = CGoodsList::GetProperty(perDTA[i].index); if(tg2) { char imagesetname[256]; sprintf(imagesetname,GOODS_PREFIXID,tg2->BaseProperty.dwIconId); CEGUI::String imagename = CEGUI::PropertyHelper::intToString(tg2->BaseProperty.dwIconId)+".jpg"; SetBackGroundImage(WGUISheet(temp),imagesetname,GOODS_ICON_PATH,imagename.c_str()); } } } return 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); } }