move game prefs into PrefsManager
This commit is contained in:
@@ -253,7 +253,7 @@ bool CodeDetector::DetectAndAdjustMusicOptions( GameController controller )
|
||||
case CODE_MINES: TOGGLE( po.m_bTransforms[PlayerOptions::TRANSFORM_NOMINES], true, false ); break;
|
||||
case CODE_DARK: FLOAT_TOGGLE( po.m_fDark ); break;
|
||||
case CODE_CANCEL_ALL: po.Init();
|
||||
po.FromString( PREFSMAN->m_sDefaultModifiers ); break;
|
||||
po.FromString( PREFSMAN->GetCurrentGamePrefs().m_sDefaultModifiers ); break;
|
||||
case CODE_HIDDEN: TOGGLE_HIDDEN; break;
|
||||
case CODE_RANDOMVANISH: TOGGLE_RANDOMVANISH; break;
|
||||
|
||||
|
||||
@@ -1103,8 +1103,8 @@ void GameCommand::ApplySelf( const vector<PlayerNumber> &vpns ) const
|
||||
if( m_bApplyDefaultOptions )
|
||||
{
|
||||
FOREACH_PlayerNumber( p )
|
||||
GAMESTATE->m_pPlayerState[p]->m_PlayerOptions.FromString( PREFSMAN->m_sDefaultModifiers );
|
||||
GAMESTATE->m_SongOptions.FromString( PREFSMAN->m_sDefaultModifiers );
|
||||
GAMESTATE->m_pPlayerState[p]->m_PlayerOptions.FromString( PREFSMAN->GetCurrentGamePrefs().m_sDefaultModifiers );
|
||||
GAMESTATE->m_SongOptions.FromString( PREFSMAN->GetCurrentGamePrefs().m_sDefaultModifiers );
|
||||
}
|
||||
// HACK: Set life type to BATTERY just once here so it happens once and
|
||||
// we don't override the user's changes if they back out.
|
||||
|
||||
@@ -244,7 +244,7 @@ void GameState::Reset()
|
||||
// could be done in the title menu GameCommand, but then it wouldn't
|
||||
// affect demo, and other non-gameplay things ...) -glenn
|
||||
ApplyModifiers( p, DEFAULT_MODIFIERS );
|
||||
ApplyModifiers( p, PREFSMAN->m_sDefaultModifiers );
|
||||
ApplyModifiers( p, PREFSMAN->GetCurrentGamePrefs().m_sDefaultModifiers );
|
||||
}
|
||||
|
||||
FOREACH_PlayerNumber(p)
|
||||
@@ -1036,10 +1036,10 @@ void GameState::ResetCurrentOptions()
|
||||
FOREACH_PlayerNumber( p )
|
||||
{
|
||||
m_pPlayerState[p]->m_PlayerOptions.Init();
|
||||
m_pPlayerState[p]->m_PlayerOptions.FromString( PREFSMAN->m_sDefaultModifiers );
|
||||
m_pPlayerState[p]->m_PlayerOptions.FromString( PREFSMAN->GetCurrentGamePrefs().m_sDefaultModifiers );
|
||||
}
|
||||
m_SongOptions.Init();
|
||||
m_SongOptions.FromString( PREFSMAN->m_sDefaultModifiers );
|
||||
m_SongOptions.FromString( PREFSMAN->GetCurrentGamePrefs().m_sDefaultModifiers );
|
||||
}
|
||||
|
||||
bool GameState::IsDisqualified( PlayerNumber pn )
|
||||
@@ -1887,7 +1887,7 @@ bool GameState::IsSyncDataChanged()
|
||||
void GameState::SaveSyncChanges()
|
||||
{
|
||||
GAMESTATE->m_pCurSong->Save();
|
||||
PREFSMAN->SaveGlobalPrefsToDisk();
|
||||
PREFSMAN->SavePrefsToDisk();
|
||||
ResetOriginalSyncData();
|
||||
}
|
||||
|
||||
|
||||
@@ -12,9 +12,9 @@
|
||||
#include "Preference.h"
|
||||
#include "RageLog.h"
|
||||
|
||||
#define DEFAULTS_INI_PATH "Data/Defaults.ini" // these can be overridden
|
||||
#define STEPMANIA_INI_PATH "Data/" PRODUCT_NAME ".ini" // overlay on Defaults.ini, contains the user's choices
|
||||
#define STATIC_INI_PATH "Data/Static.ini" // overlay on the 2 above, can't be overridden
|
||||
const CString DEFAULTS_INI_PATH = "Data/Defaults.ini"; // these can be overridden
|
||||
const CString STEPMANIA_INI_PATH = "Data/" PRODUCT_NAME ".ini"; // overlay on Defaults.ini, contains the user's choices
|
||||
const CString STATIC_INI_PATH = "Data/Static.ini"; // overlay on the 2 above, can't be overridden
|
||||
|
||||
PrefsManager* PREFSMAN = NULL; // global and accessable from anywhere in our program
|
||||
|
||||
@@ -241,7 +241,8 @@ void MemoryCardUsbLevelInit( size_t /*PlayerNumber*/ i, CString &sNameOut, int &
|
||||
|
||||
|
||||
PrefsManager::PrefsManager() :
|
||||
m_bWindowed ( "Windowed", TRUE_IF_DEBUG),
|
||||
m_sCurrentGame ( "CurrentGame", "" ),
|
||||
m_bWindowed ( "Windowed", TRUE_IF_DEBUG ),
|
||||
m_iDisplayWidth ( "DisplayWidth", 640 ),
|
||||
m_iDisplayHeight ( "DisplayHeight", 480 ),
|
||||
m_iDisplayColorDepth ( "DisplayColorDepth", 16 ),
|
||||
@@ -421,10 +422,7 @@ PrefsManager::PrefsManager() :
|
||||
m_bShowLogOutput ( "ShowLogOutput", false ),
|
||||
m_bLogSkips ( "LogSkips", false ),
|
||||
m_bLogCheckpoints ( "LogCheckpoints", false ),
|
||||
m_bShowLoadingWindow ( "ShowLoadingWindow", true ),
|
||||
|
||||
/* Game-specific prefs: */
|
||||
m_sDefaultModifiers ( "DefaultModifiers", "" )
|
||||
m_bShowLoadingWindow ( "ShowLoadingWindow", true )
|
||||
|
||||
#if defined(XBOX)
|
||||
,
|
||||
@@ -442,7 +440,7 @@ PrefsManager::PrefsManager() :
|
||||
|
||||
{
|
||||
Init();
|
||||
ReadGlobalPrefsFromDisk();
|
||||
ReadPrefsFromDisk();
|
||||
}
|
||||
#undef TRUE_IF_DEBUG
|
||||
|
||||
@@ -456,7 +454,7 @@ PrefsManager::~PrefsManager()
|
||||
{
|
||||
}
|
||||
|
||||
void PrefsManager::ReadGlobalPrefsFromDisk()
|
||||
void PrefsManager::ReadPrefsFromDisk()
|
||||
{
|
||||
ReadPrefsFromFile( DEFAULTS_INI_PATH );
|
||||
ReadPrefsFromFile( STEPMANIA_INI_PATH );
|
||||
@@ -470,7 +468,7 @@ void PrefsManager::ResetToFactoryDefaults()
|
||||
ReadPrefsFromFile( DEFAULTS_INI_PATH );
|
||||
ReadPrefsFromFile( STATIC_INI_PATH );
|
||||
|
||||
SaveGlobalPrefsToDisk();
|
||||
SavePrefsToDisk();
|
||||
}
|
||||
|
||||
void PrefsManager::ReadPrefsFromFile( CString sIni )
|
||||
@@ -479,10 +477,12 @@ void PrefsManager::ReadPrefsFromFile( CString sIni )
|
||||
if( !ini.ReadFile(sIni) )
|
||||
return;
|
||||
|
||||
ReadGlobalPrefsFromIni( ini );
|
||||
ReadPrefsFromIni( ini );
|
||||
}
|
||||
|
||||
void PrefsManager::ReadGlobalPrefsFromIni( const IniFile &ini )
|
||||
static const CString GAME_SECTION_PREFIX = "Game-";
|
||||
|
||||
void PrefsManager::ReadPrefsFromIni( const IniFile &ini )
|
||||
{
|
||||
FOREACHS_CONST( IPreference*, *SubscriptionManager<IPreference>::s_pSubscribers, p )
|
||||
(*p)->ReadFrom( ini );
|
||||
@@ -492,19 +492,42 @@ void PrefsManager::ReadGlobalPrefsFromIni( const IniFile &ini )
|
||||
FOREACH_PlayerNumber( pn )
|
||||
m_sMemoryCardOsMountPoint[pn].Set( FixSlashes(m_sMemoryCardOsMountPoint[pn]) );
|
||||
m_BackgroundMode.Set( (BackgroundMode)clamp((int)m_BackgroundMode.Get(),0,(int)NUM_BackgroundMode-1) );
|
||||
|
||||
|
||||
FOREACH_CONST_Child( &ini, section )
|
||||
{
|
||||
if( !BeginsWith(section->m_sName, GAME_SECTION_PREFIX) )
|
||||
continue;
|
||||
|
||||
CString sGame = section->m_sName.Right( section->m_sName.length() - GAME_SECTION_PREFIX.length() );
|
||||
GamePrefs &gp = m_mapGameNameToGamePrefs[ sGame ];
|
||||
|
||||
ini.GetValue( section->m_sName, "Announcer", gp.m_sAnnouncer );
|
||||
ini.GetValue( section->m_sName, "Theme", gp.m_sTheme );
|
||||
ini.GetValue( section->m_sName, "DefaultModifiers", gp.m_sDefaultModifiers );
|
||||
}
|
||||
}
|
||||
|
||||
void PrefsManager::SaveGlobalPrefsToDisk() const
|
||||
void PrefsManager::SavePrefsToDisk() const
|
||||
{
|
||||
IniFile ini;
|
||||
SaveGlobalPrefsToIni( ini );
|
||||
SavePrefsToIni( ini );
|
||||
ini.WriteFile( STEPMANIA_INI_PATH );
|
||||
}
|
||||
|
||||
void PrefsManager::SaveGlobalPrefsToIni( IniFile &ini ) const
|
||||
void PrefsManager::SavePrefsToIni( IniFile &ini ) const
|
||||
{
|
||||
FOREACHS_CONST( IPreference*, *SubscriptionManager<IPreference>::s_pSubscribers, p )
|
||||
(*p)->WriteTo( ini );
|
||||
|
||||
FOREACHM_CONST( CString, GamePrefs, m_mapGameNameToGamePrefs, iter )
|
||||
{
|
||||
CString sSection = "Game-" + CString( iter->first );
|
||||
|
||||
ini.SetValue( sSection, "Announcer", iter->second.m_sAnnouncer );
|
||||
ini.SetValue( sSection, "Theme", iter->second.m_sTheme );
|
||||
ini.SetValue( sSection, "DefaultModifiers", iter->second.m_sDefaultModifiers );
|
||||
}
|
||||
}
|
||||
|
||||
// wrappers
|
||||
|
||||
@@ -21,6 +21,7 @@ public:
|
||||
|
||||
void Init();
|
||||
|
||||
Preference<CString> m_sCurrentGame;
|
||||
Preference<bool> m_bWindowed;
|
||||
Preference<int> m_iDisplayWidth;
|
||||
Preference<int> m_iDisplayHeight;
|
||||
@@ -249,9 +250,6 @@ public:
|
||||
Preference<bool> m_bLogCheckpoints;
|
||||
Preference<bool> m_bShowLoadingWindow;
|
||||
|
||||
/* Game-specific prefs: */
|
||||
Preference<CString> m_sDefaultModifiers;
|
||||
|
||||
#if defined(XBOX)
|
||||
// Virtual memory preferences
|
||||
Preference<bool> m_bEnableVirtualMemory;
|
||||
@@ -275,11 +273,11 @@ public:
|
||||
CString GetLightsDriver();
|
||||
|
||||
|
||||
void ReadGlobalPrefsFromIni( const IniFile &ini );
|
||||
void SaveGlobalPrefsToIni( IniFile &ini ) const;
|
||||
void ReadPrefsFromIni( const IniFile &ini );
|
||||
void SavePrefsToIni( IniFile &ini ) const;
|
||||
|
||||
void ReadGlobalPrefsFromDisk();
|
||||
void SaveGlobalPrefsToDisk() const;
|
||||
void ReadPrefsFromDisk();
|
||||
void SavePrefsToDisk() const;
|
||||
|
||||
void ResetToFactoryDefaults();
|
||||
|
||||
@@ -289,6 +287,24 @@ public:
|
||||
static void Subscribe( IPreference *p );
|
||||
static void Unsubscribe( IPreference *p );
|
||||
|
||||
|
||||
//
|
||||
// Non-self-registering prefs
|
||||
//
|
||||
struct GamePrefs
|
||||
{
|
||||
CString m_sAnnouncer;
|
||||
CString m_sTheme;
|
||||
CString m_sDefaultModifiers;
|
||||
};
|
||||
map<CString, GamePrefs> m_mapGameNameToGamePrefs;
|
||||
|
||||
GamePrefs &GetCurrentGamePrefs() { return m_mapGameNameToGamePrefs[m_sCurrentGame]; } // inserts if not already present
|
||||
|
||||
void SaveGamePrefsToDisk();
|
||||
void ReadGamePrefsFromDisk();
|
||||
|
||||
|
||||
// Lua
|
||||
void PushSelf( lua_State *L );
|
||||
|
||||
|
||||
@@ -633,7 +633,7 @@ class DebugLineWritePreferences : public IDebugLine
|
||||
virtual bool IsEnabled() { return true; }
|
||||
virtual void Do( CString &sMessageOut )
|
||||
{
|
||||
PREFSMAN->SaveGlobalPrefsToDisk();
|
||||
PREFSMAN->SavePrefsToDisk();
|
||||
IDebugLine::Do( sMessageOut );
|
||||
}
|
||||
};
|
||||
|
||||
@@ -214,13 +214,13 @@ void ScreenJukebox::Init()
|
||||
if( GAMESTATE->m_bJukeboxUsesModifiers )
|
||||
{
|
||||
GAMESTATE->m_pPlayerState[p]->m_PlayerOptions.Init();
|
||||
GAMESTATE->m_pPlayerState[p]->m_PlayerOptions.FromString( PREFSMAN->m_sDefaultModifiers );
|
||||
GAMESTATE->m_pPlayerState[p]->m_PlayerOptions.FromString( PREFSMAN->GetCurrentGamePrefs().m_sDefaultModifiers );
|
||||
GAMESTATE->m_pPlayerState[p]->m_PlayerOptions.ChooseRandomModifiers();
|
||||
}
|
||||
}
|
||||
|
||||
GAMESTATE->m_SongOptions.Init();
|
||||
GAMESTATE->m_SongOptions.FromString( PREFSMAN->m_sDefaultModifiers );
|
||||
GAMESTATE->m_SongOptions.FromString( PREFSMAN->GetCurrentGamePrefs().m_sDefaultModifiers );
|
||||
|
||||
GAMESTATE->m_SongOptions.m_FailType = SongOptions::FAIL_OFF;
|
||||
|
||||
|
||||
@@ -688,7 +688,7 @@ void ScreenManager::LoadDelayedScreen()
|
||||
|
||||
// If we're exiting a system menu, persist settings in case we don't exit normally
|
||||
if( bWasOnSystemMenu && !bIsOnSystemMenu )
|
||||
PREFSMAN->SaveGlobalPrefsToDisk();
|
||||
PREFSMAN->SavePrefsToDisk();
|
||||
|
||||
if( bTimeToDeleteScreens )
|
||||
DeletePreparedScreens();
|
||||
|
||||
@@ -201,8 +201,7 @@ void ScreenOptionsMaster::HandleScreenMessage( const ScreenMessage SM )
|
||||
{
|
||||
/* Save preferences. */
|
||||
LOG->Trace("ROW_CONFIG used; saving ...");
|
||||
PREFSMAN->SaveGlobalPrefsToDisk();
|
||||
SaveGamePrefsToDisk();
|
||||
PREFSMAN->SavePrefsToDisk();
|
||||
}
|
||||
|
||||
if( m_iChangeMask & OPT_RESET_GAME )
|
||||
|
||||
@@ -18,8 +18,8 @@
|
||||
|
||||
static void GetDefaultModifiers( PlayerOptions &po, SongOptions &so )
|
||||
{
|
||||
po.FromString( PREFSMAN->m_sDefaultModifiers );
|
||||
so.FromString( PREFSMAN->m_sDefaultModifiers );
|
||||
po.FromString( PREFSMAN->GetCurrentGamePrefs().m_sDefaultModifiers );
|
||||
so.FromString( PREFSMAN->GetCurrentGamePrefs().m_sDefaultModifiers );
|
||||
}
|
||||
|
||||
static void SetDefaultModifiers( const PlayerOptions &po, const SongOptions &so )
|
||||
@@ -30,7 +30,7 @@ static void SetDefaultModifiers( const PlayerOptions &po, const SongOptions &so
|
||||
if( so.GetString() != "" )
|
||||
as.push_back( so.GetString() );
|
||||
|
||||
PREFSMAN->m_sDefaultModifiers.Set( join(", ",as) );
|
||||
PREFSMAN->GetCurrentGamePrefs().m_sDefaultModifiers = join( ", ",as );
|
||||
}
|
||||
|
||||
template<class T>
|
||||
@@ -238,7 +238,7 @@ static void DefaultNoteSkin( int &sel, bool ToSel, const ConfOption *pConfOption
|
||||
if( ToSel )
|
||||
{
|
||||
PlayerOptions po;
|
||||
po.FromString( PREFSMAN->m_sDefaultModifiers );
|
||||
po.FromString( PREFSMAN->GetCurrentGamePrefs().m_sDefaultModifiers );
|
||||
sel = 0;
|
||||
for( unsigned i=0; i < choices.size(); i++ )
|
||||
if( !stricmp(choices[i], po.m_sNoteSkin) )
|
||||
@@ -397,7 +397,7 @@ static void DefaultFailType( int &sel, bool ToSel, const ConfOption *pConfOption
|
||||
if( ToSel )
|
||||
{
|
||||
SongOptions so;
|
||||
so.FromString( PREFSMAN->m_sDefaultModifiers );
|
||||
so.FromString( PREFSMAN->GetCurrentGamePrefs().m_sDefaultModifiers );
|
||||
sel = so.m_FailType;
|
||||
}
|
||||
else
|
||||
|
||||
@@ -99,7 +99,7 @@ void ScreenPlayerOptions::Input( const InputEventPlus &input )
|
||||
|
||||
// apply the game default mods, but not the Profile saved mods
|
||||
GAMESTATE->m_pPlayerState[pn]->m_PlayerOptions.Init();
|
||||
GAMESTATE->m_pPlayerState[pn]->m_PlayerOptions.FromString( PREFSMAN->m_sDefaultModifiers );
|
||||
GAMESTATE->m_pPlayerState[pn]->m_PlayerOptions.FromString( PREFSMAN->GetCurrentGamePrefs().m_sDefaultModifiers );
|
||||
|
||||
MESSAGEMAN->Broadcast( ssprintf("CancelAllP%i", pn+1) );
|
||||
|
||||
|
||||
@@ -131,7 +131,7 @@ void ScreenSMOnlineLogin::HandleScreenMessage(const ScreenMessage SM)
|
||||
for( unsigned r=0; r<m_pRows.size(); r++ )
|
||||
ExportOptions( r, v );
|
||||
|
||||
PREFSMAN->SaveGlobalPrefsToDisk();
|
||||
PREFSMAN->SavePrefsToDisk();
|
||||
FOREACH_EnabledPlayer(pn)
|
||||
{
|
||||
PROFILEMAN->LoadLocalProfileFromMachine((PlayerNumber) pn);
|
||||
|
||||
@@ -125,7 +125,7 @@ void SongOptions::FromString( CString sOptions )
|
||||
{
|
||||
SongOptions so;
|
||||
// TODO: Fix this so that SongOptions don't depend on PrefsManager
|
||||
so.FromString( PREFSMAN->m_sDefaultModifiers );
|
||||
so.FromString( PREFSMAN->GetCurrentGamePrefs().m_sDefaultModifiers );
|
||||
m_FailType = so.m_FailType;
|
||||
}
|
||||
|
||||
|
||||
+13
-41
@@ -286,8 +286,6 @@ void ResetGame()
|
||||
THEME->SwitchThemeAndLanguage( "default", THEME->GetCurLanguage() );
|
||||
TEXTUREMAN->DoDelayedDelete();
|
||||
}
|
||||
SaveGamePrefsToDisk();
|
||||
|
||||
|
||||
//
|
||||
// update last seen joysticks
|
||||
@@ -310,6 +308,8 @@ void ResetGame()
|
||||
|
||||
PREFSMAN->m_sLastSeenInputDevices.Set( sInputDevices );
|
||||
}
|
||||
|
||||
PREFSMAN->SavePrefsToDisk();
|
||||
}
|
||||
|
||||
|
||||
@@ -382,7 +382,7 @@ static void CheckSettings()
|
||||
* systems. */
|
||||
PREFSMAN->m_BannerCache.Set( LowMemory ? PrefsManager::BNCACHE_OFF:PrefsManager::BNCACHE_LOW_RES_PRELOAD );
|
||||
|
||||
PREFSMAN->SaveGlobalPrefsToDisk();
|
||||
PREFSMAN->SavePrefsToDisk();
|
||||
#endif
|
||||
}
|
||||
|
||||
@@ -739,24 +739,22 @@ RageDisplay *CreateDisplay()
|
||||
RageException::Throw( error );
|
||||
}
|
||||
|
||||
#define GAMEPREFS_INI_PATH "Data/GamePrefs.ini"
|
||||
#define STATIC_INI_PATH "Data/Static.ini"
|
||||
|
||||
void ChangeCurrentGame( const Game* g )
|
||||
{
|
||||
ASSERT( g );
|
||||
|
||||
SaveGamePrefsToDisk();
|
||||
INPUTMAPPER->SaveMappingsToDisk(); // save mappings before switching the game
|
||||
|
||||
GAMESTATE->m_pCurGame = g;
|
||||
|
||||
/* Load this game's preferences. If we just set an unavailable game type, this
|
||||
* will change it back to the default. */
|
||||
ReadGamePrefsFromDisk( false );
|
||||
PREFSMAN->m_sCurrentGame.Set( g->m_szName );
|
||||
|
||||
/* Save the newly-selected game. */
|
||||
SaveGamePrefsToDisk();
|
||||
PREFSMAN->SavePrefsToDisk();
|
||||
|
||||
/* Load keymaps for the new game. */
|
||||
INPUTMAPPER->ReadMappingsFromDisk();
|
||||
@@ -769,17 +767,13 @@ void ReadGamePrefsFromDisk( bool bSwitchToLastPlayedGame )
|
||||
ASSERT( THEME );
|
||||
ASSERT( GAMESTATE );
|
||||
|
||||
IniFile ini;
|
||||
ini.ReadFile( GAMEPREFS_INI_PATH ); // it's OK if this fails
|
||||
ini.ReadFile( STATIC_INI_PATH ); // it's OK if this fails, too
|
||||
|
||||
if( bSwitchToLastPlayedGame )
|
||||
{
|
||||
ASSERT( GAMEMAN != NULL );
|
||||
CString sGame;
|
||||
GAMESTATE->m_pCurGame = NULL;
|
||||
if( ini.GetValue("Options", "Game", sGame) )
|
||||
GAMESTATE->m_pCurGame = GAMEMAN->StringToGameType( sGame );
|
||||
if( !PREFSMAN->m_sCurrentGame.Get().empty() )
|
||||
GAMESTATE->m_pCurGame = GAMEMAN->StringToGameType( PREFSMAN->m_sCurrentGame );
|
||||
}
|
||||
|
||||
/* If the active game type isn't actually available, revert to the default. */
|
||||
@@ -805,40 +799,19 @@ void ReadGamePrefsFromDisk( bool bSwitchToLastPlayedGame )
|
||||
CString sGameName = GAMESTATE->GetCurrentGame()->m_szName;
|
||||
CString sAnnouncer = sGameName;
|
||||
CString sTheme = sGameName;
|
||||
CString sNoteSkin = sGameName;
|
||||
CString sDefaultModifiers;
|
||||
|
||||
// if these calls fail, the three strings will keep the initial values set above.
|
||||
ini.GetValue( sGameName, "Announcer", sAnnouncer );
|
||||
ini.GetValue( sGameName, "Theme", sTheme );
|
||||
ini.GetValue( sGameName, "DefaultModifiers", sDefaultModifiers );
|
||||
PREFSMAN->m_sDefaultModifiers.Set( sDefaultModifiers );
|
||||
if( !PREFSMAN->GetCurrentGamePrefs().m_sAnnouncer.empty() )
|
||||
sAnnouncer = PREFSMAN->GetCurrentGamePrefs().m_sAnnouncer;
|
||||
if( !PREFSMAN->GetCurrentGamePrefs().m_sTheme.empty() )
|
||||
sTheme = PREFSMAN->GetCurrentGamePrefs().m_sTheme;
|
||||
|
||||
// it's OK to call these functions with names that don't exist.
|
||||
ANNOUNCER->SwitchAnnouncer( sAnnouncer );
|
||||
THEME->SwitchThemeAndLanguage( sTheme, PREFSMAN->m_sLanguage );
|
||||
|
||||
// NOTESKIN->SwitchNoteSkin( sNoteSkin );
|
||||
}
|
||||
|
||||
|
||||
void SaveGamePrefsToDisk()
|
||||
{
|
||||
if( !GAMESTATE )
|
||||
return;
|
||||
|
||||
CString sGameName = GAMESTATE->GetCurrentGame()->m_szName;
|
||||
IniFile ini;
|
||||
ini.ReadFile( GAMEPREFS_INI_PATH ); // it's OK if this fails
|
||||
|
||||
ini.SetValue( sGameName, "Announcer", ANNOUNCER->GetCurAnnouncerName() );
|
||||
ini.SetValue( sGameName, "Theme", THEME->GetCurThemeName() );
|
||||
ini.SetValue( sGameName, "DefaultModifiers", PREFSMAN->m_sDefaultModifiers );
|
||||
ini.SetValue( "Options", "Game", (CString)GAMESTATE->GetCurrentGame()->m_szName );
|
||||
|
||||
ini.WriteFile( GAMEPREFS_INI_PATH );
|
||||
}
|
||||
|
||||
static void MountTreeOfZips( const CString &dir )
|
||||
{
|
||||
vector<CString> dirs;
|
||||
@@ -1037,7 +1010,7 @@ int main(int argc, char* argv[])
|
||||
|
||||
/* One of the above filesystems might contain files that affect preferences, eg Data/Static.ini.
|
||||
* Re-read preferences. */
|
||||
PREFSMAN->ReadGlobalPrefsFromDisk();
|
||||
PREFSMAN->ReadPrefsFromDisk();
|
||||
ApplyLogPreferences();
|
||||
|
||||
#if defined(HAVE_SDL)
|
||||
@@ -1174,8 +1147,7 @@ int main(int argc, char* argv[])
|
||||
/* If we ended mid-game, finish up. */
|
||||
GAMESTATE->EndGame();
|
||||
|
||||
PREFSMAN->SaveGlobalPrefsToDisk();
|
||||
SaveGamePrefsToDisk();
|
||||
PREFSMAN->SavePrefsToDisk();
|
||||
|
||||
ShutdownGame();
|
||||
|
||||
|
||||
@@ -13,7 +13,6 @@ void ApplyGraphicOptions();
|
||||
void NORETURN HandleException( CString error );
|
||||
void ExitGame();
|
||||
void ResetGame();
|
||||
void SaveGamePrefsToDisk();
|
||||
void ChangeCurrentGame( const Game* g );
|
||||
void FocusChanged( bool bHasFocus );
|
||||
bool AppHasFocus();
|
||||
|
||||
Reference in New Issue
Block a user