Merge branch 'unicode-blips' into 'master'

Text is now advanced based on graphemes, rather than bytes.

`QTextBoundaryFinder` is used to determine the end of a grapheme cluster, and then the entire cluster is copied into `f_character`. This will not influence text comparisons, like when determining formatting characters.

The `f_character` being potentially more than one byte long is then used to advance the `tick_pos` to the correct position, using its length.

See merge request AttorneyOnline/AO2-Client!60
This commit is contained in:
oldmud0 2019-05-10 17:58:06 +00:00
commit 15db260639
2 changed files with 16 additions and 4 deletions

View File

@ -48,6 +48,7 @@
#include <QFont>
#include <QInputDialog>
#include <QFileDialog>
#include <QTextBoundaryFinder>
#include <stack>

View File

@ -2024,6 +2024,7 @@ void Courtroom::chat_tick()
//do not perform heavy operations here
QString f_message = m_chatmessage[MESSAGE];
f_message.remove(0, tick_pos);
// Due to our new text speed system, we always need to stop the timer now.
chat_tick_timer->stop();
@ -2038,7 +2039,7 @@ void Courtroom::chat_tick()
f_message.remove(0,2);
}
if (tick_pos >= f_message.size())
if (f_message.size() == 0)
{
text_state = 2;
if (anim_state != 4)
@ -2050,7 +2051,16 @@ void Courtroom::chat_tick()
else
{
QString f_character = f_message.at(tick_pos);
QTextBoundaryFinder tbf(QTextBoundaryFinder::Grapheme, f_message);
QString f_character;
tbf.toNextBoundary();
if (tbf.position() == -1)
f_character = f_message;
else
f_character = f_message.left(tbf.position());
f_character = f_character.toHtmlEscaped();
if (f_character == " ")
@ -2265,7 +2275,7 @@ void Courtroom::chat_tick()
if(blank_blip)
qDebug() << "blank_blip found true";
if (f_message.at(tick_pos) != ' ' || blank_blip)
if (f_character != ' ' || blank_blip)
{
if (blip_pos % blip_rate == 0 && !formatting_char)
@ -2277,7 +2287,7 @@ void Courtroom::chat_tick()
++blip_pos;
}
++tick_pos;
tick_pos += f_character.length();
// Restart the timer, but according to the newly set speeds, if there were any.
// Keep the speed at bay.
@ -2304,6 +2314,7 @@ void Courtroom::chat_tick()
}
}
void Courtroom::show_testimony()
{
if (!testimony_in_progress || m_chatmessage[SIDE] != "wit")