diff --git a/stepmania/src/ActorFrame.cpp b/stepmania/src/ActorFrame.cpp index 181553dc1e..02aee967bd 100644 --- a/stepmania/src/ActorFrame.cpp +++ b/stepmania/src/ActorFrame.cpp @@ -10,10 +10,6 @@ #include "ScreenDimensions.h" #include "Foreach.h" -// lua start -LUA_REGISTER_CLASS( ActorFrame ) -// lua end - /* Tricky: We need ActorFrames created in XML to auto delete their children. * We don't want classes that derive from ActorFrame to auto delete their * children. The name "ActorFrame" is widely used in XML, so we'll have @@ -328,6 +324,48 @@ void ActorFrame::SetDrawByZPosition( bool b ) m_bDrawByZPosition = b; } + +// lua start +#include "LuaBinding.h" + +template +class LunaActorFrame : public Luna +{ +public: + LunaActorFrame() { LUA->Register( Register ); } + + static int propagate( T* p, lua_State *L ) { p->SetPropagateCommands( !!IArg(1) ); return 0; } + static int fov( T* p, lua_State *L ) { p->SetFOV( FArg(1) ); return 0; } + static int SetUpdateRate( T* p, lua_State *L ) { p->SetUpdateRate( FArg(1) ); return 0; } + static int SetFOV( T* p, lua_State *L ) { p->SetFOV( FArg(1) ); return 0; } + static int GetChild( T* p, lua_State *L ) + { + Actor *pChild = p->GetChild( SArg(1) ); + if( pChild ) + pChild->PushSelf( L ); + else + lua_pushnil( L ); + return 1; + } + static int GetNumChildren( T* p, lua_State *L ) { lua_pushnumber( L, p->GetNumChildren() ); return 1; } + static int SetDrawByZPosition( T* p, lua_State *L ) { p->SetDrawByZPosition( BArg(1) ); return 1; } + + static void Register(lua_State *L) + { + ADD_METHOD( propagate ) + ADD_METHOD( fov ) + ADD_METHOD( SetUpdateRate ) + ADD_METHOD( SetFOV ) + ADD_METHOD( GetChild ) + ADD_METHOD( GetNumChildren ) + ADD_METHOD( SetDrawByZPosition ) + Luna::Register( L ); + } +}; + +LUA_REGISTER_DERIVED_CLASS( ActorFrame, Actor ) +// lua end + /* * (c) 2001-2004 Chris Danford * All rights reserved. diff --git a/stepmania/src/ActorFrame.h b/stepmania/src/ActorFrame.h index 30ddbeb43e..088ef8cc51 100644 --- a/stepmania/src/ActorFrame.h +++ b/stepmania/src/ActorFrame.h @@ -5,41 +5,6 @@ #include "Actor.h" -template -class LunaActorFrame : public LunaActor -{ -public: - LunaActorFrame() { LUA->Register( Register ); } - - static int propagate( T* p, lua_State *L ) { p->SetPropagateCommands( !!IArg(1) ); return 0; } - static int fov( T* p, lua_State *L ) { p->SetFOV( FArg(1) ); return 0; } - static int SetUpdateRate( T* p, lua_State *L ) { p->SetUpdateRate( FArg(1) ); return 0; } - static int SetFOV( T* p, lua_State *L ) { p->SetFOV( FArg(1) ); return 0; } - static int GetChild( T* p, lua_State *L ) - { - Actor *pChild = p->GetChild( SArg(1) ); - if( pChild ) - pChild->PushSelf( L ); - else - lua_pushnil( L ); - return 1; - } - static int GetNumChildren( T* p, lua_State *L ) { lua_pushnumber( L, p->GetNumChildren() ); return 1; } - static int SetDrawByZPosition( T* p, lua_State *L ) { p->SetDrawByZPosition( BArg(1) ); return 1; } - - static void Register(lua_State *L) - { - ADD_METHOD( propagate ) - ADD_METHOD( fov ) - ADD_METHOD( SetUpdateRate ) - ADD_METHOD( SetFOV ) - ADD_METHOD( GetChild ) - ADD_METHOD( GetNumChildren ) - ADD_METHOD( SetDrawByZPosition ) - LunaActor::Register( L ); - } -}; - class ActorFrame : public Actor { public: diff --git a/stepmania/src/ActorScroller.cpp b/stepmania/src/ActorScroller.cpp index b5961ef10a..e33736e55c 100644 --- a/stepmania/src/ActorScroller.cpp +++ b/stepmania/src/ActorScroller.cpp @@ -9,10 +9,6 @@ #include "ActorUtil.h" #include -// lua start -LUA_REGISTER_CLASS( ActorScroller ) -// lua end - /* Tricky: We need ActorFrames created in XML to auto delete their children. * We don't want classes that derive from ActorFrame to auto delete their * children. The name "ActorFrame" is widely used in XML, so we'll have @@ -282,6 +278,27 @@ void ActorScroller::DrawPrimitives() } } +// lua start +#include "LuaBinding.h" + +template +class LunaActorScroller : public Luna +{ +public: + LunaActorScroller() { LUA->Register( Register ); } + + static int SetCurrentAndDestinationItem( T* p, lua_State *L ) { p->SetCurrentAndDestinationItem( FArg(1) ); return 0; } + + static void Register(lua_State *L) + { + ADD_METHOD( SetCurrentAndDestinationItem ) + Luna::Register( L ); + } +}; + +LUA_REGISTER_DERIVED_CLASS( ActorScroller, ActorFrame ) +// lua end + /* * (c) 2003-2004 Chris Danford * All rights reserved. diff --git a/stepmania/src/ActorScroller.h b/stepmania/src/ActorScroller.h index e6248341ff..46be5d4350 100644 --- a/stepmania/src/ActorScroller.h +++ b/stepmania/src/ActorScroller.h @@ -7,21 +7,6 @@ #include "Quad.h" struct XNode; -template -class LunaActorScroller : public LunaActorFrame -{ -public: - LunaActorScroller() { LUA->Register( Register ); } - - static int SetCurrentAndDestinationItem( T* p, lua_State *L ) { p->SetCurrentAndDestinationItem( FArg(1) ); return 0; } - - static void Register(lua_State *L) - { - ADD_METHOD( SetCurrentAndDestinationItem ) - LunaActor::Register( L ); - } -}; - class ActorScroller : public ActorFrame { public: diff --git a/stepmania/src/DifficultyMeter.cpp b/stepmania/src/DifficultyMeter.cpp index 21a68475d5..00a61ad2db 100644 --- a/stepmania/src/DifficultyMeter.cpp +++ b/stepmania/src/DifficultyMeter.cpp @@ -12,9 +12,6 @@ #include "Style.h" #include "XmlFile.h" -// lua start -LUA_REGISTER_CLASS( DifficultyMeter ) -// lua end REGISTER_ACTOR_CLASS( DifficultyMeter ); @@ -255,6 +252,57 @@ void DifficultyMeter::SetInternal( int iMeter, Difficulty dc, const CString &sDi m_textMeter.PlayCommand( sDifficultyCommand ); } +// lua start +#include "LuaBinding.h" + +template +class LunaDifficultyMeter : public Luna +{ +public: + LunaDifficultyMeter() { LUA->Register( Register ); } + + static int Load( T* p, lua_State *L ) { p->Load( SArg(1) ); return 0; } + static int SetFromMeterAndDifficulty( T* p, lua_State *L ) { p->SetFromMeterAndDifficulty( IArg(1), (Difficulty)IArg(2) ); return 0; } + static int SetFromSteps( T* p, lua_State *L ) + { + if( lua_isnil(L,1) ) + { + p->SetFromSteps( NULL ); + } + else + { + Steps *pS = Luna::check(L,1); + p->SetFromSteps( pS ); + } + return 0; + } + static int SetFromTrail( T* p, lua_State *L ) + { + if( lua_isnil(L,1) ) + { + p->SetFromTrail( NULL ); + } + else + { + Trail *pT = Luna::check(L,1); + p->SetFromTrail( pT ); + } + return 0; + } + + static void Register(lua_State *L) + { + ADD_METHOD( Load ) + ADD_METHOD( SetFromMeterAndDifficulty ) + ADD_METHOD( SetFromSteps ) + ADD_METHOD( SetFromTrail ) + Luna::Register( L ); + } +}; + +LUA_REGISTER_DERIVED_CLASS( DifficultyMeter, ActorFrame ) +// lua end + /* * (c) 2001-2004 Chris Danford, Glenn Maynard * All rights reserved. diff --git a/stepmania/src/DifficultyMeter.h b/stepmania/src/DifficultyMeter.h index 77953a2156..7e13f66ba5 100644 --- a/stepmania/src/DifficultyMeter.h +++ b/stepmania/src/DifficultyMeter.h @@ -15,51 +15,6 @@ class Steps; class Trail; -template -class LunaDifficultyMeter : public LunaActorFrame -{ -public: - LunaDifficultyMeter() { LUA->Register( Register ); } - - static int Load( T* p, lua_State *L ) { p->Load( SArg(1) ); return 0; } - static int SetFromMeterAndDifficulty( T* p, lua_State *L ) { p->SetFromMeterAndDifficulty( IArg(1), (Difficulty)IArg(2) ); return 0; } - static int SetFromSteps( T* p, lua_State *L ) - { - if( lua_isnil(L,1) ) - { - p->SetFromSteps( NULL ); - } - else - { - Steps *pS = Luna::check(L,1); - p->SetFromSteps( pS ); - } - return 0; - } - static int SetFromTrail( T* p, lua_State *L ) - { - if( lua_isnil(L,1) ) - { - p->SetFromTrail( NULL ); - } - else - { - Trail *pT = Luna::check(L,1); - p->SetFromTrail( pT ); - } - return 0; - } - - static void Register(lua_State *L) - { - ADD_METHOD( Load ) - ADD_METHOD( SetFromMeterAndDifficulty ) - ADD_METHOD( SetFromSteps ) - ADD_METHOD( SetFromTrail ) - LunaActor::Register( L ); - } -}; - class DifficultyMeter: public ActorFrame { public: diff --git a/stepmania/src/FadingBanner.cpp b/stepmania/src/FadingBanner.cpp index 97a9842d0f..36e136d941 100644 --- a/stepmania/src/FadingBanner.cpp +++ b/stepmania/src/FadingBanner.cpp @@ -11,9 +11,6 @@ #include "ThemeMetric.h" #include "ActorUtil.h" -// lua start -LUA_REGISTER_CLASS( FadingBanner ) -// lua end REGISTER_ACTOR_CLASS( FadingBanner ) /* @@ -210,6 +207,35 @@ void FadingBanner::LoadFallback() m_Banner[m_iIndexLatest].LoadFallback(); } + +// lua start +#include "LuaBinding.h" + +template +class LunaFadingBanner : public Luna +{ +public: + LunaFadingBanner() { LUA->Register( Register ); } + + static int ScaleToClipped( T* p, lua_State *L ) { p->ScaleToClipped(FArg(1),FArg(2)); return 0; } + static int LoadFromSong( T* p, lua_State *L ) + { + if( lua_isnil(L,1) ) { p->LoadFromSong( NULL ); } + else { Song *pS = Luna::check(L,1); p->LoadFromSong( pS ); } + return 0; + } + + static void Register(lua_State *L) + { + ADD_METHOD( ScaleToClipped ) + ADD_METHOD( LoadFromSong ) + Luna::Register( L ); + } +}; + +LUA_REGISTER_DERIVED_CLASS( FadingBanner, ActorFrame ) +// lua end + /* * (c) 2001-2004 Chris Danford * All rights reserved. diff --git a/stepmania/src/FadingBanner.h b/stepmania/src/FadingBanner.h index cfd3ff9c01..cdc4bc56b0 100644 --- a/stepmania/src/FadingBanner.h +++ b/stepmania/src/FadingBanner.h @@ -7,28 +7,6 @@ #include "ActorFrame.h" #include "RageTimer.h" -template -class LunaFadingBanner : public LunaActorFrame -{ -public: - LunaFadingBanner() { LUA->Register( Register ); } - - static int ScaleToClipped( T* p, lua_State *L ) { p->ScaleToClipped(FArg(1),FArg(2)); return 0; } - static int LoadFromSong( T* p, lua_State *L ) - { - if( lua_isnil(L,1) ) { p->LoadFromSong( NULL ); } - else { Song *pS = Luna::check(L,1); p->LoadFromSong( pS ); } - return 0; - } - - static void Register(lua_State *L) - { - ADD_METHOD( ScaleToClipped ) - ADD_METHOD( LoadFromSong ) - LunaActor::Register( L ); - } -}; - class FadingBanner : public ActorFrame { public: