diff --git a/stepmania/src/GameConstantsAndTypes.cpp b/stepmania/src/GameConstantsAndTypes.cpp index b4d383f3b2..484a5931ab 100644 --- a/stepmania/src/GameConstantsAndTypes.cpp +++ b/stepmania/src/GameConstantsAndTypes.cpp @@ -166,19 +166,10 @@ TapNoteScore StringToTapNoteScore( const RString &s ) else if( s == "Perfect" ) return TNS_W2; else if( s == "Marvelous" ) return TNS_W1; - return TNS_INVALID; + return TNS_Invalid; } XToLocalizedString( TapNoteScore ); -LuaFunction( TapNoteScoreToLocalizedString, TapNoteScoreToLocalizedString((TapNoteScore) IArg(1)) ); -static void LuaTapNoteScores( lua_State* L ) -{ - FOREACH_TapNoteScore( i ) - { - RString s = TapNoteScoreNames[i]; - LUA->SetGlobal( "TNS_"+s, i ); - } -} -REGISTER_WITH_LUA_FUNCTION( LuaTapNoteScores ); +LuaFunction( TapNoteScoreToLocalizedString, TapNoteScoreToLocalizedString(Enum::Check(L, 1)) ); static const char *HoldNoteScoreNames[] = { @@ -187,6 +178,7 @@ static const char *HoldNoteScoreNames[] = { "Held", }; XToString( HoldNoteScore, NUM_HoldNoteScore ); +LuaXType( HoldNoteScore ); HoldNoteScore StringToHoldNoteScore( const RString &s ) { // for backward compatibility @@ -198,18 +190,9 @@ HoldNoteScore StringToHoldNoteScore( const RString &s ) else if( s == "LetGo" ) return HNS_LetGo; else if( s == "Held" ) return HNS_Held; - return HNS_INVALID; + return HNS_Invalid; } XToLocalizedString( HoldNoteScore ); -static void LuaHoldNoteScores( lua_State* L ) -{ - FOREACH_HoldNoteScore( i ) - { - RString s = HoldNoteScoreNames[i]; - LUA->SetGlobal( "HNS_"+s, i ); - } -} -REGISTER_WITH_LUA_FUNCTION( LuaHoldNoteScores ); static const char *MemoryCardStateNames[] = { @@ -326,16 +309,7 @@ static const char *GoalTypeNames[] = { }; XToString( GoalType, NUM_GoalType ); StringToX( GoalType ); -static void LuaGoalType(lua_State* L) -{ - FOREACH_GoalType( gt ) - { - RString s = GoalTypeNames[gt]; - s.MakeUpper(); - LUA->SetGlobal( "GOAL_"+s, gt ); - } -} -REGISTER_WITH_LUA_FUNCTION( LuaGoalType ); +LuaXType( GoalType ); static const char *EditModeNames[] = { "Practice", diff --git a/stepmania/src/GameConstantsAndTypes.h b/stepmania/src/GameConstantsAndTypes.h index fd4e9591fb..034b73c86f 100644 --- a/stepmania/src/GameConstantsAndTypes.h +++ b/stepmania/src/GameConstantsAndTypes.h @@ -143,7 +143,7 @@ enum TapNoteScore { TNS_W2, TNS_W1, NUM_TapNoteScore, - TNS_INVALID, + TNS_Invalid, }; #define FOREACH_TapNoteScore( tns ) FOREACH_ENUM( TapNoteScore, NUM_TapNoteScore, tns ) const RString& TapNoteScoreToString( TapNoteScore tns ); @@ -158,7 +158,7 @@ enum HoldNoteScore HNS_LetGo, // the HoldNote has passed and they missed it HNS_Held, // the HoldNote has passed and was successfully held all the way through NUM_HoldNoteScore, - HNS_INVALID, + HNS_Invalid, }; #define FOREACH_HoldNoteScore( hns ) FOREACH_ENUM( HoldNoteScore, NUM_HoldNoteScore, hns ) const RString& HoldNoteScoreToString( HoldNoteScore hns ); @@ -320,7 +320,7 @@ enum Premium PREMIUM_DOUBLE, PREMIUM_JOINT, NUM_Premium, - Premium_Invalidz + Premium_Invalid }; #define FOREACH_Premium( i ) FOREACH_ENUM( Premium, NUM_Premium, i ) const RString& PremiumToString( Premium p ); @@ -409,6 +409,7 @@ enum GoalType #define FOREACH_GoalType( gt ) FOREACH_ENUM( GoalType, NUM_GoalType, gt ) const RString& GoalTypeToString( GoalType gt ); GoalType StringToGoalType( const RString& s ); +LuaDeclareType( GoalType ); enum EditMode diff --git a/stepmania/src/PlayerStageStats.cpp b/stepmania/src/PlayerStageStats.cpp index ea973e9ee1..488920b8dc 100644 --- a/stepmania/src/PlayerStageStats.cpp +++ b/stepmania/src/PlayerStageStats.cpp @@ -32,8 +32,8 @@ void PlayerStageStats::Init() iSongsPassed = iSongsPlayed = 0; fLifeRemainingSeconds = 0; fCaloriesBurned = 0; - tnsLast = TNS_INVALID; - hnsLast = HNS_INVALID; + tnsLast = TNS_Invalid; + hnsLast = HNS_Invalid; ZERO( iTapNoteScores ); ZERO( iHoldNoteScores ); diff --git a/stepmania/src/Profile.cpp b/stepmania/src/Profile.cpp index 4965311973..199c1bc39e 100644 --- a/stepmania/src/Profile.cpp +++ b/stepmania/src/Profile.cpp @@ -1915,7 +1915,7 @@ public: static int GetWeightPounds( T* p, lua_State *L ) { lua_pushnumber(L, p->m_iWeightPounds ); return 1; } static int SetWeightPounds( T* p, lua_State *L ) { p->m_iWeightPounds = IArg(1); return 0; } static int GetGoalType( T* p, lua_State *L ) { lua_pushnumber(L, p->m_GoalType ); return 1; } - static int SetGoalType( T* p, lua_State *L ) { p->m_GoalType = (GoalType)IArg(1); return 0; } + static int SetGoalType( T* p, lua_State *L ) { p->m_GoalType = Enum::Check(L, 1); return 0; } static int GetGoalCalories( T* p, lua_State *L ) { lua_pushnumber(L, p->m_iGoalCalories ); return 1; } static int SetGoalCalories( T* p, lua_State *L ) { p->m_iGoalCalories = IArg(1); return 0; } static int GetGoalSeconds( T* p, lua_State *L ) { lua_pushnumber(L, p->m_iGoalSeconds ); return 1; } diff --git a/stepmania/src/ScoreKeeperNormal.cpp b/stepmania/src/ScoreKeeperNormal.cpp index e914d66fc3..88ecab74bc 100644 --- a/stepmania/src/ScoreKeeperNormal.cpp +++ b/stepmania/src/ScoreKeeperNormal.cpp @@ -36,8 +36,8 @@ void ScoreKeeperNormal::Load( /* True if a jump is one to combo, false if combo is purely based on tap count. */ m_bComboIsPerRow = THEME->GetMetricB( "Gameplay", "ComboIsPerRow" ); - m_MinScoreToContinueCombo = (TapNoteScore) THEME->GetMetricI( "Gameplay", "MinScoreToContinueCombo" ); - m_MinScoreToMaintainCombo = (TapNoteScore) THEME->GetMetricI( "Gameplay", "MinScoreToMaintainCombo" ); + m_MinScoreToContinueCombo.Load( "Gameplay", "MinScoreToContinueCombo" ); + m_MinScoreToMaintainCombo.Load( "Gameplay", "MinScoreToMaintainCombo" ); // // Fill in STATSMAN->m_CurStageStats, calculate multiplier diff --git a/stepmania/src/ScoreKeeperNormal.h b/stepmania/src/ScoreKeeperNormal.h index c16099fdb8..37060c1bc4 100644 --- a/stepmania/src/ScoreKeeperNormal.h +++ b/stepmania/src/ScoreKeeperNormal.h @@ -6,6 +6,7 @@ #include "ScoreKeeper.h" #include "Attack.h" #include "ScreenMessage.h" +#include "ThemeMetric.h" class Steps; class Song; struct RadarValues; @@ -26,8 +27,8 @@ class ScoreKeeperNormal: public ScoreKeeper bool m_bIsBeginner; bool m_bComboIsPerRow; - TapNoteScore m_MinScoreToContinueCombo; - TapNoteScore m_MinScoreToMaintainCombo; + ThemeMetric m_MinScoreToContinueCombo; + ThemeMetric m_MinScoreToMaintainCombo; vector m_apSteps;