コード例 #1
0
const char* CGUIGridList_Impl::GetItemText ( int iRow, int hColumn )
{
    try
    {
        CEGUI::MultiColumnList* pMultiColumnList = reinterpret_cast < CEGUI::MultiColumnList* > ( m_pWindow );
        if ( (uint)iRow >= pMultiColumnList->getRowCount() || (uint)GetColumnIndex( hColumn ) >= pMultiColumnList->getColumnCount() )
            return "";

        // 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 )
        {
            const char *szRet = pItem->getText().c_str ();

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

                if ( GetColumnIndex ( hColumn ) == 0 ) {
                    // 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 "";
}
コード例 #2
0
CGUIListItem* CGUIGridList_Impl::GetItem ( int iRow, int hColumn )
{
    try
    {
        CEGUI::MultiColumnList* pMultiColumnList = reinterpret_cast < CEGUI::MultiColumnList* > ( m_pWindow );
        if ( (uint)iRow >= pMultiColumnList->getRowCount() || (uint)GetColumnIndex( hColumn ) >= pMultiColumnList->getColumnCount() )
            return NULL;

        // Grab the item at the chosen row / column
        CEGUI::ListboxItem* pItem = reinterpret_cast < CEGUI::MultiColumnList* > ( m_pWindow ) -> getItemAtGridReference ( CEGUI::MCLGridRef ( iRow, GetColumnIndex ( hColumn ) ) );

        // If it exists, get the CGUIListItem by using the pool
        if ( pItem )
        {
            return GetListItem ( pItem );
        }
    }
    catch ( CEGUI::Exception )
    {}

    return NULL;
}
コード例 #3
0
    void PropertiesWindow::addPropertyArray(const Property& prop, const CeGuiString& key)
    {
        // Create the new MultiColumnList with two columns
        // Type and Value and set tab text to key
        int tabCount = mTabPane->getTabCount();
        CEGUI::MultiColumnList* newTable = static_cast<CEGUI::MultiColumnList*>
            (CEGUI::WindowManager::getSingleton().createWindow("RastullahLook/MultiColumnList",
            "PropertiesWindow/PropertiesTabControl/" + key));

        // Set table properties
        newTable->setText(key);
        newTable->setPosition(CEGUI::UVector2(
            CEGUI::UDim(0,0),
            CEGUI::UDim(0,0)));
        newTable->setSize(CEGUI::UVector2(
            CEGUI::UDim(1,0),
            CEGUI::UDim(1,0)));
        newTable->setUserSortControlEnabled(false);
        newTable->setFont("Vera Serif-8");

        newTable->addColumn("Type", 0, cegui_reldim(0.3));
        newTable->addColumn("Value", 1, cegui_reldim(0.7));

        // Add the MultiColumnList to the tab pane
        mTabPane->addTab(newTable);

        // Get access to the vector
        PropertyArray vProp = prop.toArray();

        // Iterate through the vector entries and add them
        // to the table
        for(PropertyArray::const_iterator it = vProp.begin(); it != vProp.end(); it++)
        {
            // Check for Int
            if (it->isInt() )
            {
                addPropertyInt(*it, newTable);
            }
            // Check for IntPair
            else if (it->isIntPair() )
            {
                addPropertyIntPair(*it, newTable);
                int rowCount = newTable->getRowCount();
                newTable->addRow(rowCount);
                newTable->setItem(new ListboxTextItem(""), 0, rowCount);
            }
            // Check for IntTriple
            else if (it->isIntTriple() )
            {
                addPropertyIntTriple(*it, newTable);
                int rowCount = newTable->getRowCount();
                newTable->addRow(rowCount);
                newTable->setItem(new ListboxTextItem(""), 0, rowCount);
            }
            // Check for String
            else if (it->isString() )
            {
                addPropertyString(*it, newTable);
            }
            // Check for Bool
            else if (it->isBool() )
            {
                addPropertyBool(*it, newTable);
            }
            // Check for Real
            else if (it->isReal() )
            {
                addPropertyReal(*it, newTable);
            }
            // Check for Vector3
            else if (it->isVector3() )
            {
                addPropertyArray3(*it, newTable);
                int rowCount = newTable->getRowCount();
                newTable->addRow(rowCount);
                newTable->setItem(new ListboxTextItem(""), 0, rowCount);
            }
            // Check for Quaternion
            else if (it->isQuaternion() )
            {
                addPropertyQuaternion(*it, newTable);
                int rowCount = newTable->getRowCount();
                newTable->addRow(rowCount);
                newTable->setItem(new ListboxTextItem(""), 0, rowCount);
            }
        }
        newTable->autoSizeColumnHeader(0);
        newTable->autoSizeColumnHeader(1);
    }
コード例 #4
0
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");
	}
}