cleanup message editor and message data
This commit is contained in:
@@ -12,9 +12,8 @@ namespace editor {
|
|||||||
|
|
||||||
const uint8_t MESSAGETERMINATOR = 0x7F;
|
const uint8_t MESSAGETERMINATOR = 0x7F;
|
||||||
|
|
||||||
static std::string AddNewLinesToCommands(std::string str);
|
std::string ReplaceAllDictionaryWords(std::string str);
|
||||||
static std::string ReplaceAllDictionaryWords(std::string str);
|
std::vector<uint8_t> ParseMessageToData(std::string str);
|
||||||
static std::vector<uint8_t> ParseMessageToData(std::string str);
|
|
||||||
|
|
||||||
const std::string CHEESE = "\uBEBE"; // Inserted into commands to protect
|
const std::string CHEESE = "\uBEBE"; // Inserted into commands to protect
|
||||||
// them from dictionary replacements.
|
// them from dictionary replacements.
|
||||||
@@ -59,20 +58,6 @@ struct MessageData {
|
|||||||
return absl::StrFormat("%0X - %s", ID, ContentsParsed);
|
return absl::StrFormat("%0X - %s", ID, ContentsParsed);
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string GetReadableDumpedContents() {
|
|
||||||
std::stringstream stringBuilder;
|
|
||||||
for (const auto& b : Data) {
|
|
||||||
stringBuilder << absl::StrFormat("%0X ", b);
|
|
||||||
}
|
|
||||||
stringBuilder << absl::StrFormat("%00X", MESSAGETERMINATOR);
|
|
||||||
|
|
||||||
return absl::StrFormat(
|
|
||||||
"[[[[\r\nMessage "
|
|
||||||
"%000X]]]]\r\n[Contents]\r\n%s\r\n\r\n[Data]\r\n%s"
|
|
||||||
"\r\n\r\n\r\n\r\n",
|
|
||||||
ID, AddNewLinesToCommands(ContentsParsed), stringBuilder.str());
|
|
||||||
}
|
|
||||||
|
|
||||||
std::string GetDumpedContents() {
|
std::string GetDumpedContents() {
|
||||||
return absl::StrFormat("%000X : %s\r\n\r\n", ID, ContentsParsed);
|
return absl::StrFormat("%000X : %s\r\n\r\n", ID, ContentsParsed);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -46,7 +46,7 @@ using ImGui::Text;
|
|||||||
using ImGui::TextWrapped;
|
using ImGui::TextWrapped;
|
||||||
using ImGui::TreeNode;
|
using ImGui::TreeNode;
|
||||||
|
|
||||||
static ParsedElement FindMatchingElement(string str) {
|
static ParsedElement FindMatchingElement(std::string str) {
|
||||||
std::smatch match;
|
std::smatch match;
|
||||||
for (auto& textElement : TextCommands) {
|
for (auto& textElement : TextCommands) {
|
||||||
match = textElement.MatchMe(str);
|
match = textElement.MatchMe(str);
|
||||||
@@ -68,8 +68,8 @@ static ParsedElement FindMatchingElement(string str) {
|
|||||||
return ParsedElement();
|
return ParsedElement();
|
||||||
}
|
}
|
||||||
|
|
||||||
static string ReplaceAllDictionaryWords(string str) {
|
std::string ReplaceAllDictionaryWords(std::string str) {
|
||||||
string temp = str;
|
std::string temp = str;
|
||||||
for (const auto& entry : AllDictionaries) {
|
for (const auto& entry : AllDictionaries) {
|
||||||
if (absl::StrContains(temp, entry.Contents)) {
|
if (absl::StrContains(temp, entry.Contents)) {
|
||||||
temp = absl::StrReplaceAll(temp, {{entry.Contents, entry.Contents}});
|
temp = absl::StrReplaceAll(temp, {{entry.Contents, entry.Contents}});
|
||||||
@@ -79,9 +79,9 @@ static string ReplaceAllDictionaryWords(string str) {
|
|||||||
return temp;
|
return temp;
|
||||||
}
|
}
|
||||||
|
|
||||||
static std::vector<uint8_t> ParseMessageToData(string str) {
|
std::vector<uint8_t> ParseMessageToData(std::string str) {
|
||||||
std::vector<uint8_t> bytes;
|
std::vector<uint8_t> bytes;
|
||||||
string tempString = str;
|
std::string tempString = str;
|
||||||
int pos = 0;
|
int pos = 0;
|
||||||
|
|
||||||
while (pos < tempString.size()) {
|
while (pos < tempString.size()) {
|
||||||
@@ -496,10 +496,10 @@ uint8_t MessageEditor::FindMatchingCharacter(char value) {
|
|||||||
return 0xFF;
|
return 0xFF;
|
||||||
}
|
}
|
||||||
|
|
||||||
string MessageEditor::ParseTextDataByte(uint8_t value) {
|
std::string MessageEditor::ParseTextDataByte(uint8_t value) {
|
||||||
if (CharEncoder.contains(value)) {
|
if (CharEncoder.contains(value)) {
|
||||||
char c = CharEncoder.at(value);
|
char c = CharEncoder.at(value);
|
||||||
string str = "";
|
std::string str = "";
|
||||||
str.push_back(c);
|
str.push_back(c);
|
||||||
return str;
|
return str;
|
||||||
}
|
}
|
||||||
@@ -554,7 +554,7 @@ void MessageEditor::DrawTileToPreview(int x, int y, int srcx, int srcy, int pal,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void MessageEditor::DrawStringToPreview(string str) {
|
void MessageEditor::DrawStringToPreview(std::string str) {
|
||||||
for (const auto c : str) {
|
for (const auto c : str) {
|
||||||
DrawCharacterToPreview(c);
|
DrawCharacterToPreview(c);
|
||||||
}
|
}
|
||||||
@@ -714,9 +714,10 @@ absl::Status MessageEditor::Save() {
|
|||||||
|
|
||||||
std::string MessageEditor::DisplayTextOverflowError(int pos, bool bank) {
|
std::string MessageEditor::DisplayTextOverflowError(int pos, bool bank) {
|
||||||
int space = bank ? kTextDataEnd - kTextData : kTextData2End - kTextData2;
|
int space = bank ? kTextDataEnd - kTextData : kTextData2End - kTextData2;
|
||||||
string bankSTR = bank ? "1st" : "2nd";
|
std::string bankSTR = bank ? "1st" : "2nd";
|
||||||
string posSTR = bank ? absl::StrFormat("%X4", pos & 0xFFFF)
|
std::string posSTR =
|
||||||
: absl::StrFormat("%X4", (pos - kTextData2) & 0xFFFF);
|
bank ? absl::StrFormat("%X4", pos & 0xFFFF)
|
||||||
|
: absl::StrFormat("%X4", (pos - kTextData2) & 0xFFFF);
|
||||||
std::string message = absl::StrFormat(
|
std::string message = 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",
|
||||||
@@ -739,7 +740,7 @@ void MessageEditor::InsertSpecialButton_Click() {
|
|||||||
// SpecialChars[SpecialsList.SelectedIndex].GetParameterizedToken());
|
// SpecialChars[SpecialsList.SelectedIndex].GetParameterizedToken());
|
||||||
}
|
}
|
||||||
|
|
||||||
void MessageEditor::InsertSelectedText(string str) {
|
void MessageEditor::InsertSelectedText(std::string str) {
|
||||||
int textboxPos = message_text_box_.selection_start;
|
int textboxPos = message_text_box_.selection_start;
|
||||||
from_form = true;
|
from_form = true;
|
||||||
// message_text_box_.Text = message_text_box_.Text.Insert(textboxPos, str);
|
// message_text_box_.Text = message_text_box_.Text.Insert(textboxPos, str);
|
||||||
|
|||||||
@@ -23,8 +23,6 @@ namespace yaze {
|
|||||||
namespace app {
|
namespace app {
|
||||||
namespace editor {
|
namespace editor {
|
||||||
|
|
||||||
using std::string;
|
|
||||||
|
|
||||||
// TEXT EDITOR RELATED CONSTANTS
|
// TEXT EDITOR RELATED CONSTANTS
|
||||||
const int kGfxFont = 0x70000; // 2bpp format
|
const int kGfxFont = 0x70000; // 2bpp format
|
||||||
const int kTextData = 0xE0000;
|
const int kTextData = 0xE0000;
|
||||||
@@ -35,16 +33,16 @@ const int kPointersDictionaries = 0x74703;
|
|||||||
const int kCharactersWidth = 0x74ADF;
|
const int kCharactersWidth = 0x74ADF;
|
||||||
constexpr int kNumDictionaryEntries = 97;
|
constexpr int kNumDictionaryEntries = 97;
|
||||||
|
|
||||||
const string DICTIONARYTOKEN = "D";
|
const std::string DICTIONARYTOKEN = "D";
|
||||||
const uint8_t DICTOFF = 0x88;
|
const uint8_t DICTOFF = 0x88;
|
||||||
const string BANKToken = "BANK";
|
const std::string BANKToken = "BANK";
|
||||||
const uint8_t BANKID = 0x80;
|
const uint8_t BANKID = 0x80;
|
||||||
|
|
||||||
constexpr uint8_t kBlockTerminator = 0x80;
|
constexpr uint8_t kBlockTerminator = 0x80;
|
||||||
|
|
||||||
static std::vector<uint8_t> ParseMessageToData(string str);
|
std::vector<uint8_t> ParseMessageToData(std::string str);
|
||||||
|
|
||||||
static ParsedElement FindMatchingElement(string str);
|
static ParsedElement FindMatchingElement(std::string str);
|
||||||
|
|
||||||
constexpr uint8_t kScrollVertical = 0x73;
|
constexpr uint8_t kScrollVertical = 0x73;
|
||||||
constexpr uint8_t kLine1 = 0x74;
|
constexpr uint8_t kLine1 = 0x74;
|
||||||
@@ -243,7 +241,7 @@ class MessageEditor : public Editor, public SharedRom {
|
|||||||
|
|
||||||
TextElement FindMatchingCommand(uint8_t byte);
|
TextElement FindMatchingCommand(uint8_t byte);
|
||||||
TextElement FindMatchingSpecial(uint8_t value);
|
TextElement FindMatchingSpecial(uint8_t value);
|
||||||
string ParseTextDataByte(uint8_t value);
|
std::string ParseTextDataByte(uint8_t value);
|
||||||
DictionaryEntry GetDictionaryFromID(uint8_t value);
|
DictionaryEntry GetDictionaryFromID(uint8_t value);
|
||||||
|
|
||||||
static uint8_t FindDictionaryEntry(uint8_t value);
|
static uint8_t FindDictionaryEntry(uint8_t value);
|
||||||
@@ -253,18 +251,18 @@ class MessageEditor : public Editor, public SharedRom {
|
|||||||
void DrawCharacterToPreview(char c);
|
void DrawCharacterToPreview(char c);
|
||||||
void DrawCharacterToPreview(const std::vector<uint8_t>& text);
|
void DrawCharacterToPreview(const std::vector<uint8_t>& text);
|
||||||
|
|
||||||
void DrawStringToPreview(string str);
|
void DrawStringToPreview(std::string str);
|
||||||
void DrawMessagePreview();
|
void DrawMessagePreview();
|
||||||
std::string DisplayTextOverflowError(int pos, bool bank);
|
std::string DisplayTextOverflowError(int pos, bool bank);
|
||||||
|
|
||||||
void InsertCommandButton_Click_1();
|
void InsertCommandButton_Click_1();
|
||||||
void InsertSpecialButton_Click();
|
void InsertSpecialButton_Click();
|
||||||
void InsertSelectedText(string str);
|
void InsertSelectedText(std::string str);
|
||||||
|
|
||||||
static const std::vector<DictionaryEntry> AllDicts;
|
static const std::vector<DictionaryEntry> AllDicts;
|
||||||
|
|
||||||
uint8_t width_array[100];
|
uint8_t width_array[100];
|
||||||
string romname = "";
|
std::string romname = "";
|
||||||
|
|
||||||
int text_line = 0;
|
int text_line = 0;
|
||||||
int text_pos = 0;
|
int text_pos = 0;
|
||||||
|
|||||||
Reference in New Issue
Block a user