2
0
mirror of https://github.com/AxioDL/metaforce.git synced 2025-12-14 16:06:10 +00:00

Weighted extractor, shared across games as template

This commit is contained in:
Jack Andersen
2015-07-29 10:45:47 -10:00
parent 28985165ff
commit 5075cb6dc4
10 changed files with 79 additions and 162 deletions

View File

@@ -54,45 +54,10 @@ ResExtractor PAKBridge::LookupExtractor(const PAK::Entry& entry)
case SBIG('TXTR'):
return {TXTR::Extract, ".png"};
case SBIG('CMDL'):
return {CMDL::Extract, ".blend"};
return {CMDL::Extract, ".blend", 1};
}
return {};
}
bool PAKBridge::extractResources(const PAKRouter<PAKBridge>& router,
bool force,
std::function<void(float)> progress)
{
size_t count = 0;
for (const std::pair<UniqueID32, PAK::Entry*>& item : m_pak.m_idMap)
{
PAKEntryReadStream s;
auto cooked = router.getCooked(item.first);
if (force || cooked.first.getPathType() == HECL::ProjectPath::PT_NONE)
{
if (!s)
s = item.second->beginReadStream(m_node);
FILE* fout = HECL::Fopen(cooked.first.getAbsolutePath().c_str(), _S("wb"));
fwrite(s.data(), 1, s.length(), fout);
fclose(fout);
}
auto working = router.getWorking(item.first);
if (working.second.func)
{
if (force || working.first.getPathType() == HECL::ProjectPath::PT_NONE)
{
s = item.second->beginReadStream(m_node);
working.second.func(s, working.first);
}
}
++count;
progress(count / (float)m_pak.m_idMap.size());
}
return true;
}
}
}