Refactor message handling and improve message editor functionality

- Combined TextCommands and SpecialChars into a single vector for streamlined matching in FindMatchingElement.
- Removed unnecessary logging in ParseMessageToData for cleaner error handling.
- Updated FindRealDictionaryEntry function signature for improved readability.
- Enhanced DrawCurrentMessage to strip newline characters from input before parsing.
- Added command parameter input in DrawTextCommands for better user interaction.
- Cleaned up unused ToString methods in MessageData and TextElement structures.
This commit is contained in:
scawful
2025-05-10 12:52:34 -04:00
parent f75830c06c
commit ce6cde438c
6 changed files with 33 additions and 32 deletions

View File

@@ -32,14 +32,16 @@ void MessagePreview::DrawTileToPreview(int x, int y, int srcx, int srcy,
}
}
void MessagePreview::DrawStringToPreview(std::string str) {
for (const auto c : str) {
void MessagePreview::DrawStringToPreview(const std::string& str) {
for (const auto& c : str) {
DrawCharacterToPreview(c);
}
}
void MessagePreview::DrawCharacterToPreview(char c) {
DrawCharacterToPreview(FindMatchingCharacter(c));
std::vector<uint8_t> text;
text.push_back(FindMatchingCharacter(c));
DrawCharacterToPreview(text);
}
void MessagePreview::DrawCharacterToPreview(const std::vector<uint8_t>& text) {
@@ -87,7 +89,8 @@ void MessagePreview::DrawCharacterToPreview(const std::vector<uint8_t>& text) {
} else if (value == 0x6A) {
// Includes parentheses to be longer, since player names can be up to 6
// characters.
DrawStringToPreview("(NAME)");
const std::string name = "(NAME)";
DrawStringToPreview(name);
} else if (value >= DICTOFF && value < (DICTOFF + 97)) {
int pos = value - DICTOFF;
if (pos < 0 || pos >= all_dictionaries_.size()) {