From 1fc4b23cfa8d8199fc8c825efb43c9cdd0d8a1b8 Mon Sep 17 00:00:00 2001 From: Steve Checkoway Date: Fri, 15 Sep 2006 03:09:23 +0000 Subject: [PATCH] Factor out code detection and simplify. The "Tricky" comment was out of date. --- stepmania/src/ScreenSelectMusic.cpp | 57 +++++++++++------------------ stepmania/src/ScreenSelectMusic.h | 1 + 2 files changed, 22 insertions(+), 36 deletions(-) diff --git a/stepmania/src/ScreenSelectMusic.cpp b/stepmania/src/ScreenSelectMusic.cpp index e16228cd57..0745c0234c 100644 --- a/stepmania/src/ScreenSelectMusic.cpp +++ b/stepmania/src/ScreenSelectMusic.cpp @@ -429,71 +429,54 @@ void ScreenSelectMusic::Input( const InputEventPlus &input ) break; } - // TRICKY: Do default processing of MenuLeft and MenuRight before detecting - // codes. Do default processing of Start AFTER detecting codes. This gives us a - // change to return if Start is part of a code because we don't want to process - // Start as "move to the next screen" if it was just part of a code. - // XXX: Why are we doing this here? Menu(Up|Down|Left|Right) don't do anything. -- Steve - switch( input.MenuI ) - { - case MENU_BUTTON_UP: this->MenuUp( input ); break; - case MENU_BUTTON_DOWN: this->MenuDown( input ); break; - case MENU_BUTTON_LEFT: this->MenuLeft( input ); break; - case MENU_BUTTON_RIGHT: this->MenuRight( input ); break; - // Screen contains the delayed back logic. - case MENU_BUTTON_BACK: Screen::Input( input ); break; - // Do the default handler for Start after detecting codes. -// case MENU_BUTTON_START: this->MenuStart( input ); break; - case MENU_BUTTON_COIN: this->MenuCoin( input ); break; - } - - - if( input.type != IET_FIRST_PRESS ) + if( input.type == IET_FIRST_PRESS && DetectCodes(input) ) return; + Screen::Input( input ); +} + +bool ScreenSelectMusic::DetectCodes( const InputEventPlus &input ) +{ if( CodeDetector::EnteredEasierDifficulty(input.GameI.controller) ) { if( GAMESTATE->IsAnExtraStage() ) m_soundLocked.Play(); else - ChangeDifficulty( pn, -1 ); - return; + ChangeDifficulty( input.pn, -1 ); } - if( CodeDetector::EnteredHarderDifficulty(input.GameI.controller) ) + else if( CodeDetector::EnteredHarderDifficulty(input.GameI.controller) ) { if( GAMESTATE->IsAnExtraStage() ) m_soundLocked.Play(); else - ChangeDifficulty( pn, +1 ); - return; + ChangeDifficulty( input.pn, +1 ); } - if( CodeDetector::EnteredModeMenu(input.GameI.controller) ) + else if( CodeDetector::EnteredModeMenu(input.GameI.controller) ) { if( MODE_MENU_AVAILABLE ) m_MusicWheel.ChangeSort( SORT_MODE_MENU ); else m_soundLocked.Play(); - return; } - if( CodeDetector::EnteredNextSort(input.GameI.controller) ) + else if( CodeDetector::EnteredNextSort(input.GameI.controller) ) { if( ( GAMESTATE->IsExtraStage() && !PREFSMAN->m_bPickExtraStage ) || GAMESTATE->IsExtraStage2() ) m_soundLocked.Play(); else m_MusicWheel.NextSort(); - return; } - if( !GAMESTATE->IsExtraStage() && !GAMESTATE->IsExtraStage2() && CodeDetector::DetectAndAdjustMusicOptions(input.GameI.controller) ) + else if( !GAMESTATE->IsExtraStage() && !GAMESTATE->IsExtraStage2() && CodeDetector::DetectAndAdjustMusicOptions(input.GameI.controller) ) { m_soundOptionsChange.Play(); - MESSAGEMAN->Broadcast( ssprintf("PlayerOptionsChangedP%i", pn+1) ); + MESSAGEMAN->Broadcast( ssprintf("PlayerOptionsChangedP%i", input.pn+1) ); MESSAGEMAN->Broadcast( "SongOptionsChanged" ); - return; } - - if( input.MenuI == MENU_BUTTON_START ) - MenuStart( input ); -} + else + { + return false; + } + return true; +} void ScreenSelectMusic::UpdateSelectButton() { @@ -646,6 +629,8 @@ void ScreenSelectMusic::HandleScreenMessage( const ScreenMessage SM ) void ScreenSelectMusic::MenuStart( const InputEventPlus &input ) { + if( input.type != IET_FIRST_PRESS ) + return; /* If false, we don't have a selection just yet. */ if( !m_MusicWheel.Select() ) return; diff --git a/stepmania/src/ScreenSelectMusic.h b/stepmania/src/ScreenSelectMusic.h index 72db54f8c5..afd70e94c9 100644 --- a/stepmania/src/ScreenSelectMusic.h +++ b/stepmania/src/ScreenSelectMusic.h @@ -53,6 +53,7 @@ protected: void AfterMusicChange(); void CheckBackgroundRequests( bool bForce ); + bool DetectCodes( const InputEventPlus &input ); vector m_vpSteps; vector m_vpTrails;