diff --git a/stepmania/Themes/default/metrics.ini b/stepmania/Themes/default/metrics.ini index 69d030e859..402881672e 100644 --- a/stepmania/Themes/default/metrics.ini +++ b/stepmania/Themes/default/metrics.ini @@ -3667,6 +3667,7 @@ NumMisses=6 [ScreenDemonstration] SecondsToShow=30 NextScreen=ScreenRanking +DifficultiesToShow=easy,medium [ScreenNameEntry] TimerX=320 diff --git a/stepmania/src/ScreenDemonstration.cpp b/stepmania/src/ScreenDemonstration.cpp index 8b16b6d625..21ef7ffbe9 100644 --- a/stepmania/src/ScreenDemonstration.cpp +++ b/stepmania/src/ScreenDemonstration.cpp @@ -25,7 +25,6 @@ #define SECONDS_TO_SHOW THEME->GetMetricF("ScreenDemonstration","SecondsToShow") #define NEXT_SCREEN THEME->GetMetric("ScreenDemonstration","NextScreen") - const ScreenMessage SM_NotesEnded = ScreenMessage(SM_User+10); // MUST be same as in ScreenGameplay diff --git a/stepmania/src/ScreenJukebox.cpp b/stepmania/src/ScreenJukebox.cpp index 5e976057bd..db9ed86b7b 100644 --- a/stepmania/src/ScreenJukebox.cpp +++ b/stepmania/src/ScreenJukebox.cpp @@ -21,12 +21,15 @@ #include "RageSounds.h" #include "Steps.h" #include "ScreenAttract.h" +#include "RageUtil.h" +// HACK: This belongs in ScreenDemonstration +#define DIFFICULTIES_TO_SHOW THEME->GetMetric ("ScreenDemonstration","DifficultiesToShow") const ScreenMessage SM_NotesEnded = ScreenMessage(SM_User+10); // MUST be same as in ScreenGameplay -bool ScreenJukebox::SetSong() +bool ScreenJukebox::SetSong( bool bDemonstration ) { vector vSongs; if( GAMESTATE->m_sPreferredGroup == GROUP_ALL_MUSIC ) @@ -34,10 +37,38 @@ bool ScreenJukebox::SetSong() else SONGMAN->GetSongs( vSongs, GAMESTATE->m_sPreferredGroup ); + // + // Calculate what difficulties to show + // + CStringArray asBits; + vector vDifficultiesToShow; + if( bDemonstration ) + { + split( DIFFICULTIES_TO_SHOW, ",", asBits ); + for( int i=0; im_PreferredDifficulty[PLAYER_1] != DIFFICULTY_INVALID ) + { + vDifficultiesToShow.push_back( GAMESTATE->m_PreferredDifficulty[PLAYER_1] ); + } + else + { + FOREACH_Difficulty( dc ) + vDifficultiesToShow.push_back( dc ); + } + } + // // Search for a Song and Steps to play during the demo // - for( int i=0; i<600; i++ ) + for( int i=0; i<1000; i++ ) { if( vSongs.size() == 0 ) return true; @@ -50,17 +81,8 @@ bool ScreenJukebox::SetSong() if( pSong->NeverDisplayed() ) continue; // skip - Difficulty dc = GAMESTATE->m_PreferredDifficulty[PLAYER_1]; - Steps* pNotes = NULL; - if( dc != DIFFICULTY_INVALID ) - pNotes = pSong->GetStepsByDifficulty( GAMESTATE->GetCurrentStyleDef()->m_StepsType, GAMESTATE->m_PreferredDifficulty[PLAYER_1] ); - else // "all difficulties" - { - vector vNotes; - pSong->GetSteps( vNotes, GAMESTATE->GetCurrentStyleDef()->m_StepsType ); - if( vNotes.size() > 0 ) - pNotes = vNotes[rand()%vNotes.size()]; - } + Difficulty dc = vDifficultiesToShow[ rand()%vDifficultiesToShow.size() ]; + Steps* pNotes = pSong->GetStepsByDifficulty( GAMESTATE->GetCurrentStyleDef()->m_StepsType, dc ); if( pNotes == NULL ) continue; // skip @@ -79,13 +101,13 @@ bool ScreenJukebox::SetSong() return false; } -bool ScreenJukebox::PrepareForJukebox() // always return true. +bool ScreenJukebox::PrepareForJukebox( bool bDemonstration ) // always return true. { // ScreeJukeboxMenu must set this ASSERT( GAMESTATE->m_CurStyle != STYLE_INVALID ); GAMESTATE->m_PlayMode = PLAY_MODE_ARCADE; - SetSong(); + SetSong( bDemonstration ); // ASSERT( GAMESTATE->m_pCurSong ); @@ -136,7 +158,7 @@ bool ScreenJukebox::PrepareForJukebox() // always return true. return true; } -ScreenJukebox::ScreenJukebox( CString sName, bool bDemonstration ) : ScreenGameplay( "ScreenGameplay", PrepareForJukebox() ) // this is a hack to get some code to execute before the ScreenGameplay constructor +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()" ); diff --git a/stepmania/src/ScreenJukebox.h b/stepmania/src/ScreenJukebox.h index e1df398e48..08483bd178 100644 --- a/stepmania/src/ScreenJukebox.h +++ b/stepmania/src/ScreenJukebox.h @@ -18,19 +18,19 @@ class ScreenJukebox : public ScreenGameplay { public: - ScreenJukebox( CString sName, bool bDemonstration = false ); + ScreenJukebox( CString sName, bool bDemonstration = false ); virtual void Input( const DeviceInput& DeviceI, const InputEventType type, const GameInput &GameI, const MenuInput &MenuI, const StyleInput &StyleI ); virtual void HandleScreenMessage( const ScreenMessage SM ); /* Hack: public for JukeboxMenu */ - static bool SetSong(); + static bool SetSong( bool bDemonstration ); protected: Transition m_In; Transition m_Out; - static bool PrepareForJukebox(); + static bool PrepareForJukebox( bool bDemonstration ); }; #endif diff --git a/stepmania/src/ScreenJukeboxMenu.cpp b/stepmania/src/ScreenJukeboxMenu.cpp index b3ed3ee49c..d6cd3ab966 100644 --- a/stepmania/src/ScreenJukeboxMenu.cpp +++ b/stepmania/src/ScreenJukeboxMenu.cpp @@ -133,7 +133,7 @@ void ScreenJukeboxMenu::MenuStart( PlayerNumber pn ) GAMESTATE->m_PreferredDifficulty[p] = dc; GAMESTATE->m_bJukeboxUsesModifiers = bModifiers; - if(!ScreenJukebox::SetSong()) + if( !ScreenJukebox::SetSong(false) ) { /* No songs are available for the selected style, group, and difficulty. */