revert henke's loadingwindow "improvements"; if you're reading this, henke, you do *NOT* sacrifice readability for misguided optimization, and you do *NOT* use a globally externed variable for something with a useful lifetime of part of one function
This commit is contained in:
@@ -108,7 +108,7 @@ static void Version()
|
||||
#endif // WIN32
|
||||
}
|
||||
|
||||
void CommandLineActions::Handle()
|
||||
void CommandLineActions::Handle(LoadingWindow* pLW)
|
||||
{
|
||||
CommandLineArgs args;
|
||||
for(int i=0; i<g_argc; ++i)
|
||||
|
||||
@@ -7,8 +7,9 @@ class LoadingWindow;
|
||||
namespace CommandLineActions
|
||||
{
|
||||
/**
|
||||
* @brief Perform a utility function, then exit. */
|
||||
void Handle();
|
||||
* @brief Perform a utility function, then exit.
|
||||
* @param pLW the LoadingWindow that is presently not used? */
|
||||
void Handle(LoadingWindow* pLW);
|
||||
|
||||
/** @brief The housing for the command line arguments. */
|
||||
class CommandLineArgs
|
||||
|
||||
@@ -338,7 +338,6 @@ DualScrollBar.cpp DualScrollBar.h \
|
||||
EditMenu.cpp EditMenu.h FadingBanner.cpp FadingBanner.h \
|
||||
GradeDisplay.cpp GradeDisplay.h GraphDisplay.cpp GraphDisplay.h \
|
||||
GrooveRadar.cpp GrooveRadar.h HelpDisplay.cpp HelpDisplay.h \
|
||||
InGameLoadingWindow.cpp InGameLoadingWindow.h \
|
||||
MemoryCardDisplay.cpp MemoryCardDisplay.h \
|
||||
MenuTimer.cpp MenuTimer.h \
|
||||
ModIcon.cpp ModIcon.h ModIconRow.cpp ModIconRow.h \
|
||||
|
||||
@@ -363,7 +363,7 @@ void ScreenInstallOverlay::Update( float fDeltaTime )
|
||||
}
|
||||
|
||||
if( playAfterLaunchInfo.bAnySongChanged )
|
||||
SONGMAN->Reload( false );
|
||||
SONGMAN->Reload( false, NULL );
|
||||
|
||||
if( !playAfterLaunchInfo.sSongDir.empty() )
|
||||
{
|
||||
|
||||
+51
-16
@@ -6,8 +6,38 @@
|
||||
#include "RageLog.h"
|
||||
#include "ThemeManager.h"
|
||||
#include "ScreenDimensions.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 for the initial load, since we don't want to start up the display
|
||||
@@ -21,30 +51,35 @@ void ScreenReloadSongs::Init()
|
||||
{
|
||||
Screen::Init();
|
||||
|
||||
loadWin=new InGameLoadingWindow( );
|
||||
m_iUpdates = 0;
|
||||
|
||||
AddChild( loadWin );
|
||||
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 );
|
||||
|
||||
pLoadingWindow=loadWin;
|
||||
|
||||
m_loadingThread.SetName("Song reload work thread");
|
||||
m_loadingThread.Create(loadingThreadProc,this);
|
||||
}
|
||||
m_pLoadingWindow = new ScreenReloadSongsLoadingWindow( m_Loading );
|
||||
}
|
||||
|
||||
ScreenReloadSongs::~ScreenReloadSongs()
|
||||
{
|
||||
m_loadingThread.Wait();
|
||||
RemoveChild(loadWin);
|
||||
delete loadWin;
|
||||
delete m_pLoadingWindow;
|
||||
}
|
||||
|
||||
int ScreenReloadSongs::loadingThreadProc(void *thisAsVoidPtr)
|
||||
void ScreenReloadSongs::Update( float fDeltaTime )
|
||||
{
|
||||
SONGMAN->Reload( false );
|
||||
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() );
|
||||
|
||||
SONGMAN->Reload( false, m_pLoadingWindow );
|
||||
|
||||
SCREENMAN->PostMessageToTopScreen( SM_GoToNextScreen, 0 );
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*
|
||||
|
||||
@@ -2,20 +2,22 @@
|
||||
#define SCREEN_RELOAD_SONGS_H
|
||||
|
||||
#include "Screen.h"
|
||||
#include "RageThreads.h"
|
||||
#include "BitmapText.h"
|
||||
|
||||
class InGameLoadingWindow;
|
||||
class LoadingWindow;
|
||||
|
||||
class ScreenReloadSongs: public Screen
|
||||
{
|
||||
public:
|
||||
ScreenReloadSongs();
|
||||
virtual void Init();
|
||||
~ScreenReloadSongs();
|
||||
|
||||
virtual void Init();
|
||||
void Update( float fDeltaTime );
|
||||
private:
|
||||
InGameLoadingWindow *loadWin;
|
||||
RageThread m_loadingThread;
|
||||
static int loadingThreadProc(void *thisAsVoidPtr);
|
||||
int m_iUpdates;
|
||||
LoadingWindow *m_pLoadingWindow;
|
||||
BitmapText m_Loading;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
+29
-28
@@ -88,11 +88,10 @@ SongManager::~SongManager()
|
||||
FreeSongs();
|
||||
}
|
||||
|
||||
void SongManager::InitAll()
|
||||
void SongManager::InitAll( LoadingWindow *ld )
|
||||
{
|
||||
InitSongsFromDisk();
|
||||
|
||||
InitCoursesFromDisk();
|
||||
InitSongsFromDisk( ld );
|
||||
InitCoursesFromDisk( ld );
|
||||
InitAutogenCourses();
|
||||
InitRandomAttacks();
|
||||
}
|
||||
@@ -100,7 +99,8 @@ void SongManager::InitAll()
|
||||
static LocalizedString RELOADING ( "SongManager", "Reloading..." );
|
||||
static LocalizedString UNLOADING_SONGS ( "SongManager", "Unloading songs..." );
|
||||
static LocalizedString UNLOADING_COURSES ( "SongManager", "Unloading courses..." );
|
||||
void SongManager::Reload( bool bAllowFastLoad )
|
||||
|
||||
void SongManager::Reload( bool bAllowFastLoad, LoadingWindow *ld )
|
||||
{
|
||||
FILEMAN->FlushDirCache( SpecialFiles::SONGS_DIR );
|
||||
FILEMAN->FlushDirCache( ADDITIONAL_SONGS_DIR );
|
||||
@@ -108,26 +108,27 @@ void SongManager::Reload( bool bAllowFastLoad )
|
||||
FILEMAN->FlushDirCache( ADDITIONAL_COURSES_DIR );
|
||||
FILEMAN->FlushDirCache( EDIT_SUBDIR );
|
||||
|
||||
if( pLoadingWindow )
|
||||
pLoadingWindow->SetText( RELOADING );
|
||||
if( ld )
|
||||
ld->SetText( RELOADING );
|
||||
|
||||
// save scores before unloading songs, of the scores will be lost
|
||||
// save scores before unloading songs, or the scores will be lost
|
||||
PROFILEMAN->SaveMachineProfile();
|
||||
|
||||
if( pLoadingWindow )
|
||||
pLoadingWindow->SetText( UNLOADING_COURSES );
|
||||
if( ld )
|
||||
ld->SetText( UNLOADING_COURSES );
|
||||
|
||||
FreeCourses();
|
||||
|
||||
if( pLoadingWindow )
|
||||
pLoadingWindow->SetText( UNLOADING_SONGS );
|
||||
if( ld )
|
||||
ld->SetText( UNLOADING_SONGS );
|
||||
|
||||
FreeSongs();
|
||||
|
||||
const bool OldVal = PREFSMAN->m_bFastLoad;
|
||||
if( !bAllowFastLoad )
|
||||
PREFSMAN->m_bFastLoad.Set( false );
|
||||
|
||||
InitAll();
|
||||
InitAll( ld );
|
||||
|
||||
// reload scores and unlocks afterward
|
||||
PROFILEMAN->LoadMachineProfile();
|
||||
@@ -139,14 +140,14 @@ void SongManager::Reload( bool bAllowFastLoad )
|
||||
UpdatePreferredSort();
|
||||
}
|
||||
|
||||
void SongManager::InitSongsFromDisk()
|
||||
void SongManager::InitSongsFromDisk( LoadingWindow *ld )
|
||||
{
|
||||
RageTimer tm;
|
||||
LoadStepManiaSongDir( SpecialFiles::SONGS_DIR);
|
||||
LoadStepManiaSongDir( SpecialFiles::SONGS_DIR, ld );
|
||||
|
||||
const bool bOldVal = PREFSMAN->m_bFastLoad;
|
||||
PREFSMAN->m_bFastLoad.Set( PREFSMAN->m_bFastLoadAdditionalSongs );
|
||||
LoadStepManiaSongDir( ADDITIONAL_SONGS_DIR );
|
||||
LoadStepManiaSongDir( ADDITIONAL_SONGS_DIR, ld );
|
||||
PREFSMAN->m_bFastLoad.Set( bOldVal );
|
||||
|
||||
LOG->Trace( "Found %d songs in %f seconds.", (int)m_pSongs.size(), tm.GetDeltaTime() );
|
||||
@@ -233,7 +234,7 @@ void SongManager::AddGroup( RString sDir, RString sGroupDirName )
|
||||
}
|
||||
|
||||
static LocalizedString LOADING_SONGS ( "SongManager", "Loading songs..." );
|
||||
void SongManager::LoadStepManiaSongDir( RString sDir )
|
||||
void SongManager::LoadStepManiaSongDir( RString sDir, LoadingWindow *ld )
|
||||
{
|
||||
// Make sure sDir has a trailing slash.
|
||||
if( sDir.Right(1) != "/" )
|
||||
@@ -270,9 +271,9 @@ void SongManager::LoadStepManiaSongDir( RString sDir )
|
||||
|
||||
if( songCount==0 ) return;
|
||||
|
||||
if( pLoadingWindow ) {
|
||||
pLoadingWindow->SetIndeterminate( false );
|
||||
pLoadingWindow->SetTotalWork( songCount );
|
||||
if( ld ) {
|
||||
ld->SetIndeterminate( false );
|
||||
ld->SetTotalWork( songCount );
|
||||
}
|
||||
|
||||
groupIndex = 0;
|
||||
@@ -293,10 +294,10 @@ void SongManager::LoadStepManiaSongDir( RString sDir )
|
||||
RString sSongDirName = arraySongDirs[j];
|
||||
|
||||
// this is a song directory. Load a new song.
|
||||
if( pLoadingWindow )
|
||||
if( ld )
|
||||
{
|
||||
pLoadingWindow->SetProgress(songIndex);
|
||||
pLoadingWindow->SetText( LOADING_SONGS.GetValue()+ssprintf("\n%s\n%s",
|
||||
ld->SetProgress(songIndex);
|
||||
ld->SetText( LOADING_SONGS.GetValue()+ssprintf("\n%s\n%s",
|
||||
Basename(sGroupDirName).c_str(),
|
||||
Basename(sSongDirName).c_str()));
|
||||
}
|
||||
@@ -329,8 +330,8 @@ void SongManager::LoadStepManiaSongDir( RString sDir )
|
||||
LoadGroupSymLinks(sDir, sGroupDirName);
|
||||
}
|
||||
|
||||
if( pLoadingWindow ) {
|
||||
pLoadingWindow->SetIndeterminate( true );
|
||||
if( ld ) {
|
||||
ld->SetIndeterminate( true );
|
||||
}
|
||||
|
||||
LoadEnabledSongsFromPref();
|
||||
@@ -758,7 +759,7 @@ RString SongManager::ShortenGroupName( RString sLongGroupName )
|
||||
}
|
||||
|
||||
static LocalizedString LOADING_COURSES ( "SongManager", "Loading courses..." );
|
||||
void SongManager::InitCoursesFromDisk()
|
||||
void SongManager::InitCoursesFromDisk( LoadingWindow *ld )
|
||||
{
|
||||
LOG->Trace( "Loading courses." );
|
||||
|
||||
@@ -788,9 +789,9 @@ void SongManager::InitCoursesFromDisk()
|
||||
|
||||
FOREACH_CONST( RString, vsCoursePaths, sCoursePath )
|
||||
{
|
||||
if( pLoadingWindow )
|
||||
if( ld )
|
||||
{
|
||||
pLoadingWindow->SetText( LOADING_COURSES.GetValue()+ssprintf("\n%s\n%s",
|
||||
ld->SetText( LOADING_COURSES.GetValue()+ssprintf("\n%s\n%s",
|
||||
Basename(*sCourseGroup).c_str(),
|
||||
Basename(*sCoursePath).c_str()));
|
||||
}
|
||||
|
||||
+6
-5
@@ -1,6 +1,7 @@
|
||||
#ifndef SONGMANAGER_H
|
||||
#define SONGMANAGER_H
|
||||
|
||||
class LoadingWindow;
|
||||
class Song;
|
||||
class Style;
|
||||
class Steps;
|
||||
@@ -34,7 +35,7 @@ public:
|
||||
SongManager();
|
||||
~SongManager();
|
||||
|
||||
void InitSongsFromDisk();
|
||||
void InitSongsFromDisk( LoadingWindow *ld );
|
||||
void FreeSongs();
|
||||
void Cleanup();
|
||||
|
||||
@@ -52,7 +53,7 @@ public:
|
||||
|
||||
void LoadGroupSymLinks( RString sDir, RString sGroupFolder );
|
||||
|
||||
void InitCoursesFromDisk();
|
||||
void InitCoursesFromDisk( LoadingWindow *ld );
|
||||
void InitAutogenCourses();
|
||||
void InitRandomAttacks();
|
||||
void FreeCourses();
|
||||
@@ -62,8 +63,8 @@ public:
|
||||
void DeleteAutogenCourses();
|
||||
void InvalidateCachedTrails();
|
||||
|
||||
void InitAll(); // songs, courses, groups - everything.
|
||||
void Reload( bool bAllowFastLoad); // songs, courses, groups - everything.
|
||||
void InitAll( LoadingWindow *ld ); // songs, courses, groups - everything.
|
||||
void Reload( bool bAllowFastLoad, LoadingWindow *ld=NULL ); // songs, courses, groups - everything.
|
||||
void PreloadSongImages();
|
||||
|
||||
RString GetSongGroupBannerPath( RString sSongGroup ) const;
|
||||
@@ -169,7 +170,7 @@ public:
|
||||
void PushSelf( lua_State *L );
|
||||
|
||||
protected:
|
||||
void LoadStepManiaSongDir( RString sDir );
|
||||
void LoadStepManiaSongDir( RString sDir, LoadingWindow *ld );
|
||||
void LoadDWISongDir( RString sDir );
|
||||
bool GetExtraStageInfoFromCourse( bool bExtra2, RString sPreferredGroup, Song*& pSongOut, Steps*& pStepsOut );
|
||||
void SanityCheckGroupDir( RString sDir ) const;
|
||||
|
||||
@@ -1620,9 +1620,6 @@
|
||||
<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">
|
||||
@@ -3011,9 +3008,6 @@
|
||||
<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">
|
||||
|
||||
+6
-6
@@ -902,7 +902,7 @@ static void WriteLogHeader()
|
||||
struct tm now;
|
||||
localtime_r( &cur_time, &now );
|
||||
|
||||
LOG->Info( "Log starting %.4d-%.2d-%.2d %.2d:%.2d:%.2d",
|
||||
LOG->Info( "Log starting %.4d-%.2d-%.2d %.2d:%.2d:%.2d",
|
||||
1900+now.tm_year, now.tm_mon+1, now.tm_mday, now.tm_hour, now.tm_min, now.tm_sec );
|
||||
LOG->Trace( " " );
|
||||
|
||||
@@ -1015,7 +1015,7 @@ int main(int argc, char* argv[])
|
||||
GAMESTATE = new GameState;
|
||||
|
||||
// This requires PREFSMAN, for PREFSMAN->m_bShowLoadingWindow.
|
||||
pLoadingWindow = LoadingWindow::Create();
|
||||
LoadingWindow *pLoadingWindow = LoadingWindow::Create();
|
||||
if(pLoadingWindow == NULL)
|
||||
RageException::Throw("%s", COULDNT_OPEN_LOADING_WINDOW.GetValue().c_str());
|
||||
|
||||
@@ -1041,7 +1041,7 @@ int main(int argc, char* argv[])
|
||||
// Switch to the last used game type, and set up the theme and announcer.
|
||||
SwitchToLastPlayedGame();
|
||||
|
||||
CommandLineActions::Handle();
|
||||
CommandLineActions::Handle(pLoadingWindow);
|
||||
|
||||
if( GetCommandlineArgument("dopefish") )
|
||||
GAMESTATE->m_bDopefish = true;
|
||||
@@ -1078,7 +1078,7 @@ int main(int argc, char* argv[])
|
||||
|
||||
// depends on SONGINDEX:
|
||||
SONGMAN = new SongManager;
|
||||
SONGMAN->InitAll(); // this takes a long time
|
||||
SONGMAN->InitAll( pLoadingWindow ); // this takes a long time
|
||||
CRYPTMAN = new CryptManager; // need to do this before ProfileMan
|
||||
if( PREFSMAN->m_bSignProfileData )
|
||||
CRYPTMAN->GenerateGlobalKeys();
|
||||
@@ -1096,10 +1096,10 @@ int main(int argc, char* argv[])
|
||||
// Initialize which courses are ranking courses here.
|
||||
SONGMAN->UpdateRankingCourses();
|
||||
|
||||
SAFE_DELETE( pLoadingWindow ); // destroy this before init'ing Display
|
||||
SAFE_DELETE( pLoadingWindow ); // destroy this before init'ing Display
|
||||
|
||||
/* If the user has tried to quit during the loading, do it before creating
|
||||
* the main window. This prevents going to full screen just to quit. */
|
||||
* the main window. This prevents going to full screen just to quit. */
|
||||
if( ArchHooks::UserQuit() )
|
||||
{
|
||||
ShutdownGame();
|
||||
|
||||
@@ -8,7 +8,6 @@
|
||||
#include "RageTimer.h"
|
||||
#include "FontCharAliases.h"
|
||||
#include "arch/ArchHooks/ArchHooks.h"
|
||||
#include "arch/LoadingWindow/LoadingWindow.h"
|
||||
#include "arch/Dialog/Dialog.h"
|
||||
#include "RageFile.h"
|
||||
#if !defined(SMPACKAGE)
|
||||
@@ -398,8 +397,6 @@ void ThemeManager::SwitchThemeAndLanguage( const RString &sThemeName_, const RSt
|
||||
if( bNothingChanging && !bForceThemeReload )
|
||||
return;
|
||||
|
||||
if(pLoadingWindow) pLoadingWindow->SetText("Loading theme & language...");
|
||||
|
||||
m_bPseudoLocalize = bPseudoLocalize;
|
||||
|
||||
// Load theme metrics. If only the language is changing, this is all
|
||||
|
||||
@@ -56,8 +56,6 @@ LoadingWindow *LoadingWindow::Create()
|
||||
return ret;
|
||||
}
|
||||
|
||||
LoadingWindow *pLoadingWindow;
|
||||
|
||||
/*
|
||||
* (c) 2002-2005 Glenn Maynard
|
||||
* All rights reserved.
|
||||
|
||||
@@ -24,8 +24,6 @@ protected:
|
||||
bool m_indeterminate;
|
||||
};
|
||||
|
||||
extern LoadingWindow *pLoadingWindow;
|
||||
|
||||
#endif
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user