VideoCommon: Make a reusable free function for getting top level directories that have a matching gameid text file underneath
This commit is contained in:
parent
0fe6081680
commit
8a1539f948
|
@ -87,7 +87,8 @@ void HiresTexture::Update()
|
||||||
}
|
}
|
||||||
|
|
||||||
const std::string& game_id = SConfig::GetInstance().GetGameID();
|
const std::string& game_id = SConfig::GetInstance().GetGameID();
|
||||||
const std::set<std::string> texture_directories = GetTextureDirectories(game_id);
|
const std::set<std::string> texture_directories =
|
||||||
|
GetTextureDirectoriesWithGameId(File::GetUserPath(D_HIRESTEXTURES_IDX), game_id);
|
||||||
const std::vector<std::string> extensions{".png", ".dds"};
|
const std::vector<std::string> extensions{".png", ".dds"};
|
||||||
|
|
||||||
for (const auto& texture_directory : texture_directories)
|
for (const auto& texture_directory : texture_directories)
|
||||||
|
@ -454,10 +455,11 @@ bool HiresTexture::LoadTexture(Level& level, const std::vector<u8>& buffer)
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::set<std::string> HiresTexture::GetTextureDirectories(const std::string& game_id)
|
std::set<std::string> GetTextureDirectoriesWithGameId(const std::string& root_directory,
|
||||||
|
const std::string& game_id)
|
||||||
{
|
{
|
||||||
std::set<std::string> result;
|
std::set<std::string> result;
|
||||||
const std::string texture_directory = File::GetUserPath(D_HIRESTEXTURES_IDX) + game_id;
|
const std::string texture_directory = root_directory + game_id;
|
||||||
|
|
||||||
if (File::Exists(texture_directory))
|
if (File::Exists(texture_directory))
|
||||||
{
|
{
|
||||||
|
@ -466,8 +468,7 @@ std::set<std::string> HiresTexture::GetTextureDirectories(const std::string& gam
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
// If there's no directory with the region-specific ID, look for a 3-character region-free one
|
// If there's no directory with the region-specific ID, look for a 3-character region-free one
|
||||||
const std::string region_free_directory =
|
const std::string region_free_directory = root_directory + game_id.substr(0, 3);
|
||||||
File::GetUserPath(D_HIRESTEXTURES_IDX) + game_id.substr(0, 3);
|
|
||||||
|
|
||||||
if (File::Exists(region_free_directory))
|
if (File::Exists(region_free_directory))
|
||||||
{
|
{
|
||||||
|
@ -482,7 +483,6 @@ std::set<std::string> HiresTexture::GetTextureDirectories(const std::string& gam
|
||||||
};
|
};
|
||||||
|
|
||||||
// Look for any other directories that might be specific to the given gameid
|
// Look for any other directories that might be specific to the given gameid
|
||||||
const auto root_directory = File::GetUserPath(D_HIRESTEXTURES_IDX);
|
|
||||||
const auto files = Common::DoFileSearch({root_directory}, {".txt"}, true);
|
const auto files = Common::DoFileSearch({root_directory}, {".txt"}, true);
|
||||||
for (const auto& file : files)
|
for (const auto& file : files)
|
||||||
{
|
{
|
||||||
|
@ -490,8 +490,8 @@ std::set<std::string> HiresTexture::GetTextureDirectories(const std::string& gam
|
||||||
{
|
{
|
||||||
// The following code is used to calculate the top directory
|
// The following code is used to calculate the top directory
|
||||||
// of a found gameid.txt file
|
// of a found gameid.txt file
|
||||||
// ex: <dolphin dir>/Load/Textures/My folder/gameids/<gameid>.txt
|
// ex: <root directory>/My folder/gameids/<gameid>.txt
|
||||||
// would insert "<dolphin dir>/Load/Textures/My folder"
|
// would insert "<root directory>/My folder"
|
||||||
const auto directory_path = file.substr(root_directory.size());
|
const auto directory_path = file.substr(root_directory.size());
|
||||||
const std::size_t first_path_separator_position = directory_path.find_first_of(DIR_SEP_CHR);
|
const std::size_t first_path_separator_position = directory_path.find_first_of(DIR_SEP_CHR);
|
||||||
result.insert(root_directory + directory_path.substr(0, first_path_separator_position));
|
result.insert(root_directory + directory_path.substr(0, first_path_separator_position));
|
||||||
|
|
|
@ -14,6 +14,9 @@
|
||||||
|
|
||||||
enum class TextureFormat;
|
enum class TextureFormat;
|
||||||
|
|
||||||
|
std::set<std::string> GetTextureDirectoriesWithGameId(const std::string& root_directory,
|
||||||
|
const std::string& game_id);
|
||||||
|
|
||||||
class HiresTexture
|
class HiresTexture
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
@ -54,8 +57,6 @@ private:
|
||||||
static bool LoadTexture(Level& level, const std::vector<u8>& buffer);
|
static bool LoadTexture(Level& level, const std::vector<u8>& buffer);
|
||||||
static void Prefetch();
|
static void Prefetch();
|
||||||
|
|
||||||
static std::set<std::string> GetTextureDirectories(const std::string& game_id);
|
|
||||||
|
|
||||||
HiresTexture() {}
|
HiresTexture() {}
|
||||||
bool m_has_arbitrary_mipmaps;
|
bool m_has_arbitrary_mipmaps;
|
||||||
};
|
};
|
||||||
|
|
Loading…
Reference in New Issue