2003-03-05 08:48:35 +00:00
|
|
|
#include "global.h"
|
|
|
|
|
/*
|
|
|
|
|
-----------------------------------------------------------------------------
|
2003-04-13 02:33:11 +00:00
|
|
|
Class: Transition
|
2003-03-05 08:48:35 +00:00
|
|
|
|
|
|
|
|
Desc: See header
|
|
|
|
|
|
|
|
|
|
Copyright (c) 2001-2002 by the person(s) listed below. All rights reserved.
|
|
|
|
|
Chris Danford
|
|
|
|
|
-----------------------------------------------------------------------------
|
|
|
|
|
*/
|
|
|
|
|
|
2003-04-13 02:33:11 +00:00
|
|
|
#include "Transition.h"
|
2003-03-05 08:48:35 +00:00
|
|
|
#include "RageUtil.h"
|
|
|
|
|
#include "ScreenManager.h"
|
2003-04-02 07:04:17 +00:00
|
|
|
#include "IniFile.h"
|
2003-07-22 07:47:27 +00:00
|
|
|
#include "RageFile.h"
|
2003-03-05 08:48:35 +00:00
|
|
|
|
|
|
|
|
|
2003-04-13 02:33:11 +00:00
|
|
|
Transition::Transition()
|
2003-03-05 08:48:35 +00:00
|
|
|
{
|
2003-04-13 00:44:50 +00:00
|
|
|
m_State = waiting;
|
2003-03-05 08:48:35 +00:00
|
|
|
m_fSecsIntoTransition = 0.0f;
|
|
|
|
|
}
|
|
|
|
|
|
2003-04-13 02:33:11 +00:00
|
|
|
void Transition::Load( CString sBGAniDir )
|
2003-03-05 08:48:35 +00:00
|
|
|
{
|
2003-12-10 09:44:16 +00:00
|
|
|
if( !sBGAniDir.empty() && sBGAniDir.Right(1) != "/" )
|
|
|
|
|
sBGAniDir += "/";
|
2003-04-02 07:04:17 +00:00
|
|
|
|
2003-03-05 08:48:35 +00:00
|
|
|
m_BGAnimation.LoadFromAniDir( sBGAniDir );
|
2003-03-09 00:55:49 +00:00
|
|
|
|
2003-04-13 00:44:50 +00:00
|
|
|
m_State = waiting;
|
|
|
|
|
m_fSecsIntoTransition = 0.0f;
|
|
|
|
|
|
2003-04-02 07:04:17 +00:00
|
|
|
// load sound from file specified by ini, or use the first sound in the directory
|
|
|
|
|
IniFile ini;
|
2004-05-23 02:27:51 +00:00
|
|
|
ini.ReadFile( sBGAniDir+"BGAnimation.ini" );
|
2003-04-02 07:04:17 +00:00
|
|
|
|
|
|
|
|
CString sSoundFileName;
|
|
|
|
|
if( ini.GetValue("BGAnimation","Sound",sSoundFileName) )
|
2003-07-22 07:47:27 +00:00
|
|
|
{
|
|
|
|
|
FixSlashesInPlace( sSoundFileName );
|
|
|
|
|
CString sPath = sBGAniDir+sSoundFileName;
|
|
|
|
|
CollapsePath( sPath );
|
|
|
|
|
m_sound.Load( sPath );
|
|
|
|
|
}
|
2003-04-02 07:04:17 +00:00
|
|
|
else
|
2003-07-22 07:47:27 +00:00
|
|
|
{
|
2003-04-02 07:04:17 +00:00
|
|
|
m_sound.Load( sBGAniDir );
|
2003-07-22 07:47:27 +00:00
|
|
|
}
|
2003-03-05 08:48:35 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2003-04-13 02:33:11 +00:00
|
|
|
void Transition::Update( float fDeltaTime )
|
2003-03-05 08:48:35 +00:00
|
|
|
{
|
|
|
|
|
Actor::Update( fDeltaTime );
|
|
|
|
|
|
|
|
|
|
if( m_State == transitioning )
|
|
|
|
|
{
|
2003-04-13 06:29:02 +00:00
|
|
|
/* Start the transition on the first update, not in the ctor, so
|
|
|
|
|
* we don't play a sound while our parent is still loading. */
|
|
|
|
|
if( m_fSecsIntoTransition==0 ) // first update
|
2003-04-14 04:10:01 +00:00
|
|
|
{
|
2003-04-13 06:29:02 +00:00
|
|
|
m_sound.PlayRandom();
|
|
|
|
|
|
2003-04-14 04:10:01 +00:00
|
|
|
// stop the sound from playing multiple times on an Update(0)
|
|
|
|
|
m_fSecsIntoTransition+=0.000001f;
|
|
|
|
|
}
|
|
|
|
|
|
2003-03-05 08:48:35 +00:00
|
|
|
m_BGAnimation.Update( fDeltaTime );
|
|
|
|
|
if( m_fSecsIntoTransition > m_BGAnimation.GetLengthSeconds() ) // over
|
|
|
|
|
{
|
2003-04-13 06:29:02 +00:00
|
|
|
SCREENMAN->SendMessageToTopScreen( m_MessageToSendWhenDone );
|
2003-03-05 08:48:35 +00:00
|
|
|
m_fSecsIntoTransition = 0.0;
|
|
|
|
|
m_State = finished;
|
|
|
|
|
}
|
2003-04-13 06:29:02 +00:00
|
|
|
else
|
|
|
|
|
m_fSecsIntoTransition += fDeltaTime;
|
2003-03-05 08:48:35 +00:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2004-02-16 07:23:28 +00:00
|
|
|
bool Transition::EarlyAbortDraw()
|
|
|
|
|
{
|
|
|
|
|
return m_State != transitioning;
|
|
|
|
|
}
|
|
|
|
|
|
2003-04-13 02:33:11 +00:00
|
|
|
void Transition::DrawPrimitives()
|
2003-03-05 08:48:35 +00:00
|
|
|
{
|
2003-04-13 00:44:50 +00:00
|
|
|
m_BGAnimation.Draw();
|
2003-03-05 08:48:35 +00:00
|
|
|
}
|
|
|
|
|
|
2003-04-13 02:33:11 +00:00
|
|
|
void Transition::StartTransitioning( ScreenMessage send_when_done )
|
2003-03-05 08:48:35 +00:00
|
|
|
{
|
2003-04-24 06:16:04 +00:00
|
|
|
if( m_State != waiting )
|
|
|
|
|
return; // ignore
|
2003-10-12 20:00:02 +00:00
|
|
|
|
2003-03-05 08:48:35 +00:00
|
|
|
m_MessageToSendWhenDone = send_when_done;
|
|
|
|
|
m_State = transitioning;
|
|
|
|
|
m_fSecsIntoTransition = 0.0;
|
|
|
|
|
}
|
|
|
|
|
|
2003-11-07 20:54:18 +00:00
|
|
|
float Transition::GetLengthSeconds() const
|
2003-03-09 00:55:49 +00:00
|
|
|
{
|
|
|
|
|
return m_BGAnimation.GetLengthSeconds();
|
|
|
|
|
}
|
2004-04-25 22:38:55 +00:00
|
|
|
|
|
|
|
|
float Transition::GetTweenTimeLeft() const
|
|
|
|
|
{
|
|
|
|
|
if( m_State != transitioning )
|
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
|
|
return m_BGAnimation.GetTweenTimeLeft();
|
|
|
|
|
}
|