From c0316ded85bbd2098fd51775632ad4c12be95cb9 Mon Sep 17 00:00:00 2001 From: scatterflower Date: Fri, 21 Aug 2020 15:30:54 -0500 Subject: [PATCH 01/81] remove fantacrypt --- include/aoapplication.h | 3 -- include/aopacket.h | 4 --- src/aopacket.cpp | 18 +---------- src/encryption_functions.cpp | 58 ------------------------------------ src/hex_functions.cpp | 17 ----------- src/packet_distribution.cpp | 20 ------------- 6 files changed, 1 insertion(+), 119 deletions(-) delete mode 100644 src/encryption_functions.cpp delete mode 100644 src/hex_functions.cpp diff --git a/include/aoapplication.h b/include/aoapplication.h index 60d945e..dccc85e 100644 --- a/include/aoapplication.h +++ b/include/aoapplication.h @@ -63,9 +63,6 @@ public: /////////////////server metadata////////////////// - unsigned int s_decryptor = 5; - bool encryption_needed = true; - bool yellow_text_enabled = false; bool prezoom_enabled = false; bool flipping_enabled = false; diff --git a/include/aopacket.h b/include/aopacket.h index 4097be8..e636998 100644 --- a/include/aopacket.h +++ b/include/aopacket.h @@ -15,14 +15,10 @@ public: QStringList &get_contents() { return m_contents; } QString to_string(); - void encrypt_header(unsigned int p_key); - void decrypt_header(unsigned int p_key); - void net_encode(); void net_decode(); private: - bool encrypted = false; QString m_header; QStringList m_contents; diff --git a/src/aopacket.cpp b/src/aopacket.cpp index 6afd39e..1cb5428 100644 --- a/src/aopacket.cpp +++ b/src/aopacket.cpp @@ -31,24 +31,8 @@ QString AOPacket::to_string() f_string += "#%"; - if (encrypted) - return "#" + f_string; - else - return f_string; -} -void AOPacket::encrypt_header(unsigned int p_key) -{ - m_header = fanta_encrypt(m_header, p_key); - - encrypted = true; -} - -void AOPacket::decrypt_header(unsigned int p_key) -{ - m_header = fanta_decrypt(m_header, p_key); - - encrypted = false; + return f_string; } void AOPacket::net_encode() diff --git a/src/encryption_functions.cpp b/src/encryption_functions.cpp deleted file mode 100644 index 6669fe1..0000000 --- a/src/encryption_functions.cpp +++ /dev/null @@ -1,58 +0,0 @@ -#include "encryption_functions.h" - -#include "hex_functions.h" - -QString fanta_encrypt(QString temp_input, unsigned int p_key) -{ - // using standard stdlib types is actually easier here because of implicit - // char<->int conversion which in turn makes encryption arithmetic easier - - unsigned int key = p_key; - unsigned int C1 = 53761; - unsigned int C2 = 32618; - - QVector temp_result; - std::string input = temp_input.toUtf8().constData(); - - for (unsigned int pos = 0; pos < input.size(); ++pos) { - uint_fast8_t output = input.at(pos) ^ (key >> 8) % 256; - temp_result.append(output); - key = (temp_result.at(pos) + key) * C1 + C2; - } - - std::string result = ""; - - for (uint_fast8_t i_int : temp_result) { - result += omni::int_to_hex(i_int); - } - - QString final_result = QString::fromStdString(result); - - return final_result; -} - -QString fanta_decrypt(QString temp_input, unsigned int key) -{ - std::string input = temp_input.toUtf8().constData(); - - QVector unhexed_vector; - - for (unsigned int i = 0; i < input.length(); i += 2) { - std::string byte = input.substr(i, 2); - unsigned int hex_int = strtoul(byte.c_str(), nullptr, 16); - unhexed_vector.append(hex_int); - } - - unsigned int C1 = 53761; - unsigned int C2 = 32618; - - std::string result = ""; - - for (int pos = 0; pos < unhexed_vector.size(); ++pos) { - unsigned char output = unhexed_vector.at(pos) ^ (key >> 8) % 256; - result += output; - key = (unhexed_vector.at(pos) + key) * C1 + C2; - } - - return QString::fromStdString(result); -} diff --git a/src/hex_functions.cpp b/src/hex_functions.cpp deleted file mode 100644 index 1e35718..0000000 --- a/src/hex_functions.cpp +++ /dev/null @@ -1,17 +0,0 @@ -#include "hex_functions.h" - -namespace omni { -std::string int_to_hex(unsigned int input) -{ - if (input > 255) - return "FF"; - - std::stringstream stream; - stream << std::setfill('0') << std::setw(sizeof(char) * 2) << std::hex - << input; - std::string result(stream.str()); - std::transform(result.begin(), result.end(), result.begin(), ::toupper); - - return result; -} -} // namespace omni diff --git a/src/packet_distribution.cpp b/src/packet_distribution.cpp index e4e5d5c..96d54b5 100644 --- a/src/packet_distribution.cpp +++ b/src/packet_distribution.cpp @@ -120,11 +120,7 @@ void AOApplication::server_packet_received(AOPacket *p_packet) if (f_contents.size() == 0) goto end; - // you may ask where 322 comes from. that would be a good question. - s_decryptor = fanta_decrypt(f_contents.at(0), 322).toUInt(); - // default(legacy) values - encryption_needed = true; yellow_text_enabled = false; prezoom_enabled = false; flipping_enabled = false; @@ -140,10 +136,6 @@ void AOApplication::server_packet_received(AOPacket *p_packet) additive_enabled = false; effects_enabled = false; - // workaround for tsuserver4 - if (f_contents.at(0) == "NOENCRYPT") - encryption_needed = false; - QString f_hdid; f_hdid = get_hdid(); @@ -201,8 +193,6 @@ void AOApplication::server_packet_received(AOPacket *p_packet) custom_objection_enabled = true; if (f_packet.contains("fastloading", Qt::CaseInsensitive)) improved_loading_enabled = true; - if (f_packet.contains("noencryption", Qt::CaseInsensitive)) - encryption_needed = false; if (f_packet.contains("deskmod", Qt::CaseInsensitive)) desk_mod_enabled = true; if (f_packet.contains("evidence", Qt::CaseInsensitive)) @@ -750,19 +740,9 @@ void AOApplication::send_server_packet(AOPacket *p_packet, bool encoded) QString f_packet = p_packet->to_string(); - if (encryption_needed) { -#ifdef DEBUG_NETWORK - qDebug() << "S(e):" << f_packet; -#endif - - p_packet->encrypt_header(s_decryptor); - f_packet = p_packet->to_string(); - } - else { #ifdef DEBUG_NETWORK qDebug() << "S:" << f_packet; #endif - } net_manager->ship_server_packet(f_packet); From 3f999455a935fd722bb49e3837b6ffb106abf870 Mon Sep 17 00:00:00 2001 From: scatterflower Date: Fri, 21 Aug 2020 15:36:31 -0500 Subject: [PATCH 02/81] remove remaining traces of fantacrypt --- include/encryption_functions.h | 15 --------------- include/hex_functions.h | 16 ---------------- src/aopacket.cpp | 2 -- src/packet_distribution.cpp | 1 - 4 files changed, 34 deletions(-) delete mode 100644 include/encryption_functions.h delete mode 100644 include/hex_functions.h diff --git a/include/encryption_functions.h b/include/encryption_functions.h deleted file mode 100644 index b70e8e6..0000000 --- a/include/encryption_functions.h +++ /dev/null @@ -1,15 +0,0 @@ -#ifndef ENCRYPTION_FUNCTIONS_H -#define ENCRYPTION_FUNCTIONS_H - -#include - -#include -#include -#include -#include -#include - -QString fanta_encrypt(QString p_input, unsigned int key); -QString fanta_decrypt(QString p_input, unsigned int key); - -#endif // ENCRYPTION_FUNCTIONS_H diff --git a/include/hex_functions.h b/include/hex_functions.h deleted file mode 100644 index d178ba1..0000000 --- a/include/hex_functions.h +++ /dev/null @@ -1,16 +0,0 @@ -#ifndef HEX_OPERATIONS_H -#define HEX_OPERATIONS_H - -#include -#include -#include -#include -#include -#include -#include - -namespace omni { -std::string int_to_hex(unsigned int input); -} - -#endif // HEX_OPERATIONS_H diff --git a/src/aopacket.cpp b/src/aopacket.cpp index 1cb5428..4cf43e1 100644 --- a/src/aopacket.cpp +++ b/src/aopacket.cpp @@ -1,7 +1,5 @@ #include "aopacket.h" -#include "encryption_functions.h" - AOPacket::AOPacket(QString p_packet_string) { QStringList packet_contents = p_packet_string.split("#"); diff --git a/src/packet_distribution.cpp b/src/packet_distribution.cpp index 96d54b5..0d5c09c 100644 --- a/src/packet_distribution.cpp +++ b/src/packet_distribution.cpp @@ -2,7 +2,6 @@ #include "courtroom.h" #include "debug_functions.h" -#include "encryption_functions.h" #include "hardware_functions.h" #include "lobby.h" #include "networkmanager.h" From 565a3cce893c15ce5b0d8d01dbaf460bb0923ff1 Mon Sep 17 00:00:00 2001 From: scatterflower Date: Fri, 21 Aug 2020 15:52:07 -0500 Subject: [PATCH 03/81] remove slow loading --- include/aoapplication.h | 1 - src/packet_distribution.cpp | 157 +----------------------------------- 2 files changed, 1 insertion(+), 157 deletions(-) diff --git a/include/aoapplication.h b/include/aoapplication.h index dccc85e..c06f3f9 100644 --- a/include/aoapplication.h +++ b/include/aoapplication.h @@ -67,7 +67,6 @@ public: bool prezoom_enabled = false; bool flipping_enabled = false; bool custom_objection_enabled = false; - bool improved_loading_enabled = false; bool desk_mod_enabled = false; bool evidence_enabled = false; bool cccc_ic_support_enabled = false; diff --git a/src/packet_distribution.cpp b/src/packet_distribution.cpp index 0d5c09c..ab9ec3f 100644 --- a/src/packet_distribution.cpp +++ b/src/packet_distribution.cpp @@ -124,7 +124,6 @@ void AOApplication::server_packet_received(AOPacket *p_packet) prezoom_enabled = false; flipping_enabled = false; custom_objection_enabled = false; - improved_loading_enabled = false; desk_mod_enabled = false; evidence_enabled = false; cccc_ic_support_enabled = false; @@ -167,12 +166,10 @@ void AOApplication::server_packet_received(AOPacket *p_packet) } } else if (header == "FL") { - // encryption_needed = true; yellow_text_enabled = false; prezoom_enabled = false; flipping_enabled = false; custom_objection_enabled = false; - improved_loading_enabled = false; desk_mod_enabled = false; evidence_enabled = false; cccc_ic_support_enabled = false; @@ -190,8 +187,6 @@ void AOApplication::server_packet_received(AOPacket *p_packet) flipping_enabled = true; if (f_packet.contains("customobjections", Qt::CaseInsensitive)) custom_objection_enabled = true; - if (f_packet.contains("fastloading", Qt::CaseInsensitive)) - improved_loading_enabled = true; if (f_packet.contains("deskmod", Qt::CaseInsensitive)) desk_mod_enabled = true; if (f_packet.contains("evidence", Qt::CaseInsensitive)) @@ -272,11 +267,7 @@ void AOApplication::server_packet_received(AOPacket *p_packet) AOPacket *f_packet; - if (improved_loading_enabled) - f_packet = new AOPacket("RC#%"); - else - f_packet = new AOPacket("askchar2#%"); - + f_packet = new AOPacket("RC#%"); send_server_packet(f_packet); // Remove any characters not accepted in folder names for the server_name @@ -297,152 +288,6 @@ void AOApplication::server_packet_received(AOPacket *p_packet) discord->state_server(server_name.toStdString(), hash.result().toBase64().toStdString()); } - else if (header == "CI") { - if (!courtroom_constructed) - goto end; - - for (int n_element = 0; n_element < f_contents.size(); n_element += 2) { - if (f_contents.at(n_element).toInt() != loaded_chars) - break; - - // this means we are on the last element and checking n + 1 element will - // be game over so - if (n_element == f_contents.size() - 1) - break; - - QStringList sub_elements = f_contents.at(n_element + 1).split("&"); - if (sub_elements.size() < 2) - break; - - char_type f_char; - f_char.name = sub_elements.at(0); - f_char.description = sub_elements.at(1); - f_char.evidence_string = sub_elements.at(3); - // temporary. the CharsCheck packet sets this properly - f_char.taken = false; - - ++loaded_chars; - - w_lobby->set_loading_text(tr("Loading chars:\n%1/%2") - .arg(QString::number(loaded_chars)) - .arg(QString::number(char_list_size))); - - w_courtroom->append_char(f_char); - - int total_loading_size = - char_list_size * 2 + evidence_list_size + music_list_size; - int loading_value = int( - ((loaded_chars + generated_chars + loaded_music + loaded_evidence) / - static_cast(total_loading_size)) * - 100); - w_lobby->set_loading_value(loading_value); - } - - if (improved_loading_enabled) - send_server_packet(new AOPacket("RE#%")); - else { - QString next_packet_number = - QString::number(((loaded_chars - 1) / 10) + 1); - send_server_packet(new AOPacket("AN#" + next_packet_number + "#%")); - } - } - else if (header == "EI") { - if (!courtroom_constructed) - goto end; - - // +1 because evidence starts at 1 rather than 0 for whatever reason - // enjoy fanta - if (f_contents.at(0).toInt() != loaded_evidence + 1) - goto end; - - if (f_contents.size() < 2) - goto end; - - QStringList sub_elements = f_contents.at(1).split("&"); - if (sub_elements.size() < 4) - goto end; - - evi_type f_evi; - f_evi.name = sub_elements.at(0); - f_evi.description = sub_elements.at(1); - // no idea what the number at position 2 is. probably an identifier? - f_evi.image = sub_elements.at(3); - - ++loaded_evidence; - - w_lobby->set_loading_text(tr("Loading evidence:\n%1/%2") - .arg(QString::number(loaded_evidence)) - .arg(QString::number(evidence_list_size))); - - w_courtroom->append_evidence(f_evi); - - int total_loading_size = - char_list_size * 2 + evidence_list_size + music_list_size; - int loading_value = - int(((loaded_chars + generated_chars + loaded_music + loaded_evidence) / - static_cast(total_loading_size)) * - 100); - w_lobby->set_loading_value(loading_value); - - QString next_packet_number = QString::number(loaded_evidence); - send_server_packet(new AOPacket("AE#" + next_packet_number + "#%")); - } - else if (header == "EM") { - if (!courtroom_constructed) - goto end; - - bool musics_time = false; - int areas = 0; - - for (int n_element = 0; n_element < f_contents.size(); n_element += 2) { - if (f_contents.at(n_element).toInt() != loaded_music) - break; - - if (n_element == f_contents.size() - 1) - break; - - QString f_music = f_contents.at(n_element + 1); - - ++loaded_music; - - w_lobby->set_loading_text(tr("Loading music:\n%1/%2") - .arg(QString::number(loaded_music)) - .arg(QString::number(music_list_size))); - - if (musics_time) { - w_courtroom->append_music(f_music); - } - else { - if (f_music.endsWith(".wav") || f_music.endsWith(".mp3") || - f_music.endsWith(".mp4") || f_music.endsWith(".ogg") || - f_music.endsWith(".opus")) { - musics_time = true; - areas--; - w_courtroom->fix_last_area(); - w_courtroom->append_music(f_music); - } - else { - w_courtroom->append_area(f_music); - areas++; - } - } - - for (int area_n = 0; area_n < areas; area_n++) { - w_courtroom->arup_append(0, "Unknown", "Unknown", "Unknown"); - } - - int total_loading_size = - char_list_size * 2 + evidence_list_size + music_list_size; - int loading_value = int( - ((loaded_chars + generated_chars + loaded_music + loaded_evidence) / - static_cast(total_loading_size)) * - 100); - w_lobby->set_loading_value(loading_value); - } - - QString next_packet_number = QString::number(((loaded_music - 1) / 10) + 1); - send_server_packet(new AOPacket("AM#" + next_packet_number + "#%")); - } else if (header == "CharsCheck") { if (!courtroom_constructed) goto end; From b036134414852036c1e9116d337c3b4d1cb02569 Mon Sep 17 00:00:00 2001 From: scatterflower Date: Fri, 21 Aug 2020 15:52:23 -0500 Subject: [PATCH 04/81] add project comment toggle for verbose network logs --- Attorney_Online.pro | 3 +++ 1 file changed, 3 insertions(+) diff --git a/Attorney_Online.pro b/Attorney_Online.pro index d2c2062..b9722b1 100644 --- a/Attorney_Online.pro +++ b/Attorney_Online.pro @@ -15,6 +15,9 @@ HEADERS += $$files($$PWD/include/*.h) LIBS += -L$$PWD/lib +# Uncomment for verbose network logging +# DEFINES += DEBUG_NETWORK + # Uncomment to enable Discord Rich Presence # DEFINES += DISCORD From 48675f00d065739d08854f8bf1a36bb87758e7db Mon Sep 17 00:00:00 2001 From: oldmud0 Date: Sat, 22 Aug 2020 15:17:48 -0500 Subject: [PATCH 05/81] Fix upward log scrolling down instead of up Stop using upwards log. Seriously. No other program does this. --- src/courtroom.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/courtroom.cpp b/src/courtroom.cpp index 2484bcb..04c625f 100644 --- a/src/courtroom.cpp +++ b/src/courtroom.cpp @@ -2660,7 +2660,8 @@ void Courtroom::append_ic_text(QString p_text, QString p_name, QString p_action, // scroll to the bottom. ui_ic_chatlog->moveCursor(log_goes_downwards ? QTextCursor::End : QTextCursor::Start); ui_ic_chatlog->verticalScrollBar()->setValue( - ui_ic_chatlog->verticalScrollBar()->maximum()); + log_goes_downwards ? ui_ic_chatlog->verticalScrollBar()->maximum() + : 0); } } From 8dcddf289f2528d8720e89c05857969c721ed559 Mon Sep 17 00:00:00 2001 From: oldmud0 Date: Sat, 22 Aug 2020 15:33:08 -0500 Subject: [PATCH 06/81] Only reinitialize audio on device change --- src/aooptionsdialog.cpp | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/aooptionsdialog.cpp b/src/aooptionsdialog.cpp index 6fc4d03..4d36f43 100644 --- a/src/aooptionsdialog.cpp +++ b/src/aooptionsdialog.cpp @@ -756,6 +756,9 @@ void AOOptionsDialog::save_pressed() // Save everything into the config.ini. QSettings *configini = ao_app->configini; + const bool audioChanged = ui_audio_device_combobox->currentText() != + ao_app->get_audio_output_device(); + configini->setValue("theme", ui_theme_combobox->currentText()); configini->setValue("log_goes_downwards", ui_downwards_cb->isChecked()); configini->setValue("log_maximum", ui_length_spinbox->value()); @@ -806,7 +809,9 @@ void AOOptionsDialog::save_pressed() configini->setValue("casing_can_host_cases", ui_casing_cm_cases_textbox->text()); - ao_app->initBASS(); + if (audioChanged) + ao_app->initBASS(); + callwordsini->close(); done(0); } From d1ac36d3c2bf4f6a42f0a0670baff07b26110656 Mon Sep 17 00:00:00 2001 From: likeawindrammer <31085911+likeawindrammer@users.noreply.github.com> Date: Sun, 23 Aug 2020 13:58:30 -0600 Subject: [PATCH 07/81] Fix: Qt failing to paint a darker button if source image is indexed By converting the image to an 8-bits per channel image with alpha channel we make sure the client won't fail painting a darker button, and keep the transparency if the source image had. --- src/aoemotebutton.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/src/aoemotebutton.cpp b/src/aoemotebutton.cpp index 9053560..652010d 100644 --- a/src/aoemotebutton.cpp +++ b/src/aoemotebutton.cpp @@ -27,6 +27,7 @@ void AOEmoteButton::set_image(QString p_image, QString p_emote_comment) } else if (p_image.contains("_on") && file_exists(tmp_p_image.replace("_on", "_off"))) { QImage tmpImage(tmp_p_image); + tmpImage = tmpImage.convertToFormat(QImage::Format_ARGB32); QPoint p1, p2; p2.setY(tmpImage.height()); From 18a9bcfe19637bfa227bcd2dc7fa34966b5f4ca5 Mon Sep 17 00:00:00 2001 From: Crystalwarrior Date: Mon, 24 Aug 2020 20:22:13 +0300 Subject: [PATCH 08/81] Remove the ".png" check from the load_image lookup to allow non-(a) and (b) images being used for static characters --- src/aocharmovie.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/aocharmovie.cpp b/src/aocharmovie.cpp index 252aab5..2fe90b6 100644 --- a/src/aocharmovie.cpp +++ b/src/aocharmovie.cpp @@ -35,8 +35,8 @@ void AOCharMovie::load_image(QString p_char, QString p_emote, ao_app->get_image_suffix(ao_app->get_character_path( p_char, emote_prefix + "/" + p_emote)), // Path check if it's categorized into a folder - ao_app->get_character_path( - p_char, p_emote + ".png"), // Non-animated path if emote_prefix fails + ao_app->get_image_suffix(ao_app->get_character_path( + p_char, p_emote)), // Just use the non-prefixed image, animated or not ao_app->get_image_suffix( ao_app->get_theme_path("placeholder")), // Theme placeholder path ao_app->get_image_suffix(ao_app->get_default_theme_path( From e2e3b28de8a59057b0bf7b13dbb0e16418a9583e Mon Sep 17 00:00:00 2001 From: Crystalwarrior Date: Fri, 28 Aug 2020 15:48:01 +0300 Subject: [PATCH 09/81] Set cache mode to "all" for both QMovie objects to preserve the client's sanity by not horribly lagging them with zoom speedlines and other continuously animated elements. --- src/aomovie.cpp | 1 + src/aoscene.cpp | 1 + 2 files changed, 2 insertions(+) diff --git a/src/aomovie.cpp b/src/aomovie.cpp index ac94921..196c1d3 100644 --- a/src/aomovie.cpp +++ b/src/aomovie.cpp @@ -9,6 +9,7 @@ AOMovie::AOMovie(QWidget *p_parent, AOApplication *p_ao_app) : QLabel(p_parent) ao_app = p_ao_app; m_movie = new QMovie(); + m_movie->setCacheMode(QMovie::CacheAll); this->setMovie(m_movie); diff --git a/src/aoscene.cpp b/src/aoscene.cpp index 594013a..78d69ac 100644 --- a/src/aoscene.cpp +++ b/src/aoscene.cpp @@ -7,6 +7,7 @@ AOScene::AOScene(QWidget *parent, AOApplication *p_ao_app) : QLabel(parent) m_parent = parent; ao_app = p_ao_app; m_movie = new QMovie(this); + m_movie->setCacheMode(QMovie::CacheAll); last_image = ""; } From 48c7984d66800326892bde1471266a9d84b3bb75 Mon Sep 17 00:00:00 2001 From: in1tiate <32779090+in1tiate@users.noreply.github.com> Date: Mon, 7 Sep 2020 12:40:22 -0500 Subject: [PATCH 10/81] Add dropdown function to set_widgets --- src/courtroom.cpp | 72 ++++++++++++++++++++++++++++++----------------- 1 file changed, 46 insertions(+), 26 deletions(-) diff --git a/src/courtroom.cpp b/src/courtroom.cpp index 04c625f..174e826 100644 --- a/src/courtroom.cpp +++ b/src/courtroom.cpp @@ -552,7 +552,11 @@ void Courtroom::set_widgets() log_maximum_blocks = ao_app->get_max_log_size(); - bool regenerate = log_goes_downwards != ao_app->get_log_goes_downwards() || log_colors != ao_app->is_colorlog_enabled() || log_newline != ao_app->get_log_newline() || log_margin != ao_app->get_log_margin() || log_timestamp != ao_app->get_log_timestamp(); + bool regenerate = log_goes_downwards != ao_app->get_log_goes_downwards() || + log_colors != ao_app->is_colorlog_enabled() || + log_newline != ao_app->get_log_newline() || + log_margin != ao_app->get_log_margin() || + log_timestamp != ao_app->get_log_timestamp(); log_goes_downwards = ao_app->get_log_goes_downwards(); log_colors = ao_app->is_colorlog_enabled(); log_newline = ao_app->get_log_newline(); @@ -563,7 +567,8 @@ void Courtroom::set_widgets() set_size_and_pos(ui_ic_chatlog, "ic_chatlog"); ui_ic_chatlog->setFrameShape(QFrame::NoFrame); - ui_ic_chatlog->setPlaceholderText(log_goes_downwards ? "▼ Log goes down ▼" : "▲ Log goes up ▲"); + ui_ic_chatlog->setPlaceholderText(log_goes_downwards ? "▼ Log goes down ▼" + : "▲ Log goes up ▲"); set_size_and_pos(ui_ms_chatlog, "ms_chatlog"); ui_ms_chatlog->setFrameShape(QFrame::NoFrame); @@ -705,6 +710,8 @@ void Courtroom::set_widgets() "the original character folder.")); ui_sfx_remove->hide(); + set_iniswap_dropdown(); + set_size_and_pos(ui_effects_dropdown, "effects_dropdown"); ui_effects_dropdown->setInsertPolicy(QComboBox::InsertAtBottom); ui_effects_dropdown->setToolTip( @@ -1853,10 +1860,10 @@ void Courtroom::handle_chatmessage(QStringList *p_contents) m_chatmessage[MESSAGE] = ""; // Turn it into true blankpost } - if (!m_chatmessage[MESSAGE].isEmpty() || ic_chatlog_history.isEmpty() || ic_chatlog_history.last().get_message() != "") - { + if (!m_chatmessage[MESSAGE].isEmpty() || ic_chatlog_history.isEmpty() || + ic_chatlog_history.last().get_message() != "") { log_ic_text(f_charname, f_displayname, m_chatmessage[MESSAGE], "", - m_chatmessage[TEXT_COLOR].toInt()); + m_chatmessage[TEXT_COLOR].toInt()); append_ic_text(m_chatmessage[MESSAGE], f_displayname, "", m_chatmessage[TEXT_COLOR].toInt()); } @@ -2254,8 +2261,9 @@ void Courtroom::handle_chatmessage_3() ui_vp_evidence_display->show_evidence(f_image, is_left_side, ui_sfx_slider->value()); - log_ic_text(m_chatmessage[CHAR_NAME], m_chatmessage[SHOWNAME], f_evi_name, tr("has presented evidence"), - m_chatmessage[TEXT_COLOR].toInt()); + log_ic_text(m_chatmessage[CHAR_NAME], m_chatmessage[SHOWNAME], f_evi_name, + tr("has presented evidence"), + m_chatmessage[TEXT_COLOR].toInt()); append_ic_text(f_evi_name, f_showname, tr("has presented evidence")); } @@ -2561,10 +2569,9 @@ QString Courtroom::filter_ic_text(QString p_text, bool html, int target_pos, } void Courtroom::log_ic_text(QString p_name, QString p_showname, - QString p_message, QString p_action, int p_color) + QString p_message, QString p_action, int p_color) { - chatlogpiece log_entry(p_name, p_showname, p_message, p_action, - p_color); + chatlogpiece log_entry(p_name, p_showname, p_message, p_action, p_color); ic_chatlog_history.append(log_entry); if (ao_app->get_auto_logging_enabled()) ao_app->append_to_file(log_entry.get_full(), ao_app->log_filename, true); @@ -2589,9 +2596,12 @@ void Courtroom::append_ic_text(QString p_text, QString p_name, QString p_action, const QTextCursor old_cursor = ui_ic_chatlog->textCursor(); const int old_scrollbar_value = ui_ic_chatlog->verticalScrollBar()->value(); const bool need_newline = !ui_ic_chatlog->document()->isEmpty(); - const int scrollbar_target_value = log_goes_downwards ? ui_ic_chatlog->verticalScrollBar()->maximum() : ui_ic_chatlog->verticalScrollBar()->minimum(); + const int scrollbar_target_value = + log_goes_downwards ? ui_ic_chatlog->verticalScrollBar()->maximum() + : ui_ic_chatlog->verticalScrollBar()->minimum(); - ui_ic_chatlog->moveCursor(log_goes_downwards ? QTextCursor::End : QTextCursor::Start); + ui_ic_chatlog->moveCursor(log_goes_downwards ? QTextCursor::End + : QTextCursor::Start); // Only prepend with newline if log goes downwards if (log_goes_downwards && need_newline) { @@ -2600,7 +2610,9 @@ void Courtroom::append_ic_text(QString p_text, QString p_name, QString p_action, // Timestamp if we're doing that meme if (log_timestamp) - ui_ic_chatlog->textCursor().insertText("[" + QDateTime::currentDateTime().toString("h:mm:ss AP") + "] ", normal); + ui_ic_chatlog->textCursor().insertText( + "[" + QDateTime::currentDateTime().toString("h:mm:ss AP") + "] ", + normal); // Format the name of the actor ui_ic_chatlog->textCursor().insertText(p_name, bold); @@ -2609,8 +2621,9 @@ void Courtroom::append_ic_text(QString p_text, QString p_name, QString p_action, // Format the action in normal ui_ic_chatlog->textCursor().insertText(" " + p_action, normal); if (log_newline) - // For some reason, we're forced to use
instead of the more sensible \n. - // Why? Because \n is treated as a new Block instead of a soft newline within a paragraph! + // For some reason, we're forced to use
instead of the more sensible + // \n. Why? Because \n is treated as a new Block instead of a soft newline + // within a paragraph! ui_ic_chatlog->textCursor().insertHtml("
"); else ui_ic_chatlog->textCursor().insertText(": ", normal); @@ -2619,16 +2632,19 @@ void Courtroom::append_ic_text(QString p_text, QString p_name, QString p_action, } else { if (log_newline) - // For some reason, we're forced to use
instead of the more sensible \n. - // Why? Because \n is treated as a new Block instead of a soft newline within a paragraph! + // For some reason, we're forced to use
instead of the more sensible + // \n. Why? Because \n is treated as a new Block instead of a soft newline + // within a paragraph! ui_ic_chatlog->textCursor().insertHtml("
"); else ui_ic_chatlog->textCursor().insertText(": ", normal); // Format the result according to html if (log_colors) - ui_ic_chatlog->textCursor().insertHtml(filter_ic_text(p_text, true, -1, color)); + ui_ic_chatlog->textCursor().insertHtml( + filter_ic_text(p_text, true, -1, color)); else - ui_ic_chatlog->textCursor().insertText(filter_ic_text(p_text, false), normal); + ui_ic_chatlog->textCursor().insertText(filter_ic_text(p_text, false), + normal); } // Only append with newline if log goes upwards @@ -2639,7 +2655,8 @@ void Courtroom::append_ic_text(QString p_text, QString p_name, QString p_action, // If we got too many blocks in the current log, delete some. while (ui_ic_chatlog->document()->blockCount() > log_maximum_blocks && log_maximum_blocks > 0) { - ui_ic_chatlog->moveCursor(log_goes_downwards ? QTextCursor::Start : QTextCursor::End); + ui_ic_chatlog->moveCursor(log_goes_downwards ? QTextCursor::Start + : QTextCursor::End); ui_ic_chatlog->textCursor().select(QTextCursor::BlockUnderCursor); ui_ic_chatlog->textCursor().removeSelectedText(); if (log_goes_downwards) @@ -2649,7 +2666,8 @@ void Courtroom::append_ic_text(QString p_text, QString p_name, QString p_action, } // Finally, scroll the scrollbar to the correct position. - if (old_cursor.hasSelection() || old_scrollbar_value != scrollbar_target_value) { + if (old_cursor.hasSelection() || + old_scrollbar_value != scrollbar_target_value) { // The user has selected text or scrolled away from the bottom: maintain // position. ui_ic_chatlog->setTextCursor(old_cursor); @@ -2658,10 +2676,10 @@ void Courtroom::append_ic_text(QString p_text, QString p_name, QString p_action, else { // The user hasn't selected any text and the scrollbar is at the bottom: // scroll to the bottom. - ui_ic_chatlog->moveCursor(log_goes_downwards ? QTextCursor::End : QTextCursor::Start); + ui_ic_chatlog->moveCursor(log_goes_downwards ? QTextCursor::End + : QTextCursor::Start); ui_ic_chatlog->verticalScrollBar()->setValue( - log_goes_downwards ? ui_ic_chatlog->verticalScrollBar()->maximum() - : 0); + log_goes_downwards ? ui_ic_chatlog->verticalScrollBar()->maximum() : 0); } } @@ -3165,7 +3183,7 @@ void Courtroom::handle_song(QStringList *p_contents) if (!mute_map.value(n_char)) { log_ic_text(str_char, str_show, f_song, tr("has played a song"), - m_chatmessage[TEXT_COLOR].toInt()); + m_chatmessage[TEXT_COLOR].toInt()); append_ic_text(f_song_clear, str_show, tr("has played a song")); music_player->play(f_song, channel, looping, effect_flags); @@ -4634,7 +4652,9 @@ void Courtroom::regenerate_ic_chatlog() { ui_ic_chatlog->clear(); foreach (chatlogpiece item, ic_chatlog_history) { - append_ic_text(item.get_message(), ui_showname_enable->isChecked() ? item.get_showname() : item.get_name(), + append_ic_text(item.get_message(), + ui_showname_enable->isChecked() ? item.get_showname() + : item.get_name(), item.get_action(), item.get_chat_color()); } } From 4562bcd82fffcd15813524f9bafc235649261bb4 Mon Sep 17 00:00:00 2001 From: in1tiate <32779090+in1tiate@users.noreply.github.com> Date: Mon, 7 Sep 2020 13:00:59 -0500 Subject: [PATCH 11/81] Alter logic flow to include theme folders for shout sounds --- src/aosfxplayer.cpp | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/aosfxplayer.cpp b/src/aosfxplayer.cpp index 8c4f3c8..1a0e2d2 100644 --- a/src/aosfxplayer.cpp +++ b/src/aosfxplayer.cpp @@ -37,11 +37,16 @@ void AOSfxPlayer::play(QString p_sfx, QString p_char, QString shout, QString misc_path = ""; QString char_path = ""; + QString theme_path = ""; QString sound_path = ao_app->get_sfx_suffix(ao_app->get_sounds_path(p_sfx)); - if (shout != "") + if (shout != "") { misc_path = ao_app->get_sfx_suffix(ao_app->get_base_path() + "misc/" + shout + "/" + p_sfx); + theme_path = ao_app->get_sfx_suffix(ao_app->get_theme_path(p_sfx)); + if (!file_exists(theme_path)) + theme_path = ao_app->get_sfx_suffix(ao_app->get_default_theme_path(p_sfx)); + } if (p_char != "") char_path = ao_app->get_sfx_suffix(ao_app->get_character_path(p_char, p_sfx)); @@ -52,6 +57,8 @@ void AOSfxPlayer::play(QString p_sfx, QString p_char, QString shout, f_path = char_path; else if (file_exists(misc_path)) f_path = misc_path; + else if (shout != "" && file_exists(theme_path)) //only check here for shouts + f_path = theme_path; else f_path = sound_path; From 311e260d658d799899140277d318773ae3a197a2 Mon Sep 17 00:00:00 2001 From: in1tiate <32779090+in1tiate@users.noreply.github.com> Date: Mon, 7 Sep 2020 13:38:10 -0500 Subject: [PATCH 12/81] Add 600ms rate limit to IC signal --- include/courtroom.h | 1 + src/courtroom.cpp | 6 ++++++ 2 files changed, 7 insertions(+) diff --git a/include/courtroom.h b/include/courtroom.h index 5b5ff6c..8f5e43a 100644 --- a/include/courtroom.h +++ b/include/courtroom.h @@ -828,6 +828,7 @@ private slots: void on_casing_clicked(); void ping_server(); + void ratelimit_ic(); }; #endif // COURTROOM_H diff --git a/src/courtroom.cpp b/src/courtroom.cpp index 04c625f..c1a306e 100644 --- a/src/courtroom.cpp +++ b/src/courtroom.cpp @@ -1525,6 +1525,8 @@ void Courtroom::on_chat_return_pressed() if ((anim_state < 3 || text_state < 2) && objection_state == 0) return; + ui_ic_chat_message->blockSignals(true); + QTimer::singleShot(600, this, SLOT(ratelimit_ic())); // MS# // deskmod# // pre-emote# @@ -4709,6 +4711,10 @@ void Courtroom::announce_case(QString title, bool def, bool pro, bool jud, } } +void Courtroom::ratelimit_ic() { + ui_ic_chat_message->blockSignals(false); +} + Courtroom::~Courtroom() { delete music_player; From 6c2010a1cfcfc4cbf884c68a3c01a67a39f7166d Mon Sep 17 00:00:00 2001 From: in1tiate <32779090+in1tiate@users.noreply.github.com> Date: Mon, 7 Sep 2020 14:53:17 -0500 Subject: [PATCH 13/81] Apply suggested change to remove need for additional function --- include/courtroom.h | 1 - src/courtroom.cpp | 8 +++----- 2 files changed, 3 insertions(+), 6 deletions(-) diff --git a/include/courtroom.h b/include/courtroom.h index 8f5e43a..5b5ff6c 100644 --- a/include/courtroom.h +++ b/include/courtroom.h @@ -828,7 +828,6 @@ private slots: void on_casing_clicked(); void ping_server(); - void ratelimit_ic(); }; #endif // COURTROOM_H diff --git a/src/courtroom.cpp b/src/courtroom.cpp index c1a306e..7d6aa40 100644 --- a/src/courtroom.cpp +++ b/src/courtroom.cpp @@ -1526,7 +1526,9 @@ void Courtroom::on_chat_return_pressed() return; ui_ic_chat_message->blockSignals(true); - QTimer::singleShot(600, this, SLOT(ratelimit_ic())); + QTimer::singleShot(600, this, [=] { + ui_ic_chat_message->blockSignals(false); + }); // MS# // deskmod# // pre-emote# @@ -4711,10 +4713,6 @@ void Courtroom::announce_case(QString title, bool def, bool pro, bool jud, } } -void Courtroom::ratelimit_ic() { - ui_ic_chat_message->blockSignals(false); -} - Courtroom::~Courtroom() { delete music_player; From 8cc067dee42ede24614f1a7bccef7f8752f56a01 Mon Sep 17 00:00:00 2001 From: Crystalwarrior Date: Fri, 11 Sep 2020 22:17:13 +0300 Subject: [PATCH 14/81] More accurate/consistent blip rate functionality inspired by https://youtu.be/Min0hkwO43g --- include/courtroom.h | 2 +- src/courtroom.cpp | 18 +++++++++++++++--- 2 files changed, 16 insertions(+), 4 deletions(-) diff --git a/include/courtroom.h b/include/courtroom.h index 5b5ff6c..31ab41c 100644 --- a/include/courtroom.h +++ b/include/courtroom.h @@ -311,7 +311,7 @@ private: int real_tick_pos = 0; // used to determine how often blips sound int blip_ticker = 0; - int blip_rate = 1; + int blip_rate = 2; int rainbow_counter = 0; bool rainbow_appended = false; bool blank_blip = false; diff --git a/src/courtroom.cpp b/src/courtroom.cpp index 04c625f..3e00158 100644 --- a/src/courtroom.cpp +++ b/src/courtroom.cpp @@ -2938,11 +2938,23 @@ 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 + if (blip_ticker % blip_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; } From d00d0769a9bf325df5bb25d7a7a4bd376b539b3c Mon Sep 17 00:00:00 2001 From: Crystalwarrior Date: Fri, 11 Sep 2020 23:38:36 +0300 Subject: [PATCH 15/81] Lots of blip rate fixes: Remove qElapsedTimer method of blip earrape protection due to major inconsistency issues with this method (the same message would produce wildly different blip sounds - consistency is preferred) More sophisticated blip earrape prevention is calculated in the chat ticker function itself, it also properly adjusts itself depending on the blip_rate used. --- include/aoblipplayer.h | 3 --- src/aoblipplayer.cpp | 4 ---- src/courtroom.cpp | 19 +++++++++++++++---- 3 files changed, 15 insertions(+), 11 deletions(-) diff --git a/include/aoblipplayer.h b/include/aoblipplayer.h index 4d3b5f1..a11e29d 100644 --- a/include/aoblipplayer.h +++ b/include/aoblipplayer.h @@ -22,12 +22,9 @@ 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/src/aoblipplayer.cpp b/src/aoblipplayer.cpp index 5b4d625..6607d46 100644 --- a/src/aoblipplayer.cpp +++ b/src/aoblipplayer.cpp @@ -26,10 +26,6 @@ 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 3e00158..13a9a6b 100644 --- a/src/courtroom.cpp +++ b/src/courtroom.cpp @@ -2943,7 +2943,17 @@ void Courtroom::chat_tick() // I am you // ! ! ! ! // where ! is the blip sound - if (blip_ticker % blip_rate == 0) { + 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(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(); @@ -2958,9 +2968,10 @@ void Courtroom::chat_tick() ++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 From c392bb3415ca8a01dbfc5129527af25ae6de9c08 Mon Sep 17 00:00:00 2001 From: Crystalwarrior Date: Fri, 11 Sep 2020 23:39:32 +0300 Subject: [PATCH 16/81] Revert the meme of instant text. Instant text using }}} is not only meme-worthy in how limited it is in practice, it also makes the blip ticker completely confused how and when to play the blips (to make instant text possible, the entire system needs rewriting (again) --- include/courtroom.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/courtroom.h b/include/courtroom.h index 31ab41c..38621c8 100644 --- a/include/courtroom.h +++ b/include/courtroom.h @@ -275,7 +275,7 @@ private: bool message_is_centered = false; int current_display_speed = 3; - int message_display_speed[7] = {0, 10, 25, 40, 50, 70, 90}; + int message_display_speed[7] = {5, 10, 25, 40, 50, 70, 90}; // The character ID of the character this user wants to appear alongside with. int other_charid = -1; From 48f8d8aa27ee08697d0f186a0ff6df9f244f7c53 Mon Sep 17 00:00:00 2001 From: in1tiate <32779090+in1tiate@users.noreply.github.com> Date: Sat, 19 Sep 2020 04:12:40 -0500 Subject: [PATCH 17/81] add variable check for evidence presenting --- include/courtroom.h | 4 ++++ src/courtroom.cpp | 6 +++++- 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/include/courtroom.h b/include/courtroom.h index 5b5ff6c..172b9f1 100644 --- a/include/courtroom.h +++ b/include/courtroom.h @@ -424,8 +424,12 @@ private: // List of all currently available pos QStringList pos_dropdown_list; + // is the message we're about to send supposed to present evidence? bool is_presenting_evidence = false; + // have we already presented evidence for this message? + bool evidence_presented = false; + QString effect = ""; // Music effect flags we want to send to server when we play music diff --git a/src/courtroom.cpp b/src/courtroom.cpp index e8d3262..d36343b 100644 --- a/src/courtroom.cpp +++ b/src/courtroom.cpp @@ -1763,6 +1763,7 @@ void Courtroom::reset_ic() ui_vp_chat_arrow->stop(); text_state = 0; anim_state = 0; + evidence_presented = false; ui_vp_objection->stop(); chat_tick_timer->stop(); ui_vp_evidence_display->reset(); @@ -2255,7 +2256,8 @@ void Courtroom::handle_chatmessage_3() .isEmpty()) // Pure whitespace showname, get outta here. f_showname = m_chatmessage[CHAR_NAME]; - if (f_evi_id > 0 && f_evi_id <= local_evidence_list.size()) { + if (f_evi_id > 0 && f_evi_id <= local_evidence_list.size() && + !evidence_presented) { // shifted by 1 because 0 is no evidence per legacy standards QString f_image = local_evidence_list.at(f_evi_id - 1).image; QString f_evi_name = local_evidence_list.at(f_evi_id - 1).name; @@ -2269,6 +2271,8 @@ void Courtroom::handle_chatmessage_3() tr("has presented evidence"), m_chatmessage[TEXT_COLOR].toInt()); append_ic_text(f_evi_name, f_showname, tr("has presented evidence")); + evidence_presented = true; // we're done presenting evidence, and we + // don't want to do it twice } int emote_mod = m_chatmessage[EMOTE_MOD].toInt(); From f91fc5739cf45e2fd23661c7ba4ca9f28e3cacec Mon Sep 17 00:00:00 2001 From: scatterflower Date: Sun, 4 Oct 2020 01:41:23 -0500 Subject: [PATCH 18/81] fix doubleclick server being buggy --- include/lobby.h | 1 + src/lobby.cpp | 3 ++- src/packet_distribution.cpp | 3 +++ 3 files changed, 6 insertions(+), 1 deletion(-) diff --git a/include/lobby.h b/include/lobby.h index 42f5297..4278534 100644 --- a/include/lobby.h +++ b/include/lobby.h @@ -46,6 +46,7 @@ public: void set_loading_value(int p_value); bool public_servers_selected = true; + bool doubleclicked = false; ~Lobby(); diff --git a/src/lobby.cpp b/src/lobby.cpp index 093b0f7..eaa73ce 100644 --- a/src/lobby.cpp +++ b/src/lobby.cpp @@ -441,8 +441,9 @@ void Lobby::on_server_list_clicked(QTreeWidgetItem *p_item, int column) // doubleclicked on an item in the serverlist so we'll connect right away void Lobby::on_server_list_doubleclicked(QTreeWidgetItem *p_item, int column) { + doubleclicked = true; on_server_list_clicked(p_item, column); - on_connect_released(); + //on_connect_released(); } void Lobby::on_server_search_edited(QString p_text) diff --git a/src/packet_distribution.cpp b/src/packet_distribution.cpp index e4e5d5c..632e51d 100644 --- a/src/packet_distribution.cpp +++ b/src/packet_distribution.cpp @@ -228,6 +228,9 @@ void AOApplication::server_packet_received(AOPacket *p_packet) w_lobby->set_player_count(f_contents.at(0).toInt(), f_contents.at(1).toInt()); + + if (w_lobby->doubleclicked) + send_server_packet(new AOPacket("askchaa#%")); } else if (header == "SI") { if (f_contents.size() != 3) From 5ab50c843174b714e7aca807d9aeec1b70f21679 Mon Sep 17 00:00:00 2001 From: stonedDiscord <10584181+stonedDiscord@users.noreply.github.com> Date: Tue, 6 Oct 2020 12:43:50 +0200 Subject: [PATCH 19/81] add BB packet for a MessageBox popup --- src/packet_distribution.cpp | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/packet_distribution.cpp b/src/packet_distribution.cpp index e4e5d5c..ee56cdb 100644 --- a/src/packet_distribution.cpp +++ b/src/packet_distribution.cpp @@ -691,6 +691,11 @@ void AOApplication::server_packet_received(AOPacket *p_packet) if (courtroom_constructed && f_contents.size() > 0) w_courtroom->set_mute(false, f_contents.at(0).toInt()); } + else if (header == "BB") { + if (courtroom_constructed && f_contents.size() >= 1) { + call_notice(f_contents.at(0)); + } + } else if (header == "KK") { if (courtroom_constructed && f_contents.size() >= 1) { call_notice(tr("You have been kicked from the server.\nReason: %1") From f00801feb678ab1ee5935116694e2c95c254bf97 Mon Sep 17 00:00:00 2001 From: in1tiate <32779090+in1tiate@users.noreply.github.com> Date: Fri, 9 Oct 2020 10:22:58 -0500 Subject: [PATCH 20/81] add indicator when song is not found --- src/courtroom.cpp | 21 ++++++++++++++------- 1 file changed, 14 insertions(+), 7 deletions(-) diff --git a/src/courtroom.cpp b/src/courtroom.cpp index e8d3262..afacda0 100644 --- a/src/courtroom.cpp +++ b/src/courtroom.cpp @@ -1533,9 +1533,8 @@ void Courtroom::on_chat_return_pressed() return; ui_ic_chat_message->blockSignals(true); - QTimer::singleShot(600, this, [=] { - ui_ic_chat_message->blockSignals(false); - }); + QTimer::singleShot(600, this, + [=] { ui_ic_chat_message->blockSignals(false); }); // MS# // deskmod# // pre-emote# @@ -3159,8 +3158,12 @@ void Courtroom::handle_song(QStringList *p_contents) } music_player->play(f_song, channel, looping, effect_flags); - if (channel == 0) - ui_music_name->setText(f_song_clear); + if (channel == 0) { + if (file_exists(ao_app->get_sfx_suffix(ao_app->get_music_path(f_song)))) + ui_music_name->setText(f_song_clear); + else + ui_music_name->setText("[MISSING] " + f_song_clear); + } } else { QString str_char = char_list.at(n_char).name; @@ -3191,8 +3194,12 @@ void Courtroom::handle_song(QStringList *p_contents) append_ic_text(f_song_clear, str_show, tr("has played a song")); music_player->play(f_song, channel, looping, effect_flags); - if (channel == 0) - ui_music_name->setText(f_song_clear); + if (channel == 0) { + if (file_exists(ao_app->get_sfx_suffix(ao_app->get_music_path(f_song)))) + ui_music_name->setText(f_song_clear); + else + ui_music_name->setText("[MISSING] " + f_song_clear); + } } } } From 74c15447b55b2548fbc596c9f8ebb78a8cc4cfd0 Mon Sep 17 00:00:00 2001 From: in1tiate <32779090+in1tiate@users.noreply.github.com> Date: Fri, 9 Oct 2020 10:24:03 -0500 Subject: [PATCH 21/81] [MISSING] should be translatable --- src/courtroom.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/courtroom.cpp b/src/courtroom.cpp index afacda0..4fa0b74 100644 --- a/src/courtroom.cpp +++ b/src/courtroom.cpp @@ -3162,7 +3162,7 @@ void Courtroom::handle_song(QStringList *p_contents) if (file_exists(ao_app->get_sfx_suffix(ao_app->get_music_path(f_song)))) ui_music_name->setText(f_song_clear); else - ui_music_name->setText("[MISSING] " + f_song_clear); + ui_music_name->setText(tr("[MISSING] ") + f_song_clear); } } else { @@ -3198,7 +3198,7 @@ void Courtroom::handle_song(QStringList *p_contents) if (file_exists(ao_app->get_sfx_suffix(ao_app->get_music_path(f_song)))) ui_music_name->setText(f_song_clear); else - ui_music_name->setText("[MISSING] " + f_song_clear); + ui_music_name->setText(tr("[MISSING] ") + f_song_clear); } } } From 5fc87a93d2c265c4d7edce4163cb3009ca73c8ef Mon Sep 17 00:00:00 2001 From: in1tiate <32779090+in1tiate@users.noreply.github.com> Date: Fri, 9 Oct 2020 20:17:23 -0500 Subject: [PATCH 22/81] Inmplement suggested change --- src/courtroom.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/courtroom.cpp b/src/courtroom.cpp index 4fa0b74..521e429 100644 --- a/src/courtroom.cpp +++ b/src/courtroom.cpp @@ -3162,7 +3162,7 @@ void Courtroom::handle_song(QStringList *p_contents) if (file_exists(ao_app->get_sfx_suffix(ao_app->get_music_path(f_song)))) ui_music_name->setText(f_song_clear); else - ui_music_name->setText(tr("[MISSING] ") + f_song_clear); + ui_music_name->setText(tr("[MISSING] %1").arg(f_song_clear)); } } else { @@ -3198,7 +3198,7 @@ void Courtroom::handle_song(QStringList *p_contents) if (file_exists(ao_app->get_sfx_suffix(ao_app->get_music_path(f_song)))) ui_music_name->setText(f_song_clear); else - ui_music_name->setText(tr("[MISSING] ") + f_song_clear); + ui_music_name->setText(tr("[MISSING] %1").arg(f_song_clear)); } } } From 38d5fc758622223e28ce3d2fa36057e8a1b6dec5 Mon Sep 17 00:00:00 2001 From: in1tiate <32779090+in1tiate@users.noreply.github.com> Date: Tue, 13 Oct 2020 15:42:06 -0500 Subject: [PATCH 23/81] Add proper masking to AOImage elements --- src/aoimage.cpp | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/src/aoimage.cpp b/src/aoimage.cpp index 2663ba0..380b5aa 100644 --- a/src/aoimage.cpp +++ b/src/aoimage.cpp @@ -29,9 +29,9 @@ bool AOImage::set_image(QString p_image) } QPixmap f_pixmap(final_image_path); - - this->setPixmap( - f_pixmap.scaled(this->width(), this->height(), Qt::IgnoreAspectRatio)); + f_pixmap = f_pixmap.scaled(this->width(), this->height(), Qt::IgnoreAspectRatio); + this->setPixmap(f_pixmap); + this->setMask(f_pixmap.mask()); return true; } @@ -45,7 +45,8 @@ bool AOImage::set_chatbox(QString p_path) QPixmap f_pixmap(p_path); - this->setPixmap( - f_pixmap.scaled(this->width(), this->height(), Qt::IgnoreAspectRatio)); + f_pixmap = f_pixmap.scaled(this->width(), this->height(), Qt::IgnoreAspectRatio); + this->setPixmap(f_pixmap); + this->setMask(f_pixmap.mask()); return true; } From f4cdb3954f500679bf61f0ac2815722669ec595a Mon Sep 17 00:00:00 2001 From: in1tiate <32779090+in1tiate@users.noreply.github.com> Date: Tue, 13 Oct 2020 18:52:23 -0500 Subject: [PATCH 24/81] Fix missing #include, run clang-format --- src/aoimage.cpp | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/aoimage.cpp b/src/aoimage.cpp index 380b5aa..3977c97 100644 --- a/src/aoimage.cpp +++ b/src/aoimage.cpp @@ -2,6 +2,8 @@ #include "aoimage.h" +#include + AOImage::AOImage(QWidget *parent, AOApplication *p_ao_app) : QLabel(parent) { m_parent = parent; @@ -29,7 +31,8 @@ bool AOImage::set_image(QString p_image) } QPixmap f_pixmap(final_image_path); - f_pixmap = f_pixmap.scaled(this->width(), this->height(), Qt::IgnoreAspectRatio); + f_pixmap = + f_pixmap.scaled(this->width(), this->height(), Qt::IgnoreAspectRatio); this->setPixmap(f_pixmap); this->setMask(f_pixmap.mask()); return true; @@ -45,7 +48,8 @@ bool AOImage::set_chatbox(QString p_path) QPixmap f_pixmap(p_path); - f_pixmap = f_pixmap.scaled(this->width(), this->height(), Qt::IgnoreAspectRatio); + f_pixmap = + f_pixmap.scaled(this->width(), this->height(), Qt::IgnoreAspectRatio); this->setPixmap(f_pixmap); this->setMask(f_pixmap.mask()); return true; From a46c7ca8f6492233adddd5ddadd7733a5ca4eaca Mon Sep 17 00:00:00 2001 From: scatterflower Date: Sun, 1 Nov 2020 13:35:57 -0600 Subject: [PATCH 25/81] reset doubleclick flag on connect --- src/packet_distribution.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/packet_distribution.cpp b/src/packet_distribution.cpp index 632e51d..b768d6c 100644 --- a/src/packet_distribution.cpp +++ b/src/packet_distribution.cpp @@ -229,8 +229,10 @@ void AOApplication::server_packet_received(AOPacket *p_packet) w_lobby->set_player_count(f_contents.at(0).toInt(), f_contents.at(1).toInt()); - if (w_lobby->doubleclicked) + if (w_lobby->doubleclicked) { send_server_packet(new AOPacket("askchaa#%")); + w_lobby->doubleclicked = false; + } } else if (header == "SI") { if (f_contents.size() != 3) From c49ce181c92ca2722c06ee5c3c1bd5d8e134a3d1 Mon Sep 17 00:00:00 2001 From: stonedDiscord <10584181+stonedDiscord@users.noreply.github.com> Date: Thu, 5 Nov 2020 23:17:15 +0100 Subject: [PATCH 26/81] set no maximize flag on lobby --- src/lobby.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/src/lobby.cpp b/src/lobby.cpp index 093b0f7..a1ee400 100644 --- a/src/lobby.cpp +++ b/src/lobby.cpp @@ -13,6 +13,7 @@ Lobby::Lobby(AOApplication *p_ao_app) : QMainWindow() this->setWindowTitle(tr("Attorney Online 2")); this->setWindowIcon(QIcon(":/logo.png")); + this->setWindowFlags( (this->windowFlags() | Qt::CustomizeWindowHint) & ~Qt::WindowMaximizeButtonHint); ui_background = new AOImage(this, ao_app); ui_public_servers = new AOButton(this, ao_app); From 997462ad54f7e42d0fa1062337287f1492e3b111 Mon Sep 17 00:00:00 2001 From: stonedDiscord <10584181+stonedDiscord@users.noreply.github.com> Date: Thu, 5 Nov 2020 23:17:22 +0100 Subject: [PATCH 27/81] set no maximize flag on courtroom --- src/courtroom.cpp | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/courtroom.cpp b/src/courtroom.cpp index a12c95a..cdadfe8 100644 --- a/src/courtroom.cpp +++ b/src/courtroom.cpp @@ -3,6 +3,9 @@ Courtroom::Courtroom(AOApplication *p_ao_app) : QMainWindow() { ao_app = p_ao_app; + + this->setWindowFlags( (this->windowFlags() | Qt::CustomizeWindowHint) & ~Qt::WindowMaximizeButtonHint); + ao_app->initBASS(); qsrand(static_cast(QDateTime::currentMSecsSinceEpoch() / 1000)); From c1dfb4928c880dfe9980e2ff39cdd164e15ceb52 Mon Sep 17 00:00:00 2001 From: stonedDiscord <10584181+stonedDiscord@users.noreply.github.com> Date: Thu, 5 Nov 2020 23:17:30 +0100 Subject: [PATCH 28/81] set no maximize flag on charselect --- src/charselect.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/charselect.cpp b/src/charselect.cpp index 8e0aab5..66223f3 100644 --- a/src/charselect.cpp +++ b/src/charselect.cpp @@ -7,6 +7,8 @@ void Courtroom::construct_char_select() { + this->setWindowFlags( (this->windowFlags() | Qt::CustomizeWindowHint) & ~Qt::WindowMaximizeButtonHint); + ui_char_select_background = new AOImage(this, ao_app); ui_char_buttons = new QWidget(ui_char_select_background); From 0a5e5582a361b57829724c8fbe3f30b435254e6e Mon Sep 17 00:00:00 2001 From: stonedDiscord <10584181+stonedDiscord@users.noreply.github.com> Date: Thu, 5 Nov 2020 23:27:43 +0100 Subject: [PATCH 29/81] stop them from dragging the charselect --- src/charselect.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/charselect.cpp b/src/charselect.cpp index 66223f3..b543934 100644 --- a/src/charselect.cpp +++ b/src/charselect.cpp @@ -74,10 +74,10 @@ void Courtroom::set_char_select() if (f_charselect.width < 0 || f_charselect.height < 0) { qDebug() << "W: did not find char_select width or height in " "courtroom_design.ini!"; - this->resize(714, 668); + this->setFixedSize(714, 668); } else - this->resize(f_charselect.width, f_charselect.height); + this->setFixedSize(f_charselect.width, f_charselect.height); ui_char_select_background->resize(f_charselect.width, f_charselect.height); ui_char_select_background->set_image("charselect_background"); From 1e1ada7437f809ca87827772860c64e8a658602b Mon Sep 17 00:00:00 2001 From: stonedDiscord <10584181+stonedDiscord@users.noreply.github.com> Date: Thu, 5 Nov 2020 23:27:49 +0100 Subject: [PATCH 30/81] stop them from dragging the courtroom --- src/courtroom.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/courtroom.cpp b/src/courtroom.cpp index cdadfe8..300d274 100644 --- a/src/courtroom.cpp +++ b/src/courtroom.cpp @@ -449,13 +449,13 @@ void Courtroom::set_widgets() if (f_courtroom.width < 0 || f_courtroom.height < 0) { qDebug() << "W: did not find courtroom width or height in " << filename; - this->resize(714, 668); + this->setFixedSize(714, 668); } else { m_courtroom_width = f_courtroom.width; m_courtroom_height = f_courtroom.height; - this->resize(f_courtroom.width, f_courtroom.height); + this->setFixedSize(f_courtroom.width, f_courtroom.height); } set_fonts(); From 2dbedf516391c8f432bfc5a2d2749ba054a78e06 Mon Sep 17 00:00:00 2001 From: stonedDiscord <10584181+stonedDiscord@users.noreply.github.com> Date: Thu, 5 Nov 2020 23:27:58 +0100 Subject: [PATCH 31/81] stop them from dragging the lobby --- src/lobby.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/lobby.cpp b/src/lobby.cpp index a1ee400..8945d4e 100644 --- a/src/lobby.cpp +++ b/src/lobby.cpp @@ -98,10 +98,10 @@ void Lobby::set_widgets() "Did you download all resources correctly from tiny.cc/getao, " "including the large 'base' folder?")); - this->resize(517, 666); + this->setFixedSize(517, 666); } else { - this->resize(f_lobby.width, f_lobby.height); + this->setFixedSize(f_lobby.width, f_lobby.height); } set_size_and_pos(ui_background, "lobby"); From 5aee23d56bc2153e830bb82d146c6188e57045d0 Mon Sep 17 00:00:00 2001 From: in1tiate <32779090+in1tiate@users.noreply.github.com> Date: Mon, 9 Nov 2020 14:47:51 -0600 Subject: [PATCH 32/81] Add context menu entry to stop music (#301) Also included in this commit are changes to the music packet handler that change the text from "has played a song" to "has stopped the music" in the case that the special "stop song" track is played, as well as a condition stopping music categories from triggering a music packet when double-clicked. Co-authored-by: oldmud0 --- include/courtroom.h | 1 + src/courtroom.cpp | 55 ++++++++++++++++++++++++++++++++++----------- 2 files changed, 43 insertions(+), 13 deletions(-) diff --git a/include/courtroom.h b/include/courtroom.h index 172b9f1..4631166 100644 --- a/include/courtroom.h +++ b/include/courtroom.h @@ -705,6 +705,7 @@ private slots: void music_random(); void music_list_expand_all(); void music_list_collapse_all(); + void music_stop(); void on_area_list_double_clicked(QTreeWidgetItem *p_item, int column); void select_emote(int p_id); diff --git a/src/courtroom.cpp b/src/courtroom.cpp index a12c95a..35c2eac 100644 --- a/src/courtroom.cpp +++ b/src/courtroom.cpp @@ -2623,8 +2623,12 @@ void Courtroom::append_ic_text(QString p_text, QString p_name, QString p_action, // Format the name of the actor ui_ic_chatlog->textCursor().insertText(p_name, bold); + // Special case for stopping the music + if (p_action == tr("has stopped the music")) { + ui_ic_chatlog->textCursor().insertText(" " + p_action + ".", normal); + } // If action not blank: - if (p_action != "") { + else if (p_action != "") { // Format the action in normal ui_ic_chatlog->textCursor().insertText(" " + p_action, normal); if (log_newline) @@ -3160,9 +3164,10 @@ void Courtroom::handle_song(QStringList *p_contents) { effect_flags = p_contents->at(5).toInt(); } - music_player->play(f_song, channel, looping, effect_flags); - if (channel == 0) { + if (f_song == "~stop.mp3") + ui_music_name->setText(tr("None")); + else if (channel == 0) { if (file_exists(ao_app->get_sfx_suffix(ao_app->get_music_path(f_song)))) ui_music_name->setText(f_song_clear); else @@ -3171,7 +3176,7 @@ void Courtroom::handle_song(QStringList *p_contents) } else { QString str_char = char_list.at(n_char).name; - QString str_show = char_list.at(n_char).name; + QString str_show = ao_app->get_showname(str_char); if (p_contents->length() > 2) { if (p_contents->at(2) != "") { @@ -3193,12 +3198,20 @@ void Courtroom::handle_song(QStringList *p_contents) } if (!mute_map.value(n_char)) { - log_ic_text(str_char, str_show, f_song, tr("has played a song"), - m_chatmessage[TEXT_COLOR].toInt()); - append_ic_text(f_song_clear, str_show, tr("has played a song")); - + if (f_song == "~stop.mp3") { + log_ic_text(str_char, str_show, "", tr("has stopped the music"), + m_chatmessage[TEXT_COLOR].toInt()); + append_ic_text("", str_show, tr("has stopped the music")); + } + else { + log_ic_text(str_char, str_show, f_song, tr("has played a song"), + m_chatmessage[TEXT_COLOR].toInt()); + append_ic_text(f_song_clear, str_show, tr("has played a song")); + } music_player->play(f_song, channel, looping, effect_flags); - if (channel == 0) { + if (f_song == "~stop.mp3") + ui_music_name->setText(tr("None")); + else if (channel == 0) { if (file_exists(ao_app->get_sfx_suffix(ao_app->get_music_path(f_song)))) ui_music_name->setText(f_song_clear); else @@ -3918,7 +3931,7 @@ void Courtroom::set_effects_dropdown() return; } - effectslist.prepend("None"); + effectslist.prepend(tr("None")); ui_effects_dropdown->show(); ui_effects_dropdown->addItems(effectslist); @@ -4096,10 +4109,10 @@ void Courtroom::on_music_list_double_clicked(QTreeWidgetItem *p_item, { if (is_muted) return; - + if (p_item->parent() == nullptr) // i.e. we've clicked a category + return; column = 1; // Column 1 is always the metadata (which we want) QString p_song = p_item->text(column); - QStringList packet_contents; packet_contents.append(p_song); packet_contents.append(QString::number(m_cid)); @@ -4114,7 +4127,7 @@ void Courtroom::on_music_list_double_clicked(QTreeWidgetItem *p_item, void Courtroom::on_music_list_context_menu_requested(const QPoint &pos) { QMenu *menu = new QMenu(); - + menu->addAction(QString(tr("Stop Current Song")), this, SLOT(music_stop())); menu->addAction(QString(tr("Play Random Song")), this, SLOT(music_random())); menu->addSeparator(); menu->addAction(QString(tr("Expand All Categories")), this, @@ -4192,6 +4205,22 @@ void Courtroom::music_list_collapse_all() ui_music_list->setCurrentItem(current); } +void Courtroom::music_stop() +{ // send a fake music packet with a nonexistent song + if (is_muted) // this requires a special exception for "~stop.mp3" in + return; // tsuserver3, as it will otherwise reject songs not on + QStringList packet_contents; // its music list + packet_contents.append( + "~stop.mp3"); // this is our fake song, playing it triggers special code + packet_contents.append(QString::number(m_cid)); + if ((!ui_ic_chat_name->text().isEmpty() && ao_app->cccc_ic_support_enabled) || + ao_app->effects_enabled) + packet_contents.append(ui_ic_chat_name->text()); + if (ao_app->effects_enabled) + packet_contents.append(QString::number(music_flags)); + ao_app->send_server_packet(new AOPacket("MC", packet_contents), false); +} + void Courtroom::on_area_list_double_clicked(QTreeWidgetItem *p_item, int column) { column = 0; // The metadata From 1502a1859336e92a2c92e960475f2c5fa1ed3f3f Mon Sep 17 00:00:00 2001 From: in1tiate <32779090+in1tiate@users.noreply.github.com> Date: Mon, 9 Nov 2020 15:05:21 -0600 Subject: [PATCH 33/81] Reformat emote_mod logic (#307) Interjections should not force preanimation if 'Pre' is unchecked. --- src/courtroom.cpp | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/src/courtroom.cpp b/src/courtroom.cpp index 35c2eac..e27603b 100644 --- a/src/courtroom.cpp +++ b/src/courtroom.cpp @@ -1596,13 +1596,11 @@ void Courtroom::on_chat_return_pressed() int f_emote_mod = ao_app->get_emote_mod(current_char, current_emote); // needed or else legacy won't understand what we're saying - if (objection_state > 0) { - if (ui_pre->isChecked()) { - if (f_emote_mod == 4 || f_emote_mod == 5) - f_emote_mod = 6; - else - f_emote_mod = 2; - } + if (objection_state > 0 && ui_pre->isChecked()) { + if (f_emote_mod == 4 || f_emote_mod == 5) + f_emote_mod = 6; + else + f_emote_mod = 2; } else if (ui_pre->isChecked() && !ui_pre_non_interrupt->isChecked()) { if (f_emote_mod == 0) From fe3224d7e8ebc81e5389e46f38f2e1120a78f9b8 Mon Sep 17 00:00:00 2001 From: in1tiate <32779090+in1tiate@users.noreply.github.com> Date: Tue, 10 Nov 2020 08:43:18 -0600 Subject: [PATCH 34/81] Add vertical offset feature (#333) --- include/courtroom.h | 7 +++- src/courtroom.cpp | 82 ++++++++++++++++++++++++++++++++++++--------- 2 files changed, 72 insertions(+), 17 deletions(-) diff --git a/include/courtroom.h b/include/courtroom.h index 4631166..df13c69 100644 --- a/include/courtroom.h +++ b/include/courtroom.h @@ -280,9 +280,12 @@ private: // The character ID of the character this user wants to appear alongside with. int other_charid = -1; - // The offset this user has given if they want to appear alongside someone. + // The horizontal offset this user has given if they want to appear alongside someone. int char_offset = 0; + // The vertical offset this user has given. + int char_vert_offset = 0; + // 0 = in front, 1 = behind int pair_order = 0; @@ -524,6 +527,7 @@ private: AOButton *ui_pair_button; QListWidget *ui_pair_list; QSpinBox *ui_pair_offset_spinbox; + QSpinBox *ui_pair_vert_offset_spinbox; QComboBox *ui_pair_order_dropdown; @@ -779,6 +783,7 @@ private slots: void on_log_limit_changed(int value); void on_pair_offset_changed(int value); + void on_pair_vert_offset_changed(int value); void on_ooc_toggle_clicked(); diff --git a/src/courtroom.cpp b/src/courtroom.cpp index e27603b..74e9cde 100644 --- a/src/courtroom.cpp +++ b/src/courtroom.cpp @@ -242,7 +242,10 @@ Courtroom::Courtroom(AOApplication *p_ao_app) : QMainWindow() ui_pair_list = new QListWidget(this); ui_pair_offset_spinbox = new QSpinBox(this); ui_pair_offset_spinbox->setRange(-100, 100); - ui_pair_offset_spinbox->setSuffix(tr("% offset")); + ui_pair_offset_spinbox->setSuffix(tr("% x offset")); + ui_pair_vert_offset_spinbox = new QSpinBox(this); + ui_pair_vert_offset_spinbox->setRange(-100, 100); + ui_pair_vert_offset_spinbox->setSuffix(tr("% y offset")); ui_pair_order_dropdown = new QComboBox(this); ui_pair_order_dropdown->addItem(tr("To front")); @@ -386,6 +389,8 @@ Courtroom::Courtroom(AOApplication *p_ao_app) : QMainWindow() SLOT(on_pair_list_clicked(QModelIndex))); connect(ui_pair_offset_spinbox, SIGNAL(valueChanged(int)), this, SLOT(on_pair_offset_changed(int))); + connect(ui_pair_vert_offset_spinbox, SIGNAL(valueChanged(int)), this, + SLOT(on_pair_vert_offset_changed(int))); connect(ui_pair_order_dropdown, SIGNAL(currentIndexChanged(int)), this, SLOT(on_pair_order_dropdown_changed(int))); @@ -586,12 +591,18 @@ void Courtroom::set_widgets() set_size_and_pos(ui_pair_offset_spinbox, "pair_offset_spinbox"); ui_pair_offset_spinbox->hide(); ui_pair_offset_spinbox->setToolTip( - tr("Change the percentage offset of your character's position from the " + tr("Change the horizontal percentage offset of your character's position from the " + "center of the screen.")); + + set_size_and_pos(ui_pair_vert_offset_spinbox, "pair_vert_offset_spinbox"); + ui_pair_vert_offset_spinbox->hide(); + ui_pair_vert_offset_spinbox->setToolTip( + tr("Change the vertical percentage offset of your character's position from the " "center of the screen.")); ui_pair_order_dropdown->hide(); set_size_and_pos(ui_pair_order_dropdown, "pair_order_dropdown"); - ui_pair_offset_spinbox->setToolTip( + ui_pair_order_dropdown->setToolTip( tr("Change the order of appearance for your character.")); set_size_and_pos(ui_pair_button, "pair_button"); @@ -1692,7 +1703,7 @@ void Courtroom::on_chat_return_pressed() packet_contents.append("-1"); } // Send the offset as it's gonna be used regardless - packet_contents.append(QString::number(char_offset)); + packet_contents.append(QString::number(char_offset) + "&" + QString::number(char_vert_offset)); // Finally, we send over if we want our pres to not interrupt. if (ui_pre_non_interrupt->isChecked() && ui_pre->isChecked()) { @@ -2083,10 +2094,19 @@ void Courtroom::handle_chatmessage_2() if (got_other_charid > -1) { // If there is, show them! ui_vp_sideplayer_char->show(); - - int other_offset = m_chatmessage[OTHER_OFFSET].toInt(); + QStringList other_offsets = m_chatmessage[OTHER_OFFSET].split("&"); + int other_offset; + int other_offset_v; + if (other_offsets.length() <= 1) { + other_offset = m_chatmessage[OTHER_OFFSET].toInt(); + other_offset_v = 0; + } + else { + other_offset = other_offsets[0].toInt(); + other_offset_v = other_offsets[1].toInt(); + } ui_vp_sideplayer_char->move(ui_viewport->width() * other_offset / 100, - 0); + ui_viewport->height() * other_offset_v / 100); QStringList args = m_chatmessage[OTHER_CHARID].split("^"); if (args.size() > @@ -2125,12 +2145,14 @@ void Courtroom::handle_chatmessage_2() } // Set ourselves according to SELF_OFFSET - bool ok; - int self_offset = m_chatmessage[SELF_OFFSET].toInt(&ok); - if (ok) - ui_vp_player_char->move(ui_viewport->width() * self_offset / 100, 0); - else - ui_vp_player_char->move(0, 0); + QStringList self_offsets = m_chatmessage[SELF_OFFSET].split("&"); + int self_offset = self_offsets[0].toInt(); + int self_offset_v; + if (self_offsets.length() <= 1) + self_offset_v = 0; + else + self_offset_v = self_offsets[1].toInt(); + ui_vp_player_char->move(ui_viewport->width() * self_offset / 100, ui_viewport->height() * self_offset_v / 100); switch (emote_mod) { case 1: @@ -3372,9 +3394,8 @@ void Courtroom::on_ooc_return_pressed() if (ok) { if (off >= -100 && off <= 100) { char_offset = off; - QString msg = tr("You have set your offset to "); - msg.append(QString::number(off)); - msg.append("%."); + QString msg = tr("You have set your offset to %1%%.") + .arg(QString::number(off)); append_server_chatmessage("CLIENT", msg, "1"); } else { @@ -3388,6 +3409,30 @@ void Courtroom::on_ooc_return_pressed() } return; } + else if (ooc_message.startsWith("/voffset")) { + ui_ooc_chat_message->clear(); + ooc_message.remove(0, 8); + + bool ok; + int off = ooc_message.toInt(&ok); + if (ok) { + if (off >= -100 && off <= 100) { + char_vert_offset = off; + QString msg = tr("You have set your vertical offset to %1%%.") + .arg(QString::number(off)); + append_server_chatmessage("CLIENT", msg, "1"); + } + else { + append_server_chatmessage( + "CLIENT", tr("Your vertical offset must be between -100% and 100%!"), "1"); + } + } + else { + append_server_chatmessage("CLIENT", + tr("That vertical offset does not look like one."), "1"); + } + return; + } else if (ooc_message.startsWith("/switch_am")) { append_server_chatmessage( "CLIENT", tr("You switched your music and area list."), "1"); @@ -4360,6 +4405,7 @@ void Courtroom::on_mute_clicked() ui_mute_list->show(); ui_pair_list->hide(); ui_pair_offset_spinbox->hide(); + ui_pair_vert_offset_spinbox->hide(); ui_pair_order_dropdown->hide(); ui_pair_button->set_image("pair_button"); ui_mute->set_image("mute_pressed"); @@ -4375,6 +4421,7 @@ void Courtroom::on_pair_clicked() if (ui_pair_list->isHidden()) { ui_pair_list->show(); ui_pair_offset_spinbox->show(); + ui_pair_vert_offset_spinbox->show(); ui_pair_order_dropdown->show(); ui_mute_list->hide(); ui_mute->set_image("mute"); @@ -4383,6 +4430,7 @@ void Courtroom::on_pair_clicked() else { ui_pair_list->hide(); ui_pair_offset_spinbox->hide(); + ui_pair_vert_offset_spinbox->hide(); ui_pair_order_dropdown->hide(); ui_pair_button->set_image("pair_button"); } @@ -4539,6 +4587,8 @@ void Courtroom::on_log_limit_changed(int value) { log_maximum_blocks = value; } void Courtroom::on_pair_offset_changed(int value) { char_offset = value; } +void Courtroom::on_pair_vert_offset_changed(int value) { char_vert_offset = value; } + void Courtroom::on_witness_testimony_clicked() { if (is_muted) From 10298230ce72c6b00336fb0ca099ba747d4cb421 Mon Sep 17 00:00:00 2001 From: stonedDiscord <10584181+stonedDiscord@users.noreply.github.com> Date: Mon, 16 Nov 2020 14:32:04 +0100 Subject: [PATCH 35/81] clean up path functions --- src/path_functions.cpp | 40 ++++------------------------------------ 1 file changed, 4 insertions(+), 36 deletions(-) diff --git a/src/path_functions.cpp b/src/path_functions.cpp index 10c8ae5..4d5a291 100644 --- a/src/path_functions.cpp +++ b/src/path_functions.cpp @@ -44,61 +44,37 @@ QString AOApplication::get_data_path() { return get_base_path() + "data/"; } QString AOApplication::get_default_theme_path(QString p_file) { QString path = get_base_path() + "themes/default/" + p_file; -#ifndef CASE_SENSITIVE_FILESYSTEM - return path; -#else return get_case_sensitive_path(path); -#endif } QString AOApplication::get_custom_theme_path(QString p_theme, QString p_file) { QString path = get_base_path() + "themes/" + p_theme + "/" + p_file; -#ifndef CASE_SENSITIVE_FILESYSTEM - return path; -#else return get_case_sensitive_path(path); -#endif } QString AOApplication::get_theme_path(QString p_file) { QString path = get_base_path() + "themes/" + current_theme + "/" + p_file; -#ifndef CASE_SENSITIVE_FILESYSTEM - return path; -#else return get_case_sensitive_path(path); -#endif } QString AOApplication::get_character_path(QString p_char, QString p_file) { QString path = get_base_path() + "characters/" + p_char + "/" + p_file; -#ifndef CASE_SENSITIVE_FILESYSTEM - return path; -#else return get_case_sensitive_path(path); -#endif } QString AOApplication::get_sounds_path(QString p_file) { QString path = get_base_path() + "sounds/general/" + p_file; -#ifndef CASE_SENSITIVE_FILESYSTEM - return path; -#else return get_case_sensitive_path(path); -#endif } QString AOApplication::get_music_path(QString p_song) { QString path = get_base_path() + "sounds/music/" + p_song; -#ifndef CASE_SENSITIVE_FILESYSTEM - return path; -#else return get_case_sensitive_path(path); -#endif } QString AOApplication::get_background_path(QString p_file) @@ -106,11 +82,7 @@ QString AOApplication::get_background_path(QString p_file) QString path = get_base_path() + "background/" + w_courtroom->get_current_background() + "/" + p_file; if (courtroom_constructed) { -#ifndef CASE_SENSITIVE_FILESYSTEM - return path; -#else return get_case_sensitive_path(path); -#endif } return get_default_background_path(p_file); } @@ -118,25 +90,18 @@ QString AOApplication::get_background_path(QString p_file) QString AOApplication::get_default_background_path(QString p_file) { QString path = get_base_path() + "background/default/" + p_file; -#ifndef CASE_SENSITIVE_FILESYSTEM - return path; -#else return get_case_sensitive_path(path); -#endif } QString AOApplication::get_evidence_path(QString p_file) { QString path = get_base_path() + "evidence/" + p_file; -#ifndef CASE_SENSITIVE_FILESYSTEM - return path; -#else return get_case_sensitive_path(path); -#endif } QString AOApplication::get_case_sensitive_path(QString p_file) { + #ifdef CASE_SENSITIVE_FILESYSTEM // first, check to see if it's actually there (also serves as base case for // recursion) if (exists(p_file)) @@ -163,4 +128,7 @@ QString AOApplication::get_case_sensitive_path(QString p_file) // if nothing is found, let the caller handle the missing file return file_parent_dir + "/" + file_basename; +#else + return p_file; +#endif } From 548eae95f27fc2dbd94f66bdba0d2d4aa0c4082b Mon Sep 17 00:00:00 2001 From: stonedDiscord <10584181+stonedDiscord@users.noreply.github.com> Date: Mon, 16 Nov 2020 14:49:28 +0100 Subject: [PATCH 36/81] filter path traversal --- src/path_functions.cpp | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/src/path_functions.cpp b/src/path_functions.cpp index 4d5a291..b1d7976 100644 --- a/src/path_functions.cpp +++ b/src/path_functions.cpp @@ -101,15 +101,19 @@ QString AOApplication::get_evidence_path(QString p_file) QString AOApplication::get_case_sensitive_path(QString p_file) { + QFileInfo file(p_file); + QString file_basename = file.fileName(); + + // no path traversal above base folder + if (!(file.absolutePath().startsWith(get_base_path()))) + return get_base_path() + file_basename; + #ifdef CASE_SENSITIVE_FILESYSTEM // first, check to see if it's actually there (also serves as base case for // recursion) if (exists(p_file)) return p_file; - QFileInfo file(p_file); - - QString file_basename = file.fileName(); QString file_parent_dir = get_case_sensitive_path(file.absolutePath()); // second, does it exist in the new parent dir? From 6e58b6a943e7deac84d11b1164fb87ad5aae339b Mon Sep 17 00:00:00 2001 From: stonedDiscord <10584181+stonedDiscord@users.noreply.github.com> Date: Mon, 16 Nov 2020 15:06:25 +0100 Subject: [PATCH 37/81] don't display the ? in the titlebar --- src/aocaseannouncerdialog.cpp | 2 +- src/aooptionsdialog.cpp | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/aocaseannouncerdialog.cpp b/src/aocaseannouncerdialog.cpp index d91433a..aea6405 100644 --- a/src/aocaseannouncerdialog.cpp +++ b/src/aocaseannouncerdialog.cpp @@ -3,7 +3,7 @@ AOCaseAnnouncerDialog::AOCaseAnnouncerDialog(QWidget *parent, AOApplication *p_ao_app, Courtroom *p_court) - : QDialog(parent) + : QDialog(parent, Qt::WindowTitleHint | Qt::WindowSystemMenuHint) { ao_app = p_ao_app; court = p_court; diff --git a/src/aooptionsdialog.cpp b/src/aooptionsdialog.cpp index 4d36f43..2641d8d 100644 --- a/src/aooptionsdialog.cpp +++ b/src/aooptionsdialog.cpp @@ -3,7 +3,7 @@ #include "bass.h" AOOptionsDialog::AOOptionsDialog(QWidget *parent, AOApplication *p_ao_app) - : QDialog(parent) + : QDialog(parent, Qt::WindowTitleHint | Qt::WindowSystemMenuHint) { ao_app = p_ao_app; From 0c382eea7dd3f4cbbeea120bdb1b764cef8e89db Mon Sep 17 00:00:00 2001 From: stonedDiscord <10584181+stonedDiscord@users.noreply.github.com> Date: Mon, 16 Nov 2020 15:13:33 +0100 Subject: [PATCH 38/81] move enter courtroom to the PV packet instead of just doing it when you click a character --- src/charselect.cpp | 2 -- src/packet_distribution.cpp | 2 ++ 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/charselect.cpp b/src/charselect.cpp index b543934..f8c622d 100644 --- a/src/charselect.cpp +++ b/src/charselect.cpp @@ -148,8 +148,6 @@ void Courtroom::char_clicked(int n_char) else update_character(n_char); - enter_courtroom(); - if (n_char != -1) ui_ic_chat_name->setPlaceholderText(char_list.at(n_char).name); } diff --git a/src/packet_distribution.cpp b/src/packet_distribution.cpp index f712579..1ffbcaf 100644 --- a/src/packet_distribution.cpp +++ b/src/packet_distribution.cpp @@ -460,6 +460,8 @@ void AOApplication::server_packet_received(AOPacket *p_packet) if (f_contents.size() < 3) goto end; + w_courtroom->enter_courtroom(); + if (courtroom_constructed) w_courtroom->update_character(f_contents.at(2).toInt()); } From fa083923f9551dd69fe37383f04297f78e4de9ce Mon Sep 17 00:00:00 2001 From: stonedDiscord <10584181+stonedDiscord@users.noreply.github.com> Date: Mon, 16 Nov 2020 15:17:49 +0100 Subject: [PATCH 39/81] change the sfx tooltop description --- src/courtroom.cpp | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/courtroom.cpp b/src/courtroom.cpp index ec4e47b..baa6631 100644 --- a/src/courtroom.cpp +++ b/src/courtroom.cpp @@ -720,8 +720,7 @@ void Courtroom::set_widgets() ui_sfx_remove->setText("X"); ui_sfx_remove->set_image("evidencex"); ui_sfx_remove->setToolTip( - tr("Remove the currently selected iniswap from the list and return to " - "the original character folder.")); + tr("Remove the currently selected sound effect.")); ui_sfx_remove->hide(); set_iniswap_dropdown(); From ffbaab5a2ae45291f4eb830d8d7d12275ff916cf Mon Sep 17 00:00:00 2001 From: in1tiate Date: Sat, 12 Dec 2020 06:54:31 -0600 Subject: [PATCH 40/81] Add QMake flags for "lib" directory --- Attorney_Online.pro | 1 + 1 file changed, 1 insertion(+) diff --git a/Attorney_Online.pro b/Attorney_Online.pro index b9722b1..1a5f214 100644 --- a/Attorney_Online.pro +++ b/Attorney_Online.pro @@ -14,6 +14,7 @@ SOURCES += $$files($$PWD/src/*.cpp) HEADERS += $$files($$PWD/include/*.h) LIBS += -L$$PWD/lib +QMAKE_LFLAGS += -Wl,-rpath,"'\$$ORIGIN/lib'" # Uncomment for verbose network logging # DEFINES += DEBUG_NETWORK From 3d4d6378384fee027ccbc3706a66c2f14cc0bac0 Mon Sep 17 00:00:00 2001 From: in1tiate Date: Sat, 12 Dec 2020 06:54:45 -0600 Subject: [PATCH 41/81] Search for plugins in "lib" directory --- src/main.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/main.cpp b/src/main.cpp index 364377b..c0a8a1d 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -21,6 +21,8 @@ int main(int argc, char *argv[]) AOApplication main_app(argc, argv); + AOApplication::setLibraryPaths({AOApplication::applicationDirPath() + "/lib"}); + QSettings *configini = main_app.configini; QPluginLoader apngPlugin("qapng"); From b159ca35df0fbfbce276c9fbaf011101bc79457b Mon Sep 17 00:00:00 2001 From: in1tiate <32779090+in1tiate@users.noreply.github.com> Date: Mon, 28 Dec 2020 00:49:50 -0600 Subject: [PATCH 42/81] Fix sounds and blips being muted forever on changing character (#345) Re-fix of #277. --- src/courtroom.cpp | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/courtroom.cpp b/src/courtroom.cpp index baa6631..9b3b206 100644 --- a/src/courtroom.cpp +++ b/src/courtroom.cpp @@ -1333,6 +1333,9 @@ void Courtroom::update_character(int p_cid) ui_char_select_background->hide(); ui_ic_chat_message->setEnabled(m_cid != -1); ui_ic_chat_message->setFocus(); + // have to call these to make sure sfx and blips don't get accidentally muted forever when we change characters + sfx_player->set_volume(ui_sfx_slider->value()); + blip_player->set_volume(ui_blip_slider->value()); } void Courtroom::enter_courtroom() From 39a8ab8ab2d7791c1954649b1fb96c52d498105f Mon Sep 17 00:00:00 2001 From: in1tiate <32779090+in1tiate@users.noreply.github.com> Date: Mon, 28 Dec 2020 00:54:08 -0600 Subject: [PATCH 43/81] Enable support for up to 6 SFX channels (#355) I'm somewhat confused as to why this wasn't enabled to begin with, since all the necessary code is here. Closes #306, and fixes the issue with realizations being cut off by other sounds. Co-authored-by: oldmud0 --- include/aosfxplayer.h | 3 +-- src/aosfxplayer.cpp | 27 ++++++++++++++------------- 2 files changed, 15 insertions(+), 15 deletions(-) diff --git a/include/aosfxplayer.h b/include/aosfxplayer.h index 0a5fffa..7597636 100644 --- a/include/aosfxplayer.h +++ b/include/aosfxplayer.h @@ -16,8 +16,7 @@ public: void clear(); void loop_clear(); - void play(QString p_sfx, QString p_char = "", QString shout = "", - int channel = -1); + void play(QString p_sfx, QString p_char = "", QString shout = ""); void stop(int channel = -1); void set_volume(qreal p_volume); void set_looping(bool toggle, int channel = -1); diff --git a/src/aosfxplayer.cpp b/src/aosfxplayer.cpp index 1a0e2d2..13de04f 100644 --- a/src/aosfxplayer.cpp +++ b/src/aosfxplayer.cpp @@ -24,17 +24,17 @@ void AOSfxPlayer::loop_clear() set_volume_internal(m_volume); } -void AOSfxPlayer::play(QString p_sfx, QString p_char, QString shout, - int channel) +void AOSfxPlayer::play(QString p_sfx, QString p_char, QString shout) { - if (channel == -1) { - if (BASS_ChannelIsActive(m_stream_list[channel]) == BASS_ACTIVE_PLAYING) - m_channel = (m_channel + 1) % m_channelmax; - channel = m_channel; + for (int i = 0; i < m_channelmax; ++i) { + if (BASS_ChannelIsActive(m_stream_list[i]) == BASS_ACTIVE_PLAYING) + m_channel = (i + 1) % m_channelmax; + else { + m_channel = i; + break; + } } - BASS_ChannelStop(m_stream_list[channel]); - QString misc_path = ""; QString char_path = ""; QString theme_path = ""; @@ -45,7 +45,8 @@ void AOSfxPlayer::play(QString p_sfx, QString p_char, QString shout, shout + "/" + p_sfx); theme_path = ao_app->get_sfx_suffix(ao_app->get_theme_path(p_sfx)); if (!file_exists(theme_path)) - theme_path = ao_app->get_sfx_suffix(ao_app->get_default_theme_path(p_sfx)); + theme_path = + ao_app->get_sfx_suffix(ao_app->get_default_theme_path(p_sfx)); } if (p_char != "") char_path = @@ -57,17 +58,17 @@ void AOSfxPlayer::play(QString p_sfx, QString p_char, QString shout, f_path = char_path; else if (file_exists(misc_path)) f_path = misc_path; - else if (shout != "" && file_exists(theme_path)) //only check here for shouts + else if (shout != "" && file_exists(theme_path)) // only check here for shouts f_path = theme_path; else f_path = sound_path; if (f_path.endsWith(".opus")) - m_stream_list[channel] = BASS_OPUS_StreamCreateFile( + m_stream_list[m_channel] = BASS_OPUS_StreamCreateFile( FALSE, f_path.utf16(), 0, 0, BASS_STREAM_AUTOFREE | BASS_UNICODE | BASS_ASYNCFILE); else - m_stream_list[channel] = BASS_StreamCreateFile( + m_stream_list[m_channel] = BASS_StreamCreateFile( FALSE, f_path.utf16(), 0, 0, BASS_STREAM_AUTOFREE | BASS_UNICODE | BASS_ASYNCFILE); @@ -81,7 +82,7 @@ void AOSfxPlayer::play(QString p_sfx, QString p_char, QString shout, } BASS_ChannelPlay(m_stream_list[m_channel], false); - BASS_ChannelSetSync(m_stream_list[channel], BASS_SYNC_DEV_FAIL, 0, + BASS_ChannelSetSync(m_stream_list[m_channel], BASS_SYNC_DEV_FAIL, 0, ao_app->BASSreset, 0); } From 570bad6d4775df19229fb7beae7c6a011220bc1c Mon Sep 17 00:00:00 2001 From: Crystalwarrior Date: Mon, 28 Dec 2020 10:19:15 +0300 Subject: [PATCH 44/81] Fix blankposting not respecting character ID's in the equation (#282) Fixes an issue where if you blankpost on top of another character's blankpost, your message won't show up on the ic log clientside. --- src/courtroom.cpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/courtroom.cpp b/src/courtroom.cpp index 9b3b206..e39c3d9 100644 --- a/src/courtroom.cpp +++ b/src/courtroom.cpp @@ -1810,6 +1810,7 @@ void Courtroom::handle_chatmessage(QStringList *p_contents) if (p_contents->size() < MS_MINIMUM) return; + int prev_char_id = m_chatmessage[CHAR_ID].toInt(); for (int n_string = 0; n_string < MS_MAXIMUM; ++n_string) { // Note that we have added stuff that vanilla clients and servers simply // won't send. So now, we have to check if the thing we want even exists @@ -1878,8 +1879,8 @@ void Courtroom::handle_chatmessage(QStringList *p_contents) m_chatmessage[MESSAGE] = ""; // Turn it into true blankpost } - if (!m_chatmessage[MESSAGE].isEmpty() || ic_chatlog_history.isEmpty() || - ic_chatlog_history.last().get_message() != "") { + if (prev_char_id != f_char_id || !m_chatmessage[MESSAGE].isEmpty() || + ic_chatlog_history.isEmpty() || ic_chatlog_history.last().get_message() != "") { log_ic_text(f_charname, f_displayname, m_chatmessage[MESSAGE], "", m_chatmessage[TEXT_COLOR].toInt()); append_ic_text(m_chatmessage[MESSAGE], f_displayname, "", From 38b730ce0d00576761fe125f8e97f0d9f5813978 Mon Sep 17 00:00:00 2001 From: in1tiate <32779090+in1tiate@users.noreply.github.com> Date: Mon, 28 Dec 2020 04:37:33 -0600 Subject: [PATCH 45/81] add library path instead of setting it Co-authored-by: oldmud0 --- src/main.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main.cpp b/src/main.cpp index c0a8a1d..ce8b1dd 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -21,7 +21,7 @@ int main(int argc, char *argv[]) AOApplication main_app(argc, argv); - AOApplication::setLibraryPaths({AOApplication::applicationDirPath() + "/lib"}); + AOApplication::addLibraryPath(AOApplication::applicationDirPath() + "/lib"); QSettings *configini = main_app.configini; From 29f8733dbaecdd51dc5855e259c5def1d03b90c2 Mon Sep 17 00:00:00 2001 From: scatterflower <2956568+scatterflower@users.noreply.github.com> Date: Sun, 3 Jan 2021 19:23:01 -0600 Subject: [PATCH 46/81] FL toggle for Y offset (#360) Use "y_offset" to enable the Y offset protocol extension. --- include/aoapplication.h | 1 + src/courtroom.cpp | 8 ++++++-- src/packet_distribution.cpp | 3 +++ 3 files changed, 10 insertions(+), 2 deletions(-) diff --git a/include/aoapplication.h b/include/aoapplication.h index c06f3f9..790b445 100644 --- a/include/aoapplication.h +++ b/include/aoapplication.h @@ -76,6 +76,7 @@ public: bool looping_sfx_support_enabled = false; bool additive_enabled = false; bool effects_enabled = false; + bool y_offset_enabled = false; ///////////////loading info/////////////////// diff --git a/src/courtroom.cpp b/src/courtroom.cpp index e39c3d9..9518911 100644 --- a/src/courtroom.cpp +++ b/src/courtroom.cpp @@ -1708,7 +1708,10 @@ void Courtroom::on_chat_return_pressed() packet_contents.append("-1"); } // Send the offset as it's gonna be used regardless - packet_contents.append(QString::number(char_offset) + "&" + QString::number(char_vert_offset)); + if(ao_app->y_offset_enabled) + packet_contents.append(QString::number(char_offset) + "&" + QString::number(char_vert_offset)); + else + packet_contents.append(QString::number(char_offset)); // Finally, we send over if we want our pres to not interrupt. if (ui_pre_non_interrupt->isChecked() && ui_pre->isChecked()) { @@ -4450,7 +4453,8 @@ void Courtroom::on_pair_clicked() if (ui_pair_list->isHidden()) { ui_pair_list->show(); ui_pair_offset_spinbox->show(); - ui_pair_vert_offset_spinbox->show(); + if(ao_app->y_offset_enabled) + ui_pair_vert_offset_spinbox->show(); ui_pair_order_dropdown->show(); ui_mute_list->hide(); ui_mute->set_image("mute"); diff --git a/src/packet_distribution.cpp b/src/packet_distribution.cpp index 1ffbcaf..0b73cdf 100644 --- a/src/packet_distribution.cpp +++ b/src/packet_distribution.cpp @@ -133,6 +133,7 @@ void AOApplication::server_packet_received(AOPacket *p_packet) looping_sfx_support_enabled = false; additive_enabled = false; effects_enabled = false; + y_offset_enabled = false; QString f_hdid; f_hdid = get_hdid(); @@ -205,6 +206,8 @@ void AOApplication::server_packet_received(AOPacket *p_packet) additive_enabled = true; if (f_packet.contains("effects", Qt::CaseInsensitive)) effects_enabled = true; + if (f_packet.contains("y_offset", Qt::CaseInsensitive)) + y_offset_enabled = true; } else if (header == "PN") { if (f_contents.size() < 2) From aabb256207b1905a31277f2593ed731ef1a0a071 Mon Sep 17 00:00:00 2001 From: Skye Deving <76892045+skyedeving@users.noreply.github.com> Date: Mon, 4 Jan 2021 06:13:54 -0600 Subject: [PATCH 47/81] Refactor AOPacket --- include/aopacket.h | 3 +-- src/aopacket.cpp | 54 ++++++++++------------------------------------ 2 files changed, 12 insertions(+), 45 deletions(-) diff --git a/include/aopacket.h b/include/aopacket.h index e636998..6d1deba 100644 --- a/include/aopacket.h +++ b/include/aopacket.h @@ -8,8 +8,7 @@ class AOPacket { public: AOPacket(QString p_packet_string); - AOPacket(QString header, QStringList &p_contents); - ~AOPacket(); + AOPacket(QString header, QStringList &p_contents) : m_header(header), m_contents(p_contents){} QString get_header() { return m_header; } QStringList &get_contents() { return m_contents; } diff --git a/src/aopacket.cpp b/src/aopacket.cpp index 4cf43e1..a989a3a 100644 --- a/src/aopacket.cpp +++ b/src/aopacket.cpp @@ -4,59 +4,27 @@ AOPacket::AOPacket(QString p_packet_string) { QStringList packet_contents = p_packet_string.split("#"); - m_header = packet_contents.at(0); - - for (int n_string = 1; n_string < packet_contents.size() - 1; ++n_string) { - m_contents.append(packet_contents.at(n_string)); - } + m_header = packet_contents.first(); + m_contents = QStringList(packet_contents.begin()+1, packet_contents.end()-1); // trims % } -AOPacket::AOPacket(QString p_header, QStringList &p_contents) -{ - m_header = p_header; - m_contents = p_contents; -} - -AOPacket::~AOPacket() {} - QString AOPacket::to_string() { - QString f_string = m_header; - - for (QString i_string : m_contents) { - f_string += ("#" + i_string); - } - - f_string += "#%"; - - - return f_string; + return m_header + "#" + m_contents.join("#") + "#%"; } void AOPacket::net_encode() { - for (int n_element = 0; n_element < m_contents.size(); ++n_element) { - QString f_element = m_contents.at(n_element); - f_element.replace("#", "") - .replace("%", "") - .replace("$", "") - .replace("&", ""); - - m_contents.removeAt(n_element); - m_contents.insert(n_element, f_element); - } + m_contents.replaceInStrings("#", "") + .replaceInStrings("%", "") + .replaceInStrings("$", "") + .replaceInStrings("&", ""); } void AOPacket::net_decode() { - for (int n_element = 0; n_element < m_contents.size(); ++n_element) { - QString f_element = m_contents.at(n_element); - f_element.replace("", "#") - .replace("", "%") - .replace("", "$") - .replace("", "&"); - - m_contents.removeAt(n_element); - m_contents.insert(n_element, f_element); - } + m_contents.replaceInStrings("", "#") + .replaceInStrings("", "%") + .replaceInStrings("", "$") + .replaceInStrings("", "&"); } From a0ef2a75ef5e83d4cae4b0ca7b314a659d0ff175 Mon Sep 17 00:00:00 2001 From: Skye Deving <76892045+skyedeving@users.noreply.github.com> Date: Mon, 4 Jan 2021 06:25:50 -0600 Subject: [PATCH 48/81] Encode doc contents with hash sign --- src/courtroom.cpp | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/courtroom.cpp b/src/courtroom.cpp index 9518911..ddecc5a 100644 --- a/src/courtroom.cpp +++ b/src/courtroom.cpp @@ -3573,9 +3573,10 @@ void Courtroom::on_ooc_return_pressed() if (!caseauth.isEmpty()) append_server_chatmessage(tr("CLIENT"), tr("Case made by %1.").arg(caseauth), "1"); - if (!casedoc.isEmpty()) - ao_app->send_server_packet(new AOPacket("CT#" + ui_ooc_chat_name->text() + - "#/doc " + casedoc + "#%")); + if (!casedoc.isEmpty()) { + QStringList f_contents = {ui_ooc_chat_name->text(), "/doc " + casedoc}; + ao_app->send_server_packet(new AOPacket("CT", f_contents)); + } if (!casestatus.isEmpty()) ao_app->send_server_packet(new AOPacket("CT#" + ui_ooc_chat_name->text() + "#/status " + casestatus + "#%")); From 0e3f44a560e68ae16eb836bc6c115717c02a9a7c Mon Sep 17 00:00:00 2001 From: Skye Deving <76892045+skyedeving@users.noreply.github.com> Date: Mon, 4 Jan 2021 07:27:09 -0600 Subject: [PATCH 49/81] Add missing bassopus to the configure script (#361) --- scripts/configure_ubuntu.sh | 3 +++ 1 file changed, 3 insertions(+) diff --git a/scripts/configure_ubuntu.sh b/scripts/configure_ubuntu.sh index 280dfdf..b010d36 100755 --- a/scripts/configure_ubuntu.sh +++ b/scripts/configure_ubuntu.sh @@ -20,10 +20,13 @@ cd tmp #get the bass prebuilt curl http://www.un4seen.com/files/bass24-linux.zip -o bass_linux.zip +curl http://www.un4seen.com/files/bassopus24-linux.zip -o bassopus_linux.zip unzip bass_linux.zip +unzip bassopus_linux.zip cp x64/libbass.so ../../lib +cp x64/libbassopus.so ../../lib #get the discord-rpc prebuilt curl -L https://github.com/discordapp/discord-rpc/releases/download/v3.4.0/discord-rpc-linux.zip -o discord_rpc_linux.zip From 2f55abe647931f31694b13e52bcc0491b27b7acd Mon Sep 17 00:00:00 2001 From: stonedDiscord Date: Mon, 4 Jan 2021 14:39:11 +0100 Subject: [PATCH 50/81] Update issue templates github told me to do this --- .github/ISSUE_TEMPLATE/bug_report.md | 38 +++++++++++++++++++++++ .github/ISSUE_TEMPLATE/feature_request.md | 20 ++++++++++++ 2 files changed, 58 insertions(+) create mode 100644 .github/ISSUE_TEMPLATE/bug_report.md create mode 100644 .github/ISSUE_TEMPLATE/feature_request.md diff --git a/.github/ISSUE_TEMPLATE/bug_report.md b/.github/ISSUE_TEMPLATE/bug_report.md new file mode 100644 index 0000000..dd84ea7 --- /dev/null +++ b/.github/ISSUE_TEMPLATE/bug_report.md @@ -0,0 +1,38 @@ +--- +name: Bug report +about: Create a report to help us improve +title: '' +labels: '' +assignees: '' + +--- + +**Describe the bug** +A clear and concise description of what the bug is. + +**To Reproduce** +Steps to reproduce the behavior: +1. Go to '...' +2. Click on '....' +3. Scroll down to '....' +4. See error + +**Expected behavior** +A clear and concise description of what you expected to happen. + +**Screenshots** +If applicable, add screenshots to help explain your problem. + +**Desktop (please complete the following information):** + - OS: [e.g. iOS] + - Browser [e.g. chrome, safari] + - Version [e.g. 22] + +**Smartphone (please complete the following information):** + - Device: [e.g. iPhone6] + - OS: [e.g. iOS8.1] + - Browser [e.g. stock browser, safari] + - Version [e.g. 22] + +**Additional context** +Add any other context about the problem here. diff --git a/.github/ISSUE_TEMPLATE/feature_request.md b/.github/ISSUE_TEMPLATE/feature_request.md new file mode 100644 index 0000000..bbcbbe7 --- /dev/null +++ b/.github/ISSUE_TEMPLATE/feature_request.md @@ -0,0 +1,20 @@ +--- +name: Feature request +about: Suggest an idea for this project +title: '' +labels: '' +assignees: '' + +--- + +**Is your feature request related to a problem? Please describe.** +A clear and concise description of what the problem is. Ex. I'm always frustrated when [...] + +**Describe the solution you'd like** +A clear and concise description of what you want to happen. + +**Describe alternatives you've considered** +A clear and concise description of any alternative solutions or features you've considered. + +**Additional context** +Add any other context or screenshots about the feature request here. From 04ed1a1812139b0cbef5599a6acd8ee9c3155c2f Mon Sep 17 00:00:00 2001 From: stonedDiscord <10584181+stonedDiscord@users.noreply.github.com> Date: Mon, 4 Jan 2021 16:44:14 +0100 Subject: [PATCH 51/81] add 3 second timer before OK shows up --- src/debug_functions.cpp | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/debug_functions.cpp b/src/debug_functions.cpp index b832164..f96d6b0 100644 --- a/src/debug_functions.cpp +++ b/src/debug_functions.cpp @@ -1,5 +1,6 @@ #include #include +#include #include "debug_functions.h" @@ -24,6 +25,10 @@ void call_notice(QString p_message) msgBox->setWindowTitle( QCoreApplication::translate("debug_functions", "Notice")); - // msgBox->setWindowModality(Qt::NonModal); - msgBox->exec(); + msgBox->setStandardButtons(QMessageBox::NoButton); + + QTimer::singleShot(3000, msgBox, std::bind(&QMessageBox::setStandardButtons,msgBox,QMessageBox::Ok)); + + msgBox->exec(); + } From 714f54b9dccf1efbdd524e17b2dd4f4deefc8a01 Mon Sep 17 00:00:00 2001 From: stonedDiscord <10584181+stonedDiscord@users.noreply.github.com> Date: Mon, 4 Jan 2021 18:05:03 +0100 Subject: [PATCH 52/81] CI needs an extra include for bind --- src/debug_functions.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/src/debug_functions.cpp b/src/debug_functions.cpp index f96d6b0..477eec7 100644 --- a/src/debug_functions.cpp +++ b/src/debug_functions.cpp @@ -1,6 +1,7 @@ #include #include #include +#include #include "debug_functions.h" From 18e5f297f6b0b0e8ad398892a4694b35fa9831f2 Mon Sep 17 00:00:00 2001 From: oldmud0 Date: Mon, 4 Jan 2021 11:20:42 -0600 Subject: [PATCH 53/81] Update bug_report.md --- .github/ISSUE_TEMPLATE/bug_report.md | 15 ++++----------- 1 file changed, 4 insertions(+), 11 deletions(-) diff --git a/.github/ISSUE_TEMPLATE/bug_report.md b/.github/ISSUE_TEMPLATE/bug_report.md index dd84ea7..0e1e98c 100644 --- a/.github/ISSUE_TEMPLATE/bug_report.md +++ b/.github/ISSUE_TEMPLATE/bug_report.md @@ -10,7 +10,7 @@ assignees: '' **Describe the bug** A clear and concise description of what the bug is. -**To Reproduce** +**To reproduce** Steps to reproduce the behavior: 1. Go to '...' 2. Click on '....' @@ -23,16 +23,9 @@ A clear and concise description of what you expected to happen. **Screenshots** If applicable, add screenshots to help explain your problem. -**Desktop (please complete the following information):** - - OS: [e.g. iOS] - - Browser [e.g. chrome, safari] - - Version [e.g. 22] - -**Smartphone (please complete the following information):** - - Device: [e.g. iPhone6] - - OS: [e.g. iOS8.1] - - Browser [e.g. stock browser, safari] - - Version [e.g. 22] +**Version:** + - OS: (e.g. Windows 10) + - Version or branch: (e.g. 2.8.5, master, ui-files, etc.) **Additional context** Add any other context about the problem here. From 6c9a2234b8ab26ce927396b4247344fd93fca4f2 Mon Sep 17 00:00:00 2001 From: stonedDiscord Date: Mon, 4 Jan 2021 18:54:48 +0100 Subject: [PATCH 54/81] use xcode 12 --- .travis.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.travis.yml b/.travis.yml index 48bc2b5..802ace9 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,5 +1,6 @@ language: cpp os: osx +osx_image: xcode12 addons: homebrew: update: true From 4d02cc8d680f4e069de0dddc8558ff9186153d59 Mon Sep 17 00:00:00 2001 From: Skye Deving <76892045+skyedeving@users.noreply.github.com> Date: Mon, 4 Jan 2021 12:51:27 -0600 Subject: [PATCH 55/81] Use QList::mid when constructing QStringList (#365) The constructor with two iterators is too cutting edge from 5.14 to be widely supported right now --- src/aopacket.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/aopacket.cpp b/src/aopacket.cpp index a989a3a..bb6ac73 100644 --- a/src/aopacket.cpp +++ b/src/aopacket.cpp @@ -5,7 +5,7 @@ AOPacket::AOPacket(QString p_packet_string) QStringList packet_contents = p_packet_string.split("#"); m_header = packet_contents.first(); - m_contents = QStringList(packet_contents.begin()+1, packet_contents.end()-1); // trims % + m_contents = packet_contents.mid(1, packet_contents.size()-2); // trims % } QString AOPacket::to_string() From 6570bcf0662d675cc3f0ed89820fc95efe4cace3 Mon Sep 17 00:00:00 2001 From: Skye Deving <76892045+skyedeving@users.noreply.github.com> Date: Mon, 4 Jan 2021 13:45:18 -0600 Subject: [PATCH 56/81] Fix timestamps when toggling showname On toggling shownames, regenerate_ic_chatlog() gets called to reprint the entire chatlog with append_ic_text(). The issue is that append_ic_text() uses QDateTime::currentDateTime() for the timestamp when it's called. Therefore the fix is adding a new timestamp parameter to the append_ic_text() which we supply from the datetime provided by each chatlogpiece --- include/courtroom.h | 2 +- src/courtroom.cpp | 18 ++++++++++++------ 2 files changed, 13 insertions(+), 7 deletions(-) diff --git a/include/courtroom.h b/include/courtroom.h index f05b15a..9332481 100644 --- a/include/courtroom.h +++ b/include/courtroom.h @@ -225,7 +225,7 @@ public: // selected // or the user isn't already scrolled to the top void append_ic_text(QString p_text, QString p_name = "", QString action = "", - int color = 0); + int color = 0, QDateTime timestamp = {}); // prints who played the song to IC chat and plays said song(if found on local // filesystem) takes in a list where the first element is the song name and diff --git a/src/courtroom.cpp b/src/courtroom.cpp index 9518911..9fda395 100644 --- a/src/courtroom.cpp +++ b/src/courtroom.cpp @@ -2619,7 +2619,7 @@ void Courtroom::log_ic_text(QString p_name, QString p_showname, } void Courtroom::append_ic_text(QString p_text, QString p_name, QString p_action, - int color) + int color, QDateTime timestamp) { QTextCharFormat bold; QTextCharFormat normal; @@ -2645,10 +2645,15 @@ void Courtroom::append_ic_text(QString p_text, QString p_name, QString p_action, } // Timestamp if we're doing that meme - if (log_timestamp) - ui_ic_chatlog->textCursor().insertText( - "[" + QDateTime::currentDateTime().toString("h:mm:ss AP") + "] ", - normal); + if (log_timestamp) { + if (timestamp.isValid()) { + ui_ic_chatlog->textCursor().insertText( + "[" + timestamp.toString("h:mm:ss AP") + "] ", normal); + } else { + ui_ic_chatlog->textCursor().insertText( + "[" + QDateTime::currentDateTime().toString("h:mm:ss AP") + "] ", normal); + } + } // Format the name of the actor ui_ic_chatlog->textCursor().insertText(p_name, bold); @@ -4780,7 +4785,8 @@ void Courtroom::regenerate_ic_chatlog() append_ic_text(item.get_message(), ui_showname_enable->isChecked() ? item.get_showname() : item.get_name(), - item.get_action(), item.get_chat_color()); + item.get_action(), item.get_chat_color(), + item.get_datetime().toLocalTime()); } } From 8aaba6633ec8b3303e0e7f24d42b96f3d5a4a90e Mon Sep 17 00:00:00 2001 From: Skye Deving <76892045+skyedeving@users.noreply.github.com> Date: Mon, 4 Jan 2021 19:21:11 -0600 Subject: [PATCH 57/81] Change default parameter to be QDateTime::currentDateTime() Print debug message if provided timestamp is invalid --- include/courtroom.h | 2 +- src/courtroom.cpp | 3 +-- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/include/courtroom.h b/include/courtroom.h index 9332481..4610130 100644 --- a/include/courtroom.h +++ b/include/courtroom.h @@ -225,7 +225,7 @@ public: // selected // or the user isn't already scrolled to the top void append_ic_text(QString p_text, QString p_name = "", QString action = "", - int color = 0, QDateTime timestamp = {}); + int color = 0, QDateTime timestamp = QDateTime::currentDateTime()); // prints who played the song to IC chat and plays said song(if found on local // filesystem) takes in a list where the first element is the song name and diff --git a/src/courtroom.cpp b/src/courtroom.cpp index 9fda395..5f9d206 100644 --- a/src/courtroom.cpp +++ b/src/courtroom.cpp @@ -2650,8 +2650,7 @@ void Courtroom::append_ic_text(QString p_text, QString p_name, QString p_action, ui_ic_chatlog->textCursor().insertText( "[" + timestamp.toString("h:mm:ss AP") + "] ", normal); } else { - ui_ic_chatlog->textCursor().insertText( - "[" + QDateTime::currentDateTime().toString("h:mm:ss AP") + "] ", normal); + qDebug() << "could not insert invalid timestamp"; } } From 5abc685b47c7ebd9e8713c087f8c4f00d9c27396 Mon Sep 17 00:00:00 2001 From: Skye Deving <76892045+skyedeving@users.noreply.github.com> Date: Mon, 4 Jan 2021 19:49:40 -0600 Subject: [PATCH 58/81] Sort case evidence numerically before adding in inventories get displayed lexigraphically too but it is assumed to not matter --- include/courtroom.h | 1 + src/courtroom.cpp | 10 +++++++++- 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/include/courtroom.h b/include/courtroom.h index f05b15a..4e8d86f 100644 --- a/include/courtroom.h +++ b/include/courtroom.h @@ -58,6 +58,7 @@ #include //#include +#include #include class AOApplication; diff --git a/src/courtroom.cpp b/src/courtroom.cpp index 9518911..bcff915 100644 --- a/src/courtroom.cpp +++ b/src/courtroom.cpp @@ -3588,7 +3588,15 @@ void Courtroom::on_ooc_return_pressed() new AOPacket("DE#" + QString::number(i) + "#%")); } - foreach (QString evi, casefile.childGroups()) { + // sort the case_evidence numerically + QStringList case_evidence = casefile.childGroups(); + std::sort(case_evidence.begin(), case_evidence.end(), + [] (const QString &a, const QString &b) { + return a.toInt() < b.toInt(); + }); + + // load evidence + foreach (QString evi, case_evidence) { if (evi == "General") continue; From 371ca313e60fe07d678f2b8f15eed8f4a28785f5 Mon Sep 17 00:00:00 2001 From: Skye Deving <76892045+skyedeving@users.noreply.github.com> Date: Tue, 5 Jan 2021 12:36:17 -0600 Subject: [PATCH 59/81] Add in support for streaming music with bass --- src/aomusicplayer.cpp | 22 +++++++++++++++++----- src/path_functions.cpp | 3 +++ 2 files changed, 20 insertions(+), 5 deletions(-) diff --git a/src/aomusicplayer.cpp b/src/aomusicplayer.cpp index 6c61b9a..585a7f4 100644 --- a/src/aomusicplayer.cpp +++ b/src/aomusicplayer.cpp @@ -23,14 +23,26 @@ void AOMusicPlayer::play(QString p_song, int channel, bool loop, unsigned int flags = BASS_STREAM_PRESCAN | BASS_STREAM_AUTOFREE | BASS_UNICODE | BASS_ASYNCFILE; - if (loop) + unsigned int streaming_flags = BASS_STREAM_AUTOFREE; + if (loop) { flags |= BASS_SAMPLE_LOOP; + streaming_flags |= BASS_SAMPLE_LOOP; + } DWORD newstream; - if (f_path.endsWith(".opus")) - newstream = BASS_OPUS_StreamCreateFile(FALSE, f_path.utf16(), 0, 0, flags); - else - newstream = BASS_StreamCreateFile(FALSE, f_path.utf16(), 0, 0, flags); + if (f_path.startsWith("http")) { + if (f_path.endsWith(".opus")) + newstream = BASS_OPUS_StreamCreateURL(f_path.toStdString().c_str(), 0, streaming_flags, nullptr, 0); + else + newstream = BASS_StreamCreateURL(f_path.toStdString().c_str(), 0, streaming_flags, nullptr, 0); + + } else { + if (f_path.endsWith(".opus")) + newstream = BASS_OPUS_StreamCreateFile(FALSE, f_path.utf16(), 0, 0, flags); + else + newstream = BASS_StreamCreateFile(FALSE, f_path.utf16(), 0, 0, flags); + } + if (ao_app->get_audio_output_device() != "default") BASS_ChannelSetDevice(m_stream_list[channel], BASS_GetDevice()); diff --git a/src/path_functions.cpp b/src/path_functions.cpp index b1d7976..c6c73a8 100644 --- a/src/path_functions.cpp +++ b/src/path_functions.cpp @@ -73,6 +73,9 @@ QString AOApplication::get_sounds_path(QString p_file) QString AOApplication::get_music_path(QString p_song) { + if (p_song.startsWith("http")) { + return p_song; // url + } QString path = get_base_path() + "sounds/music/" + p_song; return get_case_sensitive_path(path); } From cb19f55a06413a8870927fce1fdea8b77ab498cb Mon Sep 17 00:00:00 2001 From: Skye Deving <76892045+skyedeving@users.noreply.github.com> Date: Wed, 6 Jan 2021 00:59:22 -0600 Subject: [PATCH 60/81] Checking for apng should be lower case --- src/lobby.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/lobby.cpp b/src/lobby.cpp index 79a565a..afbf221 100644 --- a/src/lobby.cpp +++ b/src/lobby.cpp @@ -356,7 +356,7 @@ void Lobby::on_connect_released() void Lobby::on_about_clicked() { - const bool hasApng = QImageReader::supportedImageFormats().contains("APNG"); + const bool hasApng = QImageReader::supportedImageFormats().contains("apng"); QString msg = tr("

Attorney Online %1

" From c4b739292a217bb6a844d3ef4e89b656ab3f2d4b Mon Sep 17 00:00:00 2001 From: oldmud0 Date: Wed, 6 Jan 2021 11:43:31 -0600 Subject: [PATCH 61/81] Use call_error() for character load error message --- src/charselect.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/charselect.cpp b/src/charselect.cpp index 8e0aab5..7356089 100644 --- a/src/charselect.cpp +++ b/src/charselect.cpp @@ -131,7 +131,7 @@ void Courtroom::char_clicked(int n_char) qDebug() << "char_ini_path" << char_ini_path; if (!file_exists(char_ini_path)) { - call_notice("Could not find " + char_ini_path); + call_error("Could not find " + char_ini_path); return; } } From e2c447f1d7ff4ecde4306ecb3ac7d6683660b722 Mon Sep 17 00:00:00 2001 From: Skye Deving <76892045+skyedeving@users.noreply.github.com> Date: Thu, 7 Jan 2021 16:21:56 -0600 Subject: [PATCH 62/81] Set emote format to apng if png supports animation (#379) --- src/aocharmovie.cpp | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/src/aocharmovie.cpp b/src/aocharmovie.cpp index 2fe90b6..09a4b88 100644 --- a/src/aocharmovie.cpp +++ b/src/aocharmovie.cpp @@ -61,6 +61,15 @@ void AOCharMovie::load_image(QString p_char, QString p_emote, return; m_reader->setFileName(emote_path); + + // set format to apng if png supports animation + if (emote_path.endsWith("png")) { + m_reader->setFormat("apng"); + if (!m_reader->supportsAnimation()) { + m_reader->setFormat("png"); + } + } + QPixmap f_pixmap = this->get_pixmap(m_reader->read()); int f_delay = m_reader->nextImageDelay(); From cbf8391a65a3f0dc7816b904261b3e38275ec063 Mon Sep 17 00:00:00 2001 From: Skye Deving <76892045+skyedeving@users.noreply.github.com> Date: Thu, 7 Jan 2021 20:44:58 -0600 Subject: [PATCH 63/81] Add QMenu delete on close attributes (#381) Fixes a minor memory leak with context menu creation. --- src/courtroom.cpp | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/courtroom.cpp b/src/courtroom.cpp index ba13e21..1cd8d31 100644 --- a/src/courtroom.cpp +++ b/src/courtroom.cpp @@ -3856,6 +3856,7 @@ void Courtroom::on_iniswap_context_menu_requested(const QPoint &pos) { QMenu *menu = ui_iniswap_dropdown->lineEdit()->createStandardContextMenu(); + menu->setAttribute(Qt::WA_DeleteOnClose); menu->addSeparator(); if (file_exists(ao_app->get_character_path(current_char, "char.ini"))) menu->addAction(QString("Edit " + current_char + "/char.ini"), this, @@ -3963,6 +3964,7 @@ void Courtroom::on_sfx_context_menu_requested(const QPoint &pos) { QMenu *menu = ui_sfx_dropdown->lineEdit()->createStandardContextMenu(); + menu->setAttribute(Qt::WA_DeleteOnClose); menu->addSeparator(); if (file_exists(ao_app->get_character_path(current_char, "soundlist.ini"))) menu->addAction(QString("Edit " + current_char + "/soundlist.ini"), this, @@ -4050,8 +4052,9 @@ void Courtroom::set_effects_dropdown() void Courtroom::on_effects_context_menu_requested(const QPoint &pos) { - QMenu *menu = new QMenu(); + QMenu *menu = new QMenu(this); + menu->setAttribute(Qt::WA_DeleteOnClose); if (!ao_app->read_char_ini(current_char, "effects", "Options").isEmpty()) menu->addAction( QString("Open misc/" + @@ -4214,7 +4217,8 @@ void Courtroom::on_music_list_double_clicked(QTreeWidgetItem *p_item, void Courtroom::on_music_list_context_menu_requested(const QPoint &pos) { - QMenu *menu = new QMenu(); + QMenu *menu = new QMenu(this); + menu->setAttribute(Qt::WA_DeleteOnClose); menu->addAction(QString(tr("Stop Current Song")), this, SLOT(music_stop())); menu->addAction(QString(tr("Play Random Song")), this, SLOT(music_random())); menu->addSeparator(); From 86fd030ef054f6dc0ececd3b5299e818c4d10927 Mon Sep 17 00:00:00 2001 From: Skye Deving <76892045+skyedeving@users.noreply.github.com> Date: Thu, 7 Jan 2021 23:12:10 -0600 Subject: [PATCH 64/81] Adopt the poor orphaned QWidgets --- src/aooptionsdialog.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/aooptionsdialog.cpp b/src/aooptionsdialog.cpp index 2641d8d..d852eae 100644 --- a/src/aooptionsdialog.cpp +++ b/src/aooptionsdialog.cpp @@ -41,7 +41,7 @@ AOOptionsDialog::AOOptionsDialog(QWidget *parent, AOApplication *p_ao_app) // Let's add the tabs one by one. // First, we'll start with 'Gameplay'. - ui_gameplay_tab = new QWidget(); + ui_gameplay_tab = new QWidget(this); ui_gameplay_tab->setSizePolicy(sizePolicy1); ui_settings_tabs->addTab(ui_gameplay_tab, tr("Gameplay")); ui_form_layout_widget = new QWidget(ui_gameplay_tab); @@ -379,7 +379,7 @@ AOOptionsDialog::AOOptionsDialog(QWidget *parent, AOApplication *p_ao_app) ui_gameplay_tab->show(); // Here we start the callwords tab. - ui_callwords_tab = new QWidget(); + ui_callwords_tab = new QWidget(this); ui_settings_tabs->addTab(ui_callwords_tab, tr("Callwords")); ui_callwords_widget = new QWidget(ui_callwords_tab); @@ -416,7 +416,7 @@ AOOptionsDialog::AOOptionsDialog(QWidget *parent, AOApplication *p_ao_app) ui_callwords_layout->addWidget(ui_callwords_explain_lbl); // The audio tab. - ui_audio_tab = new QWidget(); + ui_audio_tab = new QWidget(this); ui_settings_tabs->addTab(ui_audio_tab, tr("Audio")); ui_audio_widget = new QWidget(ui_audio_tab); @@ -577,7 +577,7 @@ AOOptionsDialog::AOOptionsDialog(QWidget *parent, AOApplication *p_ao_app) ui_audio_layout->setWidget(row, QFormLayout::FieldRole, ui_objectmusic_cb); // The casing tab! - ui_casing_tab = new QWidget(); + ui_casing_tab = new QWidget(this); ui_settings_tabs->addTab(ui_casing_tab, tr("Casing")); ui_casing_widget = new QWidget(ui_casing_tab); From c46ab13c629854377aff767aea8d342c5c5d8014 Mon Sep 17 00:00:00 2001 From: Skye Deving <76892045+skyedeving@users.noreply.github.com> Date: Thu, 7 Jan 2021 23:30:46 -0600 Subject: [PATCH 65/81] Adopt the scroll widget in the options dialog --- src/aooptionsdialog.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/aooptionsdialog.cpp b/src/aooptionsdialog.cpp index d852eae..075e2d0 100644 --- a/src/aooptionsdialog.cpp +++ b/src/aooptionsdialog.cpp @@ -372,7 +372,7 @@ AOOptionsDialog::AOOptionsDialog(QWidget *parent, AOApplication *p_ao_app) ui_gameplay_form->setWidget(row, QFormLayout::FieldRole, ui_customchat_cb); - QScrollArea *scroll = new QScrollArea; + QScrollArea *scroll = new QScrollArea(this); scroll->setWidget(ui_form_layout_widget); ui_gameplay_tab->setLayout(new QVBoxLayout); ui_gameplay_tab->layout()->addWidget(scroll); From df24961c0d45324705fc9f70b2ff03fc490dd777 Mon Sep 17 00:00:00 2001 From: Skye Deving <76892045+skyedeving@users.noreply.github.com> Date: Thu, 7 Jan 2021 23:31:08 -0600 Subject: [PATCH 66/81] Set delete on close attribute for orphaned widgets --- src/debug_functions.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/debug_functions.cpp b/src/debug_functions.cpp index 477eec7..1613a7d 100644 --- a/src/debug_functions.cpp +++ b/src/debug_functions.cpp @@ -9,6 +9,7 @@ void call_error(QString p_message) { QMessageBox *msgBox = new QMessageBox; + msgBox->setAttribute(Qt::WA_DeleteOnClose); msgBox->setText(QCoreApplication::translate("debug_functions", "Error: %1") .arg(p_message)); msgBox->setWindowTitle( @@ -22,6 +23,7 @@ void call_notice(QString p_message) { QMessageBox *msgBox = new QMessageBox; + msgBox->setAttribute(Qt::WA_DeleteOnClose); msgBox->setText(p_message); msgBox->setWindowTitle( QCoreApplication::translate("debug_functions", "Notice")); From 512b7a37de7993eeca16e52ede74a7a07de4cd30 Mon Sep 17 00:00:00 2001 From: Skye Deving <76892045+skyedeving@users.noreply.github.com> Date: Thu, 7 Jan 2021 23:32:00 -0600 Subject: [PATCH 67/81] Adopt the orphaned msgBox's and add delete on close attribute --- src/evidence.cpp | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/src/evidence.cpp b/src/evidence.cpp index a8f5913..b97607b 100644 --- a/src/evidence.cpp +++ b/src/evidence.cpp @@ -258,8 +258,9 @@ void Courtroom::set_evidence_list(QVector &p_evi_list) else if (compare_evidence_changed( old_list.at(current_evidence), local_evidence_list.at(current_evidence))) { - QMessageBox *msgBox = new QMessageBox; + QMessageBox *msgBox = new QMessageBox(this); + msgBox->setAttribute(Qt::WA_DeleteOnClose); msgBox->setText(tr("The piece of evidence you've been editing has changed.")); msgBox->setInformativeText(tr("Do you wish to keep your changes?")); msgBox->setDetailedText(tr( @@ -552,7 +553,8 @@ void Courtroom::on_evidence_x_clicked() evidence_close(); return; } - QMessageBox *msgBox = new QMessageBox; + QMessageBox *msgBox = new QMessageBox(this); + msgBox->setAttribute(Qt::WA_DeleteOnClose); msgBox->setText(tr("Evidence has been modified.")); msgBox->setInformativeText(tr("Do you want to save your changes?")); msgBox->setStandardButtons(QMessageBox::Save | QMessageBox::Discard | @@ -655,7 +657,8 @@ void Courtroom::on_evidence_transfer_clicked() private_evidence_list.append(f_evi); } - QMessageBox *msgBox = new QMessageBox; + QMessageBox *msgBox = new QMessageBox(this); + msgBox->setAttribute(Qt::WA_DeleteOnClose); msgBox->setText(tr("\"%1\" has been transferred.").arg(name)); msgBox->setStandardButtons(QMessageBox::Ok); msgBox->setDefaultButton(QMessageBox::Ok); From 079c45e298e4198b9c6828603a3e9a71b07a08a7 Mon Sep 17 00:00:00 2001 From: in1tiate <32779090+in1tiate@users.noreply.github.com> Date: Sat, 9 Jan 2021 09:09:18 -0600 Subject: [PATCH 68/81] Define IC Log colors independent of character, define message colors according to character (#323) * IC Log colors now defined independent of character * Fix regression causing incorrect colors in the viewport * fix goof that broke chat scrolling * Only regenerate color vector when it's needed --- include/courtroom.h | 11 ++++++++ src/courtroom.cpp | 55 ++++++++++++++++++++++++++----------- src/text_file_functions.cpp | 2 ++ 3 files changed, 52 insertions(+), 16 deletions(-) diff --git a/include/courtroom.h b/include/courtroom.h index eb33fd8..6a00bdc 100644 --- a/include/courtroom.h +++ b/include/courtroom.h @@ -412,6 +412,17 @@ private: // List of associated RGB colors for this color index QVector color_rgb_list; + // Same as above but populated from misc/default's config + QVector default_color_rgb_list; + + // Get a color index from an arbitrary misc config + void gen_char_rgb_list(QString p_char); + QVector char_color_rgb_list; + + // Misc we used for the last message, and the one we're using now. Used to avoid loading assets when it's not needed + QString current_misc; + QString last_misc; + // List of markdown start characters, their index is tied to the color index QStringList color_markdown_start_list; diff --git a/src/courtroom.cpp b/src/courtroom.cpp index 1cd8d31..e1ac8e4 100644 --- a/src/courtroom.cpp +++ b/src/courtroom.cpp @@ -2395,9 +2395,7 @@ QString Courtroom::filter_ic_text(QString p_text, bool html, int target_pos, // If html is enabled, prepare this text to be all ready for it. if (html) { ic_color_stack.push(default_color); - QString appendage = ""; + QString appendage = ""; if (!align.isEmpty()) appendage.prepend("
"); @@ -2516,8 +2514,7 @@ QString Courtroom::filter_ic_text(QString p_text, bool html, int target_pos, if (!ic_color_stack.empty()) appendage += - ""; if (is_end && !skip) { @@ -2683,12 +2680,16 @@ void Courtroom::append_ic_text(QString p_text, QString p_name, QString p_action, else ui_ic_chatlog->textCursor().insertText(": ", normal); // Format the result according to html - if (log_colors) - ui_ic_chatlog->textCursor().insertHtml( - filter_ic_text(p_text, true, -1, color)); + if (log_colors) { + QString p_text_filtered = filter_ic_text(p_text, true, -1, color); + p_text_filtered = p_text_filtered.replace("$c0", ao_app->get_color("ic_chatlog_color", "courtroom_fonts.ini").name(QColor::HexRgb)); + for (int c = 1; c < max_colors; ++c) { + p_text_filtered = p_text_filtered.replace("$c" + QString::number(c), default_color_rgb_list.at(c).name(QColor::HexRgb)); + } + ui_ic_chatlog->textCursor().insertHtml(p_text_filtered); + } else - ui_ic_chatlog->textCursor().insertText(filter_ic_text(p_text, false), - normal); + ui_ic_chatlog->textCursor().insertText(filter_ic_text(p_text, false), normal); } // Only append with newline if log goes upwards @@ -2837,6 +2838,11 @@ void Courtroom::start_chat_ticking() chat_tick_timer->start(0); // Display the first char right away QString f_gender = ao_app->get_gender(m_chatmessage[CHAR_NAME]); + + last_misc = current_misc; + current_misc = ao_app->get_char_shouts(m_chatmessage[CHAR_NAME]); + if (last_misc != current_misc) + gen_char_rgb_list(m_chatmessage[CHAR_NAME]); blip_player->set_blips(f_gender); @@ -2870,9 +2876,11 @@ void Courtroom::chat_tick() ui_vp_chat_arrow->play( "chat_arrow", f_char, f_custom_theme); // Chat stopped being processed, indicate that. - additive_previous = - additive_previous + - filter_ic_text(f_message, true, -1, m_chatmessage[TEXT_COLOR].toInt()); + QString f_message_filtered = filter_ic_text(f_message, true, -1, m_chatmessage[TEXT_COLOR].toInt()); + for (int c = 0; c < max_colors; ++c) { + f_message_filtered = f_message_filtered.replace("$c" + QString::number(c), char_color_rgb_list.at(c).name(QColor::HexRgb)); + } + additive_previous = additive_previous + f_message_filtered; real_tick_pos = ui_vp_message->toPlainText().size(); return; } @@ -2985,9 +2993,11 @@ void Courtroom::chat_tick() else { int msg_delay = message_display_speed[current_display_speed]; // Do the colors, gradual showing, etc. in here - ui_vp_message->setHtml(additive_previous + - filter_ic_text(f_message, true, tick_pos, - m_chatmessage[TEXT_COLOR].toInt())); + 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) { + f_message_filtered = f_message_filtered.replace("$c" + QString::number(c), char_color_rgb_list.at(c).name(QColor::HexRgb)); + } + ui_vp_message->setHtml(additive_previous + f_message_filtered); // This should always be done AFTER setHtml. Scroll the chat window with the // text. @@ -4535,6 +4545,7 @@ void Courtroom::set_text_color_dropdown() // Clear the stored optimization information color_rgb_list.clear(); + default_color_rgb_list.clear(); color_markdown_start_list.clear(); color_markdown_end_list.clear(); color_markdown_remove_list.clear(); @@ -4571,6 +4582,18 @@ void Courtroom::set_text_color_dropdown() ui_text_color->setItemIcon(ui_text_color->count() - 1, QIcon(pixmap)); color_row_to_number.append(c); } + for (int c = 0; c < max_colors; ++c) { + QColor color = ao_app->get_chat_color("c" + QString::number(c), "default"); + default_color_rgb_list.append(color); + } +} + +void Courtroom::gen_char_rgb_list(QString p_char) { + char_color_rgb_list.clear(); + for (int c = 0; c < max_colors; ++c) { + QColor color = ao_app->get_chat_color("c" + QString::number(c), p_char); + char_color_rgb_list.append(color); + } } void Courtroom::on_text_color_changed(int p_color) diff --git a/src/text_file_functions.cpp b/src/text_file_functions.cpp index 8247fd8..00eaa00 100644 --- a/src/text_file_functions.cpp +++ b/src/text_file_functions.cpp @@ -636,6 +636,8 @@ QString AOApplication::get_gender(QString p_char) QString AOApplication::get_chat(QString p_char) { + if (p_char == "default") + return "default"; QString f_result = read_char_ini(p_char, "chat", "Options"); // handling the correct order of chat is a bit complicated, we let the caller From fc4e707381d6524ea3f413b49f486b44daae47b7 Mon Sep 17 00:00:00 2001 From: in1tiate <32779090+in1tiate@users.noreply.github.com> Date: Sat, 9 Jan 2021 09:11:57 -0600 Subject: [PATCH 69/81] Move user-made iniswaps to a global configuration file and make character folder iniswap files immutable (#350) * add default iniswap file * switch to using base/iniswaps.ini for user iniswaps --- src/courtroom.cpp | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/src/courtroom.cpp b/src/courtroom.cpp index e1ac8e4..9b69bd9 100644 --- a/src/courtroom.cpp +++ b/src/courtroom.cpp @@ -697,7 +697,7 @@ void Courtroom::set_widgets() tr("Set an 'iniswap', or an alternative character folder to refer to " "from your current character.\n" "Edit by typing and pressing Enter, [X] to remove. This saves to your " - "base/characters//iniswaps.ini")); + "base/iniswaps.ini")); set_size_and_pos(ui_iniswap_remove, "iniswap_remove"); ui_iniswap_remove->setText("X"); @@ -3814,7 +3814,8 @@ void Courtroom::set_iniswap_dropdown() return; } QStringList iniswaps = ao_app->get_list_file( - ao_app->get_character_path(char_list.at(m_cid).name, "iniswaps.ini")); + ao_app->get_character_path(char_list.at(m_cid).name, "iniswaps.ini")) + ao_app->get_list_file(ao_app->get_base_path() + "iniswaps.ini"); + iniswaps.removeDuplicates(); iniswaps.prepend(char_list.at(m_cid).name); if (iniswaps.size() <= 0) { ui_iniswap_dropdown->hide(); @@ -3844,14 +3845,15 @@ void Courtroom::on_iniswap_dropdown_changed(int p_index) ao_app->set_char_ini(char_list.at(m_cid).name, iniswap, "name", "Options"); QStringList swaplist; + QStringList defswaplist = ao_app->get_list_file(ao_app->get_character_path(char_list.at(m_cid).name, "iniswaps.ini")); for (int i = 0; i < ui_iniswap_dropdown->count(); ++i) { QString entry = ui_iniswap_dropdown->itemText(i); - if (!swaplist.contains(entry) && entry != char_list.at(m_cid).name) + if (!swaplist.contains(entry) && entry != char_list.at(m_cid).name && !defswaplist.contains(entry)) swaplist.append(entry); } ao_app->write_to_file( swaplist.join("\n"), - ao_app->get_character_path(char_list.at(m_cid).name, "iniswaps.ini")); + ao_app->get_base_path() + "iniswaps.ini"); ui_iniswap_dropdown->blockSignals(true); ui_iniswap_dropdown->setCurrentIndex(p_index); ui_iniswap_dropdown->blockSignals(false); From 1da6e37e048572422346a821da21b7249eecf013 Mon Sep 17 00:00:00 2001 From: Crystalwarrior Date: Sat, 9 Jan 2021 18:14:04 +0300 Subject: [PATCH 70/81] Resolve https://github.com/AttorneyOnline/AO2-Client/issues/275 by adding a "Nothing" option to play no SFX even when playing a preanimation that behaves similar to the Default option (#383) --- src/courtroom.cpp | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/src/courtroom.cpp b/src/courtroom.cpp index 9b69bd9..eb05665 100644 --- a/src/courtroom.cpp +++ b/src/courtroom.cpp @@ -1602,7 +1602,7 @@ void Courtroom::on_chat_return_pressed() packet_contents.append(current_side); packet_contents.append(get_char_sfx()); - if (ui_pre->isChecked() && !ao_app->is_stickysounds_enabled()) { + if (ui_pre->isChecked() && !ao_app->is_stickysounds_enabled() && ui_sfx_dropdown->currentIndex() > 1) { ui_sfx_dropdown->blockSignals(true); ui_sfx_dropdown->setCurrentIndex(0); ui_sfx_dropdown->blockSignals(false); @@ -3928,6 +3928,7 @@ void Courtroom::set_sfx_dropdown() ui_sfx_remove->hide(); return; } + soundlist.prepend("Nothing"); soundlist.prepend("Default"); ui_sfx_dropdown->show(); @@ -3942,9 +3943,9 @@ void Courtroom::on_sfx_dropdown_changed(int p_index) ui_ic_chat_message->setFocus(); QStringList soundlist; - for (int i = 0; i < ui_sfx_dropdown->count(); ++i) { + for (int i = 2; i < ui_sfx_dropdown->count(); ++i) { QString entry = ui_sfx_dropdown->itemText(i); - if (!soundlist.contains(entry) && entry != "Default") + if (!soundlist.contains(entry)) soundlist.append(entry); } @@ -3966,7 +3967,7 @@ void Courtroom::on_sfx_dropdown_changed(int p_index) ui_sfx_dropdown->blockSignals(true); ui_sfx_dropdown->setCurrentIndex(p_index); ui_sfx_dropdown->blockSignals(false); - if (p_index != 0) + if (p_index > 1) ui_sfx_remove->show(); else ui_sfx_remove->hide(); @@ -3984,7 +3985,7 @@ void Courtroom::on_sfx_context_menu_requested(const QPoint &pos) else menu->addAction(QString("Edit theme's character_soundlist.ini"), this, SLOT(on_sfx_edit_requested())); - if (ui_sfx_dropdown->currentIndex() != 0) + if (ui_sfx_dropdown->currentIndex() > 1) menu->addAction(QString("Remove " + ui_sfx_dropdown->itemText( ui_sfx_dropdown->currentIndex())), this, SLOT(on_sfx_remove_clicked())); @@ -4012,7 +4013,7 @@ void Courtroom::on_sfx_remove_clicked() // client will crash return; } - if (ui_sfx_dropdown->itemText(ui_sfx_dropdown->currentIndex()) != "Default") { + if (ui_sfx_dropdown->currentIndex() > 1) { ui_sfx_dropdown->removeItem(ui_sfx_dropdown->currentIndex()); on_sfx_dropdown_changed(0); // Reset back to original } @@ -4119,6 +4120,8 @@ bool Courtroom::effects_dropdown_find_and_set(QString effect) QString Courtroom::get_char_sfx() { QString sfx = ui_sfx_dropdown->itemText(ui_sfx_dropdown->currentIndex()); + if (sfx == "Nothing") + return "1"; if (sfx != "" && sfx != "Default") return sfx; return ao_app->get_sfx_name(current_char, current_emote); From 7bac3c9514f2c5b01d0c49f60849d897993765db Mon Sep 17 00:00:00 2001 From: in1tiate <32779090+in1tiate@users.noreply.github.com> Date: Sat, 9 Jan 2021 09:14:56 -0600 Subject: [PATCH 71/81] only play expanded songs, music_random (#376) --- src/courtroom.cpp | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/src/courtroom.cpp b/src/courtroom.cpp index eb05665..9b54941 100644 --- a/src/courtroom.cpp +++ b/src/courtroom.cpp @@ -4295,11 +4295,14 @@ void Courtroom::music_random() QTreeWidgetItemIterator::NotHidden | QTreeWidgetItemIterator::NoChildren); while (*it) { - clist += (*it); + if ((*it)->parent()->isExpanded()) { + clist += (*it); + } ++it; } - int i = qrand() % clist.length(); - on_music_list_double_clicked(clist.at(i), 1); + if (clist.length() == 0) + return; + on_music_list_double_clicked(clist.at(qrand() % clist.length()), 1); } void Courtroom::music_list_expand_all() { ui_music_list->expandAll(); } From 15c3d607c616a6171118cfdd4967e35489c99312 Mon Sep 17 00:00:00 2001 From: in1tiate <32779090+in1tiate@users.noreply.github.com> Date: Sat, 9 Jan 2021 09:17:12 -0600 Subject: [PATCH 72/81] Log objections IC, overhaul custom objections context menu, add more configuration options per-character (#356) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * initial commit * The Quick-Fix is a secondary weapon for the Medic. It is a prototype Medi Gun with a group of three gauges on one side, a (cosmetic) ÜberCharge gauge on the other side, and what appears to be a blender for a body. The main gun is coupled with a medicinal reactor backpack with glowing portions that replaces Medic's default backpack. * fixed settings dialog * slightly less stupid custom objection default Co-authored-by: oldmud0 Co-authored-by: oldmud0 --- include/aoapplication.h | 3 ++ include/aooptionsdialog.h | 2 + include/courtroom.h | 8 ++++ src/aooptionsdialog.cpp | 14 ++++++ src/courtroom.cpp | 94 ++++++++++++++++++++++++++++--------- src/text_file_functions.cpp | 7 +++ 6 files changed, 107 insertions(+), 21 deletions(-) diff --git a/include/aoapplication.h b/include/aoapplication.h index 790b445..3465202 100644 --- a/include/aoapplication.h +++ b/include/aoapplication.h @@ -220,6 +220,9 @@ public: // Returns whether the log should have a timestamp. bool get_log_timestamp(); + // Returns whether to log IC actions. + bool get_log_ic_actions(); + // Returns the username the user may have set in config.ini. QString get_default_username(); diff --git a/include/aooptionsdialog.h b/include/aooptionsdialog.h index fe99626..2e2d7b8 100644 --- a/include/aooptionsdialog.h +++ b/include/aooptionsdialog.h @@ -52,6 +52,8 @@ private: QSpinBox *ui_log_margin_spinbox; QLabel *ui_log_timestamp_lbl; QCheckBox *ui_log_timestamp_cb; + QLabel *ui_log_ic_actions_lbl; + QCheckBox *ui_log_ic_actions_cb; QFrame *ui_log_names_divider; QLineEdit *ui_username_textbox; QLabel *ui_username_lbl; diff --git a/include/courtroom.h b/include/courtroom.h index 6a00bdc..a35d830 100644 --- a/include/courtroom.h +++ b/include/courtroom.h @@ -332,6 +332,9 @@ private: // True, if the log should display the message like name
text instead of name: text bool log_newline = false; + // True, if the log should include RP actions like interjections, showing evidence, etc. + bool log_ic_actions = true; + // Margin in pixels between log entries for the IC log. int log_margin = 0; @@ -398,6 +401,11 @@ private: int objection_state = 0; QString objection_custom = ""; + struct CustomObjection { + QString name; + QString filename; + }; + QList custom_objections_list; int realization_state = 0; int screenshake_state = 0; int text_color = 0; diff --git a/src/aooptionsdialog.cpp b/src/aooptionsdialog.cpp index 075e2d0..314e982 100644 --- a/src/aooptionsdialog.cpp +++ b/src/aooptionsdialog.cpp @@ -163,6 +163,19 @@ AOOptionsDialog::AOOptionsDialog(QWidget *parent, AOApplication *p_ao_app) ui_gameplay_form->setWidget(row, QFormLayout::FieldRole, ui_log_timestamp_cb); + row += 1; + ui_log_ic_actions_lbl = new QLabel(ui_form_layout_widget); + ui_log_ic_actions_lbl->setText(tr("Log IC actions:")); + ui_log_ic_actions_lbl->setToolTip( + tr("If ticked, log will show IC actions such as shouting and presenting evidence.")); + + ui_gameplay_form->setWidget(row, QFormLayout::LabelRole, ui_log_ic_actions_lbl); + + ui_log_ic_actions_cb = new QCheckBox(ui_form_layout_widget); + ui_log_ic_actions_cb->setChecked(p_ao_app->get_log_ic_actions()); + + ui_gameplay_form->setWidget(row, QFormLayout::FieldRole, ui_log_ic_actions_cb); + row += 1; ui_log_names_divider = new QFrame(ui_form_layout_widget); ui_log_names_divider->setFrameShape(QFrame::HLine); @@ -765,6 +778,7 @@ void AOOptionsDialog::save_pressed() configini->setValue("log_newline", ui_log_newline_cb->isChecked()); configini->setValue("log_margin", ui_log_margin_spinbox->value()); configini->setValue("log_timestamp", ui_log_timestamp_cb->isChecked()); + configini->setValue("log_ic_actions", ui_log_ic_actions_cb->isChecked()); configini->setValue("default_username", ui_username_textbox->text()); configini->setValue("show_custom_shownames", ui_showname_cb->isChecked()); configini->setValue("master", ui_ms_textbox->text()); diff --git a/src/courtroom.cpp b/src/courtroom.cpp index 9b54941..b8aa0bd 100644 --- a/src/courtroom.cpp +++ b/src/courtroom.cpp @@ -1300,10 +1300,16 @@ void Courtroom::update_character(int p_cid) if (ao_app->custom_objection_enabled) // if setting is enabled { custom_obj_menu->clear(); + custom_objections_list.clear(); if (file_exists(ao_app->get_image_suffix( ao_app->get_character_path(current_char, "custom")))) { ui_custom_objection->show(); - QAction *action = custom_obj_menu->addAction("Default"); + QString custom_name = ao_app->read_char_ini(f_char, "custom_name", "Shouts"); + QAction *action; + if (custom_name != "") + action = custom_obj_menu->addAction(custom_name); + else + action = custom_obj_menu->addAction("Default"); custom_obj_menu->setDefaultAction(action); objection_custom = ""; } @@ -1318,11 +1324,23 @@ void Courtroom::update_character(int p_cid) << "*.webp", QDir::Files); for (const QString &filename : custom_obj) { - QAction *action = custom_obj_menu->addAction(filename); + CustomObjection custom_objection; + custom_objection.filename = filename; + QString custom_name = ao_app->read_char_ini(f_char, filename.split(".")[0] + "_name", "Shouts"); + QAction *action; + if (custom_name != "") { + custom_objection.name = custom_name; + action = custom_obj_menu->addAction(custom_name); + } + else { + custom_objection.name = filename.split(".")[0]; + action = custom_obj_menu->addAction(filename.split(".")[0]); + } if (custom_obj_menu->defaultAction() == nullptr) { custom_obj_menu->setDefaultAction(action); - objection_custom = action->text(); + objection_custom = custom_objection.filename; } + custom_objections_list.append(custom_objection); } } } @@ -1881,34 +1899,36 @@ void Courtroom::handle_chatmessage(QStringList *p_contents) { m_chatmessage[MESSAGE] = ""; // Turn it into true blankpost } - - if (prev_char_id != f_char_id || !m_chatmessage[MESSAGE].isEmpty() || - ic_chatlog_history.isEmpty() || ic_chatlog_history.last().get_message() != "") { - log_ic_text(f_charname, f_displayname, m_chatmessage[MESSAGE], "", - m_chatmessage[TEXT_COLOR].toInt()); - append_ic_text(m_chatmessage[MESSAGE], f_displayname, "", - m_chatmessage[TEXT_COLOR].toInt()); - } - + QString f_char = m_chatmessage[CHAR_NAME]; QString f_custom_theme = ao_app->get_char_shouts(f_char); // if an objection is used if (objection_mod <= 4 && objection_mod >= 1) { + QString shout_message; switch (objection_mod) { case 1: ui_vp_objection->play("holdit_bubble", f_char, f_custom_theme, 724); objection_player->play("holdit", f_char, f_custom_theme); + shout_message = ao_app->read_char_ini(f_char, "holdit_message", "Shouts"); + if (shout_message == "") + shout_message = tr("HOLD IT!"); break; case 2: ui_vp_objection->play("objection_bubble", f_char, f_custom_theme, 724); objection_player->play("objection", f_char, f_custom_theme); + shout_message = ao_app->read_char_ini(f_char, "objection_message", "Shouts"); + if (shout_message == "") + shout_message = tr("OBJECTION!"); if (ao_app->objection_stop_music()) music_player->stop(); break; case 3: ui_vp_objection->play("takethat_bubble", f_char, f_custom_theme, 724); objection_player->play("takethat", f_char, f_custom_theme); + shout_message = ao_app->read_char_ini(f_char, "takethat_message", "Shouts"); + if (shout_message == "") + shout_message = tr("TAKE THAT!"); break; // case 4 is AO2 only case 4: @@ -1918,19 +1938,36 @@ void Courtroom::handle_chatmessage(QStringList *p_contents) objection_player->play("custom_objections/" + custom_objection.split('.')[0], f_char, f_custom_theme); + shout_message = ao_app->read_char_ini(f_char, custom_objection.split('.')[0] + "_message", "Shouts"); + if (shout_message == "") + shout_message = custom_objection.split('.')[0]; } else { ui_vp_objection->play("custom", f_char, f_custom_theme, shout_stay_time); objection_player->play("custom", f_char, f_custom_theme); + shout_message = ao_app->read_char_ini(f_char, "custom_message", "Shouts"); + if (shout_message == "") + shout_message = tr("CUSTOM OBJECTION!"); } m_chatmessage[EMOTE_MOD] = 1; break; } + log_ic_text(f_char, f_displayname, shout_message, + tr("shouts"),2); + append_ic_text(shout_message, f_displayname, tr("shouts")); sfx_player->clear(); // Objection played! Cut all sfx. } else handle_chatmessage_2(); + + if (!m_chatmessage[MESSAGE].isEmpty() || ic_chatlog_history.isEmpty() || + ic_chatlog_history.last().get_message() != "") { + log_ic_text(f_charname, f_displayname, m_chatmessage[MESSAGE], "", + m_chatmessage[TEXT_COLOR].toInt()); + append_ic_text(m_chatmessage[MESSAGE], f_displayname, "", + m_chatmessage[TEXT_COLOR].toInt()); + } } void Courtroom::objection_done() { handle_chatmessage_2(); } @@ -2294,11 +2331,12 @@ void Courtroom::handle_chatmessage_3() f_side == "jud" || f_side == "jur"); ui_vp_evidence_display->show_evidence(f_image, is_left_side, ui_sfx_slider->value()); - - log_ic_text(m_chatmessage[CHAR_NAME], m_chatmessage[SHOWNAME], f_evi_name, - tr("has presented evidence"), - m_chatmessage[TEXT_COLOR].toInt()); - append_ic_text(f_evi_name, f_showname, tr("has presented evidence")); + if (log_ic_actions) { + log_ic_text(m_chatmessage[CHAR_NAME], m_chatmessage[SHOWNAME], f_evi_name, + tr("has presented evidence"), + m_chatmessage[TEXT_COLOR].toInt()); + append_ic_text(f_evi_name, f_showname, tr("has presented evidence")); + } evidence_presented = true; // we're done presenting evidence, and we // don't want to do it twice } @@ -2657,8 +2695,16 @@ void Courtroom::append_ic_text(QString p_text, QString p_name, QString p_action, if (p_action == tr("has stopped the music")) { ui_ic_chatlog->textCursor().insertText(" " + p_action + ".", normal); } + // Make shout text bold + else if (p_action == tr("shouts") && log_ic_actions) { + ui_ic_chatlog->textCursor().insertText(" " + p_action + " ", normal); + if (log_colors) + ui_ic_chatlog->textCursor().insertHtml("" + filter_ic_text(p_text, true, -1, 0) + ""); + else + ui_ic_chatlog->textCursor().insertText(" " + p_text, italics); + } // If action not blank: - else if (p_action != "") { + else if (p_action != "" && log_ic_actions) { // Format the action in normal ui_ic_chatlog->textCursor().insertText(" " + p_action, normal); if (log_newline) @@ -4424,10 +4470,16 @@ void Courtroom::show_custom_objection_menu(const QPoint &pos) ui_take_that->set_image("takethat"); ui_hold_it->set_image("holdit"); ui_custom_objection->set_image("custom_selected"); - if (selecteditem->text() == "Default") + if (selecteditem->text() == ao_app->read_char_ini(current_char, "custom_name", "Shouts") || selecteditem->text() == "Default") objection_custom = ""; - else - objection_custom = selecteditem->text(); + else { + foreach (CustomObjection custom_objection, custom_objections_list) { + if (custom_objection.name == selecteditem->text()) { + objection_custom = custom_objection.filename; + break; + } + } + } objection_state = 4; custom_obj_menu->setDefaultAction(selecteditem); } diff --git a/src/text_file_functions.cpp b/src/text_file_functions.cpp index 00eaa00..eb0976a 100644 --- a/src/text_file_functions.cpp +++ b/src/text_file_functions.cpp @@ -73,6 +73,13 @@ bool AOApplication::get_log_timestamp() return result.startsWith("true"); } +bool AOApplication::get_log_ic_actions() +{ + QString result = + configini->value("log_ic_actions", "true").value(); + return result.startsWith("true"); +} + bool AOApplication::get_showname_enabled_by_default() { QString result = From 5b09dd45d5f9b3cdef7ceae11780fe1741569a33 Mon Sep 17 00:00:00 2001 From: in1tiate <32779090+in1tiate@users.noreply.github.com> Date: Sat, 9 Jan 2021 09:21:35 -0600 Subject: [PATCH 73/81] Populate non-default background positions from design.ini, allow 2.8-style default positions (#352) * populate pos dropdown from design.ini * add sane default, remove hardcode bs --- src/courtroom.cpp | 78 ++++++++++++++++++++++++++++++----------------- 1 file changed, 50 insertions(+), 28 deletions(-) diff --git a/src/courtroom.cpp b/src/courtroom.cpp index b8aa0bd..0613bad 100644 --- a/src/courtroom.cpp +++ b/src/courtroom.cpp @@ -4,7 +4,8 @@ Courtroom::Courtroom(AOApplication *p_ao_app) : QMainWindow() { ao_app = p_ao_app; - this->setWindowFlags( (this->windowFlags() | Qt::CustomizeWindowHint) & ~Qt::WindowMaximizeButtonHint); + this->setWindowFlags((this->windowFlags() | Qt::CustomizeWindowHint) & + ~Qt::WindowMaximizeButtonHint); ao_app->initBASS(); @@ -594,13 +595,15 @@ void Courtroom::set_widgets() set_size_and_pos(ui_pair_offset_spinbox, "pair_offset_spinbox"); ui_pair_offset_spinbox->hide(); ui_pair_offset_spinbox->setToolTip( - tr("Change the horizontal percentage offset of your character's position from the " + tr("Change the horizontal percentage offset of your character's position " + "from the " "center of the screen.")); - + set_size_and_pos(ui_pair_vert_offset_spinbox, "pair_vert_offset_spinbox"); ui_pair_vert_offset_spinbox->hide(); ui_pair_vert_offset_spinbox->setToolTip( - tr("Change the vertical percentage offset of your character's position from the " + tr("Change the vertical percentage offset of your character's position " + "from the " "center of the screen.")); ui_pair_order_dropdown->hide(); @@ -719,8 +722,7 @@ void Courtroom::set_widgets() set_size_and_pos(ui_sfx_remove, "sfx_remove"); ui_sfx_remove->setText("X"); ui_sfx_remove->set_image("evidencex"); - ui_sfx_remove->setToolTip( - tr("Remove the currently selected sound effect.")); + ui_sfx_remove->setToolTip(tr("Remove the currently selected sound effect.")); ui_sfx_remove->hide(); set_iniswap_dropdown(); @@ -1146,14 +1148,18 @@ void Courtroom::set_background(QString p_background, bool display) // Populate the dropdown list with all pos that exist on this bg QStringList pos_list = {}; for (QString key : default_pos.keys()) { - if (file_exists( - ao_app->get_image_suffix(ao_app->get_background_path(key)))) { + if (file_exists(ao_app->get_image_suffix( + ao_app->get_background_path(default_pos[key]))) || // if we have 2.8-style positions, e.g. def.png, wit.webp, hld.apng + file_exists( + ao_app->get_image_suffix(ao_app->get_background_path(key)))) { // if we have pre-2.8-style positions, e.g. defenseempty.png pos_list.append(default_pos[key]); } } - - // TODO: search through extra/custom pos and add them to the pos dropdown as - // well + for (QString pos : ao_app->read_design_ini("positions", ao_app->get_background_path("design.ini")).split(",")) { + if (file_exists(ao_app->get_image_suffix(ao_app->get_background_path(pos)))) { + pos_list.append(pos); + } + } set_pos_dropdown(pos_list); @@ -2152,7 +2158,8 @@ void Courtroom::handle_chatmessage_2() other_offset_v = other_offsets[1].toInt(); } ui_vp_sideplayer_char->move(ui_viewport->width() * other_offset / 100, - ui_viewport->height() * other_offset_v / 100); + ui_viewport->height() * other_offset_v / + 100); QStringList args = m_chatmessage[OTHER_CHARID].split("^"); if (args.size() > @@ -2196,9 +2203,10 @@ void Courtroom::handle_chatmessage_2() int self_offset_v; if (self_offsets.length() <= 1) self_offset_v = 0; - else + else self_offset_v = self_offsets[1].toInt(); - ui_vp_player_char->move(ui_viewport->width() * self_offset / 100, ui_viewport->height() * self_offset_v / 100); + ui_vp_player_char->move(ui_viewport->width() * self_offset / 100, + ui_viewport->height() * self_offset_v / 100); switch (emote_mod) { case 1: @@ -3069,7 +3077,9 @@ void Courtroom::chat_tick() // 40/25 = 1.6 = 2 // And if it's faster than that: // 40/10 = 4 - b_rate = qMax(b_rate, qRound(static_cast(message_display_speed[3])/msg_delay)); + b_rate = + qMax(b_rate, qRound(static_cast(message_display_speed[3]) / + msg_delay)); } if (blip_ticker % b_rate == 0) { // ignoring white space unless blank_blip is enabled. @@ -3078,8 +3088,7 @@ void Courtroom::chat_tick() ++blip_ticker; } } - else - { + 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. @@ -3088,7 +3097,8 @@ 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 + // Making the user have to wait any longer than 150ms per letter is + // downright unreasonable msg_delay = qMin(150, msg_delay * punctuation_modifier); } @@ -3136,8 +3146,16 @@ void Courtroom::play_sfx() void Courtroom::set_scene(QString f_desk_mod, QString f_side) { // witness is default if pos is invalid - QString f_background = "witnessempty"; - QString f_desk_image = "stand"; + QString f_background; + QString f_desk_image; + if (file_exists(ao_app->get_image_suffix(ao_app->get_background_path("witnessempty")) { + f_background = "witnessempty"; + f_desk_image = "stand"; + } + else { + f_background = "wit"; + f_desk_image = "wit_overlay"; + } if (f_side == "def" && file_exists(ao_app->get_image_suffix( ao_app->get_background_path("defenseempty")))) { @@ -3486,8 +3504,8 @@ void Courtroom::on_ooc_return_pressed() if (ok) { if (off >= -100 && off <= 100) { char_offset = off; - QString msg = tr("You have set your offset to %1%%.") - .arg(QString::number(off)); + QString msg = + tr("You have set your offset to %1%%.").arg(QString::number(off)); append_server_chatmessage("CLIENT", msg, "1"); } else { @@ -3511,17 +3529,18 @@ void Courtroom::on_ooc_return_pressed() if (off >= -100 && off <= 100) { char_vert_offset = off; QString msg = tr("You have set your vertical offset to %1%%.") - .arg(QString::number(off)); + .arg(QString::number(off)); append_server_chatmessage("CLIENT", msg, "1"); } else { append_server_chatmessage( - "CLIENT", tr("Your vertical offset must be between -100% and 100%!"), "1"); + "CLIENT", + tr("Your vertical offset must be between -100% and 100%!"), "1"); } } else { - append_server_chatmessage("CLIENT", - tr("That vertical offset does not look like one."), "1"); + append_server_chatmessage( + "CLIENT", tr("That vertical offset does not look like one."), "1"); } return; } @@ -3832,7 +3851,7 @@ void Courtroom::on_music_search_return_pressed() void Courtroom::on_pos_dropdown_changed(int p_index) { - if (p_index < 0 || p_index > 7) + if (p_index < 0) return; toggle_judge_buttons(false); @@ -4720,7 +4739,10 @@ void Courtroom::on_log_limit_changed(int value) { log_maximum_blocks = value; } void Courtroom::on_pair_offset_changed(int value) { char_offset = value; } -void Courtroom::on_pair_vert_offset_changed(int value) { char_vert_offset = value; } +void Courtroom::on_pair_vert_offset_changed(int value) +{ + char_vert_offset = value; +} void Courtroom::on_witness_testimony_clicked() { From 883fa8547d2d650ab28fcc91169e1d0068760ac9 Mon Sep 17 00:00:00 2001 From: in1tiate <32779090+in1tiate@users.noreply.github.com> Date: Sat, 9 Jan 2021 09:24:06 -0600 Subject: [PATCH 74/81] replace "gender" with "blips" (#386) Co-authored-by: Crystalwarrior --- include/aoapplication.h | 4 ++-- src/courtroom.cpp | 5 ++--- src/text_file_functions.cpp | 11 +++++++---- 3 files changed, 11 insertions(+), 9 deletions(-) diff --git a/include/aoapplication.h b/include/aoapplication.h index 3465202..3325156 100644 --- a/include/aoapplication.h +++ b/include/aoapplication.h @@ -403,8 +403,8 @@ public: // Returns the desk modifier for p_char's p_emote int get_desk_mod(QString p_char, int p_emote); - // Returns p_char's gender - QString get_gender(QString p_char); + // Returns p_char's blips (previously called their "gender") + QString get_blips(QString p_char); // ====== // These are all casing-related settings. diff --git a/src/courtroom.cpp b/src/courtroom.cpp index 0613bad..be7dab1 100644 --- a/src/courtroom.cpp +++ b/src/courtroom.cpp @@ -2891,14 +2891,13 @@ void Courtroom::start_chat_ticking() current_display_speed = 3; chat_tick_timer->start(0); // Display the first char right away - QString f_gender = ao_app->get_gender(m_chatmessage[CHAR_NAME]); - last_misc = current_misc; current_misc = ao_app->get_char_shouts(m_chatmessage[CHAR_NAME]); if (last_misc != current_misc) gen_char_rgb_list(m_chatmessage[CHAR_NAME]); - blip_player->set_blips(f_gender); + QString f_blips = ao_app->get_blips(m_chatmessage[CHAR_NAME]); + blip_player->set_blips(f_blips); // means text is currently ticking text_state = 1; diff --git a/src/text_file_functions.cpp b/src/text_file_functions.cpp index eb0976a..3524d87 100644 --- a/src/text_file_functions.cpp +++ b/src/text_file_functions.cpp @@ -625,12 +625,15 @@ QString AOApplication::get_char_side(QString p_char) return f_result; } -QString AOApplication::get_gender(QString p_char) +QString AOApplication::get_blips(QString p_char) { - QString f_result = read_char_ini(p_char, "gender", "Options"); + QString f_result = read_char_ini(p_char, "blips", "Options"); - if (f_result == "") - f_result = "male"; + if (f_result == "") { + f_result = read_char_ini(p_char, "gender", "Options"); // not very PC, FanatSors + if (f_result == "") + f_result = "male"; + } if (!file_exists(get_sfx_suffix(get_sounds_path(f_result)))) { if (file_exists(get_sfx_suffix(get_sounds_path("../blips/" + f_result)))) From 5b34df1c5a6da97ad426a6cfb4a7c43c03fb0aad Mon Sep 17 00:00:00 2001 From: Crystalwarrior Date: Sat, 9 Jan 2021 18:43:24 +0300 Subject: [PATCH 75/81] Rename noninterrupting_preanim and all its associated bullshit with more cooler and nicer bro immediate In themes, pre_no_interrupt old-style name is still supported if we cannot find "immediate" Resolves https://github.com/AttorneyOnline/AO2-Client/issues/64 --- include/courtroom.h | 4 ++-- include/datatypes.h | 2 +- src/courtroom.cpp | 42 +++++++++++++++++++++++++----------------- 3 files changed, 28 insertions(+), 20 deletions(-) diff --git a/include/courtroom.h b/include/courtroom.h index a35d830..94a115f 100644 --- a/include/courtroom.h +++ b/include/courtroom.h @@ -233,7 +233,7 @@ public: // the second is the char id of who played it void handle_song(QStringList *p_contents); - void play_preanim(bool noninterrupting); + void play_preanim(bool immediate); // plays the witness testimony or cross examination animation based on // argument @@ -607,7 +607,7 @@ private: QCheckBox *ui_guard; QCheckBox *ui_casing; - QCheckBox *ui_pre_non_interrupt; + QCheckBox *ui_immediate; QCheckBox *ui_showname_enable; AOButton *ui_custom_objection; diff --git a/include/datatypes.h b/include/datatypes.h index 21ade04..ebf2e38 100644 --- a/include/datatypes.h +++ b/include/datatypes.h @@ -91,7 +91,7 @@ enum CHAT_MESSAGE { SELF_OFFSET, OTHER_OFFSET, OTHER_FLIP, - NONINTERRUPTING_PRE, + IMMEDIATE, LOOPING_SFX, SCREENSHAKE, FRAME_SCREENSHAKE, diff --git a/src/courtroom.cpp b/src/courtroom.cpp index be7dab1..b59c71d 100644 --- a/src/courtroom.cpp +++ b/src/courtroom.cpp @@ -210,9 +210,9 @@ Courtroom::Courtroom(AOApplication *p_ao_app) : QMainWindow() ui_showname_enable->setChecked(ao_app->get_showname_enabled_by_default()); ui_showname_enable->setText(tr("Shownames")); - ui_pre_non_interrupt = new QCheckBox(this); - ui_pre_non_interrupt->setText(tr("No Interrupt")); - ui_pre_non_interrupt->hide(); + ui_immediate = new QCheckBox(this); + ui_immediate->setText(tr("No Interrupt")); + ui_immediate->hide(); ui_custom_objection = new AOButton(this, ao_app); ui_custom_objection->setContextMenuPolicy(Qt::CustomContextMenu); @@ -477,14 +477,14 @@ void Courtroom::set_widgets() // if needed. if (ao_app->cccc_ic_support_enabled) { ui_pair_button->show(); - ui_pre_non_interrupt->show(); + ui_immediate->show(); ui_showname_enable->show(); ui_ic_chat_name->show(); ui_ic_chat_name->setEnabled(true); } else { ui_pair_button->hide(); - ui_pre_non_interrupt->hide(); + ui_immediate->hide(); ui_showname_enable->hide(); ui_ic_chat_name->hide(); ui_ic_chat_name->setEnabled(false); @@ -839,8 +839,16 @@ void Courtroom::set_widgets() ui_pre->setToolTip( tr("Play a single-shot animation as defined by the emote when checked.")); - set_size_and_pos(ui_pre_non_interrupt, "pre_no_interrupt"); - ui_pre_non_interrupt->setToolTip( + pos_size_type design_ini_result = + ao_app->get_element_dimensions("immediate", "courtroom_design.ini"); + + // If we don't have new-style naming, fall back to the old method + if (design_ini_result.width < 0 || design_ini_result.height < 0) + set_size_and_pos(ui_immediate, "pre_no_interrupt"); + else // Adopt the based new method instead + set_size_and_pos(ui_immediate, "immediate"); + + ui_immediate->setToolTip( tr("If preanim is checked, display the input text immediately as the " "animation plays concurrently.")); @@ -1597,7 +1605,7 @@ void Courtroom::on_chat_return_pressed() // showname# // other_charid# // self_offset# - // noninterrupting_preanim#% + // immediate_preanim#% QStringList packet_contents; @@ -1642,7 +1650,7 @@ void Courtroom::on_chat_return_pressed() else f_emote_mod = 2; } - else if (ui_pre->isChecked() && !ui_pre_non_interrupt->isChecked()) { + else if (ui_pre->isChecked() && !ui_immediate->isChecked()) { if (f_emote_mod == 0) f_emote_mod = 1; else if (f_emote_mod == 5 && ao_app->prezoom_enabled) @@ -1738,7 +1746,7 @@ void Courtroom::on_chat_return_pressed() packet_contents.append(QString::number(char_offset)); // Finally, we send over if we want our pres to not interrupt. - if (ui_pre_non_interrupt->isChecked() && ui_pre->isChecked()) { + if (ui_immediate->isChecked() && ui_pre->isChecked()) { packet_contents.append("1"); } else { @@ -2216,7 +2224,7 @@ void Courtroom::handle_chatmessage_2() break; case 0: case 5: - if (m_chatmessage[NONINTERRUPTING_PRE].toInt() == 0) + if (m_chatmessage[IMMEDIATE].toInt() == 0) handle_chatmessage_3(); else play_preanim(true); @@ -2782,7 +2790,7 @@ void Courtroom::append_ic_text(QString p_text, QString p_name, QString p_action, } } -void Courtroom::play_preanim(bool noninterrupting) +void Courtroom::play_preanim(bool immediate) { QString f_char = m_chatmessage[CHAR_NAME]; QString f_preanim = m_chatmessage[PRE_EMOTE]; @@ -2804,7 +2812,7 @@ void Courtroom::play_preanim(bool noninterrupting) QString anim_to_find = ao_app->get_image_suffix(ao_app->get_character_path(f_char, f_preanim)); if (!file_exists(anim_to_find)) { - if (noninterrupting) + if (immediate) anim_state = 4; else anim_state = 1; @@ -2815,7 +2823,7 @@ void Courtroom::play_preanim(bool noninterrupting) ui_vp_player_char->play_pre(f_char, f_preanim, preanim_duration); - if (noninterrupting) + if (immediate) anim_state = 4; else anim_state = 1; @@ -2823,7 +2831,7 @@ void Courtroom::play_preanim(bool noninterrupting) if (text_delay >= 0) text_delay_timer->start(text_delay); - if (noninterrupting) + if (immediate) handle_chatmessage_3(); } @@ -3564,13 +3572,13 @@ void Courtroom::on_ooc_return_pressed() return; } else if (ooc_message.startsWith("/non_int_pre")) { - if (ui_pre_non_interrupt->isChecked()) + if (ui_immediate->isChecked()) append_server_chatmessage( "CLIENT", tr("Your pre-animations interrupt again."), "1"); else append_server_chatmessage( "CLIENT", tr("Your pre-animations will not interrupt text."), "1"); - ui_pre_non_interrupt->setChecked(!ui_pre_non_interrupt->isChecked()); + ui_immediate->setChecked(!ui_immediate->isChecked()); ui_ooc_chat_message->clear(); return; } From 05dd086fff26f951de41702df19d74767c8f711c Mon Sep 17 00:00:00 2001 From: Skye Deving <76892045+skyedeving@users.noreply.github.com> Date: Sat, 9 Jan 2021 11:59:51 -0600 Subject: [PATCH 76/81] Fix segfault in server list without a server selection (#374) Also bumps C++ version to C++17 (C++1z). --- Attorney_Online.pro | 2 +- src/lobby.cpp | 17 ++++++++++------- 2 files changed, 11 insertions(+), 8 deletions(-) diff --git a/Attorney_Online.pro b/Attorney_Online.pro index 1a5f214..5ee3f40 100644 --- a/Attorney_Online.pro +++ b/Attorney_Online.pro @@ -35,7 +35,7 @@ LIBS += -lbassopus macx:LIBS += -framework CoreFoundation -framework Foundation -framework CoreServices -CONFIG += c++14 +CONFIG += c++17 RESOURCES += resources.qrc diff --git a/src/lobby.cpp b/src/lobby.cpp index afbf221..954c30a 100644 --- a/src/lobby.cpp +++ b/src/lobby.cpp @@ -283,7 +283,10 @@ QString Lobby::get_chatlog() int Lobby::get_selected_server() { - return ui_server_list->currentItem()->text(0).toInt(); + if (auto item = ui_server_list->currentItem()) { + return item->text(0).toInt(); + } + return -1; } void Lobby::set_loading_value(int p_value) @@ -333,12 +336,12 @@ void Lobby::on_add_to_fav_pressed() void Lobby::on_add_to_fav_released() { ui_add_to_fav->set_image("addtofav"); - - // you cant add favorites from favorites m8 - if (!public_servers_selected) - return; - - ao_app->add_favorite_server(get_selected_server()); + if (public_servers_selected) { + int selection = get_selected_server(); + if (selection > -1) { + ao_app->add_favorite_server(selection); + } + } } void Lobby::on_connect_pressed() { ui_connect->set_image("connect_pressed"); } From 10fb54db61c1b00a60985f5cc1b6499c06acceea Mon Sep 17 00:00:00 2001 From: in1tiate <32779090+in1tiate@users.noreply.github.com> Date: Sat, 9 Jan 2021 12:00:26 -0600 Subject: [PATCH 77/81] correct my widdle fucky wucky (#390) --- src/courtroom.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/courtroom.cpp b/src/courtroom.cpp index be7dab1..b3aaa62 100644 --- a/src/courtroom.cpp +++ b/src/courtroom.cpp @@ -3147,7 +3147,7 @@ void Courtroom::set_scene(QString f_desk_mod, QString f_side) // witness is default if pos is invalid QString f_background; QString f_desk_image; - if (file_exists(ao_app->get_image_suffix(ao_app->get_background_path("witnessempty")) { + if (file_exists(ao_app->get_image_suffix(ao_app->get_background_path("witnessempty")))) { f_background = "witnessempty"; f_desk_image = "stand"; } From 3993ba47e5f801d603b5da973d5e5e57eba14b0b Mon Sep 17 00:00:00 2001 From: in1tiate <32779090+in1tiate@users.noreply.github.com> Date: Sat, 9 Jan 2021 12:32:24 -0600 Subject: [PATCH 78/81] Add desk_mods 2 -5 for more flexibility in emotes (#353) --- include/aoapplication.h | 1 + include/courtroom.h | 3 +++ src/courtroom.cpp | 53 +++++++++++++++++++++++++++++++++++-- src/packet_distribution.cpp | 3 +++ 4 files changed, 58 insertions(+), 2 deletions(-) diff --git a/include/aoapplication.h b/include/aoapplication.h index 3325156..a0121f2 100644 --- a/include/aoapplication.h +++ b/include/aoapplication.h @@ -77,6 +77,7 @@ public: bool additive_enabled = false; bool effects_enabled = false; bool y_offset_enabled = false; + bool expanded_desk_mods_enabled = false; ///////////////loading info/////////////////// diff --git a/include/courtroom.h b/include/courtroom.h index a35d830..d9c843a 100644 --- a/include/courtroom.h +++ b/include/courtroom.h @@ -175,6 +175,9 @@ public: // sets desk and bg based on pos in chatmessage void set_scene(QString f_desk_mod, QString f_side); + // sets ui_vp_player_char according to SELF_OFFSET, only a function bc it's used with desk_mod 4 and 5 + void set_self_offset(QString p_list); + // takes in serverD-formatted IP list as prints a converted version to server // OOC admittedly poorly named void set_ip_list(QString p_list); diff --git a/src/courtroom.cpp b/src/courtroom.cpp index b3aaa62..80c53c3 100644 --- a/src/courtroom.cpp +++ b/src/courtroom.cpp @@ -1609,6 +1609,12 @@ void Courtroom::on_chat_return_pressed() if (ao_app->desk_mod_enabled) { f_desk_mod = QString::number(ao_app->get_desk_mod(current_char, current_emote)); + if (!ao_app->expanded_desk_mods_enabled) { + if (f_desk_mod == "2" || f_desk_mod == "4") + f_desk_mod = "0"; + else if (f_desk_mod == "3" || f_desk_mod == "5") + f_desk_mod = "1"; + } if (f_desk_mod == "-1") f_desk_mod = "chat"; } @@ -2113,8 +2119,6 @@ void Courtroom::handle_chatmessage_2() f_pointsize = chatsize; set_font(ui_vp_message, "", "message", customchar, font_name, f_pointsize); - set_scene(m_chatmessage[DESK_MOD], m_chatmessage[SIDE]); - int emote_mod = m_chatmessage[EMOTE_MOD].toInt(); // Deal with invalid emote modifiers if (emote_mod != 0 && emote_mod != 1 && emote_mod != 2 && emote_mod != 5 && @@ -2208,6 +2212,22 @@ void Courtroom::handle_chatmessage_2() ui_vp_player_char->move(ui_viewport->width() * self_offset / 100, ui_viewport->height() * self_offset_v / 100); + switch(m_chatmessage[DESK_MOD].toInt()) { + case 4: + ui_vp_sideplayer_char->hide(); + ui_vp_player_char->move(0, 0); + [[fallthrough]]; + case 2: + set_scene("0", m_chatmessage[SIDE]); + break; + case 5: + case 3: + set_scene("1", m_chatmessage[SIDE]); + break; + default: + set_scene(m_chatmessage[DESK_MOD], m_chatmessage[SIDE]); + break; + } switch (emote_mod) { case 1: case 2: @@ -2353,6 +2373,24 @@ void Courtroom::handle_chatmessage_3() QString side = m_chatmessage[SIDE]; + switch(m_chatmessage[DESK_MOD].toInt()) { + case 4: + set_self_offset(m_chatmessage[SELF_OFFSET]); + [[fallthrough]]; + case 2: + set_scene("1", m_chatmessage[SIDE]); + break; + case 5: + ui_vp_sideplayer_char->hide(); + ui_vp_player_char->move(0, 0); + [[fallthrough]]; + case 3: + set_scene("0", m_chatmessage[SIDE]); + break; + default: + set_scene(m_chatmessage[DESK_MOD], m_chatmessage[SIDE]); + break; + } if (emote_mod == 5 || emote_mod == 6) { ui_vp_desk->hide(); ui_vp_legacy_desk->hide(); @@ -3219,6 +3257,17 @@ void Courtroom::set_scene(QString f_desk_mod, QString f_side) } } +void Courtroom::set_self_offset(QString p_list) { + QStringList self_offsets = p_list.split("&"); + int self_offset = self_offsets[0].toInt(); + int self_offset_v; + if (self_offsets.length() <= 1) + self_offset_v = 0; + else + self_offset_v = self_offsets[1].toInt(); + ui_vp_player_char->move(ui_viewport->width() * self_offset / 100, ui_viewport->height() * self_offset_v / 100); +} + void Courtroom::set_ip_list(QString p_list) { QString f_list = p_list.replace("|", ":").replace("*", "\n"); diff --git a/src/packet_distribution.cpp b/src/packet_distribution.cpp index 4e2d5ed..7146e6e 100644 --- a/src/packet_distribution.cpp +++ b/src/packet_distribution.cpp @@ -180,6 +180,7 @@ void AOApplication::server_packet_received(AOPacket *p_packet) looping_sfx_support_enabled = false; additive_enabled = false; effects_enabled = false; + expanded_desk_mods_enabled = false; if (f_packet.contains("yellowtext", Qt::CaseInsensitive)) yellow_text_enabled = true; if (f_packet.contains("prezoom", Qt::CaseInsensitive)) @@ -208,6 +209,8 @@ void AOApplication::server_packet_received(AOPacket *p_packet) effects_enabled = true; if (f_packet.contains("y_offset", Qt::CaseInsensitive)) y_offset_enabled = true; + if (f_packet.contains("expanded_desk_mods", Qt::CaseInsensitive)) + expanded_desk_mods_enabled = true; } else if (header == "PN") { if (f_contents.size() < 2) From ee8c6e3df7eaf7317ff241cd6821c61b1eb0c52a Mon Sep 17 00:00:00 2001 From: Skye Deving <76892045+skyedeving@users.noreply.github.com> Date: Sat, 9 Jan 2021 13:41:52 -0600 Subject: [PATCH 79/81] Remove redefinition of variable in same scope (#391) --- src/courtroom.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/courtroom.cpp b/src/courtroom.cpp index ad401bb..4992015 100644 --- a/src/courtroom.cpp +++ b/src/courtroom.cpp @@ -839,8 +839,8 @@ void Courtroom::set_widgets() ui_pre->setToolTip( tr("Play a single-shot animation as defined by the emote when checked.")); - pos_size_type design_ini_result = - ao_app->get_element_dimensions("immediate", "courtroom_design.ini"); + design_ini_result = + ao_app->get_element_dimensions("immediate", "courtroom_design.ini"); // If we don't have new-style naming, fall back to the old method if (design_ini_result.width < 0 || design_ini_result.height < 0) From 3a207dccf0f20f344676ef00ed72c5e268d8c0c4 Mon Sep 17 00:00:00 2001 From: in1tiate Date: Sat, 9 Jan 2021 15:13:19 -0600 Subject: [PATCH 80/81] i barely had to modify this --- include/courtroom.h | 3 ++ src/charselect.cpp | 3 ++ src/courtroom.cpp | 102 ++++++++++++++++++++++++++++++++++++++++---- 3 files changed, 99 insertions(+), 9 deletions(-) diff --git a/include/courtroom.h b/include/courtroom.h index 5fdbbac..cb1c458 100644 --- a/include/courtroom.h +++ b/include/courtroom.h @@ -254,6 +254,9 @@ public: void check_connection_received(); + // Truncates text so it fits within theme-specified boundaries and sets the tooltip to the full string + void truncate_label_text(QWidget* p_widget, QString p_identifier); + ~Courtroom(); private: diff --git a/src/charselect.cpp b/src/charselect.cpp index 1091a7a..33cc517 100644 --- a/src/charselect.cpp +++ b/src/charselect.cpp @@ -62,6 +62,9 @@ void Courtroom::construct_char_select() SLOT(on_char_passworded_clicked())); connect(ui_char_taken, SIGNAL(stateChanged(int)), this, SLOT(on_char_taken_clicked())); + + truncate_label_text(ui_char_taken, "char_taken"); + truncate_label_text(ui_char_passworded, "char_passworded"); } void Courtroom::set_char_select() diff --git a/src/courtroom.cpp b/src/courtroom.cpp index 4992015..acb5420 100644 --- a/src/courtroom.cpp +++ b/src/courtroom.cpp @@ -839,19 +839,23 @@ void Courtroom::set_widgets() ui_pre->setToolTip( tr("Play a single-shot animation as defined by the emote when checked.")); - design_ini_result = - ao_app->get_element_dimensions("immediate", "courtroom_design.ini"); - - // If we don't have new-style naming, fall back to the old method - if (design_ini_result.width < 0 || design_ini_result.height < 0) - set_size_and_pos(ui_immediate, "pre_no_interrupt"); - else // Adopt the based new method instead - set_size_and_pos(ui_immediate, "immediate"); - ui_immediate->setToolTip( tr("If preanim is checked, display the input text immediately as the " "animation plays concurrently.")); + design_ini_result = + ao_app->get_element_dimensions("immediate", "courtroom_design.ini"); + // If we don't have new-style naming, fall back to the old method + if (design_ini_result.width < 0 || design_ini_result.height < 0) { + set_size_and_pos(ui_immediate, "pre_no_interrupt"); + truncate_label_text(ui_immediate, "pre_no_interrupt"); + } + else {// Adopt the based new method instead + set_size_and_pos(ui_immediate, "immediate"); + truncate_label_text(ui_immediate, "immediate"); + } + + set_size_and_pos(ui_flip, "flip"); ui_flip->setToolTip(tr("Mirror your character's emotes when checked.")); @@ -946,6 +950,17 @@ void Courtroom::set_widgets() ui_spectator->setToolTip(tr("Become a spectator. You won't be able to " "interact with the in-character screen.")); + // QCheckBox + truncate_label_text(ui_guard, "guard"); + truncate_label_text(ui_pre, "pre"); + truncate_label_text(ui_flip, "flip"); + truncate_label_text(ui_showname_enable, "showname_enable"); + + // QLabel + truncate_label_text(ui_music_label, "music_label"); + truncate_label_text(ui_sfx_label, "sfx_label"); + truncate_label_text(ui_blip_label, "blip_label"); + free_brush = QBrush(ao_app->get_color("area_free_color", "courtroom_design.ini")); lfp_brush = @@ -5033,6 +5048,75 @@ void Courtroom::announce_case(QString title, bool def, bool pro, bool jud, } } +void Courtroom::truncate_label_text(QWidget *p_widget, QString p_identifier) +{ + // Get the pixel width of the string if it were p_widget's label + QString filename = "courtroom_design.ini"; + // Get the width of the element as defined by the current theme + pos_size_type design_ini_result = + ao_app->get_element_dimensions(p_identifier, filename); + + QLabel *p_label = qobject_cast(p_widget); + QCheckBox *p_checkbox = qobject_cast(p_widget); + + if (p_checkbox == nullptr && + p_label == + nullptr) { // i.e. the given p_widget isn't a QLabel or a QCheckBox + qWarning() << "W: Tried to truncate an unsupported widget:" << p_identifier; + return; + } + + QString label_text_tr = + QCoreApplication::translate(p_widget->metaObject()->className(), "%1") + .arg((p_label != nullptr ? p_label->text() : p_checkbox->text())); + int label_theme_width = + (p_label != nullptr + ? design_ini_result.width + : design_ini_result.width - + 18); // 18 is the width of a checkbox on win10 + 5px of + // padding, should probably try to fetch the actual size + int label_px_width = + p_widget->fontMetrics().boundingRect(label_text_tr).width(); + p_widget->setToolTip(label_text_tr + "\n" + p_widget->toolTip()); + // qInfo() << "I: Width of label text: " << label_px_width << "px. Theme's + // width: " << label_theme_width << "px."; + + // we can't do much with a 0-width widget, and there's no need to truncate if + // the theme gives us enough space + if (label_theme_width <= 0 || label_px_width < label_theme_width) { + qInfo() << "I: Truncation aborted for label text " << label_text_tr + << ", either theme width <= 0 or label width < theme width."; + return; + } + + QString truncated_label = label_text_tr; + int truncated_px_width = label_px_width; + while (truncated_px_width > label_theme_width && truncated_label != "…") { + truncated_label.chop(2); + truncated_label.append("…"); + // qInfo() << "I: Attempted to truncate label to string: " << + // truncated_label; + truncated_px_width = + p_widget->fontMetrics().boundingRect(truncated_label).width(); + } + if (truncated_label == "…") { + // Safeguard against edge case where label text is shorter in px than '…', + // causing an infinite loop. Additionally, having just an ellipse for a + // label looks strange, so we don't set the new label. + qWarning() << "W: Potential infinite loop prevented: Label text " + << label_text_tr + << "truncated to '…', so truncation was aborted."; + return; + } + if (p_label != nullptr) + p_label->setText(truncated_label); + else if (p_checkbox != nullptr) + p_checkbox->setText(truncated_label); + qInfo() << "I: Truncated label text from " << label_text_tr << " (" + << label_px_width << "px ) to " << truncated_label << " (" + << truncated_px_width << "px )"; +} + Courtroom::~Courtroom() { delete music_player; From 057353e9f6b1aab950fdb746bedeb34f1a579de6 Mon Sep 17 00:00:00 2001 From: in1tiate Date: Sat, 9 Jan 2021 15:19:50 -0600 Subject: [PATCH 81/81] more comments --- src/courtroom.cpp | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/courtroom.cpp b/src/courtroom.cpp index acb5420..0f807c3 100644 --- a/src/courtroom.cpp +++ b/src/courtroom.cpp @@ -5050,12 +5050,12 @@ void Courtroom::announce_case(QString title, bool def, bool pro, bool jud, void Courtroom::truncate_label_text(QWidget *p_widget, QString p_identifier) { - // Get the pixel width of the string if it were p_widget's label QString filename = "courtroom_design.ini"; - // Get the width of the element as defined by the current theme pos_size_type design_ini_result = ao_app->get_element_dimensions(p_identifier, filename); + // Get the width of the element as defined by the current theme + // Cast to make sure we're working with one of the two supported widget types QLabel *p_label = qobject_cast(p_widget); QCheckBox *p_checkbox = qobject_cast(p_widget); @@ -5065,7 +5065,7 @@ void Courtroom::truncate_label_text(QWidget *p_widget, QString p_identifier) qWarning() << "W: Tried to truncate an unsupported widget:" << p_identifier; return; } - + // translate the text for the widget we're working with so we truncate the right string QString label_text_tr = QCoreApplication::translate(p_widget->metaObject()->className(), "%1") .arg((p_label != nullptr ? p_label->text() : p_checkbox->text())); @@ -5074,9 +5074,9 @@ void Courtroom::truncate_label_text(QWidget *p_widget, QString p_identifier) ? design_ini_result.width : design_ini_result.width - 18); // 18 is the width of a checkbox on win10 + 5px of - // padding, should probably try to fetch the actual size + // padding, TODO: fetch the actual size int label_px_width = - p_widget->fontMetrics().boundingRect(label_text_tr).width(); + p_widget->fontMetrics().boundingRect(label_text_tr).width(); // pixel width of our translated text p_widget->setToolTip(label_text_tr + "\n" + p_widget->toolTip()); // qInfo() << "I: Width of label text: " << label_px_width << "px. Theme's // width: " << label_theme_width << "px.";