[loading window] Trying to clean up the in game song reloading.
This commit is contained in:
@@ -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 );
|
||||
}
|
||||
@@ -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;
|
||||
};
|
||||
|
||||
+21
-45
@@ -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;
|
||||
}
|
||||
|
||||
/*
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -1629,6 +1629,9 @@
|
||||
<ClCompile Include="SongPosition.cpp">
|
||||
<Filter>Data Structures</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="InGameLoadingWindow.cpp">
|
||||
<Filter>Actors used in Menus</Filter>
|
||||
</ClCompile>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClInclude Include="Screen.h">
|
||||
@@ -3026,6 +3029,9 @@
|
||||
<ClInclude Include="SongPosition.h">
|
||||
<Filter>Data Structures</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="InGameLoadingWindow.h">
|
||||
<Filter>Actors used in Menus</Filter>
|
||||
</ClInclude>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<None Include="archutils\Win32\smzip.ico">
|
||||
@@ -3154,4 +3160,4 @@
|
||||
<Filter>BaseClasses</Filter>
|
||||
</CustomBuildStep>
|
||||
</ItemGroup>
|
||||
</Project>
|
||||
</Project>
|
||||
Reference in New Issue
Block a user