From b9238373b7a3d25eec0c714ec3dc2c64535312c3 Mon Sep 17 00:00:00 2001 From: Glenn Maynard Date: Sat, 15 Oct 2005 00:09:19 +0000 Subject: [PATCH] lua --- stepmania/src/DifficultyIcon.cpp | 49 ++++++++++++++++++++++++++++++++ stepmania/src/DifficultyIcon.h | 3 ++ 2 files changed, 52 insertions(+) diff --git a/stepmania/src/DifficultyIcon.cpp b/stepmania/src/DifficultyIcon.cpp index f0277ce1e3..54310325cc 100644 --- a/stepmania/src/DifficultyIcon.cpp +++ b/stepmania/src/DifficultyIcon.cpp @@ -82,6 +82,55 @@ void DifficultyIcon::SetFromDifficulty( PlayerNumber pn, Difficulty dc ) } } +// lua start +#include "LuaBinding.h" + +class LunaDifficultyIcon: public Luna +{ +public: + LunaDifficultyIcon() { LUA->Register( Register ); } + + static int SetFromSteps( T* p, lua_State *L ) + { + if( lua_isnil(L,1) ) + { + p->SetFromSteps( PLAYER_1, NULL ); + } + else + { + Steps *pS = Luna::check(L,1); + p->SetFromSteps( PLAYER_1, pS ); + } + return 0; + } + static int SetFromTrail( T* p, lua_State *L ) + { + if( lua_isnil(L,1) ) + { + p->SetFromTrail( PLAYER_1, NULL ); + } + else + { + Trail *pT = Luna::check(L,1); + p->SetFromTrail( PLAYER_1, pT ); + } + return 0; + } + static int SetFromDifficulty( T* p, lua_State *L ) { p->SetFromDifficulty( PLAYER_1, (Difficulty)IArg(1) ); return 0; } + + static void Register(lua_State *L) + { + ADD_METHOD( SetFromSteps ); + ADD_METHOD( SetFromTrail ); + ADD_METHOD( SetFromDifficulty ); + + Luna::Register( L ); + } +}; + +LUA_REGISTER_DERIVED_CLASS( DifficultyIcon, Sprite ) +// lua end + /* * (c) 2001-2004 Chris Danford * All rights reserved. diff --git a/stepmania/src/DifficultyIcon.h b/stepmania/src/DifficultyIcon.h index 5ade251a8b..ed5040bc5e 100644 --- a/stepmania/src/DifficultyIcon.h +++ b/stepmania/src/DifficultyIcon.h @@ -25,6 +25,9 @@ public: void SetFromTrail( PlayerNumber pn, const Trail* pTrail ); void SetFromDifficulty( PlayerNumber pn, Difficulty dc ); + // Lua + void PushSelf( lua_State *L ); + protected: bool m_bBlank; };