add default text archive for ep3 card disassembly
This commit is contained in:
@@ -727,7 +727,7 @@ string CardDefinition::Effect::str_for_arg(const string& arg) {
|
||||
}
|
||||
}
|
||||
|
||||
string CardDefinition::Effect::str(const char* separator) const {
|
||||
string CardDefinition::Effect::str(const char* separator, const TextArchive* text_archive) const {
|
||||
vector<string> tokens;
|
||||
tokens.emplace_back(string_printf("%hhu:", this->effect_num));
|
||||
{
|
||||
@@ -761,7 +761,25 @@ string CardDefinition::Effect::str(const char* separator) const {
|
||||
}
|
||||
tokens.emplace_back(std::move(cond_str));
|
||||
}
|
||||
tokens.emplace_back(string_printf("name_index=%02hhX", this->name_index));
|
||||
|
||||
const char* name = nullptr;
|
||||
if (this->name_index && text_archive) {
|
||||
try {
|
||||
name = text_archive->get_string(45, this->name_index).c_str();
|
||||
} catch (const exception&) {
|
||||
}
|
||||
}
|
||||
if (name) {
|
||||
string formatted_name = name;
|
||||
for (char& ch : formatted_name) {
|
||||
if (ch == '\t') {
|
||||
ch = '$';
|
||||
}
|
||||
}
|
||||
tokens.emplace_back(string_printf("name_index=%02hhX \"%s\"", this->name_index, formatted_name.c_str()));
|
||||
} else {
|
||||
tokens.emplace_back(string_printf("name_index=%02hhX", this->name_index));
|
||||
}
|
||||
|
||||
return join(tokens, separator);
|
||||
}
|
||||
@@ -1006,7 +1024,7 @@ static const char* name_for_assist_ai_param_target(uint8_t target) {
|
||||
}
|
||||
}
|
||||
|
||||
string CardDefinition::str(bool single_line) const {
|
||||
string CardDefinition::str(bool single_line, const TextArchive* text_archive) const {
|
||||
string type_str;
|
||||
try {
|
||||
type_str = name_for_card_type(this->type);
|
||||
@@ -1045,7 +1063,7 @@ string CardDefinition::str(bool single_line) const {
|
||||
} else if (!effects_str.empty()) {
|
||||
effects_str += ", ";
|
||||
}
|
||||
effects_str += this->effects[x].str(single_line ? ", " : "\n ");
|
||||
effects_str += this->effects[x].str(single_line ? ", " : "\n ", text_archive);
|
||||
}
|
||||
if (!single_line && effects_str.empty()) {
|
||||
effects_str = " (none)";
|
||||
|
||||
@@ -15,6 +15,7 @@
|
||||
|
||||
#include "../PlayerSubordinates.hh"
|
||||
#include "../Text.hh"
|
||||
#include "../TextArchive.hh"
|
||||
|
||||
namespace Episode3 {
|
||||
|
||||
@@ -496,7 +497,7 @@ struct CardDefinition {
|
||||
|
||||
bool is_empty() const;
|
||||
static std::string str_for_arg(const std::string& arg);
|
||||
std::string str(const char* separator = ", ") const;
|
||||
std::string str(const char* separator = ", ", const TextArchive* text_archive = nullptr) const;
|
||||
} __attribute__((packed));
|
||||
|
||||
/* 0000 */ be_uint32_t card_id;
|
||||
@@ -716,7 +717,7 @@ struct CardDefinition {
|
||||
CardClass card_class() const;
|
||||
|
||||
void decode_range();
|
||||
std::string str(bool single_line = true) const;
|
||||
std::string str(bool single_line = true, const TextArchive* text_archive = nullptr) const;
|
||||
} __attribute__((packed)); // 0x128 bytes in total
|
||||
|
||||
struct CardDefinitionsFooter {
|
||||
|
||||
+7
-1
@@ -1687,12 +1687,18 @@ int main(int argc, char** argv) {
|
||||
|
||||
case Behavior::SHOW_EP3_CARDS: {
|
||||
Episode3::CardIndex card_index("system/ep3/card-definitions.mnr", "system/ep3/card-definitions.mnrd", "system/ep3/card-text.mnr", "system/ep3/card-text.mnrd");
|
||||
unique_ptr<TextArchive> text_english;
|
||||
try {
|
||||
JSON json = JSON::parse(load_file("system/ep3/text-english.json"));
|
||||
text_english.reset(new TextArchive(json));
|
||||
} catch (const exception& e) {
|
||||
}
|
||||
|
||||
auto card_ids = card_index.all_ids();
|
||||
log_info("%zu card definitions", card_ids.size());
|
||||
for (uint32_t card_id : card_ids) {
|
||||
auto entry = card_index.definition_for_id(card_id);
|
||||
string s = entry->def.str(one_line);
|
||||
string s = entry->def.str(one_line, text_english.get());
|
||||
if (one_line) {
|
||||
fprintf(stdout, "%s\n", s.c_str());
|
||||
} else {
|
||||
|
||||
Executable
+3628
File diff suppressed because one or more lines are too long
Reference in New Issue
Block a user