mirror of
https://github.com/holub/mame
synced 2025-07-04 09:28:51 +03:00
render/bgfx: Fix failure to load texture .png files when -artpath contains multiple directories
This commit is contained in:
parent
bcf647342a
commit
f806cfd21c
@ -155,7 +155,7 @@ void path_iterator::reset()
|
||||
// in the search path
|
||||
//-------------------------------------------------
|
||||
|
||||
const osd::directory::entry *file_enumerator::next()
|
||||
const osd::directory::entry *file_enumerator::next(const char *subdir)
|
||||
{
|
||||
// loop over potentially empty directories
|
||||
while (true)
|
||||
@ -164,7 +164,7 @@ const osd::directory::entry *file_enumerator::next()
|
||||
while (!m_curdir)
|
||||
{
|
||||
// if we fail to get anything more, we're done
|
||||
if (!m_iterator.next(m_pathbuffer))
|
||||
if (!m_iterator.next(m_pathbuffer, subdir))
|
||||
return nullptr;
|
||||
|
||||
// open the path
|
||||
|
@ -107,7 +107,7 @@ public:
|
||||
file_enumerator &operator=(file_enumerator const &) = delete;
|
||||
|
||||
// iterator
|
||||
const osd::directory::entry *next();
|
||||
const osd::directory::entry *next(const char *subdir = nullptr);
|
||||
|
||||
private:
|
||||
// internal state
|
||||
|
@ -109,20 +109,10 @@ bgfx_chain_entry* chain_entry_reader::read_from_value(const Value& value, std::s
|
||||
}
|
||||
|
||||
// get directory of file
|
||||
std::string directory_path = std::string(chains.options().art_path());
|
||||
std::string file_directory = "";
|
||||
const size_t last_slash = texture_name.rfind('/');
|
||||
if (last_slash != std::string::npos)
|
||||
{
|
||||
file_directory = texture_name.substr(0, last_slash);
|
||||
|
||||
directory_path += "/" + file_directory;
|
||||
}
|
||||
|
||||
osd::directory::ptr directory = osd::directory::open(directory_path);
|
||||
if (directory)
|
||||
{
|
||||
for (const osd::directory::entry *entry = directory->read(); entry != nullptr; entry = directory->read())
|
||||
const std::string file_directory = last_slash != std::string::npos ? texture_name.substr(0, last_slash) : std::string();
|
||||
file_enumerator directory_path(chains.options().art_path());
|
||||
while (const osd::directory::entry *entry = directory_path.next(file_directory.empty() ? nullptr : file_directory.c_str()))
|
||||
{
|
||||
if (entry->type == osd::directory::entry::entry_type::FILE)
|
||||
{
|
||||
@ -150,7 +140,7 @@ bgfx_chain_entry* chain_entry_reader::read_from_value(const Value& value, std::s
|
||||
}
|
||||
|
||||
// check for .png extension
|
||||
if (file_extension == extension)
|
||||
if (file_extension == extension && std::find(texture_names.begin(), texture_names.end(), file_path) == texture_names.end())
|
||||
{
|
||||
// create textures for all files containd in the path of the specified file name
|
||||
uint32_t flags = bilinear ? 0u : (BGFX_SAMPLER_MIN_POINT | BGFX_SAMPLER_MAG_POINT | BGFX_SAMPLER_MIP_POINT);
|
||||
@ -167,7 +157,6 @@ bgfx_chain_entry* chain_entry_reader::read_from_value(const Value& value, std::s
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (has_target)
|
||||
{
|
||||
texture_name = input["target"].GetString();
|
||||
|
Loading…
Reference in New Issue
Block a user