From 446c8cb5ae3264a4dcec839a420f1c6c18b10f07 Mon Sep 17 00:00:00 2001 From: Chris Danford Date: Mon, 4 Apr 2005 02:34:56 +0000 Subject: [PATCH] add AllowRepeatingInput --- stepmania/Themes/default/metrics.ini | 2 + stepmania/src/ScreenSelectMaster.cpp | 25 +++++-- stepmania/src/ScreenSelectMaster.h | 9 +-- stepmania/src/ScreenTitleMenu.cpp | 100 +++++++++++++-------------- 4 files changed, 78 insertions(+), 58 deletions(-) diff --git a/stepmania/Themes/default/metrics.ini b/stepmania/Themes/default/metrics.ini index 2665331f42..79bf7f1c32 100644 --- a/stepmania/Themes/default/metrics.ini +++ b/stepmania/Themes/default/metrics.ini @@ -63,6 +63,7 @@ ChoiceNames=1,2,3,4,5,6,7 DefaultChoice=1 NumChoicesOnPage1=100 WrapCursor=1 +AllowRepeatingInput=1 Choice1=@"ApplyDefaultOptions;screen,"..ScreenCautionBranch() Choice2=screen,ScreenSelectGame Choice3=screen,ScreenOptionsMenu @@ -2924,6 +2925,7 @@ AttackDurationSeconds=10 Fallback=ScreenSelect Class=ScreenSelectMaster WrapCursor=0 +AllowRepeatingInput=0 PreSwitchPageSeconds=0 PostSwitchPageSeconds=0 ScrollerSecondsPerItem=0 diff --git a/stepmania/src/ScreenSelectMaster.cpp b/stepmania/src/ScreenSelectMaster.cpp index a148f9ed40..8a0f5575d7 100644 --- a/stepmania/src/ScreenSelectMaster.cpp +++ b/stepmania/src/ScreenSelectMaster.cpp @@ -38,6 +38,7 @@ ScreenSelectMaster::ScreenSelectMaster( CString sClassName ) : ScreenSelect( sCl SLEEP_AFTER_TWEEN_OFF_SECONDS(m_sName,"SleepAfterTweenOffSeconds"), OPTION_ORDER(m_sName,OPTION_ORDER_NAME,NUM_MENU_DIRS), WRAP_CURSOR(m_sName,"WrapCursor"), + ALLOW_REPEATING_INPUT(m_sName,"AllowRepeatingInput"), SHOW_SCROLLER(m_sName,"ShowScroller"), SCROLLER_SECONDS_PER_ITEM(m_sName,"ScrollerSecondsPerItem"), SCROLLER_NUM_ITEMS_TO_DRAW(m_sName,"ScrollerNumItemsToDraw"), @@ -391,34 +392,50 @@ bool ScreenSelectMaster::Move( PlayerNumber pn, MenuDir dir ) return ChangeSelection( pn, iSwitchToIndex ); } -void ScreenSelectMaster::MenuLeft( PlayerNumber pn ) +void ScreenSelectMaster::MenuLeft( PlayerNumber pn, const InputEventType type ) { if( m_fLockInputSecs > 0 || m_bChosen[pn] ) return; + if( type == IET_RELEASE ) + return; + if( !ALLOW_REPEATING_INPUT && type != IET_FIRST_PRESS ) + return; if( Move(pn, MENU_DIR_LEFT) ) m_soundChange.Play(); } -void ScreenSelectMaster::MenuRight( PlayerNumber pn ) +void ScreenSelectMaster::MenuRight( PlayerNumber pn, const InputEventType type ) { if( m_fLockInputSecs > 0 || m_bChosen[pn] ) return; + if( type == IET_RELEASE ) + return; + if( !ALLOW_REPEATING_INPUT && type != IET_FIRST_PRESS ) + return; if( Move(pn, MENU_DIR_RIGHT) ) m_soundChange.Play(); } -void ScreenSelectMaster::MenuUp( PlayerNumber pn ) +void ScreenSelectMaster::MenuUp( PlayerNumber pn, const InputEventType type ) { if( m_fLockInputSecs > 0 || m_bChosen[pn] ) return; + if( type == IET_RELEASE ) + return; + if( !ALLOW_REPEATING_INPUT && type != IET_FIRST_PRESS ) + return; if( Move(pn, MENU_DIR_UP) ) m_soundChange.Play(); } -void ScreenSelectMaster::MenuDown( PlayerNumber pn ) +void ScreenSelectMaster::MenuDown( PlayerNumber pn, const InputEventType type ) { if( m_fLockInputSecs > 0 || m_bChosen[pn] ) return; + if( type == IET_RELEASE ) + return; + if( !ALLOW_REPEATING_INPUT && type != IET_FIRST_PRESS ) + return; if( Move(pn, MENU_DIR_DOWN) ) m_soundChange.Play(); } diff --git a/stepmania/src/ScreenSelectMaster.h b/stepmania/src/ScreenSelectMaster.h index 635ba8c97f..2009f10394 100644 --- a/stepmania/src/ScreenSelectMaster.h +++ b/stepmania/src/ScreenSelectMaster.h @@ -22,10 +22,10 @@ public: virtual void Update( float fDelta ); - virtual void MenuLeft( PlayerNumber pn ); - virtual void MenuRight( PlayerNumber pn ); - virtual void MenuUp( PlayerNumber pn ); - virtual void MenuDown( PlayerNumber pn ); + virtual void MenuLeft( PlayerNumber pn, const InputEventType type ); + virtual void MenuRight( PlayerNumber pn, const InputEventType type ); + virtual void MenuUp( PlayerNumber pn, const InputEventType type ); + virtual void MenuDown( PlayerNumber pn, const InputEventType type ); virtual void MenuStart( PlayerNumber pn ); void TweenOffScreen(); void TweenOnScreen(); @@ -52,6 +52,7 @@ protected: ThemeMetric SLEEP_AFTER_TWEEN_OFF_SECONDS; ThemeMetric1D OPTION_ORDER; ThemeMetric WRAP_CURSOR; + ThemeMetric ALLOW_REPEATING_INPUT; ThemeMetric SHOW_SCROLLER; ThemeMetric SCROLLER_SECONDS_PER_ITEM; ThemeMetric SCROLLER_NUM_ITEMS_TO_DRAW; diff --git a/stepmania/src/ScreenTitleMenu.cpp b/stepmania/src/ScreenTitleMenu.cpp index 4f3120f4a6..04d0a19fbc 100644 --- a/stepmania/src/ScreenTitleMenu.cpp +++ b/stepmania/src/ScreenTitleMenu.cpp @@ -112,63 +112,63 @@ void ScreenTitleMenu::Input( const DeviceInput& DeviceI, const InputEventType ty { LOG->Trace( "ScreenTitleMenu::Input( %d-%d )", DeviceI.device, DeviceI.button ); // debugging gameport joystick problem - if( type != IET_FIRST_PRESS ) - return; - - /* If the CoinMode was changed, we need to reload this screen - * so that the right m_aGameCommands will show */ - if( ScreenAttract::ChangeCoinModeInput( DeviceI, type, GameI, MenuI, StyleI ) ) + if( type == IET_FIRST_PRESS ) { - SCREENMAN->SetNewScreen( COIN_MODE_CHANGE_SCREEN ); - return; - } + /* If the CoinMode was changed, we need to reload this screen + * so that the right m_aGameCommands will show */ + if( ScreenAttract::ChangeCoinModeInput( DeviceI, type, GameI, MenuI, StyleI ) ) + { + SCREENMAN->SetNewScreen( COIN_MODE_CHANGE_SCREEN ); + return; + } - if( m_In.IsTransitioning() || m_Cancel.IsTransitioning() ) /* not m_Out */ - return; - - // - // detect codes - // - if( CodeDetector::EnteredCode(GameI.controller,CodeDetector::CODE_NEXT_THEME) || - CodeDetector::EnteredCode(GameI.controller,CodeDetector::CODE_NEXT_THEME2) ) - { - THEME->NextTheme(); - ApplyGraphicOptions(); // update window title and icon - SCREENMAN->SystemMessage( "Theme: "+THEME->GetCurThemeName() ); - SCREENMAN->SetNewScreen( m_sName ); - TEXTUREMAN->DoDelayedDelete(); - } - if( CodeDetector::EnteredCode(GameI.controller,CodeDetector::CODE_NEXT_ANNOUNCER) || - CodeDetector::EnteredCode(GameI.controller,CodeDetector::CODE_NEXT_ANNOUNCER2) ) - { - ANNOUNCER->NextAnnouncer(); - CString sName = ANNOUNCER->GetCurAnnouncerName(); - if( sName=="" ) sName = "(none)"; - SCREENMAN->SystemMessage( "Announcer: "+sName ); - SCREENMAN->SetNewScreen( m_sName ); - } - if( CodeDetector::EnteredCode(GameI.controller,CodeDetector::CODE_NEXT_GAME) || - CodeDetector::EnteredCode(GameI.controller,CodeDetector::CODE_NEXT_GAME2) ) - { - vector vGames; - GAMEMAN->GetEnabledGames( vGames ); - ASSERT( !vGames.empty() ); - vector::iterator iter = find(vGames.begin(),vGames.end(),GAMESTATE->m_pCurGame); - ASSERT( iter != vGames.end() ); + if( m_In.IsTransitioning() || m_Cancel.IsTransitioning() ) /* not m_Out */ + return; + + // + // detect codes + // + if( CodeDetector::EnteredCode(GameI.controller,CodeDetector::CODE_NEXT_THEME) || + CodeDetector::EnteredCode(GameI.controller,CodeDetector::CODE_NEXT_THEME2) ) + { + THEME->NextTheme(); + ApplyGraphicOptions(); // update window title and icon + SCREENMAN->SystemMessage( "Theme: "+THEME->GetCurThemeName() ); + SCREENMAN->SetNewScreen( m_sName ); + TEXTUREMAN->DoDelayedDelete(); + } + if( CodeDetector::EnteredCode(GameI.controller,CodeDetector::CODE_NEXT_ANNOUNCER) || + CodeDetector::EnteredCode(GameI.controller,CodeDetector::CODE_NEXT_ANNOUNCER2) ) + { + ANNOUNCER->NextAnnouncer(); + CString sName = ANNOUNCER->GetCurAnnouncerName(); + if( sName=="" ) sName = "(none)"; + SCREENMAN->SystemMessage( "Announcer: "+sName ); + SCREENMAN->SetNewScreen( m_sName ); + } + if( CodeDetector::EnteredCode(GameI.controller,CodeDetector::CODE_NEXT_GAME) || + CodeDetector::EnteredCode(GameI.controller,CodeDetector::CODE_NEXT_GAME2) ) + { + vector vGames; + GAMEMAN->GetEnabledGames( vGames ); + ASSERT( !vGames.empty() ); + vector::iterator iter = find(vGames.begin(),vGames.end(),GAMESTATE->m_pCurGame); + ASSERT( iter != vGames.end() ); - iter++; // move to the next game + iter++; // move to the next game - // wrap - if( iter == vGames.end() ) - iter = vGames.begin(); + // wrap + if( iter == vGames.end() ) + iter = vGames.begin(); - GAMESTATE->m_pCurGame = *iter; + GAMESTATE->m_pCurGame = *iter; - /* Reload the theme if it's changed, but don't back to the initial screen. */ - ResetGame( false ); + /* Reload the theme if it's changed, but don't back to the initial screen. */ + ResetGame( false ); - SCREENMAN->SystemMessage( CString("Game: ") + GAMESTATE->GetCurrentGame()->m_szName ); - SCREENMAN->SetNewScreen( m_sName ); + SCREENMAN->SystemMessage( CString("Game: ") + GAMESTATE->GetCurrentGame()->m_szName ); + SCREENMAN->SetNewScreen( m_sName ); + } } ScreenSelectMaster::Input( DeviceI, type, GameI, MenuI, StyleI );