示例#1
0
//更新寄售UI提示
bool UpdateAgentSaleUIDate(const CEGUI::EventArgs& e)
{
	CEGUI::WindowManager& mgr = GetWndMgr();
	CEGUI::Window* wnd = NULL;
	CEGUI::Editbox* edb = WEditBox(mgr.getWindow("Auction/Tab/Agent/sale/EditNum"));//寄售数量
	uint cnt = CEGUI::PropertyHelper::stringToInt(edb->getText());

	edb = WEditBox(mgr.getWindow("Auction/Tab/Agent/sale/EditPrice"));//寄售单价
	uint price = CEGUI::PropertyHelper::stringToInt(edb->getText());

	if(cnt == 0 || price == 0)//任意一个为0,则直接返回,不更新UI
	{
		//设置支付手续费提示
		wnd = mgr.getWindow("Auction/Tab/Agent/sale/subGold");
		wnd->setText("");
		return false;
	}
	//设置支付位面提示
	wnd = mgr.getWindow("Auction/Tab/Agent/sale/subNum");
	wnd->setText(CEGUI::PropertyHelper::intToString(cnt * ORDER_PER_NUM));
	//设置支付手续费提示
	wnd = mgr.getWindow("Auction/Tab/Agent/sale/subGold");
	float extraCust = cnt * price * AGENT_EXTRACUST ;
	wnd->setText(CEGUI::PropertyHelper::intToString((int)extraCust));
	return true;
}
示例#2
0
//更新委托求购界面提示
bool UpdateAgentBuyUIDate(const CEGUI::EventArgs& e)
{
	CEGUI::WindowManager& mgr = GetWndMgr();
	CEGUI::Window* wnd = NULL;
	//求购数量
	CEGUI::Editbox* edb = WEditBox(mgr.getWindow("Auction/Tab/Agent/Buy/EditNum"));
	uint cnt = CEGUI::PropertyHelper::stringToInt(edb->getText());
	//求购单价
	edb = WEditBox(mgr.getWindow("Auction/Tab/Agent/Buy/EditPrice"));
	uint price = CEGUI::PropertyHelper::stringToInt(edb->getText());
	if(cnt == 0 || price == 0)//如何一个为0,直接返回
	{
		wnd = mgr.getWindow("Auction/Tab/Agent/Buy/subGold");
		wnd->setText("");//手续费
		wnd = mgr.getWindow("Auction/Tab/Agent/Buy/Text");//总共支付
		wnd->setText("");
		return false;
	}
	//设置委托购买位面总价提示
	 wnd = mgr.getWindow("Auction/Tab/Agent/Buy/subNum");
	uint sumPrice = price * cnt;
	wnd->setText(CEGUI::PropertyHelper::intToString(sumPrice));

	float extreCust = price * cnt * AGENT_EXTRACUST;//手续费
	wnd = mgr.getWindow("Auction/Tab/Agent/Buy/subGold");
	wnd->setText(CEGUI::PropertyHelper::intToString((int)extreCust));

	wnd = mgr.getWindow("Auction/Tab/Agent/Buy/Text");//总共支付
	wnd->setText(CEGUI::PropertyHelper::intToString((sumPrice + (int)extreCust)));
	return true;
}
示例#3
0
bool UpdateSaleUIDate( const CEGUI::EventArgs& e )
{	
	CEGUI::WindowManager& mgr = GetWndMgr();
	CEGUI::Window* weimian = mgr.getWindow("Auction/SaleWnd/Text61");
	weimian->setText("");
	CEGUI::Window* gold = mgr.getWindow("Auction/SaleWnd/Text6");
	gold->setText("");
	//获取输入的出售数目
	CEGUI::Editbox* edb = WEditBox(mgr.getWindow("Auction/SaleWnd/saleNum"));
	if(!edb)
		return false;
	uint saleNum = CEGUI::PropertyHelper::stringToInt(edb->getText());
	if(saleNum==0)
		return false;
	//设置支付位面数
	weimian->setText(edb->getText());

	AHdata& ah = GetInst(AHdata);
	uint orderID = ah.GetCanSaleID();//获取要出售的订单ID
	uint price = ah.GetPriceByCanSaleID(orderID);//单价
	//计算价格
	uint subCust = saleNum * price;
	//设置需要支付金币
	gold->setText(CEGUI::PropertyHelper::intToString(subCust));
	return true;
}
bool CREvent::OnCreateRoleBtn(const CEGUI::EventArgs &e)
{
	if (GetInst(SelectRolePage).GetPlayerCount() >= 1)
	{
        GetInst(MsgEventManager).PushEvent(Msg_Ok,AppFrame::GetText("Base_34"));   //目前不能创建更多的角色了!
		return false;
	}
	CEGUI::Window *pPageWin = GetInst(CreateRolePage).GetPageWindow();
	CEGUI::Editbox* pNameEdit = static_cast<CEGUI::Editbox*>(pPageWin->getChild("EditName"));

	const char * strName = CEGUIStringToAnsiChar(pNameEdit->getText());
	if (strcmp(strName,"") == 0)
	{
		GetInst(MsgEventManager).PushEvent(Msg_Ok,AppFrame::GetText("Player_72"));  //"名字不能为空"
		return false;
	}
	if (!CheckName(strName))
	{
		GetInst(MsgEventManager).PushEvent(Msg_Ok,AppFrame::GetText("Player_73"));  //"名字中不能有空格"
		return false; 
	}
	int  iSex  = random(2);
	//RandomChoseDetails();
	//RandomChoseCountry();
	BYTE lConstellation = random(12) + 1;
	//const char *strName,char nOccupation, char nSex, BYTE lHead, BYTE lFace, BYTE lCountry,BYTE lConstellation,BYTE bRandCountry
	GetGame()->C2L_AddRole_Send(strName, 0, (char)GetSelectSex(), GetHair(), GetFace(), GetSelectCountry(), lConstellation, 0 );
	return true;
}
示例#5
0
bool OnAgentSaleSubmit(const CEGUI::EventArgs& e)
{
	//得到委托出售数目和单价
	AH::OrderRaw or;
	CEGUI::Editbox* edb = WEditBox(GetWndMgr().getWindow("Auction/Tab/Agent/sale/EditNum"));
	if(!edb)
		return false;
	or.id = -1;//-1标识 id不会用到
	//单数
	or.cnt = CEGUI::PropertyHelper::stringToInt(edb->getText());
	if(or.cnt == 0)
	{
		GetInst(MsgEventManager).PushEvent(Msg_Ok,AppFrame::GetText("AU_109"),NULL,NULL,true);
		return false;
	}
	edb = WEditBox(GetWndMgr().getWindow("Auction/Tab/Agent/sale/EditPrice"));
	if(!edb)
		return false;
	//单价
	or.price = CEGUI::PropertyHelper::stringToInt(edb->getText());
	if(or.price == 0)
	{
		GetInst(MsgEventManager).PushEvent(Msg_Ok,AppFrame::GetText("AU_110"),NULL,NULL,true);
		return false;
	}
	//检查玩家身上位面是否满足数目
	CPlayer* player = GetGame()->GetMainPlayer();
	long cnt = player->GetGoodsAmount(CGlobeSetup::GetSetup()->strWeiMianName);
	if(cnt < or.cnt * 100 ) //玩家身上数量小于出售数量
	{
		GetInst(MsgEventManager).PushEvent(Msg_Ok,AppFrame::GetText("AU_111"),NULL,NULL,true);
		return false;
	}
	//检查玩家身上的金币是否满足委托收取的手续费
	long money = player->GetMoney();
	float custm = or.cnt * or.price * AGENT_EXTRACUST;//算上手续费
	if ( custm > money  )
	{
		GetInst(MsgEventManager).PushEvent(Msg_Ok,AppFrame::GetText("AU_112"),NULL,NULL,true);
		return false;
	}
	//提交委托出售订单
	AHdata& ah = GetInst(AHdata);
	ah.Send_AH_ADD_AGENT(or,AH::OT_SELL);
	return true;
}
	void ControllerUI::CopyToClipboard(::CEGUI::Window* EditBox, bool Cut)
	{
		if (!EditBox)
			return;

		// get possibly typed instances we process
		CEGUI::Editbox* box				= dynamic_cast<CEGUI::Editbox*>(EditBox);
		CEGUI::MultiLineEditbox* mlbox	= dynamic_cast<CEGUI::MultiLineEditbox*>(EditBox);
		
		// type of Editbox
		if (box)
		{						
			// get text from cegui textbox
			::CEGUI::String boxStr = box->getText();

			size_t start = box->getSelectionStartIndex();
			size_t len = box->getSelectionLength();

			// get substring which is selected
			boxStr = boxStr.substr(start, len);
			
			// copy to clipboard
			if (boxStr.length() > 0)
			{
				::System::Windows::Forms::Clipboard::SetText(StringConvert::CEGUIToCLR(boxStr));
			
				if (Cut)			
					box->eraseSelectedText();
			}
		}

		// type of MultiLineEditbox
		else if (mlbox)
		{
			// get text from cegui textbox
			::CEGUI::String boxStr = mlbox->getText();

			size_t start = mlbox->getSelectionStartIndex();
			size_t len = mlbox->getSelectionLength();

			// get substring which is selected
			boxStr = boxStr.substr(start, len);
			
			// copy to clipboard
			if (boxStr.length() > 0)
			{
				::System::Windows::Forms::Clipboard::SetText(StringConvert::CEGUIToCLR(boxStr));
			
				if (Cut)			
					mlbox->eraseSelectedText();
			}
		}	
	};
示例#7
0
bool OnAgentBuySubmit(const CEGUI::EventArgs& e)
{
	//得到委托购买数目和单价
	AH::OrderRaw or;
	CEGUI::Editbox* edb = WEditBox(GetWndMgr().getWindow("Auction/Tab/Agent/Buy/EditNum"));
	if(!edb)
		return false;
	or.id = -1 ;// -1标识ID不会用到
	//数目
	or.cnt = CEGUI::PropertyHelper::stringToInt(edb->getText());//单位为:百个
	if(or.cnt == 0)
	{
		GetInst(MsgEventManager).PushEvent(Msg_Ok,AppFrame::GetText("AU_106"),NULL,NULL,true);
		return false;
	}
	edb = WEditBox(GetWndMgr().getWindow("Auction/Tab/Agent/Buy/EditPrice"));
	if(!edb)
		return false;
	//单价
	or.price = CEGUI::PropertyHelper::stringToInt(edb->getText());// 金币/100位面
	if(or.price == 0)
	{
		GetInst(MsgEventManager).PushEvent(Msg_Ok,AppFrame::GetText("AU_107"),NULL,NULL,true);
	}
	//检查玩家身上金币是否满足购买条件
	CPlayer* player = GetGame()->GetMainPlayer();
	long money = player->GetMoney();
	float custm = or.price * or.cnt * AGENT_EXTRACUST ;//算上手续费
	if( custm > money)
	{
		GetInst(MsgEventManager).PushEvent(Msg_Ok,AppFrame::GetText("AU_108"),NULL,NULL,true);
		return false;
	}

	//提交委托购买订单
	AHdata& ah = GetInst(AHdata);
	ah.Send_AH_ADD_AGENT(or,AH::OT_BUY);
	return true;
}
示例#8
0
/***********************************************************
handle connect button event
***********************************************************/
bool LoginGUI::HandleConnect(const CEGUI::EventArgs& e)
{
	try
	{
		CEGUI::WindowManager::getSingleton().getWindow("DisplayLoginErrorFrame")->hide();

		CEGUI::Editbox * lt = static_cast<CEGUI::Editbox *> (
				CEGUI::WindowManager::getSingleton().getWindow("LoginText"));
		CEGUI::Editbox * pt = static_cast<CEGUI::Editbox *> (
				CEGUI::WindowManager::getSingleton().getWindow("PasswordText"));

		CEGUI::Checkbox * cbl = static_cast<CEGUI::Checkbox *> (
				CEGUI::WindowManager::getSingleton().getWindow("LoginPlayLocalCb"));


		if(lt && pt && cbl)
		{
			bool seleplaylo = cbl->isSelected();
			std::string txtl = lt->getText().c_str();
			std::string txtt = pt->getText().c_str();
			if((txtl != "") && (txtl.size() <= 20) && (txtt.size() <= 20))
			{
				std::string samples = "Data/Samples/lba2launcherblob.wav";
				MusicHandler::getInstance()->PlaySample(samples, 0);
				ConfigurationManager::GetInstance()->SetString("Player.Name", txtl);
				pt->setText("");
				ThreadSafeWorkpile::getInstance()->AddEvent(new LoginEvent(txtl, txtt, seleplaylo));
			}
		}
	}
	catch(CEGUI::Exception &ex)
	{
		LogHandler::getInstance()->LogToFile(std::string("Exception trying to get connection info from the gui: ") + ex.getMessage().c_str());
		return false;
	}

	return true;
}
示例#9
0
//提交出售请求
bool OnSaleSubmit(const CEGUI::EventArgs& e)
{
	CEGUI::WindowManager& wndmgr = GetWndMgr();
	CEGUI::Editbox* edb = WEditBox(wndmgr.getWindow("Auction/SaleWnd/saleNum"));
	AHdata& ah = GetInst(AHdata);
	//获取出售数量
	uint saleNum = CEGUI::PropertyHelper::stringToInt(edb->getText());
	uint cansaleNum = ah.GetCountByCanSaleID(ah.GetCanSaleID());
	if(saleNum == 0 || saleNum > cansaleNum )
	{
		GetInst(MsgEventManager).PushEvent(Msg_Ok,AppFrame::GetText("AU_101"),NULL,NULL,true);
		return false;
	}
	ah.Send_AH_SEL(cansaleNum);//发送出售请求前要设置出售的订单ID
	return true;
}
示例#10
0
////提交购买请求
bool OnBuySubmit(const CEGUI::EventArgs& e)
{
	CEGUI::WindowManager& wndmgr = GetWndMgr();
	CEGUI::Editbox* edb = WEditBox(wndmgr.getWindow("Auction/Buy/buyNum"));
	AHdata& ah = GetInst(AHdata);
	//获取购买数量
	uint buyNum = CEGUI::PropertyHelper::stringToInt(edb->getText());
	uint canbuyNum = ah.GetCountByCanBuyID(ah.GetCanBuyID());
	if(buyNum== 0 || buyNum > canbuyNum)
	{
		GetInst(MsgEventManager).PushEvent(Msg_Ok,AppFrame::GetText("AU_103"),NULL,NULL,true);
		return false;
	}
	ah.Send_AH_BUY(buyNum);//发送购买请求前要设置购买的订单ID
	return true;
}
示例#11
0
bool GameState::enterHighScore(const CEGUI::EventArgs& /*e*/)
{
	if(!_highScoreEntryDialog)
		return false;
	
	CEGUI::WindowManager& winMgr = CEGUI::WindowManager::getSingleton();
	CEGUI::Editbox* editbox = static_cast<CEGUI::Editbox*>(winMgr.getWindow("Editbox"));
	std::string name(editbox->getText().c_str());

	if(name.length() == 0)
		return false;

	Lagom::getSingleton().addHighScore(name,Lagom::getSingleton().GetChallengeStage(),_playerScore);
	
	CEGUI::System::getSingleton().setGUISheet( nullptr );
	_highScoreEntryDialog->destroy();
	m_bQuit = true;
	return true;
}
示例#12
0
bool GameMenuDemo::handleLoginAcceptButtonClicked(const CEGUI::EventArgs& args)
{
    d_startButtonClickArea->setAlpha(0.0f);
    d_startButtonBlendInAnimInst->start();

    enableNavigationBarElements();

    d_loginContainerMoveOutInst->start();
    d_navigationTravelIcon->setEnabled(true);

    CEGUI::Editbox* loginEditbox = static_cast<CEGUI::Editbox*>(d_root->getChild("LoginContainer/LoginEditbox"));
    d_userName = loginEditbox->getText();

    d_timeSinceLoginAccepted = 0.0f;
    d_loginWasAccepted = true;
    d_currentWriteFocus = WF_TopBar;

    d_botNaviContainer->setEnabled(true);

    return false;
}
示例#13
0
	void MenuState::ValidateNAMEIP()
	{
		// This shouldn't be here!!!
		// Socket needs to be closed/reset before IO_Service is reset.
		if(LC::Client::getSingletonPtr()->socket_)
		{
			boost::shared_ptr<tcp::socket> sockets;
			sockets = LC::Client::getSingletonPtr()->socket_;
			boost::system::error_code error;
			sockets->shutdown(boost::asio::socket_base::shutdown_both, error);
			sockets->close(error);
		}
		LC::Client::getSingletonPtr()->socket_.reset();
		
		// May be overly drastic.
		TheApplication.ResetIOService();

		if(m_IsHost)
		{
			// Create Server.
			std::string userName = wmgr->getWindow("LIGHTCYCLEMENU/Name/EditBox")->getText().c_str();
			Server::getSingletonPtr()->reset(TheApplication.getIOService(), userName);

			// Create Client.
			// Need better way of doing this.
			tcp::resolver resolver(*TheApplication.getIOService());
			std::ostringstream ss;
			int portnumber = TheApplication.getPortNumber();
			ss << portnumber;
			tcp::resolver::query query("127.0.0.1", ss.str().c_str());
			tcp::resolver::iterator iterator = resolver.resolve(query);
			Client::getSingletonPtr()->reset(TheApplication.getIOService(), iterator, userName);
			
			wmgr->getWindow("LIGHTCYCLEMENU/Lobby/ConnectedIP")->setText("IP: SERVER");
			wmgr->getWindow("LIGHTCYCLEMENU/IP/EditBox")->setText("");
			wmgr->getWindow("LIGHTCYCLEMENU/Name/EditBox")->setText("");
		}
		else
		{
			std::string text = wmgr->getWindow("LIGHTCYCLEMENU/IP/EditBox")->getText().c_str();

			// Check for valid IP address.
			boost::system::error_code ec;
			boost::asio::ip::address address = boost::asio::ip::address::from_string(text, ec);

			std::string userName = wmgr->getWindow("LIGHTCYCLEMENU/Name/EditBox")->getText().c_str();

			if(!ec && userName.length()>=1)
			{
				CEGUI::String IPAddress = wmgr->getWindow("LIGHTCYCLEMENU/IP/EditBox")->getText();

				// Need better way of doing this.
				tcp::resolver resolver(*TheApplication.getIOService());
				std::ostringstream ss;
				int portnumber = TheApplication.getPortNumber();
				ss << portnumber;
				tcp::resolver::query query(IPAddress.c_str(), ss.str().c_str());
				tcp::resolver::iterator iterator = resolver.resolve(query);
				Client::getSingletonPtr()->reset(TheApplication.getIOService(), iterator, userName);

				wmgr->getWindow("LIGHTCYCLEMENU/Lobby/ConnectedIP")->setText("IP: " + address.to_string());
			}
			else if(ec)
			{
				wmgr->getWindow("LIGHTCYCLEMENU/IP/EditBox")->setText("Invalid Address");
				CEGUI::Editbox *editBox = static_cast<CEGUI::Editbox*>(wmgr->getWindow("LIGHTCYCLEMENU/IP/EditBox"));
				editBox->setCaratIndex(editBox->getText().length());
			}
		}
	}
示例#14
0
bool GUI_Paste_From_Clipboard( void )
{
	CEGUI::Window *sheet = CEGUI::System::getSingleton().getGUISheet();

	// no sheet
	if( !sheet )
	{
		return 0;
	}

	CEGUI::Window *window_active = sheet->getActiveChild();

	// no active window
	if( !window_active )
	{
		return 0;
	}

	const CEGUI::String &type = window_active->getType();

	// MultiLineEditbox
	if( type.find( "/MultiLineEditbox" ) != CEGUI::String::npos )
	{
		CEGUI::MultiLineEditbox *editbox = static_cast<CEGUI::MultiLineEditbox*>(window_active);

		if( editbox->isReadOnly() )
		{
			return 0;
		}

		CEGUI::String::size_type beg = editbox->getSelectionStartIndex();
		CEGUI::String::size_type len = editbox->getSelectionLength();

		CEGUI::String new_text = editbox->getText();
		// erase selected text
		new_text.erase( beg, len );

		// get clipboard text
		CEGUI::String clipboard_text = reinterpret_cast<const CEGUI::utf8*>(Get_Clipboard_Content().c_str());
		// set new text
		editbox->setText( new_text.insert( beg, clipboard_text ) );
		// set new carat index
		editbox->setCaratIndex( editbox->getCaratIndex() + clipboard_text.length() );
	}
	// Editbox
	else if( type.find( "/Editbox" ) != CEGUI::String::npos )
	{
		CEGUI::Editbox *editbox = static_cast<CEGUI::Editbox*>(window_active);

		if( editbox->isReadOnly() )
		{
			return 0;
		}

		CEGUI::String::size_type beg = editbox->getSelectionStartIndex();
		CEGUI::String::size_type len = editbox->getSelectionLength();

		CEGUI::String new_text = editbox->getText();
		// erase selected text
		new_text.erase( beg, len );

		// get clipboard text
		CEGUI::String clipboard_text = reinterpret_cast<const CEGUI::utf8*>(Get_Clipboard_Content().c_str());
		// set new text
		editbox->setText( new_text.insert( beg, clipboard_text ) );
		// set new carat index
		editbox->setCaratIndex( editbox->getCaratIndex() + clipboard_text.length() );
	}
	else
	{
		return 0;
	}

	return 1;
}
示例#15
0
/***********************************************************
handle send button event
***********************************************************/
bool ChatBox::HandleEnterKey (const CEGUI::EventArgs& e)
{
	const CEGUI::KeyEventArgs& we =
    static_cast<const CEGUI::KeyEventArgs&>(e);

	const CEGUI::WindowEventArgs& wine =
    static_cast<const CEGUI::WindowEventArgs&>(e);


	if(we.scancode == CEGUI::Key::LeftControl || we.scancode == CEGUI::Key::RightControl)
	{
		_control_key_on = true;
		return true;
	}

	if(we.scancode == CEGUI::Key::LeftShift || we.scancode == CEGUI::Key::RightShift)
	{
		_shift_key_on = true;
		return true;
	}


	if(wine.window->getName() == "Chat/edit")
	{
		if(we.scancode == CEGUI::Key::Return)
		{
			HandleSend (e);

			CEGUI::Editbox * bed = static_cast<CEGUI::Editbox *>
			(CEGUI::WindowManager::getSingleton().getWindow("Chat/edit"));
			bed->deactivate();
			return true;
		}

		if(we.scancode == CEGUI::Key::ArrowUp)
		{
			if(_itltext == _lasttexts.end())
				_itltext = _lasttexts.begin();
			else
			{
				std::list<std::string>::iterator ittmp = _itltext;
				++ittmp;
				if(ittmp != _lasttexts.end())
					++_itltext;
			}

			try
			{
				if(_itltext != _lasttexts.end())
				{
					CEGUI::WindowManager::getSingleton().getWindow("Chat/edit")->setText(
														(const unsigned char *)_itltext->c_str());
				}
				else
				{
					CEGUI::WindowManager::getSingleton().getWindow("Chat/edit")->setText("");
				}
			}
			catch(...){}

			return true;
		}
		if(we.scancode == CEGUI::Key::ArrowDown)
		{
			if(_itltext != _lasttexts.end())
			{
				if(_itltext != _lasttexts.begin())
					--_itltext;
				else
					_itltext = _lasttexts.end();
			}

			if(_itltext != _lasttexts.end())
			{
				CEGUI::WindowManager::getSingleton().getWindow("Chat/edit")->setText(
													(const unsigned char *)_itltext->c_str());
			}
			else
			{
				CEGUI::WindowManager::getSingleton().getWindow("Chat/edit")->setText("");
			}

			return true;
		}


		if(we.scancode == CEGUI::Key::ArrowUp || we.scancode == CEGUI::Key::ArrowDown)
			return true;



		// paste text
		if(we.scancode == CEGUI::Key::V && _control_key_on)
		{
			CEGUI::Editbox * bed = static_cast<CEGUI::Editbox *>
				(CEGUI::WindowManager::getSingleton().getWindow("Chat/edit"));
			if(bed->isActive())
			{
				if(_text_copyed != "")
				{
					size_t selB = bed->getSelectionStartIndex();
					size_t selE = bed->getSelectionLength();
					CEGUI::String str = bed->getText();
					if(selE > 0)
					{
						str = str.erase(selB, selE);
					}

					if(str.size() + _text_copyed.size() < bed->getMaxTextLength())
					{
						size_t idx = bed->getCaratIndex();
						str = str.insert(idx, (unsigned char *)_text_copyed.c_str());
						bed->setText(str);
						bed->setCaratIndex(idx + _text_copyed.size());
					}
				}

				return true;
			}
		}
	}



	// copy text
	if(we.scancode == CEGUI::Key::C && _control_key_on)
	{
		CEGUI::Window * actw = _myChat->getActiveChild();
		if(actw != NULL)
		{
			if(actw->getName() == "Chat/edit")
			{
				CEGUI::Editbox * bed = static_cast<CEGUI::Editbox *> (actw);
				size_t selB = bed->getSelectionStartIndex();
				size_t selE = bed->getSelectionLength();
				if(selE > 0)
				{
					CEGUI::String str = bed->getText().substr(selB, selE);
					_text_copyed = str.c_str();
				}

				return true;
			}
			else
			{
				CEGUI::MultiLineEditbox* txt = static_cast<CEGUI::MultiLineEditbox *>(actw);
				size_t selB = txt->getSelectionStartIndex();
				size_t selE = txt->getSelectionLength();
				if(selE > 0)
				{
					CEGUI::String str = txt->getText().substr(selB, selE);
					_text_copyed = str.c_str();
				}

				return true;
			}
		}

	}

    return false;
}
示例#16
0
/***********************************************************
handle send button event
***********************************************************/
bool ChatBox::HandleEnterKey (const CEGUI::EventArgs& e)
{
	const CEGUI::KeyEventArgs& we =
    static_cast<const CEGUI::KeyEventArgs&>(e);

	const CEGUI::WindowEventArgs& wine =
    static_cast<const CEGUI::WindowEventArgs&>(e);


	if(we.scancode == CEGUI::Key::LeftControl || we.scancode == CEGUI::Key::RightControl)
	{
		_control_key_on = true;
		return true;
	}

	if(we.scancode == CEGUI::Key::LeftShift || we.scancode == CEGUI::Key::RightShift)
	{
		_shift_key_on = true;
		return true;
	}

	if(we.scancode == CEGUI::Key::LeftAlt || we.scancode == CEGUI::Key::RightAlt)
	{
		return true;
	}

	if(wine.window->getName() == "Chat/edit")
	{
		if(we.scancode == CEGUI::Key::Return)
		{
			HandleSend (e);

			CEGUI::Editbox * bed = static_cast<CEGUI::Editbox *>
			(CEGUI::WindowManager::getSingleton().getWindow("Chat/edit"));
			bed->deactivate();
			return true;
		}

		if(we.scancode == CEGUI::Key::ArrowUp)
		{
			if(_itltext == _lasttexts.end())
				_itltext = _lasttexts.begin();
			else
			{
				std::list<std::string>::iterator ittmp = _itltext;
				++ittmp;
				if(ittmp != _lasttexts.end())
					++_itltext;
			}

			try
			{
				CEGUI::Window *windowchat = CEGUI::WindowManager::getSingleton().getWindow("Chat/edit");
				std::string text = "";
				if(_itltext != _lasttexts.end())
					text = *_itltext;

				if(windowchat)
					windowchat->setText((const unsigned char *)text.c_str());
			}
			catch(...){}

			//++_currSelectedch;
			//if(_currSelectedch >= (int)_channels.size())
			//	--_currSelectedch;
			//else
			//{
			//	std::list<std::string>::const_iterator it = _channels.begin();
			//	std::list<std::string>::const_iterator end = _channels.end();
			//	for(int cc=0; cc<_currSelectedch && it != end; ++it, ++cc);

			//	CEGUI::PushButton * bch = static_cast<CEGUI::PushButton *>
			//		(CEGUI::WindowManager::getSingleton().getWindow("Chat/bChannel"));
			//	bch->setProperty("Text", *it);
			//}



			return true;
		}
		if(we.scancode == CEGUI::Key::ArrowDown)
		{
			if(_itltext != _lasttexts.end())
			{
				if(_itltext != _lasttexts.begin())
					--_itltext;
				else
					_itltext = _lasttexts.end();
			}

			CEGUI::Window *windowchat = CEGUI::WindowManager::getSingleton().getWindow("Chat/edit");
			std::string text = "";
			if(_itltext != _lasttexts.end())
				text = *_itltext;

			if(windowchat)
				windowchat->setText((const unsigned char *)text.c_str());


			//--_currSelectedch;
			//if(_currSelectedch < 0)
			//	++_currSelectedch;
			//else
			//{
			//	std::list<std::string>::const_iterator it = _channels.begin();
			//	std::list<std::string>::const_iterator end = _channels.end();
			//	for(int cc=0; cc<_currSelectedch && it != end; ++it, ++cc);

			//	CEGUI::PushButton * bch = static_cast<CEGUI::PushButton *>
			//		(CEGUI::WindowManager::getSingleton().getWindow("Chat/bChannel"));
			//	bch->setProperty("Text", *it);
			//}

			return true;
		}


		if(we.scancode == CEGUI::Key::ArrowUp || we.scancode == CEGUI::Key::ArrowDown)
			return true;



		// paste text
		if(we.scancode == CEGUI::Key::V && _control_key_on)
		{
			CEGUI::Editbox * bed = static_cast<CEGUI::Editbox *>
				(CEGUI::WindowManager::getSingleton().getWindow("Chat/edit"));
			if(bed && bed->isActive())
			{
				if(_text_copyed != "")
				{
					size_t selB = bed->getSelectionStartIndex();
					size_t selE = bed->getSelectionLength();
					CEGUI::String str = bed->getText();
					if(selE > 0)
					{
						str = str.erase(selB, selE);
					}

					if(str.size() + _text_copyed.size() < bed->getMaxTextLength())
					{
						size_t idx = bed->getCaratIndex();
						str = str.insert(idx, (unsigned char *)_text_copyed.c_str());
						bed->setText(str);
						bed->setCaratIndex(idx + _text_copyed.size());
					}
				}

				return true;
			}
		}
	}



	// copy text
	if(we.scancode == CEGUI::Key::C && _control_key_on)
	{
		CEGUI::Window * actw = _myChat->getActiveChild();
		if(actw != NULL)
		{
			if(actw->getName() == "Chat/edit")
			{
				CEGUI::Editbox * bed = static_cast<CEGUI::Editbox *> (actw);
				size_t selB = bed->getSelectionStartIndex();
				size_t selE = bed->getSelectionLength();
				if(selE > 0)
				{
					CEGUI::String str = bed->getText().substr(selB, selE);
					_text_copyed = str.c_str();
				}

				return true;
			}
			else
			{
				CEGUI::MultiLineEditbox* txt = static_cast<CEGUI::MultiLineEditbox *>(actw);
				size_t selB = txt->getSelectionStartIndex();
				size_t selE = txt->getSelectionLength();
				if(selE > 0)
				{
					CEGUI::String str = txt->getText().substr(selB, selE);
					_text_copyed = str.c_str();
				}

				return true;
			}
		}

	}

    return false;
}
示例#17
0
  bool accepted() {
    m_sString = m_pEditbox->getText().c_str();

    return true;
  }
示例#18
0
void GameState::BuildSkeleton()
{
	CEGUI::Editbox* heightbox = static_cast<CEGUI::Editbox*>(mGUIRoot->getChild("Settings Box/Skeleton Height/HeightEdit"));
	CEGUI::Editbox* widthbox = static_cast<CEGUI::Editbox*>(mGUIRoot->getChild("Settings Box/Skeleton Width/WidthEditBox"));
	CEGUI::Editbox* depthbox = static_cast<CEGUI::Editbox*>(mGUIRoot->getChild("Settings Box/Skeleton Depth/DepthEditBox"));
	CEGUI::Editbox* neckbox = static_cast<CEGUI::Editbox*>(mGUIRoot->getChild("Settings Box/Neck Incline/NeckEditbox"));
	CEGUI::Editbox* tailbox = static_cast<CEGUI::Editbox*>(mGUIRoot->getChild("Settings Box/Tail Incline/TailEditbox"));
	CEGUI::Editbox* Xbox = static_cast<CEGUI::Editbox*>(mGUIRoot->getChild("Settings Box/Spawn Position/X Editbox"));
	CEGUI::Editbox* Ybox = static_cast<CEGUI::Editbox*>(mGUIRoot->getChild("Settings Box/Spawn Position/Y Editbox"));
	CEGUI::Editbox* Zbox = static_cast<CEGUI::Editbox*>(mGUIRoot->getChild("Settings Box/Spawn Position/Z Editbox"));
	Skeleton_Builder::TorsoType Torso;
	Skeleton_Builder::ArmType Arm;
	Skeleton_Builder::LegType Leg;
	Skeleton_Builder::NeckType Neck;
	Skeleton_Builder::TailType Tail;
	auto legitem = static_cast<CEGUI::Combobox*>(mGUIRoot->getChild("Settings Box/Leg Combobox"))->getSelectedItem();
	auto torsoitem = static_cast<CEGUI::Combobox*>(mGUIRoot->getChild("Settings Box/Torso Combobox"))->getSelectedItem();
	auto armitem = static_cast<CEGUI::Combobox*>(mGUIRoot->getChild("Settings Box/Arm Combobox"))->getSelectedItem();
	auto tailitem = static_cast<CEGUI::Combobox*>(mGUIRoot->getChild("Settings Box/Tail Combobox"))->getSelectedItem();
	auto neckitem = static_cast<CEGUI::Combobox*>(mGUIRoot->getChild("Settings Box/Neck Combobox"))->getSelectedItem();

	if (legitem->getID() == 0)
		Leg = Skeleton_Builder::LegType::Uninverted;
	else
		Leg = Skeleton_Builder::LegType::Inverted;

	if (torsoitem->getID() == 0)
		Torso = Skeleton_Builder::TorsoType::Upright;
	else
		Torso = Skeleton_Builder::TorsoType::Horizontal;

	if (armitem->getID() == 0)
		Arm = Skeleton_Builder::ArmType::NoArms;
	else if (armitem->getID() == 1)
		Arm = Skeleton_Builder::ArmType::ShortArms;
	else
		Arm = Skeleton_Builder::ArmType::LongArms;

	if (tailitem->getID() == 0)
		Tail = Skeleton_Builder::TailType::NoTail;
	else if (tailitem->getID() == 1)
		Tail = Skeleton_Builder::TailType::ShortTail;
	else
		Tail = Skeleton_Builder::TailType::LongTail;

	if (neckitem->getID() == 1)
		Neck = Skeleton_Builder::NeckType::ShortNeck;
	else if (neckitem->getID() == 0)
		Neck = Skeleton_Builder::NeckType::LongNeck;

	auto Position = Ogre::Vector3(std::stof(Xbox->getText().c_str()), std::stof(Ybox->getText().c_str()), std::stof(Zbox->getText().c_str()));
	mPhysics->BuildCharacter(Torso, Arm, Leg,Neck,Tail,
		std::stof(heightbox->getText().c_str()),
		std::stof(widthbox->getText().c_str()),
		std::stof(depthbox->getText().c_str()),
		std::stof(neckbox->getText().c_str()),
		std::stof(tailbox->getText().c_str()),
		static_cast<CEGUI::ToggleButton*>(mGUIRoot->getChild("Settings Box/Hide Arm/Checkbox"))->isSelected(),
		static_cast<CEGUI::ToggleButton*>(mGUIRoot->getChild("Settings Box/Hide Leg/Checkbox"))->isSelected(),
		static_cast<CEGUI::ToggleButton*>(mGUIRoot->getChild("Settings Box/Hide Neck/Checkbox"))->isSelected(),
		static_cast<CEGUI::ToggleButton*>(mGUIRoot->getChild("Settings Box/Has Muscles/Checkbox"))->isSelected(),
		static_cast<CEGUI::ToggleButton*>(mGUIRoot->getChild("Settings Box/Is Fixed/Checkbox"))->isSelected(),
		Position);
}
示例#19
0
bool GUI_Copy_To_Clipboard( bool cut )
{
	CEGUI::Window *sheet = CEGUI::System::getSingleton().getGUISheet();

	// no sheet
	if( !sheet )
	{
		return 0;
	}

	CEGUI::Window *window_active = sheet->getActiveChild();

	// no active window
	if( !window_active )
	{
		return 0;
	}

	CEGUI::String sel_text;
	const CEGUI::String &type = window_active->getType();

	// MultiLineEditbox
	if( type.find( "/MultiLineEditbox" ) != CEGUI::String::npos )
	{
		CEGUI::MultiLineEditbox *editbox = static_cast<CEGUI::MultiLineEditbox*>(window_active);
		CEGUI::String::size_type beg = editbox->getSelectionStartIndex();
		CEGUI::String::size_type len = editbox->getSelectionLength();
		sel_text = editbox->getText().substr( beg, len ).c_str();

		// if cutting
		if( cut )
		{
			if( editbox->isReadOnly() )
			{
				return 0;
			}

			CEGUI::String new_text = editbox->getText();
			editbox->setText( new_text.erase( beg, len ) );
		}
	}
	// Editbox
	else if( type.find( "/Editbox" ) != CEGUI::String::npos )
	{
		CEGUI::Editbox *editbox = static_cast<CEGUI::Editbox*>(window_active);
		CEGUI::String::size_type beg = editbox->getSelectionStartIndex();
		CEGUI::String::size_type len = editbox->getSelectionLength();
		sel_text = editbox->getText().substr( beg, len ).c_str();

		// if cutting
		if( cut )
		{
			if( editbox->isReadOnly() )
			{
				return 0;
			}

			CEGUI::String new_text = editbox->getText();
			editbox->setText( new_text.erase( beg, len ) );
		}
	}
	else
	{
		return 0;
	}

	Set_Clipboard_Content( sel_text.c_str() );
	return 1;
}