From 5063880530c98d17e6d15a888f7c4a8462351e52 Mon Sep 17 00:00:00 2001 From: Crystalwarrior Date: Tue, 16 Feb 2021 11:04:07 +0300 Subject: [PATCH 01/17] Patch a segfault by play_frame_effect being wacky Split behavior for courtroom resizing into its own function Use that function to optimize character changing screen Fix reload theme breaking the background positioning Fix changing character breaking the background positioning Fix excessive set_widgets() calls that caused unnecessary lag Fix unnecessary set_size_and_pos calls that didn't need to be there Only call size_and_pos on the chatbox in the initialize_chatbox func Remove checks for a boolean that will always be true Simplify two functions that copy-paste code called set_size_and_pos into a single one Fix "disable custom chat" setting not being used when setting chat sizes and pos --- include/courtroom.h | 14 ++--- src/aolayer.cpp | 4 ++ src/charselect.cpp | 3 +- src/courtroom.cpp | 121 +++++++++++------------------------- src/packet_distribution.cpp | 4 +- 5 files changed, 51 insertions(+), 95 deletions(-) diff --git a/include/courtroom.h b/include/courtroom.h index eb1aa7b..69dd58e 100644 --- a/include/courtroom.h +++ b/include/courtroom.h @@ -121,6 +121,9 @@ public: void character_loading_finished(); + // + void set_courtroom_size(); + // sets position of widgets based on theme ini files void set_widgets(); @@ -147,11 +150,8 @@ public: void set_window_title(QString p_title); - // reads theme inis and sets size and pos based on the identifier - void set_size_and_pos(QWidget *p_widget, QString p_identifier); - - // reads theme and char inis and sets size and pos based on the identifier - void set_size_and_pos(QWidget *p_widget, QString p_identifier, QString p_char); + // reads theme and sets size and pos based on the identifier (using p_misc if provided) + void set_size_and_pos(QWidget *p_widget, QString p_identifier, QString p_misc=""); // reads theme inis and returns the size and pos as defined by it QPoint get_theme_pos(QString p_identifier); @@ -576,10 +576,6 @@ private: int evidence_rows = 3; int max_evidence_on_page = 18; - // is set to true if the bg folder contains defensedesk.png, - // prosecutiondesk.png and stand.png - bool is_ao2_bg = false; - // whether the ooc chat is server or master chat, true is server bool server_ooc = true; diff --git a/src/aolayer.cpp b/src/aolayer.cpp index e766495..8d2c796 100644 --- a/src/aolayer.cpp +++ b/src/aolayer.cpp @@ -450,6 +450,10 @@ void CharLayer::load_network_effects() void CharLayer::play_frame_effect(int p_frame) { + if (p_frame >= movie_effects.size()) { + qDebug() << "W: Attempted to play a frame effect bigger than the size of movie_effects"; + return; + } if (p_frame < max_frames) { foreach (QString effect, movie_effects[p_frame]) { if (effect == "shake") { diff --git a/src/charselect.cpp b/src/charselect.cpp index 4f3ba99..510d8c0 100644 --- a/src/charselect.cpp +++ b/src/charselect.cpp @@ -177,7 +177,8 @@ void Courtroom::char_clicked(int n_char) } else { update_character(n_char); - set_widgets(); // so we don't erroneously keep the charselect's fixedSize + enter_courtroom(); + set_courtroom_size(); } if (n_char != -1) diff --git a/src/courtroom.cpp b/src/courtroom.cpp index b9ca070..3d67def 100644 --- a/src/courtroom.cpp +++ b/src/courtroom.cpp @@ -437,6 +437,28 @@ Courtroom::Courtroom(AOApplication *p_ao_app) : QMainWindow() set_char_select(); } +void Courtroom::set_courtroom_size() +{ + QString filename = "courtroom_design.ini"; + pos_size_type f_courtroom = + ao_app->get_element_dimensions("courtroom", filename); + + if (f_courtroom.width < 0 || f_courtroom.height < 0) { + qDebug() << "W: did not find courtroom width or height in " << filename; + + this->setFixedSize(714, 668); + } + else { + m_courtroom_width = f_courtroom.width; + m_courtroom_height = f_courtroom.height; + + this->setFixedSize(f_courtroom.width, f_courtroom.height); + } + ui_background->move(0, 0); + ui_background->resize(m_courtroom_width, m_courtroom_height); + ui_background->set_image("courtroombackground"); +} + void Courtroom::set_mute_list() { mute_map.clear(); @@ -480,27 +502,7 @@ void Courtroom::set_widgets() QSettings settings(ao_app->get_theme_path(filename, ao_app->current_theme), QSettings::IniFormat); ao_app->default_theme = settings.value("default_theme", "default").toString(); - pos_size_type f_courtroom = - ao_app->get_element_dimensions("courtroom", filename); - - if (f_courtroom.width < 0 || f_courtroom.height < 0) { - qDebug() << "W: did not find courtroom width or height in " << filename; - - this->setFixedSize(714, 668); - } - else { - m_courtroom_width = f_courtroom.width; - m_courtroom_height = f_courtroom.height; - - this->setFixedSize(f_courtroom.width, f_courtroom.height); - } - set_fonts(); - - ui_background->move(0, 0); - ui_background->resize(m_courtroom_width, m_courtroom_height); - ui_background->set_image("courtroombackground"); - set_size_and_pos(ui_viewport, "viewport"); // If there is a point to it, show all CCCC features. @@ -680,17 +682,8 @@ void Courtroom::set_widgets() for (int i = 0; i < max_clocks; i++) { set_size_and_pos(ui_clock[i], "clock_" + QString::number(i)); } - - if (is_ao2_bg) { - set_size_and_pos(ui_ic_chat_message, "ao2_ic_chat_message"); - // set_size_and_pos(ui_vp_chatbox, "ao2_chatbox"); - set_size_and_pos(ui_ic_chat_name, "ao2_ic_chat_name"); - } - else { - set_size_and_pos(ui_ic_chat_message, "ic_chat_message"); - // set_size_and_pos(ui_vp_chatbox, "chatbox"); - set_size_and_pos(ui_ic_chat_name, "ic_chat_name"); - } + set_size_and_pos(ui_ic_chat_message, "ao2_ic_chat_message"); + set_size_and_pos(ui_ic_chat_name, "ao2_ic_chat_name"); ui_ic_chat_message->setStyleSheet( "QLineEdit{background-color: rgba(100, 100, 100, 255);}"); @@ -1137,30 +1130,12 @@ void Courtroom::set_window_title(QString p_title) this->setWindowTitle(p_title); } -void Courtroom::set_size_and_pos(QWidget *p_widget, QString p_identifier) +void Courtroom::set_size_and_pos(QWidget *p_widget, QString p_identifier, QString p_misc) { QString filename = "courtroom_design.ini"; pos_size_type design_ini_result = - ao_app->get_element_dimensions(p_identifier, filename); - - if (design_ini_result.width < 0 || design_ini_result.height < 0) { - qDebug() << "W: could not find \"" << p_identifier << "\" in " << filename; - p_widget->hide(); - } - else { - p_widget->move(design_ini_result.x, design_ini_result.y); - p_widget->resize(design_ini_result.width, design_ini_result.height); - } -} - -void Courtroom::set_size_and_pos(QWidget *p_widget, QString p_identifier, - QString p_char) -{ - QString filename = "courtroom_design.ini"; - - pos_size_type design_ini_result = - ao_app->get_element_dimensions(p_identifier, filename, ao_app->get_chat(p_char)); + ao_app->get_element_dimensions(p_identifier, filename, p_misc); if (design_ini_result.width < 0 || design_ini_result.height < 0) { qDebug() << "W: could not find \"" << p_identifier << "\" in " << filename; @@ -1268,17 +1243,6 @@ void Courtroom::set_background(QString p_background, bool display) set_pos_dropdown(pos_list); - is_ao2_bg = true; - - if (is_ao2_bg) { - // set_size_and_pos(ui_vp_chatbox, "ao2_chatbox"); - set_size_and_pos(ui_ic_chat_message, "ao2_ic_chat_message"); - } - else { - // set_size_and_pos(ui_vp_chatbox, "chatbox"); - set_size_and_pos(ui_ic_chat_message, "ic_chat_message"); - } - if (display) { ui_vp_speedlines->stop(); ui_vp_player_char->stop(); @@ -1461,12 +1425,6 @@ void Courtroom::update_character(int p_cid) } } } - if (is_ao2_bg) { - set_size_and_pos(ui_vp_chatbox, "ao2_chatbox", f_char); - } - else { - set_size_and_pos(ui_vp_chatbox, "chatbox", f_char); - } if (m_cid != -1) // there is no name at char_list -1, and we crash if we try // to find one @@ -1483,8 +1441,6 @@ void Courtroom::update_character(int p_cid) void Courtroom::enter_courtroom() { - set_widgets(); - current_evidence_page = 0; current_evidence = 0; @@ -2546,23 +2502,18 @@ void Courtroom::initialize_chatbox() else { ui_vp_showname->setText(m_chatmessage[SHOWNAME]); } - - if (is_ao2_bg) { - set_size_and_pos(ui_vp_chatbox, "ao2_chatbox", m_chatmessage[CHAR_NAME]); - } - else { - set_size_and_pos(ui_vp_chatbox, "chatbox", m_chatmessage[CHAR_NAME]); - } - set_size_and_pos(ui_vp_showname, "showname", m_chatmessage[CHAR_NAME]); - set_size_and_pos(ui_vp_message, "message", m_chatmessage[CHAR_NAME]); - ui_vp_message->move(ui_vp_message->x() + ui_vp_chatbox->x(), - ui_vp_message->y() + ui_vp_chatbox->y()); - ui_vp_message->setTextInteractionFlags(Qt::NoTextInteraction); - QString customchar; if (ao_app->is_customchat_enabled()) customchar = m_chatmessage[CHAR_NAME]; QString p_misc = ao_app->get_chat(customchar); + + set_size_and_pos(ui_vp_chatbox, "ao2_chatbox", p_misc); + set_size_and_pos(ui_vp_showname, "showname", p_misc); + set_size_and_pos(ui_vp_message, "message", p_misc); + ui_vp_message->move(ui_vp_message->x() + ui_vp_chatbox->x(), + ui_vp_message->y() + ui_vp_chatbox->y()); + ui_vp_message->setTextInteractionFlags(Qt::NoTextInteraction); + if (ui_vp_showname->text().trimmed().isEmpty()) // Whitespace showname { ui_vp_chatbox->set_image("chatblank", p_misc); @@ -5264,8 +5215,10 @@ void Courtroom::on_reload_theme_clicked() { ao_app->reload_theme(); - enter_courtroom(); + set_courtroom_size(); + set_widgets(); update_character(m_cid); + enter_courtroom(); anim_state = 4; text_state = 3; diff --git a/src/packet_distribution.cpp b/src/packet_distribution.cpp index 1c88120..1053c20 100644 --- a/src/packet_distribution.cpp +++ b/src/packet_distribution.cpp @@ -493,8 +493,10 @@ void AOApplication::server_packet_received(AOPacket *p_packet) w_courtroom->enter_courtroom(); - if (courtroom_constructed) + if (courtroom_constructed) { + w_courtroom->set_courtroom_size(); w_courtroom->update_character(f_contents.at(2).toInt()); + } } else if (header == "MS") { if (courtroom_constructed && courtroom_loaded) From 63128fea1362b0fe2388ff0b85b9f1120806b332 Mon Sep 17 00:00:00 2001 From: Crystalwarrior Date: Tue, 16 Feb 2021 11:20:54 +0300 Subject: [PATCH 02/17] Stop supporting the DRO way (we will make a .bat file or utility that does it for you automatically instead!) Add an option to enable/disable stickers Make stickers actually respect the custom chatbox setting properly --- include/aoapplication.h | 3 +++ include/aooptionsdialog.h | 3 +++ src/aolayer.cpp | 7 +++---- src/aooptionsdialog.cpp | 14 ++++++++++++++ src/courtroom.cpp | 3 ++- src/text_file_functions.cpp | 6 ++++++ 6 files changed, 31 insertions(+), 5 deletions(-) diff --git a/include/aoapplication.h b/include/aoapplication.h index cd9f736..2dc8649 100644 --- a/include/aoapplication.h +++ b/include/aoapplication.h @@ -228,6 +228,9 @@ public: // for settings. bool is_customchat_enabled(); + // Returns the value of characer sticker (avatar) setting + bool is_sticker_enabled(); + // Returns the value of whether continuous playback should be used // from the config.ini. bool is_continuous_enabled(); diff --git a/include/aooptionsdialog.h b/include/aooptionsdialog.h index 31f3d66..e88ce54 100644 --- a/include/aooptionsdialog.h +++ b/include/aooptionsdialog.h @@ -108,6 +108,9 @@ private: QLabel *ui_customchat_lbl; QCheckBox *ui_customchat_cb; + QLabel *ui_sticker_lbl; + QCheckBox *ui_sticker_cb; + QLabel *ui_continuous_lbl; QCheckBox *ui_continuous_cb; diff --git a/src/aolayer.cpp b/src/aolayer.cpp index 8d2c796..e2a1f07 100644 --- a/src/aolayer.cpp +++ b/src/aolayer.cpp @@ -240,12 +240,11 @@ void InterfaceLayer::load_image(QString p_filename, QString p_miscname) void StickerLayer::load_image(QString p_charname) { - QString p_miscname = ao_app->get_chat(p_charname); + QString p_miscname; + if (ao_app->is_customchat_enabled()) + p_miscname = ao_app->get_chat(p_charname); transform_mode = ao_app->get_misc_scaling(p_miscname); QString final_image = ao_app->get_image("sticker/" + p_charname, ao_app->current_theme, ao_app->get_subtheme(), ao_app->default_theme, p_miscname); - if (!file_exists((final_image))) - final_image = ao_app->get_image_suffix( - ao_app->get_character_path(p_charname, "showname")), // Scuffed DRO way start_playback(final_image); } diff --git a/src/aooptionsdialog.cpp b/src/aooptionsdialog.cpp index dfd8555..5817d96 100644 --- a/src/aooptionsdialog.cpp +++ b/src/aooptionsdialog.cpp @@ -485,6 +485,19 @@ AOOptionsDialog::AOOptionsDialog(QWidget *parent, AOApplication *p_ao_app) ui_gameplay_form->setWidget(row, QFormLayout::FieldRole, ui_customchat_cb); + row += 1; + ui_sticker_lbl = new QLabel(ui_form_layout_widget); + ui_sticker_lbl->setText(tr("Stickers:")); + ui_sticker_lbl->setToolTip( + tr("Turn this on to allow characters to define their own " + "stickers (unique images that show up over the chatbox - like avatars or shownames).")); + + ui_gameplay_form->setWidget(row, QFormLayout::LabelRole, ui_sticker_lbl); + + ui_sticker_cb = new QCheckBox(ui_form_layout_widget); + + ui_gameplay_form->setWidget(row, QFormLayout::FieldRole, ui_sticker_cb); + row += 1; ui_continuous_lbl = new QLabel(ui_form_layout_widget); ui_continuous_lbl->setText(tr("Continuous Playback:")); @@ -909,6 +922,7 @@ void AOOptionsDialog::update_values() { ui_stickyeffects_cb->setChecked(ao_app->is_stickyeffects_enabled()); ui_stickypres_cb->setChecked(ao_app->is_stickypres_enabled()); ui_customchat_cb->setChecked(ao_app->is_customchat_enabled()); + ui_sticker_cb->setChecked(ao_app->is_sticker_enabled()); ui_continuous_cb->setChecked(ao_app->is_continuous_enabled()); ui_category_stop_cb->setChecked(ao_app->is_category_stop_enabled()); ui_blank_blips_cb->setChecked(ao_app->get_blank_blip()); diff --git a/src/courtroom.cpp b/src/courtroom.cpp index 3d67def..183bcba 100644 --- a/src/courtroom.cpp +++ b/src/courtroom.cpp @@ -3209,7 +3209,8 @@ void Courtroom::start_chat_ticking() ui_vp_chatbox->show(); ui_vp_message->show(); - ui_vp_sticker->load_image(m_chatmessage[CHAR_NAME]); + if (ao_app->is_sticker_enabled()) + ui_vp_sticker->load_image(m_chatmessage[CHAR_NAME]); if (m_chatmessage[ADDITIVE] != "1") { ui_vp_message->clear(); diff --git a/src/text_file_functions.cpp b/src/text_file_functions.cpp index 45df30d..4718f74 100644 --- a/src/text_file_functions.cpp +++ b/src/text_file_functions.cpp @@ -981,6 +981,12 @@ bool AOApplication::is_customchat_enabled() return result.startsWith("true"); } +bool AOApplication::is_sticker_enabled() +{ + QString result = configini->value("sticker", "true").value(); + return result.startsWith("true"); +} + bool AOApplication::is_continuous_enabled() { QString result = configini->value("continuous_playback", "true").value(); From b5f581eb5b336273c3e7976ac8f7c438fe454bb4 Mon Sep 17 00:00:00 2001 From: Crystalwarrior Date: Wed, 17 Feb 2021 15:15:40 +0300 Subject: [PATCH 03/17] Revert bad "fix" of the sound names for WTCE courtroom_sounds.ini Make pos dropdown ui editable for a custom pos Keep track of the custom pos index On switching from the custom pos, remove the entry at that index Fix regression causing the "sort by name" lobby server list header disappearing Expose column 0 for the # in the lobby server list header ("too ugly" just use lobby_stylesheets.css and pretty it up) --- include/courtroom.h | 1 + src/courtroom.cpp | 36 ++++++++++++++++++++++++++++++++---- src/lobby.cpp | 4 ++-- 3 files changed, 35 insertions(+), 6 deletions(-) diff --git a/include/courtroom.h b/include/courtroom.h index 69dd58e..d1395e1 100644 --- a/include/courtroom.h +++ b/include/courtroom.h @@ -581,6 +581,7 @@ private: QString current_background = "default"; QString current_side = ""; + int temp_side_index = -1; QBrush free_brush; QBrush lfp_brush; diff --git a/src/courtroom.cpp b/src/courtroom.cpp index 183bcba..c98d663 100644 --- a/src/courtroom.cpp +++ b/src/courtroom.cpp @@ -727,6 +727,7 @@ void Courtroom::set_widgets() tr("Set your character's emote to play on your next message.")); set_size_and_pos(ui_pos_dropdown, "pos_dropdown"); + ui_pos_dropdown->setEditable(true); ui_pos_dropdown->setToolTip( tr("Set your character's supplementary background.")); @@ -1317,9 +1318,19 @@ void Courtroom::set_side(QString p_side, bool block_signals) ui_pos_dropdown->blockSignals(false); // alright we dun, jobs done here boyos - break; + return; } } + // We will only get there if we failed the last step + if (block_signals) + ui_pos_dropdown->blockSignals(true); + if (temp_side_index > -1) + ui_pos_dropdown->removeItem(temp_side_index); + ui_pos_dropdown->addItem(f_side); + temp_side_index = ui_pos_dropdown->count()-1; + ui_pos_dropdown->setCurrentIndex(temp_side_index); + if (block_signals) + ui_pos_dropdown->blockSignals(false); } void Courtroom::set_pos_dropdown(QStringList pos_dropdowns) @@ -1327,8 +1338,14 @@ void Courtroom::set_pos_dropdown(QStringList pos_dropdowns) // Block the signals to prevent setCurrentIndex from triggering a pos change ui_pos_dropdown->blockSignals(true); pos_dropdown_list = pos_dropdowns; + temp_side_index = -1; ui_pos_dropdown->clear(); ui_pos_dropdown->addItems(pos_dropdown_list); + // Custom pos + if (current_side != "" && !pos_dropdown_list.contains(current_side)) { + ui_pos_dropdown->addItem(current_side); + temp_side_index = ui_pos_dropdown->count() - 1; + } // Unblock the signals so the element can be used for setting pos again ui_pos_dropdown->blockSignals(false); set_side(current_side); @@ -3758,13 +3775,13 @@ void Courtroom::handle_wtce(QString p_wtce, int variant) ui_vp_testimony->kill(); return; } - sfx_name = ao_app->get_court_sfx("witnesstestimony", bg_misc); + sfx_name = ao_app->get_court_sfx("witness_testimony", bg_misc); filename = "witnesstestimony"; ui_vp_testimony->load_image("testimony", "", bg_misc); } // cross examination else if (p_wtce == "testimony2") { - sfx_name = ao_app->get_court_sfx("crossexamination", bg_misc); + sfx_name = ao_app->get_court_sfx("cross_examination", bg_misc); filename = "crossexamination"; ui_vp_testimony->kill(); } @@ -3774,7 +3791,7 @@ void Courtroom::handle_wtce(QString p_wtce, int variant) // Verdict? if (p_wtce == "judgeruling") { if (variant == 0) { - sfx_name = ao_app->get_court_sfx("notguilty", bg_misc); + sfx_name = ao_app->get_court_sfx("not_guilty", bg_misc); filename = "notguilty"; ui_vp_testimony->kill(); } @@ -4282,10 +4299,19 @@ void Courtroom::on_pos_dropdown_changed(int p_index) // YEAH SENDING LIKE 20 PACKETS IF THE USER SCROLLS THROUGH, GREAT IDEA // how about this instead set_side(f_pos); + if (temp_side_index > -1 && p_index == temp_side_index) { + ui_pos_dropdown->removeItem(temp_side_index); + temp_side_index = -1; + } } void Courtroom::on_pos_remove_clicked() { + if (temp_side_index > -1) { + ui_pos_dropdown->removeItem(temp_side_index); + temp_side_index = -1; + } + QString default_side = ao_app->get_char_side(current_char); for (int i = 0; i < ui_pos_dropdown->count(); ++i) { @@ -4296,10 +4322,12 @@ void Courtroom::on_pos_remove_clicked() } } int wit_index = ui_pos_dropdown->findText("wit"); + ui_pos_dropdown->blockSignals(true); if ((ui_pos_dropdown->currentText() != default_side) & (wit_index != -1)) //i.e. this bg doesn't have our pos ui_pos_dropdown->setCurrentIndex(wit_index); // fall back to "wit" else if (ui_pos_dropdown->currentText() != default_side) // we don't have "wit" either? ui_pos_dropdown->setCurrentIndex(0); // as a last resort, choose the first item in the dropdown + ui_pos_dropdown->blockSignals(false); current_side = ""; ui_pos_remove->hide(); ui_ic_chat_message->setFocus(); diff --git a/src/lobby.cpp b/src/lobby.cpp index 314874e..2397c70 100644 --- a/src/lobby.cpp +++ b/src/lobby.cpp @@ -28,8 +28,8 @@ Lobby::Lobby(AOApplication *p_ao_app) : QMainWindow() ui_server_list = new QTreeWidget(this); ui_server_list->setHeaderLabels({"#", "Name"}); //, "Players"}); - ui_server_list->hideColumn(0); - ui_server_list->setHeaderHidden(true); +// ui_server_list->hideColumn(0); +// ui_server_list->setHeaderHidden(true); ui_server_search = new QLineEdit(this); ui_server_search->setFrame(false); From f881df241533dafc214f72983d9c6e1c59837891 Mon Sep 17 00:00:00 2001 From: Crystalwarrior Date: Wed, 17 Feb 2021 15:29:18 +0300 Subject: [PATCH 04/17] Make the server list display all pretty and nice Resize the 0thcolumn to smallest possible size so it's not intrusive Remove text eliding so numbers don't get ...'s --- include/lobby.h | 1 + src/lobby.cpp | 5 +++++ 2 files changed, 6 insertions(+) diff --git a/include/lobby.h b/include/lobby.h index 4278534..ca2b88b 100644 --- a/include/lobby.h +++ b/include/lobby.h @@ -17,6 +17,7 @@ #include #include +#include class AOApplication; diff --git a/src/lobby.cpp b/src/lobby.cpp index 2397c70..d9336e5 100644 --- a/src/lobby.cpp +++ b/src/lobby.cpp @@ -28,6 +28,11 @@ Lobby::Lobby(AOApplication *p_ao_app) : QMainWindow() ui_server_list = new QTreeWidget(this); ui_server_list->setHeaderLabels({"#", "Name"}); //, "Players"}); + ui_server_list->setTextElideMode(Qt::ElideNone); + ui_server_list->header()->setMinimumSectionSize(24); + ui_server_list->header()->setSectionsMovable(false); + ui_server_list->setColumnWidth(0, 0); + ui_server_list->setIndentation(0); // ui_server_list->hideColumn(0); // ui_server_list->setHeaderHidden(true); From 7246965e00e1ffb5b91517aa6d58e17a664d6454 Mon Sep 17 00:00:00 2001 From: Crystalwarrior Date: Wed, 17 Feb 2021 15:47:54 +0300 Subject: [PATCH 05/17] Adopt better method for setting custom pos using the pos dropdown Make it actually work properly --- include/courtroom.h | 2 +- src/courtroom.cpp | 46 +++++++++++++++------------------------------ 2 files changed, 16 insertions(+), 32 deletions(-) diff --git a/include/courtroom.h b/include/courtroom.h index d1395e1..98d4df9 100644 --- a/include/courtroom.h +++ b/include/courtroom.h @@ -581,7 +581,6 @@ private: QString current_background = "default"; QString current_side = ""; - int temp_side_index = -1; QBrush free_brush; QBrush lfp_brush; @@ -835,6 +834,7 @@ private slots: void on_emote_dropdown_changed(int p_index); void on_pos_dropdown_changed(int p_index); + void on_pos_dropdown_changed(QString p_text); void on_pos_remove_clicked(); void on_iniswap_dropdown_changed(int p_index); diff --git a/src/courtroom.cpp b/src/courtroom.cpp index c98d663..ed70288 100644 --- a/src/courtroom.cpp +++ b/src/courtroom.cpp @@ -308,6 +308,8 @@ Courtroom::Courtroom(AOApplication *p_ao_app) : QMainWindow() connect(ui_pos_dropdown, SIGNAL(currentIndexChanged(int)), this, SLOT(on_pos_dropdown_changed(int))); + connect(ui_pos_dropdown, SIGNAL(editTextChanged(QString)), this, + SLOT(on_pos_dropdown_changed(QString))); connect(ui_pos_remove, SIGNAL(clicked()), this, SLOT(on_pos_remove_clicked())); connect(ui_iniswap_dropdown, SIGNAL(currentIndexChanged(int)), this, @@ -728,6 +730,7 @@ void Courtroom::set_widgets() set_size_and_pos(ui_pos_dropdown, "pos_dropdown"); ui_pos_dropdown->setEditable(true); + ui_pos_dropdown->setInsertPolicy(QComboBox::NoInsert); ui_pos_dropdown->setToolTip( tr("Set your character's supplementary background.")); @@ -1322,15 +1325,8 @@ void Courtroom::set_side(QString p_side, bool block_signals) } } // We will only get there if we failed the last step - if (block_signals) - ui_pos_dropdown->blockSignals(true); - if (temp_side_index > -1) - ui_pos_dropdown->removeItem(temp_side_index); - ui_pos_dropdown->addItem(f_side); - temp_side_index = ui_pos_dropdown->count()-1; - ui_pos_dropdown->setCurrentIndex(temp_side_index); - if (block_signals) - ui_pos_dropdown->blockSignals(false); + ui_pos_dropdown->setEditText(f_side); + ui_pos_remove->show(); } void Courtroom::set_pos_dropdown(QStringList pos_dropdowns) @@ -1338,13 +1334,11 @@ void Courtroom::set_pos_dropdown(QStringList pos_dropdowns) // Block the signals to prevent setCurrentIndex from triggering a pos change ui_pos_dropdown->blockSignals(true); pos_dropdown_list = pos_dropdowns; - temp_side_index = -1; ui_pos_dropdown->clear(); ui_pos_dropdown->addItems(pos_dropdown_list); - // Custom pos if (current_side != "" && !pos_dropdown_list.contains(current_side)) { - ui_pos_dropdown->addItem(current_side); - temp_side_index = ui_pos_dropdown->count() - 1; + ui_pos_dropdown->setEditText(current_side); + ui_pos_remove->show(); } // Unblock the signals so the element can be used for setting pos again ui_pos_dropdown->blockSignals(false); @@ -4281,37 +4275,27 @@ void Courtroom::on_pos_dropdown_changed(int p_index) { if (p_index < 0) return; + on_pos_dropdown_changed(ui_pos_dropdown->itemText(p_index)); +} +void Courtroom::on_pos_dropdown_changed(QString p_text) +{ toggle_judge_buttons(false); - QString f_pos = ui_pos_dropdown->itemText(p_index); - - if (f_pos == "") - return; - - if (f_pos == "jud") + if (p_text == "jud") toggle_judge_buttons(true); - + ui_pos_remove->show(); - current_side = f_pos; + current_side = p_text; // YEAH SENDING LIKE 20 PACKETS IF THE USER SCROLLS THROUGH, GREAT IDEA // how about this instead - set_side(f_pos); - if (temp_side_index > -1 && p_index == temp_side_index) { - ui_pos_dropdown->removeItem(temp_side_index); - temp_side_index = -1; - } + set_side(p_text); } void Courtroom::on_pos_remove_clicked() { - if (temp_side_index > -1) { - ui_pos_dropdown->removeItem(temp_side_index); - temp_side_index = -1; - } - QString default_side = ao_app->get_char_side(current_char); for (int i = 0; i < ui_pos_dropdown->count(); ++i) { From ec6d657f311bb9c46e7df3116bdc8210180a4225 Mon Sep 17 00:00:00 2001 From: Crystalwarrior Date: Wed, 17 Feb 2021 15:55:33 +0300 Subject: [PATCH 06/17] rename wtce lookups to `_bubble` (themes need to be updated for this) --- src/courtroom.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/courtroom.cpp b/src/courtroom.cpp index ed70288..c7bc456 100644 --- a/src/courtroom.cpp +++ b/src/courtroom.cpp @@ -3770,13 +3770,13 @@ void Courtroom::handle_wtce(QString p_wtce, int variant) return; } sfx_name = ao_app->get_court_sfx("witness_testimony", bg_misc); - filename = "witnesstestimony"; + filename = "witnesstestimony_bubble"; ui_vp_testimony->load_image("testimony", "", bg_misc); } // cross examination else if (p_wtce == "testimony2") { sfx_name = ao_app->get_court_sfx("cross_examination", bg_misc); - filename = "crossexamination"; + filename = "crossexamination_bubble"; ui_vp_testimony->kill(); } else { @@ -3786,12 +3786,12 @@ void Courtroom::handle_wtce(QString p_wtce, int variant) if (p_wtce == "judgeruling") { if (variant == 0) { sfx_name = ao_app->get_court_sfx("not_guilty", bg_misc); - filename = "notguilty"; + filename = "notguilty_bubble"; ui_vp_testimony->kill(); } else if (variant == 1) { sfx_name = ao_app->get_court_sfx("guilty", bg_misc); - filename = "guilty"; + filename = "guilty_bubble"; ui_vp_testimony->kill(); } } From aa790dbc4b22badabbbc30bd1fb70668d0682ece Mon Sep 17 00:00:00 2001 From: Crystalwarrior Date: Fri, 19 Feb 2021 11:20:38 +0300 Subject: [PATCH 07/17] Overhaul pos dropdown and pos remove system to work well with custom pos, char pos etc. Remove accidental duplicate code Fix some genius using & instead of && (SMH) Block pos_dropdown signals better --- include/courtroom.h | 2 +- src/courtroom.cpp | 75 +++++++++++++------------------------ src/packet_distribution.cpp | 3 +- 3 files changed, 30 insertions(+), 50 deletions(-) diff --git a/include/courtroom.h b/include/courtroom.h index 98d4df9..bba38b6 100644 --- a/include/courtroom.h +++ b/include/courtroom.h @@ -165,7 +165,7 @@ public: void set_background(QString p_background, bool display = false); // sets the local character pos/side to use. - void set_side(QString p_side, bool block_signals=true); + void set_side(QString p_side); // sets the pos dropdown void set_pos_dropdown(QStringList pos_dropdowns); diff --git a/src/courtroom.cpp b/src/courtroom.cpp index c7bc456..f80c39a 100644 --- a/src/courtroom.cpp +++ b/src/courtroom.cpp @@ -1275,50 +1275,38 @@ void Courtroom::set_background(QString p_background, bool display) } } -void Courtroom::set_side(QString p_side, bool block_signals) +void Courtroom::set_side(QString p_side) { QString f_side; - if (p_side == "") + if (p_side == ao_app->get_char_side(current_char)) + p_side = ""; + current_side = p_side; + if (current_side == "") { f_side = ao_app->get_char_side(current_char); - else - f_side = p_side; - - if (f_side == "jud") { - ui_witness_testimony->show(); - ui_cross_examination->show(); - ui_not_guilty->show(); - ui_guilty->show(); - ui_defense_minus->show(); - ui_defense_plus->show(); - ui_prosecution_minus->show(); - ui_prosecution_plus->show(); + ui_pos_remove->hide(); } else { - ui_witness_testimony->hide(); - ui_cross_examination->hide(); - ui_guilty->hide(); - ui_not_guilty->hide(); - ui_defense_minus->hide(); - ui_defense_plus->hide(); - ui_prosecution_minus->hide(); - ui_prosecution_plus->hide(); + f_side = current_side; + ui_pos_remove->show(); } + toggle_judge_buttons(false); + + if (f_side == "jud") + toggle_judge_buttons(true); + + // Block the signals to prevent setCurrentIndex from triggering a pos + // change + ui_pos_dropdown->blockSignals(true); for (int i = 0; i < ui_pos_dropdown->count(); ++i) { QString pos = ui_pos_dropdown->itemText(i); if (pos == f_side) { - // Block the signals to prevent setCurrentIndex from triggering a pos - // change - if (block_signals) - ui_pos_dropdown->blockSignals(true); // Set the index on dropdown ui element to let you know what pos you're on // right now ui_pos_dropdown->setCurrentIndex(i); - // Unblock the signals so the element can be used for setting pos again - if (block_signals) - ui_pos_dropdown->blockSignals(false); + ui_pos_dropdown->blockSignals(false); // alright we dun, jobs done here boyos return; @@ -1326,7 +1314,8 @@ void Courtroom::set_side(QString p_side, bool block_signals) } // We will only get there if we failed the last step ui_pos_dropdown->setEditText(f_side); - ui_pos_remove->show(); + // Unblock the signals so the element can be used for setting pos again + ui_pos_dropdown->blockSignals(false); } void Courtroom::set_pos_dropdown(QStringList pos_dropdowns) @@ -1336,12 +1325,13 @@ void Courtroom::set_pos_dropdown(QStringList pos_dropdowns) pos_dropdown_list = pos_dropdowns; ui_pos_dropdown->clear(); ui_pos_dropdown->addItems(pos_dropdown_list); - if (current_side != "" && !pos_dropdown_list.contains(current_side)) { + + if (current_side != "" && !pos_dropdown_list.contains(current_side)) ui_pos_dropdown->setEditText(current_side); - ui_pos_remove->show(); - } + // Unblock the signals so the element can be used for setting pos again ui_pos_dropdown->blockSignals(false); + // Don't block the signals when setting side set_side(current_side); } @@ -3699,7 +3689,7 @@ void Courtroom::handle_song(QStringList *p_contents) 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))) & !f_song.startsWith("http")) + if (file_exists(ao_app->get_sfx_suffix(ao_app->get_music_path(f_song))) && !f_song.startsWith("http")) ui_music_name->setText(f_song_clear); else if (f_song.startsWith("http")) ui_music_name->setText(tr("[STREAM] %1").arg(f_song_clear)); @@ -3743,7 +3733,7 @@ void Courtroom::handle_song(QStringList *p_contents) if (is_stop) 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))) & !f_song.startsWith("http")) + if (file_exists(ao_app->get_sfx_suffix(ao_app->get_music_path(f_song))) && !f_song.startsWith("http")) ui_music_name->setText(f_song_clear); else if (f_song.startsWith("http")) ui_music_name->setText(tr("[STREAM] %1").arg(f_song_clear)); @@ -4280,22 +4270,12 @@ void Courtroom::on_pos_dropdown_changed(int p_index) void Courtroom::on_pos_dropdown_changed(QString p_text) { - toggle_judge_buttons(false); - - if (p_text == "jud") - toggle_judge_buttons(true); - - ui_pos_remove->show(); - - current_side = p_text; - - // YEAH SENDING LIKE 20 PACKETS IF THE USER SCROLLS THROUGH, GREAT IDEA - // how about this instead set_side(p_text); } void Courtroom::on_pos_remove_clicked() { + ui_pos_dropdown->blockSignals(true); QString default_side = ao_app->get_char_side(current_char); for (int i = 0; i < ui_pos_dropdown->count(); ++i) { @@ -4306,8 +4286,7 @@ void Courtroom::on_pos_remove_clicked() } } int wit_index = ui_pos_dropdown->findText("wit"); - ui_pos_dropdown->blockSignals(true); - if ((ui_pos_dropdown->currentText() != default_side) & (wit_index != -1)) //i.e. this bg doesn't have our pos + if (ui_pos_dropdown->currentText() != default_side && wit_index != -1) //i.e. this bg doesn't have our pos ui_pos_dropdown->setCurrentIndex(wit_index); // fall back to "wit" else if (ui_pos_dropdown->currentText() != default_side) // we don't have "wit" either? ui_pos_dropdown->setCurrentIndex(0); // as a last resort, choose the first item in the dropdown diff --git a/src/packet_distribution.cpp b/src/packet_distribution.cpp index 1053c20..b2e5d3e 100644 --- a/src/packet_distribution.cpp +++ b/src/packet_distribution.cpp @@ -462,6 +462,7 @@ void AOApplication::server_packet_received(AOPacket *p_packet) goto end; if (courtroom_constructed) { + qDebug() << f_contents; if (f_contents.size() >= 2) // We have a pos included in the background packet! w_courtroom->set_side(f_contents.at(1)); @@ -475,7 +476,7 @@ void AOApplication::server_packet_received(AOPacket *p_packet) if (courtroom_constructed) // We were sent a "set position" packet { - w_courtroom->set_side(f_contents.at(0), false); + w_courtroom->set_side(f_contents.at(0)); append_to_demofile(p_packet->to_string(true)); } } From f1aa57b1253ed267c1cab3c32a1ffc38ad29e854 Mon Sep 17 00:00:00 2001 From: in1tiate Date: Sat, 20 Feb 2021 04:10:35 -0600 Subject: [PATCH 08/17] fix speedlines never being unhidden --- src/aolayer.cpp | 4 ++-- src/courtroom.cpp | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/aolayer.cpp b/src/aolayer.cpp index e2a1f07..0488364 100644 --- a/src/aolayer.cpp +++ b/src/aolayer.cpp @@ -260,7 +260,8 @@ void CharLayer::start_playback(QString p_image) void AOLayer::start_playback(QString p_image) { - + this->show(); + if (!ao_app->is_continuous_enabled()) { continuous = false; force_continuous = true; @@ -321,7 +322,6 @@ void AOLayer::start_playback(QString p_image) int f_delay = m_reader.nextImageDelay(); this->set_frame(f_pixmap); - this->show(); if (max_frames > 1) { movie_frames.append(f_pixmap); movie_delays.append(f_delay); diff --git a/src/courtroom.cpp b/src/courtroom.cpp index f80c39a..70cc0ff 100644 --- a/src/courtroom.cpp +++ b/src/courtroom.cpp @@ -1248,7 +1248,7 @@ void Courtroom::set_background(QString p_background, bool display) set_pos_dropdown(pos_list); if (display) { - ui_vp_speedlines->stop(); + ui_vp_speedlines->hide(); ui_vp_player_char->stop(); ui_vp_sideplayer_char->stop(); @@ -2218,7 +2218,7 @@ void Courtroom::effect_done() void Courtroom::display_character() { // Stop all previously playing animations, effects etc. - ui_vp_speedlines->stop(); + ui_vp_speedlines->hide(); ui_vp_player_char->stop(); ui_vp_effect->stop(); // Clear all looping sfx to prevent obnoxiousness From 0ee6888dec0bc653468a9a24896e20d5de69ba06 Mon Sep 17 00:00:00 2001 From: in1tiate Date: Sat, 20 Feb 2021 04:30:09 -0600 Subject: [PATCH 09/17] prevent static preanims from playing --- src/aolayer.cpp | 2 +- src/courtroom.cpp | 9 +++++++++ 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/src/aolayer.cpp b/src/aolayer.cpp index 0488364..f0d5779 100644 --- a/src/aolayer.cpp +++ b/src/aolayer.cpp @@ -261,7 +261,7 @@ void CharLayer::start_playback(QString p_image) void AOLayer::start_playback(QString p_image) { this->show(); - + if (!ao_app->is_continuous_enabled()) { continuous = false; force_continuous = true; diff --git a/src/courtroom.cpp b/src/courtroom.cpp index 70cc0ff..014bd7b 100644 --- a/src/courtroom.cpp +++ b/src/courtroom.cpp @@ -3109,6 +3109,15 @@ void Courtroom::play_preanim(bool immediate) qDebug() << "W: could not find " + anim_to_find; return; } + else { + QImageReader s_reader = QImageReader(anim_to_find); + int image_count = s_reader.imageCount(); + if (image_count <= 1) { + preanim_done(); + qDebug() << "W: tried to play static preanim " + anim_to_find; + return; + } + } ui_vp_player_char->set_static_duration(preanim_duration); ui_vp_player_char->set_play_once(true); ui_vp_player_char->load_image(f_preanim, f_char, preanim_duration, true); From d6ebc3e80b9abc29fef70f6ef18434ea877f4b66 Mon Sep 17 00:00:00 2001 From: Crystalwarrior Date: Sun, 21 Feb 2021 11:38:04 +0300 Subject: [PATCH 10/17] Fix chat arrow being frozen on frame 1 --- src/courtroom.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/courtroom.cpp b/src/courtroom.cpp index 014bd7b..22491f2 100644 --- a/src/courtroom.cpp +++ b/src/courtroom.cpp @@ -1256,7 +1256,7 @@ void Courtroom::set_background(QString p_background, bool display) ui_vp_message->hide(); ui_vp_chatbox->hide(); // Stop the chat arrow from animating - ui_vp_chat_arrow->stop(); + ui_vp_chat_arrow->hide(); // Clear the message queue text_queue_timer->stop(); @@ -2014,7 +2014,7 @@ void Courtroom::unpack_chatmessage(QStringList p_contents) handle_callwords(); // Reset the interface to make room for objection handling - ui_vp_chat_arrow->stop(); + ui_vp_chat_arrow->hide(); text_state = 0; anim_state = 0; evidence_presented = false; From ee918a4f818326cba66ec07bf4be57c4d67c08da Mon Sep 17 00:00:00 2001 From: Crystalwarrior Date: Sun, 21 Feb 2021 12:03:56 +0300 Subject: [PATCH 11/17] Fix edge cases where screenshake uses wrong chatbox coordinates due to it being initialized later than needed. --- src/courtroom.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/courtroom.cpp b/src/courtroom.cpp index 22491f2..9c9c6ad 100644 --- a/src/courtroom.cpp +++ b/src/courtroom.cpp @@ -2360,6 +2360,9 @@ void Courtroom::objection_done() { handle_ic_message(); } void Courtroom::handle_ic_message() { + // Update the chatbox information + initialize_chatbox(); + // Display our own character display_character(); @@ -2377,9 +2380,6 @@ void Courtroom::handle_ic_message() // Parse the emote_mod part of the chat message handle_emote_mod(m_chatmessage[EMOTE_MOD].toInt(), m_chatmessage[IMMEDIATE].toInt() == 1); - // Update the chatbox information - initialize_chatbox(); - // if we have instant objections disabled, and queue is not empty, check if next message after this is an objection. if (!ao_app->is_instant_objection_enabled() && chatmessage_queue.size() > 0) { From 37011fc22d2d821f5370e21b626dc295a002defa Mon Sep 17 00:00:00 2001 From: Crystalwarrior Date: Sun, 21 Feb 2021 15:50:34 +0300 Subject: [PATCH 12/17] Remove background-color stylesheet from the set_qfont (allowing stylesheets to properly initialize custom backgrounds for labels w/ transparent ones) rename "set_dropdown_ to "set_stylesheet" cuz that's what it is --- include/courtroom.h | 4 ++-- src/courtroom.cpp | 15 +++++---------- 2 files changed, 7 insertions(+), 12 deletions(-) diff --git a/include/courtroom.h b/include/courtroom.h index bba38b6..2e007d2 100644 --- a/include/courtroom.h +++ b/include/courtroom.h @@ -143,10 +143,10 @@ public: void set_fonts(QString p_char = ""); // sets dropdown menu stylesheet - void set_dropdown(QWidget *widget); + void set_stylesheet(QWidget *widget); // helper funciton that call above function on the relevant widgets - void set_dropdowns(); + void set_stylesheets(); void set_window_title(QString p_title); diff --git a/src/courtroom.cpp b/src/courtroom.cpp index 9c9c6ad..94d7ab8 100644 --- a/src/courtroom.cpp +++ b/src/courtroom.cpp @@ -1043,7 +1043,7 @@ void Courtroom::set_fonts(QString p_char) for (int i = 0; i < max_clocks; i++) set_font(ui_clock[i], "", "clock_" + QString::number(i), p_char); - set_dropdowns(); + set_stylesheets(); } void Courtroom::set_font(QWidget *widget, QString class_name, @@ -1105,13 +1105,13 @@ void Courtroom::set_qfont(QWidget *widget, QString class_name, QFont font, widget->setFont(font); QString style_sheet_string = - class_name + " { background-color: rgba(0, 0, 0, 0);\n" + "color: rgba(" + + class_name + " { color: rgba(" + QString::number(f_color.red()) + ", " + QString::number(f_color.green()) + ", " + QString::number(f_color.blue()) + ", 255);}"; widget->setStyleSheet(style_sheet_string); } -void Courtroom::set_dropdown(QWidget *widget) +void Courtroom::set_stylesheet(QWidget *widget) { QString f_file = "courtroom_stylesheets.css"; QString style_sheet_string = ao_app->get_stylesheet(f_file); @@ -1119,14 +1119,9 @@ void Courtroom::set_dropdown(QWidget *widget) widget->setStyleSheet(style_sheet_string); } -void Courtroom::set_dropdowns() +void Courtroom::set_stylesheets() { - set_dropdown( - this); // EXPERIMENTAL - Read the style-sheet as-is for maximum memeage - // set_dropdown(ui_text_color, "[TEXT COLOR]"); - // set_dropdown(ui_pos_dropdown, "[POS DROPDOWN]"); - // set_dropdown(ui_emote_dropdown, "[EMOTE DROPDOWN]"); - // set_dropdown(ui_mute_list, "[MUTE LIST]"); + set_stylesheet(this); } void Courtroom::set_window_title(QString p_title) From 354fbd239c203d0ed3f9d98bd32bef6f6dbe26d6 Mon Sep 17 00:00:00 2001 From: Crystalwarrior Date: Sun, 21 Feb 2021 16:07:12 +0300 Subject: [PATCH 13/17] Stop hardcoding stylesheets so the behavior is more consistent finally (and courtorom_stylesheets.css is more useful) --- src/courtroom.cpp | 10 +--------- src/evidence.cpp | 2 -- 2 files changed, 1 insertion(+), 11 deletions(-) diff --git a/src/courtroom.cpp b/src/courtroom.cpp index 94d7ab8..b7d8a07 100644 --- a/src/courtroom.cpp +++ b/src/courtroom.cpp @@ -687,11 +687,6 @@ void Courtroom::set_widgets() set_size_and_pos(ui_ic_chat_message, "ao2_ic_chat_message"); set_size_and_pos(ui_ic_chat_name, "ao2_ic_chat_name"); - ui_ic_chat_message->setStyleSheet( - "QLineEdit{background-color: rgba(100, 100, 100, 255);}"); - ui_ic_chat_name->setStyleSheet( - "QLineEdit{background-color: rgba(180, 180, 180, 255);}"); - ui_vp_chatbox->set_image("chatblank"); ui_vp_chatbox->hide(); @@ -714,15 +709,12 @@ void Courtroom::set_widgets() ui_muted->set_image("muted"); ui_muted->setToolTip(tr("Oops, you're muted!")); - set_size_and_pos(ui_ooc_chat_message, "ooc_chat_message"); - ui_ooc_chat_message->setStyleSheet("background-color: rgba(0, 0, 0, 0);"); + set_size_and_pos(ui_ooc_chat_message, "ooc_chat_message");; set_size_and_pos(ui_ooc_chat_name, "ooc_chat_name"); - ui_ooc_chat_name->setStyleSheet("background-color: rgba(0, 0, 0, 0);"); // set_size_and_pos(ui_area_password, "area_password"); set_size_and_pos(ui_music_search, "music_search"); - ui_music_search->setStyleSheet("background-color: rgba(0, 0, 0, 0);"); set_size_and_pos(ui_emote_dropdown, "emote_dropdown"); ui_emote_dropdown->setToolTip( diff --git a/src/evidence.cpp b/src/evidence.cpp index b97607b..8825753 100644 --- a/src/evidence.cpp +++ b/src/evidence.cpp @@ -41,8 +41,6 @@ void Courtroom::initialize_evidence() "evidence and send them to server.")); ui_evidence_description = new AOTextEdit(ui_evidence_overlay); - ui_evidence_description->setStyleSheet("background-color: rgba(0, 0, 0, 0);" - "color: white;"); ui_evidence_description->setFrameStyle(QFrame::NoFrame); ui_evidence_description->setToolTip( tr("Double-click to edit. Press [X] to update your changes.")); From 679dcca0792650f3a2899af8009846fdc289c9ba Mon Sep 17 00:00:00 2001 From: Crystalwarrior Date: Sun, 21 Feb 2021 16:18:45 +0300 Subject: [PATCH 14/17] Remove hardcoded stylesheets from lobby Stop doing the "tagget stylesheets" monstrosity --- include/lobby.h | 2 +- src/lobby.cpp | 30 +++--------------------------- 2 files changed, 4 insertions(+), 28 deletions(-) diff --git a/include/lobby.h b/include/lobby.h index ca2b88b..0f066ab 100644 --- a/include/lobby.h +++ b/include/lobby.h @@ -33,7 +33,7 @@ public: void append_chatmessage(QString f_name, QString f_message); void append_error(QString f_message); void set_player_count(int players_online, int max_players); - void set_stylesheet(QWidget *widget, QString target_tag); + void set_stylesheet(QWidget *widget); void set_stylesheets(); void set_fonts(); void set_font(QWidget *widget, QString p_identifier); diff --git a/src/lobby.cpp b/src/lobby.cpp index d9336e5..616e520 100644 --- a/src/lobby.cpp +++ b/src/lobby.cpp @@ -142,36 +142,21 @@ void Lobby::set_widgets() tr("Allows you to change various aspects of the client.")); set_size_and_pos(ui_server_list, "server_list"); - ui_server_list->setStyleSheet("background-color: rgba(0, 0, 0, 0);" - "font: bold;"); set_size_and_pos(ui_server_search, "server_search"); - ui_server_search->setStyleSheet("background-color: rgba(0, 0, 0, 0);"); set_size_and_pos(ui_player_count, "player_count"); ui_player_count->setText(tr("Offline")); - ui_player_count->setStyleSheet("font: bold;" - "color: white;" - "qproperty-alignment: AlignCenter;"); set_size_and_pos(ui_description, "description"); ui_description->setReadOnly(true); - ui_description->setStyleSheet("background-color: rgba(0, 0, 0, 0);" - "color: white;"); set_size_and_pos(ui_chatbox, "chatbox"); ui_chatbox->setReadOnly(true); - ui_chatbox->setStyleSheet( - "QTextBrowser{background-color: rgba(0, 0, 0, 0);}"); set_size_and_pos(ui_chatname, "chatname"); - ui_chatname->setStyleSheet("background-color: rgba(0, 0, 0, 0);" - "selection-background-color: rgba(0, 0, 0, 0);"); set_size_and_pos(ui_chatmessage, "chatmessage"); - ui_chatmessage->setStyleSheet( - "background-color: rgba(0, 0, 0, 0);" - "selection-background-color: rgba(0, 0, 0, 0);"); ui_loading_background->resize(this->width(), this->height()); ui_loading_background->set_image("loadingbackground"); @@ -181,8 +166,6 @@ void Lobby::set_widgets() ui_loading_text->setReadOnly(true); ui_loading_text->setAlignment(Qt::AlignCenter); ui_loading_text->setFrameStyle(QFrame::NoFrame); - ui_loading_text->setStyleSheet("background-color: rgba(0, 0, 0, 0);" - "color: rgba(255, 128, 0, 255);"); ui_loading_text->append(tr("Loading")); set_size_and_pos(ui_progress_bar, "progress_bar"); @@ -223,24 +206,17 @@ void Lobby::set_fonts() set_font(ui_server_list, "server_list"); } -void Lobby::set_stylesheet(QWidget *widget, QString target_tag) +void Lobby::set_stylesheet(QWidget *widget) { QString f_file = "lobby_stylesheets.css"; - QString style_sheet_string = - ao_app->get_tagged_stylesheet(target_tag, f_file); + QString style_sheet_string = ao_app->get_stylesheet(f_file); if (style_sheet_string != "") widget->setStyleSheet(style_sheet_string); } void Lobby::set_stylesheets() { - set_stylesheet(ui_player_count, "[PLAYER COUNT]"); - set_stylesheet(ui_description, "[DESCRIPTION]"); - set_stylesheet(ui_chatbox, "[CHAT BOX]"); - set_stylesheet(ui_chatname, "[CHAT NAME]"); - set_stylesheet(ui_chatmessage, "[CHAT MESSAGE]"); - set_stylesheet(ui_loading_text, "[LOADING TEXT]"); - set_stylesheet(ui_server_list, "[SERVER LIST]"); + set_stylesheet(this); } void Lobby::set_font(QWidget *widget, QString p_identifier) From d32ad43665e9218258ff57ed98b8ed457e313ee5 Mon Sep 17 00:00:00 2001 From: oldmud0 Date: Mon, 22 Feb 2021 12:54:06 -0600 Subject: [PATCH 15/17] Fix crash caused by pre-2.6 IC packet --- src/courtroom.cpp | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/courtroom.cpp b/src/courtroom.cpp index b7d8a07..cc97a40 100644 --- a/src/courtroom.cpp +++ b/src/courtroom.cpp @@ -1941,7 +1941,13 @@ void Courtroom::chatmessage_enqueue(QStringList p_contents) // Record the log I/O, log files should be accurate. // If desynced logs are on, display the log IC immediately. LogMode log_mode = ao_app->is_desyncrhonized_logs_enabled() ? DISPLAY_AND_IO : IO_ONLY; - log_chatmessage(p_contents[MESSAGE], f_char_id, p_contents[SHOWNAME], p_contents[TEXT_COLOR].toInt(), log_mode); + + // Use null showname if packet does not support 2.6+ extensions + QString showname = QString(); + if (SHOWNAME < p_contents.size()) + showname = p_contents[SHOWNAME]; + + log_chatmessage(p_contents[MESSAGE], f_char_id, showname, p_contents[TEXT_COLOR].toInt(), log_mode); // Send this boi into the queue chatmessage_queue.enqueue(p_contents); From 7579457e897cba6d358bd65dba1ee05e1db87c06 Mon Sep 17 00:00:00 2001 From: oldmud0 Date: Mon, 22 Feb 2021 14:31:23 -0600 Subject: [PATCH 16/17] Avoid use of QImageReader copy constructor --- src/courtroom.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/courtroom.cpp b/src/courtroom.cpp index cc97a40..4782e39 100644 --- a/src/courtroom.cpp +++ b/src/courtroom.cpp @@ -3103,7 +3103,7 @@ void Courtroom::play_preanim(bool immediate) return; } else { - QImageReader s_reader = QImageReader(anim_to_find); + QImageReader s_reader(anim_to_find); int image_count = s_reader.imageCount(); if (image_count <= 1) { preanim_done(); From 5ac95ada564f11419441eca32907aef7ec16dd90 Mon Sep 17 00:00:00 2001 From: Crystalwarrior Date: Wed, 24 Feb 2021 16:02:07 +0300 Subject: [PATCH 17/17] Make "stop music on objection" work in tandem with the server by calling "music_stop()" instead of only working on the client-side --- include/courtroom.h | 2 +- src/aooptionsdialog.cpp | 3 +-- src/courtroom.cpp | 16 +++++++++++----- 3 files changed, 13 insertions(+), 8 deletions(-) diff --git a/include/courtroom.h b/include/courtroom.h index 2e007d2..6a64deb 100644 --- a/include/courtroom.h +++ b/include/courtroom.h @@ -822,7 +822,7 @@ private slots: void music_random(); void music_list_expand_all(); void music_list_collapse_all(); - void music_stop(); + void music_stop(bool no_effects = false); void on_area_list_double_clicked(QTreeWidgetItem *p_item, int column); void select_emote(int p_id); diff --git a/src/aooptionsdialog.cpp b/src/aooptionsdialog.cpp index 5817d96..9ca0865 100644 --- a/src/aooptionsdialog.cpp +++ b/src/aooptionsdialog.cpp @@ -704,8 +704,7 @@ AOOptionsDialog::AOOptionsDialog(QWidget *parent, AOApplication *p_ao_app) ui_objectmusic_lbl = new QLabel(ui_audio_widget); ui_objectmusic_lbl->setText(tr("Kill Music On Objection:")); ui_objectmusic_lbl->setToolTip( - tr("If true, AO2 will stop the music for you when you or someone else " - "does 'Objection!'.")); + tr("If true, AO2 will ask the server to stop music when you use 'Objection!' ")); ui_audio_layout->setWidget(row, QFormLayout::LabelRole, ui_objectmusic_lbl); diff --git a/src/courtroom.cpp b/src/courtroom.cpp index 4782e39..c8d8320 100644 --- a/src/courtroom.cpp +++ b/src/courtroom.cpp @@ -1747,6 +1747,10 @@ void Courtroom::on_chat_return_pressed() else f_obj_state = QString::number(objection_state); + // We're doing an Objection (custom objections not yet supported) + if (objection_state == 2 && ao_app->objection_stop_music()) + music_stop(true); + packet_contents.append(f_obj_state); if (is_presenting_evidence) @@ -2166,8 +2170,6 @@ bool Courtroom::handle_objection() filename = "objection_bubble"; objection_player->play("objection", m_chatmessage[CHAR_NAME], ao_app->get_chat(m_chatmessage[CHAR_NAME])); - if (ao_app->objection_stop_music()) - music_player->stop(); break; case 3: filename = "takethat_bubble"; @@ -4777,7 +4779,7 @@ void Courtroom::music_list_collapse_all() ui_music_list->setCurrentItem(current); } -void Courtroom::music_stop() +void Courtroom::music_stop(bool no_effects) { if (is_muted) return; @@ -4802,8 +4804,12 @@ void Courtroom::music_stop() 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)); + if (ao_app->effects_enabled) { + if (no_effects) + packet_contents.append("0"); + else + packet_contents.append(QString::number(music_flags)); + } ao_app->send_server_packet(new AOPacket("MC", packet_contents), false); }