コード例 #1
0
ファイル: ArrayEditor.cpp プロジェクト: Ocerus/Ocerus
	void ArrayEditor<ElementType>::SetupWidget(Model* model)
	{
		// Set dimensions
		CEGUI::UDim dimLeft = model->IsShareable() ? cegui_absdim(16) : cegui_absdim(0);

		// Setup label widget
		CEGUI::Window* labelWidget = mHeaderWidget->getChildAtIdx(0);
		labelWidget->setArea(CEGUI::URect(dimLeft, cegui_absdim(0), CEGUI::UDim(0.5f, -2), cegui_reldim(1)));
		labelWidget->setText(utf8StringToCEGUI(model->GetName()));
		labelWidget->setTooltipText(model->GetTooltip());

		// Setup buttons
		if (model->IsReadOnly())
		{
			mButtonAddElement->setEnabled(false);
			mButtonSave->setEnabled(false);
			mButtonRevert->setEnabled(false);
		}
		else
		{
			mButtonAddElement->setEnabled(true);
			mButtonSave->setEnabled(false);
			mButtonRevert->setEnabled(false);
		}
		
		// Setup is-shared checkbox
		CEGUI::Checkbox* isSharedCheckbox = static_cast<CEGUI::Checkbox*>(mHeaderWidget->getChildAtIdx(4));
		if (model->IsShareable())
		{
			isSharedCheckbox->setVisible(true);
			isSharedCheckbox->setPosition(CEGUI::UVector2(cegui_absdim(0), cegui_absdim(0)));
			isSharedCheckbox->setSelected(model->IsShared());
		}
		else
		{
			isSharedCheckbox->setVisible(false);
		}

		// Setup body widget
		mEditorWidget->getChildAtIdx(1)->setHeight(cegui_absdim(0));
		mBodyLayout->Clear();
	}
コード例 #2
0
ファイル: Gui.cpp プロジェクト: agudpp/CordobaZombie
void Gui::cargarImagen(const string &imagen, const string &nombre)
{
	CEGUI::Window *myImageWindow = CEGUI::WindowManager::getSingleton().createWindow("Menu/StaticImage", nombre);
	wMgrPtr->getWindow("Root")->addChildWindow(myImageWindow);
	myImageWindow->setPosition(CEGUI::UVector2( CEGUI::UDim( 0, 0 ), CEGUI::UDim( 0, 0 ) ) );

	cout<<"h " << h << endl;
	float proporcion = (float)h / 1920;
	cout<<"proporcion " << proporcion << endl;
	int ancho = 944*proporcion;
	cout<<"ancho " << ancho << endl;

	myImageWindow->setSize(CEGUI::UVector2(CEGUI::UDim(0,ancho),CEGUI::UDim(1,0)));
	myImageWindow->setProperty("Image",imagen);
	myImageWindow->setProperty("BackgroundEnabled", "true");
	myImageWindow->setProperty("FrameEnabled", "False");
	myImageWindow->setText("Prueba de texto dentro de la ventana");
	myImageWindow->setTooltipText("Texto de la imagen");
	myImageWindow->setAlpha(1.0);

}
コード例 #3
0
void  DrawWarfare::DoDraw(Logic::ShowWarfare* 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 ="BattlifieldSheet/";
	Ogre::String text;
	mCountry = evnt->contry;
	if(wmgr.isWindowPresent("BattlifieldSheet")){
		if(!evnt->isReSend){
			ClearFromAllChild(mFrameWindow);
		}

		if(!evnt->isReSend){
			mFrameWindow->addChildWindow(mCloseBtn); 

		}
	}else{
		mFrameWindow= wmgr.createWindow("TaharezLook/StaticImage",  "BattlifieldSheet");
		mFrameWindow->setSize(CEGUI::UVector2(CEGUI::UDim(1, 0), CEGUI::UDim(1, 0)));
		mCloseBtn= wmgr.createWindow("TaharezLook/Button",  "BattlifieldSheet/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));
		mFrameWindow->addChildWindow(mCloseBtn);

	}
	int i=0,j=0;
	std::map<Ogre::String,int>::iterator charItr;
	std::map<Ogre::String,Ogre::String>::iterator charContItr;
	float size= evnt->countryChar.size();
	for(charContItr=evnt->countryChar.begin();charContItr!= evnt->countryChar.end();++charContItr){

		name="BattlifieldSheet/countrychar"+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(1/size*i,0), CEGUI::UDim(0.1, 0)));
			res->setSize(CEGUI::UVector2(CEGUI::UDim(1/size, 0), CEGUI::UDim(0.15, 0)));

			mFrameWindow->addChildWindow(res);
		}
		i++;
		res->setText(charContItr->first+" :\n "+charContItr->second);
	}
	std::vector<Logic::UnitForSendWar>::iterator unitItr;
	i=0;
	for(unitItr=evnt->playerUnit.begin();unitItr!= evnt->playerUnit.end();++unitItr){
		name="BattlifieldSheet/unitName"+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.25, 0)));
			res->setSize(CEGUI::UVector2(CEGUI::UDim(0.1, 0), CEGUI::UDim(0.3, 0)));

			mFrameWindow->addChildWindow(res);
		}
		
		res->setText(unitItr->name);
		
		j=0;
		name="";
		
		for(charItr=unitItr->character.begin();charItr!= unitItr->character.end();++charItr){
			if(charItr->first=="Manpower"){
				text="\n HP:"+Logic::LogicStd::IntToString(charItr->second);
			}
			name +=charItr->first+" : "+Logic::LogicStd::IntToString(charItr->second)+"\n";
		}
		res->setText(unitItr->name+text);
		res->setTooltipText(name);
		i++;
	}
	i=0;
	for(unitItr=evnt->NPCUnit.begin();unitItr!= evnt->NPCUnit.end();++unitItr){
		name="BattlifieldSheet/npcunitName"+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.65, 0)));
			res->setSize(CEGUI::UVector2(CEGUI::UDim(0.1, 0), CEGUI::UDim(0.3, 0)));

			mFrameWindow->addChildWindow(res);
		}
		
	
		
		
		name="";
		
		for(charItr=unitItr->character.begin();charItr!= unitItr->character.end();++charItr){
			if(charItr->first=="Manpower"){
				text="\n HP:"+Logic::LogicStd::IntToString(charItr->second);
			}
			name +=charItr->first+" : "+Logic::LogicStd::IntToString(charItr->second)+"\n";
		}
		res->setText(unitItr->name+text);
		res->setTooltipText(name);
		i++;
	}

	for(i=0;i<4;i++){
		name = "BattlifieldSheet/action"+Logic::LogicStd::IntToString(i);
		if(!wmgr.isWindowPresent(name)){

			res= wmgr.createWindow("TaharezLook/Button",name );
			res->setPosition(CEGUI::UVector2(CEGUI::UDim(1-0.15*(i+1),0), CEGUI::UDim(0, 0)));
			res->setSize(CEGUI::UVector2(CEGUI::UDim(0.15, 0), CEGUI::UDim(0.05, 0)));
			
			res->subscribeEvent(CEGUI::PushButton::EventClicked,
				CEGUI::Event::Subscriber(&DrawWarfare::SetAction,this));
			res->setUserString("type" ,Logic::LogicStd::IntToString(i));
		}else{
			res= wmgr.getWindow(name);
			if(!evnt->isReSend){
				mFrameWindow->addChildWindow(res);
			}
		}
		name = "";
		
		if(evnt->curAction == (Logic::WarfareAction)i){
			name="[colour='FFFF0000']";
		}
		switch(i){
			case 0:
				res->setText(name+"Stand");	
				break;
			case 1:
				res->setText(name+"Occupied");	
				break;
			case 2:
				res->setText(name+"Pillage");	
				break;	
			case 3:
				res->setText(name+"Kill with Fire");	
				break;
			}
		if(!evnt->isReSend){
			mFrameWindow->addChildWindow(res);
		}
	} 
	switch(evnt->status){
	case  Logic::WARSTS_AFTERMATCH:

		break;
	}
	if(!evnt->isReSend){
	mMainWindow->addChildWindow(mFrameWindow);
	PriorIdDraw= true;
	}else{
	PriorIdDraw= false;
	}
}
コード例 #4
0
// 添加货物列表
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);
	}
}