add option to reload songs and courses w/o restarting
This commit is contained in:
@@ -2288,6 +2288,7 @@ SoundOptions=
|
|||||||
AutogenOptions=
|
AutogenOptions=
|
||||||
BackgroundOptions=
|
BackgroundOptions=
|
||||||
AutoAdjustGraphicDetail=
|
AutoAdjustGraphicDetail=
|
||||||
|
ReloadSongs/Courses=
|
||||||
|
|
||||||
[TextBanner]
|
[TextBanner]
|
||||||
Width=180
|
Width=180
|
||||||
|
|||||||
@@ -430,7 +430,7 @@ Screen* ScreenManager::MakeNewScreen( CString sClassName )
|
|||||||
DISPLAY->ResetStats();
|
DISPLAY->ResetStats();
|
||||||
|
|
||||||
/* This is a convenient time to clean up our song cache. */
|
/* This is a convenient time to clean up our song cache. */
|
||||||
SONGMAN->CleanData();
|
SONGMAN->CompressSongs();
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -23,6 +23,7 @@
|
|||||||
#include "GameManager.h"
|
#include "GameManager.h"
|
||||||
#include "GameState.h"
|
#include "GameState.h"
|
||||||
#include "ThemeManager.h"
|
#include "ThemeManager.h"
|
||||||
|
#include "SongManager.h"
|
||||||
|
|
||||||
|
|
||||||
enum {
|
enum {
|
||||||
@@ -35,6 +36,7 @@ enum {
|
|||||||
OM_GRAPHIC,
|
OM_GRAPHIC,
|
||||||
OM_MACHINE,
|
OM_MACHINE,
|
||||||
// OM_SOUND,
|
// OM_SOUND,
|
||||||
|
OM_RELOAD,
|
||||||
NUM_OPTIONS_MENU_LINES
|
NUM_OPTIONS_MENU_LINES
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -48,6 +50,7 @@ OptionRow g_OptionsMenuLines[NUM_OPTIONS_MENU_LINES] = {
|
|||||||
OptionRow( "", "Graphic Options" ),
|
OptionRow( "", "Graphic Options" ),
|
||||||
OptionRow( "", "Machine Options" ),
|
OptionRow( "", "Machine Options" ),
|
||||||
// OptionRow( "", "Sound Options" ),
|
// OptionRow( "", "Sound Options" ),
|
||||||
|
OptionRow( "", "Reload Songs/Courses" ),
|
||||||
};
|
};
|
||||||
|
|
||||||
ScreenOptionsMenu::ScreenOptionsMenu() :
|
ScreenOptionsMenu::ScreenOptionsMenu() :
|
||||||
@@ -103,6 +106,11 @@ void ScreenOptionsMenu::GoToNextState()
|
|||||||
case OM_INPUT: SCREENMAN->SetNewScreen("ScreenInputOptions"); break;
|
case OM_INPUT: SCREENMAN->SetNewScreen("ScreenInputOptions"); break;
|
||||||
case OM_MACHINE: SCREENMAN->SetNewScreen("ScreenMachineOptions"); break;
|
case OM_MACHINE: SCREENMAN->SetNewScreen("ScreenMachineOptions"); break;
|
||||||
// case OM_SOUND: SCREENMAN->SetNewScreen("ScreenSoundOptions"); break;
|
// case OM_SOUND: SCREENMAN->SetNewScreen("ScreenSoundOptions"); break;
|
||||||
|
case OM_RELOAD:
|
||||||
|
SONGMAN->ReloadSongs();
|
||||||
|
SONGMAN->ReloadCourses();
|
||||||
|
SCREENMAN->SetNewScreen( "ScreenTitleMenu" );
|
||||||
|
break;
|
||||||
default: // Exit
|
default: // Exit
|
||||||
SCREENMAN->SetNewScreen("ScreenTitleMenu");
|
SCREENMAN->SetNewScreen("ScreenTitleMenu");
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -73,8 +73,8 @@ SongManager::SongManager( LoadingWindow *ld )
|
|||||||
SONGMAN = this;
|
SONGMAN = this;
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
InitSongArrayFromDisk( ld );
|
InitSongsFromDisk( ld );
|
||||||
InitCoursesFromDisk();
|
InitCoursesFromDisk( ld );
|
||||||
InitAutogenCourses();
|
InitAutogenCourses();
|
||||||
InitMachineScoresFromDisk();
|
InitMachineScoresFromDisk();
|
||||||
|
|
||||||
@@ -91,7 +91,23 @@ SongManager::~SongManager()
|
|||||||
{
|
{
|
||||||
SaveMachineScoresToDisk();
|
SaveMachineScoresToDisk();
|
||||||
|
|
||||||
FreeSongArray();
|
FreeSongs();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void SongManager::ReloadSongs()
|
||||||
|
{
|
||||||
|
FlushDirCache();
|
||||||
|
FreeSongs();
|
||||||
|
InitSongsFromDisk(NULL);
|
||||||
|
}
|
||||||
|
|
||||||
|
void SongManager::ReloadCourses()
|
||||||
|
{
|
||||||
|
FlushDirCache();
|
||||||
|
FreeCourses();
|
||||||
|
InitCoursesFromDisk(NULL);
|
||||||
|
InitAutogenCourses();
|
||||||
}
|
}
|
||||||
|
|
||||||
void SongManager::SaveMachineScoresToDisk()
|
void SongManager::SaveMachineScoresToDisk()
|
||||||
@@ -105,7 +121,7 @@ void SongManager::SaveMachineScoresToDisk()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void SongManager::InitSongArrayFromDisk( LoadingWindow *ld )
|
void SongManager::InitSongsFromDisk( LoadingWindow *ld )
|
||||||
{
|
{
|
||||||
LoadStepManiaSongDir( SONGS_DIR, ld );
|
LoadStepManiaSongDir( SONGS_DIR, ld );
|
||||||
|
|
||||||
@@ -241,7 +257,7 @@ void SongManager::LoadStepManiaSongDir( CString sDir, LoadingWindow *ld )
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void SongManager::FreeSongArray()
|
void SongManager::FreeSongs()
|
||||||
{
|
{
|
||||||
for( unsigned i=0; i<m_pSongs.size(); i++ )
|
for( unsigned i=0; i<m_pSongs.size(); i++ )
|
||||||
SAFE_DELETE( m_pSongs[i] );
|
SAFE_DELETE( m_pSongs[i] );
|
||||||
@@ -251,12 +267,6 @@ void SongManager::FreeSongArray()
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void SongManager::ReloadSongArray()
|
|
||||||
{
|
|
||||||
InitSongArrayFromDisk( NULL );
|
|
||||||
FreeSongArray();
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void SongManager::ReadNoteScoresFromFile( CString fn, int c )
|
void SongManager::ReadNoteScoresFromFile( CString fn, int c )
|
||||||
{
|
{
|
||||||
@@ -745,7 +755,7 @@ int SongManager::GetNumStagesForSong( const Song* pSong )
|
|||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
void SongManager::InitCoursesFromDisk()
|
void SongManager::InitCoursesFromDisk( LoadingWindow *ld )
|
||||||
{
|
{
|
||||||
unsigned i;
|
unsigned i;
|
||||||
|
|
||||||
@@ -759,6 +769,15 @@ void SongManager::InitCoursesFromDisk()
|
|||||||
Course* pCourse = new Course;
|
Course* pCourse = new Course;
|
||||||
pCourse->LoadFromCRSFile( saCourseFiles[i] );
|
pCourse->LoadFromCRSFile( saCourseFiles[i] );
|
||||||
m_pCourses.push_back( pCourse );
|
m_pCourses.push_back( pCourse );
|
||||||
|
|
||||||
|
if( ld )
|
||||||
|
{
|
||||||
|
ld->SetText( ssprintf("Loading courses...\n%s\n%s",
|
||||||
|
"Courses",
|
||||||
|
Basename(saCourseFiles[i]).c_str()));
|
||||||
|
ld->Paint();
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -781,6 +800,14 @@ void SongManager::InitCoursesFromDisk()
|
|||||||
|
|
||||||
for( unsigned j=0; j<arrayCoursePaths.size(); j++ )
|
for( unsigned j=0; j<arrayCoursePaths.size(); j++ )
|
||||||
{
|
{
|
||||||
|
if( ld )
|
||||||
|
{
|
||||||
|
ld->SetText( ssprintf("Loading courses...\n%s\n%s",
|
||||||
|
Basename(arrayGroupDirs[i]).c_str(),
|
||||||
|
Basename(arrayCoursePaths[j]).c_str()));
|
||||||
|
ld->Paint();
|
||||||
|
}
|
||||||
|
|
||||||
Course* pCourse = new Course;
|
Course* pCourse = new Course;
|
||||||
pCourse->LoadFromCRSFile( arrayCoursePaths[j] );
|
pCourse->LoadFromCRSFile( arrayCoursePaths[j] );
|
||||||
m_pCourses.push_back( pCourse );
|
m_pCourses.push_back( pCourse );
|
||||||
@@ -824,7 +851,7 @@ void SongManager::FreeCourses()
|
|||||||
|
|
||||||
/* Called periodically to wipe out cached NoteData. This is called when we change
|
/* Called periodically to wipe out cached NoteData. This is called when we change
|
||||||
* screens. */
|
* screens. */
|
||||||
void SongManager::CleanData()
|
void SongManager::CompressSongs()
|
||||||
{
|
{
|
||||||
for( unsigned i=0; i<m_pSongs.size(); i++ )
|
for( unsigned i=0; i<m_pSongs.size(); i++ )
|
||||||
{
|
{
|
||||||
|
|||||||
+10
-15
@@ -32,9 +32,15 @@ public:
|
|||||||
SongManager( LoadingWindow *ld );
|
SongManager( LoadingWindow *ld );
|
||||||
~SongManager();
|
~SongManager();
|
||||||
|
|
||||||
void InitSongArrayFromDisk( LoadingWindow *ld );
|
void InitSongsFromDisk( LoadingWindow *ld );
|
||||||
void FreeSongArray();
|
void FreeSongs();
|
||||||
void ReloadSongArray();
|
void ReloadSongs();
|
||||||
|
void CompressSongs();
|
||||||
|
|
||||||
|
void InitCoursesFromDisk( LoadingWindow *ld );
|
||||||
|
void InitAutogenCourses();
|
||||||
|
void FreeCourses();
|
||||||
|
void ReloadCourses();
|
||||||
|
|
||||||
|
|
||||||
CString GetGroupBannerPath( CString sGroupName );
|
CString GetGroupBannerPath( CString sGroupName );
|
||||||
@@ -49,18 +55,6 @@ public:
|
|||||||
static int GetNumStagesForSong( const Song* pSong ); // LongVer songs take 2 stages, MarathonVer take 3
|
static int GetNumStagesForSong( const Song* pSong ); // LongVer songs take 2 stages, MarathonVer take 3
|
||||||
|
|
||||||
|
|
||||||
//
|
|
||||||
// Courses for Nonstop, Oni, and Endless
|
|
||||||
//
|
|
||||||
vector<Course*> m_pCourses;
|
|
||||||
|
|
||||||
void InitCoursesFromDisk();
|
|
||||||
void InitAutogenCourses();
|
|
||||||
void FreeCourses();
|
|
||||||
void CleanData();
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// Lookup
|
// Lookup
|
||||||
const vector<Song*> &GetAllSongs() const { return m_pSongs; }
|
const vector<Song*> &GetAllSongs() const { return m_pSongs; }
|
||||||
const vector<Song*> &GetBestSongs() const { return m_pBestSongs; }
|
const vector<Song*> &GetBestSongs() const { return m_pBestSongs; }
|
||||||
@@ -132,6 +126,7 @@ protected:
|
|||||||
vector<Song*> m_pBestSongs;
|
vector<Song*> m_pBestSongs;
|
||||||
CStringArray m_arrayGroupNames;
|
CStringArray m_arrayGroupNames;
|
||||||
CStringArray m_GroupBannerPaths; // each song group has a banner associated with it
|
CStringArray m_GroupBannerPaths; // each song group has a banner associated with it
|
||||||
|
vector<Course*> m_pCourses;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user