I'm not sure why this ClearSubscribers was here; it's causing
metrics to not be loaded after a resolution change, because the reload is optimized out by SwitchThemeAndLanguage. (We may have loaded ThemeMetrics on demand in the past.) The reload needs to always happen, even though the theme hasn't changed, since the theme load is affected by the resolution; eg. upvalues in Lua scripts may have been computed based on SCREEN_WIDTH.
This commit is contained in:
@@ -115,10 +115,12 @@ static void CheckFocus()
|
||||
/* On the next update, change themes, and load sNewScreen. */
|
||||
static RString g_sNewTheme;
|
||||
static RString g_sNewScreen;
|
||||
void GameLoop::ChangeTheme( const RString &sNewTheme, const RString &sNewScreen )
|
||||
static bool g_bForceThemeReload;
|
||||
void GameLoop::ChangeTheme( const RString &sNewTheme, const RString &sNewScreen, bool bForced )
|
||||
{
|
||||
g_sNewTheme = sNewTheme;
|
||||
g_sNewScreen = sNewScreen;
|
||||
g_bForceThemeReload = bForced;
|
||||
}
|
||||
|
||||
#include "StepMania.h" // XXX
|
||||
@@ -129,14 +131,10 @@ namespace
|
||||
SAFE_DELETE( SCREENMAN );
|
||||
TEXTUREMAN->DoDelayedDelete();
|
||||
|
||||
/* Clear theme metrics, so ThemeMetric<apActorCommand>s are cleared. */
|
||||
THEME->ClearSubscribers();
|
||||
|
||||
/* In case the previous theme overloaded class bindings, reinitialize them. */
|
||||
LUA->RegisterTypes();
|
||||
|
||||
if( !THEME->SwitchThemeAndLanguage( g_sNewTheme, THEME->GetCurLanguage(), PREFSMAN->m_bPseudoLocalize ) )
|
||||
THEME->ReloadSubscribers();
|
||||
THEME->SwitchThemeAndLanguage( g_sNewTheme, THEME->GetCurLanguage(), PREFSMAN->m_bPseudoLocalize, g_bForceThemeReload );
|
||||
PREFSMAN->m_sTheme.Set( g_sNewTheme );
|
||||
|
||||
/* Apply the new window title, icon and aspect ratio. */
|
||||
|
||||
@@ -7,7 +7,7 @@ namespace GameLoop
|
||||
{
|
||||
void RunGameLoop();
|
||||
void SetUpdateRate( float fUpdateRate );
|
||||
void ChangeTheme( const RString &sNewTheme, const RString &sNewScreen );
|
||||
void ChangeTheme( const RString &sNewTheme, const RString &sNewScreen, bool bForced = false );
|
||||
void StartConcurrentRendering();
|
||||
void FinishConcurrentRendering();
|
||||
};
|
||||
|
||||
@@ -123,8 +123,11 @@ void ScreenOptionsMaster::HandleScreenMessage( const ScreenMessage SM )
|
||||
(m_iChangeMask & OPT_APPLY_GRAPHICS) ||
|
||||
(m_iChangeMask & OPT_APPLY_ASPECT_RATIO) )
|
||||
{
|
||||
/* If the resolution or aspect ratio changes, always reload the theme. Otherwise,
|
||||
* only reload it if it changed. */
|
||||
RString sNewTheme = PREFSMAN->m_sTheme.Get();
|
||||
GameLoop::ChangeTheme( sNewTheme, this->GetNextScreen() );
|
||||
bool bForceThemeReload = !!(m_iChangeMask & OPT_APPLY_ASPECT_RATIO) || !!(m_iChangeMask & OPT_APPLY_GRAPHICS);
|
||||
GameLoop::ChangeTheme( sNewTheme, this->GetNextScreen(), bForceThemeReload );
|
||||
StepMania::ApplyGraphicOptions();
|
||||
}
|
||||
|
||||
|
||||
@@ -345,7 +345,7 @@ RString ThemeManager::GetDefaultLanguage()
|
||||
return sLangCode;
|
||||
}
|
||||
|
||||
bool ThemeManager::SwitchThemeAndLanguage( const RString &sThemeName_, const RString &sLanguage_, bool bPseudoLocalize )
|
||||
void ThemeManager::SwitchThemeAndLanguage( const RString &sThemeName_, const RString &sLanguage_, bool bPseudoLocalize, bool bForceThemeReload )
|
||||
{
|
||||
RString sThemeName = sThemeName_;
|
||||
RString sLanguage = sLanguage_;
|
||||
@@ -366,8 +366,8 @@ bool ThemeManager::SwitchThemeAndLanguage( const RString &sThemeName_, const RSt
|
||||
sThemeName.c_str(), sLanguage.c_str() );
|
||||
|
||||
bool bNothingChanging = sThemeName == m_sCurThemeName && sLanguage == m_sCurLanguage && m_bPseudoLocalize == bPseudoLocalize;
|
||||
if( bNothingChanging )
|
||||
return false;
|
||||
if( bNothingChanging && !bForceThemeReload )
|
||||
return;
|
||||
|
||||
m_bPseudoLocalize = bPseudoLocalize;
|
||||
|
||||
@@ -397,7 +397,6 @@ bool ThemeManager::SwitchThemeAndLanguage( const RString &sThemeName_, const RSt
|
||||
LocalizedString::RegisterLocalizer( LocalizedStringImplThemeMetric::Create );
|
||||
|
||||
ReloadSubscribers();
|
||||
return true;
|
||||
}
|
||||
|
||||
void ThemeManager::ReloadSubscribers()
|
||||
|
||||
@@ -41,8 +41,7 @@ public:
|
||||
RString GetThemeDisplayName( const RString &sThemeName );
|
||||
void GetLanguages( vector<RString>& AddTo );
|
||||
bool DoesLanguageExist( const RString &sLanguage );
|
||||
// Return false if nothing changed.
|
||||
bool SwitchThemeAndLanguage( const RString &sThemeName, const RString &sLanguage, bool bPseudoLocalize );
|
||||
void SwitchThemeAndLanguage( const RString &sThemeName, const RString &sLanguage, bool bPseudoLocalize, bool bForceThemeReload = false );
|
||||
void UpdateLuaGlobals();
|
||||
RString GetCurThemeName() const { return m_sCurThemeName; };
|
||||
bool IsThemeLoaded() const { return !m_sCurThemeName.empty(); };
|
||||
|
||||
Reference in New Issue
Block a user