From 1ebe763c9a72c8150d4f5c698aa73d5c1e642e1f Mon Sep 17 00:00:00 2001 From: Andrew Wong Date: Tue, 12 Aug 2003 23:18:19 +0000 Subject: [PATCH] add option to push random courses to end or sort them based on GetMeter --- stepmania/src/Course.cpp | 37 +++++++++++++++-------- stepmania/src/Course.h | 1 + stepmania/src/MusicWheel.cpp | 4 +++ stepmania/src/PrefsManager.cpp | 5 +++ stepmania/src/PrefsManager.h | 1 + stepmania/src/ScreenAppearanceOptions.cpp | 4 +++ 6 files changed, 39 insertions(+), 13 deletions(-) diff --git a/stepmania/src/Course.cpp b/stepmania/src/Course.cpp index d8b17fa69d..a9baf4f652 100644 --- a/stepmania/src/Course.cpp +++ b/stepmania/src/Course.cpp @@ -125,8 +125,7 @@ float Course::GetMeter( int Difficult ) const else fTotalMeter += ci[c].pNotes->GetMeter(); } - - LOG->Trace("Course '%s': %f", m_sName.c_str(), fTotalMeter/ci.size() ); +// LOG->Trace("Course '%s': %f", m_sName.c_str(), fTotalMeter/ci.size() ); return fTotalMeter / ci.size(); } @@ -514,7 +513,7 @@ void Course::GetCourseInfo( StepsType nt, vector &ci, int Difficul for( unsigned i=0; i &ci, int Difficul else pNotes = pSong->GetStepsByDifficulty( nt, DIFFICULTY_MEDIUM, PREFSMAN->m_bAutogenMissingTypes ); } + e.mystery = false; break; case COURSE_ENTRY_RANDOM: case COURSE_ENTRY_RANDOM_WITHIN_GROUP: @@ -566,6 +566,7 @@ void Course::GetCourseInfo( StepsType nt, vector &ci, int Difficul pNotes = NULL; } } + e.mystery = true; break; case COURSE_ENTRY_BEST: case COURSE_ENTRY_WORST: @@ -599,6 +600,7 @@ void Course::GetCourseInfo( StepsType nt, vector &ci, int Difficul if( pNotes == NULL ) pNotes = pSong->GetClosestNotes( nt, DIFFICULTY_MEDIUM ); } + e.mystery = false; break; default: ASSERT(0); @@ -873,16 +875,6 @@ static bool CompareCoursePointersByAvgDifficulty(const Course* pCourse1, const C float fNum1 = pCourse1->GetMeter( false ); float fNum2 = pCourse2->GetMeter( false ); - // push non-fixed courses to end - if ( !pCourse1->IsFixed() ) - fNum1 = 1000.0f; - if ( !pCourse2->IsFixed() ) - fNum2 = 1000.0f; - - LOG->Trace("Comparison between %s (%f) and %s (%f)", - pCourse1->m_sName.c_str() , fNum1, - pCourse2->m_sName.c_str() , fNum2); - if( fNum1 < fNum2 ) return true; else if( fNum1 > fNum2 ) @@ -934,6 +926,21 @@ static bool MovePlayersBestToEnd( const Course* pCourse1, const Course* pCourse2 return pCourse1->m_sName < pCourse2->m_sName; } +static bool CompareRandom( const Course* pCourse1, const Course* pCourse2 ) +{ + bool C1Fixed = pCourse1->IsFixed(); + bool C2Fixed = pCourse2->IsFixed(); + if( !C1Fixed && !C2Fixed ) + return false; + if( C1Fixed && !C2Fixed ) + return true; + if( !C1Fixed && C2Fixed ) + return false; + + return false; +// return pCourse1->m_sName < pCourse2->m_sName; +} + static bool CompareCoursePointersByRanking(const Course* pCourse1, const Course* pCourse2) { int iNum1 = pCourse1->SortOrder_Ranking; @@ -977,6 +984,10 @@ static bool CompareCoursePointersByType(const Course* pCourse1, const Course* pC return pCourse1->GetPlayMode() < pCourse2->GetPlayMode(); } +void MoveRandomToEnd( vector &apCourses ) +{ + stable_sort( apCourses.begin(), apCourses.end(), CompareRandom ); +} void SortCoursePointerArrayByType( vector &apCourses ) { diff --git a/stepmania/src/Course.h b/stepmania/src/Course.h index 5f8c66f6e1..ab62b20baa 100644 --- a/stepmania/src/Course.h +++ b/stepmania/src/Course.h @@ -166,5 +166,6 @@ void SortCoursePointerArrayByAvgDifficulty( vector &apCourses ); void SortCoursePointerArrayByTotalDifficulty( vector &apCourses ); void SortCoursePointerArrayByRanking( vector &apCourses ); +void MoveRandomToEnd( vector &apCourses ); #endif diff --git a/stepmania/src/MusicWheel.cpp b/stepmania/src/MusicWheel.cpp index e68a6219c9..106157a6da 100644 --- a/stepmania/src/MusicWheel.cpp +++ b/stepmania/src/MusicWheel.cpp @@ -586,6 +586,10 @@ void MusicWheel::BuildWheelItemDatas( vector &arrayWheelItemDatas if (PREFSMAN->m_iCourseSortOrder == PrefsManager::COURSE_SORT_RANK) SortCoursePointerArrayByRanking( apCourses ); + + // since we can't agree, make it an option + if (PREFSMAN->m_bMoveRandomToEnd) + MoveRandomToEnd( apCourses ); } if( so == SORT_ALL_COURSES ) diff --git a/stepmania/src/PrefsManager.cpp b/stepmania/src/PrefsManager.cpp index e6c7b5be3c..5c5319a701 100644 --- a/stepmania/src/PrefsManager.cpp +++ b/stepmania/src/PrefsManager.cpp @@ -116,6 +116,7 @@ PrefsManager::PrefsManager() // default to old sort order m_iCourseSortOrder = COURSE_SORT_SONGS; + m_bMoveRandomToEnd = false; m_iScoringType = SCORING_MAX2; m_fLongVerSongSeconds = 60*2.5f; // Dynamite Rave is 2:55 @@ -235,7 +236,9 @@ void PrefsManager::ReadGlobalPrefsFromDisk( bool bSwitchToLastPlayedGame ) ini.GetValueB( "Options", "BreakComboToGetItem", m_bBreakComboToGetItem ); ini.GetValueB( "Options", "ShowDancingCharacters", m_bShowDancingCharacters ); ini.GetValueB( "Options", "TenFooterInRed", m_bTenFooterInRed ); + ini.GetValueI( "Options", "CourseSortOrder", (int&)m_iCourseSortOrder ); + ini.GetValueB( "Options", "MoveRandomToEnd", m_bMoveRandomToEnd ); ini.GetValueI( "Options", "ScoringType", (int&)m_iScoringType ); @@ -358,6 +361,8 @@ void PrefsManager::SaveGlobalPrefsToDisk() ini.SetValueB( "Options", "TenFooterInRed", m_bTenFooterInRed ); ini.SetValueI( "Options", "CourseSortOrder", m_iCourseSortOrder ); + ini.SetValueB( "Options", "MoveRandomToEnd", m_bMoveRandomToEnd ); + ini.SetValueI( "Options", "ScoringType", m_iScoringType ); ini.SetValueI( "Options", "ProgressiveLifebar", m_iProgressiveLifebar ); diff --git a/stepmania/src/PrefsManager.h b/stepmania/src/PrefsManager.h index 1625f898a7..50f579e9d1 100644 --- a/stepmania/src/PrefsManager.h +++ b/stepmania/src/PrefsManager.h @@ -93,6 +93,7 @@ public: // course ranking enum { COURSE_SORT_SONGS, COURSE_SORT_METER, COURSE_SORT_METER_SUM, COURSE_SORT_RANK } m_iCourseSortOrder; + bool m_bMoveRandomToEnd; // scoring type; SCORING_MAX2 should always be first enum { SCORING_MAX2, SCORING_5TH } m_iScoringType; diff --git a/stepmania/src/ScreenAppearanceOptions.cpp b/stepmania/src/ScreenAppearanceOptions.cpp index b21769a58a..5fa7a8585b 100644 --- a/stepmania/src/ScreenAppearanceOptions.cpp +++ b/stepmania/src/ScreenAppearanceOptions.cpp @@ -38,6 +38,7 @@ enum { AO_WHEEL_SECTIONS, AO_TEN_FOOT_RED, AO_COURSE_SORT, + AO_COURSE_MOVE_RANDOM, AO_SHOW_TRANSLATIONS, AO_SHOW_LYRICS, NUM_APPEARANCE_OPTIONS_LINES @@ -55,6 +56,7 @@ OptionRow g_AppearanceOptionsLines[NUM_APPEARANCE_OPTIONS_LINES] = { OptionRow( "Wheel\nSections", "NEVER","ALWAYS", "ABC ONLY"), OptionRow( "10+ foot\nIn Red", "NO", "YES"), OptionRow( "Course\nSort", "# SONGS", "AVG FEET", "TOTAL FEET", "RANKING"), + OptionRow( "Random\nAt End", "NO","YES"), OptionRow( "Translations", "NATIVE","TRANSLITERATE"), OptionRow( "Lyrics", "HIDE","SHOW"), }; @@ -148,6 +150,7 @@ void ScreenAppearanceOptions::ImportOptions() m_iSelectedOption[0][AO_WHEEL_SECTIONS] = (int)PREFSMAN->m_MusicWheelUsesSections; m_iSelectedOption[0][AO_TEN_FOOT_RED] = PREFSMAN->m_bTenFooterInRed? 1:0; m_iSelectedOption[0][AO_COURSE_SORT] = (int)PREFSMAN->m_iCourseSortOrder; + m_iSelectedOption[0][AO_COURSE_MOVE_RANDOM] = PREFSMAN->m_bMoveRandomToEnd? 1:0; m_iSelectedOption[0][AO_SHOW_TRANSLATIONS] = PREFSMAN->m_bShowNative? 0:1; m_iSelectedOption[0][AO_SHOW_LYRICS] = PREFSMAN->m_bShowLyrics; } @@ -199,6 +202,7 @@ void ScreenAppearanceOptions::ExportOptions() PREFSMAN->m_bDancePointsForOni = !!m_iSelectedOption[0][AO_DANCE_POINTS_FOR_ONI]; PREFSMAN->m_bTenFooterInRed = !!m_iSelectedOption[0][AO_TEN_FOOT_RED]; (int&)PREFSMAN->m_iCourseSortOrder = m_iSelectedOption[0][AO_COURSE_SORT]; + PREFSMAN->m_bMoveRandomToEnd = !!m_iSelectedOption[0][AO_COURSE_MOVE_RANDOM]; PREFSMAN->SaveGamePrefsToDisk(); PREFSMAN->SaveGlobalPrefsToDisk();