TransitionBGAnimation -> Transition
This commit is contained in:
@@ -0,0 +1,88 @@
|
||||
#include "global.h"
|
||||
/*
|
||||
-----------------------------------------------------------------------------
|
||||
Class: Transition
|
||||
|
||||
Desc: See header
|
||||
|
||||
Copyright (c) 2001-2002 by the person(s) listed below. All rights reserved.
|
||||
Chris Danford
|
||||
-----------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
#include "Transition.h"
|
||||
#include "RageUtil.h"
|
||||
#include "ScreenManager.h"
|
||||
#include "IniFile.h"
|
||||
|
||||
|
||||
Transition::Transition()
|
||||
{
|
||||
m_State = waiting;
|
||||
m_fSecsIntoTransition = 0.0f;
|
||||
}
|
||||
|
||||
void Transition::Load( CString sBGAniDir )
|
||||
{
|
||||
if( !sBGAniDir.empty() && sBGAniDir.Right(1) != "/" )
|
||||
sBGAniDir += "/";
|
||||
|
||||
m_BGAnimation.LoadFromAniDir( sBGAniDir );
|
||||
|
||||
m_State = waiting;
|
||||
m_fSecsIntoTransition = 0.0f;
|
||||
|
||||
// load sound from file specified by ini, or use the first sound in the directory
|
||||
IniFile ini;
|
||||
ini.SetPath( sBGAniDir+"BGAnimation.ini" );
|
||||
ini.ReadFile();
|
||||
|
||||
CString sSoundFileName;
|
||||
if( ini.GetValue("BGAnimation","Sound",sSoundFileName) )
|
||||
m_sound.Load( sBGAniDir+sSoundFileName );
|
||||
else
|
||||
m_sound.Load( sBGAniDir );
|
||||
}
|
||||
|
||||
|
||||
void Transition::Update( float fDeltaTime )
|
||||
{
|
||||
Actor::Update( fDeltaTime );
|
||||
|
||||
if( m_State == transitioning )
|
||||
{
|
||||
m_BGAnimation.Update( fDeltaTime );
|
||||
if( m_fSecsIntoTransition > m_BGAnimation.GetLengthSeconds() ) // over
|
||||
{
|
||||
m_fSecsIntoTransition = 0.0;
|
||||
m_State = finished;
|
||||
SCREENMAN->SendMessageToTopScreen( m_MessageToSendWhenDone );
|
||||
}
|
||||
|
||||
m_fSecsIntoTransition += fDeltaTime;
|
||||
}
|
||||
}
|
||||
|
||||
void Transition::DrawPrimitives()
|
||||
{
|
||||
// Unless we're transitioning, don't draw because we'll waste resources drawing things
|
||||
// that aren't visible. -Chris
|
||||
if( m_State != transitioning )
|
||||
return;
|
||||
|
||||
m_BGAnimation.Draw();
|
||||
}
|
||||
|
||||
void Transition::StartTransitioning( ScreenMessage send_when_done )
|
||||
{
|
||||
ASSERT( m_State == waiting ); // can't call this more than once
|
||||
m_MessageToSendWhenDone = send_when_done;
|
||||
m_State = transitioning;
|
||||
m_sound.PlayRandom();
|
||||
m_fSecsIntoTransition = 0.0;
|
||||
}
|
||||
|
||||
float Transition::GetLengthSeconds()
|
||||
{
|
||||
return m_BGAnimation.GetLengthSeconds();
|
||||
}
|
||||
Reference in New Issue
Block a user