diff --git a/stepmania/src/Sprite.h b/stepmania/src/Sprite.h index 2e58598537..7515c4ec59 100644 --- a/stepmania/src/Sprite.h +++ b/stepmania/src/Sprite.h @@ -8,63 +8,6 @@ class RageTexture; -template -class LunaSprite : public LunaActor -{ -public: - LunaSprite() { LUA->Register( Register ); } - - static int Load( T* p, lua_State *L ) - { - RageTextureID ID( SArg(1) ); - lua_pushboolean( LUA->L, p->Load(ID) ); - return 1; - } - static int LoadBackground( T* p, lua_State *L ) - { - RageTextureID ID( SArg(1) ); - lua_pushboolean( LUA->L, p->Load(Sprite::SongBGTexture(ID)) ); - return 1; - } - static int LoadBanner( T* p, lua_State *L ) - { - RageTextureID ID( SArg(1) ); - lua_pushboolean( LUA->L, p->Load(Sprite::SongBannerTexture(ID)) ); - return 1; - } - - /* Commands that go in the tweening queue: - * Commands that take effect immediately (ignoring the tweening queue): */ - static int customtexturerect( T* p, lua_State *L ) { p->SetCustomTextureRect( RectF(FArg(1),FArg(2),FArg(3),FArg(4)) ); return 0; } - static int texcoordvelocity( T* p, lua_State *L ) { p->SetTexCoordVelocity( FArg(1),FArg(2) ); return 0; } - static int scaletoclipped( T* p, lua_State *L ) { p->ScaleToClipped( FArg(1),FArg(2) ); return 0; } - static int stretchtexcoords( T* p, lua_State *L ) { p->StretchTexCoords( FArg(1),FArg(2) ); return 0; } - static int setstate( T* p, lua_State *L ) { p->SetState( IArg(1) ); return 0; } - /* Texture commands; these could be moved to RageTexture* (even though that's - * not an Actor) if these are needed for other things that use textures. - * We'd need to break the command helpers into a separate function; RageTexture - * shouldn't depend on Actor. */ - static int position( T* p, lua_State *L ) { p->SetPosition(FArg(1)); return 0; } - static int loop( T* p, lua_State *L ) { p->SetLooping(!!IArg(1)); return 0; } - static int rate( T* p, lua_State *L ) { p->SetPlaybackRate(FArg(1)); return 0; } - - static void Register(lua_State *L) { - ADD_METHOD( Load ) - ADD_METHOD( LoadBanner ) - ADD_METHOD( LoadBackground ) - ADD_METHOD( customtexturerect ) - ADD_METHOD( texcoordvelocity ) - ADD_METHOD( scaletoclipped ) - ADD_METHOD( stretchtexcoords ) - ADD_METHOD( setstate ) - ADD_METHOD( position ) - ADD_METHOD( loop ) - ADD_METHOD( rate ) - LunaActor::Register( L ); - } -}; - - class Sprite: public Actor { public: @@ -159,6 +102,61 @@ protected: float m_fTexCoordVelocityY; }; +template +class LunaSprite : public LunaActor +{ +public: + LunaSprite() { LUA->Register( Register ); } + + static int Load( T* p, lua_State *L ) + { + RageTextureID ID( SArg(1) ); + lua_pushboolean( LUA->L, p->Load(ID) ); + return 1; + } + static int LoadBackground( T* p, lua_State *L ) + { + RageTextureID ID( SArg(1) ); + lua_pushboolean( LUA->L, p->Load(Sprite::SongBGTexture(ID)) ); + return 1; + } + static int LoadBanner( T* p, lua_State *L ) + { + RageTextureID ID( SArg(1) ); + lua_pushboolean( LUA->L, p->Load(Sprite::SongBannerTexture(ID)) ); + return 1; + } + + /* Commands that go in the tweening queue: + * Commands that take effect immediately (ignoring the tweening queue): */ + static int customtexturerect( T* p, lua_State *L ) { p->SetCustomTextureRect( RectF(FArg(1),FArg(2),FArg(3),FArg(4)) ); return 0; } + static int texcoordvelocity( T* p, lua_State *L ) { p->SetTexCoordVelocity( FArg(1),FArg(2) ); return 0; } + static int scaletoclipped( T* p, lua_State *L ) { p->ScaleToClipped( FArg(1),FArg(2) ); return 0; } + static int stretchtexcoords( T* p, lua_State *L ) { p->StretchTexCoords( FArg(1),FArg(2) ); return 0; } + static int setstate( T* p, lua_State *L ) { p->SetState( IArg(1) ); return 0; } + /* Texture commands; these could be moved to RageTexture* (even though that's + * not an Actor) if these are needed for other things that use textures. + * We'd need to break the command helpers into a separate function; RageTexture + * shouldn't depend on Actor. */ + static int position( T* p, lua_State *L ) { p->SetPosition(FArg(1)); return 0; } + static int loop( T* p, lua_State *L ) { p->SetLooping(!!IArg(1)); return 0; } + static int rate( T* p, lua_State *L ) { p->SetPlaybackRate(FArg(1)); return 0; } + + static void Register(lua_State *L) { + ADD_METHOD( Load ) + ADD_METHOD( LoadBanner ) + ADD_METHOD( LoadBackground ) + ADD_METHOD( customtexturerect ) + ADD_METHOD( texcoordvelocity ) + ADD_METHOD( scaletoclipped ) + ADD_METHOD( stretchtexcoords ) + ADD_METHOD( setstate ) + ADD_METHOD( position ) + ADD_METHOD( loop ) + ADD_METHOD( rate ) + LunaActor::Register( L ); + } +}; #endif