2015-07-13 06:29:12 +00:00
|
|
|
#ifndef __DNAMP3_STRG_HPP__
|
|
|
|
#define __DNAMP3_STRG_HPP__
|
|
|
|
|
|
|
|
#include <unordered_map>
|
2015-08-22 01:58:41 +00:00
|
|
|
#include "../DNACommon/PAK.hpp"
|
2015-07-13 06:29:12 +00:00
|
|
|
#include "../DNACommon/STRG.hpp"
|
|
|
|
|
|
|
|
namespace Retro
|
|
|
|
{
|
|
|
|
namespace DNAMP3
|
|
|
|
{
|
|
|
|
|
2015-08-09 03:55:11 +00:00
|
|
|
struct STRG : ISTRG
|
2015-07-13 06:29:12 +00:00
|
|
|
{
|
2015-08-09 03:55:11 +00:00
|
|
|
DECL_YAML
|
|
|
|
Delete expl;
|
2015-07-13 06:29:12 +00:00
|
|
|
void _read(Athena::io::IStreamReader& reader);
|
2015-08-23 06:42:29 +00:00
|
|
|
std::vector<std::pair<DNAFourCC, std::vector<std::string>>> langs;
|
|
|
|
std::unordered_map<DNAFourCC, std::vector<std::string>*> langMap;
|
2015-07-13 06:29:12 +00:00
|
|
|
std::map<std::string, int32_t> names;
|
|
|
|
|
|
|
|
inline int32_t lookupIdx(const std::string& name) const
|
|
|
|
{
|
|
|
|
auto search = names.find(name);
|
|
|
|
if (search == names.end())
|
|
|
|
return -1;
|
|
|
|
return search->second;
|
|
|
|
}
|
|
|
|
|
|
|
|
inline size_t count() const
|
|
|
|
{
|
|
|
|
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;
|
|
|
|
}
|
|
|
|
inline std::string getUTF8(const FourCC& lang, size_t idx) const
|
|
|
|
{
|
2015-07-18 04:33:38 +00:00
|
|
|
auto search = langMap.find(lang);
|
|
|
|
if (search != langMap.end())
|
|
|
|
return search->second->at(idx);
|
2015-07-13 06:29:12 +00:00
|
|
|
return std::string();
|
|
|
|
}
|
|
|
|
inline std::wstring getUTF16(const FourCC& lang, size_t idx) const
|
|
|
|
{
|
2015-07-18 04:33:38 +00:00
|
|
|
auto search = langMap.find(lang);
|
|
|
|
if (search != langMap.end())
|
|
|
|
return HECL::UTF8ToWide(search->second->at(idx));
|
2015-07-13 06:29:12 +00:00
|
|
|
return std::wstring();
|
|
|
|
}
|
|
|
|
inline HECL::SystemString getSystemString(const FourCC& lang, size_t idx) const
|
|
|
|
{
|
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
|
2015-07-18 04:33:38 +00:00
|
|
|
return HECL::UTF8ToWide(search->second->at(idx));
|
2015-07-13 06:29:12 +00:00
|
|
|
#else
|
2015-07-18 04:33:38 +00:00
|
|
|
return search->second->at(idx);
|
2015-07-13 06:29:12 +00:00
|
|
|
#endif
|
2015-07-22 19:05:18 +00:00
|
|
|
return HECL::SystemString();
|
2015-07-13 06:29:12 +00:00
|
|
|
}
|
2015-07-16 01:57:34 +00:00
|
|
|
|
2015-09-19 01:38:40 +00:00
|
|
|
static bool Extract(PAKEntryReadStream& rs, const HECL::ProjectPath& outPath)
|
2015-07-18 04:33:38 +00:00
|
|
|
{
|
2015-08-09 03:55:11 +00:00
|
|
|
std::unique_ptr<ISTRG> strg = LoadSTRG(rs);
|
|
|
|
FILE* fp = HECL::Fopen(outPath.getAbsolutePath().c_str(), _S("wb"));
|
|
|
|
strg->toYAMLFile(fp);
|
|
|
|
fclose(fp);
|
2015-07-18 04:33:38 +00:00
|
|
|
return true;
|
|
|
|
}
|
2015-07-22 19:05:18 +00:00
|
|
|
|
|
|
|
static bool Cook(const HECL::ProjectPath& inPath, const HECL::ProjectPath& outPath)
|
|
|
|
{
|
2015-08-09 03:55:11 +00:00
|
|
|
STRG strg;
|
|
|
|
FILE* fp = HECL::Fopen(inPath.getAbsolutePath().c_str(), _S("rb"));
|
|
|
|
strg.fromYAMLFile(fp);
|
|
|
|
fclose(fp);
|
|
|
|
Athena::io::FileWriter ws(outPath.getAbsolutePath());
|
|
|
|
strg.write(ws);
|
2015-07-22 19:05:18 +00:00
|
|
|
return true;
|
|
|
|
}
|
2015-07-13 06:29:12 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
#endif // __DNAMP2_STRG_HPP__
|