Esempio n. 1
0
//更新右搜索(筛选)菜单
bool OnSearchRightMenuUpdate(const CEGUI::EventArgs& e)
{
    CEGUI::Combobox* cbbox = WComboBox(WEArgs(e).window);
    cbbox->clearAllSelections();
    cbbox->resetList();
    cbbox->getEditbox()->setText("");

    //由索引关联商城类型
    SCGData::eSCType eShopCityType = GetShopCityTypeByTabContentSelIndex();
    //由索引关联商店类型,tabControl的索引0单独对应热销商品
    SCGData::eSType shoptype = GetShopTypeByTabContentSelIndex();
    if(shoptype == SCGData::TABTYPE_HOT)//热销没有筛选项
        return true;
    //根据商城和商店类型获取筛选数据
    SCGData* dt = GetInst(ShopCityMsgMgr).GetShopCityGoodsData();
    SCGData::MapFLDTA& mapSel = dt->GetFilterList();
    SCGData::MapUFLDTPA& mapUSel = mapSel[eShopCityType];
    SCGData::MapStrFilDTPA& mapStrSel = mapUSel[shoptype];
    SCGData::MapStrFilDTPA::iterator iter = mapStrSel.begin();
    for( ; iter != mapStrSel.end() ; ++iter)
    {
        //初始化筛选菜单
        string str = (*iter).first;
        //CEGUI::ListboxItem* lbi = new CEGUI::ListboxTextItem(str.c_str());
        CEGUI::ListboxItem* lbi = new CEGUI::ListboxTextItem(ToCEGUIString(str.c_str()));
        lbi->setSelectionBrushImage(IMAGES_FILE_NAME,BRUSH_NAME);
        if(iter == mapStrSel.begin() )//默认让第一个为选中项
            lbi->setSelected(true);
        cbbox->addItem(lbi);
    }
    return true;
}
Esempio n. 2
0
_MEMBER_FUNCTION_IMPL(GUIMultiColumnList, getItem)
{
	CEGUI::MultiColumnList * pWindow = sq_getinstance<CEGUI::MultiColumnList *>(pVM);
	if(!pWindow)
	{
		sq_pushbool(pVM, false);
		return 1;
	}

	SQInteger sqiRow;
	SQInteger sqiColumn;

	sq_getinteger(pVM, -2, &sqiRow);
	sq_getinteger(pVM, -1, &sqiColumn);

	try
	{
		CEGUI::MCLGridRef grid_ref(sqiRow, sqiColumn);
		CEGUI::ListboxItem* pItem = pWindow->getItemAtGridReference(grid_ref);
		sq_pushstring(pVM, pItem->getText().c_str(), -1);
	}
	catch(...)
	{
		sq_pushbool(pVM, false);
	}
	return 1;
}
Esempio n. 3
0
bool OpenSaleUI()
{
	CEGUI::WindowManager& wndmgr = GetWndMgr();
	//获取出售订单ID
	CEGUI::MultiColumnList* mcl = WMCL(wndmgr.getWindow("Auction/Tab/BuySale/BuyMCL"));
	if(!mcl)
		return false;
	CEGUI::ListboxItem* lbi = mcl->getFirstSelectedItem();
	if(!lbi)
	{
		//MessageBox(g_hWnd,AppFrame::GetText("AU_100"),"ERROR",MB_OK);
		GetInst(MsgEventManager).PushEvent(Msg_Ok,AppFrame::GetText("AU_100"),NULL,NULL,true);
		return false;
	}

	CEGUI::Window* wnd = wndmgr.getWindow("Auction/SaleWnd");
	wnd->setVisible(true);
	wnd->setAlwaysOnTop(true);
	CEGUI::Editbox* editbox = WEditBox(wnd->getChildRecursive("Auction/SaleWnd/saleNum"));//出售界面编辑框激活
	editbox->activate();

	AHdata& ah = GetInst(AHdata);
	uint ID = lbi->getID();
	ah.SetCanSaleID(ID);
	return true;
}
Esempio n. 4
0
char* CGUIGridList_Impl::GetItemText ( int iRow, int hColumn )
{
    try
    {
        // Grab the item at the chosen row / column
        CEGUI::ListboxItem* pItem = reinterpret_cast < CEGUI::MultiColumnList* > ( m_pWindow ) -> getItemAtGridReference ( CEGUI::MCLGridRef ( iRow, GetColumnIndex ( hColumn ) ) );
        if ( pItem )
        {
            char *szRet = const_cast < char* > ( pItem->getText().c_str () );

            if ( !m_bIgnoreTextSpacer )
            {
                unsigned char ucSpacerSize = (unsigned char)(strlen ( CGUIGRIDLIST_SPACER ));

                if ( hColumn == 1 ) {
                    // Make sure there is a spacer to skip
                    if ( strncmp ( szRet, CGUIGRIDLIST_SPACER, strlen ( CGUIGRIDLIST_SPACER ) ) == 0 )
                        szRet += ucSpacerSize;
                }
            }

            return szRet;
        }
    }
    catch ( CEGUI::Exception )
    {
        return "";
    }

    return "";
}
Esempio n. 5
0
void InspectWidget::addChildToList(Eris::Entity* child)
{
	CEGUI::String name(child->getType()->getName() + " ("+ child->getId() +" : "+child->getName()+")");
	CEGUI::ListboxItem* item = Gui::ColouredListItem::createColouredListItem(name);
	item->setUserData(child);
	mChildList->addItem(item);
}
Esempio n. 6
0
//更新左搜索(导购)菜单
bool OnSearchLeftMenuUpdate(const CEGUI::EventArgs& e)
{
    CEGUI::Combobox* cbbox = WComboBox(WEArgs(e).window);
    cbbox->clearAllSelections();
    cbbox->resetList();
    cbbox->getEditbox()->setText("");
    //由索引关联商城类型
    SCGData::eSCType eCityType = GetShopCityTypeByTabContentSelIndex();
    SCGData* dt = GetInst(ShopCityMsgMgr).GetShopCityGoodsData();
    SCGData::MapGuideDataA& mapGuide = dt->GetGuideList();
    //根据索引获取导购数据
    SCGData::MapStrGGDTPA& mapGuideDTA = mapGuide[eCityType];
    CEGUI::Combobox* cbboxRight = WComboBox(GetWndMgr().getWindow(SHOPCITY_SEARCH_RIGHTWND_NAME));
    if(cbboxRight)
    {
        CEGUI::ListboxItem* lbi = cbboxRight->getSelectedItem();
        size_t idx = 0;
        if(lbi)
            idx = cbboxRight->getItemIndex(lbi);
        SCGData::MapStrGGDTPA::iterator iter = mapGuideDTA.begin();
        for(; iter != mapGuideDTA.end() ; ++iter)
        {
            //添加导购菜单
            string menuStr = iter->first;
            //CEGUI::ListboxItem* lbi = new CEGUI::ListboxTextItem(menuStr.c_str());
            CEGUI::ListboxItem* lbi = new CEGUI::ListboxTextItem(ToCEGUIString(menuStr.c_str()));
            lbi->setSelectionBrushImage(IMAGES_FILE_NAME,BRUSH_NAME);
            if(iter == mapGuideDTA.begin())//默认让第一个为选中
                lbi->setSelected(true);
            cbbox->addItem(lbi);
        }
    }
    return true;
}
Esempio n. 7
0
bool cBonusBox::Editor_Gold_Color_Select(const CEGUI::EventArgs& event)
{
    const CEGUI::WindowEventArgs& windowEventArgs = static_cast<const CEGUI::WindowEventArgs&>(event);
    CEGUI::ListboxItem* item = static_cast<CEGUI::Combobox*>(windowEventArgs.window)->getSelectedItem();

    Set_Goldcolor(Get_Color_Id(item->getText().c_str()));

    return 1;
}
Esempio n. 8
0
bool cRokko::Editor_Direction_Select(const CEGUI::EventArgs& event)
{
    const CEGUI::WindowEventArgs& windowEventArgs = static_cast<const CEGUI::WindowEventArgs&>(event);
    CEGUI::ListboxItem* item = static_cast<CEGUI::Combobox*>(windowEventArgs.window)->getSelectedItem();

    Set_Direction(Get_Direction_Id(item->getText().c_str()));

    return 1;
}
Esempio n. 9
0
bool FolderSelector::OnFolderListDoubleClicked(const CEGUI::EventArgs&)
{
    CEGUI::ListboxItem* selectedItem = static_cast<CEGUI::ListboxItem*>(mFolderList->getFirstSelectedItem());
    if (selectedItem == 0)
        return false;
    ChangeFolder(mFolders[selectedItem->getID()]);
    UpdateFolderList();
    return true;
}
Esempio n. 10
0
bool OnCountryChanged(const CEGUI::EventArgs& e)
{
    CEGUI::Combobox* cbb = WComboBox(WEArgs(e).window);
    CEGUI::ListboxItem* lti = cbb->getSelectedItem();
    if(lti)
        CREvent::SetSelectCountry(lti->getID());
    else
        CREvent::SetSelectCountry(1);//range由Data/CountryList.xml 配置决定,这里根据配置设置默认国家ID为1
    return true;
}
Esempio n. 11
0
bool InspectWidget::ChildList_MouseDoubleClick(const CEGUI::EventArgs& args)
{
	//Inspect the child entity
	CEGUI::ListboxItem* item = mChildList->getFirstSelectedItem();
	if (item) {
		startInspecting(static_cast<EmberEntity*>(item->getUserData()));
	}

	return true;
}
Esempio n. 12
0
void InspectWidget::entity_ChildRemoved(Eris::Entity* entity)
{
	for (unsigned int i = 0; i < mChildList->getItemCount(); ++i) {
		CEGUI::ListboxItem* item = mChildList->getListboxItemFromIndex(i);
		if (item->getUserData() == entity) {
			mChildList->removeItem(item);
			break;
		}
	}
}
Esempio n. 13
0
bool OnHairColorChanged(const CEGUI::EventArgs& e)
{
    CEGUI::Combobox* cbb = WComboBox(WEArgs(e).window);
    CEGUI::ListboxItem* lti = cbb->getSelectedItem();
    if(lti)
        CREvent::SetHairColor(lti->getID());
    else
        CREvent::SetHairColor(0);
    return true;
}
Esempio n. 14
0
void AreaAdapter::fillElementFromGui()
{
	//Start by using the shape element from the polygon adapter
	mEditedValue = ::Atlas::Message::MapType();
	CEGUI::ListboxItem* item = mLayerWindow->getSelectedItem();
	if (item) {
		mLayer = item->getID();
	}
	Terrain::TerrainAreaParser parser;
	mEditedValue = parser.createElement(mPolygonAdapter->getShape(), mLayer);
}
Esempio n. 15
0
//双击推荐列表,打开购买页面
bool OnShopCityTwitterMouseDoubleClicked(const CEGUI::EventArgs& e)
{
    CEGUI::Listbox* twitterList = WListBox(WEArgs(e).window);
    CEGUI::ListboxItem* lbi = twitterList->getFirstSelectedItem();
    if(lbi)
    {
        uint index = lbi->getID();//获取索引,索引关联物品索引
        CEGUI::Window* buyPage = GetWindow(SHOPCITY_BUY_PAGE_NAME);
        buyPage->setID(index);//购买界面ID与物品索引关联
        //打开购买界面
        FireUIEvent(SHOPCITY_BUY_PAGE_NAME,EVENT_OPEN);
    }
    return true;
}
Esempio n. 16
0
bool cBonusBox::Editor_Force_best_item_Select(const CEGUI::EventArgs& event)
{
    const CEGUI::WindowEventArgs& windowEventArgs = static_cast<const CEGUI::WindowEventArgs&>(event);
    CEGUI::ListboxItem* item = static_cast<CEGUI::Combobox*>(windowEventArgs.window)->getSelectedItem();

    if (item->getText().compare(UTF8_("Enabled")) == 0) {
        Set_Force_Best_Item(1);
    }
    else {
        Set_Force_Best_Item(0);
    }

    return 1;
}
Esempio n. 17
0
bool cBonusBox :: Editor_Item_Select( const CEGUI::EventArgs &event )
{
	const CEGUI::WindowEventArgs &windowEventArgs = static_cast<const CEGUI::WindowEventArgs&>( event );
	CEGUI::ListboxItem *item = static_cast<CEGUI::Combobox *>( windowEventArgs.window )->getSelectedItem();

	if( item->getText().compare( UTF8_("Mushroom") ) == 0 )
	{
		Set_Bonus_Type( TYPE_MUSHROOM_DEFAULT );
	}
	else if( item->getText().compare( UTF8_("Fireplant") ) == 0 )
	{
		Set_Bonus_Type( TYPE_FIREPLANT );
	}
	else if( item->getText().compare( UTF8_("Mushroom Blue") ) == 0 )
	{
		Set_Bonus_Type( TYPE_MUSHROOM_BLUE );
	}
	else if( item->getText().compare( UTF8_("Mushroom Ghost") ) == 0 )
	{
		Set_Bonus_Type( TYPE_MUSHROOM_GHOST );
	}
	else if( item->getText().compare( UTF8_("Mushroom 1-UP") ) == 0 )
	{
		Set_Bonus_Type( TYPE_MUSHROOM_LIVE_1 );
	}
	else if( item->getText().compare( UTF8_("Star") ) == 0 )
	{
		Set_Bonus_Type( TYPE_STAR );
	}
	else if( item->getText().compare( UTF8_("Goldpiece") ) == 0 )
	{
		Set_Bonus_Type( TYPE_GOLDPIECE );
	}
	else if( item->getText().compare( UTF8_("Mushroom Poison") ) == 0 )
	{
		Set_Bonus_Type( TYPE_MUSHROOM_POISON );
	}
	else if( item->getText().compare( UTF8_("Random") ) == 0 )
	{
		Set_Bonus_Type( TYPE_POWERUP );
	}
	else
	{
		Set_Bonus_Type( TYPE_UNDEFINED );
	}

	Editor_State_Update();

	return 1;
}
Esempio n. 18
0
void FolderSelector::Submit()
{
    if (mCallback.IsSet())
    {
        CEGUI::ListboxItem* selectedItem = static_cast<CEGUI::ListboxItem*>(mFolderList->getFirstSelectedItem());
        if (selectedItem != 0)
        {
            ChangeFolder(mFolders[selectedItem->getID()]);
        }
        const string& path = GetRelativePath(mCurrentPath);
        const string& editboxValue = mEditbox->getText().c_str();
        mCallback.Call(path, editboxValue, false, mTag);
    }
    delete this;
}
Esempio n. 19
0
bool cStaticEnemy :: Editor_Fire_Resistant_Select( const CEGUI::EventArgs &event )
{
	const CEGUI::WindowEventArgs &windowEventArgs = static_cast<const CEGUI::WindowEventArgs&>( event );
	CEGUI::ListboxItem *item = static_cast<CEGUI::Combobox *>( windowEventArgs.window )->getSelectedItem();

	if( item->getText().compare( UTF8_("Enabled") ) == 0 )
	{
		m_fire_resistant = 1;
	}
	else
	{
		m_fire_resistant = 0;
	}

	return 1;
}
Esempio n. 20
0
bool FileWindow::onSelect(const CEGUI::EventArgs& e)
{
   CEGUI::ListboxItem* item = _pFileList->getFirstSelectedItem();
   if (item == NULL) { return true; }
   intptr_t data = reinterpret_cast< intptr_t >(item->getUserData());

   if (data == 0) { //file
      _pSelectBox->setText(item->getText());
      _pOkButton->setEnabled(true);
   } else if (data == 1) { //dir
      TCHAR* name = ::bootes::lib::util::TChar::C2T(item->getText().c_str());
      tc_string dir = _cwd + _T('\\') + name;
      delete name;
      list(dir.c_str());
   }
   return true;
}
bool
CComboboxImp::GetListItems( TStringVector& items ) const
{GUCE_TRACE;

    if ( NULL != m_combobox )
    {
        CEGUI::ListboxItem* item = NULL;
        size_t itemCount = m_combobox->getItemCount();
        for ( size_t i=0; i<itemCount; ++i )
        {
            item = m_combobox->getListboxItemFromIndex( i );
            items.push_back( item->getText().c_str() );
        }
        return true;
    }
    return false;
}
Esempio n. 22
0
bool WidgetDemo::getWidgetType(CEGUI::String &widgetName, CEGUI::String &widgetTypeString)
{
    //Retrieving the Strings for the selections
    CEGUI::ListboxItem* widgetListboxItem = d_widgetSelectorListbox->getFirstSelectedItem();
    CEGUI::ListboxItem* skinListboxItem = d_skinSelectionCombobox->getSelectedItem();

    if(!skinListboxItem || !widgetListboxItem)
        return false;

    //Recreate the widget's type as String
    widgetName = widgetListboxItem->getText();

    if(skinListboxItem->getText().compare("No Skin") != 0)
        widgetTypeString= skinListboxItem->getText() + "/";

    widgetTypeString += widgetName;

    return true;
}
Esempio n. 23
0
/***********************************************************
add people friend
***********************************************************/
void CommunityBox::UpdateFriend(const LbaNet::FriendInfo & frd)
{
	//RemoveFriend(frd.Name);

	CEGUI::Listbox * lb = static_cast<CEGUI::Listbox *> (
		CEGUI::WindowManager::getSingleton().getWindow("Community/friendlist"));


	bool connected = false;
	std::string color = "FF777777";
	std::map<std::string, CEGUI::ListboxItem *>::iterator iton = _onlines.find(frd.Name);
	if(iton != _onlines.end())
	{
		connected = true;
		color = "FF33FF33";
	}

	std::string dis = "[colour='" + color + "']";
	if(frd.ToAccept)
		dis += "(Request) ";

	dis += frd.Name;

	if(frd.Pending)
		dis += " (Pending)";


	//check if already exist just update the text
	T_friendmap::iterator it = _friends.find(frd.Id);
	if(it != _friends.end())
	{
		it->second.second->setText(dis);
		lb->invalidate();
	}
	else
	{
		CEGUI::ListboxItem *item = new MyComListItem(dis);
		item->setID((unsigned int)frd.Id);
		lb->addItem(item);
		_friends[frd.Id] = std::make_pair<LbaNet::FriendInfo, CEGUI::ListboxItem *>(frd, item);

	}
}
Esempio n. 24
0
//撤销委托订单事件
bool OnCancelAgentOrder(const CEGUI::EventArgs& e)
{
	CEGUI::WindowManager& mgr = GetWndMgr();
	CEGUI::MultiColumnList* mcl = WMCL(mgr.getWindow("Auction/Tab/Query/MCL"));
	//获得选中Item对应的订单ID
	CEGUI::ListboxItem* li = mcl->getFirstSelectedItem();
	if(!li)
	{
		/***********************************************************************/
		/* zhaohang fix 2010-9-3
		/* 修改消息框形式,采用封装的MsgEventManager,以及新的字符资源加载方式Appframe
		/***********************************************************************/
		GetInst(MsgEventManager).PushEvent(Msg_Ok,AppFrame::GetText("AU_113"),NULL,NULL,true);
		return false;
	}
	uint orderID = li->getID();
	AHdata& ah = GetInst(AHdata);
	ah.Send_AH_REMOVE_AGENT(orderID);
	return true;
}
Esempio n. 25
0
void FontDemo::changeFontSelectorFontSelection(const CEGUI::String& font)
{
    while(d_fontSelector->getFirstSelectedItem())
    {
        d_fontSelector->setItemSelectState(d_fontSelector->getFirstSelectedItem(), false);
    }

    unsigned int itemCount = d_fontSelector->getItemCount();
    for(unsigned int i = 0; i < itemCount; ++i)
    {
        CEGUI::ListboxItem* item = d_fontSelector->getListboxItemFromIndex(i);

        CEGUI::String itemFontName = item->getText();

        if(itemFontName.compare(font) == 0)
        {
            d_fontSelector->setItemSelectState(item, true);
            return;
        }
    }
}
Esempio n. 26
0
bool OnSexChanged(const CEGUI::EventArgs& e)
{
    CEGUI::Combobox* cbb = WComboBox(WEArgs(e).window);
    CEGUI::ListboxItem* lti = cbb->getSelectedItem();
    if(lti)
    {
        CREvent::SetSelectSex(lti->getID());
        //更改性别后,修改默认Face和HairStyle,使得模型能够正常显示
        CREvent::SetFace(0);
        CREvent::SetHairStyle(0);
    }
    else
    {
        CREvent::SetSelectSex(0);
        //更改性别后,修改默认Face和HairStyle,使得模型能够正常显示
        CREvent::SetFace(0);
        CREvent::SetHairStyle(0);
    }
    ResetDataBySexSelChanged();
    return true;
}
Esempio n. 27
0
bool OpenBuyUI()
{
	CEGUI::WindowManager& wndmgr = GetWndMgr();
	CEGUI::MultiColumnList* mcl = WMCL(wndmgr.getWindow("Auction/Tab/BuySale/SaleMCL"));
	if(!mcl)
		return false;
	CEGUI::ListboxItem* lbi = mcl->getFirstSelectedItem();
	if(!lbi)
	{
		GetInst(MsgEventManager).PushEvent(Msg_Ok,AppFrame::GetText("AU_102"),NULL,NULL,true);
		return false;
	}
	CEGUI::Window* wnd = wndmgr.getWindow("Auction/BuyWnd");
	wnd->setVisible(true);
	wnd->setAlwaysOnTop(true);
	CEGUI::Editbox* editbox = WEditBox(wnd->getChildRecursive("Auction/Buy/buyNum"));//购买界面编辑框激活
	editbox->activate();
	AHdata& ah = GetInst(AHdata);
	//界面获取购买订单ID
	uint ID = lbi->getID();
	ah.SetCanBuyID(ID);//保存要购买的订单ID
	return true;
}
bool CServerBrowser::OnConnectButtonClick(const CEGUI::EventArgs &eventArgs)
{
	CEGUI::MultiColumnList * pMultiColumnList = (CEGUI::MultiColumnList *)m_GUIElements.pServerMultiColumnList;
	CEGUI::ListboxItem * pHostname = pMultiColumnList->getFirstSelectedItem();
	CEGUI::ListboxItem * pHost = pMultiColumnList->getNextSelected(pHostname);
	CEGUI::ListboxItem * pPlayerCount = pMultiColumnList->getNextSelected(pHost);
	CEGUI::ListboxItem * pMaxPlayers = pMultiColumnList->getNextSelected(pPlayerCount);
	CEGUI::ListboxItem * pPing = pMultiColumnList->getNextSelected(pMaxPlayers);
	CEGUI::ListboxItem * pPassworded = pMultiColumnList->getNextSelected(pPing);


	// Get the host and port
	String strHost;
	unsigned short usPort;

	if(!CMainMenu::GetHostAndPort(pHost->getText().c_str(), strHost, usPort))
	{
		g_pClient->GetGUI()->ShowMessageBox("You must enter a valid host and port!", "Error!");
		return false;
	}

	// Hide the server browser window
	SetVisible(false);

	// Does this server require a password?
	if(pPassworded->getText() == "yes")
	{
		// TODO: Show password entry window
	}
	else
	{
		// Call the connect function
		CMainMenu::GetSingleton()->OnConnect(strHost, usPort, "");
	}

	return true;
}
bool
CFileSystemDialogImp::OnItemDblClicked( const CEGUI::EventArgs& e )
{GUCE_TRACE;
            
    // Test if this was a left mouse click
    const CEGUI::MouseEventArgs& eData = static_cast< const CEGUI::MouseEventArgs& >( e );    
    if ( eData.button == CEGUI::LeftButton )
    {
        // Get some easy access to data
        CGridViewImp* fsView = static_cast< CGridViewImp* >( GetFileSystemGridView() );
        CEGUI::MultiColumnList* fsViewWidget = fsView->GetImplementationWidget();        

        UInt32 columnIndex = 0;
        UInt32 rowIndex = 0;
        if ( fsView->TestForItemHit( eData.position.d_x , 
                                     eData.position.d_y ,
                                     columnIndex        ,
                                     rowIndex           ) )
        {        
            CEGUI::ListboxItem* listItem = fsViewWidget->getItemAtGridReference( CEGUI::MCLGridRef( rowIndex, columnIndex ) );
            if ( NULL != listItem )
            {
                if ( listItem->getText() == ".." )
                {
                    // ".." means go up one dir
                    m_currentPath = GUCEF::CORE::StripLastSubDir( m_currentPath );
                    RefreshView();
                }
                else
                if ( IsItemADirectory( listItem->getText().c_str() ) )
                {
                    GUCEF::CORE::AppendToPath( m_currentPath, listItem->getText().c_str() );
                    RefreshView();
                }
                else
                if ( IsItemAnArchive( listItem->getText().c_str() ) )
                {
                    CString itemName( listItem->getText().c_str() );
                    CString realName = itemName.CutChars( 3, true );
                    GUCEF::CORE::AppendToPath( m_currentPath, realName );
                    RefreshView();
                }
            }
        }
    }
    
    return true;
}
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");
	}
}