diff options
| -rw-r--r-- | Attorney_Online.pro | 3 | ||||
| m--------- | base/themes | 0 | ||||
| -rw-r--r-- | include/aoapplication.h | 7 | ||||
| -rw-r--r-- | include/aooptionsdialog.h | 5 | ||||
| -rw-r--r-- | include/aopacket.h | 2 | ||||
| -rw-r--r-- | include/courtroom.h | 3 | ||||
| -rw-r--r-- | src/aolayer.cpp | 11 | ||||
| -rw-r--r-- | src/aooptionsdialog.cpp | 50 | ||||
| -rw-r--r-- | src/aopacket.cpp | 27 | ||||
| -rw-r--r-- | src/charselect.cpp | 4 | ||||
| -rw-r--r-- | src/courtroom.cpp | 19 | ||||
| -rw-r--r-- | src/packet_distribution.cpp | 9 | ||||
| -rw-r--r-- | src/text_file_functions.cpp | 12 |
13 files changed, 120 insertions, 32 deletions
diff --git a/Attorney_Online.pro b/Attorney_Online.pro index 52570469..ba1c80a8 100644 --- a/Attorney_Online.pro +++ b/Attorney_Online.pro @@ -19,6 +19,9 @@ QMAKE_LFLAGS += -Wl,-rpath,"'\$$ORIGIN/lib'" # Uncomment for verbose network logging # DEFINES += DEBUG_NETWORK +# Uncomment for building with debug symbols +# CONFIG += debug + # Uncomment to enable Discord Rich Presence # DEFINES += DISCORD diff --git a/base/themes b/base/themes -Subproject 15b0cc4aa1241a9b740fb1ce8a61c7f699a80de +Subproject 9090a63dec0384c63fc4bdc7fc68dccb961e05c diff --git a/include/aoapplication.h b/include/aoapplication.h index c217dad7..9667b269 100644 --- a/include/aoapplication.h +++ b/include/aoapplication.h @@ -222,6 +222,10 @@ public: // for settings. bool is_customchat_enabled(); + // Returns the value of whether continuous playback should be used + // from the config.ini. + bool is_continuous_enabled(); + // Returns the value of the maximum amount of lines the IC chatlog // may contain, from config.ini. int get_max_log_size(); @@ -229,6 +233,9 @@ public: // Current wait time between messages for the queue system int stay_time(); + // 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 74fc9af7..340a9f07 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_crawl_lbl; + QSpinBox *ui_text_crawl_spinbox; QLabel *ui_chat_ratelimit_lbl; QSpinBox *ui_chat_ratelimit_spinbox; QLabel *ui_log_ic_actions_lbl; @@ -97,6 +99,9 @@ private: QLabel *ui_customchat_lbl; QCheckBox *ui_customchat_cb; + QLabel *ui_continuous_lbl; + QCheckBox *ui_continuous_cb; + QWidget *ui_callwords_tab; QWidget *ui_callwords_widget; QVBoxLayout *ui_callwords_layout; diff --git a/include/aopacket.h b/include/aopacket.h index 794025c5..a3251033 100644 --- a/include/aopacket.h +++ b/include/aopacket.h @@ -17,6 +17,8 @@ public: void net_encode(); void net_decode(); + static void escape(QStringList &contents); + static void unescape(QStringList &contents); private: QString m_header; diff --git a/include/courtroom.h b/include/courtroom.h index bf335814..fe3a1713 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 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. int other_charid = -1; diff --git a/src/aolayer.cpp b/src/aolayer.cpp index f95773b0..efa0e447 100644 --- a/src/aolayer.cpp +++ b/src/aolayer.cpp @@ -325,6 +325,11 @@ void AOLayer::start_playback(QString p_image) if (!file_exists(p_image)) return; + if (!ao_app->is_continuous_enabled()) { + continuous = false; + force_continuous = true; + } + QString scaling_override = ao_app->read_design_ini("scaling", p_image + ".ini"); if (scaling_override != "") @@ -351,12 +356,13 @@ void AOLayer::start_playback(QString p_image) frame = 0; continuous = false; } - // CANTFIX: this causes a slight hitch + // CANTFIX: this causes a hitch // The correct way of doing this would be to use QImageReader::jumpToImage() // and populate missing data in the movie ticker when it's needed. This is - // unforunately completely impossible, because QImageReader::jumpToImage() is + // unfortunately completely impossible, because QImageReader::jumpToImage() is // not implemented in any image format AO2 is equipped to use. Instead, the // default behavior is used - that is, absolutely nothing. + // This is why continuous playback can be toggled off. if (continuous) { for (int i = frame; i--;) { if (i <= -1) @@ -368,6 +374,7 @@ void AOLayer::start_playback(QString p_image) // qDebug() << "appending delay of " << l_delay; } } + last_path = p_image; // qDebug() << "CONT: " << continuous << " MAX: " << max_frames // << " LAST MAX: " << last_max_frames << " FRAME: " << frame; QPixmap f_pixmap = this->get_pixmap(m_reader.read()); diff --git a/src/aooptionsdialog.cpp b/src/aooptionsdialog.cpp index 0fbee478..2f7e8543 100644 --- a/src/aooptionsdialog.cpp +++ b/src/aooptionsdialog.cpp @@ -8,18 +8,18 @@ AOOptionsDialog::AOOptionsDialog(QWidget *parent, AOApplication *p_ao_app) ao_app = p_ao_app; // Setting up the basics. - // setAttribute(Qt::WA_DeleteOnClose); + setWindowFlag(Qt::WindowCloseButtonHint); setWindowTitle(tr("Settings")); - resize(398, 320); + resize(400, 408); ui_settings_buttons = new QDialogButtonBox(this); - QSizePolicy sizePolicy1(QSizePolicy::Minimum, QSizePolicy::MinimumExpanding); + QSizePolicy sizePolicy1(QSizePolicy::MinimumExpanding, QSizePolicy::MinimumExpanding); sizePolicy1.setHorizontalStretch(0); sizePolicy1.setVerticalStretch(0); sizePolicy1.setHeightForWidth( ui_settings_buttons->sizePolicy().hasHeightForWidth()); - ui_settings_buttons->setSizePolicy(sizePolicy1); + ui_settings_buttons->setSizePolicy(QSizePolicy(QSizePolicy::MinimumExpanding, QSizePolicy::Maximum)); ui_settings_buttons->setOrientation(Qt::Horizontal); ui_settings_buttons->setStandardButtons(QDialogButtonBox::Cancel | QDialogButtonBox::Save); @@ -45,7 +45,6 @@ AOOptionsDialog::AOOptionsDialog(QWidget *parent, AOApplication *p_ao_app) ui_gameplay_tab->setSizePolicy(sizePolicy1); ui_settings_tabs->addTab(ui_gameplay_tab, tr("Gameplay")); ui_form_layout_widget = new QWidget(ui_gameplay_tab); - ui_form_layout_widget->setGeometry(QRect(10, 10, 361, 361)); ui_form_layout_widget->setSizePolicy(sizePolicy1); ui_gameplay_form = new QFormLayout(ui_form_layout_widget); @@ -54,7 +53,7 @@ AOOptionsDialog::AOOptionsDialog(QWidget *parent, AOApplication *p_ao_app) ui_gameplay_form->setFormAlignment(Qt::AlignLeading | Qt::AlignLeft | Qt::AlignTop); ui_gameplay_form->setContentsMargins(0, 0, 0, 0); - ui_gameplay_form->setSpacing(2); + ui_gameplay_form->setSpacing(4); int row = 0; @@ -109,12 +108,13 @@ AOOptionsDialog::AOOptionsDialog(QWidget *parent, AOApplication *p_ao_app) ui_length_lbl = new QLabel(ui_form_layout_widget); ui_length_lbl->setText(tr("Log length:")); ui_length_lbl->setToolTip(tr( - "The amount of messages the IC chatlog will keep before " - "deleting older messages. A value of 0 or below counts as 'infinite'.")); + "The amount of message lines the IC chatlog will keep before " + "deleting older message lines. A value of 0 or below counts as 'infinite'.")); ui_gameplay_form->setWidget(row, QFormLayout::LabelRole, ui_length_lbl); ui_length_spinbox = new QSpinBox(ui_form_layout_widget); + ui_length_spinbox->setSuffix(" lines"); ui_length_spinbox->setMaximum(10000); ui_length_spinbox->setValue(p_ao_app->get_max_log_size()); @@ -145,6 +145,7 @@ AOOptionsDialog::AOOptionsDialog(QWidget *parent, AOApplication *p_ao_app) ui_gameplay_form->setWidget(row, QFormLayout::LabelRole, ui_log_margin_lbl); ui_log_margin_spinbox = new QSpinBox(ui_form_layout_widget); + ui_log_margin_spinbox->setSuffix(" px"); ui_log_margin_spinbox->setMaximum(1000); ui_log_margin_spinbox->setValue(p_ao_app->get_log_margin()); @@ -187,6 +188,7 @@ AOOptionsDialog::AOOptionsDialog(QWidget *parent, AOApplication *p_ao_app) ui_gameplay_form->setWidget(row, QFormLayout::LabelRole, ui_stay_time_lbl); ui_stay_time_spinbox = new QSpinBox(ui_form_layout_widget); + ui_stay_time_spinbox->setSuffix(" ms"); ui_stay_time_spinbox->setMaximum(10000); ui_stay_time_spinbox->setValue(p_ao_app->stay_time()); @@ -219,6 +221,21 @@ AOOptionsDialog::AOOptionsDialog(QWidget *parent, AOApplication *p_ao_app) ui_gameplay_form->setWidget(row, QFormLayout::FieldRole, ui_instant_objection_cb); row += 1; + 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_crawl_lbl); + + 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_crawl_spinbox); + + 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( @@ -227,10 +244,12 @@ AOOptionsDialog::AOOptionsDialog(QWidget *parent, AOApplication *p_ao_app) 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->setSuffix(" ms"); 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); @@ -440,6 +459,19 @@ AOOptionsDialog::AOOptionsDialog(QWidget *parent, AOApplication *p_ao_app) ui_gameplay_form->setWidget(row, QFormLayout::FieldRole, ui_customchat_cb); + row += 1; + ui_continuous_lbl = new QLabel(ui_form_layout_widget); + ui_continuous_lbl->setText(tr("Continuous Playback:")); + ui_continuous_lbl->setToolTip( + tr("Whether or not to resume playing animations from where they left off. Turning off might reduce lag.")); + + ui_gameplay_form->setWidget(row, QFormLayout::LabelRole, ui_continuous_lbl); + + ui_continuous_cb = new QCheckBox(ui_form_layout_widget); + ui_continuous_cb->setChecked(ao_app->is_continuous_enabled()); + + ui_gameplay_form->setWidget(row, QFormLayout::FieldRole, ui_continuous_cb); + QScrollArea *scroll = new QScrollArea(this); scroll->setWidget(ui_form_layout_widget); ui_gameplay_tab->setLayout(new QVBoxLayout); @@ -837,6 +869,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_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()); @@ -852,6 +885,7 @@ void AOOptionsDialog::save_pressed() configini->setValue("stickypres", ui_stickypres_cb->isChecked()); configini->setValue("customchat", ui_customchat_cb->isChecked()); configini->setValue("automatic_logging_enabled", ui_log_cb->isChecked()); + configini->setValue("continuous_playback", ui_continuous_cb->isChecked()); QFile *callwordsini = new QFile(ao_app->get_base_path() + "callwords.ini"); if (callwordsini->open(QIODevice::WriteOnly | QIODevice::Truncate | diff --git a/src/aopacket.cpp b/src/aopacket.cpp index a40d2ef7..8f4a6e36 100644 --- a/src/aopacket.cpp +++ b/src/aopacket.cpp @@ -12,25 +12,34 @@ QString AOPacket::to_string(bool encoded) { QStringList contents = m_contents; if (encoded) - contents.replaceInStrings("#", "<num>") - .replaceInStrings("%", "<percent>") - .replaceInStrings("$", "<dollar>") - .replaceInStrings("&", "<and>"); + escape(contents); return m_header + "#" + contents.join("#") + "#%"; } void AOPacket::net_encode() { - m_contents.replaceInStrings("#", "<num>") - .replaceInStrings("%", "<percent>") - .replaceInStrings("$", "<dollar>") - .replaceInStrings("&", "<and>"); + escape(m_contents); } void AOPacket::net_decode() { - m_contents.replaceInStrings("<num>", "#") + unescape(m_contents); +} + +void AOPacket::escape(QStringList &contents) +{ + contents.replaceInStrings("#", "<num>") + .replaceInStrings("%", "<percent>") + .replaceInStrings("$", "<dollar>") + .replaceInStrings("&", "<and>"); + +} + +void AOPacket::unescape(QStringList &contents) +{ + contents.replaceInStrings("<num>", "#") .replaceInStrings("<percent>", "%") .replaceInStrings("<dollar>", "$") .replaceInStrings("<and>", "&"); + } diff --git a/src/charselect.cpp b/src/charselect.cpp index abed0950..1356f242 100644 --- a/src/charselect.cpp +++ b/src/charselect.cpp @@ -176,8 +176,10 @@ void Courtroom::char_clicked(int n_char) new AOPacket("CC#" + QString::number(ao_app->s_pv) + "#" + QString::number(n_char) + "#" + get_hdid() + "#%")); } - else + else { update_character(n_char); + set_widgets(); // so we don't erroneously keep the charselect's fixedSize + } if (n_char != -1) ui_ic_chat_name->setPlaceholderText(char_list.at(n_char).name); diff --git a/src/courtroom.cpp b/src/courtroom.cpp index dcc3175c..0e2c2805 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 = @@ -3231,6 +3228,9 @@ void Courtroom::start_chat_ticking() tick_pos = 0; blip_ticker = 0; + text_crawl = ao_app->get_text_crawl(); + 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; @@ -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 = text_crawl * 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 @@ -3426,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) { @@ -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<float>(message_display_speed[3]) / + qMax(b_rate, qRound(static_cast<float>(text_crawl) / msg_delay)); } if (blip_ticker % b_rate == 0) { @@ -3478,9 +3478,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 = text_crawl * message_display_mult[6] * 1.5; + msg_delay = qMin(max_delay, msg_delay * punctuation_modifier); } // If this color is talking diff --git a/src/packet_distribution.cpp b/src/packet_distribution.cpp index 2da6981c..5a093e3c 100644 --- a/src/packet_distribution.cpp +++ b/src/packet_distribution.cpp @@ -8,9 +8,12 @@ void AOApplication::ms_packet_received(AOPacket *p_packet) { - p_packet->net_decode(); - QString header = p_packet->get_header(); + + // Some packets need to handle decode/encode separately + if (header != "SC") { + p_packet->net_decode(); + } QStringList f_contents = p_packet->get_contents(); #ifdef DEBUG_NETWORK @@ -333,6 +336,8 @@ void AOApplication::server_packet_received(AOPacket *p_packet) for (int n_element = 0; n_element < f_contents.size(); ++n_element) { QStringList sub_elements = f_contents.at(n_element).split("&"); + AOPacket::unescape(sub_elements); + char_type f_char; f_char.name = sub_elements.at(0); if (sub_elements.size() >= 2) diff --git a/src/text_file_functions.cpp b/src/text_file_functions.cpp index 0128f565..95a54f10 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_crawl() +{ + int result = configini->value("text_crawl", 40).toInt(); + return result; +} + int AOApplication::get_chat_ratelimit() { int result = configini->value("chat_ratelimit", 300).toInt(); @@ -1089,6 +1095,12 @@ bool AOApplication::is_customchat_enabled() return result.startsWith("true"); } +bool AOApplication::is_continuous_enabled() +{ + QString result = configini->value("continuous_playback", "true").value<QString>(); + return result.startsWith("true"); +} + bool AOApplication::get_casing_enabled() { QString result = configini->value("casing_enabled", "false").value<QString>(); |
