diff --git a/stepmania/src/GameState.cpp b/stepmania/src/GameState.cpp index 318a29fe14..bb6316c124 100644 --- a/stepmania/src/GameState.cpp +++ b/stepmania/src/GameState.cpp @@ -40,10 +40,12 @@ #include "StepMania.h" #include +#include #define DEFAULT_MODIFIERS THEME->GetMetric( "Common","DefaultModifiers" ) #define DEFAULT_CPU_MODIFIERS THEME->GetMetric( "Common","DefaultCpuModifiers" ) #define DIFFICULTIES_TO_SHOW THEME->GetMetric( "Common","DifficultiesToShow" ) +#define COURSE_DIFFICULTIES_TO_SHOW THEME->GetMetric( "Common","CourseDifficultiesToShow" ) GameState* GAMESTATE = NULL; // global and accessable from anywhere in our program @@ -1646,13 +1648,36 @@ bool GameState::ChangeDifficulty( PlayerNumber pn, int dir ) return ChangeDifficulty( pn, diff ); } +static set GetCourseDifficultiesToShow() +{ + CStringArray asDiff; + split( COURSE_DIFFICULTIES_TO_SHOW, ",", asDiff ); + ASSERT( asDiff.size() > 0 ); + + set ret; + for( unsigned i = 0; i < asDiff.size(); ++i ) + { + CourseDifficulty cd = StringToCourseDifficulty(asDiff[i]); + if( cd == NUM_COURSE_DIFFICULTIES ) + RageException::Throw( "Unknown difficulty \"%s\" in CourseDifficultiesToShow", asDiff[i].c_str() ); + ret.insert( cd ); + } + return ret; +} + bool GameState::ChangeCourseDifficulty( PlayerNumber pn, int dir ) { - CourseDifficulty diff = (CourseDifficulty)(m_PreferredCourseDifficulty[pn]+dir); - if( diff < 0 || diff >= NUM_COURSE_DIFFICULTIES ) - return false; + const set asDiff = GetCourseDifficultiesToShow(); + + CourseDifficulty cd = m_PreferredCourseDifficulty[pn]; + do { + cd = (CourseDifficulty)(cd+dir); + if( cd < 0 || cd >= NUM_COURSE_DIFFICULTIES ) + return false; + } while( asDiff.find(cd) == asDiff.end() ); + + this->m_PreferredCourseDifficulty[pn] = cd; - this->m_PreferredCourseDifficulty[pn] = diff; if( PREFSMAN->m_bLockCourseDifficulties ) for( int p = 0; p < NUM_PLAYERS; ++p ) m_PreferredCourseDifficulty[p] = m_PreferredCourseDifficulty[pn]; @@ -1660,6 +1685,12 @@ bool GameState::ChangeCourseDifficulty( PlayerNumber pn, int dir ) return true; } +bool GameState::IsCourseDifficultyShown( CourseDifficulty cd ) +{ + const set asDiff = GetCourseDifficultiesToShow(); + return asDiff.find(cd) != asDiff.end(); +} + Difficulty GameState::GetEasiestNotesDifficulty() const { Difficulty dc = DIFFICULTY_INVALID; diff --git a/stepmania/src/GameState.h b/stepmania/src/GameState.h index edfd8052b6..b38ce11270 100644 --- a/stepmania/src/GameState.h +++ b/stepmania/src/GameState.h @@ -65,6 +65,7 @@ public: bool ChangeDifficulty( PlayerNumber pn, Difficulty dc ); bool ChangeDifficulty( PlayerNumber pn, int dir ); bool ChangeCourseDifficulty( PlayerNumber pn, int dir ); + bool IsCourseDifficultyShown( CourseDifficulty cd ); Difficulty GetEasiestNotesDifficulty() const; RageTimer m_timeGameStarted; // from the moment the first player pressed Start