aboutsummaryrefslogtreecommitdiff
path: root/src/aocharbutton.cpp
diff options
context:
space:
mode:
authorTrickyLeifa <date.epoch@gmail.com>2024-05-15 00:00:17 +0200
committerTrickyLeifa <date.epoch@gmail.com>2024-05-15 00:04:16 +0200
commitc9f52b7223685d2e7fca925594171f94dd8c6e3b (patch)
tree740bb32a40da98a4d52836432f59a16b31333900 /src/aocharbutton.cpp
parent951766666621fa77e257e6b5616fe4ab1eb2a52f (diff)
Ported to CMake, ...
* Ported the project to CMake * Android and Mac support dropped for the time being. * Tests, BASS and Discord-RPC are now options * Restructured and reformated the project. * Merged `include` and `src` * Renamed `resource` to `data` * Renamed various files * External libraries headers are no longer included in `src` * Replaced header guards with #pragma once * Multiple refactors (keywords, headers) * Added Qt6 compatibility * Removed various unused functions and headers * Reworked AOPacket * When content is passed to AOPacket, it should be ensured that the content is already decoded. * Encoding/decoding are now static methods. * Fixed various memory leaks * Removed animation code for AOImage * AOImage is always using static images * Simplified ChatLogPiece
Diffstat (limited to 'src/aocharbutton.cpp')
-rw-r--r--src/aocharbutton.cpp44
1 files changed, 18 insertions, 26 deletions
diff --git a/src/aocharbutton.cpp b/src/aocharbutton.cpp
index 4f00e3c8..cab7fddd 100644
--- a/src/aocharbutton.cpp
+++ b/src/aocharbutton.cpp
@@ -2,35 +2,24 @@
#include "file_functions.h"
-AOCharButton::AOCharButton(QWidget *parent, AOApplication *p_ao_app, int x_pos,
- int y_pos, bool is_taken)
+AOCharButton::AOCharButton(AOApplication *p_ao_app, int x_pos, int y_pos, bool is_taken, QWidget *parent)
: QPushButton(parent)
+ , ao_app(p_ao_app)
+ , m_taken(is_taken)
{
- m_parent = parent;
-
- ao_app = p_ao_app;
-
- taken = is_taken;
-
int size = 60 * Options::getInstance().themeScalingFactor();
int selector_size = 62 * Options::getInstance().themeScalingFactor();
this->resize(size, size);
this->move(x_pos, y_pos);
- ui_taken = new AOImage(this, ao_app, true);
+ ui_taken = new AOImage(ao_app, this);
ui_taken->resize(size, size);
ui_taken->set_image("char_taken");
ui_taken->setAttribute(Qt::WA_TransparentForMouseEvents);
ui_taken->hide();
- ui_passworded = new AOImage(this, ao_app, true);
- ui_passworded->resize(size, size);
- ui_passworded->set_image("char_passworded");
- ui_passworded->setAttribute(Qt::WA_TransparentForMouseEvents);
- ui_passworded->hide();
-
- ui_selector = new AOImage(parent, ao_app, true);
+ ui_selector = new AOImage(ao_app, parent);
ui_selector->resize(selector_size, selector_size);
int offset = Options::getInstance().themeScalingFactor();
ui_selector->move(x_pos - offset, y_pos - offset);
@@ -42,39 +31,42 @@ AOCharButton::AOCharButton(QWidget *parent, AOApplication *p_ao_app, int x_pos,
void AOCharButton::reset()
{
ui_taken->hide();
- ui_passworded->hide();
ui_selector->hide();
}
-void AOCharButton::set_taken(bool is_taken) { taken = is_taken; }
+void AOCharButton::set_taken(bool is_taken)
+{
+ m_taken = is_taken;
+}
void AOCharButton::apply_taken_image()
{
- if (taken) {
+ if (m_taken)
+ {
ui_taken->move(0, 0);
ui_taken->show();
}
- else {
+ else
+ {
ui_taken->hide();
}
}
-void AOCharButton::set_passworded() { ui_passworded->show(); }
-
void AOCharButton::set_image(QString p_character)
{
- QString image_path = ao_app->get_image_suffix(
- ao_app->get_character_path(p_character, "char_icon"), true);
+ QString image_path = ao_app->get_image_suffix(ao_app->get_character_path(p_character, "char_icon"), true);
this->setText("");
- if (file_exists(image_path)) {
+ if (file_exists(image_path))
+ {
this->setStyleSheet("QPushButton { border-image: url(\"" + image_path +
"\") 0 0 0 0 stretch stretch; }"
"QToolTip { background-image: url(); color: #000000; "
"background-color: #ffffff; border: 0px; }");
}
- else {
+ else
+ {
this->setStyleSheet("QPushButton { border-image: url(); }"
"QToolTip { background-image: url(); color: #000000; "
"background-color: #ffffff; border: 0px; }");