From 2a1ce6b79a6cb0e7fe523959ae8dfed6586f19d9 Mon Sep 17 00:00:00 2001 From: Chris Danford Date: Sat, 4 Feb 2006 18:37:26 +0000 Subject: [PATCH] make background and foreground optional when loading this screen --- stepmania/src/ScreenGameplay.cpp | 63 ++++++++++++++++++-------- stepmania/src/ScreenGameplay.h | 10 ++-- stepmania/src/ScreenGameplayLesson.cpp | 2 +- 3 files changed, 51 insertions(+), 24 deletions(-) diff --git a/stepmania/src/ScreenGameplay.cpp b/stepmania/src/ScreenGameplay.cpp index f5eecd5525..e53db336d5 100644 --- a/stepmania/src/ScreenGameplay.cpp +++ b/stepmania/src/ScreenGameplay.cpp @@ -50,6 +50,8 @@ #include "PlayerScoreList.h" #include "InputEventPlus.h" #include "XmlFile.h" +#include "Background.h" +#include "Foreground.h" // // Defines @@ -334,10 +336,12 @@ GetNextVisiblePlayerInfo( vector::iterator iter, vector ScreenGameplay::ScreenGameplay() { + m_pSongBackground = NULL; + m_pSongForeground = NULL; m_pPlayerScoreList = NULL; } -void ScreenGameplay::Init() +void ScreenGameplay::Init( bool bUseSongBackgroundAndForeground ) { PLAYER_TYPE.Load( m_sName, "PlayerType" ); GIVE_UP_TEXT.Load( m_sName, "GiveUpText" ); @@ -350,6 +354,12 @@ void ScreenGameplay::Init() FAIL_AFTER_30_MISSES.Load( m_sName, "FailAfter30Misses" ); USE_FORCED_MODIFIERS_IN_BEGINNER.Load( m_sName, "UseForcedModifiersInBeginner" ); FORCED_MODIFIERS_IN_BEGINNER.Load( m_sName, "ForcedModifiersInBeginner" ); + + if( bUseSongBackgroundAndForeground ) + { + m_pSongBackground = new Background; + m_pSongForeground = new Foreground; + } this->FillPlayerInfo( m_vPlayerInfo ); ASSERT_M( !m_vPlayerInfo.empty(), "m_vPlayerInfo must be filled by FillPlayerInfo" ); @@ -425,15 +435,21 @@ void ScreenGameplay::Init() m_bZeroDeltaOnNextUpdate = false; - m_SongBackground.SetName( "SongBackground" ); - m_SongBackground.SetDrawOrder( DRAW_ORDER_BEFORE_EVERYTHING ); - ON_COMMAND( m_SongBackground ); - this->AddChild( &m_SongBackground ); + if( m_pSongBackground ) + { + m_pSongBackground->SetName( "SongBackground" ); + m_pSongBackground->SetDrawOrder( DRAW_ORDER_BEFORE_EVERYTHING ); + ON_COMMAND( m_pSongBackground ); + this->AddChild( m_pSongBackground ); + } - m_SongForeground.SetName( "SongForeground" ); - m_SongForeground.SetDrawOrder( DRAW_ORDER_OVERLAY+1 ); // on top of the overlay, but under transitions - ON_COMMAND( m_SongForeground ); - this->AddChild( &m_SongForeground ); + if( m_pSongForeground ) + { + m_pSongForeground->SetName( "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 ) { @@ -768,7 +784,8 @@ void ScreenGameplay::Init() } } - m_SongBackground.Init(); + if( m_pSongBackground ) + m_pSongBackground->Init(); 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) ) { m_BeginnerHelper.SetHidden( true ); /* 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 ) { @@ -1216,8 +1235,11 @@ void ScreenGameplay::LoadNextSong() * 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 * that means it's impossible to snap to the new brightness immediately. */ - m_SongBackground.SetBrightness( INITIAL_BACKGROUND_BRIGHTNESS ); - m_SongBackground.FadeToActualBrightness(); + if( m_pSongBackground ) + { + m_pSongBackground->SetBrightness( INITIAL_BACKGROUND_BRIGHTNESS ); + m_pSongBackground->FadeToActualBrightness(); + } } } else @@ -1242,12 +1264,13 @@ void ScreenGameplay::LoadNextSong() m_pCombinedLifeMeter->OnLoadSong(); - m_SongForeground.LoadFromSong( GAMESTATE->m_pCurSong ); + if( m_pSongBackground ) + m_pSongForeground->LoadFromSong( GAMESTATE->m_pCurSong ); 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. * -Chris */ m_bZeroDeltaOnNextUpdate = true; @@ -1703,7 +1726,9 @@ void ScreenGameplay::Update( float fDeltaTime ) // FOREACH_EnabledPlayerNumberInfo( m_vPlayerInfo, pi ) { - DancingCharacters *pCharacter = m_SongBackground.GetDancingCharacters(); + DancingCharacters *pCharacter = NULL; + if( m_pSongBackground ) + pCharacter = m_pSongBackground->GetDancingCharacters(); if( pCharacter != NULL ) { TapNoteScore tns = pi->m_pPlayer->GetLastTapNoteScore(); @@ -2333,7 +2358,9 @@ void ScreenGameplay::HandleScreenMessage( const ScreenMessage SM ) else if( SM == SM_LeaveGameplay ) { // update dancing characters for win / lose - DancingCharacters *pDancers = m_SongBackground.GetDancingCharacters(); + DancingCharacters *pDancers = NULL; + if( m_pSongBackground ) + pDancers = m_pSongBackground->GetDancingCharacters(); if( pDancers ) { FOREACH_EnabledPlayerNumberInfo( m_vPlayerInfo, pi ) diff --git a/stepmania/src/ScreenGameplay.h b/stepmania/src/ScreenGameplay.h index 421aa54cb6..f571cac7ef 100644 --- a/stepmania/src/ScreenGameplay.h +++ b/stepmania/src/ScreenGameplay.h @@ -8,8 +8,6 @@ #include "Transition.h" #include "BitmapText.h" #include "RageSound.h" -#include "Background.h" -#include "Foreground.h" #include "BPMDisplay.h" #include "BeginnerHelper.h" #include "LyricDisplay.h" @@ -32,6 +30,8 @@ class DifficultyMeter; class Inventory; class ScoreKeeper; class PlayerScoreList; +class Background; +class Foreground; AutoScreenMessage( SM_NotesEnded ) AutoScreenMessage( SM_BeginFailed ) @@ -98,7 +98,7 @@ class ScreenGameplay : public ScreenWithMenuElements { public: ScreenGameplay(); - virtual void Init(); + virtual void Init( bool bUseSongBackgroundAndForeground = true ); virtual ~ScreenGameplay(); virtual void BeginScreen(); @@ -169,8 +169,8 @@ protected: LyricDisplay m_LyricDisplay; - Background m_SongBackground; - Foreground m_SongForeground; + Background *m_pSongBackground; + Foreground *m_pSongForeground; Transition m_NextSong; // shows between songs in a course Transition m_SongFinished; // shows after each song, course or not diff --git a/stepmania/src/ScreenGameplayLesson.cpp b/stepmania/src/ScreenGameplayLesson.cpp index 11ff7eca39..00ff6c7d9e 100644 --- a/stepmania/src/ScreenGameplayLesson.cpp +++ b/stepmania/src/ScreenGameplayLesson.cpp @@ -18,7 +18,7 @@ void ScreenGameplayLesson::Init() ASSERT( GAMESTATE->m_pCurSong ); /* 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.