From b040449f7fd6ddf404e81d4b44c1726827959aa9 Mon Sep 17 00:00:00 2001 From: Crystalwarrior Date: Wed, 27 Jan 2021 18:20:56 +0300 Subject: [PATCH] Redesign the text display speed delay to be more modular by introducing a "base display speed" variable --- include/courtroom.h | 3 ++- src/courtroom.cpp | 12 +++++++----- 2 files changed, 9 insertions(+), 6 deletions(-) diff --git a/include/courtroom.h b/include/courtroom.h index bf33581..d20c580 100644 --- a/include/courtroom.h +++ b/include/courtroom.h @@ -336,7 +336,8 @@ private: bool message_is_centered = false; int current_display_speed = 3; - int message_display_speed[7] = {5, 10, 25, 40, 50, 70, 90}; + int base_display_speed = 40; + double message_display_mult[7] = {0.125, 0.25, 0.65, 1, 1.25, 1.75, 2.25}; // The character ID of the character this user wants to appear alongside with. int other_charid = -1; diff --git a/src/courtroom.cpp b/src/courtroom.cpp index dcc3175..0b42dae 100644 --- a/src/courtroom.cpp +++ b/src/courtroom.cpp @@ -3415,7 +3415,8 @@ void Courtroom::chat_tick() else if (current_display_speed > 6) current_display_speed = 6; - if ((message_display_speed[current_display_speed] <= 0 && + int msg_delay = base_display_speed * message_display_mult[current_display_speed]; + if ((msg_delay <= 0 && tick_pos < f_message.size() - 1) || formatting_char) { chat_tick_timer->start(0); // Don't bother rendering anything out as we're @@ -3459,7 +3460,7 @@ void Courtroom::chat_tick() // And if it's faster than that: // 40/10 = 4 b_rate = - qMax(b_rate, qRound(static_cast(message_display_speed[3]) / + qMax(b_rate, qRound(static_cast(base_display_speed) / msg_delay)); } if (blip_ticker % b_rate == 0) { @@ -3478,9 +3479,10 @@ void Courtroom::chat_tick() // Punctuation delayer, only kicks in on speed ticks less than }} if (current_display_speed > 1 && punctuation_chars.contains(f_character)) { - // Making the user have to wait any longer than 150ms per letter is - // downright unreasonable - msg_delay = qMin(150, msg_delay * punctuation_modifier); + // Making the user have to wait any longer than 1.5 of the slowest speed + // is downright unreasonable + int max_delay = base_display_speed * message_display_mult[6] * 1.5; + msg_delay = qMin(max_delay, msg_delay * punctuation_modifier); } // If this color is talking