2015-07-10 05:28:08 +00:00
|
|
|
#ifndef __DNAMP1_STRG_HPP__
|
|
|
|
#define __DNAMP1_STRG_HPP__
|
|
|
|
|
2015-07-13 06:29:12 +00:00
|
|
|
#include <unordered_map>
|
2015-07-10 05:28:08 +00:00
|
|
|
#include "../DNACommon/DNACommon.hpp"
|
2015-07-13 06:29:12 +00:00
|
|
|
#include "../DNACommon/STRG.hpp"
|
2015-08-04 02:14:47 +00:00
|
|
|
#include "DNAMP1.hpp"
|
2015-07-10 05:28:08 +00:00
|
|
|
|
2016-02-13 09:02:47 +00:00
|
|
|
namespace DataSpec
|
2015-07-10 05:28:08 +00:00
|
|
|
{
|
|
|
|
namespace DNAMP1
|
|
|
|
{
|
|
|
|
|
2015-08-09 03:55:11 +00:00
|
|
|
struct STRG : ISTRG
|
2015-07-10 05:28:08 +00:00
|
|
|
{
|
2015-08-09 03:55:11 +00:00
|
|
|
DECL_YAML
|
|
|
|
Delete expl;
|
2016-03-04 23:04:53 +00:00
|
|
|
void _read(athena::io::IStreamReader& reader);
|
2017-01-24 07:41:33 +00:00
|
|
|
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
|
|
|
|
2017-11-13 06:19:18 +00:00
|
|
|
int32_t lookupIdx(std::string_view name) const {return -1;}
|
2015-07-10 05:28:08 +00:00
|
|
|
|
2017-01-26 08:09:22 +00:00
|
|
|
size_t count() const
|
2015-07-13 06:29:12 +00:00
|
|
|
{
|
|
|
|
size_t retval = 0;
|
2015-07-16 01:57:34 +00:00
|
|
|
for (const auto& item : langs)
|
2015-07-13 06:29:12 +00:00
|
|
|
{
|
|
|
|
size_t sz = item.second.size();
|
|
|
|
if (sz > retval)
|
|
|
|
retval = sz;
|
|
|
|
}
|
|
|
|
return retval;
|
|
|
|
}
|
2017-01-26 08:09:22 +00:00
|
|
|
std::string getUTF8(const FourCC& lang, size_t idx) const
|
2015-07-13 06:29:12 +00:00
|
|
|
{
|
2015-07-18 04:33:38 +00:00
|
|
|
auto search = langMap.find(lang);
|
|
|
|
if (search != langMap.end())
|
2017-01-24 07:41:33 +00:00
|
|
|
return hecl::Char16ToUTF8(search->second->at(idx));
|
2015-07-13 06:29:12 +00:00
|
|
|
return std::string();
|
|
|
|
}
|
2017-01-26 08:09:22 +00:00
|
|
|
std::u16string getUTF16(const FourCC& lang, size_t idx) const
|
2015-07-13 06:29:12 +00:00
|
|
|
{
|
2015-07-18 04:33:38 +00:00
|
|
|
auto search = langMap.find(lang);
|
|
|
|
if (search != langMap.end())
|
|
|
|
return search->second->at(idx);
|
2017-01-24 07:41:33 +00:00
|
|
|
return std::u16string();
|
2015-07-13 06:29:12 +00:00
|
|
|
}
|
2017-01-26 08:09:22 +00:00
|
|
|
hecl::SystemString getSystemString(const FourCC& lang, size_t idx) const
|
2015-07-10 05:28:08 +00:00
|
|
|
{
|
2015-07-18 04:33:38 +00:00
|
|
|
auto search = langMap.find(lang);
|
|
|
|
if (search != langMap.end())
|
2015-07-13 06:29:12 +00:00
|
|
|
#if HECL_UCS2
|
2017-01-24 07:59:32 +00:00
|
|
|
return hecl::Char16ToWide(search->second->at(idx));
|
2015-07-13 06:29:12 +00:00
|
|
|
#else
|
2017-01-24 07:41:33 +00:00
|
|
|
return hecl::Char16ToUTF8(search->second->at(idx));
|
2015-07-13 06:29:12 +00:00
|
|
|
#endif
|
2016-03-04 23:04:53 +00:00
|
|
|
return hecl::SystemString();
|
2015-07-13 06:29:12 +00:00
|
|
|
}
|
2015-07-16 01:57:34 +00:00
|
|
|
|
2016-03-04 23:04:53 +00:00
|
|
|
static bool Extract(PAKEntryReadStream& rs, const hecl::ProjectPath& outPath)
|
2015-07-22 19:05:18 +00:00
|
|
|
{
|
|
|
|
STRG strg;
|
|
|
|
strg.read(rs);
|
2017-01-27 02:22:52 +00:00
|
|
|
athena::io::TransactionalFileWriter writer(outPath.getAbsolutePath());
|
2016-08-22 03:47:48 +00:00
|
|
|
strg.toYAMLStream(writer);
|
2015-07-22 19:05:18 +00:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2016-03-04 23:04:53 +00:00
|
|
|
static bool Cook(const hecl::ProjectPath& inPath, const hecl::ProjectPath& outPath)
|
2015-07-22 19:05:18 +00:00
|
|
|
{
|
|
|
|
STRG strg;
|
2016-08-22 03:47:48 +00:00
|
|
|
athena::io::FileReader reader(inPath.getAbsolutePath());
|
|
|
|
strg.fromYAMLStream(reader);
|
2017-01-27 02:22:52 +00:00
|
|
|
athena::io::TransactionalFileWriter ws(outPath.getAbsolutePath());
|
2015-07-22 19:05:18 +00:00
|
|
|
strg.write(ws);
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2016-03-28 21:38:48 +00:00
|
|
|
static bool Cook(const STRG& strg, const hecl::ProjectPath& outPath)
|
|
|
|
{
|
2017-01-27 02:22:52 +00:00
|
|
|
athena::io::TransactionalFileWriter ws(outPath.getAbsolutePath());
|
2016-03-28 21:38:48 +00:00
|
|
|
strg.write(ws);
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2017-01-31 11:21:45 +00:00
|
|
|
void gatherDependencies(std::vector<hecl::ProjectPath> &pathsOut) const;
|
2015-07-10 05:28:08 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
#endif // __DNAMP1_STRG_HPP__
|