Merge pull request #3456 from JosJuice/custom-texture-all-regions

HiresTextures: Also look for directories with 3-character IDs
This commit is contained in:
JosJuice 2016-01-06 14:43:49 +01:00
commit 42237dc511
2 changed files with 16 additions and 7 deletions

View File

@ -86,11 +86,14 @@ void HiresTexture::Update()
s_textureCache.clear(); s_textureCache.clear();
} }
const std::string& gameCode = SConfig::GetInstance().m_strUniqueID; const std::string& game_id = SConfig::GetInstance().m_strUniqueID;
std::string texture_directory = GetTextureFolder(game_id);
std::string szDir = StringFromFormat("%s%s", File::GetUserPath(D_HIRESTEXTURES_IDX).c_str(), gameCode.c_str()); // If there's no directory with the region-specific ID, look for a 3-character region-free one
if (!File::Exists(texture_directory))
texture_directory = GetTextureFolder(game_id.substr(0, 3));
std::vector<std::string> Extensions { std::vector<std::string> extensions {
".png", ".png",
".bmp", ".bmp",
".tga", ".tga",
@ -98,12 +101,11 @@ void HiresTexture::Update()
".jpg" // Why not? Could be useful for large photo-like textures ".jpg" // Why not? Could be useful for large photo-like textures
}; };
auto rFilenames = DoFileSearch(Extensions, {szDir}, /*recursive*/ true); std::vector<std::string> filenames = DoFileSearch(extensions, {texture_directory}, /*recursive*/ true);
const std::string code = StringFromFormat("%s_", gameCode.c_str()); const std::string code = game_id + "_";
const std::string code2 = "";
for (auto& rFilename : rFilenames) for (auto& rFilename : filenames)
{ {
std::string FileName; std::string FileName;
SplitPath(rFilename, nullptr, &FileName, nullptr); SplitPath(rFilename, nullptr, &FileName, nullptr);
@ -437,6 +439,11 @@ std::unique_ptr<HiresTexture> HiresTexture::Load(const std::string& base_filenam
return ret; return ret;
} }
std::string HiresTexture::GetTextureFolder(const std::string& game_id)
{
return File::GetUserPath(D_HIRESTEXTURES_IDX) + game_id;
}
HiresTexture::~HiresTexture() HiresTexture::~HiresTexture()
{ {
} }

View File

@ -51,6 +51,8 @@ private:
static std::unique_ptr<HiresTexture> Load(const std::string& base_filename, u32 width, u32 height); static std::unique_ptr<HiresTexture> Load(const std::string& base_filename, u32 width, u32 height);
static void Prefetch(); static void Prefetch();
static std::string GetTextureFolder(const std::string& game_id);
HiresTexture() {} HiresTexture() {}
}; };