Merge pull request #366 from kyzentun/bgm_formats
Unduplicate file extension lists.
This commit is contained in:
+91
-29
@@ -507,47 +507,109 @@ static const char *FileTypeNames[] = {
|
|||||||
"Xml",
|
"Xml",
|
||||||
"Model",
|
"Model",
|
||||||
"Lua",
|
"Lua",
|
||||||
|
"Ini",
|
||||||
};
|
};
|
||||||
XToString( FileType );
|
XToString( FileType );
|
||||||
LuaXType( FileType );
|
LuaXType( FileType );
|
||||||
|
|
||||||
|
// convenience so the for-loop lines can be shorter.
|
||||||
|
typedef map<RString, FileType> etft_cont_t;
|
||||||
|
typedef map<FileType, vector<RString> > fttel_cont_t;
|
||||||
|
etft_cont_t ExtensionToFileType;
|
||||||
|
fttel_cont_t FileTypeToExtensionList;
|
||||||
|
|
||||||
|
void ActorUtil::InitFileTypeLists()
|
||||||
|
{
|
||||||
|
// This function creates things to serve two purposes:
|
||||||
|
// 1. A map from extensions to filetypes, so extensions can be converted.
|
||||||
|
// 2. A reverse map for things that need a list of extensions to look for.
|
||||||
|
// The first section creates the map from extensions to filetypes, then the
|
||||||
|
// second section uses that map to build the reverse map.
|
||||||
|
ExtensionToFileType["lua"]= FT_Lua;
|
||||||
|
|
||||||
|
ExtensionToFileType["xml"]= FT_Xml;
|
||||||
|
|
||||||
|
ExtensionToFileType["ini"]= FT_Ini;
|
||||||
|
|
||||||
|
// Update RageSurfaceUtils when adding new image formats.
|
||||||
|
ExtensionToFileType["bmp"]= FT_Bitmap;
|
||||||
|
ExtensionToFileType["gif"]= FT_Bitmap;
|
||||||
|
ExtensionToFileType["jpeg"]= FT_Bitmap;
|
||||||
|
ExtensionToFileType["jpg"]= FT_Bitmap;
|
||||||
|
ExtensionToFileType["png"]= FT_Bitmap;
|
||||||
|
|
||||||
|
// Update RageSoundReader_FileReader when adding new sound formats.
|
||||||
|
ExtensionToFileType["mp3"]= FT_Sound;
|
||||||
|
ExtensionToFileType["oga"]= FT_Sound;
|
||||||
|
ExtensionToFileType["ogg"]= FT_Sound;
|
||||||
|
ExtensionToFileType["wav"]= FT_Sound;
|
||||||
|
|
||||||
|
// ffmpeg takes care of loading videos, not sure whether this list should
|
||||||
|
// have everything ffmpeg supports.
|
||||||
|
ExtensionToFileType["avi"]= FT_Movie;
|
||||||
|
ExtensionToFileType["f4v"]= FT_Movie;
|
||||||
|
ExtensionToFileType["flv"]= FT_Movie;
|
||||||
|
ExtensionToFileType["mkv"]= FT_Movie;
|
||||||
|
ExtensionToFileType["mp4"]= FT_Movie;
|
||||||
|
ExtensionToFileType["mpeg"]= FT_Movie;
|
||||||
|
ExtensionToFileType["mpg"]= FT_Movie;
|
||||||
|
ExtensionToFileType["mov"]= FT_Movie;
|
||||||
|
ExtensionToFileType["ogv"]= FT_Movie;
|
||||||
|
ExtensionToFileType["webm"]= FT_Movie;
|
||||||
|
ExtensionToFileType["wmv"]= FT_Movie;
|
||||||
|
|
||||||
|
ExtensionToFileType["sprite"]= FT_Sprite;
|
||||||
|
|
||||||
|
ExtensionToFileType["txt"]= FT_Model;
|
||||||
|
|
||||||
|
// When adding new extensions, do not add them below this line. This line
|
||||||
|
// marks the point where the function switches to building the reverse map.
|
||||||
|
for(etft_cont_t::iterator curr_ext= ExtensionToFileType.begin();
|
||||||
|
curr_ext != ExtensionToFileType.end(); ++curr_ext)
|
||||||
|
{
|
||||||
|
FileTypeToExtensionList[curr_ext->second].push_back(curr_ext->first);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
vector<RString> const& ActorUtil::GetTypeExtensionList(FileType ft)
|
||||||
|
{
|
||||||
|
return FileTypeToExtensionList[ft];
|
||||||
|
}
|
||||||
|
|
||||||
|
void ActorUtil::AddTypeExtensionsToList(FileType ft, vector<RString>& add_to)
|
||||||
|
{
|
||||||
|
fttel_cont_t::iterator ext_list= FileTypeToExtensionList.find(ft);
|
||||||
|
if(ext_list != FileTypeToExtensionList.end())
|
||||||
|
{
|
||||||
|
add_to.reserve(add_to.size() + ext_list->second.size());
|
||||||
|
for(vector<RString>::iterator curr= ext_list->second.begin();
|
||||||
|
curr != ext_list->second.end(); ++curr)
|
||||||
|
{
|
||||||
|
add_to.push_back(*curr);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
FileType ActorUtil::GetFileType( const RString &sPath )
|
FileType ActorUtil::GetFileType( const RString &sPath )
|
||||||
{
|
{
|
||||||
RString sExt = GetExtension( sPath );
|
RString sExt = GetExtension( sPath );
|
||||||
sExt.MakeLower();
|
sExt.MakeLower();
|
||||||
|
|
||||||
if( sExt=="lua" ) return FT_Lua;
|
etft_cont_t::iterator conversion_entry= ExtensionToFileType.find(sExt);
|
||||||
else if(sExt=="xml") return FT_Xml;
|
if(conversion_entry != ExtensionToFileType.end())
|
||||||
else if(
|
{
|
||||||
sExt=="png" ||
|
return conversion_entry->second;
|
||||||
sExt=="jpg" ||
|
}
|
||||||
sExt=="jpeg" ||
|
|
||||||
sExt=="gif" ||
|
|
||||||
sExt=="bmp" ) return FT_Bitmap;
|
|
||||||
else if(
|
|
||||||
sExt=="ogg" ||
|
|
||||||
sExt=="oga" ||
|
|
||||||
sExt=="wav" ||
|
|
||||||
sExt=="mp3" ) return FT_Sound;
|
|
||||||
else if(
|
|
||||||
sExt=="ogv" ||
|
|
||||||
sExt=="avi" ||
|
|
||||||
sExt=="mpeg" ||
|
|
||||||
sExt=="mp4" ||
|
|
||||||
sExt=="mkv" ||
|
|
||||||
sExt=="mov" ||
|
|
||||||
sExt=="flv" ||
|
|
||||||
sExt=="f4v" ||
|
|
||||||
sExt=="mpg" ) return FT_Movie;
|
|
||||||
else if(
|
|
||||||
sExt=="sprite" ) return FT_Sprite;
|
|
||||||
else if(
|
|
||||||
sExt=="txt" ) return FT_Model;
|
|
||||||
else if(sPath.size() > 0 && sPath[sPath.size()-1] == '/')
|
else if(sPath.size() > 0 && sPath[sPath.size()-1] == '/')
|
||||||
|
{
|
||||||
return FT_Directory;
|
return FT_Directory;
|
||||||
|
}
|
||||||
/* Do this last, to avoid the IsADirectory in most cases. */
|
/* Do this last, to avoid the IsADirectory in most cases. */
|
||||||
else if( IsADirectory(sPath) ) return FT_Directory;
|
else if(IsADirectory(sPath))
|
||||||
else return FileType_Invalid;
|
{
|
||||||
|
return FT_Directory;
|
||||||
|
}
|
||||||
|
return FileType_Invalid;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -38,6 +38,7 @@ enum FileType
|
|||||||
FT_Xml,
|
FT_Xml,
|
||||||
FT_Model,
|
FT_Model,
|
||||||
FT_Lua,
|
FT_Lua,
|
||||||
|
FT_Ini,
|
||||||
NUM_FileType,
|
NUM_FileType,
|
||||||
FileType_Invalid
|
FileType_Invalid
|
||||||
};
|
};
|
||||||
@@ -46,6 +47,10 @@ const RString& FileTypeToString( FileType ft );
|
|||||||
/** @brief Utility functions for creating and manipulating Actors. */
|
/** @brief Utility functions for creating and manipulating Actors. */
|
||||||
namespace ActorUtil
|
namespace ActorUtil
|
||||||
{
|
{
|
||||||
|
void InitFileTypeLists();
|
||||||
|
vector<RString> const& GetTypeExtensionList(FileType ft);
|
||||||
|
void AddTypeExtensionsToList(FileType ft, vector<RString>& add_to);
|
||||||
|
|
||||||
// Every screen should register its class at program initialization.
|
// Every screen should register its class at program initialization.
|
||||||
void Register( const RString& sClassName, CreateActorFn pfn );
|
void Register( const RString& sClassName, CreateActorFn pfn );
|
||||||
|
|
||||||
|
|||||||
+6
-14
@@ -7,6 +7,8 @@
|
|||||||
#include "RageLog.h"
|
#include "RageLog.h"
|
||||||
#include <set>
|
#include <set>
|
||||||
#include "Background.h"
|
#include "Background.h"
|
||||||
|
#include "RageFileManager.h"
|
||||||
|
#include "ActorUtil.h"
|
||||||
|
|
||||||
|
|
||||||
bool BackgroundDef::operator<( const BackgroundDef &other ) const
|
bool BackgroundDef::operator<( const BackgroundDef &other ) const
|
||||||
@@ -194,15 +196,8 @@ void BackgroundUtil::GetSongMovies( const Song *pSong, const RString &sMatch, ve
|
|||||||
vsPathsOut.clear();
|
vsPathsOut.clear();
|
||||||
if( sMatch.empty() )
|
if( sMatch.empty() )
|
||||||
{
|
{
|
||||||
GetDirListing( pSong->GetSongDir()+sMatch+"*.ogv", vsPathsOut, false, true );
|
FILEMAN->GetDirListingWithMultipleExtensions(pSong->GetSongDir()+sMatch,
|
||||||
GetDirListing( pSong->GetSongDir()+sMatch+"*.avi", vsPathsOut, false, true );
|
ActorUtil::GetTypeExtensionList(FT_Movie), vsPathsOut, false, true);
|
||||||
GetDirListing( pSong->GetSongDir()+sMatch+"*.mpg", vsPathsOut, false, true );
|
|
||||||
GetDirListing( pSong->GetSongDir()+sMatch+"*.mpeg", vsPathsOut, false, true );
|
|
||||||
GetDirListing( pSong->GetSongDir()+sMatch+"*.mp4", vsPathsOut, false, true );
|
|
||||||
GetDirListing( pSong->GetSongDir()+sMatch+"*.flv", vsPathsOut, false, true );
|
|
||||||
GetDirListing( pSong->GetSongDir()+sMatch+"*.f4v", vsPathsOut, false, true );
|
|
||||||
GetDirListing( pSong->GetSongDir()+sMatch+"*.mov", vsPathsOut, false, true );
|
|
||||||
GetDirListing( pSong->GetSongDir()+sMatch+"*.mkv", vsPathsOut, false, true );
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@@ -221,11 +216,8 @@ void BackgroundUtil::GetSongBitmaps( const Song *pSong, const RString &sMatch, v
|
|||||||
vsPathsOut.clear();
|
vsPathsOut.clear();
|
||||||
if( sMatch.empty() )
|
if( sMatch.empty() )
|
||||||
{
|
{
|
||||||
GetDirListing( pSong->GetSongDir()+sMatch+"*.png", vsPathsOut, false, true );
|
FILEMAN->GetDirListingWithMultipleExtensions(pSong->GetSongDir()+sMatch,
|
||||||
GetDirListing( pSong->GetSongDir()+sMatch+"*.jpg", vsPathsOut, false, true );
|
ActorUtil::GetTypeExtensionList(FT_Bitmap), vsPathsOut, false, true);
|
||||||
GetDirListing( pSong->GetSongDir()+sMatch+"*.jpeg", vsPathsOut, false, true );
|
|
||||||
GetDirListing( pSong->GetSongDir()+sMatch+"*.gif", vsPathsOut, false, true );
|
|
||||||
GetDirListing( pSong->GetSongDir()+sMatch+"*.bmp", vsPathsOut, false, true );
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
|||||||
+12
-10
@@ -15,6 +15,8 @@
|
|||||||
#include "NotesLoader.h"
|
#include "NotesLoader.h"
|
||||||
#include "PrefsManager.h"
|
#include "PrefsManager.h"
|
||||||
#include "BackgroundUtil.h"
|
#include "BackgroundUtil.h"
|
||||||
|
#include "ActorUtil.h"
|
||||||
|
#include "RageFileManager.h"
|
||||||
|
|
||||||
/* BMS encoding: tap-hold
|
/* BMS encoding: tap-hold
|
||||||
* 4&8panel: Player1 Player2
|
* 4&8panel: Player1 Player2
|
||||||
@@ -351,8 +353,8 @@ int BMSSong::AllocateKeysound( RString filename, RString path )
|
|||||||
|
|
||||||
if( !IsAFile(dir + normalizedFilename) )
|
if( !IsAFile(dir + normalizedFilename) )
|
||||||
{
|
{
|
||||||
const char *exts[] = { "oga", "ogg", "wav", "mp3", NULL }; // XXX: stop duplicating these everywhere
|
vector<RString> const& exts= ActorUtil::GetTypeExtensionList(FT_Sound);
|
||||||
for( unsigned i = 0; exts[i] != NULL; ++i )
|
for(size_t i = 0; i < exts.size(); ++i)
|
||||||
{
|
{
|
||||||
RString fn = SetExtension( normalizedFilename, exts[i] );
|
RString fn = SetExtension( normalizedFilename, exts[i] );
|
||||||
if( IsAFile(dir + fn) )
|
if( IsAFile(dir + fn) )
|
||||||
@@ -416,8 +418,10 @@ bool BMSSong::GetBackground( RString filename, RString path, RString &bgfile )
|
|||||||
|
|
||||||
if( !IsAFile(dir + normalizedFilename) )
|
if( !IsAFile(dir + normalizedFilename) )
|
||||||
{
|
{
|
||||||
const char *exts[] = { "ogv", "avi", "mpg", "mpeg", "bmp", "png", "jpeg", NULL }; // XXX: stop duplicating these everywhere
|
vector<RString> exts;
|
||||||
for( unsigned i = 0; exts[i] != NULL; ++i )
|
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] );
|
RString fn = SetExtension( normalizedFilename, exts[i] );
|
||||||
if( IsAFile(dir + fn) )
|
if( IsAFile(dir + fn) )
|
||||||
@@ -447,12 +451,10 @@ void BMSSong::PrecacheBackgrounds(const RString &dir)
|
|||||||
backgroundsPrecached = true;
|
backgroundsPrecached = true;
|
||||||
vector<RString> arrayPossibleFiles;
|
vector<RString> arrayPossibleFiles;
|
||||||
|
|
||||||
const char *exts[] = { "ogv", "avi", "mpg", "mpeg", "bmp", "png", "jpeg", NULL }; // XXX: stop duplicating these everywhere
|
vector<RString> exts;
|
||||||
|
ActorUtil::AddTypeExtensionsToList(FT_Movie, exts);
|
||||||
for( unsigned i = 0; exts[i] != NULL; ++i )
|
ActorUtil::AddTypeExtensionsToList(FT_Bitmap, exts);
|
||||||
{
|
FILEMAN->GetDirListingWithMultipleExtensions(dir + RString("*."), exts, arrayPossibleFiles);
|
||||||
GetDirListing( dir + RString("*.") + RString(exts[i]), arrayPossibleFiles );
|
|
||||||
}
|
|
||||||
|
|
||||||
for( unsigned i = 0; i < arrayPossibleFiles.size(); i++ )
|
for( unsigned i = 0; i < arrayPossibleFiles.size(); i++ )
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -397,6 +397,15 @@ void RageFileManager::GetDirListing( const RString &sPath_, vector<RString> &Add
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void RageFileManager::GetDirListingWithMultipleExtensions( const RString &sPath, vector<RString> const& ExtensionList, vector<RString> &AddTo, bool bOnlyDirs, bool bReturnPathToo )
|
||||||
|
{
|
||||||
|
for(vector<RString>::const_iterator curr_ext= ExtensionList.begin();
|
||||||
|
curr_ext != ExtensionList.end(); ++curr_ext)
|
||||||
|
{
|
||||||
|
GetDirListing(sPath + (*curr_ext), AddTo, bOnlyDirs, bReturnPathToo);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/* Files may only be moved within the same file driver. */
|
/* Files may only be moved within the same file driver. */
|
||||||
bool RageFileManager::Move( const RString &sOldPath_, const RString &sNewPath_ )
|
bool RageFileManager::Move( const RString &sOldPath_, const RString &sNewPath_ )
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -24,6 +24,9 @@ public:
|
|||||||
void MountUserFilesystems();
|
void MountUserFilesystems();
|
||||||
|
|
||||||
void GetDirListing( const RString &sPath, vector<RString> &AddTo, bool bOnlyDirs, bool bReturnPathToo );
|
void GetDirListing( const RString &sPath, vector<RString> &AddTo, bool bOnlyDirs, bool bReturnPathToo );
|
||||||
|
void GetDirListingWithMultipleExtensions(const RString &sPath,
|
||||||
|
vector<RString> const& ExtensionList, vector<RString> &AddTo,
|
||||||
|
bool bOnlyDirs= false, bool bReturnPathToo= false);
|
||||||
bool Move( const RString &sOldPath, const RString &sNewPath );
|
bool Move( const RString &sOldPath, const RString &sNewPath );
|
||||||
bool Remove( const RString &sPath );
|
bool Remove( const RString &sPath );
|
||||||
void CreateDir( const RString &sDir );
|
void CreateDir( const RString &sDir );
|
||||||
|
|||||||
@@ -2,6 +2,7 @@
|
|||||||
#include "RageSoundReader_FileReader.h"
|
#include "RageSoundReader_FileReader.h"
|
||||||
#include "RageUtil.h"
|
#include "RageUtil.h"
|
||||||
#include "RageLog.h"
|
#include "RageLog.h"
|
||||||
|
#include "ActorUtil.h"
|
||||||
|
|
||||||
#include <set>
|
#include <set>
|
||||||
#ifndef NO_WAV_SUPPORT
|
#ifndef NO_WAV_SUPPORT
|
||||||
@@ -122,10 +123,12 @@ RageSoundReader_FileReader *RageSoundReader_FileReader::OpenFile( RString filena
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
set<RString> FileTypes;
|
set<RString> FileTypes;
|
||||||
FileTypes.insert("oga");
|
vector<RString> const& sound_exts= ActorUtil::GetTypeExtensionList(FT_Sound);
|
||||||
FileTypes.insert("ogg");
|
for(vector<RString>::const_iterator curr= sound_exts.begin();
|
||||||
FileTypes.insert("mp3");
|
curr != sound_exts.end(); ++curr)
|
||||||
FileTypes.insert("wav");
|
{
|
||||||
|
FileTypes.insert(*curr);
|
||||||
|
}
|
||||||
|
|
||||||
RString format = GetExtension( filename );
|
RString format = GetExtension( filename );
|
||||||
format.MakeLower();
|
format.MakeLower();
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
#include "global.h"
|
#include "global.h"
|
||||||
|
#include "ActorUtil.h"
|
||||||
#include "RageSurface_Load.h"
|
#include "RageSurface_Load.h"
|
||||||
#include "RageSurface_Load_PNG.h"
|
#include "RageSurface_Load_PNG.h"
|
||||||
#include "RageSurface_Load_JPEG.h"
|
#include "RageSurface_Load_JPEG.h"
|
||||||
@@ -85,11 +86,12 @@ RageSurface *RageSurfaceUtils::LoadFile( const RString &sPath, RString &error, b
|
|||||||
}
|
}
|
||||||
|
|
||||||
set<RString> FileTypes;
|
set<RString> FileTypes;
|
||||||
FileTypes.insert("png");
|
vector<RString> const& exts= ActorUtil::GetTypeExtensionList(FT_Bitmap);
|
||||||
FileTypes.insert("jpg");
|
for(vector<RString>::const_iterator curr= exts.begin();
|
||||||
FileTypes.insert("jpeg");
|
curr != exts.end(); ++curr)
|
||||||
FileTypes.insert("gif");
|
{
|
||||||
FileTypes.insert("bmp");
|
FileTypes.insert(*curr);
|
||||||
|
}
|
||||||
|
|
||||||
RString format = GetExtension(sPath);
|
RString format = GetExtension(sPath);
|
||||||
format.MakeLower();
|
format.MakeLower();
|
||||||
|
|||||||
@@ -26,6 +26,7 @@
|
|||||||
#include "RageLog.h"
|
#include "RageLog.h"
|
||||||
#include "RageDisplay.h"
|
#include "RageDisplay.h"
|
||||||
#include "Foreach.h"
|
#include "Foreach.h"
|
||||||
|
#include "ActorUtil.h"
|
||||||
|
|
||||||
#include <map>
|
#include <map>
|
||||||
|
|
||||||
@@ -147,17 +148,13 @@ RageTexture* RageTextureManager::LoadTextureInternal( RageTextureID ID )
|
|||||||
}
|
}
|
||||||
|
|
||||||
// The texture is not already loaded. Load it.
|
// The texture is not already loaded. Load it.
|
||||||
RString sExt = GetExtension( ID.filename );
|
|
||||||
sExt.MakeLower();
|
|
||||||
|
|
||||||
RageTexture* pTexture;
|
RageTexture* pTexture;
|
||||||
if( ID.filename == g_sDefaultTextureName )
|
if( ID.filename == g_sDefaultTextureName )
|
||||||
{
|
{
|
||||||
pTexture = new RageTexture_Default;
|
pTexture = new RageTexture_Default;
|
||||||
}
|
}
|
||||||
else if(sExt == "ogv" || sExt == "avi" || sExt == "mpg" ||
|
else if(ActorUtil::GetFileType(ID.filename) == FT_Movie)
|
||||||
sExt == "mpeg" || sExt == "mp4" || sExt == "mkv" || sExt == "mov" ||
|
|
||||||
sExt == "flv" || sExt == "f4v")
|
|
||||||
{
|
{
|
||||||
pTexture = RageMovieTexture::Create( ID );
|
pTexture = RageMovieTexture::Create( ID );
|
||||||
}
|
}
|
||||||
|
|||||||
+5
-13
@@ -32,6 +32,7 @@
|
|||||||
#include "NotesWriterSSC.h"
|
#include "NotesWriterSSC.h"
|
||||||
#include "UnlockManager.h"
|
#include "UnlockManager.h"
|
||||||
#include "LyricsLoader.h"
|
#include "LyricsLoader.h"
|
||||||
|
#include "ActorUtil.h"
|
||||||
|
|
||||||
#include <time.h>
|
#include <time.h>
|
||||||
#include <set>
|
#include <set>
|
||||||
@@ -516,10 +517,8 @@ void Song::TidyUpData( bool fromCache, bool /* duringCache */ )
|
|||||||
if( !HasMusic() )
|
if( !HasMusic() )
|
||||||
{
|
{
|
||||||
vector<RString> arrayPossibleMusic;
|
vector<RString> arrayPossibleMusic;
|
||||||
GetDirListing( m_sSongDir + RString("*.mp3"), arrayPossibleMusic );
|
FILEMAN->GetDirListingWithMultipleExtensions(m_sSongDir,
|
||||||
GetDirListing( m_sSongDir + RString("*.oga"), arrayPossibleMusic );
|
ActorUtil::GetTypeExtensionList(FT_Sound), arrayPossibleMusic);
|
||||||
GetDirListing( m_sSongDir + RString("*.ogg"), arrayPossibleMusic );
|
|
||||||
GetDirListing( m_sSongDir + RString("*.wav"), arrayPossibleMusic );
|
|
||||||
|
|
||||||
if( !arrayPossibleMusic.empty() )
|
if( !arrayPossibleMusic.empty() )
|
||||||
{
|
{
|
||||||
@@ -854,15 +853,8 @@ void Song::TidyUpData( bool fromCache, bool /* duringCache */ )
|
|||||||
if( (!HasBGChanges() && !fromCache) )
|
if( (!HasBGChanges() && !fromCache) )
|
||||||
{
|
{
|
||||||
vector<RString> arrayPossibleMovies;
|
vector<RString> arrayPossibleMovies;
|
||||||
GetDirListing( m_sSongDir + RString("*.ogv"), arrayPossibleMovies );
|
FILEMAN->GetDirListingWithMultipleExtensions(m_sSongDir,
|
||||||
GetDirListing( m_sSongDir + RString("*.avi"), arrayPossibleMovies );
|
ActorUtil::GetTypeExtensionList(FT_Movie), arrayPossibleMovies);
|
||||||
GetDirListing( m_sSongDir + RString("*.mpg"), arrayPossibleMovies );
|
|
||||||
GetDirListing( m_sSongDir + RString("*.mpeg"), arrayPossibleMovies );
|
|
||||||
GetDirListing( m_sSongDir + RString("*.mp4"), arrayPossibleMovies );
|
|
||||||
GetDirListing( m_sSongDir + RString("*.mkv"), arrayPossibleMovies );
|
|
||||||
GetDirListing( m_sSongDir + RString("*.flv"), arrayPossibleMovies );
|
|
||||||
GetDirListing( m_sSongDir + RString("*.f4v"), arrayPossibleMovies );
|
|
||||||
GetDirListing( m_sSongDir + RString("*.mov"), arrayPossibleMovies );
|
|
||||||
|
|
||||||
/* Use this->GetBeatFromElapsedTime(0) instead of 0 to start when the
|
/* Use this->GetBeatFromElapsedTime(0) instead of 0 to start when the
|
||||||
* music starts. */
|
* music starts. */
|
||||||
|
|||||||
@@ -67,6 +67,7 @@
|
|||||||
#include "GameLoop.h"
|
#include "GameLoop.h"
|
||||||
#include "SpecialFiles.h"
|
#include "SpecialFiles.h"
|
||||||
#include "Profile.h"
|
#include "Profile.h"
|
||||||
|
#include "ActorUtil.h"
|
||||||
|
|
||||||
#if defined(WIN32)
|
#if defined(WIN32)
|
||||||
#include <windows.h>
|
#include <windows.h>
|
||||||
@@ -951,6 +952,10 @@ int main(int argc, char* argv[])
|
|||||||
|
|
||||||
LUA = new LuaManager;
|
LUA = new LuaManager;
|
||||||
|
|
||||||
|
// Initialize the file extension type lists so everything can ask ActorUtil
|
||||||
|
// what the type of a file is.
|
||||||
|
ActorUtil::InitFileTypeLists();
|
||||||
|
|
||||||
// Almost everything uses this to read and write files. Load this early.
|
// Almost everything uses this to read and write files. Load this early.
|
||||||
FILEMAN = new RageFileManager( argv[0] );
|
FILEMAN = new RageFileManager( argv[0] );
|
||||||
FILEMAN->MountInitialFilesystems();
|
FILEMAN->MountInitialFilesystems();
|
||||||
|
|||||||
+27
-21
@@ -616,32 +616,32 @@ bool ThemeManager::GetPathInfoToRaw( PathInfo &out, const RString &sThemeName_,
|
|||||||
for( unsigned p = 0; p < asPaths.size(); ++p )
|
for( unsigned p = 0; p < asPaths.size(); ++p )
|
||||||
{
|
{
|
||||||
// BGAnimations, Fonts, Graphics, Sounds, Other
|
// BGAnimations, Fonts, Graphics, Sounds, Other
|
||||||
static const char *masks[NUM_ElementCategory][15] = {
|
|
||||||
{ "redir", "lua", "xml", "png", "jpg", "jpeg", "bmp", "gif", "ogv", "avi", "mpg", "mpeg", "txt", "", NULL},
|
|
||||||
{ "redir", "ini", NULL },
|
|
||||||
{ "redir", "lua", "xml", "png", "jpg", "jpeg", "bmp", "gif", "ogv", "avi", "mpg", "mpeg", "txt", "", NULL},
|
|
||||||
{ "redir", "lua", "mp3", "oga", "ogg", "wav", NULL },
|
|
||||||
{ "*", NULL },
|
|
||||||
};
|
|
||||||
const char **asset_masks = masks[category];
|
|
||||||
|
|
||||||
const RString ext = GetExtension(asPaths[p]);
|
const RString ext = GetExtension(asPaths[p]);
|
||||||
|
bool matches= category == EC_OTHER || ext == "redir";
|
||||||
for( int i = 0; asset_masks[i]; ++i )
|
if(!matches)
|
||||||
{
|
{
|
||||||
// No extension means directories.
|
FileType ft= ActorUtil::GetFileType(asPaths[p]);
|
||||||
if( asset_masks[i][0] == 0 )
|
switch(ft)
|
||||||
|
{
|
||||||
|
case FT_Bitmap:
|
||||||
|
case FT_Sprite:
|
||||||
|
case FT_Movie:
|
||||||
|
case FT_Xml:
|
||||||
|
case FT_Model:
|
||||||
|
case FT_Lua:
|
||||||
|
matches= category == EC_BGANIMATIONS || category == EC_GRAPHICS;
|
||||||
|
break;
|
||||||
|
case FT_Ini:
|
||||||
|
matches= category == EC_FONTS;
|
||||||
|
break;
|
||||||
|
case FT_Directory:
|
||||||
{
|
{
|
||||||
if( !IsADirectory(asPaths[p]) )
|
|
||||||
continue;
|
|
||||||
|
|
||||||
RString sXMLPath = asPaths[p] + "/default.xml";
|
RString sXMLPath = asPaths[p] + "/default.xml";
|
||||||
if(DoesFileExist(sXMLPath))
|
if(DoesFileExist(sXMLPath))
|
||||||
{
|
{
|
||||||
asElementPaths.push_back(sXMLPath);
|
asElementPaths.push_back(sXMLPath);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
RString sLuaPath = asPaths[p] + "/default.lua";
|
RString sLuaPath = asPaths[p] + "/default.lua";
|
||||||
if(DoesFileExist(sLuaPath))
|
if(DoesFileExist(sLuaPath))
|
||||||
{
|
{
|
||||||
@@ -649,13 +649,19 @@ bool ThemeManager::GetPathInfoToRaw( PathInfo &out, const RString &sThemeName_,
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
break;
|
||||||
if( ext == asset_masks[i] || !strcmp(asset_masks[i], "*") )
|
case FT_Sound:
|
||||||
{
|
matches= category == EC_SOUNDS;
|
||||||
asElementPaths.push_back( asPaths[p] );
|
break;
|
||||||
|
default:
|
||||||
|
matches= false;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if(matches)
|
||||||
|
{
|
||||||
|
asElementPaths.push_back(asPaths[p]);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user