mirror of
https://github.com/pret/pokeheartgold.git
synced 2024-12-12 07:05:58 +00:00
Print messages in generated message headers
This commit is contained in:
parent
cb8d9a9f1c
commit
5409311897
@ -56,9 +56,12 @@ void GMM::WriteGmmHeader(const string &_filename) {
|
||||
hstrm << "#ifndef MSGENC_" << guard << endl;
|
||||
hstrm << "#define MSGENC_" << guard << endl;
|
||||
hstrm << endl;
|
||||
int i = 0;
|
||||
for (const auto & id : id_strings) {
|
||||
hstrm << "#define " << id << " " << i++ << endl;
|
||||
for (size_t i = 0; i < id_strings.size(); i++) {
|
||||
auto message_lines = SplitMessage(messages[i]);
|
||||
for (const auto & message_line : message_lines) {
|
||||
hstrm << "// " << message_line << endl;
|
||||
}
|
||||
hstrm << "#define " << id_strings[i] << " " << i << endl;
|
||||
}
|
||||
hstrm << endl;
|
||||
hstrm << "#endif //MSGENC_" << guard << endl;
|
||||
@ -98,6 +101,7 @@ void GMM::FromFile(MessagesConverter &converter) {
|
||||
row_id = rowname_pref + '_' + row_no_buf;
|
||||
}
|
||||
id_strings.emplace_back(row_id);
|
||||
messages.emplace_back(message);
|
||||
i++;
|
||||
IncRowNoBuf();
|
||||
}
|
||||
@ -159,3 +163,15 @@ void GMM::ToFile(MessagesConverter &converter) {
|
||||
}
|
||||
doc.save(stream);
|
||||
}
|
||||
|
||||
// The message headers are included in script files, which can cause the
|
||||
// assembler to break if the lines are too long.
|
||||
vector<string> GMM::SplitMessage(const string &message) {
|
||||
vector<string> v;
|
||||
|
||||
auto limit = 300;
|
||||
for (size_t i = 0; i < message.size(); i += limit) {
|
||||
v.push_back(message.substr(i, limit));
|
||||
}
|
||||
return v;
|
||||
}
|
||||
|
@ -26,6 +26,7 @@ class GMM {
|
||||
fstream stream;
|
||||
pugi::xml_document doc;
|
||||
vector<string> id_strings;
|
||||
vector<string> messages;
|
||||
void ReadGmmHeader(const string &_filename);
|
||||
void WriteGmmHeader(const string &_filename);
|
||||
void IncRowNoBuf() {
|
||||
@ -47,6 +48,9 @@ public:
|
||||
}
|
||||
void FromFile(MessagesConverter &converter);
|
||||
void ToFile(MessagesConverter &converter);
|
||||
|
||||
private:
|
||||
vector<string> SplitMessage(const string &message);
|
||||
};
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user