示例#1
0
bool DynamicEditor::createFactory(const CEGUI::EventArgs& _args)
{
    unsigned int index = typeTab->getSelectedTabIndex();
    CEGUI::Window* tab = typeTab->getTabContentsAtIndex(index);
    static_cast<EditorFactoryType*>(tab->getUserData())->createButton(_args);
    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 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 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 OgreCmdWindow::entryKeyDownHandler(const CEGUI::EventArgs& e)
 {
     std::stringstream ss;
     if(((const CEGUI::KeyEventArgs&)e).scancode == 28)
     {
         CEGUI::Window * wnd = ((const CEGUI::KeyEventArgs&)e).window;
         ((OgreCmdWindow*)wnd->getUserData())->readString(wnd->getText().c_str());
         wnd->setText("");
     }
     return true;
 }
CGUITab* CGUITabPanel_Impl::GetSelectedTab ( void )
{
    CEGUI::TabControl* pControl = reinterpret_cast < CEGUI::TabControl* > ( m_pWindow );

    if ( pControl->getTabCount() > 0 )
    {
        CEGUI::Window* pTab = pControl->getTabContentsAtIndex ( pControl->getSelectedTabIndex() );

        try
        {
            return reinterpret_cast < CGUITab* > ( pTab->getUserData() );
        }
        catch ( CEGUI::Exception )
        {
            return NULL;
        }
    }
    return NULL;
}
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;
}
示例#8
0
InputContext* DynamicEditor::getActiveEditor()
{
    CEGUI::Window* page = instanceTab->getTabContentsAtIndex(instanceTab->getSelectedTabIndex());
    return static_cast<InputContext*>(page->getUserData());
}
示例#9
0
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;
	}
	


}