simpler Lua boilerplate

This commit is contained in:
Glenn Maynard
2006-09-27 19:47:52 +00:00
parent e0bf203af4
commit 4002071bea
7 changed files with 29 additions and 43 deletions
+3 -8
View File
@@ -198,24 +198,19 @@ void Character::UndemandGraphics()
class LunaCharacter: public Luna<Character> class LunaCharacter: public Luna<Character>
{ {
public: public:
LunaCharacter() { LUA->Register( Register ); }
static int GetCardPath( T* p, lua_State *L ) { lua_pushstring(L, p->GetCardPath() ); return 1; } static int GetCardPath( T* p, lua_State *L ) { lua_pushstring(L, p->GetCardPath() ); return 1; }
static int GetIconPath( T* p, lua_State *L ) { lua_pushstring(L, p->GetIconPath() ); return 1; } static int GetIconPath( T* p, lua_State *L ) { lua_pushstring(L, p->GetIconPath() ); return 1; }
static int GetSongSelectIconPath( T* p, lua_State *L ) { lua_pushstring(L, p->GetSongSelectIconPath() ); return 1; } static int GetSongSelectIconPath( T* p, lua_State *L ) { lua_pushstring(L, p->GetSongSelectIconPath() ); return 1; }
static int GetStageIconPath( T* p, lua_State *L ) { lua_pushstring(L, p->GetStageIconPath() ); return 1; } static int GetStageIconPath( T* p, lua_State *L ) { lua_pushstring(L, p->GetStageIconPath() ); return 1; }
RString GetCardPath() const; LunaCharacter()
RString GetIconPath() const;
static void Register( Lua *L )
{ {
LUA->Register( Register );
ADD_METHOD( GetCardPath ); ADD_METHOD( GetCardPath );
ADD_METHOD( GetIconPath ); ADD_METHOD( GetIconPath );
ADD_METHOD( GetSongSelectIconPath ); ADD_METHOD( GetSongSelectIconPath );
ADD_METHOD( GetStageIconPath ); ADD_METHOD( GetStageIconPath );
Luna<T>::Register( L );
} }
}; };
+3 -4
View File
@@ -281,7 +281,6 @@ void Screen::ClearMessageQueue( const ScreenMessage SM )
class LunaScreen: public Luna<Screen> class LunaScreen: public Luna<Screen>
{ {
public: public:
LunaScreen() { LUA->Register( Register ); }
static int GetNextScreen( T* p, lua_State *L ) { lua_pushstring(L, p->GetNextScreen() ); return 1; } static int GetNextScreen( T* p, lua_State *L ) { lua_pushstring(L, p->GetNextScreen() ); return 1; }
static int lockinput( T* p, lua_State *L ) { p->SetLockInputSecs(FArg(1)); return 0; } static int lockinput( T* p, lua_State *L ) { p->SetLockInputSecs(FArg(1)); return 0; }
@@ -293,13 +292,13 @@ public:
return 0; return 0;
} }
static void Register( Lua *L ) LunaScreen()
{ {
LUA->Register( Register );
ADD_METHOD( GetNextScreen ); ADD_METHOD( GetNextScreen );
ADD_METHOD( PostScreenMessage ); ADD_METHOD( PostScreenMessage );
ADD_METHOD( lockinput ); ADD_METHOD( lockinput );
Luna<T>::Register( L );
} }
}; };
+4 -5
View File
@@ -2634,16 +2634,15 @@ void ScreenGameplay::SaveReplay()
class LunaScreenGameplay: public Luna<ScreenGameplay> class LunaScreenGameplay: public Luna<ScreenGameplay>
{ {
public: public:
LunaScreenGameplay() { LUA->Register( Register ); }
static int GetNextCourseSong( T* p, lua_State *L ) { p->GetNextCourseSong()->PushSelf(L); return 1; } static int GetNextCourseSong( T* p, lua_State *L ) { p->GetNextCourseSong()->PushSelf(L); return 1; }
static int Center1Player( T* p, lua_State *L ) { lua_pushboolean( L, p->Center1Player() ); return 1; } static int Center1Player( T* p, lua_State *L ) { lua_pushboolean( L, p->Center1Player() ); return 1; }
static void Register( Lua *L )
LunaScreenGameplay()
{ {
LUA->Register( Register );
ADD_METHOD( GetNextCourseSong ); ADD_METHOD( GetNextCourseSong );
ADD_METHOD( Center1Player ); ADD_METHOD( Center1Player );
Luna<T>::Register( L );
} }
}; };
+5 -6
View File
@@ -1250,14 +1250,13 @@ void ScreenOptions::MenuUpDown( const InputEventPlus &input, int iDir )
class LunaScreenOptions: public Luna<ScreenOptions> class LunaScreenOptions: public Luna<ScreenOptions>
{ {
public: public:
LunaScreenOptions() { LUA->Register( Register ); }
static int GetCurrentRow( T* p, lua_State *L ) { lua_pushnumber( L, p->GetCurrentRow(Enum::Check<PlayerNumber>(L, 1)) ); return 1; } static int GetCurrentRow( T* p, lua_State *L ) { lua_pushnumber( L, p->GetCurrentRow(Enum::Check<PlayerNumber>(L, 1)) ); return 1; }
static void Register( Lua *L )
{
ADD_METHOD( GetCurrentRow );
Luna<T>::Register( L ); LunaScreenOptions()
{
LUA->Register( Register );
ADD_METHOD( GetCurrentRow );
} }
}; };
+5 -6
View File
@@ -185,14 +185,13 @@ void ScreenPlayerOptions::UpdateDisqualified( int row, PlayerNumber pn )
class LunaScreenPlayerOptions: public Luna<ScreenPlayerOptions> class LunaScreenPlayerOptions: public Luna<ScreenPlayerOptions>
{ {
public: public:
LunaScreenPlayerOptions() { LUA->Register( Register ); }
static int GetGoToOptions( T* p, lua_State *L ) { lua_pushboolean( L, p->GetGoToOptions() ); return 1; } static int GetGoToOptions( T* p, lua_State *L ) { lua_pushboolean( L, p->GetGoToOptions() ); return 1; }
static void Register( Lua *L )
{
ADD_METHOD( GetGoToOptions );
Luna<T>::Register( L ); LunaScreenPlayerOptions()
{
LUA->Register( Register );
ADD_METHOD( GetGoToOptions );
} }
}; };
+5 -6
View File
@@ -1028,14 +1028,13 @@ void ScreenSelectMusic::AfterMusicChange()
class LunaScreenSelectMusic: public Luna<ScreenSelectMusic> class LunaScreenSelectMusic: public Luna<ScreenSelectMusic>
{ {
public: public:
LunaScreenSelectMusic() { LUA->Register( Register ); }
static int GetGoToOptions( T* p, lua_State *L ) { lua_pushboolean( L, p->GetGoToOptions() ); return 1; } static int GetGoToOptions( T* p, lua_State *L ) { lua_pushboolean( L, p->GetGoToOptions() ); return 1; }
static void Register( Lua *L )
{
ADD_METHOD( GetGoToOptions );
Luna<T>::Register( L ); LunaScreenSelectMusic()
{
LUA->Register( Register );
ADD_METHOD( GetGoToOptions );
} }
}; };
+4 -8
View File
@@ -351,11 +351,9 @@ void ScreenWithMenuElementsSimple::MenuBack( const InputEventPlus &input )
class LunaScreenWithMenuElements: public Luna<ScreenWithMenuElements> class LunaScreenWithMenuElements: public Luna<ScreenWithMenuElements>
{ {
public: public:
LunaScreenWithMenuElements() { LUA->Register( Register ); } LunaScreenWithMenuElements()
static void Register( Lua *L )
{ {
Luna<T>::Register( L ); LUA->Register( Register );
} }
}; };
@@ -364,11 +362,9 @@ LUA_REGISTER_DERIVED_CLASS( ScreenWithMenuElements, Screen )
class LunaScreenWithMenuElementsSimple: public Luna<ScreenWithMenuElementsSimple> class LunaScreenWithMenuElementsSimple: public Luna<ScreenWithMenuElementsSimple>
{ {
public: public:
LunaScreenWithMenuElementsSimple() { LUA->Register( Register ); } LunaScreenWithMenuElementsSimple()
static void Register( Lua *L )
{ {
Luna<T>::Register( L ); LUA->Register( Register );
} }
}; };