New Lua Bindings: Profile:SetCharacter(sCharID), GAMESTATE:GetCharacter(PlayerNumber), GAMESTATE:SetCharacter(PlayerNumber,sCharID)

This commit is contained in:
AJ Kelly
2010-12-18 14:42:07 -06:00
parent ac92794e43
commit a8de96107f
4 changed files with 21 additions and 0 deletions
+3
View File
@@ -16,6 +16,9 @@ sm-ssc v1.2 | 201012xx
20101218
--------
* [MusicWheelItem] Add OverPart. [freem]
* [Profile] SetCharacter(sCharID) Lua binding added. [freem]
* [GameState] GetCharacter(PlayerNumber) and SetCharacter(PlayerNumber,sCharID)
Lua bindings added. [freem]
20101217
--------
+9
View File
@@ -2448,6 +2448,13 @@ public:
DEFINE_METHOD( GetCurMusicSeconds, m_fMusicSeconds )
DEFINE_METHOD( GetWorkoutGoalComplete, m_bWorkoutGoalComplete )
static int GetCharacter( T* p, lua_State *L ) { p->m_pCurCharacters[Enum::Check<PlayerNumber>(L, 1)]->PushSelf(L); return 1; }
static int SetCharacter( T* p, lua_State *L ){
Character* c = CHARMAN->GetCharacterFromID(SArg(2));
if (c)
p->m_pCurCharacters[Enum::Check<PlayerNumber>(L, 1)] = c;
return 0;
}
LunaGameState()
{
@@ -2543,6 +2550,8 @@ public:
ADD_METHOD( UnjoinPlayer );
ADD_METHOD( GetSongPercent );
ADD_METHOD( GetCurMusicSeconds );
ADD_METHOD( GetCharacter );
ADD_METHOD( SetCharacter );
}
};
+8
View File
@@ -201,6 +201,12 @@ Character *Profile::GetCharacter() const
return CHARMAN->GetDefaultCharacter();
}
void Profile::SetCharacter(const RString sCharacterID)
{
if(CHARMAN->GetCharacterFromID(sCharacterID))
m_sCharacterID = sCharacterID;
}
static RString FormatCalories( float fCals )
{
return Commify((int)fCals) + " Cal";
@@ -1957,6 +1963,7 @@ public:
}
static int GetCharacter( T* p, lua_State *L ) { p->GetCharacter()->PushSelf(L); return 1; }
static int SetCharacter( T* p, lua_State *L ) { p->SetCharacter(SArg(1)); return 0; }
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; }
@@ -2030,6 +2037,7 @@ public:
ADD_METHOD( GetDisplayName );
ADD_METHOD( GetHighScoreList );
ADD_METHOD( GetCharacter );
ADD_METHOD( SetCharacter );
ADD_METHOD( GetWeightPounds );
ADD_METHOD( SetWeightPounds );
ADD_METHOD( GetGoalType );
+1
View File
@@ -67,6 +67,7 @@ public:
// smart accessors
RString GetDisplayNameOrHighScoreName() const;
Character *GetCharacter() const;
void SetCharacter(const RString sCharacterID);
RString GetDisplayTotalCaloriesBurned() const; // remove me and use Lua instead
RString GetDisplayTotalCaloriesBurnedToday() const; // remove me and use Lua instead
int GetCalculatedWeightPounds() const; // returns a default value if m_iWeightPounds isn't set