Make chat rate limit configurable (#398)

Co-authored-by: stonedDiscord <10584181+stonedDiscord@users.noreply.github.com>
This commit is contained in:
Crystalwarrior 2021-01-15 00:45:30 +03:00 committed by GitHub
parent 31798583a9
commit c42496e204
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 26 additions and 1 deletions

View File

@ -222,6 +222,9 @@ public:
// Current wait time between messages for the queue system
int stay_time();
// 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();
// Returns whether the log should go upwards (new behaviour)
// or downwards (vanilla behaviour).
bool get_log_goes_downwards();

View File

@ -58,6 +58,8 @@ private:
QCheckBox *ui_desync_logs_cb;
QLabel *ui_instant_objection_lbl;
QCheckBox *ui_instant_objection_cb;
QLabel *ui_chat_ratelimit_lbl;
QSpinBox *ui_chat_ratelimit_spinbox;
QLabel *ui_log_ic_actions_lbl;
QCheckBox *ui_log_ic_actions_cb;
QFrame *ui_log_names_divider;

View File

@ -218,6 +218,19 @@ AOOptionsDialog::AOOptionsDialog(QWidget *parent, AOApplication *p_ao_app)
ui_gameplay_form->setWidget(row, QFormLayout::FieldRole, ui_instant_objection_cb);
row += 1;
ui_chat_ratelimit_lbl = new QLabel(ui_form_layout_widget);
ui_chat_ratelimit_lbl->setText(tr("Chat Rate Limit:"));
ui_chat_ratelimit_lbl->setToolTip(tr(
"Minimum amount of time (in miliseconds) that must pass before the next Enter key press will send your IC message."));
ui_gameplay_form->setWidget(row, QFormLayout::LabelRole, ui_chat_ratelimit_lbl);
ui_chat_ratelimit_spinbox = new QSpinBox(ui_form_layout_widget);
ui_chat_ratelimit_spinbox->setMaximum(5000);
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);
@ -824,6 +837,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("chat_ratelimit", ui_chat_ratelimit_spinbox->value());
configini->setValue("default_username", ui_username_textbox->text());
configini->setValue("show_custom_shownames", ui_showname_cb->isChecked());
configini->setValue("master", ui_ms_textbox->text());

View File

@ -1627,7 +1627,7 @@ void Courtroom::on_chat_return_pressed()
return;
ui_ic_chat_message->blockSignals(true);
QTimer::singleShot(600, this,
QTimer::singleShot(ao_app->get_chat_ratelimit(), this,
[=] { ui_ic_chat_message->blockSignals(false); });
// MS#
// deskmod#

View File

@ -52,6 +52,12 @@ int AOApplication::stay_time()
return result;
}
int AOApplication::get_chat_ratelimit()
{
int result = configini->value("chat_ratelimit", 300).toInt();
return result;
}
bool AOApplication::get_log_goes_downwards()
{
QString result =