summaryrefslogtreecommitdiff
path: root/mm/2s2h/CustomMessage
diff options
context:
space:
mode:
Diffstat (limited to 'mm/2s2h/CustomMessage')
-rw-r--r--mm/2s2h/CustomMessage/CustomMessage.cpp14
-rw-r--r--mm/2s2h/CustomMessage/CustomMessage.h1
2 files changed, 15 insertions, 0 deletions
diff --git a/mm/2s2h/CustomMessage/CustomMessage.cpp b/mm/2s2h/CustomMessage/CustomMessage.cpp
index b2b1cd311..ff3a16152 100644
--- a/mm/2s2h/CustomMessage/CustomMessage.cpp
+++ b/mm/2s2h/CustomMessage/CustomMessage.cpp
@@ -9,6 +9,20 @@ extern f32 sNESFontWidths[160];
CustomMessage::Entry activeCustomMessage;
+std::string CustomMessage::RemoveColorCodes(const std::string& input) {
+ std::string output = input;
+ const std::vector<std::string> codes = { "%r", "%w", "%y", "%g", "%b", "%p" };
+
+ for (const auto& code : codes) {
+ size_t pos = 0;
+ while ((pos = output.find(code, pos)) != std::string::npos) {
+ output.erase(pos, code.length());
+ }
+ }
+
+ return output;
+}
+
void CustomMessage::StartTextbox(std::string msg, CustomMessage::Entry options) {
options.msg = msg;
activeCustomMessage = options;
diff --git a/mm/2s2h/CustomMessage/CustomMessage.h b/mm/2s2h/CustomMessage/CustomMessage.h
index a1668ca3f..6a9a0761a 100644
--- a/mm/2s2h/CustomMessage/CustomMessage.h
+++ b/mm/2s2h/CustomMessage/CustomMessage.h
@@ -32,6 +32,7 @@ void StartTextbox(std::string msg, Entry options = {});
void SetActiveCustomMessage(std::string msg, Entry options = {});
// Helpers
+std::string RemoveColorCodes(const std::string& input);
void Replace(std::string* msg, const std::string& placeholder, const std::string& value);
void AddLineBreaks(std::string* msg);
void ReplaceColorChars(std::string* msg);