feat: 支持 en 服肉鸽全部关卡名替换

This commit is contained in:
MistEO
2022-07-21 22:38:07 +08:00
parent 343a11f6aa
commit 0f28674a0d
2 changed files with 280 additions and 0 deletions

View File

@@ -298,21 +298,253 @@
"text": [],
"Doc": "该任务的 ocrReplace 被所有涉及Rouge-like的English识别任务复用",
"ocrReplace": [
[
"A Date With Slugs",
"与虫为伴"
],
[
"Beast Taming",
"驯兽小屋"
],
[
"Gun Salute",
"礼炮小队"
],
[
"Accident",
"意外"
],
[
"The Grand Finale",
"压轴登场"
],
[
"Patrol Squad",
"巡逻队"
],
[
"Destitute Knights",
"落魄骑士"
],
[
"Unequal Split",
"分赃不均"
],
[
"Justice",
"正义"
],
[
"A Familiar Face",
"似曾相识"
],
[
"Vintage Transport",
"酒商运输队"
],
[
"With The Crowd",
"从众效应"
],
[
"Beast Fighting",
"斗兽笼"
],
[
"Premiere",
"首演"
],
[
"Reform",
"感化"
],
[
"Pressing Ahead",
"步步紧逼"
],
[
"Shrouded in Clouds",
"阴云笼罩"
],
[
"Fireworks Show",
"烟花秀"
],
[
"Unending",
"永无尽头"
],
[
"Traveler From Afar",
"远方来客"
],
[
"A Dance Together",
"共舞"
],
[
"Bob's Beers",
"鲍勃酒品"
],
[
"Drone Landing Zone",
"无人机起降库"
],
[
"The Red Mist",
"红雾弥漫"
],
[
"The Night of Ritual",
"仪式之夜"
],
[
"The Biting Cold",
"彻骨冰寒"
],
[
"Dangers Abound",
"危机四伏"
],
[
"Surprise Factory",
"惊喜工厂"
],
[
"Absurd Trickeries",
"荒唐把戏"
],
[
"Sarkaz Desire",
"萨卡兹的渴求"
],
[
"Ursus Desire",
"乌萨斯的渴求"
],
[
"A Date With Slugs",
"与虫为伴"
],
[
"Beast Taming",
"驯兽小屋"
],
[
"Gun Salute",
"礼炮小队"
],
[
"Accident",
"意外"
],
[
"The Grand Finale",
"压轴登场"
],
[
"Patrol Squad",
"巡逻队"
],
[
"Destitute Knights",
"落魄骑士"
],
[
"Unequal Split",
"分赃不均"
],
[
"Justice",
"正义"
],
[
"A Familiar Face",
"似曾相识"
],
[
"Vintage Transport",
"酒商运输队"
],
[
"With The Crowd",
"从众效应"
],
[
"Beast Fighting",
"斗兽笼"
],
[
"Premiere",
"首演"
],
[
"Reform",
"感化"
],
[
"Pressing Ahead",
"步步紧逼"
],
[
"Shrouded in Clouds",
"阴云笼罩"
],
[
"Fireworks Show",
"烟花秀"
],
[
"Unending",
"永无尽头"
],
[
"Traveler From Afar",
"远方来客"
],
[
"A Dance Together",
"共舞"
],
[
"Bob's Beers",
"鲍勃酒品"
],
[
"Drone Landing Zone",
"无人机起降库"
],
[
"The Red Mist",
"红雾弥漫"
],
[
"The Night of Ritual",
"仪式之夜"
],
[
"The Biting Cold",
"彻骨冰寒"
],
[
"Dangers Abound",
"危机四伏"
],
[
"Surprise Factory",
"惊喜工厂"
],
[
"Absurd Trickeries",
"荒唐把戏"
],
[
"Sarkaz Desire",
"萨卡兹的渴求"
],
[
"Ursus Desire",
"乌萨斯的渴求"
]
],
"roi": [

View File

@@ -12,6 +12,7 @@ bool update_infrast_data(const std::filesystem::path& input_dir, const std::file
bool update_stages_data(const std::filesystem::path& input_dir, const std::filesystem::path& output_dir);
bool update_infrast_templates(const std::filesystem::path& input_dir, const std::filesystem::path& output_dir);
bool generate_english_roguelike_stage_name_replacement(const std::filesystem::path& ch_file, const std::filesystem::path& en_file);
int main([[maybe_unused]] int argc, char** argv)
{
@@ -54,6 +55,9 @@ int main([[maybe_unused]] int argc, char** argv)
return -1;
}
// 这个 en_levels.json 是自己手动生成放进去的
generate_english_roguelike_stage_name_replacement(input_dir / "levels.json", cur_path / "en_levels.json");
/* Update infrast data from Arknights-Bot-Resource*/
std::cout << "------------Update infrast data------------" << std::endl;
if (!update_infrast_data(input_dir, resource_dir)) {
@@ -416,3 +420,47 @@ bool update_infrast_templates(const std::filesystem::path& input_dir, const std:
}
return true;
}
bool generate_english_roguelike_stage_name_replacement(const std::filesystem::path& ch_file, const std::filesystem::path& en_file)
{
auto ch_opt = json::open(ch_file);
auto en_opt = json::open(en_file);
if (!ch_opt || !en_opt) {
return false;
}
auto& ch_json = ch_opt.value();
auto& en_json = en_opt.value();
std::unordered_map<std::string, std::string> ch_levelid_name;
for (auto& stage_obj : ch_json.as_array()) {
// 肉鸽关卡全叫这个
if (stage_obj["code"].as_string() != "ISW-NO") {
continue;
}
ch_levelid_name[stage_obj["levelId"].as_string()] = stage_obj["name"].as_string();
}
json::array en_to_ch_vec;
for (auto& stage_obj : en_json.as_array()) {
// 肉鸽关卡全叫这个
if (stage_obj["code"].as_string() != "ISW-NO") {
continue;
}
std::string level_id = stage_obj["levelId"].as_string();
auto it = ch_levelid_name.find(level_id);
if (it == ch_levelid_name.cend()) {
std::cerr << "Unknown en stage id: " << level_id << std::endl;
}
json::array arr;
arr.emplace_back(stage_obj["name"].as_string());
arr.emplace_back(it->second);
en_to_ch_vec.emplace_back(std::move(arr));
}
std::ofstream ofs(en_file.parent_path() / "en_replace.json", std::ios::out);
ofs << en_to_ch_vec.format();
ofs.close();
return true;
}