Merge pull request #1452 from psi29a/loading_screens

add support for png and dds splashscreens
This commit is contained in:
scrawl 2017-09-13 23:10:00 +00:00 committed by GitHub
commit 5817674651

View File

@ -66,15 +66,27 @@ namespace MWGui
std::string pattern = "Splash/"; std::string pattern = "Splash/";
mVFS->normalizeFilename(pattern); mVFS->normalizeFilename(pattern);
std::map<std::string, VFS::File*>::const_iterator found = index.lower_bound(pattern); /* priority given to the left */
std::list<std::string> supported_extensions = {".tga", ".dds", ".png", ".bmp", ".jpeg", ".jpg"};
auto found = index.lower_bound(pattern);
while (found != index.end()) while (found != index.end())
{ {
const std::string& name = found->first; const std::string& name = found->first;
if (name.size() >= pattern.size() && name.substr(0, pattern.size()) == pattern) if (name.size() >= pattern.size() && name.substr(0, pattern.size()) == pattern)
{ {
size_t pos = name.find_last_of('.'); size_t pos = name.find_last_of('.');
if (pos != std::string::npos && name.compare(pos, name.size()-pos, ".tga") == 0) if (pos != std::string::npos)
mSplashScreens.push_back(found->first); {
for(auto const extension: supported_extensions)
{
if (name.compare(pos, name.size() - pos, extension) == 0)
{
mSplashScreens.push_back(found->first);
break; /* based on priority */
}
}
}
} }
else else
break; break;