Ejemplo n.º 1
0
void C2DRenderUtils::DrawText(
    const float fX, const float fY,
    const float fSizeX, const float fSizeY,
    const char *strText,
    const ColorF& color,
    const EUIDRAWHORIZONTAL	eUIDrawHorizontal        /* = UIDRAWHORIZONTAL_LEFT*/,  // Checked
    const EUIDRAWVERTICAL		eUIDrawVertical          /* = UIDRAWVERTICAL_TOP*/,
    const EUIDRAWHORIZONTAL	eUIDrawHorizontalDocking /* = UIDRAWHORIZONTAL_LEFT*/,
    const EUIDRAWVERTICAL		eUIDrawVerticalDocking   /* = UIDRAWVERTICAL_TOP */)
{
    float drawX = fX;
    float drawY = fY;
    float sizeX = (fSizeX<=0.0f) ? 15.0f : fSizeX;
    float sizeY = (fSizeY<=0.0f) ? 15.0f : fSizeY;

    InitFont( m_pFont, sizeX, sizeY, color );

    float w=0.0f, h=0.0f;
    InternalGetTextDim( m_pFont, &w, &h, 0.0f, strText );
    const float wcpy=w, hcpy=h;
    m_pLayoutManager->AdjustToSafeArea( &drawX, &drawY, &w, &h, eUIDrawHorizontal, eUIDrawVertical, eUIDrawHorizontalDocking, eUIDrawVerticalDocking );
    // Scale the font
    sizeX *= w/wcpy;
    sizeY *= h/hcpy;
    InitFont( m_pFont, sizeX, sizeY, color );
    //InternalDrawRect( drawX, drawY, w, h, ColorF(0.0f,0,1.0f,0.1f));
    InternalDrawText( drawX, drawY, strText );
}
void CUIDraw::DrawTextSimple(IFFont *pFont,
															float fX, float fY,
															float fSizeX, float fSizeY,
															const char *strText, ColorF color,
															EUIDRAWHORIZONTAL	eUIDrawHorizontal, EUIDRAWVERTICAL		eUIDrawVertical)
{
	InternalDrawText(pFont, fX, fY, 0.0f,
		fSizeX, fSizeY,
		strText,
		color.a, color.r, color.g, color.b,
		UIDRAWHORIZONTAL_LEFT, UIDRAWVERTICAL_TOP, eUIDrawHorizontal, eUIDrawVertical);
}
void CUIDraw::DrawText(IFFont *pFont,
												float fX,
												float fY,
												float fSizeX,
												float fSizeY,
												const char *strText,
												float fAlpha,
												float fRed,
												float fGreen,
												float fBlue,
												EUIDRAWHORIZONTAL	eUIDrawHorizontalDocking,
												EUIDRAWVERTICAL		eUIDrawVerticalDocking,
												EUIDRAWHORIZONTAL	eUIDrawHorizontal,
												EUIDRAWVERTICAL		eUIDrawVertical)
{
	InternalDrawText(pFont, fX, fY, 0.0f,
		fSizeX, fSizeY, 
		strText, 
		fAlpha, fRed, fGreen, fBlue, 
		eUIDrawHorizontalDocking, eUIDrawVerticalDocking, eUIDrawHorizontal, eUIDrawVertical);
}
Ejemplo n.º 4
0
//-----------------------------------------------------------------------------------------------------
void C2DRenderUtils::DrawWrappedText(
    const float fX,
    const float fY,
    const float fMaxWidth,
    const float fSizeX,
    const float fSizeY,
    const char *strText,
    const ColorF& cfColor,
    const EUIDRAWHORIZONTAL	eUIDrawHorizontal /*= UIDRAWHORIZONTAL_LEFT*/, // Checked
    const EUIDRAWVERTICAL		eUIDrawVertical /*= UIDRAWVERTICAL_TOP*/,
    const EUIDRAWHORIZONTAL	eUIDrawHorizontalDocking /*= UIDRAWHORIZONTAL_LEFT*/,
    const EUIDRAWVERTICAL		eUIDrawVerticalDocking /*= UIDRAWVERTICAL_TOP*/
)
{
    float drawX = fX;
    float drawY = fY;
    float sizeX = (fSizeX<=0.0f) ? 15.0f : fSizeX;
    float sizeY = (fSizeY<=0.0f) ? 15.0f : fSizeY;

    InitFont( m_pFont, fSizeX, fSizeY, cfColor );

    string wrappedStr;
    const bool bWrapText = fMaxWidth > 0.0f;
    if (bWrapText)
    {
        m_pFont->WrapText(wrappedStr, fMaxWidth, strText, m_ctx);
        strText = wrappedStr.c_str();
    }
    Vec2 vDim = m_pFont->GetTextSize(strText, true, m_ctx);

    const float wcpy=vDim.x, hcpy=vDim.y;
    m_pLayoutManager->AdjustToSafeArea( &drawX, &drawY, &vDim.x, &vDim.y, eUIDrawHorizontal, eUIDrawVertical, eUIDrawHorizontalDocking, eUIDrawVerticalDocking );

    // scale font size appropriately
    sizeX *= vDim.x/wcpy;
    sizeY *= vDim.y/hcpy;
    InitFont( m_pFont, sizeX, sizeY, cfColor );
    //InternalDrawRect( drawX, drawY, vDim.x, vDim.y, ColorF(0.0f,1.0f,0.0f,0.1f));
    InternalDrawText( drawX, drawY, strText );
}