From 4645d9dd080964560477e48d99812bc494c1965b Mon Sep 17 00:00:00 2001 From: Crystalwarrior Date: Sat, 14 Sep 2019 00:46:46 +0300 Subject: [PATCH] Add a blip sound QElapsedTimer so blipsounds don't play more frequently than 60ms to preserve all of our ears. Adjust the message display speeds to feel more accurate to AA, with }}} speed displaying text instantly for that section --- include/aoblipplayer.h | 4 ++++ include/courtroom.h | 2 +- src/aoblipplayer.cpp | 4 ++++ src/courtroom.cpp | 28 +++++++++++----------------- 4 files changed, 20 insertions(+), 18 deletions(-) diff --git a/include/aoblipplayer.h b/include/aoblipplayer.h index 44ca48b..9a42837 100644 --- a/include/aoblipplayer.h +++ b/include/aoblipplayer.h @@ -11,6 +11,7 @@ #include #include +#include #include @@ -26,9 +27,12 @@ public: int m_cycle = 0; private: + const int max_blip_ms = 60; + QWidget *m_parent; AOApplication *ao_app; qreal m_volume; + QElapsedTimer delay; void set_volume_internal(qreal p_volume); diff --git a/include/courtroom.h b/include/courtroom.h index 682e12a..9c79a3e 100644 --- a/include/courtroom.h +++ b/include/courtroom.h @@ -259,7 +259,7 @@ private: bool message_is_centered = false; int current_display_speed = 3; - int message_display_speed[7] = {10, 20, 30, 40, 50, 60, 75}; + int message_display_speed[7] = {0, 10, 25, 40, 50, 70, 90}; // This is for checking if the character should start talking again // when an inline blue text ends. diff --git a/src/aoblipplayer.cpp b/src/aoblipplayer.cpp index 1c668ab..5f4dc6c 100644 --- a/src/aoblipplayer.cpp +++ b/src/aoblipplayer.cpp @@ -23,6 +23,10 @@ void AOBlipPlayer::set_blips(QString p_sfx) void AOBlipPlayer::blip_tick() { + if (delay.isValid() && delay.elapsed() < max_blip_ms) + return; + + delay.start(); int f_cycle = m_cycle++; if (m_cycle == 5) diff --git a/src/courtroom.cpp b/src/courtroom.cpp index 06f5aa0..1435b0d 100644 --- a/src/courtroom.cpp +++ b/src/courtroom.cpp @@ -2386,23 +2386,6 @@ void Courtroom::chat_tick() QScrollBar *scroll = ui_vp_message->verticalScrollBar(); scroll->setValue(scroll->maximum()); - if(blank_blip) - qDebug() << "blank_blip found true"; - - if (f_character != ' ' || blank_blip) - { - - if (blip_pos % blip_rate == 0 && !formatting_char) - { - blip_pos = 0; - blip_player->blip_tick(); - } - - ++blip_pos; - } - - tick_pos += f_char_length; - // Restart the timer, but according to the newly set speeds, if there were any. // Keep the speed at bay. if (current_display_speed < 0) @@ -2415,6 +2398,17 @@ void Courtroom::chat_tick() current_display_speed = 6; } + if (!formatting_char && (f_character != ' ' || blank_blip)) + { + if (blip_pos % blip_rate == 0) + { + blip_player->blip_tick(); + } + ++blip_pos; + } + + tick_pos += f_char_length; + // If we had a formatting char, we shouldn't wait so long again, as it won't appear! if (formatting_char) {