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 "ScreenManager.h"
|
|
|
|
|
|
|
|
|
|
|
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
|
|
|
}
|
|
|
|
|
|
2006-01-22 01:00:06 +00:00
|
|
|
void Transition::Load( RString sBGAniDir )
|
2003-03-05 08:48:35 +00:00
|
|
|
{
|
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-03-05 08:48:35 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2005-06-11 10:32:58 +00:00
|
|
|
void Transition::UpdateInternal( float fDeltaTime )
|
2003-03-05 08:48:35 +00:00
|
|
|
{
|
2005-01-15 20:55:04 +00:00
|
|
|
if( m_State != transitioning )
|
|
|
|
|
return;
|
|
|
|
|
|
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-06-11 10:32:58 +00:00
|
|
|
ActorFrame::UpdateInternal( 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;
|
2005-07-15 05:44:06 +00:00
|
|
|
m_bFirstUpdate = true;
|
|
|
|
|
|
|
|
|
|
if( m_sprTransition.IsLoaded() )
|
|
|
|
|
{
|
|
|
|
|
m_sprTransition->FinishTweening();
|
|
|
|
|
m_sprTransition->PlayCommand( "On" );
|
|
|
|
|
}
|
2004-02-16 07:23:28 +00:00
|
|
|
}
|
2003-04-13 00:44:50 +00:00
|
|
|
|
2005-08-25 00:57:53 +00:00
|
|
|
bool Transition::EarlyAbortDraw() const
|
2004-02-16 07:23:28 +00:00
|
|
|
{
|
2005-07-07 07:37:10 +00:00
|
|
|
return m_State == waiting;
|
2003-03-05 08:48:35 +00:00
|
|
|
}
|
|
|
|
|
|
2005-10-18 03:35:00 +00:00
|
|
|
/* Our parent might send us OnCommand. We do that ourself, because
|
|
|
|
|
* we sometimes want to know GetLengthSeconds before StartTransitioning.
|
|
|
|
|
* Make sure we don't process OnCommand twice. */
|
2006-08-15 19:24:29 +00:00
|
|
|
void Transition::PlayCommand( const RString &sCommandName )
|
2005-10-18 03:35:00 +00:00
|
|
|
{
|
|
|
|
|
if( sCommandName == "On" )
|
|
|
|
|
return;
|
|
|
|
|
|
2006-08-15 19:24:29 +00:00
|
|
|
ActorFrame::PlayCommand( sCommandName );
|
2005-10-18 03:35:00 +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.
|
|
|
|
|
*/
|