aboutsummaryrefslogtreecommitdiff
path: root/src/courtroom.cpp
diff options
context:
space:
mode:
authorRosemary Witchaven <32779090+in1tiate@users.noreply.github.com>2022-03-29 09:37:02 -0500
committerGitHub <noreply@github.com>2022-03-29 17:37:02 +0300
commit68d0b838cf5abf01c4956a9f079fa76fef340a2e (patch)
tree46f51c1cce650270d273f4013a0f480ce0e391d8 /src/courtroom.cpp
parent18412cc9303b1c11c8e35818d57b39aee72a5ec2 (diff)
Add two ways of controlling judge buttons that aren't hardcoded nonsense (networked and local) (#537)
* add both network and local ways to show judge buttons on pos other than jud * hide judge buttons when pos_removing to a non-judge position * alter packet header * Only use pos jud hardcoding if no design.ini if design.ini does not define judges= then we fall back to pos jud garbage * Fix judge buttons being disabled if default_side pos is judge (logic poopy) Fix positions.isEmpty() returning False cuz a split of an empty string returns the list with an empty string by default * Expand JD packet to be able to send -1, 0 and 1. If -1 is received, fall back on client-sided judge button behavior. If 0 or 1 is received, treat it as "absolute override" and adhere to that packet. * alter check for empty qstringlist to support old qt versions * heehoo * trigger client side behavior when jd -1 is sent * less confusing variable names * remove useless code, trim some fat Co-authored-by: oldmud0 <oldmud0@users.noreply.github.com> * use an enum dammit! & warn on malformed auth * use an enum dammit! pt. 2 * appease clang, rewrite ugly judge controls function * please squash this its so bad Co-authored-by: Crystalwarrior <Varsash@Gmail.com> Co-authored-by: oldmud0 <oldmud0@users.noreply.github.com>
Diffstat (limited to 'src/courtroom.cpp')
-rw-r--r--src/courtroom.cpp50
1 files changed, 25 insertions, 25 deletions
diff --git a/src/courtroom.cpp b/src/courtroom.cpp
index 8e60994f..1e1fcd0f 100644
--- a/src/courtroom.cpp
+++ b/src/courtroom.cpp
@@ -1406,10 +1406,7 @@ void Courtroom::set_side(QString p_side)
ui_pos_remove->show();
}
- toggle_judge_buttons(false);
-
- if (f_side == "jud")
- toggle_judge_buttons(true);
+ set_judge_buttons();
// Block the signals to prevent setCurrentIndex from triggering a pos
// change
@@ -4042,27 +4039,28 @@ void Courtroom::set_hp_bar(int p_bar, int p_state)
}
}
-void Courtroom::toggle_judge_buttons(bool is_on)
+void Courtroom::show_judge_controls(bool visible)
{
- if (is_on) {
- ui_witness_testimony->show();
- ui_cross_examination->show();
- ui_guilty->show();
- ui_not_guilty->show();
- ui_defense_minus->show();
- ui_defense_plus->show();
- ui_prosecution_minus->show();
- ui_prosecution_plus->show();
+ if (judge_state != POS_DEPENDENT) {
+ visible = judge_state == SHOW_CONTROLS; // Server-side override
}
- 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();
+ QList<QWidget*> judge_controls =
+ {
+ ui_witness_testimony,
+ ui_cross_examination,
+ ui_guilty,
+ ui_not_guilty,
+ ui_defense_minus,
+ ui_defense_plus,
+ ui_prosecution_minus,
+ ui_prosecution_plus
+ };
+
+ for (QWidget* control : judge_controls) {
+ if (visible)
+ control->show();
+ else
+ control->hide();
}
}
@@ -4093,10 +4091,10 @@ void Courtroom::on_ooc_return_pressed()
//Using an arbitrary 2.8 feature flag certainly won't cause issues someday.
if (ooc_message.startsWith("/pos") & !ao_app->effects_enabled) {
if (ooc_message == "/pos jud") {
- toggle_judge_buttons(true);
+ show_judge_controls(true);
}
else {
- toggle_judge_buttons(false);
+ show_judge_controls(false);
}
}
@@ -4373,6 +4371,8 @@ void Courtroom::on_pos_remove_clicked()
ui_pos_dropdown->blockSignals(true);
QString default_side = ao_app->get_char_side(current_char);
+ show_judge_controls(ao_app->get_pos_is_judge(default_side));
+
for (int i = 0; i < ui_pos_dropdown->count(); ++i) {
QString pos = ui_pos_dropdown->itemText(i);
if (pos == default_side) {