Make "stop music on objection" work in tandem with the server by calling "music_stop()" instead of only working on the client-side

This commit is contained in:
Crystalwarrior 2021-02-24 16:02:07 +03:00
parent 7579457e89
commit 5ac95ada56
3 changed files with 13 additions and 8 deletions

View File

@ -822,7 +822,7 @@ private slots:
void music_random(); void music_random();
void music_list_expand_all(); void music_list_expand_all();
void music_list_collapse_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 on_area_list_double_clicked(QTreeWidgetItem *p_item, int column);
void select_emote(int p_id); void select_emote(int p_id);

View File

@ -704,8 +704,7 @@ AOOptionsDialog::AOOptionsDialog(QWidget *parent, AOApplication *p_ao_app)
ui_objectmusic_lbl = new QLabel(ui_audio_widget); ui_objectmusic_lbl = new QLabel(ui_audio_widget);
ui_objectmusic_lbl->setText(tr("Kill Music On Objection:")); ui_objectmusic_lbl->setText(tr("Kill Music On Objection:"));
ui_objectmusic_lbl->setToolTip( ui_objectmusic_lbl->setToolTip(
tr("If true, AO2 will stop the music for you when you or someone else " tr("If true, AO2 will ask the server to stop music when you use 'Objection!' "));
"does 'Objection!'."));
ui_audio_layout->setWidget(row, QFormLayout::LabelRole, ui_objectmusic_lbl); ui_audio_layout->setWidget(row, QFormLayout::LabelRole, ui_objectmusic_lbl);

View File

@ -1747,6 +1747,10 @@ void Courtroom::on_chat_return_pressed()
else else
f_obj_state = QString::number(objection_state); 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); packet_contents.append(f_obj_state);
if (is_presenting_evidence) if (is_presenting_evidence)
@ -2166,8 +2170,6 @@ bool Courtroom::handle_objection()
filename = "objection_bubble"; filename = "objection_bubble";
objection_player->play("objection", m_chatmessage[CHAR_NAME], objection_player->play("objection", m_chatmessage[CHAR_NAME],
ao_app->get_chat(m_chatmessage[CHAR_NAME])); ao_app->get_chat(m_chatmessage[CHAR_NAME]));
if (ao_app->objection_stop_music())
music_player->stop();
break; break;
case 3: case 3:
filename = "takethat_bubble"; filename = "takethat_bubble";
@ -4777,7 +4779,7 @@ void Courtroom::music_list_collapse_all()
ui_music_list->setCurrentItem(current); ui_music_list->setCurrentItem(current);
} }
void Courtroom::music_stop() void Courtroom::music_stop(bool no_effects)
{ {
if (is_muted) if (is_muted)
return; return;
@ -4802,8 +4804,12 @@ void Courtroom::music_stop()
if ((!ui_ic_chat_name->text().isEmpty() && ao_app->cccc_ic_support_enabled) || if ((!ui_ic_chat_name->text().isEmpty() && ao_app->cccc_ic_support_enabled) ||
ao_app->effects_enabled) ao_app->effects_enabled)
packet_contents.append(ui_ic_chat_name->text()); packet_contents.append(ui_ic_chat_name->text());
if (ao_app->effects_enabled) if (ao_app->effects_enabled) {
packet_contents.append(QString::number(music_flags)); 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); ao_app->send_server_packet(new AOPacket("MC", packet_contents), false);
} }