示例#1
0
/***********************************************************
handle world selected event
***********************************************************/
bool ChooseWorldGUI::HandleWorldSelected (const CEGUI::EventArgs& e)
{
	try
	{
		CEGUI::Listbox * lb = static_cast<CEGUI::Listbox *> (
				CEGUI::WindowManager::getSingleton().getWindow("ChooseWorldList"));
		if(lb)
		{
			size_t idx = lb->getItemIndex(lb->getFirstSelectedItem());
			if(idx < _wlist.size())
			{
				CEGUI::MultiLineEditbox * eb = static_cast<CEGUI::MultiLineEditbox *> (
					CEGUI::WindowManager::getSingleton().getWindow("ChooseWorldDescription"));
				if(eb)
				{
					eb->setText(_wlist[idx].Description);
				}

				_selectedworld = _wlist[idx].WorldName;
			}
		}
	}
	catch(CEGUI::Exception &ex)
	{
		LogHandler::getInstance()->LogToFile(std::string("Exception init the world list: ") + ex.getMessage().c_str());
		_root = NULL;
	}

	return true;
}
示例#2
0
/***********************************************************
handle world selected event
***********************************************************/
bool ChooseWorldGUI::HandleWorldSelected (const CEGUI::EventArgs& e)
{
	try
	{
		CEGUI::Listbox * lb = static_cast<CEGUI::Listbox *> (
				CEGUI::WindowManager::getSingleton().getWindow("ChooseWorldList"));
		if(lb)
		{
			size_t idx = lb->getItemIndex(lb->getFirstSelectedItem());
			if(idx < _wlist.size())
			{
				CEGUI::MultiLineEditbox * eb = static_cast<CEGUI::MultiLineEditbox *> (
					CEGUI::WindowManager::getSingleton().getWindow("ChooseWorldDescription"));
				if(eb)
				{
					std::string str = _wlist[idx].Description;
					int idxs = 0;
					bool firsttime=true;
					while((idxs = str.find(" @ ")) != std::string::npos)
					{
						std::string tmp = str.substr(0, idxs);
						if(tmp == "")
							tmp = "\n";

						if(firsttime)
						{
							firsttime = false;
							eb->setText((const unsigned char *)tmp.c_str());
						}
						else
							eb->appendText((const unsigned char *)tmp.c_str());

						while(((idxs+4) < (int)str.size()) && (str[idxs+3] == '@') && (str[idxs+4] == ' '))
						{
							eb->appendText("\n");
							idxs+= 2;
						}

						str = str.substr(idxs+3);
					}

					if(firsttime)
					{
						firsttime = false;
						eb->setText((const unsigned char *)str.c_str());
					}
					else
						eb->appendText((const unsigned char *)str.c_str());
				}

				 eb = static_cast<CEGUI::MultiLineEditbox *> (
					CEGUI::WindowManager::getSingleton().getWindow("ChooseWorldNews"));
				if(eb)
				{
					std::string str = _wlist[idx].News;
					int idxs = 0;
					bool firsttime=true;
					while((idxs = str.find(" @ ")) != std::string::npos)
					{
						std::string tmp = str.substr(0, idxs);
						if(tmp == "")
							tmp = "\n";

						if(firsttime)
						{
							firsttime = false;
							eb->setText((const unsigned char *)tmp.c_str());
						}
						else
							eb->appendText((const unsigned char *)tmp.c_str());

						while(((idxs+4) < (int)str.size()) && (str[idxs+3] == '@') && (str[idxs+4] == ' '))
						{
							eb->appendText("\n");
							idxs+= 2;
						}

						str = str.substr(idxs+3);
					}

					if(firsttime)
					{
						firsttime = false;
						eb->setText((const unsigned char *)str.c_str());
					}
					else
						eb->appendText((const unsigned char *)str.c_str());
				}

				_selectedworld = idx;
				ConfigurationManager::GetInstance()->SetValue("Options.General.SelectedWorld", _selectedworld);
			}
		}
	}
	catch(CEGUI::Exception &ex)
	{
		LogHandler::getInstance()->LogToFile(std::string("Exception init the world list: ") + ex.getMessage().c_str());
		_root = NULL;
	}

	return true;
}