avoid calling GetDirListing ten times per theme lookup
This commit is contained in:
@@ -188,19 +188,38 @@ try_element_again:
|
|||||||
GetDirListing( sThemeDir + sCategory + SLASH + sFileName + ".redir",
|
GetDirListing( sThemeDir + sCategory + SLASH + sFileName + ".redir",
|
||||||
asElementPaths, false, true );
|
asElementPaths, false, true );
|
||||||
|
|
||||||
static const char *masks[NUM_ELEMENT_CATEGORIES][12] = {
|
const CString wildcard = (category == BGAnimations? "":"*");
|
||||||
{ "", NULL },
|
CStringArray asPaths;
|
||||||
{ "*.ini", NULL },
|
GetDirListing( sThemeDir + sCategory + SLASH + sFileName + wildcard,
|
||||||
{ "*.actor", "*.sprite", "*.png", "*.jpg", "*.bmp", "*.gif","*.avi", "*.mpg", "*.mpeg", "*.txt", NULL},
|
asPaths, bDirsOnly, true );
|
||||||
{ "*.png", NULL },
|
|
||||||
{ "*.mp3", "*.ogg", "*.wav", NULL },
|
for( unsigned p = 0; p < asPaths.size(); ++p )
|
||||||
{ "*.sm", NULL },
|
{
|
||||||
};
|
static const char *masks[NUM_ELEMENT_CATEGORIES][12] = {
|
||||||
const char **asset_masks = masks[category];
|
{ "", NULL },
|
||||||
|
{ "ini", NULL },
|
||||||
|
{ "actor", "sprite", "png", "jpg", "bmp", "gif","avi", "mpg", "mpeg", "txt", NULL},
|
||||||
|
{ "png", NULL },
|
||||||
|
{ "mp3", "ogg", "wav", NULL },
|
||||||
|
{ "sm", NULL },
|
||||||
|
};
|
||||||
|
const char **asset_masks = masks[category];
|
||||||
|
|
||||||
|
const CString ext = GetExtension( asPaths[p] );
|
||||||
|
|
||||||
|
if( ext == "redir" )
|
||||||
|
continue; // got it already
|
||||||
|
|
||||||
|
for( int i = 0; asset_masks[i]; ++i )
|
||||||
|
{
|
||||||
|
if( ext == asset_masks[i] )
|
||||||
|
{
|
||||||
|
asElementPaths.push_back( asPaths[p] );
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
for( int i = 0; asset_masks[i]; ++i )
|
|
||||||
GetDirListing( sThemeDir + sCategory + SLASH + sFileName + asset_masks[i],
|
|
||||||
asElementPaths, bDirsOnly, true );
|
|
||||||
if( category == Fonts )
|
if( category == Fonts )
|
||||||
Font::WeedFontNames(asElementPaths, sFileName);
|
Font::WeedFontNames(asElementPaths, sFileName);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user