Use new old loader dialog stuff.
Set the icon from an XPM.
This commit is contained in:
@@ -19,6 +19,7 @@
|
||||
#include "PrefsManager.h"
|
||||
#include "RageException.h"
|
||||
#include "RageTimer.h"
|
||||
#include "arch/LoadingWindow.h"
|
||||
|
||||
#include "AnnouncerManager.h"
|
||||
#include "ThemeManager.h"
|
||||
@@ -37,13 +38,13 @@ RageColor g_GroupColors[30];
|
||||
RageColor g_ExtraColor;
|
||||
|
||||
|
||||
SongManager::SongManager( void(*callback)() )
|
||||
SongManager::SongManager( LoadingWindow *ld )
|
||||
{
|
||||
for( int i=0; i<NUM_GROUP_COLORS; i++ )
|
||||
g_GroupColors[i] = GROUP_COLOR( i );
|
||||
g_ExtraColor = EXTRA_COLOR;
|
||||
|
||||
InitSongArrayFromDisk( callback );
|
||||
InitSongArrayFromDisk( ld );
|
||||
ReadStatisticsFromDisk();
|
||||
|
||||
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++ )
|
||||
LoadStepManiaSongDir( PREFSMAN->m_asAdditionalSongFolders[i], callback );
|
||||
LoadStepManiaSongDir( PREFSMAN->m_asAdditionalSongFolders[i], ld );
|
||||
|
||||
if( PREFSMAN->m_DWIPath != "" )
|
||||
LoadStepManiaSongDir( PREFSMAN->m_DWIPath + "\\Songs", callback );
|
||||
LoadStepManiaSongDir( PREFSMAN->m_DWIPath + "\\Songs", ld );
|
||||
|
||||
LOG->Trace( "Found %d Songs.", m_pSongs.size() );
|
||||
}
|
||||
@@ -114,7 +115,7 @@ void SongManager::AddGroup( CString sDir, CString sGroupDirName )
|
||||
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
|
||||
TrimRight( sDir, "/\\" );
|
||||
@@ -149,9 +150,10 @@ void SongManager::LoadStepManiaSongDir( CString sDir, void(*callback)() )
|
||||
continue; // ignore it
|
||||
|
||||
// this is a song directory. Load a new song!
|
||||
GAMESTATE->m_sLoadingMessage = ssprintf("Loading songs...\n%s\n%s", sGroupDirName.GetString(), sSongDirName.GetString());
|
||||
if( callback )
|
||||
callback();
|
||||
if( ld ) {
|
||||
ld->SetText( ssprintf("Loading songs...\n%s\n%s", sGroupDirName.GetString(), sSongDirName.GetString()));
|
||||
ld->Paint();
|
||||
}
|
||||
Song* pNewSong = new Song;
|
||||
if( !pNewSong->LoadFromSongDir( ssprintf("%s\\%s\\%s", sDir.GetString(), sGroupDirName.GetString(), sSongDirName.GetString()) ) ) {
|
||||
/* The song failed to load. */
|
||||
@@ -169,10 +171,11 @@ void SongManager::LoadStepManiaSongDir( CString sDir, void(*callback)() )
|
||||
/* Add this group to the group array. */
|
||||
AddGroup(sDir, sGroupDirName);
|
||||
}
|
||||
|
||||
GAMESTATE->m_sLoadingMessage = "Done loading songs.";
|
||||
if( callback )
|
||||
callback();
|
||||
|
||||
if( ld ) {
|
||||
ld->Paint();
|
||||
ld->SetText("Done loading songs.");
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
|
||||
@@ -13,20 +13,22 @@
|
||||
*/
|
||||
|
||||
|
||||
#include "Song.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
|
||||
{
|
||||
public:
|
||||
SongManager( void(*callback)() );
|
||||
SongManager( LoadingWindow *ld );
|
||||
~SongManager();
|
||||
|
||||
CArray<Song*, Song*> m_pSongs; // all songs that can be played
|
||||
|
||||
void InitSongArrayFromDisk( void(*callback)() );
|
||||
void InitSongArrayFromDisk( LoadingWindow *ld );
|
||||
void FreeSongArray();
|
||||
void ReloadSongArray();
|
||||
|
||||
@@ -66,7 +68,7 @@ public:
|
||||
Song* GetSongFromPath( const CString &sSongPath );
|
||||
|
||||
protected:
|
||||
void LoadStepManiaSongDir( CString sDir, void(*callback)() );
|
||||
void LoadStepManiaSongDir( CString sDir, LoadingWindow *ld );
|
||||
void LoadDWISongDir( CString sDir );
|
||||
bool GetExtraStageInfoFromCourse( bool bExtra2, CString sPreferredGroup,
|
||||
Song*& pSongOut, Notes*& pNotesOut, PlayerOptions& po_out, SongOptions& so_out );
|
||||
|
||||
+37
-48
@@ -30,6 +30,9 @@
|
||||
#include "RageNetwork.h"
|
||||
#include "RageMath.h"
|
||||
|
||||
#include "arch/arch.h"
|
||||
#include "arch/LoadingWindow.h"
|
||||
|
||||
#include "SDL.h"
|
||||
#include "SDL_syswm.h" // for SDL_SysWMinfo
|
||||
|
||||
@@ -85,9 +88,8 @@ const int SM_PORT = 26573; // Quake port + "Ko" + "na" + "mitsu"
|
||||
Common stuff
|
||||
------------------------------------------------*/
|
||||
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 */
|
||||
SDL_Surface *loading_screen = NULL;
|
||||
LoadingWindow *loading_window = NULL;
|
||||
CString g_sErrorString = "";
|
||||
|
||||
void ChangeToDirOfExecutable()
|
||||
@@ -109,54 +111,14 @@ void ChangeToDirOfExecutable()
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void PaintLoadingWindow()
|
||||
{
|
||||
SDL_UpdateRect(loading_screen, 0,0,0,0);
|
||||
}
|
||||
|
||||
void CreateLoadingWindow()
|
||||
{
|
||||
ASSERT( loading_screen == 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() );
|
||||
ASSERT( loading_window == NULL );
|
||||
|
||||
loading_window = MakeLoadingWindow();
|
||||
SDL_WM_SetCaption("StepMania", "StepMania");
|
||||
|
||||
/* Blit onto the screen surface */
|
||||
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;
|
||||
loading_window->Paint();
|
||||
}
|
||||
|
||||
|
||||
@@ -269,6 +231,28 @@ void ApplyGraphicOptions()
|
||||
|
||||
|
||||
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()
|
||||
@@ -316,9 +300,14 @@ int main(int argc, char* argv[])
|
||||
try{
|
||||
#endif
|
||||
|
||||
/* Initialize the SDL library. */
|
||||
if( SDL_InitSubSystem(SDL_INIT_VIDEO) < 0 )
|
||||
throw RageException( "Couldn't initialize SDL: %s\n", SDL_GetError() );
|
||||
|
||||
SetIcon();
|
||||
|
||||
CreateLoadingWindow();
|
||||
PaintLoadingWindow();
|
||||
loading_window->Paint();
|
||||
|
||||
//
|
||||
// Create game objects
|
||||
@@ -343,9 +332,9 @@ int main(int argc, char* argv[])
|
||||
INPUTQUEUE = new InputQueue;
|
||||
SONGINDEX = new SongCacheIndex;
|
||||
/* 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 );
|
||||
|
||||
|
||||
Reference in New Issue
Block a user