add Lua bindings
This commit is contained in:
@@ -1228,6 +1228,51 @@ void SongManager::FreeAllLoadedFromProfiles()
|
|||||||
StepsID::ClearCache();
|
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 )
|
static bool CheckPointer( const Song *p )
|
||||||
{
|
{
|
||||||
const vector<Song*> &songs = SONGMAN->GetAllSongs();
|
const vector<Song*> &songs = SONGMAN->GetAllSongs();
|
||||||
|
|||||||
@@ -9,6 +9,7 @@ class Style;
|
|||||||
class Course;
|
class Course;
|
||||||
class Steps;
|
class Steps;
|
||||||
struct PlayerOptions;
|
struct PlayerOptions;
|
||||||
|
struct lua_State;
|
||||||
|
|
||||||
#include "RageTypes.h"
|
#include "RageTypes.h"
|
||||||
#include "GameConstantsAndTypes.h"
|
#include "GameConstantsAndTypes.h"
|
||||||
@@ -95,6 +96,9 @@ public:
|
|||||||
|
|
||||||
void UpdateRankingCourses(); // courses shown on the ranking screen
|
void UpdateRankingCourses(); // courses shown on the ranking screen
|
||||||
|
|
||||||
|
// Lua
|
||||||
|
void PushSelf( lua_State *L );
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
void LoadStepManiaSongDir( CString sDir, LoadingWindow *ld );
|
void LoadStepManiaSongDir( CString sDir, LoadingWindow *ld );
|
||||||
void LoadDWISongDir( CString sDir );
|
void LoadDWISongDir( CString sDir );
|
||||||
|
|||||||
Reference in New Issue
Block a user