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
|
|
|
|
|
|
|
namespace Retro
|
|
|
|
{
|
|
|
|
namespace DNAMP1
|
|
|
|
{
|
|
|
|
|
2015-08-01 00:38:35 +00:00
|
|
|
struct STRG : ISTRG, BigYAML
|
2015-07-10 05:28:08 +00:00
|
|
|
{
|
|
|
|
DECL_EXPLICIT_DNA
|
2015-08-01 00:38:35 +00:00
|
|
|
DECL_EXPLICIT_YAML
|
2015-07-13 06:29:12 +00:00
|
|
|
void _read(Athena::io::IStreamReader& reader);
|
2015-07-18 04:33:38 +00:00
|
|
|
std::vector<std::pair<FourCC, std::vector<std::wstring>>> langs;
|
|
|
|
std::unordered_map<FourCC, std::vector<std::wstring>*> langMap;
|
2015-07-13 06:29:12 +00:00
|
|
|
|
|
|
|
inline int32_t lookupIdx(const std::string& name) const {return -1;}
|
2015-07-10 05:28:08 +00:00
|
|
|
|
2015-07-13 06:29:12 +00:00
|
|
|
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 HECL::WideToUTF8(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 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-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
|
2015-07-18 04:33:38 +00:00
|
|
|
return search->second->at(idx);
|
2015-07-13 06:29:12 +00:00
|
|
|
#else
|
2015-07-18 04:33:38 +00:00
|
|
|
return HECL::WideToUTF8(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
|
|
|
|
|
|
|
bool readAngelScript(const AngelScript::asIScriptModule& in);
|
|
|
|
void writeAngelScript(std::ofstream& out) const;
|
2015-07-17 00:01:05 +00:00
|
|
|
|
2015-08-05 21:46:07 +00:00
|
|
|
static bool Extract(const SpecBase& dataspec, PAKEntryReadStream& rs, const HECL::ProjectPath& outPath)
|
2015-07-22 19:05:18 +00:00
|
|
|
{
|
|
|
|
STRG strg;
|
|
|
|
strg.read(rs);
|
2015-08-02 23:30:39 +00:00
|
|
|
FILE* fp = HECL::Fopen(outPath.getAbsolutePath().c_str(), _S("wb"));
|
2015-08-01 00:38:35 +00:00
|
|
|
strg.toYAMLFile(fp);
|
|
|
|
fclose(fp);
|
2015-07-22 19:05:18 +00:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
static bool Cook(const HECL::ProjectPath& inPath, const HECL::ProjectPath& outPath)
|
|
|
|
{
|
|
|
|
STRG strg;
|
2015-08-02 23:30:39 +00:00
|
|
|
FILE* fp = HECL::Fopen(inPath.getAbsolutePath().c_str(), _S("rb"));
|
2015-08-01 00:38:35 +00:00
|
|
|
strg.fromYAMLFile(fp);
|
|
|
|
fclose(fp);
|
2015-07-22 19:05:18 +00:00
|
|
|
Athena::io::FileWriter ws(outPath.getAbsolutePath());
|
|
|
|
strg.write(ws);
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2015-07-10 05:28:08 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
#endif // __DNAMP1_STRG_HPP__
|