From 50beb7de444e8cd544702e00da945853b9929bed Mon Sep 17 00:00:00 2001 From: Salanto <62221668+Salanto@users.noreply.github.com> Date: Sun, 29 Jan 2023 22:11:04 +0100 Subject: [PATCH] Fix incorrect judge-button display behaviour(#884) Co-authored-by: stonedDiscord --- src/courtroom.cpp | 20 ++++++++------------ src/packet_distribution.cpp | 4 +++- 2 files changed, 11 insertions(+), 13 deletions(-) diff --git a/src/courtroom.cpp b/src/courtroom.cpp index acbcd1d..a08b5e1 100644 --- a/src/courtroom.cpp +++ b/src/courtroom.cpp @@ -1420,17 +1420,13 @@ void Courtroom::set_background(QString p_background, bool display) void Courtroom::set_side(QString p_side) { - QString f_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); - ui_pos_remove->hide(); + if (p_side.isEmpty() || p_side == ao_app->get_char_side(current_char)) { + ui_pos_remove->hide(); + current_side = ao_app->get_char_side(current_char); } else { - f_side = current_side; - ui_pos_remove->show(); + ui_pos_remove->show(); + current_side = p_side; } set_judge_buttons(); @@ -1440,7 +1436,7 @@ void Courtroom::set_side(QString p_side) 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) { + if (pos == current_side) { // Set the index on dropdown ui element to let you know what pos you're on // right now @@ -1453,7 +1449,7 @@ void Courtroom::set_side(QString p_side) } } // We will only get there if we failed the last step - ui_pos_dropdown->setEditText(f_side); + ui_pos_dropdown->setEditText(current_side); // Unblock the signals so the element can be used for setting pos again ui_pos_dropdown->blockSignals(false); } @@ -1479,7 +1475,6 @@ void Courtroom::set_pos_dropdown(QStringList pos_dropdowns) // Unblock the signals so the element can be used for setting pos again ui_pos_dropdown->blockSignals(false); - set_side(current_side); } void Courtroom::update_character(int p_cid, QString char_name, bool reset_emote) @@ -1506,6 +1501,7 @@ void Courtroom::update_character(int p_cid, QString char_name, bool reset_emote) } current_char = f_char; + current_side = ao_app->get_char_side(current_char); set_side(current_side); set_text_color_dropdown(); diff --git a/src/packet_distribution.cpp b/src/packet_distribution.cpp index db7d261..9c05b65 100644 --- a/src/packet_distribution.cpp +++ b/src/packet_distribution.cpp @@ -388,7 +388,9 @@ void AOApplication::server_packet_received(AOPacket *p_packet) if (f_contents.size() >= 2) { // We have a pos included in the background packet! - w_courtroom->set_side(f_contents.at(1)); + if (!f_contents.at(1).isEmpty()) + //Not touching it when its empty. + w_courtroom->set_side(f_contents.at(1)); } w_courtroom->set_background(f_contents.at(0), f_contents.size() >= 2); }