2003-03-05 08:48:35 +00:00
|
|
|
#include "global.h"
|
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()
|
2003-03-05 08:48:35 +00:00
|
|
|
{
|
2004-02-16 07:23:28 +00:00
|
|
|
return m_State != transitioning;
|
|
|
|
|
}
|
2003-04-13 00:44:50 +00:00
|
|
|
|
2004-02-16 07:23:28 +00:00
|
|
|
void Transition::DrawPrimitives()
|
|
|
|
|
{
|
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();
|
|
|
|
|
}
|
2004-06-01 00:53:06 +00:00
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
* (c) 2001-2004 Chris Danford
|
|
|
|
|
* All rights reserved.
|
|
|
|
|
*
|
|
|
|
|
* Permission is hereby granted, free of charge, to any person obtaining a
|
|
|
|
|
* copy of this software and associated documentation files (the
|
|
|
|
|
* "Software"), to deal in the Software without restriction, including
|
|
|
|
|
* without limitation the rights to use, copy, modify, merge, publish,
|
|
|
|
|
* distribute, and/or sell copies of the Software, and to permit persons to
|
|
|
|
|
* whom the Software is furnished to do so, provided that the above
|
|
|
|
|
* copyright notice(s) and this permission notice appear in all copies of
|
|
|
|
|
* the Software and that both the above copyright notice(s) and this
|
|
|
|
|
* permission notice appear in supporting documentation.
|
|
|
|
|
*
|
|
|
|
|
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
|
|
|
|
|
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
|
|
|
|
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT OF
|
|
|
|
|
* THIRD PARTY RIGHTS. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR HOLDERS
|
|
|
|
|
* INCLUDED IN THIS NOTICE BE LIABLE FOR ANY CLAIM, OR ANY SPECIAL INDIRECT
|
|
|
|
|
* OR CONSEQUENTIAL DAMAGES, OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS
|
|
|
|
|
* OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
|
|
|
|
|
* OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
|
|
|
|
|
* PERFORMANCE OF THIS SOFTWARE.
|
|
|
|
|
*/
|