mirror of
https://github.com/AxioDL/metaforce.git
synced 2025-12-08 15:44:56 +00:00
shared resource routing
This commit is contained in:
@@ -55,8 +55,7 @@ ResExtractor PAKBridge::LookupExtractor(const DNAMP1::PAK::Entry& entry)
|
||||
return {};
|
||||
}
|
||||
|
||||
bool PAKBridge::extractResources(const HECL::ProjectPath& workingOut,
|
||||
const HECL::ProjectPath& cookedOut,
|
||||
bool PAKBridge::extractResources(const PAKRouter<PAKBridge>& router,
|
||||
bool force,
|
||||
std::function<void(float)> progress)
|
||||
{
|
||||
@@ -64,26 +63,27 @@ bool PAKBridge::extractResources(const HECL::ProjectPath& workingOut,
|
||||
for (const std::pair<UniqueID32, DNAMP1::PAK::Entry*>& item : m_pak.m_idMap)
|
||||
{
|
||||
PAKEntryReadStream s;
|
||||
ResExtractor extractor = LookupExtractor(*item.second);
|
||||
if (extractor.func)
|
||||
{
|
||||
HECL::ProjectPath workPath(workingOut, m_pak.bestEntryName(*item.second) + extractor.fileExt);
|
||||
if (force || workPath.getPathType() == HECL::ProjectPath::PT_NONE)
|
||||
{
|
||||
s = item.second->beginReadStream(m_node);
|
||||
extractor.func(s, workPath);
|
||||
}
|
||||
}
|
||||
HECL::ProjectPath cookPath(cookedOut, m_pak.bestEntryName(*item.second));
|
||||
if (force || cookPath.getPathType() == HECL::ProjectPath::PT_NONE)
|
||||
|
||||
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(cookPath.getAbsolutePath().c_str(), _S("wb"));
|
||||
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());
|
||||
}
|
||||
|
||||
@@ -17,15 +17,17 @@ class PAKBridge
|
||||
HECL::Database::Project& m_project;
|
||||
const NOD::DiscBase::IPartition::Node& m_node;
|
||||
DNAMP1::PAK m_pak;
|
||||
static ResExtractor LookupExtractor(const DNAMP1::PAK::Entry& entry);
|
||||
public:
|
||||
PAKBridge(HECL::Database::Project& project, const NOD::DiscBase::IPartition::Node& node);
|
||||
static ResExtractor LookupExtractor(const DNAMP1::PAK::Entry& entry);
|
||||
const std::string& getName() const {return m_node.getName();}
|
||||
HECL::SystemString getLevelString() const;
|
||||
bool extractResources(const HECL::ProjectPath& dirOut,
|
||||
const HECL::ProjectPath& cookedOut,
|
||||
bool extractResources(const PAKRouter<PAKBridge>& router,
|
||||
bool force,
|
||||
std::function<void(float)> progress);
|
||||
|
||||
typedef DNAMP1::PAK PAKType;
|
||||
const PAKType& getPAK() const {return m_pak;}
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user