Merge pull request #366 from kyzentun/bgm_formats

Unduplicate file extension lists.
This commit is contained in:
Kyzentun
2014-12-01 16:18:09 -07:00
12 changed files with 208 additions and 130 deletions
+12 -10
View File
@@ -15,6 +15,8 @@
#include "NotesLoader.h"
#include "PrefsManager.h"
#include "BackgroundUtil.h"
#include "ActorUtil.h"
#include "RageFileManager.h"
/* BMS encoding: tap-hold
* 4&8panel: Player1 Player2
@@ -351,8 +353,8 @@ int BMSSong::AllocateKeysound( RString filename, RString path )
if( !IsAFile(dir + normalizedFilename) )
{
const char *exts[] = { "oga", "ogg", "wav", "mp3", NULL }; // XXX: stop duplicating these everywhere
for( unsigned i = 0; exts[i] != NULL; ++i )
vector<RString> const& exts= ActorUtil::GetTypeExtensionList(FT_Sound);
for(size_t i = 0; i < exts.size(); ++i)
{
RString fn = SetExtension( normalizedFilename, exts[i] );
if( IsAFile(dir + fn) )
@@ -416,8 +418,10 @@ bool BMSSong::GetBackground( RString filename, RString path, RString &bgfile )
if( !IsAFile(dir + normalizedFilename) )
{
const char *exts[] = { "ogv", "avi", "mpg", "mpeg", "bmp", "png", "jpeg", NULL }; // XXX: stop duplicating these everywhere
for( unsigned i = 0; exts[i] != NULL; ++i )
vector<RString> exts;
ActorUtil::AddTypeExtensionsToList(FT_Movie, exts);
ActorUtil::AddTypeExtensionsToList(FT_Bitmap, exts);
for(size_t i = 0; i < exts.size(); ++i)
{
RString fn = SetExtension( normalizedFilename, exts[i] );
if( IsAFile(dir + fn) )
@@ -447,12 +451,10 @@ void BMSSong::PrecacheBackgrounds(const RString &dir)
backgroundsPrecached = true;
vector<RString> arrayPossibleFiles;
const char *exts[] = { "ogv", "avi", "mpg", "mpeg", "bmp", "png", "jpeg", NULL }; // XXX: stop duplicating these everywhere
for( unsigned i = 0; exts[i] != NULL; ++i )
{
GetDirListing( dir + RString("*.") + RString(exts[i]), arrayPossibleFiles );
}
vector<RString> exts;
ActorUtil::AddTypeExtensionsToList(FT_Movie, exts);
ActorUtil::AddTypeExtensionsToList(FT_Bitmap, exts);
FILEMAN->GetDirListingWithMultipleExtensions(dir + RString("*."), exts, arrayPossibleFiles);
for( unsigned i = 0; i < arrayPossibleFiles.size(); i++ )
{