add progress update
This commit is contained in:
@@ -4,6 +4,41 @@
|
|||||||
#include "SongManager.h"
|
#include "SongManager.h"
|
||||||
#include "UnlockSystem.h"
|
#include "UnlockSystem.h"
|
||||||
#include "ScreenManager.h"
|
#include "ScreenManager.h"
|
||||||
|
#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();
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
/* This could be cleaned up: show progress, for example. Let's not use
|
/* 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
|
* this for the initial load, since we don't want to start up the display
|
||||||
@@ -11,16 +46,32 @@
|
|||||||
* computer while songs load. */
|
* computer while songs load. */
|
||||||
ScreenReloadSongs::ScreenReloadSongs( CString sClassName ): Screen(sClassName)
|
ScreenReloadSongs::ScreenReloadSongs( CString sClassName ): Screen(sClassName)
|
||||||
{
|
{
|
||||||
m_FirstUpdate = true;
|
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 );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ScreenReloadSongs::~ScreenReloadSongs()
|
||||||
|
{
|
||||||
|
delete m_LoadingWindow;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
void ScreenReloadSongs::Update( float fDeltaTime )
|
void ScreenReloadSongs::Update( float fDeltaTime )
|
||||||
{
|
{
|
||||||
if( !m_FirstUpdate )
|
Screen::Update( fDeltaTime );
|
||||||
return;
|
|
||||||
|
|
||||||
m_FirstUpdate = false;
|
/* Start the reload on the second update. On the first, 0, SCREENMAN->Draw won't draw. */
|
||||||
SONGMAN->Reload();
|
++m_iUpdates;
|
||||||
|
if( m_iUpdates != 2 )
|
||||||
|
return;
|
||||||
|
ASSERT( !IsFirstUpdate() );
|
||||||
|
|
||||||
|
SONGMAN->Reload( m_LoadingWindow );
|
||||||
UNLOCKMAN->UpdateSongs();
|
UNLOCKMAN->UpdateSongs();
|
||||||
SCREENMAN->SetNewScreen( "ScreenTitleMenu" );
|
SCREENMAN->SetNewScreen( "ScreenTitleMenu" );
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,14 +2,20 @@
|
|||||||
#define SCREEN_RELOAD_SONGS_H
|
#define SCREEN_RELOAD_SONGS_H
|
||||||
|
|
||||||
#include "Screen.h"
|
#include "Screen.h"
|
||||||
|
#include "BitmapText.h"
|
||||||
|
class LoadingWindow;
|
||||||
|
|
||||||
class ScreenReloadSongs: public Screen
|
class ScreenReloadSongs: public Screen
|
||||||
{
|
{
|
||||||
bool m_FirstUpdate;
|
|
||||||
|
|
||||||
public:
|
public:
|
||||||
ScreenReloadSongs( CString sClassName );
|
ScreenReloadSongs( CString sClassName );
|
||||||
|
~ScreenReloadSongs();
|
||||||
void Update( float fDeltaTime );
|
void Update( float fDeltaTime );
|
||||||
|
|
||||||
|
private:
|
||||||
|
int m_iUpdates;
|
||||||
|
LoadingWindow *m_LoadingWindow;
|
||||||
|
BitmapText m_Loading;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
Reference in New Issue
Block a user