2015-07-07 03:22:44 +00:00
|
|
|
#include <utility>
|
2017-12-29 08:08:12 +00:00
|
|
|
#include <cstdio>
|
|
|
|
#include <cstring>
|
2015-07-07 03:22:44 +00:00
|
|
|
|
2015-07-01 23:50:39 +00:00
|
|
|
#include "SpecBase.hpp"
|
2015-07-17 00:01:05 +00:00
|
|
|
#include "DNAMP1/DNAMP1.hpp"
|
2015-07-01 23:50:39 +00:00
|
|
|
|
2016-09-10 04:50:00 +00:00
|
|
|
#include "DNAMP1/HINT.hpp"
|
2015-10-01 00:40:21 +00:00
|
|
|
#include "DNAMP1/MLVL.hpp"
|
|
|
|
#include "DNAMP1/STRG.hpp"
|
2017-01-31 11:21:45 +00:00
|
|
|
#include "DNAMP1/SCAN.hpp"
|
2015-10-07 01:17:17 +00:00
|
|
|
#include "DNAMP1/CMDL.hpp"
|
2017-10-17 05:51:53 +00:00
|
|
|
#include "DNAMP1/DCLN.hpp"
|
2016-08-10 02:52:00 +00:00
|
|
|
#include "DNAMP1/MREA.hpp"
|
2015-10-23 00:45:26 +00:00
|
|
|
#include "DNAMP1/ANCS.hpp"
|
2016-09-18 23:47:48 +00:00
|
|
|
#include "DNAMP1/AGSC.hpp"
|
|
|
|
#include "DNAMP1/CSNG.hpp"
|
2017-03-20 05:09:53 +00:00
|
|
|
#include "DNAMP1/MAPA.hpp"
|
2018-02-25 08:23:27 +00:00
|
|
|
#include "DNAMP1/PATH.hpp"
|
2018-03-28 08:09:41 +00:00
|
|
|
#include "DNAMP1/FRME.hpp"
|
2018-04-07 20:55:57 +00:00
|
|
|
#include "DNAMP1/AFSM.hpp"
|
2017-01-21 02:38:34 +00:00
|
|
|
#include "DNACommon/ATBL.hpp"
|
2016-08-17 05:40:25 +00:00
|
|
|
#include "DNACommon/FONT.hpp"
|
2016-03-28 21:38:48 +00:00
|
|
|
#include "DNACommon/PART.hpp"
|
2016-03-29 02:24:47 +00:00
|
|
|
#include "DNACommon/SWHC.hpp"
|
|
|
|
#include "DNACommon/ELSC.hpp"
|
|
|
|
#include "DNACommon/WPSC.hpp"
|
|
|
|
#include "DNACommon/CRSC.hpp"
|
|
|
|
#include "DNACommon/DPSC.hpp"
|
2016-04-12 11:37:07 +00:00
|
|
|
#include "DNACommon/DGRP.hpp"
|
2017-03-20 05:09:53 +00:00
|
|
|
#include "DNACommon/MAPU.hpp"
|
2021-04-10 08:42:06 +00:00
|
|
|
#include "DNACommon/MetaforceVersionInfo.hpp"
|
2016-08-31 19:58:21 +00:00
|
|
|
#include "DNACommon/Tweaks/TweakWriter.hpp"
|
|
|
|
#include "DNAMP1/Tweaks/CTweakPlayerRes.hpp"
|
2016-08-31 21:00:06 +00:00
|
|
|
#include "DNAMP1/Tweaks/CTweakGunRes.hpp"
|
2016-09-16 20:18:03 +00:00
|
|
|
#include "DNAMP1/Tweaks/CTweakSlideShow.hpp"
|
2016-09-15 07:26:35 +00:00
|
|
|
#include "DNAMP1/Tweaks/CTweakPlayer.hpp"
|
|
|
|
#include "DNAMP1/Tweaks/CTweakCameraBob.hpp"
|
2017-01-22 01:40:12 +00:00
|
|
|
#include "DNAMP1/Tweaks/CTweakGame.hpp"
|
2017-01-26 10:06:18 +00:00
|
|
|
#include "DNAMP1/Tweaks/CTweakTargeting.hpp"
|
|
|
|
#include "DNAMP1/Tweaks/CTweakAutoMapper.hpp"
|
|
|
|
#include "DNAMP1/Tweaks/CTweakGui.hpp"
|
|
|
|
#include "DNAMP1/Tweaks/CTweakPlayerControl.hpp"
|
|
|
|
#include "DNAMP1/Tweaks/CTweakBall.hpp"
|
|
|
|
#include "DNAMP1/Tweaks/CTweakParticle.hpp"
|
|
|
|
#include "DNAMP1/Tweaks/CTweakGuiColors.hpp"
|
2017-01-27 02:58:21 +00:00
|
|
|
#include "DNAMP1/Tweaks/CTweakPlayerGun.hpp"
|
2017-05-22 11:24:24 +00:00
|
|
|
#include "DNAMP1/MazeSeeds.hpp"
|
|
|
|
#include "DNAMP1/SnowForces.hpp"
|
2016-04-01 04:25:00 +00:00
|
|
|
#include "hecl/ClientProcess.hpp"
|
2018-03-23 21:56:17 +00:00
|
|
|
#include "hecl/MultiProgressPrinter.hpp"
|
2017-12-29 08:08:12 +00:00
|
|
|
#include "hecl/Blender/Connection.hpp"
|
2018-10-22 09:29:44 +00:00
|
|
|
#include "hecl/Blender/SDNARead.hpp"
|
2017-12-29 08:08:12 +00:00
|
|
|
#include "nod/nod.hpp"
|
2016-04-01 04:25:00 +00:00
|
|
|
|
2018-12-08 05:30:43 +00:00
|
|
|
namespace DataSpec {
|
2015-07-01 23:50:39 +00:00
|
|
|
|
2017-11-13 06:19:18 +00:00
|
|
|
using namespace std::literals;
|
|
|
|
|
2021-04-10 13:37:03 +00:00
|
|
|
static logvisor::Module Log("DataSpec::SpecMP1");
|
2016-03-04 23:04:53 +00:00
|
|
|
extern hecl::Database::DataSpecEntry SpecEntMP1;
|
2016-04-10 04:49:02 +00:00
|
|
|
extern hecl::Database::DataSpecEntry SpecEntMP1PC;
|
2017-01-17 01:23:19 +00:00
|
|
|
extern hecl::Database::DataSpecEntry SpecEntMP1ORIG;
|
2015-07-16 01:57:34 +00:00
|
|
|
|
2019-08-03 23:44:52 +00:00
|
|
|
struct TextureCache {
|
2020-04-15 07:56:59 +00:00
|
|
|
static void Generate(PAKRouter<DNAMP1::PAKBridge>& pakRouter, hecl::Database::Project& project,
|
|
|
|
const hecl::ProjectPath& pakPath) {
|
2019-12-03 08:47:05 +00:00
|
|
|
hecl::ProjectPath texturePath(pakPath, _SYS_STR("texture_cache.yaml"));
|
|
|
|
hecl::ProjectPath catalogPath(pakPath, _SYS_STR("!catalog.yaml"));
|
2020-04-11 07:53:04 +00:00
|
|
|
texturePath.makeDirChain(false);
|
2019-12-03 08:47:05 +00:00
|
|
|
|
|
|
|
if (const auto fp = hecl::FopenUnique(catalogPath.getAbsolutePath().data(), _SYS_STR("a"))) {
|
2020-04-11 22:51:39 +00:00
|
|
|
fmt::print(fp.get(), FMT_STRING("TextureCache: {}\n"), texturePath.getRelativePathUTF8());
|
2019-12-03 08:47:05 +00:00
|
|
|
}
|
|
|
|
|
2020-04-11 22:51:39 +00:00
|
|
|
Log.report(logvisor::Level::Info, FMT_STRING("Gathering Texture metadata (this can take up to 10 seconds)..."));
|
2019-08-03 23:44:52 +00:00
|
|
|
std::unordered_map<UniqueID32, TXTR::Meta> metaMap;
|
|
|
|
|
|
|
|
pakRouter.enumerateResources([&](const DNAMP1::PAK::Entry* ent) {
|
|
|
|
if (ent->type == FOURCC('TXTR') && metaMap.find(ent->id) == metaMap.end()) {
|
|
|
|
PAKEntryReadStream rs = pakRouter.beginReadStreamForId(ent->id);
|
|
|
|
metaMap[ent->id] = TXTR::GetMetaData(rs);
|
|
|
|
}
|
|
|
|
return true;
|
|
|
|
});
|
|
|
|
|
|
|
|
athena::io::YAMLDocWriter yamlW("MP1TextureCache");
|
|
|
|
for (const auto& pair : metaMap) {
|
|
|
|
hecl::ProjectPath path = pakRouter.getWorking(pair.first);
|
2019-10-01 07:38:03 +00:00
|
|
|
auto rec = yamlW.enterSubRecord(path.getRelativePathUTF8());
|
2019-08-03 23:44:52 +00:00
|
|
|
pair.second.write(yamlW);
|
|
|
|
}
|
|
|
|
|
2019-12-03 08:47:05 +00:00
|
|
|
athena::io::FileWriter fileW(texturePath.getAbsolutePath());
|
2019-08-03 23:44:52 +00:00
|
|
|
yamlW.finish(&fileW);
|
2020-04-11 22:51:39 +00:00
|
|
|
Log.report(logvisor::Level::Info, FMT_STRING("Done..."));
|
2019-08-09 21:55:59 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void Cook(const hecl::ProjectPath& inPath, const hecl::ProjectPath& outPath) {
|
|
|
|
hecl::Database::Project& project = inPath.getProject();
|
|
|
|
athena::io::YAMLDocReader r;
|
|
|
|
athena::io::FileReader fr(inPath.getAbsolutePath());
|
|
|
|
if (!fr.isOpen() || !r.parse(&fr))
|
|
|
|
return;
|
|
|
|
|
|
|
|
std::vector<std::pair<UniqueID32, TXTR::Meta>> metaPairs;
|
|
|
|
metaPairs.reserve(r.getRootNode()->m_mapChildren.size());
|
|
|
|
for (const auto& node : r.getRootNode()->m_mapChildren) {
|
|
|
|
hecl::ProjectPath projectPath(project, node.first);
|
|
|
|
auto rec = r.enterSubRecord(node.first.c_str());
|
|
|
|
TXTR::Meta meta;
|
|
|
|
meta.read(r);
|
2020-03-31 16:40:34 +00:00
|
|
|
metaPairs.emplace_back(projectPath.parsedHash32(), meta);
|
2019-08-09 21:55:59 +00:00
|
|
|
}
|
|
|
|
|
2020-04-15 07:56:59 +00:00
|
|
|
std::sort(metaPairs.begin(), metaPairs.end(),
|
|
|
|
[](const auto& a, const auto& b) -> bool { return a.first < b.first; });
|
2019-08-09 21:55:59 +00:00
|
|
|
|
|
|
|
athena::io::FileWriter w(outPath.getAbsolutePath());
|
|
|
|
w.writeUint32Big(metaPairs.size());
|
|
|
|
for (const auto& pair : metaPairs) {
|
|
|
|
pair.first.write(w);
|
|
|
|
pair.second.write(w);
|
|
|
|
}
|
2019-08-03 23:44:52 +00:00
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2018-12-08 05:30:43 +00:00
|
|
|
struct SpecMP1 : SpecBase {
|
2019-08-10 02:32:48 +00:00
|
|
|
bool checkStandaloneID(const char* id) const override { return !memcmp(id, "GM8", 3); }
|
2018-12-08 05:30:43 +00:00
|
|
|
|
|
|
|
std::vector<const nod::Node*> m_nonPaks;
|
|
|
|
std::vector<DNAMP1::PAKBridge> m_paks;
|
|
|
|
std::map<std::string, DNAMP1::PAKBridge*, hecl::CaseInsensitiveCompare> m_orderedPaks;
|
|
|
|
|
|
|
|
hecl::ProjectPath m_workPath;
|
|
|
|
hecl::ProjectPath m_cookPath;
|
|
|
|
PAKRouter<DNAMP1::PAKBridge> m_pakRouter;
|
|
|
|
|
|
|
|
std::unique_ptr<uint8_t[]> m_dolBuf;
|
|
|
|
|
|
|
|
std::unordered_map<hecl::Hash, hecl::blender::Matrix4f> m_mreaPathToXF;
|
|
|
|
|
|
|
|
SpecMP1(const hecl::Database::DataSpecEntry* specEntry, hecl::Database::Project& project, bool pc)
|
|
|
|
: SpecBase(specEntry, project, pc)
|
|
|
|
, m_workPath(project.getProjectWorkingPath(), _SYS_STR("MP1"))
|
|
|
|
, m_cookPath(project.getProjectCookedPath(SpecEntMP1), _SYS_STR("MP1"))
|
2019-10-01 07:38:03 +00:00
|
|
|
, m_pakRouter(*this, m_workPath, m_cookPath) {
|
2020-04-15 13:42:44 +00:00
|
|
|
m_game = EGame::MetroidPrime1;
|
|
|
|
SpecBase::setThreadProject();
|
2018-12-08 05:30:43 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void buildPaks(nod::Node& root, const std::vector<hecl::SystemString>& args, ExtractReport& rep) {
|
|
|
|
m_nonPaks.clear();
|
|
|
|
m_paks.clear();
|
|
|
|
for (const nod::Node& child : root) {
|
|
|
|
bool isPak = false;
|
|
|
|
auto name = child.getName();
|
|
|
|
std::string lowerName(name);
|
|
|
|
std::transform(lowerName.begin(), lowerName.end(), lowerName.begin(), tolower);
|
|
|
|
if (name.size() > 4) {
|
|
|
|
std::string::iterator extit = lowerName.end() - 4;
|
2019-10-01 07:38:03 +00:00
|
|
|
if (std::string(extit, lowerName.end()) == ".pak") {
|
2018-12-08 05:30:43 +00:00
|
|
|
/* This is a pak */
|
|
|
|
isPak = true;
|
|
|
|
std::string lowerBase(lowerName.begin(), extit);
|
|
|
|
|
|
|
|
/* Needs filter */
|
|
|
|
bool good = true;
|
|
|
|
if (args.size()) {
|
|
|
|
good = false;
|
|
|
|
if (!lowerName.compare(0, 7, "metroid")) {
|
|
|
|
hecl::SystemChar idxChar = lowerName[7];
|
|
|
|
for (const hecl::SystemString& arg : args) {
|
|
|
|
if (arg.size() == 1 && iswdigit(arg[0]))
|
|
|
|
if (arg[0] == idxChar)
|
|
|
|
good = true;
|
|
|
|
}
|
|
|
|
} else
|
|
|
|
good = true;
|
|
|
|
|
|
|
|
if (!good) {
|
|
|
|
for (const hecl::SystemString& arg : args) {
|
|
|
|
std::string lowerArg(hecl::SystemUTF8Conv(arg).str());
|
|
|
|
std::transform(lowerArg.begin(), lowerArg.end(), lowerArg.begin(), tolower);
|
|
|
|
if (!lowerArg.compare(0, lowerBase.size(), lowerBase))
|
|
|
|
good = true;
|
|
|
|
}
|
2015-07-07 03:22:44 +00:00
|
|
|
}
|
2018-12-08 05:30:43 +00:00
|
|
|
}
|
2015-07-18 04:33:38 +00:00
|
|
|
|
2018-12-08 05:30:43 +00:00
|
|
|
m_paks.emplace_back(child, good);
|
2015-07-10 05:28:08 +00:00
|
|
|
}
|
2018-12-08 05:30:43 +00:00
|
|
|
}
|
2015-07-10 05:28:08 +00:00
|
|
|
|
2018-12-08 05:30:43 +00:00
|
|
|
if (!isPak)
|
|
|
|
m_nonPaks.push_back(&child);
|
2015-07-01 23:50:39 +00:00
|
|
|
}
|
2015-07-12 18:07:58 +00:00
|
|
|
|
2018-12-08 05:30:43 +00:00
|
|
|
/* Sort PAKs alphabetically */
|
|
|
|
m_orderedPaks.clear();
|
2020-04-15 13:42:44 +00:00
|
|
|
for (DNAMP1::PAKBridge& dpak : m_paks) {
|
2018-12-08 05:30:43 +00:00
|
|
|
m_orderedPaks[std::string(dpak.getName())] = &dpak;
|
2020-04-15 13:42:44 +00:00
|
|
|
}
|
2018-12-08 05:30:43 +00:00
|
|
|
|
|
|
|
/* Assemble extract report */
|
|
|
|
rep.childOpts.reserve(m_orderedPaks.size());
|
2020-03-31 16:36:15 +00:00
|
|
|
for (const auto& item : m_orderedPaks) {
|
|
|
|
if (!item.second->m_doExtract) {
|
2018-12-08 05:30:43 +00:00
|
|
|
continue;
|
2020-03-31 16:36:15 +00:00
|
|
|
}
|
2020-03-31 16:38:28 +00:00
|
|
|
|
|
|
|
ExtractReport& childRep = rep.childOpts.emplace_back();
|
2018-12-08 05:30:43 +00:00
|
|
|
hecl::SystemStringConv nameView(item.first);
|
|
|
|
childRep.name = nameView.sys_str();
|
|
|
|
childRep.desc = item.second->getLevelString();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
bool checkFromStandaloneDisc(nod::DiscBase& disc, const hecl::SystemString& regstr,
|
2019-08-10 02:32:48 +00:00
|
|
|
const std::vector<hecl::SystemString>& args, std::vector<ExtractReport>& reps) override {
|
2018-12-08 05:30:43 +00:00
|
|
|
nod::IPartition* partition = disc.getDataPartition();
|
|
|
|
m_dolBuf = partition->getDOLBuf();
|
2020-04-15 13:42:44 +00:00
|
|
|
const char* buildInfo =
|
|
|
|
static_cast<char*>(memmem(m_dolBuf.get(), partition->getDOLSize(), "MetroidBuildInfo", 16)) + 19;
|
2018-12-08 05:30:43 +00:00
|
|
|
|
2020-04-15 13:42:44 +00:00
|
|
|
if (buildInfo == nullptr)
|
2018-12-08 05:30:43 +00:00
|
|
|
return false;
|
|
|
|
|
2020-04-15 07:56:59 +00:00
|
|
|
m_version = std::string(buildInfo);
|
2018-12-08 05:30:43 +00:00
|
|
|
/* Root Report */
|
2020-03-31 16:38:28 +00:00
|
|
|
ExtractReport& rep = reps.emplace_back();
|
2018-12-08 05:30:43 +00:00
|
|
|
rep.name = _SYS_STR("MP1");
|
|
|
|
rep.desc = _SYS_STR("Metroid Prime ") + regstr;
|
|
|
|
if (buildInfo) {
|
2020-04-15 07:56:59 +00:00
|
|
|
hecl::SystemStringConv buildView(m_version);
|
2018-12-08 05:30:43 +00:00
|
|
|
rep.desc += _SYS_STR(" (") + buildView + _SYS_STR(")");
|
|
|
|
}
|
2015-09-24 07:47:30 +00:00
|
|
|
|
2018-12-08 05:30:43 +00:00
|
|
|
/* Iterate PAKs and build level options */
|
|
|
|
nod::Node& root = partition->getFSTRoot();
|
|
|
|
buildPaks(root, args, rep);
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool checkFromTrilogyDisc(nod::DiscBase& disc, const hecl::SystemString& regstr,
|
2019-08-10 02:32:48 +00:00
|
|
|
const std::vector<hecl::SystemString>& args, std::vector<ExtractReport>& reps) override {
|
2018-12-08 05:30:43 +00:00
|
|
|
std::vector<hecl::SystemString> mp1args;
|
|
|
|
bool doExtract = false;
|
|
|
|
if (args.size()) {
|
|
|
|
/* Needs filter */
|
|
|
|
for (const hecl::SystemString& arg : args) {
|
|
|
|
hecl::SystemString lowerArg = arg;
|
|
|
|
hecl::ToLower(lowerArg);
|
|
|
|
if (!lowerArg.compare(0, 3, _SYS_STR("mp1"))) {
|
|
|
|
doExtract = true;
|
|
|
|
mp1args.reserve(args.size());
|
|
|
|
size_t slashPos = arg.find(_SYS_STR('/'));
|
|
|
|
if (slashPos == hecl::SystemString::npos)
|
|
|
|
slashPos = arg.find(_SYS_STR('\\'));
|
|
|
|
if (slashPos != hecl::SystemString::npos)
|
|
|
|
mp1args.emplace_back(hecl::SystemString(arg.begin() + slashPos + 1, arg.end()));
|
2015-07-13 06:29:12 +00:00
|
|
|
}
|
2018-12-08 05:30:43 +00:00
|
|
|
}
|
|
|
|
} else
|
|
|
|
doExtract = true;
|
|
|
|
|
|
|
|
if (!doExtract)
|
|
|
|
return false;
|
|
|
|
|
|
|
|
nod::IPartition* partition = disc.getDataPartition();
|
|
|
|
nod::Node& root = partition->getFSTRoot();
|
|
|
|
nod::Node::DirectoryIterator dolIt = root.find("rs5mp1_p.dol");
|
|
|
|
if (dolIt == root.end()) {
|
|
|
|
dolIt = root.find("rs5mp1jpn_p.dol");
|
|
|
|
if (dolIt == root.end())
|
|
|
|
return false;
|
|
|
|
}
|
2015-07-12 18:07:58 +00:00
|
|
|
|
2018-12-08 05:30:43 +00:00
|
|
|
m_dolBuf = dolIt->getBuf();
|
2020-04-15 13:42:44 +00:00
|
|
|
const char* buildInfo = static_cast<char*>(memmem(m_dolBuf.get(), dolIt->size(), "MetroidBuildInfo", 16)) + 19;
|
2018-12-08 05:30:43 +00:00
|
|
|
|
|
|
|
/* Root Report */
|
2020-03-31 16:38:28 +00:00
|
|
|
ExtractReport& rep = reps.emplace_back();
|
2018-12-08 05:30:43 +00:00
|
|
|
rep.name = _SYS_STR("MP1");
|
|
|
|
rep.desc = _SYS_STR("Metroid Prime ") + regstr;
|
2020-04-15 13:42:44 +00:00
|
|
|
if (buildInfo != nullptr) {
|
|
|
|
m_version = std::string(buildInfo);
|
|
|
|
hecl::SystemStringConv buildView(m_version);
|
2018-12-08 05:30:43 +00:00
|
|
|
rep.desc += _SYS_STR(" (") + buildView + _SYS_STR(")");
|
|
|
|
}
|
2015-07-12 18:07:58 +00:00
|
|
|
|
2018-12-08 05:30:43 +00:00
|
|
|
/* Iterate PAKs and build level options */
|
|
|
|
nod::Node::DirectoryIterator mp1It = root.find("MP1");
|
|
|
|
if (mp1It == root.end()) {
|
|
|
|
mp1It = root.find("MP1JPN");
|
|
|
|
if (mp1It == root.end())
|
|
|
|
return false;
|
2015-07-01 23:50:39 +00:00
|
|
|
}
|
2018-12-08 05:30:43 +00:00
|
|
|
buildPaks(*mp1It, mp1args, rep);
|
2015-07-01 23:50:39 +00:00
|
|
|
|
2018-12-08 05:30:43 +00:00
|
|
|
return true;
|
|
|
|
}
|
2015-07-18 04:33:38 +00:00
|
|
|
|
2019-08-10 02:32:48 +00:00
|
|
|
bool extractFromDisc(nod::DiscBase& disc, bool force, const hecl::MultiProgressPrinter& progress) override {
|
2018-12-08 05:30:43 +00:00
|
|
|
m_project.enableDataSpecs({_SYS_STR("MP1-PC")});
|
2015-07-13 06:29:12 +00:00
|
|
|
|
2018-12-08 05:30:43 +00:00
|
|
|
nod::ExtractionContext ctx = {force, nullptr};
|
2015-07-13 06:29:12 +00:00
|
|
|
|
2018-12-08 05:30:43 +00:00
|
|
|
m_workPath.makeDir();
|
2015-07-13 06:29:12 +00:00
|
|
|
|
2018-12-08 05:30:43 +00:00
|
|
|
progress.startNewLine();
|
|
|
|
progress.print(_SYS_STR("Indexing PAKs"), _SYS_STR(""), 0.0);
|
|
|
|
m_pakRouter.build(m_paks,
|
|
|
|
[&progress](float factor) { progress.print(_SYS_STR("Indexing PAKs"), _SYS_STR(""), factor); });
|
|
|
|
progress.print(_SYS_STR("Indexing PAKs"), _SYS_STR(""), 1.0);
|
2015-07-13 06:29:12 +00:00
|
|
|
|
2018-12-08 05:30:43 +00:00
|
|
|
hecl::ProjectPath outPath(m_project.getProjectWorkingPath(), _SYS_STR("out"));
|
|
|
|
outPath.makeDir();
|
|
|
|
disc.getDataPartition()->extractSysFiles(outPath.getAbsolutePath(), ctx);
|
2021-02-26 09:35:54 +00:00
|
|
|
hecl::ProjectPath mp1OutPath(outPath, _SYS_STR("files/MP1"));
|
2018-12-08 05:30:43 +00:00
|
|
|
mp1OutPath.makeDirChain(true);
|
2015-07-16 01:57:34 +00:00
|
|
|
|
2018-12-08 05:30:43 +00:00
|
|
|
/* Extract non-pak files */
|
|
|
|
progress.startNewLine();
|
|
|
|
progress.print(_SYS_STR("MP1 Root"), _SYS_STR(""), 0.0);
|
|
|
|
int prog = 0;
|
|
|
|
ctx.progressCB = [&](std::string_view name, float) {
|
|
|
|
hecl::SystemStringConv nameView(name);
|
|
|
|
progress.print(_SYS_STR("MP1 Root"), nameView.c_str(), prog / (float)m_nonPaks.size());
|
|
|
|
};
|
|
|
|
for (const nod::Node* node : m_nonPaks) {
|
|
|
|
node->extractToDirectory(mp1OutPath.getAbsolutePath(), ctx);
|
|
|
|
prog++;
|
|
|
|
}
|
|
|
|
progress.print(_SYS_STR("MP1 Root"), _SYS_STR(""), 1.0);
|
2015-07-18 04:33:38 +00:00
|
|
|
|
2018-12-08 05:30:43 +00:00
|
|
|
/* Extract unique resources */
|
|
|
|
hecl::ClientProcess process;
|
|
|
|
progress.startNewLine();
|
|
|
|
for (std::pair<const std::string, DNAMP1::PAKBridge*>& pair : m_orderedPaks) {
|
2016-04-08 03:30:00 +00:00
|
|
|
#if 0
|
2019-08-31 20:40:07 +00:00
|
|
|
const DNAMP1::PAK::Entry* ent = pair.second->getPAK().lookupEntry(UniqueID32(0xE39FC9A1));
|
|
|
|
if (ent) {
|
|
|
|
PAKEntryReadStream rs = ent->beginReadStream(pair.second->getNode());
|
|
|
|
DNAMP1::CMDL::Extract(*this, rs, hecl::ProjectPath(m_project.getProjectWorkingPath(), "MP1/Metroid1/!1IntroLevel1027/CMDL_E39FC9A1.blend"), m_pakRouter, *ent, true, hecl::blender::SharedBlenderToken, {});
|
|
|
|
|
|
|
|
ent = pair.second->getPAK().lookupEntry(UniqueID32(0xC1AE2B4A));
|
|
|
|
rs = ent->beginReadStream(pair.second->getNode());
|
|
|
|
DNAMP1::CMDL::Extract(*this, rs, hecl::ProjectPath(m_project.getProjectWorkingPath(), "MP1/Metroid1/!1IntroLevel1027/CMDL_C1AE2B4A.blend"), m_pakRouter, *ent, true, hecl::blender::SharedBlenderToken, {});
|
|
|
|
|
|
|
|
exit(0);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
continue;
|
2016-04-08 03:30:00 +00:00
|
|
|
#endif
|
|
|
|
|
2018-12-08 05:30:43 +00:00
|
|
|
DNAMP1::PAKBridge& pak = *pair.second;
|
|
|
|
if (!pak.m_doExtract)
|
|
|
|
continue;
|
|
|
|
|
|
|
|
auto name = pak.getName();
|
|
|
|
hecl::SystemStringConv sysName(name);
|
|
|
|
|
|
|
|
auto pakName = hecl::SystemString(sysName.sys_str());
|
|
|
|
process.addLambdaTransaction([this, &progress, &pak, pakName, force](hecl::blender::Token& btok) {
|
|
|
|
int threadIdx = hecl::ClientProcess::GetThreadWorkerIdx();
|
|
|
|
m_pakRouter.extractResources(pak, force, btok,
|
|
|
|
[&progress, &pakName, threadIdx](const hecl::SystemChar* substr, float factor) {
|
|
|
|
progress.print(pakName.c_str(), substr, factor, threadIdx);
|
|
|
|
});
|
|
|
|
});
|
|
|
|
}
|
2015-09-28 01:13:27 +00:00
|
|
|
|
2018-12-08 05:30:43 +00:00
|
|
|
process.waitUntilComplete();
|
2015-07-16 01:57:34 +00:00
|
|
|
|
2018-12-08 05:30:43 +00:00
|
|
|
/* Extract part of .dol for RandomStatic entropy */
|
2019-12-03 08:47:05 +00:00
|
|
|
hecl::ProjectPath noAramPath(m_project.getProjectWorkingPath(), _SYS_STR("MP1/URDE"));
|
2018-12-08 05:30:43 +00:00
|
|
|
extractRandomStaticEntropy(m_dolBuf.get() + 0x4f60, noAramPath);
|
2016-04-09 23:19:17 +00:00
|
|
|
|
2019-08-03 23:44:52 +00:00
|
|
|
/* Generate Texture Cache containing meta data for every texture file */
|
2019-12-03 08:47:05 +00:00
|
|
|
TextureCache::Generate(m_pakRouter, m_project, noAramPath);
|
2017-06-01 05:34:24 +00:00
|
|
|
|
2020-04-15 07:56:59 +00:00
|
|
|
/* Write version data */
|
2021-02-26 09:35:54 +00:00
|
|
|
hecl::ProjectPath versionPath = hecl::ProjectPath(m_project.getProjectWorkingPath(), _SYS_STR("out/files/MP1"));
|
2020-04-15 07:56:59 +00:00
|
|
|
WriteVersionInfo(m_project, versionPath);
|
2018-12-08 05:30:43 +00:00
|
|
|
return true;
|
|
|
|
}
|
2018-01-14 06:44:22 +00:00
|
|
|
|
2019-08-10 02:32:48 +00:00
|
|
|
const hecl::Database::DataSpecEntry& getOriginalSpec() const override { return SpecEntMP1; }
|
2015-10-01 00:40:21 +00:00
|
|
|
|
2019-08-10 02:32:48 +00:00
|
|
|
const hecl::Database::DataSpecEntry& getUnmodifiedSpec() const override { return SpecEntMP1ORIG; }
|
2017-01-17 01:23:19 +00:00
|
|
|
|
2019-08-10 02:32:48 +00:00
|
|
|
hecl::ProjectPath getWorking(class UniqueID32& id) override { return m_pakRouter.getWorking(id); }
|
2016-03-27 20:43:04 +00:00
|
|
|
|
2019-08-10 02:32:48 +00:00
|
|
|
bool checkPathPrefix(const hecl::ProjectPath& path) const override {
|
2018-12-08 05:30:43 +00:00
|
|
|
return path.getRelativePath().compare(0, 4, _SYS_STR("MP1/")) == 0;
|
|
|
|
}
|
2015-11-10 02:07:15 +00:00
|
|
|
|
2019-08-10 02:32:48 +00:00
|
|
|
bool validateYAMLDNAType(athena::io::IStreamReader& fp) const override {
|
2018-12-08 05:30:43 +00:00
|
|
|
athena::io::YAMLDocReader reader;
|
|
|
|
yaml_parser_set_input(reader.getParser(), (yaml_read_handler_t*)athena::io::YAMLAthenaReader, &fp);
|
2019-10-01 07:38:03 +00:00
|
|
|
return reader.ClassTypeOperation([](std::string_view classType) {
|
|
|
|
if (classType == DNAMP1::MLVL::DNAType())
|
2018-12-08 05:30:43 +00:00
|
|
|
return true;
|
2019-10-01 07:38:03 +00:00
|
|
|
else if (classType == DNAMP1::STRG::DNAType())
|
2018-12-08 05:30:43 +00:00
|
|
|
return true;
|
2019-10-01 07:38:03 +00:00
|
|
|
else if (classType == DNAMP1::SCAN::DNAType())
|
2018-12-08 05:30:43 +00:00
|
|
|
return true;
|
2019-10-01 07:38:03 +00:00
|
|
|
else if (classType == DNAParticle::GPSM<UniqueID32>::DNAType())
|
2018-12-08 05:30:43 +00:00
|
|
|
return true;
|
2019-10-01 07:38:03 +00:00
|
|
|
else if (classType == DNAParticle::SWSH<UniqueID32>::DNAType())
|
2018-12-08 05:30:43 +00:00
|
|
|
return true;
|
2019-10-01 07:38:03 +00:00
|
|
|
else if (classType == DNAParticle::ELSM<UniqueID32>::DNAType())
|
2018-12-08 05:30:43 +00:00
|
|
|
return true;
|
2019-10-01 07:38:03 +00:00
|
|
|
else if (classType == DNAParticle::WPSM<UniqueID32>::DNAType())
|
2018-12-08 05:30:43 +00:00
|
|
|
return true;
|
2019-10-01 07:38:03 +00:00
|
|
|
else if (classType == DNAParticle::CRSM<UniqueID32>::DNAType())
|
2018-12-08 05:30:43 +00:00
|
|
|
return true;
|
2019-10-01 07:38:03 +00:00
|
|
|
else if (classType == DNAParticle::DPSM<UniqueID32>::DNAType())
|
2018-12-08 05:30:43 +00:00
|
|
|
return true;
|
2019-10-01 07:38:03 +00:00
|
|
|
else if (classType == DNADGRP::DGRP<UniqueID32>::DNAType())
|
2018-12-08 05:30:43 +00:00
|
|
|
return true;
|
2019-10-01 07:38:03 +00:00
|
|
|
else if (classType == DNAFont::FONT<UniqueID32>::DNAType())
|
2018-12-08 05:30:43 +00:00
|
|
|
return true;
|
2020-04-16 05:26:14 +00:00
|
|
|
else if (classType == DNAMP1::CTweakPlayerRes<true>::DNAType())
|
|
|
|
return true;
|
|
|
|
else if (classType == DNAMP1::CTweakPlayerRes<false>::DNAType())
|
2018-12-08 05:30:43 +00:00
|
|
|
return true;
|
2019-10-01 07:38:03 +00:00
|
|
|
else if (classType == DNAMP1::CTweakGunRes::DNAType())
|
2018-12-08 05:30:43 +00:00
|
|
|
return true;
|
2019-10-01 07:38:03 +00:00
|
|
|
else if (classType == DNAMP1::CTweakSlideShow::DNAType())
|
2018-12-08 05:30:43 +00:00
|
|
|
return true;
|
2019-10-01 07:38:03 +00:00
|
|
|
else if (classType == DNAMP1::CTweakPlayer::DNAType())
|
2018-12-08 05:30:43 +00:00
|
|
|
return true;
|
2019-10-01 07:38:03 +00:00
|
|
|
else if (classType == DNAMP1::CTweakCameraBob::DNAType())
|
2018-12-08 05:30:43 +00:00
|
|
|
return true;
|
2019-10-01 07:38:03 +00:00
|
|
|
else if (classType == DNAMP1::CTweakGame::DNAType())
|
2018-12-08 05:30:43 +00:00
|
|
|
return true;
|
2019-10-01 07:38:03 +00:00
|
|
|
else if (classType == DNAMP1::CTweakAutoMapper::DNAType())
|
2018-12-08 05:30:43 +00:00
|
|
|
return true;
|
2020-04-16 05:26:14 +00:00
|
|
|
else if (classType == DNAMP1::CTweakTargeting<true>::DNAType())
|
|
|
|
return true;
|
|
|
|
else if (classType == DNAMP1::CTweakTargeting<false>::DNAType())
|
2018-12-08 05:30:43 +00:00
|
|
|
return true;
|
2019-10-01 07:38:03 +00:00
|
|
|
else if (classType == DNAMP1::CTweakGui::DNAType())
|
2018-12-08 05:30:43 +00:00
|
|
|
return true;
|
2019-10-01 07:38:03 +00:00
|
|
|
else if (classType == DNAMP1::CTweakPlayerControl::DNAType())
|
2018-12-08 05:30:43 +00:00
|
|
|
return true;
|
2019-10-01 07:38:03 +00:00
|
|
|
else if (classType == DNAMP1::CTweakBall::DNAType())
|
2018-12-08 05:30:43 +00:00
|
|
|
return true;
|
2019-10-01 07:38:03 +00:00
|
|
|
else if (classType == DNAMP1::CTweakParticle::DNAType())
|
2018-12-08 05:30:43 +00:00
|
|
|
return true;
|
2019-10-01 07:38:03 +00:00
|
|
|
else if (classType == DNAMP1::CTweakGuiColors::DNAType())
|
2018-12-08 05:30:43 +00:00
|
|
|
return true;
|
2019-10-01 07:38:03 +00:00
|
|
|
else if (classType == DNAMP1::CTweakPlayerGun::DNAType())
|
2018-12-08 05:30:43 +00:00
|
|
|
return true;
|
2019-10-01 07:38:03 +00:00
|
|
|
else if (classType == DNAMP1::HINT::DNAType())
|
2018-12-08 05:30:43 +00:00
|
|
|
return true;
|
2019-10-01 07:38:03 +00:00
|
|
|
else if (classType == DNAMP1::EVNT::DNAType())
|
2018-12-08 05:30:43 +00:00
|
|
|
return true;
|
2019-10-01 07:38:03 +00:00
|
|
|
else if (classType == DNAMP1::MazeSeeds::DNAType())
|
2018-12-08 05:30:43 +00:00
|
|
|
return true;
|
2019-10-01 07:38:03 +00:00
|
|
|
else if (classType == DNAMP1::SnowForces::DNAType())
|
2018-12-08 05:30:43 +00:00
|
|
|
return true;
|
2019-10-01 07:38:03 +00:00
|
|
|
else if (classType == "ATBL")
|
2018-12-08 05:30:43 +00:00
|
|
|
return true;
|
2019-10-01 07:38:03 +00:00
|
|
|
else if (classType == DNAMP1::AFSM::DNAType())
|
2018-12-08 05:30:43 +00:00
|
|
|
return true;
|
2019-10-01 07:38:03 +00:00
|
|
|
else if (classType == "MP1TextureCache")
|
2019-08-09 21:55:59 +00:00
|
|
|
return true;
|
2018-12-08 05:30:43 +00:00
|
|
|
return false;
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
2021-04-10 08:42:06 +00:00
|
|
|
metaforce::SObjectTag buildTagFromPath(const hecl::ProjectPath& path) const override {
|
2019-10-01 07:38:03 +00:00
|
|
|
if (hecl::StringUtils::EndsWith(path.getAuxInfo(), _SYS_STR(".CSKR")))
|
|
|
|
return {SBIG('CSKR'), path.parsedHash32()};
|
2018-12-08 05:30:43 +00:00
|
|
|
else if (hecl::StringUtils::EndsWith(path.getAuxInfo(), _SYS_STR(".ANIM")))
|
2019-10-01 07:38:03 +00:00
|
|
|
return {SBIG('ANIM'), path.parsedHash32()};
|
2018-12-08 05:30:43 +00:00
|
|
|
else if (const hecl::SystemChar* ext = path.getLastComponentExt().data()) {
|
|
|
|
if (ext[0] == _SYS_STR('*') || !hecl::StrCmp(ext, _SYS_STR("mid"))) {
|
|
|
|
if (path.getWithExtension(_SYS_STR(".mid"), true).isFile() &&
|
|
|
|
path.getWithExtension(_SYS_STR(".yaml"), true).isFile()) {
|
|
|
|
hecl::ProjectPath glob = path.getWithExtension(_SYS_STR(".*"), true);
|
2019-10-01 07:38:03 +00:00
|
|
|
return {SBIG('CSNG'), glob.parsedHash32()};
|
2018-12-08 05:30:43 +00:00
|
|
|
}
|
|
|
|
}
|
2015-10-04 05:08:56 +00:00
|
|
|
}
|
|
|
|
|
2018-12-08 05:30:43 +00:00
|
|
|
if (path.getPathType() == hecl::ProjectPath::Type::Directory) {
|
|
|
|
if (hecl::ProjectPath(path, _SYS_STR("!project.yaml")).isFile() &&
|
|
|
|
hecl::ProjectPath(path, _SYS_STR("!pool.yaml")).isFile())
|
2019-10-01 07:38:03 +00:00
|
|
|
return {SBIG('AGSC'), path.parsedHash32()};
|
2015-10-01 00:40:21 +00:00
|
|
|
}
|
2015-10-04 05:08:56 +00:00
|
|
|
|
2018-12-08 05:30:43 +00:00
|
|
|
hecl::ProjectPath asBlend;
|
|
|
|
if (path.getPathType() == hecl::ProjectPath::Type::Glob)
|
|
|
|
asBlend = path.getWithExtension(_SYS_STR(".blend"), true);
|
|
|
|
else
|
|
|
|
asBlend = path;
|
|
|
|
|
|
|
|
if (hecl::IsPathBlend(asBlend)) {
|
|
|
|
switch (hecl::blender::GetBlendType(asBlend.getAbsolutePath())) {
|
|
|
|
case hecl::blender::BlendType::Mesh:
|
2019-10-01 07:38:03 +00:00
|
|
|
return {SBIG('CMDL'), path.parsedHash32()};
|
2018-12-08 05:30:43 +00:00
|
|
|
case hecl::blender::BlendType::ColMesh:
|
2019-10-01 07:38:03 +00:00
|
|
|
return {SBIG('DCLN'), path.parsedHash32()};
|
|
|
|
case hecl::blender::BlendType::Armature:
|
|
|
|
return {SBIG('CINF'), path.parsedHash32()};
|
2018-12-08 05:30:43 +00:00
|
|
|
case hecl::blender::BlendType::PathMesh:
|
2019-10-01 07:38:03 +00:00
|
|
|
return {SBIG('PATH'), path.parsedHash32()};
|
2018-12-08 05:30:43 +00:00
|
|
|
case hecl::blender::BlendType::Actor:
|
|
|
|
if (path.getAuxInfo().size()) {
|
2019-10-01 07:38:03 +00:00
|
|
|
if (hecl::StringUtils::EndsWith(path.getAuxInfo(), _SYS_STR(".CSKR")))
|
|
|
|
return {SBIG('CSKR'), path.getWithExtension(_SYS_STR(".*"), true).parsedHash32()};
|
2018-12-08 05:30:43 +00:00
|
|
|
else if (hecl::StringUtils::EndsWith(path.getAuxInfo(), _SYS_STR(".ANIM")))
|
2019-10-01 07:38:03 +00:00
|
|
|
return {SBIG('ANIM'), path.getWithExtension(_SYS_STR(".*"), true).parsedHash32()};
|
2017-01-21 02:38:34 +00:00
|
|
|
}
|
2019-10-01 07:38:03 +00:00
|
|
|
return {SBIG('ANCS'), path.getWithExtension(_SYS_STR(".*"), true).parsedHash32()};
|
2018-12-08 05:30:43 +00:00
|
|
|
case hecl::blender::BlendType::Area:
|
2019-10-01 07:38:03 +00:00
|
|
|
return {SBIG('MREA'), path.parsedHash32()};
|
|
|
|
case hecl::blender::BlendType::World:
|
|
|
|
return {SBIG('MLVL'), path.getWithExtension(_SYS_STR(".*"), true).parsedHash32()};
|
2018-12-08 05:30:43 +00:00
|
|
|
case hecl::blender::BlendType::MapArea:
|
2019-10-01 07:38:03 +00:00
|
|
|
return {SBIG('MAPA'), path.parsedHash32()};
|
2018-12-08 05:30:43 +00:00
|
|
|
case hecl::blender::BlendType::MapUniverse:
|
2019-10-01 07:38:03 +00:00
|
|
|
return {SBIG('MAPU'), path.parsedHash32()};
|
2018-12-08 05:30:43 +00:00
|
|
|
case hecl::blender::BlendType::Frame:
|
2019-10-01 07:38:03 +00:00
|
|
|
return {SBIG('FRME'), path.parsedHash32()};
|
2018-12-08 05:30:43 +00:00
|
|
|
default:
|
|
|
|
return {};
|
|
|
|
}
|
|
|
|
} else if (hecl::IsPathPNG(path)) {
|
2019-10-01 07:38:03 +00:00
|
|
|
return {SBIG('TXTR'), path.parsedHash32()};
|
2018-12-08 05:30:43 +00:00
|
|
|
} else if (hecl::IsPathYAML(path)) {
|
2019-08-26 18:37:19 +00:00
|
|
|
auto fp = hecl::FopenUnique(path.getAbsolutePath().data(), _SYS_STR("r"));
|
|
|
|
if (fp == nullptr) {
|
2018-12-08 05:30:43 +00:00
|
|
|
return {};
|
2019-08-26 18:37:19 +00:00
|
|
|
}
|
2018-09-03 00:46:16 +00:00
|
|
|
|
2018-12-08 05:30:43 +00:00
|
|
|
athena::io::YAMLDocReader reader;
|
2019-08-26 18:37:19 +00:00
|
|
|
yaml_parser_set_input_file(reader.getParser(), fp.get());
|
2016-10-02 22:41:36 +00:00
|
|
|
|
2021-04-10 08:42:06 +00:00
|
|
|
metaforce::SObjectTag resTag;
|
2019-10-01 07:38:03 +00:00
|
|
|
if (reader.ClassTypeOperation([&](std::string_view className) {
|
|
|
|
if (className == DNAParticle::GPSM<UniqueID32>::DNAType()) {
|
2018-12-08 05:30:43 +00:00
|
|
|
resTag.type = SBIG('PART');
|
|
|
|
return true;
|
2016-10-02 22:41:36 +00:00
|
|
|
}
|
2019-10-01 07:38:03 +00:00
|
|
|
if (className == DNAParticle::SWSH<UniqueID32>::DNAType()) {
|
2018-12-08 05:30:43 +00:00
|
|
|
resTag.type = SBIG('SWHC');
|
|
|
|
return true;
|
2016-10-02 22:41:36 +00:00
|
|
|
}
|
2019-10-01 07:38:03 +00:00
|
|
|
if (className == DNAParticle::ELSM<UniqueID32>::DNAType()) {
|
2018-12-08 05:30:43 +00:00
|
|
|
resTag.type = SBIG('ELSC');
|
|
|
|
return true;
|
2016-10-02 22:41:36 +00:00
|
|
|
}
|
2019-10-01 07:38:03 +00:00
|
|
|
if (className == DNAParticle::WPSM<UniqueID32>::DNAType()) {
|
2018-12-08 05:30:43 +00:00
|
|
|
resTag.type = SBIG('WPSC');
|
|
|
|
return true;
|
2018-03-28 08:09:41 +00:00
|
|
|
}
|
2019-10-01 07:38:03 +00:00
|
|
|
if (className == DNAParticle::CRSM<UniqueID32>::DNAType()) {
|
2018-12-08 05:30:43 +00:00
|
|
|
resTag.type = SBIG('CRSC');
|
|
|
|
return true;
|
2018-03-28 08:09:41 +00:00
|
|
|
}
|
2019-10-01 07:38:03 +00:00
|
|
|
if (className == DNAParticle::DPSM<UniqueID32>::DNAType()) {
|
2018-12-08 05:30:43 +00:00
|
|
|
resTag.type = SBIG('DPSC');
|
|
|
|
return true;
|
2019-10-01 07:38:03 +00:00
|
|
|
} else if (className == DNAFont::FONT<UniqueID32>::DNAType()) {
|
2018-12-08 05:30:43 +00:00
|
|
|
resTag.type = SBIG('FONT');
|
|
|
|
return true;
|
2019-10-01 07:38:03 +00:00
|
|
|
} else if (className == DNAMP1::EVNT::DNAType()) {
|
2018-12-08 05:30:43 +00:00
|
|
|
resTag.type = SBIG('EVNT');
|
|
|
|
return true;
|
2019-10-01 07:38:03 +00:00
|
|
|
} else if (className == DNADGRP::DGRP<UniqueID32>::DNAType()) {
|
2018-12-08 05:30:43 +00:00
|
|
|
resTag.type = SBIG('DGRP');
|
|
|
|
return true;
|
2019-10-01 07:38:03 +00:00
|
|
|
} else if (className == DataSpec::DNAMP1::STRG::DNAType()) {
|
2018-12-08 05:30:43 +00:00
|
|
|
resTag.type = SBIG('STRG');
|
|
|
|
return true;
|
2019-10-01 07:38:03 +00:00
|
|
|
} else if (className == DataSpec::DNAMP1::SCAN::DNAType()) {
|
2018-12-08 05:30:43 +00:00
|
|
|
resTag.type = SBIG('SCAN');
|
|
|
|
return true;
|
2020-04-16 05:26:14 +00:00
|
|
|
} else if (className == DataSpec::DNAMP1::CTweakPlayerRes<true>::DNAType() ||
|
|
|
|
className == DataSpec::DNAMP1::CTweakPlayerRes<false>::DNAType() ||
|
2019-10-01 07:38:03 +00:00
|
|
|
className == DataSpec::DNAMP1::CTweakGunRes::DNAType() ||
|
|
|
|
className == DataSpec::DNAMP1::CTweakSlideShow::DNAType() ||
|
|
|
|
className == DataSpec::DNAMP1::CTweakPlayer::DNAType() ||
|
|
|
|
className == DataSpec::DNAMP1::CTweakCameraBob::DNAType() ||
|
|
|
|
className == DataSpec::DNAMP1::CTweakGame::DNAType() ||
|
2020-04-16 05:26:14 +00:00
|
|
|
className == DataSpec::DNAMP1::CTweakTargeting<true>::DNAType() ||
|
|
|
|
className == DataSpec::DNAMP1::CTweakTargeting<false>::DNAType() ||
|
2019-10-01 07:38:03 +00:00
|
|
|
className == DataSpec::DNAMP1::CTweakAutoMapper::DNAType() ||
|
|
|
|
className == DataSpec::DNAMP1::CTweakGui::DNAType() ||
|
|
|
|
className == DataSpec::DNAMP1::CTweakPlayerControl::DNAType() ||
|
|
|
|
className == DataSpec::DNAMP1::CTweakBall::DNAType() ||
|
|
|
|
className == DataSpec::DNAMP1::CTweakParticle::DNAType() ||
|
|
|
|
className == DataSpec::DNAMP1::CTweakGuiColors::DNAType() ||
|
|
|
|
className == DataSpec::DNAMP1::CTweakPlayerGun::DNAType()) {
|
2018-12-08 05:30:43 +00:00
|
|
|
resTag.type = SBIG('CTWK');
|
|
|
|
return true;
|
2019-10-01 07:38:03 +00:00
|
|
|
} else if (className == DataSpec::DNAMP1::MazeSeeds::DNAType() ||
|
|
|
|
className == DataSpec::DNAMP1::SnowForces::DNAType()) {
|
2018-12-08 05:30:43 +00:00
|
|
|
resTag.type = SBIG('DUMB');
|
|
|
|
return true;
|
2019-10-01 07:38:03 +00:00
|
|
|
} else if (className == DataSpec::DNAMP1::HINT::DNAType()) {
|
2018-12-08 05:30:43 +00:00
|
|
|
resTag.type = SBIG('HINT');
|
|
|
|
return true;
|
2019-10-01 07:38:03 +00:00
|
|
|
} else if (className == "ATBL") {
|
2018-12-08 05:30:43 +00:00
|
|
|
resTag.type = SBIG('ATBL');
|
|
|
|
return true;
|
2019-10-01 07:38:03 +00:00
|
|
|
} else if (className == DataSpec::DNAMP1::AFSM::DNAType()) {
|
2018-12-08 05:30:43 +00:00
|
|
|
resTag.type = SBIG('AFSM');
|
|
|
|
return true;
|
2019-10-01 07:38:03 +00:00
|
|
|
} else if (className == "MP1TextureCache") {
|
2019-08-09 21:55:59 +00:00
|
|
|
resTag.type = SBIG('TMET');
|
|
|
|
return true;
|
2019-10-01 07:38:03 +00:00
|
|
|
} else if (className == "DataSpec::DNAMP1::SAVW") {
|
|
|
|
resTag.type = SBIG('SAVW');
|
|
|
|
return true;
|
|
|
|
} else if (className == "DataSpec::DNAMP1::MAPW") {
|
|
|
|
resTag.type = SBIG('MAPW');
|
|
|
|
return true;
|
2018-04-07 20:55:57 +00:00
|
|
|
}
|
2016-08-10 02:52:00 +00:00
|
|
|
|
2018-12-08 05:30:43 +00:00
|
|
|
return false;
|
|
|
|
})) {
|
2019-10-01 07:38:03 +00:00
|
|
|
resTag.id = path.parsedHash32();
|
2019-08-26 18:37:19 +00:00
|
|
|
fp.reset();
|
2018-12-08 05:30:43 +00:00
|
|
|
return resTag;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return {};
|
|
|
|
}
|
|
|
|
|
2021-04-10 08:42:06 +00:00
|
|
|
void getTagListForFile(const char* pakName, std::vector<metaforce::SObjectTag>& out) const override {
|
2018-12-08 05:30:43 +00:00
|
|
|
std::string pathPrefix("MP1/");
|
|
|
|
pathPrefix += pakName;
|
|
|
|
pathPrefix += '/';
|
|
|
|
|
2020-04-10 00:28:46 +00:00
|
|
|
std::unique_lock lk(m_backgroundIndexMutex);
|
2018-12-08 05:30:43 +00:00
|
|
|
for (const auto& tag : m_tagToPath)
|
|
|
|
if (!tag.second.getRelativePathUTF8().compare(0, pathPrefix.size(), pathPrefix))
|
|
|
|
out.push_back(tag.first);
|
|
|
|
}
|
|
|
|
|
|
|
|
void cookMesh(const hecl::ProjectPath& out, const hecl::ProjectPath& in, BlendStream& ds, bool fast,
|
2019-08-10 02:32:48 +00:00
|
|
|
hecl::blender::Token& btok, FCookProgress progress) override {
|
2019-05-08 03:50:21 +00:00
|
|
|
Mesh mesh = ds.compileMesh(fast ? hecl::HMDLTopology::Triangles : hecl::HMDLTopology::TriStrips, m_pc ? 16 : -1);
|
2018-12-08 05:30:43 +00:00
|
|
|
|
|
|
|
if (m_pc)
|
|
|
|
DNAMP1::CMDL::HMDLCook(out, in, mesh);
|
|
|
|
else
|
|
|
|
DNAMP1::CMDL::Cook(out, in, mesh);
|
|
|
|
}
|
|
|
|
|
|
|
|
void cookColMesh(const hecl::ProjectPath& out, const hecl::ProjectPath& in, BlendStream& ds, bool fast,
|
2019-08-10 02:32:48 +00:00
|
|
|
hecl::blender::Token& btok, FCookProgress progress) override {
|
2018-12-08 05:30:43 +00:00
|
|
|
std::vector<ColMesh> mesh = ds.compileColMeshes();
|
|
|
|
ds.close();
|
|
|
|
DNAMP1::DCLN::Cook(out, mesh);
|
|
|
|
}
|
|
|
|
|
2019-10-01 07:38:03 +00:00
|
|
|
void cookArmature(const hecl::ProjectPath& out, const hecl::ProjectPath& in, BlendStream& ds, bool fast,
|
|
|
|
hecl::blender::Token& btok, FCookProgress progress) override {
|
|
|
|
Armature armature = ds.compileArmature();
|
|
|
|
ds.close();
|
|
|
|
DNAMP1::CINF::Cook(out, in, armature);
|
|
|
|
}
|
|
|
|
|
2018-12-08 05:30:43 +00:00
|
|
|
void cookPathMesh(const hecl::ProjectPath& out, const hecl::ProjectPath& in, BlendStream& ds, bool fast,
|
2019-08-10 02:32:48 +00:00
|
|
|
hecl::blender::Token& btok, FCookProgress progress) override {
|
2018-12-08 05:30:43 +00:00
|
|
|
PathMesh mesh = ds.compilePathMesh();
|
|
|
|
ds.close();
|
2019-01-31 07:52:21 +00:00
|
|
|
DNAMP1::PATH::Cook(out, in, mesh, btok);
|
2018-12-08 05:30:43 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void cookActor(const hecl::ProjectPath& out, const hecl::ProjectPath& in, BlendStream& ds, bool fast,
|
2019-08-10 02:32:48 +00:00
|
|
|
hecl::blender::Token& btok, FCookProgress progress) override {
|
2019-10-01 07:38:03 +00:00
|
|
|
if (hecl::StringUtils::EndsWith(in.getAuxInfo(), _SYS_STR(".CSKR"))) {
|
2018-12-08 05:30:43 +00:00
|
|
|
Actor actor = ds.compileActorCharacterOnly();
|
|
|
|
ds.close();
|
|
|
|
if (m_pc) {
|
|
|
|
DNAMP1::ANCS::CookCSKRPC(out, in, actor, [&](const hecl::ProjectPath& modelPath) {
|
|
|
|
hecl::ProjectPath cooked = modelPath.getCookedPath(SpecEntMP1PC);
|
|
|
|
doCook(modelPath, cooked, fast, btok, progress);
|
|
|
|
return true;
|
|
|
|
});
|
|
|
|
} else {
|
|
|
|
DNAMP1::ANCS::CookCSKR(out, in, actor, [&](const hecl::ProjectPath& modelPath) {
|
|
|
|
hecl::ProjectPath cooked = modelPath.getCookedPath(SpecEntMP1);
|
|
|
|
doCook(modelPath, cooked, fast, btok, progress);
|
|
|
|
return true;
|
|
|
|
});
|
|
|
|
}
|
|
|
|
} else if (hecl::StringUtils::EndsWith(in.getAuxInfo(), _SYS_STR(".ANIM"))) {
|
|
|
|
Actor actor = ds.compileActorCharacterOnly();
|
|
|
|
DNAMP1::ANCS::CookANIM(out, in, actor, ds, m_pc);
|
|
|
|
} else {
|
|
|
|
Actor actor = ds.compileActor();
|
|
|
|
DNAMP1::ANCS::Cook(out, in, actor);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void buildAreaXFs(hecl::blender::Token& btok) {
|
|
|
|
hecl::blender::Connection& conn = btok.getBlenderConnection();
|
|
|
|
for (const auto& ent : m_workPath.enumerateDir()) {
|
|
|
|
if (ent.m_isDir) {
|
|
|
|
hecl::ProjectPath pakPath(m_workPath, ent.m_name);
|
|
|
|
for (const auto& ent2 : pakPath.enumerateDir()) {
|
|
|
|
if (ent2.m_isDir) {
|
2019-10-01 07:38:03 +00:00
|
|
|
hecl::ProjectPath wldDir(pakPath, ent2.m_name);
|
|
|
|
for (const auto& ent3 : wldDir.enumerateDir()) {
|
2021-05-31 06:10:59 +00:00
|
|
|
if (hecl::StringUtils::BeginsWith(ent3.m_name, _SYS_STR("!world")) &&
|
2019-10-01 07:38:03 +00:00
|
|
|
hecl::StringUtils::EndsWith(ent3.m_name, _SYS_STR(".blend"))) {
|
|
|
|
hecl::ProjectPath wldPath(wldDir, ent3.m_name);
|
|
|
|
if (wldPath.isFile()) {
|
|
|
|
if (!conn.openBlend(wldPath))
|
|
|
|
continue;
|
|
|
|
hecl::blender::DataStream ds = conn.beginData();
|
|
|
|
hecl::blender::World world = ds.compileWorld();
|
|
|
|
for (const auto& area : world.areas)
|
|
|
|
m_mreaPathToXF[area.path.hash()] = area.transform;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
2016-08-10 21:54:53 +00:00
|
|
|
}
|
2018-12-08 05:30:43 +00:00
|
|
|
}
|
2018-02-25 08:23:27 +00:00
|
|
|
}
|
2018-12-08 05:30:43 +00:00
|
|
|
}
|
2015-10-04 05:08:56 +00:00
|
|
|
}
|
2018-12-08 05:30:43 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void cookArea(const hecl::ProjectPath& out, const hecl::ProjectPath& in, BlendStream& ds, bool fast,
|
2019-08-10 02:32:48 +00:00
|
|
|
hecl::blender::Token& btok, FCookProgress progress) override {
|
2018-12-08 05:30:43 +00:00
|
|
|
std::vector<std::string> meshes = ds.getMeshList();
|
|
|
|
std::vector<Mesh> meshCompiles;
|
|
|
|
meshCompiles.reserve(meshes.size());
|
|
|
|
|
2019-06-12 02:05:17 +00:00
|
|
|
std::optional<ColMesh> colMesh;
|
2018-12-08 05:30:43 +00:00
|
|
|
|
|
|
|
for (const std::string& mesh : meshes) {
|
|
|
|
hecl::SystemStringConv meshSys(mesh);
|
2019-10-01 07:38:03 +00:00
|
|
|
if (mesh == "CMESH") {
|
2018-12-08 05:30:43 +00:00
|
|
|
colMesh = ds.compileColMesh(mesh);
|
|
|
|
progress(_SYS_STR("Collision Mesh"));
|
|
|
|
continue;
|
|
|
|
}
|
2019-08-03 23:44:52 +00:00
|
|
|
meshCompiles.push_back(
|
|
|
|
ds.compileMesh(mesh, fast ? hecl::HMDLTopology::Triangles : hecl::HMDLTopology::TriStrips, -1, !m_pc));
|
2016-09-30 22:43:19 +00:00
|
|
|
}
|
|
|
|
|
2018-12-08 05:30:43 +00:00
|
|
|
if (!colMesh)
|
2020-04-15 07:56:59 +00:00
|
|
|
Log.report(logvisor::Fatal, FMT_STRING(_SYS_STR("unable to find mesh named 'CMESH' in {}")),
|
|
|
|
in.getAbsolutePath());
|
2018-12-08 05:30:43 +00:00
|
|
|
|
|
|
|
std::vector<Light> lights = ds.compileLights();
|
|
|
|
|
|
|
|
ds.close();
|
|
|
|
|
|
|
|
if (m_mreaPathToXF.empty())
|
|
|
|
buildAreaXFs(btok);
|
|
|
|
|
|
|
|
const hecl::blender::Matrix4f* xf = nullptr;
|
|
|
|
auto xfSearch = m_mreaPathToXF.find(in.getParentPath().hash());
|
|
|
|
if (xfSearch != m_mreaPathToXF.cend())
|
|
|
|
xf = &xfSearch->second;
|
|
|
|
DNAMP1::MREA::Cook(out, in, meshCompiles, *colMesh, lights, btok, xf, m_pc);
|
|
|
|
}
|
|
|
|
|
|
|
|
void cookWorld(const hecl::ProjectPath& out, const hecl::ProjectPath& in, BlendStream& ds, bool fast,
|
2019-08-10 02:32:48 +00:00
|
|
|
hecl::blender::Token& btok, FCookProgress progress) override {
|
2019-10-01 07:38:03 +00:00
|
|
|
hecl::blender::World world = ds.compileWorld();
|
|
|
|
ds.close();
|
|
|
|
DNAMP1::MLVL::Cook(out, in, world, btok);
|
2018-12-08 05:30:43 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void cookGuiFrame(const hecl::ProjectPath& out, const hecl::ProjectPath& in, BlendStream& ds,
|
2019-08-10 02:32:48 +00:00
|
|
|
hecl::blender::Token& btok, FCookProgress progress) override {
|
2018-12-08 05:30:43 +00:00
|
|
|
auto data = ds.compileGuiFrame(0);
|
|
|
|
athena::io::MemoryReader r(data.data(), data.size());
|
|
|
|
DNAMP1::FRME frme;
|
|
|
|
frme.read(r);
|
|
|
|
athena::io::FileWriter w(out.getAbsolutePath());
|
|
|
|
frme.write(w);
|
|
|
|
}
|
|
|
|
|
|
|
|
void cookYAML(const hecl::ProjectPath& out, const hecl::ProjectPath& in, athena::io::IStreamReader& fin,
|
2019-10-01 07:38:03 +00:00
|
|
|
hecl::blender::Token& btok, FCookProgress progress) override {
|
2018-12-08 05:30:43 +00:00
|
|
|
athena::io::YAMLDocReader reader;
|
|
|
|
if (reader.parse(&fin)) {
|
|
|
|
std::string classStr = reader.readString("DNAType");
|
|
|
|
if (classStr.empty())
|
|
|
|
return;
|
|
|
|
|
2019-10-01 07:38:03 +00:00
|
|
|
if (classStr == DNAMP1::STRG::DNAType()) {
|
2018-12-08 05:30:43 +00:00
|
|
|
DNAMP1::STRG strg;
|
|
|
|
strg.read(reader);
|
|
|
|
DNAMP1::STRG::Cook(strg, out);
|
2019-10-01 07:38:03 +00:00
|
|
|
} else if (classStr == DNAMP1::SCAN::DNAType()) {
|
2018-12-08 05:30:43 +00:00
|
|
|
DNAMP1::SCAN scan;
|
|
|
|
scan.read(reader);
|
|
|
|
DNAMP1::SCAN::Cook(scan, out);
|
2019-10-01 07:38:03 +00:00
|
|
|
} else if (classStr == DNAParticle::GPSM<UniqueID32>::DNAType()) {
|
2018-12-08 05:30:43 +00:00
|
|
|
DNAParticle::GPSM<UniqueID32> gpsm;
|
|
|
|
gpsm.read(reader);
|
|
|
|
DNAParticle::WriteGPSM(gpsm, out);
|
2019-10-01 07:38:03 +00:00
|
|
|
} else if (classStr == DNAParticle::SWSH<UniqueID32>::DNAType()) {
|
2018-12-08 05:30:43 +00:00
|
|
|
DNAParticle::SWSH<UniqueID32> swsh;
|
|
|
|
swsh.read(reader);
|
|
|
|
DNAParticle::WriteSWSH(swsh, out);
|
2019-10-01 07:38:03 +00:00
|
|
|
} else if (classStr == DNAParticle::ELSM<UniqueID32>::DNAType()) {
|
2018-12-08 05:30:43 +00:00
|
|
|
DNAParticle::ELSM<UniqueID32> elsm;
|
|
|
|
elsm.read(reader);
|
|
|
|
DNAParticle::WriteELSM(elsm, out);
|
2019-10-01 07:38:03 +00:00
|
|
|
} else if (classStr == DNAParticle::WPSM<UniqueID32>::DNAType()) {
|
2018-12-08 05:30:43 +00:00
|
|
|
DNAParticle::WPSM<UniqueID32> wpsm;
|
|
|
|
wpsm.read(reader);
|
|
|
|
DNAParticle::WriteWPSM(wpsm, out);
|
2019-10-01 07:38:03 +00:00
|
|
|
} else if (classStr == DNAParticle::CRSM<UniqueID32>::DNAType()) {
|
2018-12-08 05:30:43 +00:00
|
|
|
DNAParticle::CRSM<UniqueID32> crsm;
|
|
|
|
crsm.read(reader);
|
|
|
|
DNAParticle::WriteCRSM(crsm, out);
|
2019-10-01 07:38:03 +00:00
|
|
|
} else if (classStr == DNAParticle::DPSM<UniqueID32>::DNAType()) {
|
2018-12-08 05:30:43 +00:00
|
|
|
DNAParticle::DPSM<UniqueID32> dpsm;
|
|
|
|
dpsm.read(reader);
|
|
|
|
DNAParticle::WriteDPSM(dpsm, out);
|
2019-10-01 07:38:03 +00:00
|
|
|
} else if (classStr == DNADGRP::DGRP<UniqueID32>::DNAType()) {
|
2018-12-08 05:30:43 +00:00
|
|
|
DNADGRP::DGRP<UniqueID32> dgrp;
|
|
|
|
dgrp.read(reader);
|
|
|
|
dgrp.validateDeps();
|
|
|
|
DNADGRP::WriteDGRP(dgrp, out);
|
2019-10-01 07:38:03 +00:00
|
|
|
} else if (classStr == DNAFont::FONT<UniqueID32>::DNAType()) {
|
2018-12-08 05:30:43 +00:00
|
|
|
DNAFont::FONT<UniqueID32> font;
|
|
|
|
font.read(reader);
|
|
|
|
DNAFont::WriteFONT(font, out);
|
2020-04-16 05:26:14 +00:00
|
|
|
} else if (classStr == DNAMP1::CTweakPlayerRes<true>::DNAType()) {
|
|
|
|
DNAMP1::CTweakPlayerRes<true> playerRes;
|
|
|
|
playerRes.read(reader);
|
|
|
|
WriteTweak(playerRes, out);
|
|
|
|
} else if (classStr == DNAMP1::CTweakPlayerRes<false>::DNAType()) {
|
|
|
|
DNAMP1::CTweakPlayerRes<false> playerRes;
|
2018-12-08 05:30:43 +00:00
|
|
|
playerRes.read(reader);
|
|
|
|
WriteTweak(playerRes, out);
|
2019-10-01 07:38:03 +00:00
|
|
|
} else if (classStr == DNAMP1::CTweakGunRes::DNAType()) {
|
2018-12-08 05:30:43 +00:00
|
|
|
DNAMP1::CTweakGunRes gunRes;
|
|
|
|
gunRes.read(reader);
|
|
|
|
WriteTweak(gunRes, out);
|
2019-10-01 07:38:03 +00:00
|
|
|
} else if (classStr == DNAMP1::CTweakSlideShow::DNAType()) {
|
2018-12-08 05:30:43 +00:00
|
|
|
DNAMP1::CTweakSlideShow slideShow;
|
|
|
|
slideShow.read(reader);
|
|
|
|
WriteTweak(slideShow, out);
|
2019-10-01 07:38:03 +00:00
|
|
|
} else if (classStr == DNAMP1::CTweakPlayer::DNAType()) {
|
2018-12-08 05:30:43 +00:00
|
|
|
DNAMP1::CTweakPlayer player;
|
|
|
|
player.read(reader);
|
|
|
|
WriteTweak(player, out);
|
2019-10-01 07:38:03 +00:00
|
|
|
} else if (classStr == DNAMP1::CTweakCameraBob::DNAType()) {
|
2018-12-08 05:30:43 +00:00
|
|
|
DNAMP1::CTweakCameraBob cBob;
|
|
|
|
cBob.read(reader);
|
|
|
|
WriteTweak(cBob, out);
|
2019-10-01 07:38:03 +00:00
|
|
|
} else if (classStr == DNAMP1::CTweakGame::DNAType()) {
|
2018-12-08 05:30:43 +00:00
|
|
|
DNAMP1::CTweakGame cGame;
|
|
|
|
cGame.read(reader);
|
|
|
|
WriteTweak(cGame, out);
|
2019-10-01 07:38:03 +00:00
|
|
|
} else if (classStr == DNAMP1::CTweakAutoMapper::DNAType()) {
|
2018-12-08 05:30:43 +00:00
|
|
|
DNAMP1::CTweakAutoMapper autoMapper;
|
|
|
|
autoMapper.read(reader);
|
|
|
|
WriteTweak(autoMapper, out);
|
2020-04-16 05:26:14 +00:00
|
|
|
} else if (classStr == DNAMP1::CTweakTargeting<true>::DNAType()) {
|
|
|
|
DNAMP1::CTweakTargeting<false> targeting;
|
|
|
|
targeting.read(reader);
|
|
|
|
WriteTweak(targeting, out);
|
|
|
|
} else if (classStr == DNAMP1::CTweakTargeting<false>::DNAType()) {
|
|
|
|
DNAMP1::CTweakTargeting<false> targeting;
|
2018-12-08 05:30:43 +00:00
|
|
|
targeting.read(reader);
|
|
|
|
WriteTweak(targeting, out);
|
2019-10-01 07:38:03 +00:00
|
|
|
} else if (classStr == DNAMP1::CTweakGui::DNAType()) {
|
2018-12-08 05:30:43 +00:00
|
|
|
DNAMP1::CTweakGui gui;
|
|
|
|
gui.read(reader);
|
|
|
|
WriteTweak(gui, out);
|
2019-10-01 07:38:03 +00:00
|
|
|
} else if (classStr == DNAMP1::CTweakPlayerControl::DNAType()) {
|
2018-12-08 05:30:43 +00:00
|
|
|
DNAMP1::CTweakPlayerControl pc;
|
|
|
|
pc.read(reader);
|
|
|
|
WriteTweak(pc, out);
|
2019-10-01 07:38:03 +00:00
|
|
|
} else if (classStr == DNAMP1::CTweakBall::DNAType()) {
|
2018-12-08 05:30:43 +00:00
|
|
|
DNAMP1::CTweakBall ball;
|
|
|
|
ball.read(reader);
|
|
|
|
WriteTweak(ball, out);
|
2019-10-01 07:38:03 +00:00
|
|
|
} else if (classStr == DNAMP1::CTweakParticle::DNAType()) {
|
2018-12-08 05:30:43 +00:00
|
|
|
DNAMP1::CTweakParticle part;
|
|
|
|
part.read(reader);
|
|
|
|
WriteTweak(part, out);
|
2019-10-01 07:38:03 +00:00
|
|
|
} else if (classStr == DNAMP1::CTweakGuiColors::DNAType()) {
|
2018-12-08 05:30:43 +00:00
|
|
|
DNAMP1::CTweakGuiColors gColors;
|
|
|
|
gColors.read(reader);
|
|
|
|
WriteTweak(gColors, out);
|
2019-10-01 07:38:03 +00:00
|
|
|
} else if (classStr == DNAMP1::CTweakPlayerGun::DNAType()) {
|
2018-12-08 05:30:43 +00:00
|
|
|
DNAMP1::CTweakPlayerGun pGun;
|
|
|
|
pGun.read(reader);
|
|
|
|
WriteTweak(pGun, out);
|
2019-10-01 07:38:03 +00:00
|
|
|
} else if (classStr == DNAMP1::CTweakPlayerControl::DNAType()) {
|
2018-12-08 05:30:43 +00:00
|
|
|
DNAMP1::CTweakPlayerControl pControl;
|
|
|
|
pControl.read(reader);
|
|
|
|
WriteTweak(pControl, out);
|
2019-10-01 07:38:03 +00:00
|
|
|
} else if (classStr == DNAMP1::MazeSeeds::DNAType()) {
|
2018-12-08 05:30:43 +00:00
|
|
|
DNAMP1::MazeSeeds mSeeds;
|
|
|
|
mSeeds.read(reader);
|
|
|
|
WriteTweak(mSeeds, out);
|
2019-10-01 07:38:03 +00:00
|
|
|
} else if (classStr == DNAMP1::SnowForces::DNAType()) {
|
2018-12-08 05:30:43 +00:00
|
|
|
DNAMP1::SnowForces sForces;
|
|
|
|
sForces.read(reader);
|
|
|
|
WriteTweak(sForces, out);
|
2019-10-01 07:38:03 +00:00
|
|
|
} else if (classStr == DNAMP1::HINT::DNAType()) {
|
2018-12-08 05:30:43 +00:00
|
|
|
DNAMP1::HINT::Cook(in, out);
|
2019-10-01 07:38:03 +00:00
|
|
|
} else if (classStr == DNAMP1::EVNT::DNAType()) {
|
2018-12-08 05:30:43 +00:00
|
|
|
DNAMP1::EVNT::Cook(in, out);
|
2019-10-01 07:38:03 +00:00
|
|
|
} else if (classStr == "ATBL") {
|
2018-12-08 05:30:43 +00:00
|
|
|
DNAAudio::ATBL::Cook(in, out);
|
2019-10-01 07:38:03 +00:00
|
|
|
} else if (classStr == DNAMP1::AFSM::DNAType()) {
|
2018-12-08 05:30:43 +00:00
|
|
|
DNAMP1::AFSM::Cook(in, out);
|
2019-10-01 07:38:03 +00:00
|
|
|
} else if (classStr == "MP1TextureCache") {
|
2019-08-09 21:55:59 +00:00
|
|
|
TextureCache::Cook(in, out);
|
2018-12-08 05:30:43 +00:00
|
|
|
}
|
2015-10-04 05:08:56 +00:00
|
|
|
}
|
2018-12-08 05:30:43 +00:00
|
|
|
progress(_SYS_STR("Done"));
|
|
|
|
}
|
|
|
|
|
2019-08-10 02:32:48 +00:00
|
|
|
void flattenDependenciesYAML(athena::io::IStreamReader& fin, std::vector<hecl::ProjectPath>& pathsOut) override {
|
2018-12-08 05:30:43 +00:00
|
|
|
athena::io::YAMLDocReader reader;
|
|
|
|
if (reader.parse(&fin)) {
|
2019-10-01 07:38:03 +00:00
|
|
|
std::string classStr = reader.readString("DNAType"sv);
|
2018-12-08 05:30:43 +00:00
|
|
|
if (classStr.empty())
|
|
|
|
return;
|
|
|
|
|
2019-10-01 07:38:03 +00:00
|
|
|
if (classStr == DNAMP1::STRG::DNAType()) {
|
2018-12-08 05:30:43 +00:00
|
|
|
DNAMP1::STRG strg;
|
|
|
|
strg.read(reader);
|
|
|
|
strg.gatherDependencies(pathsOut);
|
|
|
|
}
|
2019-10-01 07:38:03 +00:00
|
|
|
if (classStr == DNAMP1::SCAN::DNAType()) {
|
2018-12-08 05:30:43 +00:00
|
|
|
DNAMP1::SCAN scan;
|
|
|
|
scan.read(reader);
|
|
|
|
scan.gatherDependencies(pathsOut);
|
2019-10-01 07:38:03 +00:00
|
|
|
} else if (classStr == DNAParticle::GPSM<UniqueID32>::DNAType()) {
|
2018-12-08 05:30:43 +00:00
|
|
|
DNAParticle::GPSM<UniqueID32> gpsm;
|
|
|
|
gpsm.read(reader);
|
|
|
|
gpsm.gatherDependencies(pathsOut);
|
2019-10-01 07:38:03 +00:00
|
|
|
} else if (classStr == DNAParticle::SWSH<UniqueID32>::DNAType()) {
|
2018-12-08 05:30:43 +00:00
|
|
|
DNAParticle::SWSH<UniqueID32> swsh;
|
|
|
|
swsh.read(reader);
|
|
|
|
swsh.gatherDependencies(pathsOut);
|
2019-10-01 07:38:03 +00:00
|
|
|
} else if (classStr == DNAParticle::ELSM<UniqueID32>::DNAType()) {
|
2018-12-08 05:30:43 +00:00
|
|
|
DNAParticle::ELSM<UniqueID32> elsm;
|
|
|
|
elsm.read(reader);
|
|
|
|
elsm.gatherDependencies(pathsOut);
|
2019-10-01 07:38:03 +00:00
|
|
|
} else if (classStr == DNAParticle::WPSM<UniqueID32>::DNAType()) {
|
2018-12-08 05:30:43 +00:00
|
|
|
DNAParticle::WPSM<UniqueID32> wpsm;
|
|
|
|
wpsm.read(reader);
|
|
|
|
wpsm.gatherDependencies(pathsOut);
|
2019-10-01 07:38:03 +00:00
|
|
|
} else if (classStr == DNAParticle::CRSM<UniqueID32>::DNAType()) {
|
2018-12-08 05:30:43 +00:00
|
|
|
DNAParticle::CRSM<UniqueID32> crsm;
|
|
|
|
crsm.read(reader);
|
|
|
|
crsm.gatherDependencies(pathsOut);
|
2019-10-01 07:38:03 +00:00
|
|
|
} else if (classStr == DNAParticle::DPSM<UniqueID32>::DNAType()) {
|
2018-12-08 05:30:43 +00:00
|
|
|
DNAParticle::DPSM<UniqueID32> dpsm;
|
|
|
|
dpsm.read(reader);
|
|
|
|
dpsm.gatherDependencies(pathsOut);
|
2019-10-01 07:38:03 +00:00
|
|
|
} else if (classStr == DNAFont::FONT<UniqueID32>::DNAType()) {
|
2018-12-08 05:30:43 +00:00
|
|
|
DNAFont::FONT<UniqueID32> font;
|
|
|
|
font.read(reader);
|
|
|
|
font.gatherDependencies(pathsOut);
|
2019-10-01 07:38:03 +00:00
|
|
|
} else if (classStr == DNAMP1::EVNT::DNAType()) {
|
2018-12-08 05:30:43 +00:00
|
|
|
DNAMP1::EVNT evnt;
|
|
|
|
evnt.read(reader);
|
|
|
|
evnt.gatherDependencies(pathsOut);
|
|
|
|
}
|
2016-10-02 22:41:36 +00:00
|
|
|
}
|
2018-12-08 05:30:43 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void flattenDependenciesANCSYAML(athena::io::IStreamReader& fin, std::vector<hecl::ProjectPath>& pathsOut,
|
2019-08-10 02:32:48 +00:00
|
|
|
int charIdx) override {
|
2018-12-08 05:30:43 +00:00
|
|
|
athena::io::YAMLDocReader reader;
|
|
|
|
if (reader.parse(&fin)) {
|
|
|
|
std::string classStr = reader.readString("DNAType");
|
2019-10-01 07:38:03 +00:00
|
|
|
if (classStr == DNAMP1::ANCS::DNAType()) {
|
2018-12-08 05:30:43 +00:00
|
|
|
DNAMP1::ANCS ancs;
|
|
|
|
ancs.read(reader);
|
|
|
|
ancs.gatherDependencies(pathsOut, charIdx);
|
|
|
|
}
|
2017-11-15 04:12:13 +00:00
|
|
|
}
|
2018-12-08 05:30:43 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void buildWorldPakList(const hecl::ProjectPath& worldPath, const hecl::ProjectPath& worldPathCooked,
|
2021-04-10 08:42:06 +00:00
|
|
|
hecl::blender::Token& btok, athena::io::FileWriter& w, std::vector<metaforce::SObjectTag>& listOut,
|
2019-08-10 02:32:48 +00:00
|
|
|
atUint64& resTableOffset,
|
2021-04-10 08:42:06 +00:00
|
|
|
std::unordered_map<metaforce::CAssetId, std::vector<uint8_t>>& mlvlData) override {
|
2018-12-08 05:30:43 +00:00
|
|
|
DNAMP1::MLVL mlvl;
|
2018-03-28 08:09:41 +00:00
|
|
|
{
|
2018-12-08 05:30:43 +00:00
|
|
|
athena::io::FileReader r(worldPathCooked.getAbsolutePath());
|
|
|
|
if (r.hasError())
|
2020-04-11 22:51:39 +00:00
|
|
|
Log.report(logvisor::Fatal, FMT_STRING(_SYS_STR("Unable to open world {}")), worldPathCooked.getRelativePath());
|
2018-12-08 05:30:43 +00:00
|
|
|
mlvl.read(r);
|
2018-03-28 08:09:41 +00:00
|
|
|
}
|
|
|
|
|
2018-12-08 05:30:43 +00:00
|
|
|
size_t count = 5;
|
|
|
|
for (const auto& area : mlvl.areas) {
|
|
|
|
auto lazyIt = area.lazyDeps.cbegin();
|
|
|
|
auto it = area.deps.cbegin();
|
|
|
|
while (it != area.deps.cend()) {
|
|
|
|
if (it->id != lazyIt->id)
|
|
|
|
++count;
|
|
|
|
++lazyIt;
|
|
|
|
++it;
|
|
|
|
}
|
2018-03-28 08:09:41 +00:00
|
|
|
}
|
2018-12-08 05:30:43 +00:00
|
|
|
listOut.reserve(count);
|
|
|
|
|
2021-04-10 08:42:06 +00:00
|
|
|
metaforce::SObjectTag worldTag = tagFromPath(worldPath.getWithExtension(_SYS_STR(".*"), true));
|
2018-12-08 05:30:43 +00:00
|
|
|
|
|
|
|
w.writeUint32Big(m_pc ? 0x80030005 : 0x00030005);
|
|
|
|
w.writeUint32Big(0);
|
|
|
|
|
|
|
|
w.writeUint32Big(1);
|
|
|
|
DNAMP1::PAK::NameEntry nameEnt;
|
|
|
|
hecl::ProjectPath parentDir = worldPath.getParentPath();
|
|
|
|
nameEnt.type = worldTag.type;
|
2019-10-01 07:38:03 +00:00
|
|
|
nameEnt.id = worldTag.id.Value();
|
2018-12-08 05:30:43 +00:00
|
|
|
nameEnt.nameLen = atUint32(parentDir.getLastComponent().size());
|
|
|
|
nameEnt.name = parentDir.getLastComponentUTF8();
|
|
|
|
nameEnt.write(w);
|
|
|
|
|
2021-04-10 08:42:06 +00:00
|
|
|
std::unordered_set<metaforce::CAssetId> addedTags;
|
2018-12-08 05:30:43 +00:00
|
|
|
for (auto& area : mlvl.areas) {
|
2021-04-10 08:42:06 +00:00
|
|
|
metaforce::SObjectTag areaTag(FOURCC('MREA'), area.areaMREAId.toUint64());
|
2018-12-08 05:30:43 +00:00
|
|
|
|
|
|
|
bool dupeRes = false;
|
|
|
|
if (hecl::ProjectPath areaDir = pathFromTag(areaTag).getParentPath())
|
|
|
|
dupeRes = hecl::ProjectPath(areaDir, _SYS_STR("!duperes")).isFile();
|
|
|
|
|
2021-04-10 08:42:06 +00:00
|
|
|
metaforce::SObjectTag nameTag(FOURCC('STRG'), area.areaNameId.toUint64());
|
2018-12-08 05:30:43 +00:00
|
|
|
if (nameTag)
|
|
|
|
listOut.push_back(nameTag);
|
|
|
|
for (const auto& dep : area.deps) {
|
2021-04-10 08:42:06 +00:00
|
|
|
metaforce::CAssetId newId = dep.id.toUint64();
|
2018-12-08 05:30:43 +00:00
|
|
|
if (dupeRes || addedTags.find(newId) == addedTags.end()) {
|
2020-03-31 16:40:34 +00:00
|
|
|
listOut.emplace_back(dep.type, newId);
|
2018-12-08 05:30:43 +00:00
|
|
|
addedTags.insert(newId);
|
2017-10-25 07:47:49 +00:00
|
|
|
}
|
2018-12-08 05:30:43 +00:00
|
|
|
}
|
|
|
|
if (areaTag)
|
|
|
|
listOut.push_back(areaTag);
|
|
|
|
|
|
|
|
std::vector<DNAMP1::MLVL::Area::Dependency> strippedDeps;
|
|
|
|
strippedDeps.reserve(area.deps.size());
|
|
|
|
std::vector<atUint32> strippedDepLayers;
|
|
|
|
strippedDepLayers.reserve(area.depLayers.size());
|
|
|
|
auto lazyIt = area.lazyDeps.cbegin();
|
|
|
|
auto it = area.deps.cbegin();
|
|
|
|
auto layerIt = area.depLayers.cbegin();
|
|
|
|
while (it != area.deps.cend()) {
|
|
|
|
while (layerIt != area.depLayers.cend() && it - area.deps.cbegin() == *layerIt) {
|
|
|
|
strippedDepLayers.push_back(atUint32(strippedDeps.size()));
|
|
|
|
++layerIt;
|
2018-04-02 04:27:24 +00:00
|
|
|
}
|
2018-12-08 05:30:43 +00:00
|
|
|
if (it->id != lazyIt->id)
|
|
|
|
strippedDeps.push_back(*it);
|
|
|
|
++lazyIt;
|
|
|
|
++it;
|
|
|
|
}
|
|
|
|
|
|
|
|
area.lazyDepCount = 0;
|
|
|
|
area.lazyDeps.clear();
|
|
|
|
area.depCount = strippedDeps.size();
|
|
|
|
area.deps = std::move(strippedDeps);
|
|
|
|
area.depLayerCount = strippedDepLayers.size();
|
|
|
|
area.depLayers = std::move(strippedDepLayers);
|
2017-10-25 07:47:49 +00:00
|
|
|
}
|
|
|
|
|
2021-04-10 08:42:06 +00:00
|
|
|
metaforce::SObjectTag nameTag(FOURCC('STRG'), mlvl.worldNameId.toUint64());
|
2018-12-08 05:30:43 +00:00
|
|
|
if (nameTag)
|
|
|
|
listOut.push_back(nameTag);
|
2017-10-25 07:47:49 +00:00
|
|
|
|
2021-04-10 08:42:06 +00:00
|
|
|
metaforce::SObjectTag savwTag(FOURCC('SAVW'), mlvl.saveWorldId.toUint64());
|
2018-12-08 05:30:43 +00:00
|
|
|
if (savwTag) {
|
|
|
|
if (hecl::ProjectPath savwPath = pathFromTag(savwTag))
|
|
|
|
m_project.cookPath(savwPath, {}, false, true);
|
|
|
|
listOut.push_back(savwTag);
|
2017-10-25 07:47:49 +00:00
|
|
|
}
|
|
|
|
|
2021-04-10 08:42:06 +00:00
|
|
|
metaforce::SObjectTag mapTag(FOURCC('MAPW'), mlvl.worldMap.toUint64());
|
2018-12-08 05:30:43 +00:00
|
|
|
if (mapTag) {
|
|
|
|
if (hecl::ProjectPath mapPath = pathFromTag(mapTag)) {
|
|
|
|
m_project.cookPath(mapPath, {}, false, true);
|
|
|
|
if (hecl::ProjectPath mapCookedPath = getCookedPath(mapPath, true)) {
|
|
|
|
athena::io::FileReader r(mapCookedPath.getAbsolutePath());
|
|
|
|
if (r.hasError())
|
2020-04-11 22:51:39 +00:00
|
|
|
Log.report(logvisor::Fatal, FMT_STRING(_SYS_STR("Unable to open {}")), mapCookedPath.getRelativePath());
|
2018-12-08 05:30:43 +00:00
|
|
|
|
|
|
|
if (r.readUint32Big() != 0xDEADF00D)
|
2020-04-11 22:51:39 +00:00
|
|
|
Log.report(logvisor::Fatal, FMT_STRING(_SYS_STR("Corrupt MAPW {}")), mapCookedPath.getRelativePath());
|
2018-12-08 05:30:43 +00:00
|
|
|
r.readUint32Big();
|
|
|
|
atUint32 mapaCount = r.readUint32Big();
|
2019-06-12 02:05:17 +00:00
|
|
|
for (atUint32 i = 0; i < mapaCount; ++i) {
|
2018-12-08 05:30:43 +00:00
|
|
|
UniqueID32 id;
|
|
|
|
id.read(r);
|
2020-03-31 16:40:34 +00:00
|
|
|
listOut.emplace_back(FOURCC('MAPA'), id.toUint64());
|
2018-12-08 05:30:43 +00:00
|
|
|
}
|
2017-10-25 07:47:49 +00:00
|
|
|
}
|
2018-12-08 05:30:43 +00:00
|
|
|
}
|
|
|
|
listOut.push_back(mapTag);
|
2017-10-25 07:47:49 +00:00
|
|
|
}
|
|
|
|
|
2021-04-10 08:42:06 +00:00
|
|
|
metaforce::SObjectTag skyboxTag(FOURCC('CMDL'), mlvl.worldSkyboxId.toUint64());
|
2018-12-08 05:30:43 +00:00
|
|
|
if (skyboxTag) {
|
|
|
|
listOut.push_back(skyboxTag);
|
|
|
|
hecl::ProjectPath skyboxPath = pathFromTag(skyboxTag);
|
|
|
|
if (btok.getBlenderConnection().openBlend(skyboxPath)) {
|
|
|
|
auto data = btok.getBlenderConnection().beginData();
|
|
|
|
std::vector<hecl::ProjectPath> textures = data.getTextures();
|
|
|
|
for (const auto& tex : textures) {
|
2021-04-10 08:42:06 +00:00
|
|
|
metaforce::SObjectTag texTag = tagFromPath(tex);
|
2018-12-08 05:30:43 +00:00
|
|
|
if (!texTag)
|
2020-04-11 22:51:39 +00:00
|
|
|
Log.report(logvisor::Fatal, FMT_STRING(_SYS_STR("Unable to resolve {}")), tex.getRelativePath());
|
2018-12-08 05:30:43 +00:00
|
|
|
listOut.push_back(texTag);
|
2017-10-25 07:47:49 +00:00
|
|
|
}
|
2018-12-08 05:30:43 +00:00
|
|
|
}
|
2016-09-18 23:47:48 +00:00
|
|
|
}
|
|
|
|
|
2018-12-08 05:30:43 +00:00
|
|
|
listOut.push_back(worldTag);
|
|
|
|
|
|
|
|
w.writeUint32Big(atUint32(listOut.size()));
|
|
|
|
resTableOffset = w.position();
|
|
|
|
for (const auto& item : listOut) {
|
|
|
|
DNAMP1::PAK::Entry ent;
|
|
|
|
ent.compressed = 0;
|
|
|
|
ent.type = item.type;
|
2019-10-01 07:38:03 +00:00
|
|
|
ent.id = item.id.Value();
|
2018-12-08 05:30:43 +00:00
|
|
|
ent.size = 0;
|
|
|
|
ent.offset = 0;
|
|
|
|
ent.write(w);
|
2016-09-18 23:47:48 +00:00
|
|
|
}
|
2017-03-20 05:09:53 +00:00
|
|
|
|
|
|
|
{
|
2018-12-08 05:30:43 +00:00
|
|
|
std::vector<uint8_t>& mlvlOut = mlvlData[worldTag.id];
|
|
|
|
size_t mlvlSize = 0;
|
|
|
|
mlvl.binarySize(mlvlSize);
|
|
|
|
mlvlOut.resize(mlvlSize);
|
2019-10-01 07:38:03 +00:00
|
|
|
athena::io::MemoryWriter mw(&mlvlOut[0], mlvlSize);
|
|
|
|
mlvl.write(mw);
|
2018-12-08 05:30:43 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-04-10 08:42:06 +00:00
|
|
|
void buildPakList(hecl::blender::Token& btok, athena::io::FileWriter& w, const std::vector<metaforce::SObjectTag>& list,
|
|
|
|
const std::vector<std::pair<metaforce::SObjectTag, std::string>>& nameList,
|
2020-04-15 07:56:59 +00:00
|
|
|
atUint64& resTableOffset) override {
|
2018-12-08 05:30:43 +00:00
|
|
|
w.writeUint32Big(m_pc ? 0x80030005 : 0x00030005);
|
|
|
|
w.writeUint32Big(0);
|
|
|
|
|
|
|
|
w.writeUint32Big(atUint32(nameList.size()));
|
|
|
|
for (const auto& item : nameList) {
|
|
|
|
DNAMP1::PAK::NameEntry nameEnt;
|
|
|
|
nameEnt.type = item.first.type;
|
2019-10-01 07:38:03 +00:00
|
|
|
nameEnt.id = item.first.id.Value();
|
2018-12-08 05:30:43 +00:00
|
|
|
nameEnt.nameLen = atUint32(item.second.size());
|
|
|
|
nameEnt.name = item.second;
|
|
|
|
nameEnt.write(w);
|
2017-03-20 05:09:53 +00:00
|
|
|
}
|
|
|
|
|
2018-12-08 05:30:43 +00:00
|
|
|
w.writeUint32Big(atUint32(list.size()));
|
|
|
|
resTableOffset = w.position();
|
|
|
|
for (const auto& item : list) {
|
|
|
|
DNAMP1::PAK::Entry ent;
|
|
|
|
ent.compressed = 0;
|
|
|
|
ent.type = item.type;
|
2019-10-01 07:38:03 +00:00
|
|
|
ent.id = item.id.Value();
|
2018-12-08 05:30:43 +00:00
|
|
|
ent.size = 0;
|
|
|
|
ent.offset = 0;
|
|
|
|
ent.write(w);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-04-10 08:42:06 +00:00
|
|
|
void writePakFileIndex(athena::io::FileWriter& w, const std::vector<metaforce::SObjectTag>& tags,
|
2019-08-10 02:32:48 +00:00
|
|
|
const std::vector<std::tuple<size_t, size_t, bool>>& index, atUint64 resTableOffset) override {
|
2019-09-08 01:01:16 +00:00
|
|
|
w.seek(resTableOffset, athena::SeekOrigin::Begin);
|
2018-12-08 05:30:43 +00:00
|
|
|
|
|
|
|
auto it = tags.begin();
|
|
|
|
for (const auto& item : index) {
|
2021-04-10 08:42:06 +00:00
|
|
|
const metaforce::SObjectTag& tag = *it++;
|
2018-12-08 05:30:43 +00:00
|
|
|
DNAMP1::PAK::Entry ent;
|
|
|
|
ent.compressed = atUint32(std::get<2>(item));
|
|
|
|
ent.type = tag.type;
|
2019-10-01 07:38:03 +00:00
|
|
|
ent.id = tag.id.Value();
|
2018-12-08 05:30:43 +00:00
|
|
|
ent.size = atUint32(std::get<1>(item));
|
|
|
|
ent.offset = atUint32(std::get<0>(item));
|
|
|
|
ent.write(w);
|
2017-03-20 05:09:53 +00:00
|
|
|
}
|
2018-12-08 05:30:43 +00:00
|
|
|
}
|
|
|
|
|
2021-04-10 08:42:06 +00:00
|
|
|
std::pair<std::unique_ptr<uint8_t[]>, size_t> compressPakData(const metaforce::SObjectTag& tag, const uint8_t* data,
|
2019-08-10 02:32:48 +00:00
|
|
|
size_t len) override {
|
2018-12-08 05:30:43 +00:00
|
|
|
bool doCompress = false;
|
2019-07-20 04:27:21 +00:00
|
|
|
switch (tag.type.toUint32()) {
|
2018-12-08 05:30:43 +00:00
|
|
|
case SBIG('TXTR'):
|
|
|
|
case SBIG('CMDL'):
|
|
|
|
case SBIG('CSKR'):
|
|
|
|
case SBIG('ANCS'):
|
|
|
|
case SBIG('ANIM'):
|
|
|
|
case SBIG('FONT'):
|
|
|
|
doCompress = true;
|
|
|
|
break;
|
|
|
|
case SBIG('PART'):
|
|
|
|
case SBIG('ELSC'):
|
|
|
|
case SBIG('SWHC'):
|
|
|
|
case SBIG('WPSC'):
|
|
|
|
case SBIG('DPSC'):
|
|
|
|
case SBIG('CRSC'):
|
|
|
|
doCompress = len >= 0x400;
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
if (!doCompress)
|
|
|
|
return {};
|
|
|
|
|
|
|
|
uLong destLen = compressBound(len);
|
|
|
|
std::pair<std::unique_ptr<uint8_t[]>, size_t> ret;
|
|
|
|
ret.first.reset(new uint8_t[destLen]);
|
|
|
|
compress2(ret.first.get(), &destLen, data, len, Z_BEST_COMPRESSION);
|
|
|
|
ret.second = destLen;
|
|
|
|
return ret;
|
|
|
|
};
|
|
|
|
|
2019-08-10 02:32:48 +00:00
|
|
|
void cookAudioGroup(const hecl::ProjectPath& out, const hecl::ProjectPath& in, FCookProgress progress) override {
|
2018-12-08 05:30:43 +00:00
|
|
|
DNAMP1::AGSC::Cook(in, out);
|
|
|
|
progress(_SYS_STR("Done"));
|
|
|
|
}
|
|
|
|
|
2019-08-10 02:32:48 +00:00
|
|
|
void cookSong(const hecl::ProjectPath& out, const hecl::ProjectPath& in, FCookProgress progress) override {
|
2018-12-08 05:30:43 +00:00
|
|
|
DNAMP1::CSNG::Cook(in, out);
|
|
|
|
progress(_SYS_STR("Done"));
|
|
|
|
}
|
|
|
|
|
|
|
|
void cookMapArea(const hecl::ProjectPath& out, const hecl::ProjectPath& in, BlendStream& ds,
|
2019-08-10 02:32:48 +00:00
|
|
|
hecl::blender::Token& btok, FCookProgress progress) override {
|
2018-12-08 05:30:43 +00:00
|
|
|
hecl::blender::MapArea mapa = ds.compileMapArea();
|
|
|
|
ds.close();
|
|
|
|
DNAMP1::MAPA::Cook(mapa, out);
|
|
|
|
progress(_SYS_STR("Done"));
|
|
|
|
}
|
|
|
|
|
|
|
|
void cookMapUniverse(const hecl::ProjectPath& out, const hecl::ProjectPath& in, BlendStream& ds,
|
2019-08-10 02:32:48 +00:00
|
|
|
hecl::blender::Token& btok, FCookProgress progress) override {
|
2018-12-08 05:30:43 +00:00
|
|
|
hecl::blender::MapUniverse mapu = ds.compileMapUniverse();
|
|
|
|
ds.close();
|
|
|
|
DNAMAPU::MAPU::Cook(mapu, out);
|
|
|
|
progress(_SYS_STR("Done"));
|
|
|
|
}
|
2015-07-01 23:50:39 +00:00
|
|
|
};
|
|
|
|
|
2017-01-31 11:21:45 +00:00
|
|
|
hecl::Database::DataSpecEntry SpecEntMP1 = {
|
2019-05-08 03:50:21 +00:00
|
|
|
_SYS_STR("MP1"sv), _SYS_STR("Data specification for original Metroid Prime engine"sv), _SYS_STR(".pak"sv),
|
2018-03-28 08:09:41 +00:00
|
|
|
[](hecl::Database::Project& project, hecl::Database::DataSpecTool) -> std::unique_ptr<hecl::Database::IDataSpec> {
|
2018-12-08 05:30:43 +00:00
|
|
|
return std::make_unique<SpecMP1>(&SpecEntMP1, project, false);
|
2017-01-31 11:21:45 +00:00
|
|
|
}};
|
2015-07-01 23:50:39 +00:00
|
|
|
|
2017-01-31 11:21:45 +00:00
|
|
|
hecl::Database::DataSpecEntry SpecEntMP1PC = {
|
2018-12-08 05:30:43 +00:00
|
|
|
_SYS_STR("MP1-PC"sv), _SYS_STR("Data specification for PC-optimized Metroid Prime engine"sv), _SYS_STR(".upak"sv),
|
|
|
|
[](hecl::Database::Project& project,
|
|
|
|
hecl::Database::DataSpecTool tool) -> std::unique_ptr<hecl::Database::IDataSpec> {
|
|
|
|
if (tool != hecl::Database::DataSpecTool::Extract)
|
|
|
|
return std::make_unique<SpecMP1>(&SpecEntMP1PC, project, true);
|
|
|
|
return {};
|
2017-01-31 11:21:45 +00:00
|
|
|
}};
|
2017-01-17 01:23:19 +00:00
|
|
|
|
2017-01-31 11:21:45 +00:00
|
|
|
hecl::Database::DataSpecEntry SpecEntMP1ORIG = {
|
2019-05-08 03:50:21 +00:00
|
|
|
_SYS_STR("MP1-ORIG"sv), _SYS_STR("Data specification for unmodified Metroid Prime resources"sv), {}, {}};
|
2018-12-08 05:30:43 +00:00
|
|
|
} // namespace DataSpec
|