From 623d67999a96178da30cab427a2c675c1eccd2d0 Mon Sep 17 00:00:00 2001 From: David Skoland Date: Fri, 20 Jan 2017 13:51:14 +0100 Subject: [PATCH 1/4] added more courtroom structure --- aoapplication.cpp | 2 ++ aocharbutton.cpp | 2 +- courtroom.cpp | 46 +++++++++++++++++++++++++++++++++++++--------- courtroom.h | 2 ++ lobby.cpp | 13 ------------- 5 files changed, 42 insertions(+), 23 deletions(-) diff --git a/aoapplication.cpp b/aoapplication.cpp index 87525a8..70aeb15 100644 --- a/aoapplication.cpp +++ b/aoapplication.cpp @@ -28,6 +28,8 @@ void AOApplication::construct_lobby() w_lobby = new Lobby(this); lobby_constructed = true; + + w_lobby->show(); } void AOApplication::destruct_lobby() diff --git a/aocharbutton.cpp b/aocharbutton.cpp index 79dc4e8..41a4f40 100644 --- a/aocharbutton.cpp +++ b/aocharbutton.cpp @@ -5,7 +5,7 @@ #include -AOCharButton::AOCharButton(QWidget *parent, AOApplication *p_ao_app) +AOCharButton::AOCharButton(QWidget *parent, AOApplication *p_ao_app) : QPushButton(parent) { m_parent = parent; diff --git a/courtroom.cpp b/courtroom.cpp index 72b53d1..f0ad216 100644 --- a/courtroom.cpp +++ b/courtroom.cpp @@ -83,8 +83,22 @@ Courtroom::Courtroom(AOApplication *p_ao_app) : QMainWindow() ui_char_select_background = new AOImage(this, ao_app); - //T0D0: allocate and position charbuttons - //QVector ui_char_button_list; + //setting up the grid and positions + const int base_x_pos{25}; + const int base_y_pos{36}; + + const int x_modifier{67}; + int x_mod_count{0}; + + const int y_modifier{67}; + int y_mod_count{0}; + + for (int n = 0 ; n < 90 ; ++n) + { + ui_char_button_list.append(new AOCharButton(ui_char_select_background, ao_app)); + } + + ui_char_select_background->hide(); ui_selector = new AOImage(ui_char_select_background, ao_app); @@ -96,12 +110,15 @@ Courtroom::Courtroom(AOApplication *p_ao_app) : QMainWindow() connect(ui_reload_theme, SIGNAL(clicked()), this, SLOT(on_reload_theme_clicked())); + connect(ui_back_to_lobby, SIGNAL(clicked()), this, SLOT(on_back_to_lobby_clicked())); + set_widgets(); } void Courtroom::set_widgets() { this->setFixedSize(m_courtroom_width, m_courtroom_height); + this->setWindowTitle("Attorney Online 2: Server name here"); ui_background->set_image("courtroombackground.png"); ui_background->move(0, 0); @@ -146,10 +163,10 @@ void Courtroom::set_widgets() set_size_and_pos(ui_ooc_toggle, "ooc_toggle"); - set_size_and_pos(ui_witness_testimony, "witness testimony"); + set_size_and_pos(ui_witness_testimony, "witness_testimony"); set_size_and_pos(ui_cross_examination, "cross_examination"); - set_size_and_pos(ui_change_character, "change_character"; + set_size_and_pos(ui_change_character, "change_character"); set_size_and_pos(ui_reload_theme, "reload_theme"); ui_reload_theme->setText("Reload theme"); @@ -185,14 +202,19 @@ void Courtroom::set_widgets() ui_char_select_background->move(0, 0); ui_char_select_background->resize(m_courtroom_width, m_courtroom_height); - QVector ui_char_button_list; - AOImage *ui_selector; + //T0D0: uncomment and set position properly + //QVector ui_char_button_list; - AOButton *ui_back_to_lobby; + ui_selector->set_image("selector.png"); + ui_selector->hide(); - QLineEdit *ui_char_password; + ui_back_to_lobby->setText("Back to Lobby"); + set_size_and_pos(ui_back_to_lobby, "back_to_lobby"); - AOButton *ui_spectator; + set_size_and_pos(ui_char_password, "char_password"); + + ui_spectator->setText("spectator"); + set_size_and_pos(ui_spectator, "spectator"); } @@ -227,6 +249,12 @@ void Courtroom::on_reload_theme_clicked() set_widgets(); } +void Courtroom::on_back_to_lobby_clicked() +{ + ao_app->construct_lobby(); + ao_app->destruct_courtroom(); +} + Courtroom::~Courtroom() { diff --git a/courtroom.h b/courtroom.h index e0dee82..dee5401 100644 --- a/courtroom.h +++ b/courtroom.h @@ -123,6 +123,8 @@ private: private slots: void on_reload_theme_clicked(); + void on_back_to_lobby_clicked(); + }; #endif // COURTROOM_H diff --git a/lobby.cpp b/lobby.cpp index 17cae5f..414ce93 100644 --- a/lobby.cpp +++ b/lobby.cpp @@ -14,7 +14,6 @@ Lobby::Lobby(AOApplication *p_ao_app) : QMainWindow() ao_app = p_ao_app; this->setWindowTitle("Attorney Online 2"); - this->resize(m_lobby_width, m_lobby_height); this->setFixedSize(m_lobby_width, m_lobby_height); ui_background = new AOImage(this, ao_app); @@ -167,18 +166,6 @@ void Lobby::on_add_to_fav_released() return; ao_app->add_favorite_server(ui_server_list->currentRow()); - /* - if (n_server < 0 || n_server >= ao_app->get_server_list().size()) - return; - - server_type fav_server = ao_app->get_server_list().at(n_server); - - QString str_port = QString::number(fav_server.port); - - QString server_line = fav_server.ip + ":" + str_port + ":" + fav_server.name; - - write_to_serverlist_txt(server_line); - */ } void Lobby::on_connect_pressed() From 7b7315005329266c26facb1885dc6483c081fabb Mon Sep 17 00:00:00 2001 From: Skoland Date: Sun, 22 Jan 2017 01:19:59 +0100 Subject: [PATCH 2/4] added hdid function(for win32) --- Attorney_Online_remake.pro | 6 ++++-- main.cpp | 16 ++++++++-------- packet_distribution.cpp | 11 +++++++++-- win32_functions.cpp | 15 +++++++++++++++ win32_functions.h | 11 +++++++++++ 5 files changed, 47 insertions(+), 12 deletions(-) create mode 100644 win32_functions.cpp create mode 100644 win32_functions.h diff --git a/Attorney_Online_remake.pro b/Attorney_Online_remake.pro index a51e1f6..fe41bc2 100644 --- a/Attorney_Online_remake.pro +++ b/Attorney_Online_remake.pro @@ -29,7 +29,8 @@ SOURCES += main.cpp\ hex_functions.cpp \ encryption_functions.cpp \ courtroom.cpp \ - aocharbutton.cpp + aocharbutton.cpp \ + win32_functions.cpp HEADERS += lobby.h \ text_file_functions.h \ @@ -46,4 +47,5 @@ HEADERS += lobby.h \ hex_functions.h \ encryption_functions.h \ courtroom.h \ - aocharbutton.h + aocharbutton.h \ + win32_functions.h diff --git a/main.cpp b/main.cpp index f1e42fd..2116b52 100644 --- a/main.cpp +++ b/main.cpp @@ -9,13 +9,13 @@ int main(int argc, char *argv[]) { - AOApplication::setAttribute(Qt::AA_EnableHighDpiScaling); - AOApplication main_app(argc, argv); - main_app.construct_lobby(); - main_app.net_manager->connect_to_master(); - AOPacket *f_packet = new AOPacket("ALL#%"); - main_app.send_ms_packet(f_packet); - main_app.w_lobby->show(); + AOApplication::setAttribute(Qt::AA_EnableHighDpiScaling); + AOApplication main_app(argc, argv); + main_app.construct_lobby(); + main_app.net_manager->connect_to_master(); + AOPacket *f_packet = new AOPacket("ALL#%"); + main_app.send_ms_packet(f_packet); + main_app.w_lobby->show(); - return main_app.exec(); + return main_app.exec(); } diff --git a/packet_distribution.cpp b/packet_distribution.cpp index 4e02fb4..114f01b 100644 --- a/packet_distribution.cpp +++ b/packet_distribution.cpp @@ -3,6 +3,7 @@ #include "lobby.h" #include "networkmanager.h" #include "encryption_functions.h" +#include "win32_functions.h" #include @@ -85,9 +86,14 @@ void AOApplication::server_packet_received(AOPacket *p_packet) //you may ask where 322 comes from. that would be a good question. s_decryptor = fanta_decrypt(f_contents.at(0), 322).toUInt(); - //T0D0 add an actual HDID here - AOPacket *hi_packet = new AOPacket("HI#ao2testinginprogressdontmindme#%"); + QString f_hdid; +#ifdef Q_OS_WIN32 + f_hdid = get_hdid(); +#else + f_hdid = "ao2testinginprogress"; +#endif + AOPacket *hi_packet = new AOPacket("HI#" + f_hdid + "#%"); send_server_packet(hi_packet); delete hi_packet; @@ -97,6 +103,7 @@ void AOApplication::server_packet_received(AOPacket *p_packet) if (f_contents.size() < 1) return; + //T0D0: save server version here, somehow } else if (header == "CT") { diff --git a/win32_functions.cpp b/win32_functions.cpp new file mode 100644 index 0000000..76ca18a --- /dev/null +++ b/win32_functions.cpp @@ -0,0 +1,15 @@ +#include "win32_functions.h" + +DWORD dwVolSerial; +BOOL bIsRetrieved; + +QString get_hdid() +{ + bIsRetrieved = GetVolumeInformation(TEXT("C:\\"), NULL, NULL, &dwVolSerial, NULL, NULL, NULL, NULL); + + if (bIsRetrieved) + return QString::number(dwVolSerial, 16); + else + return "invalidhd"; //what could possibly go wrong + +} diff --git a/win32_functions.h b/win32_functions.h new file mode 100644 index 0000000..a095b88 --- /dev/null +++ b/win32_functions.h @@ -0,0 +1,11 @@ +#ifndef WIN32_FUNCTIONS_H +#define WIN32_FUNCTIONS_H + +#include + +#include +#include + +QString get_hdid(); + +#endif // WIN32_FUNCTIONS_H From 9ba9987d1fae9de120ee19ac93655efe9ed6566b Mon Sep 17 00:00:00 2001 From: David Skoland Date: Mon, 23 Jan 2017 12:21:58 +0100 Subject: [PATCH 3/4] added cleaner frame for cross-platform hdid implementation --- Attorney_Online_remake.pro | 4 +-- hardware_functions.cpp | 34 +++++++++++++++++++++++ win32_functions.h => hardware_functions.h | 3 ++ packet_distribution.cpp | 6 +--- win32_functions.cpp | 15 ---------- 5 files changed, 40 insertions(+), 22 deletions(-) create mode 100644 hardware_functions.cpp rename win32_functions.h => hardware_functions.h (80%) delete mode 100644 win32_functions.cpp diff --git a/Attorney_Online_remake.pro b/Attorney_Online_remake.pro index fe41bc2..1b2a1a2 100644 --- a/Attorney_Online_remake.pro +++ b/Attorney_Online_remake.pro @@ -30,7 +30,7 @@ SOURCES += main.cpp\ encryption_functions.cpp \ courtroom.cpp \ aocharbutton.cpp \ - win32_functions.cpp + hardware_functions.cpp HEADERS += lobby.h \ text_file_functions.h \ @@ -48,4 +48,4 @@ HEADERS += lobby.h \ encryption_functions.h \ courtroom.h \ aocharbutton.h \ - win32_functions.h + hardware_functions.h diff --git a/hardware_functions.cpp b/hardware_functions.cpp new file mode 100644 index 0000000..ce6e35a --- /dev/null +++ b/hardware_functions.cpp @@ -0,0 +1,34 @@ +#include "hardware_functions.h" + +#if (defined (_WIN32) || defined (_WIN64)) +DWORD dwVolSerial; +BOOL bIsRetrieved; + +QString get_hdid() +{ + bIsRetrieved = GetVolumeInformation(TEXT("C:\\"), NULL, NULL, &dwVolSerial, NULL, NULL, NULL, NULL); + + if (bIsRetrieved) + return QString::number(dwVolSerial, 16); + else + return "invalid_windows_hd"; //what could possibly go wrong + +} + +#elif (defined (LINUX) || defined (__linux__)) + +QString get_hdid() +{ + //T0D0: add linux implementation + return "linux_os_hdid"; +} + +#else + +QString get_hdid() +{ + //T0D0: find a sane way to handle this + return "unknown_os_hdid"; +} + +#endif diff --git a/win32_functions.h b/hardware_functions.h similarity index 80% rename from win32_functions.h rename to hardware_functions.h index a095b88..7508a5a 100644 --- a/win32_functions.h +++ b/hardware_functions.h @@ -3,7 +3,10 @@ #include +#ifdef Q_OS_WIN32 #include +#endif // Q_OS_WIN32 + #include QString get_hdid(); diff --git a/packet_distribution.cpp b/packet_distribution.cpp index 114f01b..852afaf 100644 --- a/packet_distribution.cpp +++ b/packet_distribution.cpp @@ -3,7 +3,7 @@ #include "lobby.h" #include "networkmanager.h" #include "encryption_functions.h" -#include "win32_functions.h" +#include "hardware_functions.h" #include @@ -87,11 +87,7 @@ void AOApplication::server_packet_received(AOPacket *p_packet) s_decryptor = fanta_decrypt(f_contents.at(0), 322).toUInt(); QString f_hdid; -#ifdef Q_OS_WIN32 f_hdid = get_hdid(); -#else - f_hdid = "ao2testinginprogress"; -#endif AOPacket *hi_packet = new AOPacket("HI#" + f_hdid + "#%"); send_server_packet(hi_packet); diff --git a/win32_functions.cpp b/win32_functions.cpp deleted file mode 100644 index 76ca18a..0000000 --- a/win32_functions.cpp +++ /dev/null @@ -1,15 +0,0 @@ -#include "win32_functions.h" - -DWORD dwVolSerial; -BOOL bIsRetrieved; - -QString get_hdid() -{ - bIsRetrieved = GetVolumeInformation(TEXT("C:\\"), NULL, NULL, &dwVolSerial, NULL, NULL, NULL, NULL); - - if (bIsRetrieved) - return QString::number(dwVolSerial, 16); - else - return "invalidhd"; //what could possibly go wrong - -} From 6b85266e869630fd642476dfd05627109b2cc7e3 Mon Sep 17 00:00:00 2001 From: David Skoland Date: Mon, 23 Jan 2017 13:09:50 +0100 Subject: [PATCH 4/4] obsoleted global_variables, moved to the AOApp object --- Attorney_Online_remake.pro | 2 -- global_variables.cpp | 8 -------- global_variables.h | 8 -------- packet_distribution.cpp | 2 +- 4 files changed, 1 insertion(+), 19 deletions(-) delete mode 100644 global_variables.cpp delete mode 100644 global_variables.h diff --git a/Attorney_Online_remake.pro b/Attorney_Online_remake.pro index 1b2a1a2..0ce693a 100644 --- a/Attorney_Online_remake.pro +++ b/Attorney_Online_remake.pro @@ -20,7 +20,6 @@ SOURCES += main.cpp\ aoimage.cpp \ file_functions.cpp \ aobutton.cpp \ - global_variables.cpp \ debug_functions.cpp \ networkmanager.cpp \ aoapplication.cpp \ @@ -38,7 +37,6 @@ HEADERS += lobby.h \ aoimage.h \ file_functions.h \ aobutton.h \ - global_variables.h \ debug_functions.h \ networkmanager.h \ aoapplication.h \ diff --git a/global_variables.cpp b/global_variables.cpp deleted file mode 100644 index b3a7e12..0000000 --- a/global_variables.cpp +++ /dev/null @@ -1,8 +0,0 @@ -#include "global_variables.h" -#include "text_file_functions.h" - -const int RELEASE = 2; -const int MAJOR_VERSION = 1; -const int MINOR_VERSION = 0; - -QString g_user_theme = "default"; diff --git a/global_variables.h b/global_variables.h deleted file mode 100644 index 941ac49..0000000 --- a/global_variables.h +++ /dev/null @@ -1,8 +0,0 @@ -#ifndef GLOBAL_VARIABLES_H -#define GLOBAL_VARIABLES_H - -#include - - - -#endif // GLOBAL_VARIABLES_H diff --git a/packet_distribution.cpp b/packet_distribution.cpp index 852afaf..5250dfa 100644 --- a/packet_distribution.cpp +++ b/packet_distribution.cpp @@ -99,7 +99,7 @@ void AOApplication::server_packet_received(AOPacket *p_packet) if (f_contents.size() < 1) return; - //T0D0: save server version here, somehow + //T0D0: save server version here, somehow(it's in the HI# packet usually) } else if (header == "CT") {