Use new old loader dialog stuff.

Set the icon from an XPM.
This commit is contained in:
Glenn Maynard
2002-11-17 09:13:35 +00:00
parent 32ca9a22c2
commit fc0cd03818
3 changed files with 61 additions and 67 deletions
+16 -13
View File
@@ -19,6 +19,7 @@
#include "PrefsManager.h" #include "PrefsManager.h"
#include "RageException.h" #include "RageException.h"
#include "RageTimer.h" #include "RageTimer.h"
#include "arch/LoadingWindow.h"
#include "AnnouncerManager.h" #include "AnnouncerManager.h"
#include "ThemeManager.h" #include "ThemeManager.h"
@@ -37,13 +38,13 @@ RageColor g_GroupColors[30];
RageColor g_ExtraColor; RageColor g_ExtraColor;
SongManager::SongManager( void(*callback)() ) SongManager::SongManager( LoadingWindow *ld )
{ {
for( int i=0; i<NUM_GROUP_COLORS; i++ ) for( int i=0; i<NUM_GROUP_COLORS; i++ )
g_GroupColors[i] = GROUP_COLOR( i ); g_GroupColors[i] = GROUP_COLOR( i );
g_ExtraColor = EXTRA_COLOR; g_ExtraColor = EXTRA_COLOR;
InitSongArrayFromDisk( callback ); InitSongArrayFromDisk( ld );
ReadStatisticsFromDisk(); ReadStatisticsFromDisk();
InitCoursesFromDisk(); InitCoursesFromDisk();
@@ -56,15 +57,15 @@ SongManager::~SongManager()
} }
void SongManager::InitSongArrayFromDisk( void(*callback)() ) void SongManager::InitSongArrayFromDisk( LoadingWindow *ld )
{ {
LoadStepManiaSongDir( "Songs", callback ); LoadStepManiaSongDir( "Songs", ld );
for( unsigned i=0; i<PREFSMAN->m_asAdditionalSongFolders.size(); i++ ) for( unsigned i=0; i<PREFSMAN->m_asAdditionalSongFolders.size(); i++ )
LoadStepManiaSongDir( PREFSMAN->m_asAdditionalSongFolders[i], callback ); LoadStepManiaSongDir( PREFSMAN->m_asAdditionalSongFolders[i], ld );
if( PREFSMAN->m_DWIPath != "" ) if( PREFSMAN->m_DWIPath != "" )
LoadStepManiaSongDir( PREFSMAN->m_DWIPath + "\\Songs", callback ); LoadStepManiaSongDir( PREFSMAN->m_DWIPath + "\\Songs", ld );
LOG->Trace( "Found %d Songs.", m_pSongs.size() ); LOG->Trace( "Found %d Songs.", m_pSongs.size() );
} }
@@ -114,7 +115,7 @@ void SongManager::AddGroup( CString sDir, CString sGroupDirName )
m_GroupBannerPaths.push_back(sBannerPath); m_GroupBannerPaths.push_back(sBannerPath);
} }
void SongManager::LoadStepManiaSongDir( CString sDir, void(*callback)() ) void SongManager::LoadStepManiaSongDir( CString sDir, LoadingWindow *ld )
{ {
// trim off the trailing slash if any // trim off the trailing slash if any
TrimRight( sDir, "/\\" ); TrimRight( sDir, "/\\" );
@@ -149,9 +150,10 @@ void SongManager::LoadStepManiaSongDir( CString sDir, void(*callback)() )
continue; // ignore it continue; // ignore it
// this is a song directory. Load a new song! // this is a song directory. Load a new song!
GAMESTATE->m_sLoadingMessage = ssprintf("Loading songs...\n%s\n%s", sGroupDirName.GetString(), sSongDirName.GetString()); if( ld ) {
if( callback ) ld->SetText( ssprintf("Loading songs...\n%s\n%s", sGroupDirName.GetString(), sSongDirName.GetString()));
callback(); ld->Paint();
}
Song* pNewSong = new Song; Song* pNewSong = new Song;
if( !pNewSong->LoadFromSongDir( ssprintf("%s\\%s\\%s", sDir.GetString(), sGroupDirName.GetString(), sSongDirName.GetString()) ) ) { if( !pNewSong->LoadFromSongDir( ssprintf("%s\\%s\\%s", sDir.GetString(), sGroupDirName.GetString(), sSongDirName.GetString()) ) ) {
/* The song failed to load. */ /* The song failed to load. */
@@ -170,9 +172,10 @@ void SongManager::LoadStepManiaSongDir( CString sDir, void(*callback)() )
AddGroup(sDir, sGroupDirName); AddGroup(sDir, sGroupDirName);
} }
GAMESTATE->m_sLoadingMessage = "Done loading songs."; if( ld ) {
if( callback ) ld->Paint();
callback(); ld->SetText("Done loading songs.");
}
} }
/* /*
+7 -5
View File
@@ -13,20 +13,22 @@
*/ */
#include "Song.h"
#include "Course.h" #include "Course.h"
const int MAX_SONG_QUEUE_SIZE = 400; // this has to be gigantic to fit an "endless" number of songs class LoadingWindow;
class Song;
class StyleDef;
struct PlayerOptions;
class SongManager class SongManager
{ {
public: public:
SongManager( void(*callback)() ); SongManager( LoadingWindow *ld );
~SongManager(); ~SongManager();
CArray<Song*, Song*> m_pSongs; // all songs that can be played CArray<Song*, Song*> m_pSongs; // all songs that can be played
void InitSongArrayFromDisk( void(*callback)() ); void InitSongArrayFromDisk( LoadingWindow *ld );
void FreeSongArray(); void FreeSongArray();
void ReloadSongArray(); void ReloadSongArray();
@@ -66,7 +68,7 @@ public:
Song* GetSongFromPath( const CString &sSongPath ); Song* GetSongFromPath( const CString &sSongPath );
protected: protected:
void LoadStepManiaSongDir( CString sDir, void(*callback)() ); void LoadStepManiaSongDir( CString sDir, LoadingWindow *ld );
void LoadDWISongDir( CString sDir ); void LoadDWISongDir( CString sDir );
bool GetExtraStageInfoFromCourse( bool bExtra2, CString sPreferredGroup, bool GetExtraStageInfoFromCourse( bool bExtra2, CString sPreferredGroup,
Song*& pSongOut, Notes*& pNotesOut, PlayerOptions& po_out, SongOptions& so_out ); Song*& pSongOut, Notes*& pNotesOut, PlayerOptions& po_out, SongOptions& so_out );
+37 -48
View File
@@ -30,6 +30,9 @@
#include "RageNetwork.h" #include "RageNetwork.h"
#include "RageMath.h" #include "RageMath.h"
#include "arch/arch.h"
#include "arch/LoadingWindow.h"
#include "SDL.h" #include "SDL.h"
#include "SDL_syswm.h" // for SDL_SysWMinfo #include "SDL_syswm.h" // for SDL_SysWMinfo
@@ -85,9 +88,8 @@ const int SM_PORT = 26573; // Quake port + "Ko" + "na" + "mitsu"
Common stuff Common stuff
------------------------------------------------*/ ------------------------------------------------*/
int flags = 0; /* SDL video flags */ int flags = 0; /* SDL video flags */
int bpp = 0; /* Preferred screen bpp */
int window_w = SCREEN_WIDTH, window_h = SCREEN_HEIGHT; /* window width and height */ int window_w = SCREEN_WIDTH, window_h = SCREEN_HEIGHT; /* window width and height */
SDL_Surface *loading_screen = NULL; LoadingWindow *loading_window = NULL;
CString g_sErrorString = ""; CString g_sErrorString = "";
void ChangeToDirOfExecutable() void ChangeToDirOfExecutable()
@@ -109,54 +111,14 @@ void ChangeToDirOfExecutable()
} }
} }
void PaintLoadingWindow()
{
SDL_UpdateRect(loading_screen, 0,0,0,0);
}
void CreateLoadingWindow() void CreateLoadingWindow()
{ {
ASSERT( loading_screen == NULL ); ASSERT( loading_window == NULL );
/* Initialize the SDL library */
if( SDL_InitSubSystem(SDL_INIT_VIDEO) < 0 )
throw RageException( "Couldn't initialize SDL: %s\n", SDL_GetError() );
SDL_Surface *image;
/* Load the BMP file into a surface */
image = SDL_LoadBMP("loading.bmp");
if( image == NULL )
throw RageException("Couldn't load loading.bmp: %s\n",SDL_GetError());
/* Initialize the display in a 640x480 16-bit mode */
loading_screen = SDL_SetVideoMode(image->w, image->h, 16, SDL_SWSURFACE|SDL_ANYFORMAT|SDL_NOFRAME);
if( loading_screen == NULL )
throw RageException( "Couldn't initialize loading window: %s\n", SDL_GetError() );
loading_window = MakeLoadingWindow();
SDL_WM_SetCaption("StepMania", "StepMania"); SDL_WM_SetCaption("StepMania", "StepMania");
/* Blit onto the screen surface */ loading_window->Paint();
SDL_Rect dest;
dest.x = 0;
dest.y = 0;
dest.w = (Uint16)image->w;
dest.h = (Uint16)image->h;
SDL_BlitSurface(image, NULL, loading_screen, NULL);
SDL_WM_SetCaption( "StepMania", NULL);
PaintLoadingWindow();
/* Free the allocated BMP surface */
SDL_FreeSurface(image);
}
void DestroyLoadingWindow()
{
SDL_QuitSubSystem( SDL_INIT_VIDEO );
loading_screen = NULL;
} }
@@ -269,6 +231,28 @@ void ApplyGraphicOptions()
void GameLoop(); void GameLoop();
#include "SDL_utils.h"
#include "SDL_image.h"
#include "SDL_rotozoom.h"
#include "StepMania.xpm" /* icon */
void SetIcon()
{
SDL_Surface *srf = IMG_ReadXPMFromArray(icon);
SDL_SetColorKey( srf, SDL_SRCCOLORKEY, SDL_MapRGB(srf->format, 0xFF, 0, 0xFF));
/* Windows icons are 32x32 and SDL can't resize them for us, which
* causes mask corruption. (Actually, the above icon *is* 32x32;
* this is here just in case it changes.) */
ConvertSDLSurface(srf, srf->w, srf->h,
32, 0xFF000000, 0x00FF0000, 0x0000FF00, 0x000000FF);
SDL_Surface *dst = zoomSurface(srf, 32, 32);
SDL_SetAlpha( dst, SDL_SRCALPHA, SDL_ALPHA_OPAQUE );
SDL_WM_SetIcon(dst, NULL /* derive from alpha */);
SDL_FreeSurface(srf);
SDL_FreeSurface(dst);
}
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
// Name: WinMain() // Name: WinMain()
@@ -316,9 +300,14 @@ int main(int argc, char* argv[])
try{ try{
#endif #endif
/* Initialize the SDL library. */
if( SDL_InitSubSystem(SDL_INIT_VIDEO) < 0 )
throw RageException( "Couldn't initialize SDL: %s\n", SDL_GetError() );
SetIcon();
CreateLoadingWindow(); CreateLoadingWindow();
PaintLoadingWindow(); loading_window->Paint();
// //
// Create game objects // Create game objects
@@ -343,9 +332,9 @@ int main(int argc, char* argv[])
INPUTQUEUE = new InputQueue; INPUTQUEUE = new InputQueue;
SONGINDEX = new SongCacheIndex; SONGINDEX = new SongCacheIndex;
/* depends on SONGINDEX: */ /* depends on SONGINDEX: */
SONGMAN = new SongManager( PaintLoadingWindow ); // this takes a long time to load SONGMAN = new SongManager( loading_window ); // this takes a long time to load
DestroyLoadingWindow(); // destroy this before init'ing Display delete loading_window; // destroy this before init'ing Display
PREFSMAN->ReadGlobalPrefsFromDisk( true ); PREFSMAN->ReadGlobalPrefsFromDisk( true );