From efdd8bcb3478ffb647b7bd0bdb6caf2e314dea8f Mon Sep 17 00:00:00 2001 From: acidvegas Date: Thu, 30 May 2024 00:15:49 -0400 Subject: [PATCH] Finally fixed line wraps with color properly --- src/main.ino | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/src/main.ino b/src/main.ino index 094aa4c..c4da677 100644 --- a/src/main.ino +++ b/src/main.ino @@ -558,13 +558,17 @@ int calculateLinesRequired(String message) { for (unsigned int i = 0; i < message.length(); i++) { char c = message[i]; if (c == '\x03') { - // Skip color code sequences from calculate instead of render to solve nick overlay issue - while (i < message.length() && (isdigit(message[i + 1]) || message[i + 1] == ',')) { + // Check for foreground color + if (i + 1 < message.length() && isdigit(message[i + 1])) { i++; - if (isdigit(message[i + 1])) { + if (i + 1 < message.length() && isdigit(message[i + 1])) { i++; } - if (message[i] == ',' && isdigit(message[i + 1])) { + } + // Check for background color + if (i + 1 < message.length() && message[i + 1] == ',' && isdigit(message[i + 2])) { + i += 2; // Skip the comma + if (i + 1 < message.length() && isdigit(message[i + 1])) { i++; } } @@ -580,6 +584,7 @@ int calculateLinesRequired(String message) { return linesRequired; } + void displayCenteredText(String text) { tft.fillScreen(TFT_BLACK); tft.setTextDatum(MC_DATUM);