Files
itgmania212121/stepmania/src/ScreenStage.cpp
T

178 lines
5.4 KiB
C++
Raw Normal View History

2003-02-16 04:01:45 +00:00
#include "global.h"
#include "ActorUtil.h"
2002-05-20 08:59:37 +00:00
#include "ScreenStage.h"
#include "ScreenManager.h"
#include "PrefsManager.h"
#include "RageLog.h"
#include "GameConstantsAndTypes.h"
#include "BitmapText.h"
#include "SongManager.h"
#include "Sprite.h"
#include "AnnouncerManager.h"
2002-07-23 01:41:40 +00:00
#include "GameState.h"
2004-07-08 00:10:34 +00:00
#include "GameSoundManager.h"
#include "ThemeManager.h"
2003-11-16 04:45:12 +00:00
#include "LightsManager.h"
2003-12-20 04:14:12 +00:00
#include "song.h"
2002-07-23 01:41:40 +00:00
2004-02-01 03:01:54 +00:00
#define NEXT_SCREEN THEME->GetMetric (m_sName,"NextScreen")
#define PREV_SCREEN THEME->GetMetric (m_sName,"PrevScreen")
#define MINIMUM_DELAY THEME->GetMetricF(m_sName,"MinimumDelay")
const ScreenMessage SM_PrepScreen = (ScreenMessage)(SM_User+0);
2004-11-26 17:28:47 +00:00
REGISTER_SCREEN_CLASS( ScreenStage );
2003-09-27 22:30:51 +00:00
ScreenStage::ScreenStage( CString sClassName ) : Screen( sClassName )
2002-05-20 08:59:37 +00:00
{
m_bZeroDeltaOnNextUpdate = false;
2003-07-26 23:05:16 +00:00
SOUND->StopMusic();
2002-07-28 20:28:37 +00:00
2004-03-23 06:11:10 +00:00
LIGHTSMAN->SetLightsMode( LIGHTSMODE_STAGE );
2003-11-16 04:45:12 +00:00
2005-01-17 04:10:50 +00:00
m_Overlay.Load( THEME->GetPathB(m_sName,"overlay") );
m_Overlay->SetName( "Overlay" );
2004-04-25 22:40:31 +00:00
ON_COMMAND( m_Overlay );
2005-01-17 04:10:50 +00:00
this->AddChild( m_Overlay );
2005-01-17 04:10:50 +00:00
m_In.Load( THEME->GetPathB(m_sName,"in") );
m_In.StartTransitioning();
2004-05-02 03:01:27 +00:00
m_In.SetDrawOrder( DRAW_ORDER_TRANSITIONS );
this->AddChild( &m_In );
2005-01-17 04:10:50 +00:00
m_Out.Load( THEME->GetPathB(m_sName,"out") );
2004-05-02 03:01:27 +00:00
m_Out.SetDrawOrder( DRAW_ORDER_TRANSITIONS );
this->AddChild( &m_Out );
2005-01-17 04:10:50 +00:00
m_Back.Load( THEME->GetPathB("Common","back") );
2004-05-02 03:01:27 +00:00
m_Back.SetDrawOrder( DRAW_ORDER_TRANSITIONS );
this->AddChild( &m_Back );
/* Prep the new screen once m_In is complete. */
2005-01-17 04:10:50 +00:00
this->PostScreenMessage( SM_PrepScreen, m_Overlay->GetTweenTimeLeft() );
2004-05-22 02:01:58 +00:00
FOREACH_PlayerNumber(p)
{
m_sprCharacterIcon[p].SetName( ssprintf("CharacterIconP%d",p+1) );
2004-12-11 22:08:49 +00:00
const Character *pChar = GAMESTATE->m_pCurCharacters[p];
CString sPath = pChar->GetStageIconPath();
if( sPath == "" )
continue;
m_sprCharacterIcon[p].Load( pChar->GetStageIconPath() );
2004-04-25 22:40:31 +00:00
SET_XY_AND_ON_COMMAND( m_sprCharacterIcon[p] );
this->AddChild( &m_sprCharacterIcon[p] );
}
m_SongTitle.SetName( "SongTitle");
m_Artist.SetName( "Artist" );
2005-01-17 04:10:50 +00:00
m_SongTitle.LoadFromFont( THEME->GetPathF(m_sName,"Title") );
m_Artist.LoadFromFont( THEME->GetPathF(m_sName,"Artist") );
2004-04-25 22:40:31 +00:00
this->AddChild( &m_SongTitle );
this->AddChild( &m_Artist );
if(GAMESTATE->m_pCurSong != NULL)
{
m_SongTitle.SetText( GAMESTATE->m_pCurSong->m_sMainTitle );
m_Artist.SetText( GAMESTATE->m_pCurSong->m_sArtist );
}
else
{
m_SongTitle.SetText( "" );
m_Artist.SetText( "" );
}
2003-12-20 01:12:38 +00:00
SET_XY_AND_ON_COMMAND( m_Artist );
SET_XY_AND_ON_COMMAND( m_SongTitle );
2003-07-26 23:05:16 +00:00
SOUND->PlayOnceFromDir( ANNOUNCER->GetPathTo("stage "+GAMESTATE->GetStageText()) );
2004-05-02 03:01:27 +00:00
this->SortByDrawOrder();
}
2002-05-20 08:59:37 +00:00
void ScreenStage::HandleScreenMessage( const ScreenMessage SM )
{
switch( SM )
{
case SM_PrepScreen:
/* Start fading out in after MINIMUM_DELAY seconds. Loading the screen
* might take longer than that, in which case we'll fade out as early as
* we can. */
this->PostScreenMessage( SM_BeginFadingOut, MINIMUM_DELAY );
SCREENMAN->PrepareScreen( NEXT_SCREEN );
2002-05-20 08:59:37 +00:00
break;
case SM_BeginFadingOut:
2004-04-25 22:40:31 +00:00
m_Out.StartTransitioning();
FOREACH_PlayerNumber( p )
OFF_COMMAND( m_sprCharacterIcon[p] );
OFF_COMMAND( m_SongTitle );
OFF_COMMAND( m_Artist );
2004-04-25 22:40:31 +00:00
this->PostScreenMessage( SM_GoToNextScreen, this->GetTweenTimeLeft() );
2002-07-11 19:02:26 +00:00
break;
case SM_GoToNextScreen:
SCREENMAN->SetNewScreen( NEXT_SCREEN );
2002-05-20 08:59:37 +00:00
break;
case SM_GoToPrevScreen:
SCREENMAN->DeletePreparedScreens();
SCREENMAN->SetNewScreen( PREV_SCREEN );
break;
2002-05-20 08:59:37 +00:00
}
}
void ScreenStage::Update( float fDeltaTime )
{
if( m_bZeroDeltaOnNextUpdate )
{
m_bZeroDeltaOnNextUpdate = false;
fDeltaTime = 0;
}
Screen::Update( fDeltaTime );
}
void ScreenStage::MenuBack( PlayerNumber pn )
{
if( m_In.IsTransitioning() || m_Out.IsTransitioning() || m_Back.IsTransitioning() )
return;
this->ClearMessageQueue();
m_Back.StartTransitioning( SM_GoToPrevScreen );
2005-01-17 04:10:50 +00:00
SOUND->PlayOnce( THEME->GetPathS("Common","back") );
/* If a Back is buffered while we're prepping the screen (very common), we'll
* get it right after the prep finishes. However, the next update will contain
* the time spent prepping the screen. Zero the next delta, so the update is
* seen. */
m_bZeroDeltaOnNextUpdate = true;
}
2004-06-08 05:22:33 +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.
*/