Add Preference<type>::PushValue() (note that this is not a PushSelf).
This commit is contained in:
@@ -2,6 +2,8 @@
|
||||
#include "Preference.h"
|
||||
#include "PrefsManager.h"
|
||||
#include "IniFile.h"
|
||||
#include "RageLog.h"
|
||||
#include "LuaFunctions.h"
|
||||
|
||||
static const CString PrefsGroupNames[NUM_PREFS_GROUPS] = {
|
||||
"Debug",
|
||||
@@ -22,6 +24,19 @@ IPreference::~IPreference()
|
||||
PrefsManager::Unsubscribe( this );
|
||||
}
|
||||
|
||||
void IPreference::PushValue( lua_State *L ) const
|
||||
{
|
||||
if( LOG )
|
||||
LOG->Trace( "The preference value \"%s\" is of a type not supported by Lua", m_sName.c_str() );
|
||||
|
||||
lua_pushnil( L );
|
||||
}
|
||||
|
||||
void Preference<CString>::PushValue( lua_State *L ) const
|
||||
{
|
||||
LuaManager::PushStack( m_currentValue, L );
|
||||
}
|
||||
|
||||
void Preference<CString>::FromString( const CString &s )
|
||||
{
|
||||
m_currentValue = s;
|
||||
@@ -41,6 +56,10 @@ CString Preference<CString>::ToString() const
|
||||
{ \
|
||||
return ::ToString( m_currentValue ); \
|
||||
} \
|
||||
void Preference<type>::PushValue( lua_State *L ) const \
|
||||
{ \
|
||||
LuaManager::PushStack( m_currentValue, L ); \
|
||||
}
|
||||
|
||||
READFROM_AND_WRITETO( int )
|
||||
READFROM_AND_WRITETO( float )
|
||||
|
||||
@@ -15,7 +15,7 @@ enum PrefsGroup
|
||||
};
|
||||
const CString& PrefsGroupToString( PrefsGroup pg );
|
||||
|
||||
|
||||
struct lua_State;
|
||||
class IPreference
|
||||
{
|
||||
public:
|
||||
@@ -29,6 +29,8 @@ public:
|
||||
virtual CString ToString() const = 0;
|
||||
virtual void FromString( const CString &s ) = 0;
|
||||
|
||||
virtual void PushValue( lua_State *L ) const;
|
||||
|
||||
PrefsGroup GetPrefsGroup() const { return m_PrefsGroup; }
|
||||
const CString &GetName() const { return m_sName; }
|
||||
|
||||
@@ -57,6 +59,7 @@ public:
|
||||
|
||||
CString ToString() const;
|
||||
void FromString( const CString &s );
|
||||
void PushValue( lua_State *L ) const;
|
||||
|
||||
void LoadDefault()
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user