From dc79673bee14efc6ed422dc37b231490686d8b5b Mon Sep 17 00:00:00 2001 From: OmniTroid Date: Fri, 16 Jun 2017 08:16:09 +0200 Subject: [PATCH] fixed evidence description bug and local mute --- aoevidencebutton.cpp | 18 ++++++++++++++++- aoevidencebutton.h | 2 ++ courtroom.cpp | 46 +++++++++++++++++++++++++++++++++++++++++--- courtroom.h | 8 +++++++- evidence.cpp | 8 ++++++-- 5 files changed, 75 insertions(+), 7 deletions(-) diff --git a/aoevidencebutton.cpp b/aoevidencebutton.cpp index 36f4adf..96bf553 100644 --- a/aoevidencebutton.cpp +++ b/aoevidencebutton.cpp @@ -25,6 +25,7 @@ AOEvidenceButton::AOEvidenceButton(QWidget *p_parent, AOApplication *p_ao_app, i this->move(p_x, p_y); this->resize(70, 70); + this->setAcceptDrops(true); connect(this, SIGNAL(clicked()), this, SLOT(on_clicked())); } @@ -81,11 +82,26 @@ void AOEvidenceButton::on_clicked() evidence_clicked(m_id); } -void AOEvidenceButton::mouseDoubleClickEvent(QMouseEvent *e) { +void AOEvidenceButton::mouseDoubleClickEvent(QMouseEvent *e) +{ QPushButton::mouseDoubleClickEvent(e); evidence_double_clicked(m_id); } +void AOEvidenceButton::dragLeaveEvent(QMouseEvent *e) +{ + //QWidget::dragLeaveEvent(e); + + qDebug() << "drag leave event"; +} + +void AOEvidenceButton::dragEnterEvent(QMouseEvent *e) +{ + //QWidget::dragEnterEvent(e); + + qDebug() << "drag enter event"; +} + void AOEvidenceButton::enterEvent(QEvent * e) { ui_selector->show(); diff --git a/aoevidencebutton.h b/aoevidencebutton.h index 9657f07..ee0a0f6 100644 --- a/aoevidencebutton.h +++ b/aoevidencebutton.h @@ -34,6 +34,8 @@ protected: void enterEvent(QEvent *e); void leaveEvent(QEvent *e); void mouseDoubleClickEvent(QMouseEvent *e); + void dragLeaveEvent(QMouseEvent *e); + void dragEnterEvent(QMouseEvent *e); signals: void evidence_clicked(int p_id); diff --git a/courtroom.cpp b/courtroom.cpp index 2b15139..137ab72 100644 --- a/courtroom.cpp +++ b/courtroom.cpp @@ -266,6 +266,12 @@ void Courtroom::set_mute_list() { mute_map.clear(); + //maps which characters are muted based on cid, none are muted by default + for (int n_cid = 0 ; n_cid < char_list.size() ; n_cid++) + { + mute_map.insert(n_cid, false); + } + QStringList sorted_mute_list; for (char_type i_char : char_list) @@ -275,7 +281,7 @@ void Courtroom::set_mute_list() for (QString i_name : sorted_mute_list) { - mute_map.insert(i_name, false); + //mute_map.insert(i_name, false); ui_mute_list->addItem(i_name); } } @@ -913,7 +919,7 @@ void Courtroom::handle_chatmessage(QStringList *p_contents) if (f_char_id < 0 || f_char_id >= char_list.size()) return; - if (mute_map.value(m_chatmessage[CHAR_NAME])) + if (mute_map.value(m_chatmessage[CHAR_ID].toInt())) return; QString f_showname = ao_app->get_showname(char_list.at(f_char_id).name); @@ -1507,7 +1513,7 @@ void Courtroom::handle_song(QStringList *p_contents) { QString str_char = char_list.at(n_char).name; - if (!mute_map.value(str_char)) + if (!mute_map.value(n_char)) { append_ic_text(str_char + " has played a song: " + f_song + "\n"); music_player->play(f_song); @@ -1689,6 +1695,39 @@ void Courtroom::on_mute_list_clicked(QModelIndex p_index) QString f_char = f_item->text(); QString real_char; + if (f_char.endsWith(" [x]")) + real_char = f_char.left(f_char.size() - 4); + else + real_char = f_char; + + int f_cid = -1; + + for (int n_char = 0 ; n_char < char_list.size() ; n_char++) + { + if (char_list.at(n_char).name == real_char) + f_cid = n_char; + } + + if (f_cid < 0 || f_cid >= char_list.size()) + { + qDebug() << "W: " << real_char << " not present in char_list"; + return; + } + + if (mute_map.value(f_cid)) + { + mute_map.insert(f_cid, false); + f_item->setText(real_char); + } + else + { + mute_map.insert(f_cid, true); + f_item->setText(real_char + " [x]"); + } + + + + /* if (f_char.endsWith(" [x]")) { real_char = f_char.left(f_char.size() - 4); @@ -1703,6 +1742,7 @@ void Courtroom::on_mute_list_clicked(QModelIndex p_index) mute_map.insert(real_char, true); f_item->setText(real_char + " [x]"); } + */ } void Courtroom::on_music_list_double_clicked(QModelIndex p_model) diff --git a/courtroom.h b/courtroom.h index cd4679f..8221f00 100644 --- a/courtroom.h +++ b/courtroom.h @@ -153,10 +153,16 @@ private: bool testimony_in_progress = false; + //in milliseconds const int testimony_show_time = 1500; + + //in milliseconds const int testimony_hide_time = 500; - QMap mute_map; + //char id, muted or not + QMap mute_map; + + //QVector muted_cids; bool is_muted = false; diff --git a/evidence.cpp b/evidence.cpp index ba38d61..a20fd06 100644 --- a/evidence.cpp +++ b/evidence.cpp @@ -214,10 +214,14 @@ void Courtroom::on_evidence_clicked(int p_id) void Courtroom::on_evidence_double_clicked(int p_id) { - if (p_id >= local_evidence_list.size()) + int f_real_id = p_id + max_evidence_on_page * current_evidence_page; + + if (f_real_id >= local_evidence_list.size()) return; - evi_type f_evi = local_evidence_list.at(p_id); + current_evidence = f_real_id; + + evi_type f_evi = local_evidence_list.at(f_real_id); ui_evidence_description->clear(); ui_evidence_description->appendPlainText(f_evi.description);