replacing SetTextMaxWidth with more general SetMaxWidth
This commit is contained in:
@@ -78,6 +78,7 @@ BitmapText::BitmapText()
|
|||||||
m_bRainbow = false;
|
m_bRainbow = false;
|
||||||
|
|
||||||
m_iWrapWidthPixels = -1;
|
m_iWrapWidthPixels = -1;
|
||||||
|
m_fMaxWidth = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
BitmapText::~BitmapText()
|
BitmapText::~BitmapText()
|
||||||
@@ -303,11 +304,28 @@ void BitmapText::SetText( CString sText, CString sAlternateText, int iWrapWidthP
|
|||||||
}
|
}
|
||||||
|
|
||||||
BuildChars();
|
BuildChars();
|
||||||
|
UpdateBaseZoom();
|
||||||
}
|
}
|
||||||
|
|
||||||
void BitmapText::SetTextMaxWidth( float MaxWidth, const CString &text, const CString &alttext )
|
void BitmapText::SetTextMaxWidth( float MaxWidth, const CString &text, const CString &alttext )
|
||||||
{
|
{
|
||||||
|
m_fMaxWidth = MaxWidth;
|
||||||
this->SetText(text, alttext);
|
this->SetText(text, alttext);
|
||||||
|
}
|
||||||
|
|
||||||
|
void BitmapText::SetMaxWidth( float MaxWidth )
|
||||||
|
{
|
||||||
|
m_fMaxWidth = MaxWidth;
|
||||||
|
UpdateBaseZoom();
|
||||||
|
}
|
||||||
|
|
||||||
|
void BitmapText::UpdateBaseZoom()
|
||||||
|
{
|
||||||
|
if( m_fMaxWidth == 0 )
|
||||||
|
{
|
||||||
|
this->SetBaseZoomX( 1 );
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
const float Width = GetUnzoomedWidth();
|
const float Width = GetUnzoomedWidth();
|
||||||
|
|
||||||
@@ -315,10 +333,9 @@ void BitmapText::SetTextMaxWidth( float MaxWidth, const CString &text, const CSt
|
|||||||
if( !Width )
|
if( !Width )
|
||||||
return;
|
return;
|
||||||
|
|
||||||
/* Never decrease the zoom. Important: make sure you reset zoom before
|
/* Never decrease the zoom. */
|
||||||
* changing text with this function. */
|
const float Zoom = min( 1, m_fMaxWidth/Width );
|
||||||
const float Zoom = min( GetZoom(), MaxWidth/Width );
|
this->SetBaseZoomX( Zoom );
|
||||||
this->SetZoomX( Zoom );
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool BitmapText::StringWillUseAlternate(CString sText, CString sAlternateText) const
|
bool BitmapText::StringWillUseAlternate(CString sText, CString sAlternateText) const
|
||||||
@@ -446,6 +463,7 @@ void BitmapText::HandleCommand( const CStringArray &asTokens )
|
|||||||
// Commands that go in the tweening queue:
|
// Commands that go in the tweening queue:
|
||||||
// Commands that take effect immediately (ignoring the tweening queue):
|
// Commands that take effect immediately (ignoring the tweening queue):
|
||||||
if( sName=="wrapwidthpixels" ) SetWrapWidthPixels( iParam(1) );
|
if( sName=="wrapwidthpixels" ) SetWrapWidthPixels( iParam(1) );
|
||||||
|
else if( sName=="maxwidth" ) SetMaxWidth( fParam(1) );
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
Actor::HandleCommand( asTokens );
|
Actor::HandleCommand( asTokens );
|
||||||
|
|||||||
@@ -27,7 +27,8 @@ public:
|
|||||||
bool LoadFromNumbers( CString sTexturePath ) { return LoadFromTextureAndChars(sTexturePath,"0123456789%. :x"); };
|
bool LoadFromNumbers( CString sTexturePath ) { return LoadFromTextureAndChars(sTexturePath,"0123456789%. :x"); };
|
||||||
bool LoadFromTextureAndChars( CString sTexturePath, CString sChars );
|
bool LoadFromTextureAndChars( CString sTexturePath, CString sChars );
|
||||||
void SetText( CString sText, CString sAlternateText = "", int iWrapWidthPixels = -1 );
|
void SetText( CString sText, CString sAlternateText = "", int iWrapWidthPixels = -1 );
|
||||||
void SetTextMaxWidth( float MaxWidth, const CString &text, const CString &alttext = "" );
|
void SetMaxWidth( float MaxWidth );
|
||||||
|
void SetTextMaxWidth( float MaxWidth, const CString &text, const CString &alttext = "" ); // deprecated
|
||||||
void SetWrapWidthPixels( int iWrapWidthPixels );
|
void SetWrapWidthPixels( int iWrapWidthPixels );
|
||||||
|
|
||||||
void CropToWidth( int iWidthInSourcePixels );
|
void CropToWidth( int iWidthInSourcePixels );
|
||||||
@@ -56,6 +57,7 @@ protected:
|
|||||||
vector<wstring> m_wTextLines;
|
vector<wstring> m_wTextLines;
|
||||||
vector<int> m_iLineWidths; // in source pixels
|
vector<int> m_iLineWidths; // in source pixels
|
||||||
int m_iWrapWidthPixels; // -1 = no wrap
|
int m_iWrapWidthPixels; // -1 = no wrap
|
||||||
|
float m_fMaxWidth;
|
||||||
|
|
||||||
bool m_bRainbow;
|
bool m_bRainbow;
|
||||||
|
|
||||||
@@ -64,6 +66,7 @@ protected:
|
|||||||
|
|
||||||
void BuildChars();
|
void BuildChars();
|
||||||
void DrawChars();
|
void DrawChars();
|
||||||
|
void UpdateBaseZoom();
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user