diff options
| author | oldmud0 <oldmud0@users.noreply.github.com> | 2020-11-10 14:07:45 -0600 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2020-11-10 14:07:45 -0600 |
| commit | 4eb45ef2b08095b9ecd81b62de1761ed5dac8b84 (patch) | |
| tree | f37f30a92bf883ea0e87cc5192d004626a1d23c1 /src/courtroom.cpp | |
| parent | fe3b16829fc51e04e284436788db57e96bdded24 (diff) | |
| parent | c392bb3415ca8a01dbfc5129527af25ae6de9c08 (diff) | |
Merge pull request #305 from Crystalwarrior/bugfix/blip-accuracy
More accurate/consistent blip rate functionality + punctuation slowdown fixes
Diffstat (limited to 'src/courtroom.cpp')
| -rw-r--r-- | src/courtroom.cpp | 35 |
1 files changed, 29 insertions, 6 deletions
diff --git a/src/courtroom.cpp b/src/courtroom.cpp index 96e2a533..ec4e47b4 100644 --- a/src/courtroom.cpp +++ b/src/courtroom.cpp @@ -2990,17 +2990,40 @@ void Courtroom::chat_tick() ui_vp_message->ensureCursorVisible(); - // Blip player and real tick pos ticker - if (!formatting_char && (f_character != ' ' || blank_blip)) { - if (blip_ticker % blip_rate == 0) { + // We blip every "blip rate" letters. + // Here's an example with blank_blip being false and blip_rate being 2: + // I am you + // ! ! ! ! + // where ! is the blip sound + int b_rate = blip_rate; + // Earrape prevention without using timers, this method is more consistent. + if (msg_delay != 0 && msg_delay <= 25) { + // The default blip speed is 40ms, and if current msg_delay is 25ms, + // the formula will result in the blip rate of: + // 40/25 = 1.6 = 2 + // And if it's faster than that: + // 40/10 = 4 + b_rate = qMax(b_rate, qRound(static_cast<float>(message_display_speed[3])/msg_delay)); + } + if (blip_ticker % b_rate == 0) { + // ignoring white space unless blank_blip is enabled. + if (!formatting_char && (f_character != ' ' || blank_blip)) { blip_player->blip_tick(); + ++blip_ticker; } + } + else + { + // Don't fully ignore whitespace still, keep ticking until + // we reached the need to play a blip sound - we also just + // need to wait for a letter to play it on. ++blip_ticker; } - // Punctuation delayer - if (punctuation_chars.contains(f_character)) { - msg_delay *= punctuation_modifier; + // 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); } // If this color is talking |
