mirror of
https://github.com/AxioDL/metaforce.git
synced 2025-12-14 16:06:10 +00:00
Merge remote-tracking branch 'origin/master' into hsh
This commit is contained in:
@@ -3,11 +3,12 @@
|
||||
#include <cstdlib>
|
||||
#endif
|
||||
|
||||
#include "SpecBase.hpp"
|
||||
#include "Blender/BlenderSupport.hpp"
|
||||
#include "DNACommon/DNACommon.hpp"
|
||||
#include "DNACommon/TXTR.hpp"
|
||||
#include "AssetNameMap.hpp"
|
||||
#include "DataSpec/SpecBase.hpp"
|
||||
#include "DataSpec/Blender/BlenderSupport.hpp"
|
||||
#include "DataSpec/DNACommon/DNACommon.hpp"
|
||||
#include "DataSpec/DNACommon/TXTR.hpp"
|
||||
#include "DataSpec/AssetNameMap.hpp"
|
||||
#include "DataSpec/DNACommon/URDEVersionInfo.hpp"
|
||||
#include "hecl/ClientProcess.hpp"
|
||||
#include "nod/DiscBase.hpp"
|
||||
#include "nod/nod.hpp"
|
||||
@@ -38,11 +39,19 @@ static const hecl::SystemChar* MomErr[] = {_SYS_STR("Your metroid is in another
|
||||
|
||||
constexpr uint32_t MomErrCount = std::extent<decltype(MomErr)>::value;
|
||||
|
||||
static ERegion g_CurRegion = ERegion::Invalid;
|
||||
static bool g_CurSpecIsWii = false;
|
||||
|
||||
ERegion getCurrentRegion() { return g_CurRegion; }
|
||||
bool isCurrentSpecWii() { return g_CurSpecIsWii; }
|
||||
|
||||
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") {
|
||||
, m_masterShader(project.getProjectWorkingPath(), ".hecl/RetroMasterShader.blend")
|
||||
, m_region(ERegion::Invalid)
|
||||
, m_game(EGame::Invalid) {
|
||||
AssetNameMap::InitAssetNameMap();
|
||||
SpecBase::setThreadProject();
|
||||
}
|
||||
@@ -75,20 +84,25 @@ bool SpecBase::canExtract(const ExtractPassInfo& info, std::vector<ExtractReport
|
||||
if (m_standalone && !checkStandaloneID(gameID))
|
||||
return false;
|
||||
|
||||
char region = m_disc->getHeader().m_gameID[3];
|
||||
m_region = ERegion(m_disc->getHeader().m_gameID[3]);
|
||||
const hecl::SystemString* regstr = ®NONE;
|
||||
switch (region) {
|
||||
case 'E':
|
||||
switch (m_region) {
|
||||
case ERegion::NTSC_U:
|
||||
regstr = ®E;
|
||||
break;
|
||||
case 'J':
|
||||
case ERegion::NTSC_J:
|
||||
regstr = ®J;
|
||||
break;
|
||||
case 'P':
|
||||
case ERegion::PAL:
|
||||
regstr = ®P;
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
setCurRegion(m_region);
|
||||
setCurSpecIsWii(m_isWii);
|
||||
|
||||
if (m_standalone)
|
||||
return checkFromStandaloneDisc(*m_disc, *regstr, info.extractArgs, reps);
|
||||
else
|
||||
@@ -126,8 +140,7 @@ bool IsPathAudioGroup(const hecl::ProjectPath& path) {
|
||||
}
|
||||
|
||||
static bool IsPathSong(const hecl::ProjectPath& path) {
|
||||
if (path.getPathType() != hecl::ProjectPath::Type::Glob ||
|
||||
!path.getWithExtension(_SYS_STR(".mid"), true).isFile() ||
|
||||
if (path.getPathType() != hecl::ProjectPath::Type::Glob || !path.getWithExtension(_SYS_STR(".mid"), true).isFile() ||
|
||||
!path.getWithExtension(_SYS_STR(".yaml"), true).isFile()) {
|
||||
return path.isFile() && path.getLastComponentExt() == _SYS_STR("mid") &&
|
||||
path.getWithExtension(_SYS_STR(".yaml"), true).isFile();
|
||||
@@ -309,7 +322,8 @@ void SpecBase::flattenDependenciesBlend(const hecl::ProjectPath& in, std::vector
|
||||
hecl::SystemStringConv chSysName(sub.name);
|
||||
if (!sub.cskrId.empty()) {
|
||||
hecl::SystemStringConv cskrSysName(sub.cskrId);
|
||||
pathsOut.push_back(asGlob.ensureAuxInfo(fmt::format(FMT_STRING(_SYS_STR("{}_{}.CSKR")), chSysName, cskrSysName)));
|
||||
pathsOut.push_back(
|
||||
asGlob.ensureAuxInfo(fmt::format(FMT_STRING(_SYS_STR("{}_{}.CSKR")), chSysName, cskrSysName)));
|
||||
} else {
|
||||
pathsOut.push_back(asGlob.ensureAuxInfo(fmt::format(FMT_STRING(_SYS_STR("{}.CSKR")), chSysName)));
|
||||
}
|
||||
@@ -325,7 +339,8 @@ void SpecBase::flattenDependenciesBlend(const hecl::ProjectPath& in, std::vector
|
||||
flattenDependenciesBlend(overlay.mesh, pathsOut, btok);
|
||||
pathsOut.push_back(overlay.mesh);
|
||||
}
|
||||
pathsOut.push_back(asGlob.ensureAuxInfo(fmt::format(FMT_STRING(_SYS_STR("{}.{}_{}.CSKR")), chSysName, overlaySys, overlayCskrId)));
|
||||
pathsOut.push_back(asGlob.ensureAuxInfo(
|
||||
fmt::format(FMT_STRING(_SYS_STR("{}.{}_{}.CSKR")), chSysName, overlaySys, overlayCskrId)));
|
||||
}
|
||||
}
|
||||
};
|
||||
@@ -343,7 +358,8 @@ void SpecBase::flattenDependenciesBlend(const hecl::ProjectPath& in, std::vector
|
||||
|
||||
hecl::SystemStringConv chSysName(att.name);
|
||||
hecl::SystemStringConv sysCskrId(att.cskrId);
|
||||
pathsOut.push_back(asGlob.ensureAuxInfo(fmt::format(FMT_STRING(_SYS_STR("ATTACH.{}_{}.CSKR")), chSysName, sysCskrId)));
|
||||
pathsOut.push_back(
|
||||
asGlob.ensureAuxInfo(fmt::format(FMT_STRING(_SYS_STR("ATTACH.{}_{}.CSKR")), chSysName, sysCskrId)));
|
||||
|
||||
if (att.armature >= 0) {
|
||||
const auto& arm = actor.armatures[att.armature];
|
||||
@@ -356,8 +372,9 @@ void SpecBase::flattenDependenciesBlend(const hecl::ProjectPath& in, std::vector
|
||||
hecl::SystemStringConv actSysName(act.first);
|
||||
hecl::SystemStringConv actAnimId(act.second);
|
||||
pathsOut.push_back(asGlob.ensureAuxInfo(fmt::format(FMT_STRING(_SYS_STR("{}_{}.ANIM")), actSysName, actAnimId)));
|
||||
hecl::SystemString searchPrefix(asGlob.getWithExtension(
|
||||
fmt::format(FMT_STRING(_SYS_STR(".{}_")), actSysName).c_str(), true).getLastComponent());
|
||||
hecl::SystemString searchPrefix(
|
||||
asGlob.getWithExtension(fmt::format(FMT_STRING(_SYS_STR(".{}_")), actSysName).c_str(), true)
|
||||
.getLastComponent());
|
||||
hecl::ProjectPath evntPath;
|
||||
for (const auto& ent : dEnum) {
|
||||
if (hecl::StringUtils::BeginsWith(ent.m_name, searchPrefix.c_str()) &&
|
||||
@@ -626,8 +643,7 @@ void SpecBase::doPackage(const hecl::ProjectPath& path, const hecl::Database::Da
|
||||
std::unordered_set<urde::SObjectTag> addedTags;
|
||||
addedTags.reserve(buildList.size());
|
||||
for (auto& tag : buildList) {
|
||||
if ((i == 0 && tag.type == FOURCC('CMDL')) ||
|
||||
(i == 1 && tag.type != FOURCC('CMDL'))) {
|
||||
if ((i == 0 && tag.type == FOURCC('CMDL')) || (i == 1 && tag.type != FOURCC('CMDL'))) {
|
||||
if (addedTags.find(tag) != addedTags.end())
|
||||
continue;
|
||||
addedTags.insert(tag);
|
||||
@@ -975,7 +991,7 @@ bool SpecBase::addFileToIndex(const hecl::ProjectPath& path, athena::io::YAMLDoc
|
||||
/* Classify intermediate into tag */
|
||||
urde::SObjectTag pathTag = buildTagFromPath(path);
|
||||
if (pathTag) {
|
||||
std::unique_lock<std::mutex> lk(m_backgroundIndexMutex);
|
||||
std::unique_lock lk{m_backgroundIndexMutex};
|
||||
bool useGlob = false;
|
||||
|
||||
/* Special multi-resource intermediates */
|
||||
@@ -1008,11 +1024,10 @@ bool SpecBase::addFileToIndex(const hecl::ProjectPath& path, athena::io::YAMLDoc
|
||||
hecl::SystemStringConv overlaySys(overlay.first);
|
||||
hecl::SystemStringConv overlayCskrId(overlay.second);
|
||||
if (!overlay.second.empty()) {
|
||||
subPath =
|
||||
asGlob.ensureAuxInfo(fmt::format(FMT_STRING(_SYS_STR("{}.{}_{}.CSKR")), subName, overlaySys, overlayCskrId));
|
||||
subPath = asGlob.ensureAuxInfo(
|
||||
fmt::format(FMT_STRING(_SYS_STR("{}.{}_{}.CSKR")), subName, overlaySys, overlayCskrId));
|
||||
} else {
|
||||
subPath =
|
||||
asGlob.ensureAuxInfo(fmt::format(FMT_STRING(_SYS_STR("{}.{}.CSKR")), subName, overlaySys));
|
||||
subPath = asGlob.ensureAuxInfo(fmt::format(FMT_STRING(_SYS_STR("{}.{}.CSKR")), subName, overlaySys));
|
||||
}
|
||||
insertPathTag(cacheWriter, buildTagFromPath(subPath), subPath);
|
||||
}
|
||||
@@ -1024,11 +1039,10 @@ bool SpecBase::addFileToIndex(const hecl::ProjectPath& path, athena::io::YAMLDoc
|
||||
hecl::SystemStringConv attachmentCskrId(attachment.second);
|
||||
hecl::ProjectPath subPath;
|
||||
if (!attachment.second.empty()) {
|
||||
subPath =
|
||||
asGlob.ensureAuxInfo(fmt::format(FMT_STRING(_SYS_STR("ATTACH.{}_{}.CSKR")), attachmentSys, attachmentCskrId));
|
||||
subPath = asGlob.ensureAuxInfo(
|
||||
fmt::format(FMT_STRING(_SYS_STR("ATTACH.{}_{}.CSKR")), attachmentSys, attachmentCskrId));
|
||||
} else {
|
||||
subPath =
|
||||
asGlob.ensureAuxInfo(fmt::format(FMT_STRING(_SYS_STR("ATTACH.{}.CSKR")), attachmentSys));
|
||||
subPath = asGlob.ensureAuxInfo(fmt::format(FMT_STRING(_SYS_STR("ATTACH.{}.CSKR")), attachmentSys));
|
||||
}
|
||||
insertPathTag(cacheWriter, buildTagFromPath(subPath), subPath);
|
||||
}
|
||||
@@ -1162,8 +1176,8 @@ void SpecBase::backgroundIndexProc() {
|
||||
}
|
||||
}
|
||||
}
|
||||
Log.report(logvisor::Info, FMT_STRING(_SYS_STR("Name index of '{}' loaded; {} names")), getOriginalSpec().m_name,
|
||||
m_catalogNameToTag.size());
|
||||
Log.report(logvisor::Info, FMT_STRING(_SYS_STR("Name index of '{}' loaded; {} names")),
|
||||
getOriginalSpec().m_name, m_catalogNameToTag.size());
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1206,4 +1220,23 @@ void SpecBase::waitForIndexComplete() const {
|
||||
}
|
||||
}
|
||||
|
||||
void SpecBase::WriteVersionInfo(hecl::Database::Project& project, const hecl::ProjectPath& pakPath) {
|
||||
hecl::ProjectPath versionPath(pakPath, _SYS_STR("version.yaml"));
|
||||
versionPath.makeDirChain(false);
|
||||
|
||||
URDEVersionInfo info;
|
||||
info.version = m_version;
|
||||
info.region = m_region;
|
||||
info.game = m_game;
|
||||
info.isTrilogy = !m_standalone;
|
||||
athena::io::FileWriter writer(versionPath.getAbsolutePath());
|
||||
athena::io::ToYAMLStream(info, writer);
|
||||
}
|
||||
void SpecBase::setCurRegion(ERegion region) {
|
||||
g_CurRegion = region;
|
||||
}
|
||||
void SpecBase::setCurSpecIsWii(bool isWii) {
|
||||
g_CurSpecIsWii = isWii;
|
||||
}
|
||||
|
||||
} // namespace DataSpec
|
||||
|
||||
Reference in New Issue
Block a user