From 00285ab5eb32ed45c9bfcbdb481a6f69d61d6157 Mon Sep 17 00:00:00 2001 From: Glenn Maynard Date: Sat, 17 Mar 2007 06:35:58 +0000 Subject: [PATCH] allow opening options menu while choosing a song --- stepmania/src/OptionsList.cpp | 6 ++ stepmania/src/OptionsList.h | 3 + stepmania/src/ScreenSelectMusic.cpp | 85 ++++++++++++++++------------- stepmania/src/ScreenSelectMusic.h | 3 +- 4 files changed, 59 insertions(+), 38 deletions(-) diff --git a/stepmania/src/OptionsList.cpp b/stepmania/src/OptionsList.cpp index 3455853dc0..7e30272453 100644 --- a/stepmania/src/OptionsList.cpp +++ b/stepmania/src/OptionsList.cpp @@ -127,6 +127,8 @@ void OptionsList::Load( RString sType, PlayerNumber pn ) { m_pn = pn; + m_Codes.Load( sType ); + m_Cursor.Load( THEME->GetPathG(sType, "cursor") ); m_Cursor->SetName( "Cursor" ); ActorUtil::LoadAllCommands( *m_Cursor, sType ); @@ -263,6 +265,10 @@ void OptionsList::SwitchMenu( int iDir ) void OptionsList::Input( const InputEventPlus &input ) { + Message msg(""); + if( m_Codes.InputMessage(input, msg) ) + this->HandleMessage( msg ); + if( input.type == IET_RELEASE ) return; if( input.type != IET_FIRST_PRESS ) diff --git a/stepmania/src/OptionsList.h b/stepmania/src/OptionsList.h index aa22929d29..3ce2ddacff 100644 --- a/stepmania/src/OptionsList.h +++ b/stepmania/src/OptionsList.h @@ -8,6 +8,7 @@ #include "OptionRowHandler.h" #include "BitmapText.h" #include "OptionsCursor.h" +#include "CodeSet.h" class OptionListRow: public ActorFrame { @@ -62,6 +63,8 @@ private: void ExportRow( RString sRow ); bool RowIsMenusOnly( RString sRow ) const; + InputQueueCodeSet m_Codes; + vector m_asLoadedRows; map m_Rows; map > m_bSelections; diff --git a/stepmania/src/ScreenSelectMusic.cpp b/stepmania/src/ScreenSelectMusic.cpp index be10c89d9c..d547366d9f 100644 --- a/stepmania/src/ScreenSelectMusic.cpp +++ b/stepmania/src/ScreenSelectMusic.cpp @@ -82,7 +82,10 @@ void ScreenSelectMusic::Init() GAMESTATE->FinishStage(); FOREACH_ENUM( PlayerNumber, p ) + { m_bSelectIsDown[p] = false; // used by UpdateSelectButton + m_bAcceptSelectRelease[p] = false; + } ScreenWithMenuElements::Init(); @@ -386,7 +389,7 @@ void ScreenSelectMusic::Input( const InputEventPlus &input ) // handle options list input - if( USE_OPTIONS_LIST && m_SelectionState == SelectionState_SelectingSteps ) + if( USE_OPTIONS_LIST ) { PlayerNumber pn = input.pn; if( pn != PLAYER_INVALID ) @@ -402,27 +405,21 @@ void ScreenSelectMusic::Input( const InputEventPlus &input ) } else { - if( input.type == IET_FIRST_PRESS && input.MenuI == GAME_BUTTON_SELECT ) - { + if( input.type == IET_RELEASE && input.MenuI == GAME_BUTTON_SELECT && m_bAcceptSelectRelease[pn] ) OpenOptionsList( pn ); - return; - } } } } + if( input.MenuI == MENU_BUTTON_SELECT && input.type != IET_REPEAT ) + m_bAcceptSelectRelease[input.pn] = (input.type == IET_FIRST_PRESS); - UpdateSelectButton(); + if( SELECT_MENU_AVAILABLE && input.MenuI == MENU_BUTTON_SELECT && input.type != IET_REPEAT ) + UpdateSelectButton( input.pn, input.type == IET_FIRST_PRESS ); - if( input.MenuI == MENU_BUTTON_SELECT ) - { - if( input.type == IET_FIRST_PRESS ) - m_MusicWheel.Move( 0 ); - return; - } - if( SELECT_MENU_AVAILABLE && INPUTMAPPER->IsBeingPressed( MENU_BUTTON_SELECT, input.pn ) ) + if( SELECT_MENU_AVAILABLE && m_bSelectIsDown[input.pn] ) { if( input.type == IET_FIRST_PRESS ) { @@ -430,23 +427,26 @@ void ScreenSelectMusic::Input( const InputEventPlus &input ) { case MENU_BUTTON_LEFT: ChangeDifficulty( input.pn, -1 ); - return; + m_bAcceptSelectRelease[input.pn] = false; + break; case MENU_BUTTON_RIGHT: ChangeDifficulty( input.pn, +1 ); - return; + m_bAcceptSelectRelease[input.pn] = false; + break; case MENU_BUTTON_START: + m_bAcceptSelectRelease[input.pn] = false; if( MODE_MENU_AVAILABLE ) m_MusicWheel.NextSort(); else m_soundLocked.Play(); - return; + break; } } - return; +// return; } if( m_SelectionState == SelectionState_SelectingSong && - (input.MenuI == m_GameButtonNextSong || input.MenuI == m_GameButtonPreviousSong) ) + (input.MenuI == m_GameButtonNextSong || input.MenuI == m_GameButtonPreviousSong || input.MenuI == MENU_BUTTON_SELECT) ) { { /* If we're rouletting, hands off. */ @@ -457,6 +457,11 @@ void ScreenSelectMusic::Input( const InputEventPlus &input ) bool bRightIsDown = false; FOREACH_HumanPlayer( p ) { + if( m_OptionsList[p].IsOpened() ) + continue; + if( SELECT_MENU_AVAILABLE && INPUTMAPPER->IsBeingPressed(MENU_BUTTON_SELECT, p) ) + continue; + bLeftIsDown |= INPUTMAPPER->IsBeingPressed( m_GameButtonPreviousSong, p ); bRightIsDown |= INPUTMAPPER->IsBeingPressed( m_GameButtonNextSong, p ); } @@ -577,21 +582,17 @@ bool ScreenSelectMusic::DetectCodes( const InputEventPlus &input ) return true; } -void ScreenSelectMusic::UpdateSelectButton() +void ScreenSelectMusic::UpdateSelectButton( PlayerNumber pn, bool bSelectIsDown ) { - FOREACH_HumanPlayer( p ) - { - bool bSelectIsDown = INPUTMAPPER->IsBeingPressed( MENU_BUTTON_SELECT, p ); - if( !SELECT_MENU_AVAILABLE || !CanChangeSong() ) - bSelectIsDown = false; + if( !SELECT_MENU_AVAILABLE || !CanChangeSong() ) + bSelectIsDown = false; - if( m_bSelectIsDown[p] != bSelectIsDown ) - { - m_bSelectIsDown[p] = bSelectIsDown; - Message msg( bSelectIsDown ? "SelectMenuOpened" : "SelectMenuClosed" ); - msg.SetParam( "Player", p ); - MESSAGEMAN->Broadcast( msg ); - } + if( m_bSelectIsDown[pn] != bSelectIsDown ) + { + m_bSelectIsDown[pn] = bSelectIsDown; + Message msg( bSelectIsDown ? "SelectMenuOpened" : "SelectMenuClosed" ); + msg.SetParam( "Player", pn ); + MESSAGEMAN->Broadcast( msg ); } } @@ -678,10 +679,6 @@ void ScreenSelectMusic::HandleScreenMessage( const ScreenMessage SM ) if( m_MusicWheel.GetSelectedSong() == NULL && m_MusicWheel.GetSelectedCourse() == NULL ) m_MusicWheel.StartRandom(); - FOREACH_ENUM( PlayerNumber, p ) - if( m_OptionsList[p].IsOpened() ) - CloseOptionsList(p); - MenuStart( InputEventPlus() ); } return; @@ -832,6 +829,16 @@ void ScreenSelectMusic::MenuStart( const InputEventPlus &input ) break; } + FOREACH_ENUM( PlayerNumber, p ) + { + if( !TWO_PART_SELECTION || m_SelectionState == SelectionState_SelectingSteps ) + { + if( m_OptionsList[p].IsOpened() ) + CloseOptionsList(p); + } + UpdateSelectButton( p, false ); + } + m_SelectionState = GetNextSelectionState(); m_soundStart.Play(); @@ -901,8 +908,12 @@ void ScreenSelectMusic::MenuStart( const InputEventPlus &input ) } else // !finalized. Set the timer for selecting difficulty and mods. { - m_MenuTimer->SetSeconds( 25 ); - m_MenuTimer->Start(); + float fSeconds = m_MenuTimer->GetSeconds(); + if( fSeconds < 10 ) + { + m_MenuTimer->SetSeconds( 10 ); + m_MenuTimer->Start(); + } } } diff --git a/stepmania/src/ScreenSelectMusic.h b/stepmania/src/ScreenSelectMusic.h index d068a87521..086ccf837c 100644 --- a/stepmania/src/ScreenSelectMusic.h +++ b/stepmania/src/ScreenSelectMusic.h @@ -45,7 +45,7 @@ public: protected: virtual bool GenericTweenOn() const { return true; } virtual bool GenericTweenOff() const { return true; } - void UpdateSelectButton(); + void UpdateSelectButton( PlayerNumber pn, bool bBeingPressed ); void ChangeDifficulty( PlayerNumber pn, int dir ); @@ -118,6 +118,7 @@ protected: float m_fSampleStartSeconds, m_fSampleLengthSeconds; bool m_bAllowOptionsMenu, m_bAllowOptionsMenuRepeat; bool m_bSelectIsDown[NUM_PLAYERS]; + bool m_bAcceptSelectRelease[NUM_PLAYERS]; RageSound m_soundStart; RageSound m_soundDifficultyEasier;