From b040449f7fd6ddf404e81d4b44c1726827959aa9 Mon Sep 17 00:00:00 2001 From: Crystalwarrior Date: Wed, 27 Jan 2021 18:20:56 +0300 Subject: [PATCH 1/6] 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 From 88cdf3c376c7eebe598f620722390daa26da02d2 Mon Sep 17 00:00:00 2001 From: Crystalwarrior Date: Wed, 27 Jan 2021 18:33:25 +0300 Subject: [PATCH 2/6] Fix a thing not being removed --- src/courtroom.cpp | 1 - 1 file changed, 1 deletion(-) diff --git a/src/courtroom.cpp b/src/courtroom.cpp index 0b42dae..92218d0 100644 --- a/src/courtroom.cpp +++ b/src/courtroom.cpp @@ -3427,7 +3427,6 @@ void Courtroom::chat_tick() // scrollbar convenience } else { - int msg_delay = message_display_speed[current_display_speed]; // Do the colors, gradual showing, etc. in here QString f_message_filtered = filter_ic_text(f_message, true, tick_pos, m_chatmessage[TEXT_COLOR].toInt()); for (int c = 0; c < max_colors; ++c) { From 423fe3d3fe5b7bce2c3879d332d5ba5e08ccd954 Mon Sep 17 00:00:00 2001 From: Crystalwarrior Date: Wed, 27 Jan 2021 19:18:43 +0300 Subject: [PATCH 3/6] Add the setting for the text scrawl --- include/aoapplication.h | 3 +++ include/aooptionsdialog.h | 2 ++ include/courtroom.h | 2 +- src/aooptionsdialog.cpp | 16 ++++++++++++++++ src/courtroom.cpp | 7 ++++--- src/text_file_functions.cpp | 6 ++++++ 6 files changed, 32 insertions(+), 4 deletions(-) diff --git a/include/aoapplication.h b/include/aoapplication.h index c217dad..9fe1d40 100644 --- a/include/aoapplication.h +++ b/include/aoapplication.h @@ -229,6 +229,9 @@ public: // Current wait time between messages for the queue system int stay_time(); + // Returns the letter display speed during text scrawl in in-character messages + int get_text_scrawl(); + // Returns Minimum amount of time (in miliseconds) that must pass before the next Enter key press will send your IC message. (new behaviour) int get_chat_ratelimit(); diff --git a/include/aooptionsdialog.h b/include/aooptionsdialog.h index 74fc9af..423b88e 100644 --- a/include/aooptionsdialog.h +++ b/include/aooptionsdialog.h @@ -58,6 +58,8 @@ private: QCheckBox *ui_desync_logs_cb; QLabel *ui_instant_objection_lbl; QCheckBox *ui_instant_objection_cb; + QLabel *ui_text_scrawl_lbl; + QSpinBox *ui_text_scrawl_spinbox; QLabel *ui_chat_ratelimit_lbl; QSpinBox *ui_chat_ratelimit_spinbox; QLabel *ui_log_ic_actions_lbl; diff --git a/include/courtroom.h b/include/courtroom.h index d20c580..52a6cde 100644 --- a/include/courtroom.h +++ b/include/courtroom.h @@ -336,7 +336,7 @@ private: bool message_is_centered = false; int current_display_speed = 3; - int base_display_speed = 40; + int text_scrawl = 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. diff --git a/src/aooptionsdialog.cpp b/src/aooptionsdialog.cpp index 0fbee47..903fc6e 100644 --- a/src/aooptionsdialog.cpp +++ b/src/aooptionsdialog.cpp @@ -218,6 +218,20 @@ AOOptionsDialog::AOOptionsDialog(QWidget *parent, AOApplication *p_ao_app) ui_gameplay_form->setWidget(row, QFormLayout::FieldRole, ui_instant_objection_cb); + row += 1; + ui_text_scrawl_lbl = new QLabel(ui_form_layout_widget); + ui_text_scrawl_lbl->setText(tr("Text Scrawl:")); + ui_text_scrawl_lbl->setToolTip(tr( + "Amount of time spent on each letter when the in-character text is being displayed.")); + + ui_gameplay_form->setWidget(row, QFormLayout::LabelRole, ui_text_scrawl_lbl); + + ui_text_scrawl_spinbox = new QSpinBox(ui_form_layout_widget); + ui_text_scrawl_spinbox->setMaximum(500); + ui_text_scrawl_spinbox->setValue(p_ao_app->get_text_scrawl()); + + ui_gameplay_form->setWidget(row, QFormLayout::FieldRole, ui_text_scrawl_spinbox); + row += 1; ui_chat_ratelimit_lbl = new QLabel(ui_form_layout_widget); ui_chat_ratelimit_lbl->setText(tr("Chat Rate Limit:")); @@ -231,6 +245,7 @@ AOOptionsDialog::AOOptionsDialog(QWidget *parent, AOApplication *p_ao_app) ui_chat_ratelimit_spinbox->setValue(p_ao_app->get_chat_ratelimit()); ui_gameplay_form->setWidget(row, QFormLayout::FieldRole, ui_chat_ratelimit_spinbox); + row += 1; ui_log_names_divider = new QFrame(ui_form_layout_widget); ui_log_names_divider->setFrameShape(QFrame::HLine); @@ -837,6 +852,7 @@ void AOOptionsDialog::save_pressed() configini->setValue("desync_logs", ui_desync_logs_cb->isChecked()); configini->setValue("stay_time", ui_stay_time_spinbox->value()); configini->setValue("instant_objection", ui_instant_objection_cb->isChecked()); + configini->setValue("text_scrawl", ui_text_scrawl_spinbox->value()); configini->setValue("chat_ratelimit", ui_chat_ratelimit_spinbox->value()); configini->setValue("default_username", ui_username_textbox->text()); configini->setValue("show_custom_shownames", ui_showname_cb->isChecked()); diff --git a/src/courtroom.cpp b/src/courtroom.cpp index 92218d0..44fc377 100644 --- a/src/courtroom.cpp +++ b/src/courtroom.cpp @@ -3231,6 +3231,7 @@ void Courtroom::start_chat_ticking() tick_pos = 0; blip_ticker = 0; + text_scrawl = ao_app->get_text_scrawl(); // At the start of every new message, we set the text speed to the default. current_display_speed = 3; @@ -3415,7 +3416,7 @@ void Courtroom::chat_tick() else if (current_display_speed > 6) current_display_speed = 6; - int msg_delay = base_display_speed * message_display_mult[current_display_speed]; + int msg_delay = text_scrawl * message_display_mult[current_display_speed]; if ((msg_delay <= 0 && tick_pos < f_message.size() - 1) || formatting_char) { @@ -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(base_display_speed) / + qMax(b_rate, qRound(static_cast(text_scrawl) / msg_delay)); } if (blip_ticker % b_rate == 0) { @@ -3480,7 +3481,7 @@ void Courtroom::chat_tick() if (current_display_speed > 1 && punctuation_chars.contains(f_character)) { // 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; + int max_delay = text_scrawl * message_display_mult[6] * 1.5; msg_delay = qMin(max_delay, msg_delay * punctuation_modifier); } diff --git a/src/text_file_functions.cpp b/src/text_file_functions.cpp index 0128f56..eed78c3 100644 --- a/src/text_file_functions.cpp +++ b/src/text_file_functions.cpp @@ -52,6 +52,12 @@ int AOApplication::stay_time() return result; } +int AOApplication::get_text_scrawl() +{ + int result = configini->value("text_scrawl", 40).toInt(); + return result; +} + int AOApplication::get_chat_ratelimit() { int result = configini->value("chat_ratelimit", 300).toInt(); From 1a3f500034fe794cff6ad418754bc29d7d3dc78c Mon Sep 17 00:00:00 2001 From: Crystalwarrior Date: Wed, 27 Jan 2021 19:58:29 +0300 Subject: [PATCH 4/6] Update text scrawl tooltip info and spinbox suffix --- src/aooptionsdialog.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/aooptionsdialog.cpp b/src/aooptionsdialog.cpp index 903fc6e..d10f6b0 100644 --- a/src/aooptionsdialog.cpp +++ b/src/aooptionsdialog.cpp @@ -222,11 +222,12 @@ AOOptionsDialog::AOOptionsDialog(QWidget *parent, AOApplication *p_ao_app) ui_text_scrawl_lbl = new QLabel(ui_form_layout_widget); ui_text_scrawl_lbl->setText(tr("Text Scrawl:")); ui_text_scrawl_lbl->setToolTip(tr( - "Amount of time spent on each letter when the in-character text is being displayed.")); + "Amount of time (in miliseconds) spent on each letter when the in-character text is being displayed.")); ui_gameplay_form->setWidget(row, QFormLayout::LabelRole, ui_text_scrawl_lbl); ui_text_scrawl_spinbox = new QSpinBox(ui_form_layout_widget); + ui_text_scrawl_spinbox->setSuffix(" ms"); ui_text_scrawl_spinbox->setMaximum(500); ui_text_scrawl_spinbox->setValue(p_ao_app->get_text_scrawl()); From 9ebc0f9b5438325cbec20ee41bd06b4033dc79da Mon Sep 17 00:00:00 2001 From: Crystalwarrior Date: Wed, 27 Jan 2021 20:01:50 +0300 Subject: [PATCH 5/6] Initialize blip_rate and blank_blip before the text message chat_tick is called instead of when reload_theme is pressed (more intuitive application of the settings) --- src/courtroom.cpp | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/src/courtroom.cpp b/src/courtroom.cpp index 44fc377..f9cbbf9 100644 --- a/src/courtroom.cpp +++ b/src/courtroom.cpp @@ -467,9 +467,6 @@ void Courtroom::set_pair_list() void Courtroom::set_widgets() { - blip_rate = ao_app->read_blip_rate(); - blank_blip = ao_app->get_blank_blip(); - QString filename = "courtroom_design.ini"; pos_size_type f_courtroom = @@ -3232,6 +3229,8 @@ void Courtroom::start_chat_ticking() tick_pos = 0; blip_ticker = 0; text_scrawl = ao_app->get_text_scrawl(); + blip_rate = ao_app->read_blip_rate(); + blank_blip = ao_app->get_blank_blip(); // At the start of every new message, we set the text speed to the default. current_display_speed = 3; From d1e7b2920b8ab0a1ae1488ea79db0d4a5a3173da Mon Sep 17 00:00:00 2001 From: Crystalwarrior Date: Wed, 27 Jan 2021 20:05:06 +0300 Subject: [PATCH 6/6] Refactor "text scrawl" to "text crawl" (sounds more simple to understand than scrawl tbh) --- include/aoapplication.h | 4 ++-- include/aooptionsdialog.h | 4 ++-- include/courtroom.h | 2 +- src/aooptionsdialog.cpp | 20 ++++++++++---------- src/courtroom.cpp | 8 ++++---- src/text_file_functions.cpp | 4 ++-- 6 files changed, 21 insertions(+), 21 deletions(-) diff --git a/include/aoapplication.h b/include/aoapplication.h index 9fe1d40..8b248cc 100644 --- a/include/aoapplication.h +++ b/include/aoapplication.h @@ -229,8 +229,8 @@ public: // Current wait time between messages for the queue system int stay_time(); - // Returns the letter display speed during text scrawl in in-character messages - int get_text_scrawl(); + // Returns the letter display speed during text crawl in in-character messages + int get_text_crawl(); // Returns Minimum amount of time (in miliseconds) that must pass before the next Enter key press will send your IC message. (new behaviour) int get_chat_ratelimit(); diff --git a/include/aooptionsdialog.h b/include/aooptionsdialog.h index 423b88e..908d918 100644 --- a/include/aooptionsdialog.h +++ b/include/aooptionsdialog.h @@ -58,8 +58,8 @@ private: QCheckBox *ui_desync_logs_cb; QLabel *ui_instant_objection_lbl; QCheckBox *ui_instant_objection_cb; - QLabel *ui_text_scrawl_lbl; - QSpinBox *ui_text_scrawl_spinbox; + QLabel *ui_text_crawl_lbl; + QSpinBox *ui_text_crawl_spinbox; QLabel *ui_chat_ratelimit_lbl; QSpinBox *ui_chat_ratelimit_spinbox; QLabel *ui_log_ic_actions_lbl; diff --git a/include/courtroom.h b/include/courtroom.h index 52a6cde..fe3a171 100644 --- a/include/courtroom.h +++ b/include/courtroom.h @@ -336,7 +336,7 @@ private: bool message_is_centered = false; int current_display_speed = 3; - int text_scrawl = 40; + int text_crawl = 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. diff --git a/src/aooptionsdialog.cpp b/src/aooptionsdialog.cpp index d10f6b0..f52c639 100644 --- a/src/aooptionsdialog.cpp +++ b/src/aooptionsdialog.cpp @@ -219,19 +219,19 @@ AOOptionsDialog::AOOptionsDialog(QWidget *parent, AOApplication *p_ao_app) ui_gameplay_form->setWidget(row, QFormLayout::FieldRole, ui_instant_objection_cb); row += 1; - ui_text_scrawl_lbl = new QLabel(ui_form_layout_widget); - ui_text_scrawl_lbl->setText(tr("Text Scrawl:")); - ui_text_scrawl_lbl->setToolTip(tr( + ui_text_crawl_lbl = new QLabel(ui_form_layout_widget); + ui_text_crawl_lbl->setText(tr("Text crawl:")); + ui_text_crawl_lbl->setToolTip(tr( "Amount of time (in miliseconds) spent on each letter when the in-character text is being displayed.")); - ui_gameplay_form->setWidget(row, QFormLayout::LabelRole, ui_text_scrawl_lbl); + ui_gameplay_form->setWidget(row, QFormLayout::LabelRole, ui_text_crawl_lbl); - ui_text_scrawl_spinbox = new QSpinBox(ui_form_layout_widget); - ui_text_scrawl_spinbox->setSuffix(" ms"); - ui_text_scrawl_spinbox->setMaximum(500); - ui_text_scrawl_spinbox->setValue(p_ao_app->get_text_scrawl()); + ui_text_crawl_spinbox = new QSpinBox(ui_form_layout_widget); + ui_text_crawl_spinbox->setSuffix(" ms"); + ui_text_crawl_spinbox->setMaximum(500); + ui_text_crawl_spinbox->setValue(p_ao_app->get_text_crawl()); - ui_gameplay_form->setWidget(row, QFormLayout::FieldRole, ui_text_scrawl_spinbox); + ui_gameplay_form->setWidget(row, QFormLayout::FieldRole, ui_text_crawl_spinbox); row += 1; ui_chat_ratelimit_lbl = new QLabel(ui_form_layout_widget); @@ -853,7 +853,7 @@ void AOOptionsDialog::save_pressed() configini->setValue("desync_logs", ui_desync_logs_cb->isChecked()); configini->setValue("stay_time", ui_stay_time_spinbox->value()); configini->setValue("instant_objection", ui_instant_objection_cb->isChecked()); - configini->setValue("text_scrawl", ui_text_scrawl_spinbox->value()); + configini->setValue("text_crawl", ui_text_crawl_spinbox->value()); configini->setValue("chat_ratelimit", ui_chat_ratelimit_spinbox->value()); configini->setValue("default_username", ui_username_textbox->text()); configini->setValue("show_custom_shownames", ui_showname_cb->isChecked()); diff --git a/src/courtroom.cpp b/src/courtroom.cpp index f9cbbf9..0e2c280 100644 --- a/src/courtroom.cpp +++ b/src/courtroom.cpp @@ -3228,7 +3228,7 @@ void Courtroom::start_chat_ticking() tick_pos = 0; blip_ticker = 0; - text_scrawl = ao_app->get_text_scrawl(); + text_crawl = ao_app->get_text_crawl(); blip_rate = ao_app->read_blip_rate(); blank_blip = ao_app->get_blank_blip(); @@ -3415,7 +3415,7 @@ void Courtroom::chat_tick() else if (current_display_speed > 6) current_display_speed = 6; - int msg_delay = text_scrawl * message_display_mult[current_display_speed]; + int msg_delay = text_crawl * message_display_mult[current_display_speed]; if ((msg_delay <= 0 && tick_pos < f_message.size() - 1) || formatting_char) { @@ -3459,7 +3459,7 @@ void Courtroom::chat_tick() // And if it's faster than that: // 40/10 = 4 b_rate = - qMax(b_rate, qRound(static_cast(text_scrawl) / + qMax(b_rate, qRound(static_cast(text_crawl) / msg_delay)); } if (blip_ticker % b_rate == 0) { @@ -3480,7 +3480,7 @@ void Courtroom::chat_tick() if (current_display_speed > 1 && punctuation_chars.contains(f_character)) { // Making the user have to wait any longer than 1.5 of the slowest speed // is downright unreasonable - int max_delay = text_scrawl * message_display_mult[6] * 1.5; + int max_delay = text_crawl * message_display_mult[6] * 1.5; msg_delay = qMin(max_delay, msg_delay * punctuation_modifier); } diff --git a/src/text_file_functions.cpp b/src/text_file_functions.cpp index eed78c3..02d4537 100644 --- a/src/text_file_functions.cpp +++ b/src/text_file_functions.cpp @@ -52,9 +52,9 @@ int AOApplication::stay_time() return result; } -int AOApplication::get_text_scrawl() +int AOApplication::get_text_crawl() { - int result = configini->value("text_scrawl", 40).toInt(); + int result = configini->value("text_crawl", 40).toInt(); return result; }