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:
@@ -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;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user