diff --git a/DataSpec/DNACommon/STRG.cpp b/DataSpec/DNACommon/STRG.cpp index 2f0e9354f..ef5a9591d 100644 --- a/DataSpec/DNACommon/STRG.cpp +++ b/DataSpec/DNACommon/STRG.cpp @@ -6,8 +6,6 @@ namespace Retro { -HECL::Database::ASListType ASTYPE_STRGLanguage("STRG", "Language", "string"); - std::unique_ptr LoadSTRG(Athena::io::IStreamReader& reader) { reader.setEndian(Athena::BigEndian); diff --git a/DataSpec/DNACommon/STRG.hpp b/DataSpec/DNACommon/STRG.hpp index abf87ea09..b45c430bd 100644 --- a/DataSpec/DNACommon/STRG.hpp +++ b/DataSpec/DNACommon/STRG.hpp @@ -3,7 +3,6 @@ #include #include -#include #include #include #include @@ -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 LoadSTRG(Athena::io::IStreamReader& reader); -extern HECL::Database::ASListType ASTYPE_STRGLanguage; - } #endif // __COMMON_STRG_HPP__ diff --git a/DataSpec/DNAMP1/ANCS.cpp b/DataSpec/DNAMP1/ANCS.cpp index df8af92a4..ebdc08136 100644 --- a/DataSpec/DNAMP1/ANCS.cpp +++ b/DataSpec/DNAMP1/ANCS.cpp @@ -10,7 +10,7 @@ void ANCS::CharacterSet::CharacterInfo::PASDatabase::AnimState::ParmInfo::read(A parmType = reader.readUint32(); unk1 = reader.readUint32(); unk2 = reader.readFloat(); - switch(DataType(parmType)) + switch (DataType(parmType)) { case DataType::DTInt32: parmVals[0].int32 = reader.readInt32(); @@ -37,7 +37,7 @@ void ANCS::CharacterSet::CharacterInfo::PASDatabase::AnimState::ParmInfo::write( writer.writeUint32(parmType); writer.writeUint32(unk1); writer.writeFloat(unk2); - switch(DataType(parmType)) + switch (DataType(parmType)) { case DataType::DTInt32: writer.writeInt32(parmVals[0].int32); @@ -65,7 +65,7 @@ void ANCS::CharacterSet::CharacterInfo::PASDatabase::AnimState::ParmInfo::fromYA unk1 = reader.readUint32("unk1"); unk2 = reader.readFloat("unk2"); reader.enterSubVector("parmVals"); - switch(DataType(parmType)) + switch (DataType(parmType)) { case DataType::DTInt32: parmVals[0].int32 = reader.readInt32(nullptr); @@ -95,7 +95,7 @@ void ANCS::CharacterSet::CharacterInfo::PASDatabase::AnimState::ParmInfo::toYAML writer.writeUint32("unk1", unk1); writer.writeFloat("unk2", unk2); writer.enterSubVector("parmVals"); - switch(DataType(parmType)) + switch (DataType(parmType)) { case DataType::DTInt32: writer.writeInt32(nullptr, parmVals[0].int32); @@ -124,23 +124,18 @@ 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(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) { - switch(ParmInfo::DataType(pi.parmType)) + switch (ParmInfo::DataType(pi.parmType)) { case ParmInfo::DTInt32: ai.parmVals.emplace_back(reader.readInt32()); @@ -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 @@ -179,7 +174,7 @@ void ANCS::CharacterSet::CharacterInfo::PASDatabase::AnimState::write(Athena::io ParmInfo::Parm pVal; if (it != ai.parmVals.end()) pVal = *it++; - switch(ParmInfo::DataType(pi.parmType)) + switch (ParmInfo::DataType(pi.parmType)) { case ParmInfo::DTInt32: writer.writeInt32(pVal.int32); @@ -206,28 +201,17 @@ 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("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"); for (const ParmInfo& pi : parmInfos) { - switch(ParmInfo::DataType(pi.parmType)) + switch (ParmInfo::DataType(pi.parmType)) { case ParmInfo::DTInt32: ai.parmVals.emplace_back(reader.readInt32(nullptr)); @@ -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("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"); @@ -278,7 +252,7 @@ void ANCS::CharacterSet::CharacterInfo::PASDatabase::AnimState::toYAML(Athena::i ParmInfo::Parm pVal; if (it != ai.parmVals.end()) pVal = *it++; - switch(ParmInfo::DataType(pi.parmType)) + switch (ParmInfo::DataType(pi.parmType)) { case ParmInfo::DTInt32: writer.writeInt32(nullptr, pVal.int32); @@ -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 5) { atUint32 elscCount = reader.readUint32(); - partResData.elsc.clear(); - partResData.elsc.reserve(elscCount); - for (int i=0 ; i 9) + { + unk2 = reader.readUint32(); + unk3 = reader.readUint32(); + } animAABBs.clear(); if (sectionCount > 1) { atUint32 aabbCount = reader.readUint32(); - animAABBs.reserve(aabbCount); - for (int i=0 ; i 2) { atUint32 effectCount = reader.readUint32(); - effects.reserve(effectCount); - for (int i=0 ; i 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 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 5) { atUint32 elscCount = reader.readUint32("elscCount"); - partResData.elsc.clear(); - partResData.elsc.reserve(elscCount); - reader.enterSubVector("elsc"); - for (int i=0 ; i 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 2) { atUint32 effectCount = reader.readUint32("effectCount"); - effects.reserve(effectCount); - reader.enterSubVector("effects"); - for (int i=0 ; i 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 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 1) { atUint32 additiveAnimCount = reader.readUint32(); - additiveAnims.reserve(additiveAnimCount); - for (int i=0 ; i 2) { atUint32 halfTransitionCount = reader.readUint32(); - halfTransitions.reserve(halfTransitionCount); - for (int i=0 ; i 3) { atUint32 animResourcesCount = reader.readUint32(); - animResources.reserve(animResourcesCount); - for (int i=0 ; i 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 1) { atUint32 additiveAnimCount = reader.readUint32("additiveAnimCount"); - additiveAnims.reserve(additiveAnimCount); - reader.enterSubVector("additiveAnims"); - for (int i=0 ; i 2) { atUint32 halfTransitionCount = reader.readUint32("halfTransitionCount"); - halfTransitions.reserve(halfTransitionCount); - reader.enterSubVector("halfTransitions"); - for (int i=0 ; i 3) { atUint32 animResourcesCount = reader.readUint32("animResourcesCount"); - animResources.reserve(animResourcesCount); - reader.enterSubVector("animResources"); - for (int i=0 ; i 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); } } diff --git a/DataSpec/DNAMP1/ANCS.hpp b/DataSpec/DNAMP1/ANCS.hpp index 4b242490e..2ca8ab5bf 100644 --- a/DataSpec/DNAMP1/ANCS.hpp +++ b/DataSpec/DNAMP1/ANCS.hpp @@ -20,6 +20,7 @@ struct ANCS : BigYAML Value characterCount; struct CharacterInfo : BigYAML { + DECL_YAML Delete expl; atUint32 idx; @@ -45,11 +46,13 @@ struct ANCS : BigYAML Value 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 parmInfos; @@ -90,12 +88,8 @@ struct ANCS : BigYAML std::vector parmVals; }; std::vector 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 animStates; } pasDatabase; struct ParticleResData @@ -106,7 +100,9 @@ struct ANCS : BigYAML std::vector 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 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 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 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 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 unk2; Value unk3; Value unk4; - }; struct MetaTransPhaseTrans : IMetaTrans { @@ -302,6 +287,7 @@ struct ANCS : BigYAML MetaTransFactory metaTrans; }; std::vector transitions; + MetaTransFactory defaultTransition; struct AdditiveAnimationInfo : BigYAML { @@ -330,12 +316,17 @@ struct ANCS : BigYAML UniqueID32 evntId; }; std::vector 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; + } }; } diff --git a/DataSpec/DNAMP1/DNAMP1.cpp b/DataSpec/DNAMP1/DNAMP1.cpp index 094bd1e00..594a78c4a 100644 --- a/DataSpec/DNAMP1/DNAMP1.cpp +++ b/DataSpec/DNAMP1/DNAMP1.cpp @@ -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::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"}; } diff --git a/DataSpec/DNAMP1/STRG.cpp b/DataSpec/DNAMP1/STRG.cpp index be516bc3a..13d7c1fbe 100644 --- a/DataSpec/DNAMP1/STRG.cpp +++ b/DataSpec/DNAMP1/STRG.cpp @@ -174,73 +174,5 @@ void STRG::toYAML(Athena::io::YAMLDocWriter& writer) const } } -bool STRG::readAngelScript(const AngelScript::asIScriptModule& in) -{ - std::wstring_convert> wconv; - - /* Validate pass */ - for (AngelScript::asUINT i=0 ; i& strsin = ASTYPE_STRGLanguage.vectorCast(in.GetAddressOfGlobalVar(i)); - std::vector 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>& item : langs) - langMap.emplace(item.first, &item.second); - - return true; -} - -void STRG::writeAngelScript(std::ofstream& out) const -{ - std::wstring_convert> wconv; - for (const std::pair>& 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"; - } -} - } } diff --git a/DataSpec/DNAMP1/STRG.hpp b/DataSpec/DNAMP1/STRG.hpp index a4f07f206..1e2589d1a 100644 --- a/DataSpec/DNAMP1/STRG.hpp +++ b/DataSpec/DNAMP1/STRG.hpp @@ -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; diff --git a/DataSpec/DNAMP2/STRG.cpp b/DataSpec/DNAMP2/STRG.cpp index 4014c497e..7b35c30e1 100644 --- a/DataSpec/DNAMP2/STRG.cpp +++ b/DataSpec/DNAMP2/STRG.cpp @@ -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> wconv; - for (const std::pair>& 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& name : names) - { - if (comma) - out << ","; - out << "\n "; - comma = true; - out << "{\"" << name.first << "\", " << name.second << "}"; - } - out << "\n});\n"; -} - } } diff --git a/DataSpec/DNAMP2/STRG.hpp b/DataSpec/DNAMP2/STRG.hpp index aeacc97af..9575c4afb 100644 --- a/DataSpec/DNAMP2/STRG.hpp +++ b/DataSpec/DNAMP2/STRG.hpp @@ -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; } }; diff --git a/DataSpec/DNAMP3/STRG.cpp b/DataSpec/DNAMP3/STRG.cpp index d721e2ab6..b5d92d2e6 100644 --- a/DataSpec/DNAMP3/STRG.cpp +++ b/DataSpec/DNAMP3/STRG.cpp @@ -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>& 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& name : names) - { - if (comma) - out << ","; - out << "\n "; - comma = true; - out << "{\"" << name.first << "\", " << name.second << "}"; - } - out << "\n});\n"; -} - } } diff --git a/DataSpec/DNAMP3/STRG.hpp b/DataSpec/DNAMP3/STRG.hpp index fb1079fed..d44d71c71 100644 --- a/DataSpec/DNAMP3/STRG.hpp +++ b/DataSpec/DNAMP3/STRG.hpp @@ -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 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; } };