HelpDisplay: support alt text
This commit is contained in:
@@ -29,20 +29,24 @@ HelpDisplay::HelpDisplay()
|
|||||||
void HelpDisplay::Load()
|
void HelpDisplay::Load()
|
||||||
{
|
{
|
||||||
m_textTip.SetName( "Tip" );
|
m_textTip.SetName( "Tip" );
|
||||||
m_textTip.LoadFromFont( THEME->GetPathToF("HelpDisplay") );
|
m_textTip.LoadFromFont( THEME->GetPathToF("HelpDisplay") ); // XXX
|
||||||
ON_COMMAND( m_textTip );
|
ON_COMMAND( m_textTip );
|
||||||
this->AddChild( &m_textTip );
|
this->AddChild( &m_textTip );
|
||||||
|
|
||||||
m_fSecsUntilSwitch = TIP_SHOW_TIME;
|
m_fSecsUntilSwitch = TIP_SHOW_TIME;
|
||||||
}
|
}
|
||||||
|
|
||||||
void HelpDisplay::SetTips( const CStringArray &arrayTips )
|
void HelpDisplay::SetTips( const CStringArray &arrayTips, const CStringArray &arrayTipsAlt )
|
||||||
{
|
{
|
||||||
m_arrayTips = arrayTips;
|
ASSERT( arrayTips.size() == arrayTipsAlt.size() );
|
||||||
if( !m_arrayTips.empty() )
|
|
||||||
m_textTip.SetText( m_arrayTips[0] );
|
|
||||||
else
|
|
||||||
m_textTip.SetText( "" );
|
m_textTip.SetText( "" );
|
||||||
|
|
||||||
|
m_arrayTips = arrayTips;
|
||||||
|
m_arrayTipsAlt = arrayTipsAlt;
|
||||||
|
|
||||||
|
m_iCurTipIndex = 0;
|
||||||
|
m_fSecsUntilSwitch = 0;
|
||||||
|
Update( 0 );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -50,15 +54,16 @@ void HelpDisplay::Update( float fDeltaTime )
|
|||||||
{
|
{
|
||||||
ActorFrame::Update( fDeltaTime );
|
ActorFrame::Update( fDeltaTime );
|
||||||
|
|
||||||
if( !m_arrayTips.empty() )
|
if( m_arrayTips.empty() )
|
||||||
{
|
return;
|
||||||
|
|
||||||
m_fSecsUntilSwitch -= fDeltaTime;
|
m_fSecsUntilSwitch -= fDeltaTime;
|
||||||
if( m_fSecsUntilSwitch < 0 ) // time to switch states
|
if( m_fSecsUntilSwitch > 0 )
|
||||||
{
|
return;
|
||||||
|
|
||||||
|
// time to switch states
|
||||||
|
m_fSecsUntilSwitch = TIP_SHOW_TIME;
|
||||||
|
m_textTip.SetText( m_arrayTips[m_iCurTipIndex], m_arrayTipsAlt[m_iCurTipIndex] );
|
||||||
m_iCurTipIndex++;
|
m_iCurTipIndex++;
|
||||||
m_iCurTipIndex = m_iCurTipIndex % m_arrayTips.size();
|
m_iCurTipIndex = m_iCurTipIndex % m_arrayTips.size();
|
||||||
m_fSecsUntilSwitch = TIP_SHOW_TIME;
|
|
||||||
m_textTip.SetText( m_arrayTips[m_iCurTipIndex] );
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -20,14 +20,15 @@ class HelpDisplay : public ActorFrame
|
|||||||
public:
|
public:
|
||||||
HelpDisplay();
|
HelpDisplay();
|
||||||
void Load();
|
void Load();
|
||||||
void SetTips( const CStringArray &arrayTips );
|
void SetTips( const CStringArray &arrayTips ) { SetTips( arrayTips, arrayTips ); }
|
||||||
|
void SetTips( const CStringArray &arrayTips, const CStringArray &arrayTipsAlt );
|
||||||
|
|
||||||
virtual void Update( float fDeltaTime );
|
virtual void Update( float fDeltaTime );
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
BitmapText m_textTip;
|
BitmapText m_textTip;
|
||||||
|
|
||||||
CStringArray m_arrayTips;
|
CStringArray m_arrayTips, m_arrayTipsAlt;
|
||||||
int m_iCurTipIndex;
|
int m_iCurTipIndex;
|
||||||
|
|
||||||
float m_fSecsUntilSwitch;
|
float m_fSecsUntilSwitch;
|
||||||
|
|||||||
Reference in New Issue
Block a user