From 51d74b092a6941ee9f96c43ca63a99e389dc2b18 Mon Sep 17 00:00:00 2001 From: Martin Michelsen Date: Fri, 9 Feb 2024 20:46:43 -0800 Subject: [PATCH] add cases for Ep3 NTE cards HTML --- src/Main.cc | 72 +++++++++++++++++++++++++++++++++++++---------------- 1 file changed, 51 insertions(+), 21 deletions(-) diff --git a/src/Main.cc b/src/Main.cc index 85f40d57..08363ce7 100644 --- a/src/Main.cc +++ b/src/Main.cc @@ -1831,12 +1831,15 @@ Action a_show_ep3_cards( Action a_generate_ep3_cards_html( "generate-ep3-cards-html", "\ - generate-ep3-cards-html\n\ + generate-ep3-cards-html [--ep3-nte] [--threads=N]\n\ Generate an HTML file describing all Episode 3 card definitions from the\n\ - system/ep3 directory.\n", + system/ep3 directory. If --ep3-nte is given, use the Trial Edition card\n\ + definitions instead.\n", +[](Arguments& args) { size_t num_threads = args.get("threads", 0); + bool is_nte = (get_cli_version(args, Version::GC_EP3) == Version::GC_EP3_NTE); + ServerState s; s.load_objects_and_upstream_dependents("ep3_data"); s.load_objects_and_upstream_dependents("text_index"); @@ -1860,13 +1863,17 @@ Action a_generate_ep3_cards_html( return (this->ce == nullptr) && this->small_data_url.empty() && this->medium_data_url.empty() && this->large_data_url.empty(); } }; + auto card_index = is_nte ? s.ep3_card_index_trial : s.ep3_card_index; vector infos; - for (uint32_t card_id : s.ep3_card_index->all_ids()) { + for (uint32_t card_id : card_index->all_ids()) { if (infos.size() <= card_id) { infos.resize(card_id + 1); } - infos[card_id].ce = s.ep3_card_index->definition_for_id(card_id); + infos[card_id].ce = card_index->definition_for_id(card_id); } + bool show_large_column = false; + bool show_medium_column = false; + bool show_small_column = false; for (const auto& filename : list_directory_sorted("system/ep3/cardtex")) { if ((filename[0] == 'C' || filename[0] == 'M' || filename[0] == 'L') && (filename[1] == '_')) { size_t card_id = stoull(filename.substr(2, 3), nullptr, 10); @@ -1876,10 +1883,13 @@ Action a_generate_ep3_cards_html( auto& info = infos[card_id]; if (filename[0] == 'C') { info.large_filename = "system/ep3/cardtex/" + filename; + show_large_column = true; } else if (filename[0] == 'L') { info.medium_filename = "system/ep3/cardtex/" + filename; + show_medium_column = true; } else if (filename[0] == 'M') { info.small_filename = "system/ep3/cardtex/" + filename; + show_small_column = true; } } } @@ -1911,7 +1921,17 @@ Action a_generate_ep3_cards_html( deque blocks; blocks.emplace_back("Phantasy Star Online Episode III cards"); blocks.emplace_back("
Legend:
Card has no definition and is obviously incomplete
Card is unobtainable in random draws but may be a quest or event reward
Card is obtainable in random draws


"); - blocks.emplace_back(""); + blocks.emplace_back("
IDSmallMediumLargeTextDisassembly
"); + if (show_small_column) { + blocks.emplace_back(""); + } + if (show_medium_column) { + blocks.emplace_back(""); + } + if (show_large_column) { + blocks.emplace_back(""); + } + blocks.emplace_back(""); for (size_t card_id = 0; card_id < infos.size(); card_id++) { const auto& entry = infos[card_id]; if (entry.is_empty()) { @@ -1931,25 +1951,35 @@ Action a_generate_ep3_cards_html( } blocks.emplace_back(string_printf("", background_color)); - blocks.emplace_back(string_printf("", card_id)); + if (show_small_column) { + blocks.emplace_back(""); } - blocks.emplace_back(""); } - blocks.emplace_back(""); } - blocks.emplace_back("
IDSmallMediumLargeTextDisassembly
%04zX
", card_id)); - if (!entry.small_data_url.empty()) { - blocks.emplace_back(""); + blocks.emplace_back(string_printf("
%04zX
"); + if (!entry.small_data_url.empty()) { + blocks.emplace_back(""); + } + blocks.emplace_back(""); - if (!entry.medium_data_url.empty()) { - blocks.emplace_back(""); + if (show_medium_column) { + blocks.emplace_back(""); + if (!entry.medium_data_url.empty()) { + blocks.emplace_back(""); + } + blocks.emplace_back(""); - if (!entry.large_data_url.empty()) { - blocks.emplace_back(""); + if (show_large_column) { + blocks.emplace_back(""); + if (!entry.large_data_url.empty()) { + blocks.emplace_back(""); + } + blocks.emplace_back(""); + blocks.emplace_back(""); if (entry.ce) { blocks.emplace_back("
");
           blocks.emplace_back(entry.ce->text);