add Lua methods
This commit is contained in:
@@ -164,14 +164,19 @@ CString Profile::GetDisplayTotalCaloriesBurned() const
|
|||||||
|
|
||||||
CString Profile::GetDisplayTotalCaloriesBurnedToday() const
|
CString Profile::GetDisplayTotalCaloriesBurnedToday() const
|
||||||
{
|
{
|
||||||
DateTime now = DateTime::GetNowDate();
|
float fCals = GetCaloriesBurnedToday();
|
||||||
float fCals = GetCaloriesBurnedForDay(now);
|
|
||||||
if( m_iWeightPounds == 0 ) // weight not entered
|
if( m_iWeightPounds == 0 ) // weight not entered
|
||||||
return "N/A";
|
return "N/A";
|
||||||
else
|
else
|
||||||
return FormatCalories( fCals );
|
return FormatCalories( fCals );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
float Profile::GetCaloriesBurnedToday() const
|
||||||
|
{
|
||||||
|
DateTime now = DateTime::GetNowDate();
|
||||||
|
return GetCaloriesBurnedForDay(now);
|
||||||
|
}
|
||||||
|
|
||||||
int Profile::GetTotalNumSongsPlayed() const
|
int Profile::GetTotalNumSongsPlayed() const
|
||||||
{
|
{
|
||||||
int iTotal = 0;
|
int iTotal = 0;
|
||||||
@@ -1641,6 +1646,31 @@ bool Profile::CreateNewProfile( CString sProfileDir, CString sName )
|
|||||||
return bResult;
|
return bResult;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// lua start
|
||||||
|
#include "LuaBinding.h"
|
||||||
|
|
||||||
|
template<class T>
|
||||||
|
class LunaProfile : public Luna<T>
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
LunaProfile() { LUA->Register( Register ); }
|
||||||
|
|
||||||
|
static int GetGoalCalories( T* p, lua_State *L ) { lua_pushnumber(L, p->m_iGoalCalories ); return 1; }
|
||||||
|
static int GetCaloriesBurnedToday( T* p, lua_State *L ) { lua_pushnumber(L, p->GetCaloriesBurnedToday() ); return 1; }
|
||||||
|
|
||||||
|
static void Register(lua_State *L)
|
||||||
|
{
|
||||||
|
ADD_METHOD( GetGoalCalories )
|
||||||
|
ADD_METHOD( GetCaloriesBurnedToday )
|
||||||
|
Luna<T>::Register( L );
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
LUA_REGISTER_CLASS( Profile )
|
||||||
|
// lua end
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* (c) 2001-2004 Chris Danford
|
* (c) 2001-2004 Chris Danford
|
||||||
* All rights reserved.
|
* All rights reserved.
|
||||||
|
|||||||
@@ -16,6 +16,7 @@
|
|||||||
#include "StyleUtil.h" // for StyleID
|
#include "StyleUtil.h" // for StyleID
|
||||||
|
|
||||||
struct XNode;
|
struct XNode;
|
||||||
|
struct lua_State;
|
||||||
|
|
||||||
//
|
//
|
||||||
// Current file versions
|
// Current file versions
|
||||||
@@ -61,8 +62,9 @@ public:
|
|||||||
// smart accessors
|
// smart accessors
|
||||||
//
|
//
|
||||||
CString GetDisplayName() const;
|
CString GetDisplayName() const;
|
||||||
CString GetDisplayTotalCaloriesBurned() const;
|
CString GetDisplayTotalCaloriesBurned() const; // remove me and use Lua instead
|
||||||
CString GetDisplayTotalCaloriesBurnedToday() const;
|
CString GetDisplayTotalCaloriesBurnedToday() const; // remove me and use Lua instead
|
||||||
|
float GetCaloriesBurnedToday() const;
|
||||||
int GetTotalNumSongsPlayed() const;
|
int GetTotalNumSongsPlayed() const;
|
||||||
int GetTotalNumSongsPassed() const;
|
int GetTotalNumSongsPassed() const;
|
||||||
float GetSongsPossible( StepsType st, Difficulty dc ) const;
|
float GetSongsPossible( StepsType st, Difficulty dc ) const;
|
||||||
@@ -299,6 +301,9 @@ public:
|
|||||||
static bool CreateNewProfile( CString sProfileDir, CString sName );
|
static bool CreateNewProfile( CString sProfileDir, CString sName );
|
||||||
static void BackupToDir( CString sFromDir, CString sToDir );
|
static void BackupToDir( CString sFromDir, CString sToDir );
|
||||||
|
|
||||||
|
// Lua
|
||||||
|
void PushSelf( lua_State *L );
|
||||||
|
|
||||||
private:
|
private:
|
||||||
const HighScoresForASong *GetHighScoresForASong( const SongID& songID ) const;
|
const HighScoresForASong *GetHighScoresForASong( const SongID& songID ) const;
|
||||||
const HighScoresForACourse *GetHighScoresForACourse( const CourseID& courseID ) const;
|
const HighScoresForACourse *GetHighScoresForACourse( const CourseID& courseID ) const;
|
||||||
|
|||||||
@@ -540,11 +540,13 @@ class LunaProfileManager : public Luna<T>
|
|||||||
public:
|
public:
|
||||||
LunaProfileManager() { LUA->Register( Register ); }
|
LunaProfileManager() { LUA->Register( Register ); }
|
||||||
|
|
||||||
static int IsUsingProfile( T* p, lua_State *L ) { lua_pushboolean(L, p->IsUsingProfile((PlayerNumber)IArg(1)) ); return 1; }
|
static int IsUsingProfile( T* p, lua_State *L ) { lua_pushboolean(L, p->IsUsingProfile((PlayerNumber)IArg(1)) ); return 1; }
|
||||||
|
static int GetProfile( T* p, lua_State *L ) { p->GetProfile((PlayerNumber)IArg(1))->PushSelf(L); return 1; }
|
||||||
|
|
||||||
static void Register(lua_State *L)
|
static void Register(lua_State *L)
|
||||||
{
|
{
|
||||||
ADD_METHOD( IsUsingProfile )
|
ADD_METHOD( IsUsingProfile )
|
||||||
|
ADD_METHOD( GetProfile )
|
||||||
Luna<T>::Register( L );
|
Luna<T>::Register( L );
|
||||||
|
|
||||||
// Add global singleton if constructed already. If it's not constructed yet,
|
// Add global singleton if constructed already. If it's not constructed yet,
|
||||||
|
|||||||
Reference in New Issue
Block a user