move CourseDifficulty names into the course loader/writer; they're
retained there for compatibility but not used anywhere else
This commit is contained in:
@@ -17,6 +17,25 @@
|
|||||||
|
|
||||||
const int MAX_EDIT_COURSE_SIZE_BYTES = 30*1024; // 30KB
|
const int MAX_EDIT_COURSE_SIZE_BYTES = 30*1024; // 30KB
|
||||||
|
|
||||||
|
const char *g_CRSDifficultyNames[] =
|
||||||
|
{
|
||||||
|
"Beginner",
|
||||||
|
"Easy",
|
||||||
|
"Regular",
|
||||||
|
"Difficult",
|
||||||
|
"Challenge",
|
||||||
|
"Edit",
|
||||||
|
};
|
||||||
|
|
||||||
|
static CourseDifficulty CRSStringToDifficulty( const RString& s )
|
||||||
|
{
|
||||||
|
FOREACH_Difficulty(i)
|
||||||
|
if( !s.CompareNoCase(g_CRSDifficultyNames[i]) )
|
||||||
|
return i;
|
||||||
|
return Difficulty_Invalid;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
bool CourseLoaderCRS::LoadFromBuffer( const RString &sPath, const RString &sBuffer, Course &out )
|
bool CourseLoaderCRS::LoadFromBuffer( const RString &sPath, const RString &sBuffer, Course &out )
|
||||||
{
|
{
|
||||||
MsdFile msd;
|
MsdFile msd;
|
||||||
@@ -72,7 +91,7 @@ bool CourseLoaderCRS::LoadFromMsd( const RString &sPath, const MsdFile &msd, Cou
|
|||||||
}
|
}
|
||||||
else if( sParams.params.size() == 3 )
|
else if( sParams.params.size() == 3 )
|
||||||
{
|
{
|
||||||
const CourseDifficulty cd = StringToCourseDifficulty( sParams[1] );
|
const CourseDifficulty cd = CRSStringToDifficulty( sParams[1] );
|
||||||
if( cd == Difficulty_Invalid )
|
if( cd == Difficulty_Invalid )
|
||||||
{
|
{
|
||||||
LOG->UserLog( "Course file", sPath, "contains an invalid #METER string: \"%s\"", sParams[1].c_str() );
|
LOG->UserLog( "Course file", sPath, "contains an invalid #METER string: \"%s\"", sParams[1].c_str() );
|
||||||
|
|||||||
@@ -7,6 +7,12 @@
|
|||||||
#include "song.h"
|
#include "song.h"
|
||||||
#include "RageFileDriverMemory.h"
|
#include "RageFileDriverMemory.h"
|
||||||
|
|
||||||
|
extern const char *g_CRSDifficultyNames[]; // in CourseLoaderCRS
|
||||||
|
|
||||||
|
static RString DifficultyToCRSString( CourseDifficulty iVal )
|
||||||
|
{
|
||||||
|
return g_CRSDifficultyNames[iVal];
|
||||||
|
}
|
||||||
|
|
||||||
bool CourseWriterCRS::Write( const Course &course, const RString &sPath, bool bSavingCache )
|
bool CourseWriterCRS::Write( const Course &course, const RString &sPath, bool bSavingCache )
|
||||||
{
|
{
|
||||||
@@ -43,7 +49,7 @@ bool CourseWriterCRS::Write( const Course &course, RageFileBasic &f, bool bSavin
|
|||||||
{
|
{
|
||||||
if( course.m_iCustomMeter[cd] == -1 )
|
if( course.m_iCustomMeter[cd] == -1 )
|
||||||
continue;
|
continue;
|
||||||
f.PutLine( ssprintf("#METER:%s:%i;", CourseDifficultyToString(cd).c_str(), course.m_iCustomMeter[cd]) );
|
f.PutLine( ssprintf("#METER:%s:%i;", DifficultyToCRSString(cd).c_str(), course.m_iCustomMeter[cd]) );
|
||||||
}
|
}
|
||||||
|
|
||||||
if( bSavingCache )
|
if( bSavingCache )
|
||||||
|
|||||||
@@ -47,20 +47,6 @@ Difficulty StringToDifficulty( const RString& sDC )
|
|||||||
else return Difficulty_Invalid;
|
else return Difficulty_Invalid;
|
||||||
}
|
}
|
||||||
|
|
||||||
static const char *CourseDifficultyNames[] =
|
|
||||||
{
|
|
||||||
"Beginner",
|
|
||||||
"Easy",
|
|
||||||
"Regular",
|
|
||||||
"Difficult",
|
|
||||||
"Challenge",
|
|
||||||
"Edit",
|
|
||||||
};
|
|
||||||
const RString& CourseDifficultyToString( CourseDifficulty x )
|
|
||||||
{
|
|
||||||
static auto_ptr<RString> as_CourseDifficultyName[NUM_CourseDifficulty+2];
|
|
||||||
return EnumToString( x, NUM_CourseDifficulty, CourseDifficultyNames, as_CourseDifficultyName );
|
|
||||||
}
|
|
||||||
|
|
||||||
const RString &CourseDifficultyToLocalizedString( CourseDifficulty x )
|
const RString &CourseDifficultyToLocalizedString( CourseDifficulty x )
|
||||||
{
|
{
|
||||||
@@ -76,16 +62,6 @@ const RString &CourseDifficultyToLocalizedString( CourseDifficulty x )
|
|||||||
return g_CourseDifficultyName[x]->GetValue();
|
return g_CourseDifficultyName[x]->GetValue();
|
||||||
}
|
}
|
||||||
|
|
||||||
CourseDifficulty StringToCourseDifficulty( const RString& s )
|
|
||||||
{
|
|
||||||
RString s2 = s;
|
|
||||||
s2.MakeLower();
|
|
||||||
for( unsigned i = 0; i < ARRAYLEN(CourseDifficultyNames); ++i )
|
|
||||||
if( !s2.CompareNoCase(CourseDifficultyNames[i]) )
|
|
||||||
return (CourseDifficulty)i;
|
|
||||||
return CourseDifficulty_Invalid;
|
|
||||||
}
|
|
||||||
|
|
||||||
LuaFunction( CourseDifficultyToLocalizedString, CourseDifficultyToLocalizedString(Enum::Check<Difficulty>(L, 1)) );
|
LuaFunction( CourseDifficultyToLocalizedString, CourseDifficultyToLocalizedString(Enum::Check<Difficulty>(L, 1)) );
|
||||||
|
|
||||||
CourseDifficulty GetNextShownCourseDifficulty( CourseDifficulty cd )
|
CourseDifficulty GetNextShownCourseDifficulty( CourseDifficulty cd )
|
||||||
|
|||||||
@@ -30,9 +30,7 @@ typedef Difficulty CourseDifficulty;
|
|||||||
#define FOREACH_CourseDifficulty FOREACH_Difficulty
|
#define FOREACH_CourseDifficulty FOREACH_Difficulty
|
||||||
#define FOREACH_ShownCourseDifficulty( cd ) for( Difficulty cd=GetNextShownCourseDifficulty((CourseDifficulty)-1); cd!=Difficulty_Invalid; cd=GetNextShownCourseDifficulty(cd) )
|
#define FOREACH_ShownCourseDifficulty( cd ) for( Difficulty cd=GetNextShownCourseDifficulty((CourseDifficulty)-1); cd!=Difficulty_Invalid; cd=GetNextShownCourseDifficulty(cd) )
|
||||||
|
|
||||||
const RString& CourseDifficultyToString( Difficulty dc );
|
|
||||||
const RString& CourseDifficultyToLocalizedString( Difficulty dc );
|
const RString& CourseDifficultyToLocalizedString( Difficulty dc );
|
||||||
Difficulty StringToCourseDifficulty( const RString& sDC );
|
|
||||||
|
|
||||||
Difficulty GetNextShownCourseDifficulty( Difficulty pn );
|
Difficulty GetNextShownCourseDifficulty( Difficulty pn );
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user