Make GetApplicableFiles() static and don't create a loader unless it can load from that directory.
This commit is contained in:
@@ -9,13 +9,6 @@
|
|||||||
#include "NotesLoaderBMS.h"
|
#include "NotesLoaderBMS.h"
|
||||||
#include "NotesLoaderKSF.h"
|
#include "NotesLoaderKSF.h"
|
||||||
|
|
||||||
bool NotesLoader::Loadable( const RString &sPath )
|
|
||||||
{
|
|
||||||
vector<RString> list;
|
|
||||||
GetApplicableFiles( sPath, list );
|
|
||||||
return !list.empty();
|
|
||||||
}
|
|
||||||
|
|
||||||
void NotesLoader::GetMainAndSubTitlesFromFullTitle( const RString &sFullTitle, RString &sMainTitleOut, RString &sSubTitleOut )
|
void NotesLoader::GetMainAndSubTitlesFromFullTitle( const RString &sFullTitle, RString &sMainTitleOut, RString &sSubTitleOut )
|
||||||
{
|
{
|
||||||
const RString sLeftSeps[] = { "\t", " -", " ~", " (", " [" };
|
const RString sLeftSeps[] = { "\t", " -", " ~", " (", " [" };
|
||||||
@@ -35,26 +28,14 @@ void NotesLoader::GetMainAndSubTitlesFromFullTitle( const RString &sFullTitle, R
|
|||||||
|
|
||||||
NotesLoader *NotesLoader::MakeLoader( const RString &sDir )
|
NotesLoader *NotesLoader::MakeLoader( const RString &sDir )
|
||||||
{
|
{
|
||||||
NotesLoader *ret;
|
vector<RString> list;
|
||||||
|
|
||||||
/* Actually, none of these have any persistant data, so we
|
#define CHECK_LOADER(x) x::GetApplicableFiles( sDir, list ); if( list.size() ) return new x
|
||||||
* could optimize this, but since they don't have any data,
|
CHECK_LOADER( SMLoader );
|
||||||
* there's no real point ... */
|
CHECK_LOADER( DWILoader );
|
||||||
ret = new SMLoader;
|
CHECK_LOADER( BMSLoader );
|
||||||
if(ret->Loadable( sDir )) return ret;
|
CHECK_LOADER( KSFLoader );
|
||||||
delete ret;
|
#undef CHECK_LOADER
|
||||||
|
|
||||||
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;
|
|
||||||
|
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -10,8 +10,6 @@ class Song;
|
|||||||
class NotesLoader
|
class NotesLoader
|
||||||
{
|
{
|
||||||
protected:
|
protected:
|
||||||
virtual void GetApplicableFiles( const RString &sPath, vector<RString> &out )=0;
|
|
||||||
|
|
||||||
set<RString> BlacklistedImages;
|
set<RString> BlacklistedImages;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
@@ -20,7 +18,6 @@ public:
|
|||||||
static void GetMainAndSubTitlesFromFullTitle( const RString &sFullTitle, RString &sMainTitleOut, RString &sSubTitleOut );
|
static void GetMainAndSubTitlesFromFullTitle( const RString &sFullTitle, RString &sMainTitleOut, RString &sSubTitleOut );
|
||||||
virtual bool LoadFromDir( const RString &sPath, Song &out ) = 0;
|
virtual bool LoadFromDir( const RString &sPath, Song &out ) = 0;
|
||||||
virtual void TidyUpData( Song &song, bool cache ) { }
|
virtual void TidyUpData( Song &song, bool cache ) { }
|
||||||
bool Loadable( const RString &sPath );
|
|
||||||
|
|
||||||
static NotesLoader *MakeLoader( const RString& sDir );
|
static NotesLoader *MakeLoader( const RString& sDir );
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -32,7 +32,7 @@ class BMSLoader: public NotesLoader
|
|||||||
map<RString,int> m_mapWavIdToKeysoundIndex;
|
map<RString,int> m_mapWavIdToKeysoundIndex;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
void GetApplicableFiles( const RString &sPath, vector<RString> &out );
|
static void GetApplicableFiles( const RString &sPath, vector<RString> &out );
|
||||||
bool LoadFromDir( const RString &sDir, Song &out );
|
bool LoadFromDir( const RString &sDir, Song &out );
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -26,7 +26,7 @@ class DWILoader: public NotesLoader
|
|||||||
RString m_sLoadingFile;
|
RString m_sLoadingFile;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
void GetApplicableFiles( const RString &sPath, vector<RString> &out );
|
static void GetApplicableFiles( const RString &sPath, vector<RString> &out );
|
||||||
bool LoadFromDir( const RString &sPath, Song &out );
|
bool LoadFromDir( const RString &sPath, Song &out );
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -17,7 +17,7 @@ class KSFLoader: public NotesLoader
|
|||||||
void LoadTags( const RString &str, Song &out );
|
void LoadTags( const RString &str, Song &out );
|
||||||
|
|
||||||
public:
|
public:
|
||||||
void GetApplicableFiles( const RString &sPath, vector<RString> &out );
|
static void GetApplicableFiles( const RString &sPath, vector<RString> &out );
|
||||||
bool LoadFromDir( const RString &sDir, Song &out );
|
bool LoadFromDir( const RString &sDir, Song &out );
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|||||||
@@ -33,7 +33,7 @@ public:
|
|||||||
return LoadFromSMFile( sPath, out );
|
return LoadFromSMFile( sPath, out );
|
||||||
}
|
}
|
||||||
|
|
||||||
void GetApplicableFiles( const RString &sPath, vector<RString> &out );
|
static void GetApplicableFiles( const RString &sPath, vector<RString> &out );
|
||||||
bool LoadFromDir( const RString &sPath, Song &out );
|
bool LoadFromDir( const RString &sPath, Song &out );
|
||||||
void TidyUpData( Song &song, bool cache );
|
void TidyUpData( Song &song, bool cache );
|
||||||
static bool LoadTimingFromFile( const RString &fn, TimingData &out );
|
static bool LoadTimingFromFile( const RString &fn, TimingData &out );
|
||||||
|
|||||||
Reference in New Issue
Block a user