diff --git a/stepmania/src/StepMania.cpp b/stepmania/src/StepMania.cpp index e8120497ea..b1ff3c82d5 100644 --- a/stepmania/src/StepMania.cpp +++ b/stepmania/src/StepMania.cpp @@ -1104,6 +1104,12 @@ int main(int argc, char* argv[]) /* Set up the theme and announcer, and switch to the last game type. */ ReadGamePrefsFromDisk( true ); + { + CString sSection = "Preferences"; + GetCommandlineArgument( "Type", &sSection ); + THEME->LoadPreferencesFromSection( sSection ); + } + { /* Now that THEME is loaded, load the icon for the current theme into the * loading window. */ diff --git a/stepmania/src/ThemeManager.cpp b/stepmania/src/ThemeManager.cpp index 325b5ed263..17e7139a73 100644 --- a/stepmania/src/ThemeManager.cpp +++ b/stepmania/src/ThemeManager.cpp @@ -868,6 +868,39 @@ void ThemeManager::GetMetricsThatBeginWith( const CString &_sClassName, const CS } } +void ThemeManager::LoadPreferencesFromSection( const CString &sClassName ) +{ + set asNames; + + GetMetricsThatBeginWith( sClassName, "", asNames ); + + /* If "Theme" isn't set, we're not changing the theme. Break out and + * load other preferences. */ + if( asNames.find("Theme") != asNames.end() ) + { + /* Change the theme. Only do this once. */ + CString sTheme; + GetMetric( sClassName, "Theme", sTheme ); + THEME->SwitchThemeAndLanguage( sTheme, PREFSMAN->m_sLanguage ); + + asNames.erase( "Theme" ); + } + + FOREACHS( CString, asNames, sName ) + { + IPreference *pPref = PREFSMAN->GetPreferenceByName( *sName ); + if( pPref == NULL ) + { + LOG->Warn( "Unknown preference in [%s]: %s", sClassName.c_str(), sName->c_str() ); + continue; + } + + CString sVal; + GetMetric( sClassName, *sName, sVal ); + + pPref->FromString( sVal ); + } +} // lua start #include "LuaBinding.h" diff --git a/stepmania/src/ThemeManager.h b/stepmania/src/ThemeManager.h index fddb07d936..e4145d5877 100644 --- a/stepmania/src/ThemeManager.h +++ b/stepmania/src/ThemeManager.h @@ -91,6 +91,7 @@ public: void GetMetric( const CString &sClassName, const CString &sValueName, apActorCommands &valueOut ); void GetMetricsThatBeginWith( const CString &sClassName, const CString &sValueName, set &vsValueNamesOut ); + void LoadPreferencesFromSection( const CString &sClassName ); // // For self-registering metrics