Esempio n. 1
0
/***********************************************************
inform the user the login failed
***********************************************************/
void LoginGUI::InformNotLoggedIn(int problem, const std::string & reason)
{
	try
	{
		CEGUI::MultiLineEditbox * txs =
		static_cast<CEGUI::MultiLineEditbox *> (CEGUI::WindowManager::getSingleton().getWindow("DisplayLoginErrorFrame/text"));


		if(problem == 0)	// can not connect to the server
		{
			txs->setText("");
			txs->appendText("Error trying to log on the server:");
			txs->appendText("Server is not reacheable.");
		}

		if(problem == -1)	// wrong login / password
		{
			txs->setText("");
			txs->appendText("Error trying to log on the server:");
			txs->appendText("Permission denied:");
			txs->appendText(reason);
		}

		if(problem == -2)	// got disconnected
		{
			txs->setText("");
			txs->appendText("You got disconnected from the server.");
		}

		CEGUI::WindowManager::getSingleton().getWindow("DisplayLoginErrorFrame")->show();
	}
	catch(CEGUI::Exception &ex)
	{
		LogHandler::getInstance()->LogToFile(std::string("Exception showing login error window: ") + ex.getMessage().c_str());
		_root = NULL;
	}
}
Esempio n. 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;
}