本文整理汇总了C++中cegui::Listbox::getItemIndex方法的典型用法代码示例。如果您正苦于以下问题:C++ Listbox::getItemIndex方法的具体用法?C++ Listbox::getItemIndex怎么用?C++ Listbox::getItemIndex使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类cegui::Listbox
的用法示例。
在下文中一共展示了Listbox::getItemIndex方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: HandleWorldSelected
/***********************************************************
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: HandleWorldSelected
/***********************************************************
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());
//.........这里部分代码省略.........