Added functions to ActorUtil for converting the extension to a file type and changed various places that had lists of extensions to use ActorUtil instead of duplicating the list of extensions. Added webm and wmv to list of video types.

This commit is contained in:
Kyzentun
2014-11-09 00:04:47 -07:00
parent 77130ed3c4
commit e22e99251e
12 changed files with 208 additions and 130 deletions
+40 -34
View File
@@ -616,46 +616,52 @@ bool ThemeManager::GetPathInfoToRaw( PathInfo &out, const RString &sThemeName_,
for( unsigned p = 0; p < asPaths.size(); ++p )
{
// 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] );
for( int i = 0; asset_masks[i]; ++i )
const RString ext = GetExtension(asPaths[p]);
bool matches= category == EC_OTHER || ext == "redir";
if(!matches)
{
// No extension means directories.
if( asset_masks[i][0] == 0 )
FileType ft= ActorUtil::GetFileType(asPaths[p]);
switch(ft)
{
if( !IsADirectory(asPaths[p]) )
continue;
RString sXMLPath = asPaths[p] + "/default.xml";
if( DoesFileExist(sXMLPath) )
{
asElementPaths.push_back( sXMLPath );
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;
}
RString sLuaPath = asPaths[p] + "/default.lua";
if( DoesFileExist(sLuaPath) )
{
asElementPaths.push_back( sLuaPath );
case FT_Ini:
matches= category == EC_FONTS;
break;
case FT_Directory:
{
RString sXMLPath = asPaths[p] + "/default.xml";
if(DoesFileExist(sXMLPath))
{
asElementPaths.push_back(sXMLPath);
break;
}
RString sLuaPath = asPaths[p] + "/default.lua";
if(DoesFileExist(sLuaPath))
{
asElementPaths.push_back(sLuaPath);
break;
}
}
break;
case FT_Sound:
matches= category == EC_SOUNDS;
break;
default:
matches= false;
break;
}
}
if( ext == asset_masks[i] || !strcmp(asset_masks[i], "*") )
{
asElementPaths.push_back( asPaths[p] );
break;
}
}
if(matches)
{
asElementPaths.push_back(asPaths[p]);
}
}
}