2003-09-28 02:57:09 +00:00
|
|
|
#include "global.h"
|
|
|
|
|
|
|
|
|
|
#include "ScreenReloadSongs.h"
|
|
|
|
|
#include "SongManager.h"
|
|
|
|
|
#include "UnlockSystem.h"
|
|
|
|
|
#include "ScreenManager.h"
|
2004-02-21 01:53:10 +00:00
|
|
|
#include "RageTimer.h"
|
|
|
|
|
#include "RageLog.h"
|
|
|
|
|
#include "ThemeManager.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( CString 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();
|
|
|
|
|
}
|
|
|
|
|
};
|
2003-09-28 02:57:09 +00:00
|
|
|
|
|
|
|
|
/* 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
|
|
|
|
|
* until we finish loading songs; that way, people can continue to use their
|
|
|
|
|
* computer while songs load. */
|
|
|
|
|
ScreenReloadSongs::ScreenReloadSongs( CString sClassName ): Screen(sClassName)
|
|
|
|
|
{
|
2004-02-21 01:53:10 +00:00
|
|
|
m_iUpdates = 0;
|
|
|
|
|
|
|
|
|
|
m_Loading.LoadFromFont( THEME->GetPathF("Common", "normal") );
|
|
|
|
|
m_Loading.SetXY( CENTER_X, CENTER_Y );
|
|
|
|
|
this->AddChild( &m_Loading );
|
|
|
|
|
|
|
|
|
|
m_LoadingWindow = new ScreenReloadSongsLoadingWindow( m_Loading );
|
2003-09-28 02:57:09 +00:00
|
|
|
}
|
|
|
|
|
|
2004-02-21 01:53:10 +00:00
|
|
|
ScreenReloadSongs::~ScreenReloadSongs()
|
|
|
|
|
{
|
|
|
|
|
delete m_LoadingWindow;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2003-09-28 02:57:09 +00:00
|
|
|
void ScreenReloadSongs::Update( float fDeltaTime )
|
|
|
|
|
{
|
2004-02-21 01:53:10 +00:00
|
|
|
Screen::Update( fDeltaTime );
|
2003-09-28 02:57:09 +00:00
|
|
|
|
2004-02-21 01:53:10 +00:00
|
|
|
/* 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() );
|
|
|
|
|
|
|
|
|
|
SONGMAN->Reload( m_LoadingWindow );
|
2004-02-21 01:06:35 +00:00
|
|
|
UNLOCKMAN->UpdateSongs();
|
2003-09-28 02:57:09 +00:00
|
|
|
SCREENMAN->SetNewScreen( "ScreenTitleMenu" );
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|