diff --git a/stepmania/src/UnlockManager.cpp b/stepmania/src/UnlockManager.cpp index 1dd0accbbc..3d78a9dd3b 100644 --- a/stepmania/src/UnlockManager.cpp +++ b/stepmania/src/UnlockManager.cpp @@ -385,6 +385,35 @@ int UnlockManager::GetNumUnlocks() const return m_SongEntries.size(); } +#include "LuaBinding.h" + +template +class LunaUnlockManager: public Luna +{ +public: + LunaUnlockManager() { LUA->Register( Register ); } + + static int UnlockCode( T* p, lua_State *L ) { int iCode = IArg(1); p->UnlockCode(iCode); return 0; } + + static void Register(lua_State *L) + { + ADD_METHOD( UnlockCode ) + Luna::Register( L ); + + // Add global singleton if constructed already. If it's not constructed yet, + // then we'll register it later when we reinit Lua just before + // initializing the display. + if( UNLOCKMAN ) + { + lua_pushstring(L, "UNLOCKMAN"); + UNLOCKMAN->PushSelf( LUA->L ); + lua_settable(L, LUA_GLOBALSINDEX); + } + } +}; + +LUA_REGISTER_CLASS( UnlockManager ) + /* * (c) 2001-2004 Kevin Slaughter, Andrew Wong, Glenn Maynard * All rights reserved. diff --git a/stepmania/src/UnlockManager.h b/stepmania/src/UnlockManager.h index c6fc8304f9..3686402034 100644 --- a/stepmania/src/UnlockManager.h +++ b/stepmania/src/UnlockManager.h @@ -8,6 +8,7 @@ class Song; class Profile; +struct lua_State; enum UnlockType { @@ -67,9 +68,10 @@ public: void GetPoints( const Profile *pProfile, float fScores[NUM_UNLOCK_TYPES] ) const; + // Unlock an entry by code. void UnlockCode( int num ); - // unlocks the song's code + // Unlocks a song. void UnlockSong( const Song *song ); // All locked songs are stored here @@ -78,6 +80,9 @@ public: // If global song or course points change, call to update void UpdateSongs(); + // Lua + void PushSelf( lua_State *L ); + private: // read unlocks bool Load();