handle CourseDifficultiesToShow, add IsCourseDifficultyShown
This commit is contained in:
@@ -40,10 +40,12 @@
|
||||
#include "StepMania.h"
|
||||
|
||||
#include <ctime>
|
||||
#include <set>
|
||||
|
||||
#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<CourseDifficulty> GetCourseDifficultiesToShow()
|
||||
{
|
||||
CStringArray asDiff;
|
||||
split( COURSE_DIFFICULTIES_TO_SHOW, ",", asDiff );
|
||||
ASSERT( asDiff.size() > 0 );
|
||||
|
||||
set<CourseDifficulty> 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<CourseDifficulty> 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<CourseDifficulty> asDiff = GetCourseDifficultiesToShow();
|
||||
return asDiff.find(cd) != asDiff.end();
|
||||
}
|
||||
|
||||
Difficulty GameState::GetEasiestNotesDifficulty() const
|
||||
{
|
||||
Difficulty dc = DIFFICULTY_INVALID;
|
||||
|
||||
@@ -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
|
||||
|
||||
|
||||
Reference in New Issue
Block a user