From 5063880530c98d17e6d15a888f7c4a8462351e52 Mon Sep 17 00:00:00 2001 From: Crystalwarrior Date: Tue, 16 Feb 2021 11:04:07 +0300 Subject: 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 --- src/courtroom.cpp | 119 +++++++++++++++++------------------------------------- 1 file changed, 36 insertions(+), 83 deletions(-) (limited to 'src/courtroom.cpp') diff --git a/src/courtroom.cpp b/src/courtroom.cpp index b9ca070d..3d67defe 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]); } + QString customchar; + if (ao_app->is_customchat_enabled()) + customchar = m_chatmessage[CHAR_NAME]; + QString p_misc = ao_app->get_chat(customchar); - 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]); + 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); - QString customchar; - if (ao_app->is_customchat_enabled()) - customchar = m_chatmessage[CHAR_NAME]; - QString p_misc = ao_app->get_chat(customchar); 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; -- cgit From 63128fea1362b0fe2388ff0b85b9f1120806b332 Mon Sep 17 00:00:00 2001 From: Crystalwarrior Date: Tue, 16 Feb 2021 11:20:54 +0300 Subject: 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 --- src/courtroom.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'src/courtroom.cpp') diff --git a/src/courtroom.cpp b/src/courtroom.cpp index 3d67defe..183bcbaf 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(); -- cgit From b5f581eb5b336273c3e7976ac8f7c438fe454bb4 Mon Sep 17 00:00:00 2001 From: Crystalwarrior Date: Wed, 17 Feb 2021 15:15:40 +0300 Subject: 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) --- src/courtroom.cpp | 36 ++++++++++++++++++++++++++++++++---- 1 file changed, 32 insertions(+), 4 deletions(-) (limited to 'src/courtroom.cpp') diff --git a/src/courtroom.cpp b/src/courtroom.cpp index 183bcbaf..c98d6635 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(); -- cgit From 7246965e00e1ffb5b91517aa6d58e17a664d6454 Mon Sep 17 00:00:00 2001 From: Crystalwarrior Date: Wed, 17 Feb 2021 15:47:54 +0300 Subject: Adopt better method for setting custom pos using the pos dropdown Make it actually work properly --- src/courtroom.cpp | 46 +++++++++++++++------------------------------- 1 file changed, 15 insertions(+), 31 deletions(-) (limited to 'src/courtroom.cpp') diff --git a/src/courtroom.cpp b/src/courtroom.cpp index c98d6635..ed70288c 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) { -- cgit From ec6d657f311bb9c46e7df3116bdc8210180a4225 Mon Sep 17 00:00:00 2001 From: Crystalwarrior Date: Wed, 17 Feb 2021 15:55:33 +0300 Subject: rename wtce lookups to `_bubble` (themes need to be updated for this) --- src/courtroom.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'src/courtroom.cpp') diff --git a/src/courtroom.cpp b/src/courtroom.cpp index ed70288c..c7bc4562 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(); } } -- cgit From aa790dbc4b22badabbbc30bd1fb70668d0682ece Mon Sep 17 00:00:00 2001 From: Crystalwarrior Date: Fri, 19 Feb 2021 11:20:38 +0300 Subject: 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 --- src/courtroom.cpp | 75 ++++++++++++++++++++----------------------------------- 1 file changed, 27 insertions(+), 48 deletions(-) (limited to 'src/courtroom.cpp') diff --git a/src/courtroom.cpp b/src/courtroom.cpp index c7bc4562..f80c39a9 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 -- cgit From f1aa57b1253ed267c1cab3c32a1ffc38ad29e854 Mon Sep 17 00:00:00 2001 From: in1tiate Date: Sat, 20 Feb 2021 04:10:35 -0600 Subject: fix speedlines never being unhidden --- src/courtroom.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src/courtroom.cpp') diff --git a/src/courtroom.cpp b/src/courtroom.cpp index f80c39a9..70cc0ffc 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 -- cgit From 0ee6888dec0bc653468a9a24896e20d5de69ba06 Mon Sep 17 00:00:00 2001 From: in1tiate Date: Sat, 20 Feb 2021 04:30:09 -0600 Subject: prevent static preanims from playing --- src/courtroom.cpp | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'src/courtroom.cpp') diff --git a/src/courtroom.cpp b/src/courtroom.cpp index 70cc0ffc..014bd7b1 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); -- cgit From d6ebc3e80b9abc29fef70f6ef18434ea877f4b66 Mon Sep 17 00:00:00 2001 From: Crystalwarrior Date: Sun, 21 Feb 2021 11:38:04 +0300 Subject: Fix chat arrow being frozen on frame 1 --- src/courtroom.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src/courtroom.cpp') diff --git a/src/courtroom.cpp b/src/courtroom.cpp index 014bd7b1..22491f28 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; -- cgit From ee918a4f818326cba66ec07bf4be57c4d67c08da Mon Sep 17 00:00:00 2001 From: Crystalwarrior Date: Sun, 21 Feb 2021 12:03:56 +0300 Subject: 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(-) (limited to 'src/courtroom.cpp') diff --git a/src/courtroom.cpp b/src/courtroom.cpp index 22491f28..9c9c6adb 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) { -- cgit From 37011fc22d2d821f5370e21b626dc295a002defa Mon Sep 17 00:00:00 2001 From: Crystalwarrior Date: Sun, 21 Feb 2021 15:50:34 +0300 Subject: 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 --- src/courtroom.cpp | 15 +++++---------- 1 file changed, 5 insertions(+), 10 deletions(-) (limited to 'src/courtroom.cpp') diff --git a/src/courtroom.cpp b/src/courtroom.cpp index 9c9c6adb..94d7ab8e 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) -- cgit From 354fbd239c203d0ed3f9d98bd32bef6f6dbe26d6 Mon Sep 17 00:00:00 2001 From: Crystalwarrior Date: Sun, 21 Feb 2021 16:07:12 +0300 Subject: Stop hardcoding stylesheets so the behavior is more consistent finally (and courtorom_stylesheets.css is more useful) --- src/courtroom.cpp | 10 +--------- 1 file changed, 1 insertion(+), 9 deletions(-) (limited to 'src/courtroom.cpp') diff --git a/src/courtroom.cpp b/src/courtroom.cpp index 94d7ab8e..b7d8a074 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( -- cgit From d32ad43665e9218258ff57ed98b8ed457e313ee5 Mon Sep 17 00:00:00 2001 From: oldmud0 Date: Mon, 22 Feb 2021 12:54:06 -0600 Subject: Fix crash caused by pre-2.6 IC packet --- src/courtroom.cpp | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) (limited to 'src/courtroom.cpp') diff --git a/src/courtroom.cpp b/src/courtroom.cpp index b7d8a074..cc97a405 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); -- cgit From 7579457e897cba6d358bd65dba1ee05e1db87c06 Mon Sep 17 00:00:00 2001 From: oldmud0 Date: Mon, 22 Feb 2021 14:31:23 -0600 Subject: Avoid use of QImageReader copy constructor --- src/courtroom.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/courtroom.cpp') diff --git a/src/courtroom.cpp b/src/courtroom.cpp index cc97a405..4782e393 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(); -- cgit From 5ac95ada564f11419441eca32907aef7ec16dd90 Mon Sep 17 00:00:00 2001 From: Crystalwarrior Date: Wed, 24 Feb 2021 16:02:07 +0300 Subject: Make "stop music on objection" work in tandem with the server by calling "music_stop()" instead of only working on the client-side --- src/courtroom.cpp | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) (limited to 'src/courtroom.cpp') diff --git a/src/courtroom.cpp b/src/courtroom.cpp index 4782e393..c8d8320f 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); } -- cgit