add SetTextMaxWidth
This commit is contained in:
@@ -241,6 +241,19 @@ void BitmapText::SetText( CString sText, CString sAlternateText )
|
||||
BuildChars();
|
||||
}
|
||||
|
||||
void BitmapText::SetTextMaxWidth( float MaxWidth, const CString &text, const CString &alttext )
|
||||
{
|
||||
this->SetText(text, alttext);
|
||||
|
||||
/* Avoid division by zero. */
|
||||
const int Width = GetWidestLineWidthInSourcePixels()+1;
|
||||
|
||||
/* Never decrease the zoom. Important: make sure you reset zoom before
|
||||
* changing text with this function. */
|
||||
const float Zoom = min( GetZoom(), MaxWidth/Width );
|
||||
this->SetZoomX( Zoom );
|
||||
}
|
||||
|
||||
bool BitmapText::StringWillUseAlternate(CString sText, CString sAlternateText) const
|
||||
{
|
||||
ASSERT( m_pFont );
|
||||
|
||||
@@ -27,6 +27,7 @@ public:
|
||||
bool LoadFromNumbers( CString sTexturePath ) { return LoadFromTextureAndChars(sTexturePath,"0123456789%. :x"); };
|
||||
bool LoadFromTextureAndChars( CString sTexturePath, CString sChars );
|
||||
void SetText( CString sText, CString sAlternateText = "" );
|
||||
void SetTextMaxWidth( float MaxWidth, const CString &text, const CString &alttext = "" );
|
||||
|
||||
int GetWidestLineWidthInSourcePixels() { return m_iWidestLineWidth; };
|
||||
void CropToWidth( int iWidthInSourcePixels );
|
||||
|
||||
Reference in New Issue
Block a user