aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDavid Skoland <davidskoland@gmail.com>2017-01-27 01:24:58 +0100
committerGitHub <noreply@github.com>2017-01-27 01:24:58 +0100
commitd4ad200b612acb1ed2a74d057efc8c3cbfa07ad2 (patch)
treea2b2dbee3b1a3102499b3cb5c6529e6f01655f74
parentea9ba4526dc313a61682ec41b3b052019051545e (diff)
parent9682087667e2de26e14406efde960b8c7f0c3c98 (diff)
Merge pull request #2 from OmniTroid/master
well
-rw-r--r--.gitignore1
-rw-r--r--Attorney_Online_remake.pro2
-rw-r--r--aoapplication.cpp25
-rw-r--r--aoapplication.h22
-rw-r--r--aobutton.cpp1
-rw-r--r--aocharbutton.cpp59
-rw-r--r--aocharbutton.h15
-rw-r--r--aoimage.cpp2
-rw-r--r--base/background/gs4/bancoacusacion.gifbin2288 -> 0 bytes
-rw-r--r--base/background/gs4/bancoacusacion.pngbin1838 -> 0 bytes
-rw-r--r--base/background/gs4/bancodefensa.gifbin1446 -> 0 bytes
-rw-r--r--base/background/gs4/bancodefensa.pngbin1918 -> 0 bytes
-rw-r--r--base/background/gs4/defenseempty.pngbin20664 -> 0 bytes
-rw-r--r--base/background/gs4/estrado.gifbin3536 -> 0 bytes
-rw-r--r--base/background/gs4/estrado.pngbin3762 -> 0 bytes
-rw-r--r--base/background/gs4/gallery.gifbin29619 -> 0 bytes
-rw-r--r--base/background/gs4/helperstand.pngbin23540 -> 0 bytes
-rw-r--r--base/background/gs4/judgestand.pngbin28073 -> 0 bytes
-rw-r--r--base/background/gs4/prohelperstand.pngbin29440 -> 0 bytes
-rw-r--r--base/background/gs4/prosecutorempty.pngbin20487 -> 0 bytes
-rw-r--r--base/background/gs4/speedlineupclose.pngbin3516 -> 0 bytes
-rw-r--r--base/background/gs4/super anim.pngbin17676 -> 0 bytes
-rw-r--r--base/background/gs4/tribunal.gifbin29619 -> 0 bytes
-rw-r--r--base/background/gs4/witnessempty.pngbin25245 -> 0 bytes
-rw-r--r--base/config.ini~1
-rw-r--r--base/serverlist.txt4
-rw-r--r--base/themes/default/courtroom_design.ini7
-rw-r--r--base/themes/default/design.ini28
-rw-r--r--base/themes/default/loadingbackground.pngbin0 -> 2194 bytes
-rw-r--r--base/themes/default/lobby_design.ini16
-rw-r--r--base/themes/default/muted.pngbin5703 -> 1013 bytes
-rw-r--r--base/themes/default/muted_old.pngbin0 -> 5703 bytes
-rw-r--r--courtroom.cpp310
-rw-r--r--courtroom.h48
-rw-r--r--datatypes.h2
-rw-r--r--hardware_functions.cpp39
-rw-r--r--hardware_functions.h10
-rw-r--r--lobby.cpp123
-rw-r--r--lobby.h12
-rw-r--r--networkmanager.cpp4
-rw-r--r--packet_distribution.cpp195
-rw-r--r--path_functions.cpp3
-rw-r--r--path_functions.h8
-rw-r--r--text_file_functions.cpp36
-rw-r--r--text_file_functions.h11
45 files changed, 824 insertions, 160 deletions
diff --git a/.gitignore b/.gitignore
index 68fa6bf8..eaa5f0d4 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1,2 +1,3 @@
*~
*.db
+*.user
diff --git a/Attorney_Online_remake.pro b/Attorney_Online_remake.pro
index 0ce693ab..c7845784 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 70aeb152..f0576eea 100644
--- a/aoapplication.cpp
+++ b/aoapplication.cpp
@@ -1,11 +1,12 @@
-#include <QDebug>
+#include "aoapplication.h"
#include "lobby.h"
#include "courtroom.h"
#include "networkmanager.h"
-#include "text_file_functions.h"
-#include "aoapplication.h"
+#include <QDebug>
+#include <QRect>
+#include <QDesktopWidget>
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();
}
@@ -55,8 +61,10 @@ void AOApplication::construct_courtroom()
w_courtroom = new Courtroom(this);
courtroom_constructed = true;
- //D3BUG
- w_courtroom->show();
+ 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()
@@ -100,3 +108,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 77d7af01..5cd255cc 100644
--- a/aoapplication.h
+++ b/aoapplication.h
@@ -44,10 +44,20 @@ public:
unsigned int s_decryptor = 5;
bool encryption_needed = true;
bool ao2_features = false;
+
+ ///////////////loading info///////////////////
+
//player number, it's hardly used but might be needed for some old servers
- bool s_pv = 0;
+ 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;
+
+ //////////////////versioning///////////////
int get_release() {return RELEASE;}
int get_major_version() {return MAJOR_VERSION;}
@@ -64,18 +74,19 @@ 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<server_type> 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;
@@ -86,6 +97,9 @@ private:
QVector<server_type> server_list;
QVector<server_type> favorite_list;
+
+public slots:
+ void loading_cancelled();
};
#endif // AOAPPLICATION_H
diff --git a/aobutton.cpp b/aobutton.cpp
index 0938f51b..370eca99 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 <QDebug>
diff --git a/aocharbutton.cpp b/aocharbutton.cpp
index 41a4f402..d6edf804 100644
--- a/aocharbutton.cpp
+++ b/aocharbutton.cpp
@@ -1,17 +1,53 @@
#include "aocharbutton.h"
-#include "path_functions.h"
#include "file_functions.h"
#include <QFile>
-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 +55,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 +71,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 e91a1201..f7154169 100644
--- a/aocharbutton.h
+++ b/aocharbutton.h
@@ -6,20 +6,33 @@
#include <QPushButton>
#include <QString>
#include <QWidget>
+#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/aoimage.cpp b/aoimage.cpp
index 2e09f6a0..4b0e9738 100644
--- a/aoimage.cpp
+++ b/aoimage.cpp
@@ -1,6 +1,4 @@
#include "file_functions.h"
-#include "path_functions.h"
-#include "global_variables.h"
#include "aoimage.h"
diff --git a/base/background/gs4/bancoacusacion.gif b/base/background/gs4/bancoacusacion.gif
deleted file mode 100644
index 7b330a3c..00000000
--- a/base/background/gs4/bancoacusacion.gif
+++ /dev/null
Binary files differ
diff --git a/base/background/gs4/bancoacusacion.png b/base/background/gs4/bancoacusacion.png
deleted file mode 100644
index cce6bfe1..00000000
--- a/base/background/gs4/bancoacusacion.png
+++ /dev/null
Binary files differ
diff --git a/base/background/gs4/bancodefensa.gif b/base/background/gs4/bancodefensa.gif
deleted file mode 100644
index bb30ac14..00000000
--- a/base/background/gs4/bancodefensa.gif
+++ /dev/null
Binary files differ
diff --git a/base/background/gs4/bancodefensa.png b/base/background/gs4/bancodefensa.png
deleted file mode 100644
index c7121cc3..00000000
--- a/base/background/gs4/bancodefensa.png
+++ /dev/null
Binary files differ
diff --git a/base/background/gs4/defenseempty.png b/base/background/gs4/defenseempty.png
deleted file mode 100644
index fc9069e5..00000000
--- a/base/background/gs4/defenseempty.png
+++ /dev/null
Binary files differ
diff --git a/base/background/gs4/estrado.gif b/base/background/gs4/estrado.gif
deleted file mode 100644
index cd5075f7..00000000
--- a/base/background/gs4/estrado.gif
+++ /dev/null
Binary files differ
diff --git a/base/background/gs4/estrado.png b/base/background/gs4/estrado.png
deleted file mode 100644
index 9341a810..00000000
--- a/base/background/gs4/estrado.png
+++ /dev/null
Binary files differ
diff --git a/base/background/gs4/gallery.gif b/base/background/gs4/gallery.gif
deleted file mode 100644
index 4469bceb..00000000
--- a/base/background/gs4/gallery.gif
+++ /dev/null
Binary files differ
diff --git a/base/background/gs4/helperstand.png b/base/background/gs4/helperstand.png
deleted file mode 100644
index 882c30ce..00000000
--- a/base/background/gs4/helperstand.png
+++ /dev/null
Binary files differ
diff --git a/base/background/gs4/judgestand.png b/base/background/gs4/judgestand.png
deleted file mode 100644
index 6a17e7c9..00000000
--- a/base/background/gs4/judgestand.png
+++ /dev/null
Binary files differ
diff --git a/base/background/gs4/prohelperstand.png b/base/background/gs4/prohelperstand.png
deleted file mode 100644
index 6554d32d..00000000
--- a/base/background/gs4/prohelperstand.png
+++ /dev/null
Binary files differ
diff --git a/base/background/gs4/prosecutorempty.png b/base/background/gs4/prosecutorempty.png
deleted file mode 100644
index eecf8522..00000000
--- a/base/background/gs4/prosecutorempty.png
+++ /dev/null
Binary files differ
diff --git a/base/background/gs4/speedlineupclose.png b/base/background/gs4/speedlineupclose.png
deleted file mode 100644
index 06dc9b3a..00000000
--- a/base/background/gs4/speedlineupclose.png
+++ /dev/null
Binary files differ
diff --git a/base/background/gs4/super anim.png b/base/background/gs4/super anim.png
deleted file mode 100644
index fd3ec29a..00000000
--- a/base/background/gs4/super anim.png
+++ /dev/null
Binary files differ
diff --git a/base/background/gs4/tribunal.gif b/base/background/gs4/tribunal.gif
deleted file mode 100644
index 4469bceb..00000000
--- a/base/background/gs4/tribunal.gif
+++ /dev/null
Binary files differ
diff --git a/base/background/gs4/witnessempty.png b/base/background/gs4/witnessempty.png
deleted file mode 100644
index 11e22f74..00000000
--- a/base/background/gs4/witnessempty.png
+++ /dev/null
Binary files differ
diff --git a/base/config.ini~ b/base/config.ini~
deleted file mode 100644
index 61e18830..00000000
--- 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 00000000..fef701da
--- /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 c96d2620..e7a3de4b 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 5488ac4b..00000000
--- 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 00000000..202a8813
--- /dev/null
+++ b/base/themes/default/loadingbackground.png
Binary files differ
diff --git a/base/themes/default/lobby_design.ini b/base/themes/default/lobby_design.ini
new file mode 100644
index 00000000..efce59a7
--- /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 f9878f1a..969da04e 100644
--- a/base/themes/default/muted.png
+++ b/base/themes/default/muted.png
Binary files differ
diff --git a/base/themes/default/muted_old.png b/base/themes/default/muted_old.png
new file mode 100644
index 00000000..f9878f1a
--- /dev/null
+++ b/base/themes/default/muted_old.png
Binary files differ
diff --git a/courtroom.cpp b/courtroom.cpp
index f0ad216e..f408b148 100644
--- a/courtroom.cpp
+++ b/courtroom.cpp
@@ -1,9 +1,9 @@
#include "courtroom.h"
#include "aoapplication.h"
-#include "text_file_functions.h"
-#include "path_functions.h"
-#include "global_variables.h"
+#include "lobby.h"
+#include "hardware_functions.h"
+#include "file_functions.h"
#include <QDebug>
@@ -11,27 +11,40 @@ 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.
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
@@ -73,9 +86,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_sfx_slider->setValue(50);
+
+ ui_blip_slider = new QSlider(Qt::Horizontal, this);
+ ui_blip_slider->setRange(0, 100);
+ ui_blip_slider->setValue(50);
ui_muted = new AOImage(this, ao_app);
@@ -83,7 +104,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};
@@ -95,23 +116,52 @@ 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;
+ }
}
- ui_char_select_background->hide();
+ 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_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()));
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();
}
@@ -127,20 +177,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");
@@ -148,44 +209,77 @@ 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");
+ 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");
+ ui_ooc_toggle->setText("Server");
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");
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");
@@ -202,10 +296,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<AOCharButton*> 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");
@@ -213,7 +306,15 @@ void Courtroom::set_widgets()
set_size_and_pos(ui_char_password, "char_password");
- ui_spectator->setText("spectator");
+ 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");
}
@@ -242,6 +343,151 @@ 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(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::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();
+}
+
void Courtroom::on_reload_theme_clicked()
{
ao_app->set_user_theme();
@@ -252,9 +498,43 @@ 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_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)
+{
+ 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 dee5401d..9f25387e 100644
--- a/courtroom.h
+++ b/courtroom.h
@@ -16,6 +16,7 @@
#include <QSlider>
#include <QVector>
#include <QCloseEvent>
+#include <QSignalMapper>
class AOApplication;
@@ -24,8 +25,20 @@ 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);
+ 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();
@@ -41,8 +54,25 @@ private:
const int m_viewport_width = 256;
const int m_viewport_height = 192;
+ QVector<char_type> char_list;
+ QVector<evi_type> evidence_list;
+ QVector<QString> music_list;
+
+ QSignalMapper *char_button_mapper;
+
+ //0 is the first page, 1 second etc.
+ //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;
- //viewport elements like background, desk, etc.
+
+ //T0D0: add viewport elements like background, desk, etc.
QPlainTextEdit *ui_ic_chatlog;
@@ -62,7 +92,7 @@ private:
QLineEdit *ui_area_password;
QLineEdit *ui_music_search;
- //emote buttons
+ //T0D0: add emote buttons
AOButton *ui_emote_left;
AOButton *ui_emote_right;
@@ -119,12 +149,26 @@ private:
QLineEdit *ui_char_password;
+ AOButton *ui_char_select_left;
+ AOButton *ui_char_select_right;
+
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_char_select_left_clicked();
+ void on_char_select_right_clicked();
+
+ void on_spectator_clicked();
+
+ void char_clicked(int n_char);
+
};
#endif // COURTROOM_H
diff --git a/datatypes.h b/datatypes.h
index 0d396bfa..9fe50166 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/hardware_functions.cpp b/hardware_functions.cpp
index ce6e35a6..0b161c3d 100644
--- a/hardware_functions.cpp
+++ b/hardware_functions.cpp
@@ -1,6 +1,10 @@
#include "hardware_functions.h"
+#include <QDebug>
+
#if (defined (_WIN32) || defined (_WIN64))
+#include <windows.h>
+
DWORD dwVolSerial;
BOOL bIsRetrieved;
@@ -11,24 +15,43 @@ 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 <QFile>
+#include <QTextStream>
+
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();
+ }
+ }
+
+ 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 7508a5a6..3fcb27cb 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 <QString>
-#ifdef Q_OS_WIN32
-#include <windows.h>
-#endif // Q_OS_WIN32
-
#include <stdio.h>
QString get_hdid();
-#endif // WIN32_FUNCTIONS_H
+#endif // HARDWARE_FUNCTIONS_H
diff --git a/lobby.cpp b/lobby.cpp
index 414ce933..8bc67bd4 100644
--- a/lobby.cpp
+++ b/lobby.cpp
@@ -1,8 +1,5 @@
#include "lobby.h"
-#include "path_functions.h"
-#include "text_file_functions.h"
-#include "global_variables.h"
#include "debug_functions.h"
#include "aoapplication.h"
#include "networkmanager.h"
@@ -28,7 +25,12 @@ 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);
+ 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()));
@@ -41,6 +43,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();
}
@@ -51,66 +54,108 @@ 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);");
+ ui_loading_background->set_image("loadingbackground.png");
+ ui_loading_background->resize(m_lobby_width, m_lobby_height);
+
+ 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();
+
+}
+
+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::set_loading_text(QString p_text)
+{
+ ui_loading_text->clear();
+ ui_loading_text->setAlignment(Qt::AlignCenter);
+ 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()
@@ -148,8 +193,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()
@@ -177,15 +220,8 @@ void Lobby::on_connect_released()
{
ui_connect->set_image("connect.png");
- //D3BUG START
-
- ao_app->construct_courtroom();
-
- ao_app->destruct_lobby();
-
- //D3BUG END
-
- //T0D0: call ao_app to initialize loading sequence
+ AOPacket *f_packet = new AOPacket("askchaa#%");
+ ao_app->send_server_packet(f_packet);
}
void Lobby::on_about_clicked()
@@ -230,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()};
@@ -238,8 +279,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 e4d6499f..ebdc05b2 100644
--- a/lobby.h
+++ b/lobby.h
@@ -10,6 +10,7 @@
#include <QLabel>
#include <QPlainTextEdit>
#include <QLineEdit>
+#include <QProgressBar>
class AOApplication;
@@ -25,6 +26,10 @@ 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();}
+ QString get_chatlog();
~Lobby();
@@ -57,6 +62,13 @@ private:
QLineEdit *ui_chatname;
QLineEdit *ui_chatmessage;
+ AOImage *ui_loading_background;
+ QTextEdit *ui_loading_text;
+ QProgressBar *ui_progress_bar;
+ AOButton *ui_cancel;
+
+ 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 2568b694..e0967f0b 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 5250dfab..163c744d 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"
@@ -62,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);
}
}
}
@@ -76,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")
{
@@ -91,15 +92,18 @@ 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")
{
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")
{
@@ -109,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")
{
@@ -121,6 +124,175 @@ 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();
+
+ w_lobby->show_loading_overlay();
+ w_lobby->set_loading_text("Loading");
+
+ AOPacket *f_packet = new AOPacket("askchar2#%");
+ send_server_packet(f_packet);
+ }
+ else if (header == "CI")
+ {
+ 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_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;
+
+ 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);
+ //temporary. the CharsCheck packet sets this properly
+ f_char.taken = false;
+
+ ++loaded_chars;
+
+ w_lobby->set_loading_text("Loading chars:\n" + QString::number(loaded_chars) + "/" + QString::number(char_list_size));
+
+ w_courtroom->append_char(f_char);
+ }
+
+ if (loaded_chars < char_list_size)
+ {
+ QString next_packet_number = QString::number(((loaded_chars - 1) / 10) + 1);
+ send_server_packet(new AOPacket("AN#" + next_packet_number + "#%"));
+ }
+
+ 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 == "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 + "#%"));
+ //}
+ }
+ 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->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)
@@ -132,6 +304,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)
@@ -142,7 +316,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();
@@ -154,4 +328,5 @@ void AOApplication::send_server_packet(AOPacket *p_packet)
net_manager->ship_server_packet(f_packet);
+ delete p_packet;
}
diff --git a/path_functions.cpp b/path_functions.cpp
index 46f80ef3..5b9e92ee 100644
--- a/path_functions.cpp
+++ b/path_functions.cpp
@@ -1,8 +1,5 @@
#include "aoapplication.h"
-#include "global_variables.h"
-#include "text_file_functions.h"
-
#include <QDir>
#include <QDebug>
diff --git a/path_functions.h b/path_functions.h
deleted file mode 100644
index 2f37a0ce..00000000
--- a/path_functions.h
+++ /dev/null
@@ -1,8 +0,0 @@
-#ifndef PATH_FUNCTIONS_H
-#define PATH_FUNCTIONS_H
-
-#include <QString>
-
-
-
-#endif // PATH_FUNCTIONS_H
diff --git a/text_file_functions.cpp b/text_file_functions.cpp
index db1ecc74..dc97c607 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 <QTextStream>
@@ -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 54abd4d8..00000000
--- 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 <QString>
-#include <QFile>
-
-
-
-#endif // TEXT_FILE_FUNCTIONS_H