From d0c14b918761af7a6304efc4ebcbc0e742ef7d35 Mon Sep 17 00:00:00 2001 From: Glenn Maynard Date: Mon, 15 Aug 2005 15:19:34 +0000 Subject: [PATCH] pull out RunConcurrentlyPrepareScreen --- stepmania/src/ScreenManager.cpp | 51 ++++++++++++++++++--------------- stepmania/src/ScreenManager.h | 1 + 2 files changed, 29 insertions(+), 23 deletions(-) diff --git a/stepmania/src/ScreenManager.cpp b/stepmania/src/ScreenManager.cpp index 39af07711b..75a7a59cab 100644 --- a/stepmania/src/ScreenManager.cpp +++ b/stepmania/src/ScreenManager.cpp @@ -397,29 +397,7 @@ void ScreenManager::Update( float fDeltaTime ) if( !m_sDelayedConcurrentPrepare.empty() ) { - /* Don't call BackgroundPrepareScreen() from within another background load. */ - ASSERT( !IsConcurrentlyLoading() ); - - CString sScreenName = m_sDelayedConcurrentPrepare; - m_sDelayedConcurrentPrepare = ""; - - ScreenMessage SM = m_OnDonePreparingScreen; - m_OnDonePreparingScreen = SM_None; - - g_bIsConcurrentlyLoading = true; - StartConcurrentRendering(); - - if( g_setGroupedScreens.find(sScreenName) == g_setGroupedScreens.end() ) - DeletePreparedScreens(); - PrepareScreen( sScreenName ); - FinishConcurrentRendering(); - g_bIsConcurrentlyLoading = false; - - LOG->Trace( "Concurrent prepare of %s finished", sScreenName.c_str() ); - - /* We're done. Send the message. The screen is allowed to start - * another concurrent prepare from this message. */ - SendMessageToTopScreen( SM ); + RunConcurrentlyPrepareScreen(); } } @@ -570,6 +548,33 @@ bool ScreenManager::ConcurrentlyPrepareScreen( const CString &sScreenName, Scree return true; } +void ScreenManager::RunConcurrentlyPrepareScreen() +{ + /* Don't call BackgroundPrepareScreen() from within another background load. */ + ASSERT( !IsConcurrentlyLoading() ); + + CString sScreenName = m_sDelayedConcurrentPrepare; + m_sDelayedConcurrentPrepare = ""; + + ScreenMessage SM = m_OnDonePreparingScreen; + m_OnDonePreparingScreen = SM_None; + + g_bIsConcurrentlyLoading = true; + StartConcurrentRendering(); + + if( g_setGroupedScreens.find(sScreenName) == g_setGroupedScreens.end() ) + DeletePreparedScreens(); + PrepareScreen( sScreenName ); + FinishConcurrentRendering(); + g_bIsConcurrentlyLoading = false; + + LOG->Trace( "Concurrent prepare of %s finished", sScreenName.c_str() ); + + /* We're done. Send the message. The screen is allowed to start + * another concurrent prepare from this message. */ + SendMessageToTopScreen( SM ); +} + void ScreenManager::PushScreen( Screen *pNewScreen, bool bDeleteWhenDone, ScreenMessage SendOnPop ) { if( g_ScreenStack.size() ) diff --git a/stepmania/src/ScreenManager.h b/stepmania/src/ScreenManager.h index 6957b582e1..d31f0bffe3 100644 --- a/stepmania/src/ScreenManager.h +++ b/stepmania/src/ScreenManager.h @@ -83,6 +83,7 @@ private: void LoadDelayedScreen(); ScreenMessage PopTopScreenInternal( bool bSendLoseFocus = true ); + void RunConcurrentlyPrepareScreen(); // Keep these sounds always loaded, because they could be // played at any time. We want to eliminate SOUND->PlayOnce