From ec23a019e29bb9447b31da76de6293aca9765821 Mon Sep 17 00:00:00 2001 From: "Devin J. Pohly" Date: Sun, 9 Jun 2013 17:22:43 -0400 Subject: [PATCH] Fix ScreenJukebox when there are no matching steps Also makes minor tweaks to the SetSong function and adds a SystemMessage to display that no steps have been found. When this happens, the ScreenJukebox will return to its PrevScreen. --- Themes/_fallback/Languages/en.ini | 3 +++ Themes/_fallback/metrics.ini | 2 ++ src/ScreenJukebox.cpp | 11 +++++++---- src/ScreenJukebox.h | 3 +-- 4 files changed, 13 insertions(+), 6 deletions(-) diff --git a/Themes/_fallback/Languages/en.ini b/Themes/_fallback/Languages/en.ini index 83fe6e3ed9..3b4617ab10 100644 --- a/Themes/_fallback/Languages/en.ini +++ b/Themes/_fallback/Languages/en.ini @@ -1494,6 +1494,9 @@ PlayMode_Battle instructions= Hold instructions=Hold arrows are arrows that you must keep held down. A successfully held down hold arrow will give you an OK while a missed hold arrow will give you an NG. Mine instructions=Mines are explosive and should be avoided at all costs as they will take life off of your meter. They will trigger if you keep your foot held down as they pass. +[ScreenJukebox] +NoMatchingSteps=No matching steps found. + [ScreenLegal] Warning=Warning BodyText=The StepMania program source code is licensed under a permissive open-source license.\n\nThe StepMania name and logos are protected by Trademark law.\n\nThe StepMania default theme SOUNDS ARE SEPARATELY OWNED BY THE AUTHORS. ALL OTHER THEME COMPONENTS ARE LICENSED UNDER THE STEPMANIA LICENSE.\n\nSee license.txt for details. diff --git a/Themes/_fallback/metrics.ini b/Themes/_fallback/metrics.ini index 2b240d46e1..7856ce0def 100644 --- a/Themes/_fallback/metrics.ini +++ b/Themes/_fallback/metrics.ini @@ -4463,6 +4463,7 @@ NumMisses=6 Fallback="ScreenGameplay" Class="ScreenDemonstration" NextScreen=Branch.NoiseTrigger() +PrevScreen=Branch.NoiseTrigger() StartScreen=Branch.TitleMenu() PlayMusic=false SecondsToShow=60 @@ -4516,6 +4517,7 @@ Line4="lua,OptionsRandomJukebox()" Class="ScreenJukebox" Fallback="ScreenGameplay" NextScreen="ScreenJukebox" +PrevScreen="ScreenJukeboxMenu" StartScreen="ScreenTitleMenu" LightsMode="LightsMode_Demonstration" ShowCourseModifiersProbability=0 diff --git a/src/ScreenJukebox.cpp b/src/ScreenJukebox.cpp index 9c12a40642..f07e30c26f 100644 --- a/src/ScreenJukebox.cpp +++ b/src/ScreenJukebox.cpp @@ -41,6 +41,10 @@ void ScreenJukebox::SetSong() if ( vSongs.size() == 0 ) vSongs = SONGMAN->GetSongs( GAMESTATE->m_sPreferredSongGroup ); + // Still nothing? + if( vSongs.size() == 0 ) + return; + // Calculate what difficulties to show vector vDifficultiesToShow; @@ -68,9 +72,6 @@ void ScreenJukebox::SetSong() // Search for a Song and Steps to play during the demo. for( int i=0; i<1000; i++ ) { - if( vSongs.size() == 0 ) - return; - Song* pSong = vSongs[RandomInt(vSongs.size())]; ASSERT( pSong != NULL ); @@ -169,6 +170,7 @@ ScreenJukebox::ScreenJukebox() m_pCourseEntry = NULL; } +static LocalizedString NO_MATCHING_STEPS("ScreenJukebox", "NoMatchingSteps"); void ScreenJukebox::Init() { // ScreenJukeboxMenu must set this @@ -228,7 +230,8 @@ void ScreenJukebox::Init() if( GAMESTATE->m_pCurSong == NULL ) // we didn't find a song. { - this->PostScreenMessage( SM_GoToNextScreen, 0 ); // Abort demonstration. + SCREENMAN->SystemMessage( NO_MATCHING_STEPS ); + this->PostScreenMessage( SM_GoToPrevScreen, 0 ); // Abort demonstration. return; } diff --git a/src/ScreenJukebox.h b/src/ScreenJukebox.h index 328c41a2d4..298fccc8ba 100644 --- a/src/ScreenJukebox.h +++ b/src/ScreenJukebox.h @@ -14,13 +14,12 @@ public: virtual bool Input( const InputEventPlus &input ); virtual void HandleScreenMessage( const ScreenMessage SM ); - void SetSong(); - protected: bool m_bDemonstration; const CourseEntry *m_pCourseEntry; + void SetSong(); virtual void InitSongQueues(); };