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
|
|
|
|
|
|
|
|
|
2005-04-15 08:05:10 +00:00
|
|
|
/*
|
|
|
|
|
* XXX: We send OnCommand on load, then we send no updates until we get
|
|
|
|
|
* StartTransitioning. Historically, this was fine, but it's incorrect now
|
|
|
|
|
* that commands can have arbitrary side-effects. We should only send OnCommand
|
|
|
|
|
* when we get StartTransitioning, but we need to run it early to set m_fLengthSeconds.
|
|
|
|
|
* Eventually, phase out GetLengthSeconds (ScreenGameplay is somewhat tricky). For
|
|
|
|
|
* now, play a "StartTransitioning" command; put anything that has side-effects in
|
|
|
|
|
* there, instead.
|
|
|
|
|
*/
|
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
|
|
|
}
|
|
|
|
|
|
2003-04-13 02:33:11 +00:00
|
|
|
void Transition::Load( CString sBGAniDir )
|
2003-03-05 08:48:35 +00:00
|
|
|
{
|
2005-03-20 07:22:10 +00:00
|
|
|
if( IsADirectory(sBGAniDir) && sBGAniDir.Right(1) != "/" )
|
|
|
|
|
sBGAniDir += "/";
|
|
|
|
|
|
2005-03-21 05:16:28 +00:00
|
|
|
this->RemoveAllChildren();
|
|
|
|
|
|
2005-01-15 21:03:26 +00:00
|
|
|
m_sprTransition.Load( sBGAniDir );
|
|
|
|
|
m_sprTransition->PlayCommand( "On" );
|
2005-03-21 05:16:28 +00:00
|
|
|
this->AddChild( m_sprTransition );
|
2005-01-15 21:03:26 +00:00
|
|
|
m_fLengthSeconds = m_sprTransition->GetTweenTimeLeft();
|
2003-03-09 00:55:49 +00:00
|
|
|
|
2003-04-13 00:44:50 +00:00
|
|
|
m_State = waiting;
|
|
|
|
|
|
2003-04-02 07:04:17 +00:00
|
|
|
// load sound from file specified by ini, or use the first sound in the directory
|
2005-04-04 01:54:55 +00:00
|
|
|
|
2005-03-27 05:16:51 +00:00
|
|
|
if( IsADirectory(sBGAniDir) )
|
2003-07-22 07:47:27 +00:00
|
|
|
{
|
2005-03-27 05:16:51 +00:00
|
|
|
IniFile ini;
|
|
|
|
|
ini.ReadFile( sBGAniDir+"/BGAnimation.ini" );
|
|
|
|
|
|
|
|
|
|
CString sSoundFileName;
|
2005-04-04 01:54:55 +00:00
|
|
|
if( ini.GetValue("BGAnimation","Sound", sSoundFileName) )
|
2005-03-27 05:16:51 +00:00
|
|
|
{
|
|
|
|
|
FixSlashesInPlace( sSoundFileName );
|
|
|
|
|
CString sPath = sBGAniDir+sSoundFileName;
|
|
|
|
|
CollapsePath( sPath );
|
|
|
|
|
m_sound.Load( sPath );
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
m_sound.Load( sBGAniDir );
|
|
|
|
|
}
|
2003-07-22 07:47:27 +00:00
|
|
|
}
|
2005-04-04 01:54:55 +00:00
|
|
|
else if( GetExtension(sBGAniDir).CompareNoCase("xml") == 0 )
|
|
|
|
|
{
|
|
|
|
|
CString sSoundFile;
|
|
|
|
|
XNode xml;
|
|
|
|
|
PARSEINFO pi;
|
|
|
|
|
xml.LoadFromFile( sBGAniDir, &pi );
|
|
|
|
|
if( xml.GetAttrValue( "Sound", sSoundFile ) )
|
|
|
|
|
{
|
|
|
|
|
m_sound.Load( Dirname(sBGAniDir) + sSoundFile );
|
|
|
|
|
}
|
|
|
|
|
}
|
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
|
|
|
{
|
2005-01-15 20:55:04 +00:00
|
|
|
if( m_State != transitioning )
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
/* 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_bFirstUpdate )
|
2005-03-21 03:41:06 +00:00
|
|
|
m_sound.PlayCopyOfRandom();
|
2005-01-15 20:55:04 +00:00
|
|
|
|
2005-03-18 22:06:33 +00:00
|
|
|
// Check this before running Update, so we draw the last frame of the finished
|
|
|
|
|
// transition before sending m_MessageToSendWhenDone.
|
2005-01-15 21:03:26 +00:00
|
|
|
if( m_sprTransition->GetTweenTimeLeft() == 0 ) // over
|
2003-03-05 08:48:35 +00:00
|
|
|
{
|
2005-01-15 20:55:04 +00:00
|
|
|
m_State = finished;
|
2005-03-18 22:06:33 +00:00
|
|
|
SCREENMAN->SendMessageToTopScreen( m_MessageToSendWhenDone );
|
2003-03-05 08:48:35 +00:00
|
|
|
}
|
2005-01-15 20:55:04 +00:00
|
|
|
|
2005-03-18 22:06:33 +00:00
|
|
|
ActorFrame::Update( fDeltaTime );
|
2003-03-05 08:48:35 +00:00
|
|
|
}
|
|
|
|
|
|
2005-03-18 22:06:33 +00:00
|
|
|
void Transition::Reset()
|
2003-03-05 08:48:35 +00:00
|
|
|
{
|
2005-03-18 22:06:33 +00:00
|
|
|
m_State = waiting;
|
2004-02-16 07:23:28 +00:00
|
|
|
}
|
2003-04-13 00:44:50 +00:00
|
|
|
|
2005-03-18 22:06:33 +00:00
|
|
|
bool Transition::EarlyAbortDraw()
|
2004-02-16 07:23:28 +00:00
|
|
|
{
|
2005-03-18 22:06:33 +00:00
|
|
|
return m_State != transitioning;
|
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
|
2005-04-16 04:50:56 +00:00
|
|
|
|
|
|
|
|
// If transition isn't loaded don't set state to transitioning.
|
|
|
|
|
// We assume elsewhere that m_sprTransition is loaded.
|
|
|
|
|
if( !m_sprTransition.IsLoaded() )
|
|
|
|
|
return;
|
|
|
|
|
|
2005-04-15 08:05:10 +00:00
|
|
|
m_sprTransition->PlayCommand( "StartTransitioning" );
|
2003-10-12 20:00:02 +00:00
|
|
|
|
2003-03-05 08:48:35 +00:00
|
|
|
m_MessageToSendWhenDone = send_when_done;
|
|
|
|
|
m_State = transitioning;
|
|
|
|
|
}
|
|
|
|
|
|
2003-11-07 20:54:18 +00:00
|
|
|
float Transition::GetLengthSeconds() const
|
2003-03-09 00:55:49 +00:00
|
|
|
{
|
2005-01-15 18:31:14 +00:00
|
|
|
return m_fLengthSeconds;
|
2003-03-09 00:55:49 +00:00
|
|
|
}
|
2004-04-25 22:38:55 +00:00
|
|
|
|
|
|
|
|
float Transition::GetTweenTimeLeft() const
|
|
|
|
|
{
|
|
|
|
|
if( m_State != transitioning )
|
|
|
|
|
return 0;
|
|
|
|
|
|
2005-01-15 21:03:26 +00:00
|
|
|
return m_sprTransition->GetTweenTimeLeft();
|
2004-04-25 22:38:55 +00:00
|
|
|
}
|
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.
|
|
|
|
|
*/
|