forked from AttorneyOnline/AO2-Client
-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathaomovie.cpp
More file actions
103 lines (81 loc) · 2.37 KB
/
aomovie.cpp
File metadata and controls
103 lines (81 loc) · 2.37 KB
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
#include "aomovie.h"
#include "file_functions.h"
#include "courtroom.h"
#include "misc_functions.h"
AOMovie::AOMovie(QWidget *p_parent, AOApplication *p_ao_app) : QLabel(p_parent)
{
ao_app = p_ao_app;
m_movie = new QMovie();
this->setMovie(m_movie);
connect(m_movie, SIGNAL(frameChanged(int)), this, SLOT(frame_change(int)));
}
void AOMovie::set_play_once(bool p_play_once)
{
play_once = p_play_once;
}
void AOMovie::play(QString p_file, QString p_char, QString p_custom_theme)
{
m_movie->stop();
QVector<QString> f_vec;
QString file_path = "";
QString custom_path;
if (p_file == "custom")
custom_path = ao_app->get_character_path(p_char) + p_file;
else
custom_path = ao_app->get_character_path(p_char) + p_file + "_bubble";
f_vec.push_back(custom_path);
QString overlay_path = ao_app->get_character_path(p_char) + "overlay/" + p_file;
QString custom_theme_path = ao_app->get_base_path() + "themes/" + p_custom_theme + "/" + p_file;
QString theme_path = ao_app->get_theme_path() + p_file;
QString default_theme_path = ao_app->get_default_theme_path() + p_file;
QString placeholder_path = ao_app->get_theme_path() + "placeholder";
QString default_placeholder_path = ao_app->get_default_theme_path() + "placeholder";
f_vec.push_back(overlay_path);
f_vec.push_back(custom_theme_path);
f_vec.push_back(theme_path);
f_vec.push_back(default_theme_path);
f_vec.push_back(placeholder_path);
f_vec.push_back(default_placeholder_path);
for(auto &f_file : f_vec)
{
bool found = false;
for (auto &ext : decltype(f_vec){".apng", ".gif", ".png"})
{
QString fullPath = f_file + ext;
found = file_exists(fullPath);
if (found)
{
file_path = fullPath;
break;
}
}
if (found)
break;
}
m_movie->setFileName(file_path);
this->show();
m_movie->setScaledSize(this->size());
m_movie->start();
}
void AOMovie::stop()
{
m_movie->stop();
this->hide();
}
void AOMovie::frame_change(int n_frame)
{
if (n_frame == (m_movie->frameCount() - 1) && play_once)
{
//we need this or else the last frame wont show
delay(m_movie->nextFrameDelay());
this->stop();
//signal connected to courtroom object, let it figure out what to do
emit done();
}
}
void AOMovie::combo_resize(int w, int h)
{
QSize f_size(w, h);
this->resize(f_size);
m_movie->setScaledSize(f_size);
}