예제 #1
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;
}
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");
	}
}