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
This commit is contained in:
Crystalwarrior 2019-09-28 20:43:19 +03:00
parent d3a58770d3
commit 709ebb7e18
3 changed files with 30 additions and 44 deletions

View File

@ -3,9 +3,9 @@
#include "aoapplication.h" #include "aoapplication.h"
#include "aosfxplayer.h" #include "aosfxplayer.h"
#include "aomovie.h"
#include <QLabel> #include <QLabel>
#include <QMovie>
#include <QDebug> #include <QDebug>
class AOEvidenceDisplay : public QLabel class AOEvidenceDisplay : public QLabel
@ -18,15 +18,16 @@ public:
void show_evidence(QString p_evidence_image, bool is_left_side, int p_volume); void show_evidence(QString p_evidence_image, bool is_left_side, int p_volume);
QLabel* get_evidence_icon(); QLabel* get_evidence_icon();
void reset(); void reset();
void combo_resize(int w, int h);
private: private:
AOApplication *ao_app; AOApplication *ao_app;
QMovie *evidence_movie; AOMovie *evidence_movie;
QLabel *evidence_icon; QLabel *evidence_icon;
AOSfxPlayer *sfx_player; AOSfxPlayer *sfx_player;
private slots: private slots:
void frame_change(int p_frame); void show_done();
}; };
#endif // AOEVIDENCEDISPLAY_H #endif // AOEVIDENCEDISPLAY_H

View File

@ -7,12 +7,12 @@
AOEvidenceDisplay::AOEvidenceDisplay(QWidget *p_parent, AOApplication *p_ao_app) : QLabel(p_parent) AOEvidenceDisplay::AOEvidenceDisplay(QWidget *p_parent, AOApplication *p_ao_app) : QLabel(p_parent)
{ {
ao_app = p_ao_app; ao_app = p_ao_app;
evidence_movie = new QMovie(this);
evidence_icon = new QLabel(this); evidence_icon = new QLabel(this);
sfx_player = new AOSfxPlayer(this, ao_app); 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) 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)); 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)); evidence_movie->play(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();
sfx_player->play(ao_app->get_sfx("evidence_present")); 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() void AOEvidenceDisplay::reset()
{ {
sfx_player->stop(); sfx_player->stop();
@ -85,9 +59,20 @@ void AOEvidenceDisplay::reset()
this->clear(); this->clear();
} }
void AOEvidenceDisplay::show_done()
{
evidence_icon->show();
}
QLabel* AOEvidenceDisplay::get_evidence_icon() QLabel* AOEvidenceDisplay::get_evidence_icon()
{ {
return 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);
}

View File

@ -490,16 +490,7 @@ void Courtroom::set_widgets()
ui_vp_legacy_desk->hide(); ui_vp_legacy_desk->hide();
ui_vp_evidence_display->move(0, 0); ui_vp_evidence_display->move(0, 0);
ui_vp_evidence_display->resize(ui_viewport->width(), ui_viewport->height()); ui_vp_evidence_display->combo_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_chat_arrow->move(0, 0); ui_vp_chat_arrow->move(0, 0);
pos_size_type design_ini_result = ao_app->get_element_dimensions("chat_arrow", "courtroom_design.ini"); 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->set_image("chatblank");
ui_vp_chatbox->hide(); 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->resize(ui_ic_chat_message->width(), ui_ic_chat_message->height());
ui_muted->set_image("muted"); ui_muted->set_image("muted");
ui_muted->setToolTip(tr("Oops, you're 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_custom_objection->set_image("custom");
ui_realization->set_image("realization"); ui_realization->set_image("realization");
ui_screenshake->set_image("screenshake"); 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. //Let the server handle actually checking if they're allowed to do this.