From 8326a2d588a4f3710d8644ecc7ff8a809f5822e1 Mon Sep 17 00:00:00 2001 From: toaster Date: Wed, 13 Sep 2023 17:53:07 +0100 Subject: [PATCH] Dialogue::WriteText improvements - Only have a long delay between symbols if the current character is std::ispunct() and the NEXT character is std::isspace - Add native color code support - Requires string concatenation to actually use it, though, which I don't know how to do in ACS --- src/k_dialogue.cpp | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/src/k_dialogue.cpp b/src/k_dialogue.cpp index e75e18a4d..7f3a03b18 100644 --- a/src/k_dialogue.cpp +++ b/src/k_dialogue.cpp @@ -157,9 +157,20 @@ void Dialogue::WriteText(void) while (textTimer <= 0 && !textDest.empty()) { - char c = textDest.back(); + char c = textDest.back(), nextc = '\n'; text.push_back(c); + textDest.pop_back(); + + if (c & 0x80) + { + // Color code support + continue; + } + + if (!textDest.empty()) + nextc = textDest.back(); + if (voicePlayed == false && std::isprint(c) && c != ' ') @@ -174,7 +185,8 @@ void Dialogue::WriteText(void) voicePlayed = true; } - if (c == '.' || c == ',' || c == ';' || c == '!' || c == '?') + if (std::ispunct(c) + && std::isspace(nextc)) { // slow down for punctuation textTimer += kTextPunctPause; @@ -183,8 +195,6 @@ void Dialogue::WriteText(void) { textTimer += FRACUNIT; } - - textDest.pop_back(); } textDone = (textTimer <= 0 && textDest.empty());