simplify LuaXType
This commit is contained in:
@@ -27,7 +27,7 @@ static const char *CourseTypeNames[] = {
|
||||
};
|
||||
XToString( CourseType, NUM_CourseType );
|
||||
XToLocalizedString( CourseType );
|
||||
LuaXType( CourseType, NUM_CourseType, "CourseType_" );
|
||||
LuaXType( CourseType );
|
||||
LuaFunction( CourseTypeToLocalizedString, CourseTypeToLocalizedString( Enum::Check<CourseType>( L, 1 ) ) );
|
||||
|
||||
|
||||
|
||||
@@ -17,7 +17,7 @@ static const char *DifficultyNames[] = {
|
||||
};
|
||||
XToString( Difficulty, NUM_Difficulty );
|
||||
XToLocalizedString( Difficulty );
|
||||
LuaXType( Difficulty, NUM_Difficulty , "Difficulty_" );
|
||||
LuaXType( Difficulty );
|
||||
|
||||
LuaFunction( DifficultyToLocalizedString, DifficultyToLocalizedString( Enum::Check<Difficulty>(L, 1)) );
|
||||
|
||||
|
||||
@@ -134,16 +134,16 @@ static const RString EMPTY_STRING;
|
||||
namespace LuaHelpers { bool FromStack( lua_State *L, X &Object, int iOffset ); } \
|
||||
namespace LuaHelpers { void Push( const X &Object, lua_State *L ); }
|
||||
|
||||
#define LuaXType(X, CNT, Prefix) \
|
||||
#define LuaXType(X) \
|
||||
static void Lua##X(lua_State* L) \
|
||||
{ \
|
||||
EnumTraits<X>::Invalid = enum_add2( CNT, 1 ); \
|
||||
EnumTraits<X>::Invalid = enum_add2( NUM_##X, 1 ); \
|
||||
/* Create the EnumToString table: { "UnlockEntry_ArcadePoints", "UnlockEntry_DancePoints" } */ \
|
||||
lua_newtable( L ); \
|
||||
FOREACH_ENUM( X, CNT, i ) \
|
||||
FOREACH_ENUM( X, NUM_##X, i ) \
|
||||
{ \
|
||||
RString s = X##Names[i]; \
|
||||
lua_pushstring( L, Prefix+s ); \
|
||||
lua_pushstring( L, (#X "_")+s ); \
|
||||
lua_rawseti( L, -2, i+1 ); /* 1-based */ \
|
||||
} \
|
||||
EnumTraits<X>::EnumToString.SetFromStack( L ); \
|
||||
@@ -151,10 +151,10 @@ static void Lua##X(lua_State* L) \
|
||||
lua_setglobal( L, #X ); \
|
||||
/* Create the StringToEnum table: { "UnlockEntry_ArcadePoints" = 0, "UnlockEntry_DancePoints" = 1 } */ \
|
||||
lua_newtable( L ); \
|
||||
FOREACH_ENUM( X, CNT, i ) \
|
||||
FOREACH_ENUM( X, NUM_##X, i ) \
|
||||
{ \
|
||||
RString s = X##Names[i]; \
|
||||
lua_pushstring( L, Prefix+s ); \
|
||||
lua_pushstring( L, (#X "_")+s ); \
|
||||
lua_pushnumber( L, i ); /* 0-based */ \
|
||||
lua_rawset( L, -3 ); \
|
||||
} \
|
||||
|
||||
@@ -69,7 +69,7 @@ XToString( PlayMode, NUM_PlayMode );
|
||||
XToLocalizedString( PlayMode );
|
||||
StringToX( PlayMode );
|
||||
LuaFunction( PlayModeToLocalizedString, PlayModeToLocalizedString((PlayMode) IArg(1)) );
|
||||
LuaXType( PlayMode, NUM_PlayMode, "PlayMode_" )
|
||||
LuaXType( PlayMode );
|
||||
|
||||
RankingCategory AverageMeterToRankingCategory( int iAverageMeter )
|
||||
{
|
||||
@@ -193,7 +193,7 @@ static const char *TapNoteScoreNames[] = {
|
||||
"W1",
|
||||
};
|
||||
XToString( TapNoteScore, NUM_TapNoteScore );
|
||||
LuaXType( TapNoteScore, NUM_TapNoteScore, "TapNoteScore_" );
|
||||
LuaXType( TapNoteScore );
|
||||
TapNoteScore StringToTapNoteScore( const RString &s )
|
||||
{
|
||||
// new style
|
||||
@@ -403,7 +403,7 @@ static const char *EditModeNames[] = {
|
||||
};
|
||||
XToString( EditMode, NUM_EditMode );
|
||||
StringToX( EditMode );
|
||||
LuaXType( EditMode, NUM_EditMode, "EditMode_" );
|
||||
LuaXType( EditMode );
|
||||
|
||||
static const char *StageNames[] = {
|
||||
"1",
|
||||
@@ -422,7 +422,7 @@ static const char *StageNames[] = {
|
||||
"Demo",
|
||||
};
|
||||
XToString( Stage, NUM_Stage );
|
||||
LuaXType( Stage, NUM_Stage, "Stage_" );
|
||||
LuaXType( Stage );
|
||||
|
||||
|
||||
static const char *MultiPlayerStatusNames[] = {
|
||||
|
||||
@@ -30,7 +30,7 @@ static const char *GradeNames[] = {
|
||||
"Tier20",
|
||||
"Failed",
|
||||
};
|
||||
LuaXType( Grade, NUM_Grade, "Grade_" );
|
||||
LuaXType( Grade );
|
||||
|
||||
RString GradeToLocalizedString( Grade g )
|
||||
{
|
||||
|
||||
@@ -8,7 +8,7 @@ static const char *ModsLevelNames[] = {
|
||||
"Stage",
|
||||
"Song",
|
||||
};
|
||||
LuaXType( ModsLevel, NUM_ModsLevel, "ModsLevel_" )
|
||||
LuaXType( ModsLevel );
|
||||
|
||||
/*
|
||||
* (c) 2006 Steve Checkoway
|
||||
|
||||
@@ -29,7 +29,7 @@ static const char *NoteTypeNames[] = {
|
||||
"192nd",
|
||||
};
|
||||
XToString( NoteType, NUM_NoteType );
|
||||
LuaXType( NoteType, NUM_NoteType, "NoteType_" )
|
||||
LuaXType( NoteType )
|
||||
XToLocalizedString( NoteType );
|
||||
|
||||
float NoteTypeToBeat( NoteType nt )
|
||||
|
||||
@@ -36,7 +36,7 @@ static const char *UnlockRequirementNames[] =
|
||||
};
|
||||
XToString( UnlockRequirement, NUM_UnlockRequirement );
|
||||
StringToX( UnlockRequirement );
|
||||
LuaXType( UnlockRequirement, NUM_UnlockRequirement, "UnlockRequirement_" );
|
||||
LuaXType( UnlockRequirement );
|
||||
|
||||
static const char *UnlockRewardTypeNames[] =
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user