From 01137a22f5edc02b6ab77e98ddf0dce13f0db6fb Mon Sep 17 00:00:00 2001 From: AJ Kelly Date: Mon, 22 Feb 2010 00:47:31 -0600 Subject: [PATCH] Two of the CodeDetector codes referenced Frieza's old MusicBannerWheel, which is not in use anymore. I have repurposed these to be Next/Previous group, a la Pump it Up. The metrics have been changed to reflect this. Also changed an assert message to be more useful in NoteField.cpp --- Themes/_fallback/metrics.ini | 4 +- src/CodeDetector.cpp | 13 +++-- src/CodeDetector.h | 9 ++-- src/MusicWheel.cpp | 99 ++++++++++++++++++++++++++---------- src/MusicWheel.h | 3 ++ src/NoteField.cpp | 3 +- src/ScreenSelectMusic.cpp | 24 +++++++++ src/WheelBase.h | 2 +- 8 files changed, 118 insertions(+), 39 deletions(-) diff --git a/Themes/_fallback/metrics.ini b/Themes/_fallback/metrics.ini index 0d8e5cc226..6eb18abd2f 100644 --- a/Themes/_fallback/metrics.ini +++ b/Themes/_fallback/metrics.ini @@ -209,8 +209,8 @@ NextTheme2="MenuLeft,MenuLeft,MenuLeft,MenuRight,MenuRight,MenuRight,MenuLeft,Me NextAnnouncer="Left,Left,Right,Right,Left,Left,Right,Right" NextAnnouncer2="MenuLeft,MenuLeft,MenuRight,MenuRight,MenuLeft,MenuLeft,MenuRight,MenuRight" # Various. -NextBannerGroup="MenuUp,MenuRight,MenuRight" -NextBannerGroup2="MenuUp,MenuDown,MenuUp,MenuDown" +NextGroup="MenuUp,MenuRight,MenuRight" +PrevGroup="MenuUp,MenuDown,MenuUp,MenuDown" Hidden="" RandomVanish="" SaveScreenshot1="MenuLeft-MenuRight" diff --git a/src/CodeDetector.cpp b/src/CodeDetector.cpp index 5f898ddce7..e036e902c2 100644 --- a/src/CodeDetector.cpp +++ b/src/CodeDetector.cpp @@ -45,8 +45,8 @@ const char *CodeNames[] = { "NextTheme2", "NextAnnouncer", "NextAnnouncer2", - "NextBannerGroup", - "NextBannerGroup2", + "NextGroup", + "PrevGroup", "SaveScreenshot1", "SaveScreenshot2", "CancelAllPlayerOptions", @@ -76,9 +76,14 @@ void CodeDetector::RefreshCacheItems( RString sClass ) } } -bool CodeDetector::EnteredNextBannerGroup( GameController controller ) +bool CodeDetector::EnteredNextGroup( GameController controller ) { - return EnteredCode(controller,CODE_BW_NEXT_GROUP) || EnteredCode(controller,CODE_BW_NEXT_GROUP2); + return EnteredCode(controller,CODE_NEXT_GROUP); +} + +bool CodeDetector::EnteredPrevGroup( GameController controller ) +{ + return EnteredCode(controller,CODE_PREV_GROUP); } bool CodeDetector::EnteredPrevSteps( GameController controller ) diff --git a/src/CodeDetector.h b/src/CodeDetector.h index eb93577a43..58d2647cb1 100644 --- a/src/CodeDetector.h +++ b/src/CodeDetector.h @@ -39,8 +39,8 @@ enum Code { CODE_NEXT_THEME2, CODE_NEXT_ANNOUNCER, CODE_NEXT_ANNOUNCER2, - CODE_BW_NEXT_GROUP, - CODE_BW_NEXT_GROUP2, + CODE_NEXT_GROUP, + CODE_PREV_GROUP, CODE_SAVE_SCREENSHOT1, CODE_SAVE_SCREENSHOT2, CODE_CANCEL_ALL_PLAYER_OPTIONS, @@ -58,9 +58,10 @@ public: static bool EnteredModeMenu( GameController controller ); static bool DetectAndAdjustMusicOptions( GameController controller ); static bool EnteredCode( GameController controller, Code code ); - static bool EnteredNextBannerGroup( GameController controller ); + static bool EnteredPrevGroup( GameController controller ); + static bool EnteredNextGroup( GameController controller ); - // move to PlayerOptions.h -aj + // todo: move to PlayerOptions.h -aj void ChangeScrollSpeed( GameController controller, bool bIncrement ); }; diff --git a/src/MusicWheel.cpp b/src/MusicWheel.cpp index 1b0b5add16..4322695294 100644 --- a/src/MusicWheel.cpp +++ b/src/MusicWheel.cpp @@ -127,7 +127,6 @@ void MusicWheel::BeginScreen() } } - WheelBase::BeginScreen(); if( GAMESTATE->IsAnExtraStageAndSelectionLocked() ) @@ -139,14 +138,14 @@ void MusicWheel::BeginScreen() GAMESTATE->m_SortOrder.Set( GAMESTATE->m_PreferredSortOrder ); - /* Never start in the mode menu; some elements may not initialize correctly. */ + // Never start in the mode menu; some elements may not initialize correctly. if( GAMESTATE->m_SortOrder == SORT_MODE_MENU ) GAMESTATE->m_SortOrder.Set( SortOrder_Invalid ); GAMESTATE->m_SortOrder.Set( ForceAppropriateSort(GAMESTATE->m_PlayMode, GAMESTATE->m_SortOrder) ); - /* Only save the sort order if the player didn't already have one. If he did, don't - * overwrite it. */ + /* Only save the sort order if the player didn't already have one. + * If he did, don't overwrite it. */ if( GAMESTATE->m_PreferredSortOrder == SortOrder_Invalid ) GAMESTATE->m_PreferredSortOrder = GAMESTATE->m_SortOrder; @@ -350,22 +349,21 @@ void MusicWheel::GetSongList( vector &arraySongs, SortOrder so ) if( iLocked & LOCKED_DISABLED ) continue; - /* If we're on an extra stage, and this song is selected, ignore #SELECTABLE. */ + // If we're on an extra stage, and this song is selected, ignore #SELECTABLE. if( pSong != GAMESTATE->m_pCurSong || !GAMESTATE->IsAnExtraStage() ) { - /* Hide songs that asked to be hidden via #SELECTABLE. */ + // Hide songs that asked to be hidden via #SELECTABLE. if( iLocked & LOCKED_SELECTABLE ) continue; if( so != SORT_ROULETTE && iLocked & LOCKED_ROULETTE ) continue; } - /* Hide locked songs. If RANDOM_PICKS_LOCKED_SONGS, hide in Roulette and Random, - * too. */ + /* Hide locked songs. If RANDOM_PICKS_LOCKED_SONGS, hide in Roulette + * and Random, too. */ if( (so!=SORT_ROULETTE || !RANDOM_PICKS_LOCKED_SONGS) && iLocked ) continue; - if( PREFSMAN->m_bOnlyPreferredDifficulties ) { // if the song has steps that fit the preferred difficulty of the default player @@ -382,8 +380,8 @@ void MusicWheel::GetSongList( vector &arraySongs, SortOrder so ) } - /* Hack: Add extra stage item if it was eliminated for any reason (eg. it's a long - * song). */ + /* Hack: Add extra stage item if it was eliminated for any reason + * (eg. it's a long song). */ if( GAMESTATE->IsAnExtraStage() ) { Song* pSong; @@ -761,14 +759,12 @@ void MusicWheel::UpdateSwitch() const Song* pPrevSelectedSong = GetCurWheelItemData(m_iSelection)->m_pSong; SCREENMAN->PostMessageToTopScreen( SM_SortOrderChanged, 0 ); - + SetOpenSection( SongUtil::GetSectionNameFromSongAndSort(pPrevSelectedSong, GAMESTATE->m_SortOrder) ); m_iSelection = 0; - // // Select the previously selected item - // switch( GAMESTATE->m_SortOrder ) { default: @@ -780,9 +776,8 @@ void MusicWheel::UpdateSwitch() break; } - // - // Change difficulty for sorts by meter - XXX: do this with GameCommand? - // + // Change difficulty for sorts by meter + // XXX: do this with GameCommand? StepsType st; Difficulty dc; if( SongUtil::GetStepsTypeAndDifficultyFromSortOrder( GAMESTATE->m_SortOrder, st, dc ) ) @@ -819,7 +814,7 @@ void MusicWheel::UpdateSwitch() SCREENMAN->PlayStartSound(); m_fLockedWheelVelocity = 0; - /* Send this again so the screen starts sample music. */ + // Send this again so the screen starts sample music. SCREENMAN->PostMessageToTopScreen( SM_SongChanged, 0 ); } else @@ -855,7 +850,7 @@ void MusicWheel::ChangeMusic( int iDist ) SCREENMAN->PostMessageToTopScreen( SM_SongChanged, 0 ); - /* If we're moving automatically, don't play this; it'll be called in Update. */ + // If we're moving automatically, don't play this; it'll be called in Update. if(!IsMoving()) m_soundChangeMusic.Play(); } @@ -867,7 +862,7 @@ bool MusicWheel::ChangeSort( SortOrder new_so ) // return true if change success if( GAMESTATE->m_SortOrder == new_so ) return false; - /* Don't change to SORT_MODE_MENU if it doesn't have at least two choices. */ + // Don't change to SORT_MODE_MENU if it doesn't have at least two choices. if( new_so == SORT_MODE_MENU && m_WheelItemDatas[new_so].size() < 2 ) return false; @@ -886,7 +881,7 @@ bool MusicWheel::ChangeSort( SortOrder new_so ) // return true if change success TweenOffScreenForSort(); - /* Save the new preference. */ + // Save the new preference. if( IsSongSort(new_so) ) GAMESTATE->m_PreferredSortOrder = new_so; GAMESTATE->m_SortOrder.Set( new_so ); @@ -1001,7 +996,7 @@ void MusicWheel::StartRandom() * game into picking a locked song, so pick from SORT_ROULETTE. */ if( RANDOM_PICKS_LOCKED_SONGS ) { - /* Shuffle and use the roulette wheel. */ + // Shuffle and use the roulette wheel. RandomGen rnd; random_shuffle( m_WheelItemDatas[SORT_ROULETTE].begin(), m_WheelItemDatas[SORT_ROULETTE].end(), rnd ); GAMESTATE->m_SortOrder.Set( SORT_ROULETTE ); @@ -1067,9 +1062,7 @@ void MusicWheel::SetOpenSection( RString group ) } - // // Try to select the item that was selected before changing groups - // m_iSelection = 0; for( unsigned i=0; im_Type == TYPE_SECTION && i != (unsigned int)m_iSelection ) + { + m_iSelection = i; + return m_CurWheelItemData[i]->m_sText; + } + } + // it should not get down here, but it might happen... only search up to + // the previous selection. + for( unsigned int i = 0; i < iLastSelection; ++i ) + { + if( m_CurWheelItemData[i]->m_Type == TYPE_SECTION && i != (unsigned int)m_iSelection ) + { + m_iSelection = i; + return m_CurWheelItemData[i]->m_sText; + } + } + // and this would be el bad: + return ""; +} + +RString MusicWheel::JumpToPrevGroup() +{ + for( unsigned int i = m_iSelection; i > 0; --i ) + { + if( m_CurWheelItemData[i]->m_Type == TYPE_SECTION && i != (unsigned int)m_iSelection ) + { + m_iSelection = i; + return m_CurWheelItemData[i]->m_sText; + } + } + // in case it wasn't found above: + for( unsigned int i = m_CurWheelItemData.size()-1; i > 0; --i ) + { + LOG->Trace( ssprintf("JumpToPrevGroup iteration 2 | i = %u",i) ); + if( m_CurWheelItemData[i]->m_Type == TYPE_SECTION ) + { + m_iSelection = i; + LOG->Trace( ssprintf("finding it in #2 | i = %u | text = %s",i, m_CurWheelItemData[i]->m_sText.c_str()) ); + return m_CurWheelItemData[i]->m_sText; + } + } + LOG->Trace("NO I'M NOT OK!!!"); + // and this would be el bad: + return ""; +} + +// Called on late join. Selectable courses may have changed; reopen the section. void MusicWheel::PlayerJoined() { SetOpenSection( m_sExpandedSectionName ); @@ -1141,8 +1186,8 @@ Song *MusicWheel::GetPreferredSelectionForRandomOrPortal() #define NUM_PROBES 1000 for( int i=0; i::iterator it = m_NoteDisplays.find( m_pPlayerState->m_PlayerOptions.GetCurrent().m_sNoteSkin ); - ASSERT_M( it != m_NoteDisplays.end(), m_pPlayerState->m_PlayerOptions.GetCurrent().m_sNoteSkin ); + ASSERT_M( it != m_NoteDisplays.end(), + ssprintf("Player noteskin: %s", m_pPlayerState->m_PlayerOptions.GetCurrent().m_sNoteSkin.c_str()) ); m_pCurDisplay = it->second; memset( m_pDisplays, 0, sizeof(m_pDisplays) ); FOREACH_EnabledPlayer( pn ) diff --git a/src/ScreenSelectMusic.cpp b/src/ScreenSelectMusic.cpp index fd81ef82dd..82fe629596 100644 --- a/src/ScreenSelectMusic.cpp +++ b/src/ScreenSelectMusic.cpp @@ -664,6 +664,30 @@ bool ScreenSelectMusic::DetectCodes( const InputEventPlus &input ) MESSAGEMAN->Broadcast( "SongOptionsChanged" ); } + else if( CodeDetector::EnteredNextGroup(input.GameI.controller) ) + { + if( GAMESTATE->IsAnExtraStageAndSelectionLocked() ) + m_soundLocked.Play(); + else + { + RString sNewGroup = m_MusicWheel.JumpToNextGroup(); + m_MusicWheel.SelectSection(sNewGroup); + m_MusicWheel.SetOpenSection(sNewGroup); + AfterMusicChange(); + } + } + else if( CodeDetector::EnteredPrevGroup(input.GameI.controller) ) + { + if( GAMESTATE->IsAnExtraStageAndSelectionLocked() ) + m_soundLocked.Play(); + else + { + RString sNewGroup = m_MusicWheel.JumpToPrevGroup(); + m_MusicWheel.SelectSection(sNewGroup); + m_MusicWheel.SetOpenSection(sNewGroup); + AfterMusicChange(); + } + } else { return false; diff --git a/src/WheelBase.h b/src/WheelBase.h index 5e651d8c8d..afe33f3036 100644 --- a/src/WheelBase.h +++ b/src/WheelBase.h @@ -77,7 +77,7 @@ protected: int m_iSwitchesLeftInSpinDown; float m_fLockedWheelVelocity; - /* 0 = none; -1 or 1 = up/down */ + // 0 = none; -1 or 1 = up/down int m_Moving; RageTimer m_MovingSoundTimer; float m_TimeBeforeMovingBegins;