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