From c3426148ded5eaa808a5af3b85256de2202ff7a1 Mon Sep 17 00:00:00 2001 From: Glenn Maynard Date: Thu, 20 May 2004 22:08:20 +0000 Subject: [PATCH] split out Difficulty and CourseDifficulty add FOREACH_DisplayedCourseDifficulty --- stepmania/src/Difficulty.cpp | 63 +++++++++++++++++++++++++ stepmania/src/Difficulty.h | 42 +++++++++++++++++ stepmania/src/GameConstantsAndTypes.cpp | 48 ------------------- stepmania/src/GameConstantsAndTypes.h | 30 +----------- 4 files changed, 106 insertions(+), 77 deletions(-) create mode 100644 stepmania/src/Difficulty.cpp create mode 100644 stepmania/src/Difficulty.h diff --git a/stepmania/src/Difficulty.cpp b/stepmania/src/Difficulty.cpp new file mode 100644 index 0000000000..580ff6a521 --- /dev/null +++ b/stepmania/src/Difficulty.cpp @@ -0,0 +1,63 @@ +#include "global.h" +#include "Difficulty.h" +#include "GameState.h" +#include "ThemeManager.h" + + +static const CString DifficultyNames[NUM_RADAR_CATEGORIES] = { + "Beginner", + "Easy", + "Medium", + "Hard", + "Challenge", + "Edit", +}; +XToString( Difficulty ); +XToThemedString( Difficulty ); + +/* We prefer the above names; recognize a number of others, too. (They'l + * get normalized when written to SMs, etc.) */ +Difficulty StringToDifficulty( const CString& sDC ) +{ + CString s2 = sDC; + s2.MakeLower(); + if( s2 == "beginner" ) return DIFFICULTY_BEGINNER; + else if( s2 == "easy" ) return DIFFICULTY_EASY; + else if( s2 == "basic" ) return DIFFICULTY_EASY; + else if( s2 == "light" ) return DIFFICULTY_EASY; + else if( s2 == "medium" ) return DIFFICULTY_MEDIUM; + else if( s2 == "another" ) return DIFFICULTY_MEDIUM; + else if( s2 == "trick" ) return DIFFICULTY_MEDIUM; + else if( s2 == "standard" ) return DIFFICULTY_MEDIUM; + else if( s2 == "difficult") return DIFFICULTY_MEDIUM; + else if( s2 == "hard" ) return DIFFICULTY_HARD; + else if( s2 == "ssr" ) return DIFFICULTY_HARD; + else if( s2 == "maniac" ) return DIFFICULTY_HARD; + else if( s2 == "heavy" ) return DIFFICULTY_HARD; + else if( s2 == "smaniac" ) return DIFFICULTY_CHALLENGE; + else if( s2 == "challenge" )return DIFFICULTY_CHALLENGE; + else if( s2 == "expert" ) return DIFFICULTY_CHALLENGE; + else if( s2 == "oni" ) return DIFFICULTY_CHALLENGE; + else if( s2 == "edit" ) return DIFFICULTY_EDIT; + else return DIFFICULTY_INVALID; +} + + +static const CString CourseDifficultyNames[NUM_COURSE_DIFFICULTIES] = +{ + "Regular", + "Difficult", +}; +XToString( CourseDifficulty ); +XToThemedString( CourseDifficulty ); +StringToX( CourseDifficulty ); + +CourseDifficulty GetNextDisplayedCourseDifficulty( CourseDifficulty cd ) +{ + for( CourseDifficulty d=(CourseDifficulty)(cd+1); dIsCourseDifficultyShown(d) ) + return d; + } + return COURSE_DIFFICULTY_INVALID; +} diff --git a/stepmania/src/Difficulty.h b/stepmania/src/Difficulty.h new file mode 100644 index 0000000000..b766615aca --- /dev/null +++ b/stepmania/src/Difficulty.h @@ -0,0 +1,42 @@ +#ifndef DIFFICULTY_H +#define DIFFICULTY_H + +#include "EnumHelper.h" + +// +// Player number stuff +// +enum Difficulty +{ + DIFFICULTY_BEGINNER, // corresponds to DDREX Beginner + DIFFICULTY_EASY, // corresponds to Basic, Easy + DIFFICULTY_MEDIUM, // corresponds to Trick, Another, Standard, Normal + DIFFICULTY_HARD, // corresponds to Maniac, SSR, Heavy, Crazy + DIFFICULTY_CHALLENGE, // corresponds to 5th SMANIAC, MAX2 Challenge, EX Challenge + DIFFICULTY_EDIT, + NUM_DIFFICULTIES, + DIFFICULTY_INVALID +}; +#define FOREACH_Difficulty( dc ) FOREACH_ENUM( Difficulty, NUM_DIFFICULTIES, dc ) +const CString& DifficultyToString( Difficulty dc ); +CString DifficultyToThemedString( Difficulty dc ); +Difficulty StringToDifficulty( const CString& sDC ); + + +enum CourseDifficulty +{ + COURSE_DIFFICULTY_REGULAR, + COURSE_DIFFICULTY_DIFFICULT, + NUM_COURSE_DIFFICULTIES, + COURSE_DIFFICULTY_INVALID +}; +#define FOREACH_CourseDifficulty( cd ) FOREACH_ENUM( CourseDifficulty, NUM_COURSE_DIFFICULTIES, cd ) +#define FOREACH_DisplayedCourseDifficulty( cd ) for( CourseDifficulty cd=GetNextDisplayedCourseDifficulty((CourseDifficulty)-1); cd!=COURSE_DIFFICULTY_INVALID; cd=GetNextDisplayedCourseDifficulty(cd) ) + +const CString& CourseDifficultyToString( CourseDifficulty dc ); +CString CourseDifficultyToThemedString( CourseDifficulty dc ); +CourseDifficulty StringToCourseDifficulty( const CString& sDC ); + +CourseDifficulty GetNextDisplayedCourseDifficulty( CourseDifficulty pn ); + +#endif diff --git a/stepmania/src/GameConstantsAndTypes.cpp b/stepmania/src/GameConstantsAndTypes.cpp index 9ca95fb2b3..d34096d446 100644 --- a/stepmania/src/GameConstantsAndTypes.cpp +++ b/stepmania/src/GameConstantsAndTypes.cpp @@ -33,54 +33,6 @@ XToString( RadarCategory ); XToThemedString( RadarCategory ); -static const CString DifficultyNames[NUM_RADAR_CATEGORIES] = { - "Beginner", - "Easy", - "Medium", - "Hard", - "Challenge", - "Edit", -}; -XToString( Difficulty ); -XToThemedString( Difficulty ); - -/* We prefer the above names; recognize a number of others, too. (They'l - * get normalized when written to SMs, etc.) */ -Difficulty StringToDifficulty( const CString& sDC ) -{ - CString s2 = sDC; - s2.MakeLower(); - if( s2 == "beginner" ) return DIFFICULTY_BEGINNER; - else if( s2 == "easy" ) return DIFFICULTY_EASY; - else if( s2 == "basic" ) return DIFFICULTY_EASY; - else if( s2 == "light" ) return DIFFICULTY_EASY; - else if( s2 == "medium" ) return DIFFICULTY_MEDIUM; - else if( s2 == "another" ) return DIFFICULTY_MEDIUM; - else if( s2 == "trick" ) return DIFFICULTY_MEDIUM; - else if( s2 == "standard" ) return DIFFICULTY_MEDIUM; - else if( s2 == "difficult") return DIFFICULTY_MEDIUM; - else if( s2 == "hard" ) return DIFFICULTY_HARD; - else if( s2 == "ssr" ) return DIFFICULTY_HARD; - else if( s2 == "maniac" ) return DIFFICULTY_HARD; - else if( s2 == "heavy" ) return DIFFICULTY_HARD; - else if( s2 == "smaniac" ) return DIFFICULTY_CHALLENGE; - else if( s2 == "challenge" )return DIFFICULTY_CHALLENGE; - else if( s2 == "expert" ) return DIFFICULTY_CHALLENGE; - else if( s2 == "oni" ) return DIFFICULTY_CHALLENGE; - else if( s2 == "edit" ) return DIFFICULTY_EDIT; - else return DIFFICULTY_INVALID; -} - - -static const CString CourseDifficultyNames[NUM_COURSE_DIFFICULTIES] = { - "Regular", - "Difficult", -}; -XToString( CourseDifficulty ); -XToThemedString( CourseDifficulty ); -StringToX( CourseDifficulty ); - - static const CString PlayModeNames[NUM_PLAY_MODES] = { "Arcade", "Nonstop", diff --git a/stepmania/src/GameConstantsAndTypes.h b/stepmania/src/GameConstantsAndTypes.h index 9232eb7eb2..dd564578a3 100644 --- a/stepmania/src/GameConstantsAndTypes.h +++ b/stepmania/src/GameConstantsAndTypes.h @@ -14,6 +14,7 @@ */ #include "PlayerNumber.h" // TODO: Get rid of this dependency. -Chris +#include "Difficulty.h" // TODO: Get rid of this dependency. #include "EnumHelper.h" // @@ -84,35 +85,6 @@ struct RadarValues }; -enum Difficulty -{ - DIFFICULTY_BEGINNER, // corresponds to DDREX Beginner - DIFFICULTY_EASY, // corresponds to Basic, Easy - DIFFICULTY_MEDIUM, // corresponds to Trick, Another, Standard, Normal - DIFFICULTY_HARD, // corresponds to Maniac, SSR, Heavy, Crazy - DIFFICULTY_CHALLENGE, // corresponds to 5th SMANIAC, MAX2 Challenge, EX Challenge - DIFFICULTY_EDIT, - NUM_DIFFICULTIES, - DIFFICULTY_INVALID -}; -#define FOREACH_Difficulty( dc ) FOREACH_ENUM( Difficulty, NUM_DIFFICULTIES, dc ) -const CString& DifficultyToString( Difficulty dc ); -CString DifficultyToThemedString( Difficulty dc ); -Difficulty StringToDifficulty( const CString& sDC ); - - -enum CourseDifficulty -{ - COURSE_DIFFICULTY_REGULAR, - COURSE_DIFFICULTY_DIFFICULT, - NUM_COURSE_DIFFICULTIES, - COURSE_DIFFICULTY_INVALID -}; -#define FOREACH_CourseDifficulty( cd ) FOREACH_ENUM( CourseDifficulty, NUM_COURSE_DIFFICULTIES, cd ) -const CString& CourseDifficultyToString( CourseDifficulty dc ); -CString CourseDifficultyToThemedString( CourseDifficulty dc ); -CourseDifficulty StringToCourseDifficulty( const CString& sDC ); - enum StepsType {