basic course sorting implemented via preferences

This commit is contained in:
Andrew Wong
2003-07-27 14:10:47 +00:00
parent 8b9ae5ae92
commit cb250344b8
6 changed files with 128 additions and 0 deletions
+88
View File
@@ -27,6 +27,7 @@
#include "BannerCache.h"
#include "RageFile.h"
#include "arch/arch.h"
#include "ThemeManager.h"
/* Amount to increase meter ranges to make them difficult: */
const int DIFFICULT_METER_CHANGE = 2;
@@ -761,11 +762,65 @@ static bool CompareCoursePointersByDifficulty(const Course* pCourse1, const Cour
return CompareCoursePointersByAutogen( pCourse1, pCourse2 );
}
static bool CompareCoursePointersByAvgDifficulty(const Course* pCourse1, const Course* pCourse2)
{
float iNum1 = pCourse1->SortOrder_AvgDifficulty;
float iNum2 = pCourse2->SortOrder_AvgDifficulty;
if( iNum1 < iNum2 )
return true;
else if( iNum1 > iNum2 )
return false;
else // iNum1 == iNum2
return CompareCoursePointersByAutogen( pCourse1, pCourse2 );
}
static bool CompareCoursePointersByTotalDifficulty(const Course* pCourse1, const Course* pCourse2)
{
float iNum1 = pCourse1->SortOrder_TotalDifficulty;
float iNum2 = pCourse2->SortOrder_TotalDifficulty;
if( iNum1 < iNum2 )
return true;
else if( iNum1 > iNum2 )
return false;
else // iNum1 == iNum2
return CompareCoursePointersByAutogen( pCourse1, pCourse2 );
}
static bool CompareCoursePointersByRanking(const Course* pCourse1, const Course* pCourse2)
{
float iNum1 = pCourse1->SortOrder_Ranking;
float iNum2 = pCourse2->SortOrder_Ranking;
if( iNum1 < iNum2 )
return true;
else if( iNum1 > iNum2 )
return false;
else // iNum1 == iNum2
return CompareCoursePointersByAutogen( pCourse1, pCourse2 );
}
void SortCoursePointerArrayByDifficulty( vector<Course*> &apCourses )
{
sort( apCourses.begin(), apCourses.end(), CompareCoursePointersByDifficulty );
}
void SortCoursePointerArrayByRanking( vector<Course*> &apCourses )
{
sort( apCourses.begin(), apCourses.end(), CompareCoursePointersByRanking );
}
void SortCoursePointerArrayByAvgDifficulty( vector<Course*> &apCourses )
{
sort( apCourses.begin(), apCourses.end(), CompareCoursePointersByAvgDifficulty );
}
void SortCoursePointerArrayByTotalDifficulty( vector<Course*> &apCourses )
{
sort( apCourses.begin(), apCourses.end(), CompareCoursePointersByTotalDifficulty );
}
static bool CompareCoursePointersByType(const Course* pCourse1, const Course* pCourse2)
{
return pCourse1->GetPlayMode() < pCourse2->GetPlayMode();
@@ -781,3 +836,36 @@ bool Course::HasBanner() const
{
return m_sBannerPath != "" && IsAFile(m_sBannerPath);
}
void Course::UpdateCourseStats()
{
LOG->Trace("Updating course stats for %s", this->m_sName.c_str() );
SortOrder_AvgDifficulty = 0;
SortOrder_NumStages = 0;
SortOrder_Ranking = 2;
SortOrder_TotalDifficulty = 0;
unsigned i;
vector<Info> ci;
GetCourseInfo( GAMESTATE->GetCurrentStyleDef()->m_NotesType, ci );
for(i = 0; i < m_entries.size(); i++)
{
SortOrder_NumStages++;
SortOrder_TotalDifficulty += ci[i].pNotes->GetMeter();
}
SortOrder_AvgDifficulty = (float)SortOrder_TotalDifficulty/SortOrder_NumStages;
if (SortOrder_NumStages > 7) SortOrder_Ranking = 3;
CStringArray RankingCourses;
split( THEME->GetMetric("ScreenRanking","CoursesToShow"),",", RankingCourses);
for(i = 0; i < RankingCourses.size(); i++)
if (!RankingCourses[i].CompareNoCase(this->m_sPath))
SortOrder_Ranking = 1;
}
+11
View File
@@ -120,6 +120,13 @@ public:
void AddScores( NotesType nt, bool bPlayerEnabled[NUM_PLAYERS], int iDancePoints[NUM_PLAYERS], float fSurviveTime[NUM_PLAYERS], int iRankingIndexOut[NUM_PLAYERS], bool bNewRecordOut[NUM_PLAYERS] ); // iNewRecordIndexOut[p] = -1 if not a new record
// sorting values
int SortOrder_NumStages;
int SortOrder_TotalDifficulty;
float SortOrder_AvgDifficulty;
int SortOrder_Ranking;
void UpdateCourseStats();
private:
void SetDefaultScore();
@@ -129,5 +136,9 @@ private:
void SortCoursePointerArrayByDifficulty( vector<Course*> &apCourses );
void SortCoursePointerArrayByType( vector<Course*> &apCourses );
void SortCoursePointerArrayByAvgDifficulty( vector<Course*> &apCourses );
void SortCoursePointerArrayByTotalDifficulty( vector<Course*> &apCourses );
void SortCoursePointerArrayByRanking( vector<Course*> &apCourses );
#endif
+16
View File
@@ -571,8 +571,24 @@ void MusicWheel::BuildWheelItemDatas( vector<WheelItemData> &arrayWheelItemDatas
default: ASSERT(0); break;
}
// default sort order; other songs may alter this
SortCoursePointerArrayByDifficulty( apCourses );
if (PREFSMAN->m_iCourseSortOrder != 0)
{
for(i=0; i<apCourses.size(); i++)
apCourses[i]->UpdateCourseStats();
if (PREFSMAN->m_iCourseSortOrder == 1)
SortCoursePointerArrayByAvgDifficulty( apCourses );
if (PREFSMAN->m_iCourseSortOrder == 2)
SortCoursePointerArrayByTotalDifficulty( apCourses );
if (PREFSMAN->m_iCourseSortOrder == 3)
SortCoursePointerArrayByRanking( apCourses );
}
if( so == SORT_ALL_COURSES )
SortCoursePointerArrayByType( apCourses );
+5
View File
@@ -109,6 +109,9 @@ PrefsManager::PrefsManager()
* stage CRS files) don't get it changed around on them. */
m_bPickExtraStage = false;
// default to old sort order
m_iCourseSortOrder = 0;
m_fLongVerSongSeconds = 60*2.5f; // Dynamite Rave is 2:55
m_fMarathonVerSongSeconds = 60*5.f;
@@ -214,6 +217,7 @@ 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", "UseUnlockSystem", m_bUseUnlockSystem );
@@ -325,6 +329,7 @@ void PrefsManager::SaveGlobalPrefsToDisk()
ini.SetValueB( "Options", "DebugMode", m_bDebugMode );
ini.SetValueB( "Options", "TenFooterInRed", m_bTenFooterInRed );
ini.SetValueI( "Options", "CourseSortOrder", m_iCourseSortOrder );
/* Only write these if they aren't the default. This ensures that we can change
+4
View File
@@ -84,6 +84,10 @@ public:
bool m_bDebugMode;
bool m_bTenFooterInRed;
// course ranking
// by # songs = 0, avg diff=1, total diff=2, ranking=3
int m_iCourseSortOrder;
/* 0 = no; 1 = yes; -1 = auto (do whatever is appropriate for the arch). */
int m_iBoostAppPriority;
@@ -36,6 +36,7 @@ enum {
AO_SELECT_GROUP,
AO_WHEEL_SECTIONS,
AO_TEN_FOOT_RED,
AO_COURSE_SORT,
AO_SHOW_TRANSLATIONS,
AO_SHOW_LYRICS,
NUM_APPEARANCE_OPTIONS_LINES
@@ -52,6 +53,7 @@ OptionRow g_AppearanceOptionsLines[NUM_APPEARANCE_OPTIONS_LINES] = {
OptionRow( "Song\nGroup", "ALL MUSIC","CHOOSE"),
OptionRow( "Wheel\nSections", "NEVER","ALWAYS", "ABC ONLY"),
OptionRow( "10+ foot\nIn Red", "NO", "YES"),
OptionRow( "Course\nSort", "# SONGS", "AVG FEET", "TOTAL FEET", "RANKING"),
OptionRow( "Translations", "NATIVE","TRANSLITERATE"),
OptionRow( "Lyrics", "HIDE","SHOW"),
};
@@ -144,6 +146,7 @@ void ScreenAppearanceOptions::ImportOptions()
m_iSelectedOption[0][AO_SELECT_GROUP] = PREFSMAN->m_bShowSelectGroup? 1:0;
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_SHOW_TRANSLATIONS] = PREFSMAN->m_bShowNative? 0:1;
m_iSelectedOption[0][AO_SHOW_LYRICS] = PREFSMAN->m_bShowLyrics;
}
@@ -192,6 +195,7 @@ void ScreenAppearanceOptions::ExportOptions()
PREFSMAN->m_bShowLyrics = !!m_iSelectedOption[0][AO_SHOW_LYRICS];
PREFSMAN->m_bDancePointsForOni = !!m_iSelectedOption[0][AO_DANCE_POINTS_FOR_ONI];
PREFSMAN->m_bTenFooterInRed = !!m_iSelectedOption[0][AO_TEN_FOOT_RED];
PREFSMAN->m_iCourseSortOrder = m_iSelectedOption[0][AO_COURSE_SORT];
PREFSMAN->SaveGamePrefsToDisk();
PREFSMAN->SaveGlobalPrefsToDisk();