From 63cc873fc98b92fa9f53424bc6297ed0d52828db Mon Sep 17 00:00:00 2001 From: Glenn Maynard Date: Sun, 19 Jun 2005 08:35:12 +0000 Subject: [PATCH] Simplify delayed/undelayed screen load path. Previously, the "delayed" path would return immediately in SetNewScreen, loading in the next update, and the "undelayed" path would load under SetNewScreen. Instead, always load on the next update, and just change the behavior (with "delayed" deleting the old screen first). These two code paths are both criticial, and they were too different, leading to inconsistent behavior; this way is simpler. --- stepmania/src/ScreenManager.cpp | 29 +++++++++++++++-------------- 1 file changed, 15 insertions(+), 14 deletions(-) diff --git a/stepmania/src/ScreenManager.cpp b/stepmania/src/ScreenManager.cpp index 5f652aade3..127ef45f35 100644 --- a/stepmania/src/ScreenManager.cpp +++ b/stepmania/src/ScreenManager.cpp @@ -191,16 +191,23 @@ void ScreenManager::Update( float fDeltaTime ) EmptyDeleteQueue(); - if(m_sDelayedScreen.size() != 0) + if( m_sDelayedScreen.size() != 0 ) { - /* We have a screen to display. Delete the current screens and load it. */ - ClearScreenStack(); - EmptyDeleteQueue(); + /* We have a screen to display. Delete the current screens and load it. + * If DelayedScreenLoad is true, clear the old screen first; this lowers + * memory requirements, but results in redundant loads as we unload common + * data. (If we don't unload the old screen here, it'll be deleted when + * we load the new screen.) */ + if( PREFSMAN->m_bDelayedScreenLoad ) + { + ClearScreenStack(); + EmptyDeleteQueue(); - /* This is the purpose of delayed screen loads: clear out the texture cache - * now, while there's (mostly) nothing loaded. */ - TEXTUREMAN->DeleteCachedTextures(); - TEXTUREMAN->DiagnosticOutput(); + /* This is the purpose of delayed screen loads: clear out the texture cache + * now, while there's (mostly) nothing loaded. */ + TEXTUREMAN->DeleteCachedTextures(); + TEXTUREMAN->DiagnosticOutput(); + } LoadDelayedScreen(); } @@ -370,12 +377,6 @@ void ScreenManager::SetNewScreen( const CString &sScreenName ) { ASSERT( sScreenName != "" ); m_sDelayedScreen = sScreenName; - - /* If we're not delaying screen loads, load it now. Otherwise, we'll load - * it on the next iteration. Only delay if we already have a screen - * loaded; otherwise, there's no reason to delay. */ - if(!PREFSMAN->m_bDelayedScreenLoad) // || m_ScreenStack.empty() ) - LoadDelayedScreen(); } void ScreenManager::LoadDelayedScreen()