From a6b39c1d4f0ee0c9d6ffae14de20188d1dedb2ea Mon Sep 17 00:00:00 2001 From: David Skoland Date: Tue, 24 Jan 2017 14:30:18 +0100 Subject: added hdid implementation for linux and did more work on courtroom --- aoapplication.h | 4 ++-- aoimage.cpp | 1 - courtroom.cpp | 58 +++++++++++++++++++++++++++++++++++++++++++------- courtroom.h | 3 +++ hardware_functions.cpp | 40 +++++++++++++++++++++++++++------- hardware_functions.h | 10 +++------ lobby.cpp | 1 - path_functions.cpp | 1 - 8 files changed, 90 insertions(+), 28 deletions(-) diff --git a/aoapplication.h b/aoapplication.h index 77d7af0..3dfd813 100644 --- a/aoapplication.h +++ b/aoapplication.h @@ -64,14 +64,14 @@ public: void set_user_theme(); QString get_user_theme() {return user_theme;} - //path functions + //implementation in path_functions.cpp QString get_base_path(); QString get_theme_path(); QString get_default_theme_path(); QString get_character_path(QString p_character); QString get_demothings_path(); - //text file functions + //implementation in text_file_functions.cpp QString read_user_theme(); void write_to_serverlist_txt(QString p_line); QVector read_serverlist_txt(); diff --git a/aoimage.cpp b/aoimage.cpp index 2e09f6a..bfe1142 100644 --- a/aoimage.cpp +++ b/aoimage.cpp @@ -1,6 +1,5 @@ #include "file_functions.h" #include "path_functions.h" -#include "global_variables.h" #include "aoimage.h" diff --git a/courtroom.cpp b/courtroom.cpp index f0ad216..49a1b23 100644 --- a/courtroom.cpp +++ b/courtroom.cpp @@ -1,9 +1,9 @@ #include "courtroom.h" #include "aoapplication.h" +#include "lobby.h" #include "text_file_functions.h" #include "path_functions.h" -#include "global_variables.h" #include @@ -73,9 +73,17 @@ Courtroom::Courtroom(AOApplication *p_ao_app) : QMainWindow() ui_text_color = new QComboBox(this); - ui_music_slider = new QSlider(this); - ui_sfx_slider = new QSlider(this); - ui_blip_slider = new QSlider(this); + ui_music_slider = new QSlider(Qt::Horizontal, this); + ui_music_slider->setRange(0, 100); + ui_music_slider->setValue(50); + + ui_sfx_slider = new QSlider(Qt::Horizontal, this); + ui_sfx_slider->setRange(0, 100); + ui_music_slider->setValue(50); + + ui_blip_slider = new QSlider(Qt::Horizontal, this); + ui_blip_slider->setRange(0, 100); + ui_music_slider->setValue(50); ui_muted = new AOImage(this, ao_app); @@ -98,8 +106,6 @@ Courtroom::Courtroom(AOApplication *p_ao_app) : QMainWindow() 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); ui_back_to_lobby = new AOButton(ui_char_select_background, ao_app); @@ -108,10 +114,14 @@ Courtroom::Courtroom(AOApplication *p_ao_app) : QMainWindow() ui_spectator = new AOButton(ui_char_select_background, ao_app); + connect(ui_change_character, SIGNAL(clicked()), this, SLOT(on_change_character_clicked())); + 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())); + connect(ui_spectator, SIGNAL(clicked()), this, SLOT(on_spectator_clicked())); + set_widgets(); } @@ -148,7 +158,10 @@ void Courtroom::set_widgets() //emote buttons set_size_and_pos(ui_emote_left, "emote_left"); + ui_emote_left->set_image("arrow_left.png"); + set_size_and_pos(ui_emote_right, "emote_right"); + ui_emote_right->set_image("arrow_right.png"); set_size_and_pos(ui_defense_bar, "defense_bar"); set_size_and_pos(ui_prosecution_bar, "prosecution_bar"); @@ -167,25 +180,43 @@ void Courtroom::set_widgets() set_size_and_pos(ui_cross_examination, "cross_examination"); set_size_and_pos(ui_change_character, "change_character"); + ui_change_character->setText("Change character"); set_size_and_pos(ui_reload_theme, "reload_theme"); ui_reload_theme->setText("Reload theme"); set_size_and_pos(ui_call_mod, "call_mod"); + ui_call_mod->setText("Call mod"); set_size_and_pos(ui_pre, "pre"); + ui_pre->setText("Pre"); + set_size_and_pos(ui_flip, "flip"); + ui_flip->setText("Flip"); + set_size_and_pos(ui_guard, "guard"); + ui_guard->setText("Guard"); set_size_and_pos(ui_custom_objection, "custom_objection"); + ui_custom_objection->set_image("custom.png"); + set_size_and_pos(ui_realization, "realization"); - set_size_and_pos(ui_mute, "mute"); + ui_realization->set_image("realization.png"); + + set_size_and_pos(ui_mute, "mute_button"); + ui_mute->set_image("mute.png"); set_size_and_pos(ui_defense_plus, "defense_plus"); + ui_defense_plus->set_image("defplus.png"); + set_size_and_pos(ui_defense_minus, "defense_minus"); + ui_defense_minus->set_image("defminus.png"); set_size_and_pos(ui_prosecution_plus, "prosecution_plus"); + ui_prosecution_plus->set_image("proplus.png"); + set_size_and_pos(ui_prosecution_minus, "prosecution_minus"); + ui_prosecution_minus->set_image("prominus.png"); set_size_and_pos(ui_text_color, "text_color"); @@ -213,7 +244,7 @@ void Courtroom::set_widgets() set_size_and_pos(ui_char_password, "char_password"); - ui_spectator->setText("spectator"); + ui_spectator->setText("Spectator"); set_size_and_pos(ui_spectator, "spectator"); } @@ -242,6 +273,11 @@ void Courtroom::set_size_and_pos(QWidget *p_widget, QString p_identifier) p_widget->resize(design_ini_result.width, design_ini_result.height); } +void Courtroom::on_change_character_clicked() +{ + ui_char_select_background->show(); +} + void Courtroom::on_reload_theme_clicked() { ao_app->set_user_theme(); @@ -252,9 +288,15 @@ void Courtroom::on_reload_theme_clicked() void Courtroom::on_back_to_lobby_clicked() { ao_app->construct_lobby(); + ao_app->w_lobby->list_servers(); ao_app->destruct_courtroom(); } +void Courtroom::on_spectator_clicked() +{ + ui_char_select_background->hide(); +} + Courtroom::~Courtroom() { diff --git a/courtroom.h b/courtroom.h index dee5401..ab78c04 100644 --- a/courtroom.h +++ b/courtroom.h @@ -121,10 +121,13 @@ private: AOButton *ui_spectator; private slots: + void on_change_character_clicked(); void on_reload_theme_clicked(); void on_back_to_lobby_clicked(); + void on_spectator_clicked(); + }; #endif // COURTROOM_H diff --git a/hardware_functions.cpp b/hardware_functions.cpp index ce6e35a..e755c24 100644 --- a/hardware_functions.cpp +++ b/hardware_functions.cpp @@ -1,6 +1,10 @@ #include "hardware_functions.h" +#include + #if (defined (_WIN32) || defined (_WIN64)) +#include + DWORD dwVolSerial; BOOL bIsRetrieved; @@ -11,24 +15,44 @@ QString get_hdid() if (bIsRetrieved) return QString::number(dwVolSerial, 16); else - return "invalid_windows_hd"; //what could possibly go wrong + return "gxsps32sa9fnwic92mfbs0"; //what could possibly go wrong } #elif (defined (LINUX) || defined (__linux__)) +#include +#include + QString get_hdid() { - //T0D0: add linux implementation - return "linux_os_hdid"; + QFile fstab_file("/etc/fstab"); + if (!fstab_file.open(QIODevice::ReadOnly)) + //literally a random string.... what else are we supposed to do? + return "gxcps32sa9fnwic92mfbs0"; + + QTextStream in(&fstab_file); + + while(!in.atEnd()) + { + QString line = in.readLine(); + + if (line.startsWith("UUID")) + { + QStringList line_elements = line.split("="); + + if (line_elements.size() > 1) + return line_elements.at(1).left(23).trimmed(); + } + } + + qDebug() << "wew"; + return "gxcpz32sa9fnwic92mfbs0"; } #else -QString get_hdid() -{ - //T0D0: find a sane way to handle this - return "unknown_os_hdid"; -} +//throwing compile-time errors professionally +fhasdfuifhidfhasjkfasdkfahsdj #endif diff --git a/hardware_functions.h b/hardware_functions.h index 7508a5a..3fcb27c 100644 --- a/hardware_functions.h +++ b/hardware_functions.h @@ -1,14 +1,10 @@ -#ifndef WIN32_FUNCTIONS_H -#define WIN32_FUNCTIONS_H +#ifndef HARDWARE_FUNCTIONS_H +#define HARDWARE_FUNCTIONS_H #include -#ifdef Q_OS_WIN32 -#include -#endif // Q_OS_WIN32 - #include QString get_hdid(); -#endif // WIN32_FUNCTIONS_H +#endif // HARDWARE_FUNCTIONS_H diff --git a/lobby.cpp b/lobby.cpp index 414ce93..04ec4f9 100644 --- a/lobby.cpp +++ b/lobby.cpp @@ -2,7 +2,6 @@ #include "path_functions.h" #include "text_file_functions.h" -#include "global_variables.h" #include "debug_functions.h" #include "aoapplication.h" #include "networkmanager.h" diff --git a/path_functions.cpp b/path_functions.cpp index 46f80ef..7afd923 100644 --- a/path_functions.cpp +++ b/path_functions.cpp @@ -1,6 +1,5 @@ #include "aoapplication.h" -#include "global_variables.h" #include "text_file_functions.h" #include -- cgit From 3e8d0610ca59700b18da97a389d45bff925f234d Mon Sep 17 00:00:00 2001 From: David Skoland Date: Tue, 24 Jan 2017 15:54:49 +0100 Subject: removed debug statement --- hardware_functions.cpp | 1 - 1 file changed, 1 deletion(-) diff --git a/hardware_functions.cpp b/hardware_functions.cpp index e755c24..0b161c3 100644 --- a/hardware_functions.cpp +++ b/hardware_functions.cpp @@ -46,7 +46,6 @@ QString get_hdid() } } - qDebug() << "wew"; return "gxcpz32sa9fnwic92mfbs0"; } -- cgit From b606b55cae1c1244ec9de19c54acf1a1824013f4 Mon Sep 17 00:00:00 2001 From: David Skoland Date: Tue, 24 Jan 2017 21:00:56 +0100 Subject: started implementing legacy loading protocol --- aoapplication.h | 14 +++++++++++--- courtroom.h | 9 +++++++++ lobby.cpp | 10 +++------- packet_distribution.cpp | 40 ++++++++++++++++++++++++++++++++++++++-- 4 files changed, 61 insertions(+), 12 deletions(-) diff --git a/aoapplication.h b/aoapplication.h index 3dfd813..3c6ef4c 100644 --- a/aoapplication.h +++ b/aoapplication.h @@ -44,10 +44,18 @@ public: unsigned int s_decryptor = 5; bool encryption_needed = true; bool ao2_features = false; - //player number, it's hardly used but might be needed for some old servers - bool s_pv = 0; - ////////////////////////////////////////////////// + ///////////////loading info/////////////////// + + //player number, it's hardly used but might be needed for some old servers + int s_pv = 0; + + int char_list_size = 0; + int loaded_chars = 0; + int evidence_list_size = 0; + int loaded_evidence = 0; + int music_list_size = 0; + int loaded_music = 0; int get_release() {return RELEASE;} int get_major_version() {return MAJOR_VERSION;} diff --git a/courtroom.h b/courtroom.h index ab78c04..1278c83 100644 --- a/courtroom.h +++ b/courtroom.h @@ -24,6 +24,11 @@ class Courtroom : public QMainWindow Q_OBJECT public: explicit Courtroom(AOApplication *p_ao_app); + + void append_char(char_type p_char){char_list.append(p_char);} + void append_evidence(evi_type p_evi){evidence_list.append(p_evi);} + void append_music(QString f_music){music_list.append(f_music);} + void set_widgets(); void set_size_and_pos(QWidget *p_widget, QString p_identifier); @@ -41,6 +46,10 @@ private: const int m_viewport_width = 256; const int m_viewport_height = 192; + QVector char_list; + QVector evidence_list; + QVector music_list; + AOImage *ui_background; //viewport elements like background, desk, etc. diff --git a/lobby.cpp b/lobby.cpp index 04ec4f9..4a43df7 100644 --- a/lobby.cpp +++ b/lobby.cpp @@ -176,15 +176,11 @@ void Lobby::on_connect_released() { ui_connect->set_image("connect.png"); - //D3BUG START + AOPacket *f_packet = new AOPacket("askchaa#%"); - ao_app->construct_courtroom(); + ao_app->send_server_packet(f_packet); - ao_app->destruct_lobby(); - - //D3BUG END - - //T0D0: call ao_app to initialize loading sequence + delete f_packet; } void Lobby::on_about_clicked() diff --git a/packet_distribution.cpp b/packet_distribution.cpp index 5250dfa..391f2e2 100644 --- a/packet_distribution.cpp +++ b/packet_distribution.cpp @@ -99,7 +99,12 @@ void AOApplication::server_packet_received(AOPacket *p_packet) if (f_contents.size() < 1) return; - //T0D0: save server version here, somehow(it's in the HI# packet usually) + s_pv = f_contents.at(0).toInt(); + + if (f_contents.size() < 2) + return; + + //T0D0: store server version } else if (header == "CT") { @@ -121,6 +126,37 @@ void AOApplication::server_packet_received(AOPacket *p_packet) w_lobby->set_player_count(f_contents.at(0).toInt(), f_contents.at(1).toInt()); } + else if (header == "SI") + { + if (f_contents.size() > 3) + return; + + char_list_size = f_contents.at(0).toInt(); + loaded_chars = 0; + evidence_list_size = f_contents.at(1).toInt(); + loaded_evidence = 0; + music_list_size = f_contents.at(2).toInt(); + loaded_music = 0; + + destruct_courtroom(); + + construct_courtroom(); + + AOPacket *f_packet = new AOPacket("askchar2#%"); + send_server_packet(f_packet); + delete f_packet; + } + else if (header == "CI") + { + if (!courtroom_constructed) + return; + AOPacket *f_packet = new AOPacket("AN#1#%"); + send_server_packet(f_packet); + delete f_packet; + + //w_courtroom->append_char(); + + } } void AOApplication::send_ms_packet(AOPacket *p_packet) @@ -142,7 +178,7 @@ void AOApplication::send_server_packet(AOPacket *p_packet) if (encryption_needed) { - qDebug() << "S:(e)" << f_packet; + qDebug() << "S(e):" << f_packet; p_packet->encrypt_header(s_decryptor); f_packet = p_packet->to_string(); -- cgit From 723582574094e4b7db6c25569c2b180c426ae513 Mon Sep 17 00:00:00 2001 From: David Skoland Date: Wed, 25 Jan 2017 15:54:00 +0100 Subject: characters now load successfully --- lobby.cpp | 69 ++++++++++++++++++++++++++----------------------- lobby.h | 2 ++ networkmanager.cpp | 4 --- packet_distribution.cpp | 47 +++++++++++++++++++++++++++------ 4 files changed, 78 insertions(+), 44 deletions(-) diff --git a/lobby.cpp b/lobby.cpp index 4a43df7..9ff0990 100644 --- a/lobby.cpp +++ b/lobby.cpp @@ -50,68 +50,79 @@ void Lobby::set_widgets() ao_app->set_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); + set_size_and_pos(ui_public_servers, "public_servers"); ui_favorites->set_image("favorites.png"); - ui_favorites->move(164, 88); - ui_favorites->resize(114, 30); + set_size_and_pos(ui_favorites, "favorites"); ui_refresh->set_image("refresh.png"); - ui_refresh->move(56, 381); - ui_refresh->resize(132, 28); + set_size_and_pos(ui_refresh, "refresh"); ui_add_to_fav->set_image("addtofav.png"); - ui_add_to_fav->move(194, 381); - ui_add_to_fav->resize(132, 28); + set_size_and_pos(ui_add_to_fav, "add_to_fav"); ui_connect->set_image("connect.png"); - ui_connect->move(332, 381); - ui_connect->resize(132, 28); + set_size_and_pos(ui_connect, "connect"); ui_about->set_image("about.png"); - ui_about->move(428, 1); - ui_about->resize(88, 21); + set_size_and_pos(ui_about, "about"); - ui_server_list->move(20, 125); - ui_server_list->resize(286, 240); + set_size_and_pos(ui_server_list, "server_list"); ui_server_list->setStyleSheet("background-color: rgba(0, 0, 0, 0);" - "font: bold;"); + "font: bold;"); - ui_player_count->move(336, 91); - ui_player_count->resize(173, 16); + set_size_and_pos(ui_player_count, "player_count"); ui_player_count->setText("Offline"); ui_player_count->setStyleSheet("font: bold;" "color: white;" "qproperty-alignment: AlignCenter;"); - ui_description->move(337, 109); - ui_description->resize(173, 245); + set_size_and_pos(ui_description, "description"); ui_description->setReadOnly(true); ui_description->setStyleSheet("background-color: rgba(0, 0, 0, 0);" "color: white;"); - ui_chatbox->move(2, 445); - ui_chatbox->resize(515, 198); + set_size_and_pos(ui_chatbox, "chatbox"); ui_chatbox->setReadOnly(true); ui_chatbox->setStyleSheet("background-color: rgba(0, 0, 0, 0);"); - ui_chatname->move(3, 646); - ui_chatname->resize(85, 19); + set_size_and_pos(ui_chatname, "chatname"); ui_chatname->setStyleSheet("background-color: rgba(0, 0, 0, 0);" "selection-background-color: rgba(0, 0, 0, 0);"); - ui_chatmessage->move(93, 646); - ui_chatmessage->resize(424, 19); + set_size_and_pos(ui_chatmessage, "chatmessage"); ui_chatmessage->setStyleSheet("background-color: rgba(0, 0, 0, 0);" "selection-background-color: rgba(0, 0, 0, 0);"); } +void Lobby::set_size_and_pos(QWidget *p_widget, QString p_identifier) +{ + QString design_ini_path = ao_app->get_theme_path() + "lobby_design.ini"; + QString default_ini_path = ao_app->get_base_path() + "themes/default/lobby_design.ini"; + + pos_size_type design_ini_result = ao_app->get_pos_and_size(p_identifier, design_ini_path); + + if (design_ini_result.width < 0 || design_ini_result.height < 0) + { + design_ini_result = ao_app->get_pos_and_size(p_identifier, default_ini_path); + + if (design_ini_result.width < 0 || design_ini_result.height < 0) + { + //at this point it's pretty much game over + //T0D0: add message box + qDebug() << "CRITICAL ERROR: NO SUITABLE DATA FOR SETTING " << p_identifier; + ao_app->quit(); + } + } + + p_widget->move(design_ini_result.x, design_ini_result.y); + p_widget->resize(design_ini_result.width, design_ini_result.height); +} + void Lobby::on_public_servers_clicked() { ui_public_servers->set_image("publicservers_selected.png"); @@ -147,8 +158,6 @@ void Lobby::on_refresh_released() AOPacket *f_packet = new AOPacket("ALL#%"); ao_app->send_ms_packet(f_packet); - - delete f_packet; } void Lobby::on_add_to_fav_pressed() @@ -179,8 +188,6 @@ void Lobby::on_connect_released() AOPacket *f_packet = new AOPacket("askchaa#%"); ao_app->send_server_packet(f_packet); - - delete f_packet; } void Lobby::on_about_clicked() @@ -233,8 +240,6 @@ void Lobby::on_chatfield_return_pressed() ao_app->send_ms_packet(f_packet); ui_chatmessage->clear(); - - delete f_packet; } void Lobby::list_servers() diff --git a/lobby.h b/lobby.h index e4d6499..812741d 100644 --- a/lobby.h +++ b/lobby.h @@ -57,6 +57,8 @@ private: QLineEdit *ui_chatname; QLineEdit *ui_chatmessage; + void set_size_and_pos(QWidget *p_widget, QString p_identifier); + private slots: void on_public_servers_clicked(); void on_favorites_clicked(); diff --git a/networkmanager.cpp b/networkmanager.cpp index 2568b69..e0967f0 100644 --- a/networkmanager.cpp +++ b/networkmanager.cpp @@ -78,8 +78,6 @@ void NetworkManager::handle_ms_packet() AOPacket *f_packet = new AOPacket(packet); ao_app->ms_packet_received(f_packet); - - delete f_packet; } } @@ -114,8 +112,6 @@ void NetworkManager::handle_server_packet() AOPacket *f_packet = new AOPacket(packet); ao_app->server_packet_received(f_packet); - - delete f_packet; } } diff --git a/packet_distribution.cpp b/packet_distribution.cpp index 391f2e2..3ddacc6 100644 --- a/packet_distribution.cpp +++ b/packet_distribution.cpp @@ -1,6 +1,7 @@ #include "aoapplication.h" #include "lobby.h" +#include "courtroom.h" #include "networkmanager.h" #include "encryption_functions.h" #include "hardware_functions.h" @@ -91,8 +92,6 @@ void AOApplication::server_packet_received(AOPacket *p_packet) AOPacket *hi_packet = new AOPacket("HI#" + f_hdid + "#%"); send_server_packet(hi_packet); - - delete hi_packet; } else if (header == "ID") { @@ -128,7 +127,7 @@ void AOApplication::server_packet_received(AOPacket *p_packet) } else if (header == "SI") { - if (f_contents.size() > 3) + if (f_contents.size() < 3) return; char_list_size = f_contents.at(0).toInt(); @@ -144,17 +143,46 @@ void AOApplication::server_packet_received(AOPacket *p_packet) AOPacket *f_packet = new AOPacket("askchar2#%"); send_server_packet(f_packet); - delete f_packet; } else if (header == "CI") { if (!courtroom_constructed) return; - AOPacket *f_packet = new AOPacket("AN#1#%"); - send_server_packet(f_packet); - delete f_packet; - //w_courtroom->append_char(); + for (int n_element = 0 ; n_element < f_contents.size() ; n_element += 2) + { + if (f_contents.at(n_element).toInt() != loaded_chars) + break; + + if (n_element == f_contents.size() - 1) + break; + + QStringList sub_elements = f_contents.at(n_element + 1).split("&"); + if (sub_elements.size() < 2) + break; + + char_type f_char; + f_char.name = sub_elements.at(0); + f_char.description = sub_elements.at(1); + + ++loaded_chars; + qDebug() << "loaded_chars" << loaded_chars; + + w_courtroom->append_char(f_char); + + + qDebug() << f_contents.at(n_element + 1); + } + + if (loaded_chars < char_list_size) + { + qDebug() << "loaded_chars" << loaded_chars; + QString next_packet_number = QString::number(((loaded_chars - 1) / 10) + 1); + AOPacket *f_packet = new AOPacket("AN#" + next_packet_number + "#%"); + send_server_packet(f_packet); + } + + } } @@ -168,6 +196,8 @@ void AOApplication::send_ms_packet(AOPacket *p_packet) net_manager->ship_ms_packet(f_packet); qDebug() << "S(ms):" << f_packet; + + delete p_packet; } void AOApplication::send_server_packet(AOPacket *p_packet) @@ -190,4 +220,5 @@ void AOApplication::send_server_packet(AOPacket *p_packet) net_manager->ship_server_packet(f_packet); + delete p_packet; } -- cgit From ddce06f42c776fd7ab5540ad281676baae1bb4f8 Mon Sep 17 00:00:00 2001 From: David Skoland Date: Wed, 25 Jan 2017 15:56:26 +0100 Subject: debug version for corno --- lobby.cpp | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/lobby.cpp b/lobby.cpp index 9ff0990..0a1a88e 100644 --- a/lobby.cpp +++ b/lobby.cpp @@ -185,9 +185,11 @@ void Lobby::on_connect_released() { ui_connect->set_image("connect.png"); - AOPacket *f_packet = new AOPacket("askchaa#%"); - - ao_app->send_server_packet(f_packet); + //D3BUG + //AOPacket *f_packet = new AOPacket("askchaa#%"); + ao_app->construct_courtroom(); + //ao_app->send_server_packet(f_packet); + //D3BUG END } void Lobby::on_about_clicked() -- cgit From 54494fa5594d7345680109417ab1aa850af4d84d Mon Sep 17 00:00:00 2001 From: David Skoland Date: Wed, 25 Jan 2017 16:40:08 +0100 Subject: finished setting images to courtroom widgets --- courtroom.cpp | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/courtroom.cpp b/courtroom.cpp index 49a1b23..7b1e041 100644 --- a/courtroom.cpp +++ b/courtroom.cpp @@ -79,11 +79,11 @@ Courtroom::Courtroom(AOApplication *p_ao_app) : QMainWindow() ui_sfx_slider = new QSlider(Qt::Horizontal, this); ui_sfx_slider->setRange(0, 100); - ui_music_slider->setValue(50); + ui_sfx_slider->setValue(50); ui_blip_slider = new QSlider(Qt::Horizontal, this); ui_blip_slider->setRange(0, 100); - ui_music_slider->setValue(50); + ui_blip_slider->setValue(50); ui_muted = new AOImage(this, ao_app); @@ -164,20 +164,31 @@ void Courtroom::set_widgets() ui_emote_right->set_image("arrow_right.png"); set_size_and_pos(ui_defense_bar, "defense_bar"); + ui_defense_bar->set_image("defensebar10.png"); + set_size_and_pos(ui_prosecution_bar, "prosecution_bar"); + ui_prosecution_bar->set_image("prosecutionbar10.png"); set_size_and_pos(ui_music_label, "music_label"); + ui_music_label->setText("Music"); set_size_and_pos(ui_sfx_label, "sfx_label"); + ui_sfx_label->setText("Sfx"); set_size_and_pos(ui_blip_label, "blip_label"); + ui_blip_label->setText("Blips"); set_size_and_pos(ui_hold_it, "hold_it"); + ui_hold_it->set_image("holdit.png"); set_size_and_pos(ui_objection, "objection"); + ui_objection->set_image("objection.png"); set_size_and_pos(ui_take_that, "take_that"); + ui_take_that->set_image("takethat.png"); set_size_and_pos(ui_ooc_toggle, "ooc_toggle"); set_size_and_pos(ui_witness_testimony, "witness_testimony"); + ui_witness_testimony->set_image("witnesstestimony.png"); set_size_and_pos(ui_cross_examination, "cross_examination"); + ui_cross_examination->set_image("crossexamination.png"); set_size_and_pos(ui_change_character, "change_character"); ui_change_character->setText("Change character"); -- cgit From 7e666b7cd152ff1271431d91375c27908f63e636 Mon Sep 17 00:00:00 2001 From: David Skoland Date: Wed, 25 Jan 2017 17:13:15 +0100 Subject: added more attributes to courtroom widgets --- courtroom.cpp | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/courtroom.cpp b/courtroom.cpp index 7b1e041..231d6e9 100644 --- a/courtroom.cpp +++ b/courtroom.cpp @@ -137,20 +137,31 @@ void Courtroom::set_widgets() //viewport elements like background, desk, etc. go here set_size_and_pos(ui_ic_chatlog, "ic_chatlog"); + ui_ic_chatlog->setStyleSheet("background-color: rgba(0, 0, 0, 0);"); set_size_and_pos(ui_ms_chatlog, "ms_chatlog"); + ui_ms_chatlog->setStyleSheet("background-color: rgba(0, 0, 0, 0);"); set_size_and_pos(ui_server_chatlog, "server_chatlog"); + ui_server_chatlog->setStyleSheet("background-color: rgba(0, 0, 0, 0);"); set_size_and_pos(ui_mute_list, "mute_list"); + ui_mute_list->hide(); + set_size_and_pos(ui_area_list, "area_list"); + ui_area_list->setStyleSheet("background-color: rgba(0, 0, 0, 0);"); set_size_and_pos(ui_music_list, "music_list"); + ui_area_list->setStyleSheet("background-color: rgba(0, 0, 0, 0);"); set_size_and_pos(ui_ic_chat_message, "ic_chat_message"); + ui_ic_chat_message->setStyleSheet("background-color: rgba(0, 0, 0, 0);"); set_size_and_pos(ui_ooc_chat_message, "ooc_chat_message"); + ui_ooc_chat_message->setStyleSheet("background-color: rgba(0, 0, 0, 0);"); + set_size_and_pos(ui_ooc_chat_name, "ooc_chat_name"); + ui_ooc_chat_name->setStyleSheet("background-color: rgba(0, 0, 0, 0);"); set_size_and_pos(ui_area_password, "area_password"); set_size_and_pos(ui_music_search, "music_search"); @@ -184,6 +195,7 @@ void Courtroom::set_widgets() ui_take_that->set_image("takethat.png"); set_size_and_pos(ui_ooc_toggle, "ooc_toggle"); + ui_ooc_toggle->setText("Server"); set_size_and_pos(ui_witness_testimony, "witness_testimony"); ui_witness_testimony->set_image("witnesstestimony.png"); -- cgit From 58d98e41bea77dac1b5726b4ead8b3f072750b38 Mon Sep 17 00:00:00 2001 From: David Skoland Date: Wed, 25 Jan 2017 18:09:55 +0100 Subject: started making the loading screen --- aoapplication.h | 2 ++ lobby.cpp | 21 ++++++++++++++++----- lobby.h | 6 ++++++ packet_distribution.cpp | 14 ++++++++++++++ 4 files changed, 38 insertions(+), 5 deletions(-) diff --git a/aoapplication.h b/aoapplication.h index 3c6ef4c..c9daf86 100644 --- a/aoapplication.h +++ b/aoapplication.h @@ -57,6 +57,8 @@ public: int music_list_size = 0; int loaded_music = 0; + //////////////////versioning/////////////// + int get_release() {return RELEASE;} int get_major_version() {return MAJOR_VERSION;} int get_minor_version() {return MINOR_VERSION;} diff --git a/lobby.cpp b/lobby.cpp index 0a1a88e..a0b37a8 100644 --- a/lobby.cpp +++ b/lobby.cpp @@ -28,6 +28,10 @@ Lobby::Lobby(AOApplication *p_ao_app) : QMainWindow() ui_chatbox = new QPlainTextEdit(this); ui_chatname = new QLineEdit(this); ui_chatmessage = new QLineEdit(this); + ui_loading_background = new AOImage(this, ao_app); + ui_loading_label = new QLabel(ui_loading_background); + ui_progress_bar = new QProgressBar(ui_loading_background); + ui_cancel = new AOButton(ui_loading_background, ao_app); connect(ui_public_servers, SIGNAL(clicked()), this, SLOT(on_public_servers_clicked())); connect(ui_favorites, SIGNAL(clicked()), this, SLOT(on_favorites_clicked())); @@ -97,6 +101,16 @@ void Lobby::set_widgets() ui_chatmessage->setStyleSheet("background-color: rgba(0, 0, 0, 0);" "selection-background-color: rgba(0, 0, 0, 0);"); + ui_loading_background->set_image("loadingbackground.png"); + ui_loading_background->resize(m_lobby_width, m_lobby_height); + + set_size_and_pos(ui_loading_label, "loading_label"); + set_size_and_pos(ui_progress_bar, "progress_bar"); + set_size_and_pos(ui_cancel, "cancel"); + ui_cancel->setText("Cancel"); + + ui_loading_background->hide(); + } void Lobby::set_size_and_pos(QWidget *p_widget, QString p_identifier) @@ -185,11 +199,8 @@ void Lobby::on_connect_released() { ui_connect->set_image("connect.png"); - //D3BUG - //AOPacket *f_packet = new AOPacket("askchaa#%"); - ao_app->construct_courtroom(); - //ao_app->send_server_packet(f_packet); - //D3BUG END + AOPacket *f_packet = new AOPacket("askchaa#%"); + ao_app->send_server_packet(f_packet); } void Lobby::on_about_clicked() diff --git a/lobby.h b/lobby.h index 812741d..0481ebd 100644 --- a/lobby.h +++ b/lobby.h @@ -10,6 +10,7 @@ #include #include #include +#include class AOApplication; @@ -57,6 +58,11 @@ private: QLineEdit *ui_chatname; QLineEdit *ui_chatmessage; + AOImage *ui_loading_background; + QLabel *ui_loading_label; + QProgressBar *ui_progress_bar; + AOButton *ui_cancel; + void set_size_and_pos(QWidget *p_widget, QString p_identifier); private slots: diff --git a/packet_distribution.cpp b/packet_distribution.cpp index 3ddacc6..014919b 100644 --- a/packet_distribution.cpp +++ b/packet_distribution.cpp @@ -182,7 +182,21 @@ void AOApplication::server_packet_received(AOPacket *p_packet) send_server_packet(f_packet); } + else if (loaded_chars >= char_list_size) + { + if (evidence_list_size == 0) + send_server_packet(new AOPacket("AM#0#%")); + else + send_server_packet(new AOPacket("AE#0#%")); + } + + + } + else if (header == "EI"){ + + } + else if (header == "EM"){ } } -- cgit From c262bb4974ed293bf8e67524576477d2e92fd4f0 Mon Sep 17 00:00:00 2001 From: David Skoland Date: Wed, 25 Jan 2017 19:13:15 +0100 Subject: set attributes on loading screen widgets --- lobby.cpp | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/lobby.cpp b/lobby.cpp index a0b37a8..feeff23 100644 --- a/lobby.cpp +++ b/lobby.cpp @@ -105,11 +105,16 @@ void Lobby::set_widgets() ui_loading_background->resize(m_lobby_width, m_lobby_height); set_size_and_pos(ui_loading_label, "loading_label"); + ui_loading_label->setFont(QFont("Arial", 20, QFont::Bold)); + ui_loading_label->setStyleSheet("color: rgba(255, 128, 0, 255);" + "qproperty-alignment: AlignCenter;"); + ui_loading_label->setText("Loading"); + set_size_and_pos(ui_progress_bar, "progress_bar"); set_size_and_pos(ui_cancel, "cancel"); ui_cancel->setText("Cancel"); - ui_loading_background->hide(); + //ui_loading_background->hide(); } -- cgit From 99aa327318ab00f2049cfcefadd353c3a4e06bf7 Mon Sep 17 00:00:00 2001 From: David Skoland Date: Wed, 25 Jan 2017 19:50:49 +0100 Subject: loading characters now works with overlay --- aoapplication.cpp | 7 +++++++ aoapplication.h | 3 +++ lobby.cpp | 24 +++++++++++++++++------- lobby.h | 5 ++++- packet_distribution.cpp | 9 +++++---- 5 files changed, 36 insertions(+), 12 deletions(-) diff --git a/aoapplication.cpp b/aoapplication.cpp index 70aeb15..bf73434 100644 --- a/aoapplication.cpp +++ b/aoapplication.cpp @@ -100,3 +100,10 @@ void AOApplication::add_favorite_server(int p_server) write_to_serverlist_txt(server_line); } + +void AOApplication::loading_cancelled() +{ + destruct_courtroom(); + + w_lobby->hide_loading_overlay(); +} diff --git a/aoapplication.h b/aoapplication.h index c9daf86..a63ec41 100644 --- a/aoapplication.h +++ b/aoapplication.h @@ -96,6 +96,9 @@ private: QVector server_list; QVector favorite_list; + +public slots: + void loading_cancelled(); }; #endif // AOAPPLICATION_H diff --git a/lobby.cpp b/lobby.cpp index feeff23..3709114 100644 --- a/lobby.cpp +++ b/lobby.cpp @@ -29,7 +29,7 @@ Lobby::Lobby(AOApplication *p_ao_app) : QMainWindow() ui_chatname = new QLineEdit(this); ui_chatmessage = new QLineEdit(this); ui_loading_background = new AOImage(this, ao_app); - ui_loading_label = new QLabel(ui_loading_background); + ui_loading_text = new QTextEdit(ui_loading_background); ui_progress_bar = new QProgressBar(ui_loading_background); ui_cancel = new AOButton(ui_loading_background, ao_app); @@ -44,6 +44,7 @@ Lobby::Lobby(AOApplication *p_ao_app) : QMainWindow() connect(ui_about, SIGNAL(clicked()), this, SLOT(on_about_clicked())); connect(ui_server_list, SIGNAL(clicked(QModelIndex)), this, SLOT(on_server_list_clicked(QModelIndex))); connect(ui_chatmessage, SIGNAL(returnPressed()), this, SLOT(on_chatfield_return_pressed())); + connect(ui_cancel, SIGNAL(clicked()), ao_app, SLOT(loading_cancelled())); set_widgets(); } @@ -104,17 +105,19 @@ void Lobby::set_widgets() ui_loading_background->set_image("loadingbackground.png"); ui_loading_background->resize(m_lobby_width, m_lobby_height); - set_size_and_pos(ui_loading_label, "loading_label"); - ui_loading_label->setFont(QFont("Arial", 20, QFont::Bold)); - ui_loading_label->setStyleSheet("color: rgba(255, 128, 0, 255);" - "qproperty-alignment: AlignCenter;"); - ui_loading_label->setText("Loading"); + set_size_and_pos(ui_loading_text, "loading_label"); + ui_loading_text->setFont(QFont("Arial", 20, QFont::Bold)); + ui_loading_text->setReadOnly(true); + ui_loading_text->setAlignment(Qt::AlignCenter); + ui_loading_text->setStyleSheet("background-color: rgba(0, 0, 0, 0);" + "color: rgba(255, 128, 0, 255);"); + ui_loading_text->append("Loading"); set_size_and_pos(ui_progress_bar, "progress_bar"); set_size_and_pos(ui_cancel, "cancel"); ui_cancel->setText("Cancel"); - //ui_loading_background->hide(); + ui_loading_background->hide(); } @@ -142,6 +145,13 @@ void Lobby::set_size_and_pos(QWidget *p_widget, QString p_identifier) p_widget->resize(design_ini_result.width, design_ini_result.height); } +void Lobby::set_loading_text(QString p_text) +{ + ui_loading_text->clear(); + ui_loading_text->setAlignment(Qt::AlignCenter); + ui_loading_text->append(p_text); +} + void Lobby::on_public_servers_clicked() { ui_public_servers->set_image("publicservers_selected.png"); diff --git a/lobby.h b/lobby.h index 0481ebd..8f9b5ea 100644 --- a/lobby.h +++ b/lobby.h @@ -26,6 +26,9 @@ public: void list_favorites(); void append_chatmessage(QString p_message_line); void set_player_count(int players_online, int max_players); + void set_loading_text(QString p_text); + void show_loading_overlay(){ui_loading_background->show();} + void hide_loading_overlay(){ui_loading_background->hide();} ~Lobby(); @@ -59,7 +62,7 @@ private: QLineEdit *ui_chatmessage; AOImage *ui_loading_background; - QLabel *ui_loading_label; + QTextEdit *ui_loading_text; QProgressBar *ui_progress_bar; AOButton *ui_cancel; diff --git a/packet_distribution.cpp b/packet_distribution.cpp index 014919b..84ace31 100644 --- a/packet_distribution.cpp +++ b/packet_distribution.cpp @@ -141,6 +141,9 @@ void AOApplication::server_packet_received(AOPacket *p_packet) construct_courtroom(); + w_lobby->show_loading_overlay(); + w_lobby->set_loading_text("Loading"); + AOPacket *f_packet = new AOPacket("askchar2#%"); send_server_packet(f_packet); } @@ -166,12 +169,10 @@ void AOApplication::server_packet_received(AOPacket *p_packet) f_char.description = sub_elements.at(1); ++loaded_chars; - qDebug() << "loaded_chars" << loaded_chars; - w_courtroom->append_char(f_char); + w_lobby->set_loading_text("Loading chars:\n" + QString::number(loaded_chars) + "/" + QString::number(char_list_size)); - - qDebug() << f_contents.at(n_element + 1); + w_courtroom->append_char(f_char); } if (loaded_chars < char_list_size) -- cgit From b4b533b72492da38381ad2fbb6c5aad99e30f110 Mon Sep 17 00:00:00 2001 From: David Skoland Date: Thu, 26 Jan 2017 00:23:53 +0100 Subject: finished legacy loading process --- aoapplication.cpp | 3 -- courtroom.cpp | 16 +++++++++ courtroom.h | 1 + datatypes.h | 2 ++ packet_distribution.cpp | 94 +++++++++++++++++++++++++++++++++++++++++++++---- 5 files changed, 107 insertions(+), 9 deletions(-) diff --git a/aoapplication.cpp b/aoapplication.cpp index bf73434..5388fc0 100644 --- a/aoapplication.cpp +++ b/aoapplication.cpp @@ -54,9 +54,6 @@ void AOApplication::construct_courtroom() w_courtroom = new Courtroom(this); courtroom_constructed = true; - - //D3BUG - w_courtroom->show(); } void AOApplication::destruct_courtroom() diff --git a/courtroom.cpp b/courtroom.cpp index 231d6e9..282c70c 100644 --- a/courtroom.cpp +++ b/courtroom.cpp @@ -296,6 +296,22 @@ void Courtroom::set_size_and_pos(QWidget *p_widget, QString p_identifier) p_widget->resize(design_ini_result.width, design_ini_result.height); } +void Courtroom::set_taken(int n_char, bool p_taken) +{ + if (n_char >= char_list.size()) + { + qDebug() << "W: set_taken attempted to set an index bigger than char_list size"; + return; + } + + char_type f_char; + f_char.name = char_list.at(0).name; + f_char.description = char_list.at(1).description; + f_char.taken = p_taken; + + char_list.replace(n_char, f_char); +} + void Courtroom::on_change_character_clicked() { ui_char_select_background->show(); diff --git a/courtroom.h b/courtroom.h index 1278c83..ec31961 100644 --- a/courtroom.h +++ b/courtroom.h @@ -31,6 +31,7 @@ public: void set_widgets(); void set_size_and_pos(QWidget *p_widget, QString p_identifier); + void set_taken(int n_char, bool p_taken); ~Courtroom(); diff --git a/datatypes.h b/datatypes.h index 0d396bf..9fe5016 100644 --- a/datatypes.h +++ b/datatypes.h @@ -26,12 +26,14 @@ struct char_type { QString name; QString description; + bool taken; }; struct evi_type { QString name; QString description; + QString image; }; struct chatmessage_type diff --git a/packet_distribution.cpp b/packet_distribution.cpp index 84ace31..a20429e 100644 --- a/packet_distribution.cpp +++ b/packet_distribution.cpp @@ -157,6 +157,7 @@ void AOApplication::server_packet_received(AOPacket *p_packet) if (f_contents.at(n_element).toInt() != loaded_chars) break; + //this means we are on the last element and checking n + 1 element will be game over so if (n_element == f_contents.size() - 1) break; @@ -167,6 +168,8 @@ void AOApplication::server_packet_received(AOPacket *p_packet) char_type f_char; f_char.name = sub_elements.at(0); f_char.description = sub_elements.at(1); + //temporary. the CharsCheck packet sets this properly + f_char.taken = false; ++loaded_chars; @@ -177,28 +180,107 @@ void AOApplication::server_packet_received(AOPacket *p_packet) if (loaded_chars < char_list_size) { - qDebug() << "loaded_chars" << loaded_chars; QString next_packet_number = QString::number(((loaded_chars - 1) / 10) + 1); - AOPacket *f_packet = new AOPacket("AN#" + next_packet_number + "#%"); - send_server_packet(f_packet); + send_server_packet(new AOPacket("AN#" + next_packet_number + "#%")); } - else if (loaded_chars >= char_list_size) + else { if (evidence_list_size == 0) send_server_packet(new AOPacket("AM#0#%")); else send_server_packet(new AOPacket("AE#0#%")); } + } + else if (header == "EI"){ + if (!courtroom_constructed) + return; + + // +1 because evidence starts at 1 rather than 0 for whatever reason + //enjoy fanta + if (f_contents.at(0).toInt() != loaded_evidence + 1) + return; + + if (f_contents.size() < 2) + return; + + QStringList sub_elements = f_contents.at(1).split("&"); + if (sub_elements.size() < 4) + return; + evi_type f_evi; + f_evi.name = sub_elements.at(0); + f_evi.description = sub_elements.at(1); + //no idea what the number at position 2 is. probably an identifier? + f_evi.image = sub_elements.at(3); + ++loaded_evidence; + + w_lobby->set_loading_text("Loading evidence:\n" + QString::number(loaded_evidence) + "/" + QString::number(evidence_list_size)); + + w_courtroom->append_evidence(f_evi); + + if (loaded_evidence < evidence_list_size) + { + qDebug() << "loaded evidence: " << loaded_evidence; + QString next_packet_number = QString::number(loaded_evidence); + send_server_packet(new AOPacket("AE#" + next_packet_number + "#%")); + } + else + { + send_server_packet(new AOPacket("AM#0#%")); + } } - else if (header == "EI"){ + else if (header == "EM") + { + if (!courtroom_constructed) + return; + + for (int n_element = 0 ; n_element < f_contents.size() ; n_element += 2) + { + if (f_contents.at(n_element).toInt() != loaded_music) + break; + + if (n_element == f_contents.size() - 1) + break; + + QString f_music = f_contents.at(n_element + 1); + + ++loaded_music; + + w_lobby->set_loading_text("Loading music:\n" + QString::number(loaded_music) + "/" + QString::number(music_list_size)); + w_courtroom->append_music(f_music); + } + + //apparently we need to intentionally send another AM packet to get onwards in the loading process + //in spite of the fact that we actually received all the music + //enjoy fanta + //if (loaded_music < music_list_size) + //{ + QString next_packet_number = QString::number(((loaded_music - 1) / 10) + 1); + send_server_packet(new AOPacket("AM#" + next_packet_number + "#%")); + //} } - else if (header == "EM"){ + if (header == "CharsCheck") + { + for (int n_char = 0 ; n_char < f_contents.size() ; ++n_char) + { + if (f_contents.at(n_char) == "-1") + w_courtroom->set_taken(n_char, true); + else + w_courtroom->set_taken(n_char, false); + } + } + if (header == "DONE") + { + if (!courtroom_constructed) + return; + + w_courtroom->show(); + destruct_lobby(); } } -- cgit From 47ffce5db5220f476e01e88a17dffcb0f5970f7e Mon Sep 17 00:00:00 2001 From: David Skoland Date: Thu, 26 Jan 2017 00:24:40 +0100 Subject: ignored .user file --- .gitignore | 1 + 1 file changed, 1 insertion(+) diff --git a/.gitignore b/.gitignore index 68fa6bf..eaa5f0d 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,3 @@ *~ *.db +*.user -- cgit From 5e2ea2b24c2c0151ff8b0354632aa00148e0e6d6 Mon Sep 17 00:00:00 2001 From: David Skoland Date: Thu, 26 Jan 2017 16:03:48 +0100 Subject: finished charselect and cleaned up some files --- aocharbutton.cpp | 58 +++++++++++++++- aocharbutton.h | 15 +++- base/background/gs4/bancoacusacion.gif | Bin 2288 -> 0 bytes base/background/gs4/bancoacusacion.png | Bin 1838 -> 0 bytes base/background/gs4/bancodefensa.gif | Bin 1446 -> 0 bytes base/background/gs4/bancodefensa.png | Bin 1918 -> 0 bytes base/background/gs4/defenseempty.png | Bin 20664 -> 0 bytes base/background/gs4/estrado.gif | Bin 3536 -> 0 bytes base/background/gs4/estrado.png | Bin 3762 -> 0 bytes base/background/gs4/gallery.gif | Bin 29619 -> 0 bytes base/background/gs4/helperstand.png | Bin 23540 -> 0 bytes base/background/gs4/judgestand.png | Bin 28073 -> 0 bytes base/background/gs4/prohelperstand.png | Bin 29440 -> 0 bytes base/background/gs4/prosecutorempty.png | Bin 20487 -> 0 bytes base/background/gs4/speedlineupclose.png | Bin 3516 -> 0 bytes base/background/gs4/super anim.png | Bin 17676 -> 0 bytes base/background/gs4/tribunal.gif | Bin 29619 -> 0 bytes base/background/gs4/witnessempty.png | Bin 25245 -> 0 bytes base/config.ini~ | 1 - base/serverlist.txt | 4 ++ base/themes/default/courtroom_design.ini | 7 +- base/themes/default/design.ini | 28 -------- base/themes/default/loadingbackground.png | Bin 0 -> 2194 bytes base/themes/default/lobby_design.ini | 16 +++++ base/themes/default/muted.png | Bin 5703 -> 1013 bytes base/themes/default/muted_old.png | Bin 0 -> 5703 bytes courtroom.cpp | 109 ++++++++++++++++++++++++++++-- courtroom.h | 21 +++++- packet_distribution.cpp | 3 + 29 files changed, 219 insertions(+), 43 deletions(-) delete mode 100644 base/background/gs4/bancoacusacion.gif delete mode 100644 base/background/gs4/bancoacusacion.png delete mode 100644 base/background/gs4/bancodefensa.gif delete mode 100644 base/background/gs4/bancodefensa.png delete mode 100644 base/background/gs4/defenseempty.png delete mode 100644 base/background/gs4/estrado.gif delete mode 100644 base/background/gs4/estrado.png delete mode 100644 base/background/gs4/gallery.gif delete mode 100644 base/background/gs4/helperstand.png delete mode 100644 base/background/gs4/judgestand.png delete mode 100644 base/background/gs4/prohelperstand.png delete mode 100644 base/background/gs4/prosecutorempty.png delete mode 100644 base/background/gs4/speedlineupclose.png delete mode 100644 base/background/gs4/super anim.png delete mode 100644 base/background/gs4/tribunal.gif delete mode 100644 base/background/gs4/witnessempty.png delete mode 100644 base/config.ini~ create mode 100644 base/serverlist.txt delete mode 100644 base/themes/default/design.ini create mode 100644 base/themes/default/loadingbackground.png create mode 100644 base/themes/default/lobby_design.ini create mode 100644 base/themes/default/muted_old.png diff --git a/aocharbutton.cpp b/aocharbutton.cpp index 41a4f40..01b3c1c 100644 --- a/aocharbutton.cpp +++ b/aocharbutton.cpp @@ -5,13 +5,50 @@ #include -AOCharButton::AOCharButton(QWidget *parent, AOApplication *p_ao_app) : QPushButton(parent) +AOCharButton::AOCharButton(QWidget *parent, AOApplication *p_ao_app, int x_pos, int y_pos) : QPushButton(parent) { m_parent = parent; ao_app = p_ao_app; this->resize(60, 60); + this->move(x_pos, y_pos); + + ui_taken = new AOImage(this, ao_app); + ui_taken->resize(60, 60); + ui_taken->set_image("char_taken.png"); + ui_taken->setAttribute(Qt::WA_TransparentForMouseEvents); + ui_taken->hide(); + + ui_passworded = new AOImage(this, ao_app); + ui_passworded->resize(60, 60); + ui_passworded->set_image("char_passworded"); + ui_passworded->setAttribute(Qt::WA_TransparentForMouseEvents); + ui_passworded->hide(); + + ui_selector = new AOImage(parent, ao_app); + ui_selector->resize(62, 62); + ui_selector->move(x_pos - 1, y_pos - 1); + ui_selector->set_image("char_selector.png"); + ui_selector->setAttribute(Qt::WA_TransparentForMouseEvents); + ui_selector->hide(); +} + +void AOCharButton::reset() +{ + ui_taken->hide(); + ui_passworded->hide(); + ui_selector->hide(); +} + +void AOCharButton::set_taken() +{ + ui_taken->show(); +} + +void AOCharButton::set_passworded() +{ + ui_passworded->show(); } void AOCharButton::set_image(QString p_character) @@ -19,6 +56,8 @@ void AOCharButton::set_image(QString p_character) QString image_path = ao_app->get_character_path(p_character) + "char_icon.png"; QString legacy_path = ao_app->get_demothings_path() + p_character.toLower() + "_char_icon.png"; + this->setText(""); + if (file_exists(image_path)) this->setStyleSheet("border-image:url(\"" + image_path + "\")"); else if (file_exists(legacy_path)) @@ -33,3 +72,20 @@ void AOCharButton::set_image(QString p_character) this->setText(p_character); } } + +void AOCharButton::enterEvent(QEvent * e) +{ + ui_selector->raise(); + ui_selector->show(); + + setFlat(false); + QPushButton::enterEvent(e); +} + +void AOCharButton::leaveEvent(QEvent * e) +{ + ui_selector->hide(); + QPushButton::leaveEvent(e); +} + + diff --git a/aocharbutton.h b/aocharbutton.h index e91a120..f715416 100644 --- a/aocharbutton.h +++ b/aocharbutton.h @@ -6,20 +6,33 @@ #include #include #include +#include "aoimage.h" class AOCharButton : public QPushButton { Q_OBJECT public: - AOCharButton(QWidget *parent, AOApplication *p_ao_app); + AOCharButton(QWidget *parent, AOApplication *p_ao_app, int x_pos, int y_pos); AOApplication *ao_app; + void reset(); + void set_taken(); + void set_passworded(); + void set_image(QString p_character); private: QWidget *m_parent; + + AOImage *ui_taken; + AOImage *ui_passworded; + AOImage *ui_selector; + +protected: + void enterEvent(QEvent *e); + void leaveEvent(QEvent *e); }; #endif // AOCHARBUTTON_H diff --git a/base/background/gs4/bancoacusacion.gif b/base/background/gs4/bancoacusacion.gif deleted file mode 100644 index 7b330a3..0000000 Binary files a/base/background/gs4/bancoacusacion.gif and /dev/null differ diff --git a/base/background/gs4/bancoacusacion.png b/base/background/gs4/bancoacusacion.png deleted file mode 100644 index cce6bfe..0000000 Binary files a/base/background/gs4/bancoacusacion.png and /dev/null differ diff --git a/base/background/gs4/bancodefensa.gif b/base/background/gs4/bancodefensa.gif deleted file mode 100644 index bb30ac1..0000000 Binary files a/base/background/gs4/bancodefensa.gif and /dev/null differ diff --git a/base/background/gs4/bancodefensa.png b/base/background/gs4/bancodefensa.png deleted file mode 100644 index c7121cc..0000000 Binary files a/base/background/gs4/bancodefensa.png and /dev/null differ diff --git a/base/background/gs4/defenseempty.png b/base/background/gs4/defenseempty.png deleted file mode 100644 index fc9069e..0000000 Binary files a/base/background/gs4/defenseempty.png and /dev/null differ diff --git a/base/background/gs4/estrado.gif b/base/background/gs4/estrado.gif deleted file mode 100644 index cd5075f..0000000 Binary files a/base/background/gs4/estrado.gif and /dev/null differ diff --git a/base/background/gs4/estrado.png b/base/background/gs4/estrado.png deleted file mode 100644 index 9341a81..0000000 Binary files a/base/background/gs4/estrado.png and /dev/null differ diff --git a/base/background/gs4/gallery.gif b/base/background/gs4/gallery.gif deleted file mode 100644 index 4469bce..0000000 Binary files a/base/background/gs4/gallery.gif and /dev/null differ diff --git a/base/background/gs4/helperstand.png b/base/background/gs4/helperstand.png deleted file mode 100644 index 882c30c..0000000 Binary files a/base/background/gs4/helperstand.png and /dev/null differ diff --git a/base/background/gs4/judgestand.png b/base/background/gs4/judgestand.png deleted file mode 100644 index 6a17e7c..0000000 Binary files a/base/background/gs4/judgestand.png and /dev/null differ diff --git a/base/background/gs4/prohelperstand.png b/base/background/gs4/prohelperstand.png deleted file mode 100644 index 6554d32..0000000 Binary files a/base/background/gs4/prohelperstand.png and /dev/null differ diff --git a/base/background/gs4/prosecutorempty.png b/base/background/gs4/prosecutorempty.png deleted file mode 100644 index eecf852..0000000 Binary files a/base/background/gs4/prosecutorempty.png and /dev/null differ diff --git a/base/background/gs4/speedlineupclose.png b/base/background/gs4/speedlineupclose.png deleted file mode 100644 index 06dc9b3..0000000 Binary files a/base/background/gs4/speedlineupclose.png and /dev/null differ diff --git a/base/background/gs4/super anim.png b/base/background/gs4/super anim.png deleted file mode 100644 index fd3ec29..0000000 Binary files a/base/background/gs4/super anim.png and /dev/null differ diff --git a/base/background/gs4/tribunal.gif b/base/background/gs4/tribunal.gif deleted file mode 100644 index 4469bce..0000000 Binary files a/base/background/gs4/tribunal.gif and /dev/null differ diff --git a/base/background/gs4/witnessempty.png b/base/background/gs4/witnessempty.png deleted file mode 100644 index 11e22f7..0000000 Binary files a/base/background/gs4/witnessempty.png and /dev/null differ diff --git a/base/config.ini~ b/base/config.ini~ deleted file mode 100644 index 61e1883..0000000 --- a/base/config.ini~ +++ /dev/null @@ -1 +0,0 @@ -theme = default diff --git a/base/serverlist.txt b/base/serverlist.txt new file mode 100644 index 0000000..fef701d --- /dev/null +++ b/base/serverlist.txt @@ -0,0 +1,4 @@ +10.0.0.1:27071:the shit server +88.203.168.170:27777:Demon Server For Demons! Vanilla! 1.8+ +24.193.75.13:27053:The Flaming Phoenix +51.255.160.217:50000:Attorney Online Vidya(Dedicated) diff --git a/base/themes/default/courtroom_design.ini b/base/themes/default/courtroom_design.ini index c96d262..e7a3de4 100644 --- a/base/themes/default/courtroom_design.ini +++ b/base/themes/default/courtroom_design.ini @@ -8,7 +8,7 @@ area_list = 266, 494, 224, 174 music_list = 490, 342, 224, 326 ic_chat_message = 0, 192, 255, 23 ooc_chat_message = 492, 281, 222, 19 -ooc_chat_name = 492, 300, 32, 19 +ooc_chat_name = 492, 300, 85, 19 area_password = 266, 471, 224, 23 music_search = 490, 319, 226, 23 emote_left = 0, 253, 20, 20 @@ -20,6 +20,7 @@ sfx_label = 260, 410, 21, 16 blip_label = 260, 430, 31, 16 hold_it = 10, 312, 76, 28 objection = 90, 312, 76, 28 +take_that = 170, 312, 76, 28 ooc_toggle = 580, 300, 133, 19 witness_testimony = 5, 345, 85, 42 cross_examination = 95, 345, 85, 42 @@ -30,8 +31,8 @@ pre = 187, 345, 51, 21 flip = 187, 362, 51, 21 guard = 187, 379, 61, 21 custom_objection = 250, 325, 40, 40 -realization = 295, 323, 40, 40 -mute = 340, 325, 40, 40 +realization = 295, 325, 40, 40 +mute_button = 340, 325, 40, 40 defense_plus = 477, 325, 9, 9 defense_minus = 385, 325, 9, 9 prosecution_plus = 477, 342, 9, 9 diff --git a/base/themes/default/design.ini b/base/themes/default/design.ini deleted file mode 100644 index 5488ac4..0000000 --- a/base/themes/default/design.ini +++ /dev/null @@ -1,28 +0,0 @@ -hold_it = 10, 312 -objection = 90, 312 -take_that = 170, 312 -objection_custom = 250, 325 -realization = 295, 325 -mute = 340, 325 -text_color = 390, 360 -defense_bar = 393, 323 -prosecution_bar = 393, 340 -def_plus = 477, 325 -def_minus = 385, 325 -pro_plus = 477, 342 -pro_minus = 385, 342 -witness_testimony = 5, 345 -cross_examination = 95, 345 -pre = 187, 345 -flip = 187, 362 -guard = 187, 379 -change_character = 5, 390 -reload_theme = 5, 415 -call_mod = 5, 440 -music_label = 260, 390 -music_slider = 310, 392 -sfx_label = 260, 410 -sfx_slider = 310, 412 -blips_label = 260, 430 -blips_slider = 310, 432 - diff --git a/base/themes/default/loadingbackground.png b/base/themes/default/loadingbackground.png new file mode 100644 index 0000000..202a881 Binary files /dev/null and b/base/themes/default/loadingbackground.png differ diff --git a/base/themes/default/lobby_design.ini b/base/themes/default/lobby_design.ini new file mode 100644 index 0000000..efce59a --- /dev/null +++ b/base/themes/default/lobby_design.ini @@ -0,0 +1,16 @@ +lobby = 0, 0, 517, 666 +public_servers = 46, 88, 114, 30 +favorites = 164, 88, 114, 30 +refresh = 56, 381, 132, 28 +add_to_fav = 194, 381, 132, 28 +connect = 332, 381, 132, 28 +about = 428, 1, 88, 21 +server_list = 20, 125, 286, 240 +player_count = 336, 91, 173, 16 +description = 337, 109, 173, 245 +chatbox = 2, 445, 515, 198 +chatname = 3, 646, 85, 19 +chatmessage = 93, 646, 424, 19 +loading_label = 135, 92, 254, 95 +progress_bar = 135, 188, 254, 21 +cancel = 220, 220, 80, 20 diff --git a/base/themes/default/muted.png b/base/themes/default/muted.png index f9878f1..969da04 100644 Binary files a/base/themes/default/muted.png and b/base/themes/default/muted.png differ diff --git a/base/themes/default/muted_old.png b/base/themes/default/muted_old.png new file mode 100644 index 0000000..f9878f1 Binary files /dev/null and b/base/themes/default/muted_old.png differ diff --git a/courtroom.cpp b/courtroom.cpp index 282c70c..381d159 100644 --- a/courtroom.cpp +++ b/courtroom.cpp @@ -11,6 +11,8 @@ Courtroom::Courtroom(AOApplication *p_ao_app) : QMainWindow() { ao_app = p_ao_app; + char_button_mapper = new QSignalMapper(this); + ui_background = new AOImage(this, ao_app); //viewport elements like background, desk, etc. @@ -91,7 +93,7 @@ Courtroom::Courtroom(AOApplication *p_ao_app) : QMainWindow() ui_char_select_background = new AOImage(this, ao_app); - //setting up the grid and positions + //constructing character button grid const int base_x_pos{25}; const int base_y_pos{36}; @@ -103,15 +105,37 @@ Courtroom::Courtroom(AOApplication *p_ao_app) : QMainWindow() for (int n = 0 ; n < 90 ; ++n) { - ui_char_button_list.append(new AOCharButton(ui_char_select_background, ao_app)); + int x_pos = base_x_pos + (x_modifier * x_mod_count); + int y_pos = base_y_pos + (y_modifier * y_mod_count); + + ui_char_button_list.append(new AOCharButton(ui_char_select_background, ao_app, x_pos, y_pos)); + + connect(ui_char_button_list.at(n), SIGNAL(clicked()), char_button_mapper, SLOT(map())) ; + char_button_mapper->setMapping (ui_char_button_list.at(n), n) ; + + ++x_mod_count; + + //if char number is divisible by ten with rest 9 then the next charicon should start on a new line + if (n % 10 == 9 && n != 0) + { + ++y_mod_count; + x_mod_count = 0; + } } + connect (char_button_mapper, SIGNAL(mapped(int)), this, SLOT(char_clicked(int))) ; + ui_selector = new AOImage(ui_char_select_background, ao_app); + ui_selector->setAttribute(Qt::WA_TransparentForMouseEvents); + ui_selector->resize(62, 62); ui_back_to_lobby = new AOButton(ui_char_select_background, ao_app); ui_char_password = new QLineEdit(ui_char_select_background); + ui_char_select_left = new AOButton(ui_char_select_background, ao_app); + ui_char_select_right = new AOButton(ui_char_select_background, ao_app); + ui_spectator = new AOButton(ui_char_select_background, ao_app); connect(ui_change_character, SIGNAL(clicked()), this, SLOT(on_change_character_clicked())); @@ -120,6 +144,9 @@ Courtroom::Courtroom(AOApplication *p_ao_app) : QMainWindow() connect(ui_back_to_lobby, SIGNAL(clicked()), this, SLOT(on_back_to_lobby_clicked())); + connect(ui_char_select_left, SIGNAL(clicked()), this, SLOT(on_char_select_left_clicked())); + connect(ui_char_select_right, SIGNAL(clicked()), this, SLOT(on_char_select_right_clicked())); + connect(ui_spectator, SIGNAL(clicked()), this, SLOT(on_spectator_clicked())); set_widgets(); @@ -256,10 +283,9 @@ void Courtroom::set_widgets() ui_char_select_background->move(0, 0); ui_char_select_background->resize(m_courtroom_width, m_courtroom_height); - //T0D0: uncomment and set position properly - //QVector ui_char_button_list; + //buttons are in the constructor - ui_selector->set_image("selector.png"); + ui_selector->set_image("char_selector.png"); ui_selector->hide(); ui_back_to_lobby->setText("Back to Lobby"); @@ -267,6 +293,14 @@ void Courtroom::set_widgets() set_size_and_pos(ui_char_password, "char_password"); + ui_char_select_left->set_image("arrow_left.png"); + ui_char_select_left->move(2, 325); + ui_char_select_left->resize(20, 20); + + ui_char_select_right->set_image("arrow_right.png"); + ui_char_select_right->move(691, 325); + ui_char_select_right->resize(20, 20); + ui_spectator->setText("Spectator"); set_size_and_pos(ui_spectator, "spectator"); @@ -305,13 +339,57 @@ void Courtroom::set_taken(int n_char, bool p_taken) } char_type f_char; - f_char.name = char_list.at(0).name; - f_char.description = char_list.at(1).description; + f_char.name = char_list.at(n_char).name; + f_char.description = char_list.at(n_char).description; f_char.taken = p_taken; char_list.replace(n_char, f_char); } +void Courtroom::set_char_select_page() +{ + ui_char_select_background->show(); + + ui_char_select_left->hide(); + ui_char_select_right->hide(); + + for (AOCharButton *i_button : ui_char_button_list) + i_button->hide(); + + int total_pages = char_list.size() / 90; + int chars_on_page = 0; + + if (char_list.size() % 90 != 0) + { + ++total_pages; + //i. e. not on the last page + if (total_pages > current_char_page + 1) + chars_on_page = 90; + else + chars_on_page = char_list.size() % 90; + + } + else + chars_on_page = 90; + + qDebug() << "chars_on_page: " << chars_on_page; + + if (total_pages > current_char_page + 1) + ui_char_select_right->show(); + + if (current_char_page > 0) + ui_char_select_left->show(); + + for (int n_button = 0 ; n_button < chars_on_page ; ++n_button) + { + int n_real_char = n_button + current_char_page * 90; + + ui_char_button_list.at(n_button)->set_image(char_list.at(n_real_char).name); + ui_char_button_list.at(n_button)->show(); + } + +} + void Courtroom::on_change_character_clicked() { ui_char_select_background->show(); @@ -331,11 +409,28 @@ void Courtroom::on_back_to_lobby_clicked() ao_app->destruct_courtroom(); } +void Courtroom::on_char_select_left_clicked() +{ + --current_char_page; + set_char_select_page(); +} + +void Courtroom::on_char_select_right_clicked() +{ + ++current_char_page; + set_char_select_page(); +} + void Courtroom::on_spectator_clicked() { ui_char_select_background->hide(); } +void Courtroom::char_clicked(int n_char) +{ + +} + Courtroom::~Courtroom() { diff --git a/courtroom.h b/courtroom.h index ec31961..5b2a111 100644 --- a/courtroom.h +++ b/courtroom.h @@ -16,6 +16,7 @@ #include #include #include +#include class AOApplication; @@ -32,6 +33,7 @@ public: void set_widgets(); void set_size_and_pos(QWidget *p_widget, QString p_identifier); void set_taken(int n_char, bool p_taken); + void set_char_select_page(); ~Courtroom(); @@ -51,8 +53,15 @@ private: QVector evidence_list; QVector music_list; + QSignalMapper *char_button_mapper; + + //0 is the first page, 1 second etc. + //makes char arithmetic easier + int current_char_page = 0; + AOImage *ui_background; - //viewport elements like background, desk, etc. + + //T0D0: add viewport elements like background, desk, etc. QPlainTextEdit *ui_ic_chatlog; @@ -72,7 +81,7 @@ private: QLineEdit *ui_area_password; QLineEdit *ui_music_search; - //emote buttons + //T0D0: add emote buttons AOButton *ui_emote_left; AOButton *ui_emote_right; @@ -129,6 +138,9 @@ private: QLineEdit *ui_char_password; + AOButton *ui_char_select_left; + AOButton *ui_char_select_right; + AOButton *ui_spectator; private slots: void on_change_character_clicked(); @@ -138,6 +150,11 @@ private slots: void on_spectator_clicked(); + void on_char_select_left_clicked(); + void on_char_select_right_clicked(); + + void char_clicked(int n_char); + }; #endif // COURTROOM_H diff --git a/packet_distribution.cpp b/packet_distribution.cpp index a20429e..d53b5a6 100644 --- a/packet_distribution.cpp +++ b/packet_distribution.cpp @@ -176,6 +176,7 @@ void AOApplication::server_packet_received(AOPacket *p_packet) w_lobby->set_loading_text("Loading chars:\n" + QString::number(loaded_chars) + "/" + QString::number(char_list_size)); w_courtroom->append_char(f_char); + //qDebug() << "appended " << f_char.name << " to char_list"; } if (loaded_chars < char_list_size) @@ -278,6 +279,8 @@ void AOApplication::server_packet_received(AOPacket *p_packet) if (!courtroom_constructed) return; + w_courtroom->set_char_select_page(); + w_courtroom->show(); destruct_lobby(); -- cgit From 9682087667e2de26e14406efde960b8c7f0c3c98 Mon Sep 17 00:00:00 2001 From: David Skoland Date: Fri, 27 Jan 2017 01:17:33 +0100 Subject: implemented ooc chat and cleaned up some old headers --- Attorney_Online_remake.pro | 2 - aoapplication.cpp | 17 +++++-- aoapplication.h | 1 + aobutton.cpp | 1 - aocharbutton.cpp | 1 - aoimage.cpp | 1 - courtroom.cpp | 110 +++++++++++++++++++++++++++++++++++++++++++-- courtroom.h | 18 +++++++- lobby.cpp | 15 ++++++- lobby.h | 1 + packet_distribution.cpp | 22 ++++++--- path_functions.cpp | 2 - path_functions.h | 8 ---- text_file_functions.cpp | 36 ++++++++++++++- text_file_functions.h | 11 ----- 15 files changed, 202 insertions(+), 44 deletions(-) delete mode 100644 path_functions.h delete mode 100644 text_file_functions.h diff --git a/Attorney_Online_remake.pro b/Attorney_Online_remake.pro index 0ce693a..c784578 100644 --- a/Attorney_Online_remake.pro +++ b/Attorney_Online_remake.pro @@ -32,8 +32,6 @@ SOURCES += main.cpp\ hardware_functions.cpp HEADERS += lobby.h \ - text_file_functions.h \ - path_functions.h \ aoimage.h \ file_functions.h \ aobutton.h \ diff --git a/aoapplication.cpp b/aoapplication.cpp index 5388fc0..f0576ee 100644 --- a/aoapplication.cpp +++ b/aoapplication.cpp @@ -1,11 +1,12 @@ -#include +#include "aoapplication.h" #include "lobby.h" #include "courtroom.h" #include "networkmanager.h" -#include "text_file_functions.h" -#include "aoapplication.h" +#include +#include +#include AOApplication::AOApplication(int &argc, char **argv) : QApplication(argc, argv) { @@ -29,6 +30,11 @@ void AOApplication::construct_lobby() w_lobby = new Lobby(this); lobby_constructed = true; + QRect screenGeometry = QApplication::desktop()->screenGeometry(); + int x = (screenGeometry.width()-w_lobby->width()) / 2; + int y = (screenGeometry.height()-w_lobby->height()) / 2; + w_lobby->move(x, y); + w_lobby->show(); } @@ -54,6 +60,11 @@ void AOApplication::construct_courtroom() w_courtroom = new Courtroom(this); courtroom_constructed = true; + + QRect screenGeometry = QApplication::desktop()->screenGeometry(); + int x = (screenGeometry.width()-w_courtroom->width()) / 2; + int y = (screenGeometry.height()-w_courtroom->height()) / 2; + w_courtroom->move(x, y); } void AOApplication::destruct_courtroom() diff --git a/aoapplication.h b/aoapplication.h index a63ec41..5cd255c 100644 --- a/aoapplication.h +++ b/aoapplication.h @@ -86,6 +86,7 @@ public: void write_to_serverlist_txt(QString p_line); QVector read_serverlist_txt(); pos_size_type get_pos_and_size(QString p_identifier, QString p_design_path); + QString get_char_side(QString p_char); private: const int RELEASE = 2; diff --git a/aobutton.cpp b/aobutton.cpp index 0938f51..370eca9 100644 --- a/aobutton.cpp +++ b/aobutton.cpp @@ -1,7 +1,6 @@ #include "aobutton.h" #include "debug_functions.h" -#include "path_functions.h" #include "file_functions.h" #include diff --git a/aocharbutton.cpp b/aocharbutton.cpp index 01b3c1c..d6edf80 100644 --- a/aocharbutton.cpp +++ b/aocharbutton.cpp @@ -1,6 +1,5 @@ #include "aocharbutton.h" -#include "path_functions.h" #include "file_functions.h" #include diff --git a/aoimage.cpp b/aoimage.cpp index bfe1142..4b0e973 100644 --- a/aoimage.cpp +++ b/aoimage.cpp @@ -1,5 +1,4 @@ #include "file_functions.h" -#include "path_functions.h" #include "aoimage.h" diff --git a/courtroom.cpp b/courtroom.cpp index 381d159..f408b14 100644 --- a/courtroom.cpp +++ b/courtroom.cpp @@ -2,8 +2,8 @@ #include "aoapplication.h" #include "lobby.h" -#include "text_file_functions.h" -#include "path_functions.h" +#include "hardware_functions.h" +#include "file_functions.h" #include @@ -18,22 +18,33 @@ Courtroom::Courtroom(AOApplication *p_ao_app) : QMainWindow() //viewport elements like background, desk, etc. ui_ic_chatlog = new QPlainTextEdit(this); + ui_ic_chatlog->setReadOnly(true); ui_ms_chatlog = new QPlainTextEdit(this); - ui_server_chatlog = new QPlainTextEdit(this); + ui_ms_chatlog->setReadOnly(true); + ui_ms_chatlog->hide(); + ui_server_chatlog = new QPlainTextEdit(this); + ui_server_chatlog->setReadOnly(true); ui_mute_list = new QListWidget(this); ui_area_list = new QListWidget(this); ui_music_list = new QListWidget(this); ui_ic_chat_message = new QLineEdit(this); + ui_ic_chat_message->setFrame(false); ui_ooc_chat_message = new QLineEdit(this); + ui_ooc_chat_message->setFrame(false); + ui_ooc_chat_name = new QLineEdit(this); + ui_ooc_chat_name->setFrame(false); + ui_ooc_chat_name->setPlaceholderText("Name"); ui_area_password = new QLineEdit(this); + ui_area_password->setFrame(false); ui_music_search = new QLineEdit(this); + ui_music_search->setFrame(false); //emote buttons @@ -138,6 +149,8 @@ Courtroom::Courtroom(AOApplication *p_ao_app) : QMainWindow() ui_spectator = new AOButton(ui_char_select_background, ao_app); + connect(ui_ooc_chat_message, SIGNAL(returnPressed()), this, SLOT(on_ooc_return_pressed())); + connect(ui_ooc_toggle, SIGNAL(clicked()), this, SLOT(on_ooc_toggle_clicked())); connect(ui_change_character, SIGNAL(clicked()), this, SLOT(on_change_character_clicked())); connect(ui_reload_theme, SIGNAL(clicked()), this, SLOT(on_reload_theme_clicked())); @@ -390,6 +403,86 @@ void Courtroom::set_char_select_page() } +void Courtroom::enter_courtroom(int p_cid) +{ + m_cid = p_cid; + QString f_char = char_list.at(m_cid).name; + + //T0D0: set emote buttons + + QString side = ao_app->get_char_side(f_char); + + if (side == "jud") + { + ui_witness_testimony->show(); + ui_cross_examination->show(); + ui_defense_minus->show(); + ui_defense_plus->show(); + ui_prosecution_minus->show(); + ui_prosecution_plus->show(); + } + else + { + ui_witness_testimony->hide(); + ui_cross_examination->hide(); + ui_defense_minus->hide(); + ui_defense_plus->hide(); + ui_prosecution_minus->hide(); + ui_prosecution_plus->hide(); + } + + ui_char_select_background->hide(); +} + +void Courtroom::append_ms_chatmessage(QString f_message) +{ + ui_ms_chatlog->appendPlainText(f_message); +} + +void Courtroom::append_server_chatmessage(QString f_message) +{ + ui_server_chatlog->appendPlainText(f_message); +} + +void Courtroom::on_ooc_return_pressed() +{ + if (ui_ooc_chat_message->text() == "" || ui_ooc_chat_name->text() == "") + return; + + QStringList packet_contents; + packet_contents.append(ui_ooc_chat_name->text()); + packet_contents.append(ui_ooc_chat_message->text()); + + AOPacket *f_packet = new AOPacket("CT", packet_contents); + + if (server_ooc) + ao_app->send_server_packet(f_packet); + else + ao_app->send_ms_packet(f_packet); + + ui_ooc_chat_message->clear(); +} + +void Courtroom::on_ooc_toggle_clicked() +{ + if (server_ooc) + { + ui_ms_chatlog->show(); + ui_server_chatlog->hide(); + ui_ooc_toggle->setText("Master"); + + server_ooc = false; + } + else + { + ui_ms_chatlog->hide(); + ui_server_chatlog->show(); + ui_ooc_toggle->setText("Server"); + + server_ooc = true; + } +} + void Courtroom::on_change_character_clicked() { ui_char_select_background->show(); @@ -428,7 +521,18 @@ void Courtroom::on_spectator_clicked() void Courtroom::char_clicked(int n_char) { + int n_real_char = n_char + current_char_page * 90; + + QString char_ini_path = ao_app->get_character_path(char_list.at(n_real_char).name) + "char.ini"; + + if (!file_exists(char_ini_path)) + { + qDebug() << "did not find " << char_ini_path; + //T0D0: call error + return; + } + ao_app->send_server_packet(new AOPacket("CC#" + QString::number(ao_app->s_pv) + "#" + QString::number(n_real_char) + "#" + get_hdid() + "#%")); } Courtroom::~Courtroom() diff --git a/courtroom.h b/courtroom.h index 5b2a111..9f25387 100644 --- a/courtroom.h +++ b/courtroom.h @@ -35,6 +35,11 @@ public: void set_taken(int n_char, bool p_taken); void set_char_select_page(); + void enter_courtroom(int p_cid); + + void append_ms_chatmessage(QString f_message); + void append_server_chatmessage(QString f_message); + ~Courtroom(); private: @@ -59,6 +64,12 @@ private: //makes char arithmetic easier int current_char_page = 0; + //character id, which index of the char_list the player is + int m_cid = 0; + + //wether the ooc chat is server or master chat, true is server + bool server_ooc = true; + AOImage *ui_background; //T0D0: add viewport elements like background, desk, etc. @@ -143,16 +154,19 @@ private: AOButton *ui_spectator; private slots: + void on_ooc_return_pressed(); + void on_ooc_toggle_clicked(); + void on_change_character_clicked(); void on_reload_theme_clicked(); void on_back_to_lobby_clicked(); - void on_spectator_clicked(); - void on_char_select_left_clicked(); void on_char_select_right_clicked(); + void on_spectator_clicked(); + void char_clicked(int n_char); }; diff --git a/lobby.cpp b/lobby.cpp index 3709114..8bc67bd 100644 --- a/lobby.cpp +++ b/lobby.cpp @@ -1,7 +1,5 @@ #include "lobby.h" -#include "path_functions.h" -#include "text_file_functions.h" #include "debug_functions.h" #include "aoapplication.h" #include "networkmanager.h" @@ -27,6 +25,7 @@ Lobby::Lobby(AOApplication *p_ao_app) : QMainWindow() ui_description = new QPlainTextEdit(this); ui_chatbox = new QPlainTextEdit(this); ui_chatname = new QLineEdit(this); + ui_chatname->setPlaceholderText("Name"); ui_chatmessage = new QLineEdit(this); ui_loading_background = new AOImage(this, ao_app); ui_loading_text = new QTextEdit(ui_loading_background); @@ -152,6 +151,13 @@ void Lobby::set_loading_text(QString p_text) ui_loading_text->append(p_text); } +QString Lobby::get_chatlog() +{ + QString return_value = ui_chatbox->toPlainText(); + + return return_value; +} + void Lobby::on_public_servers_clicked() { ui_public_servers->set_image("publicservers_selected.png"); @@ -260,6 +266,11 @@ void Lobby::on_server_list_clicked(QModelIndex p_model) void Lobby::on_chatfield_return_pressed() { + //no you can't send empty messages + if (ui_chatname->text() == "" || ui_chatmessage->text() == "") + return; + + QString f_header = "CT"; QStringList f_contents{ui_chatname->text(), ui_chatmessage->text()}; diff --git a/lobby.h b/lobby.h index 8f9b5ea..ebdc05b 100644 --- a/lobby.h +++ b/lobby.h @@ -29,6 +29,7 @@ public: void set_loading_text(QString p_text); void show_loading_overlay(){ui_loading_background->show();} void hide_loading_overlay(){ui_loading_background->hide();} + QString get_chatlog(); ~Lobby(); diff --git a/packet_distribution.cpp b/packet_distribution.cpp index d53b5a6..163c744 100644 --- a/packet_distribution.cpp +++ b/packet_distribution.cpp @@ -63,8 +63,7 @@ void AOApplication::ms_packet_received(AOPacket *p_packet) } if (courtroom_constructed) { - //T0D0: uncomment this when it's implemented - //w_courtroom->append_ms_chat_message(message_line); + w_courtroom->append_ms_chatmessage(message_line); } } } @@ -77,7 +76,8 @@ void AOApplication::server_packet_received(AOPacket *p_packet) QStringList f_contents = p_packet->get_contents(); QString f_packet = p_packet->to_string(); - qDebug() << "R: " << f_packet; + if (header != "checkconnection") + qDebug() << "R: " << f_packet; if (header == "decryptor") { @@ -113,10 +113,9 @@ void AOApplication::server_packet_received(AOPacket *p_packet) return; } - //QString message_line = f_contents.at(0) + ": " + f_contents.at(1); + QString message_line = f_contents.at(0) + ": " + f_contents.at(1); - //T0D0, uncomment when implemented - //w_courtroom->append_ooc_chatmessage(message_line) + w_courtroom->append_server_chatmessage(message_line); } else if (header == "PN") { @@ -176,7 +175,6 @@ void AOApplication::server_packet_received(AOPacket *p_packet) w_lobby->set_loading_text("Loading chars:\n" + QString::number(loaded_chars) + "/" + QString::number(char_list_size)); w_courtroom->append_char(f_char); - //qDebug() << "appended " << f_char.name << " to char_list"; } if (loaded_chars < char_list_size) @@ -281,10 +279,20 @@ void AOApplication::server_packet_received(AOPacket *p_packet) w_courtroom->set_char_select_page(); + w_courtroom->append_ms_chatmessage(w_lobby->get_chatlog()); + w_courtroom->show(); destruct_lobby(); } + //server accepting char request(CC) packet + if (header == "PV") + { + if (f_contents.size() < 3) + return; + + w_courtroom->enter_courtroom(f_contents.at(2).toInt()); + } } void AOApplication::send_ms_packet(AOPacket *p_packet) diff --git a/path_functions.cpp b/path_functions.cpp index 7afd923..5b9e92e 100644 --- a/path_functions.cpp +++ b/path_functions.cpp @@ -1,7 +1,5 @@ #include "aoapplication.h" -#include "text_file_functions.h" - #include #include diff --git a/path_functions.h b/path_functions.h deleted file mode 100644 index 2f37a0c..0000000 --- a/path_functions.h +++ /dev/null @@ -1,8 +0,0 @@ -#ifndef PATH_FUNCTIONS_H -#define PATH_FUNCTIONS_H - -#include - - - -#endif // PATH_FUNCTIONS_H diff --git a/text_file_functions.cpp b/text_file_functions.cpp index db1ecc7..dc97c60 100644 --- a/text_file_functions.cpp +++ b/text_file_functions.cpp @@ -1,6 +1,5 @@ #include "aoapplication.h" -#include "path_functions.h" #include "file_functions.h" #include @@ -140,3 +139,38 @@ pos_size_type AOApplication::get_pos_and_size(QString p_identifier, QString p_de return return_value; } +QString AOApplication::get_char_side(QString p_char) +{ + QString char_ini_path = get_character_path(p_char) + "char.ini"; + + QFile char_ini; + + char_ini.setFileName(char_ini_path); + + if (!char_ini.open(QIODevice::ReadOnly)) + { + //default to wit and don't make a big deal about it + return "wit"; + } + + QTextStream in(&char_ini); + + while(!in.atEnd()) + { + QString line = in.readLine(); + + if (!line.startsWith("side")) + continue; + + QStringList line_elements = line.split("="); + + if (line_elements.size() < 2) + continue; + + //note that we do not validate if this is a valid side or not. that's up to the caller + return line_elements.at(1).trimmed().toLower(); + } + + return "wit"; +} + diff --git a/text_file_functions.h b/text_file_functions.h deleted file mode 100644 index 54abd4d..0000000 --- a/text_file_functions.h +++ /dev/null @@ -1,11 +0,0 @@ -#ifndef TEXT_FILE_FUNCTIONS_H -#define TEXT_FILE_FUNCTIONS_H - -#include "datatypes.h" - -#include -#include - - - -#endif // TEXT_FILE_FUNCTIONS_H -- cgit