diff --git a/DataSpec/DNAMP1/STRG.cpp b/DataSpec/DNAMP1/STRG.cpp index e42c2a990..b72bd37f6 100644 --- a/DataSpec/DNAMP1/STRG.cpp +++ b/DataSpec/DNAMP1/STRG.cpp @@ -6,30 +6,51 @@ namespace DataSpec namespace DNAMP1 { +const std::vector skLanguages = +{ + FOURCC('ENGL'), + FOURCC('FREN'), + FOURCC('GERM'), + FOURCC('SPAN'), + FOURCC('ITAL'), + FOURCC('DUTC'), + FOURCC('JAPN') +}; + void STRG::_read(athena::io::IStreamReader& reader) { atUint32 langCount = reader.readUint32Big(); atUint32 strCount = reader.readUint32Big(); - std::vector readLangs; + std::vector> readLangs; + readLangs.reserve(langCount); for (atUint32 l=0 ; l& lang : readLangs) { std::vector strs; - reader.seek(strCount * 4 + 4); + reader.seek(tablesStart + lang.second, athena::SeekOrigin::Begin); + reader.readUint32Big(); // table size + atUint32 langStart = reader.position(); for (atUint32 s=0 ; sm_mapChildren) { + if (lang.first == "DNAType") + continue; + if (lang.first.size() != 4) { Log.report(logvisor::Warning, "STRG language string '%s' must be exactly 4 characters; skipping", lang.first.c_str()); @@ -170,6 +194,9 @@ void STRG::read(athena::io::YAMLDocReader& reader) langs.clear(); for (const auto& lang : root->m_mapChildren) { + if (lang.first == "DNAType") + continue; + std::vector strs; for (const auto& str : lang.second->m_seqChildren) strs.emplace_back(hecl::UTF8ToWide(str->m_scalarString)); diff --git a/DataSpec/SpecMP1.cpp b/DataSpec/SpecMP1.cpp index 4ab863757..56c1b94e8 100644 --- a/DataSpec/SpecMP1.cpp +++ b/DataSpec/SpecMP1.cpp @@ -10,6 +10,7 @@ #include "DNAMP1/CMDL.hpp" #include "DNAMP1/MREA.hpp" #include "DNAMP1/ANCS.hpp" +#include "DNACommon/FONT.hpp" #include "DNACommon/PART.hpp" #include "DNACommon/SWHC.hpp" #include "DNACommon/ELSC.hpp" @@ -343,6 +344,8 @@ struct SpecMP1 : SpecBase return true; else if (!strcmp(classType, DNADGRP::DGRP::DNAType())) return true; + else if (!strcmp(classType, DNAFont::FONT::DNAType())) + return true; return false; }); } @@ -477,6 +480,12 @@ struct SpecMP1 : SpecBase dgrp.read(reader); DNADGRP::WriteDGRP(dgrp, out); } + else if (!classStr.compare(DNAFont::FONT::DNAType())) + { + DNAFont::FONT font; + font.read(reader); + DNAFont::WriteFONT(font, out); + } } progress(_S("Done")); } diff --git a/Editor/ProjectResourceFactoryMP1.cpp b/Editor/ProjectResourceFactoryMP1.cpp index aed22a0ec..5867ecd4b 100644 --- a/Editor/ProjectResourceFactoryMP1.cpp +++ b/Editor/ProjectResourceFactoryMP1.cpp @@ -7,6 +7,7 @@ #include "Runtime/Particle/CSwooshDescription.hpp" #include "Runtime/GuiSys/CGuiFrame.hpp" #include "Runtime/GuiSys/CRasterFont.hpp" +#include "Runtime/GuiSys/CStringTable.hpp" #include "Runtime/Graphics/CModel.hpp" #include "Runtime/Graphics/CTexture.hpp" #include "Runtime/Character/CCharLayoutInfo.hpp" @@ -44,6 +45,7 @@ ProjectResourceFactoryMP1::ProjectResourceFactoryMP1(hecl::ClientProcess& client m_factoryMgr.AddFactory(FOURCC('DCLN'), FFactoryFunc(FCollidableOBBTreeGroupFactory)); m_factoryMgr.AddFactory(FOURCC('DGRP'), FFactoryFunc(FDependencyGroupFactory)); m_factoryMgr.AddFactory(FOURCC('AGSC'), FMemFactoryFunc(FAudioGroupSetDataFactory)); + m_factoryMgr.AddFactory(FOURCC('STRG'), FFactoryFunc(FStringTableFactory)); } void ProjectResourceFactoryMP1::IndexMP1Resources(hecl::Database::Project& proj) @@ -128,8 +130,18 @@ SObjectTag ProjectResourceFactoryMP1::TagFromPath(const hecl::ProjectPath& path, } else if (!strcmp(className, "urde::DGRP")) { - resTag.type = SBIG('DGRP'); - return true; + resTag.type = SBIG('DGRP'); + return true; + } + else if (!strcmp(className, "urde::DNAMP1::STRG")) + { + resTag.type = SBIG('STRG'); + return true; + } + else if (!strcmp(className, "FONT")) + { + resTag.type = SBIG('FONT'); + return true; } return false; })) diff --git a/Runtime/GuiSys/CRasterFont.cpp b/Runtime/GuiSys/CRasterFont.cpp index c732dcff7..2d040d22c 100644 --- a/Runtime/GuiSys/CRasterFont.cpp +++ b/Runtime/GuiSys/CRasterFont.cpp @@ -32,7 +32,7 @@ CRasterFont::CRasterFont(urde::CInputStream& in, urde::IObjectStore& store) std::string name= in.readString(); u32 txtrId = in.readUint32Big(); x30_fontInfo = CFontInfo(tmp1, tmp2, tmp3, tmp4, name.c_str()); - x80_texture = store.GetObj({'TXTR', txtrId}); + x80_texture = store.GetObj({FOURCC('TXTR'), txtrId}); x2c_mode = EColorType(in.readUint32Big()); u32 glyphCount = in.readUint32Big(); @@ -84,7 +84,7 @@ void CRasterFont::SinglePassDrawString(const CDrawStringOptions& opts, int x, in const wchar_t* chr = str; const CGlyph* prevGlyph = nullptr; - while (*chr == '\0') + while (*chr != '\0') { const CGlyph* glyph = GetGlyph(*chr); if (glyph) diff --git a/Runtime/GuiSys/CStringTable.cpp b/Runtime/GuiSys/CStringTable.cpp index 4c0e1d8b0..bebb1fb96 100644 --- a/Runtime/GuiSys/CStringTable.cpp +++ b/Runtime/GuiSys/CStringTable.cpp @@ -27,7 +27,7 @@ void CStringTable::LoadStringTable(CInputStream &in) std::vector> langOffsets; for (u32 i = 0 ; i(x4_data.get() + i); + u16* chr = reinterpret_cast(x4_data.get() + i); *chr = hecl::SBig(*chr); } }