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
This commit is contained in:
toaster 2023-09-13 17:53:07 +01:00
parent 753c6f414d
commit 8326a2d588

View file

@ -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());