add Lua bindings

This commit is contained in:
Chris Danford
2005-02-22 23:06:51 +00:00
parent fd6a03977d
commit 105e01232a
5 changed files with 69 additions and 0 deletions
+4
View File
@@ -1873,6 +1873,8 @@ public:
p->ApplyGameCommand(SArg(1),pn); p->ApplyGameCommand(SArg(1),pn);
return 0; return 0;
} }
static int GetCurrentSong( T* p, lua_State *L ) { if(p->m_pCurSong) p->m_pCurSong->PushSelf(L); else lua_pushnil(L); return 1; }
static int SetCurrentSong( T* p, lua_State *L ) { Song *pS = Luna<Song>::check(L,1); p->m_pCurSong = pS; return 0; }
static int GetCurrentCourse( T* p, lua_State *L ) { if(p->m_pCurCourse) p->m_pCurCourse->PushSelf(L); else lua_pushnil(L); return 1; } static int GetCurrentCourse( T* p, lua_State *L ) { if(p->m_pCurCourse) p->m_pCurCourse->PushSelf(L); else lua_pushnil(L); return 1; }
static int SetCurrentCourse( T* p, lua_State *L ) { Course *pC = Luna<Course>::check(L,1); p->m_pCurCourse = pC; return 0; } static int SetCurrentCourse( T* p, lua_State *L ) { Course *pC = Luna<Course>::check(L,1); p->m_pCurCourse = pC; return 0; }
static int SetTemporaryEventMode( T* p, lua_State *L ) { p->m_bTemporaryEventMode = BArg(1); return 0; } static int SetTemporaryEventMode( T* p, lua_State *L ) { p->m_bTemporaryEventMode = BArg(1); return 0; }
@@ -1884,6 +1886,8 @@ public:
ADD_METHOD( GetPlayerDisplayName ) ADD_METHOD( GetPlayerDisplayName )
ADD_METHOD( GetMasterPlayerNumber ) ADD_METHOD( GetMasterPlayerNumber )
ADD_METHOD( ApplyGameCommand ) ADD_METHOD( ApplyGameCommand )
ADD_METHOD( GetCurrentSong )
ADD_METHOD( SetCurrentSong )
ADD_METHOD( GetCurrentCourse ) ADD_METHOD( GetCurrentCourse )
ADD_METHOD( SetCurrentCourse ) ADD_METHOD( SetCurrentCourse )
ADD_METHOD( SetTemporaryEventMode ) ADD_METHOD( SetTemporaryEventMode )
+32
View File
@@ -1404,6 +1404,38 @@ bool Song::HasSignificantBpmChangesOrStops() const
return m_Timing.HasBpmChangesOrStops(); return m_Timing.HasBpmChangesOrStops();
} }
// lua start
#include "LuaBinding.h"
template<class T>
class LunaSong : public Luna<T>
{
public:
LunaSong() { LUA->Register( Register ); }
static int GetFullDisplayTitle( T* p, lua_State *L ) { lua_pushstring(L, p->GetFullDisplayTitle() ); return 1; }
static int GetFullTranslitTitle( T* p, lua_State *L ) { lua_pushstring(L, p->GetFullTranslitTitle() ); return 1; }
static int GetAllSteps( T* p, lua_State *L )
{
const vector<Steps*> &v = p->GetAllSteps();
CreateTableFromArray<Steps*>( v, L );
return 1;
}
static void Register(lua_State *L)
{
ADD_METHOD( GetFullDisplayTitle )
ADD_METHOD( GetFullTranslitTitle )
ADD_METHOD( GetAllSteps )
Luna<T>::Register( L );
}
};
LUA_REGISTER_CLASS( Song )
// lua end
/* /*
* (c) 2001-2004 Chris Danford, Glenn Maynard * (c) 2001-2004 Chris Danford, Glenn Maynard
* All rights reserved. * All rights reserved.
+25
View File
@@ -326,6 +326,31 @@ void Steps::SetRadarValues( const RadarValues& v )
m_RadarValues = v; m_RadarValues = v;
} }
// lua start
#include "LuaBinding.h"
template<class T>
class LunaSteps : public Luna<T>
{
public:
LunaSteps() { LUA->Register( Register ); }
static int GetStepsType( T* p, lua_State *L ) { lua_pushnumber(L, p->m_StepsType ); return 1; }
static int GetDescription( T* p, lua_State *L ) { lua_pushstring(L, p->GetDescription() ); return 1; }
static void Register(lua_State *L)
{
ADD_METHOD( GetStepsType )
ADD_METHOD( GetDescription )
Luna<T>::Register( L );
}
};
LUA_REGISTER_CLASS( Steps )
// lua end
/* /*
* (c) 2001-2004 Chris Danford, Glenn Maynard, David Wilson * (c) 2001-2004 Chris Danford, Glenn Maynard, David Wilson
* All rights reserved. * All rights reserved.
+4
View File
@@ -10,6 +10,7 @@
#include "Difficulty.h" #include "Difficulty.h"
class NoteData; class NoteData;
class Profile; class Profile;
struct lua_State;
class Steps class Steps
{ {
@@ -55,6 +56,9 @@ public:
void TidyUpData(); void TidyUpData();
// Lua
void PushSelf( lua_State *L );
protected: protected:
/* If this Steps is autogenerated, this will point to the autogen /* If this Steps is autogenerated, this will point to the autogen
* source. If this is true, notes_comp will always be NULL. */ * source. If this is true, notes_comp will always be NULL. */
+4
View File
@@ -15,6 +15,7 @@ class NotesLoader;
class LyricsLoader; class LyricsLoader;
class Profile; class Profile;
class StepsID; class StepsID;
struct lua_State;
#define MAX_EDITS_PER_SONG_PER_PROFILE 5 #define MAX_EDITS_PER_SONG_PER_PROFILE 5
#define MAX_EDITS_PER_SONG 5*NUM_PROFILE_SLOTS #define MAX_EDITS_PER_SONG 5*NUM_PROFILE_SLOTS
@@ -224,6 +225,9 @@ public:
// means "this note doens't have a keysound". // means "this note doens't have a keysound".
vector<CString> m_vsKeysoundFile; vector<CString> m_vsKeysoundFile;
// Lua
void PushSelf( lua_State *L );
private: private:
void AdjustDuplicateSteps(); // part of TidyUpData void AdjustDuplicateSteps(); // part of TidyUpData
void DeleteDuplicateSteps( vector<Steps*> &vSteps ); void DeleteDuplicateSteps( vector<Steps*> &vSteps );