Archived
1
Fork 0

Add language code support when reading EXD files

This commit is contained in:
Joshua Goins 2022-04-11 10:36:34 -04:00
parent 7006cc4662
commit 58cd40912f
4 changed files with 49 additions and 23 deletions

View file

@ -19,6 +19,6 @@ struct EXD {
std::vector<Row> rows;
};
std::string getEXDFilename(EXH& exh, std::string_view name, ExcelDataPagination& page);
std::string getEXDFilename(EXH& exh, std::string_view name, std::string_view lang, ExcelDataPagination& page);
EXD readEXD(EXH& exh, std::string_view path, ExcelDataPagination& page);

View file

@ -3,6 +3,8 @@
#include <string_view>
#include <vector>
#include "language.h"
// taken from https://xiv.dev/game-data/file-formats/excel
struct ExhHeader {
char magic[0x4];
@ -53,24 +55,6 @@ struct ExcelDataPagination {
uint32_t rowCount;
};
enum Language : uint16_t {
None,
// ja
Japanese,
// en
English,
// de
German,
// fr
French,
// chs
ChineseSimplified,
// cht
ChineseTraditional,
// ko
Korean
};
struct EXH {
ExhHeader header;

40
include/language.h Normal file
View file

@ -0,0 +1,40 @@
#pragma once
enum Language : uint16_t {
None,
// ja
Japanese,
// en
English,
// de
German,
// fr
French,
// chs
ChineseSimplified,
// cht
ChineseTraditional,
// ko
Korean
};
inline std::string_view getLanguageCode(const Language lang) {
switch(lang) {
case Language::Japanese:
return "ja";
case Language::English:
return "en";
case Language::German:
return "de";
case Language::French:
return "fr";
case Language::ChineseSimplified:
return "chs";
case Language::ChineseTraditional:
return "cht";
case Language::Korean:
return "ko";
}
return "";
}

View file

@ -36,10 +36,12 @@ std::string readData(FILE* file, int offset) {
return std::to_string(value);
}
std::string getEXDFilename(EXH& exh, std::string_view name, ExcelDataPagination& page) {
auto path = fmt::format("{}_{}.exd", name, page.startId);
return path;
std::string getEXDFilename(EXH& exh, std::string_view name, std::string_view lang, ExcelDataPagination& page) {
if(lang.empty()) {
return fmt::format("{}_{}.exd", name, page.startId);
} else {
return fmt::format("{}_{}_{}.exd", name, page.startId, lang);
}
}
EXD readEXD(EXH& exh, std::string_view path, ExcelDataPagination& page) {