From 3653da83c68358672bba0ed01492a6068eda14c0 Mon Sep 17 00:00:00 2001 From: Alberto Ramos Date: Mon, 26 Jul 2010 13:09:56 -0600 Subject: [PATCH] Two part can be cancelled with menuup/down, todo: make it a metric --- Themes/_fallback/metrics.ini | 9 +++- src/MusicWheel.cpp | 63 ++++++++++++++++++++++---- src/MusicWheel.h | 2 + src/ScreenSelectMusic.cpp | 85 +++++++++++++++++++++++++++--------- 4 files changed, 129 insertions(+), 30 deletions(-) diff --git a/Themes/_fallback/metrics.ini b/Themes/_fallback/metrics.ini index 10afa7fd1c..38ab2d4d04 100644 --- a/Themes/_fallback/metrics.ini +++ b/Themes/_fallback/metrics.ini @@ -724,7 +724,10 @@ UseSectionsWithPreferredGroup=false RouletteSwitchSeconds=0.05 RouletteSlowDownSwitches=5 LockedInitialVelocity=15 - +# +OnlyShowActiveSection=true +RemindWheelPositions=true +# ScrollBarHeight=300 ScrollBarOnCommand=visible,false # @@ -1767,6 +1770,10 @@ ChangeStepsWithGameButtons=false PreviousDifficultyButton="MenuUp" NextDifficultyButton="MenuDown" # +ChangeGroupsWithGameButtoms=false +PreviousDifficultyButton="MenuUp" +NextDifficultyButton="MenuDown" +# TwoPartSelection=false TwoPartConfirmsOnly=false TwoPartTimerSeconds=15 diff --git a/src/MusicWheel.cpp b/src/MusicWheel.cpp index fa39914dd3..f0c5901dec 100644 --- a/src/MusicWheel.cpp +++ b/src/MusicWheel.cpp @@ -80,11 +80,12 @@ void MusicWheel::Load( RString sType ) SHOW_EASY_FLAG .Load(sType,"UseEasyMarkerFlag"); USE_SECTIONS_WITH_PREFERRED_GROUP .Load(sType,"UseSectionsWithPreferredGroup"); HIDE_INACTIVE_SECTIONS .Load(sType,"OnlyShowActiveSection"); + REMIND_WHEEL_POSITIONS .Load(sType,"RemindWheelPositions"); vector vsModeChoiceNames; split( MODE_MENU_CHOICE_NAMES, ",", vsModeChoiceNames ); CHOICE .Load(sType,CHOICE_NAME,vsModeChoiceNames); SECTION_COLORS .Load(sType,SECTION_COLORS_NAME,NUM_SECTION_COLORS); - + WheelBase::Load( sType ); SONGMAN->UpdateRankingCourses(); @@ -193,6 +194,20 @@ void MusicWheel::BeginScreen() SetOpenSection(""); } + if( REMIND_WHEEL_POSITIONS && HIDE_INACTIVE_SECTIONS ) + { + // store the group song index, run this also here because it forgets the current position when + // not changing the song if you came back from gameplay or your last round song (profiles) + // is not the first one in the group. + for( unsigned idx = 0 ; idx < m_viWheelPositions.size() ; idx++ ) + { + if( m_sExpandedSectionName == SONGMAN->GetSongGroupByIndex(idx) ) + { + m_viWheelPositions[idx] = m_iSelection; + } + } + } + // rebuild the WheelItems that appear on screen RebuildWheelItems(); } @@ -897,6 +912,18 @@ void MusicWheel::ChangeMusic( int iDist ) m_iSelection += iDist; wrap( m_iSelection, m_CurWheelItemData.size() ); + if( REMIND_WHEEL_POSITIONS && HIDE_INACTIVE_SECTIONS ) + { + // store the group song index + for( unsigned idx = 0 ; idx < m_viWheelPositions.size() ; idx++ ) + { + if( m_sExpandedSectionName == SONGMAN->GetSongGroupByIndex(idx) ) + { + m_viWheelPositions[idx] = m_iSelection; + } + } + } + RebuildWheelItems( iDist ); m_fPositionOffsetFromSelection += iDist; @@ -1076,6 +1103,10 @@ void MusicWheel::SetOpenSection( RString group ) //LOG->Trace( "SetOpenSection %s", group.c_str() ); m_sExpandedSectionName = group; + // wheel positions = num song groups + if ( REMIND_WHEEL_POSITIONS && HIDE_INACTIVE_SECTIONS ) + m_viWheelPositions.resize( SONGMAN->GetNumSongGroups() ); + const WheelItemBaseData *old = NULL; if( !m_CurWheelItemData.empty() ) old = GetCurWheelItemData(m_iSelection); @@ -1114,16 +1145,29 @@ void MusicWheel::SetOpenSection( RString group ) m_CurWheelItemData.push_back(&d); } - - // Try to select the item that was selected before changing groups - m_iSelection = 0; - - for( unsigned i=0; iGetSongGroupByIndex(idx) ) + { + m_iSelection = m_viWheelPositions[idx]; + } + } + } + else + { + // Try to select the item that was selected before changing groups + m_iSelection = 0; + + for( unsigned i=0; iGetNumSongGroups(); for(unsigned i = 0 ; i < iNumGroups ; i++) diff --git a/src/MusicWheel.h b/src/MusicWheel.h index f939a97991..92b3263988 100644 --- a/src/MusicWheel.h +++ b/src/MusicWheel.h @@ -87,6 +87,8 @@ protected: // sm-ssc additions: ThemeMetric USE_SECTIONS_WITH_PREFERRED_GROUP; ThemeMetric HIDE_INACTIVE_SECTIONS; + ThemeMetric REMIND_WHEEL_POSITIONS; + vector m_viWheelPositions; }; #endif diff --git a/src/ScreenSelectMusic.cpp b/src/ScreenSelectMusic.cpp index 52d4d03361..9066a51250 100644 --- a/src/ScreenSelectMusic.cpp +++ b/src/ScreenSelectMusic.cpp @@ -635,7 +635,7 @@ void ScreenSelectMusic::Input( const InputEventPlus &input ) // yeah, wanted this since a while ago... -DaisuMaster if( CHANGE_STEPS_WITH_GAME_BUTTONS ) { - // avoid anything not being just press (read: release or repeat/hold) + // Avoid any event not being first press if( input.type != IET_FIRST_PRESS ) return; @@ -657,8 +657,8 @@ void ScreenSelectMusic::Input( const InputEventPlus &input ) } } } - - // Most likely a copypasta of the previous addition -DaisuMaster + // Actually I don't like to just copy and paste code because it may go wrong + // if something goes overlooked -DaisuMaster if( CHANGE_GROUPS_WITH_GAME_BUTTONS ) { if( input.type != IET_FIRST_PRESS) @@ -672,14 +672,14 @@ void ScreenSelectMusic::Input( const InputEventPlus &input ) m_soundLocked.Play(); else { - // for real: copypasta RString sNewGroup = m_MusicWheel.JumpToPrevGroup(); m_MusicWheel.SelectSection(sNewGroup); m_MusicWheel.SetOpenSection(sNewGroup); + MESSAGEMAN->Broadcast("PreviousGroup"); AfterMusicChange(); } } - if(input.MenuI == m_GameButtonNextGroup ) + else if(input.MenuI == m_GameButtonNextGroup ) { if( GAMESTATE->IsAnExtraStageAndSelectionLocked() ) m_soundLocked.Play(); @@ -688,6 +688,7 @@ void ScreenSelectMusic::Input( const InputEventPlus &input ) RString sNewGroup = m_MusicWheel.JumpToNextGroup(); m_MusicWheel.SelectSection(sNewGroup); m_MusicWheel.SetOpenSection(sNewGroup); + MESSAGEMAN->Broadcast("NextGroup"); AfterMusicChange(); } } @@ -723,8 +724,7 @@ void ScreenSelectMusic::Input( const InputEventPlus &input ) m_MusicWheel.ChangeMusicUnlessLocked( +1 ); } } - // added an entry for difficulty change with - // gamebuttons -DaisuMaster + // added an entry for difficulty change with gamebuttons -DaisuMaster else if( input.MenuI == m_GameButtonPreviousDifficulty ) { if( GAMESTATE->IsAnExtraStageAndSelectionLocked() ) @@ -747,28 +747,70 @@ void ScreenSelectMusic::Input( const InputEventPlus &input ) ChangeSteps( input.pn, +1); } } + // added also for groupchanges + else if(input.MenuI == m_GameButtonPreviousGroup ) + { + if( GAMESTATE->IsAnExtraStageAndSelectionLocked() ) + m_soundLocked.Play(); + else + { + RString sNewGroup = m_MusicWheel.JumpToPrevGroup(); + m_MusicWheel.SelectSection(sNewGroup); + m_MusicWheel.SetOpenSection(sNewGroup); + MESSAGEMAN->Broadcast("PreviousGroup"); + AfterMusicChange(); + } + } + else if(input.MenuI == m_GameButtonNextGroup ) + { + if( GAMESTATE->IsAnExtraStageAndSelectionLocked() ) + m_soundLocked.Play(); + else + { + RString sNewGroup = m_MusicWheel.JumpToNextGroup(); + m_MusicWheel.SelectSection(sNewGroup); + m_MusicWheel.SetOpenSection(sNewGroup); + MESSAGEMAN->Broadcast("NextGroup"); + AfterMusicChange(); + } + } } } else { - if( m_SelectionState == SelectionState_SelectingSteps && - input.type == IET_FIRST_PRESS && - (input.MenuI == m_GameButtonNextSong || input.MenuI == m_GameButtonPreviousSong) && - !m_bStepsChosen[input.pn] ) + if( m_SelectionState == SelectionState_SelectingSteps && input.type == IET_FIRST_PRESS && !m_bStepsChosen[input.pn] ) { - if( input.MenuI == m_GameButtonPreviousSong ) + if( input.MenuI == m_GameButtonNextSong || input.MenuI == m_GameButtonPreviousSong ) { - if( GAMESTATE->IsAnExtraStageAndSelectionLocked() ) - m_soundLocked.Play(); - else - ChangeSteps( input.pn, -1 ); + if( input.MenuI == m_GameButtonPreviousSong ) + { + if( GAMESTATE->IsAnExtraStageAndSelectionLocked() ) + m_soundLocked.Play(); + else + ChangeSteps( input.pn, -1 ); + } + else if( input.MenuI == m_GameButtonNextSong ) + { + if( GAMESTATE->IsAnExtraStageAndSelectionLocked() ) + m_soundLocked.Play(); + else + ChangeSteps( input.pn, +1 ); + } } - else if( input.MenuI == m_GameButtonNextSong ) + else if( input.MenuI == GAME_BUTTON_MENUUP || input.MenuI == GAME_BUTTON_MENUDOWN ) // && TWO_PART_DESELECTS_WITH_MENUUPDOWN { if( GAMESTATE->IsAnExtraStageAndSelectionLocked() ) m_soundLocked.Play(); else - ChangeSteps( input.pn, +1 ); + { + Message msg("SongUnchosen"); + msg.SetParam( "Player", input.pn ); + MESSAGEMAN->Broadcast( msg ); + //unset all steps + FOREACH_ENUM( PlayerNumber , p ) + m_bStepsChosen[p] = false; + m_SelectionState = SelectionState_SelectingSong; + } } } } @@ -828,6 +870,7 @@ bool ScreenSelectMusic::DetectCodes( const InputEventPlus &input ) RString sNewGroup = m_MusicWheel.JumpToNextGroup(); m_MusicWheel.SelectSection(sNewGroup); m_MusicWheel.SetOpenSection(sNewGroup); + MESSAGEMAN->Broadcast("PreviousGroup"); AfterMusicChange(); } } @@ -840,6 +883,7 @@ bool ScreenSelectMusic::DetectCodes( const InputEventPlus &input ) RString sNewGroup = m_MusicWheel.JumpToPrevGroup(); m_MusicWheel.SelectSection(sNewGroup); m_MusicWheel.SetOpenSection(sNewGroup); + MESSAGEMAN->Broadcast("NextGroup"); AfterMusicChange(); } } @@ -1407,7 +1451,8 @@ void ScreenSelectMusic::MenuBack( const InputEventPlus &input ) { // Handle unselect song (ffff) // todo: this isn't right at all. -aj - if( m_SelectionState == SelectionState_SelectingSteps && !m_bStepsChosen[input.pn] && input.MenuI == GAME_BUTTON_BACK && input.type == IET_FIRST_PRESS ) + // temporal: deactivating this for the time being -DaisuMaster + /*if( m_SelectionState == SelectionState_SelectingSteps && !m_bStepsChosen[input.pn] && input.MenuI == GAME_BUTTON_BACK && input.type == IET_FIRST_PRESS ) { // if a player has chosen their steps already, don't unchoose song. FOREACH_HumanPlayer( p ) @@ -1419,7 +1464,7 @@ void ScreenSelectMusic::MenuBack( const InputEventPlus &input ) MESSAGEMAN->Broadcast( msg ); m_SelectionState = SelectionState_SelectingSong; return; - } + }*/ m_BackgroundLoader.Abort();