This repository has been archived by the owner on Jun 10, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
aoevidencedisplay.cpp
111 lines (83 loc) · 2.63 KB
/
aoevidencedisplay.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
//////////////////////////////////////////////////
//
// This work is licensed under the MIT license.
//
// You are free to copy, modify and distribute
// this work freely given that proper attribution
// is supplied and the author is not held liable.
// See LICENSE for details.
//
// Copyright (c) 2016-2018 David "OmniTroid" Skoland
//
//////////////////////////////////////////////////
#include <QDebug>
#include "aoevidencedisplay.h"
#include "file_functions.h"
#include "datatypes.h"
#include "misc_functions.h"
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)));
}
void AOEvidenceDisplay::show_evidence(QString p_evidence_image, bool is_left_side, int p_volume)
{
this->reset();
sfx_player->set_volume(p_volume);
QString f_evidence_path = ao_app->get_evidence_path() + p_evidence_image;
QPixmap f_pixmap(f_evidence_path);
QString final_gif_path;
QString gif_name;
QString icon_identifier;
if (is_left_side)
{
icon_identifier = "left_evidence_icon";
gif_name = "evidence_appear_left.gif";
}
else
{
icon_identifier = "right_evidence_icon";
gif_name = "evidence_appear_right.gif";
}
pos_size_type icon_dimensions = ao_app->get_element_dimensions(icon_identifier, "courtroom_design.ini");
evidence_icon->move(icon_dimensions.x, icon_dimensions.y);
evidence_icon->resize(icon_dimensions.width, icon_dimensions.height);
evidence_icon->setPixmap(f_pixmap.scaled(evidence_icon->width(), evidence_icon->height(), Qt::IgnoreAspectRatio));
QString f_default_gif_path = ao_app->get_default_theme_path() + gif_name;
QString f_gif_path = 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);
if(evidence_movie->frameCount() < 1)
return;
this->setMovie(evidence_movie);
evidence_movie->start();
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();
evidence_movie->stop();
evidence_icon->hide();
this->clear();
}
QLabel* AOEvidenceDisplay::get_evidence_icon()
{
return evidence_icon;
}