diff options
| author | David Skoland <davidskoland@gmail.com> | 2017-01-02 12:42:07 +0100 |
|---|---|---|
| committer | David Skoland <davidskoland@gmail.com> | 2017-01-02 12:42:07 +0100 |
| commit | c206cccb8e0e84713cb5e6a95ef347a30df23a18 (patch) | |
| tree | 1c9e37b261520e001f97b4a8f6fe11539c053ff6 | |
| parent | ca732f27a1352ec656b2b7680c6ee2b61762c38d (diff) | |
added lobby buttons
| -rw-r--r-- | aobutton.cpp | 4 | ||||
| -rw-r--r-- | aoimage.cpp | 7 | ||||
| -rw-r--r-- | aoimage.h | 2 | ||||
| -rw-r--r-- | lobby.cpp | 49 | ||||
| -rw-r--r-- | lobby.h | 13 | ||||
| -rw-r--r-- | main.cpp | 2 | ||||
| -rw-r--r-- | path_functions.cpp | 5 | ||||
| -rw-r--r-- | path_functions.h | 1 |
8 files changed, 62 insertions, 21 deletions
diff --git a/aobutton.cpp b/aobutton.cpp index b96af678..3566c2b6 100644 --- a/aobutton.cpp +++ b/aobutton.cpp @@ -1,3 +1,5 @@ +#include <QDebug> + #include "path_functions.h" #include "file_functions.h" @@ -16,7 +18,7 @@ AOButton::~AOButton() void AOButton::set_image(QString p_image) { QString image_path = get_theme_path() + p_image; - QString default_image_path = get_base_path() + "themes/default/"; + QString default_image_path = get_default_theme_path() + p_image; if (file_exists(image_path)) this->setStyleSheet("border-image:url(\"" + image_path + "\")"); diff --git a/aoimage.cpp b/aoimage.cpp index 0997e767..0f03a7b6 100644 --- a/aoimage.cpp +++ b/aoimage.cpp @@ -4,10 +4,9 @@ #include "aoimage.h" -AOImage::AOImage(QWidget *parent, int x_pos, int y_pos, int x_size, int y_size) : QLabel(parent) +AOImage::AOImage(QWidget *parent) : QLabel(parent) { - this->move(x_pos, y_pos); - this->resize(x_size, y_size); + } AOImage::~AOImage() @@ -18,7 +17,7 @@ AOImage::~AOImage() void AOImage::set_image(QString p_image) { QString theme_image_path = get_theme_path() + p_image; - QString default_image_path = get_base_path() + "themes/default/" + p_image; + QString default_image_path = get_default_theme_path() + p_image; if (file_exists(theme_image_path)) this->setPixmap(theme_image_path); @@ -8,7 +8,7 @@ class AOImage : public QLabel { public: - AOImage(QWidget *parent, int x_pos, int y_pos, int x_size, int y_size); + AOImage(QWidget *parent); ~AOImage(); void set_image(QString p_image); @@ -8,24 +8,51 @@ Lobby::Lobby(QWidget *parent) : QMainWindow(parent) { - const int lobby_width = 517; - const int lobby_height = 666; - - this->resize(lobby_width, lobby_height); + this->setWindowTitle("Attorney Online 2"); + this->resize(m_lobby_width, m_lobby_height); + + ui_background = new AOImage(this); + ui_public_servers = new AOButton(this); + ui_favorites = new AOButton(this); + ui_refresh = new AOButton(this); + ui_add_to_fav = new AOButton(this); + ui_connect = new AOButton(this); +} - ui_background = new AOImage(this, 0, 0, lobby_width, lobby_height); +Lobby::~Lobby() +{ + delete ui_background; } -void Lobby::set_theme_images() +//sets images, position and size +void Lobby::set_widgets() { + //global to efficiently set images on button presses g_user_theme = get_user_theme(); ui_background->set_image("lobbybackground.png"); - ui_public_servers->set_image("publicservers.png"); + ui_background->move(0, 0); + ui_background->resize(m_lobby_width, m_lobby_height); + + ui_public_servers->set_image("publicservers_selected.png"); + ui_public_servers->move(46, 88); + ui_public_servers->resize(114, 30); + ui_favorites->set_image("favorites.png"); -} + ui_favorites->move(164, 88); + ui_favorites->resize(114, 30); -Lobby::~Lobby() -{ - delete ui_background; + ui_refresh->set_image("refresh.png"); + ui_refresh->move(56, 381); + ui_refresh->resize(132, 28); + + ui_add_to_fav->set_image("addtofav.png"); + ui_add_to_fav->move(194, 381); + ui_add_to_fav->resize(132, 28); + + ui_connect->set_image("connect.png"); + ui_connect->move(332, 381); + ui_connect->resize(132, 28); } + + @@ -11,15 +11,22 @@ class Lobby : public QMainWindow public: Lobby(QWidget *parent = nullptr); - - void set_theme_images(); - ~Lobby(); + void set_widgets(); + private: + const int m_lobby_width = 517; + const int m_lobby_height = 666; + AOImage *ui_background; + AOButton *ui_public_servers; AOButton *ui_favorites; + + AOButton *ui_refresh; + AOButton *ui_add_to_fav; + AOButton *ui_connect; }; #endif // LOBBY_H @@ -6,7 +6,7 @@ int main(int argc, char *argv[]) { QApplication a(argc, argv); Lobby w; - w.set_theme_images(); + w.set_widgets(); w.show(); return a.exec(); diff --git a/path_functions.cpp b/path_functions.cpp index 936060e1..3be93174 100644 --- a/path_functions.cpp +++ b/path_functions.cpp @@ -14,4 +14,9 @@ QString get_theme_path() return get_base_path() + "themes/" + g_user_theme.toLower() + "/"; } +QString get_default_theme_path() +{ + return get_base_path() + "themes/default/"; +} + diff --git a/path_functions.h b/path_functions.h index 3912c17a..eae5c75a 100644 --- a/path_functions.h +++ b/path_functions.h @@ -5,5 +5,6 @@ QString get_base_path(); QString get_theme_path(); +QString get_default_theme_path(); #endif // PATH_FUNCTIONS_H |
