Files
itgmania212121/stepmania/src/TipDisplay.cpp
T

89 lines
1.9 KiB
C++
Raw Normal View History

2002-01-16 10:01:32 +00:00
#include "stdafx.h"
/*
-----------------------------------------------------------------------------
File: TipDisplay.h
Desc: A graphic displayed in the TipDisplay during Dancing.
2002-05-19 01:59:48 +00:00
Copyright (c) 2001-2002 by the person(s) listed below. All rights reserved.
2002-01-16 10:01:32 +00:00
-----------------------------------------------------------------------------
*/
#include "TipDisplay.h"
#include "RageUtil.h"
#include "ThemeManager.h"
2002-05-01 19:14:55 +00:00
#include "RageLog.h"
2002-01-16 10:01:32 +00:00
const float TIP_FADE_TIME = 0.3f;
const float TIP_SHOW_TIME = 2;
TipDisplay::TipDisplay()
{
2002-05-01 19:14:55 +00:00
LOG->WriteLine( "TipDisplay::TipDisplay()" );
2002-01-16 10:01:32 +00:00
m_textTip.Load( THEME->GetPathTo(FONT_NORMAL) );
this->AddActor( &m_textTip );
iLastTipShown = -1;
m_TipState = STATE_SHOWING;
m_fTimeLeftInState = 0;
}
void TipDisplay::SetTips( CStringArray &arrayTips )
{
m_arrayTips.RemoveAll();
m_arrayTips.Copy( arrayTips );
}
void TipDisplay::Update( float fDeltaTime )
{
ActorFrame::Update( fDeltaTime );
if( m_arrayTips.GetSize() == 0 )
return;
m_fTimeLeftInState -= fDeltaTime;
if( m_fTimeLeftInState <= 0 ) // time to switch states
{
switch( m_TipState )
{
case STATE_SHOWING:
m_TipState = STATE_FADING_OUT;
m_fTimeLeftInState = TIP_FADE_TIME;
// fade out
m_textTip.SetZoomY( 1 );
m_textTip.BeginTweening( TIP_FADE_TIME );
m_textTip.SetTweenZoomY( 0 );
break;
case STATE_FADING_OUT:
m_TipState = STATE_FADING_IN;
m_fTimeLeftInState = TIP_FADE_TIME;
// switch the tip
int iTipToShow;
iTipToShow = iLastTipShown + 1;
if( iTipToShow > m_arrayTips.GetSize()-1 )
iTipToShow = 0;
m_textTip.SetText( m_arrayTips[iTipToShow] );
iLastTipShown = iTipToShow;
// fade in
m_textTip.SetZoomY( 0 );
m_textTip.BeginTweening( TIP_FADE_TIME );
m_textTip.SetTweenZoomY( 1 );
break;
case STATE_FADING_IN:
m_TipState = STATE_SHOWING;
m_fTimeLeftInState = TIP_SHOW_TIME;
break;
}
}
}