2
0
mirror of https://github.com/AxioDL/metaforce.git synced 2025-12-09 21:07:42 +00:00
This commit is contained in:
2016-03-28 17:08:05 -07:00
12 changed files with 259 additions and 58 deletions

View File

@@ -626,12 +626,15 @@ struct VEConstant : IVectorElement
void read(athena::io::YAMLDocReader& r)
{
for (int i=0 ; i<3 ; ++i)
size_t elemCount;
r.enterSubVector(nullptr, elemCount);
for (int i=0 ; i<3 && i<elemCount ; ++i)
{
r.enterSubRecord(nullptr);
comps[i].read(r);
r.leaveSubRecord();
}
r.leaveSubVector();
}
void write(athena::io::YAMLDocWriter& w) const
{

View File

@@ -79,6 +79,13 @@ struct STRG : ISTRG
return true;
}
static bool Cook(const STRG& strg, const hecl::ProjectPath& outPath)
{
athena::io::FileWriter ws(outPath.getAbsolutePath());
strg.write(ws);
return true;
}
};
}

View File

@@ -33,8 +33,8 @@ static const hecl::SystemChar* MomErr[] =
};
constexpr uint32_t MomErrCount = std::extent<decltype(MomErr)>::value;
SpecBase::SpecBase(hecl::Database::Project& project, bool pc)
: m_project(project), m_pc(pc),
SpecBase::SpecBase(const hecl::Database::DataSpecEntry* specEntry, hecl::Database::Project& project, bool pc)
: hecl::Database::IDataSpec(specEntry), m_project(project), m_pc(pc),
m_masterShader(project.getProjectWorkingPath(), ".hecl/RetroMasterShader.blend") {}
bool SpecBase::canExtract(const ExtractPassInfo& info, std::vector<ExtractReport>& reps)
@@ -114,13 +114,13 @@ void SpecBase::doExtract(const ExtractPassInfo& info, FProgress progress)
extractFromDisc(*m_disc, info.force, progress);
}
bool SpecBase::canCook(const hecl::ProjectPath& path)
bool SpecBase::canCook(const hecl::ProjectPath& path, hecl::BlenderToken& btok)
{
if (!checkPathPrefix(path))
return false;
if (hecl::IsPathBlend(path))
{
hecl::BlenderConnection& conn = hecl::BlenderConnection::SharedConnection();
hecl::BlenderConnection& conn = btok.getBlenderConnection();
if (!conn.openBlend(path))
return false;
if (conn.getBlendType() != hecl::BlenderConnection::BlendType::None)
@@ -141,13 +141,14 @@ bool SpecBase::canCook(const hecl::ProjectPath& path)
}
const hecl::Database::DataSpecEntry* SpecBase::overrideDataSpec(const hecl::ProjectPath& path,
const hecl::Database::DataSpecEntry* oldEntry)
const hecl::Database::DataSpecEntry* oldEntry,
hecl::BlenderToken& btok)
{
if (!checkPathPrefix(path))
return nullptr;
if (hecl::IsPathBlend(path))
{
hecl::BlenderConnection& conn = hecl::BlenderConnection::SharedConnection();
hecl::BlenderConnection& conn = btok.getBlenderConnection();
if (!conn.openBlend(path))
{
Log.report(logvisor::Error, _S("unable to cook '%s'"),
@@ -167,12 +168,12 @@ const hecl::Database::DataSpecEntry* SpecBase::overrideDataSpec(const hecl::Proj
}
void SpecBase::doCook(const hecl::ProjectPath& path, const hecl::ProjectPath& cookedPath,
bool fast, FCookProgress progress)
bool fast, hecl::BlenderToken& btok, FCookProgress progress)
{
DataSpec::g_curSpec = this;
if (hecl::IsPathBlend(path))
{
hecl::BlenderConnection& conn = hecl::BlenderConnection::SharedConnection();
hecl::BlenderConnection& conn = btok.getBlenderConnection();
if (!conn.openBlend(path))
return;
switch (conn.getBlendType())
@@ -209,6 +210,7 @@ void SpecBase::doCook(const hecl::ProjectPath& path, const hecl::ProjectPath& co
{
FILE* fp = hecl::Fopen(path.getAbsolutePath().c_str(), _S("r"));
cookYAML(cookedPath, path, fp, progress);
fclose(fp);
}
}

View File

@@ -16,11 +16,12 @@ struct SpecBase : hecl::Database::IDataSpec
bool canExtract(const ExtractPassInfo& info, std::vector<ExtractReport>& reps);
void doExtract(const ExtractPassInfo& info, FProgress progress);
bool canCook(const hecl::ProjectPath& path);
bool canCook(const hecl::ProjectPath& path, hecl::BlenderToken& btok);
const hecl::Database::DataSpecEntry* overrideDataSpec(const hecl::ProjectPath& path,
const hecl::Database::DataSpecEntry* oldEntry);
const hecl::Database::DataSpecEntry* oldEntry,
hecl::BlenderToken& btok);
void doCook(const hecl::ProjectPath& path, const hecl::ProjectPath& cookedPath,
bool fast, FCookProgress progress);
bool fast, hecl::BlenderToken& btok, FCookProgress progress);
bool canPackage(const PackagePassInfo& info);
void gatherDependencies(const PackagePassInfo& info,
@@ -72,7 +73,7 @@ struct SpecBase : hecl::Database::IDataSpec
/* Project accessor */
hecl::Database::Project& getProject() const {return m_project;}
SpecBase(hecl::Database::Project& project, bool pc);
SpecBase(const hecl::Database::DataSpecEntry* specEntry, hecl::Database::Project& project, bool pc);
protected:
hecl::Database::Project& m_project;
bool m_pc;

View File

@@ -9,6 +9,7 @@
#include "DNAMP1/STRG.hpp"
#include "DNAMP1/CMDL.hpp"
#include "DNAMP1/ANCS.hpp"
#include "DNACommon/PART.hpp"
namespace DataSpec
{
@@ -33,8 +34,8 @@ struct SpecMP1 : SpecBase
hecl::ProjectPath m_cookPath;
PAKRouter<DNAMP1::PAKBridge> m_pakRouter;
SpecMP1(hecl::Database::Project& project, bool pc)
: SpecBase(project, pc),
SpecMP1(const hecl::Database::DataSpecEntry* specEntry, hecl::Database::Project& project, bool pc)
: SpecBase(specEntry, project, pc),
m_workPath(project.getProjectWorkingPath(), _S("MP1")),
m_cookPath(project.getProjectCookedPath(SpecEntMP1), _S("MP1")),
m_pakRouter(*this, m_workPath, m_cookPath) {}
@@ -286,11 +287,18 @@ struct SpecMP1 : SpecBase
bool validateYAMLDNAType(FILE* fp) const
{
if (BigYAML::ValidateFromYAMLFile<DNAMP1::MLVL>(fp))
return true;
if (BigYAML::ValidateFromYAMLFile<DNAMP1::STRG>(fp))
return true;
return false;
athena::io::YAMLDocReader reader;
yaml_parser_set_input_file(reader.getParser(), fp);
return reader.ClassTypeOperation([](const char* classType)
{
if (!strcmp(classType, DNAMP1::MLVL::DNAType()))
return true;
else if (!strcmp(classType, DNAMP1::STRG::DNAType()))
return true;
else if (!strcmp(classType, DNAParticle::GPSM<UniqueID32>::DNAType()))
return true;
return false;
});
}
void cookMesh(const hecl::ProjectPath& out, const hecl::ProjectPath& in,
@@ -319,6 +327,27 @@ struct SpecMP1 : SpecBase
void cookYAML(const hecl::ProjectPath& out, const hecl::ProjectPath& in,
FILE* fin, FCookProgress progress) const
{
athena::io::YAMLDocReader reader;
yaml_parser_set_input_file(reader.getParser(), fin);
if (reader.parse())
{
std::string classStr = reader.readString("DNAType");
if (classStr.empty())
return;
if (!classStr.compare(DNAMP1::STRG::DNAType()))
{
DNAMP1::STRG strg;
strg.read(reader);
DNAMP1::STRG::Cook(strg, out);
}
else if (!classStr.compare(DNAParticle::GPSM<UniqueID32>::DNAType()))
{
DNAParticle::GPSM<UniqueID32> gpsm;
gpsm.read(reader);
DNAParticle::WriteGPSM(gpsm, out);
}
}
}
};
@@ -327,7 +356,7 @@ hecl::Database::DataSpecEntry SpecEntMP1 =
_S("MP1"),
_S("Data specification for original Metroid Prime engine"),
[](hecl::Database::Project& project, hecl::Database::DataSpecTool)
-> hecl::Database::IDataSpec* {return new struct SpecMP1(project, false);}
-> hecl::Database::IDataSpec* {return new struct SpecMP1(&SpecEntMP1, project, false);}
};
hecl::Database::DataSpecEntry SpecEntMP1PC =
@@ -338,7 +367,7 @@ hecl::Database::DataSpecEntry SpecEntMP1PC =
-> hecl::Database::IDataSpec*
{
if (tool != hecl::Database::DataSpecTool::Extract)
return new struct SpecMP1(project, true);
return new struct SpecMP1(&SpecEntMP1PC, project, true);
return nullptr;
}
};

View File

@@ -29,8 +29,8 @@ struct SpecMP2 : SpecBase
hecl::ProjectPath m_cookPath;
PAKRouter<DNAMP2::PAKBridge> m_pakRouter;
SpecMP2(hecl::Database::Project& project, bool pc)
: SpecBase(project, pc),
SpecMP2(const hecl::Database::DataSpecEntry* specEntry, hecl::Database::Project& project, bool pc)
: SpecBase(specEntry, project, pc),
m_workPath(project.getProjectWorkingPath(), _S("MP2")),
m_cookPath(project.getProjectCookedPath(SpecEntMP2), _S("MP2")),
m_pakRouter(*this, m_workPath, m_cookPath) {}
@@ -307,7 +307,7 @@ hecl::Database::DataSpecEntry SpecEntMP2
_S("MP2"),
_S("Data specification for original Metroid Prime 2 engine"),
[](hecl::Database::Project& project, hecl::Database::DataSpecTool)
-> hecl::Database::IDataSpec* {return new struct SpecMP2(project, false);}
-> hecl::Database::IDataSpec* {return new struct SpecMP2(&SpecEntMP2, project, false);}
);
hecl::Database::DataSpecEntry SpecEntMP2PC =
@@ -318,7 +318,7 @@ hecl::Database::DataSpecEntry SpecEntMP2PC =
-> hecl::Database::IDataSpec*
{
if (tool != hecl::Database::DataSpecTool::Extract)
return new struct SpecMP2(project, true);
return new struct SpecMP2(&SpecEntMP2PC, project, true);
return nullptr;
}
};

View File

@@ -42,8 +42,8 @@ struct SpecMP3 : SpecBase
hecl::ProjectPath m_feCookPath;
PAKRouter<DNAMP3::PAKBridge> m_fePakRouter;
SpecMP3(hecl::Database::Project& project, bool pc)
: SpecBase(project, pc),
SpecMP3(const hecl::Database::DataSpecEntry* specEntry, hecl::Database::Project& project, bool pc)
: SpecBase(specEntry, project, pc),
m_workPath(project.getProjectWorkingPath(), _S("MP3")),
m_cookPath(project.getProjectCookedPath(SpecEntMP3), _S("MP3")),
m_pakRouter(*this, m_workPath, m_cookPath),
@@ -491,7 +491,7 @@ hecl::Database::DataSpecEntry SpecEntMP3
_S("MP3"),
_S("Data specification for original Metroid Prime 3 engine"),
[](hecl::Database::Project& project, hecl::Database::DataSpecTool)
-> hecl::Database::IDataSpec* {return new struct SpecMP3(project, false);}
-> hecl::Database::IDataSpec* {return new struct SpecMP3(&SpecEntMP3, project, false);}
);
hecl::Database::DataSpecEntry SpecEntMP3PC =
@@ -502,7 +502,7 @@ hecl::Database::DataSpecEntry SpecEntMP3PC =
-> hecl::Database::IDataSpec*
{
if (tool != hecl::Database::DataSpecTool::Extract)
return new struct SpecMP3(project, true);
return new struct SpecMP3(&SpecEntMP3PC, project, true);
return nullptr;
}
};