make background and foreground optional when loading this screen

This commit is contained in:
Chris Danford
2006-02-04 18:37:26 +00:00
parent f872743129
commit 2a1ce6b79a
3 changed files with 51 additions and 24 deletions
+45 -18
View File
@@ -50,6 +50,8 @@
#include "PlayerScoreList.h" #include "PlayerScoreList.h"
#include "InputEventPlus.h" #include "InputEventPlus.h"
#include "XmlFile.h" #include "XmlFile.h"
#include "Background.h"
#include "Foreground.h"
// //
// Defines // Defines
@@ -334,10 +336,12 @@ GetNextVisiblePlayerInfo( vector<PlayerInfo>::iterator iter, vector<PlayerInfo>
ScreenGameplay::ScreenGameplay() ScreenGameplay::ScreenGameplay()
{ {
m_pSongBackground = NULL;
m_pSongForeground = NULL;
m_pPlayerScoreList = NULL; m_pPlayerScoreList = NULL;
} }
void ScreenGameplay::Init() void ScreenGameplay::Init( bool bUseSongBackgroundAndForeground )
{ {
PLAYER_TYPE.Load( m_sName, "PlayerType" ); PLAYER_TYPE.Load( m_sName, "PlayerType" );
GIVE_UP_TEXT.Load( m_sName, "GiveUpText" ); GIVE_UP_TEXT.Load( m_sName, "GiveUpText" );
@@ -351,6 +355,12 @@ void ScreenGameplay::Init()
USE_FORCED_MODIFIERS_IN_BEGINNER.Load( m_sName, "UseForcedModifiersInBeginner" ); USE_FORCED_MODIFIERS_IN_BEGINNER.Load( m_sName, "UseForcedModifiersInBeginner" );
FORCED_MODIFIERS_IN_BEGINNER.Load( m_sName, "ForcedModifiersInBeginner" ); FORCED_MODIFIERS_IN_BEGINNER.Load( m_sName, "ForcedModifiersInBeginner" );
if( bUseSongBackgroundAndForeground )
{
m_pSongBackground = new Background;
m_pSongForeground = new Foreground;
}
this->FillPlayerInfo( m_vPlayerInfo ); this->FillPlayerInfo( m_vPlayerInfo );
ASSERT_M( !m_vPlayerInfo.empty(), "m_vPlayerInfo must be filled by FillPlayerInfo" ); ASSERT_M( !m_vPlayerInfo.empty(), "m_vPlayerInfo must be filled by FillPlayerInfo" );
@@ -425,15 +435,21 @@ void ScreenGameplay::Init()
m_bZeroDeltaOnNextUpdate = false; m_bZeroDeltaOnNextUpdate = false;
m_SongBackground.SetName( "SongBackground" ); if( m_pSongBackground )
m_SongBackground.SetDrawOrder( DRAW_ORDER_BEFORE_EVERYTHING ); {
ON_COMMAND( m_SongBackground ); m_pSongBackground->SetName( "SongBackground" );
this->AddChild( &m_SongBackground ); m_pSongBackground->SetDrawOrder( DRAW_ORDER_BEFORE_EVERYTHING );
ON_COMMAND( m_pSongBackground );
this->AddChild( m_pSongBackground );
}
m_SongForeground.SetName( "SongForeground" ); if( m_pSongForeground )
m_SongForeground.SetDrawOrder( DRAW_ORDER_OVERLAY+1 ); // on top of the overlay, but under transitions {
ON_COMMAND( m_SongForeground ); m_pSongForeground->SetName( "SongForeground" );
this->AddChild( &m_SongForeground ); m_pSongForeground->SetDrawOrder( DRAW_ORDER_OVERLAY+1 ); // on top of the overlay, but under transitions
ON_COMMAND( m_pSongForeground );
this->AddChild( m_pSongForeground );
}
if( PREFSMAN->m_bShowBeginnerHelper ) if( PREFSMAN->m_bShowBeginnerHelper )
{ {
@@ -768,7 +784,8 @@ void ScreenGameplay::Init()
} }
} }
m_SongBackground.Init(); if( m_pSongBackground )
m_pSongBackground->Init();
FOREACH_EnabledPlayerInfo( m_vPlayerInfo, pi ) FOREACH_EnabledPlayerInfo( m_vPlayerInfo, pi )
{ {
@@ -1200,14 +1217,16 @@ void ScreenGameplay::LoadNextSong()
} }
} }
m_SongBackground.Unload(); if( m_pSongBackground )
m_pSongBackground->Unload();
if( !PREFSMAN->m_bShowBeginnerHelper || !m_BeginnerHelper.Initialize(2) ) if( !PREFSMAN->m_bShowBeginnerHelper || !m_BeginnerHelper.Initialize(2) )
{ {
m_BeginnerHelper.SetHidden( true ); m_BeginnerHelper.SetHidden( true );
/* BeginnerHelper disabled, or failed to load. */ /* BeginnerHelper disabled, or failed to load. */
m_SongBackground.LoadFromSong( GAMESTATE->m_pCurSong ); if( m_pSongBackground )
m_pSongBackground->LoadFromSong( GAMESTATE->m_pCurSong );
if( !GAMESTATE->m_bDemonstrationOrJukebox ) if( !GAMESTATE->m_bDemonstrationOrJukebox )
{ {
@@ -1216,8 +1235,11 @@ void ScreenGameplay::LoadNextSong()
* black), or it might be 1, if the stage screen has the song BG and we're * black), or it might be 1, if the stage screen has the song BG and we're
* coming from it (like Pump). This used to be done in SM_PlayReady, but * coming from it (like Pump). This used to be done in SM_PlayReady, but
* that means it's impossible to snap to the new brightness immediately. */ * that means it's impossible to snap to the new brightness immediately. */
m_SongBackground.SetBrightness( INITIAL_BACKGROUND_BRIGHTNESS ); if( m_pSongBackground )
m_SongBackground.FadeToActualBrightness(); {
m_pSongBackground->SetBrightness( INITIAL_BACKGROUND_BRIGHTNESS );
m_pSongBackground->FadeToActualBrightness();
}
} }
} }
else else
@@ -1242,12 +1264,13 @@ void ScreenGameplay::LoadNextSong()
m_pCombinedLifeMeter->OnLoadSong(); m_pCombinedLifeMeter->OnLoadSong();
m_SongForeground.LoadFromSong( GAMESTATE->m_pCurSong ); if( m_pSongBackground )
m_pSongForeground->LoadFromSong( GAMESTATE->m_pCurSong );
m_fTimeSinceLastDancingComment = 0; m_fTimeSinceLastDancingComment = 0;
/* m_soundMusic and m_SongBackground take a very long time to load, /* m_soundMusic and m_pSongBackground take a very long time to load,
* so cap fDelta at 0 so m_NextSong will show up on screen. * so cap fDelta at 0 so m_NextSong will show up on screen.
* -Chris */ * -Chris */
m_bZeroDeltaOnNextUpdate = true; m_bZeroDeltaOnNextUpdate = true;
@@ -1703,7 +1726,9 @@ void ScreenGameplay::Update( float fDeltaTime )
// //
FOREACH_EnabledPlayerNumberInfo( m_vPlayerInfo, pi ) FOREACH_EnabledPlayerNumberInfo( m_vPlayerInfo, pi )
{ {
DancingCharacters *pCharacter = m_SongBackground.GetDancingCharacters(); DancingCharacters *pCharacter = NULL;
if( m_pSongBackground )
pCharacter = m_pSongBackground->GetDancingCharacters();
if( pCharacter != NULL ) if( pCharacter != NULL )
{ {
TapNoteScore tns = pi->m_pPlayer->GetLastTapNoteScore(); TapNoteScore tns = pi->m_pPlayer->GetLastTapNoteScore();
@@ -2333,7 +2358,9 @@ void ScreenGameplay::HandleScreenMessage( const ScreenMessage SM )
else if( SM == SM_LeaveGameplay ) else if( SM == SM_LeaveGameplay )
{ {
// update dancing characters for win / lose // update dancing characters for win / lose
DancingCharacters *pDancers = m_SongBackground.GetDancingCharacters(); DancingCharacters *pDancers = NULL;
if( m_pSongBackground )
pDancers = m_pSongBackground->GetDancingCharacters();
if( pDancers ) if( pDancers )
{ {
FOREACH_EnabledPlayerNumberInfo( m_vPlayerInfo, pi ) FOREACH_EnabledPlayerNumberInfo( m_vPlayerInfo, pi )
+5 -5
View File
@@ -8,8 +8,6 @@
#include "Transition.h" #include "Transition.h"
#include "BitmapText.h" #include "BitmapText.h"
#include "RageSound.h" #include "RageSound.h"
#include "Background.h"
#include "Foreground.h"
#include "BPMDisplay.h" #include "BPMDisplay.h"
#include "BeginnerHelper.h" #include "BeginnerHelper.h"
#include "LyricDisplay.h" #include "LyricDisplay.h"
@@ -32,6 +30,8 @@ class DifficultyMeter;
class Inventory; class Inventory;
class ScoreKeeper; class ScoreKeeper;
class PlayerScoreList; class PlayerScoreList;
class Background;
class Foreground;
AutoScreenMessage( SM_NotesEnded ) AutoScreenMessage( SM_NotesEnded )
AutoScreenMessage( SM_BeginFailed ) AutoScreenMessage( SM_BeginFailed )
@@ -98,7 +98,7 @@ class ScreenGameplay : public ScreenWithMenuElements
{ {
public: public:
ScreenGameplay(); ScreenGameplay();
virtual void Init(); virtual void Init( bool bUseSongBackgroundAndForeground = true );
virtual ~ScreenGameplay(); virtual ~ScreenGameplay();
virtual void BeginScreen(); virtual void BeginScreen();
@@ -169,8 +169,8 @@ protected:
LyricDisplay m_LyricDisplay; LyricDisplay m_LyricDisplay;
Background m_SongBackground; Background *m_pSongBackground;
Foreground m_SongForeground; Foreground *m_pSongForeground;
Transition m_NextSong; // shows between songs in a course Transition m_NextSong; // shows between songs in a course
Transition m_SongFinished; // shows after each song, course or not Transition m_SongFinished; // shows after each song, course or not
+1 -1
View File
@@ -18,7 +18,7 @@ void ScreenGameplayLesson::Init()
ASSERT( GAMESTATE->m_pCurSong ); ASSERT( GAMESTATE->m_pCurSong );
/* Now that we've set up, init the base class. */ /* Now that we've set up, init the base class. */
ScreenGameplay::Init(); ScreenGameplayNormal::Init();
ClearMessageQueue(); // remove all of the messages set in ScreenGameplay that animate "ready", "here we go", etc. ClearMessageQueue(); // remove all of the messages set in ScreenGameplay that animate "ready", "here we go", etc.