@@ -1275,58 +1275,47 @@ void Courtroom::set_background(QString p_background, bool display)
12751275 }
12761276}
12771277
1278- void Courtroom::set_side (QString p_side, bool block_signals )
1278+ void Courtroom::set_side (QString p_side)
12791279{
12801280 QString f_side;
1281- if (p_side == " " )
1281+ if (p_side == ao_app->get_char_side (current_char))
1282+ p_side = " " ;
1283+ current_side = p_side;
1284+ if (current_side == " " ) {
12821285 f_side = ao_app->get_char_side (current_char);
1283- else
1284- f_side = p_side;
1285-
1286- if (f_side == " jud" ) {
1287- ui_witness_testimony->show ();
1288- ui_cross_examination->show ();
1289- ui_not_guilty->show ();
1290- ui_guilty->show ();
1291- ui_defense_minus->show ();
1292- ui_defense_plus->show ();
1293- ui_prosecution_minus->show ();
1294- ui_prosecution_plus->show ();
1286+ ui_pos_remove->hide ();
12951287 }
12961288 else {
1297- ui_witness_testimony->hide ();
1298- ui_cross_examination->hide ();
1299- ui_guilty->hide ();
1300- ui_not_guilty->hide ();
1301- ui_defense_minus->hide ();
1302- ui_defense_plus->hide ();
1303- ui_prosecution_minus->hide ();
1304- ui_prosecution_plus->hide ();
1289+ f_side = current_side;
1290+ ui_pos_remove->show ();
13051291 }
13061292
1293+ toggle_judge_buttons (false );
1294+
1295+ if (f_side == " jud" )
1296+ toggle_judge_buttons (true );
1297+
1298+ // Block the signals to prevent setCurrentIndex from triggering a pos
1299+ // change
1300+ ui_pos_dropdown->blockSignals (true );
13071301 for (int i = 0 ; i < ui_pos_dropdown->count (); ++i) {
13081302 QString pos = ui_pos_dropdown->itemText (i);
13091303 if (pos == f_side) {
1310- // Block the signals to prevent setCurrentIndex from triggering a pos
1311- // change
1312- if (block_signals)
1313- ui_pos_dropdown->blockSignals (true );
13141304
13151305 // Set the index on dropdown ui element to let you know what pos you're on
13161306 // right now
13171307 ui_pos_dropdown->setCurrentIndex (i);
1318-
13191308 // Unblock the signals so the element can be used for setting pos again
1320- if (block_signals)
1321- ui_pos_dropdown->blockSignals (false );
1309+ ui_pos_dropdown->blockSignals (false );
13221310
13231311 // alright we dun, jobs done here boyos
13241312 return ;
13251313 }
13261314 }
13271315 // We will only get there if we failed the last step
13281316 ui_pos_dropdown->setEditText (f_side);
1329- ui_pos_remove->show ();
1317+ // Unblock the signals so the element can be used for setting pos again
1318+ ui_pos_dropdown->blockSignals (false );
13301319}
13311320
13321321void Courtroom::set_pos_dropdown (QStringList pos_dropdowns)
@@ -1336,12 +1325,13 @@ void Courtroom::set_pos_dropdown(QStringList pos_dropdowns)
13361325 pos_dropdown_list = pos_dropdowns;
13371326 ui_pos_dropdown->clear ();
13381327 ui_pos_dropdown->addItems (pos_dropdown_list);
1339- if (current_side != " " && !pos_dropdown_list.contains (current_side)) {
1328+
1329+ if (current_side != " " && !pos_dropdown_list.contains (current_side))
13401330 ui_pos_dropdown->setEditText (current_side);
1341- ui_pos_remove->show ();
1342- }
1331+
13431332 // Unblock the signals so the element can be used for setting pos again
13441333 ui_pos_dropdown->blockSignals (false );
1334+ // Don't block the signals when setting side
13451335 set_side (current_side);
13461336}
13471337
@@ -3699,7 +3689,7 @@ void Courtroom::handle_song(QStringList *p_contents)
36993689 if (f_song == " ~stop.mp3" )
37003690 ui_music_name->setText (tr (" None" ));
37013691 else if (channel == 0 ) {
3702- if (file_exists (ao_app->get_sfx_suffix (ao_app->get_music_path (f_song))) & !f_song.startsWith (" http" ))
3692+ if (file_exists (ao_app->get_sfx_suffix (ao_app->get_music_path (f_song))) && !f_song.startsWith (" http" ))
37033693 ui_music_name->setText (f_song_clear);
37043694 else if (f_song.startsWith (" http" ))
37053695 ui_music_name->setText (tr (" [STREAM] %1" ).arg (f_song_clear));
@@ -3743,7 +3733,7 @@ void Courtroom::handle_song(QStringList *p_contents)
37433733 if (is_stop)
37443734 ui_music_name->setText (tr (" None" ));
37453735 else if (channel == 0 ) {
3746- if (file_exists (ao_app->get_sfx_suffix (ao_app->get_music_path (f_song))) & !f_song.startsWith (" http" ))
3736+ if (file_exists (ao_app->get_sfx_suffix (ao_app->get_music_path (f_song))) && !f_song.startsWith (" http" ))
37473737 ui_music_name->setText (f_song_clear);
37483738 else if (f_song.startsWith (" http" ))
37493739 ui_music_name->setText (tr (" [STREAM] %1" ).arg (f_song_clear));
@@ -4280,22 +4270,12 @@ void Courtroom::on_pos_dropdown_changed(int p_index)
42804270
42814271void Courtroom::on_pos_dropdown_changed (QString p_text)
42824272{
4283- toggle_judge_buttons (false );
4284-
4285- if (p_text == " jud" )
4286- toggle_judge_buttons (true );
4287-
4288- ui_pos_remove->show ();
4289-
4290- current_side = p_text;
4291-
4292- // YEAH SENDING LIKE 20 PACKETS IF THE USER SCROLLS THROUGH, GREAT IDEA
4293- // how about this instead
42944273 set_side (p_text);
42954274}
42964275
42974276void Courtroom::on_pos_remove_clicked ()
42984277{
4278+ ui_pos_dropdown->blockSignals (true );
42994279 QString default_side = ao_app->get_char_side (current_char);
43004280
43014281 for (int i = 0 ; i < ui_pos_dropdown->count (); ++i) {
@@ -4306,8 +4286,7 @@ void Courtroom::on_pos_remove_clicked()
43064286 }
43074287 }
43084288 int wit_index = ui_pos_dropdown->findText (" wit" );
4309- ui_pos_dropdown->blockSignals (true );
4310- if ((ui_pos_dropdown->currentText () != default_side) & (wit_index != -1 )) // i.e. this bg doesn't have our pos
4289+ if (ui_pos_dropdown->currentText () != default_side && wit_index != -1 ) // i.e. this bg doesn't have our pos
43114290 ui_pos_dropdown->setCurrentIndex (wit_index); // fall back to "wit"
43124291 else if (ui_pos_dropdown->currentText () != default_side) // we don't have "wit" either?
43134292 ui_pos_dropdown->setCurrentIndex (0 ); // as a last resort, choose the first item in the dropdown
0 commit comments