diff --git a/stepmania/src/BitmapText.cpp b/stepmania/src/BitmapText.cpp index 36784b70bb..3bc1fb160a 100644 --- a/stepmania/src/BitmapText.cpp +++ b/stepmania/src/BitmapText.cpp @@ -12,9 +12,6 @@ #include "ActorUtil.h" // for BeginHandleArgs #include "LuaBinding.h" -// lua start -LUA_REGISTER_CLASS( BitmapText ) -// lua end REGISTER_ACTOR_CLASS( BitmapText ) /* @@ -841,6 +838,36 @@ void ColorBitmapText::SetMaxLines( int iNumLines, int iDirection ) } BuildChars(); } + +// lua start + +template +class LunaBitmapText : public Luna +{ +public: + LunaBitmapText() { LUA->Register( Register ); } + + static int wrapwidthpixels( T* p, lua_State *L ) { p->SetWrapWidthPixels( IArg(1) ); return 0; } + static int maxwidth( T* p, lua_State *L ) { p->SetMaxWidth( FArg(1) ); return 0; } + static int maxheight( T* p, lua_State *L ) { p->SetMaxHeight( FArg(1) ); return 0; } + static int settext( T* p, lua_State *L ) { p->SetText( SArg(1) ); return 0; } + static int GetText( T* p, lua_State *L ) { lua_pushstring( L, p->GetText() ); return 1; } + + static void Register(lua_State *L) + { + ADD_METHOD( wrapwidthpixels ) + ADD_METHOD( maxwidth ) + ADD_METHOD( maxheight ) + ADD_METHOD( settext ) + ADD_METHOD( GetText ) + Luna::Register( L ); + } +}; + +LUA_REGISTER_DERIVED_CLASS( BitmapText, Actor ) + +// lua end + /* * (c) 2003-2004 Chris Danford, Charles Lohr * All rights reserved. diff --git a/stepmania/src/BitmapText.h b/stepmania/src/BitmapText.h index dd7e9065ae..c17e4991aa 100644 --- a/stepmania/src/BitmapText.h +++ b/stepmania/src/BitmapText.h @@ -8,31 +8,6 @@ class RageTexture; class Font; - -template -class LunaBitmapText : public LunaActor -{ -public: - LunaBitmapText() { LUA->Register( Register ); } - - static int wrapwidthpixels( T* p, lua_State *L ) { p->SetWrapWidthPixels( IArg(1) ); return 0; } - static int maxwidth( T* p, lua_State *L ) { p->SetMaxWidth( FArg(1) ); return 0; } - static int maxheight( T* p, lua_State *L ) { p->SetMaxHeight( FArg(1) ); return 0; } - static int settext( T* p, lua_State *L ) { p->SetText( SArg(1) ); return 0; } - static int GetText( T* p, lua_State *L ) { lua_pushstring( L, p->GetText() ); return 1; } - - static void Register(lua_State *L) - { - ADD_METHOD( wrapwidthpixels ) - ADD_METHOD( maxwidth ) - ADD_METHOD( maxheight ) - ADD_METHOD( settext ) - ADD_METHOD( GetText ) - LunaActor::Register( L ); - } -}; - - class BitmapText : public Actor { public: diff --git a/stepmania/src/HelpDisplay.cpp b/stepmania/src/HelpDisplay.cpp index f9c1740596..b466a41703 100644 --- a/stepmania/src/HelpDisplay.cpp +++ b/stepmania/src/HelpDisplay.cpp @@ -75,7 +75,7 @@ void HelpDisplay::Update( float fDeltaTime ) template -class LunaHelpDisplay : public LunaBitmapText +class LunaHelpDisplay : public Luna { public: LunaHelpDisplay() { LUA->Register( Register ); } @@ -119,11 +119,11 @@ public: { ADD_METHOD( settips ) ADD_METHOD( gettips ) - LunaActor::Register( L ); + Luna::Register( L ); } }; -LUA_REGISTER_CLASS( HelpDisplay ) +LUA_REGISTER_DERIVED_CLASS( HelpDisplay, BitmapText ) #include "song.h" diff --git a/stepmania/src/RollingNumbers.cpp b/stepmania/src/RollingNumbers.cpp index e7560db689..3618c76e3d 100644 --- a/stepmania/src/RollingNumbers.cpp +++ b/stepmania/src/RollingNumbers.cpp @@ -4,9 +4,6 @@ #include "XmlFile.h" #include "ActorUtil.h" -// lua start -LUA_REGISTER_CLASS( RollingNumbers ) -// lua end REGISTER_ACTOR_CLASS( RollingNumbers ) RollingNumbers::RollingNumbers() @@ -60,6 +57,22 @@ void RollingNumbers::UpdateText() SetText( ssprintf(m_sFormat, m_fCurrentNumber) ); } +// lua start +template +class LunaRollingNumbers : public Luna +{ +public: + LunaRollingNumbers() { LUA->Register( Register ); } + + static void Register(lua_State *L) + { + Luna::Register( L ); + } +}; + +LUA_REGISTER_DERIVED_CLASS( RollingNumbers, BitmapText ) + +// lua end /* * (c) 2001-2004 Chris Danford diff --git a/stepmania/src/RollingNumbers.h b/stepmania/src/RollingNumbers.h index 9ccfbefdd4..72b843df6f 100644 --- a/stepmania/src/RollingNumbers.h +++ b/stepmania/src/RollingNumbers.h @@ -5,20 +5,6 @@ #include "BitmapText.h" - -template -class LunaRollingNumbers : public LunaBitmapText -{ -public: - LunaRollingNumbers() { LUA->Register( Register ); } - - static void Register(lua_State *L) - { - LunaBitmapText::Register( L ); - } -}; - - class RollingNumbers : public BitmapText { public: diff --git a/stepmania/src/ScoreDisplayAliveTime.cpp b/stepmania/src/ScoreDisplayAliveTime.cpp index db08c7b492..887e217e81 100644 --- a/stepmania/src/ScoreDisplayAliveTime.cpp +++ b/stepmania/src/ScoreDisplayAliveTime.cpp @@ -7,9 +7,6 @@ #include "StatsManager.h" #include "ActorUtil.h" -// lua start -LUA_REGISTER_CLASS( ScoreDisplayAliveTime ) -// lua end REGISTER_ACTOR_CLASS( ScoreDisplayAliveTime ) @@ -60,6 +57,23 @@ void ScoreDisplayAliveTime::UpdateNumber() SetText( SecondsToMMSSMsMs(fSecsIntoPlay) ); } +// lua start +template +class LunaScoreDisplayAliveTime : public Luna +{ +public: + LunaScoreDisplayAliveTime() { LUA->Register( Register ); } + + static void Register(lua_State *L) + { + Luna::Register( L ); + } +}; + +LUA_REGISTER_DERIVED_CLASS( ScoreDisplayAliveTime, BitmapText ) + +// lua end + /* * (c) 2001-2004 Chris Danford * All rights reserved. diff --git a/stepmania/src/ScoreDisplayAliveTime.h b/stepmania/src/ScoreDisplayAliveTime.h index d0f6c72ad4..4b8220beaa 100644 --- a/stepmania/src/ScoreDisplayAliveTime.h +++ b/stepmania/src/ScoreDisplayAliveTime.h @@ -8,19 +8,6 @@ #include "PlayerNumber.h" -template -class LunaScoreDisplayAliveTime : public LunaBitmapText -{ -public: - LunaScoreDisplayAliveTime() { LUA->Register( Register ); } - - static void Register(lua_State *L) - { - LunaBitmapText::Register( L ); - } -}; - - class ScoreDisplayAliveTime : public BitmapText { public: diff --git a/stepmania/src/ScoreDisplayCalories.cpp b/stepmania/src/ScoreDisplayCalories.cpp index 1e51b22de6..712d1464d4 100644 --- a/stepmania/src/ScoreDisplayCalories.cpp +++ b/stepmania/src/ScoreDisplayCalories.cpp @@ -9,9 +9,6 @@ #include "ActorUtil.h" #include "StatsManager.h" -// lua start -LUA_REGISTER_CLASS( ScoreDisplayCalories ) -// lua end REGISTER_ACTOR_CLASS( ScoreDisplayCalories ) ScoreDisplayCalories::ScoreDisplayCalories() @@ -69,6 +66,23 @@ void ScoreDisplayCalories::UpdateNumber() SetTargetNumber( fCals ); } +// lua start +template +class LunaScoreDisplayCalories : public Luna +{ +public: + LunaScoreDisplayCalories() { LUA->Register( Register ); } + + static void Register(lua_State *L) + { + Luna::Register( L ); + } +}; + +LUA_REGISTER_DERIVED_CLASS( ScoreDisplayCalories, BitmapText ) + +// lua end + /* * (c) 2001-2004 Chris Danford * All rights reserved. diff --git a/stepmania/src/ScoreDisplayCalories.h b/stepmania/src/ScoreDisplayCalories.h index 3c582dc0e2..85068f4687 100644 --- a/stepmania/src/ScoreDisplayCalories.h +++ b/stepmania/src/ScoreDisplayCalories.h @@ -7,19 +7,6 @@ #include "PlayerNumber.h" -template -class LunaScoreDisplayCalories : public LunaRollingNumbers -{ -public: - LunaScoreDisplayCalories() { LUA->Register( Register ); } - - static void Register(lua_State *L) - { - LunaRollingNumbers::Register( L ); - } -}; - - class ScoreDisplayCalories : public RollingNumbers { public: