Add output callbacks to NODLib contexts

This commit is contained in:
Phillip Stephens 2015-09-28 22:17:54 -07:00
parent 34e0361bc1
commit 6d6deff2a2
4 changed files with 47 additions and 19 deletions

View File

@ -54,11 +54,19 @@ void SpecBase::doExtract(const ExtractPassInfo& info, FExtractProgress progress)
/* Extract update partition for repacking later */
const HECL::SystemString& target = m_project.getProjectRootPath().getAbsolutePath();
NOD::DiscBase::IPartition* update = m_disc->getUpdatePartition();
NOD::ExtractionContext ctx = {false, info.force, nullptr};
NOD::ExtractionContext ctx = {true, info.force, nullptr};
if (update)
{
atUint64 idx = 0;
progress(_S("Update Partition"), _S(""), 0, 0.0);
const atUint64 nodeCount = update->getFSTRoot().rawEnd() - update->getFSTRoot().rawBegin();
ctx.progressCB = [&](const std::string& name) {
HECL::SystemStringView nameView(name);
progress(_S("Update Partition"), nameView.sys_str().c_str(), 0, idx / (float)nodeCount);
idx++;
};
update->getFSTRoot().extractToDirectory(target, ctx);
progress(_S("Update Partition"), _S(""), 0, 1.0);
}

View File

@ -210,7 +210,7 @@ struct SpecMP1 : SpecBase
bool extractFromDisc(NOD::DiscBase&, bool force, FExtractProgress progress)
{
NOD::ExtractionContext ctx = {false, force, nullptr};
NOD::ExtractionContext ctx = {true, force, nullptr};
progress(_S("Indexing PAKs"), _S(""), 2, 0.0);
m_pakRouter.build(m_paks, [&progress](float factor)
@ -222,11 +222,14 @@ struct SpecMP1 : SpecBase
m_workPath.makeDir();
progress(_S("MP1 Root"), _S(""), 3, 0.0);
int prog = 0;
ctx.progressCB = [&](const std::string& name) {
HECL::SystemStringView nameView(name);
progress(_S("MP1 Root"), nameView.sys_str().c_str(), 3, prog / (float)m_nonPaks.size());
};
for (const NOD::DiscBase::IPartition::Node* node : m_nonPaks)
{
node->extractToDirectory(m_workPath.getAbsolutePath(), ctx);
HECL::SystemStringView nameView(node->getName());
progress(_S("MP1 Root"), nameView.sys_str().c_str(), 3, prog++ / (float)m_nonPaks.size());
prog++;
}
progress(_S("MP1 Root"), _S(""), 3, 1.0);

View File

@ -203,7 +203,7 @@ struct SpecMP2 : SpecBase
bool extractFromDisc(NOD::DiscBase&, bool force, FExtractProgress progress)
{
NOD::ExtractionContext ctx = {false, force, nullptr};
NOD::ExtractionContext ctx = {true, force, nullptr};
progress(_S("Indexing PAKs"), _S(""), 2, 0.0);
m_pakRouter.build(m_paks, [&progress](float factor)
{
@ -214,11 +214,14 @@ struct SpecMP2 : SpecBase
m_workPath.makeDir();
progress(_S("MP2 Root"), _S(""), 3, 0.0);
int prog = 0;
ctx.progressCB = [&](const std::string& name) {
HECL::SystemStringView nameView(name);
progress(_S("MP2 Root"), nameView.sys_str().c_str(), 3, prog / (float)m_nonPaks.size());
};
for (const NOD::DiscBase::IPartition::Node* node : m_nonPaks)
{
node->extractToDirectory(m_workPath.getAbsolutePath(), ctx);
HECL::SystemStringView nameView(node->getName());
progress(_S("MP2 Root"), nameView.sys_str().c_str(), 3, prog++ / (float)m_nonPaks.size());
prog++;
}
progress(_S("MP2 Root"), _S(""), 3, 1.0);

View File

@ -321,9 +321,16 @@ struct SpecMP3 : SpecBase
bool extractFromDisc(NOD::DiscBase&, bool force, FExtractProgress progress)
{
NOD::ExtractionContext ctx = {false, force, nullptr};
int compIdx = 2;
int prog;
HECL::SystemString currentTarget = _S("");
size_t nodeCount = 0;
int prog = 0;
NOD::ExtractionContext ctx = {true, force,
[&](const std::string& name)
{
HECL::SystemStringView nameView(name);
progress(currentTarget.c_str(), nameView.sys_str().c_str(), compIdx, prog / (float)nodeCount);
}};
if (doMP3)
{
progress(_S("Indexing PAKs"), _S(""), compIdx, 0.0);
@ -335,15 +342,20 @@ struct SpecMP3 : SpecBase
HECL::ProjectPath mp3WorkPath(m_project.getProjectRootPath(), "MP3");
mp3WorkPath.makeDir();
progress(_S("MP3 Root"), _S(""), compIdx, 0.0);
currentTarget = _S("MP3 Root");
progress(currentTarget.c_str(), _S(""), compIdx, 0.0);
prog = 0;
nodeCount = m_nonPaks.size();
// TODO: Make this more granular
for (const NOD::DiscBase::IPartition::Node* node : m_nonPaks)
{
node->extractToDirectory(mp3WorkPath.getAbsolutePath(), ctx);
HECL::SystemStringView nameView(node->getName());
progress(_S("MP3 Root"), nameView.sys_str().c_str(), compIdx, prog++ / (float)m_nonPaks.size());
prog++;
}
progress(_S("MP3 Root"), _S(""), compIdx++, 1.0);
ctx.progressCB = nullptr;
progress(currentTarget.c_str(), _S(""), compIdx++, 1.0);
const HECL::ProjectPath& cookPath = m_project.getProjectCookedPath(SpecEntMP3);
cookPath.makeDir();
@ -380,15 +392,18 @@ struct SpecMP3 : SpecBase
progress(_S("Indexing PAKs"), _S(""), compIdx++, 1.0);
m_feWorkPath.makeDir();
progress(_S("fe Root"), _S(""), compIdx, 0.0);
int prog = 0;
currentTarget = _S("fe Root");
progress(currentTarget.c_str(), _S(""), compIdx, 0.0);
prog = 0;
nodeCount = m_feNonPaks.size();
// TODO: Make this more granular
for (const NOD::DiscBase::IPartition::Node* node : m_feNonPaks)
{
node->extractToDirectory(m_feWorkPath.getAbsolutePath(), ctx);
HECL::SystemStringView nameView(node->getName());
progress(_S("fe Root"), nameView.sys_str().c_str(), compIdx, prog++ / (float)m_feNonPaks.size());
prog++;
}
progress(_S("fe Root"), _S(""), compIdx++, 1.0);
progress(currentTarget.c_str(), _S(""), compIdx++, 1.0);
const HECL::ProjectPath& cookPath = m_project.getProjectCookedPath(SpecEntMP3);
cookPath.makeDir();
@ -413,7 +428,6 @@ struct SpecMP3 : SpecBase
progress(sysName.sys_str().c_str(), _S(""), compIdx++, 1.0);
}
}
return true;
}