Add in a way to AutoFormat with an item icon.

This commit is contained in:
Christopher Leggett 2025-02-27 16:36:06 -05:00
commit a513a422b0
No known key found for this signature in database
GPG key ID: F2121C0AF9938ABF
2 changed files with 11 additions and 2 deletions

View file

@ -353,6 +353,14 @@ void CustomMessage::AutoFormat() {
} }
} }
void CustomMessage::AutoFormat(ItemID iid) {
for (std::string &str : messages) {
str.insert(0, ITEM_OBTAINED(iid));
}
AutoFormat();
Replace(WAIT_FOR_INPUT(), WAIT_FOR_INPUT() + ITEM_OBTAINED(iid));
}
void CustomMessage::Clean() { void CustomMessage::Clean() {
for (std::string& str : messages) { for (std::string& str : messages) {
CleanString(str); CleanString(str);
@ -408,7 +416,7 @@ static size_t NextLineLength(const std::string* textStr, const size_t lastNewlin
// Skip over control codes // Skip over control codes
if (textStr->at(currentPos) == '%') { if (textStr->at(currentPos) == '%') {
nextPosJump = 2; nextPosJump = 2;
} else if (textStr->at(currentPos) == '$') { } else if (textStr->at(currentPos) == '\x13') {
nextPosJump = 2; nextPosJump = 2;
} else if (textStr->at(currentPos) == '@') { } else if (textStr->at(currentPos) == '@') {
nextPosJump = 1; nextPosJump = 1;
@ -512,7 +520,7 @@ void CustomMessage::AutoFormatString(std::string& str) const {
ReplaceColors(str); ReplaceColors(str);
// insert newlines either manually or when encountering a '&' // insert newlines either manually or when encountering a '&'
size_t lastNewline = 0; size_t lastNewline = 0;
const bool hasIcon = str.find('$', 0) != std::string::npos; const bool hasIcon = str.find('\x13') != std::string::npos;
size_t lineLength = NextLineLength(&str, lastNewline, hasIcon); size_t lineLength = NextLineLength(&str, lastNewline, hasIcon);
size_t lineCount = 1; size_t lineCount = 1;
size_t yesNo = str.find("\x1B"s[0], lastNewline); size_t yesNo = str.find("\x1B"s[0], lastNewline);

View file

@ -163,6 +163,7 @@ class CustomMessage {
* textboxes, and use it's formatting. * textboxes, and use it's formatting.
*/ */
void AutoFormat(); void AutoFormat();
void AutoFormat(ItemID iid);
/** /**
* @brief Removes all OoT formatting from the message, * @brief Removes all OoT formatting from the message,