forked from AttorneyOnline/AO2-Client
-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathaocharbutton.cpp
More file actions
89 lines (71 loc) · 2.06 KB
/
aocharbutton.cpp
File metadata and controls
89 lines (71 loc) · 2.06 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
#include "aocharbutton.h"
#include "file_functions.h"
#include <QFile>
AOCharButton::AOCharButton(QWidget *parent, AOApplication *p_ao_app, int x_pos, int y_pos) : QPushButton(parent)
{
ao_app = p_ao_app;
this->resize(60, 60);
this->move(x_pos, y_pos);
ui_taken = new AOImage(this, ao_app);
ui_taken->resize(60, 60);
ui_taken->set_image("char_taken.png");
ui_taken->setAttribute(Qt::WA_TransparentForMouseEvents);
ui_taken->hide();
ui_passworded = new AOImage(this, ao_app);
ui_passworded->resize(60, 60);
ui_passworded->set_image("char_passworded");
ui_passworded->setAttribute(Qt::WA_TransparentForMouseEvents);
ui_passworded->hide();
ui_selector = new AOImage(parent, ao_app);
ui_selector->resize(62, 62);
ui_selector->move(x_pos - 1, y_pos - 1);
ui_selector->set_image("char_selector.png");
ui_selector->setAttribute(Qt::WA_TransparentForMouseEvents);
ui_selector->hide();
}
void AOCharButton::reset()
{
ui_taken->hide();
ui_passworded->hide();
ui_selector->hide();
}
void AOCharButton::set_taken()
{
ui_taken->show();
}
void AOCharButton::set_passworded()
{
ui_passworded->show();
}
void AOCharButton::set_image(QString p_character)
{
QString image_path = ao_app->get_character_path(p_character) + "char_icon.png";
QString legacy_path = ao_app->get_demothings_path() + p_character.toLower() + "_char_icon.png";
QString alt_path = ao_app->get_demothings_path() + p_character.toLower() + "_off.png";
this->setText("");
if (file_exists(image_path))
this->setStyleSheet("border-image:url(\"" + image_path + "\")");
else if (file_exists(legacy_path))
{
this->setStyleSheet("border-image:url(\"" + legacy_path + "\")");
//ninja optimization
QFile::copy(legacy_path, image_path);
}
else
{
this->setStyleSheet("border-image:url()");
this->setText(p_character);
}
}
void AOCharButton::enterEvent(QEvent * e)
{
ui_selector->raise();
ui_selector->show();
setFlat(false);
QPushButton::enterEvent(e);
}
void AOCharButton::leaveEvent(QEvent * e)
{
ui_selector->hide();
QPushButton::leaveEvent(e);
}