This commit is contained in:
Glenn Maynard
2005-02-21 06:51:04 +00:00
parent e33b520a26
commit a25eb2443c
2 changed files with 35 additions and 1 deletions
+29
View File
@@ -385,6 +385,35 @@ int UnlockManager::GetNumUnlocks() const
return m_SongEntries.size(); return m_SongEntries.size();
} }
#include "LuaBinding.h"
template<class T>
class LunaUnlockManager: public Luna<T>
{
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<T>::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 * (c) 2001-2004 Kevin Slaughter, Andrew Wong, Glenn Maynard
* All rights reserved. * All rights reserved.
+6 -1
View File
@@ -8,6 +8,7 @@
class Song; class Song;
class Profile; class Profile;
struct lua_State;
enum UnlockType enum UnlockType
{ {
@@ -67,9 +68,10 @@ public:
void GetPoints( const Profile *pProfile, float fScores[NUM_UNLOCK_TYPES] ) const; void GetPoints( const Profile *pProfile, float fScores[NUM_UNLOCK_TYPES] ) const;
// Unlock an entry by code.
void UnlockCode( int num ); void UnlockCode( int num );
// unlocks the song's code // Unlocks a song.
void UnlockSong( const Song *song ); void UnlockSong( const Song *song );
// All locked songs are stored here // All locked songs are stored here
@@ -78,6 +80,9 @@ public:
// If global song or course points change, call to update // If global song or course points change, call to update
void UpdateSongs(); void UpdateSongs();
// Lua
void PushSelf( lua_State *L );
private: private:
// read unlocks // read unlocks
bool Load(); bool Load();