void DrawBase::DrawBlueprint(Logic::SendBlueToGui *evnt){ CEGUI::WindowManager &wmgr = CEGUI::WindowManager::getSingleton(); CEGUI::Window *res; Ogre::String name; Ogre::String text; int x=0,y=0,i=0; std::vector<Logic::BuildingBlueprint *>::iterator the_iterator; the_iterator = evnt->allBlue.begin(); if(wmgr.isWindowPresent( "Blueprint/sheet")){ mBlueSheet= wmgr.getWindow( "Blueprint/sheet"); ClearFromAllChild(mBlueSheet); mBlueSheet->addChildWindow(mBlueSheetClose); }else{ mBlueSheet= wmgr.createWindow("TaharezLook/StaticImage", "Blueprint/sheet"); mBlueSheet->setSize(CEGUI::UVector2(CEGUI::UDim(0.5, 0), CEGUI::UDim(0.5, 0))); mBlueSheet->setPosition(CEGUI::UVector2(CEGUI::UDim(0.5,0), CEGUI::UDim(0, 0))); mBlueSheetClose= wmgr.createWindow("TaharezLook/Button", "Blueprint/close"); mBlueSheetClose->setPosition(CEGUI::UVector2(CEGUI::UDim(0,0), CEGUI::UDim(0, 0))); mBlueSheetClose->setSize(CEGUI::UVector2(CEGUI::UDim(0.3, 0), CEGUI::UDim(0.1, 0))); mBlueSheetClose->setText("Close"); mBlueSheetClose->subscribeEvent(CEGUI::PushButton::EventClicked, CEGUI::Event::Subscriber(&BaseDraw::Close,(BaseDraw*) this)); mBlueSheet->addChildWindow(mBlueSheetClose); } while (the_iterator != evnt->allBlue.end()) { name= "Blueprint/BlueNum"+Logic::LogicStd::IntToString(i++); if(wmgr.isWindowPresent(name)){ res= wmgr.getWindow(name); res->setUserData((*the_iterator)); mBlueSheet->addChildWindow(res); }else{ res= wmgr.createWindow("TaharezLook/Button", name); res->setPosition(CEGUI::UVector2(CEGUI::UDim(0.5*x,0), CEGUI::UDim(0.2*y+0.1, 0))); res->setSize(CEGUI::UVector2(CEGUI::UDim(0.5, 0), CEGUI::UDim(0.2, 0))); res->setUserData((*the_iterator)); mBlueSheet->addChildWindow(res); res->subscribeEvent(CEGUI::PushButton::EventClicked, CEGUI::Event::Subscriber(&DrawBase::BuildOrder, this)); } text=(*the_iterator)->mName; text+="_"+Logic::LogicStd::IntToString((*the_iterator)->mCost); res->setText(text); if(++x>=2){ x=0; y++; } ++the_iterator; } mMainWindow->addChildWindow(mBlueSheet); }
bool OnPlayerShopResetGoods(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; CPlayer *pPlayer = GetGame()->GetMainPlayer(); CMainPlayerHand* pHand = GetGame()->GetMainPlayerHand(); if (!pPlayer || !pHand) return false; int shopState = GetPlayerShop().GetCurShopState(); if (shopState==PlayerShop::SET_SHOP) { GetPlayerShop().ReMoveShopGoods(goods->GetIndex(),goods->GetExID()); wnd->setUserData(NULL); int index = GetPlayerShop().GetCurGoodsNum(); GetPlayerShop().OnOrderPageOpen(goods, index); FireUIEvent("PlayerShop","ClearGoodsInfo"); FireUIEvent("PlayerShop","UpdateMoneyInfo"); return true; } return false; }
bool CActionListPopup::OnShow(Events::CEventDispatcher* pDispatcher, const Events::CEventBase& Event) { Data::PParams P = ((const Events::CEvent&)Event).Params; Clear(); //???here or when hidden? need to process re-request when visible pActorEnt = (Game::CEntity*)P->Get<PVOID>(CStrID("ActorEntityPtr")); pCtl = (Prop::CPropUIControl*)P->Get<PVOID>(CStrID("CtlPtr")); if (!pCtl) OK; // Later this may be a case for formation & movement menu const CArray<Prop::CPropUIControl::CAction>& Actions = pCtl->GetActions(); // Actions are sorted by Enabled flag and then by priority for (CArray<Prop::CPropUIControl::CAction>::CIterator It = Actions.Begin(); It != Actions.End(); ++It) if (It->Visible) { CEGUI::Window* pItem = CEGUI::WindowManager::getSingleton().createWindow("TaharezLook/MenuItem"); pItem->setText((CEGUI::utf8*)It->GetUIName()); pItem->setEnabled(It->Enabled); if (It->Enabled) { pItem->setUserData((void*)It->ID.CStr()); pItem->subscribeEvent(CEGUI::MenuItem::EventClicked, CEGUI::Event::Subscriber(&CActionListPopup::OnBtnClicked, this)); } pWnd->addChild(pItem); } if (((CEGUI::PopupMenu*)pWnd)->getItemCount()) { CEGUI::Vector2f Pos = pWnd->getGUIContext().getMouseCursor().getPosition(); SetPosition(CEGUI::UVector2(CEGUI::UDim(0.f, Pos.d_x), CEGUI::UDim(0.f, Pos.d_y))); Show(); } else Hide(); OK; }
InputContext* DynamicEditor::EditorFactoryType::createEditor(CEGUI::TabControl* _tab, std::string _factoryName, std::string _typeName, DynamicEditor* _editor) { CEGUI::Window* page = CEGUI::WindowManager::getSingletonPtr()->loadWindowLayout("EntityInstanceTab.layout", _factoryName); FactoryParameters* params = new FactoryParameters(true); DynamicEditorMode* editorMode = modeFactory->createMode(page, params); CEGUI::Window* typeNameDisplay = page->getChild(_factoryName + "Tab/EntityTypeName"); typeNameDisplay->appendText(_typeName); page->setProperty("Text",_factoryName); _tab->addTab(page); page->setUserData(editorMode); editorMode->initEditorMode(_factoryName, _editor); float uiElementTop = 0.0f; for (auto i = instanceVariableFactories.begin(); i != instanceVariableFactories.end(); i++) { DynamicEditorVariable* editorVar = (*i)->createVariable(editorMode->getWindow(),params->getTypeTable(), _factoryName, &uiElementTop); editorMode->addVariable((*i)->getName(), editorVar); } return editorMode; }
void DrawMilitary::DoDraw(Logic::ShowMilitary *evnt){ if(!isOpen&&evnt->isReSend){ return; } if(evnt->isReSend&& PriorIdDraw){ return; } isOpen =true; mIsResend = false; CEGUI::WindowManager &wmgr = CEGUI::WindowManager::getSingleton(); CEGUI::Window *res; CEGUI::ProgressBar *prog; Ogre::String name ="MilitarySheet/"; Ogre::String text; mBuilding = evnt->target; if(wmgr.isWindowPresent("MilitarySheet")){ if(!evnt->isReSend){ ClearFromAllChild(mFrameWindow); } prog= static_cast<CEGUI::ProgressBar *>(wmgr.getWindow("MilitarySheet/Progress")); if(!evnt->isReSend){ mFrameWindow->addChildWindow(mCloseBtn); mFrameWindow->addChildWindow(prog); } }else{ mFrameWindow= wmgr.createWindow("TaharezLook/StaticImage", "MilitarySheet"); mFrameWindow->setSize(CEGUI::UVector2(CEGUI::UDim(1, 0), CEGUI::UDim(1, 0))); mCloseBtn= wmgr.createWindow("TaharezLook/Button", "MilitarySheet/Close"); mCloseBtn->setPosition(CEGUI::UVector2(CEGUI::UDim(0,0), CEGUI::UDim(0, 0))); mCloseBtn->setSize(CEGUI::UVector2(CEGUI::UDim(0.15, 0), CEGUI::UDim(0.05, 0))); mCloseBtn->setText("Close"); mCloseBtn->subscribeEvent(CEGUI::PushButton::EventClicked, CEGUI::Event::Subscriber(&BaseDraw::Close,(BaseDraw*) this)); prog= static_cast<CEGUI::ProgressBar *>(wmgr.createWindow("TaharezLook/ProgressBar", "MilitarySheet/Progress")); prog->setPosition(CEGUI::UVector2(CEGUI::UDim(0.2,0), CEGUI::UDim(0, 0))); prog->setSize(CEGUI::UVector2(CEGUI::UDim(0.2, 0), CEGUI::UDim(0.05, 0))); mFrameWindow->addChildWindow(mCloseBtn); mFrameWindow->addChildWindow(prog); } prog->setProgress(evnt->procent); int i=0; while(i<5&&!(evnt->unitQueue.empty())){ name="MilitarySheet/quere"+Logic::LogicStd::IntToString(i); if(wmgr.isWindowPresent(name)){ res= wmgr.getWindow(name); if(!evnt->isReSend){ mFrameWindow->addChildWindow(res); } }else{ res= wmgr.createWindow("TaharezLook/StaticText", name); res->setPosition(CEGUI::UVector2(CEGUI::UDim(0.1*i,0), CEGUI::UDim(0.05, 0))); res->setSize(CEGUI::UVector2(CEGUI::UDim(0.1, 0), CEGUI::UDim(0.1, 0))); mFrameWindow->addChildWindow(res); } res->setText(evnt->unitQueue.front()); evnt->unitQueue.pop(); i++; } i=0; std::map<Ogre::String,Logic::BaseUnitBlueprint*>::iterator iterAvUn; for(iterAvUn = evnt->avaibleUnits.begin();iterAvUn!=evnt->avaibleUnits.end();++iterAvUn){ name="MilitarySheet/availebtobuild"+Logic::LogicStd::IntToString(i); if(wmgr.isWindowPresent(name)){ res= wmgr.getWindow(name); if(!evnt->isReSend){ mFrameWindow->addChildWindow(res); } }else{ res= wmgr.createWindow("TaharezLook/Button", name); res->setPosition(CEGUI::UVector2(CEGUI::UDim(0.9,0), CEGUI::UDim(0.1*i+0.05, 0))); res->setSize(CEGUI::UVector2(CEGUI::UDim(0.1, 0), CEGUI::UDim(0.1, 0))); res->subscribeEvent(CEGUI::PushButton::EventClicked, CEGUI::Event::Subscriber(&DrawMilitary::AddUnitToQueue, this)); mFrameWindow->addChildWindow(res); } res->setUserData(iterAvUn->second); res->setText(iterAvUn->first); } i=0; std::vector<Logic::UnitToSend>::iterator iterUnOnBase; int x=0,y=0; for(iterUnOnBase = evnt->unitOnBase.begin();iterUnOnBase!=evnt->unitOnBase.end();++iterUnOnBase){ name="MilitarySheet/onBase"+Logic::LogicStd::IntToString(i); if(wmgr.isWindowPresent(name)){ res= wmgr.getWindow(name); if(!evnt->isReSend){ mFrameWindow->addChildWindow(res); } }else{ res= wmgr.createWindow("TaharezLook/Button", name); res->setPosition(CEGUI::UVector2(CEGUI::UDim(0.15*x,0), CEGUI::UDim(0.05*(y+1)+0.5, 0))); res->setSize(CEGUI::UVector2(CEGUI::UDim(0.15, 0), CEGUI::UDim(0.05, 0))); mFrameWindow->addChildWindow(res); res->subscribeEvent(CEGUI::PushButton::EventClicked, CEGUI::Event::Subscriber(&DrawMilitary::UnitClick, this)); } res->setText(iterUnOnBase->name); res->setUserData(iterUnOnBase->unit); if(++x>3){ y++; x=0; } i++; } if(!evnt->isReSend){ mMainWindow->addChildWindow(mFrameWindow); PriorIdDraw= true; }else{ PriorIdDraw= false; } }
DynamicEditor::EditorFactoryType* DynamicEditor::searchExistingFactoryInstances(const std::string& factoryName) { AbstractFactoryBase<Entity>* factory = nullptr; /// FIXME AbstractFactories::global().getFactory<Entity>(factoryName); EditorFactoryType* editor = nullptr; { FactoryParameters _parameters(true); deadBodies.push_back(factory->use(&_parameters, nullptr)); std::vector<std::string> values = _parameters.getUndefinedLog(); /// FIXME this could be faster, its stored as a map internally, we could sort it for (auto editorMode = editorModes.begin(); editorMode != editorModes.end(); editorMode++) { unsigned int matches = 0; std::vector<std::vector<std::string>::iterator> matchedStrings; /// Keep a track of these so we can delete them in case of a complete match for (auto string = editorMode->first.begin(); string != editorMode->first.end(); string++) { for (auto value = values.begin(); value != values.end(); value++) { if (*value == *string) { matches++; matchedStrings.push_back(value); break; } } } if (matches == editorMode->first.size()) { editor = new EditorFactoryType(editorMode->second, this, factoryName); while (!matchedStrings.empty()) { values.erase(matchedStrings.back()); matchedStrings.pop_back(); } for (auto value = values.begin(); value != values.end(); value++) { auto variable = editorVariables.find(*value); if (variable != editorVariables.end()) { editor->addInstanceVariableFactory(variable->second); } } editor->addInstanceVariableFactory(nameVariableControllerFactory); //break; goto MATCH_FOUND; } } } return nullptr; MATCH_FOUND: TextFileFactoryLoader loader(nullptr, nullptr, true); /// FIXME FactoryGetList getList; ///Events::global().registerListener<FactoryGetEvent<Entity>>(&getList,{eBlockQueue}); FIXME this is now missing //factory->baseInit(factoryName, &loader, &AbstractFactories::global()); ///Events::global().unregisterListener<FactoryGetEvent<Entity>>(&getList, true); std::vector<std::string> values = loader.getUndefinedLog(); FactoryParameters* params = new FactoryParameters(nullptr); CEGUI::Window* page = CEGUI::WindowManager::getSingletonPtr()->loadWindowLayout("EntityTypeTab.layout", factoryName); page = page->getChild(factoryName + "Properties"); float uiElementTop = 0.f; for (auto value = values.begin(); value != values.end(); value++) { auto variable = editorVariables.find(*value); if (variable != editorVariables.end()) { editor->addTypeVariable(variable->second->createVariable(page, params->getTypeTable(),factoryName, &uiElementTop)); } else { TextEditBoxFactory factory(*value, ""); editor->addTypeVariable(factory.createVariable(page, params->getTypeTable(),factoryName, &uiElementTop)); } } page->setProperty("Text",factoryName); typeTab->addTab(page); page->setUserData(editor); CEGUI::Window* factoryNameBox = typeTab->getParent()->getChild("Root/EntityTypes/NewFactoryName"); editor->setInstanceNameWidget(factoryNameBox); return editor; }
void DrawBase::DoDraw(Logic::SendCoreToGui *evnt){ if(!isOpen&&evnt->isReSend){ return; } if(evnt->isReSend&& PriorIdDraw){ return; } mIsResend= false; CEGUI::WindowManager &wmgr = CEGUI::WindowManager::getSingleton(); CEGUI::Window *res; isOpen = true; Ogre::String name; int x=0,y=0; name= "BaseDraw"; if(wmgr.isWindowPresent(name)){ mFrameWindow= wmgr.getWindow(name); }else{ mFrameWindow= wmgr.createWindow("DefaultWindow", name); mFrameWindow->setSize(CEGUI::UVector2(CEGUI::UDim(0.5, 0), CEGUI::UDim(0.5, 0))); mFrameWindow->setMousePassThroughEnabled(true); mCloseBtn= wmgr.createWindow("TaharezLook/Button", "BaseDraw/Close"); mCloseBtn->setPosition(CEGUI::UVector2(CEGUI::UDim(0,0), CEGUI::UDim(0, 0))); mCloseBtn->setSize(CEGUI::UVector2(CEGUI::UDim(0.3, 0), CEGUI::UDim(0.1, 0))); mCloseBtn->setText("Close"); mCloseBtn->subscribeEvent(CEGUI::PushButton::EventClicked, CEGUI::Event::Subscriber(&BaseDraw::Close,(BaseDraw*)this)); mFrameWindow->addChildWindow(mCloseBtn); } for(int i=0; i < evnt->SlotCnt;++i){ name= "BaseDraw/BuildNum_"+Logic::LogicStd::IntToString(i); if(wmgr.isWindowPresent(name)){ res= wmgr.getWindow(name); delete static_cast<Logic::BuildingForSent *>( res->getUserData()); res->setUserData(evnt->allSlots[i]); }else{ res= wmgr.createWindow("TaharezLook/Button", name); res->setPosition(CEGUI::UVector2(CEGUI::UDim(0.33*x,0), CEGUI::UDim(0.1*(y+1), 0))); res->setSize(CEGUI::UVector2(CEGUI::UDim(0.33, 0), CEGUI::UDim(0.1, 0))); res->setUserData(evnt->allSlots[i]); res->subscribeEvent(CEGUI::Window::EventDestructionStarted, CEGUI::Event::Subscriber(&BaseDraw::ClearUserData,(BaseDraw*)this)); mFrameWindow->addChildWindow(res); res->subscribeEvent(CEGUI::PushButton::EventClicked, CEGUI::Event::Subscriber(&DrawBase::SlotClick, this)); } if(evnt->allSlots[i]->empty){ res->setText("EMPTY"); }else{ res->setText(evnt->allSlots[i]->name); } if(++x>2){ x=0; y++; } } SetBase(evnt->target); if(!evnt->isReSend){ mMainWindow->addChildWindow(mFrameWindow); PriorIdDraw= true; }else{ PriorIdDraw= false; } }
// 添加货物列表 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); } }