Edit loading overhaul: Load edits from song folders; Allow a songfolder-style hierarchy in profile edit folders; Make the #SONG tag optional if we can infer the intended song from the directory hierarchy.
This commit is contained in:
+61
-7
@@ -1713,26 +1713,80 @@ void SongManager::LoadStepEditsFromProfileDir( const RString &sProfileDir, Profi
|
||||
{
|
||||
// Load all edit steps
|
||||
RString sDir = sProfileDir + EDIT_STEPS_SUBDIR;
|
||||
|
||||
vector<RString> vsFiles;
|
||||
GetDirListing( sDir+"*.edit", vsFiles, false, true );
|
||||
|
||||
SSCLoader loaderSSC;
|
||||
SMLoader loaderSM;
|
||||
int iNumEditsLoaded = GetNumEditsLoadedFromProfile( slot );
|
||||
int size = min( (int) vsFiles.size(), MAX_EDIT_STEPS_PER_PROFILE - iNumEditsLoaded );
|
||||
|
||||
// Pass 1: Flat folder (old style)
|
||||
vector<RString> vsFiles;
|
||||
int size = min( (int) vsFiles.size(), MAX_EDIT_STEPS_PER_PROFILE - iNumEditsLoaded );
|
||||
GetDirListing( sDir+"*.edit", vsFiles, false, true );
|
||||
|
||||
// XXX: If some edits are invalid and they're close to the edit limit, this may erroneously skip some edits, and won't warn.
|
||||
for( int i=0; i<size; i++ )
|
||||
{
|
||||
RString fn = vsFiles[i];
|
||||
SSCLoader loaderSSC;
|
||||
bool bLoadedFromSSC = loaderSSC.LoadEditFromFile( fn, slot, true );
|
||||
// If we don't load the edit from a .ssc-style .edit, then we should
|
||||
// also try the .sm-style edit file. -aj
|
||||
if( !bLoadedFromSSC )
|
||||
{
|
||||
SMLoader loaderSM;
|
||||
loaderSM.LoadEditFromFile( fn, slot, true );
|
||||
}
|
||||
}
|
||||
|
||||
if( vsFiles.size() > MAX_EDIT_STEPS_PER_PROFILE - iNumEditsLoaded )
|
||||
{
|
||||
LOG->Warn("Profile %s has too many edits; some have been skipped.", ProfileSlotToString( slot ).c_str() );
|
||||
return;
|
||||
}
|
||||
|
||||
// Some .edit files may have been invalid, so re-query instead of just += size.
|
||||
iNumEditsLoaded = GetNumEditsLoadedFromProfile( slot );
|
||||
|
||||
// Pass 2: Group and song folders with #SONG inferred from folder (optional new style)
|
||||
vector<RString> vsGroups;
|
||||
GetDirListing( sDir+"*", vsGroups, true, false );
|
||||
|
||||
// XXX: Same as above, edits may be skipped in error in some cases
|
||||
for( int i=0; i<vsGroups.size(); i++ )
|
||||
{
|
||||
RString sGroupDir = vsGroups[i]+"/";
|
||||
vector<RString> vsSongs;
|
||||
GetDirListing(sDir+sGroupDir+"*", vsSongs, true, false );
|
||||
|
||||
for( int j=0; j<vsSongs.size(); j++ )
|
||||
{
|
||||
vector<RString> vsEdits;
|
||||
RString sSongDir = sGroupDir+vsSongs[j]+"/";
|
||||
// XXX There doesn't appear to be a songdir const?
|
||||
Song *given = GetSongFromDir( "/Songs/"+sSongDir );
|
||||
// NOTE: We don't have to check the return value of GetSongFromDir here,
|
||||
// because if it fails, it returns NULL, which is then passed to NotesLoader*.LoadEditFromFile(),
|
||||
// which will interpret that as "we couldn't infer the song from the path",
|
||||
// which is what we want in that case anyway.
|
||||
GetDirListing(sDir+sSongDir+"/*.edit", vsEdits, false, true );
|
||||
size = min( (int) vsEdits.size(), MAX_EDIT_STEPS_PER_PROFILE - iNumEditsLoaded );
|
||||
|
||||
for( int k=0; k<size; k++ )
|
||||
{
|
||||
RString fn = vsEdits[k];
|
||||
bool bLoadedFromSSC = loaderSSC.LoadEditFromFile( fn, slot, true, given );
|
||||
// And try again with SM
|
||||
if( !bLoadedFromSSC )
|
||||
loaderSM.LoadEditFromFile( fn, slot, true, given );
|
||||
}
|
||||
|
||||
if( vsEdits.size() > MAX_EDIT_STEPS_PER_PROFILE - iNumEditsLoaded )
|
||||
{
|
||||
LOG->Warn("Profile %s has too many edits; some have been skipped.", ProfileSlotToString( slot ).c_str() );
|
||||
return;
|
||||
}
|
||||
|
||||
// Some .edit files may have been invalid, so re-query instead of just += size.
|
||||
iNumEditsLoaded = GetNumEditsLoadedFromProfile( slot );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void SongManager::LoadCourseEditsFromProfileDir( const RString &sProfileDir, ProfileSlot slot )
|
||||
|
||||
Reference in New Issue
Block a user