From 709ebb7e1872394731c2edb282a1ce73fdc353f9 Mon Sep 17 00:00:00 2001 From: Crystalwarrior Date: Sat, 28 Sep 2019 20:43:19 +0300 Subject: [PATCH] Fix AOEvidenceDisplay not respecting the size of the viewport properly and breaking if a static image was used for evidence appearance Fix an issue with chat message being resized before the chat box is in reload theme --- include/aoevidencedisplay.h | 7 +++--- src/aoevidencedisplay.cpp | 45 +++++++++++++------------------------ src/courtroom.cpp | 22 +++++++++--------- 3 files changed, 30 insertions(+), 44 deletions(-) diff --git a/include/aoevidencedisplay.h b/include/aoevidencedisplay.h index 13ca00d..93455c0 100644 --- a/include/aoevidencedisplay.h +++ b/include/aoevidencedisplay.h @@ -3,9 +3,9 @@ #include "aoapplication.h" #include "aosfxplayer.h" +#include "aomovie.h" #include -#include #include class AOEvidenceDisplay : public QLabel @@ -18,15 +18,16 @@ public: void show_evidence(QString p_evidence_image, bool is_left_side, int p_volume); QLabel* get_evidence_icon(); void reset(); + void combo_resize(int w, int h); private: AOApplication *ao_app; - QMovie *evidence_movie; + AOMovie *evidence_movie; QLabel *evidence_icon; AOSfxPlayer *sfx_player; private slots: - void frame_change(int p_frame); + void show_done(); }; #endif // AOEVIDENCEDISPLAY_H diff --git a/src/aoevidencedisplay.cpp b/src/aoevidencedisplay.cpp index 3fde05a..fef072b 100644 --- a/src/aoevidencedisplay.cpp +++ b/src/aoevidencedisplay.cpp @@ -7,12 +7,12 @@ AOEvidenceDisplay::AOEvidenceDisplay(QWidget *p_parent, AOApplication *p_ao_app) : QLabel(p_parent) { ao_app = p_ao_app; - - evidence_movie = new QMovie(this); evidence_icon = new QLabel(this); sfx_player = new AOSfxPlayer(this, ao_app); - connect(evidence_movie, SIGNAL(frameChanged(int)), this, SLOT(frame_change(int))); + evidence_movie = new AOMovie(this, ao_app); + + connect(evidence_movie, SIGNAL(done()), this, SLOT(show_done())); } void AOEvidenceDisplay::show_evidence(QString p_evidence_image, bool is_left_side, int p_volume) @@ -47,36 +47,10 @@ void AOEvidenceDisplay::show_evidence(QString p_evidence_image, bool is_left_sid evidence_icon->setPixmap(f_pixmap.scaled(evidence_icon->width(), evidence_icon->height(), Qt::IgnoreAspectRatio)); - QString f_default_gif_path = ao_app->get_image_suffix(ao_app->get_default_theme_path(gif_name)); - QString f_gif_path = ao_app->get_image_suffix(ao_app->get_theme_path(gif_name)); - - if (file_exists(f_gif_path)) - final_gif_path = f_gif_path; - else - final_gif_path = f_default_gif_path; - - evidence_movie->setFileName(final_gif_path); - - this->setMovie(evidence_movie); - - evidence_movie->start(); + evidence_movie->play(gif_name); sfx_player->play(ao_app->get_sfx("evidence_present")); } -void AOEvidenceDisplay::frame_change(int p_frame) -{ - if (p_frame == (evidence_movie->frameCount() - 1)) - { - //we need this or else the last frame wont show - delay(evidence_movie->nextFrameDelay()); - - evidence_movie->stop(); - this->clear(); - - evidence_icon->show(); - } -} - void AOEvidenceDisplay::reset() { sfx_player->stop(); @@ -85,9 +59,20 @@ void AOEvidenceDisplay::reset() this->clear(); } +void AOEvidenceDisplay::show_done() +{ + evidence_icon->show(); +} + QLabel* AOEvidenceDisplay::get_evidence_icon() { return evidence_icon; } +void AOEvidenceDisplay::combo_resize(int w, int h) +{ + QSize f_size(w, h); + this->resize(f_size); + evidence_movie->combo_resize(w, h); +} diff --git a/src/courtroom.cpp b/src/courtroom.cpp index 428d98c..6ea98f1 100644 --- a/src/courtroom.cpp +++ b/src/courtroom.cpp @@ -490,16 +490,7 @@ void Courtroom::set_widgets() ui_vp_legacy_desk->hide(); ui_vp_evidence_display->move(0, 0); - ui_vp_evidence_display->resize(ui_viewport->width(), ui_viewport->height()); - - set_size_and_pos(ui_vp_showname, "showname"); - - set_size_and_pos(ui_vp_message, "message"); - //We detached the text as parent from the chatbox so it doesn't get affected by the screenshake. - ui_vp_message->move(ui_vp_message->x() + ui_vp_chatbox->x(), ui_vp_message->y() + ui_vp_chatbox->y()); - ui_vp_message->setTextInteractionFlags(Qt::NoTextInteraction); -// ui_vp_message->setStyleSheet("background-color: rgba(0, 0, 0, 0);" -// "color: white"); + ui_vp_evidence_display->combo_resize(ui_viewport->width(), ui_viewport->height()); ui_vp_chat_arrow->move(0, 0); pos_size_type design_ini_result = ao_app->get_element_dimensions("chat_arrow", "courtroom_design.ini"); @@ -586,6 +577,15 @@ void Courtroom::set_widgets() ui_vp_chatbox->set_image("chatblank"); ui_vp_chatbox->hide(); + set_size_and_pos(ui_vp_showname, "showname"); + + set_size_and_pos(ui_vp_message, "message"); + //We detached the text as parent from the chatbox so it doesn't get affected by the screenshake. + ui_vp_message->move(ui_vp_message->x() + ui_vp_chatbox->x(), ui_vp_message->y() + ui_vp_chatbox->y()); + ui_vp_message->setTextInteractionFlags(Qt::NoTextInteraction); +// ui_vp_message->setStyleSheet("background-color: rgba(0, 0, 0, 0);" +// "color: white"); + ui_muted->resize(ui_ic_chat_message->width(), ui_ic_chat_message->height()); ui_muted->set_image("muted"); ui_muted->setToolTip(tr("Oops, you're muted!")); @@ -1582,7 +1582,7 @@ void Courtroom::handle_chatmessage(QStringList *p_contents) ui_custom_objection->set_image("custom"); ui_realization->set_image("realization"); ui_screenshake->set_image("screenshake"); - ui_evidence_present->set_image("present_disabled"); + ui_evidence_present->set_image("present"); } //Let the server handle actually checking if they're allowed to do this.