remove includes from Preference.h
This commit is contained in:
@@ -0,0 +1,61 @@
|
||||
#include "global.h"
|
||||
#include "Preference.h"
|
||||
#include "PrefsManager.h"
|
||||
#include "IniFile.h"
|
||||
|
||||
static const CString PrefsGroupNames[NUM_PREFS_GROUPS] = {
|
||||
"Debug",
|
||||
"Editor",
|
||||
"Options",
|
||||
};
|
||||
XToString( PrefsGroup );
|
||||
|
||||
void SubscribePreference( IPreference *p )
|
||||
{
|
||||
PrefsManager::Subscribe( p );
|
||||
}
|
||||
|
||||
void UnsubscribePreference( IPreference *p )
|
||||
{
|
||||
PrefsManager::Unsubscribe( p );
|
||||
}
|
||||
|
||||
#define READFROM_AND_WRITETO( type ) \
|
||||
void Preference<type>::ReadFrom( const IniFile &ini ) \
|
||||
{ \
|
||||
ini.GetValue( PrefsGroupToString(m_PrefsGroup), m_sName, m_currentValue ); \
|
||||
} \
|
||||
void Preference<type>::WriteTo( IniFile &ini ) const \
|
||||
{ \
|
||||
ini.SetValue( PrefsGroupToString(m_PrefsGroup), m_sName, m_currentValue ); \
|
||||
} \
|
||||
|
||||
READFROM_AND_WRITETO( CString )
|
||||
READFROM_AND_WRITETO( int )
|
||||
READFROM_AND_WRITETO( float )
|
||||
READFROM_AND_WRITETO( bool )
|
||||
|
||||
/*
|
||||
* (c) 2001-2004 Chris Danford, Chris Gomez
|
||||
* All rights reserved.
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a
|
||||
* copy of this software and associated documentation files (the
|
||||
* "Software"), to deal in the Software without restriction, including
|
||||
* without limitation the rights to use, copy, modify, merge, publish,
|
||||
* distribute, and/or sell copies of the Software, and to permit persons to
|
||||
* whom the Software is furnished to do so, provided that the above
|
||||
* copyright notice(s) and this permission notice appear in all copies of
|
||||
* the Software and that both the above copyright notice(s) and this
|
||||
* permission notice appear in supporting documentation.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
|
||||
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT OF
|
||||
* THIRD PARTY RIGHTS. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR HOLDERS
|
||||
* INCLUDED IN THIS NOTICE BE LIABLE FOR ANY CLAIM, OR ANY SPECIAL INDIRECT
|
||||
* OR CONSEQUENTIAL DAMAGES, OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS
|
||||
* OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
|
||||
* OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
|
||||
* PERFORMANCE OF THIS SOFTWARE.
|
||||
*/
|
||||
+17
-25
@@ -3,26 +3,18 @@
|
||||
#ifndef PREFERENCE_H
|
||||
#define PREFERENCE_H
|
||||
|
||||
#include "IniFile.h"
|
||||
#include "PrefsManager.h"
|
||||
#include "EnumHelper.h"
|
||||
class IniFile;
|
||||
|
||||
enum PrefsGroup
|
||||
{
|
||||
Debug,
|
||||
Editor,
|
||||
Options,
|
||||
NUM_PREFS_GROUPS
|
||||
};
|
||||
const CString& PrefsGroupToString( PrefsGroup pg );
|
||||
|
||||
inline CString PrefsGroupToString( PrefsGroup pg )
|
||||
{
|
||||
switch( pg )
|
||||
{
|
||||
case Debug: return "Debug";
|
||||
case Editor: return "Editor";
|
||||
case Options: return "Options";
|
||||
default: ASSERT(0); return "";
|
||||
}
|
||||
}
|
||||
|
||||
class IPreference
|
||||
{
|
||||
@@ -33,6 +25,9 @@ public:
|
||||
virtual void WriteTo( IniFile &ini ) const = 0;
|
||||
};
|
||||
|
||||
void SubscribePreference( IPreference *p );
|
||||
void UnsubscribePreference( IPreference *p );
|
||||
|
||||
template <class T>
|
||||
class Preference : public IPreference
|
||||
{
|
||||
@@ -41,6 +36,9 @@ private:
|
||||
CString m_sName;
|
||||
T m_defaultValue;
|
||||
T m_currentValue;
|
||||
|
||||
CString ToString();
|
||||
void FromString( const CString &s );
|
||||
|
||||
public:
|
||||
Preference( PrefsGroup PrefsGroup, const CString& sName, const T& defaultValue ):
|
||||
@@ -49,12 +47,13 @@ public:
|
||||
m_defaultValue( defaultValue ),
|
||||
m_currentValue( defaultValue )
|
||||
{
|
||||
PrefsManager::Subscribe( this );
|
||||
SubscribePreference( this );
|
||||
LoadDefault();
|
||||
}
|
||||
|
||||
~Preference()
|
||||
{
|
||||
PrefsManager::Unsubscribe( this );
|
||||
UnsubscribePreference( this );
|
||||
}
|
||||
|
||||
void LoadDefault()
|
||||
@@ -62,21 +61,14 @@ public:
|
||||
m_currentValue = m_defaultValue;
|
||||
}
|
||||
|
||||
void ReadFrom( const IniFile &ini )
|
||||
{
|
||||
ini.GetValue( PrefsGroupToString(m_PrefsGroup), m_sName, m_currentValue );
|
||||
}
|
||||
void ReadFrom( const IniFile &ini );
|
||||
void WriteTo( IniFile &ini ) const;
|
||||
|
||||
void WriteTo( IniFile &ini ) const
|
||||
{
|
||||
ini.SetValue( PrefsGroupToString(m_PrefsGroup), m_sName, m_currentValue );
|
||||
}
|
||||
|
||||
const T& GetValue() const
|
||||
operator T& ()
|
||||
{
|
||||
return m_currentValue;
|
||||
}
|
||||
|
||||
|
||||
operator const T& () const
|
||||
{
|
||||
return m_currentValue;
|
||||
|
||||
@@ -275,12 +275,15 @@ void ScreenSystemLayer::Update( float fDeltaTime )
|
||||
{
|
||||
Screen::Update(fDeltaTime);
|
||||
|
||||
if( PREFSMAN && PREFSMAN->m_bShowStats )
|
||||
if( PREFSMAN && (bool)PREFSMAN->m_bShowStats )
|
||||
{
|
||||
m_textStats.SetDiffuse( RageColor(1,1,1,0.7f) );
|
||||
m_textStats.SetText( DISPLAY->GetStats() );
|
||||
} else
|
||||
}
|
||||
else
|
||||
{
|
||||
m_textStats.SetDiffuse( RageColor(1,1,1,0) ); /* hide */
|
||||
}
|
||||
|
||||
UpdateTimestampAndSkips();
|
||||
}
|
||||
|
||||
@@ -62,7 +62,7 @@ IntDir=.\../Debug6
|
||||
TargetDir=\stepmania\stepmania\Program
|
||||
TargetName=StepMania-debug
|
||||
SOURCE="$(InputPath)"
|
||||
PreLink_Cmds=archutils\Win32\verinc cl /Zl /nologo /c verstub.cpp /Fo$(IntDir)\
|
||||
PreLink_Cmds=archutils\Win32\verinc cl /Zl /nologo /c verstub.cpp /Fo$(IntDir)\
|
||||
PostBuild_Cmds=archutils\Win32\mapconv $(IntDir)\$(TargetName).map $(TargetDir)\StepMania.vdi
|
||||
# End Special Build Tool
|
||||
|
||||
@@ -99,7 +99,7 @@ IntDir=.\../Release6
|
||||
TargetDir=\stepmania\stepmania\Program
|
||||
TargetName=StepMania
|
||||
SOURCE="$(InputPath)"
|
||||
PreLink_Cmds=archutils\Win32\verinc cl /Zl /nologo /c verstub.cpp /Fo$(IntDir)\
|
||||
PreLink_Cmds=archutils\Win32\verinc cl /Zl /nologo /c verstub.cpp /Fo$(IntDir)\
|
||||
PostBuild_Cmds=archutils\Win32\mapconv $(IntDir)\$(TargetName).map $(TargetDir)\StepMania.vdi
|
||||
# End Special Build Tool
|
||||
|
||||
@@ -940,6 +940,14 @@ SOURCE=.\PlayerOptions.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\Preference.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\Preference.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\Profile.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
@@ -833,6 +833,9 @@ cl /Zl /nologo /c verstub.cpp /Fo"$(IntDir)"\
|
||||
<File
|
||||
RelativePath="PlayerOptions.h">
|
||||
</File>
|
||||
<File
|
||||
RelativePath="Preference.cpp">
|
||||
</File>
|
||||
<File
|
||||
RelativePath="Profile.cpp">
|
||||
</File>
|
||||
|
||||
Reference in New Issue
Block a user