Files
itgmania212121/stepmania/src/GameConstantsAndTypes.cpp
T

288 lines
7.1 KiB
C++
Raw Normal View History

2003-02-16 04:01:45 +00:00
#include "global.h"
2002-07-27 19:29:51 +00:00
/*
-----------------------------------------------------------------------------
File: GameConstantsAndTypes.cpp
Desc: See header.
Copyright (c) 2001-2002 by the person(s) listed below. All rights reserved.
Chris Danford
-----------------------------------------------------------------------------
*/
#include "GameConstantsAndTypes.h"
#include "GameState.h"
#include "RageUtil.h"
2004-03-07 04:34:49 +00:00
#include "ThemeManager.h"
2002-07-27 19:29:51 +00:00
2003-04-25 05:45:53 +00:00
2004-02-10 09:42:01 +00:00
CString RadarCategoryToString( RadarCategory cat )
2003-04-22 08:43:12 +00:00
{
switch( cat )
{
case RADAR_STREAM: return "stream";
case RADAR_VOLTAGE: return "voltage";
case RADAR_AIR: return "air";
case RADAR_FREEZE: return "freeze";
case RADAR_CHAOS: return "chaos";
2003-11-26 04:21:59 +00:00
case RADAR_NUM_TAPS_AND_HOLDS: return "taps";
case RADAR_NUM_JUMPS: return "jumps";
case RADAR_NUM_HOLDS: return "holds";
case RADAR_NUM_MINES: return "mines";
case RADAR_NUM_HANDS: return "hands";
2003-04-22 08:43:12 +00:00
default: ASSERT(0); return ""; // invalid
}
}
2002-07-27 19:29:51 +00:00
2002-09-29 05:06:18 +00:00
CString DifficultyToString( Difficulty dc )
2002-07-27 19:29:51 +00:00
{
switch( dc )
{
case DIFFICULTY_BEGINNER: return "beginner";
case DIFFICULTY_EASY: return "easy";
case DIFFICULTY_MEDIUM: return "medium";
case DIFFICULTY_HARD: return "hard";
case DIFFICULTY_CHALLENGE: return "challenge";
2004-02-08 01:05:53 +00:00
case DIFFICULTY_EDIT: return "edit";
default: ASSERT(0); return ""; // invalid Difficulty
2002-07-27 19:29:51 +00:00
}
}
/* We prefer the above names; recognize a number of others, too. (They'l
* get normalized when written to SMs, etc.) */
2002-09-29 05:06:18 +00:00
Difficulty StringToDifficulty( CString sDC )
2002-07-27 19:29:51 +00:00
{
sDC.MakeLower();
if( sDC == "beginner" ) return DIFFICULTY_BEGINNER;
else if( sDC == "easy" ) return DIFFICULTY_EASY;
else if( sDC == "basic" ) return DIFFICULTY_EASY;
else if( sDC == "light" ) return DIFFICULTY_EASY;
else if( sDC == "medium" ) return DIFFICULTY_MEDIUM;
else if( sDC == "another" ) return DIFFICULTY_MEDIUM;
else if( sDC == "trick" ) return DIFFICULTY_MEDIUM;
else if( sDC == "standard" ) return DIFFICULTY_MEDIUM;
2003-09-10 08:44:08 +00:00
else if( sDC == "difficult") return DIFFICULTY_MEDIUM;
else if( sDC == "hard" ) return DIFFICULTY_HARD;
else if( sDC == "ssr" ) return DIFFICULTY_HARD;
else if( sDC == "maniac" ) return DIFFICULTY_HARD;
else if( sDC == "heavy" ) return DIFFICULTY_HARD;
else if( sDC == "smaniac" ) return DIFFICULTY_CHALLENGE;
else if( sDC == "challenge" ) return DIFFICULTY_CHALLENGE;
2003-09-10 08:44:08 +00:00
else if( sDC == "expert" ) return DIFFICULTY_CHALLENGE;
else if( sDC == "oni" ) return DIFFICULTY_CHALLENGE;
2004-02-08 01:05:53 +00:00
else if( sDC == "edit" ) return DIFFICULTY_EDIT;
else return DIFFICULTY_INVALID;
2002-07-27 19:29:51 +00:00
}
CString CourseDifficultyToString( CourseDifficulty dc )
{
switch( dc )
{
case COURSE_DIFFICULTY_REGULAR: return "regular";
case COURSE_DIFFICULTY_DIFFICULT: return "difficult";
default: ASSERT(0); return ""; // invalid Difficulty
}
}
/* We prefer the above names; recognize a number of others, too. (They'l
* get normalized when written to SMs, etc.) */
CourseDifficulty StringToCourseDifficulty( CString sDC )
{
sDC.MakeLower();
if( sDC == "regular" ) return COURSE_DIFFICULTY_REGULAR;
else if( sDC == "difficult" ) return COURSE_DIFFICULTY_DIFFICULT;
else return COURSE_DIFFICULTY_INVALID;
}
CString PlayModeToString( PlayMode pm )
{
switch( pm )
{
2003-08-19 04:27:50 +00:00
case PLAY_MODE_ARCADE: return "arcade";
case PLAY_MODE_ONI: return "oni";
case PLAY_MODE_NONSTOP: return "nonstop";
case PLAY_MODE_ENDLESS: return "endless";
case PLAY_MODE_BATTLE: return "battle";
case PLAY_MODE_RAVE: return "rave";
default: ASSERT(0); return "";
}
}
PlayMode StringToPlayMode( CString s )
{
for( int i=0; i<NUM_PLAY_MODES; i++ )
if( PlayModeToString((PlayMode)i).CompareNoCase(s) == 0 )
return (PlayMode)i;
return PLAY_MODE_INVALID;
}
2003-01-26 07:33:03 +00:00
RankingCategory AverageMeterToRankingCategory( float fAverageMeter )
{
2003-01-26 07:33:03 +00:00
if( fAverageMeter <= 3 ) return RANKING_A;
else if( fAverageMeter <= 6 ) return RANKING_B;
else if( fAverageMeter <= 9 ) return RANKING_C;
else return RANKING_D;
}
CString RankingCategoryToString( RankingCategory rc )
{
switch( rc )
{
case RANKING_A: return "A";
case RANKING_B: return "B";
case RANKING_C: return "C";
case RANKING_D: return "D";
default: FAIL_M( ssprintf("%i", rc) );
}
}
RankingCategory StringToRankingCategory( CString rc )
{
if( rc == "A" ) return RANKING_A;
if( rc == "B" ) return RANKING_B;
if( rc == "C" ) return RANKING_C;
if( rc == "D" ) return RANKING_D;
return RANKING_INVALID;
}
CString CoinModeToString( CoinMode cm )
{
switch( cm )
{
case COIN_HOME: return "home";
case COIN_PAY: return "pay";
case COIN_FREE: return "free";
default: ASSERT(0); return "";
}
}
2003-06-16 17:28:58 +00:00
2003-07-20 06:26:29 +00:00
static const char *SongSortOrderNames[NUM_SORT_ORDERS] = {
"PREFERRED",
"GROUP",
"TITLE",
"BPM",
"PLAYERS BEST",
"TOP GRADE",
"ARTIST",
"EASY METER",
"MEDIUM METER",
"HARD METER",
2004-01-27 05:37:43 +00:00
"CHALLENGE METER",
2003-07-20 06:26:29 +00:00
"SORT",
2004-01-23 04:40:38 +00:00
"MODE",
2003-07-20 06:26:29 +00:00
"COURSES",
"NONSTOP",
"ONI",
"ENDLESS",
2003-07-20 06:26:29 +00:00
"ROULETTE"
};
2003-06-16 17:28:58 +00:00
CString SongSortOrderToString( SongSortOrder so )
{
2003-07-20 06:26:29 +00:00
ASSERT(so < NUM_SORT_ORDERS);
return SongSortOrderNames[so];
}
SongSortOrder StringToSongSortOrder( CString str )
{
for( unsigned i = 0; i < NUM_SORT_ORDERS; ++i)
if( !str.CompareNoCase(SongSortOrderNames[i]) )
return (SongSortOrder)i;
2003-07-20 06:40:04 +00:00
return SORT_INVALID;
2003-06-16 17:28:58 +00:00
}
CString TapNoteScoreToString( TapNoteScore tns )
{
switch( tns )
{
2004-01-02 08:43:14 +00:00
case TNS_NONE: return "None";
case TNS_HIT_MINE: return "HitMine";
case TNS_MISS: return "Miss";
case TNS_BOO: return "Boo";
case TNS_GOOD: return "Good";
case TNS_GREAT: return "Great";
case TNS_PERFECT: return "Perfect";
case TNS_MARVELOUS: return "Marvelous";
default: ASSERT(0); return ""; // invalid
}
}
CString MemoryCardStateToString( MemoryCardState mcs )
{
switch( mcs )
{
case MEMORY_CARD_STATE_READY: return "ready";
case MEMORY_CARD_STATE_TOO_LATE: return "late";
case MEMORY_CARD_STATE_WRITE_ERROR: return "error";
case MEMORY_CARD_STATE_NO_CARD: return "none";
default: ASSERT(0); return "";
}
}
2004-03-07 04:34:49 +00:00
#define XToString(X) \
CString X##ToString( X x ) \
{ \
2004-03-11 10:58:36 +00:00
ASSERT(unsigned(x) < ARRAYSIZE(X##Names)); \
2004-03-07 04:34:49 +00:00
return X##Names[x]; \
}
#define XToThemedString(X) \
CString X##ToThemedString( X x ) \
{ \
return THEME->GetMetric( #X, X##ToString(x) ); \
}
#define StringToX(X) \
X StringTo##X( CString s ) \
{ \
unsigned i; \
for( i = 0; i < ARRAYSIZE(X##Names); ++i ) \
if( !s.CompareNoCase(X##Names[i]) ) \
return (X)i; \
return (X)i; \
}
static const char *PerDifficultyAwardNames[NUM_PER_DIFFICULTY_AWARDS] = {
"FullComboGreats",
"FullComboPerfects",
"FullComboMarvelouses",
"SingleDigitGreats",
"SingleDigitPerfects",
"Greats80Percent",
"Greats90Percent",
"Greats100Percent",
};
XToString( PerDifficultyAward );
XToThemedString( PerDifficultyAward );
StringToX( PerDifficultyAward );
// The number is not at the front so that these strings can be used as XML entity names
// The number is not at the back so that "1000" and "10000" don't conflict when
// searching for theme elements.
static const char *PeakComboAwardNames[NUM_PEAK_COMBO_AWARDS] = {
"Peak1000Combo",
"Peak2000Combo",
"Peak3000Combo",
"Peak4000Combo",
"Peak5000Combo",
"Peak6000Combo",
"Peak7000Combo",
"Peak8000Combo",
"Peak9000Combo",
"Peak10000Combo",
};
XToString( PeakComboAward );
XToThemedString( PeakComboAward );
StringToX( PeakComboAward );