diff --git a/Themes/_fallback/Fonts/ScreenReloadSongs LoadingText.redir b/Themes/_fallback/Fonts/InGameLoadingWindow LoadingText.redir similarity index 100% rename from Themes/_fallback/Fonts/ScreenReloadSongs LoadingText.redir rename to Themes/_fallback/Fonts/InGameLoadingWindow LoadingText.redir diff --git a/src/InGameLoadingWindow.cpp b/src/InGameLoadingWindow.cpp new file mode 100644 index 0000000000..381871e51b --- /dev/null +++ b/src/InGameLoadingWindow.cpp @@ -0,0 +1,23 @@ +#include "global.h" +#include "InGameLoadingWindow.h" +#include "ScreenManager.h" +#include "ThemeManager.h" +#include "ActorUtil.h" + +//REGISTER_ACTOR_CLASS( InGameLoadingWindow ); + +InGameLoadingWindow::InGameLoadingWindow() { + SetName("InGameLoadingWindow"); + m_Text.SetName("LoadingText"); + m_Text.LoadFromFont( THEME->GetPathF(m_sName, "LoadingText") ); + m_Text.SetXY(0,0); + AddChild(&m_Text); +} + +InGameLoadingWindow::~InGameLoadingWindow() { + RemoveChild(&m_Text); +} + +void InGameLoadingWindow::SetText( RString str ) { + m_Text.SetText( str ); +} diff --git a/src/InGameLoadingWindow.h b/src/InGameLoadingWindow.h new file mode 100644 index 0000000000..f9c4ae8b8b --- /dev/null +++ b/src/InGameLoadingWindow.h @@ -0,0 +1,19 @@ +#include "arch/LoadingWindow/LoadingWindow.h" +#include "BitmapText.h" +#include "RageTimer.h" +#include "global.h" +#include "ActorFrame.h" + +class InGameLoadingWindow: public LoadingWindow, public ActorFrame { + +public: + InGameLoadingWindow(); + ~InGameLoadingWindow(); + + void SetText( RString str ); + +private: + RageTimer m_LastDraw; + BitmapText m_Text; +}; + diff --git a/src/ScreenReloadSongs.cpp b/src/ScreenReloadSongs.cpp index 48d94907b0..cfa926dfba 100644 --- a/src/ScreenReloadSongs.cpp +++ b/src/ScreenReloadSongs.cpp @@ -6,38 +6,8 @@ #include "RageLog.h" #include "ThemeManager.h" #include "ScreenDimensions.h" - #include "arch/LoadingWindow/LoadingWindow.h" - -static const int DrawFrameRate = 20; -class ScreenReloadSongsLoadingWindow: public LoadingWindow -{ - RageTimer m_LastDraw; - BitmapText &m_BitmapText; - -public: - ScreenReloadSongsLoadingWindow( BitmapText &bt ): - m_BitmapText(bt) - { - } - - void SetText( RString str ) - { - m_BitmapText.SetText( str ); - Paint(); - } - - void Paint() - { - /* We load songs much faster than we draw frames. Cap the draw rate, - * so we don't slow down the reload. */ - if( m_LastDraw.PeekDeltaTime() < 1.0f/DrawFrameRate ) - return; - m_LastDraw.GetDeltaTime(); - - SCREENMAN->Draw(); - } -}; +#include "InGameLoadingWindow.h" /* This could be cleaned up: show progress, for example. Let's not use * this for the initial load, since we don't want to start up the display @@ -49,14 +19,16 @@ void ScreenReloadSongs::Init() { Screen::Init(); - m_iUpdates = 0; + loadWin=new InGameLoadingWindow( ); - m_Loading.SetName("LoadingText"); - m_Loading.LoadFromFont( THEME->GetPathF(m_sName, "LoadingText") ); - m_Loading.SetXY( SCREEN_CENTER_X, SCREEN_CENTER_Y ); - this->AddChild( &m_Loading ); + loadWin->SetXY( SCREEN_CENTER_X, SCREEN_CENTER_Y ); + + AddChild( loadWin ); - pLoadingWindow = new ScreenReloadSongsLoadingWindow( m_Loading ); + pLoadingWindow = new InGameLoadingWindow( ); + + m_loadingThread.SetName("Song reload work thread"); + m_loadingThread.Create(loadingThreadProc,this); } ScreenReloadSongs::~ScreenReloadSongs() @@ -64,20 +36,24 @@ ScreenReloadSongs::~ScreenReloadSongs() delete pLoadingWindow; } +void ScreenReloadSongs::Update( float fDeltaTime ) { + Screen::Update( fDeltaTime ); + + //SCREENMAN->Draw(); +} -void ScreenReloadSongs::Update( float fDeltaTime ) -{ - Screen::Update( fDeltaTime ); - /* Start the reload on the second update. On the first (0), SCREENMAN->Draw won't draw. */ - ++m_iUpdates; - if( m_iUpdates != 2 ) - return; - ASSERT( !IsFirstUpdate() ); + + +int ScreenReloadSongs::loadingThreadProc(void *thisAsVoidPtr) { + + ScreenReloadSongs *self=(ScreenReloadSongs *)thisAsVoidPtr; SONGMAN->Reload( false ); SCREENMAN->PostMessageToTopScreen( SM_GoToNextScreen, 0 ); + + return 0; } /* diff --git a/src/ScreenReloadSongs.h b/src/ScreenReloadSongs.h index 908f61da72..93ffa37d4f 100644 --- a/src/ScreenReloadSongs.h +++ b/src/ScreenReloadSongs.h @@ -2,8 +2,9 @@ #define SCREEN_RELOAD_SONGS_H #include "Screen.h" -#include "BitmapText.h" -class LoadingWindow; +#include "RageThreads.h" + +class InGameLoadingWindow; class ScreenReloadSongs: public Screen { @@ -11,10 +12,10 @@ public: virtual void Init(); ~ScreenReloadSongs(); void Update( float fDeltaTime ); - private: - int m_iUpdates; - BitmapText m_Loading; + InGameLoadingWindow *loadWin; + RageThread m_loadingThread; + static int loadingThreadProc(void *thisAsVoidPtr); }; #endif diff --git a/src/StepMania-net2010.vcxproj.filters b/src/StepMania-net2010.vcxproj.filters index 0d28f9a2c7..7c21d06c80 100644 --- a/src/StepMania-net2010.vcxproj.filters +++ b/src/StepMania-net2010.vcxproj.filters @@ -1629,6 +1629,9 @@ Data Structures + + Actors used in Menus + @@ -3026,6 +3029,9 @@ Data Structures + + Actors used in Menus + @@ -3154,4 +3160,4 @@ BaseClasses - + \ No newline at end of file