bool KSFLoader::LoadFromDir( CString sDir, Song &out ) { LOG->Trace( "Song::LoadFromKSFDir(%s)", sDir.c_str() ); CStringArray arrayKSFFileNames; GetDirListing( sDir + CString("*.ksf"), arrayKSFFileNames ); /* We shouldn't have been called to begin with if there were no KSFs. */ if( arrayKSFFileNames.empty() ) RageException::Throw( "Couldn't find any KSF files in '%s'", sDir.c_str() ); if(!LoadGlobalData(out.GetSongDir() + arrayKSFFileNames[0], out)) return false; // load the Steps from the rest of the KSF files for( unsigned i=0; i<arrayKSFFileNames.size(); i++ ) { Steps* pNewNotes = new Steps; if(!LoadFromKSFFile( out.GetSongDir() + arrayKSFFileNames[i], *pNewNotes, out )) { delete pNewNotes; continue; } out.AddSteps( pNewNotes ); } return true; }
bool KSFLoader::LoadNoteDataFromSimfile( const RString & cachePath, Steps &out ) { bool KIUCompliant = false; Song dummy; if (!LoadGlobalData(cachePath, dummy, KIUCompliant)) return false; Steps *notes = dummy.CreateSteps(); if (LoadFromKSFFile(cachePath, *notes, dummy, KIUCompliant)) { KIUCompliant = true; // yeah, reusing a variable. out.SetNoteData(notes->GetNoteData()); } delete notes; return KIUCompliant; }
bool KSFLoader::LoadFromDir( const RString &sDir, Song &out ) { LOG->Trace( "KSFLoader::LoadFromDir(%s)", sDir.c_str() ); vector<RString> arrayKSFFileNames; GetDirListing( sDir + RString("*.ksf"), arrayKSFFileNames ); // We shouldn't have been called to begin with if there were no KSFs. ASSERT( arrayKSFFileNames.size() != 0 ); bool bKIUCompliant = false; /* With Split Timing, there has to be a backup Song Timing in case * anything goes wrong. As these files are kept in alphabetical * order (hopefully), it is best to use the LAST file for timing * purposes, for that is the "normal", or easiest difficulty. * Usually. */ // Nevermind, kiu compilancy is screwing things up: // IE, I have two simfiles, oh wich each have four ksf files, the first one has // the first ksf with directmove timing changes, and the rest are not, everything // goes fine. In the other hand I have my second simfile with the first ksf file // without directmove timing changes and the rest have changes, changes are not // loaded due to kiucompilancy in the first ksf file. // About the "normal" thing, my simfiles' ksfs uses non-standard naming so // the last chart is usually nightmare or normal, I use easy and normal // indistinctly for SM so it shouldn't matter, I use piu fiesta/ex naming // for directmove though, and we're just gathering basic info anyway, and // most of the time all the KSF files have the same info in the #TITLE:; section unsigned files = arrayKSFFileNames.size(); RString dir = out.GetSongDir(); if( !LoadGlobalData(dir + arrayKSFFileNames[files - 1], out, bKIUCompliant) ) return false; out.m_sSongFileName = dir + arrayKSFFileNames[files - 1]; // load the Steps from the rest of the KSF files for( unsigned i=0; i<files; i++ ) { Steps* pNewNotes = out.CreateSteps(); if( !LoadFromKSFFile(dir + arrayKSFFileNames[i], *pNewNotes, out, bKIUCompliant) ) { delete pNewNotes; continue; } pNewNotes->SetFilename(dir + arrayKSFFileNames[i]); out.AddSteps( pNewNotes ); } return true; }