add AdditionalCourseFolders pref

This commit is contained in:
Chris Danford
2006-08-14 20:05:35 +00:00
parent 7a86226dd4
commit 1e6f968d8e
5 changed files with 55 additions and 4 deletions
+1
View File
@@ -299,6 +299,7 @@ PrefsManager::PrefsManager() :
m_GetRankingName ( "GetRankingName", RANKING_ON ),
m_ScoringType ( "ScoringType", SCORING_NEW ),
m_sAdditionalSongFolders ( "AdditionalSongFolders", "" ),
m_sAdditionalCourseFolders ( "AdditionalCourseFolders", "" ),
m_sAdditionalFolders ( "AdditionalFolders", "" ),
m_sLastSeenVideoDriver ( "LastSeenVideoDriver", "" ),
m_sVideoRenderers ( "VideoRenderers", "" ), // StepMania.cpp sets these on first run:
+1
View File
@@ -201,6 +201,7 @@ public:
Preference<ScoringType,int> m_ScoringType;
Preference<RString> m_sAdditionalSongFolders;
Preference<RString> m_sAdditionalCourseFolders;
Preference<RString> m_sAdditionalFolders;
Preference<RString> m_sLastSeenVideoDriver;
+43 -4
View File
@@ -42,6 +42,7 @@ SongManager* SONGMAN = NULL; // global and accessable from anywhere in our progr
const RString SONGS_DIR = "/Songs/";
const RString ADDITIONAL_SONGS_DIR = "/AdditionalSongs/";
const RString COURSES_DIR = "/Courses/";
const RString ADDITIONAL_COURSES_DIR = "/AdditionalCourses/";
const RString EDIT_SUBDIR = "Edits/";
static const ThemeMetric<RageColor> EXTRA_COLOR ( "SongManager", "ExtraColor" );
@@ -608,6 +609,17 @@ int SongManager::GetNumCourses() const
return m_pCourses.size();
}
int SongManager::GetNumAdditionalCourses() const
{
int num = 0;
FOREACH_CONST( Course*, m_pCourses, i )
{
if( SONGMAN->WasLoadedFromAdditionalCourses( *i ) )
num++;
}
return num;
}
int SongManager::GetNumCourseGroups() const
{
return m_mapCourseGroupToInfo.size();
@@ -674,18 +686,37 @@ void SongManager::InitCoursesFromDisk( LoadingWindow *ld )
}
// Find all group directories in Courses dir
vector<RString> vsCourseDirs;
vsCourseDirs.push_back( COURSES_DIR );
vsCourseDirs.push_back( ADDITIONAL_COURSES_DIR );
FOREACH_CONST( RString, vsCourseDirs, sDir )
{
// Find all group directories in Courses dir
vector<RString> vsCourseGroupNames;
GetDirListing( COURSES_DIR+"*", vsCourseGroupNames, true );
GetDirListing( *sDir + "*", vsCourseGroupNames, true );
StripCvs( vsCourseGroupNames );
SortRStringArray( vsCourseGroupNames );
FOREACH( RString, vsCourseGroupNames, sCourseGroup ) // for each dir in /Courses/
FOREACH_CONST( RString, vsCourseGroupNames, sCourseGroup ) // for each dir in /Courses/
{
#if defined(ITG)
if( !ALLOW_ITG_NAMES_IN_ADDITIONAL_FOLDERS )
{
// Don't load any folders containing "Marathon" so that they don't conflict with the official courses.
if( *sDir == ADDITIONAL_COURSES_DIR && BeginsWith(*sCourseGroup, "Marathon") )
continue;
if( *sDir == ADDITIONAL_COURSES_DIR && BeginsWith(*sCourseGroup, "Survival") )
continue;
if( *sDir == ADDITIONAL_COURSES_DIR && BeginsWith(*sCourseGroup, "Workout") )
continue;
}
#endif
// Find all CRS files in this group directory
vector<RString> vsCoursePaths;
GetDirListing( COURSES_DIR + *sCourseGroup + "/*.crs", vsCoursePaths, false, true );
GetDirListing( *sDir + *sCourseGroup + "/*.crs", vsCoursePaths, false, true );
SortRStringArray( vsCoursePaths );
FOREACH_CONST( RString, vsCoursePaths, sCoursePath )
@@ -1069,6 +1100,12 @@ bool SongManager::WasLoadedFromAdditionalSongs( const Song *pSong ) const
return BeginsWith( sDir, ADDITIONAL_SONGS_DIR );
}
bool SongManager::WasLoadedFromAdditionalCourses( const Course *pCourse ) const
{
RString sDir = pCourse->m_sPath;
return BeginsWith( sDir, ADDITIONAL_COURSES_DIR );
}
void SongManager::GetAllCourses( vector<Course*> &AddTo, bool bIncludeAutogen )
{
for( unsigned i=0; i<m_pCourses.size(); i++ )
@@ -1776,6 +1813,7 @@ public:
static int GetNumAdditionalSongs( T* p, lua_State *L ) { lua_pushnumber( L, p->GetNumAdditionalSongs() ); return 1; }
static int GetNumSongGroups( T* p, lua_State *L ) { lua_pushnumber( L, p->GetNumSongGroups() ); return 1; }
static int GetNumCourses( T* p, lua_State *L ) { lua_pushnumber( L, p->GetNumCourses() ); return 1; }
static int GetNumAdditionalCourses( T* p, lua_State *L ){ lua_pushnumber( L, p->GetNumAdditionalCourses() ); return 1; }
static int GetNumCourseGroups( T* p, lua_State *L ) { lua_pushnumber( L, p->GetNumCourseGroups() ); return 1; }
static int GetSongFromSteps( T* p, lua_State *L )
{
@@ -1801,6 +1839,7 @@ public:
ADD_METHOD( GetNumAdditionalSongs );
ADD_METHOD( GetNumSongGroups );
ADD_METHOD( GetNumCourses );
ADD_METHOD( GetNumAdditionalCourses );
ADD_METHOD( GetNumCourseGroups );
ADD_METHOD( GetSongFromSteps );
+2
View File
@@ -91,6 +91,7 @@ public:
int GetNumAdditionalSongs() const;
int GetNumSongGroups() const;
int GetNumCourses() const;
int GetNumAdditionalCourses() const;
int GetNumCourseGroups() const;
int GetNumEditCourses( ProfileSlot slot ) const;
Song* GetRandomSong();
@@ -100,6 +101,7 @@ public:
Song *GetSongFromSteps( Steps *pSteps );
void DeleteSteps( Steps *pSteps ); // transfers ownership of pSteps
bool WasLoadedFromAdditionalSongs( const Song *pSong ) const;
bool WasLoadedFromAdditionalCourses( const Course *pCourse ) const;
void GetAllCourses( vector<Course*> &AddTo, bool bIncludeAutogen );
void GetCourses( CourseType ct, vector<Course*> &AddTo, bool bIncludeAutogen ) const;
+8
View File
@@ -978,6 +978,14 @@ int main(int argc, char* argv[])
for( unsigned i=0; i < dirs.size(); i++)
FILEMAN->Mount( "dir", dirs[i], "/AdditionalSongs" );
}
if( PREFSMAN->m_sAdditionalCourseFolders.Get() != "" )
{
vector<RString> dirs;
split( PREFSMAN->m_sAdditionalCourseFolders, ",", dirs, true );
for( unsigned i=0; i < dirs.size(); i++)
FILEMAN->Mount( "dir", dirs[i], "/AdditionalCourses" );
}
MountTreeOfZips( ZIPS_DIR );
/* One of the above filesystems might contain files that affect preferences, eg Data/Static.ini.