Add language code support when reading EXD files
This commit is contained in:
parent
7006cc4662
commit
58cd40912f
4 changed files with 49 additions and 23 deletions
|
@ -19,6 +19,6 @@ struct EXD {
|
||||||
std::vector<Row> rows;
|
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);
|
EXD readEXD(EXH& exh, std::string_view path, ExcelDataPagination& page);
|
|
@ -3,6 +3,8 @@
|
||||||
#include <string_view>
|
#include <string_view>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
|
#include "language.h"
|
||||||
|
|
||||||
// taken from https://xiv.dev/game-data/file-formats/excel
|
// taken from https://xiv.dev/game-data/file-formats/excel
|
||||||
struct ExhHeader {
|
struct ExhHeader {
|
||||||
char magic[0x4];
|
char magic[0x4];
|
||||||
|
@ -53,24 +55,6 @@ struct ExcelDataPagination {
|
||||||
uint32_t rowCount;
|
uint32_t rowCount;
|
||||||
};
|
};
|
||||||
|
|
||||||
enum Language : uint16_t {
|
|
||||||
None,
|
|
||||||
// ja
|
|
||||||
Japanese,
|
|
||||||
// en
|
|
||||||
English,
|
|
||||||
// de
|
|
||||||
German,
|
|
||||||
// fr
|
|
||||||
French,
|
|
||||||
// chs
|
|
||||||
ChineseSimplified,
|
|
||||||
// cht
|
|
||||||
ChineseTraditional,
|
|
||||||
// ko
|
|
||||||
Korean
|
|
||||||
};
|
|
||||||
|
|
||||||
struct EXH {
|
struct EXH {
|
||||||
ExhHeader header;
|
ExhHeader header;
|
||||||
|
|
||||||
|
|
40
include/language.h
Normal file
40
include/language.h
Normal 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 "";
|
||||||
|
}
|
|
@ -36,10 +36,12 @@ std::string readData(FILE* file, int offset) {
|
||||||
return std::to_string(value);
|
return std::to_string(value);
|
||||||
}
|
}
|
||||||
|
|
||||||
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) {
|
||||||
auto path = fmt::format("{}_{}.exd", name, page.startId);
|
if(lang.empty()) {
|
||||||
|
return fmt::format("{}_{}.exd", name, page.startId);
|
||||||
return path;
|
} else {
|
||||||
|
return fmt::format("{}_{}_{}.exd", name, page.startId, lang);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
EXD readEXD(EXH& exh, std::string_view path, ExcelDataPagination& page) {
|
EXD readEXD(EXH& exh, std::string_view path, ExcelDataPagination& page) {
|
||||||
|
|
Reference in a new issue