add Lua methods
This commit is contained in:
@@ -819,6 +819,42 @@ void PrefsManager::SaveGlobalPrefsToDisk() const
|
|||||||
ini.WriteFile( STEPMANIA_INI_PATH );
|
ini.WriteFile( STEPMANIA_INI_PATH );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// lua start
|
||||||
|
#include "LuaBinding.h"
|
||||||
|
|
||||||
|
template<class T>
|
||||||
|
class LunaPrefsManager : public Luna<T>
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
LunaPrefsManager() { LUA->Register( Register ); }
|
||||||
|
|
||||||
|
static int GetEventMode( T* p, lua_State *L ) { lua_pushboolean(L, p->m_bEventMode ); return 1; }
|
||||||
|
static int SetEventMode( T* p, lua_State *L ) { p->m_bEventMode = BArg(1); return 0; }
|
||||||
|
|
||||||
|
static void Register(lua_State *L)
|
||||||
|
{
|
||||||
|
ADD_METHOD( GetEventMode )
|
||||||
|
ADD_METHOD( SetEventMode )
|
||||||
|
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( PREFSMAN )
|
||||||
|
{
|
||||||
|
lua_pushstring(L, "PREFSMAN");
|
||||||
|
PREFSMAN->PushSelf( LUA->L );
|
||||||
|
lua_settable(L, LUA_GLOBALSINDEX);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
LUA_REGISTER_CLASS( PrefsManager )
|
||||||
|
// lua end
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
CoinMode PrefsManager::GetCoinMode()
|
CoinMode PrefsManager::GetCoinMode()
|
||||||
{
|
{
|
||||||
if( m_bEventMode && m_CoinMode == COIN_PAY )
|
if( m_bEventMode && m_CoinMode == COIN_PAY )
|
||||||
|
|||||||
@@ -304,6 +304,9 @@ public:
|
|||||||
static void Subscribe( IPreference *p );
|
static void Subscribe( IPreference *p );
|
||||||
static void Unsubscribe( IPreference *p );
|
static void Unsubscribe( IPreference *p );
|
||||||
|
|
||||||
|
// Lua
|
||||||
|
void PushSelf( lua_State *L );
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
void ReadPrefsFromFile( CString sIni );
|
void ReadPrefsFromFile( CString sIni );
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user