本文整理汇总了C++中cegui::ListboxItem::setText方法的典型用法代码示例。如果您正苦于以下问题:C++ ListboxItem::setText方法的具体用法?C++ ListboxItem::setText怎么用?C++ ListboxItem::setText使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类cegui::ListboxItem
的用法示例。
在下文中一共展示了ListboxItem::setText方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: ServerQueryHandler
void CServerBrowser::ServerQueryHandler(String strHost, unsigned short usPort, String strQuery, CBitStream * pReply)
{
// Read the query type
char cQueryType;
if(!pReply->Read(cQueryType))
return;
// Get the server host and port
String strHostAndPort("%s:%d", strHost.Get(), usPort);
if(cQueryType == 'p') // Ping
{
// Get the start time from the ping map
unsigned long ulStartTime = serverPingStartMap[strHostAndPort];
// Do we have a valid start time?
if(ulStartTime > 0)
{
// Calculate the round trip time
unsigned long ulPing = (SharedUtility::GetTime() - ulStartTime);
// Set the server ping in the multi column list
CEGUI::MultiColumnList * pMultiColumnList = (CEGUI::MultiColumnList *)CServerBrowser::GetSingleton()->m_GUIElements.pServerMultiColumnList;
for(unsigned int i = 0; i < pMultiColumnList->getRowCount(); i++)
{
CEGUI::ListboxItem * pHost = pMultiColumnList->getItemAtGridReference(CEGUI::MCLGridRef(i, 1));
if(!strHostAndPort.Compare(pHost->getText().c_str()))
{
CEGUI::ListboxItem * pPing = pMultiColumnList->getItemAtGridReference(CEGUI::MCLGridRef(i, 3));
if(pPing)
{
char szTempBuf[64];
pPing->setText(itoa(ulPing, szTempBuf, 10));
pMultiColumnList->invalidate();
break;
}
}
}
}
}
else
{
// Check if we have a valid stream
if(!pReply || cQueryType != 'i')
return;
// Read the host name
String strHostName;
int iPlayerCount;
int iMaxPlayers;
bool bPassworded;
pReply->Read(strHostName);
pReply->Read(iPlayerCount);
pReply->Read(iMaxPlayers);
pReply->Read(bPassworded);
// Add the server to the multi column list
CEGUI::MultiColumnList * pMultiColumnList = (CEGUI::MultiColumnList *)CServerBrowser::GetSingleton()->m_GUIElements.pServerMultiColumnList;
unsigned int iRowIndex = pMultiColumnList->addRow();
pMultiColumnList->setItem(new ServerBrowserListItem(strHostName.Get()), 0, iRowIndex);
pMultiColumnList->setItem(new ServerBrowserListItem(strHostAndPort.Get()), 1, iRowIndex);
char szPlayerCount[9];
sprintf(szPlayerCount, "%s/%s", iPlayerCount, iMaxPlayers);
pMultiColumnList->setItem(new ServerBrowserListItem(szPlayerCount), 2, iRowIndex);
pMultiColumnList->setItem(new ServerBrowserListItem("9999"), 3, iRowIndex);
pMultiColumnList->setItem(new ServerBrowserListItem(bPassworded ? "Yes" : "No"), 4, iRowIndex);
pMultiColumnList->invalidate();
// Save the current time to the ping map
serverPingStartMap[strHostAndPort] = SharedUtility::GetTime();
// Send a ping query to the server
CServerBrowser::GetSingleton()->m_pServerQuery->Query(strHost, usPort, "p");
}
}