Make CourseDifficulty its own enum.

This commit is contained in:
Steve Checkoway
2006-10-07 10:49:04 +00:00
parent 0600ff5a1c
commit 64cf91a6bc
2 changed files with 25 additions and 17 deletions
+5 -4
View File
@@ -40,7 +40,7 @@ Difficulty StringToDifficulty( const RString& sDC )
else if( s2 == "maniac" ) return DIFFICULTY_HARD; else if( s2 == "maniac" ) return DIFFICULTY_HARD;
else if( s2 == "heavy" ) return DIFFICULTY_HARD; else if( s2 == "heavy" ) return DIFFICULTY_HARD;
else if( s2 == "smaniac" ) return DIFFICULTY_CHALLENGE; else if( s2 == "smaniac" ) return DIFFICULTY_CHALLENGE;
else if( s2 == "challenge" )return DIFFICULTY_CHALLENGE; else if( s2 == "challenge" ) return DIFFICULTY_CHALLENGE;
else if( s2 == "expert" ) return DIFFICULTY_CHALLENGE; else if( s2 == "expert" ) return DIFFICULTY_CHALLENGE;
else if( s2 == "oni" ) return DIFFICULTY_CHALLENGE; else if( s2 == "oni" ) return DIFFICULTY_CHALLENGE;
else if( s2 == "edit" ) return DIFFICULTY_EDIT; else if( s2 == "edit" ) return DIFFICULTY_EDIT;
@@ -59,17 +59,18 @@ static const char *CourseDifficultyNames[] =
XToString( CourseDifficulty, NUM_Difficulty ); XToString( CourseDifficulty, NUM_Difficulty );
XToLocalizedString( CourseDifficulty ); XToLocalizedString( CourseDifficulty );
StringToX( CourseDifficulty ); StringToX( CourseDifficulty );
LuaXType( CourseDifficulty );
LuaFunction( CourseDifficultyToLocalizedString, CourseDifficultyToLocalizedString(Enum::Check<Difficulty>(L, 1)) ); LuaFunction( CourseDifficultyToLocalizedString, CourseDifficultyToLocalizedString(Enum::Check<CourseDifficulty>(L, 1)) );
CourseDifficulty GetNextShownCourseDifficulty( CourseDifficulty cd ) CourseDifficulty GetNextShownCourseDifficulty( CourseDifficulty cd )
{ {
for( CourseDifficulty d=(CourseDifficulty)(cd+1); d<NUM_Difficulty; ((int&)d)++ ) for( CourseDifficulty d=enum_add2(cd,1); d<NUM_CourseDifficulty; enum_add(d, 1) )
{ {
if( GAMESTATE->IsCourseDifficultyShown(d) ) if( GAMESTATE->IsCourseDifficultyShown(d) )
return d; return d;
} }
return Difficulty_Invalid; return CourseDifficulty_Invalid;
} }
/* /*
+18 -11
View File
@@ -23,18 +23,25 @@ const RString& DifficultyToLocalizedString( Difficulty dc );
Difficulty StringToDifficulty( const RString& sDC ); Difficulty StringToDifficulty( const RString& sDC );
LuaDeclareType( Difficulty ); LuaDeclareType( Difficulty );
enum CourseDifficulty
{
COURSE_DIFFICULTY_BEGINNER,
COURSE_DIFFICULTY_EASY,
COURSE_DIFFICULTY_REGULAR,
COURSE_DIFFICULTY_DIFFICULT,
COURSE_DIFFICULTY_CHALLENGE,
COURSE_DIFFICULTY_EDIT,
NUM_CourseDifficulty,
CourseDifficulty_Invalid
};
#define FOREACH_CourseDifficulty( cd ) FOREACH_ENUM( CourseDifficulty, cd )
#define FOREACH_ShownCourseDifficulty( cd ) for( CourseDifficulty cd=GetNextShownCourseDifficulty((CourseDifficulty)-1); cd!=CourseDifficulty_Invalid; cd=GetNextShownCourseDifficulty(cd) )
typedef Difficulty CourseDifficulty; const RString& CourseDifficultyToString( CourseDifficulty dc );
#define NUM_CourseDifficulty NUM_Difficulty const RString& CourseDifficultyToLocalizedString( CourseDifficulty dc );
#define CourseDifficulty_Invalid Difficulty_Invalid CourseDifficulty StringToCourseDifficulty( const RString& sDC );
#define FOREACH_CourseDifficulty FOREACH_Difficulty LuaDeclareType( CourseDifficulty );
#define FOREACH_ShownCourseDifficulty( cd ) for( Difficulty cd=GetNextShownCourseDifficulty((CourseDifficulty)-1); cd!=Difficulty_Invalid; cd=GetNextShownCourseDifficulty(cd) ) CourseDifficulty GetNextShownCourseDifficulty( CourseDifficulty pn );
const RString& CourseDifficultyToString( Difficulty dc );
const RString& CourseDifficultyToLocalizedString( Difficulty dc );
Difficulty StringToCourseDifficulty( const RString& sDC );
Difficulty GetNextShownCourseDifficulty( Difficulty pn );
#endif #endif