Updates for new working directory layout

This commit is contained in:
Jack Andersen 2016-03-01 10:29:18 -10:00
parent 2a614215c8
commit 8648dfbf10
8 changed files with 39 additions and 47 deletions

View File

@ -93,26 +93,11 @@ void SpecBase::doExtract(const ExtractPassInfo& info, FProgress progress)
Log.report(LogVisor::FatalError, "Unable to build master shader blend"); Log.report(LogVisor::FatalError, "Unable to build master shader blend");
if (m_isWii) if (m_isWii)
{ {
/* Extract update partition for repacking later */ /* Extract root files for repacking later */
const HECL::SystemString& target = m_project.getProjectWorkingPath().getAbsolutePath(); HECL::ProjectPath outDir(m_project.getProjectWorkingPath(), _S("out"));
NOD::Partition* update = m_disc->getUpdatePartition(); outDir.makeDir();
NOD::ExtractionContext ctx = {true, 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);
}
if (!m_standalone) if (!m_standalone)
{ {
progress(_S("Trilogy Files"), _S(""), 1, 0.0); progress(_S("Trilogy Files"), _S(""), 1, 0.0);
@ -120,7 +105,7 @@ void SpecBase::doExtract(const ExtractPassInfo& info, FProgress progress)
const NOD::Node& root = data->getFSTRoot(); const NOD::Node& root = data->getFSTRoot();
for (const NOD::Node& child : root) for (const NOD::Node& child : root)
if (child.getKind() == NOD::Node::Kind::File) if (child.getKind() == NOD::Node::Kind::File)
child.extractToDirectory(target, ctx); child.extractToDirectory(outDir.getAbsolutePath(), ctx);
progress(_S("Trilogy Files"), _S(""), 1, 1.0); progress(_S("Trilogy Files"), _S(""), 1, 1.0);
} }
} }

View File

@ -227,6 +227,10 @@ struct SpecMP1 : SpecBase
progress(_S("Indexing PAKs"), _S(""), 2, 1.0); progress(_S("Indexing PAKs"), _S(""), 2, 1.0);
m_workPath.makeDir(); m_workPath.makeDir();
HECL::ProjectPath outPath(m_project.getProjectWorkingPath(), _S("out"));
outPath.makeDir();
HECL::ProjectPath mp1OutPath(outPath, _S("MP1"));
mp1OutPath.makeDir();
progress(_S("MP1 Root"), _S(""), 3, 0.0); progress(_S("MP1 Root"), _S(""), 3, 0.0);
int prog = 0; int prog = 0;
ctx.progressCB = [&](const std::string& name) { ctx.progressCB = [&](const std::string& name) {
@ -235,7 +239,7 @@ struct SpecMP1 : SpecBase
}; };
for (const NOD::Node* node : m_nonPaks) for (const NOD::Node* node : m_nonPaks)
{ {
node->extractToDirectory(m_workPath.getAbsolutePath(), ctx); node->extractToDirectory(mp1OutPath.getAbsolutePath(), ctx);
prog++; prog++;
} }
progress(_S("MP1 Root"), _S(""), 3, 1.0); progress(_S("MP1 Root"), _S(""), 3, 1.0);

View File

@ -217,6 +217,10 @@ struct SpecMP2 : SpecBase
progress(_S("Indexing PAKs"), _S(""), 2, 1.0); progress(_S("Indexing PAKs"), _S(""), 2, 1.0);
m_workPath.makeDir(); m_workPath.makeDir();
HECL::ProjectPath outPath(m_project.getProjectWorkingPath(), _S("out"));
outPath.makeDir();
HECL::ProjectPath mp2OutPath(outPath, _S("MP2"));
mp2OutPath.makeDir();
progress(_S("MP2 Root"), _S(""), 3, 0.0); progress(_S("MP2 Root"), _S(""), 3, 0.0);
int prog = 0; int prog = 0;
ctx.progressCB = [&](const std::string& name) { ctx.progressCB = [&](const std::string& name) {
@ -225,7 +229,7 @@ struct SpecMP2 : SpecBase
}; };
for (const NOD::Node* node : m_nonPaks) for (const NOD::Node* node : m_nonPaks)
{ {
node->extractToDirectory(m_workPath.getAbsolutePath(), ctx); node->extractToDirectory(mp2OutPath.getAbsolutePath(), ctx);
prog++; prog++;
} }
progress(_S("MP2 Root"), _S(""), 3, 1.0); progress(_S("MP2 Root"), _S(""), 3, 1.0);

View File

@ -346,8 +346,12 @@ struct SpecMP3 : SpecBase
}); });
progress(_S("Indexing PAKs"), _S(""), compIdx++, 1.0); progress(_S("Indexing PAKs"), _S(""), compIdx++, 1.0);
HECL::ProjectPath mp3WorkPath(m_project.getProjectWorkingPath(), "MP3"); HECL::ProjectPath mp3WorkPath(m_project.getProjectWorkingPath(), _S("MP3"));
mp3WorkPath.makeDir(); mp3WorkPath.makeDir();
HECL::ProjectPath outPath(m_project.getProjectWorkingPath(), _S("out"));
outPath.makeDir();
HECL::ProjectPath mp3OutPath(outPath, _S("MP3"));
mp3OutPath.makeDir();
currentTarget = _S("MP3 Root"); currentTarget = _S("MP3 Root");
progress(currentTarget.c_str(), _S(""), compIdx, 0.0); progress(currentTarget.c_str(), _S(""), compIdx, 0.0);
prog = 0; prog = 0;
@ -356,7 +360,7 @@ struct SpecMP3 : SpecBase
// TODO: Make this more granular // TODO: Make this more granular
for (const NOD::Node* node : m_nonPaks) for (const NOD::Node* node : m_nonPaks)
{ {
node->extractToDirectory(mp3WorkPath.getAbsolutePath(), ctx); node->extractToDirectory(mp3OutPath.getAbsolutePath(), ctx);
prog++; prog++;
} }
ctx.progressCB = nullptr; ctx.progressCB = nullptr;
@ -398,6 +402,10 @@ struct SpecMP3 : SpecBase
progress(_S("Indexing PAKs"), _S(""), compIdx++, 1.0); progress(_S("Indexing PAKs"), _S(""), compIdx++, 1.0);
m_feWorkPath.makeDir(); m_feWorkPath.makeDir();
HECL::ProjectPath outPath(m_project.getProjectWorkingPath(), _S("out"));
outPath.makeDir();
HECL::ProjectPath feOutPath(outPath, _S("fe"));
feOutPath.makeDir();
currentTarget = _S("fe Root"); currentTarget = _S("fe Root");
progress(currentTarget.c_str(), _S(""), compIdx, 0.0); progress(currentTarget.c_str(), _S(""), compIdx, 0.0);
prog = 0; prog = 0;
@ -406,7 +414,7 @@ struct SpecMP3 : SpecBase
// TODO: Make this more granular // TODO: Make this more granular
for (const NOD::Node* node : m_feNonPaks) for (const NOD::Node* node : m_feNonPaks)
{ {
node->extractToDirectory(m_feWorkPath.getAbsolutePath(), ctx); node->extractToDirectory(feOutPath.getAbsolutePath(), ctx);
prog++; prog++;
} }
progress(currentTarget.c_str(), _S(""), compIdx++, 1.0); progress(currentTarget.c_str(), _S(""), compIdx++, 1.0);

View File

@ -89,7 +89,7 @@ bool ProjectManager::openProject(const HECL::SystemString& path)
goto makeDefault; goto makeDefault;
yaml_parser_set_input_file(r.getParser(), fp); yaml_parser_set_input_file(r.getParser(), fp);
if (!r.ValidateClassType(r.getParser(), "UrdeSpacesState")) if (!r.ValidateClassType("UrdeSpacesState"))
{ {
fclose(fp); fclose(fp);
goto makeDefault; goto makeDefault;
@ -123,7 +123,9 @@ makeDefault:
m_vm.SetupEditorView(); m_vm.SetupEditorView();
saveProject(); saveProject();
m_vm.m_mainWindow->setTitle(m_proj->getProjectRootPath().getLastComponent()); HECL::SystemString windowTitle(m_proj->getProjectRootPath().getLastComponent());
windowTitle += _S(" - URDE");
m_vm.m_mainWindow->setTitle(windowTitle.c_str());
m_vm.DismissSplash(); m_vm.DismissSplash();
m_vm.FadeInEditors(); m_vm.FadeInEditors();
return true; return true;
@ -158,20 +160,12 @@ bool ProjectManager::saveProject()
Athena::io::YAMLDocWriter w("UrdeSpacesState"); Athena::io::YAMLDocWriter w("UrdeSpacesState");
yaml_emitter_set_output_file(w.getEmitter(), fp); yaml_emitter_set_output_file(w.getEmitter(), fp);
if (!w.open())
{
fclose(fp);
return false;
}
m_vm.SaveEditorView(w); m_vm.SaveEditorView(w);
if (!w.finish()) if (!w.finish())
{ {
fclose(fp); fclose(fp);
return false; return false;
} }
w.close();
fclose(fp); fclose(fp);
HECL::ProjectPath newSpacesPath(*m_proj, _S(".hecl/urde_spaces.yaml")); HECL::ProjectPath newSpacesPath(*m_proj, _S(".hecl/urde_spaces.yaml"));

View File

@ -39,17 +39,11 @@ void ProjectResourceFactory::BuildObjectMap(const HECL::Database::Project::Proje
if (!HECL::StrCmp(spec.spec.m_name, _S("MP3"))) if (!HECL::StrCmp(spec.spec.m_name, _S("MP3")))
{ {
DataSpec::NamedResourceCatalog<DataSpec::UniqueID64> catalog; RecursiveAddDirObjects(spec.cookedPath);
if (catalogFile)
catalog.fromYAMLFile(catalogFile);
RecursiveAddDirObjects(spec.cookedPath, catalog);
} }
else else
{ {
DataSpec::NamedResourceCatalog<DataSpec::UniqueID32> catalog; RecursiveAddDirObjects(spec.cookedPath);
if (catalogFile)
catalog.fromYAMLFile(catalogFile);
RecursiveAddDirObjects(spec.cookedPath, catalog);
} }
} }

View File

@ -13,15 +13,14 @@ class ProjectResourceFactory : public pshag::IFactory
std::unordered_map<std::string, pshag::SObjectTag> m_catalogNameToTag; std::unordered_map<std::string, pshag::SObjectTag> m_catalogNameToTag;
std::unordered_map<std::string, HECL::ProjectPath> m_catalogNameToPath; std::unordered_map<std::string, HECL::ProjectPath> m_catalogNameToPath;
pshag::CFactoryMgr m_factoryMgr; pshag::CFactoryMgr m_factoryMgr;
template <class IDType> void RecursiveAddDirObjects(const HECL::ProjectPath& path)
void RecursiveAddDirObjects(const HECL::ProjectPath& path, const DataSpec::NamedResourceCatalog<IDType>& catalog)
{ {
HECL::DirectoryEnumerator de = path.enumerateDir(); HECL::DirectoryEnumerator de = path.enumerateDir();
const int idLen = 5 + (IDType::BinarySize() * 2); const int idLen = 5 + 8;
for (const HECL::DirectoryEnumerator::Entry& ent : de) for (const HECL::DirectoryEnumerator::Entry& ent : de)
{ {
if (ent.m_isDir) if (ent.m_isDir)
RecursiveAddDirObjects(HECL::ProjectPath(path, ent.m_name), catalog); RecursiveAddDirObjects(HECL::ProjectPath(path, ent.m_name));
if (ent.m_name.size() == idLen && ent.m_name[4] == _S('_')) if (ent.m_name.size() == idLen && ent.m_name[4] == _S('_'))
{ {
HECL::SystemUTF8View entu8(ent.m_name); HECL::SystemUTF8View entu8(ent.m_name);
@ -40,6 +39,7 @@ class ProjectResourceFactory : public pshag::IFactory
} }
else else
{ {
#if 0
HECL::SystemUTF8View nameView(ent.m_name); HECL::SystemUTF8View nameView(ent.m_name);
auto it = std::find_if(catalog.namedResources.begin(), catalog.namedResources.end(), auto it = std::find_if(catalog.namedResources.begin(), catalog.namedResources.end(),
[&nameView](const typename DataSpec::NamedResourceCatalog<IDType>::NamedResource& res) -> bool [&nameView](const typename DataSpec::NamedResourceCatalog<IDType>::NamedResource& res) -> bool
@ -52,10 +52,12 @@ class ProjectResourceFactory : public pshag::IFactory
m_catalogNameToTag[nr.name.c_str()] = objTag; m_catalogNameToTag[nr.name.c_str()] = objTag;
m_tagToPath[objTag] = HECL::ProjectPath(path, ent.m_name); m_tagToPath[objTag] = HECL::ProjectPath(path, ent.m_name);
#endif
} }
} }
} }
#if 0
template <class IDType> template <class IDType>
pshag::SObjectTag GetTag(const DataSpec::NamedResourceCatalog<DataSpec::UniqueID32>::NamedResource &nr, pshag::SObjectTag GetTag(const DataSpec::NamedResourceCatalog<DataSpec::UniqueID32>::NamedResource &nr,
typename std::enable_if<std::is_same<IDType, DataSpec::UniqueID32>::value>::type* = 0) typename std::enable_if<std::is_same<IDType, DataSpec::UniqueID32>::value>::type* = 0)
@ -65,6 +67,7 @@ class ProjectResourceFactory : public pshag::IFactory
pshag::SObjectTag GetTag(const typename DataSpec::NamedResourceCatalog<IDType>::NamedResource& nr, pshag::SObjectTag GetTag(const typename DataSpec::NamedResourceCatalog<IDType>::NamedResource& nr,
typename std::enable_if<std::is_same<IDType, DataSpec::UniqueID64>::value>::type* = 0) typename std::enable_if<std::is_same<IDType, DataSpec::UniqueID64>::value>::type* = 0)
{ return { nr.type, nr.uid.toUint64() }; } { return { nr.type, nr.uid.toUint64() }; }
#endif
public: public:
ProjectResourceFactory(); ProjectResourceFactory();

2
hecl

@ -1 +1 @@
Subproject commit 82333be06ce889bdb78986ba0137f17832366c45 Subproject commit f33c1774196a2648599b57dd3638b415dc6c77e5