add Lua bindings

This commit is contained in:
Chris Danford
2005-02-21 17:26:43 +00:00
parent a0ebb13fec
commit d7bcadccc7
2 changed files with 49 additions and 0 deletions
+45
View File
@@ -1228,6 +1228,51 @@ void SongManager::FreeAllLoadedFromProfiles()
StepsID::ClearCache();
}
// lua start
#include "LuaBinding.h"
template<class T>
class LunaSongManager : public Luna<T>
{
public:
LunaSongManager() { LUA->Register( Register ); }
static int GetAllCourses( T* p, lua_State *L )
{
vector<Course*> vCourses;
p->GetAllCourses( vCourses, BArg(1) );
CreateTableFromArray<Course*>( vCourses, L );
return 1;
}
static int FindCourse( T* p, lua_State *L ) { Course *pC = p->FindCourse(SArg(1)); if(pC) pC->PushSelf(L); else lua_pushnil(L); return 1; }
static void Register(lua_State *L)
{
ADD_METHOD( GetAllCourses )
ADD_METHOD( FindCourse )
Luna<T>::Register( L );
// Add global singleton if constructed already. If it's not constructed yet,
// then we'll register it later when we reinit Lua just before
// initializing the display.
if( SONGMAN )
{
lua_pushstring(L, "SONGMAN");
SONGMAN->PushSelf( LUA->L );
lua_settable(L, LUA_GLOBALSINDEX);
}
}
};
LUA_REGISTER_CLASS( SongManager )
// lua end
static bool CheckPointer( const Song *p )
{
const vector<Song*> &songs = SONGMAN->GetAllSongs();
+4
View File
@@ -9,6 +9,7 @@ class Style;
class Course;
class Steps;
struct PlayerOptions;
struct lua_State;
#include "RageTypes.h"
#include "GameConstantsAndTypes.h"
@@ -95,6 +96,9 @@ public:
void UpdateRankingCourses(); // courses shown on the ranking screen
// Lua
void PushSelf( lua_State *L );
protected:
void LoadStepManiaSongDir( CString sDir, LoadingWindow *ld );
void LoadDWISongDir( CString sDir );