added lobby buttons
This commit is contained in:
parent
ca732f27a1
commit
c206cccb8e
@ -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 + "\")");
|
||||
|
@ -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);
|
||||
|
55
lobby.cpp
55
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);
|
||||
}
|
||||
|
||||
|
||||
|
13
lobby.h
13
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
|
||||
|
2
main.cpp
2
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();
|
||||
|
@ -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/";
|
||||
}
|
||||
|
||||
|
||||
|
@ -5,5 +5,6 @@
|
||||
|
||||
QString get_base_path();
|
||||
QString get_theme_path();
|
||||
QString get_default_theme_path();
|
||||
|
||||
#endif // PATH_FUNCTIONS_H
|
||||
|
Loading…
Reference in New Issue
Block a user