From 455d6106e3c923e86b1b75687d1dbd3c52e8a11b Mon Sep 17 00:00:00 2001 From: David Skoland Date: Tue, 3 Jan 2017 15:01:54 +0100 Subject: [PATCH] establishing child-parent relation with the ao app --- Attorney_Online_remake.pro | 3 +- aoapplication.cpp | 7 ++-- aoapplication.h | 5 ++- datatypes.h | 68 ++++++++++++++++++++++++++++++++++++++ lobby.cpp | 18 +++++++++- lobby.h | 15 ++++++++- networkmanager.cpp | 10 ++++-- networkmanager.h | 5 ++- 8 files changed, 122 insertions(+), 9 deletions(-) create mode 100644 datatypes.h diff --git a/Attorney_Online_remake.pro b/Attorney_Online_remake.pro index 38374f2..ab07286 100644 --- a/Attorney_Online_remake.pro +++ b/Attorney_Online_remake.pro @@ -34,4 +34,5 @@ HEADERS += lobby.h \ global_variables.h \ debug_functions.h \ networkmanager.h \ - aoapplication.h + aoapplication.h \ + datatypes.h diff --git a/aoapplication.cpp b/aoapplication.cpp index cb7c44d..8ba9c39 100644 --- a/aoapplication.cpp +++ b/aoapplication.cpp @@ -1,5 +1,7 @@ #include +#include "lobby.h" + #include "aoapplication.h" AOApplication::AOApplication(int &argc, char **argv) : QApplication(argc, argv) @@ -20,7 +22,7 @@ void AOApplication::construct_lobby() return; } - w_lobby = new Lobby(); + w_lobby = new Lobby(this); lobby_constructed = true; } @@ -44,7 +46,8 @@ void AOApplication::construct_courtroom() return; } - w_courtroom = new QMainWindow(); + //T0D0, make custom Courtroom class and uncomment + //w_courtroom = new QMainWindow(this); courtroom_constructed = true; } diff --git a/aoapplication.h b/aoapplication.h index 9523824..194612c 100644 --- a/aoapplication.h +++ b/aoapplication.h @@ -4,7 +4,8 @@ #include #include -#include "lobby.h" +class NetworkManager; +class Lobby; class AOApplication : public QApplication { @@ -12,7 +13,9 @@ public: AOApplication(int &argc, char **argv); ~AOApplication(); + NetworkManager *net_manager; Lobby *w_lobby; + //T0D0: change to custom class "Courtroom" QMainWindow *w_courtroom; bool lobby_constructed = false; diff --git a/datatypes.h b/datatypes.h new file mode 100644 index 0000000..172c32f --- /dev/null +++ b/datatypes.h @@ -0,0 +1,68 @@ +#ifndef DATATYPES_H +#define DATATYPES_H + +#include + +struct server_type +{ + QString name; + QString desc; + QString ip; + int port; +}; + +struct emote_type +{ + QString comment; + QString preanim; + QString anim; + int mod; + QString sfx_name; + int sfx_delay; + int sfx_duration; +}; + +struct char_type +{ + QString name; + QString description; +}; + +struct evi_type +{ + QString name; + QString description; +}; + +struct chatmessage_type +{ + QString message; + QString character; + QString side; + QString sfx_name; + QString pre_emote; + QString emote; + int emote_modifier; + int objection_modifier; + int realization; + int text_color; + int evidence; + int cid; + int sfx_delay; + int flip; +}; + +struct area_type +{ + QString name; + QString background; + bool passworded; +}; + +struct pos_type +{ + int x; + int y; +}; + +#endif // DATATYPES_H diff --git a/lobby.cpp b/lobby.cpp index 45aadec..24e3ae9 100644 --- a/lobby.cpp +++ b/lobby.cpp @@ -3,11 +3,14 @@ #include "path_functions.h" #include "text_file_functions.h" #include "global_variables.h" +#include "debug_functions.h" #include "lobby.h" -Lobby::Lobby(QWidget *parent) : QMainWindow(parent) +Lobby::Lobby(AOApplication *parent) : QMainWindow() { + m_parent = parent; + this->setWindowTitle("Attorney Online 2"); this->resize(m_lobby_width, m_lobby_height); @@ -17,6 +20,7 @@ Lobby::Lobby(QWidget *parent) : QMainWindow(parent) ui_refresh = new AOButton(this); ui_add_to_fav = new AOButton(this); ui_connect = new AOButton(this); + ui_about = 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())); @@ -28,6 +32,8 @@ Lobby::Lobby(QWidget *parent) : QMainWindow(parent) connect(ui_connect, SIGNAL(pressed()), this, SLOT(on_connect_pressed())); connect(ui_connect, SIGNAL(released()), this, SLOT(on_connect_released())); + connect(ui_about, SIGNAL(clicked()), this, SLOT(on_about_clicked())); + set_widgets(); } @@ -65,6 +71,10 @@ void Lobby::set_widgets() ui_connect->set_image("connect.png"); ui_connect->move(332, 381); ui_connect->resize(132, 28); + + ui_about->set_image("about.png"); + ui_about->move(428, 1); + ui_about->resize(88, 21); } void Lobby::on_public_servers_clicked() @@ -119,3 +129,9 @@ void Lobby::on_connect_released() //T0D0: connect to selected server(show loading overlay?) } +void Lobby::on_about_clicked() +{ + //T0D0: add something real here + call_error("YEBOIIII"); +} + diff --git a/lobby.h b/lobby.h index a8f20e8..d67be82 100644 --- a/lobby.h +++ b/lobby.h @@ -2,15 +2,19 @@ #define LOBBY_H #include +#include + #include "aoimage.h" #include "aobutton.h" +class AOApplication; + class Lobby : public QMainWindow { Q_OBJECT public: - Lobby(QWidget *parent = nullptr); + Lobby(AOApplication *parent); ~Lobby(); void set_widgets(); @@ -19,6 +23,8 @@ private: const int m_lobby_width = 517; const int m_lobby_height = 666; + AOApplication *m_parent; + AOImage *ui_background; AOButton *ui_public_servers; @@ -28,6 +34,11 @@ private: AOButton *ui_add_to_fav; AOButton *ui_connect; + AOButton *ui_about; + + QListWidget *ui_server_list; +// QListWidget + public slots: void on_public_servers_clicked(); void on_favorites_clicked(); @@ -38,6 +49,8 @@ public slots: void on_add_to_fav_released(); void on_connect_pressed(); void on_connect_released(); + + void on_about_clicked(); }; #endif // LOBBY_H diff --git a/networkmanager.cpp b/networkmanager.cpp index 89413e4..d5a2dac 100644 --- a/networkmanager.cpp +++ b/networkmanager.cpp @@ -1,13 +1,19 @@ +#include "aoapplication.h" + #include "networkmanager.h" -NetworkManager::NetworkManager() + +NetworkManager::NetworkManager(AOApplication *parent) { + ao_app = parent; + ms_socket = new QTcpSocket(); server_socket = new QTcpSocket(); } NetworkManager::~NetworkManager() { - + delete ms_socket; + delete server_socket; } diff --git a/networkmanager.h b/networkmanager.h index 7aaf001..ba539dd 100644 --- a/networkmanager.h +++ b/networkmanager.h @@ -3,12 +3,15 @@ #include +class AOApplication; + class NetworkManager { public: - NetworkManager(); + NetworkManager(AOApplication *parent); ~NetworkManager(); + AOApplication *ao_app; QTcpSocket *ms_socket; QTcpSocket *server_socket; };