From 21bc8586cd28a7024e484d7752da88f9d18f993d Mon Sep 17 00:00:00 2001 From: Glenn Maynard Date: Wed, 25 Jan 2006 05:49:49 +0000 Subject: [PATCH] split out ScreenManager::ActivatePreparedScreenAndBackground (no real logic change) --- stepmania/src/ScreenManager.cpp | 88 ++++++++++++++++++--------------- stepmania/src/ScreenManager.h | 1 + 2 files changed, 49 insertions(+), 40 deletions(-) diff --git a/stepmania/src/ScreenManager.cpp b/stepmania/src/ScreenManager.cpp index 8158e49556..9f4c6f323b 100644 --- a/stepmania/src/ScreenManager.cpp +++ b/stepmania/src/ScreenManager.cpp @@ -621,51 +621,14 @@ void ScreenManager::SetNewScreen( const RString &sScreenName ) m_sDelayedScreen = sScreenName; } -void ScreenManager::LoadDelayedScreen() +Screen *ScreenManager::ActivatePreparedScreenAndBackground( const RString &sScreenName ) { - const bool bWasOnSystemMenu = !g_ScreenStack.empty() && g_ScreenStack.back().m_pScreen->GetScreenType() == system_menu; - - RString sScreenName = m_sDelayedScreen; - m_sDelayedScreen = ""; - - // Pop the top screen, if any. - ScreenMessage SM = PopTopScreenInternal(); - - /* We have a screen to display. Delete the current screens and load it. - * If DelayedScreenLoad is true and the screen isn't already loaded, delete - * old screens first; this lowers memory requirements, but results in - * redundant loads as we unload common data. (If the screen is already - * loaded, then do this cleanup later; otherwise we'll delete the prepared - * screen.) */ - bool bTimeToDeleteScreens = (g_setGroupedScreens.find(sScreenName) == g_setGroupedScreens.end()); - vector apActorsToDelete; - if( bTimeToDeleteScreens && !ScreenIsPrepped(sScreenName) ) - { - if( PREFSMAN->m_bDelayedScreenLoad ) - { - DeletePreparedScreens(); - } - else - { - /* Since DelayedScreenLoad is false, we want to keep the - * old screens in memory until we finish loading the new - * ones, in order to prevent unloading assets and then - * immediately reloading them. However, since the - * screen isn't in the current group, we must remove - * it from the pool before loading the new screen. */ - GrabPreparedActors( apActorsToDelete ); - } - } - - // Load the screen, if it's not already prepared. - PrepareScreen( sScreenName ); - // // Find the prepped screen. // LoadedScreen ls; - bool b = GetPreppedScreen( sScreenName, ls ); - ASSERT( b ); + if( !GetPreppedScreen(sScreenName, ls) ) + return NULL; // Screens may not call SetNewScreen from the ctor or Init(). ASSERT_M( m_sDelayedScreen.empty(), m_sDelayedScreen ); @@ -706,6 +669,51 @@ void ScreenManager::LoadDelayedScreen() LOG->Trace("... PushScreen"); PushLoadedScreen( ls ); + return ls.m_pScreen; +} + +void ScreenManager::LoadDelayedScreen() +{ + const bool bWasOnSystemMenu = !g_ScreenStack.empty() && g_ScreenStack.back().m_pScreen->GetScreenType() == system_menu; + + RString sScreenName = m_sDelayedScreen; + m_sDelayedScreen = ""; + + // Pop the top screen, if any. + ScreenMessage SM = PopTopScreenInternal(); + + /* We have a screen to display. Delete the current screens and load it. + * If DelayedScreenLoad is true and the screen isn't already loaded, delete + * old screens first; this lowers memory requirements, but results in + * redundant loads as we unload common data. (If the screen is already + * loaded, then do this cleanup later; otherwise we'll delete the prepared + * screen.) */ + bool bTimeToDeleteScreens = (g_setGroupedScreens.find(sScreenName) == g_setGroupedScreens.end()); + vector apActorsToDelete; + if( bTimeToDeleteScreens && !ScreenIsPrepped(sScreenName) ) + { + if( PREFSMAN->m_bDelayedScreenLoad ) + { + DeletePreparedScreens(); + } + else + { + /* Since DelayedScreenLoad is false, we want to keep the + * old screens in memory until we finish loading the new + * ones, in order to prevent unloading assets and then + * immediately reloading them. However, since the + * screen isn't in the current group, we must remove + * it from the pool before loading the new screen. */ + GrabPreparedActors( apActorsToDelete ); + } + } + + // Load the screen, if it's not already prepared. + PrepareScreen( sScreenName ); + + Screen *pScreen = ActivatePreparedScreenAndBackground( sScreenName ); + ASSERT( pScreen != NULL ); + bool bIsOnSystemMenu = ls.m_pScreen->GetScreenType() == system_menu; // If we're exiting a system menu, persist settings in case we don't exit normally diff --git a/stepmania/src/ScreenManager.h b/stepmania/src/ScreenManager.h index 418625b0f8..ca18b488a0 100644 --- a/stepmania/src/ScreenManager.h +++ b/stepmania/src/ScreenManager.h @@ -83,6 +83,7 @@ private: bool m_bZeroNextUpdate; void LoadDelayedScreen(); + Screen *ActivatePreparedScreenAndBackground( const RString &sScreenName ); ScreenMessage PopTopScreenInternal( bool bSendLoseFocus = true ); void RunConcurrentlyPrepareScreen();