void ThemeManager::SwitchThemeAndLanguage( const RString &sThemeName_, const RString &sLanguage_, bool bPseudoLocalize, bool bForceThemeReload ) { RString sThemeName = sThemeName_; RString sLanguage = sLanguage_; // todo: if the theme isn't selectable, find the next theme that is, // and change to that instead of asserting/crashing since // SpecialFiles::BASE_THEME_NAME is _fallback now. -aj #if !defined(SMPACKAGE) if( !IsThemeSelectable(sThemeName) ) sThemeName = PREFSMAN->m_sTheme.GetDefault(); // sm-ssc's SpecialFiles::BASE_THEME_NAME is _fallback, which you can't // select. This requires a preference, which allows it to be adapted for // other purposes (e.g. PARASTAR). if( !IsThemeSelectable(sThemeName) ) sThemeName = PREFSMAN->m_sDefaultTheme; #endif ASSERT( IsThemeSelectable(sThemeName) ); /* We haven't actually loaded the theme yet, so we can't check whether * sLanguage exists. Just check for empty. */ if( sLanguage.empty() ) sLanguage = GetDefaultLanguage(); LOG->Trace("ThemeManager::SwitchThemeAndLanguage: \"%s\", \"%s\"", sThemeName.c_str(), sLanguage.c_str() ); bool bNothingChanging = sThemeName == m_sCurThemeName && sLanguage == m_sCurLanguage && m_bPseudoLocalize == bPseudoLocalize; if( bNothingChanging && !bForceThemeReload ) return; m_bPseudoLocalize = bPseudoLocalize; // Load theme metrics. If only the language is changing, this is all // we need to reload. bool bThemeChanging = (sThemeName != m_sCurThemeName); LoadThemeMetrics( sThemeName, sLanguage ); // Clear the theme path cache. This caches language-specific graphic paths, // so do this even if only the language is changing. ClearThemePathCache(); if( bThemeChanging ) { #if !defined(SMPACKAGE) // reload common sounds if( SCREENMAN != NULL ) SCREENMAN->ThemeChanged(); #endif /* Lua globals can use metrics which are cached, and vice versa. Update Lua * globals first; it's Lua's job to explicitly update cached metrics that it * uses. */ UpdateLuaGlobals(); // Reload MachineProfile with new theme's CustomLoadFunction if( PROFILEMAN != NULL ) { Profile* pProfile = PROFILEMAN->GetMachineProfile(); pProfile->LoadCustomFunction( "/Save/MachineProfile/" ); } } // Use theme metrics for localization. LocalizedString::RegisterLocalizer( LocalizedStringImplThemeMetric::Create ); ReloadSubscribers(); }