diff --git a/stepmania/src/NotesLoader.cpp b/stepmania/src/NotesLoader.cpp index 6ace116ddc..31563dc32a 100644 --- a/stepmania/src/NotesLoader.cpp +++ b/stepmania/src/NotesLoader.cpp @@ -9,13 +9,6 @@ #include "NotesLoaderBMS.h" #include "NotesLoaderKSF.h" -bool NotesLoader::Loadable( const RString &sPath ) -{ - vector list; - GetApplicableFiles( sPath, list ); - return !list.empty(); -} - void NotesLoader::GetMainAndSubTitlesFromFullTitle( const RString &sFullTitle, RString &sMainTitleOut, RString &sSubTitleOut ) { const RString sLeftSeps[] = { "\t", " -", " ~", " (", " [" }; @@ -35,26 +28,14 @@ void NotesLoader::GetMainAndSubTitlesFromFullTitle( const RString &sFullTitle, R NotesLoader *NotesLoader::MakeLoader( const RString &sDir ) { - NotesLoader *ret; + vector list; - /* Actually, none of these have any persistant data, so we - * could optimize this, but since they don't have any data, - * there's no real point ... */ - ret = new SMLoader; - if(ret->Loadable( sDir )) return ret; - delete ret; - - ret = new DWILoader; - if(ret->Loadable( sDir )) return ret; - delete ret; - - ret = new BMSLoader; - if(ret->Loadable( sDir )) return ret; - delete ret; - - ret = new KSFLoader; - if(ret->Loadable( sDir )) return ret; - delete ret; +#define CHECK_LOADER(x) x::GetApplicableFiles( sDir, list ); if( list.size() ) return new x + CHECK_LOADER( SMLoader ); + CHECK_LOADER( DWILoader ); + CHECK_LOADER( BMSLoader ); + CHECK_LOADER( KSFLoader ); +#undef CHECK_LOADER return NULL; } diff --git a/stepmania/src/NotesLoader.h b/stepmania/src/NotesLoader.h index da387bcc9b..02fd697773 100644 --- a/stepmania/src/NotesLoader.h +++ b/stepmania/src/NotesLoader.h @@ -10,8 +10,6 @@ class Song; class NotesLoader { protected: - virtual void GetApplicableFiles( const RString &sPath, vector &out )=0; - set BlacklistedImages; public: @@ -20,7 +18,6 @@ public: static void GetMainAndSubTitlesFromFullTitle( const RString &sFullTitle, RString &sMainTitleOut, RString &sSubTitleOut ); virtual bool LoadFromDir( const RString &sPath, Song &out ) = 0; virtual void TidyUpData( Song &song, bool cache ) { } - bool Loadable( const RString &sPath ); static NotesLoader *MakeLoader( const RString& sDir ); }; diff --git a/stepmania/src/NotesLoaderBMS.h b/stepmania/src/NotesLoaderBMS.h index b34a061e29..1cb3b692c9 100644 --- a/stepmania/src/NotesLoaderBMS.h +++ b/stepmania/src/NotesLoaderBMS.h @@ -32,7 +32,7 @@ class BMSLoader: public NotesLoader map m_mapWavIdToKeysoundIndex; public: - void GetApplicableFiles( const RString &sPath, vector &out ); + static void GetApplicableFiles( const RString &sPath, vector &out ); bool LoadFromDir( const RString &sDir, Song &out ); }; diff --git a/stepmania/src/NotesLoaderDWI.h b/stepmania/src/NotesLoaderDWI.h index fb2f2065b1..eb0f4d9fb5 100644 --- a/stepmania/src/NotesLoaderDWI.h +++ b/stepmania/src/NotesLoaderDWI.h @@ -26,7 +26,7 @@ class DWILoader: public NotesLoader RString m_sLoadingFile; public: - void GetApplicableFiles( const RString &sPath, vector &out ); + static void GetApplicableFiles( const RString &sPath, vector &out ); bool LoadFromDir( const RString &sPath, Song &out ); }; diff --git a/stepmania/src/NotesLoaderKSF.h b/stepmania/src/NotesLoaderKSF.h index 30d29fdda5..21000feb34 100644 --- a/stepmania/src/NotesLoaderKSF.h +++ b/stepmania/src/NotesLoaderKSF.h @@ -17,7 +17,7 @@ class KSFLoader: public NotesLoader void LoadTags( const RString &str, Song &out ); public: - void GetApplicableFiles( const RString &sPath, vector &out ); + static void GetApplicableFiles( const RString &sPath, vector &out ); bool LoadFromDir( const RString &sDir, Song &out ); private: diff --git a/stepmania/src/NotesLoaderSM.h b/stepmania/src/NotesLoaderSM.h index d632da0592..d76c3f9d89 100644 --- a/stepmania/src/NotesLoaderSM.h +++ b/stepmania/src/NotesLoaderSM.h @@ -33,7 +33,7 @@ public: return LoadFromSMFile( sPath, out ); } - void GetApplicableFiles( const RString &sPath, vector &out ); + static void GetApplicableFiles( const RString &sPath, vector &out ); bool LoadFromDir( const RString &sPath, Song &out ); void TidyUpData( Song &song, bool cache ); static bool LoadTimingFromFile( const RString &fn, TimingData &out );