From 3bf1c81a48ad9b8a7271d761db12d1710c08f9ef Mon Sep 17 00:00:00 2001 From: Chris Danford Date: Sun, 29 Sep 2002 23:29:01 +0000 Subject: [PATCH] Initial sort order now sorts by meter of Easy notes, ala MAX. --- stepmania/NEWS | 1 + stepmania/src/ScreenSelectMode.cpp | 2 -- stepmania/src/Song.cpp | 37 ++++++++++++++++++++++++++++-- stepmania/src/SongManager.cpp | 8 +++---- stepmania/src/song.h | 1 + 5 files changed, 41 insertions(+), 8 deletions(-) diff --git a/stepmania/NEWS b/stepmania/NEWS index 4aa6b969d5..4c7aa49594 100644 --- a/stepmania/NEWS +++ b/stepmania/NEWS @@ -1,4 +1,5 @@ ------------------------CVS after 3.00 beta 6---------------- +CHANGE: Initial sort order now sorts by meter of Easy notes, ala MAX. BUG FIX: DWI music sample info now read correctly - again. NEW FEATURE: Precise adjustment of timing window for each grade via the stepmania.ini file (see JudgeWindowPerfectPercent, JudgeWindowGreatPercent, diff --git a/stepmania/src/ScreenSelectMode.cpp b/stepmania/src/ScreenSelectMode.cpp index 19738c7cb2..89280fca73 100644 --- a/stepmania/src/ScreenSelectMode.cpp +++ b/stepmania/src/ScreenSelectMode.cpp @@ -215,8 +215,6 @@ void ScreenSelectMode::RefreshModeChoices() m_BGAnimations[i].LoadFromAniDir( THEME->GetPathTo("BGAnimations",ssprintf("select mode %s %s", sGameName, sChoiceName)) ); } } - - } diff --git a/stepmania/src/Song.cpp b/stepmania/src/Song.cpp index c98817a11f..ca090c4bdc 100644 --- a/stepmania/src/Song.cpp +++ b/stepmania/src/Song.cpp @@ -25,6 +25,7 @@ #include "PrefsManager.h" #include "StyleDef.h" #include "Notes.h" +#include "GameState.h" #include "NotesLoaderSM.h" #include "NotesLoaderDWI.h" @@ -795,6 +796,38 @@ bool Song::IsEasy( NotesType nt ) const // Sorting ///////////////////////////////////// +int CompareSongPointersByDifficulty(const void *arg1, const void *arg2) +{ + const Song* pSong1 = *(const Song**)arg1; + const Song* pSong2 = *(const Song**)arg2; + + CArray aNotes1; + CArray aNotes2; + + pSong1->GetNotesThatMatch( GAMESTATE->GetCurrentStyleDef(), PLAYER_1, aNotes1 ); + pSong2->GetNotesThatMatch( GAMESTATE->GetCurrentStyleDef(), PLAYER_1, aNotes2 ); + + int iEasiestMeter1 = 1000; // infinity + int iEasiestMeter2 = 1000; // infinity + + for( int i=0; im_iMeter ); + for( int i=0; im_iMeter ); + + if( iEasiestMeter1 < iEasiestMeter2 ) + return -1; + else if( iEasiestMeter1 == iEasiestMeter2 ) + return 0; + else + return +1; +} + +void SortSongPointerArrayByDifficulty( CArray &arraySongPointers ) +{ + qsort( arraySongPointers.GetData(), arraySongPointers.GetSize(), sizeof(Song*), CompareSongPointersByDifficulty ); +} + int CompareSongPointersByTitle(const void *arg1, const void *arg2) { const Song* pSong1 = *(const Song**)arg1; @@ -877,8 +910,8 @@ int CompareSongPointersByGroup(const void *arg1, const void *arg2) else if( sGroup1 > sGroup2 ) return 1; - /* Same group; compare by title. */ - return CompareSongPointersByTitle( arg1, arg2 ); + /* Same group; compare by difficulty. */ + return CompareSongPointersByDifficulty( arg1, arg2 ); } void SortSongPointerArrayByGroup( CArray &arraySongPointers ) diff --git a/stepmania/src/SongManager.cpp b/stepmania/src/SongManager.cpp index 67559793a0..974e726948 100644 --- a/stepmania/src/SongManager.cpp +++ b/stepmania/src/SongManager.cpp @@ -414,7 +414,7 @@ void SongManager::GetSongsInGroup( const CString sGroupName, CArraym_sGroupName ) AddTo.Add( pSong ); } - SortSongPointerArrayByGroup( AddTo ); +// SortSongPointerArrayByGroup( AddTo ); } CString SongManager::ShortenGroupName( const CString &sOrigGroupName ) @@ -423,9 +423,9 @@ CString SongManager::ShortenGroupName( const CString &sOrigGroupName ) sShortName.Replace( "Dance Dance Revolution", "DDR" ); sShortName.Replace( "dance dance revolution", "DDR" ); sShortName.Replace( "DANCE DANCE REVOLUTION", "DDR" ); - sShortName.Replace( "Pump It Up", "Pump" ); - sShortName.Replace( "pump it up", "pump" ); - sShortName.Replace( "PUMP IT UP", "PUMP" ); + sShortName.Replace( "Pump It Up", "PIU" ); + sShortName.Replace( "pump it up", "PIU" ); + sShortName.Replace( "PUMP IT UP", "PIU" ); return sShortName; } diff --git a/stepmania/src/song.h b/stepmania/src/song.h index 55fbf3574e..72fc4aef68 100644 --- a/stepmania/src/song.h +++ b/stepmania/src/song.h @@ -198,6 +198,7 @@ public: }; +void SortSongPointerArrayByDifficulty( CArray &arraySongPointers ); void SortSongPointerArrayByTitle( CArray &arraySongPointers ); void SortSongPointerArrayByBPM( CArray &arraySongPointers ); void SortSongPointerArrayByArtist( CArray &arraySongPointers );