[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 "RageLog.h"
|
||||||
#include "ThemeManager.h"
|
#include "ThemeManager.h"
|
||||||
#include "ScreenDimensions.h"
|
#include "ScreenDimensions.h"
|
||||||
|
|
||||||
#include "arch/LoadingWindow/LoadingWindow.h"
|
#include "arch/LoadingWindow/LoadingWindow.h"
|
||||||
|
#include "InGameLoadingWindow.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();
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
/* 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
|
||||||
@@ -49,14 +19,16 @@ void ScreenReloadSongs::Init()
|
|||||||
{
|
{
|
||||||
Screen::Init();
|
Screen::Init();
|
||||||
|
|
||||||
m_iUpdates = 0;
|
loadWin=new InGameLoadingWindow( );
|
||||||
|
|
||||||
m_Loading.SetName("LoadingText");
|
loadWin->SetXY( SCREEN_CENTER_X, SCREEN_CENTER_Y );
|
||||||
m_Loading.LoadFromFont( THEME->GetPathF(m_sName, "LoadingText") );
|
|
||||||
m_Loading.SetXY( SCREEN_CENTER_X, SCREEN_CENTER_Y );
|
|
||||||
this->AddChild( &m_Loading );
|
|
||||||
|
|
||||||
pLoadingWindow = new ScreenReloadSongsLoadingWindow( m_Loading );
|
AddChild( loadWin );
|
||||||
|
|
||||||
|
pLoadingWindow = new InGameLoadingWindow( );
|
||||||
|
|
||||||
|
m_loadingThread.SetName("Song reload work thread");
|
||||||
|
m_loadingThread.Create(loadingThreadProc,this);
|
||||||
}
|
}
|
||||||
|
|
||||||
ScreenReloadSongs::~ScreenReloadSongs()
|
ScreenReloadSongs::~ScreenReloadSongs()
|
||||||
@@ -64,20 +36,24 @@ ScreenReloadSongs::~ScreenReloadSongs()
|
|||||||
delete pLoadingWindow;
|
delete pLoadingWindow;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void ScreenReloadSongs::Update( float fDeltaTime ) {
|
||||||
void ScreenReloadSongs::Update( float fDeltaTime )
|
|
||||||
{
|
|
||||||
Screen::Update( fDeltaTime );
|
Screen::Update( fDeltaTime );
|
||||||
|
|
||||||
/* Start the reload on the second update. On the first (0), SCREENMAN->Draw won't draw. */
|
//SCREENMAN->Draw();
|
||||||
++m_iUpdates;
|
}
|
||||||
if( m_iUpdates != 2 )
|
|
||||||
return;
|
|
||||||
ASSERT( !IsFirstUpdate() );
|
|
||||||
|
|
||||||
|
int ScreenReloadSongs::loadingThreadProc(void *thisAsVoidPtr) {
|
||||||
|
|
||||||
|
ScreenReloadSongs *self=(ScreenReloadSongs *)thisAsVoidPtr;
|
||||||
|
|
||||||
SONGMAN->Reload( false );
|
SONGMAN->Reload( false );
|
||||||
|
|
||||||
SCREENMAN->PostMessageToTopScreen( SM_GoToNextScreen, 0 );
|
SCREENMAN->PostMessageToTopScreen( SM_GoToNextScreen, 0 );
|
||||||
|
|
||||||
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|||||||
@@ -2,8 +2,9 @@
|
|||||||
#define SCREEN_RELOAD_SONGS_H
|
#define SCREEN_RELOAD_SONGS_H
|
||||||
|
|
||||||
#include "Screen.h"
|
#include "Screen.h"
|
||||||
#include "BitmapText.h"
|
#include "RageThreads.h"
|
||||||
class LoadingWindow;
|
|
||||||
|
class InGameLoadingWindow;
|
||||||
|
|
||||||
class ScreenReloadSongs: public Screen
|
class ScreenReloadSongs: public Screen
|
||||||
{
|
{
|
||||||
@@ -11,10 +12,10 @@ public:
|
|||||||
virtual void Init();
|
virtual void Init();
|
||||||
~ScreenReloadSongs();
|
~ScreenReloadSongs();
|
||||||
void Update( float fDeltaTime );
|
void Update( float fDeltaTime );
|
||||||
|
|
||||||
private:
|
private:
|
||||||
int m_iUpdates;
|
InGameLoadingWindow *loadWin;
|
||||||
BitmapText m_Loading;
|
RageThread m_loadingThread;
|
||||||
|
static int loadingThreadProc(void *thisAsVoidPtr);
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@@ -1629,6 +1629,9 @@
|
|||||||
<ClCompile Include="SongPosition.cpp">
|
<ClCompile Include="SongPosition.cpp">
|
||||||
<Filter>Data Structures</Filter>
|
<Filter>Data Structures</Filter>
|
||||||
</ClCompile>
|
</ClCompile>
|
||||||
|
<ClCompile Include="InGameLoadingWindow.cpp">
|
||||||
|
<Filter>Actors used in Menus</Filter>
|
||||||
|
</ClCompile>
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<ClInclude Include="Screen.h">
|
<ClInclude Include="Screen.h">
|
||||||
@@ -3026,6 +3029,9 @@
|
|||||||
<ClInclude Include="SongPosition.h">
|
<ClInclude Include="SongPosition.h">
|
||||||
<Filter>Data Structures</Filter>
|
<Filter>Data Structures</Filter>
|
||||||
</ClInclude>
|
</ClInclude>
|
||||||
|
<ClInclude Include="InGameLoadingWindow.h">
|
||||||
|
<Filter>Actors used in Menus</Filter>
|
||||||
|
</ClInclude>
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<None Include="archutils\Win32\smzip.ico">
|
<None Include="archutils\Win32\smzip.ico">
|
||||||
|
|||||||
Reference in New Issue
Block a user