Move MakeLoader to NotesLoader. It doesn't make sense for it to be a member function of Song.

This commit is contained in:
Steve Checkoway
2006-06-20 07:12:52 +00:00
parent 5e7ac2deed
commit 3a9bdc1646
4 changed files with 36 additions and 33 deletions
+33 -1
View File
@@ -4,6 +4,11 @@
#include "GameManager.h"
#include "RageUtil.h"
#include "NotesLoaderSM.h"
#include "NotesLoaderDWI.h"
#include "NotesLoaderBMS.h"
#include "NotesLoaderKSF.h"
bool NotesLoader::Loadable( const RString &sPath )
{
vector<RString> list;
@@ -26,7 +31,34 @@ void NotesLoader::GetMainAndSubTitlesFromFullTitle( const RString &sFullTitle, R
}
sMainTitleOut = sFullTitle;
sSubTitleOut = "";
};
};
NotesLoader *NotesLoader::MakeLoader( const RString &sDir )
{
NotesLoader *ret;
/* 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;
return NULL;
}
/*
* (c) 2001-2004 Chris Danford, Glenn Maynard
+2
View File
@@ -21,6 +21,8 @@ public:
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 );
};
#endif
+1 -30
View File
@@ -26,9 +26,6 @@
#include "SpecialFiles.h"
#include "NotesLoaderSM.h"
#include "NotesLoaderDWI.h"
#include "NotesLoaderBMS.h"
#include "NotesLoaderKSF.h"
#include "NotesWriterDWI.h"
#include "NotesWriterSM.h"
@@ -164,32 +161,6 @@ const RString &Song::GetSongFilePath() const
return m_sSongFileName;
}
NotesLoader *Song::MakeLoader( RString sDir ) const
{
NotesLoader *ret;
/* 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;
return NULL;
}
/* Hack: This should be a parameter to TidyUpData, but I don't want to
* pull in <set> into Song.h, which is heavily used. */
static set<RString> BlacklistedImages;
@@ -244,7 +215,7 @@ bool Song::LoadFromSongDir( RString sDir )
// Let's load it from a file, then write a cache entry.
//
NotesLoader *ld = MakeLoader( sDir );
NotesLoader *ld = NotesLoader::MakeLoader( sDir );
if( ld )
{
bool success = ld->LoadFromDir( sDir, *this );
-2
View File
@@ -58,8 +58,6 @@ public:
void Reset();
void DetachSteps();
NotesLoader *MakeLoader( RString sDir ) const;
bool LoadFromSongDir( RString sDir );
void TidyUpData(); // call after loading to clean up invalid data