diff --git a/aobutton.cpp b/aobutton.cpp index b96af67..3566c2b 100644 --- a/aobutton.cpp +++ b/aobutton.cpp @@ -1,3 +1,5 @@ +#include + #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 0997e76..0f03a7b 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); diff --git a/aoimage.h b/aoimage.h index 631375d..93fa6fd 100644 --- a/aoimage.h +++ b/aoimage.h @@ -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); diff --git a/lobby.cpp b/lobby.cpp index 5140c07..d2a56dc 100644 --- a/lobby.cpp +++ b/lobby.cpp @@ -8,24 +8,51 @@ Lobby::Lobby(QWidget *parent) : QMainWindow(parent) { - const int lobby_width = 517; - const int lobby_height = 666; + this->setWindowTitle("Attorney Online 2"); + this->resize(m_lobby_width, m_lobby_height); - this->resize(lobby_width, lobby_height); - - ui_background = new AOImage(this, 0, 0, lobby_width, lobby_height); -} - -void Lobby::set_theme_images() -{ - g_user_theme = get_user_theme(); - - ui_background->set_image("lobbybackground.png"); - ui_public_servers->set_image("publicservers.png"); - ui_favorites->set_image("favorites.png"); + 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); } Lobby::~Lobby() { delete ui_background; } + +//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_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); + + 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); +} + + diff --git a/lobby.h b/lobby.h index ed7ca50..e9e062a 100644 --- a/lobby.h +++ b/lobby.h @@ -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 diff --git a/main.cpp b/main.cpp index bbb10bb..9ae6ab2 100644 --- a/main.cpp +++ b/main.cpp @@ -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 936060e..3be9317 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 3912c17..eae5c75 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