Refactor message data handling and improve variable naming for clarity
This commit is contained in:
@@ -1,6 +1,7 @@
|
|||||||
#include "message_data.h"
|
#include "message_data.h"
|
||||||
|
|
||||||
#include "app/core/common.h"
|
#include "app/core/common.h"
|
||||||
|
#include <string>
|
||||||
|
|
||||||
namespace yaze {
|
namespace yaze {
|
||||||
namespace editor {
|
namespace editor {
|
||||||
@@ -45,14 +46,14 @@ TextElement FindMatchingSpecial(uint8_t value) {
|
|||||||
|
|
||||||
ParsedElement FindMatchingElement(const std::string &str) {
|
ParsedElement FindMatchingElement(const std::string &str) {
|
||||||
std::smatch match;
|
std::smatch match;
|
||||||
for (auto &textElement : TextCommands) {
|
for (auto &text_element : TextCommands) {
|
||||||
match = textElement.MatchMe(str);
|
match = text_element.MatchMe(str);
|
||||||
if (match.size() > 0) {
|
if (match.size() > 0) {
|
||||||
if (textElement.HasArgument) {
|
if (text_element.HasArgument) {
|
||||||
return ParsedElement(textElement,
|
return ParsedElement(text_element,
|
||||||
std::stoi(match[1].str(), nullptr, 16));
|
std::stoi(match[1].str(), nullptr, 16));
|
||||||
} else {
|
} else {
|
||||||
return ParsedElement(textElement, 0);
|
return ParsedElement(text_element, 0);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -77,15 +78,15 @@ std::string ParseTextDataByte(uint8_t value) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Check for command.
|
// Check for command.
|
||||||
TextElement textElement = FindMatchingCommand(value);
|
TextElement text_element = FindMatchingCommand(value);
|
||||||
if (!textElement.Empty()) {
|
if (!text_element.Empty()) {
|
||||||
return textElement.GenericToken;
|
return text_element.GenericToken;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Check for special characters.
|
// Check for special characters.
|
||||||
textElement = FindMatchingSpecial(value);
|
text_element = FindMatchingSpecial(value);
|
||||||
if (!textElement.Empty()) {
|
if (!text_element.Empty()) {
|
||||||
return textElement.GenericToken;
|
return text_element.GenericToken;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Check for dictionary.
|
// Check for dictionary.
|
||||||
@@ -176,9 +177,9 @@ std::vector<DictionaryEntry> BuildDictionaryEntries(Rom *rom) {
|
|||||||
return AllDictionaries;
|
return AllDictionaries;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::vector<std::string>
|
std::vector<std::string> ParseMessageData(
|
||||||
ParseMessageData(std::vector<MessageData> &message_data,
|
std::vector<MessageData> &message_data,
|
||||||
const std::vector<DictionaryEntry> &dictionary_entries) {
|
const std::vector<DictionaryEntry> &dictionary_entries) {
|
||||||
std::vector<std::string> parsed_messages;
|
std::vector<std::string> parsed_messages;
|
||||||
|
|
||||||
for (auto &message : message_data) {
|
for (auto &message : message_data) {
|
||||||
@@ -187,14 +188,17 @@ ParseMessageData(std::vector<MessageData> &message_data,
|
|||||||
std::cout << " " << message.RawString << std::endl;
|
std::cout << " " << message.RawString << std::endl;
|
||||||
|
|
||||||
std::string parsed_message = "";
|
std::string parsed_message = "";
|
||||||
|
|
||||||
for (const uint8_t &byte : message.Data) {
|
for (const uint8_t &byte : message.Data) {
|
||||||
if (CharEncoder.contains(byte)) {
|
if (CharEncoder.contains(byte)) {
|
||||||
parsed_message.push_back(CharEncoder.at(byte));
|
parsed_message.push_back(CharEncoder.at(byte));
|
||||||
} else {
|
} else {
|
||||||
if (byte >= DICTOFF && byte < (DICTOFF + 97)) {
|
if (byte >= DICTOFF && byte < (DICTOFF + 97)) {
|
||||||
auto dic_entry = dictionary_entries[byte];
|
if (byte > 0 && byte <= dictionary_entries.size()) {
|
||||||
parsed_message.append(dic_entry.Contents);
|
auto dic_entry = dictionary_entries[byte];
|
||||||
|
parsed_message.append(dic_entry.Contents);
|
||||||
|
} else {
|
||||||
|
parsed_message.append(dictionary_entries[0].Contents);
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
auto text_element = FindMatchingCommand(byte);
|
auto text_element = FindMatchingCommand(byte);
|
||||||
if (!text_element.Empty()) {
|
if (!text_element.Empty()) {
|
||||||
@@ -213,5 +217,26 @@ ParseMessageData(std::vector<MessageData> &message_data,
|
|||||||
return parsed_messages;
|
return parsed_messages;
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace editor
|
std::vector<std::string> ImportMessageData(std::string_view filename) {
|
||||||
} // namespace yaze
|
std::vector<std::string> messages;
|
||||||
|
std::ifstream file(filename.data());
|
||||||
|
if (!file.is_open()) {
|
||||||
|
core::logf("Error opening file: %s", filename);
|
||||||
|
return messages;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Parse a file with dialogue IDs and convert
|
||||||
|
std::string line;
|
||||||
|
while (std::getline(file, line)) {
|
||||||
|
if (line.empty()) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Get the Dialogue ID and then read until the next header
|
||||||
|
}
|
||||||
|
|
||||||
|
return messages;
|
||||||
|
}
|
||||||
|
|
||||||
|
} // namespace editor
|
||||||
|
} // namespace yaze
|
||||||
|
|||||||
@@ -14,7 +14,7 @@ namespace yaze {
|
|||||||
namespace editor {
|
namespace editor {
|
||||||
|
|
||||||
const uint8_t kMessageTerminator = 0x7F;
|
const uint8_t kMessageTerminator = 0x7F;
|
||||||
const std::string BANKToken = "BANK";
|
const std::string kBankToken = "BANK";
|
||||||
const std::string DICTIONARYTOKEN = "D";
|
const std::string DICTIONARYTOKEN = "D";
|
||||||
constexpr uint8_t DICTOFF = 0x88;
|
constexpr uint8_t DICTOFF = 0x88;
|
||||||
|
|
||||||
@@ -40,7 +40,6 @@ static const std::unordered_map<uint8_t, wchar_t> CharEncoder = {
|
|||||||
|
|
||||||
uint8_t FindMatchingCharacter(char value);
|
uint8_t FindMatchingCharacter(char value);
|
||||||
uint8_t FindDictionaryEntry(uint8_t value);
|
uint8_t FindDictionaryEntry(uint8_t value);
|
||||||
|
|
||||||
std::vector<uint8_t> ParseMessageToData(std::string str);
|
std::vector<uint8_t> ParseMessageToData(std::string str);
|
||||||
|
|
||||||
struct DictionaryEntry {
|
struct DictionaryEntry {
|
||||||
@@ -62,13 +61,13 @@ struct DictionaryEntry {
|
|||||||
}
|
}
|
||||||
|
|
||||||
std::string ReplaceInstancesOfIn(std::string s) const {
|
std::string ReplaceInstancesOfIn(std::string s) const {
|
||||||
std::string replacedString = s;
|
std::string replaced_string = s;
|
||||||
size_t pos = replacedString.find(Contents);
|
size_t pos = replaced_string.find(Contents);
|
||||||
while (pos != std::string::npos) {
|
while (pos != std::string::npos) {
|
||||||
replacedString.replace(pos, Contents.length(), Token);
|
replaced_string.replace(pos, Contents.length(), Token);
|
||||||
pos = replacedString.find(Contents, pos + Token.length());
|
pos = replaced_string.find(Contents, pos + Token.length());
|
||||||
}
|
}
|
||||||
return replacedString;
|
return replaced_string;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -82,7 +81,6 @@ constexpr uint8_t kLine2 = 0x75;
|
|||||||
constexpr uint8_t kLine3 = 0x76;
|
constexpr uint8_t kLine3 = 0x76;
|
||||||
|
|
||||||
std::vector<DictionaryEntry> BuildDictionaryEntries(Rom *rom);
|
std::vector<DictionaryEntry> BuildDictionaryEntries(Rom *rom);
|
||||||
|
|
||||||
std::string ReplaceAllDictionaryWords(std::string str,
|
std::string ReplaceAllDictionaryWords(std::string str,
|
||||||
std::vector<DictionaryEntry> dictionary);
|
std::vector<DictionaryEntry> dictionary);
|
||||||
|
|
||||||
@@ -120,11 +118,11 @@ struct MessageData {
|
|||||||
}
|
}
|
||||||
|
|
||||||
std::string
|
std::string
|
||||||
OptimizeMessageForDictionary(std::string messageString,
|
OptimizeMessageForDictionary(std::string message_string,
|
||||||
const std::vector<DictionaryEntry> &dictionary) {
|
const std::vector<DictionaryEntry> &dictionary) {
|
||||||
std::stringstream protons;
|
std::stringstream protons;
|
||||||
bool command = false;
|
bool command = false;
|
||||||
for (const auto &c : messageString) {
|
for (const auto &c : message_string) {
|
||||||
if (c == '[') {
|
if (c == '[') {
|
||||||
command = true;
|
command = true;
|
||||||
} else if (c == ']') {
|
} else if (c == ']') {
|
||||||
@@ -137,13 +135,13 @@ struct MessageData {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string protonsString = protons.str();
|
std::string protons_string = protons.str();
|
||||||
std::string replacedString =
|
std::string replaced_string =
|
||||||
ReplaceAllDictionaryWords(protonsString, dictionary);
|
ReplaceAllDictionaryWords(protons_string, dictionary);
|
||||||
std::string finalString =
|
std::string final_string =
|
||||||
absl::StrReplaceAll(replacedString, {{CHEESE, ""}});
|
absl::StrReplaceAll(replaced_string, {{CHEESE, ""}});
|
||||||
|
|
||||||
return finalString;
|
return final_string;
|
||||||
}
|
}
|
||||||
|
|
||||||
void SetMessage(const std::string &message,
|
void SetMessage(const std::string &message,
|
||||||
@@ -153,8 +151,6 @@ struct MessageData {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
struct TextElement {
|
struct TextElement {
|
||||||
uint8_t ID;
|
uint8_t ID;
|
||||||
std::string Token;
|
std::string Token;
|
||||||
@@ -183,7 +179,7 @@ struct TextElement {
|
|||||||
StrictPattern = "^" + Pattern + "$";
|
StrictPattern = "^" + Pattern + "$";
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string GetParameterizedToken(uint8_t value = 0) const {
|
std::string GetParamToken(uint8_t value = 0) const {
|
||||||
if (HasArgument) {
|
if (HasArgument) {
|
||||||
return absl::StrFormat("[%s:%02X]", Token, value);
|
return absl::StrFormat("[%s:%02X]", Token, value);
|
||||||
} else {
|
} else {
|
||||||
@@ -252,7 +248,7 @@ static const std::vector<TextElement> TextCommands = {
|
|||||||
TextElement(0x68, "CH2I", false, kChoose2Indented),
|
TextElement(0x68, "CH2I", false, kChoose2Indented),
|
||||||
TextElement(0x69, "CHI", false, kChooseItem),
|
TextElement(0x69, "CHI", false, kChooseItem),
|
||||||
TextElement(0x67, "IMG", false, kNextAttractImage),
|
TextElement(0x67, "IMG", false, kNextAttractImage),
|
||||||
TextElement(0x80, BANKToken, false, kBankMarker),
|
TextElement(0x80, kBankToken, false, kBankMarker),
|
||||||
TextElement(0x70, "NONO", false, kCrash),
|
TextElement(0x70, "NONO", false, kCrash),
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -305,6 +301,8 @@ std::vector<std::string>
|
|||||||
ParseMessageData(std::vector<MessageData> &message_data,
|
ParseMessageData(std::vector<MessageData> &message_data,
|
||||||
const std::vector<DictionaryEntry> &dictionary_entries);
|
const std::vector<DictionaryEntry> &dictionary_entries);
|
||||||
|
|
||||||
|
std::vector<std::string> ImportMessageData(std::string_view filename);
|
||||||
|
|
||||||
} // namespace editor
|
} // namespace editor
|
||||||
} // namespace yaze
|
} // namespace yaze
|
||||||
|
|
||||||
|
|||||||
@@ -44,21 +44,22 @@ constexpr ImGuiTableFlags kDictTableFlags =
|
|||||||
ImGuiTableFlags_Borders | ImGuiTableFlags_Resizable;
|
ImGuiTableFlags_Borders | ImGuiTableFlags_Resizable;
|
||||||
|
|
||||||
absl::Status MessageEditor::Initialize() {
|
absl::Status MessageEditor::Initialize() {
|
||||||
std::copy(rom()->vector().begin() + kCharactersWidth,
|
for (int i = 0; i < kWidthArraySize; i++) {
|
||||||
rom()->vector().begin() + kCharactersWidth + kWidthArraySize,
|
width_array[i] = rom()->data()[kCharactersWidth + i];
|
||||||
width_array.begin());
|
}
|
||||||
|
|
||||||
all_dictionaries_ = BuildDictionaryEntries(rom());
|
all_dictionaries_ = BuildDictionaryEntries(rom());
|
||||||
ReadAllTextDataV2();
|
ReadAllTextDataV2();
|
||||||
|
|
||||||
font_preview_colors_.AddColor(0x7FFF); // White
|
font_preview_colors_.AddColor(0x7FFF); // White
|
||||||
font_preview_colors_.AddColor(0x7C00); // Red
|
font_preview_colors_.AddColor(0x7C00); // Red
|
||||||
font_preview_colors_.AddColor(0x03E0); // Green
|
font_preview_colors_.AddColor(0x03E0); // Green
|
||||||
font_preview_colors_.AddColor(0x001F); // Blue
|
font_preview_colors_.AddColor(0x001F); // Blue
|
||||||
|
|
||||||
std::vector<uint8_t> data(0x4000, 0);
|
std::vector<uint8_t> data(0x4000, 0);
|
||||||
std::copy(rom()->vector().begin() + kGfxFont,
|
for (int i = 0; i < 0x4000; i++) {
|
||||||
rom()->vector().begin() + kGfxFont + 0x4000, data.begin());
|
data[i] = rom()->data()[kGfxFont + i];
|
||||||
|
}
|
||||||
font_gfx16_data_ = gfx::SnesTo8bppSheet(data, /*bpp=*/2, /*num_sheets=*/2);
|
font_gfx16_data_ = gfx::SnesTo8bppSheet(data, /*bpp=*/2, /*num_sheets=*/2);
|
||||||
|
|
||||||
// 4bpp
|
// 4bpp
|
||||||
@@ -235,23 +236,31 @@ void MessageEditor::ReadAllTextDataV2() {
|
|||||||
while (current_byte != 0xFF) {
|
while (current_byte != 0xFF) {
|
||||||
current_byte = rom()->data()[pos++];
|
current_byte = rom()->data()[pos++];
|
||||||
if (current_byte == kMessageTerminator) {
|
if (current_byte == kMessageTerminator) {
|
||||||
auto message =
|
list_of_texts_.push_back(
|
||||||
MessageData(message_id++, pos, current_raw_message, raw_message,
|
MessageData(message_id++, pos, current_raw_message, raw_message,
|
||||||
current_parsed_message, parsed_message);
|
current_parsed_message, parsed_message));
|
||||||
|
std::cout << "Message ID: " << message_id << std::endl;
|
||||||
list_of_texts_.push_back(message);
|
std::cout << "Raw: " << current_raw_message << std::endl;
|
||||||
|
std::cout << "Parsed: " << current_parsed_message << std::endl;
|
||||||
|
std::cout << "Raw Bytes: ";
|
||||||
|
for (const auto &byte : raw_message) {
|
||||||
|
std::cout << core::HexByte(byte) << " ";
|
||||||
|
}
|
||||||
|
std::cout << std::endl;
|
||||||
|
std::cout << "Parsed Bytes: ";
|
||||||
|
for (const auto &byte : parsed_message) {
|
||||||
|
std::cout << core::HexByte(byte) << " ";
|
||||||
|
}
|
||||||
|
std::cout << std::endl;
|
||||||
raw_message.clear();
|
raw_message.clear();
|
||||||
parsed_message.clear();
|
parsed_message.clear();
|
||||||
current_raw_message.clear();
|
current_raw_message.clear();
|
||||||
current_parsed_message.clear();
|
current_parsed_message.clear();
|
||||||
|
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
raw_message.push_back(current_byte);
|
raw_message.push_back(current_byte);
|
||||||
|
|
||||||
// Check for command.
|
|
||||||
TextElement text_element = FindMatchingCommand(current_byte);
|
TextElement text_element = FindMatchingCommand(current_byte);
|
||||||
if (!text_element.Empty()) {
|
if (!text_element.Empty()) {
|
||||||
parsed_message.push_back(current_byte);
|
parsed_message.push_back(current_byte);
|
||||||
@@ -261,12 +270,10 @@ void MessageEditor::ReadAllTextDataV2() {
|
|||||||
parsed_message.push_back(current_byte);
|
parsed_message.push_back(current_byte);
|
||||||
}
|
}
|
||||||
|
|
||||||
current_raw_message.append(
|
current_raw_message.append(text_element.GetParamToken(current_byte));
|
||||||
text_element.GetParameterizedToken(current_byte));
|
current_parsed_message.append(text_element.GetParamToken(current_byte));
|
||||||
current_parsed_message.append(
|
|
||||||
text_element.GetParameterizedToken(current_byte));
|
|
||||||
|
|
||||||
if (text_element.Token == BANKToken) {
|
if (text_element.Token == kBankToken) {
|
||||||
pos = kTextData2;
|
pos = kTextData2;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -276,8 +283,8 @@ void MessageEditor::ReadAllTextDataV2() {
|
|||||||
// Check for special characters.
|
// Check for special characters.
|
||||||
text_element = FindMatchingSpecial(current_byte);
|
text_element = FindMatchingSpecial(current_byte);
|
||||||
if (!text_element.Empty()) {
|
if (!text_element.Empty()) {
|
||||||
current_raw_message.append(text_element.GetParameterizedToken());
|
current_raw_message.append(text_element.GetParamToken());
|
||||||
current_parsed_message.append(text_element.GetParameterizedToken());
|
current_parsed_message.append(text_element.GetParamToken());
|
||||||
parsed_message.push_back(current_byte);
|
parsed_message.push_back(current_byte);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
@@ -293,9 +300,9 @@ void MessageEditor::ReadAllTextDataV2() {
|
|||||||
|
|
||||||
uint32_t address = core::Get24LocalFromPC(
|
uint32_t address = core::Get24LocalFromPC(
|
||||||
rom()->mutable_data(), kPointersDictionaries + (dictionary * 2));
|
rom()->mutable_data(), kPointersDictionaries + (dictionary * 2));
|
||||||
uint32_t address_end = core::Get24LocalFromPC(rom()->mutable_data(),
|
uint32_t address_end = core::Get24LocalFromPC(
|
||||||
kPointersDictionaries +
|
rom()->mutable_data(),
|
||||||
((dictionary + 1) * 2));
|
kPointersDictionaries + ((dictionary + 1) * 2));
|
||||||
|
|
||||||
for (uint32_t i = address; i < address_end; i++) {
|
for (uint32_t i = address; i < address_end; i++) {
|
||||||
parsed_message.push_back(rom()->data()[i]);
|
parsed_message.push_back(rom()->data()[i]);
|
||||||
@@ -360,12 +367,10 @@ void MessageEditor::ReadAllTextData() {
|
|||||||
temp_bytes_parsed.push_back(current_byte);
|
temp_bytes_parsed.push_back(current_byte);
|
||||||
}
|
}
|
||||||
|
|
||||||
current_message_raw.append(
|
current_message_raw.append(text_element.GetParamToken(current_byte));
|
||||||
text_element.GetParameterizedToken(current_byte));
|
current_message_parsed.append(text_element.GetParamToken(current_byte));
|
||||||
current_message_parsed.append(
|
|
||||||
text_element.GetParameterizedToken(current_byte));
|
|
||||||
|
|
||||||
if (text_element.Token == BANKToken) {
|
if (text_element.Token == kBankToken) {
|
||||||
pos = kTextData2;
|
pos = kTextData2;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -375,8 +380,8 @@ void MessageEditor::ReadAllTextData() {
|
|||||||
// Check for special characters.
|
// Check for special characters.
|
||||||
text_element = FindMatchingSpecial(current_byte);
|
text_element = FindMatchingSpecial(current_byte);
|
||||||
if (!text_element.Empty()) {
|
if (!text_element.Empty()) {
|
||||||
current_message_raw.append(text_element.GetParameterizedToken());
|
current_message_raw.append(text_element.GetParamToken());
|
||||||
current_message_parsed.append(text_element.GetParameterizedToken());
|
current_message_parsed.append(text_element.GetParamToken());
|
||||||
temp_bytes_parsed.push_back(current_byte);
|
temp_bytes_parsed.push_back(current_byte);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
@@ -393,9 +398,9 @@ void MessageEditor::ReadAllTextData() {
|
|||||||
|
|
||||||
uint32_t address = core::Get24LocalFromPC(
|
uint32_t address = core::Get24LocalFromPC(
|
||||||
rom()->mutable_data(), kPointersDictionaries + (dictionary * 2));
|
rom()->mutable_data(), kPointersDictionaries + (dictionary * 2));
|
||||||
uint32_t address_end = core::Get24LocalFromPC(rom()->mutable_data(),
|
uint32_t address_end = core::Get24LocalFromPC(
|
||||||
kPointersDictionaries +
|
rom()->mutable_data(),
|
||||||
((dictionary + 1) * 2));
|
kPointersDictionaries + ((dictionary + 1) * 2));
|
||||||
|
|
||||||
for (uint32_t i = address; i < address_end; i++) {
|
for (uint32_t i = address; i < address_end; i++) {
|
||||||
temp_bytes_parsed.push_back(rom()->data()[i]);
|
temp_bytes_parsed.push_back(rom()->data()[i]);
|
||||||
@@ -437,7 +442,7 @@ DictionaryEntry MessageEditor::GetDictionaryFromID(uint8_t value) {
|
|||||||
void MessageEditor::DrawTileToPreview(int x, int y, int srcx, int srcy, int pal,
|
void MessageEditor::DrawTileToPreview(int x, int y, int srcx, int srcy, int pal,
|
||||||
int sizex, int sizey) {
|
int sizex, int sizey) {
|
||||||
const int num_x_tiles = 16;
|
const int num_x_tiles = 16;
|
||||||
const int img_width = 512; // (imgwidth/2)
|
const int img_width = 512; // (imgwidth/2)
|
||||||
int draw_id = srcx + (srcy * 32);
|
int draw_id = srcx + (srcy * 32);
|
||||||
for (int yl = 0; yl < sizey * 8; yl++) {
|
for (int yl = 0; yl < sizey * 8; yl++) {
|
||||||
for (int xl = 0; xl < 4; xl++) {
|
for (int xl = 0; xl < 4; xl++) {
|
||||||
@@ -512,7 +517,7 @@ void MessageEditor::DrawCharacterToPreview(const std::vector<uint8_t> &text) {
|
|||||||
skip_next = true;
|
skip_next = true;
|
||||||
|
|
||||||
continue;
|
continue;
|
||||||
} else if (value == 0x6C) // BCD numbers.
|
} else if (value == 0x6C) // BCD numbers.
|
||||||
{
|
{
|
||||||
DrawCharacterToPreview('0');
|
DrawCharacterToPreview('0');
|
||||||
skip_next = true;
|
skip_next = true;
|
||||||
@@ -582,7 +587,7 @@ absl::Status MessageEditor::Undo() {
|
|||||||
absl::Status MessageEditor::Save() {
|
absl::Status MessageEditor::Save() {
|
||||||
std::vector<uint8_t> backup = rom()->vector();
|
std::vector<uint8_t> backup = rom()->vector();
|
||||||
|
|
||||||
for (int i = 0; i < 100; i++) {
|
for (int i = 0; i < kWidthArraySize; i++) {
|
||||||
RETURN_IF_ERROR(rom()->WriteByte(kCharactersWidth + i, width_array[i]));
|
RETURN_IF_ERROR(rom()->WriteByte(kCharactersWidth + i, width_array[i]));
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -609,7 +614,7 @@ absl::Status MessageEditor::Save() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
RETURN_IF_ERROR(rom()->WriteByte(
|
RETURN_IF_ERROR(rom()->WriteByte(
|
||||||
pos++, kMessageTerminator)); // , true, "Terminator text"
|
pos++, kMessageTerminator)); // , true, "Terminator text"
|
||||||
}
|
}
|
||||||
|
|
||||||
// Verify that we didn't go over the space available for the second block.
|
// Verify that we didn't go over the space available for the second block.
|
||||||
@@ -619,7 +624,7 @@ absl::Status MessageEditor::Save() {
|
|||||||
return absl::InternalError(DisplayTextOverflowError(pos, false));
|
return absl::InternalError(DisplayTextOverflowError(pos, false));
|
||||||
}
|
}
|
||||||
|
|
||||||
RETURN_IF_ERROR(rom()->WriteByte(pos, 0xFF)); // , true, "End of text"
|
RETURN_IF_ERROR(rom()->WriteByte(pos, 0xFF)); // , true, "End of text"
|
||||||
|
|
||||||
return absl::OkStatus();
|
return absl::OkStatus();
|
||||||
}
|
}
|
||||||
@@ -630,10 +635,10 @@ std::string MessageEditor::DisplayTextOverflowError(int pos, bool bank) {
|
|||||||
std::string posSTR =
|
std::string posSTR =
|
||||||
bank ? absl::StrFormat("%X4", pos & 0xFFFF)
|
bank ? absl::StrFormat("%X4", pos & 0xFFFF)
|
||||||
: absl::StrFormat("%X4", (pos - kTextData2) & 0xFFFF);
|
: absl::StrFormat("%X4", (pos - kTextData2) & 0xFFFF);
|
||||||
std::string message =
|
std::string message = absl::StrFormat(
|
||||||
absl::StrFormat("There is too much text data in the %s block to save.\n"
|
"There is too much text data in the %s block to save.\n"
|
||||||
"Available: %X4 | Used: %s",
|
"Available: %X4 | Used: %s",
|
||||||
bankSTR, space, posSTR);
|
bankSTR, space, posSTR);
|
||||||
return message;
|
return message;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -656,5 +661,5 @@ void MessageEditor::SelectAll() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace editor
|
} // namespace editor
|
||||||
} // namespace yaze
|
} // namespace yaze
|
||||||
|
|||||||
Reference in New Issue
Block a user