mirror of https://github.com/AxioDL/metaforce.git
ANCS fixes and cleanup
This commit is contained in:
parent
e0bf3a7024
commit
2d18e95a91
|
@ -6,8 +6,6 @@
|
|||
namespace Retro
|
||||
{
|
||||
|
||||
HECL::Database::ASListType<std::string> ASTYPE_STRGLanguage("STRG", "Language", "string");
|
||||
|
||||
std::unique_ptr<ISTRG> LoadSTRG(Athena::io::IStreamReader& reader)
|
||||
{
|
||||
reader.setEndian(Athena::BigEndian);
|
||||
|
|
|
@ -3,7 +3,6 @@
|
|||
|
||||
#include <string>
|
||||
#include <fstream>
|
||||
#include <angelscript.h>
|
||||
#include <HECL/HECL.hpp>
|
||||
#include <HECL/Database.hpp>
|
||||
#include <Athena/FileWriter.hpp>
|
||||
|
@ -20,14 +19,9 @@ struct ISTRG
|
|||
virtual std::wstring getUTF16(const FourCC& lang, size_t idx) const=0;
|
||||
virtual HECL::SystemString getSystemString(const FourCC& lang, size_t idx) const=0;
|
||||
virtual int32_t lookupIdx(const std::string& name) const=0;
|
||||
|
||||
virtual bool readAngelScript(const AngelScript::asIScriptModule& in)=0;
|
||||
virtual void writeAngelScript(std::ofstream& out) const=0;
|
||||
};
|
||||
std::unique_ptr<ISTRG> LoadSTRG(Athena::io::IStreamReader& reader);
|
||||
|
||||
extern HECL::Database::ASListType<std::string> ASTYPE_STRGLanguage;
|
||||
|
||||
}
|
||||
|
||||
#endif // __COMMON_STRG_HPP__
|
||||
|
|
|
@ -124,18 +124,13 @@ void ANCS::CharacterSet::CharacterInfo::PASDatabase::AnimState::read(Athena::io:
|
|||
atUint32 parmInfoCount = reader.readUint32();
|
||||
atUint32 animInfoCount = reader.readUint32();
|
||||
|
||||
parmInfos.reserve(parmInfoCount);
|
||||
for (int i=0 ; i<parmInfoCount ; ++i)
|
||||
{
|
||||
parmInfos.emplace_back();
|
||||
parmInfos.back().read(reader);
|
||||
}
|
||||
reader.enumerate(parmInfos, parmInfoCount);
|
||||
|
||||
animInfos.clear();
|
||||
animInfos.reserve(animInfoCount);
|
||||
for (int i=0 ; i<animInfoCount ; ++i)
|
||||
reader.enumerate<AnimInfo>(animInfos, animInfoCount,
|
||||
[this, parmInfoCount](Athena::io::IStreamReader& reader, AnimInfo& ai)
|
||||
{
|
||||
animInfos.emplace_back();
|
||||
AnimInfo& ai = animInfos.back();
|
||||
ai.id = reader.readUint32();
|
||||
ai.parmVals.reserve(parmInfoCount);
|
||||
for (const ParmInfo& pi : parmInfos)
|
||||
|
@ -158,7 +153,7 @@ void ANCS::CharacterSet::CharacterInfo::PASDatabase::AnimState::read(Athena::io:
|
|||
default: break;
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
void ANCS::CharacterSet::CharacterInfo::PASDatabase::AnimState::write(Athena::io::IStreamWriter& writer) const
|
||||
|
@ -206,22 +201,11 @@ void ANCS::CharacterSet::CharacterInfo::PASDatabase::AnimState::fromYAML(Athena:
|
|||
atUint32 parmInfoCount = reader.readUint32("parmInfoCount");
|
||||
atUint32 animInfoCount = reader.readUint32("animInfoCount");
|
||||
|
||||
parmInfos.reserve(parmInfoCount);
|
||||
reader.enterSubVector("parmInfos");
|
||||
for (int i=0 ; i<parmInfoCount ; ++i)
|
||||
{
|
||||
parmInfos.emplace_back();
|
||||
parmInfos.back().fromYAML(reader);
|
||||
}
|
||||
reader.leaveSubVector();
|
||||
reader.enumerate("parmInfos", parmInfos, parmInfoCount);
|
||||
|
||||
animInfos.reserve(animInfoCount);
|
||||
reader.enterSubVector("animInfos");
|
||||
for (int i=0 ; i<animInfoCount ; ++i)
|
||||
reader.enumerate<AnimInfo>("animInfos", animInfos, animInfoCount,
|
||||
[this, parmInfoCount](Athena::io::YAMLDocReader& reader, AnimInfo& ai)
|
||||
{
|
||||
animInfos.emplace_back();
|
||||
AnimInfo& ai = animInfos.back();
|
||||
reader.enterSubRecord(nullptr);
|
||||
ai.id = reader.readUint32("id");
|
||||
ai.parmVals.reserve(parmInfoCount);
|
||||
reader.enterSubVector("parmVals");
|
||||
|
@ -246,9 +230,7 @@ void ANCS::CharacterSet::CharacterInfo::PASDatabase::AnimState::fromYAML(Athena:
|
|||
}
|
||||
}
|
||||
reader.leaveSubVector();
|
||||
reader.leaveSubRecord();
|
||||
}
|
||||
reader.leaveSubVector();
|
||||
});
|
||||
}
|
||||
|
||||
void ANCS::CharacterSet::CharacterInfo::PASDatabase::AnimState::toYAML(Athena::io::YAMLDocWriter& writer) const
|
||||
|
@ -257,19 +239,11 @@ void ANCS::CharacterSet::CharacterInfo::PASDatabase::AnimState::toYAML(Athena::i
|
|||
writer.writeUint32("parmInfoCount", parmInfos.size());
|
||||
writer.writeUint32("animInfoCount", animInfos.size());
|
||||
|
||||
writer.enterSubVector("parmInfos");
|
||||
for (const ParmInfo& pi : parmInfos)
|
||||
{
|
||||
writer.enterSubRecord(nullptr);
|
||||
pi.toYAML(writer);
|
||||
writer.leaveSubRecord();
|
||||
}
|
||||
writer.leaveSubVector();
|
||||
writer.enumerate("parmInfos", parmInfos);
|
||||
|
||||
writer.enterSubVector("animInfos");
|
||||
for (const AnimInfo& ai : animInfos)
|
||||
writer.enumerate<AnimInfo>("animInfos", animInfos,
|
||||
[this](Athena::io::YAMLDocWriter& writer, const AnimInfo& ai)
|
||||
{
|
||||
writer.enterSubRecord("info");
|
||||
writer.writeUint32("id", ai.id);
|
||||
auto it = ai.parmVals.begin();
|
||||
writer.enterSubVector("parms");
|
||||
|
@ -297,9 +271,7 @@ void ANCS::CharacterSet::CharacterInfo::PASDatabase::AnimState::toYAML(Athena::i
|
|||
}
|
||||
}
|
||||
writer.leaveSubVector();
|
||||
writer.leaveSubRecord();
|
||||
}
|
||||
writer.leaveSubVector();
|
||||
});
|
||||
}
|
||||
|
||||
void ANCS::CharacterSet::CharacterInfo::read(Athena::io::IStreamReader& reader)
|
||||
|
@ -312,78 +284,45 @@ void ANCS::CharacterSet::CharacterInfo::read(Athena::io::IStreamReader& reader)
|
|||
cinf.read(reader);
|
||||
|
||||
atUint32 animationCount = reader.readUint32();
|
||||
animations.reserve(animationCount);
|
||||
for (int i=0 ; i<animationCount ; ++i)
|
||||
{
|
||||
animations.emplace_back();
|
||||
animations.back().read(reader);
|
||||
}
|
||||
reader.enumerate(animations, animationCount);
|
||||
|
||||
pasDatabase.read(reader);
|
||||
|
||||
atUint32 partCount = reader.readUint32();
|
||||
partResData.part.clear();
|
||||
partResData.part.reserve(partCount);
|
||||
for (int i=0 ; i<partCount ; ++i)
|
||||
{
|
||||
partResData.part.emplace_back();
|
||||
partResData.part.back().read(reader);
|
||||
}
|
||||
reader.enumerate(partResData.part, partCount);
|
||||
|
||||
atUint32 swhcCount = reader.readUint32();
|
||||
partResData.swhc.clear();
|
||||
partResData.swhc.reserve(swhcCount);
|
||||
for (int i=0 ; i<swhcCount ; ++i)
|
||||
{
|
||||
partResData.swhc.emplace_back();
|
||||
partResData.swhc.back().read(reader);
|
||||
}
|
||||
reader.enumerate(partResData.swhc, swhcCount);
|
||||
|
||||
atUint32 unkCount = reader.readUint32();
|
||||
partResData.unk.clear();
|
||||
partResData.unk.reserve(unkCount);
|
||||
for (int i=0 ; i<unkCount ; ++i)
|
||||
{
|
||||
partResData.unk.emplace_back();
|
||||
partResData.unk.back().read(reader);
|
||||
}
|
||||
reader.enumerate(partResData.unk, unkCount);
|
||||
|
||||
partResData.elsc.clear();
|
||||
if (sectionCount > 5)
|
||||
{
|
||||
atUint32 elscCount = reader.readUint32();
|
||||
partResData.elsc.clear();
|
||||
partResData.elsc.reserve(elscCount);
|
||||
for (int i=0 ; i<elscCount ; ++i)
|
||||
{
|
||||
partResData.elsc.emplace_back();
|
||||
partResData.elsc.back().read(reader);
|
||||
}
|
||||
reader.enumerate(partResData.elsc, elscCount);
|
||||
}
|
||||
|
||||
unk1 = reader.readUint32();
|
||||
if (sectionCount > 9)
|
||||
{
|
||||
unk2 = reader.readUint32();
|
||||
unk3 = reader.readUint32();
|
||||
}
|
||||
|
||||
animAABBs.clear();
|
||||
if (sectionCount > 1)
|
||||
{
|
||||
atUint32 aabbCount = reader.readUint32();
|
||||
animAABBs.reserve(aabbCount);
|
||||
for (int i=0 ; i<aabbCount ; ++i)
|
||||
{
|
||||
animAABBs.emplace_back();
|
||||
animAABBs.back().read(reader);
|
||||
}
|
||||
reader.enumerate(animAABBs, aabbCount);
|
||||
}
|
||||
|
||||
effects.clear();
|
||||
if (sectionCount > 2)
|
||||
{
|
||||
atUint32 effectCount = reader.readUint32();
|
||||
effects.reserve(effectCount);
|
||||
for (int i=0 ; i<effectCount ; ++i)
|
||||
{
|
||||
effects.emplace_back();
|
||||
effects.back().read(reader);
|
||||
}
|
||||
reader.enumerate(effects, effectCount);
|
||||
}
|
||||
|
||||
if (sectionCount > 3)
|
||||
|
@ -396,9 +335,7 @@ void ANCS::CharacterSet::CharacterInfo::read(Athena::io::IStreamReader& reader)
|
|||
if (sectionCount > 4)
|
||||
{
|
||||
atUint32 aidxCount = reader.readUint32();
|
||||
animIdxs.reserve(aidxCount);
|
||||
for (int i=0 ; i<aidxCount ; ++i)
|
||||
animIdxs.emplace_back(reader.readUint32());
|
||||
reader.enumerate(animIdxs, aidxCount);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -407,7 +344,9 @@ void ANCS::CharacterSet::CharacterInfo::write(Athena::io::IStreamWriter& writer)
|
|||
writer.writeUint32(idx);
|
||||
|
||||
atUint16 sectionCount;
|
||||
if (partResData.elsc.size())
|
||||
if (unk2 || unk3)
|
||||
sectionCount = 10;
|
||||
else if (partResData.elsc.size())
|
||||
sectionCount = 6;
|
||||
else if (animIdxs.size())
|
||||
sectionCount = 5;
|
||||
|
@ -427,44 +366,42 @@ void ANCS::CharacterSet::CharacterInfo::write(Athena::io::IStreamWriter& writer)
|
|||
cinf.write(writer);
|
||||
|
||||
writer.writeUint32(animations.size());
|
||||
for (const Animation& anim : animations)
|
||||
anim.write(writer);
|
||||
writer.enumerate(animations);
|
||||
|
||||
pasDatabase.write(writer);
|
||||
|
||||
writer.writeUint32(partResData.part.size());
|
||||
for (const UniqueID32& id : partResData.part)
|
||||
id.write(writer);
|
||||
writer.enumerate(partResData.part);
|
||||
|
||||
writer.writeUint32(partResData.swhc.size());
|
||||
for (const UniqueID32& id : partResData.swhc)
|
||||
id.write(writer);
|
||||
writer.enumerate(partResData.swhc);
|
||||
|
||||
writer.writeUint32(partResData.unk.size());
|
||||
for (const UniqueID32& id : partResData.unk)
|
||||
id.write(writer);
|
||||
writer.enumerate(partResData.unk);
|
||||
|
||||
if (sectionCount > 5)
|
||||
{
|
||||
writer.writeUint32(partResData.elsc.size());
|
||||
for (const UniqueID32& id : partResData.elsc)
|
||||
id.write(writer);
|
||||
writer.enumerate(partResData.elsc);
|
||||
}
|
||||
|
||||
writer.writeUint32(unk1);
|
||||
if (sectionCount > 9)
|
||||
{
|
||||
writer.writeUint32(unk2);
|
||||
writer.writeUint32(unk3);
|
||||
}
|
||||
|
||||
if (sectionCount > 1)
|
||||
{
|
||||
writer.writeUint32(animAABBs.size());
|
||||
for (const ActionAABB& aabb : animAABBs)
|
||||
aabb.write(writer);
|
||||
writer.enumerate(animAABBs);
|
||||
}
|
||||
|
||||
if (sectionCount > 2)
|
||||
{
|
||||
writer.writeUint32(effects.size());
|
||||
for (const Effect& effect : effects)
|
||||
effect.write(writer);
|
||||
writer.enumerate(effects);
|
||||
}
|
||||
|
||||
if (sectionCount > 3)
|
||||
|
@ -486,140 +423,63 @@ void ANCS::CharacterSet::CharacterInfo::fromYAML(Athena::io::YAMLDocReader& read
|
|||
idx = reader.readUint32("idx");
|
||||
atUint16 sectionCount = reader.readUint16("sectionCount");
|
||||
name = reader.readString("name");
|
||||
reader.enterSubRecord("cmdl");
|
||||
cmdl.fromYAML(reader);
|
||||
reader.leaveSubRecord();
|
||||
reader.enterSubRecord("cskr");
|
||||
cskr.fromYAML(reader);
|
||||
reader.leaveSubRecord();
|
||||
reader.enterSubRecord("cinf");
|
||||
cinf.fromYAML(reader);
|
||||
reader.leaveSubRecord();
|
||||
reader.enumerate("cmdl", cmdl);
|
||||
reader.enumerate("cskr", cskr);
|
||||
reader.enumerate("cinf", cinf);
|
||||
|
||||
atUint32 animationCount = reader.readUint32("animationCount");
|
||||
animations.reserve(animationCount);
|
||||
reader.enterSubVector("animations");
|
||||
for (int i=0 ; i<animationCount ; ++i)
|
||||
{
|
||||
animations.emplace_back();
|
||||
reader.enterSubRecord(nullptr);
|
||||
animations.back().fromYAML(reader);
|
||||
reader.leaveSubRecord();
|
||||
}
|
||||
reader.leaveSubVector();
|
||||
reader.enumerate("animations", animations, animationCount);
|
||||
|
||||
reader.enterSubRecord("pasDatabase");
|
||||
pasDatabase.fromYAML(reader);
|
||||
reader.leaveSubRecord();
|
||||
reader.enumerate("pasDatabase", pasDatabase);
|
||||
|
||||
atUint32 partCount = reader.readUint32("partCount");
|
||||
partResData.part.clear();
|
||||
partResData.part.reserve(partCount);
|
||||
reader.enterSubVector("part");
|
||||
for (int i=0 ; i<partCount ; ++i)
|
||||
{
|
||||
partResData.part.emplace_back();
|
||||
reader.enterSubRecord(nullptr);
|
||||
partResData.part.back().fromYAML(reader);
|
||||
reader.leaveSubRecord();
|
||||
}
|
||||
reader.leaveSubVector();
|
||||
reader.enumerate("part", partResData.part, partCount);
|
||||
|
||||
atUint32 swhcCount = reader.readUint32("swhcCount");
|
||||
partResData.swhc.clear();
|
||||
partResData.swhc.reserve(swhcCount);
|
||||
reader.enterSubVector("swhc");
|
||||
for (int i=0 ; i<swhcCount ; ++i)
|
||||
{
|
||||
partResData.swhc.emplace_back();
|
||||
reader.enterSubRecord(nullptr);
|
||||
partResData.swhc.back().fromYAML(reader);
|
||||
reader.leaveSubRecord();
|
||||
}
|
||||
reader.leaveSubVector();
|
||||
reader.enumerate("swhc", partResData.swhc, swhcCount);
|
||||
|
||||
atUint32 unkCount = reader.readUint32("unkCount");
|
||||
partResData.unk.clear();
|
||||
partResData.unk.reserve(unkCount);
|
||||
reader.enterSubVector("unk");
|
||||
for (int i=0 ; i<unkCount ; ++i)
|
||||
{
|
||||
partResData.unk.emplace_back();
|
||||
reader.enterSubRecord(nullptr);
|
||||
partResData.unk.back().fromYAML(reader);
|
||||
reader.leaveSubRecord();
|
||||
}
|
||||
reader.leaveSubVector();
|
||||
reader.enumerate("unk", partResData.unk, unkCount);
|
||||
|
||||
partResData.elsc.clear();
|
||||
if (sectionCount > 5)
|
||||
{
|
||||
atUint32 elscCount = reader.readUint32("elscCount");
|
||||
partResData.elsc.clear();
|
||||
partResData.elsc.reserve(elscCount);
|
||||
reader.enterSubVector("elsc");
|
||||
for (int i=0 ; i<elscCount ; ++i)
|
||||
{
|
||||
partResData.elsc.emplace_back();
|
||||
reader.enterSubRecord(nullptr);
|
||||
partResData.elsc.back().fromYAML(reader);
|
||||
reader.leaveSubRecord();
|
||||
}
|
||||
reader.leaveSubVector();
|
||||
reader.enumerate("elsc", partResData.elsc, elscCount);
|
||||
}
|
||||
|
||||
unk1 = reader.readUint32("unk1");
|
||||
if (sectionCount > 9)
|
||||
{
|
||||
unk2 = reader.readUint32("unk2");
|
||||
unk3 = reader.readUint32("unk3");
|
||||
}
|
||||
|
||||
animAABBs.clear();
|
||||
if (sectionCount > 1)
|
||||
{
|
||||
atUint32 aabbCount = reader.readUint32("animAABBCount");
|
||||
animAABBs.reserve(aabbCount);
|
||||
reader.enterSubVector("animAABBs");
|
||||
for (int i=0 ; i<aabbCount ; ++i)
|
||||
{
|
||||
animAABBs.emplace_back();
|
||||
reader.enterSubRecord(nullptr);
|
||||
animAABBs.back().fromYAML(reader);
|
||||
reader.leaveSubRecord();
|
||||
}
|
||||
reader.leaveSubVector();
|
||||
reader.enumerate("part", animAABBs, aabbCount);
|
||||
}
|
||||
|
||||
effects.clear();
|
||||
if (sectionCount > 2)
|
||||
{
|
||||
atUint32 effectCount = reader.readUint32("effectCount");
|
||||
effects.reserve(effectCount);
|
||||
reader.enterSubVector("effects");
|
||||
for (int i=0 ; i<effectCount ; ++i)
|
||||
{
|
||||
effects.emplace_back();
|
||||
reader.enterSubRecord(nullptr);
|
||||
effects.back().fromYAML(reader);
|
||||
reader.leaveSubRecord();
|
||||
}
|
||||
reader.leaveSubVector();
|
||||
reader.enumerate("effects", effects, effectCount);
|
||||
}
|
||||
|
||||
if (sectionCount > 3)
|
||||
{
|
||||
reader.enterSubRecord("cmdlOverride");
|
||||
cmdlOverride.fromYAML(reader);
|
||||
reader.leaveSubRecord();
|
||||
reader.enterSubRecord("cskrOverride");
|
||||
cskrOverride.fromYAML(reader);
|
||||
reader.leaveSubRecord();
|
||||
reader.enumerate("cmdlOverride", cmdlOverride);
|
||||
reader.enumerate("cskrOverride", cskrOverride);
|
||||
}
|
||||
|
||||
animIdxs.clear();
|
||||
if (sectionCount > 4)
|
||||
{
|
||||
atUint32 animIdxCount = reader.readUint32("animIdxCount");
|
||||
animIdxs.reserve(animIdxCount);
|
||||
reader.enterSubVector("animIdxs");
|
||||
for (int i=0 ; i<animIdxCount ; ++i)
|
||||
animIdxs.emplace_back(reader.readUint32(nullptr));
|
||||
reader.leaveSubVector();
|
||||
reader.enumerate("animIdxs", animIdxs, animIdxCount);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -628,7 +488,9 @@ void ANCS::CharacterSet::CharacterInfo::toYAML(Athena::io::YAMLDocWriter& writer
|
|||
writer.writeUint32("idx", idx);
|
||||
|
||||
atUint16 sectionCount;
|
||||
if (partResData.elsc.size())
|
||||
if (unk2 || unk3)
|
||||
sectionCount = 10;
|
||||
else if (partResData.elsc.size())
|
||||
sectionCount = 6;
|
||||
else if (animIdxs.size())
|
||||
sectionCount = 5;
|
||||
|
@ -643,118 +505,59 @@ void ANCS::CharacterSet::CharacterInfo::toYAML(Athena::io::YAMLDocWriter& writer
|
|||
writer.writeUint16("sectionCount", sectionCount);
|
||||
|
||||
writer.writeString("name", name);
|
||||
writer.enterSubRecord("cmdl");
|
||||
cmdl.toYAML(writer);
|
||||
writer.leaveSubRecord();
|
||||
writer.enterSubRecord("cskr");
|
||||
cskr.toYAML(writer);
|
||||
writer.leaveSubRecord();
|
||||
writer.enterSubRecord("cinf");
|
||||
cinf.toYAML(writer);
|
||||
writer.leaveSubRecord();
|
||||
writer.enumerate("cmdl", cmdl);
|
||||
writer.enumerate("cskr", cskr);
|
||||
writer.enumerate("cinf", cinf);
|
||||
|
||||
writer.writeUint32("animationCount", animations.size());
|
||||
writer.enterSubVector("animations");
|
||||
for (const Animation& anim : animations)
|
||||
{
|
||||
writer.enterSubRecord(nullptr);
|
||||
anim.toYAML(writer);
|
||||
writer.leaveSubRecord();
|
||||
}
|
||||
writer.leaveSubVector();
|
||||
writer.enumerate("animations", animations);
|
||||
|
||||
writer.enterSubRecord("pasDatabase");
|
||||
pasDatabase.toYAML(writer);
|
||||
writer.leaveSubRecord();
|
||||
writer.enumerate("pasDatabase", pasDatabase);
|
||||
|
||||
writer.writeUint32("partCount", partResData.part.size());
|
||||
writer.enterSubVector("part");
|
||||
for (const UniqueID32& id : partResData.part)
|
||||
{
|
||||
writer.enterSubRecord(nullptr);
|
||||
id.toYAML(writer);
|
||||
writer.leaveSubRecord();
|
||||
}
|
||||
writer.leaveSubVector();
|
||||
writer.enumerate("part", partResData.part);
|
||||
|
||||
writer.writeUint32("swhcCount", partResData.swhc.size());
|
||||
writer.enterSubVector("swhc");
|
||||
for (const UniqueID32& id : partResData.swhc)
|
||||
{
|
||||
writer.enterSubRecord(nullptr);
|
||||
id.toYAML(writer);
|
||||
writer.leaveSubRecord();
|
||||
}
|
||||
writer.leaveSubVector();
|
||||
writer.enumerate("swhc", partResData.swhc);
|
||||
|
||||
writer.writeUint32("unkCount", partResData.unk.size());
|
||||
writer.enterSubVector("unk");
|
||||
for (const UniqueID32& id : partResData.unk)
|
||||
{
|
||||
writer.enterSubRecord(nullptr);
|
||||
id.toYAML(writer);
|
||||
writer.leaveSubRecord();
|
||||
}
|
||||
writer.leaveSubVector();
|
||||
writer.enumerate("unk", partResData.unk);
|
||||
|
||||
if (sectionCount > 5)
|
||||
{
|
||||
writer.writeUint32("elscCount", partResData.elsc.size());
|
||||
writer.enterSubVector("elsc");
|
||||
for (const UniqueID32& id : partResData.elsc)
|
||||
{
|
||||
writer.enterSubRecord(nullptr);
|
||||
id.toYAML(writer);
|
||||
writer.leaveSubRecord();
|
||||
}
|
||||
writer.leaveSubVector();
|
||||
writer.enumerate("elsc", partResData.elsc);
|
||||
}
|
||||
|
||||
writer.writeUint32("unk1", unk1);
|
||||
if (sectionCount > 9)
|
||||
{
|
||||
writer.writeUint32("unk2", unk2);
|
||||
writer.writeUint32("unk3", unk3);
|
||||
}
|
||||
|
||||
if (sectionCount > 1)
|
||||
{
|
||||
writer.writeUint32("animAABBCount", animAABBs.size());
|
||||
writer.enterSubVector("animAABBs");
|
||||
for (const ActionAABB& aabb : animAABBs)
|
||||
{
|
||||
writer.enterSubRecord(nullptr);
|
||||
aabb.toYAML(writer);
|
||||
writer.leaveSubRecord();
|
||||
}
|
||||
writer.leaveSubVector();
|
||||
writer.enumerate("animAABBs", animAABBs);
|
||||
}
|
||||
|
||||
if (sectionCount > 2)
|
||||
{
|
||||
writer.writeUint32("effectCount", effects.size());
|
||||
writer.enterSubVector("effects");
|
||||
for (const Effect& effect : effects)
|
||||
{
|
||||
writer.enterSubRecord(nullptr);
|
||||
effect.toYAML(writer);
|
||||
writer.leaveSubRecord();
|
||||
}
|
||||
writer.leaveSubVector();
|
||||
writer.enumerate("effects", effects);
|
||||
}
|
||||
|
||||
if (sectionCount > 3)
|
||||
{
|
||||
writer.enterSubRecord("cmdlOverride");
|
||||
cmdlOverride.toYAML(writer);
|
||||
writer.leaveSubRecord();
|
||||
writer.enterSubRecord("cskrOverride");
|
||||
cskrOverride.toYAML(writer);
|
||||
writer.leaveSubRecord();
|
||||
writer.enumerate("cmdlOverride", cmdlOverride);
|
||||
writer.enumerate("cskrOverride", cskrOverride);
|
||||
}
|
||||
|
||||
if (sectionCount > 4)
|
||||
{
|
||||
writer.writeUint32("animIdxCount", animIdxs.size());
|
||||
writer.enterSubVector("animIdxs");
|
||||
for (atUint32 idx : animIdxs)
|
||||
writer.writeUint32(nullptr, idx);
|
||||
writer.leaveSubVector();
|
||||
writer.enumerate("animIdxs", animIdxs);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -833,6 +636,14 @@ void ANCS::AnimationSet::MetaAnimFactory::fromYAML(Athena::io::YAMLDocReader& re
|
|||
|
||||
}
|
||||
|
||||
void ANCS::AnimationSet::MetaAnimFactory::toYAML(Athena::io::YAMLDocWriter& writer) const
|
||||
{
|
||||
if (!m_anim)
|
||||
return;
|
||||
writer.writeString("type", m_anim->m_typeStr);
|
||||
m_anim->toYAML(writer);
|
||||
}
|
||||
|
||||
void ANCS::AnimationSet::MetaTransFactory::read(Athena::io::IStreamReader& reader)
|
||||
{
|
||||
IMetaTrans::Type type(IMetaTrans::Type(reader.readUint32()));
|
||||
|
@ -905,67 +716,38 @@ void ANCS::AnimationSet::MetaTransFactory::toYAML(Athena::io::YAMLDocWriter& wri
|
|||
m_trans->toYAML(writer);
|
||||
}
|
||||
|
||||
void ANCS::AnimationSet::MetaAnimFactory::toYAML(Athena::io::YAMLDocWriter& writer) const
|
||||
{
|
||||
if (!m_anim)
|
||||
return;
|
||||
writer.writeString("type", m_anim->m_typeStr);
|
||||
m_anim->toYAML(writer);
|
||||
}
|
||||
|
||||
void ANCS::AnimationSet::read(Athena::io::IStreamReader& reader)
|
||||
{
|
||||
atUint16 sectionCount = reader.readUint16();
|
||||
|
||||
atUint32 animationCount = reader.readUint32();
|
||||
animations.reserve(animationCount);
|
||||
for (int i=0 ; i<animationCount ; ++i)
|
||||
{
|
||||
animations.emplace_back();
|
||||
animations.back().read(reader);
|
||||
}
|
||||
reader.enumerate(animations, animationCount);
|
||||
|
||||
atUint32 transitionCount = reader.readUint32();
|
||||
transitions.reserve(transitionCount);
|
||||
for (int i=0 ; i<transitionCount ; ++i)
|
||||
{
|
||||
transitions.emplace_back();
|
||||
transitions.back().read(reader);
|
||||
}
|
||||
reader.enumerate(transitions, transitionCount);
|
||||
defaultTransition.read(reader);
|
||||
|
||||
additiveAnims.clear();
|
||||
if (sectionCount > 1)
|
||||
{
|
||||
atUint32 additiveAnimCount = reader.readUint32();
|
||||
additiveAnims.reserve(additiveAnimCount);
|
||||
for (int i=0 ; i<additiveAnimCount ; ++i)
|
||||
{
|
||||
additiveAnims.emplace_back();
|
||||
additiveAnims.back().read(reader);
|
||||
}
|
||||
reader.enumerate(additiveAnims, additiveAnimCount);
|
||||
floatA = reader.readFloat();
|
||||
floatB = reader.readFloat();
|
||||
}
|
||||
|
||||
halfTransitions.clear();
|
||||
if (sectionCount > 2)
|
||||
{
|
||||
atUint32 halfTransitionCount = reader.readUint32();
|
||||
halfTransitions.reserve(halfTransitionCount);
|
||||
for (int i=0 ; i<halfTransitionCount ; ++i)
|
||||
{
|
||||
halfTransitions.emplace_back();
|
||||
halfTransitions.back().read(reader);
|
||||
}
|
||||
reader.enumerate(halfTransitions, halfTransitionCount);
|
||||
}
|
||||
|
||||
animResources.clear();
|
||||
if (sectionCount > 3)
|
||||
{
|
||||
atUint32 animResourcesCount = reader.readUint32();
|
||||
animResources.reserve(animResourcesCount);
|
||||
for (int i=0 ; i<animResourcesCount ; ++i)
|
||||
{
|
||||
animResources.emplace_back();
|
||||
animResources.back().read(reader);
|
||||
}
|
||||
reader.enumerate(animResources, animResourcesCount);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -984,18 +766,16 @@ void ANCS::AnimationSet::write(Athena::io::IStreamWriter& writer) const
|
|||
writer.writeUint16(sectionCount);
|
||||
|
||||
writer.writeUint32(animations.size());
|
||||
for (const auto& anim : animations)
|
||||
anim.write(writer);
|
||||
writer.enumerate(animations);
|
||||
|
||||
writer.writeUint32(transitions.size());
|
||||
for (const auto& trans : transitions)
|
||||
trans.write(writer);
|
||||
writer.enumerate(transitions);
|
||||
defaultTransition.write(writer);
|
||||
|
||||
if (sectionCount > 1)
|
||||
{
|
||||
writer.writeUint32(additiveAnims.size());
|
||||
for (const auto& aa : additiveAnims)
|
||||
aa.write(writer);
|
||||
writer.enumerate(additiveAnims);
|
||||
writer.writeFloat(floatA);
|
||||
writer.writeFloat(floatB);
|
||||
}
|
||||
|
@ -1003,15 +783,13 @@ void ANCS::AnimationSet::write(Athena::io::IStreamWriter& writer) const
|
|||
if (sectionCount > 2)
|
||||
{
|
||||
writer.writeUint32(halfTransitions.size());
|
||||
for (const auto& ht : halfTransitions)
|
||||
ht.write(writer);
|
||||
writer.enumerate(halfTransitions);
|
||||
}
|
||||
|
||||
if (sectionCount > 3)
|
||||
{
|
||||
writer.writeUint32(animResources.size());
|
||||
for (const auto& ar : animResources)
|
||||
ar.write(writer);
|
||||
writer.enumerate(animResources);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1020,74 +798,33 @@ void ANCS::AnimationSet::fromYAML(Athena::io::YAMLDocReader& reader)
|
|||
atUint16 sectionCount = reader.readUint16("sectionCount");
|
||||
|
||||
atUint32 animationCount = reader.readUint32("animationCount");
|
||||
animations.reserve(animationCount);
|
||||
reader.enterSubVector("animations");
|
||||
for (int i=0 ; i<animationCount ; ++i)
|
||||
{
|
||||
animations.emplace_back();
|
||||
reader.enterSubRecord(nullptr);
|
||||
animations.back().fromYAML(reader);
|
||||
reader.leaveSubRecord();
|
||||
}
|
||||
reader.leaveSubVector();
|
||||
reader.enumerate("animations", animations, animationCount);
|
||||
|
||||
atUint32 transitionCount = reader.readUint32("transitionCount");
|
||||
transitions.reserve(transitionCount);
|
||||
reader.enterSubVector("transitions");
|
||||
for (int i=0 ; i<transitionCount ; ++i)
|
||||
{
|
||||
transitions.emplace_back();
|
||||
reader.enterSubRecord(nullptr);
|
||||
transitions.back().fromYAML(reader);
|
||||
reader.leaveSubRecord();
|
||||
}
|
||||
reader.leaveSubVector();
|
||||
reader.enumerate("transitions", transitions, transitionCount);
|
||||
reader.enumerate("defaultTransition", defaultTransition);
|
||||
|
||||
additiveAnims.clear();
|
||||
if (sectionCount > 1)
|
||||
{
|
||||
atUint32 additiveAnimCount = reader.readUint32("additiveAnimCount");
|
||||
additiveAnims.reserve(additiveAnimCount);
|
||||
reader.enterSubVector("additiveAnims");
|
||||
for (int i=0 ; i<additiveAnimCount ; ++i)
|
||||
{
|
||||
additiveAnims.emplace_back();
|
||||
reader.enterSubRecord(nullptr);
|
||||
additiveAnims.back().fromYAML(reader);
|
||||
reader.leaveSubRecord();
|
||||
}
|
||||
reader.leaveSubVector();
|
||||
reader.enumerate("additiveAnims", additiveAnims, additiveAnimCount);
|
||||
floatA = reader.readFloat("floatA");
|
||||
floatB = reader.readFloat("floatB");
|
||||
}
|
||||
|
||||
halfTransitions.clear();
|
||||
if (sectionCount > 2)
|
||||
{
|
||||
atUint32 halfTransitionCount = reader.readUint32("halfTransitionCount");
|
||||
halfTransitions.reserve(halfTransitionCount);
|
||||
reader.enterSubVector("halfTransitions");
|
||||
for (int i=0 ; i<halfTransitionCount ; ++i)
|
||||
{
|
||||
halfTransitions.emplace_back();
|
||||
reader.enterSubRecord(nullptr);
|
||||
halfTransitions.back().fromYAML(reader);
|
||||
reader.leaveSubRecord();
|
||||
}
|
||||
reader.leaveSubVector();
|
||||
reader.enumerate("halfTransitions", halfTransitions, halfTransitionCount);
|
||||
}
|
||||
|
||||
animResources.clear();
|
||||
if (sectionCount > 3)
|
||||
{
|
||||
atUint32 animResourcesCount = reader.readUint32("animResourcesCount");
|
||||
animResources.reserve(animResourcesCount);
|
||||
reader.enterSubVector("animResources");
|
||||
for (int i=0 ; i<animResourcesCount ; ++i)
|
||||
{
|
||||
animResources.emplace_back();
|
||||
reader.enterSubRecord(nullptr);
|
||||
animResources.back().fromYAML(reader);
|
||||
reader.leaveSubRecord();
|
||||
}
|
||||
reader.leaveSubVector();
|
||||
reader.enumerate("animResources", animResources, animResourcesCount);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1106,36 +843,16 @@ void ANCS::AnimationSet::toYAML(Athena::io::YAMLDocWriter& writer) const
|
|||
writer.writeUint16("sectionCount", sectionCount);
|
||||
|
||||
writer.writeUint32("animationCount", animations.size());
|
||||
writer.enterSubVector("animations");
|
||||
for (const auto& anim : animations)
|
||||
{
|
||||
writer.enterSubRecord(nullptr);
|
||||
anim.toYAML(writer);
|
||||
writer.leaveSubRecord();
|
||||
}
|
||||
writer.leaveSubVector();
|
||||
writer.enumerate("animations", animations);
|
||||
|
||||
writer.writeUint32("transitionCount", transitions.size());
|
||||
writer.enterSubVector("transitions");
|
||||
for (const auto& trans : transitions)
|
||||
{
|
||||
writer.enterSubRecord(nullptr);
|
||||
trans.toYAML(writer);
|
||||
writer.leaveSubRecord();
|
||||
}
|
||||
writer.leaveSubVector();
|
||||
writer.enumerate("transitions", transitions);
|
||||
writer.enumerate("defaultTransition", defaultTransition);
|
||||
|
||||
if (sectionCount > 1)
|
||||
{
|
||||
writer.writeUint32("additiveAnimCount", additiveAnims.size());
|
||||
writer.enterSubVector("additiveAnims");
|
||||
for (const auto& aa : additiveAnims)
|
||||
{
|
||||
writer.enterSubRecord(nullptr);
|
||||
aa.toYAML(writer);
|
||||
writer.leaveSubRecord();
|
||||
}
|
||||
writer.leaveSubVector();
|
||||
writer.enumerate("additiveAnims", additiveAnims);
|
||||
writer.writeFloat("floatA", floatA);
|
||||
writer.writeFloat("floatB", floatB);
|
||||
}
|
||||
|
@ -1143,27 +860,13 @@ void ANCS::AnimationSet::toYAML(Athena::io::YAMLDocWriter& writer) const
|
|||
if (sectionCount > 2)
|
||||
{
|
||||
writer.writeUint32("halfTransitionCount", halfTransitions.size());
|
||||
writer.enterSubVector("halfTransitions");
|
||||
for (const auto& ht : halfTransitions)
|
||||
{
|
||||
writer.enterSubRecord(nullptr);
|
||||
ht.toYAML(writer);
|
||||
writer.leaveSubRecord();
|
||||
}
|
||||
writer.leaveSubVector();
|
||||
writer.enumerate("halfTransitions", halfTransitions);
|
||||
}
|
||||
|
||||
if (sectionCount > 3)
|
||||
{
|
||||
writer.writeUint32("animResourcesCount", animResources.size());
|
||||
writer.enterSubVector("animResources");
|
||||
for (const auto& ar : animResources)
|
||||
{
|
||||
writer.enterSubRecord(nullptr);
|
||||
ar.toYAML(writer);
|
||||
writer.leaveSubRecord();
|
||||
}
|
||||
writer.leaveSubVector();
|
||||
writer.enumerate("animResources", animResources);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -20,6 +20,7 @@ struct ANCS : BigYAML
|
|||
Value<atUint32> characterCount;
|
||||
struct CharacterInfo : BigYAML
|
||||
{
|
||||
DECL_YAML
|
||||
Delete expl;
|
||||
|
||||
atUint32 idx;
|
||||
|
@ -45,11 +46,13 @@ struct ANCS : BigYAML
|
|||
Value<atUint32> defaultState;
|
||||
struct AnimState : BigYAML
|
||||
{
|
||||
DECL_YAML
|
||||
Delete expl;
|
||||
atUint32 id;
|
||||
|
||||
struct ParmInfo : BigYAML
|
||||
{
|
||||
DECL_YAML
|
||||
Delete expl;
|
||||
enum DataType
|
||||
{
|
||||
|
@ -76,11 +79,6 @@ struct ANCS : BigYAML
|
|||
atUint32 unk1;
|
||||
float unk2;
|
||||
Parm parmVals[2];
|
||||
|
||||
void read(Athena::io::IStreamReader& reader);
|
||||
void write(Athena::io::IStreamWriter& writer) const;
|
||||
void fromYAML(Athena::io::YAMLDocReader& reader);
|
||||
void toYAML(Athena::io::YAMLDocWriter& writer) const;
|
||||
};
|
||||
std::vector<ParmInfo> parmInfos;
|
||||
|
||||
|
@ -90,12 +88,8 @@ struct ANCS : BigYAML
|
|||
std::vector<ParmInfo::Parm> parmVals;
|
||||
};
|
||||
std::vector<AnimInfo> animInfos;
|
||||
|
||||
void read(Athena::io::IStreamReader& reader);
|
||||
void write(Athena::io::IStreamWriter& writer) const;
|
||||
void fromYAML(Athena::io::YAMLDocReader& reader);
|
||||
void toYAML(Athena::io::YAMLDocWriter& writer) const;
|
||||
};
|
||||
Vector<AnimState, DNA_COUNT(animStateCount)> animStates;
|
||||
} pasDatabase;
|
||||
|
||||
struct ParticleResData
|
||||
|
@ -106,7 +100,9 @@ struct ANCS : BigYAML
|
|||
std::vector<UniqueID32> elsc;
|
||||
} partResData;
|
||||
|
||||
atUint32 unk1;
|
||||
atUint32 unk1 = 0;
|
||||
atUint32 unk2 = 0;
|
||||
atUint32 unk3 = 0;
|
||||
|
||||
struct ActionAABB : BigYAML
|
||||
{
|
||||
|
@ -140,17 +136,13 @@ struct ANCS : BigYAML
|
|||
UniqueID32 cskrOverride;
|
||||
|
||||
std::vector<atUint32> animIdxs;
|
||||
|
||||
void read(Athena::io::IStreamReader& reader);
|
||||
void write(Athena::io::IStreamWriter& writer) const;
|
||||
void fromYAML(Athena::io::YAMLDocReader& reader);
|
||||
void toYAML(Athena::io::YAMLDocWriter& writer) const;
|
||||
|
||||
};
|
||||
Vector<CharacterInfo, DNA_COUNT(characterCount)> characters;
|
||||
} characterSet;
|
||||
|
||||
struct AnimationSet : BigYAML
|
||||
{
|
||||
DECL_YAML
|
||||
Delete expl;
|
||||
|
||||
struct IMetaAnim : BigYAML
|
||||
|
@ -174,12 +166,9 @@ struct ANCS : BigYAML
|
|||
};
|
||||
struct MetaAnimFactory : BigYAML
|
||||
{
|
||||
DECL_YAML
|
||||
Delete expl;
|
||||
std::unique_ptr<IMetaAnim> m_anim;
|
||||
void read(Athena::io::IStreamReader& reader);
|
||||
void write(Athena::io::IStreamWriter& writer) const;
|
||||
void fromYAML(Athena::io::YAMLDocReader& reader);
|
||||
void toYAML(Athena::io::YAMLDocWriter& writer) const;
|
||||
};
|
||||
struct MetaAnimPrimitive : IMetaAnim
|
||||
{
|
||||
|
@ -258,12 +247,9 @@ struct ANCS : BigYAML
|
|||
};
|
||||
struct MetaTransFactory : BigYAML
|
||||
{
|
||||
DECL_YAML
|
||||
Delete expl;
|
||||
std::unique_ptr<IMetaTrans> m_trans;
|
||||
void read(Athena::io::IStreamReader& reader);
|
||||
void write(Athena::io::IStreamWriter& writer) const;
|
||||
void fromYAML(Athena::io::YAMLDocReader& reader);
|
||||
void toYAML(Athena::io::YAMLDocWriter& writer) const;
|
||||
};
|
||||
struct MetaTransMetaAnim : IMetaTrans
|
||||
{
|
||||
|
@ -280,7 +266,6 @@ struct ANCS : BigYAML
|
|||
Value<atUint8> unk2;
|
||||
Value<atUint8> unk3;
|
||||
Value<atUint32> unk4;
|
||||
|
||||
};
|
||||
struct MetaTransPhaseTrans : IMetaTrans
|
||||
{
|
||||
|
@ -302,6 +287,7 @@ struct ANCS : BigYAML
|
|||
MetaTransFactory metaTrans;
|
||||
};
|
||||
std::vector<Transition> transitions;
|
||||
MetaTransFactory defaultTransition;
|
||||
|
||||
struct AdditiveAnimationInfo : BigYAML
|
||||
{
|
||||
|
@ -330,12 +316,17 @@ struct ANCS : BigYAML
|
|||
UniqueID32 evntId;
|
||||
};
|
||||
std::vector<AnimationResources> animResources;
|
||||
|
||||
void read(Athena::io::IStreamReader& reader);
|
||||
void write(Athena::io::IStreamWriter& writer) const;
|
||||
void fromYAML(Athena::io::YAMLDocReader& reader);
|
||||
void toYAML(Athena::io::YAMLDocWriter& writer) const;
|
||||
} animationSet;
|
||||
|
||||
static bool Extract(const SpecBase&, PAKEntryReadStream& rs, const HECL::ProjectPath& outPath)
|
||||
{
|
||||
ANCS ancs;
|
||||
ancs.read(rs);
|
||||
FILE* fp = HECL::Fopen(outPath.getAbsolutePath().c_str(), _S("wb"));
|
||||
ancs.toYAMLFile(fp);
|
||||
fclose(fp);
|
||||
return true;
|
||||
}
|
||||
};
|
||||
|
||||
}
|
||||
|
|
|
@ -6,6 +6,7 @@
|
|||
#include "MLVL.hpp"
|
||||
#include "../DNACommon/TXTR.hpp"
|
||||
#include "CMDL.hpp"
|
||||
#include "ANCS.hpp"
|
||||
|
||||
namespace Retro
|
||||
{
|
||||
|
@ -181,6 +182,8 @@ ResExtractor<PAKBridge> PAKBridge::LookupExtractor(const PAK::Entry& entry)
|
|||
return {TXTR::Extract, nullptr, ".png"};
|
||||
case SBIG('CMDL'):
|
||||
return {nullptr, CMDL::Extract, ".blend", 1};
|
||||
case SBIG('ANCS'):
|
||||
return {ANCS::Extract, nullptr, ".yaml"};
|
||||
case SBIG('MLVL'):
|
||||
return {MLVL::Extract, nullptr, ".yaml"};
|
||||
}
|
||||
|
|
|
@ -174,73 +174,5 @@ void STRG::toYAML(Athena::io::YAMLDocWriter& writer) const
|
|||
}
|
||||
}
|
||||
|
||||
bool STRG::readAngelScript(const AngelScript::asIScriptModule& in)
|
||||
{
|
||||
std::wstring_convert<std::codecvt_utf8<wchar_t>> wconv;
|
||||
|
||||
/* Validate pass */
|
||||
for (AngelScript::asUINT i=0 ; i<in.GetGlobalVarCount() ; ++i)
|
||||
{
|
||||
const char* name;
|
||||
int typeId;
|
||||
if (in.GetGlobalVar(i, &name, 0, &typeId) < 0)
|
||||
continue;
|
||||
if (typeId == ASTYPE_STRGLanguage.getTypeID())
|
||||
{
|
||||
if (strlen(name) != 4)
|
||||
{
|
||||
Log.report(LogVisor::Error, "STRG language string '%s' from %s must be exactly 4 characters", name, in.GetName());
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* Read pass */
|
||||
langs.clear();
|
||||
for (AngelScript::asUINT i=0 ; i<in.GetGlobalVarCount() ; ++i)
|
||||
{
|
||||
const char* name;
|
||||
int typeId;
|
||||
if (in.GetGlobalVar(i, &name, 0, &typeId) < 0)
|
||||
continue;
|
||||
if (typeId == ASTYPE_STRGLanguage.getTypeID())
|
||||
{
|
||||
const std::vector<std::string*>& strsin = ASTYPE_STRGLanguage.vectorCast(in.GetAddressOfGlobalVar(i));
|
||||
std::vector<std::wstring> strs;
|
||||
for (const std::string* str : strsin)
|
||||
strs.emplace_back(wconv.from_bytes(*str));
|
||||
langs.emplace_back(FourCC(name), strs);
|
||||
}
|
||||
}
|
||||
|
||||
langMap.clear();
|
||||
langMap.reserve(langs.size());
|
||||
for (std::pair<FourCC, std::vector<std::wstring>>& item : langs)
|
||||
langMap.emplace(item.first, &item.second);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void STRG::writeAngelScript(std::ofstream& out) const
|
||||
{
|
||||
std::wstring_convert<std::codecvt_utf8<wchar_t>> wconv;
|
||||
for (const std::pair<FourCC, std::vector<std::wstring>>& lang : langs)
|
||||
{
|
||||
out << "STRG::Language " << lang.first.toString() << "({";
|
||||
bool comma = false;
|
||||
unsigned idx = 0;
|
||||
for (const std::wstring& str : lang.second)
|
||||
{
|
||||
if (comma)
|
||||
out << ",";
|
||||
out << "\n/* " << idx++ << " */ \"";
|
||||
out << wconv.to_bytes(str);
|
||||
out << "\"";
|
||||
comma = true;
|
||||
}
|
||||
out << "\n});\n";
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
@ -58,9 +58,6 @@ struct STRG : ISTRG, BigYAML
|
|||
return HECL::SystemString();
|
||||
}
|
||||
|
||||
bool readAngelScript(const AngelScript::asIScriptModule& in);
|
||||
void writeAngelScript(std::ofstream& out) const;
|
||||
|
||||
static bool Extract(const SpecBase& dataspec, PAKEntryReadStream& rs, const HECL::ProjectPath& outPath)
|
||||
{
|
||||
STRG strg;
|
||||
|
|
|
@ -139,43 +139,5 @@ void STRG::write(Athena::io::IStreamWriter& writer) const
|
|||
}
|
||||
}
|
||||
|
||||
bool STRG::readAngelScript(const AngelScript::asIScriptModule& in)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
void STRG::writeAngelScript(std::ofstream& out) const
|
||||
{
|
||||
std::wstring_convert<std::codecvt_utf8<wchar_t>> wconv;
|
||||
for (const std::pair<FourCC, std::vector<std::wstring>>& lang : langs)
|
||||
{
|
||||
out << "STRG::Language " << lang.first.toString() << "({";
|
||||
bool comma = false;
|
||||
unsigned idx = 0;
|
||||
for (const std::wstring& str : lang.second)
|
||||
{
|
||||
if (comma)
|
||||
out << ",";
|
||||
out << "\n/* " << idx++ << " */ \"";
|
||||
out << wconv.to_bytes(str);
|
||||
out << "\"";
|
||||
comma = true;
|
||||
}
|
||||
out << "\n});\n";
|
||||
}
|
||||
|
||||
out << "STRG::Names NAMES({";
|
||||
bool comma = false;
|
||||
for (const std::pair<std::string, int32_t>& name : names)
|
||||
{
|
||||
if (comma)
|
||||
out << ",";
|
||||
out << "\n ";
|
||||
comma = true;
|
||||
out << "{\"" << name.first << "\", " << name.second << "}";
|
||||
}
|
||||
out << "\n});\n";
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
@ -63,27 +63,13 @@ struct STRG : ISTRG, BigDNA
|
|||
return HECL::SystemString();
|
||||
}
|
||||
|
||||
bool readAngelScript(const AngelScript::asIScriptModule& in);
|
||||
void writeAngelScript(std::ofstream& out) const;
|
||||
|
||||
static bool Extract(const SpecBase& dataspec, PAKEntryReadStream& rs, const HECL::ProjectPath& outPath)
|
||||
{
|
||||
STRG strg;
|
||||
strg.read(rs);
|
||||
std::ofstream strgOut(outPath.getAbsolutePath());
|
||||
strg.writeAngelScript(strgOut);
|
||||
return true;
|
||||
}
|
||||
|
||||
static bool Cook(const HECL::ProjectPath& inPath, const HECL::ProjectPath& outPath)
|
||||
{
|
||||
STRG strg;
|
||||
HECL::Database::ASUniqueModule mod = HECL::Database::ASUniqueModule::CreateFromPath(inPath);
|
||||
if (!mod)
|
||||
return false;
|
||||
strg.readAngelScript(mod);
|
||||
Athena::io::FileWriter ws(outPath.getAbsolutePath());
|
||||
strg.write(ws);
|
||||
return true;
|
||||
}
|
||||
};
|
||||
|
|
|
@ -147,41 +147,5 @@ void STRG::write(Athena::io::IStreamWriter& writer) const
|
|||
}
|
||||
}
|
||||
|
||||
bool STRG::readAngelScript(const AngelScript::asIScriptModule& in)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
void STRG::writeAngelScript(std::ofstream& out) const
|
||||
{
|
||||
for (const std::pair<FourCC, std::vector<std::string>>& lang : langs)
|
||||
{
|
||||
out << "STRG::Language " << lang.first.toString() << "({";
|
||||
bool comma = false;
|
||||
unsigned idx = 0;
|
||||
for (const std::string& str : lang.second)
|
||||
{
|
||||
if (comma)
|
||||
out << ",";
|
||||
out << "\n/* " << idx++ << " */ \"";
|
||||
out << str << "\"";
|
||||
comma = true;
|
||||
}
|
||||
out << "\n});\n";
|
||||
}
|
||||
|
||||
out << "STRG::Names NAMES({";
|
||||
bool comma = false;
|
||||
for (const std::pair<std::string, int32_t>& name : names)
|
||||
{
|
||||
if (comma)
|
||||
out << ",";
|
||||
out << "\n ";
|
||||
comma = true;
|
||||
out << "{\"" << name.first << "\", " << name.second << "}";
|
||||
}
|
||||
out << "\n});\n";
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
@ -63,26 +63,13 @@ struct STRG : ISTRG, BigDNA
|
|||
return HECL::SystemString();
|
||||
}
|
||||
|
||||
bool readAngelScript(const AngelScript::asIScriptModule& in);
|
||||
void writeAngelScript(std::ofstream& out) const;
|
||||
|
||||
static bool Extract(const SpecBase& dataspec, PAKEntryReadStream& rs, const HECL::ProjectPath& outPath)
|
||||
{
|
||||
std::unique_ptr<ISTRG> strg = LoadSTRG(rs);
|
||||
std::ofstream strgOut(outPath.getAbsolutePath());
|
||||
strg->writeAngelScript(strgOut);
|
||||
return true;
|
||||
}
|
||||
|
||||
static bool Cook(const HECL::ProjectPath& inPath, const HECL::ProjectPath& outPath)
|
||||
{
|
||||
STRG strg;
|
||||
HECL::Database::ASUniqueModule mod = HECL::Database::ASUniqueModule::CreateFromPath(inPath);
|
||||
if (!mod)
|
||||
return false;
|
||||
strg.readAngelScript(mod);
|
||||
Athena::io::FileWriter ws(outPath.getAbsolutePath());
|
||||
strg.write(ws);
|
||||
return true;
|
||||
}
|
||||
};
|
||||
|
|
Loading…
Reference in New Issue