示例#1
0
 void DrawItem(Surface* pSurface, const WinRect& rect, bool fSelected, int iFirstSlot)
 {
     int data = (int)this;
     char buf[30];
     sprintf(buf,"%d", data);
     pSurface->DrawString(TrekResources::SmallFont(), Color::White(), rect.Min(), buf);
 }
示例#2
0
 void DrawItem(Surface* pSurface, const WinRect& rect, bool fSelected, int iFirstSlot)
 {
     IEngineFont* pfont = m_pchatInfo->IsFromLeader() ? TrekResources::SmallBoldFont() : TrekResources::SmallFont();
     WinPoint pt(rect.Min() + WinPoint(3,3));
     for (
         int i = iFirstSlot; 
         i < m_vMsgLines.GetCount() && pt.Y() < rect.YMax(); 
         i++
     ) {
         pSurface->DrawString(pfont, m_pchatInfo->GetColor(), pt, m_vMsgLines[i]);
         pt += WinPoint(0, m_ptLineSize.Y());
     }
 }
示例#3
0
////////////////////////////////////////////////////////////////////////////////////////////////////
// GenerateFillVerticesD3DColor()
//
////////////////////////////////////////////////////////////////////////////////////////////////////
void CVertexGenerator::GenerateFillVerticesD3DColor( const WinRect & rectToFill, const bool bSetStream, D3DCOLOR d3dColor )
{
    UICOLOURFILLVERTEX * pVertArray;
    if( CVBIBManager::Get()->LockDynamicVertexBuffer(
                &m_sVGState.hPredefinedDynBuffers[ePDBT_UIFillVB],
                4,
                (void**) &pVertArray ) == false )
    {
        // Failed to lock the vertex buffer.
        _ASSERT( false );
        return;
    }
    // 2d texturing, adjust the vertex positions slightly.
    float fMinX, fMinY, fMaxX, fMaxY;
    fMinX = (float) rectToFill.Min().X() - 0.5f;
    fMinY = (float) rectToFill.Min().Y() - 0.5f;
    fMaxX = (float) rectToFill.Max().X() - 0.5f;
    fMaxY = (float) rectToFill.Max().Y() - 0.5f;

    pVertArray[0].x		= fMinX;
    pVertArray[0].y		= fMinY;
    pVertArray[0].z		= 0.5f;
    pVertArray[0].rhw	= 1.0f;
    pVertArray[0].color	= d3dColor;

    pVertArray[1].x		= fMaxX;
    pVertArray[1].y		= fMinY;
    pVertArray[1].z		= 0.5f;
    pVertArray[1].rhw	= 1.0f;
    pVertArray[1].color	= d3dColor;

    pVertArray[2].x		= fMinX;
    pVertArray[2].y		= fMaxY;
    pVertArray[2].z		= 0.5f;
    pVertArray[2].rhw	= 1.0f;
    pVertArray[2].color	= d3dColor;

    pVertArray[3].x		= fMaxX;
    pVertArray[3].y		= fMaxY;
    pVertArray[3].z		= 0.5f;
    pVertArray[3].rhw	= 1.0f;
    pVertArray[3].color	= d3dColor;

    // Finished adding verts, unlock.
    CVBIBManager::Get()->UnlockDynamicVertexBuffer( &m_sVGState.hPredefinedDynBuffers[ePDBT_UIFillVB] );

    if( bSetStream == true )
    {
        CVBIBManager::Get()->SetVertexStream( &m_sVGState.hPredefinedDynBuffers[ePDBT_UIFillVB] );
    }
}
示例#4
0
    void Paint(Surface* pSurface)
    {

        if (m_pImageBkgnd)
            pSurface->BitBlt(WinPoint(0, 0), 
                m_pImageBkgnd->GetSurface(),
                WinRect(m_ptImgOrigin.X(), m_ptImgOrigin.Y(),
                    m_ptImgOrigin.X() + XSize(), m_ptImgOrigin.Y() + YSize()));

        // calc num Items to draw
        int iLastVisibleItem = LastVisibleItem();
        int iLastItem = m_vItems.GetCount() - 1;
        if (iLastVisibleItem > iLastItem)
            iLastVisibleItem = iLastItem;

        // draw each Item
        WinRect rectPaint = WinRect(0, 0, m_nItemWidth, YSize());
        WinRect rectItem = rectPaint;
        rectItem.bottom = rectItem.top;
        ZAssert(m_iTopItem >= 0);

        // count the number of slots for the first item which we are not drawing
        int nNumHiddenSlots = 0;
        
        if (m_vItems.GetCount() > 0)
            {
            while (m_iTopItem - nNumHiddenSlots > 0 
                && m_vItems[m_iTopItem - (nNumHiddenSlots + 1)] == m_vItems[m_iTopItem])
                nNumHiddenSlots++;

            for (int iItem = m_iTopItem;
                    iItem <= iLastVisibleItem; 
                    iItem += m_vItems[iItem]->GetItemHeight() - nNumHiddenSlots, nNumHiddenSlots = 0)
                {
                rectItem.top = rectItem.bottom;
                int nLinesLeft = (iLastVisibleItem - iItem) + 1;
                int nLines = m_vItems[iItem]->GetItemHeight() - nNumHiddenSlots;
                rectItem.bottom += m_nItemHeight * (nLines > nLinesLeft ? nLinesLeft : nLines);

                // draw highlight if selected
                bool bItemSel = (m_iSelItem == iItem);
                if (bItemSel && m_pImageBkgndSel)
                    pSurface->BitBlt(rectItem.Min(), 
                        m_pImageBkgndSel->GetSurface(),
                        rectItem);
                // draw item
                m_vItems[iItem]->DrawItem(pSurface, rectItem, bItemSel, nNumHiddenSlots);
                }
            }
    }
示例#5
0
////////////////////////////////////////////////////////////////////////////////////////////////////
// GenerateUITexturedVertices()
//
////////////////////////////////////////////////////////////////////////////////////////////////////
void CVertexGenerator::GenerateUITexturedVertices( 	const TEXHANDLE hTexture,
        const WinRect & rectToDraw,
        const bool bSetStream )
{
    _ASSERT( hTexture != INVALID_TEX_HANDLE );
    float fMinX, fMinY, fMaxX, fMaxY;
    float fU1, fV1;
    DWORD dwWidth, dwHeight;
    UIVERTEX * pVertArray;

    CVRAMManager::Get()->GetOriginalDimensions( hTexture, &dwWidth, &dwHeight );

    if( CVBIBManager::Get()->LockDynamicVertexBuffer(
//							&m_sVGState.hUITexVertsVB,
                &m_sVGState.hPredefinedDynBuffers[ePDBT_UITexVB],
                4,
                (void**) &pVertArray ) == false )
    {
        // Failed to lock the vertex buffer.
        _ASSERT( false );
        return;
    }

    // 2d texturing, adjust the vertex positions slightly.
    fMinX = (float) rectToDraw.Min().X() - 0.5f;
    fMinY = (float) rectToDraw.Min().Y() - 0.5f;
    fMaxX = (float) rectToDraw.Max().X() - 0.5f;
    fMaxY = (float) rectToDraw.Max().Y() - 0.5f;

    // Calculate our uv coords.
    fU1 = 1.0f;
    fV1 = 1.0f;
    if( rectToDraw.XSize() < (int)dwWidth )
    {
        fU1 = (float) rectToDraw.XSize() / (float) dwWidth;
    }
    if( rectToDraw.YSize() < (int)dwHeight )
    {
        fV1 = (float) rectToDraw.YSize() / (float) dwHeight;
    }

    pVertArray[0].x = fMinX;
    pVertArray[0].y = fMinY;
    pVertArray[0].z = 0.5f;
    pVertArray[0].rhw = 1.0f;
    pVertArray[0].fU = 0.0f;
    pVertArray[0].fV = 0.0f;

    pVertArray[1].x = fMaxX;
    pVertArray[1].y = fMinY;
    pVertArray[1].z = 0.5f;
    pVertArray[1].rhw = 1.0f;
    pVertArray[1].fU = fU1;
    pVertArray[1].fV = 0.0f;

    pVertArray[2].x = fMinX;
    pVertArray[2].y = fMaxY;
    pVertArray[2].z = 0.5f;
    pVertArray[2].rhw = 1.0f;
    pVertArray[2].fU = 0.0f;
    pVertArray[2].fV = fV1;

    pVertArray[3].x = fMaxX;
    pVertArray[3].y = fMaxY;
    pVertArray[3].z = 0.5f;
    pVertArray[3].rhw = 1.0f;
    pVertArray[3].fU = fU1;
    pVertArray[3].fV = fV1;

    // Finished adding verts, unlock.
    CVBIBManager::Get()->UnlockDynamicVertexBuffer( &m_sVGState.hPredefinedDynBuffers[ePDBT_UITexVB] );

    if( bSetStream == true )
    {
        CVBIBManager::Get()->SetVertexStream( &m_sVGState.hPredefinedDynBuffers[ePDBT_UITexVB] );
    }
}