IPreference stores preferences, but knows nothing about loading or
saving them; that's up to PrefsManager. Treat IPreference as a simple data holder, with simple facilities for looking them up by name, converting to/from strings, and storing to/from an XNode, but with no application-specific code to save to disk. This can be used alone as a way for code to configure things internally, even for uses that have no notion of storing user preferences (eg. unit tests), and other programs can use it to store preferences in entirely different ways (SMPackage could use it to store to the registry). PrefsManager is layered on top, to implement StepMania's particular use of Preference (saving and loading INIs), but isn't needed for Preference to be useful. This also makes Preference only use XNode, not the more specialized IniFile. (One piece is missing: several low-level places, eg. Dialog, want to set a preference and write it to disk immediately. The only way to do that is to have access to PREFSMAN. FIXME.)
This commit is contained in:
@@ -419,7 +419,7 @@ void PrefsManager::ReadPrefsFromIni( const IniFile &ini, const CString &sSection
|
||||
CString sFallback;
|
||||
if( ini.GetValue(sSection,"Fallback",sFallback) )
|
||||
{
|
||||
ReadPrefsFromIni( ini, sFallback );
|
||||
IPreference::ReadAllPrefsFromNode( ini.GetChild(sFallback) );
|
||||
}
|
||||
|
||||
//IPreference *pPref = PREFSMAN->GetPreferenceByName( *sName );
|
||||
@@ -430,7 +430,7 @@ void PrefsManager::ReadPrefsFromIni( const IniFile &ini, const CString &sSection
|
||||
// }
|
||||
// pPref->FromString( sVal );
|
||||
|
||||
IPreference::ReadAllPrefsFromIni( ini, sSection );
|
||||
IPreference::ReadAllPrefsFromNode( ini.GetChild(sSection) );
|
||||
|
||||
// validate
|
||||
m_iSongsPerPlay.Set( clamp(m_iSongsPerPlay.Get(),0,MAX_SONGS_PER_PLAY) );
|
||||
@@ -469,7 +469,10 @@ void PrefsManager::SavePrefsToIni( IniFile &ini )
|
||||
if( !m_sCurrentGame.Get().empty() )
|
||||
StoreGamePrefs();
|
||||
|
||||
IPreference::SavePrefsToIni( ini );
|
||||
XNode* pNode = ini.GetChild( "Options" );
|
||||
if( pNode == NULL )
|
||||
pNode = ini.AppendChild( "Options" );
|
||||
IPreference::SavePrefsToNode( pNode );
|
||||
|
||||
FOREACHM_CONST( CString, GamePrefs, m_mapGameNameToGamePrefs, iter )
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user