mirror of
https://github.com/AxioDL/metaforce.git
synced 2025-12-16 04:57:01 +00:00
AGSC/ATBL/CSNG extracting and cooking
This commit is contained in:
97
DataSpec/DNAMP2/AGSC.cpp
Normal file
97
DataSpec/DNAMP2/AGSC.cpp
Normal file
@@ -0,0 +1,97 @@
|
||||
#include "AGSC.hpp"
|
||||
|
||||
namespace DataSpec
|
||||
{
|
||||
namespace DNAMP2
|
||||
{
|
||||
|
||||
bool AGSC::Extract(PAKEntryReadStream& rs, const hecl::ProjectPath& outPath)
|
||||
{
|
||||
Header head;
|
||||
head.read(rs);
|
||||
|
||||
{
|
||||
hecl::ProjectPath poolPath = outPath.getWithExtension(_S(".pool"), true);
|
||||
athena::io::FileWriter w(poolPath.getAbsolutePath());
|
||||
w.writeBytes(rs.readBytes(head.poolSz).get(), head.poolSz);
|
||||
}
|
||||
|
||||
{
|
||||
hecl::ProjectPath projPath = outPath.getWithExtension(_S(".proj"), true);
|
||||
athena::io::FileWriter w(projPath.getAbsolutePath());
|
||||
w.writeBytes(rs.readBytes(head.projSz).get(), head.projSz);
|
||||
}
|
||||
|
||||
{
|
||||
hecl::ProjectPath sdirPath = outPath.getWithExtension(_S(".sdir"), true);
|
||||
athena::io::FileWriter w(sdirPath.getAbsolutePath());
|
||||
w.writeBytes(rs.readBytes(head.sdirSz).get(), head.sdirSz);
|
||||
}
|
||||
|
||||
{
|
||||
hecl::ProjectPath sampPath = outPath.getWithExtension(_S(".samp"), true);
|
||||
athena::io::FileWriter w(sampPath.getAbsolutePath());
|
||||
w.writeBytes(rs.readBytes(head.sampSz).get(), head.sampSz);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool AGSC::Cook(const hecl::ProjectPath& inPath, const hecl::ProjectPath& outPath)
|
||||
{
|
||||
athena::io::FileWriter w(outPath.getAbsolutePath());
|
||||
if (w.hasError())
|
||||
return false;
|
||||
|
||||
hecl::ProjectPath woExt = inPath.getWithExtension(nullptr, true);
|
||||
std::string lastComp = woExt.getLastComponentUTF8();
|
||||
if (hecl::StringUtils::EndsWith(lastComp, "_AGSC"))
|
||||
lastComp.assign(lastComp.cbegin(), lastComp.cend() - 5);
|
||||
|
||||
hecl::ProjectPath poolPath = inPath.getWithExtension(_S(".pool"), true);
|
||||
athena::io::FileReader poolR(poolPath.getAbsolutePath());
|
||||
if (poolR.hasError())
|
||||
return false;
|
||||
uint32_t poolLen = poolR.length();
|
||||
|
||||
hecl::ProjectPath projPath = inPath.getWithExtension(_S(".proj"), true);
|
||||
athena::io::FileReader projR(projPath.getAbsolutePath());
|
||||
if (projR.hasError())
|
||||
return false;
|
||||
uint32_t projLen = projR.length();
|
||||
|
||||
hecl::ProjectPath sdirPath = inPath.getWithExtension(_S(".sdir"), true);
|
||||
athena::io::FileReader sdirR(sdirPath.getAbsolutePath());
|
||||
if (sdirR.hasError())
|
||||
return false;
|
||||
uint32_t sdirLen = sdirR.length();
|
||||
|
||||
hecl::ProjectPath sampPath = inPath.getWithExtension(_S(".samp"), true);
|
||||
athena::io::FileReader sampR(sampPath.getAbsolutePath());
|
||||
if (sampR.hasError())
|
||||
return false;
|
||||
uint32_t sampLen = sampR.length();
|
||||
|
||||
projR.seek(4, athena::SeekOrigin::Begin);
|
||||
uint16_t groupId = projR.readUint16Big();
|
||||
projR.seek(0, athena::SeekOrigin::Begin);
|
||||
|
||||
Header head;
|
||||
head.groupName = lastComp;
|
||||
head.groupId = groupId;
|
||||
head.poolSz = poolLen;
|
||||
head.projSz = projLen;
|
||||
head.sdirSz = sdirLen;
|
||||
head.sampSz = sampLen;
|
||||
head.write(w);
|
||||
|
||||
w.writeBytes(poolR.readBytes(poolLen).get(), poolLen);
|
||||
w.writeBytes(projR.readBytes(projLen).get(), projLen);
|
||||
w.writeBytes(sdirR.readBytes(sdirLen).get(), sdirLen);
|
||||
w.writeBytes(sampR.readBytes(sampLen).get(), sampLen);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
32
DataSpec/DNAMP2/AGSC.hpp
Normal file
32
DataSpec/DNAMP2/AGSC.hpp
Normal file
@@ -0,0 +1,32 @@
|
||||
#ifndef _DNAMP2_AGSC_HPP_
|
||||
#define _DNAMP2_AGSC_HPP_
|
||||
|
||||
#include "../DNACommon/DNACommon.hpp"
|
||||
#include "DNAMP2.hpp"
|
||||
|
||||
namespace DataSpec
|
||||
{
|
||||
namespace DNAMP2
|
||||
{
|
||||
|
||||
class AGSC
|
||||
{
|
||||
struct Header : BigDNA
|
||||
{
|
||||
DECL_DNA
|
||||
String<-1> groupName;
|
||||
Value<atUint16> groupId = -1;
|
||||
Value<atUint32> poolSz = 0;
|
||||
Value<atUint32> projSz = 0;
|
||||
Value<atUint32> sdirSz = 0;
|
||||
Value<atUint32> sampSz = 0;
|
||||
};
|
||||
public:
|
||||
static bool Extract(PAKEntryReadStream& rs, const hecl::ProjectPath& outPath);
|
||||
static bool Cook(const hecl::ProjectPath& inPath, const hecl::ProjectPath& outPath);
|
||||
};
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
#endif // _DNAMP2_AGSC_HPP_
|
||||
@@ -5,7 +5,7 @@
|
||||
#include "../DNACommon/DNACommon.hpp"
|
||||
#include "../DNACommon/ANCS.hpp"
|
||||
#include "CMDLMaterials.hpp"
|
||||
#include "BlenderConnection.hpp"
|
||||
#include "hecl/Blender/BlenderConnection.hpp"
|
||||
#include "CINF.hpp"
|
||||
#include "CSKR.hpp"
|
||||
#include "ANIM.hpp"
|
||||
@@ -226,9 +226,9 @@ struct ANCS : BigYAML
|
||||
hecl::BlenderToken& btok,
|
||||
std::function<void(const hecl::SystemChar*)> fileChanged)
|
||||
{
|
||||
hecl::ProjectPath yamlPath = outPath.getWithExtension(_S(".yaml"));
|
||||
hecl::ProjectPath yamlPath = outPath.getWithExtension(_S(".yaml"), true);
|
||||
hecl::ProjectPath::Type yamlType = yamlPath.getPathType();
|
||||
hecl::ProjectPath blendPath = outPath.getWithExtension(_S(".blend"));
|
||||
hecl::ProjectPath blendPath = outPath.getWithExtension(_S(".blend"), true);
|
||||
hecl::ProjectPath::Type blendType = blendPath.getPathType();
|
||||
|
||||
if (force ||
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
#ifndef _DNAMP2_ANIM_HPP_
|
||||
#define _DNAMP2_ANIM_HPP_
|
||||
|
||||
#include "BlenderConnection.hpp"
|
||||
#include "hecl/Blender/BlenderConnection.hpp"
|
||||
#include "DNAMP2.hpp"
|
||||
#include "../DNACommon/ANIM.hpp"
|
||||
#include "../DNACommon/RigInverter.hpp"
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
#ifndef _DNAMP2_CINF_HPP_
|
||||
#define _DNAMP2_CINF_HPP_
|
||||
|
||||
#include "BlenderConnection.hpp"
|
||||
#include "hecl/Blender/BlenderConnection.hpp"
|
||||
#include "../DNACommon/DNACommon.hpp"
|
||||
#include "../DNACommon/RigInverter.hpp"
|
||||
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
make_dnalist(liblist
|
||||
MLVL
|
||||
ANIM
|
||||
AGSC
|
||||
ANCS
|
||||
CMDLMaterials
|
||||
CINF
|
||||
@@ -13,6 +14,7 @@ add_library(DNAMP2
|
||||
DNAMP2.hpp DNAMP2.cpp
|
||||
${liblist}
|
||||
ANIM.cpp
|
||||
AGSC.cpp
|
||||
CINF.cpp
|
||||
ANCS.cpp
|
||||
CMDL.hpp
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
#ifndef _DNAMP2_CSKR_HPP_
|
||||
#define _DNAMP2_CSKR_HPP_
|
||||
|
||||
#include "BlenderConnection.hpp"
|
||||
#include "hecl/Blender/BlenderConnection.hpp"
|
||||
#include "../DNACommon/DNACommon.hpp"
|
||||
#include "CINF.hpp"
|
||||
#include "../DNAMP1/CSKR.hpp"
|
||||
|
||||
@@ -8,11 +8,14 @@
|
||||
#include "MAPA.hpp"
|
||||
#include "AFSM.hpp"
|
||||
#include "SAVW.hpp"
|
||||
#include "AGSC.hpp"
|
||||
#include "../DNAMP1/HINT.hpp"
|
||||
#include "../DNAMP1/CSNG.hpp"
|
||||
#include "../DNACommon/FSM2.hpp"
|
||||
#include "../DNACommon/TXTR.hpp"
|
||||
#include "../DNACommon/FONT.hpp"
|
||||
#include "../DNACommon/DGRP.hpp"
|
||||
#include "../DNACommon/ATBL.hpp"
|
||||
|
||||
namespace DataSpec
|
||||
{
|
||||
@@ -205,31 +208,37 @@ ResExtractor<PAKBridge> PAKBridge::LookupExtractor(const DNAMP1::PAK& pak, const
|
||||
switch (entry.type)
|
||||
{
|
||||
case SBIG('HINT'):
|
||||
return {DNAMP1::HINT::Extract, nullptr, {_S(".yaml")}};
|
||||
return {DNAMP1::HINT::Extract, {_S(".yaml")}};
|
||||
case SBIG('STRG'):
|
||||
return {STRG::Extract, nullptr, {_S(".yaml")}};
|
||||
return {STRG::Extract, {_S(".yaml")}};
|
||||
case SBIG('TXTR'):
|
||||
return {TXTR::Extract, nullptr, {_S(".png")}};
|
||||
return {TXTR::Extract, {_S(".png")}};
|
||||
case SBIG('AFSM'):
|
||||
return {AFSM::Extract, nullptr, {_S(".yaml")}};
|
||||
return {AFSM::Extract, {_S(".yaml")}};
|
||||
case SBIG('SAVW'):
|
||||
return {SAVWCommon::ExtractSAVW<SAVW>, nullptr, {_S(".yaml")}};
|
||||
return {SAVWCommon::ExtractSAVW<SAVW>, {_S(".yaml")}};
|
||||
case SBIG('CMDL'):
|
||||
return {nullptr, CMDL::Extract, {_S(".blend")}, 1};
|
||||
return {CMDL::Extract, {_S(".blend")}, 1};
|
||||
case SBIG('ANCS'):
|
||||
return {nullptr, ANCS::Extract, {_S(".yaml"), _S(".blend")}, 2};
|
||||
return {ANCS::Extract, {_S(".yaml"), _S(".blend")}, 2};
|
||||
case SBIG('MLVL'):
|
||||
return {nullptr, MLVL::Extract, {_S(".blend")}, 3};
|
||||
return {MLVL::Extract, {_S(".blend")}, 3};
|
||||
case SBIG('MREA'):
|
||||
return {nullptr, MREA::Extract, {_S(".blend")}, 4};
|
||||
return {MREA::Extract, {_S(".blend")}, 4};
|
||||
case SBIG('MAPA'):
|
||||
return {nullptr, MAPA::Extract, {_S(".blend")}, 4};
|
||||
return {MAPA::Extract, {_S(".blend")}, 4};
|
||||
case SBIG('FSM2'):
|
||||
return {DNAFSM2::ExtractFSM2<UniqueID32>, nullptr, {_S(".yaml")}};
|
||||
return {DNAFSM2::ExtractFSM2<UniqueID32>, {_S(".yaml")}};
|
||||
case SBIG('FONT'):
|
||||
return {DNAFont::ExtractFONT<UniqueID32>, nullptr, {_S(".yaml")}};
|
||||
return {DNAFont::ExtractFONT<UniqueID32>, {_S(".yaml")}};
|
||||
case SBIG('DGRP'):
|
||||
return {DNADGRP::ExtractDGRP<UniqueID32>, nullptr, {_S(".yaml")}};
|
||||
return {DNADGRP::ExtractDGRP<UniqueID32>, {_S(".yaml")}};
|
||||
case SBIG('AGSC'):
|
||||
return {AGSC::Extract, {_S(".pool"), _S(".proj"), _S(".samp"), _S(".sdir")}};
|
||||
case SBIG('CSNG'):
|
||||
return {DNAMP1::CSNG::Extract, {_S(".mid"), _S(".yaml")}};
|
||||
case SBIG('ATBL'):
|
||||
return {DNAAudio::ATBL::Extract, {_S(".yaml")}};
|
||||
}
|
||||
return {};
|
||||
}
|
||||
|
||||
@@ -177,7 +177,7 @@ bool MREA::Extract(const SpecBase& dataSpec,
|
||||
/* We're not in a world pak, so lets keep the original name */
|
||||
mreaPath = outPath;
|
||||
|
||||
if (!force && mreaPath.getPathType() == hecl::ProjectPath::Type::File)
|
||||
if (!force && mreaPath.isFile())
|
||||
return true;
|
||||
|
||||
/* Do extract */
|
||||
|
||||
Reference in New Issue
Block a user