Skip to content

Commit de4115e

Browse files
Merge branch 'master' into crystalwarrior/demo-reload
2 parents 43340e8 + 5fca085 commit de4115e

15 files changed

Lines changed: 219 additions & 155 deletions

include/aoimage.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111

1212
class AOImage : public QLabel {
1313
public:
14-
AOImage(QWidget *parent, AOApplication *p_ao_app);
14+
AOImage(QWidget *parent, AOApplication *p_ao_app, bool make_static = false);
1515
~AOImage();
1616

1717
QWidget *m_parent;
@@ -20,6 +20,8 @@ class AOImage : public QLabel {
2020

2121
QString path;
2222

23+
bool is_static = false;
24+
2325
bool set_image(QString p_image, QString p_misc = "");
2426
void set_size_and_pos(QString identifier);
2527
};

include/aolayer.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@ class AOLayer : public QLabel {
5252
bool force_continuous = false;
5353
Qt::TransformationMode transform_mode = Qt::FastTransformation; // transformation mode to use for this image
5454
bool stretch = false; // Should we stretch/squash this image to fill the screen?
55+
bool masked = true; // Set a mask to the dimensions of the widget?
5556

5657
// Set the movie's image to provided paths, preparing for playback.
5758
void start_playback(QString p_image);

include/courtroom.h

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -235,7 +235,7 @@ class Courtroom : public QMainWindow {
235235
DISPLAY_AND_IO
236236
};
237237
// Log the message contents and information such as evidence presenting etc. into the log file, the IC log, or both.
238-
void log_chatmessage(QString f_message, int f_char_id, QString f_showname = "", int f_color = 0, LogMode f_log_mode=IO_ONLY);
238+
void log_chatmessage(QString f_message, int f_char_id, QString f_showname = "", QString f_char = "", QString f_objection_mod = "", int f_evi_id = 0, int f_color = 0, LogMode f_log_mode=IO_ONLY);
239239

240240
// Log the message contents and information such as evidence presenting etc. into the IC logs
241241
void handle_callwords();
@@ -755,7 +755,6 @@ class Courtroom : public QMainWindow {
755755

756756
QVector<AOCharButton *> ui_char_button_list;
757757
QVector<AOCharButton *> ui_char_button_list_filtered;
758-
AOImage *ui_selector;
759758

760759
AOButton *ui_back_to_lobby;
761760

include/demoserver.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
#include <QTcpSocket>
1111
#include <QTimer>
1212
#include <QFileDialog>
13+
#include <QMessageBox>
1314

1415
class DemoServer : public QObject
1516
{

src/aocharbutton.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,19 +15,19 @@ AOCharButton::AOCharButton(QWidget *parent, AOApplication *p_ao_app, int x_pos,
1515
this->resize(60, 60);
1616
this->move(x_pos, y_pos);
1717

18-
ui_taken = new AOImage(this, ao_app);
18+
ui_taken = new AOImage(this, ao_app, true);
1919
ui_taken->resize(60, 60);
2020
ui_taken->set_image("char_taken");
2121
ui_taken->setAttribute(Qt::WA_TransparentForMouseEvents);
2222
ui_taken->hide();
2323

24-
ui_passworded = new AOImage(this, ao_app);
24+
ui_passworded = new AOImage(this, ao_app, true);
2525
ui_passworded->resize(60, 60);
2626
ui_passworded->set_image("char_passworded");
2727
ui_passworded->setAttribute(Qt::WA_TransparentForMouseEvents);
2828
ui_passworded->hide();
2929

30-
ui_selector = new AOImage(parent, ao_app);
30+
ui_selector = new AOImage(parent, ao_app, true);
3131
ui_selector->resize(62, 62);
3232
ui_selector->move(x_pos - 1, y_pos - 1);
3333
ui_selector->set_image("char_selector");

src/aoevidencebutton.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,14 +9,14 @@ AOEvidenceButton::AOEvidenceButton(QWidget *p_parent, AOApplication *p_ao_app,
99
ao_app = p_ao_app;
1010
m_parent = p_parent;
1111

12-
ui_selected = new AOImage(this, ao_app);
12+
ui_selected = new AOImage(this, ao_app, true);
1313
ui_selected->resize(p_w, p_h);
1414
// ui_selected->move(p_x, p_y);
1515
ui_selected->set_image("evidence_selected");
1616
ui_selected->setAttribute(Qt::WA_TransparentForMouseEvents);
1717
ui_selected->hide();
1818

19-
ui_selector = new AOImage(this, ao_app);
19+
ui_selector = new AOImage(this, ao_app, true);
2020
ui_selector->resize(p_w, p_h);
2121
// ui_selector->move(p_x - 1, p_y - 1);
2222
ui_selector->set_image("evidence_selector");

src/aoimage.cpp

Lines changed: 21 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -4,26 +4,30 @@
44

55
#include <QBitmap>
66

7-
AOImage::AOImage(QWidget *parent, AOApplication *p_ao_app) : QLabel(parent)
7+
AOImage::AOImage(QWidget *parent, AOApplication *p_ao_app, bool make_static) : QLabel(parent)
88
{
99
m_parent = parent;
1010
ao_app = p_ao_app;
11-
movie = new QMovie();
12-
connect(movie, &QMovie::frameChanged, [=]{
13-
QPixmap f_pixmap = movie->currentPixmap();
14-
f_pixmap =
15-
f_pixmap.scaled(this->size(), Qt::IgnoreAspectRatio);
16-
this->setPixmap(f_pixmap);
17-
this->setMask(f_pixmap.mask());
18-
});
11+
is_static = make_static;
12+
if (!is_static) // Only create the QMovie if we're non-static
13+
{
14+
movie = new QMovie(this);
15+
connect(movie, &QMovie::frameChanged, [=]{
16+
QPixmap f_pixmap = movie->currentPixmap();
17+
f_pixmap =
18+
f_pixmap.scaled(this->size(), Qt::IgnoreAspectRatio);
19+
this->setPixmap(f_pixmap);
20+
this->setMask(f_pixmap.mask());
21+
});
22+
}
1923
}
2024

2125
AOImage::~AOImage() {}
2226

2327
bool AOImage::set_image(QString p_path, QString p_misc)
2428
{
2529
// Check if the user wants animated themes
26-
if (ao_app->get_animated_theme())
30+
if (!is_static && ao_app->get_animated_theme())
2731
// We want an animated image
2832
p_path = ao_app->get_image(p_path, ao_app->current_theme, ao_app->get_subtheme(), ao_app->default_theme, p_misc);
2933
else
@@ -35,12 +39,14 @@ bool AOImage::set_image(QString p_path, QString p_misc)
3539
return false;
3640
}
3741
path = p_path;
38-
movie->stop();
39-
movie->setFileName(path);
40-
if (ao_app->get_animated_theme() && movie->frameCount() > 1) {
41-
movie->start();
42+
if (!is_static) {
43+
movie->stop();
44+
movie->setFileName(path);
45+
if (ao_app->get_animated_theme() && movie->frameCount() > 1) {
46+
movie->start();
47+
}
4248
}
43-
else {
49+
if (is_static || !ao_app->get_animated_theme() || movie->frameCount() <= 1) {
4450
QPixmap f_pixmap(path);
4551

4652
f_pixmap =

src/aolayer.cpp

Lines changed: 15 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -98,9 +98,10 @@ void AOLayer::center_pixmap(QPixmap f_pixmap) {
9898
x + (f_w - f_pixmap.width()) / 2,
9999
y + (f_h - f_pixmap.height())); // Always center horizontally, always put
100100
// at the bottom vertically
101-
this->setMask(
102-
QRegion((f_pixmap.width() - f_w) / 2, (f_pixmap.height() - f_h) / 2, f_w,
103-
f_h)); // make sure we don't escape the area we've been given
101+
if (masked)
102+
this->setMask(
103+
QRegion((f_pixmap.width() - f_w) / 2, (f_pixmap.height() - f_h) / 2, f_w,
104+
f_h)); // make sure we don't escape the area we've been given
104105
}
105106

106107
void AOLayer::combo_resize(int w, int h)
@@ -196,20 +197,20 @@ void CharLayer::load_image(QString p_filename, QString p_charname,
196197
<< " continuous: " << continuous;
197198
#endif
198199
QStringList pathlist = {
199-
ao_app->get_image_suffix(ao_app->get_character_path(
200-
p_charname, prefix + current_emote)), // Default path
201-
ao_app->get_image_suffix(ao_app->get_character_path(
200+
ao_app->get_character_path(
201+
p_charname, prefix + current_emote), // Default path
202+
ao_app->get_character_path(
202203
p_charname,
203-
prefix + "/" + current_emote)), // Path check if it's categorized
204+
prefix + "/" + current_emote), // Path check if it's categorized
204205
// into a folder
205-
ao_app->get_image_suffix(ao_app->get_character_path(
206+
ao_app->get_character_path(
206207
p_charname,
207-
current_emote)), // Just use the non-prefixed image, animated or not
208-
ao_app->get_image_suffix(
209-
ao_app->get_theme_path("placeholder")), // Theme placeholder path
210-
ao_app->get_image_suffix(ao_app->get_theme_path(
211-
"placeholder", ao_app->default_theme))}; // Default theme placeholder path
212-
start_playback(find_image(pathlist));
208+
current_emote), // Just use the non-prefixed image, animated or not
209+
current_emote, // The path by itself after the above fail
210+
ao_app->get_theme_path("placeholder"), // Theme placeholder path
211+
ao_app->get_theme_path(
212+
"placeholder", ao_app->default_theme)}; // Default theme placeholder path
213+
start_playback(ao_app->get_image_path(pathlist));
213214
}
214215

215216
void SplashLayer::load_image(QString p_filename, QString p_charname,

src/charselect.cpp

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,10 +21,6 @@ void Courtroom::construct_char_select()
2121

2222
ui_char_buttons = new QWidget(ui_char_select_background);
2323

24-
ui_selector = new AOImage(ui_char_select_background, ao_app);
25-
ui_selector->setAttribute(Qt::WA_TransparentForMouseEvents);
26-
ui_selector->resize(62, 62);
27-
2824
ui_back_to_lobby = new AOButton(ui_char_select_background, ao_app);
2925

3026
ui_char_password = new QLineEdit(ui_char_select_background);

0 commit comments

Comments
 (0)