2018-10-07 03:42:33 +00:00
|
|
|
#pragma once
|
2015-07-10 05:28:08 +00:00
|
|
|
|
2015-07-13 06:29:12 +00:00
|
|
|
#include <unordered_map>
|
2018-06-29 20:21:36 +00:00
|
|
|
#include "DataSpec/DNACommon/DNACommon.hpp"
|
|
|
|
#include "DataSpec/DNACommon/STRG.hpp"
|
2015-08-04 02:14:47 +00:00
|
|
|
#include "DNAMP1.hpp"
|
2015-07-10 05:28:08 +00:00
|
|
|
|
2018-12-08 05:30:43 +00:00
|
|
|
namespace DataSpec::DNAMP1 {
|
2015-07-10 05:28:08 +00:00
|
|
|
|
2018-12-08 05:30:43 +00:00
|
|
|
struct STRG : ISTRG {
|
2019-08-11 00:49:41 +00:00
|
|
|
AT_DECL_EXPLICIT_DNA_YAMLV
|
2018-12-08 05:30:43 +00:00
|
|
|
void _read(athena::io::IStreamReader& reader);
|
|
|
|
std::vector<std::pair<FourCC, std::vector<std::u16string>>> langs;
|
|
|
|
std::unordered_map<FourCC, std::vector<std::u16string>*> langMap;
|
2015-07-13 06:29:12 +00:00
|
|
|
|
2019-08-10 02:32:48 +00:00
|
|
|
int32_t lookupIdx(std::string_view name) const override { return -1; }
|
2015-07-10 05:28:08 +00:00
|
|
|
|
2019-08-10 02:32:48 +00:00
|
|
|
size_t count() const override {
|
2018-12-08 05:30:43 +00:00
|
|
|
size_t retval = 0;
|
|
|
|
for (const auto& item : langs) {
|
|
|
|
size_t sz = item.second.size();
|
|
|
|
if (sz > retval)
|
|
|
|
retval = sz;
|
2015-07-13 06:29:12 +00:00
|
|
|
}
|
2018-12-08 05:30:43 +00:00
|
|
|
return retval;
|
|
|
|
}
|
2019-08-10 02:32:48 +00:00
|
|
|
std::string getUTF8(const FourCC& lang, size_t idx) const override {
|
2018-12-08 05:30:43 +00:00
|
|
|
auto search = langMap.find(lang);
|
|
|
|
if (search != langMap.end())
|
|
|
|
return hecl::Char16ToUTF8(search->second->at(idx));
|
|
|
|
return std::string();
|
|
|
|
}
|
2019-08-10 02:32:48 +00:00
|
|
|
std::u16string getUTF16(const FourCC& lang, size_t idx) const override {
|
2018-12-08 05:30:43 +00:00
|
|
|
auto search = langMap.find(lang);
|
|
|
|
if (search != langMap.end())
|
|
|
|
return search->second->at(idx);
|
|
|
|
return std::u16string();
|
|
|
|
}
|
2015-07-16 01:57:34 +00:00
|
|
|
|
2018-12-08 05:30:43 +00:00
|
|
|
static bool Extract(PAKEntryReadStream& rs, const hecl::ProjectPath& outPath) {
|
|
|
|
STRG strg;
|
|
|
|
strg.read(rs);
|
|
|
|
athena::io::TransactionalFileWriter writer(outPath.getAbsolutePath());
|
|
|
|
athena::io::ToYAMLStream(strg, writer);
|
|
|
|
return true;
|
|
|
|
}
|
2015-07-22 19:05:18 +00:00
|
|
|
|
2018-12-08 05:30:43 +00:00
|
|
|
static bool Cook(const hecl::ProjectPath& inPath, const hecl::ProjectPath& outPath) {
|
|
|
|
STRG strg;
|
|
|
|
athena::io::FileReader reader(inPath.getAbsolutePath());
|
|
|
|
athena::io::FromYAMLStream(strg, reader);
|
|
|
|
athena::io::TransactionalFileWriter ws(outPath.getAbsolutePath());
|
|
|
|
strg.write(ws);
|
|
|
|
return true;
|
|
|
|
}
|
2015-07-22 19:05:18 +00:00
|
|
|
|
2018-12-08 05:30:43 +00:00
|
|
|
static bool Cook(const STRG& strg, const hecl::ProjectPath& outPath) {
|
|
|
|
athena::io::TransactionalFileWriter ws(outPath.getAbsolutePath());
|
|
|
|
strg.write(ws);
|
|
|
|
return true;
|
|
|
|
}
|
2016-03-28 21:38:48 +00:00
|
|
|
|
2019-08-10 02:32:48 +00:00
|
|
|
void gatherDependencies(std::vector<hecl::ProjectPath>& pathsOut) const override;
|
2015-07-10 05:28:08 +00:00
|
|
|
};
|
|
|
|
|
2018-12-08 05:30:43 +00:00
|
|
|
} // namespace DataSpec::DNAMP1
|