From 5de58766e98c56be5fba63d590719519e5159d34 Mon Sep 17 00:00:00 2001 From: Glenn Maynard Date: Mon, 3 Jan 2005 23:20:11 +0000 Subject: [PATCH] simplify demo/jukebox setup --- stepmania/src/ScreenGameplay.cpp | 25 ++++++++++++------------- stepmania/src/ScreenGameplay.h | 3 +-- stepmania/src/ScreenJukebox.cpp | 21 +++++++++------------ stepmania/src/ScreenJukebox.h | 5 ++--- 4 files changed, 24 insertions(+), 30 deletions(-) diff --git a/stepmania/src/ScreenGameplay.cpp b/stepmania/src/ScreenGameplay.cpp index 70bf071134..046a17d19e 100644 --- a/stepmania/src/ScreenGameplay.cpp +++ b/stepmania/src/ScreenGameplay.cpp @@ -86,16 +86,15 @@ const ScreenMessage SM_StopHereWeGo = ScreenMessage(SM_User+41); REGISTER_SCREEN_CLASS( ScreenGameplay ); -ScreenGameplay::ScreenGameplay( CString sName, bool bDemonstration ) : Screen(sName) +ScreenGameplay::ScreenGameplay( CString sName ) : Screen(sName) { - m_bDemonstration = bDemonstration; } void ScreenGameplay::Init() { Screen::Init(); - if( m_bDemonstration ) + if( GAMESTATE->m_bDemonstrationOrJukebox ) LIGHTSMAN->SetLightsMode( LIGHTSMODE_DEMONSTRATION ); else LIGHTSMAN->SetLightsMode( LIGHTSMODE_GAMEPLAY ); @@ -184,7 +183,7 @@ void ScreenGameplay::Init() ASSERT( pCourse ); /* Increment the play count. */ - if( !m_bDemonstration ) + if( !GAMESTATE->m_bDemonstrationOrJukebox ) { FOREACH_EnabledPlayer(p) PROFILEMAN->IncrementCoursePlayCount( pCourse, GAMESTATE->m_pCurTrail[p], p ); @@ -306,7 +305,7 @@ void ScreenGameplay::Init() m_sprStaticBackground.SetDrawOrder( DRAW_ORDER_BEFORE_EVERYTHING ); // behind everything else this->AddChild(&m_sprStaticBackground); - if( !m_bDemonstration ) // only load if we're going to use it + if( !GAMESTATE->m_bDemonstrationOrJukebox ) // only load if we're going to use it { m_Toasty.Load( THEME->GetPathB(m_sName,"toasty") ); this->AddChild( &m_Toasty ); @@ -642,7 +641,7 @@ void ScreenGameplay::Init() m_textAutoPlay.LoadFromFont( THEME->GetPathF(m_sName,"autoplay") ); m_textAutoPlay.SetName( "AutoPlay" ); SET_XY( m_textAutoPlay ); - if( !m_bDemonstration ) // only load if we're not in demonstration of jukebox + if( !GAMESTATE->m_bDemonstrationOrJukebox ) // only load if we're not in demonstration or jukebox this->AddChild( &m_textAutoPlay ); UpdateAutoPlayText(); @@ -667,7 +666,7 @@ void ScreenGameplay::Init() } - if( !m_bDemonstration ) // only load if we're going to use it + if( !GAMESTATE->m_bDemonstrationOrJukebox ) // only load if we're going to use it { m_Ready.Load( THEME->GetPathB(m_sName,"ready") ); this->AddChild( &m_Ready ); @@ -743,7 +742,7 @@ void ScreenGameplay::Init() this->SortByDrawOrder(); - if( !m_bDemonstration ) // only load if we're going to use it + if( !GAMESTATE->m_bDemonstrationOrJukebox ) // only load if we're going to use it { m_soundAssistTick.Load( THEME->GetPathS(m_sName,"assist tick"), true ); @@ -935,7 +934,7 @@ void ScreenGameplay::LoadNextSong() /* Increment the play count even if the player fails. (It's still popular, * even if the people playing it aren't good at it.) */ - if( !m_bDemonstration ) + if( !GAMESTATE->m_bDemonstrationOrJukebox ) PROFILEMAN->IncrementStepsPlayCount( pSong, pSteps, p ); m_textPlayerOptions[p].SetText( GAMESTATE->m_pPlayerState[p]->m_PlayerOptions.GetString() ); @@ -948,7 +947,7 @@ void ScreenGameplay::LoadNextSong() if( GAMESTATE->m_SongOptions.m_LifeType==SongOptions::LIFE_BATTERY && g_CurStageStats.m_player[p].bFailed ) // already failed ShowOniGameOver(p); - if( GAMESTATE->m_SongOptions.m_LifeType==SongOptions::LIFE_BAR && GAMESTATE->m_PlayMode == PLAY_MODE_REGULAR && !PREFSMAN->m_bEventMode && !m_bDemonstration) + if( GAMESTATE->m_SongOptions.m_LifeType==SongOptions::LIFE_BAR && GAMESTATE->m_PlayMode == PLAY_MODE_REGULAR && !PREFSMAN->m_bEventMode && !GAMESTATE->m_bDemonstrationOrJukebox) { m_pLifeMeter[p]->UpdateNonstopLifebar( GAMESTATE->GetStageIndex(), @@ -974,7 +973,7 @@ void ScreenGameplay::LoadNextSong() if( m_pSecondaryScoreKeeper[p] ) m_pSecondaryScoreKeeper[p]->OnNextSong( GAMESTATE->GetCourseSongIndex(), GAMESTATE->m_pCurSteps[p], &m_Player[p].m_NoteData ); - if( m_bDemonstration ) + if( GAMESTATE->m_bDemonstrationOrJukebox ) { GAMESTATE->m_pPlayerState[p]->m_PlayerController = PC_CPU; GAMESTATE->m_pPlayerState[p]->m_iCpuSkill = 5; @@ -1065,7 +1064,7 @@ void ScreenGameplay::LoadNextSong() { /* BeginnerHelper disabled/failed to load. */ m_Background.LoadFromSong( GAMESTATE->m_pCurSong ); - if( !m_bDemonstration ) + if( !GAMESTATE->m_bDemonstrationOrJukebox ) { /* This will fade from a preset brightness to the actual brightness (based * on prefs and "cover"). The preset brightness may be 0 (to fade from @@ -1254,7 +1253,7 @@ void ScreenGameplay::Update( float fDeltaTime ) // // Get the transitions rolling // - if( m_bDemonstration ) + if( GAMESTATE->m_bDemonstrationOrJukebox ) { StartPlayingSong( 0, 0 ); // *kick* (no transitions) } diff --git a/stepmania/src/ScreenGameplay.h b/stepmania/src/ScreenGameplay.h index 682ee19488..bdb4ef8d7d 100644 --- a/stepmania/src/ScreenGameplay.h +++ b/stepmania/src/ScreenGameplay.h @@ -55,7 +55,7 @@ class LyricsLoader; class ScreenGameplay : public Screen { public: - ScreenGameplay( CString sName, bool bDemonstration = false ); + ScreenGameplay( CString sName ); virtual void Init(); virtual ~ScreenGameplay(); @@ -177,7 +177,6 @@ protected: RageSound m_soundBattleTrickLevel3; bool m_bZeroDeltaOnNextUpdate; - bool m_bDemonstration; RageSound m_soundAssistTick; RageSound *m_pSoundMusic; diff --git a/stepmania/src/ScreenJukebox.cpp b/stepmania/src/ScreenJukebox.cpp index 2bb81894b7..09e5541510 100644 --- a/stepmania/src/ScreenJukebox.cpp +++ b/stepmania/src/ScreenJukebox.cpp @@ -107,13 +107,19 @@ bool ScreenJukebox::SetSong( bool bDemonstration ) return false; } -bool ScreenJukebox::PrepareForJukebox( bool bDemonstration ) // always return true. +ScreenJukebox::ScreenJukebox( CString sName ) : ScreenGameplay( "ScreenGameplay" ) +{ + LOG->Trace( "ScreenJukebox::ScreenJukebox()" ); + m_bDemonstration = false; +} + +void ScreenJukebox::Init() { // ScreeJukeboxMenu must set this ASSERT( GAMESTATE->m_pCurStyle ); GAMESTATE->m_PlayMode = PLAY_MODE_REGULAR; - SetSong( bDemonstration ); + SetSong( m_bDemonstration ); // ASSERT( GAMESTATE->m_pCurSong ); @@ -161,16 +167,7 @@ bool ScreenJukebox::PrepareForJukebox( bool bDemonstration ) // always return t GAMESTATE->m_bDemonstrationOrJukebox = true; - return true; -} - -ScreenJukebox::ScreenJukebox( CString sName, bool bDemonstration ) : ScreenGameplay( "ScreenGameplay", PrepareForJukebox(bDemonstration) ) // this is a hack to get some code to execute before the ScreenGameplay constructor -{ - LOG->Trace( "ScreenJukebox::ScreenJukebox()" ); -} - -void ScreenJukebox::Init() -{ + /* Now that we've set up, init the base class. */ ScreenGameplay::Init(); if( GAMESTATE->m_pCurSong == NULL ) // we didn't find a song. diff --git a/stepmania/src/ScreenJukebox.h b/stepmania/src/ScreenJukebox.h index 23bd0ac86a..c968d7c481 100644 --- a/stepmania/src/ScreenJukebox.h +++ b/stepmania/src/ScreenJukebox.h @@ -10,7 +10,7 @@ class ScreenJukebox : public ScreenGameplay { public: - ScreenJukebox( CString sName, bool bDemonstration = false ); + ScreenJukebox( CString sName ); virtual void Init(); virtual void Input( const DeviceInput& DeviceI, const InputEventType type, const GameInput &GameI, const MenuInput &MenuI, const StyleInput &StyleI ); @@ -20,10 +20,9 @@ public: static bool SetSong( bool bDemonstration ); protected: + bool m_bDemonstration; Transition m_In; Transition m_Out; - - static bool PrepareForJukebox( bool bDemonstration ); }; #endif