made fundamental app structure, now with more OO
This commit is contained in:
parent
d8468b4467
commit
a699b6eb9c
@ -11,6 +11,7 @@ greaterThan(QT_MAJOR_VERSION, 4): QT += widgets
|
||||
TARGET = Attorney_Online_remake
|
||||
TEMPLATE = app
|
||||
|
||||
VERSION = 2.1.0.0
|
||||
|
||||
SOURCES += main.cpp\
|
||||
lobby.cpp \
|
||||
@ -19,7 +20,10 @@ SOURCES += main.cpp\
|
||||
aoimage.cpp \
|
||||
file_functions.cpp \
|
||||
aobutton.cpp \
|
||||
global_variables.cpp
|
||||
global_variables.cpp \
|
||||
debug_functions.cpp \
|
||||
networkmanager.cpp \
|
||||
aoapplication.cpp
|
||||
|
||||
HEADERS += lobby.h \
|
||||
text_file_functions.h \
|
||||
@ -27,4 +31,7 @@ HEADERS += lobby.h \
|
||||
aoimage.h \
|
||||
file_functions.h \
|
||||
aobutton.h \
|
||||
global_variables.h
|
||||
global_variables.h \
|
||||
debug_functions.h \
|
||||
networkmanager.h \
|
||||
aoapplication.h
|
||||
|
63
aoapplication.cpp
Normal file
63
aoapplication.cpp
Normal file
@ -0,0 +1,63 @@
|
||||
#include <QDebug>
|
||||
|
||||
#include "aoapplication.h"
|
||||
|
||||
AOApplication::AOApplication(int &argc, char **argv) : QApplication(argc, argv)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
AOApplication::~AOApplication()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void AOApplication::construct_lobby()
|
||||
{
|
||||
if (lobby_constructed)
|
||||
{
|
||||
qDebug() << "W: lobby was attempted constructed when it already exists";
|
||||
return;
|
||||
}
|
||||
|
||||
w_lobby = new Lobby();
|
||||
lobby_constructed = true;
|
||||
}
|
||||
|
||||
void AOApplication::destruct_lobby()
|
||||
{
|
||||
if(!lobby_constructed)
|
||||
{
|
||||
qDebug() << "W: lobby was attempted destructed when it did not exist";
|
||||
return;
|
||||
}
|
||||
|
||||
delete w_lobby;
|
||||
lobby_constructed = false;
|
||||
}
|
||||
|
||||
void AOApplication::construct_courtroom()
|
||||
{
|
||||
if (courtroom_constructed)
|
||||
{
|
||||
qDebug() << "W: courtroom was attempted constructed when it already exists";
|
||||
return;
|
||||
}
|
||||
|
||||
w_courtroom = new QMainWindow();
|
||||
courtroom_constructed = true;
|
||||
}
|
||||
|
||||
void AOApplication::destruct_courtroom()
|
||||
{
|
||||
if (!courtroom_constructed)
|
||||
{
|
||||
qDebug() << "W: courtroom was attempted destructed when it did not exist";
|
||||
return;
|
||||
}
|
||||
|
||||
delete w_courtroom;
|
||||
courtroom_constructed = false;
|
||||
}
|
||||
|
||||
|
28
aoapplication.h
Normal file
28
aoapplication.h
Normal file
@ -0,0 +1,28 @@
|
||||
#ifndef AOAPPLICATION_H
|
||||
#define AOAPPLICATION_H
|
||||
|
||||
#include <QApplication>
|
||||
#include <QMainWindow>
|
||||
|
||||
#include "lobby.h"
|
||||
|
||||
class AOApplication : public QApplication
|
||||
{
|
||||
public:
|
||||
AOApplication(int &argc, char **argv);
|
||||
~AOApplication();
|
||||
|
||||
Lobby *w_lobby;
|
||||
QMainWindow *w_courtroom;
|
||||
|
||||
bool lobby_constructed = false;
|
||||
bool courtroom_constructed = false;
|
||||
|
||||
void construct_lobby();
|
||||
void destruct_lobby();
|
||||
|
||||
void construct_courtroom();
|
||||
void destruct_courtroom();
|
||||
};
|
||||
|
||||
#endif // AOAPPLICATION_H
|
@ -1,5 +1,6 @@
|
||||
#include <QDebug>
|
||||
|
||||
#include "debug_functions.h"
|
||||
#include "path_functions.h"
|
||||
#include "file_functions.h"
|
||||
|
||||
|
@ -12,11 +12,6 @@ public:
|
||||
~AOButton();
|
||||
|
||||
void set_image(QString p_image);
|
||||
|
||||
signals:
|
||||
void clicked();
|
||||
void pressed();
|
||||
void released();
|
||||
};
|
||||
|
||||
#endif // AOBUTTON_H
|
||||
|
15
debug_functions.cpp
Normal file
15
debug_functions.cpp
Normal file
@ -0,0 +1,15 @@
|
||||
#include <QMessageBox>
|
||||
|
||||
#include "debug_functions.h"
|
||||
|
||||
void call_error(QString p_message)
|
||||
{
|
||||
QMessageBox *msgBox = new QMessageBox;
|
||||
|
||||
msgBox->setText("Error: " + p_message);
|
||||
msgBox->setWindowTitle("Error");
|
||||
|
||||
|
||||
msgBox->setWindowModality(Qt::NonModal);
|
||||
msgBox->show();
|
||||
}
|
8
debug_functions.h
Normal file
8
debug_functions.h
Normal file
@ -0,0 +1,8 @@
|
||||
#ifndef DEBUG_FUNCTIONS_H
|
||||
#define DEBUG_FUNCTIONS_H
|
||||
|
||||
#include <QString>
|
||||
|
||||
void call_error(QString message);
|
||||
|
||||
#endif // DEBUG_FUNCTIONS_H
|
@ -1,3 +1,7 @@
|
||||
#include "global_variables.h"
|
||||
|
||||
const int RELEASE = 2;
|
||||
const int MAJOR_VERSION = 1;
|
||||
const int MINOR_VERSION = 0;
|
||||
|
||||
QString g_user_theme = "default";
|
||||
|
46
lobby.cpp
46
lobby.cpp
@ -19,6 +19,16 @@ Lobby::Lobby(QWidget *parent) : QMainWindow(parent)
|
||||
ui_connect = new AOButton(this);
|
||||
|
||||
connect(ui_public_servers, SIGNAL(clicked()), this, SLOT(on_public_servers_clicked()));
|
||||
connect(ui_favorites, SIGNAL(clicked()), this, SLOT(on_favorites_clicked()));
|
||||
|
||||
connect(ui_refresh, SIGNAL(pressed()), this, SLOT(on_refresh_pressed()));
|
||||
connect(ui_refresh, SIGNAL(released()), this, SLOT(on_refresh_released()));
|
||||
connect(ui_add_to_fav, SIGNAL(pressed()), this, SLOT(on_add_to_fav_pressed()));
|
||||
connect(ui_add_to_fav, SIGNAL(released()), this, SLOT(on_add_to_fav_released()));
|
||||
connect(ui_connect, SIGNAL(pressed()), this, SLOT(on_connect_pressed()));
|
||||
connect(ui_connect, SIGNAL(released()), this, SLOT(on_connect_released()));
|
||||
|
||||
set_widgets();
|
||||
}
|
||||
|
||||
Lobby::~Lobby()
|
||||
@ -36,7 +46,7 @@ void Lobby::set_widgets()
|
||||
ui_background->move(0, 0);
|
||||
ui_background->resize(m_lobby_width, m_lobby_height);
|
||||
|
||||
ui_public_servers->set_image("publicservers.png");
|
||||
ui_public_servers->set_image("publicservers_selected.png");
|
||||
ui_public_servers->move(46, 88);
|
||||
ui_public_servers->resize(114, 30);
|
||||
|
||||
@ -60,46 +70,52 @@ void Lobby::set_widgets()
|
||||
void Lobby::on_public_servers_clicked()
|
||||
{
|
||||
ui_public_servers->set_image("publicservers_selected.png");
|
||||
ui_favorites->set_image("favorites.png");
|
||||
|
||||
//clear server list and show public servers
|
||||
//T0D0: clear server list and show public servers
|
||||
}
|
||||
|
||||
void Lobby::on_favorites_clicked()
|
||||
{
|
||||
ui_favorites->set_image("favorites_selected.png");
|
||||
ui_public_servers->set_image("publicservers.png");
|
||||
|
||||
//T0D0: clear server list and show favorites from serverlist.txt
|
||||
}
|
||||
|
||||
/*
|
||||
void Lobby::on_refresh_pressed()
|
||||
{
|
||||
ui->refresh->setStyleSheet(get_stylesheet_path("refresh_pressed.png"));
|
||||
ui_refresh->set_image("refresh_pressed.png");
|
||||
}
|
||||
|
||||
void Lobby::on_refresh_released()
|
||||
{
|
||||
ui->refresh->setStyleSheet(get_stylesheet_path("refresh.png"));
|
||||
ui_refresh->set_image("refresh.png");
|
||||
|
||||
all_servers_requested();
|
||||
//T0D0: clear serverlist, request new list from MS and show them
|
||||
}
|
||||
|
||||
void Lobby::on_addtofav_pressed()
|
||||
void Lobby::on_add_to_fav_pressed()
|
||||
{
|
||||
ui->addtofav->setStyleSheet(get_stylesheet_path("addtofav_pressed.png"));
|
||||
ui_add_to_fav->set_image("addtofav_pressed.png");
|
||||
}
|
||||
|
||||
void Lobby::on_addtofav_released()
|
||||
void Lobby::on_add_to_fav_released()
|
||||
{
|
||||
ui->addtofav->setStyleSheet(get_stylesheet_path("addtofav.png"));
|
||||
ui_add_to_fav->set_image("addtofav.png");
|
||||
|
||||
//T0D0, add selected element to serverlist.txt
|
||||
|
||||
}
|
||||
|
||||
void Lobby::on_connect_pressed()
|
||||
{
|
||||
ui->connect->setStyleSheet(get_stylesheet_path("connect_pressed.png"));
|
||||
ui_connect->set_image("connect_pressed.png");
|
||||
}
|
||||
|
||||
void Lobby::on_connect_released()
|
||||
{
|
||||
ui->connect->setStyleSheet(get_stylesheet_path("connect.png"));
|
||||
ui_connect->set_image("connect.png");
|
||||
|
||||
enter_server_requested();
|
||||
//T0D0: connect to selected server(show loading overlay?)
|
||||
}
|
||||
*/
|
||||
|
||||
|
8
lobby.h
8
lobby.h
@ -30,6 +30,14 @@ private:
|
||||
|
||||
public slots:
|
||||
void on_public_servers_clicked();
|
||||
void on_favorites_clicked();
|
||||
|
||||
void on_refresh_pressed();
|
||||
void on_refresh_released();
|
||||
void on_add_to_fav_pressed();
|
||||
void on_add_to_fav_released();
|
||||
void on_connect_pressed();
|
||||
void on_connect_released();
|
||||
};
|
||||
|
||||
#endif // LOBBY_H
|
||||
|
13
main.cpp
13
main.cpp
@ -1,13 +1,14 @@
|
||||
#include <QApplication>
|
||||
#include <QDebug>
|
||||
|
||||
#include "aoapplication.h"
|
||||
|
||||
#include "lobby.h"
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
QApplication a(argc, argv);
|
||||
Lobby w;
|
||||
w.set_widgets();
|
||||
w.show();
|
||||
AOApplication main_app(argc, argv);
|
||||
main_app.construct_lobby();
|
||||
main_app.w_lobby->show();
|
||||
|
||||
return a.exec();
|
||||
return main_app.exec();
|
||||
}
|
||||
|
13
networkmanager.cpp
Normal file
13
networkmanager.cpp
Normal file
@ -0,0 +1,13 @@
|
||||
#include "networkmanager.h"
|
||||
|
||||
NetworkManager::NetworkManager()
|
||||
{
|
||||
ms_socket = new QTcpSocket();
|
||||
server_socket = new QTcpSocket();
|
||||
}
|
||||
|
||||
NetworkManager::~NetworkManager()
|
||||
{
|
||||
|
||||
}
|
||||
|
16
networkmanager.h
Normal file
16
networkmanager.h
Normal file
@ -0,0 +1,16 @@
|
||||
#ifndef NETWORKMANAGER_H
|
||||
#define NETWORKMANAGER_H
|
||||
|
||||
#include <QTcpSocket>
|
||||
|
||||
class NetworkManager
|
||||
{
|
||||
public:
|
||||
NetworkManager();
|
||||
~NetworkManager();
|
||||
|
||||
QTcpSocket *ms_socket;
|
||||
QTcpSocket *server_socket;
|
||||
};
|
||||
|
||||
#endif // NETWORKMANAGER_H
|
Loading…
Reference in New Issue
Block a user