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.
|
||||||
|
*/
|
||||||
+16
-24
@@ -3,26 +3,18 @@
|
|||||||
#ifndef PREFERENCE_H
|
#ifndef PREFERENCE_H
|
||||||
#define PREFERENCE_H
|
#define PREFERENCE_H
|
||||||
|
|
||||||
#include "IniFile.h"
|
#include "EnumHelper.h"
|
||||||
#include "PrefsManager.h"
|
class IniFile;
|
||||||
|
|
||||||
enum PrefsGroup
|
enum PrefsGroup
|
||||||
{
|
{
|
||||||
Debug,
|
Debug,
|
||||||
Editor,
|
Editor,
|
||||||
Options,
|
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
|
class IPreference
|
||||||
{
|
{
|
||||||
@@ -33,6 +25,9 @@ public:
|
|||||||
virtual void WriteTo( IniFile &ini ) const = 0;
|
virtual void WriteTo( IniFile &ini ) const = 0;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
void SubscribePreference( IPreference *p );
|
||||||
|
void UnsubscribePreference( IPreference *p );
|
||||||
|
|
||||||
template <class T>
|
template <class T>
|
||||||
class Preference : public IPreference
|
class Preference : public IPreference
|
||||||
{
|
{
|
||||||
@@ -42,6 +37,9 @@ private:
|
|||||||
T m_defaultValue;
|
T m_defaultValue;
|
||||||
T m_currentValue;
|
T m_currentValue;
|
||||||
|
|
||||||
|
CString ToString();
|
||||||
|
void FromString( const CString &s );
|
||||||
|
|
||||||
public:
|
public:
|
||||||
Preference( PrefsGroup PrefsGroup, const CString& sName, const T& defaultValue ):
|
Preference( PrefsGroup PrefsGroup, const CString& sName, const T& defaultValue ):
|
||||||
m_PrefsGroup( PrefsGroup ),
|
m_PrefsGroup( PrefsGroup ),
|
||||||
@@ -49,12 +47,13 @@ public:
|
|||||||
m_defaultValue( defaultValue ),
|
m_defaultValue( defaultValue ),
|
||||||
m_currentValue( defaultValue )
|
m_currentValue( defaultValue )
|
||||||
{
|
{
|
||||||
PrefsManager::Subscribe( this );
|
SubscribePreference( this );
|
||||||
|
LoadDefault();
|
||||||
}
|
}
|
||||||
|
|
||||||
~Preference()
|
~Preference()
|
||||||
{
|
{
|
||||||
PrefsManager::Unsubscribe( this );
|
UnsubscribePreference( this );
|
||||||
}
|
}
|
||||||
|
|
||||||
void LoadDefault()
|
void LoadDefault()
|
||||||
@@ -62,17 +61,10 @@ public:
|
|||||||
m_currentValue = m_defaultValue;
|
m_currentValue = m_defaultValue;
|
||||||
}
|
}
|
||||||
|
|
||||||
void ReadFrom( const IniFile &ini )
|
void ReadFrom( const IniFile &ini );
|
||||||
{
|
void WriteTo( IniFile &ini ) const;
|
||||||
ini.GetValue( PrefsGroupToString(m_PrefsGroup), m_sName, m_currentValue );
|
|
||||||
}
|
|
||||||
|
|
||||||
void WriteTo( IniFile &ini ) const
|
operator T& ()
|
||||||
{
|
|
||||||
ini.SetValue( PrefsGroupToString(m_PrefsGroup), m_sName, m_currentValue );
|
|
||||||
}
|
|
||||||
|
|
||||||
const T& GetValue() const
|
|
||||||
{
|
{
|
||||||
return m_currentValue;
|
return m_currentValue;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -275,12 +275,15 @@ void ScreenSystemLayer::Update( float fDeltaTime )
|
|||||||
{
|
{
|
||||||
Screen::Update(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.SetDiffuse( RageColor(1,1,1,0.7f) );
|
||||||
m_textStats.SetText( DISPLAY->GetStats() );
|
m_textStats.SetText( DISPLAY->GetStats() );
|
||||||
} else
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
m_textStats.SetDiffuse( RageColor(1,1,1,0) ); /* hide */
|
m_textStats.SetDiffuse( RageColor(1,1,1,0) ); /* hide */
|
||||||
|
}
|
||||||
|
|
||||||
UpdateTimestampAndSkips();
|
UpdateTimestampAndSkips();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -62,7 +62,7 @@ IntDir=.\../Debug6
|
|||||||
TargetDir=\stepmania\stepmania\Program
|
TargetDir=\stepmania\stepmania\Program
|
||||||
TargetName=StepMania-debug
|
TargetName=StepMania-debug
|
||||||
SOURCE="$(InputPath)"
|
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
|
PostBuild_Cmds=archutils\Win32\mapconv $(IntDir)\$(TargetName).map $(TargetDir)\StepMania.vdi
|
||||||
# End Special Build Tool
|
# End Special Build Tool
|
||||||
|
|
||||||
@@ -99,7 +99,7 @@ IntDir=.\../Release6
|
|||||||
TargetDir=\stepmania\stepmania\Program
|
TargetDir=\stepmania\stepmania\Program
|
||||||
TargetName=StepMania
|
TargetName=StepMania
|
||||||
SOURCE="$(InputPath)"
|
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
|
PostBuild_Cmds=archutils\Win32\mapconv $(IntDir)\$(TargetName).map $(TargetDir)\StepMania.vdi
|
||||||
# End Special Build Tool
|
# End Special Build Tool
|
||||||
|
|
||||||
@@ -940,6 +940,14 @@ SOURCE=.\PlayerOptions.h
|
|||||||
# End Source File
|
# End Source File
|
||||||
# Begin 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
|
SOURCE=.\Profile.cpp
|
||||||
# End Source File
|
# End Source File
|
||||||
# Begin Source File
|
# Begin Source File
|
||||||
|
|||||||
@@ -833,6 +833,9 @@ cl /Zl /nologo /c verstub.cpp /Fo"$(IntDir)"\
|
|||||||
<File
|
<File
|
||||||
RelativePath="PlayerOptions.h">
|
RelativePath="PlayerOptions.h">
|
||||||
</File>
|
</File>
|
||||||
|
<File
|
||||||
|
RelativePath="Preference.cpp">
|
||||||
|
</File>
|
||||||
<File
|
<File
|
||||||
RelativePath="Profile.cpp">
|
RelativePath="Profile.cpp">
|
||||||
</File>
|
</File>
|
||||||
|
|||||||
Reference in New Issue
Block a user