aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/aoapplication.cpp83
-rw-r--r--src/aoblipplayer.cpp38
-rw-r--r--src/aobutton.cpp9
-rw-r--r--src/aocaseannouncerdialog.cpp41
-rw-r--r--src/aocharbutton.cpp32
-rw-r--r--src/aocharmovie.cpp212
-rw-r--r--src/aoemotebutton.cpp18
-rw-r--r--src/aoevidencebutton.cpp19
-rw-r--r--src/aoevidencedisplay.cpp37
-rw-r--r--src/aoimage.cpp11
-rw-r--r--src/aolineedit.cpp5
-rw-r--r--src/aomovie.cpp233
-rw-r--r--src/aomusicplayer.cpp79
-rw-r--r--src/aopacket.cpp29
-rw-r--r--src/aosfxplayer.cpp76
-rw-r--r--src/aotextarea.cpp43
-rw-r--r--src/aotextedit.cpp8
-rw-r--r--src/charselect.cpp146
-rw-r--r--src/chatlogpiece.cpp31
-rw-r--r--src/courtroom.cpp7344
-rw-r--r--src/debug_functions.cpp16
-rw-r--r--src/discord_rich_presence.cpp37
-rw-r--r--src/emotes.cpp43
-rw-r--r--src/encryption_functions.cpp19
-rw-r--r--src/evidence.cpp100
-rw-r--r--src/file_functions.cpp3
-rw-r--r--src/hardware_functions.cpp56
-rw-r--r--src/hex_functions.cpp23
-rw-r--r--src/lobby.cpp795
-rw-r--r--src/main.cpp51
-rw-r--r--src/misc_functions.cpp2
-rw-r--r--src/networkmanager.cpp142
-rw-r--r--src/packet_distribution.cpp1381
-rw-r--r--src/path_functions.cpp380
-rw-r--r--src/text_file_functions.cpp1450
35 files changed, 6422 insertions, 6570 deletions
diff --git a/src/aoapplication.cpp b/src/aoapplication.cpp
index 85465660..3b5e836d 100644
--- a/src/aoapplication.cpp
+++ b/src/aoapplication.cpp
@@ -1,17 +1,17 @@
#include "aoapplication.h"
-#include "lobby.h"
+#include "aocaseannouncerdialog.h"
+#include "aooptionsdialog.h"
#include "courtroom.h"
-#include "networkmanager.h"
#include "debug_functions.h"
-
-#include "aooptionsdialog.h"
-#include "aocaseannouncerdialog.h"
+#include "lobby.h"
+#include "networkmanager.h"
AOApplication::AOApplication(int &argc, char **argv) : QApplication(argc, argv)
{
// Create the QSettings class that points to the config.ini.
- configini = new QSettings(get_base_path() + "config.ini", QSettings::IniFormat);
+ configini =
+ new QSettings(get_base_path() + "config.ini", QSettings::IniFormat);
net_manager = new NetworkManager(this);
discord = new AttorneyOnline::Discord();
@@ -28,8 +28,7 @@ AOApplication::~AOApplication()
void AOApplication::construct_lobby()
{
- if (lobby_constructed)
- {
+ if (lobby_constructed) {
qDebug() << "W: lobby was attempted constructed when it already exists";
return;
}
@@ -38,8 +37,8 @@ void AOApplication::construct_lobby()
lobby_constructed = true;
QRect geometry = QGuiApplication::primaryScreen()->geometry();
- int x = (geometry.width()-w_lobby->width()) / 2;
- int y = (geometry.height()-w_lobby->height()) / 2;
+ int x = (geometry.width() - w_lobby->width()) / 2;
+ int y = (geometry.height() - w_lobby->height()) / 2;
w_lobby->move(x, y);
if (is_discord_enabled())
@@ -50,8 +49,7 @@ void AOApplication::construct_lobby()
void AOApplication::destruct_lobby()
{
- if(!lobby_constructed)
- {
+ if (!lobby_constructed) {
qDebug() << "W: lobby was attempted destructed when it did not exist";
return;
}
@@ -63,8 +61,7 @@ void AOApplication::destruct_lobby()
void AOApplication::construct_courtroom()
{
- if (courtroom_constructed)
- {
+ if (courtroom_constructed) {
qDebug() << "W: courtroom was attempted constructed when it already exists";
return;
}
@@ -73,15 +70,14 @@ void AOApplication::construct_courtroom()
courtroom_constructed = true;
QRect geometry = QGuiApplication::primaryScreen()->geometry();
- int x = (geometry.width()-w_courtroom->width()) / 2;
- int y = (geometry.height()-w_courtroom->height()) / 2;
+ int x = (geometry.width() - w_courtroom->width()) / 2;
+ int y = (geometry.height() - w_courtroom->height()) / 2;
w_courtroom->move(x, y);
}
void AOApplication::destruct_courtroom()
{
- if (!courtroom_constructed)
- {
+ if (!courtroom_constructed) {
qDebug() << "W: courtroom was attempted destructed when it did not exist";
return;
}
@@ -93,16 +89,11 @@ void AOApplication::destruct_courtroom()
QString AOApplication::get_version_string()
{
- return
- QString::number(RELEASE) + "." +
- QString::number(MAJOR_VERSION) + "." +
- QString::number(MINOR_VERSION);
+ return QString::number(RELEASE) + "." + QString::number(MAJOR_VERSION) + "." +
+ QString::number(MINOR_VERSION);
}
-void AOApplication::reload_theme()
-{
- current_theme = read_theme();
-}
+void AOApplication::reload_theme() { current_theme = read_theme(); }
void AOApplication::set_favorite_list()
{
@@ -133,8 +124,7 @@ void AOApplication::add_favorite_server(int p_server)
void AOApplication::server_disconnected()
{
- if (courtroom_constructed)
- {
+ if (courtroom_constructed) {
beep();
call_notice(tr("Disconnected from server."));
construct_lobby();
@@ -145,43 +135,44 @@ void AOApplication::server_disconnected()
void AOApplication::loading_cancelled()
{
destruct_courtroom();
-
w_lobby->hide_loading_overlay();
}
void AOApplication::ms_connect_finished(bool connected, bool will_retry)
{
- if (connected)
- {
+ if (connected) {
AOPacket *f_packet = new AOPacket("ALL#%");
send_ms_packet(f_packet);
}
- else
- {
- if (will_retry)
- {
+ else {
+ if (will_retry) {
if (lobby_constructed)
- w_lobby->append_error(tr("Error connecting to master server. Will try again in %1 seconds.").arg(QString::number(net_manager->ms_reconnect_delay)));
+ w_lobby->append_error(
+ tr("Error connecting to master server. Will try again in %1 "
+ "seconds.")
+ .arg(QString::number(net_manager->ms_reconnect_delay)));
}
- else
- {
+ else {
call_error(tr("There was an error connecting to the master server.\n"
- "We deploy multiple master servers to mitigate any possible downtime, "
- "but the client appears to have exhausted all possible methods of finding "
- "and connecting to one.\n"
- "Please check your Internet connection and firewall, and please try again."));
+ "We deploy multiple master servers to mitigate any "
+ "possible downtime, "
+ "but the client appears to have exhausted all possible "
+ "methods of finding "
+ "and connecting to one.\n"
+ "Please check your Internet connection and firewall, and "
+ "please try again."));
}
}
}
void AOApplication::call_settings_menu()
{
- AOOptionsDialog settings(nullptr, this);
- settings.exec();
+ AOOptionsDialog settings(nullptr, this);
+ settings.exec();
}
void AOApplication::call_announce_menu(Courtroom *court)
{
- AOCaseAnnouncerDialog announcer(nullptr, this, court);
- announcer.exec();
+ AOCaseAnnouncerDialog announcer(nullptr, this, court);
+ announcer.exec();
}
diff --git a/src/aoblipplayer.cpp b/src/aoblipplayer.cpp
index 9b548c33..7d598b5f 100644
--- a/src/aoblipplayer.cpp
+++ b/src/aoblipplayer.cpp
@@ -1,6 +1,6 @@
#include "aoblipplayer.h"
-#if defined(BASSAUDIO) //Using bass.dll for the blips
+#if defined(BASSAUDIO) // Using bass.dll for the blips
AOBlipPlayer::AOBlipPlayer(QWidget *parent, AOApplication *p_ao_app)
{
m_parent = parent;
@@ -11,11 +11,11 @@ void AOBlipPlayer::set_blips(QString p_sfx)
{
QString f_path = ao_app->get_sounds_path(p_sfx);
- for (int n_stream = 0 ; n_stream < 5 ; ++n_stream)
- {
+ for (int n_stream = 0; n_stream < 5; ++n_stream) {
BASS_StreamFree(m_stream_list[n_stream]);
- m_stream_list[n_stream] = BASS_StreamCreateFile(FALSE, f_path.utf16(), 0, 0, BASS_UNICODE | BASS_ASYNCFILE);
+ m_stream_list[n_stream] = BASS_StreamCreateFile(
+ FALSE, f_path.utf16(), 0, 0, BASS_UNICODE | BASS_ASYNCFILE);
}
set_volume_internal(m_volume);
@@ -44,12 +44,11 @@ void AOBlipPlayer::set_volume_internal(qreal p_value)
{
float volume = p_value;
- for (int n_stream = 0 ; n_stream < 5 ; ++n_stream)
- {
+ for (int n_stream = 0; n_stream < 5; ++n_stream) {
BASS_ChannelSetAttribute(m_stream_list[n_stream], BASS_ATTRIB_VOL, volume);
}
}
-#elif defined(QTAUDIO) //Using Qt's QSoundEffect class
+#elif defined(QTAUDIO) // Using Qt's QSoundEffect class
AOBlipPlayer::AOBlipPlayer(QWidget *parent, AOApplication *p_ao_app)
{
m_parent = parent;
@@ -60,8 +59,7 @@ void AOBlipPlayer::set_blips(QString p_sfx)
{
QString f_path = ao_app->get_sounds_path(p_sfx);
- for (int n_stream = 0 ; n_stream < 5 ; ++n_stream)
- {
+ for (int n_stream = 0; n_stream < 5; ++n_stream) {
m_blips.setSource(QUrl::fromLocalFile(f_path));
}
@@ -88,30 +86,18 @@ void AOBlipPlayer::set_volume_internal(qreal p_value)
{
m_blips.setVolume(m_volume);
}
-#else //No audio
+#else // No audio
AOBlipPlayer::AOBlipPlayer(QWidget *parent, AOApplication *p_ao_app)
{
m_parent = parent;
ao_app = p_ao_app;
}
-void AOBlipPlayer::set_blips(QString p_sfx)
-{
-
-}
-
-void AOBlipPlayer::blip_tick()
-{
-
-}
-
-void AOBlipPlayer::set_volume(qreal p_value)
-{
+void AOBlipPlayer::set_blips(QString p_sfx) {}
-}
+void AOBlipPlayer::blip_tick() {}
-void AOBlipPlayer::set_volume_internal(qreal p_value)
-{
+void AOBlipPlayer::set_volume(qreal p_value) {}
-}
+void AOBlipPlayer::set_volume_internal(qreal p_value) {}
#endif
diff --git a/src/aobutton.cpp b/src/aobutton.cpp
index 5be2e678..fee946a4 100644
--- a/src/aobutton.cpp
+++ b/src/aobutton.cpp
@@ -3,15 +3,13 @@
#include "debug_functions.h"
#include "file_functions.h"
-AOButton::AOButton(QWidget *parent, AOApplication *p_ao_app) : QPushButton(parent)
+AOButton::AOButton(QWidget *parent, AOApplication *p_ao_app)
+ : QPushButton(parent)
{
ao_app = p_ao_app;
}
-AOButton::~AOButton()
-{
-
-}
+AOButton::~AOButton() {}
void AOButton::set_image(QString p_image)
{
@@ -23,4 +21,3 @@ void AOButton::set_image(QString p_image)
else
this->setStyleSheet("border-image:url(\"" + default_image_path + "\")");
}
-
diff --git a/src/aocaseannouncerdialog.cpp b/src/aocaseannouncerdialog.cpp
index 4b36fe62..0a287c37 100644
--- a/src/aocaseannouncerdialog.cpp
+++ b/src/aocaseannouncerdialog.cpp
@@ -1,7 +1,9 @@
#include "aocaseannouncerdialog.h"
-AOCaseAnnouncerDialog::AOCaseAnnouncerDialog(QWidget *parent, AOApplication *p_ao_app, Courtroom *p_court)
- : QDialog(parent)
+AOCaseAnnouncerDialog::AOCaseAnnouncerDialog(QWidget *parent,
+ AOApplication *p_ao_app,
+ Courtroom *p_court)
+ : QDialog(parent)
{
ao_app = p_ao_app;
court = p_court;
@@ -14,21 +16,27 @@ AOCaseAnnouncerDialog::AOCaseAnnouncerDialog(QWidget *parent, AOApplication *p_a
QSizePolicy sizepolicy(QSizePolicy::Expanding, QSizePolicy::Fixed);
sizepolicy.setHorizontalStretch(0);
sizepolicy.setVerticalStretch(0);
- sizepolicy.setHeightForWidth(ui_announcer_buttons->sizePolicy().hasHeightForWidth());
+ sizepolicy.setHeightForWidth(
+ ui_announcer_buttons->sizePolicy().hasHeightForWidth());
ui_announcer_buttons->setSizePolicy(sizepolicy);
ui_announcer_buttons->setOrientation(Qt::Horizontal);
- ui_announcer_buttons->setStandardButtons(QDialogButtonBox::Ok | QDialogButtonBox::Cancel);
+ ui_announcer_buttons->setStandardButtons(QDialogButtonBox::Ok |
+ QDialogButtonBox::Cancel);
- QObject::connect(ui_announcer_buttons, SIGNAL(accepted()), this, SLOT(ok_pressed()));
- QObject::connect(ui_announcer_buttons, SIGNAL(rejected()), this, SLOT(cancel_pressed()));
+ QObject::connect(ui_announcer_buttons, SIGNAL(accepted()), this,
+ SLOT(ok_pressed()));
+ QObject::connect(ui_announcer_buttons, SIGNAL(rejected()), this,
+ SLOT(cancel_pressed()));
setUpdatesEnabled(false);
ui_vbox_layout = new QVBoxLayout(this);
ui_form_layout = new QFormLayout(this);
- ui_form_layout->setLabelAlignment(Qt::AlignLeading | Qt::AlignLeft | Qt::AlignVCenter);
- ui_form_layout->setFormAlignment(Qt::AlignLeading | Qt::AlignLeft | Qt::AlignTop);
+ ui_form_layout->setLabelAlignment(Qt::AlignLeading | Qt::AlignLeft |
+ Qt::AlignVCenter);
+ ui_form_layout->setFormAlignment(Qt::AlignLeading | Qt::AlignLeft |
+ Qt::AlignTop);
ui_form_layout->setContentsMargins(6, 6, 6, 6);
ui_vbox_layout->addItem(ui_form_layout);
@@ -69,18 +77,13 @@ AOCaseAnnouncerDialog::AOCaseAnnouncerDialog(QWidget *parent, AOApplication *p_a
void AOCaseAnnouncerDialog::ok_pressed()
{
- court->announce_case(ui_case_title_textbox->text(),
- ui_defense_needed->isChecked(),
- ui_prosecutor_needed->isChecked(),
- ui_judge_needed->isChecked(),
- ui_juror_needed->isChecked(),
- ui_steno_needed->isChecked(),
- ui_witness_needed->isChecked());
+ court->announce_case(
+ ui_case_title_textbox->text(), ui_defense_needed->isChecked(),
+ ui_prosecutor_needed->isChecked(), ui_judge_needed->isChecked(),
+ ui_juror_needed->isChecked(), ui_steno_needed->isChecked(),
+ ui_witness_needed->isChecked());
done(0);
}
-void AOCaseAnnouncerDialog::cancel_pressed()
-{
- done(0);
-}
+void AOCaseAnnouncerDialog::cancel_pressed() { done(0); }
diff --git a/src/aocharbutton.cpp b/src/aocharbutton.cpp
index 76610270..5c8a73bb 100644
--- a/src/aocharbutton.cpp
+++ b/src/aocharbutton.cpp
@@ -2,7 +2,9 @@
#include "file_functions.h"
-AOCharButton::AOCharButton(QWidget *parent, AOApplication *p_ao_app, int x_pos, int y_pos, bool is_taken) : QPushButton(parent)
+AOCharButton::AOCharButton(QWidget *parent, AOApplication *p_ao_app, int x_pos,
+ int y_pos, bool is_taken)
+ : QPushButton(parent)
{
m_parent = parent;
@@ -40,45 +42,35 @@ void AOCharButton::reset()
ui_selector->hide();
}
-void AOCharButton::set_taken(bool is_taken)
-{
- taken = is_taken;
-}
+void AOCharButton::set_taken(bool is_taken) { taken = is_taken; }
void AOCharButton::apply_taken_image()
{
- if (taken)
- {
- ui_taken->move(0,0);
+ if (taken) {
+ ui_taken->move(0, 0);
ui_taken->show();
}
- else
- {
+ else {
ui_taken->hide();
}
}
-void AOCharButton::set_passworded()
-{
- ui_passworded->show();
-}
+void AOCharButton::set_passworded() { ui_passworded->show(); }
void AOCharButton::set_image(QString p_character)
{
QString image_path = ao_app->get_character_path(p_character, "char_icon.png");
-
this->setText("");
if (file_exists(image_path))
this->setStyleSheet("border-image:url(\"" + image_path + "\")");
- else
- {
+ else {
this->setStyleSheet("border-image:url()");
this->setText(p_character);
}
}
-void AOCharButton::enterEvent(QEvent * e)
+void AOCharButton::enterEvent(QEvent *e)
{
ui_selector->move(this->x() - 1, this->y() - 1);
ui_selector->raise();
@@ -88,10 +80,8 @@ void AOCharButton::enterEvent(QEvent * e)
QPushButton::enterEvent(e);
}
-void AOCharButton::leaveEvent(QEvent * e)
+void AOCharButton::leaveEvent(QEvent *e)
{
ui_selector->hide();
QPushButton::leaveEvent(e);
}
-
-
diff --git a/src/aocharmovie.cpp b/src/aocharmovie.cpp
index f0dad421..4252923a 100644
--- a/src/aocharmovie.cpp
+++ b/src/aocharmovie.cpp
@@ -1,10 +1,11 @@
#include "aocharmovie.h"
-#include "misc_functions.h"
-#include "file_functions.h"
#include "aoapplication.h"
+#include "file_functions.h"
+#include "misc_functions.h"
-AOCharMovie::AOCharMovie(QWidget *p_parent, AOApplication *p_ao_app) : QLabel(p_parent)
+AOCharMovie::AOCharMovie(QWidget *p_parent, AOApplication *p_ao_app)
+ : QLabel(p_parent)
{
ao_app = p_ao_app;
m_movie = new QMovie(this);
@@ -19,17 +20,22 @@ AOCharMovie::AOCharMovie(QWidget *p_parent, AOApplication *p_ao_app) : QLabel(p_
void AOCharMovie::play(QString p_char, QString p_emote, QString emote_prefix)
{
apng = false;
- QString original_path = ao_app->get_character_path(p_char, emote_prefix + p_emote + ".gif");
- QString alt_path = ao_app->get_character_path(p_char, emote_prefix + p_emote + ".png");
+
+ QString original_path =
+ ao_app->get_character_path(p_char, emote_prefix + p_emote + ".gif");
+ QString alt_path =
+ ao_app->get_character_path(p_char, emote_prefix + p_emote + ".png");
+ QString apng_path =
+ ao_app->get_character_path(p_char, emote_prefix + p_emote + ".apng");
QString alt_path_still = ao_app->get_character_path(p_char, p_emote + ".png");
- QString apng_path = ao_app->get_character_path(p_char, emote_prefix + p_emote + ".apng");
+
QString placeholder_path = ao_app->get_theme_path("placeholder.gif");
- QString placeholder_default_path = ao_app->get_default_theme_path("placeholder.gif");
+ QString placeholder_default_path =
+ ao_app->get_default_theme_path("placeholder.gif");
QString gif_path;
current_emote = emote_prefix + p_emote;
current_char = p_char;
- if (file_exists(apng_path))
- {
+ if (file_exists(apng_path)) {
gif_path = apng_path;
apng = true;
}
@@ -53,7 +59,8 @@ void AOCharMovie::play(QString p_char, QString p_emote, QString emote_prefix)
this->LoadImageWithStupidMethodForFlipSupport(m_movie->currentImage());
this->show();
this->play_frame_sfx();
- // if the frame count is 0 (i.e. it's a static PNG) don't try to play the next frame, ya goofus
+ // if the frame count is 0 (i.e. it's a static PNG) don't try to play the next
+ // frame, ya goofus
if (m_movie->frameCount() != 0) {
ticker->start(m_movie->nextFrameDelay());
}
@@ -62,148 +69,147 @@ void AOCharMovie::play(QString p_char, QString p_emote, QString emote_prefix)
void AOCharMovie::play_frame_sfx()
{
int current_frame = m_movie->currentFrameNumber();
- QString sfx_to_play = ao_app->get_frame_sfx_name(current_char, current_emote, current_frame);
- QString screenshake_to_play = ao_app->get_screenshake_frame(current_char, current_emote, current_frame);
- QString realization_to_play = ao_app->get_realization_frame(current_char, current_emote, current_frame);
- if(sfx_to_play != "" && !use_networked_framehell)
- {
+ QString sfx_to_play =
+ ao_app->get_frame_sfx_name(current_char, current_emote, current_frame);
+ QString screenshake_to_play =
+ ao_app->get_screenshake_frame(current_char, current_emote, current_frame);
+ QString realization_to_play =
+ ao_app->get_realization_frame(current_char, current_emote, current_frame);
+ if (sfx_to_play != "" && !use_networked_framehell) {
frame_specific_sfx_player->play(ao_app->get_sfx_suffix(sfx_to_play));
}
- else if(use_networked_framehell)
- {
- this->sfx_two_network_boogaloo();
+ else if (use_networked_framehell) {
+ this->sfx_two_network_boogaloo();
}
- if(screenshake_to_play != "" && !use_networked_framehell)
- {
+ if (screenshake_to_play != "" && !use_networked_framehell) {
mycourtroom->doScreenShake();
}
- else if(use_networked_framehell)
- {
- this->screenshake_two_network_boogaloo();
+ else if (use_networked_framehell) {
+ this->screenshake_two_network_boogaloo();
}
- if(realization_to_play != "" && !use_networked_framehell)
- {
+ if (realization_to_play != "" && !use_networked_framehell) {
mycourtroom->doRealization();
}
- else if(use_networked_framehell)
- {
- this->realization_two_network_boogaloo();
+ else if (use_networked_framehell) {
+ this->realization_two_network_boogaloo();
}
}
void AOCharMovie::realization_two_network_boogaloo()
{
- int current_frame = m_movie->currentFrameNumber();
- QStringList realizationList = this->frame_realization_hellstring.split("^");
- for (int i = 0; i < realizationList.length(); i++) {
- QString screenshakeList = realizationList.at(i);
- QStringList extra_garbage = screenshakeList.split("|");
- if(extra_garbage.at(0) != current_emote){
- continue;
- }
- for (int ii = 1; ii < extra_garbage.length(); ii++) {
- QString levels_of_garbage = extra_garbage.at(ii);
- QStringList that_shouldnt_be_possible = levels_of_garbage.split("=");
- if(that_shouldnt_be_possible.at(0).toInt() == current_frame && that_shouldnt_be_possible.at(1) != "") {
- mycourtroom->doRealization();
- }
- }
+ int current_frame = m_movie->currentFrameNumber();
+ QStringList realizationList = this->frame_realization_hellstring.split("^");
+ for (int i = 0; i < realizationList.length(); i++) {
+ QString screenshakeList = realizationList.at(i);
+ QStringList extra_garbage = screenshakeList.split("|");
+ if (extra_garbage.at(0) != current_emote) {
+ continue;
+ }
+ for (int ii = 1; ii < extra_garbage.length(); ii++) {
+ QString levels_of_garbage = extra_garbage.at(ii);
+ QStringList that_shouldnt_be_possible = levels_of_garbage.split("=");
+ if (that_shouldnt_be_possible.at(0).toInt() == current_frame &&
+ that_shouldnt_be_possible.at(1) != "") {
+ mycourtroom->doRealization();
+ }
}
+ }
}
void AOCharMovie::screenshake_two_network_boogaloo()
{
- int current_frame = m_movie->currentFrameNumber();
- QStringList realizationList = this->frame_screenshake_hellstring.split("^");
- for (int i = 0; i < realizationList.length(); i++) {
- QString screenshakeList = realizationList.at(i);
- QStringList extra_garbage = screenshakeList.split("|");
- if(extra_garbage.at(0) != current_emote){
- continue;
- }
- for (int ii = 1; ii < extra_garbage.length(); ii++) {
- QString levels_of_garbage = extra_garbage.at(ii);
- QStringList that_shouldnt_be_possible = levels_of_garbage.split("=");
- if(that_shouldnt_be_possible.at(0).toInt() == current_frame && that_shouldnt_be_possible.at(1) != "") {
- mycourtroom->doScreenShake();
- }
- }
+ int current_frame = m_movie->currentFrameNumber();
+ QStringList realizationList = this->frame_screenshake_hellstring.split("^");
+ for (int i = 0; i < realizationList.length(); i++) {
+ QString screenshakeList = realizationList.at(i);
+ QStringList extra_garbage = screenshakeList.split("|");
+ if (extra_garbage.at(0) != current_emote) {
+ continue;
+ }
+ for (int ii = 1; ii < extra_garbage.length(); ii++) {
+ QString levels_of_garbage = extra_garbage.at(ii);
+ QStringList that_shouldnt_be_possible = levels_of_garbage.split("=");
+ if (that_shouldnt_be_possible.at(0).toInt() == current_frame &&
+ that_shouldnt_be_possible.at(1) != "") {
+ mycourtroom->doScreenShake();
+ }
}
+ }
}
void AOCharMovie::sfx_two_network_boogaloo()
{
- int current_frame = m_movie->currentFrameNumber();
- QStringList realizationList = this->frame_sfx_hellstring.split("^");
- for (int i = 0; i < realizationList.length(); i++) {
- QString screenshakeList = realizationList.at(i);
- QStringList extra_garbage = screenshakeList.split("|");
- if(extra_garbage.at(0) != current_emote){
- continue;
- }
- for (int ii = 1; ii < extra_garbage.length(); ii++) {
- QString levels_of_garbage = extra_garbage.at(ii);
- QStringList that_shouldnt_be_possible = levels_of_garbage.split("=");
- if(that_shouldnt_be_possible.at(0).toInt() == current_frame && that_shouldnt_be_possible.at(1) != "") {
- frame_specific_sfx_player->play(ao_app->get_sfx_suffix(that_shouldnt_be_possible.at(1)));
- }
- }
+ int current_frame = m_movie->currentFrameNumber();
+ QStringList realizationList = this->frame_sfx_hellstring.split("^");
+ for (int i = 0; i < realizationList.length(); i++) {
+ QString screenshakeList = realizationList.at(i);
+ QStringList extra_garbage = screenshakeList.split("|");
+ if (extra_garbage.at(0) != current_emote) {
+ continue;
+ }
+ for (int ii = 1; ii < extra_garbage.length(); ii++) {
+ QString levels_of_garbage = extra_garbage.at(ii);
+ QStringList that_shouldnt_be_possible = levels_of_garbage.split("=");
+ if (that_shouldnt_be_possible.at(0).toInt() == current_frame &&
+ that_shouldnt_be_possible.at(1) != "") {
+ frame_specific_sfx_player->play(
+ ao_app->get_sfx_suffix(that_shouldnt_be_possible.at(1)));
+ }
}
+ }
}
-
void AOCharMovie::movie_ticker()
{
- if(m_movie->currentFrameNumber() == m_movie->frameCount() - 1)
- {
+ if (m_movie->currentFrameNumber() == m_movie->frameCount() - 1) {
delete m_movie;
m_movie = new QMovie(this);
m_movie->stop();
this->clear();
m_movie->setFileName(last_path);
m_movie->jumpToFrame(0);
- if(play_once)
- {
- timer_done();
+ if (play_once) {
+ timer_done();
}
}
- else
- {
+ else {
m_movie->jumpToNextFrame();
}
this->LoadImageWithStupidMethodForFlipSupport(m_movie->currentImage());
- // imagine if QT had sane stuff like "mirror on QMovie" or "resize the image on QT" or "interface with the current QMovie image" or anything else
+ // imagine if QT had sane stuff like "mirror on QMovie" or "resize the image
+ // on QT" or "interface with the current QMovie image" or anything else
this->play_frame_sfx();
- if (m_movie->frameCount() == 0)
- {
+ if (m_movie->frameCount() == 0) {
return;
}
- else if (!apng)
- {
+ else if (!apng) {
ticker->start(m_movie->nextFrameDelay());
}
}
void AOCharMovie::LoadImageWithStupidMethodForFlipSupport(QImage image)
{
- QPixmap f_pixmap;
- if(m_flipped)
- f_pixmap = QPixmap::fromImage(image.mirrored(true, false));
- else
- f_pixmap = QPixmap::fromImage(image);
- auto aspect_ratio = Qt::KeepAspectRatio;
+ QPixmap f_pixmap;
+ if (m_flipped)
+ f_pixmap = QPixmap::fromImage(image.mirrored(true, false));
+ else
+ f_pixmap = QPixmap::fromImage(image);
+ auto aspect_ratio = Qt::KeepAspectRatio;
- if (f_pixmap.size().width() > f_pixmap.size().height())
- aspect_ratio = Qt::KeepAspectRatioByExpanding;
+ if (f_pixmap.size().width() > f_pixmap.size().height())
+ aspect_ratio = Qt::KeepAspectRatioByExpanding;
- if (f_pixmap.size().width() > this->size().width() || f_pixmap.size().height() > this->size().height())
- this->setPixmap(f_pixmap.scaled(this->width(), this->height(), aspect_ratio, Qt::SmoothTransformation));
- else
- this->setPixmap(f_pixmap.scaled(this->width(), this->height(), aspect_ratio, Qt::FastTransformation));
+ if (f_pixmap.size().width() > this->size().width() ||
+ f_pixmap.size().height() > this->size().height())
+ this->setPixmap(f_pixmap.scaled(this->width(), this->height(), aspect_ratio,
+ Qt::SmoothTransformation));
+ else
+ this->setPixmap(f_pixmap.scaled(this->width(), this->height(), aspect_ratio,
+ Qt::FastTransformation));
- QLabel::move(x + (this->width() - this->pixmap()->width())/2, y);
+ QLabel::move(x + (this->width() - this->pixmap()->width()) / 2, y);
}
void AOCharMovie::play_pre(QString p_char, QString p_emote, int duration)
@@ -231,7 +237,8 @@ void AOCharMovie::play_idle(QString p_char, QString p_emote)
void AOCharMovie::stop()
{
- //for all intents and purposes, stopping is the same as hiding. at no point do we want a frozen gif to display
+ // for all intents and purposes, stopping is the same as hiding. at no point
+ // do we want a frozen gif to display
m_movie->stop();
frame_specific_sfx_player->stop();
this->hide();
@@ -250,7 +257,4 @@ void AOCharMovie::move(int ax, int ay)
QLabel::move(x, y);
}
-void AOCharMovie::timer_done()
-{
- done();
-}
+void AOCharMovie::timer_done() { done(); }
diff --git a/src/aoemotebutton.cpp b/src/aoemotebutton.cpp
index 9c1d3889..29329c98 100644
--- a/src/aoemotebutton.cpp
+++ b/src/aoemotebutton.cpp
@@ -2,7 +2,9 @@
#include "file_functions.h"
-AOEmoteButton::AOEmoteButton(QWidget *p_parent, AOApplication *p_ao_app, int p_x, int p_y) : QPushButton(p_parent)
+AOEmoteButton::AOEmoteButton(QWidget *p_parent, AOApplication *p_ao_app,
+ int p_x, int p_y)
+ : QPushButton(p_parent)
{
parent = p_parent;
ao_app = p_ao_app;
@@ -16,21 +18,17 @@ AOEmoteButton::AOEmoteButton(QWidget *p_parent, AOApplication *p_ao_app, int p_x
void AOEmoteButton::set_image(QString p_char, int p_emote, QString suffix)
{
QString emotion_number = QString::number(p_emote + 1);
- QString image_path = ao_app->get_character_path(p_char, "emotions/button" + emotion_number + suffix);
+ QString image_path = ao_app->get_character_path(
+ p_char, "emotions/button" + emotion_number + suffix);
- if (file_exists(image_path))
- {
+ if (file_exists(image_path)) {
this->setText("");
this->setStyleSheet("border-image:url(\"" + image_path + "\")");
}
- else
- {
+ else {
this->setText(ao_app->get_emote_comment(p_char, p_emote));
this->setStyleSheet("border-image:url(\"\")");
}
}
-void AOEmoteButton::on_clicked()
-{
- emote_clicked(m_id);
-}
+void AOEmoteButton::on_clicked() { emote_clicked(m_id); }
diff --git a/src/aoevidencebutton.cpp b/src/aoevidencebutton.cpp
index 4dc03959..d0a6ac1b 100644
--- a/src/aoevidencebutton.cpp
+++ b/src/aoevidencebutton.cpp
@@ -2,7 +2,9 @@
#include "file_functions.h"
-AOEvidenceButton::AOEvidenceButton(QWidget *p_parent, AOApplication *p_ao_app, int p_x, int p_y) : QPushButton(p_parent)
+AOEvidenceButton::AOEvidenceButton(QWidget *p_parent, AOApplication *p_ao_app,
+ int p_x, int p_y)
+ : QPushButton(p_parent)
{
ao_app = p_ao_app;
m_parent = p_parent;
@@ -39,13 +41,11 @@ void AOEvidenceButton::set_image(QString p_image)
{
QString image_path = ao_app->get_evidence_path(p_image);
- if (file_exists(image_path))
- {
+ if (file_exists(image_path)) {
this->setText("");
this->setStyleSheet("border-image:url(\"" + image_path + "\")");
}
- else
- {
+ else {
this->setText(p_image);
this->setStyleSheet("");
}
@@ -75,10 +75,7 @@ void AOEvidenceButton::set_selected(bool p_selected)
ui_selected->hide();
}
-void AOEvidenceButton::on_clicked()
-{
- evidence_clicked(m_id);
-}
+void AOEvidenceButton::on_clicked() { evidence_clicked(m_id); }
void AOEvidenceButton::mouseDoubleClickEvent(QMouseEvent *e)
{
@@ -98,7 +95,7 @@ void AOEvidenceButton::dragEnterEvent(QMouseEvent *e)
}
*/
-void AOEvidenceButton::enterEvent(QEvent * e)
+void AOEvidenceButton::enterEvent(QEvent *e)
{
ui_selector->show();
@@ -108,7 +105,7 @@ void AOEvidenceButton::enterEvent(QEvent * e)
QPushButton::enterEvent(e);
}
-void AOEvidenceButton::leaveEvent(QEvent * e)
+void AOEvidenceButton::leaveEvent(QEvent *e)
{
ui_selector->hide();
diff --git a/src/aoevidencedisplay.cpp b/src/aoevidencedisplay.cpp
index 9ec105dd..9dd062b7 100644
--- a/src/aoevidencedisplay.cpp
+++ b/src/aoevidencedisplay.cpp
@@ -1,10 +1,11 @@
#include "aoevidencedisplay.h"
-#include "file_functions.h"
#include "datatypes.h"
+#include "file_functions.h"
#include "misc_functions.h"
-AOEvidenceDisplay::AOEvidenceDisplay(QWidget *p_parent, AOApplication *p_ao_app) : QLabel(p_parent)
+AOEvidenceDisplay::AOEvidenceDisplay(QWidget *p_parent, AOApplication *p_ao_app)
+ : QLabel(p_parent)
{
ao_app = p_ao_app;
@@ -12,10 +13,12 @@ AOEvidenceDisplay::AOEvidenceDisplay(QWidget *p_parent, AOApplication *p_ao_app)
evidence_icon = new QLabel(this);
sfx_player = new AOSfxPlayer(this, ao_app);
- connect(evidence_movie, SIGNAL(frameChanged(int)), this, SLOT(frame_change(int)));
+ connect(evidence_movie, SIGNAL(frameChanged(int)), this,
+ SLOT(frame_change(int)));
}
-void AOEvidenceDisplay::show_evidence(QString p_evidence_image, bool is_left_side, int p_volume)
+void AOEvidenceDisplay::show_evidence(QString p_evidence_image,
+ bool is_left_side, int p_volume)
{
this->reset();
@@ -29,23 +32,23 @@ void AOEvidenceDisplay::show_evidence(QString p_evidence_image, bool is_left_sid
QString gif_name;
QString icon_identifier;
- if (is_left_side)
- {
+ if (is_left_side) {
icon_identifier = "left_evidence_icon";
gif_name = "evidence_appear_left.gif";
}
- else
- {
+ else {
icon_identifier = "right_evidence_icon";
gif_name = "evidence_appear_right.gif";
}
- pos_size_type icon_dimensions = ao_app->get_element_dimensions(icon_identifier, "courtroom_design.ini");
+ pos_size_type icon_dimensions =
+ ao_app->get_element_dimensions(icon_identifier, "courtroom_design.ini");
evidence_icon->move(icon_dimensions.x, icon_dimensions.y);
evidence_icon->resize(icon_dimensions.width, icon_dimensions.height);
- evidence_icon->setPixmap(f_pixmap.scaled(evidence_icon->width(), evidence_icon->height(), Qt::IgnoreAspectRatio));
+ evidence_icon->setPixmap(f_pixmap.scaled(
+ evidence_icon->width(), evidence_icon->height(), Qt::IgnoreAspectRatio));
QString f_default_gif_path = ao_app->get_default_theme_path(gif_name);
QString f_gif_path = ao_app->get_theme_path(gif_name);
@@ -57,7 +60,7 @@ void AOEvidenceDisplay::show_evidence(QString p_evidence_image, bool is_left_sid
evidence_movie->setFileName(final_gif_path);
- if(evidence_movie->frameCount() < 1)
+ if (evidence_movie->frameCount() < 1)
return;
this->setMovie(evidence_movie);
@@ -68,9 +71,8 @@ void AOEvidenceDisplay::show_evidence(QString p_evidence_image, bool is_left_sid
void AOEvidenceDisplay::frame_change(int p_frame)
{
- if (p_frame == (evidence_movie->frameCount() - 1))
- {
- //we need this or else the last frame wont show
+ if (p_frame == (evidence_movie->frameCount() - 1)) {
+ // we need this or else the last frame wont show
delay(evidence_movie->nextFrameDelay());
evidence_movie->stop();
@@ -88,9 +90,4 @@ void AOEvidenceDisplay::reset()
this->clear();
}
-QLabel* AOEvidenceDisplay::get_evidence_icon()
-{
- return evidence_icon;
-}
-
-
+QLabel *AOEvidenceDisplay::get_evidence_icon() { return evidence_icon; }
diff --git a/src/aoimage.cpp b/src/aoimage.cpp
index 7bb56bb6..ffdf25aa 100644
--- a/src/aoimage.cpp
+++ b/src/aoimage.cpp
@@ -8,10 +8,7 @@ AOImage::AOImage(QWidget *parent, AOApplication *p_ao_app) : QLabel(parent)
ao_app = p_ao_app;
}
-AOImage::~AOImage()
-{
-
-}
+AOImage::~AOImage() {}
void AOImage::set_image(QString p_image)
{
@@ -27,7 +24,8 @@ void AOImage::set_image(QString p_image)
QPixmap f_pixmap(final_image_path);
- this->setPixmap(f_pixmap.scaled(this->width(), this->height(), Qt::IgnoreAspectRatio));
+ this->setPixmap(
+ f_pixmap.scaled(this->width(), this->height(), Qt::IgnoreAspectRatio));
}
void AOImage::set_image_from_path(QString p_path)
@@ -43,5 +41,6 @@ void AOImage::set_image_from_path(QString p_path)
QPixmap f_pixmap(final_path);
- this->setPixmap(f_pixmap.scaled(this->width(), this->height(), Qt::IgnoreAspectRatio));
+ this->setPixmap(
+ f_pixmap.scaled(this->width(), this->height(), Qt::IgnoreAspectRatio));
}
diff --git a/src/aolineedit.cpp b/src/aolineedit.cpp
index f6026e14..211d9f78 100644
--- a/src/aolineedit.cpp
+++ b/src/aolineedit.cpp
@@ -15,7 +15,4 @@ void AOLineEdit::mouseDoubleClickEvent(QMouseEvent *e)
this->setReadOnly(false);
}
-void AOLineEdit::on_enter_pressed()
-{
- this->setReadOnly(true);
-}
+void AOLineEdit::on_enter_pressed() { this->setReadOnly(true); }
diff --git a/src/aomovie.cpp b/src/aomovie.cpp
index bb8e53d3..9ffd62f0 100644
--- a/src/aomovie.cpp
+++ b/src/aomovie.cpp
@@ -1,119 +1,116 @@
-#include "aomovie.h"
-
-#include "courtroom.h"
+#include "aomovie.h"
+
+#include "courtroom.h"
#include "file_functions.h"
-#include "misc_functions.h"
-
-AOMovie::AOMovie(QWidget *p_parent, AOApplication *p_ao_app) : QLabel(p_parent)
-{
- ao_app = p_ao_app;
-
- m_movie = new QMovie();
-
- this->setMovie(m_movie);
- timer = new QTimer(this);
- timer->setTimerType(Qt::PreciseTimer);
- timer->setSingleShot(true);
- connect(m_movie, SIGNAL(frameChanged(int)), this, SLOT(frame_change(int)));
- connect(timer, SIGNAL(timeout()), this, SLOT(timer_done()));
-}
-
-void AOMovie::set_play_once(bool p_play_once)
-{
- play_once = p_play_once;
-}
-void AOMovie::start_timer(int delay) { timer->start(delay); }
-
-void AOMovie::play(QString p_gif, QString p_char, QString p_custom_theme,
- int duration)
-{
-
- m_movie->stop();
- // this->timer_done();
- QString shout_path = p_gif;
- QList<QString> pathlist;
-
- if (ao_app->get_character_path(p_char, p_gif)
- .contains(
- "custom_objections")) // checks if the file is located within the
- // folder of custom objections
- pathlist << ao_app->get_character_path(
- p_char,
- p_gif); // get_image_suffix is unecessery as it is already given.
- else if (p_gif == "custom")
- pathlist << ao_app->get_image_suffix(
- ao_app->get_character_path(p_char, p_gif));
- else
- pathlist << ao_app->get_image_suffix(
- ao_app->get_character_path(p_char, p_gif + "_bubble"));
-
- QString misc_path = ao_app->get_base_path() + "misc/" + p_custom_theme + "/" +
- p_gif + "_bubble.gif";
- QString custom_theme_path =
- ao_app->get_custom_theme_path(p_custom_theme, p_gif + ".gif");
- QString theme_path = ao_app->get_theme_path(p_gif + ".gif");
- QString default_theme_path = ao_app->get_default_theme_path(p_gif + ".gif");
- QString placeholder_path = ao_app->get_theme_path("placeholder.gif");
- QString default_placeholder_path =
- ao_app->get_default_theme_path("placeholder.gif");
-
- pathlist << ao_app->get_image_suffix(ao_app->get_base_path() + "misc/" +
- p_custom_theme + "/" + p_gif + "_bubble")
- << // Misc path
- ao_app->get_image_suffix(
- ao_app->get_custom_theme_path(p_custom_theme, p_gif))
- << // Custom theme path
- ao_app->get_image_suffix(ao_app->get_theme_path(p_gif)) << // Theme path
- ao_app->get_image_suffix(ao_app->get_default_theme_path(p_gif))
- << // Default theme path
- ao_app->get_image_suffix(ao_app->get_theme_path("placeholder"))
- << // Placeholder path
- ao_app->get_image_suffix(ao_app->get_default_theme_path(
- "placeholder")); // Default placeholder path
-
- for (QString path : pathlist) {
- if (file_exists(path)) {
- shout_path = path;
- break;
- }
- }
- m_movie->setFileName(shout_path);
- if (m_movie->loopCount() == 0)
- play_once = true;
-
- this->show();
- m_movie->start();
- if (m_movie->frameCount() == 0 && duration > 0)
- timer->start(duration);
-}
-
-void AOMovie::stop()
-{
- m_movie->stop();
- this->hide();
-}
-
-void AOMovie::frame_change(int n_frame)
-{
- // If it's a "static movie" (only one frame - png image), we can't change
- // frames - ignore this function (use timer instead). If the frame didn't
- // reach the last frame or the movie is continuous, don't stop the movie.
- if (m_movie->frameCount() == 0 || n_frame < (m_movie->frameCount() - 1) ||
- !play_once)
- return;
- // we need this or else the last frame wont show
- timer->start(m_movie->nextFrameDelay());
-}
-
-void AOMovie::timer_done()
-{
- this->stop();
- done();
-}
-
-void AOMovie::combo_resize(int w, int h)
-{
- QSize f_size(w, h);
- this->resize(f_size);
- m_movie->setScaledSize(f_size);
-}
+#include "misc_functions.h"
+
+AOMovie::AOMovie(QWidget *p_parent, AOApplication *p_ao_app) : QLabel(p_parent)
+{
+ ao_app = p_ao_app;
+
+ m_movie = new QMovie();
+
+ this->setMovie(m_movie);
+ timer = new QTimer(this);
+ timer->setTimerType(Qt::PreciseTimer);
+ timer->setSingleShot(true);
+ connect(m_movie, SIGNAL(frameChanged(int)), this, SLOT(frame_change(int)));
+ connect(timer, SIGNAL(timeout()), this, SLOT(timer_done()));
+}
+
+void AOMovie::set_play_once(bool p_play_once) { play_once = p_play_once; }
+void AOMovie::start_timer(int delay) { timer->start(delay); }
+
+void AOMovie::play(QString p_gif, QString p_char, QString p_custom_theme,
+ int duration)
+{
+
+ m_movie->stop();
+ // this->timer_done();
+ QString shout_path = p_gif;
+ QList<QString> pathlist;
+
+ if (ao_app->get_character_path(p_char, p_gif)
+ .contains(
+ "custom_objections")) // checks if the file is located within the
+ // folder of custom objections
+ pathlist << ao_app->get_character_path(
+ p_char,
+ p_gif); // get_image_suffix is unecessery as it is already given.
+ else if (p_gif == "custom")
+ pathlist << ao_app->get_image_suffix(
+ ao_app->get_character_path(p_char, p_gif));
+ else
+ pathlist << ao_app->get_image_suffix(
+ ao_app->get_character_path(p_char, p_gif + "_bubble"));
+
+ QString misc_path = ao_app->get_base_path() + "misc/" + p_custom_theme + "/" +
+ p_gif + "_bubble.gif";
+ QString custom_theme_path =
+ ao_app->get_custom_theme_path(p_custom_theme, p_gif + ".gif");
+ QString theme_path = ao_app->get_theme_path(p_gif + ".gif");
+ QString default_theme_path = ao_app->get_default_theme_path(p_gif + ".gif");
+ QString placeholder_path = ao_app->get_theme_path("placeholder.gif");
+ QString default_placeholder_path =
+ ao_app->get_default_theme_path("placeholder.gif");
+
+ pathlist << ao_app->get_image_suffix(ao_app->get_base_path() + "misc/" +
+ p_custom_theme + "/" + p_gif + "_bubble")
+ << // Misc path
+ ao_app->get_image_suffix(
+ ao_app->get_custom_theme_path(p_custom_theme, p_gif))
+ << // Custom theme path
+ ao_app->get_image_suffix(ao_app->get_theme_path(p_gif)) << // Theme path
+ ao_app->get_image_suffix(ao_app->get_default_theme_path(p_gif))
+ << // Default theme path
+ ao_app->get_image_suffix(ao_app->get_theme_path("placeholder"))
+ << // Placeholder path
+ ao_app->get_image_suffix(ao_app->get_default_theme_path(
+ "placeholder")); // Default placeholder path
+
+ for (QString path : pathlist) {
+ if (file_exists(path)) {
+ shout_path = path;
+ break;
+ }
+ }
+ m_movie->setFileName(shout_path);
+ if (m_movie->loopCount() == 0)
+ play_once = true;
+
+ this->show();
+ m_movie->start();
+ if (m_movie->frameCount() == 0 && duration > 0)
+ timer->start(duration);
+}
+
+void AOMovie::stop()
+{
+ m_movie->stop();
+ this->hide();
+}
+
+void AOMovie::frame_change(int n_frame)
+{
+ // If it's a "static movie" (only one frame - png image), we can't change
+ // frames - ignore this function (use timer instead). If the frame didn't
+ // reach the last frame or the movie is continuous, don't stop the movie.
+ if (m_movie->frameCount() == 0 || n_frame < (m_movie->frameCount() - 1) ||
+ !play_once)
+ return;
+ // we need this or else the last frame wont show
+ timer->start(m_movie->nextFrameDelay());
+}
+
+void AOMovie::timer_done()
+{
+ this->stop();
+ done();
+}
+
+void AOMovie::combo_resize(int w, int h)
+{
+ QSize f_size(w, h);
+ this->resize(f_size);
+ m_movie->setScaledSize(f_size);
+}
diff --git a/src/aomusicplayer.cpp b/src/aomusicplayer.cpp
index 74dcc639..e767435f 100644
--- a/src/aomusicplayer.cpp
+++ b/src/aomusicplayer.cpp
@@ -1,16 +1,14 @@
#include "aomusicplayer.h"
#if defined(BASSAUDIO)
-AOMusicPlayer::AOMusicPlayer(QWidget *parent, AOApplication *p_ao_app): QObject()
+AOMusicPlayer::AOMusicPlayer(QWidget *parent, AOApplication *p_ao_app)
+ : QObject()
{
m_parent = parent;
ao_app = p_ao_app;
}
-AOMusicPlayer::~AOMusicPlayer()
-{
- kill_loop();
-}
+AOMusicPlayer::~AOMusicPlayer() { kill_loop(); }
void AOMusicPlayer::play(QString p_song)
{
@@ -18,24 +16,21 @@ void AOMusicPlayer::play(QString p_song)
f_path = ao_app->get_music_path(p_song);
- m_stream = BASS_StreamCreateFile(FALSE, f_path.utf16(), 0, 0, BASS_STREAM_AUTOFREE | BASS_UNICODE | BASS_ASYNCFILE);
+ m_stream = BASS_StreamCreateFile(FALSE, f_path.utf16(), 0, 0,
+ BASS_STREAM_AUTOFREE | BASS_UNICODE |
+ BASS_ASYNCFILE);
this->set_volume(m_volume);
if (ao_app->get_audio_output_device() != "default")
BASS_ChannelSetDevice(m_stream, BASS_GetDevice());
- if(enable_looping)
- {
+ if (enable_looping) {
BASS_ChannelFlags(m_stream, BASS_SAMPLE_LOOP, BASS_SAMPLE_LOOP);
}
- else
- {
+ else {
BASS_ChannelFlags(m_stream, 0, BASS_SAMPLE_LOOP);
}
BASS_ChannelPlay(m_stream, false);
-
-
-
}
void AOMusicPlayer::set_volume(int p_value)
@@ -45,27 +40,19 @@ void AOMusicPlayer::set_volume(int p_value)
BASS_ChannelSetAttribute(m_stream, BASS_ATTRIB_VOL, volume);
}
-QString AOMusicPlayer::get_path()
-{
- return f_path;
-}
+QString AOMusicPlayer::get_path() { return f_path; }
-void AOMusicPlayer::kill_loop()
-{
- BASS_ChannelStop(m_stream);
-}
+void AOMusicPlayer::kill_loop() { BASS_ChannelStop(m_stream); }
#elif defined(QTAUDIO)
-AOMusicPlayer::AOMusicPlayer(QWidget *parent, AOApplication *p_ao_app): QObject()
+AOMusicPlayer::AOMusicPlayer(QWidget *parent, AOApplication *p_ao_app)
+ : QObject()
{
m_parent = parent;
ao_app = p_ao_app;
}
-AOMusicPlayer::~AOMusicPlayer()
-{
- m_player.stop();
-}
+AOMusicPlayer::~AOMusicPlayer() { m_player.stop(); }
void AOMusicPlayer::play(QString p_song)
{
@@ -88,47 +75,27 @@ void AOMusicPlayer::set_volume(int p_value)
QAudio::LogarithmicVolumeScale,
QAudio::LinearVolumeScale);
- m_player.setVolume(linearVolume*100);
+ m_player.setVolume(linearVolume * 100);
}
-QString AOMusicPlayer::get_path()
-{
- return f_path;
-}
+QString AOMusicPlayer::get_path() { return f_path; }
-void AOMusicPlayer::kill_loop()
-{
- m_player.stop();
-}
+void AOMusicPlayer::kill_loop() { m_player.stop(); }
#else
-AOMusicPlayer::AOMusicPlayer(QWidget *parent, AOApplication *p_ao_app): QObject()
+AOMusicPlayer::AOMusicPlayer(QWidget *parent, AOApplication *p_ao_app)
+ : QObject()
{
m_parent = parent;
ao_app = p_ao_app;
}
-AOMusicPlayer::~AOMusicPlayer()
-{
-
-}
-
-void AOMusicPlayer::play(QString p_song)
-{
-
-}
+AOMusicPlayer::~AOMusicPlayer() {}
-void AOMusicPlayer::set_volume(int p_value)
-{
-
-}
+void AOMusicPlayer::play(QString p_song) {}
-QString AOMusicPlayer::get_path()
-{
- return f_path;
-}
+void AOMusicPlayer::set_volume(int p_value) {}
-void AOMusicPlayer::kill_loop()
-{
+QString AOMusicPlayer::get_path() { return f_path; }
-}
+void AOMusicPlayer::kill_loop() {}
#endif
diff --git a/src/aopacket.cpp b/src/aopacket.cpp
index b957efea..6afd39e7 100644
--- a/src/aopacket.cpp
+++ b/src/aopacket.cpp
@@ -8,8 +8,7 @@ AOPacket::AOPacket(QString p_packet_string)
m_header = packet_contents.at(0);
- for(int n_string = 1 ; n_string < packet_contents.size() - 1 ; ++n_string)
- {
+ for (int n_string = 1; n_string < packet_contents.size() - 1; ++n_string) {
m_contents.append(packet_contents.at(n_string));
}
}
@@ -20,23 +19,18 @@ AOPacket::AOPacket(QString p_header, QStringList &p_contents)
m_contents = p_contents;
}
-AOPacket::~AOPacket()
-{
-
-}
+AOPacket::~AOPacket() {}
QString AOPacket::to_string()
{
QString f_string = m_header;
- for (QString i_string : m_contents)
- {
+ for (QString i_string : m_contents) {
f_string += ("#" + i_string);
}
f_string += "#%";
-
if (encrypted)
return "#" + f_string;
else
@@ -59,10 +53,12 @@ void AOPacket::decrypt_header(unsigned int p_key)
void AOPacket::net_encode()
{
- for (int n_element = 0 ; n_element < m_contents.size() ; ++n_element)
- {
+ for (int n_element = 0; n_element < m_contents.size(); ++n_element) {
QString f_element = m_contents.at(n_element);
- f_element.replace("#", "<num>").replace("%", "<percent>").replace("$", "<dollar>").replace("&", "<and>");
+ f_element.replace("#", "<num>")
+ .replace("%", "<percent>")
+ .replace("$", "<dollar>")
+ .replace("&", "<and>");
m_contents.removeAt(n_element);
m_contents.insert(n_element, f_element);
@@ -71,13 +67,14 @@ void AOPacket::net_encode()
void AOPacket::net_decode()
{
- for (int n_element = 0 ; n_element < m_contents.size() ; ++n_element)
- {
+ for (int n_element = 0; n_element < m_contents.size(); ++n_element) {
QString f_element = m_contents.at(n_element);
- f_element.replace("<num>", "#").replace("<percent>", "%").replace("<dollar>", "$").replace("<and>", "&");
+ f_element.replace("<num>", "#")
+ .replace("<percent>", "%")
+ .replace("<dollar>", "$")
+ .replace("<and>", "&");
m_contents.removeAt(n_element);
m_contents.insert(n_element, f_element);
}
}
-
diff --git a/src/aosfxplayer.cpp b/src/aosfxplayer.cpp
index d2140e3e..4684acdb 100644
--- a/src/aosfxplayer.cpp
+++ b/src/aosfxplayer.cpp
@@ -1,8 +1,8 @@
#include "aosfxplayer.h"
#include "file_functions.h"
-#if defined(BASSAUDIO) //Using bass.dll for sfx
-AOSfxPlayer::AOSfxPlayer(QWidget *parent, AOApplication *p_ao_app): QObject()
+#if defined(BASSAUDIO) // Using bass.dll for sfx
+AOSfxPlayer::AOSfxPlayer(QWidget *parent, AOApplication *p_ao_app) : QObject()
{
m_parent = parent;
ao_app = p_ao_app;
@@ -11,7 +11,7 @@ AOSfxPlayer::AOSfxPlayer(QWidget *parent, AOApplication *p_ao_app): QObject()
void AOSfxPlayer::play(QString p_sfx, QString p_char, QString shout)
{
BASS_ChannelStop(m_stream);
-
+
QString misc_path = "";
QString char_path = "";
QString sound_path = ao_app->get_sounds_path(p_sfx);
@@ -24,38 +24,35 @@ void AOSfxPlayer::play(QString p_sfx, QString p_char, QString shout)
QString f_path;
if (file_exists(char_path))
- f_path = char_path;
+ f_path = char_path;
else if (file_exists(misc_path))
f_path = misc_path;
else
f_path = sound_path;
BASS_ChannelStop(m_stream);
- m_stream = BASS_StreamCreateFile(FALSE, f_path.utf16(), 0, 0, BASS_STREAM_AUTOFREE | BASS_UNICODE | BASS_ASYNCFILE);
+ m_stream = BASS_StreamCreateFile(FALSE, f_path.utf16(), 0, 0,
+ BASS_STREAM_AUTOFREE | BASS_UNICODE |
+ BASS_ASYNCFILE);
set_volume_internal(m_volume);
if (ao_app->get_audio_output_device() != "default")
BASS_ChannelSetDevice(m_stream, BASS_GetDevice());
BASS_ChannelPlay(m_stream, false);
- if(looping_sfx && ao_app->get_looping_sfx())
- {
+ if (looping_sfx && ao_app->get_looping_sfx()) {
BASS_ChannelFlags(m_stream, BASS_SAMPLE_LOOP, BASS_SAMPLE_LOOP);
}
- else
- {
+ else {
BASS_ChannelFlags(m_stream, 0, BASS_SAMPLE_LOOP);
}
}
void AOSfxPlayer::setLooping(bool is_looping)
{
- this->looping_sfx = is_looping;
+ this->looping_sfx = is_looping;
}
-void AOSfxPlayer::stop()
-{
- BASS_ChannelStop(m_stream);
-}
+void AOSfxPlayer::stop() { BASS_ChannelStop(m_stream); }
void AOSfxPlayer::set_volume(qreal p_value)
{
@@ -65,11 +62,11 @@ void AOSfxPlayer::set_volume(qreal p_value)
void AOSfxPlayer::set_volume_internal(qreal p_value)
{
- float volume = p_value;
- BASS_ChannelSetAttribute(m_stream, BASS_ATTRIB_VOL, volume);
+ float volume = p_value;
+ BASS_ChannelSetAttribute(m_stream, BASS_ATTRIB_VOL, volume);
}
-#elif defined(QTAUDIO) //Using Qt's QSoundEffect class
-AOSfxPlayer::AOSfxPlayer(QWidget *parent, AOApplication *p_ao_app): QObject()
+#elif defined(QTAUDIO) // Using Qt's QSoundEffect class
+AOSfxPlayer::AOSfxPlayer(QWidget *parent, AOApplication *p_ao_app) : QObject()
{
m_parent = parent;
ao_app = p_ao_app;
@@ -91,35 +88,32 @@ void AOSfxPlayer::play(QString p_sfx, QString p_char, QString shout)
QString f_path;
if (file_exists(char_path))
- f_path = char_path;
+ f_path = char_path;
else if (file_exists(misc_path))
f_path = misc_path;
else
f_path = sound_path;
- if (file_exists(f_path)) //if its missing, it will glitch out
+ if (file_exists(f_path)) // if its missing, it will glitch out
{
- m_sfx.setSource(QUrl::fromLocalFile(f_path));
+ m_sfx.setSource(QUrl::fromLocalFile(f_path));
- set_volume_internal(m_volume);
+ set_volume_internal(m_volume);
- m_sfx.play();
+ m_sfx.play();
}
}
void AOSfxPlayer::setLooping(bool is_looping)
{
- this->looping_sfx = is_looping;
+ this->looping_sfx = is_looping;
}
-void AOSfxPlayer::stop()
-{
- m_sfx.stop();
-}
+void AOSfxPlayer::stop() { m_sfx.stop(); }
void AOSfxPlayer::set_volume(qreal p_value)
{
- m_volume = p_value/100;
+ m_volume = p_value / 100;
set_volume_internal(m_volume);
}
@@ -128,34 +122,22 @@ void AOSfxPlayer::set_volume_internal(qreal p_value)
m_sfx.setVolume(m_volume);
}
#else
-AOSfxPlayer::AOSfxPlayer(QWidget *parent, AOApplication *p_ao_app): QObject()
+AOSfxPlayer::AOSfxPlayer(QWidget *parent, AOApplication *p_ao_app) : QObject()
{
m_parent = parent;
ao_app = p_ao_app;
}
-void AOSfxPlayer::play(QString p_sfx, QString p_char, QString shout)
-{
-
-}
+void AOSfxPlayer::play(QString p_sfx, QString p_char, QString shout) {}
void AOSfxPlayer::setLooping(bool is_looping)
{
- this->looping_sfx = is_looping;
+ this->looping_sfx = is_looping;
}
-void AOSfxPlayer::stop()
-{
+void AOSfxPlayer::stop() {}
-}
-
-void AOSfxPlayer::set_volume(qreal p_value)
-{
+void AOSfxPlayer::set_volume(qreal p_value) {}
-}
-
-void AOSfxPlayer::set_volume_internal(qreal p_value)
-{
-
-}
+void AOSfxPlayer::set_volume_internal(qreal p_value) {}
#endif
diff --git a/src/aotextarea.cpp b/src/aotextarea.cpp
index c7415699..04d44318 100644
--- a/src/aotextarea.cpp
+++ b/src/aotextarea.cpp
@@ -1,16 +1,14 @@
#include "aotextarea.h"
-AOTextArea::AOTextArea(QWidget *p_parent) : QTextBrowser(p_parent)
-{
-
-}
+AOTextArea::AOTextArea(QWidget *p_parent) : QTextBrowser(p_parent) {}
void AOTextArea::append_chatmessage(QString p_name, QString p_message,
QString p_colour, bool song)
{
const QTextCursor old_cursor = this->textCursor();
const int old_scrollbar_value = this->verticalScrollBar()->value();
- const bool is_scrolled_down = old_scrollbar_value == this->verticalScrollBar()->maximum();
+ const bool is_scrolled_down =
+ old_scrollbar_value == this->verticalScrollBar()->maximum();
this->moveCursor(QTextCursor::End);
@@ -22,9 +20,11 @@ void AOTextArea::append_chatmessage(QString p_name, QString p_message,
this->insertHtml("<b><font color=" + p_colour + ">" +
p_name.toHtmlEscaped() + "</font></b>:&nbsp;");
- //cheap workarounds ahoy
+ // cheap workarounds ahoy
p_message += " ";
- QString result = p_message.toHtmlEscaped().replace("\n", "<br>").replace(omnis_dank_url_regex, "<a href='\\1'>\\1</a>" );
+ QString result = p_message.toHtmlEscaped()
+ .replace("\n", "<br>")
+ .replace(omnis_dank_url_regex, "<a href='\\1'>\\1</a>");
this->insertHtml(result);
@@ -35,32 +35,35 @@ void AOTextArea::append_error(QString p_message)
{
const QTextCursor old_cursor = this->textCursor();
const int old_scrollbar_value = this->verticalScrollBar()->value();
- const bool is_scrolled_down = old_scrollbar_value == this->verticalScrollBar()->maximum();
+ const bool is_scrolled_down =
+ old_scrollbar_value == this->verticalScrollBar()->maximum();
this->moveCursor(QTextCursor::End);
this->append("");
p_message += " ";
- QString result = p_message.replace("\n", "<br>").replace(omnis_dank_url_regex, "<a href='\\1'>\\1</a>" );
+ QString result = p_message.replace("\n", "<br>")
+ .replace(omnis_dank_url_regex, "<a href='\\1'>\\1</a>");
this->insertHtml("<font color='red'>" + result + "</font>");
this->auto_scroll(old_cursor, old_scrollbar_value, is_scrolled_down);
}
-void AOTextArea::auto_scroll(QTextCursor old_cursor, int old_scrollbar_value, bool is_scrolled_down)
+void AOTextArea::auto_scroll(QTextCursor old_cursor, int old_scrollbar_value,
+ bool is_scrolled_down)
{
- if (old_cursor.hasSelection() || !is_scrolled_down)
- {
- // The user has selected text or scrolled away from the bottom: maintain position.
- this->setTextCursor(old_cursor);
- this->verticalScrollBar()->setValue(old_scrollbar_value);
+ if (old_cursor.hasSelection() || !is_scrolled_down) {
+ // The user has selected text or scrolled away from the bottom: maintain
+ // position.
+ this->setTextCursor(old_cursor);
+ this->verticalScrollBar()->setValue(old_scrollbar_value);
}
- else
- {
- // The user hasn't selected any text and the scrollbar is at the bottom: scroll to the bottom.
- this->moveCursor(QTextCursor::End);
- this->verticalScrollBar()->setValue(this->verticalScrollBar()->maximum());
+ else {
+ // The user hasn't selected any text and the scrollbar is at the bottom:
+ // scroll to the bottom.
+ this->moveCursor(QTextCursor::End);
+ this->verticalScrollBar()->setValue(this->verticalScrollBar()->maximum());
}
}
diff --git a/src/aotextedit.cpp b/src/aotextedit.cpp
index 30e48b73..22d9a62e 100644
--- a/src/aotextedit.cpp
+++ b/src/aotextedit.cpp
@@ -4,7 +4,7 @@ AOTextEdit::AOTextEdit(QWidget *parent) : QPlainTextEdit(parent)
{
this->setReadOnly(true);
- //connect(this, SIGNAL(returnPressed()), this, SLOT(on_enter_pressed()));
+ // connect(this, SIGNAL(returnPressed()), this, SLOT(on_enter_pressed()));
}
void AOTextEdit::mouseDoubleClickEvent(QMouseEvent *e)
@@ -14,8 +14,4 @@ void AOTextEdit::mouseDoubleClickEvent(QMouseEvent *e)
this->setReadOnly(false);
}
-void AOTextEdit::on_enter_pressed()
-{
- this->setReadOnly(true);
-}
-
+void AOTextEdit::on_enter_pressed() { this->setReadOnly(true); }
diff --git a/src/charselect.cpp b/src/charselect.cpp
index e942fbea..9dee2373 100644
--- a/src/charselect.cpp
+++ b/src/charselect.cpp
@@ -1,12 +1,11 @@
#include "courtroom.h"
#include "lobby.h"
-#include "file_functions.h"
#include "debug_functions.h"
+#include "file_functions.h"
#include "hardware_functions.h"
-class AOCharSelectGenerationThreading : public QRunnable
-{
+class AOCharSelectGenerationThreading : public QRunnable {
public:
Courtroom *thisCourtroom;
int char_num;
@@ -93,28 +92,36 @@ void Courtroom::construct_char_select()
set_size_and_pos(ui_char_buttons, "char_buttons");
- connect(char_button_mapper, SIGNAL(mapped(int)), this, SLOT(char_clicked(int)));
- connect(ui_back_to_lobby, SIGNAL(clicked()), this, SLOT(on_back_to_lobby_clicked()));
+ connect(char_button_mapper, SIGNAL(mapped(int)), this,
+ SLOT(char_clicked(int)));
+ 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_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()));
- connect(ui_char_search, SIGNAL(textEdited(const QString&)), this, SLOT(on_char_search_changed()));
- connect(ui_char_passworded, SIGNAL(stateChanged(int)), this, SLOT(on_char_passworded_clicked()));
- connect(ui_char_taken, SIGNAL(stateChanged(int)), this, SLOT(on_char_taken_clicked()));
+ connect(ui_char_search, SIGNAL(textEdited(const QString &)), this,
+ SLOT(on_char_search_changed()));
+ connect(ui_char_passworded, SIGNAL(stateChanged(int)), this,
+ SLOT(on_char_passworded_clicked()));
+ connect(ui_char_taken, SIGNAL(stateChanged(int)), this,
+ SLOT(on_char_taken_clicked()));
}
void Courtroom::set_char_select()
{
QString filename = "courtroom_design.ini";
- pos_size_type f_charselect = ao_app->get_element_dimensions("char_select", filename);
+ pos_size_type f_charselect =
+ ao_app->get_element_dimensions("char_select", filename);
- if (f_charselect.width < 0 || f_charselect.height < 0)
- {
- qDebug() << "W: did not find courtroom width or height in courtroom_design.ini!";
+ if (f_charselect.width < 0 || f_charselect.height < 0) {
+ qDebug()
+ << "W: did not find courtroom width or height in courtroom_design.ini!";
this->resize(714, 668);
}
else
@@ -135,25 +142,22 @@ void Courtroom::set_char_select_page()
ui_char_select_left->hide();
ui_char_select_right->hide();
- for (AOCharButton *i_button : ui_char_button_list)
- {
+ for (AOCharButton *i_button : ui_char_button_list) {
i_button->reset();
i_button->hide();
- i_button->move(0,0);
+ i_button->move(0, 0);
}
int total_pages = ui_char_button_list_filtered.size() / max_chars_on_page;
int chars_on_page = 0;
- if (ui_char_button_list_filtered.size() % max_chars_on_page != 0)
- {
+ if (ui_char_button_list_filtered.size() % max_chars_on_page != 0) {
++total_pages;
- //i. e. not on the last page
+ // i. e. not on the last page
if (total_pages > current_char_page + 1)
chars_on_page = max_chars_on_page;
else
chars_on_page = ui_char_button_list_filtered.size() % max_chars_on_page;
-
}
else
chars_on_page = max_chars_on_page;
@@ -169,24 +173,25 @@ void Courtroom::set_char_select_page()
void Courtroom::char_clicked(int n_char)
{
- QString char_ini_path = ao_app->get_character_path(char_list.at(n_char).name, "char.ini");
+ QString char_ini_path =
+ ao_app->get_character_path(char_list.at(n_char).name, "char.ini");
qDebug() << "char_ini_path" << char_ini_path;
- if (!file_exists(char_ini_path))
- {
+ if (!file_exists(char_ini_path)) {
call_notice(tr("Could not find %1").arg(char_ini_path, 1));
return;
}
- if (n_char == m_cid)
- {
+ if (n_char == m_cid) {
enter_courtroom(m_cid);
}
- else
- {
- ao_app->send_server_packet(new AOPacket("PW#" + ui_char_password->text() + "#%"));
- ao_app->send_server_packet(new AOPacket("CC#" + QString::number(ao_app->s_pv) + "#" + QString::number(n_char) + "#" + get_hdid() + "#%"));
+ else {
+ ao_app->send_server_packet(
+ new AOPacket("PW#" + ui_char_password->text() + "#%"));
+ ao_app->send_server_packet(
+ new AOPacket("CC#" + QString::number(ao_app->s_pv) + "#" +
+ QString::number(n_char) + "#" + get_hdid() + "#%"));
}
ui_ic_chat_name->setPlaceholderText(char_list.at(n_char).name);
@@ -194,53 +199,55 @@ void Courtroom::char_clicked(int n_char)
void Courtroom::put_button_in_place(int starting, int chars_on_this_page)
{
- if (ui_char_button_list_filtered.size() == 0)
- return;
+ if (ui_char_button_list_filtered.size() == 0)
+ return;
- QPoint f_spacing = ao_app->get_button_spacing("char_button_spacing", "courtroom_design.ini");
+ QPoint f_spacing =
+ ao_app->get_button_spacing("char_button_spacing", "courtroom_design.ini");
- int x_spacing = f_spacing.x();
- int x_mod_count = 0;
+ int x_spacing = f_spacing.x();
+ int x_mod_count = 0;
- int y_spacing = f_spacing.y();
- int y_mod_count = 0;
+ int y_spacing = f_spacing.y();
+ int y_mod_count = 0;
- char_columns = ((ui_char_buttons->width() - button_width) / (x_spacing + button_width)) + 1;
- char_rows = ((ui_char_buttons->height() - button_height) / (y_spacing + button_height)) + 1;
+ char_columns =
+ ((ui_char_buttons->width() - button_width) / (x_spacing + button_width)) +
+ 1;
+ char_rows = ((ui_char_buttons->height() - button_height) /
+ (y_spacing + button_height)) +
+ 1;
- max_chars_on_page = char_columns * char_rows;
+ max_chars_on_page = char_columns * char_rows;
- int startout = starting;
- for (int n = starting ; n < startout+chars_on_this_page ; ++n)
- {
- int x_pos = (button_width + x_spacing) * x_mod_count;
- int y_pos = (button_height + y_spacing) * y_mod_count;
+ int startout = starting;
+ for (int n = starting; n < startout + chars_on_this_page; ++n) {
+ int x_pos = (button_width + x_spacing) * x_mod_count;
+ int y_pos = (button_height + y_spacing) * y_mod_count;
- ui_char_button_list_filtered.at(n)->move(x_pos, y_pos);
- ui_char_button_list_filtered.at(n)->show();
- ui_char_button_list_filtered.at(n)->apply_taken_image();
+ ui_char_button_list_filtered.at(n)->move(x_pos, y_pos);
+ ui_char_button_list_filtered.at(n)->show();
+ ui_char_button_list_filtered.at(n)->apply_taken_image();
- ++x_mod_count;
+ ++x_mod_count;
- if (x_mod_count == char_columns)
- {
- ++y_mod_count;
- x_mod_count = 0;
- }
+ if (x_mod_count == char_columns) {
+ ++y_mod_count;
+ x_mod_count = 0;
}
+ }
}
void Courtroom::character_loading_finished()
{
- // Zeroeth, we'll clear any leftover characters from previous server visits.
- ao_app->generated_chars = 0;
- if (ui_char_button_list.size() > 0)
- {
- foreach (AOCharButton* item, ui_char_button_list) {
- delete item;
- }
- ui_char_button_list.clear();
+ // Zeroeth, we'll clear any leftover characters from previous server visits.
+ ao_app->generated_chars = 0;
+ if (ui_char_button_list.size() > 0) {
+ foreach (AOCharButton *item, ui_char_button_list) {
+ delete item;
}
+ ui_char_button_list.clear();
+ }
// First, we'll make all the character buttons in the very beginning.
// Since we can't trust what will happen during the multi threading process,
@@ -278,17 +285,8 @@ void Courtroom::filter_character_list()
set_char_select_page();
}
-void Courtroom::on_char_search_changed()
-{
- filter_character_list();
-}
+void Courtroom::on_char_search_changed() { filter_character_list(); }
-void Courtroom::on_char_passworded_clicked()
-{
- filter_character_list();
-}
+void Courtroom::on_char_passworded_clicked() { filter_character_list(); }
-void Courtroom::on_char_taken_clicked()
-{
- filter_character_list();
-}
+void Courtroom::on_char_taken_clicked() { filter_character_list(); }
diff --git a/src/chatlogpiece.cpp b/src/chatlogpiece.cpp
index b96d5027..9017b961 100644
--- a/src/chatlogpiece.cpp
+++ b/src/chatlogpiece.cpp
@@ -33,36 +33,17 @@ chatlogpiece::chatlogpiece(QString p_name, QString p_showname,
datetime = p_datetime.toUTC();
}
-QString chatlogpiece::get_name()
-{
- return name;
-}
+QString chatlogpiece::get_name() { return name; }
-QString chatlogpiece::get_showname()
-{
- return showname;
-}
+QString chatlogpiece::get_showname() { return showname; }
-QString chatlogpiece::get_message()
-{
- return message;
-}
+QString chatlogpiece::get_message() { return message; }
-QDateTime chatlogpiece::get_datetime()
-{
- return datetime;
-}
-
-bool chatlogpiece::get_is_song()
-{
- return is_song;
-}
+QDateTime chatlogpiece::get_datetime() { return datetime; }
-QString chatlogpiece::get_datetime_as_string()
-{
- return datetime.toString();
-}
+bool chatlogpiece::get_is_song() { return is_song; }
+QString chatlogpiece::get_datetime_as_string() { return datetime.toString(); }
int chatlogpiece::get_chat_color() { return color; }
QString chatlogpiece::get_full()
diff --git a/src/courtroom.cpp b/src/courtroom.cpp
index 71910ab2..ca1c789c 100644
--- a/src/courtroom.cpp
+++ b/src/courtroom.cpp
@@ -1,136 +1,134 @@
-#include "courtroom.h"
-Courtroom::Courtroom(AOApplication *p_ao_app) : QMainWindow()
-{
- ao_app = p_ao_app;
- #ifdef BASSAUDIO
- // Change the default audio output device to be the one the user has given
- // in his config.ini file for now.
- unsigned int a = 0;
- BASS_DEVICEINFO info;
-
- if (ao_app->get_audio_output_device() == "default")
- {
- BASS_Init(-1, 48000, BASS_DEVICE_LATENCY, nullptr, nullptr);
- load_bass_opus_plugin();
- }
- else
- {
- for (a = 0; BASS_GetDeviceInfo(a, &info); a++)
- {
- if (ao_app->get_audio_output_device() == info.name)
- {
- BASS_SetDevice(a);
- BASS_Init(static_cast<int>(a), 48000, BASS_DEVICE_LATENCY, nullptr, nullptr);
- load_bass_opus_plugin();
- qDebug() << info.name << "was set as the default audio output device.";
- break;
- }
- }
- }
- #elif defined QTAUDIO
-
- if (ao_app->get_audio_output_device() != "default")
- {
- foreach (const QAudioDeviceInfo &deviceInfo, QAudioDeviceInfo::availableDevices(QAudio::AudioOutput))
- {
- if (ao_app->get_audio_output_device() == deviceInfo.deviceName())
- {
- ao_app->QtAudioDevice = deviceInfo;
- qDebug() << deviceInfo.deviceName() << "was set as the default audio output device.";
- break;
- }
- }
- }
- #endif
-
- keepalive_timer = new QTimer(this);
- keepalive_timer->start(60000);
-
- chat_tick_timer = new QTimer(this);
-
- text_delay_timer = new QTimer(this);
- text_delay_timer->setSingleShot(true);
-
- sfx_delay_timer = new QTimer(this);
- sfx_delay_timer->setSingleShot(true);
-
- realization_timer = new QTimer(this);
- realization_timer->setSingleShot(true);
-
- char_button_mapper = new QSignalMapper(this);
-
- music_player = new AOMusicPlayer(this, ao_app);
- music_player->set_volume(0);
-
- sfx_player = new AOSfxPlayer(this, ao_app);
- sfx_player->set_volume(0);
-
- objection_player = new AOSfxPlayer(this, ao_app);
- objection_player->set_volume(0);
-
- misc_sfx_player = new AOSfxPlayer(this, ao_app);
- misc_sfx_player->set_volume(0);
- frame_emote_sfx_player = new AOSfxPlayer(this, ao_app);
- frame_emote_sfx_player->set_volume(0);
+#include "courtroom.h"
+
+Courtroom::Courtroom(AOApplication *p_ao_app) : QMainWindow()
+{
+ ao_app = p_ao_app;
+#ifdef BASSAUDIO
+ // Change the default audio output device to be the one the user has given
+ // in his config.ini file for now.
+ unsigned int a = 0;
+ BASS_DEVICEINFO info;
+
+ if (ao_app->get_audio_output_device() == "default") {
+ BASS_Init(-1, 48000, BASS_DEVICE_LATENCY, nullptr, nullptr);
+ load_bass_opus_plugin();
+ }
+ else {
+ for (a = 0; BASS_GetDeviceInfo(a, &info); a++) {
+ if (ao_app->get_audio_output_device() == info.name) {
+ BASS_SetDevice(a);
+ BASS_Init(static_cast<int>(a), 48000, BASS_DEVICE_LATENCY, nullptr,
+ nullptr);
+ load_bass_opus_plugin();
+ qDebug() << info.name << "was set as the default audio output device.";
+ break;
+ }
+ }
+ }
+#elif defined QTAUDIO
+
+ if (ao_app->get_audio_output_device() != "default") {
+ foreach (const QAudioDeviceInfo &deviceInfo,
+ QAudioDeviceInfo::availableDevices(QAudio::AudioOutput)) {
+ if (ao_app->get_audio_output_device() == deviceInfo.deviceName()) {
+ ao_app->QtAudioDevice = deviceInfo;
+ qDebug() << deviceInfo.deviceName()
+ << "was set as the default audio output device.";
+ break;
+ }
+ }
+ }
+#endif
+
+ keepalive_timer = new QTimer(this);
+ keepalive_timer->start(60000);
+
+ chat_tick_timer = new QTimer(this);
+
+ text_delay_timer = new QTimer(this);
+ text_delay_timer->setSingleShot(true);
+
+ sfx_delay_timer = new QTimer(this);
+ sfx_delay_timer->setSingleShot(true);
+
+ realization_timer = new QTimer(this);
+ realization_timer->setSingleShot(true);
+
+ char_button_mapper = new QSignalMapper(this);
+
+ music_player = new AOMusicPlayer(this, ao_app);
+ music_player->set_volume(0);
+
+ sfx_player = new AOSfxPlayer(this, ao_app);
+ sfx_player->set_volume(0);
+
+ objection_player = new AOSfxPlayer(this, ao_app);
+ objection_player->set_volume(0);
+
+ misc_sfx_player = new AOSfxPlayer(this, ao_app);
+ misc_sfx_player->set_volume(0);
+ frame_emote_sfx_player = new AOSfxPlayer(this, ao_app);
+ frame_emote_sfx_player->set_volume(0);
pair_frame_emote_sfx_player = new AOSfxPlayer(this, ao_app);
- pair_frame_emote_sfx_player->set_volume(0);
-
+ pair_frame_emote_sfx_player->set_volume(0);
+
char_button_mapper = new QSignalMapper(this);
- blip_player = new AOBlipPlayer(this, ao_app);
- blip_player->set_volume(0);
-
- modcall_player = new AOSfxPlayer(this, ao_app);
- modcall_player->set_volume(50);
-
- ui_background = new AOImage(this, ao_app);
-
- ui_viewport = new QWidget(this);
- ui_vp_background = new AOScene(ui_viewport, ao_app);
- ui_vp_speedlines = new AOMovie(ui_viewport, ao_app);
- ui_vp_speedlines->set_play_once(false);
- ui_vp_player_char = new AOCharMovie(ui_viewport, ao_app);
- ui_vp_player_char->frame_specific_sfx_player = frame_emote_sfx_player;
- ui_vp_player_char->mycourtroom = this;
- ui_vp_sideplayer_char = new AOCharMovie(ui_viewport, ao_app);
- ui_vp_sideplayer_char->frame_specific_sfx_player = pair_frame_emote_sfx_player;
- ui_vp_sideplayer_char->mycourtroom = this;
- ui_vp_sideplayer_char->hide();
- ui_vp_desk = new AOScene(ui_viewport, ao_app);
- ui_vp_legacy_desk = new AOScene(ui_viewport, ao_app);
-
- ui_vp_evidence_display = new AOEvidenceDisplay(this, ao_app);
-
- ui_vp_chatbox = new AOImage(this, ao_app);
- ui_vp_showname = new QLabel(ui_vp_chatbox);
- ui_vp_message = new QTextEdit(ui_vp_chatbox);
- ui_vp_message->setFrameStyle(QFrame::NoFrame);
- ui_vp_message->setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
- ui_vp_message->setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
- ui_vp_message->setReadOnly(true);
-
+ blip_player = new AOBlipPlayer(this, ao_app);
+ blip_player->set_volume(0);
+
+ modcall_player = new AOSfxPlayer(this, ao_app);
+ modcall_player->set_volume(50);
+
+ ui_background = new AOImage(this, ao_app);
+
+ ui_viewport = new QWidget(this);
+ ui_vp_background = new AOScene(ui_viewport, ao_app);
+ ui_vp_speedlines = new AOMovie(ui_viewport, ao_app);
+ ui_vp_speedlines->set_play_once(false);
+ ui_vp_player_char = new AOCharMovie(ui_viewport, ao_app);
+ ui_vp_player_char->frame_specific_sfx_player = frame_emote_sfx_player;
+ ui_vp_player_char->mycourtroom = this;
+ ui_vp_sideplayer_char = new AOCharMovie(ui_viewport, ao_app);
+ ui_vp_sideplayer_char->frame_specific_sfx_player =
+ pair_frame_emote_sfx_player;
+ ui_vp_sideplayer_char->mycourtroom = this;
+ ui_vp_sideplayer_char->hide();
+ ui_vp_desk = new AOScene(ui_viewport, ao_app);
+ ui_vp_legacy_desk = new AOScene(ui_viewport, ao_app);
+
+ ui_vp_evidence_display = new AOEvidenceDisplay(this, ao_app);
+
+ ui_vp_chatbox = new AOImage(this, ao_app);
+ ui_vp_showname = new QLabel(ui_vp_chatbox);
+ ui_vp_message = new QTextEdit(ui_vp_chatbox);
+ ui_vp_message->setFrameStyle(QFrame::NoFrame);
+ ui_vp_message->setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
+ ui_vp_message->setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
+ ui_vp_message->setReadOnly(true);
+
ui_vp_testimony = new AOMovie(this, ao_app);
ui_vp_testimony->set_play_once(false);
ui_vp_realization = new AOMovie(this, ao_app);
- ui_vp_wtce = new AOMovie(this, ao_app);
- ui_vp_objection = new AOMovie(this, ao_app);
-
- ui_ic_chatlog = new QTextEdit(this);
- ui_ic_chatlog->setReadOnly(true);
-
- log_maximum_blocks = ao_app->get_max_log_size();
- log_goes_downwards = ao_app->get_log_goes_downwards();
-
- ui_ms_chatlog = new AOTextArea(this);
- ui_ms_chatlog->setReadOnly(true);
- ui_ms_chatlog->setOpenExternalLinks(true);
- ui_ms_chatlog->hide();
-
- ui_server_chatlog = new AOTextArea(this);
- ui_server_chatlog->setReadOnly(true);
- ui_server_chatlog->setOpenExternalLinks(true);
-
- ui_area_list = new QListWidget(this);
+ ui_vp_wtce = new AOMovie(this, ao_app);
+ ui_vp_objection = new AOMovie(this, ao_app);
+
+ ui_ic_chatlog = new QTextEdit(this);
+ ui_ic_chatlog->setReadOnly(true);
+
+ log_maximum_blocks = ao_app->get_max_log_size();
+ log_goes_downwards = ao_app->get_log_goes_downwards();
+
+ ui_ms_chatlog = new AOTextArea(this);
+ ui_ms_chatlog->setReadOnly(true);
+ ui_ms_chatlog->setOpenExternalLinks(true);
+ ui_ms_chatlog->hide();
+
+ ui_server_chatlog = new AOTextArea(this);
+ ui_server_chatlog->setReadOnly(true);
+ ui_server_chatlog->setOpenExternalLinks(true);
+
+ ui_area_list = new QListWidget(this);
ui_music_list = new QTreeWidget(this);
ui_music_list->setColumnCount(2);
@@ -145,907 +143,913 @@ Courtroom::Courtroom(AOApplication *p_ao_app) : QMainWindow()
ui_music_list->setContextMenuPolicy(Qt::CustomContextMenu);
ui_music_list->hide();
-
- ui_ic_chat_name = new QLineEdit(this);
- ui_ic_chat_name->setFrame(false);
- ui_ic_chat_name->setPlaceholderText(tr("Showname"));
-
- ui_ic_chat_message = new QLineEdit(this);
- ui_ic_chat_message->setFrame(false);
- ui_ic_chat_message->setPlaceholderText(tr("Message"));
-
- ui_muted = new AOImage(ui_ic_chat_message, ao_app);
- ui_muted->hide();
-
- ui_ooc_chat_message = new QLineEdit(this);
- ui_ooc_chat_message->setFrame(false);
- ui_ooc_chat_message->setPlaceholderText(tr("OOC Message"));
-
- ui_ooc_chat_name = new QLineEdit(this);
- ui_ooc_chat_name->setFrame(false);
- ui_ooc_chat_name->setPlaceholderText(tr("Name"));
- ui_ooc_chat_name->setMaxLength(30);
- ui_ooc_chat_name->setText(p_ao_app->get_default_username());
-
+
+ ui_ic_chat_name = new QLineEdit(this);
+ ui_ic_chat_name->setFrame(false);
+ ui_ic_chat_name->setPlaceholderText(tr("Showname"));
+
+ ui_ic_chat_message = new QLineEdit(this);
+ ui_ic_chat_message->setFrame(false);
+ ui_ic_chat_message->setPlaceholderText(tr("Message"));
+
+ ui_muted = new AOImage(ui_ic_chat_message, ao_app);
+ ui_muted->hide();
+
+ ui_ooc_chat_message = new QLineEdit(this);
+ ui_ooc_chat_message->setFrame(false);
+ ui_ooc_chat_message->setPlaceholderText(tr("OOC Message"));
+
+ ui_ooc_chat_name = new QLineEdit(this);
+ ui_ooc_chat_name->setFrame(false);
+ ui_ooc_chat_name->setPlaceholderText(tr("Name"));
+ ui_ooc_chat_name->setMaxLength(30);
+ ui_ooc_chat_name->setText(p_ao_app->get_default_username());
+
punctuation_modifier = p_ao_app->get_pundelay();
colorf_iclog = p_ao_app->get_colored_iclog_enabled();
mirror_iclog = p_ao_app->get_iclmir_enabled();
colorf_limit = p_ao_app->colorlog_restricted_enabled();
keep_evidence_display = p_ao_app->is_keepevi_enabled();
- //ui_area_password = new QLineEdit(this);
- //ui_area_password->setFrame(false);
- ui_music_search = new QLineEdit(this);
- ui_music_search->setFrame(false);
- ui_music_search->setPlaceholderText(tr("Search"));
-
- construct_emotes();
-
- ui_emote_left = new AOButton(this, ao_app);
- ui_emote_right = new AOButton(this, ao_app);
-
- ui_emote_dropdown = new QComboBox(this);
- ui_pos_dropdown = new QComboBox(this);
- ui_pos_dropdown->addItem("wit");
- ui_pos_dropdown->addItem("def");
- ui_pos_dropdown->addItem("pro");
- ui_pos_dropdown->addItem("jud");
- ui_pos_dropdown->addItem("hld");
- ui_pos_dropdown->addItem("hlp");
- ui_pos_dropdown->addItem("jur");
- ui_pos_dropdown->addItem("sea");
-
- ui_defense_bar = new AOImage(this, ao_app);
- ui_prosecution_bar = new AOImage(this, ao_app);
-
- ui_music_label = new QLabel(this);
- ui_sfx_label = new QLabel(this);
- ui_blip_label = new QLabel(this);
-
- ui_log_limit_label = new QLabel(this);
-
- ui_hold_it = new AOButton(this, ao_app);
- ui_objection = new AOButton(this, ao_app);
- ui_take_that = new AOButton(this, ao_app);
-
- ui_ooc_toggle = new AOButton(this, ao_app);
- ui_witness_testimony = new AOButton(this, ao_app);
- ui_cross_examination = new AOButton(this, ao_app);
- ui_guilty = new AOButton(this, ao_app);
- ui_not_guilty = new AOButton(this, ao_app);
-
- ui_change_character = new AOButton(this, ao_app);
- ui_reload_theme = new AOButton(this, ao_app);
- ui_call_mod = new AOButton(this, ao_app);
- ui_settings = new AOButton(this, ao_app);
- ui_announce_casing = new AOButton(this, ao_app);
- ui_switch_area_music = new AOButton(this, ao_app);
-
- ui_pre = new QCheckBox(this);
- ui_pre->setText(tr("Pre"));
-
- ui_flip = new QCheckBox(this);
- ui_flip->setText(tr("Flip"));
- ui_flip->hide();
-
- ui_guard = new QCheckBox(this);
-
- ui_guard->setText(tr("Disable Modcalls"));
-
- ui_guard->hide();
-
- ui_casing = new QCheckBox(this);
- ui_casing->setChecked(ao_app->get_casing_enabled());
- ui_casing->setText(tr("Casing"));
- ui_casing->hide();
-
- ui_showname_enable = new QCheckBox(this);
- ui_showname_enable->setChecked(ao_app->get_showname_enabled_by_default());
- ui_showname_enable->setText(tr("Shownames"));
-
- ui_pre_non_interrupt = new QCheckBox(this);
- ui_pre_non_interrupt->setText(tr("No Interrupt"));
- ui_pre_non_interrupt->hide();
-
- ui_custom_objection = new AOButton(this, ao_app);
+ // ui_area_password = new QLineEdit(this);
+ // ui_area_password->setFrame(false);
+ ui_music_search = new QLineEdit(this);
+ ui_music_search->setFrame(false);
+ ui_music_search->setPlaceholderText(tr("Search"));
+
+ construct_emotes();
+
+ ui_emote_left = new AOButton(this, ao_app);
+ ui_emote_right = new AOButton(this, ao_app);
+
+ ui_emote_dropdown = new QComboBox(this);
+ ui_pos_dropdown = new QComboBox(this);
+ ui_pos_dropdown->addItem("wit");
+ ui_pos_dropdown->addItem("def");
+ ui_pos_dropdown->addItem("pro");
+ ui_pos_dropdown->addItem("jud");
+ ui_pos_dropdown->addItem("hld");
+ ui_pos_dropdown->addItem("hlp");
+ ui_pos_dropdown->addItem("jur");
+ ui_pos_dropdown->addItem("sea");
+
+ ui_defense_bar = new AOImage(this, ao_app);
+ ui_prosecution_bar = new AOImage(this, ao_app);
+
+ ui_music_label = new QLabel(this);
+ ui_sfx_label = new QLabel(this);
+ ui_blip_label = new QLabel(this);
+
+ ui_log_limit_label = new QLabel(this);
+
+ ui_hold_it = new AOButton(this, ao_app);
+ ui_objection = new AOButton(this, ao_app);
+ ui_take_that = new AOButton(this, ao_app);
+
+ ui_ooc_toggle = new AOButton(this, ao_app);
+ ui_witness_testimony = new AOButton(this, ao_app);
+ ui_cross_examination = new AOButton(this, ao_app);
+ ui_guilty = new AOButton(this, ao_app);
+ ui_not_guilty = new AOButton(this, ao_app);
+
+ ui_change_character = new AOButton(this, ao_app);
+ ui_reload_theme = new AOButton(this, ao_app);
+ ui_call_mod = new AOButton(this, ao_app);
+ ui_settings = new AOButton(this, ao_app);
+ ui_announce_casing = new AOButton(this, ao_app);
+ ui_switch_area_music = new AOButton(this, ao_app);
+
+ ui_pre = new QCheckBox(this);
+ ui_pre->setText(tr("Pre"));
+
+ ui_flip = new QCheckBox(this);
+ ui_flip->setText(tr("Flip"));
+ ui_flip->hide();
+
+ ui_guard = new QCheckBox(this);
+
+ ui_guard->setText(tr("Disable Modcalls"));
+
+ ui_guard->hide();
+
+ ui_casing = new QCheckBox(this);
+ ui_casing->setChecked(ao_app->get_casing_enabled());
+ ui_casing->setText(tr("Casing"));
+ ui_casing->hide();
+
+ ui_showname_enable = new QCheckBox(this);
+ ui_showname_enable->setChecked(ao_app->get_showname_enabled_by_default());
+ ui_showname_enable->setText(tr("Shownames"));
+
+ ui_pre_non_interrupt = new QCheckBox(this);
+ ui_pre_non_interrupt->setText(tr("No Interrupt"));
+ ui_pre_non_interrupt->hide();
+
+ ui_custom_objection = new AOButton(this, ao_app);
ui_custom_objection->setContextMenuPolicy(Qt::CustomContextMenu);
custom_obj_menu = new QMenu;
- ui_realization = new AOButton(this, ao_app);
- ui_screenshake = new AOButton(this, ao_app);
- ui_mute = new AOButton(this, ao_app);
-
- ui_defense_plus = new AOButton(this, ao_app);
- ui_defense_minus = new AOButton(this, ao_app);
-
- ui_prosecution_plus = new AOButton(this, ao_app);
- ui_prosecution_minus = new AOButton(this, ao_app);
-
- ui_text_color = new QComboBox(this);
- ui_text_color->addItem(tr("White"));
- ui_text_color->addItem(tr("Green"));
- ui_text_color->addItem(tr("Red"));
- ui_text_color->addItem(tr("Orange"));
- ui_text_color->addItem(tr("Blue"));
- ui_text_color->addItem(tr("Yellow"));
- ui_text_color->addItem(tr("Rainbow"));
- ui_text_color->addItem(tr("Pink"));
- ui_text_color->addItem(tr("Cyan"));
-
- ui_music_slider = new QSlider(Qt::Horizontal, this);
- ui_music_slider->setRange(0, 100);
- ui_music_slider->setValue(ao_app->get_default_music());
-
- ui_sfx_slider = new QSlider(Qt::Horizontal, this);
- ui_sfx_slider->setRange(0, 100);
- ui_sfx_slider->setValue(ao_app->get_default_sfx());
-
- ui_blip_slider = new QSlider(Qt::Horizontal, this);
- ui_blip_slider->setRange(0, 100);
- ui_blip_slider->setValue(ao_app->get_default_blip());
-
- ui_log_limit_spinbox = new QSpinBox(this);
- ui_log_limit_spinbox->setRange(0, 10000);
- ui_log_limit_spinbox->setValue(ao_app->get_max_log_size());
-
- ui_mute_list = new QListWidget(this);
-
- ui_pair_list = new QListWidget(this);
- ui_pair_offset_spinbox = new QSpinBox(this);
- ui_pair_offset_spinbox->setRange(-100,100);
- ui_pair_offset_spinbox->setSuffix(tr("% offset"));
- ui_pair_button = new AOButton(this, ao_app);
-
- ui_evidence_button = new AOButton(this, ao_app);
-
- construct_evidence();
-
- construct_char_select();
-
- connect(keepalive_timer, SIGNAL(timeout()), this, SLOT(ping_server()));
-
- connect(ui_vp_objection, SIGNAL(done()), this, SLOT(objection_done()));
- connect(ui_vp_player_char, SIGNAL(done()), this, SLOT(preanim_done()));
-
- connect(text_delay_timer, SIGNAL(timeout()), this, SLOT(start_chat_ticking()));
- connect(sfx_delay_timer, SIGNAL(timeout()), this, SLOT(play_sfx()));
-
- connect(chat_tick_timer, SIGNAL(timeout()), this, SLOT(chat_tick()));
-
- connect(realization_timer, SIGNAL(timeout()), this, SLOT(realization_done()));
-
-
- connect(ui_emote_left, SIGNAL(clicked()), this, SLOT(on_emote_left_clicked()));
- connect(ui_emote_right, SIGNAL(clicked()), this, SLOT(on_emote_right_clicked()));
-
- connect(ui_emote_dropdown, SIGNAL(activated(int)), this, SLOT(on_emote_dropdown_changed(int)));
- connect(ui_pos_dropdown, SIGNAL(currentIndexChanged(int)), this, SLOT(on_pos_dropdown_changed(int)));
+ ui_realization = new AOButton(this, ao_app);
+ ui_screenshake = new AOButton(this, ao_app);
+ ui_mute = new AOButton(this, ao_app);
+
+ ui_defense_plus = new AOButton(this, ao_app);
+ ui_defense_minus = new AOButton(this, ao_app);
+
+ ui_prosecution_plus = new AOButton(this, ao_app);
+ ui_prosecution_minus = new AOButton(this, ao_app);
+
+ ui_text_color = new QComboBox(this);
+ ui_text_color->addItem(tr("White"));
+ ui_text_color->addItem(tr("Green"));
+ ui_text_color->addItem(tr("Red"));
+ ui_text_color->addItem(tr("Orange"));
+ ui_text_color->addItem(tr("Blue"));
+ ui_text_color->addItem(tr("Yellow"));
+ ui_text_color->addItem(tr("Rainbow"));
+ ui_text_color->addItem(tr("Pink"));
+ ui_text_color->addItem(tr("Cyan"));
+
+ ui_music_slider = new QSlider(Qt::Horizontal, this);
+ ui_music_slider->setRange(0, 100);
+ ui_music_slider->setValue(ao_app->get_default_music());
+
+ ui_sfx_slider = new QSlider(Qt::Horizontal, this);
+ ui_sfx_slider->setRange(0, 100);
+ ui_sfx_slider->setValue(ao_app->get_default_sfx());
+
+ ui_blip_slider = new QSlider(Qt::Horizontal, this);
+ ui_blip_slider->setRange(0, 100);
+ ui_blip_slider->setValue(ao_app->get_default_blip());
+
+ ui_log_limit_spinbox = new QSpinBox(this);
+ ui_log_limit_spinbox->setRange(0, 10000);
+ ui_log_limit_spinbox->setValue(ao_app->get_max_log_size());
+
+ ui_mute_list = new QListWidget(this);
+
+ ui_pair_list = new QListWidget(this);
+ ui_pair_offset_spinbox = new QSpinBox(this);
+ ui_pair_offset_spinbox->setRange(-100, 100);
+ ui_pair_offset_spinbox->setSuffix(tr("% offset"));
+ ui_pair_button = new AOButton(this, ao_app);
+
+ ui_evidence_button = new AOButton(this, ao_app);
+
+ construct_evidence();
+
+ construct_char_select();
+
+ connect(keepalive_timer, SIGNAL(timeout()), this, SLOT(ping_server()));
+
+ connect(ui_vp_objection, SIGNAL(done()), this, SLOT(objection_done()));
+ connect(ui_vp_player_char, SIGNAL(done()), this, SLOT(preanim_done()));
+
+ connect(text_delay_timer, SIGNAL(timeout()), this,
+ SLOT(start_chat_ticking()));
+ connect(sfx_delay_timer, SIGNAL(timeout()), this, SLOT(play_sfx()));
+
+ connect(chat_tick_timer, SIGNAL(timeout()), this, SLOT(chat_tick()));
+ connect(realization_timer, SIGNAL(timeout()), this, SLOT(realization_done()));
+
+ connect(ui_emote_left, SIGNAL(clicked()), this,
+ SLOT(on_emote_left_clicked()));
+ connect(ui_emote_right, SIGNAL(clicked()), this,
+ SLOT(on_emote_right_clicked()));
+
+ connect(ui_emote_dropdown, SIGNAL(activated(int)), this,
+ SLOT(on_emote_dropdown_changed(int)));
+ connect(ui_pos_dropdown, SIGNAL(currentIndexChanged(int)), this,
+ SLOT(on_pos_dropdown_changed(int)));
+
connect(ui_mute_list, SIGNAL(clicked(QModelIndex)), this,
SLOT(on_mute_list_clicked(QModelIndex)));
-
-
- connect(ui_ic_chat_message, SIGNAL(returnPressed()), this, SLOT(on_chat_return_pressed()));
-
- connect(ui_ooc_chat_message, SIGNAL(returnPressed()), this, SLOT(on_ooc_return_pressed()));
+
+ connect(ui_ic_chat_message, SIGNAL(returnPressed()), this,
+ SLOT(on_chat_return_pressed()));
+
+ connect(ui_ooc_chat_message, SIGNAL(returnPressed()), this,
+ SLOT(on_ooc_return_pressed()));
+
connect(ui_music_list, SIGNAL(itemDoubleClicked(QTreeWidgetItem *, int)),
this, SLOT(on_music_list_double_clicked(QTreeWidgetItem *, int)));
connect(ui_area_list, SIGNAL(doubleClicked(QModelIndex)), this,
SLOT(on_area_list_double_clicked(QModelIndex)));
- connect(ui_hold_it, SIGNAL(clicked()), this, SLOT(on_hold_it_clicked()));
- connect(ui_objection, SIGNAL(clicked()), this, SLOT(on_objection_clicked()));
- connect(ui_take_that, SIGNAL(clicked()), this, SLOT(on_take_that_clicked()));
-
- connect(ui_realization, SIGNAL(clicked()), this, SLOT(on_realization_clicked()));
- connect(ui_screenshake, SIGNAL(clicked()), this, SLOT(on_screenshake_clicked()));
+ connect(ui_hold_it, SIGNAL(clicked()), this, SLOT(on_hold_it_clicked()));
+ connect(ui_objection, SIGNAL(clicked()), this, SLOT(on_objection_clicked()));
+ connect(ui_take_that, SIGNAL(clicked()), this, SLOT(on_take_that_clicked()));
connect(ui_custom_objection, SIGNAL(clicked()), this,
SLOT(on_custom_objection_clicked()));
connect(ui_custom_objection,
SIGNAL(customContextMenuRequested(const QPoint &)), this,
SLOT(ShowContextMenu(const QPoint &)));
- connect(ui_mute, SIGNAL(clicked()), this, SLOT(on_mute_clicked()));
-
- connect(ui_defense_minus, SIGNAL(clicked()), this, SLOT(on_defense_minus_clicked()));
- connect(ui_defense_plus, SIGNAL(clicked()), this, SLOT(on_defense_plus_clicked()));
- connect(ui_prosecution_minus, SIGNAL(clicked()), this, SLOT(on_prosecution_minus_clicked()));
- connect(ui_prosecution_plus, SIGNAL(clicked()), this, SLOT(on_prosecution_plus_clicked()));
-
- connect(ui_text_color, SIGNAL(currentIndexChanged(int)), this, SLOT(on_text_color_changed(int)));
-
- connect(ui_music_slider, SIGNAL(valueChanged(int)), this, SLOT(on_music_slider_moved(int)));
- connect(ui_sfx_slider, SIGNAL(valueChanged(int)), this, SLOT(on_sfx_slider_moved(int)));
- connect(ui_blip_slider, SIGNAL(valueChanged(int)), this, SLOT(on_blip_slider_moved(int)));
-
- connect(ui_log_limit_spinbox, SIGNAL(valueChanged(int)), this, SLOT(on_log_limit_changed(int)));
-
- connect(ui_ooc_toggle, SIGNAL(clicked()), this, SLOT(on_ooc_toggle_clicked()));
-
- connect(ui_music_search, SIGNAL(textChanged(QString)), this, SLOT(on_music_search_edited(QString)));
-
- connect(ui_witness_testimony, SIGNAL(clicked()), this, SLOT(on_witness_testimony_clicked()));
- connect(ui_cross_examination, SIGNAL(clicked()), this, SLOT(on_cross_examination_clicked()));
- connect(ui_guilty, SIGNAL(clicked()), this, SLOT(on_guilty_clicked()));
- connect(ui_not_guilty, SIGNAL(clicked()), this, SLOT(on_not_guilty_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_call_mod, SIGNAL(clicked()), this, SLOT(on_call_mod_clicked()));
- connect(ui_settings, SIGNAL(clicked()), this, SLOT(on_settings_clicked()));
- connect(ui_announce_casing, SIGNAL(clicked()), this, SLOT(on_announce_casing_clicked()));
- connect(ui_switch_area_music, SIGNAL(clicked()), this, SLOT(on_switch_area_music_clicked()));
-
- connect(ui_pre, SIGNAL(clicked()), this, SLOT(on_pre_clicked()));
- connect(ui_flip, SIGNAL(clicked()), this, SLOT(on_flip_clicked()));
- connect(ui_guard, SIGNAL(clicked()), this, SLOT(on_guard_clicked()));
- connect(ui_casing, SIGNAL(clicked()), this, SLOT(on_casing_clicked()));
-
- connect(ui_showname_enable, SIGNAL(clicked()), this, SLOT(on_showname_enable_clicked()));
-
- connect(ui_pair_button, SIGNAL(clicked()), this, SLOT(on_pair_clicked()));
- connect(ui_pair_list, SIGNAL(clicked(QModelIndex)), this, SLOT(on_pair_list_clicked(QModelIndex)));
- connect(ui_pair_offset_spinbox, SIGNAL(valueChanged(int)), this, SLOT(on_pair_offset_changed(int)));
-
- connect(ui_evidence_button, SIGNAL(clicked()), this, SLOT(on_evidence_button_clicked()));
-
- set_widgets();
-
- set_char_select();
- detect_fallback_text();
-}
-
-void Courtroom::set_mute_list()
-{
- mute_map.clear();
-
- //maps which characters are muted based on cid, none are muted by default
- for (int n_cid = 0 ; n_cid < char_list.size() ; n_cid++)
- {
- mute_map.insert(n_cid, false);
- }
-
- QStringList sorted_mute_list;
-
- for (char_type i_char : char_list)
- sorted_mute_list.append(i_char.name);
-
- sorted_mute_list.sort();
-
- for (QString i_name : sorted_mute_list)
- {
- //mute_map.insert(i_name, false);
- ui_mute_list->addItem(i_name);
- }
-}
-
-void Courtroom::set_pair_list()
-{
- QStringList sorted_pair_list;
-
- for (char_type i_char : char_list)
- sorted_pair_list.append(i_char.name);
-
- sorted_pair_list.sort();
-
- for (QString i_name : sorted_pair_list)
- {
- ui_pair_list->addItem(i_name);
- }
-}
-
-void Courtroom::set_widgets()
-{
- blip_rate = ao_app->read_blip_rate();
- blank_blip = ao_app->get_blank_blip();
-
- QString filename = "courtroom_design.ini";
-
- pos_size_type f_courtroom = ao_app->get_element_dimensions("courtroom", filename);
-
- if (f_courtroom.width < 0 || f_courtroom.height < 0)
- {
- qDebug() << "W: did not find courtroom width or height in " << filename;
-
- this->resize(714, 668);
- }
- else
- {
- m_courtroom_width = f_courtroom.width;
- m_courtroom_height = f_courtroom.height;
-
- this->resize(f_courtroom.width, f_courtroom.height);
- }
-
- set_fonts();
-
- ui_background->move(0, 0);
- ui_background->resize(m_courtroom_width, m_courtroom_height);
- ui_background->set_image("courtroombackground.png");
-
- set_size_and_pos(ui_viewport, "viewport");
-
- // If there is a point to it, show all CCCC features.
- // We also do this this soon so that set_size_and_pos can hide them all later, if needed.
- if (ao_app->cccc_ic_support_enabled)
- {
- ui_pair_button->show();
- ui_pre_non_interrupt->show();
- ui_showname_enable->show();
- ui_ic_chat_name->show();
- ui_ic_chat_name->setEnabled(true);
- }
- else
- {
- ui_pair_button->hide();
- ui_pre_non_interrupt->hide();
- ui_showname_enable->hide();
- ui_ic_chat_name->hide();
- ui_ic_chat_name->setEnabled(false);
- }
-
- if (ao_app->casing_alerts_enabled)
- {
- ui_announce_casing->show();
- }
- else
- {
- ui_announce_casing->hide();
- }
-
- // We also show the non-server-dependent client additions.
- // Once again, if the theme can't display it, set_move_and_pos will catch them.
- ui_settings->show();
- ui_log_limit_label->show();
- ui_log_limit_spinbox->show();
-
- ui_vp_background->move(0, 0);
- ui_vp_background->resize(ui_viewport->width(), ui_viewport->height());
-
- ui_vp_speedlines->move(0, 0);
- ui_vp_speedlines->combo_resize(ui_viewport->width(), ui_viewport->height());
-
- ui_vp_player_char->move(0, 0);
- ui_vp_player_char->combo_resize(ui_viewport->width(), ui_viewport->height());
-
- ui_vp_sideplayer_char->move(0, 0);
- ui_vp_sideplayer_char->combo_resize(ui_viewport->width(), ui_viewport->height());
-
- //the AO2 desk element
- ui_vp_desk->move(0, 0);
- ui_vp_desk->resize(ui_viewport->width(), ui_viewport->height());
-
- //the size of the ui_vp_legacy_desk element relies on various factors and is set in set_scene()
-
- double y_modifier = 147.0 / 192.0;
- int final_y = static_cast<int>(y_modifier * ui_viewport->height());
- ui_vp_legacy_desk->move(0, final_y);
- ui_vp_legacy_desk->hide();
-
- ui_vp_evidence_display->move(0, 0);
- ui_vp_evidence_display->resize(ui_viewport->width(), ui_viewport->height());
-
- set_size_and_pos(ui_vp_showname, "showname");
-
- set_size_and_pos(ui_vp_message, "message");
- ui_vp_message->setTextInteractionFlags(Qt::NoTextInteraction);
- ui_vp_message->setStyleSheet("background-color: rgba(0, 0, 0, 0);"
- "color: white");
-
- ui_vp_testimony->move(ui_viewport->x(), ui_viewport->y());
+ connect(ui_realization, SIGNAL(clicked()), this,
+ SLOT(on_realization_clicked()));
+ connect(ui_screenshake, SIGNAL(clicked()), this,
+ SLOT(on_screenshake_clicked()));
+ connect(ui_mute, SIGNAL(clicked()), this, SLOT(on_mute_clicked()));
+
+ connect(ui_defense_minus, SIGNAL(clicked()), this,
+ SLOT(on_defense_minus_clicked()));
+ connect(ui_defense_plus, SIGNAL(clicked()), this,
+ SLOT(on_defense_plus_clicked()));
+ connect(ui_prosecution_minus, SIGNAL(clicked()), this,
+ SLOT(on_prosecution_minus_clicked()));
+ connect(ui_prosecution_plus, SIGNAL(clicked()), this,
+ SLOT(on_prosecution_plus_clicked()));
+
+ connect(ui_text_color, SIGNAL(currentIndexChanged(int)), this,
+ SLOT(on_text_color_changed(int)));
+
+ connect(ui_music_slider, SIGNAL(valueChanged(int)), this,
+ SLOT(on_music_slider_moved(int)));
+ connect(ui_sfx_slider, SIGNAL(valueChanged(int)), this,
+ SLOT(on_sfx_slider_moved(int)));
+ connect(ui_blip_slider, SIGNAL(valueChanged(int)), this,
+ SLOT(on_blip_slider_moved(int)));
+
+ connect(ui_log_limit_spinbox, SIGNAL(valueChanged(int)), this,
+ SLOT(on_log_limit_changed(int)));
+
+ connect(ui_ooc_toggle, SIGNAL(clicked()), this,
+ SLOT(on_ooc_toggle_clicked()));
+
+ connect(ui_music_search, SIGNAL(returnPressed()), this,
+ SLOT(on_music_search_keypr()));
+ connect(ui_music_search, SIGNAL(textChanged(QString)), this,
+ SLOT(on_music_search_edited(QString)));
+
+ connect(ui_witness_testimony, SIGNAL(clicked()), this,
+ SLOT(on_witness_testimony_clicked()));
+ connect(ui_cross_examination, SIGNAL(clicked()), this,
+ SLOT(on_cross_examination_clicked()));
+ connect(ui_guilty, SIGNAL(clicked()), this, SLOT(on_guilty_clicked()));
+ connect(ui_not_guilty, SIGNAL(clicked()), this,
+ SLOT(on_not_guilty_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_call_mod, SIGNAL(clicked()), this, SLOT(on_call_mod_clicked()));
+ connect(ui_settings, SIGNAL(clicked()), this, SLOT(on_settings_clicked()));
+ connect(ui_announce_casing, SIGNAL(clicked()), this,
+ SLOT(on_announce_casing_clicked()));
+ connect(ui_switch_area_music, SIGNAL(clicked()), this,
+ SLOT(on_switch_area_music_clicked()));
+
+ connect(ui_pre, SIGNAL(clicked()), this, SLOT(on_pre_clicked()));
+ connect(ui_flip, SIGNAL(clicked()), this, SLOT(on_flip_clicked()));
+ connect(ui_guard, SIGNAL(clicked()), this, SLOT(on_guard_clicked()));
+ connect(ui_casing, SIGNAL(clicked()), this, SLOT(on_casing_clicked()));
+
+ connect(ui_showname_enable, SIGNAL(clicked()), this,
+ SLOT(on_showname_enable_clicked()));
+
+ connect(ui_pair_button, SIGNAL(clicked()), this, SLOT(on_pair_clicked()));
+ connect(ui_pair_list, SIGNAL(clicked(QModelIndex)), this,
+ SLOT(on_pair_list_clicked(QModelIndex)));
+ connect(ui_pair_offset_spinbox, SIGNAL(valueChanged(int)), this,
+ SLOT(on_pair_offset_changed(int)));
+
+ connect(ui_evidence_button, SIGNAL(clicked()), this,
+ SLOT(on_evidence_button_clicked()));
+
+ set_widgets();
+
+ set_char_select();
+ detect_fallback_text();
+}
+
+void Courtroom::set_mute_list()
+{
+ mute_map.clear();
+
+ // maps which characters are muted based on cid, none are muted by default
+ for (int n_cid = 0; n_cid < char_list.size(); n_cid++) {
+ mute_map.insert(n_cid, false);
+ }
+
+ QStringList sorted_mute_list;
+
+ for (char_type i_char : char_list)
+ sorted_mute_list.append(i_char.name);
+
+ sorted_mute_list.sort();
+
+ for (QString i_name : sorted_mute_list) {
+ // mute_map.insert(i_name, false);
+ ui_mute_list->addItem(i_name);
+ }
+}
+
+void Courtroom::set_pair_list()
+{
+ QStringList sorted_pair_list;
+
+ for (char_type i_char : char_list)
+ sorted_pair_list.append(i_char.name);
+
+ sorted_pair_list.sort();
+
+ for (QString i_name : sorted_pair_list) {
+ ui_pair_list->addItem(i_name);
+ }
+}
+
+void Courtroom::set_widgets()
+{
+ blip_rate = ao_app->read_blip_rate();
+ blank_blip = ao_app->get_blank_blip();
+
+ QString filename = "courtroom_design.ini";
+
+ pos_size_type f_courtroom =
+ ao_app->get_element_dimensions("courtroom", filename);
+
+ if (f_courtroom.width < 0 || f_courtroom.height < 0) {
+ qDebug() << "W: did not find courtroom width or height in " << filename;
+
+ this->resize(714, 668);
+ }
+ else {
+ m_courtroom_width = f_courtroom.width;
+ m_courtroom_height = f_courtroom.height;
+
+ this->resize(f_courtroom.width, f_courtroom.height);
+ }
+
+ set_fonts();
+
+ ui_background->move(0, 0);
+ ui_background->resize(m_courtroom_width, m_courtroom_height);
+ ui_background->set_image("courtroombackground.png");
+
+ set_size_and_pos(ui_viewport, "viewport");
+
+ // If there is a point to it, show all CCCC features.
+ // We also do this this soon so that set_size_and_pos can hide them all later,
+ // if needed.
+ if (ao_app->cccc_ic_support_enabled) {
+ ui_pair_button->show();
+ ui_pre_non_interrupt->show();
+ ui_showname_enable->show();
+ ui_ic_chat_name->show();
+ ui_ic_chat_name->setEnabled(true);
+ }
+ else {
+ ui_pair_button->hide();
+ ui_pre_non_interrupt->hide();
+ ui_showname_enable->hide();
+ ui_ic_chat_name->hide();
+ ui_ic_chat_name->setEnabled(false);
+ }
+
+ if (ao_app->casing_alerts_enabled) {
+ ui_announce_casing->show();
+ }
+ else {
+ ui_announce_casing->hide();
+ }
+
+ // We also show the non-server-dependent client additions.
+ // Once again, if the theme can't display it, set_move_and_pos will catch
+ // them.
+ ui_settings->show();
+ ui_log_limit_label->show();
+ ui_log_limit_spinbox->show();
+
+ ui_vp_background->move(0, 0);
+ ui_vp_background->resize(ui_viewport->width(), ui_viewport->height());
+
+ ui_vp_speedlines->move(0, 0);
+ ui_vp_speedlines->combo_resize(ui_viewport->width(), ui_viewport->height());
+
+ ui_vp_player_char->move(0, 0);
+ ui_vp_player_char->combo_resize(ui_viewport->width(), ui_viewport->height());
+
+ ui_vp_sideplayer_char->move(0, 0);
+ ui_vp_sideplayer_char->combo_resize(ui_viewport->width(),
+ ui_viewport->height());
+
+ // the AO2 desk element
+ ui_vp_desk->move(0, 0);
+ ui_vp_desk->resize(ui_viewport->width(), ui_viewport->height());
+
+ // the size of the ui_vp_legacy_desk element relies on various factors and is
+ // set in set_scene()
+
+ double y_modifier = 147.0 / 192.0;
+ int final_y = static_cast<int>(y_modifier * ui_viewport->height());
+ ui_vp_legacy_desk->move(0, final_y);
+ ui_vp_legacy_desk->hide();
+
+ ui_vp_evidence_display->move(0, 0);
+ ui_vp_evidence_display->resize(ui_viewport->width(), ui_viewport->height());
+
+ set_size_and_pos(ui_vp_showname, "showname");
+
+ set_size_and_pos(ui_vp_message, "message");
+ ui_vp_message->setTextInteractionFlags(Qt::NoTextInteraction);
+ ui_vp_message->setStyleSheet("background-color: rgba(0, 0, 0, 0);"
+ "color: white");
+
+ ui_vp_testimony->move(ui_viewport->x(), ui_viewport->y());
ui_vp_testimony->combo_resize(ui_viewport->width(), ui_viewport->height());
-
- ui_vp_realization->move(ui_viewport->x(), ui_viewport->y());
+
+ ui_vp_realization->move(ui_viewport->x(), ui_viewport->y());
ui_vp_realization->combo_resize(ui_viewport->width(), ui_viewport->height());
-
- ui_vp_wtce->move(ui_viewport->x(), ui_viewport->y());
- ui_vp_wtce->combo_resize(ui_viewport->width(), ui_viewport->height());
-
- ui_vp_objection->move(ui_viewport->x(), ui_viewport->y());
- ui_vp_objection->combo_resize(ui_viewport->width(), ui_viewport->height());
-
- set_size_and_pos(ui_ic_chatlog, "ic_chatlog");
-
- set_size_and_pos(ui_ms_chatlog, "ms_chatlog");
-
- set_size_and_pos(ui_server_chatlog, "server_chatlog");
-
- set_size_and_pos(ui_mute_list, "mute_list");
- ui_mute_list->hide();
-
- set_size_and_pos(ui_pair_list, "pair_list");
- ui_pair_list->hide();
- set_size_and_pos(ui_pair_offset_spinbox, "pair_offset_spinbox");
- ui_pair_offset_spinbox->hide();
- set_size_and_pos(ui_pair_button, "pair_button");
- ui_pair_button->set_image("pair_button.png");
-
- set_size_and_pos(ui_area_list, "music_list");
- ui_area_list->setStyleSheet("background-color: rgba(0, 0, 0, 0);");
-
+
+ ui_vp_wtce->move(ui_viewport->x(), ui_viewport->y());
+ ui_vp_wtce->combo_resize(ui_viewport->width(), ui_viewport->height());
+
+ ui_vp_objection->move(ui_viewport->x(), ui_viewport->y());
+ ui_vp_objection->combo_resize(ui_viewport->width(), ui_viewport->height());
+
+ set_size_and_pos(ui_ic_chatlog, "ic_chatlog");
+
+ set_size_and_pos(ui_ms_chatlog, "ms_chatlog");
+
+ set_size_and_pos(ui_server_chatlog, "server_chatlog");
+
+ set_size_and_pos(ui_mute_list, "mute_list");
+ ui_mute_list->hide();
+
+ set_size_and_pos(ui_pair_list, "pair_list");
+ ui_pair_list->hide();
+ set_size_and_pos(ui_pair_offset_spinbox, "pair_offset_spinbox");
+ ui_pair_offset_spinbox->hide();
+ set_size_and_pos(ui_pair_button, "pair_button");
+ ui_pair_button->set_image("pair_button.png");
+
+ set_size_and_pos(ui_area_list, "music_list");
+ ui_area_list->setStyleSheet("background-color: rgba(0, 0, 0, 0);");
+
ui_music_list->setStyleSheet("background-color: rgba(100, 103, 132, 225);");
ui_music_list->collapseAll();
- set_size_and_pos(ui_music_list, "music_list");
-
- if (is_ao2_bg)
- {
- set_size_and_pos(ui_ic_chat_message, "ao2_ic_chat_message");
- set_size_and_pos(ui_vp_chatbox, "ao2_chatbox");
- set_size_and_pos(ui_ic_chat_name, "ao2_ic_chat_name");
- }
- else
- {
- set_size_and_pos(ui_ic_chat_message, "ic_chat_message");
- set_size_and_pos(ui_vp_chatbox, "chatbox");
- set_size_and_pos(ui_ic_chat_name, "ic_chat_name");
- }
-
- ui_ic_chat_message->setStyleSheet("QLineEdit{background-color: rgba(100, 100, 100, 255);}");
- ui_ic_chat_name->setStyleSheet("QLineEdit{background-color: rgba(180, 180, 180, 255);}");
-
- ui_vp_chatbox->set_image("chatmed.png");
- ui_vp_chatbox->hide();
-
- ui_muted->resize(ui_ic_chat_message->width(), ui_ic_chat_message->height());
- ui_muted->set_image("muted.png");
-
- 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");
-
- set_size_and_pos(ui_emotes, "emotes");
-
- 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_emote_dropdown, "emote_dropdown");
- set_size_and_pos(ui_pos_dropdown, "pos_dropdown");
-
- set_size_and_pos(ui_defense_bar, "defense_bar");
- ui_defense_bar->set_image("defensebar" + QString::number(defense_bar_state) + ".png");
-
- set_size_and_pos(ui_prosecution_bar, "prosecution_bar");
- ui_prosecution_bar->set_image("prosecutionbar" + QString::number(prosecution_bar_state) + ".png");
-
- set_size_and_pos(ui_music_label, "music_label");
- ui_music_label->setText(tr("Music"));
- set_size_and_pos(ui_sfx_label, "sfx_label");
- ui_sfx_label->setText(tr("Sfx"));
- set_size_and_pos(ui_blip_label, "blip_label");
- ui_blip_label->setText(tr("Blips"));
-
- set_size_and_pos(ui_log_limit_label, "log_limit_label");
- ui_log_limit_label->setText(tr("Log limit"));
-
- 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");
- if (ooc_toggle_fallback)
- {
- ui_ooc_toggle->setText(tr("Server"));
- }
- else
- {
- ui_ooc_toggle->set_image("ooc_toggle_server.png");
- ui_ooc_toggle->setText(tr(""));
- }
-
- 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_guilty, "guilty");
- ui_guilty->set_image("guilty.png");
- set_size_and_pos(ui_not_guilty, "not_guilty");
- ui_not_guilty->set_image("notguilty.png");
-
- set_size_and_pos(ui_change_character, "change_character");
- if (change_char_fallback)
- {
- ui_change_character->setText(tr("Change character"));
- }
- else
- {
- ui_change_character->set_image("change_character.png");
- ui_change_character->setText(tr("")); // set text to empty otherwise it just sits there
- }
-
- set_size_and_pos(ui_reload_theme, "reload_theme");
- if (reload_theme_fallback)
- {
- ui_reload_theme->setText(tr("Reload theme"));
- }
- else
- {
- ui_reload_theme->set_image("reload_theme.png");
- ui_reload_theme->setText(tr(""));
- }
-
- set_size_and_pos(ui_call_mod, "call_mod");
- if (call_mod_fallback)
- {
- ui_call_mod->setText(tr("Call mod"));
- }
- else
- {
- ui_call_mod->set_image("call_mod.png");
- ui_call_mod->setText(tr(""));
- }
-
- set_size_and_pos(ui_settings, "settings");
- if (settings_fallback)
- {
- ui_settings->setText(tr("Settings"));
- }
- else
- {
- ui_settings->set_image("settings.png");
- ui_settings->setText(tr(""));
- }
-
- set_size_and_pos(ui_announce_casing, "casing_button");
- if (casing_fallback)
- {
- ui_announce_casing->setText(tr("Casing"));
- }
- else
- {
- ui_announce_casing->set_image("casing.png");
- ui_announce_casing->setText(tr(""));
- }
-
- set_size_and_pos(ui_switch_area_music, "switch_area_music");
- if (amswap_fallback)
- {
- ui_switch_area_music->setText(tr("A/M"));
- }
- else
- {
- ui_switch_area_music->set_image("amswap.png");
- ui_switch_area_music->setText(tr(""));
- }
-
- set_size_and_pos(ui_pre, "pre");
- ui_pre->setText(tr("Preanim"));
-
- set_size_and_pos(ui_pre_non_interrupt, "pre_no_interrupt");
- set_size_and_pos(ui_flip, "flip");
-
- set_size_and_pos(ui_guard, "guard");
-
- set_size_and_pos(ui_casing, "casing");
-
- set_size_and_pos(ui_showname_enable, "showname_enable");
-
- set_size_and_pos(ui_custom_objection, "custom_objection");
- ui_custom_objection->set_image("custom.png");
-
- set_size_and_pos(ui_realization, "realization");
- ui_realization->set_image("realization.png");
-
- set_size_and_pos(ui_screenshake, "screenshake");
- ui_screenshake->set_image("screenshake.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");
-
- set_size_and_pos(ui_music_slider, "music_slider");
- set_size_and_pos(ui_sfx_slider, "sfx_slider");
- set_size_and_pos(ui_blip_slider, "blip_slider");
-
- set_size_and_pos(ui_log_limit_spinbox, "log_limit_spinbox");
-
- set_size_and_pos(ui_evidence_button, "evidence_button");
- ui_evidence_button->set_image("evidencebutton.png");
-
- set_size_and_pos(ui_evidence, "evidence_background");
- ui_evidence->set_image("evidencebackground.png");
-
- set_size_and_pos(ui_evidence_name, "evidence_name");
-
- set_size_and_pos(ui_evidence_buttons, "evidence_buttons");
-
- set_size_and_pos(ui_evidence_left, "evidence_left");
- ui_evidence_left->set_image("arrow_left.png");
-
- set_size_and_pos(ui_evidence_right, "evidence_right");
- ui_evidence_right->set_image("arrow_right.png");
-
- set_size_and_pos(ui_evidence_present, "evidence_present");
- ui_evidence_present->set_image("present_disabled.png");
-
- set_size_and_pos(ui_evidence_overlay, "evidence_overlay");
- ui_evidence_overlay->set_image("evidenceoverlay.png");
-
- set_size_and_pos(ui_evidence_delete, "evidence_delete");
- ui_evidence_delete->set_image("deleteevidence.png");
-
- set_size_and_pos(ui_evidence_image_name, "evidence_image_name");
-
- set_size_and_pos(ui_evidence_image_button, "evidence_image_button");
-
- set_size_and_pos(ui_evidence_x, "evidence_x");
- ui_evidence_x->set_image("evidencex.png");
-
- set_size_and_pos(ui_evidence_description, "evidence_description");
-
- ui_selector->set_image("char_selector.png");
- ui_selector->hide();
-
- set_size_and_pos(ui_back_to_lobby, "back_to_lobby");
- ui_back_to_lobby->setText(tr("Back to Lobby"));
-
- set_size_and_pos(ui_char_password, "char_password");
-
- set_size_and_pos(ui_char_buttons, "char_buttons");
-
- set_size_and_pos(ui_char_select_left, "char_select_left");
- ui_char_select_left->set_image("arrow_left.png");
-
- set_size_and_pos(ui_char_select_right, "char_select_right");
- ui_char_select_right->set_image("arrow_right.png");
-
- set_size_and_pos(ui_spectator, "spectator");
-}
-
-void Courtroom::set_fonts()
-{
- set_font(ui_vp_showname, "showname");
- set_font(ui_vp_message, "message");
- set_font(ui_ic_chatlog, "ic_chatlog");
- set_font(ui_ms_chatlog, "ms_chatlog");
- set_font(ui_server_chatlog, "server_chatlog");
- set_font(ui_music_list, "music_list");
+ set_size_and_pos(ui_music_list, "music_list");
+
+ if (is_ao2_bg) {
+ set_size_and_pos(ui_ic_chat_message, "ao2_ic_chat_message");
+ set_size_and_pos(ui_vp_chatbox, "ao2_chatbox");
+ set_size_and_pos(ui_ic_chat_name, "ao2_ic_chat_name");
+ }
+ else {
+ set_size_and_pos(ui_ic_chat_message, "ic_chat_message");
+ set_size_and_pos(ui_vp_chatbox, "chatbox");
+ set_size_and_pos(ui_ic_chat_name, "ic_chat_name");
+ }
+
+ ui_ic_chat_message->setStyleSheet(
+ "QLineEdit{background-color: rgba(100, 100, 100, 255);}");
+ ui_ic_chat_name->setStyleSheet(
+ "QLineEdit{background-color: rgba(180, 180, 180, 255);}");
+
+ ui_vp_chatbox->set_image("chatmed.png");
+ ui_vp_chatbox->hide();
+
+ ui_muted->resize(ui_ic_chat_message->width(), ui_ic_chat_message->height());
+ ui_muted->set_image("muted.png");
+
+ 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");
+
+ set_size_and_pos(ui_emotes, "emotes");
+
+ 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_emote_dropdown, "emote_dropdown");
+ set_size_and_pos(ui_pos_dropdown, "pos_dropdown");
+
+ set_size_and_pos(ui_defense_bar, "defense_bar");
+ ui_defense_bar->set_image("defensebar" + QString::number(defense_bar_state) +
+ ".png");
+
+ set_size_and_pos(ui_prosecution_bar, "prosecution_bar");
+ ui_prosecution_bar->set_image(
+ "prosecutionbar" + QString::number(prosecution_bar_state) + ".png");
+
+ set_size_and_pos(ui_music_label, "music_label");
+ ui_music_label->setText(tr("Music"));
+ set_size_and_pos(ui_sfx_label, "sfx_label");
+ ui_sfx_label->setText(tr("Sfx"));
+ set_size_and_pos(ui_blip_label, "blip_label");
+ ui_blip_label->setText(tr("Blips"));
+
+ set_size_and_pos(ui_log_limit_label, "log_limit_label");
+ ui_log_limit_label->setText(tr("Log limit"));
+
+ 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");
+ if (ooc_toggle_fallback) {
+ ui_ooc_toggle->setText(tr("Server"));
+ }
+ else {
+ ui_ooc_toggle->set_image("ooc_toggle_server.png");
+ ui_ooc_toggle->setText(tr(""));
+ }
+
+ 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_guilty, "guilty");
+ ui_guilty->set_image("guilty.png");
+ set_size_and_pos(ui_not_guilty, "not_guilty");
+ ui_not_guilty->set_image("notguilty.png");
+
+ set_size_and_pos(ui_change_character, "change_character");
+ if (change_char_fallback) {
+ ui_change_character->setText(tr("Change character"));
+ }
+ else {
+ ui_change_character->set_image("change_character.png");
+ ui_change_character->setText(
+ tr("")); // set text to empty otherwise it just sits there
+ }
+
+ set_size_and_pos(ui_reload_theme, "reload_theme");
+ if (reload_theme_fallback) {
+ ui_reload_theme->setText(tr("Reload theme"));
+ }
+ else {
+ ui_reload_theme->set_image("reload_theme.png");
+ ui_reload_theme->setText(tr(""));
+ }
+
+ set_size_and_pos(ui_call_mod, "call_mod");
+ if (call_mod_fallback) {
+ ui_call_mod->setText(tr("Call mod"));
+ }
+ else {
+ ui_call_mod->set_image("call_mod.png");
+ ui_call_mod->setText(tr(""));
+ }
+
+ set_size_and_pos(ui_settings, "settings");
+ if (settings_fallback) {
+ ui_settings->setText(tr("Settings"));
+ }
+ else {
+ ui_settings->set_image("settings.png");
+ ui_settings->setText(tr(""));
+ }
+
+ set_size_and_pos(ui_announce_casing, "casing_button");
+ if (casing_fallback) {
+ ui_announce_casing->setText(tr("Casing"));
+ }
+ else {
+ ui_announce_casing->set_image("casing.png");
+ ui_announce_casing->setText(tr(""));
+ }
+
+ set_size_and_pos(ui_switch_area_music, "switch_area_music");
+ if (amswap_fallback) {
+ ui_switch_area_music->setText(tr("A/M"));
+ }
+ else {
+ ui_switch_area_music->set_image("amswap.png");
+ ui_switch_area_music->setText(tr(""));
+ }
+
+ set_size_and_pos(ui_pre, "pre");
+ ui_pre->setText(tr("Preanim"));
+
+ set_size_and_pos(ui_pre_non_interrupt, "pre_no_interrupt");
+ set_size_and_pos(ui_flip, "flip");
+
+ set_size_and_pos(ui_guard, "guard");
+
+ set_size_and_pos(ui_casing, "casing");
+
+ set_size_and_pos(ui_showname_enable, "showname_enable");
+
+ set_size_and_pos(ui_custom_objection, "custom_objection");
+ ui_custom_objection->set_image("custom.png");
+
+ set_size_and_pos(ui_realization, "realization");
+ ui_realization->set_image("realization.png");
+
+ set_size_and_pos(ui_screenshake, "screenshake");
+ ui_screenshake->set_image("screenshake.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");
+
+ set_size_and_pos(ui_music_slider, "music_slider");
+ set_size_and_pos(ui_sfx_slider, "sfx_slider");
+ set_size_and_pos(ui_blip_slider, "blip_slider");
+
+ set_size_and_pos(ui_log_limit_spinbox, "log_limit_spinbox");
+
+ set_size_and_pos(ui_evidence_button, "evidence_button");
+ ui_evidence_button->set_image("evidencebutton.png");
+
+ set_size_and_pos(ui_evidence, "evidence_background");
+ ui_evidence->set_image("evidencebackground.png");
+
+ set_size_and_pos(ui_evidence_name, "evidence_name");
+
+ set_size_and_pos(ui_evidence_buttons, "evidence_buttons");
+
+ set_size_and_pos(ui_evidence_left, "evidence_left");
+ ui_evidence_left->set_image("arrow_left.png");
+
+ set_size_and_pos(ui_evidence_right, "evidence_right");
+ ui_evidence_right->set_image("arrow_right.png");
+
+ set_size_and_pos(ui_evidence_present, "evidence_present");
+ ui_evidence_present->set_image("present_disabled.png");
+
+ set_size_and_pos(ui_evidence_overlay, "evidence_overlay");
+ ui_evidence_overlay->set_image("evidenceoverlay.png");
+
+ set_size_and_pos(ui_evidence_delete, "evidence_delete");
+ ui_evidence_delete->set_image("deleteevidence.png");
+
+ set_size_and_pos(ui_evidence_image_name, "evidence_image_name");
+
+ set_size_and_pos(ui_evidence_image_button, "evidence_image_button");
+
+ set_size_and_pos(ui_evidence_x, "evidence_x");
+ ui_evidence_x->set_image("evidencex.png");
+
+ set_size_and_pos(ui_evidence_description, "evidence_description");
+
+ ui_selector->set_image("char_selector.png");
+ ui_selector->hide();
+
+ set_size_and_pos(ui_back_to_lobby, "back_to_lobby");
+ ui_back_to_lobby->setText(tr("Back to Lobby"));
+
+ set_size_and_pos(ui_char_password, "char_password");
+
+ set_size_and_pos(ui_char_buttons, "char_buttons");
+
+ set_size_and_pos(ui_char_select_left, "char_select_left");
+ ui_char_select_left->set_image("arrow_left.png");
+
+ set_size_and_pos(ui_char_select_right, "char_select_right");
+ ui_char_select_right->set_image("arrow_right.png");
+
+ set_size_and_pos(ui_spectator, "spectator");
+}
+
+void Courtroom::set_fonts()
+{
+ set_font(ui_vp_showname, "showname");
+ set_font(ui_vp_message, "message");
+ set_font(ui_ic_chatlog, "ic_chatlog");
+ set_font(ui_ms_chatlog, "ms_chatlog");
+ set_font(ui_server_chatlog, "server_chatlog");
+ set_font(ui_music_list, "music_list");
set_font(ui_area_list, "area_list");
-
- // Set color of labels and checkboxes
- const QString design_file = "courtroom_fonts.ini";
- QColor f_color = ao_app->get_color("label_color", design_file);
- QString color_string = "color: rgba(" +
- QString::number(f_color.red()) + ", " +
- QString::number(f_color.green()) + ", " +
- QString::number(f_color.blue()) + ", 255); }";
- QString style_sheet_string = "QLabel {" + color_string + "}"
- "QCheckBox {" + color_string + "}";
- setStyleSheet(style_sheet_string);
-}
-
-void Courtroom::set_font(QWidget *widget, QString p_identifier)
-{
- QString design_file = "courtroom_fonts.ini";
- int f_weight = ao_app->get_font_size(p_identifier, design_file);
- QString class_name = widget->metaObject()->className();
-
- QString fontt = ao_app->get_font_name(p_identifier + "_font", design_file);
- widget->setFont(QFont(fontt, f_weight));
-
-
- QColor f_color = ao_app->get_color(p_identifier + "_color", design_file);
-
- QString style_sheet_string = class_name + " { background-color: rgba(0, 0, 0, 0);\n" +
- "color: rgba(" +
- QString::number(f_color.red()) + ", " +
- QString::number(f_color.green()) + ", " +
- QString::number(f_color.blue()) + ", 255); }";
-
- widget->setStyleSheet(style_sheet_string);
-}
-
-void Courtroom::set_window_title(QString p_title)
-{
- this->setWindowTitle(p_title);
-}
-
-void Courtroom::set_size_and_pos(QWidget *p_widget, QString p_identifier)
-{
- QString filename = "courtroom_design.ini";
-
- pos_size_type design_ini_result = ao_app->get_element_dimensions(p_identifier, filename);
-
- if (design_ini_result.width < 0 || design_ini_result.height < 0)
- {
- qDebug() << "W: could not find \"" << p_identifier << "\" in " << filename;
- p_widget->hide();
- }
- else
- {
- p_widget->move(design_ini_result.x, design_ini_result.y);
- p_widget->resize(design_ini_result.width, design_ini_result.height);
- }
-}
-
-QPoint Courtroom::get_theme_pos(QString p_identifier)
-{
- QString filename = "courtroom_design.ini";
-
- pos_size_type design_ini_result = ao_app->get_element_dimensions(p_identifier, filename);
-
- if (design_ini_result.width < 0 || design_ini_result.height < 0)
- {
- qDebug() << "W: could not find \"" << p_identifier << "\" in " << filename;
- return QPoint(0,0);
- }
- else
- {
- return QPoint(design_ini_result.x, design_ini_result.y);
- }
-}
-
-
-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;
- f_char.evidence_string = char_list.at(n_char).evidence_string;
-
- char_list.replace(n_char, f_char);
-}
-
-void Courtroom::done_received()
-{
- m_cid = -1;
-
- music_player->set_volume(0);
- sfx_player->set_volume(0);
- objection_player->set_volume(0);
- blip_player->set_volume(0);
-
- set_char_select_page();
-
- set_mute_list();
- set_pair_list();
-
- set_char_select();
-
- show();
-
- ui_spectator->show();
-}
-
-void Courtroom::set_background(QString p_background)
-{
+
+ // Set color of labels and checkboxes
+ const QString design_file = "courtroom_fonts.ini";
+ QColor f_color = ao_app->get_color("label_color", design_file);
+ QString color_string = "color: rgba(" + QString::number(f_color.red()) +
+ ", " + QString::number(f_color.green()) + ", " +
+ QString::number(f_color.blue()) + ", 255); }";
+ QString style_sheet_string = "QLabel {" + color_string +
+ "}"
+ "QCheckBox {" +
+ color_string + "}";
+ setStyleSheet(style_sheet_string);
+}
+
+void Courtroom::set_font(QWidget *widget, QString p_identifier)
+{
+ QString design_file = "courtroom_fonts.ini";
+ int f_weight = ao_app->get_font_size(p_identifier, design_file);
+ QString class_name = widget->metaObject()->className();
+
+ QString fontt = ao_app->get_font_name(p_identifier + "_font", design_file);
+ widget->setFont(QFont(fontt, f_weight));
+
+ QColor f_color = ao_app->get_color(p_identifier + "_color", design_file);
+
+ QString style_sheet_string =
+ class_name + " { background-color: rgba(0, 0, 0, 0);\n" + "color: rgba(" +
+ QString::number(f_color.red()) + ", " + QString::number(f_color.green()) +
+ ", " + QString::number(f_color.blue()) + ", 255); }";
+
+ widget->setStyleSheet(style_sheet_string);
+}
+
+void Courtroom::set_window_title(QString p_title)
+{
+ this->setWindowTitle(p_title);
+}
+
+void Courtroom::set_size_and_pos(QWidget *p_widget, QString p_identifier)
+{
+ QString filename = "courtroom_design.ini";
+
+ pos_size_type design_ini_result =
+ ao_app->get_element_dimensions(p_identifier, filename);
+
+ if (design_ini_result.width < 0 || design_ini_result.height < 0) {
+ qDebug() << "W: could not find \"" << p_identifier << "\" in " << filename;
+ p_widget->hide();
+ }
+ else {
+ p_widget->move(design_ini_result.x, design_ini_result.y);
+ p_widget->resize(design_ini_result.width, design_ini_result.height);
+ }
+}
+
+QPoint Courtroom::get_theme_pos(QString p_identifier)
+{
+ QString filename = "courtroom_design.ini";
+
+ pos_size_type design_ini_result =
+ ao_app->get_element_dimensions(p_identifier, filename);
+
+ if (design_ini_result.width < 0 || design_ini_result.height < 0) {
+ qDebug() << "W: could not find \"" << p_identifier << "\" in " << filename;
+ return QPoint(0, 0);
+ }
+ else {
+ return QPoint(design_ini_result.x, design_ini_result.y);
+ }
+}
+
+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;
+ f_char.evidence_string = char_list.at(n_char).evidence_string;
+
+ char_list.replace(n_char, f_char);
+}
+
+void Courtroom::done_received()
+{
+ m_cid = -1;
+
+ music_player->set_volume(0);
+ sfx_player->set_volume(0);
+ objection_player->set_volume(0);
+ blip_player->set_volume(0);
+
+ set_char_select_page();
+
+ set_mute_list();
+ set_pair_list();
+
+ set_char_select();
+
+ show();
+
+ ui_spectator->show();
+}
+
+void Courtroom::set_background(QString p_background)
+{
ui_vp_testimony->stop();
-
- current_background = p_background;
-
- is_ao2_bg = file_exists(ao_app->get_background_path("defensedesk.png")) &&
- file_exists(ao_app->get_background_path("prosecutiondesk.png")) &&
- file_exists(ao_app->get_background_path("stand.png"));
-
- if (is_ao2_bg)
- {
- set_size_and_pos(ui_vp_chatbox, "ao2_chatbox");
- set_size_and_pos(ui_ic_chat_message, "ao2_ic_chat_message");
- }
- else
- {
- set_size_and_pos(ui_vp_chatbox, "chatbox");
- set_size_and_pos(ui_ic_chat_message, "ic_chat_message");
- }
-}
-
-void Courtroom::set_character(int char_id)
-{
- m_cid = char_id;
-
- QString f_char;
-
- if (m_cid == -1)
- {
- if (ao_app->is_discord_enabled())
- ao_app->discord->state_spectate();
- f_char = "";
- }
- else
- {
- f_char = ao_app->get_char_name(char_list.at(m_cid).name);
-
- if (ao_app->is_discord_enabled())
- ao_app->discord->state_character(f_char.toStdString());
- }
-
- current_char = f_char;
-
- current_emote_page = 0;
- current_emote = 0;
-
- if (m_cid == -1)
- ui_emotes->hide();
- else
- ui_emotes->show();
-
- set_emote_page();
- set_emote_dropdown();
-
- if (ao_app->custom_objection_enabled &&
- (file_exists(ao_app->get_character_path(current_char, "custom.gif")) ||
- file_exists(ao_app->get_character_path(current_char, "custom.apng"))) &&
- file_exists(ao_app->get_character_path(current_char, "custom.wav")))
- ui_custom_objection->show();
- else
- ui_custom_objection->hide();
-}
-
-void Courtroom::enter_courtroom(int p_cid)
-{
- this->set_character(p_cid);
-
- current_evidence_page = 0;
- current_evidence = 0;
-
- set_evidence_page();
-
- QString side = ao_app->get_char_side(current_char);
-
- // We block signals from ui_pos_dropdown to stop on_pos_dropdown_changed from firing here.
- // Per the Qt docs, QSignalBlocker only affects the rest of this function,
- // so it doesn't stop the dropdown from working once we finish here.
- const QSignalBlocker blocker(ui_pos_dropdown);
- ui_pos_dropdown->setCurrentText(side);
-
- if (side == "jud")
- {
- ui_witness_testimony->show();
- ui_cross_examination->show();
- ui_not_guilty->show();
- ui_guilty->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_guilty->hide();
- ui_not_guilty->hide();
- ui_defense_minus->hide();
- ui_defense_plus->hide();
- ui_prosecution_minus->hide();
- ui_prosecution_plus->hide();
- }
-
+
+ current_background = p_background;
+
+ is_ao2_bg = file_exists(ao_app->get_background_path("defensedesk.png")) &&
+ file_exists(ao_app->get_background_path("prosecutiondesk.png")) &&
+ file_exists(ao_app->get_background_path("stand.png"));
+
+ if (is_ao2_bg) {
+ set_size_and_pos(ui_vp_chatbox, "ao2_chatbox");
+ set_size_and_pos(ui_ic_chat_message, "ao2_ic_chat_message");
+ }
+ else {
+ set_size_and_pos(ui_vp_chatbox, "chatbox");
+ set_size_and_pos(ui_ic_chat_message, "ic_chat_message");
+ }
+}
+
+void Courtroom::set_character(int char_id)
+{
+ m_cid = char_id;
+
+ QString f_char;
+
+ if (m_cid == -1) {
+ if (ao_app->is_discord_enabled())
+ ao_app->discord->state_spectate();
+ f_char = "";
+ }
+ else {
+ f_char = ao_app->get_char_name(char_list.at(m_cid).name);
+
+ if (ao_app->is_discord_enabled())
+ ao_app->discord->state_character(f_char.toStdString());
+ }
+
+ current_char = f_char;
+
+ current_emote_page = 0;
+ current_emote = 0;
+
+ if (m_cid == -1)
+ ui_emotes->hide();
+ else
+ ui_emotes->show();
+
+ set_emote_page();
+ set_emote_dropdown();
+
+ if (ao_app->custom_objection_enabled &&
+ (file_exists(ao_app->get_character_path(current_char, "custom.gif")) ||
+ file_exists(ao_app->get_character_path(current_char, "custom.apng"))) &&
+ file_exists(ao_app->get_character_path(current_char, "custom.wav")))
+ ui_custom_objection->show();
+ else
+ ui_custom_objection->hide();
+}
+
+void Courtroom::enter_courtroom(int p_cid)
+{
+ this->set_character(p_cid);
+ current_evidence_page = 0;
+ current_evidence = 0;
+
+ set_evidence_page();
+
+ QString side = ao_app->get_char_side(current_char);
+
+ // We block signals from ui_pos_dropdown to stop on_pos_dropdown_changed from
+ // firing here. Per the Qt docs, QSignalBlocker only affects the rest of this
+ // function, so it doesn't stop the dropdown from working once we finish here.
+ const QSignalBlocker blocker(ui_pos_dropdown);
+ ui_pos_dropdown->setCurrentText(side);
+
+ if (side == "jud") {
+
+ ui_witness_testimony->show();
+ ui_cross_examination->show();
+ ui_not_guilty->show();
+ ui_guilty->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_guilty->hide();
+ ui_not_guilty->hide();
+ ui_defense_minus->hide();
+ ui_defense_plus->hide();
+ ui_prosecution_minus->hide();
+ ui_prosecution_plus->hide();
+ }
+
if (ao_app->custom_objection_enabled && // if setting is enabled
(file_exists(ao_app->get_image_suffix(
ao_app->get_character_path(current_char, "custom"))) &&
file_exists(ao_app->get_character_path(current_char, "custom.wav")))) {
- ui_custom_objection->show();
+ ui_custom_objection->show();
if (dir_exists(
ao_app->get_character_path(current_char, "custom_objections"))) {
custom_obj_menu->clear();
@@ -1059,69 +1063,69 @@ void Courtroom::enter_courtroom(int p_cid)
}
}
}
- else
- ui_custom_objection->hide();
-
- if (ao_app->flipping_enabled)
- ui_flip->show();
- else
- ui_flip->hide();
-
- if (ao_app->casing_alerts_enabled)
- ui_casing->show();
- else
- ui_casing->hide();
-
- list_music();
- list_areas();
-
- music_player->set_volume(ui_music_slider->value());
- sfx_player->set_volume(ui_sfx_slider->value());
- objection_player->set_volume(ui_sfx_slider->value());
- misc_sfx_player->set_volume(ui_sfx_slider->value());
- frame_emote_sfx_player->set_volume(ui_sfx_slider->value());
- pair_frame_emote_sfx_player->set_volume(ui_sfx_slider->value());
- blip_player->set_volume(ui_blip_slider->value());
-
+ else
+ ui_custom_objection->hide();
+
+ if (ao_app->flipping_enabled)
+ ui_flip->show();
+ else
+ ui_flip->hide();
+
+ if (ao_app->casing_alerts_enabled)
+ ui_casing->show();
+ else
+ ui_casing->hide();
+
+ list_music();
+ list_areas();
+
+ music_player->set_volume(ui_music_slider->value());
+ sfx_player->set_volume(ui_sfx_slider->value());
+ objection_player->set_volume(ui_sfx_slider->value());
+ misc_sfx_player->set_volume(ui_sfx_slider->value());
+ frame_emote_sfx_player->set_volume(ui_sfx_slider->value());
+ pair_frame_emote_sfx_player->set_volume(ui_sfx_slider->value());
+ blip_player->set_volume(ui_blip_slider->value());
+
misc_sfx_player->set_volume(ui_sfx_slider->value());
frame_emote_sfx_player->set_volume(ui_sfx_slider->value());
pair_frame_emote_sfx_player->set_volume(ui_sfx_slider->value());
ui_vp_testimony->stop();
-
- set_widgets();
-
- //ui_server_chatlog->setHtml(ui_server_chatlog->toHtml());
-
- ui_char_select_background->hide();
-
- ui_ic_chat_message->setEnabled(m_cid != -1);
- ui_ic_chat_message->setFocus();
-}
-
-void Courtroom::list_music()
-{
- ui_music_list->clear();
-
- QString f_file = "courtroom_design.ini";
-
- QBrush found_brush(ao_app->get_color("found_song_color", f_file));
- QBrush missing_brush(ao_app->get_color("missing_song_color", f_file));
-
- int n_listed_songs = 0;
-
+
+ set_widgets();
+
+ // ui_server_chatlog->setHtml(ui_server_chatlog->toHtml());
+
+ ui_char_select_background->hide();
+
+ ui_ic_chat_message->setEnabled(m_cid != -1);
+ ui_ic_chat_message->setFocus();
+}
+
+void Courtroom::list_music()
+{
+ ui_music_list->clear();
+
+ QString f_file = "courtroom_design.ini";
+
+ QBrush found_brush(ao_app->get_color("found_song_color", f_file));
+ QBrush missing_brush(ao_app->get_color("missing_song_color", f_file));
+
+ int n_listed_songs = 0;
+
QTreeWidgetItem *parent = nullptr;
for (int n_song = 0; n_song < music_list.size(); ++n_song) {
- QString i_song = music_list.at(n_song);
+ QString i_song = music_list.at(n_song);
QString i_song_listname = i_song.left(i_song.lastIndexOf("."));
i_song_listname = i_song_listname.right(
i_song_listname.length() - (i_song_listname.lastIndexOf("/") + 1));
-
+
QTreeWidgetItem *treeItem;
if (i_song_listname != i_song && parent != nullptr &&
i_song.toLower().contains(
ui_music_search->text().toLower())) // not a category, parent exists
- {
+ {
treeItem = new QTreeWidgetItem(parent);
treeItem->setText(0, i_song_listname);
treeItem->setText(1, i_song);
@@ -1142,620 +1146,666 @@ void Courtroom::list_music()
treeItem = new QTreeWidgetItem(ui_music_list);
treeItem->setText(0, i_song_listname);
treeItem->setText(1, i_song);
-
- QString song_path = ao_app->get_music_path(i_song);
-
- if (file_exists(song_path))
+
+ QString song_path = ao_app->get_music_path(i_song);
+
+ if (file_exists(song_path))
treeItem->setBackground(0, found_brush);
- else
+ else
treeItem->setBackground(0, missing_brush);
-
+
if (i_song_listname ==
i_song) // Not supposed to be a song to begin with - a category?
parent = treeItem;
- ++n_listed_songs;
- }
- }
+ ++n_listed_songs;
+ }
+ }
ui_music_list->expandAll(); // Needs to somehow remember which categories were
// expanded/collapsed if the music list didn't
// change since last time
-}
-
-void Courtroom::list_areas()
-{
- ui_area_list->clear();
- area_row_to_number.clear();
-
- QString f_file = "courtroom_design.ini";
-
- QBrush free_brush(ao_app->get_color("area_free_color", f_file));
- QBrush lfp_brush(ao_app->get_color("area_lfp_color", f_file));
- QBrush casing_brush(ao_app->get_color("area_casing_color", f_file));
- QBrush recess_brush(ao_app->get_color("area_recess_color", f_file));
- QBrush rp_brush(ao_app->get_color("area_rp_color", f_file));
- QBrush gaming_brush(ao_app->get_color("area_gaming_color", f_file));
- QBrush locked_brush(ao_app->get_color("area_locked_color", f_file));
-
- int n_listed_areas = 0;
-
- for (int n_area = 0 ; n_area < area_list.size() ; ++n_area)
- {
- QString i_area = "";
-// i_area.append("[");
-// i_area.append(QString::number(n_area));
-// i_area.append("] ");
-
- i_area.append(area_list.at(n_area));
-
- if (ao_app->arup_enabled)
- {
- i_area.append("\n ");
-
- i_area.append(arup_statuses.at(n_area));
- i_area.append(" | CM: ");
- i_area.append(arup_cms.at(n_area));
-
- i_area.append("\n ");
-
- i_area.append(QString::number(arup_players.at(n_area)));
- i_area.append(" users | ");
-
- i_area.append(arup_locks.at(n_area));
- }
-
- if (i_area.toLower().contains(ui_music_search->text().toLower()))
- {
- ui_area_list->addItem(i_area);
- area_row_to_number.append(n_area);
-
- if (ao_app->arup_enabled)
- {
- // Colouring logic here.
- ui_area_list->item(n_listed_areas)->setBackground(free_brush);
- if (arup_locks.at(n_area) == "LOCKED")
- {
- ui_area_list->item(n_listed_areas)->setBackground(locked_brush);
- }
- else
- {
- if (arup_statuses.at(n_area) == "LOOKING-FOR-PLAYERS")
- ui_area_list->item(n_listed_areas)->setBackground(lfp_brush);
- else if (arup_statuses.at(n_area) == "CASING")
- ui_area_list->item(n_listed_areas)->setBackground(casing_brush);
- else if (arup_statuses.at(n_area) == "RECESS")
- ui_area_list->item(n_listed_areas)->setBackground(recess_brush);
- else if (arup_statuses.at(n_area) == "RP")
- ui_area_list->item(n_listed_areas)->setBackground(rp_brush);
- else if (arup_statuses.at(n_area) == "GAMING")
- ui_area_list->item(n_listed_areas)->setBackground(gaming_brush);
- }
- }
- else
- {
- ui_area_list->item(n_listed_areas)->setBackground(free_brush);
- }
-
- ++n_listed_areas;
- }
- }
-}
-
-void Courtroom::append_ms_chatmessage(QString f_name, QString f_message)
-{
- ui_ms_chatlog->append_chatmessage(f_name, f_message, ao_app->get_color("ooc_default_color", "courtroom_design.ini").name());
-}
-
-void Courtroom::append_server_chatmessage(QString p_name, QString p_message, QString p_colour)
-{
- QString colour = "#000000";
-
- if (p_colour == "0")
- colour = ao_app->get_color("ooc_default_color", "courtroom_design.ini").name();
- if (p_colour == "1")
- colour = ao_app->get_color("ooc_server_color", "courtroom_design.ini").name();
- if(p_message == "Logged in as a moderator.")
- {
- ui_guard->show();
- append_server_chatmessage("CLIENT", tr("You were granted the Disable Modcalls button."), "1");
- }
-
+}
+
+void Courtroom::list_areas()
+{
+ ui_area_list->clear();
+ area_row_to_number.clear();
+
+ QString f_file = "courtroom_design.ini";
+
+ QBrush free_brush(ao_app->get_color("area_free_color", f_file));
+ QBrush lfp_brush(ao_app->get_color("area_lfp_color", f_file));
+ QBrush casing_brush(ao_app->get_color("area_casing_color", f_file));
+ QBrush recess_brush(ao_app->get_color("area_recess_color", f_file));
+ QBrush rp_brush(ao_app->get_color("area_rp_color", f_file));
+ QBrush gaming_brush(ao_app->get_color("area_gaming_color", f_file));
+ QBrush locked_brush(ao_app->get_color("area_locked_color", f_file));
+
+ int n_listed_areas = 0;
+
+ for (int n_area = 0; n_area < area_list.size(); ++n_area) {
+ QString i_area = "";
+
+ // i_area.append("[");
+ // i_area.append(QString::number(n_area));
+ // i_area.append("] ");
+
+ i_area.append(area_list.at(n_area));
+
+ if (ao_app->arup_enabled) {
+ i_area.append("\n ");
+
+ i_area.append(arup_statuses.at(n_area));
+ i_area.append(" | CM: ");
+ i_area.append(arup_cms.at(n_area));
+
+ i_area.append("\n ");
+
+ i_area.append(QString::number(arup_players.at(n_area)));
+ i_area.append(" users | ");
+
+ i_area.append(arup_locks.at(n_area));
+ }
+
+ if (i_area.toLower().contains(ui_music_search->text().toLower())) {
+ ui_area_list->addItem(i_area);
+ area_row_to_number.append(n_area);
+
+ if (ao_app->arup_enabled) {
+ // Colouring logic here.
+ ui_area_list->item(n_listed_areas)->setBackground(free_brush);
+ if (arup_locks.at(n_area) == "LOCKED") {
+ ui_area_list->item(n_listed_areas)->setBackground(locked_brush);
+ }
+ else {
+ if (arup_statuses.at(n_area) == "LOOKING-FOR-PLAYERS")
+ ui_area_list->item(n_listed_areas)->setBackground(lfp_brush);
+ else if (arup_statuses.at(n_area) == "CASING")
+ ui_area_list->item(n_listed_areas)->setBackground(casing_brush);
+ else if (arup_statuses.at(n_area) == "RECESS")
+ ui_area_list->item(n_listed_areas)->setBackground(recess_brush);
+ else if (arup_statuses.at(n_area) == "RP")
+ ui_area_list->item(n_listed_areas)->setBackground(rp_brush);
+ else if (arup_statuses.at(n_area) == "GAMING")
+ ui_area_list->item(n_listed_areas)->setBackground(gaming_brush);
+ }
+ }
+ else {
+ ui_area_list->item(n_listed_areas)->setBackground(free_brush);
+ }
+
+ ++n_listed_areas;
+ }
+ }
+}
+
+void Courtroom::append_ms_chatmessage(QString f_name, QString f_message)
+{
+ ui_ms_chatlog->append_chatmessage(
+ f_name, f_message,
+ ao_app->get_color("ooc_default_color", "courtroom_design.ini").name(),
+ false);
+}
+
+void Courtroom::append_server_chatmessage(QString p_name, QString p_message,
+ QString p_colour)
+{
+ QString colour = "#000000";
+
+ if (p_colour == "0")
+ colour =
+ ao_app->get_color("ooc_default_color", "courtroom_design.ini").name();
+ if (p_colour == "1")
+
+ colour =
+ ao_app->get_color("ooc_server_color", "courtroom_design.ini").name();
+ if (p_message == "Logged in as a moderator.") {
+ ui_guard->show();
+ append_server_chatmessage(
+ "CLIENT", tr("You were granted the Disable Modcalls button."), "1");
+ }
+
ui_server_chatlog->append_chatmessage(p_name, p_message, colour, false);
-}
-
-void Courtroom::detect_fallback_text()
-{
- QString change_char_path = ao_app->get_theme_path("change_character.png");
- QString reload_theme_path = ao_app->get_theme_path("reload_theme.png");
- QString settings_path = ao_app->get_theme_path("settings.png");
- QString call_mod_path = ao_app->get_theme_path("call_mod.png");
- QString casing_path = ao_app->get_theme_path("casing.png");
- QString amswap_path = ao_app->get_theme_path("amswap.png");
- QString ooc_toggle_path = ao_app->get_theme_path("ooc_toggle_ms.png");
-
- if (file_exists(change_char_path)) {change_char_fallback = false;}
- else {change_char_fallback = true;}
- if (file_exists(reload_theme_path)) {reload_theme_fallback = false;}
- else {reload_theme_fallback = true;}
- if (file_exists(settings_path)) {settings_fallback = false;}
- else {settings_fallback = true;}
- if (file_exists(call_mod_path)) {call_mod_fallback = false;}
- else {call_mod_fallback = true;}
- if (file_exists(casing_path)) {casing_fallback = false;}
- else {casing_fallback = true;}
- if (file_exists(amswap_path)) {amswap_fallback = false;}
- else {amswap_fallback = true;}
- if (file_exists(ooc_toggle_path)) {ooc_toggle_fallback = false;}
- else {ooc_toggle_fallback = true;}
-}
-
-class AOFrameThreadingPre : public QRunnable
-{
-public:
- Courtroom *thisCourtroom;
- int my_frameNumber;
- AOFrameThreadingPre(Courtroom *my_courtroom, int frameNumber){
- thisCourtroom = my_courtroom;
- my_frameNumber = frameNumber;
- }
- void run()
- {
- qDebug() << my_frameNumber << " FRAME NUMBER" << " from" << QThread::currentThread();
- QString sfx_to_play = thisCourtroom->ao_app->get_frame_sfx_name(thisCourtroom->current_char, thisCourtroom->ao_app->get_pre_emote(thisCourtroom->current_char, thisCourtroom->current_emote), my_frameNumber);
- QString screenshake_to_play = thisCourtroom->ao_app->get_screenshake_frame(thisCourtroom->current_char, thisCourtroom->ao_app->get_pre_emote(thisCourtroom->current_char, thisCourtroom->current_emote), my_frameNumber);
- QString realization_to_play = thisCourtroom->ao_app->get_realization_frame(thisCourtroom->current_char, thisCourtroom->ao_app->get_pre_emote(thisCourtroom->current_char, thisCourtroom->current_emote), my_frameNumber);
- if(sfx_to_play != "")
- {
- thisCourtroom->threading_sfx += "|" + QString::number(my_frameNumber) + "=" + sfx_to_play;
- }
- if(screenshake_to_play != "")
- {
- thisCourtroom->threading_shake += "|" + QString::number(my_frameNumber) + "=" + screenshake_to_play;
- }
- if(realization_to_play != "")
- {
- thisCourtroom->threading_flash += "|" + QString::number(my_frameNumber) + "=" + realization_to_play;
- }
- }
-};
-
-
-class AOFrameThreading : public QRunnable
-{
-public:
- Courtroom *thisCourtroom;
- int my_frameNumber;
- AOFrameThreading(Courtroom *my_courtroom, int frameNumber){
- thisCourtroom = my_courtroom;
- my_frameNumber = frameNumber;
- }
- void run()
- {
- QString sfx_to_play = thisCourtroom->ao_app->get_frame_sfx_name(thisCourtroom->current_char, thisCourtroom->threading_prefix + thisCourtroom->ao_app->get_emote(thisCourtroom->current_char, thisCourtroom->current_emote), my_frameNumber);
- QString screenshake_to_play = thisCourtroom->ao_app->get_screenshake_frame(thisCourtroom->current_char, thisCourtroom->threading_prefix + thisCourtroom->ao_app->get_emote(thisCourtroom->current_char, thisCourtroom->current_emote), my_frameNumber);
- QString realization_to_play = thisCourtroom->ao_app->get_realization_frame(thisCourtroom->current_char, thisCourtroom->threading_prefix + thisCourtroom->ao_app->get_emote(thisCourtroom->current_char, thisCourtroom->current_emote), my_frameNumber);
- if(sfx_to_play != "")
- {
- thisCourtroom->threading_sfx += "|" + QString::number(my_frameNumber) + "=" + sfx_to_play;
- }
- if(screenshake_to_play != "")
- {
- thisCourtroom->threading_shake += "|" + QString::number(my_frameNumber) + "=" + screenshake_to_play;
- }
- if(realization_to_play != "")
- {
- thisCourtroom->threading_flash += "|" + QString::number(my_frameNumber) + "=" + realization_to_play;
- }
- }
-};
-
-void Courtroom::on_chat_return_pressed()
-{
- if (ui_ic_chat_message->text() == "" || is_muted)
- return;
-
- if ((anim_state < 3 || text_state < 2) &&
- objection_state == 0)
- return;
-
- //MS#
- //deskmod#
- //pre-emote#
- //character#
- //emote#
- //message#
- //side#
- //sfx-name#
- //emote_modifier#
- //char_id#
- //sfx_delay#
- //objection_modifier#
- //evidence#
- //placeholder#
- //realization#
- //text_color#%
-
- // Additionally, in our case:
-
- //showname#
- //other_charid#
- //self_offset#
- //noninterrupting_preanim#%
-
- QStringList packet_contents;
-
- QString f_side = ao_app->get_char_side(current_char);
-
- QString f_desk_mod = "chat";
-
- if (ao_app->desk_mod_enabled)
- {
- f_desk_mod = QString::number(ao_app->get_desk_mod(current_char, current_emote));
- if (f_desk_mod == "-1")
- f_desk_mod = "chat";
- }
-
- packet_contents.append(f_desk_mod);
-
- packet_contents.append(ao_app->get_pre_emote(current_char, current_emote));
-
- packet_contents.append(current_char);
-
- packet_contents.append(ao_app->get_emote(current_char, current_emote));
-
- packet_contents.append(ui_ic_chat_message->text());
-
- packet_contents.append(f_side);
-
- packet_contents.append(ao_app->get_sfx_name(current_char, current_emote));
-
- int f_emote_mod = ao_app->get_emote_mod(current_char, current_emote);
-
- //needed or else legacy won't understand what we're saying
+}
+
+void Courtroom::detect_fallback_text()
+{
+ QString change_char_path = ao_app->get_theme_path("change_character.png");
+ QString reload_theme_path = ao_app->get_theme_path("reload_theme.png");
+ QString settings_path = ao_app->get_theme_path("settings.png");
+ QString call_mod_path = ao_app->get_theme_path("call_mod.png");
+ QString casing_path = ao_app->get_theme_path("casing.png");
+ QString amswap_path = ao_app->get_theme_path("amswap.png");
+ QString ooc_toggle_path = ao_app->get_theme_path("ooc_toggle_ms.png");
+
+ if (file_exists(change_char_path)) {
+ change_char_fallback = false;
+ }
+ else {
+ change_char_fallback = true;
+ }
+ if (file_exists(reload_theme_path)) {
+ reload_theme_fallback = false;
+ }
+ else {
+ reload_theme_fallback = true;
+ }
+ if (file_exists(settings_path)) {
+ settings_fallback = false;
+ }
+ else {
+ settings_fallback = true;
+ }
+ if (file_exists(call_mod_path)) {
+ call_mod_fallback = false;
+ }
+ else {
+ call_mod_fallback = true;
+ }
+ if (file_exists(casing_path)) {
+ casing_fallback = false;
+ }
+ else {
+ casing_fallback = true;
+ }
+ if (file_exists(amswap_path)) {
+ amswap_fallback = false;
+ }
+ else {
+ amswap_fallback = true;
+ }
+ if (file_exists(ooc_toggle_path)) {
+ ooc_toggle_fallback = false;
+ }
+ else {
+ ooc_toggle_fallback = true;
+ }
+}
+
+class AOFrameThreadingPre : public QRunnable {
+public:
+ Courtroom *thisCourtroom;
+ int my_frameNumber;
+ AOFrameThreadingPre(Courtroom *my_courtroom, int frameNumber)
+ {
+ thisCourtroom = my_courtroom;
+ my_frameNumber = frameNumber;
+ }
+ void run()
+ {
+ qDebug() << my_frameNumber << " FRAME NUMBER"
+ << " from" << QThread::currentThread();
+ QString sfx_to_play = thisCourtroom->ao_app->get_frame_sfx_name(
+ thisCourtroom->current_char,
+ thisCourtroom->ao_app->get_pre_emote(thisCourtroom->current_char,
+ thisCourtroom->current_emote),
+ my_frameNumber);
+ QString screenshake_to_play = thisCourtroom->ao_app->get_screenshake_frame(
+ thisCourtroom->current_char,
+ thisCourtroom->ao_app->get_pre_emote(thisCourtroom->current_char,
+ thisCourtroom->current_emote),
+ my_frameNumber);
+ QString realization_to_play = thisCourtroom->ao_app->get_realization_frame(
+ thisCourtroom->current_char,
+ thisCourtroom->ao_app->get_pre_emote(thisCourtroom->current_char,
+ thisCourtroom->current_emote),
+ my_frameNumber);
+ if (sfx_to_play != "") {
+ thisCourtroom->threading_sfx +=
+ "|" + QString::number(my_frameNumber) + "=" + sfx_to_play;
+ }
+ if (screenshake_to_play != "") {
+ thisCourtroom->threading_shake +=
+ "|" + QString::number(my_frameNumber) + "=" + screenshake_to_play;
+ }
+ if (realization_to_play != "") {
+ thisCourtroom->threading_flash +=
+ "|" + QString::number(my_frameNumber) + "=" + realization_to_play;
+ }
+ }
+};
+
+class AOFrameThreading : public QRunnable {
+public:
+ Courtroom *thisCourtroom;
+ int my_frameNumber;
+ AOFrameThreading(Courtroom *my_courtroom, int frameNumber)
+ {
+ thisCourtroom = my_courtroom;
+ my_frameNumber = frameNumber;
+ }
+ void run()
+ {
+ QString sfx_to_play = thisCourtroom->ao_app->get_frame_sfx_name(
+ thisCourtroom->current_char,
+ thisCourtroom->threading_prefix +
+ thisCourtroom->ao_app->get_emote(thisCourtroom->current_char,
+ thisCourtroom->current_emote),
+ my_frameNumber);
+ QString screenshake_to_play = thisCourtroom->ao_app->get_screenshake_frame(
+ thisCourtroom->current_char,
+ thisCourtroom->threading_prefix +
+ thisCourtroom->ao_app->get_emote(thisCourtroom->current_char,
+ thisCourtroom->current_emote),
+ my_frameNumber);
+ QString realization_to_play = thisCourtroom->ao_app->get_realization_frame(
+ thisCourtroom->current_char,
+ thisCourtroom->threading_prefix +
+ thisCourtroom->ao_app->get_emote(thisCourtroom->current_char,
+ thisCourtroom->current_emote),
+ my_frameNumber);
+ if (sfx_to_play != "") {
+ thisCourtroom->threading_sfx +=
+ "|" + QString::number(my_frameNumber) + "=" + sfx_to_play;
+ }
+ if (screenshake_to_play != "") {
+ thisCourtroom->threading_shake +=
+ "|" + QString::number(my_frameNumber) + "=" + screenshake_to_play;
+ }
+ if (realization_to_play != "") {
+ thisCourtroom->threading_flash +=
+ "|" + QString::number(my_frameNumber) + "=" + realization_to_play;
+ }
+ }
+};
+
+void Courtroom::on_chat_return_pressed()
+{
+ if (ui_ic_chat_message->text() == "" || is_muted)
+ return;
+
+ if ((anim_state < 3 || text_state < 2) && objection_state == 0)
+ return;
+
+ // MS#
+ // deskmod#
+ // pre-emote#
+ // character#
+ // emote#
+ // message#
+ // side#
+ // sfx-name#
+ // emote_modifier#
+ // char_id#
+ // sfx_delay#
+ // objection_modifier#
+ // evidence#
+ // placeholder#
+ // realization#
+ // text_color#%
+
+ // Additionally, in our case:
+
+ // showname#
+ // other_charid#
+ // self_offset#
+ // noninterrupting_preanim#%
+
+ QStringList packet_contents;
+
+ QString f_side = ao_app->get_char_side(current_char);
+
+ QString f_desk_mod = "chat";
+
+ if (ao_app->desk_mod_enabled) {
+ f_desk_mod =
+ QString::number(ao_app->get_desk_mod(current_char, current_emote));
+ if (f_desk_mod == "-1")
+ f_desk_mod = "chat";
+ }
+
+ packet_contents.append(f_desk_mod);
+
+ packet_contents.append(ao_app->get_pre_emote(current_char, current_emote));
+
+ packet_contents.append(current_char);
+
+ packet_contents.append(ao_app->get_emote(current_char, current_emote));
+
+ packet_contents.append(ui_ic_chat_message->text());
+
+ packet_contents.append(f_side);
+
+ packet_contents.append(ao_app->get_sfx_name(current_char, current_emote));
+
+ int f_emote_mod = ao_app->get_emote_mod(current_char, current_emote);
+
+ // needed or else legacy won't understand what we're saying
if (objection_state > 0) {
if (ui_pre->isChecked()) {
if (f_emote_mod == 5 || f_emote_mod == 4)
- f_emote_mod = 6;
- else
- f_emote_mod = 2;
- }
- }
- else if (ui_pre->isChecked() and !ui_pre_non_interrupt->isChecked())
- {
- if (f_emote_mod == 0)
- f_emote_mod = 1;
- else if (f_emote_mod == 5 && ao_app->prezoom_enabled)
- f_emote_mod = 4;
- }
- else
- {
- if (f_emote_mod == 1)
- f_emote_mod = 0;
- else if (f_emote_mod == 4)
- f_emote_mod = 5;
- }
-
- packet_contents.append(QString::number(f_emote_mod));
- packet_contents.append(QString::number(m_cid));
-
- packet_contents.append(QString::number(ao_app->get_sfx_delay(current_char, current_emote)));
-
- QString f_obj_state;
-
- if ((objection_state == 4 && !ao_app->custom_objection_enabled) ||
- (objection_state < 0))
- f_obj_state = "0";
+ f_emote_mod = 6;
+ else
+ f_emote_mod = 2;
+ }
+ }
+ else if (ui_pre->isChecked() and !ui_pre_non_interrupt->isChecked()) {
+ if (f_emote_mod == 0)
+ f_emote_mod = 1;
+ else if (f_emote_mod == 5 && ao_app->prezoom_enabled)
+ f_emote_mod = 4;
+ }
+ else {
+ if (f_emote_mod == 1)
+ f_emote_mod = 0;
+ else if (f_emote_mod == 4)
+ f_emote_mod = 5;
+ }
+
+ packet_contents.append(QString::number(f_emote_mod));
+ packet_contents.append(QString::number(m_cid));
+
+ packet_contents.append(
+ QString::number(ao_app->get_sfx_delay(current_char, current_emote)));
+
+ QString f_obj_state;
+
+ if ((objection_state == 4 && !ao_app->custom_objection_enabled) ||
+ (objection_state < 0))
+ f_obj_state = "0";
else if (objection_custom != "" && objection_state == 4) {
f_obj_state = QString::number(objection_state) + "&" +
objection_custom; // we add the name of the objection so the
// packet is like: 4&(name of custom obj)
}
- else
- f_obj_state = QString::number(objection_state);
-
- packet_contents.append(f_obj_state);
-
- if (is_presenting_evidence)
- //the evidence index is shifted by 1 because 0 is no evidence per legacy standards
- //besides, older clients crash if we pass -1
- packet_contents.append(QString::number(current_evidence + 1));
- else
- packet_contents.append("0");
-
- QString f_flip;
-
- if (ao_app->flipping_enabled)
- {
- if (ui_flip->isChecked())
- f_flip = "1";
- else
- f_flip = "0";
- }
- else
- f_flip = QString::number(m_cid);
-
- packet_contents.append(f_flip);
-
- packet_contents.append(QString::number(realization_state));
-
- QString f_text_color;
-
- if (text_color < 0)
- f_text_color = "0";
- else if (text_color > 8)
- f_text_color = "0";
- else
- f_text_color = QString::number(text_color);
-
- packet_contents.append(f_text_color);
-
- // If the server we're on supports CCCC stuff, we should use it!
- if (ao_app->cccc_ic_support_enabled)
- {
- // If there is a showname entered, use that -- else, just send an empty packet-part.
- if (!ui_ic_chat_name->text().isEmpty())
- {
- packet_contents.append(ui_ic_chat_name->text());
- }
- else
- {
- packet_contents.append("");
- }
-
- // Similarly, we send over whom we're paired with, unless we have chosen ourselves.
- // Or a charid of -1 or lower, through some means.
- if (other_charid > -1 && other_charid != m_cid)
- {
- packet_contents.append(QString::number(other_charid));
- packet_contents.append(QString::number(offset_with_pair));
- }
- else
- {
- packet_contents.append("-1");
- packet_contents.append("0");
- }
-
- // Finally, we send over if we want our pres to not interrupt.
- if (ui_pre_non_interrupt->isChecked() && ui_pre->isChecked())
- {
- packet_contents.append("1");
- }
- else
- {
- packet_contents.append("0");
- }
- }
- // If the server we're on supports Looping SFX and Screenshake, use it if the emote uses it.
- if (ao_app->looping_sfx_support_enabled)
- {
- packet_contents.append(ao_app->get_sfx_looping(current_char, current_emote));
- qDebug() << "Are we looping this? " << ao_app->get_sfx_looping(current_char, current_emote);
- packet_contents.append(QString::number(screenshake_state));
- qDebug() << "Are we screen shaking this one? " << screenshake_state;
- qDebug() << "MAX THREAD COUNT " << QThreadPool::globalInstance()->maxThreadCount();
- QString frame_screenshake = "";
- QString frame_realization = "";
- QString frame_sfx = "";
-
- QString preemote_sfx = "";
- QString preemote_shake = "";
- QString preemote_flash = "";
-
- QString talkemote_sfx = "";
- QString talkemote_shake = "";
- QString talkemote_flash = "";
-
- QString idleemote_sfx = "";
- QString idleemote_shake = "";
- QString idleemote_flash = "";
-
- QString preemote = ao_app->get_image_suffix(ao_app->get_character_path(current_char, ao_app->get_pre_emote(current_char, current_emote)));
- QString talkemote_to_check = ao_app->get_image_suffix(ao_app->get_character_path(current_char, "(b)" + ao_app->get_emote(current_char, current_emote)));
- QString idleemote_to_check = ao_app->get_image_suffix(ao_app->get_character_path(current_char, "(a)" + ao_app->get_emote(current_char, current_emote)));
-
- frame_emote_checker = new QMovie(this);
- frame_emote_checker->setFileName(preemote);
- frame_emote_checker->jumpToFrame(0);
- qDebug() << "Premote: " << frame_emote_checker->frameCount();
-
- preemote_sfx += ao_app->get_pre_emote(current_char, current_emote);
- preemote_shake += ao_app->get_pre_emote(current_char, current_emote);
- preemote_flash += ao_app->get_pre_emote(current_char, current_emote);
-
- threading_sfx = preemote_sfx;
- threading_shake = preemote_shake;
- threading_flash = preemote_flash;
-
- for(int i=0; i < frame_emote_checker->frameCount(); i++){
+ else
+ f_obj_state = QString::number(objection_state);
+ packet_contents.append(f_obj_state);
+ if (is_presenting_evidence)
+ // the evidence index is shifted by 1 because 0 is no evidence per legacy
+ // standards besides, older clients crash if we pass -1
+ packet_contents.append(QString::number(current_evidence + 1));
+ else
+ packet_contents.append("0");
+
+ QString f_flip;
+
+ if (ao_app->flipping_enabled) {
+ if (ui_flip->isChecked())
+ f_flip = "1";
+ else
+ f_flip = "0";
+ }
+ else
+ f_flip = QString::number(m_cid);
+
+ packet_contents.append(f_flip);
+
+ packet_contents.append(QString::number(realization_state));
+
+ QString f_text_color;
+
+ if (text_color < 0)
+ f_text_color = "0";
+ else if (text_color > 8)
+ f_text_color = "0";
+ else
+ f_text_color = QString::number(text_color);
+
+ packet_contents.append(f_text_color);
+
+ // If the server we're on supports CCCC stuff, we should use it!
+ if (ao_app->cccc_ic_support_enabled) {
+ // If there is a showname entered, use that -- else, just send an empty
+ // packet-part.
+ if (!ui_ic_chat_name->text().isEmpty()) {
+ packet_contents.append(ui_ic_chat_name->text());
+ }
+ else {
+ packet_contents.append("");
+ }
+
+ // Similarly, we send over whom we're paired with, unless we have chosen
+ // ourselves. Or a charid of -1 or lower, through some means.
+ if (other_charid > -1 && other_charid != m_cid) {
+ packet_contents.append(QString::number(other_charid));
+ packet_contents.append(QString::number(offset_with_pair));
+ }
+ else {
+ packet_contents.append("-1");
+ packet_contents.append("0");
+ }
+
+ // Finally, we send over if we want our pres to not interrupt.
+ if (ui_pre_non_interrupt->isChecked() && ui_pre->isChecked()) {
+ packet_contents.append("1");
+ }
+ else {
+ packet_contents.append("0");
+ }
+ }
+ // If the server we're on supports Looping SFX and Screenshake, use it if the
+ // emote uses it.
+ if (ao_app->looping_sfx_support_enabled) {
+ packet_contents.append(
+ ao_app->get_sfx_looping(current_char, current_emote));
+ qDebug() << "Are we looping this? "
+ << ao_app->get_sfx_looping(current_char, current_emote);
+ packet_contents.append(QString::number(screenshake_state));
+ qDebug() << "Are we screen shaking this one? " << screenshake_state;
+ qDebug() << "MAX THREAD COUNT "
+ << QThreadPool::globalInstance()->maxThreadCount();
+ QString frame_screenshake = "";
+ QString frame_realization = "";
+ QString frame_sfx = "";
+
+ QString preemote_sfx = "";
+ QString preemote_shake = "";
+ QString preemote_flash = "";
+
+ QString talkemote_sfx = "";
+ QString talkemote_shake = "";
+ QString talkemote_flash = "";
+
+ QString idleemote_sfx = "";
+ QString idleemote_shake = "";
+ QString idleemote_flash = "";
+
+ QString preemote = ao_app->get_image_suffix(ao_app->get_character_path(
+ current_char, ao_app->get_pre_emote(current_char, current_emote)));
+ QString talkemote_to_check =
+ ao_app->get_image_suffix(ao_app->get_character_path(
+ current_char,
+ "(b)" + ao_app->get_emote(current_char, current_emote)));
+ QString idleemote_to_check =
+ ao_app->get_image_suffix(ao_app->get_character_path(
+ current_char,
+ "(a)" + ao_app->get_emote(current_char, current_emote)));
+
+ frame_emote_checker = new QMovie(this);
+ frame_emote_checker->setFileName(preemote);
+ frame_emote_checker->jumpToFrame(0);
+ qDebug() << "Premote: " << frame_emote_checker->frameCount();
+
+ preemote_sfx += ao_app->get_pre_emote(current_char, current_emote);
+ preemote_shake += ao_app->get_pre_emote(current_char, current_emote);
+ preemote_flash += ao_app->get_pre_emote(current_char, current_emote);
+
+ threading_sfx = preemote_sfx;
+ threading_shake = preemote_shake;
+ threading_flash = preemote_flash;
+
+ for (int i = 0; i < frame_emote_checker->frameCount(); i++) {
AOFrameThreadingPre *frame_thread = new AOFrameThreadingPre(this, i);
QThreadPool::globalInstance()->start(frame_thread);
frame_thread->setAutoDelete(true);
- }
- QThreadPool::globalInstance()->waitForDone();
- preemote_sfx = threading_sfx;
- preemote_shake = threading_shake;
- preemote_flash = threading_flash;
- preemote_sfx += "^";
- preemote_shake += "^";
- preemote_flash += "^";
- delete frame_emote_checker;
-
-
-
- talkemote_sfx += "(b)" + ao_app->get_emote(current_char, current_emote);
- talkemote_shake += "(b)" + ao_app->get_emote(current_char, current_emote);
- talkemote_flash += "(b)" + ao_app->get_emote(current_char, current_emote);
-
- frame_emote_checker = new QMovie(this);
- frame_emote_checker->setFileName(talkemote_to_check);
- frame_emote_checker->jumpToFrame(0);
- qDebug() << "Talk: " << frame_emote_checker->frameCount();
-
- threading_sfx = talkemote_sfx;
- threading_shake = talkemote_shake;
- threading_flash = talkemote_flash;
- threading_prefix = QString("(b)");
-
- for(int i=0; i < frame_emote_checker->frameCount(); i++){
+ }
+ QThreadPool::globalInstance()->waitForDone();
+ preemote_sfx = threading_sfx;
+ preemote_shake = threading_shake;
+ preemote_flash = threading_flash;
+ preemote_sfx += "^";
+ preemote_shake += "^";
+ preemote_flash += "^";
+ delete frame_emote_checker;
+
+ talkemote_sfx += "(b)" + ao_app->get_emote(current_char, current_emote);
+ talkemote_shake += "(b)" + ao_app->get_emote(current_char, current_emote);
+ talkemote_flash += "(b)" + ao_app->get_emote(current_char, current_emote);
+
+ frame_emote_checker = new QMovie(this);
+ frame_emote_checker->setFileName(talkemote_to_check);
+ frame_emote_checker->jumpToFrame(0);
+ qDebug() << "Talk: " << frame_emote_checker->frameCount();
+
+ threading_sfx = talkemote_sfx;
+ threading_shake = talkemote_shake;
+ threading_flash = talkemote_flash;
+ threading_prefix = QString("(b)");
+
+ for (int i = 0; i < frame_emote_checker->frameCount(); i++) {
AOFrameThreading *frame_thread = new AOFrameThreading(this, i);
QThreadPool::globalInstance()->start(frame_thread);
frame_thread->setAutoDelete(true);
- }
- QThreadPool::globalInstance()->waitForDone();
-
- talkemote_sfx = threading_sfx;
- talkemote_shake = threading_shake;
- talkemote_flash = threading_flash;
- talkemote_sfx += "^";
- talkemote_shake += "^";
- talkemote_flash += "^";
- delete frame_emote_checker;
-
-
-
- idleemote_sfx += "(a)" + ao_app->get_emote(current_char, current_emote);
- idleemote_shake += "(a)" + ao_app->get_emote(current_char, current_emote);
- idleemote_flash += "(a)" + ao_app->get_emote(current_char, current_emote);
-
- frame_emote_checker = new QMovie(this);
- frame_emote_checker->setFileName(idleemote_to_check);
- frame_emote_checker->jumpToFrame(0);
- qDebug() << "idle: " << frame_emote_checker->frameCount();
-
- threading_sfx = idleemote_sfx;
- threading_shake = idleemote_shake;
- threading_flash = idleemote_flash;
- threading_prefix = QString("(a)");
- for(int i=0; i < frame_emote_checker->frameCount(); i++){
+ }
+ QThreadPool::globalInstance()->waitForDone();
+
+ talkemote_sfx = threading_sfx;
+ talkemote_shake = threading_shake;
+ talkemote_flash = threading_flash;
+ talkemote_sfx += "^";
+ talkemote_shake += "^";
+ talkemote_flash += "^";
+ delete frame_emote_checker;
+
+ idleemote_sfx += "(a)" + ao_app->get_emote(current_char, current_emote);
+ idleemote_shake += "(a)" + ao_app->get_emote(current_char, current_emote);
+ idleemote_flash += "(a)" + ao_app->get_emote(current_char, current_emote);
+
+ frame_emote_checker = new QMovie(this);
+ frame_emote_checker->setFileName(idleemote_to_check);
+ frame_emote_checker->jumpToFrame(0);
+ qDebug() << "idle: " << frame_emote_checker->frameCount();
+
+ threading_sfx = idleemote_sfx;
+ threading_shake = idleemote_shake;
+ threading_flash = idleemote_flash;
+ threading_prefix = QString("(a)");
+ for (int i = 0; i < frame_emote_checker->frameCount(); i++) {
AOFrameThreading *frame_thread = new AOFrameThreading(this, i);
QThreadPool::globalInstance()->start(frame_thread);
frame_thread->setAutoDelete(true);
- }
- QThreadPool::globalInstance()->waitForDone();
- idleemote_sfx = threading_sfx;
- idleemote_shake = threading_shake;
- idleemote_flash = threading_flash;
- delete frame_emote_checker;
-
- frame_screenshake += preemote_shake;
- frame_screenshake += talkemote_shake;
- frame_screenshake += idleemote_shake;
-
- frame_realization += preemote_flash;
- frame_realization += talkemote_flash;
- frame_realization += idleemote_flash;
-
- frame_sfx += preemote_sfx;
- frame_sfx += talkemote_sfx;
- frame_sfx += idleemote_sfx;
-
- packet_contents.append(frame_screenshake);
- packet_contents.append(frame_realization);
- packet_contents.append(frame_sfx);
+ }
+ QThreadPool::globalInstance()->waitForDone();
+ idleemote_sfx = threading_sfx;
+ idleemote_shake = threading_shake;
+ idleemote_flash = threading_flash;
+ delete frame_emote_checker;
+
+ frame_screenshake += preemote_shake;
+ frame_screenshake += talkemote_shake;
+ frame_screenshake += idleemote_shake;
+
+ frame_realization += preemote_flash;
+ frame_realization += talkemote_flash;
+ frame_realization += idleemote_flash;
+
+ frame_sfx += preemote_sfx;
+ frame_sfx += talkemote_sfx;
+ frame_sfx += idleemote_sfx;
+
+ packet_contents.append(frame_screenshake);
+ packet_contents.append(frame_realization);
+ packet_contents.append(frame_sfx);
} // Honestly this is a copy paste dump and I have no idea what this does. If
// this breaks blame aov thanks
- ao_app->send_server_packet(new AOPacket("MS", packet_contents));
-}
-void Courtroom::handle_chatmessage(QStringList *p_contents)
-{
- // Instead of checking for whether a message has at least chatmessage_size
- // amount of packages, we'll check if it has at least 15.
- // That was the original chatmessage_size.
- if (p_contents->size() < 15)
- return;
-
- for (int n_string = 0 ; n_string < chatmessage_size ; ++n_string)
- {
- //m_chatmessage[n_string] = p_contents->at(n_string);
-
- // Note that we have added stuff that vanilla clients and servers simply won't send.
- // So now, we have to check if the thing we want even exists amongst the packet's content.
- // We also have to check if the server even supports CCCC's IC features, or if it's just japing us.
- // Also, don't forget! A size 15 message will have indices from 0 to 14.
- if (n_string < p_contents->size() &&
- (n_string < 15 || ao_app->cccc_ic_support_enabled))
- {
- m_chatmessage[n_string] = p_contents->at(n_string);
- }
- else
- {
- m_chatmessage[n_string] = "";
- }
- }
-
- int f_char_id = m_chatmessage[CHAR_ID].toInt();
-
- if (f_char_id < 0 || f_char_id >= char_list.size())
- return;
-
- if (mute_map.value(m_chatmessage[CHAR_ID].toInt()))
- return;
-
- QString f_showname;
- if (m_chatmessage[SHOWNAME].isEmpty() || !ui_showname_enable->isChecked())
- {
- f_showname = ao_app->get_showname(char_list.at(f_char_id).name);
- }
- else
- {
- f_showname = m_chatmessage[SHOWNAME];
- }
-
-
- QString f_message = f_showname + ": " + m_chatmessage[MESSAGE] + '\n';
-
- if (f_message == previous_ic_message)
- return;
-
- text_state = 0;
- anim_state = 0;
- ui_vp_objection->stop();
+ ao_app->send_server_packet(new AOPacket("MS", packet_contents));
+}
+void Courtroom::handle_chatmessage(QStringList *p_contents)
+{
+ // Instead of checking for whether a message has at least chatmessage_size
+ // amount of packages, we'll check if it has at least 15.
+ // That was the original chatmessage_size.
+ if (p_contents->size() < 15)
+ return;
+
+ for (int n_string = 0; n_string < chatmessage_size; ++n_string) {
+ // m_chatmessage[n_string] = p_contents->at(n_string);
+
+ // Note that we have added stuff that vanilla clients and servers simply
+ // won't send. So now, we have to check if the thing we want even exists
+ // amongst the packet's content. We also have to check if the server even
+ // supports CCCC's IC features, or if it's just japing us. Also, don't
+ // forget! A size 15 message will have indices from 0 to 14.
+ if (n_string < p_contents->size() &&
+ (n_string < 15 || ao_app->cccc_ic_support_enabled)) {
+ m_chatmessage[n_string] = p_contents->at(n_string);
+ }
+ else {
+ m_chatmessage[n_string] = "";
+ }
+ }
+
+ int f_char_id = m_chatmessage[CHAR_ID].toInt();
+
+ if (f_char_id < 0 || f_char_id >= char_list.size())
+ return;
+
+ if (mute_map.value(m_chatmessage[CHAR_ID].toInt()))
+ return;
+
+ QString f_showname;
+ if (m_chatmessage[SHOWNAME].isEmpty() || !ui_showname_enable->isChecked()) {
+ f_showname = ao_app->get_showname(char_list.at(f_char_id).name);
+ }
+ else {
+ f_showname = m_chatmessage[SHOWNAME];
+ }
+
+ QString f_message = f_showname + ": " + m_chatmessage[MESSAGE] + '\n';
+
+ if (f_message == previous_ic_message)
+ return;
+
+ text_state = 0;
+ anim_state = 0;
+ ui_vp_objection->stop();
// ui_vp_player_char->stop();
- chat_tick_timer->stop();
+ chat_tick_timer->stop();
if (keep_evidence_display)
- ui_vp_evidence_display->reset();
-
- chatmessage_is_empty = m_chatmessage[MESSAGE] == " " || m_chatmessage[MESSAGE] == "";
-
- if (m_chatmessage[MESSAGE] == ui_ic_chat_message->text() && m_chatmessage[CHAR_ID].toInt() == m_cid)
- {
- ui_ic_chat_message->clear();
- objection_state = 0;
+ ui_vp_evidence_display->reset();
+
+ chatmessage_is_empty =
+ m_chatmessage[MESSAGE] == " " || m_chatmessage[MESSAGE] == "";
+ if (m_chatmessage[MESSAGE] == ui_ic_chat_message->text() &&
+ m_chatmessage[CHAR_ID].toInt() == m_cid) {
+ ui_ic_chat_message->clear();
+ objection_state = 0;
objection_custom = "";
char_name = m_chatmessage[CHAR_NAME];
- realization_state = 0;
- screenshake_state = 0;
- is_presenting_evidence = false;
- ui_pre->setChecked(false);
- ui_hold_it->set_image("holdit.png");
- ui_objection->set_image("objection.png");
- ui_take_that->set_image("takethat.png");
- ui_custom_objection->set_image("custom.png");
- ui_realization->set_image("realization.png");
- ui_screenshake->set_image("screenshake.png");
- ui_evidence_present->set_image("present_disabled.png");
+ realization_state = 0;
+ screenshake_state = 0;
+ is_presenting_evidence = false;
+ ui_pre->setChecked(false);
+ ui_hold_it->set_image("holdit.png");
+ ui_objection->set_image("objection.png");
+ ui_take_that->set_image("takethat.png");
+ ui_custom_objection->set_image("custom.png");
+ ui_realization->set_image("realization.png");
ui_screenshake->set_image("screenshake.png");
- }
-
+ ui_evidence_present->set_image("present_disabled.png");
+ ui_screenshake->set_image("screenshake.png");
+ }
+
QString tmpmsg = "";
chatlogpiece *temp = new chatlogpiece(
ao_app->get_showname(char_list.at(f_char_id).name), f_showname,
": " + m_chatmessage[MESSAGE], false, m_chatmessage[TEXT_COLOR].toInt());
- ic_chatlog_history.append(*temp);
-
- while(ic_chatlog_history.size() > log_maximum_blocks && log_maximum_blocks > 0)
- {
- ic_chatlog_history.removeFirst();
- }
+ ic_chatlog_history.append(*temp);
+
+ while (ic_chatlog_history.size() > log_maximum_blocks &&
+ log_maximum_blocks > 0) {
+ ic_chatlog_history.removeFirst();
+ }
refresh_iclog(true);
-
+
if (f_showname == "")
f_showname = m_chatmessage[CHAR_NAME];
if (!mirror_iclog)
append_ic_text(": " + m_chatmessage[MESSAGE], f_showname, false, true,
false, m_chatmessage[TEXT_COLOR].toInt());
-
- previous_ic_message = f_message;
+
+ previous_ic_message = f_message;
bool ok;
int objection_mod = m_chatmessage[OBJECTION_MOD].toInt(
&ok, 10); // checks if its a custom obj.
@@ -1767,32 +1817,31 @@ void Courtroom::handle_chatmessage(QStringList *p_contents)
}
QString f_char = char_name;
f_char = m_chatmessage[CHAR_NAME];
- QString f_custom_theme = ao_app->get_char_shouts(f_char);
+ QString f_custom_theme = ao_app->get_char_shouts(f_char);
ui_vp_message->clear();
ui_vp_chatbox->hide();
- //if an objection is used
- if (objection_mod <= 4 && objection_mod >= 1)
- {
- switch (objection_mod)
- {
- case 1:
+ // if an objection is used
+ if (objection_mod <= 4 && objection_mod >= 1) {
+
+ switch (objection_mod) {
+ case 1:
ui_vp_objection->play("holdit", f_char, f_custom_theme, shout_stay_time);
- objection_player->play("holdit.wav", f_char, f_custom_theme);
- break;
- case 2:
+ objection_player->play("holdit.wav", f_char, f_custom_theme);
+ break;
+ case 2:
ui_vp_objection->play("objection", f_char, f_custom_theme,
shout_stay_time);
- objection_player->play("objection.wav", f_char, f_custom_theme);
- if(ao_app->get_objectmusic())
- music_player->kill_loop();
- break;
- case 3:
+ objection_player->play("objection.wav", f_char, f_custom_theme);
+ if (ao_app->get_objectmusic())
+ music_player->kill_loop();
+ break;
+ case 3:
ui_vp_objection->play("takethat", f_char, f_custom_theme,
shout_stay_time);
- objection_player->play("takethat.wav", f_char, f_custom_theme);
- break;
- //case 4 is AO2 only
- case 4:
+ objection_player->play("takethat.wav", f_char, f_custom_theme);
+ break;
+ // case 4 is AO2 only
+ case 4:
if (custom_objection != "") {
ui_vp_objection->play("custom_objections/" + custom_objection, f_char,
f_custom_theme, shout_stay_time);
@@ -1803,326 +1852,316 @@ void Courtroom::handle_chatmessage(QStringList *p_contents)
else {
ui_vp_objection->play("custom", f_char, f_custom_theme,
shout_stay_time);
- objection_player->play("custom.wav", f_char, f_custom_theme);
+ objection_player->play("custom.wav", f_char, f_custom_theme);
}
- break;
- default:
- qDebug() << "W: Logic error in objection switch statement!";
- }
-
- int emote_mod = m_chatmessage[EMOTE_MOD].toInt();
-
- if (emote_mod == 0)
- m_chatmessage[EMOTE_MOD] = 1;
- }
- else
- handle_chatmessage_2();
-}
-
-void Courtroom::objection_done()
-{
- handle_chatmessage_2();
-}
-
-void Courtroom::handle_chatmessage_2()
-{
- ui_vp_speedlines->stop();
+ break;
+ default:
+ qDebug() << "W: Logic error in objection switch statement!";
+ }
+
+ int emote_mod = m_chatmessage[EMOTE_MOD].toInt();
+
+ if (emote_mod == 0)
+ m_chatmessage[EMOTE_MOD] = 1;
+ }
+ else {
+ handle_chatmessage_2();
+ }
+}
+
+void Courtroom::objection_done() { handle_chatmessage_2(); }
+
+void Courtroom::handle_chatmessage_2()
+{
+ ui_vp_speedlines->stop();
// ui_vp_player_char->stop();
- ui_vp_player_char->frame_sfx_hellstring = m_chatmessage[FRAME_SFX];
+ ui_vp_player_char->frame_sfx_hellstring = m_chatmessage[FRAME_SFX];
ui_vp_player_char->frame_realization_hellstring =
m_chatmessage[FRAME_REALIZATION];
ui_vp_player_char->frame_screenshake_hellstring =
m_chatmessage[FRAME_SCREENSHAKE];
- ui_vp_player_char->use_networked_framehell = true;
- if (m_chatmessage[SHOWNAME].isEmpty() || !ui_showname_enable->isChecked())
- {
- QString real_name = char_list.at(m_chatmessage[CHAR_ID].toInt()).name;
-
+ ui_vp_player_char->use_networked_framehell = true;
+ if (m_chatmessage[SHOWNAME].isEmpty() || !ui_showname_enable->isChecked()) {
+ QString real_name = char_list.at(m_chatmessage[CHAR_ID].toInt()).name;
+
QString f_showname = ao_app->get_showname(m_chatmessage[CHAR_NAME]);
-
- ui_vp_showname->setText(f_showname);
- }
- else
- {
- ui_vp_showname->setText(m_chatmessage[SHOWNAME]);
- }
-
+
+ ui_vp_showname->setText(f_showname);
+ }
+
+ else {
+ ui_vp_showname->setText(m_chatmessage[SHOWNAME]);
+ }
+
QString f_char = m_chatmessage[CHAR_NAME];
QString chatbox = ao_app->get_chat(f_char);
-
- if (chatbox == "")
- ui_vp_chatbox->set_image("chatmed.png");
- else
- {
- QString chatbox_path;
- QString misc_path = ao_app->get_base_path() + "misc/" + chatbox + "/chatbox.png";
- // support for 2.4 legacy chatboxes
- QString legacy_path = ao_app->get_base_path() + "misc/" + chatbox + ".png";
- if (file_exists(misc_path))
- {
- chatbox_path = misc_path;
- }
- else if (file_exists(legacy_path))
- chatbox_path = legacy_path;
- else
- {
- QString default_chatbox_path = ao_app->get_theme_path("chatmed.png");
- chatbox_path = default_chatbox_path;
- }
- ui_vp_chatbox->set_image_from_path(chatbox_path);
- }
-
- ui_vp_showname->setStyleSheet("QLabel { color : " + get_text_color("_showname").name() + "; }");
-
- set_scene();
- set_text_color();
-
- // Check if the message needs to be centered.
- QString f_message = m_chatmessage[MESSAGE];
- if (f_message.size() >= 2)
- {
- if (f_message.startsWith("~~"))
- {
- message_is_centered = true;
- }
- else
- {
- message_is_centered = false;
- }
- }
- else
- {
- ui_vp_message->setAlignment(Qt::AlignLeft);
- }
-
-
- int emote_mod = m_chatmessage[EMOTE_MOD].toInt();
-
- if (ao_app->flipping_enabled && m_chatmessage[FLIP].toInt() == 1)
- ui_vp_player_char->set_flipped(true);
- else
- ui_vp_player_char->set_flipped(false);
-
- QString side = m_chatmessage[SIDE];
+
+ if (chatbox == "") {
+ ui_vp_chatbox->set_image("chatmed.png");
+ }
+ else {
+ QString chatbox_path;
+ QString misc_path =
+ ao_app->get_base_path() + "misc/" + chatbox + "/chatbox.png";
+ // support for 2.4 legacy chatboxes
+ QString legacy_path = ao_app->get_base_path() + "misc/" + chatbox + ".png";
+ if (file_exists(misc_path)) {
+ chatbox_path = misc_path;
+ }
+ else if (file_exists(legacy_path))
+ chatbox_path = legacy_path;
+ else {
+ QString default_chatbox_path = ao_app->get_theme_path("chatmed.png");
+ chatbox_path = default_chatbox_path;
+ }
+ ui_vp_chatbox->set_image_from_path(chatbox_path);
+ }
+
+ ui_vp_showname->setStyleSheet(
+ "QLabel { color : " + get_text_color("_showname").name() + "; }");
+
+ set_scene();
+ set_text_color();
+
+ // Check if the message needs to be centered.
+ QString f_message = m_chatmessage[MESSAGE];
+ if (f_message.size() >= 2) {
+ if (f_message.startsWith("~~")) {
+ message_is_centered = true;
+ }
+ else {
+ message_is_centered = false;
+ }
+ }
+ else {
+ ui_vp_message->setAlignment(Qt::AlignLeft);
+ }
+
+ int emote_mod = m_chatmessage[EMOTE_MOD].toInt();
+
+ if (ao_app->flipping_enabled && m_chatmessage[FLIP].toInt() == 1)
+ ui_vp_player_char->set_flipped(true);
+ else
+ ui_vp_player_char->set_flipped(false);
+
+ QString side = m_chatmessage[SIDE];
if (side != "wit")
ui_vp_testimony->stop();
-
- // Making the second character appear.
- if (m_chatmessage[OTHER_CHARID].isEmpty())
- {
- // If there is no second character, hide 'em, and center the first.
- ui_vp_sideplayer_char->hide();
- ui_vp_sideplayer_char->move(0,0);
-
- ui_vp_player_char->move(0,0);
- }
- else
- {
- bool ok;
- int got_other_charid = m_chatmessage[OTHER_CHARID].toInt(&ok);
- if (ok)
- {
- if (got_other_charid > -1)
- {
- // If there is, show them!
- ui_vp_sideplayer_char->show();
-
- // Depending on where we are, we offset the characters, and reorder their stacking.
- if (side == "def")
- {
- // We also move the character down depending on how far the are to the right.
- int hor_offset = m_chatmessage[SELF_OFFSET].toInt();
- int vert_offset = 0;
- if (hor_offset > 0)
- {
- vert_offset = hor_offset / 10;
- }
- ui_vp_player_char->move(ui_viewport->width() * hor_offset / 100, ui_viewport->height() * vert_offset / 100);
-
- // We do the same with the second character.
- int hor2_offset = m_chatmessage[OTHER_OFFSET].toInt();
- int vert2_offset = 0;
- if (hor2_offset > 0)
- {
- vert2_offset = hor2_offset / 10;
- }
- ui_vp_sideplayer_char->move(ui_viewport->width() * hor2_offset / 100, ui_viewport->height() * vert2_offset / 100);
-
- // Finally, we reorder them based on who is more to the left.
- // The person more to the left is more in the front.
- if (hor2_offset >= hor_offset)
- {
- ui_vp_sideplayer_char->raise();
- ui_vp_player_char->raise();
- }
- else
- {
- ui_vp_player_char->raise();
- ui_vp_sideplayer_char->raise();
- }
- ui_vp_desk->raise();
- ui_vp_legacy_desk->raise();
- }
- else if (side == "pro")
- {
- // Almost the same thing happens here, but in reverse.
- int hor_offset = m_chatmessage[SELF_OFFSET].toInt();
- int vert_offset = 0;
- if (hor_offset < 0)
- {
- // We don't want to RAISE the char off the floor.
- vert_offset = -1 * hor_offset / 10;
- }
- ui_vp_player_char->move(ui_viewport->width() * hor_offset / 100, ui_viewport->height() * vert_offset / 100);
-
- // We do the same with the second character.
- int hor2_offset = m_chatmessage[OTHER_OFFSET].toInt();
- int vert2_offset = 0;
- if (hor2_offset < 0)
- {
- vert2_offset = -1 * hor2_offset / 10;
- }
- ui_vp_sideplayer_char->move(ui_viewport->width() * hor2_offset / 100, ui_viewport->height() * vert2_offset / 100);
-
- // Finally, we reorder them based on who is more to the right.
- if (hor2_offset <= hor_offset)
- {
- ui_vp_sideplayer_char->raise();
- ui_vp_player_char->raise();
- }
- else
- {
- ui_vp_player_char->raise();
- ui_vp_sideplayer_char->raise();
- }
- ui_vp_desk->raise();
- ui_vp_legacy_desk->raise();
- }
- else
- {
- // In every other case, the person more to the left is on top.
- // These cases also don't move the characters down.
- int hor_offset = m_chatmessage[SELF_OFFSET].toInt();
- ui_vp_player_char->move(ui_viewport->width() * hor_offset / 100, 0);
-
- // We do the same with the second character.
- int hor2_offset = m_chatmessage[OTHER_OFFSET].toInt();
- ui_vp_sideplayer_char->move(ui_viewport->width() * hor2_offset / 100, 0);
-
- // Finally, we reorder them based on who is more to the left.
- // The person more to the left is more in the front.
- if (hor2_offset >= hor_offset)
- {
- ui_vp_sideplayer_char->raise();
- ui_vp_player_char->raise();
- }
- else
- {
- ui_vp_player_char->raise();
- ui_vp_sideplayer_char->raise();
- }
- ui_vp_desk->raise();
- ui_vp_legacy_desk->raise();
- }
- // We should probably also play the other character's idle emote.
- if (ao_app->flipping_enabled && m_chatmessage[OTHER_FLIP].toInt() == 1)
- ui_vp_sideplayer_char->set_flipped(true);
- else
- ui_vp_sideplayer_char->set_flipped(false);
- ui_vp_sideplayer_char->use_networked_framehell = false;
- ui_vp_sideplayer_char->play_idle(m_chatmessage[OTHER_NAME], m_chatmessage[OTHER_EMOTE]);
- }
- else
- {
- // If the server understands other characters, but there
- // really is no second character, hide 'em, and center the first.
- ui_vp_sideplayer_char->hide();
- ui_vp_sideplayer_char->stop();
- ui_vp_sideplayer_char->move(0,0);
-
- ui_vp_player_char->move(0,0);
- }
- }
- }
- if (m_chatmessage[SCREENSHAKE] == "1")
- {
- this->doScreenShake();
- }
- switch (emote_mod)
- {
- case 1: case 2: case 6:
- play_preanim(false);
- break;
- case 0: case 5:
- if (m_chatmessage[NONINTERRUPTING_PRE].toInt() == 0)
- handle_chatmessage_3();
- else
- play_preanim(true);
- break;
- default:
- qDebug() << "W: invalid emote mod: " << QString::number(emote_mod);
- }
-}
+
+ // Making the second character appear.
+ if (m_chatmessage[OTHER_CHARID].isEmpty()) {
+ // If there is no second character, hide 'em, and center the first.
+ ui_vp_sideplayer_char->hide();
+ ui_vp_sideplayer_char->move(0, 0);
+
+ ui_vp_player_char->move(0, 0);
+ }
+ else {
+ bool ok;
+ int got_other_charid = m_chatmessage[OTHER_CHARID].toInt(&ok);
+ if (ok) {
+ if (got_other_charid > -1) {
+ // If there is, show them!
+ ui_vp_sideplayer_char->show();
+
+ // Depending on where we are, we offset the characters, and reorder
+ // their stacking.
+ if (side == "def") {
+
+ // We also move the character down depending on how far the are to the
+ // right.
+ int hor_offset = m_chatmessage[SELF_OFFSET].toInt();
+ int vert_offset = 0;
+ if (hor_offset > 0) {
+ vert_offset = hor_offset / 10;
+ }
+ ui_vp_player_char->move(ui_viewport->width() * hor_offset / 100,
+ ui_viewport->height() * vert_offset / 100);
+
+ // We do the same with the second character.
+ int hor2_offset = m_chatmessage[OTHER_OFFSET].toInt();
+ int vert2_offset = 0;
+ if (hor2_offset > 0) {
+ vert2_offset = hor2_offset / 10;
+ }
+ ui_vp_sideplayer_char->move(ui_viewport->width() * hor2_offset / 100,
+ ui_viewport->height() * vert2_offset /
+ 100);
+
+ // Finally, we reorder them based on who is more to the left.
+ // The person more to the left is more in the front.
+ if (hor2_offset >= hor_offset) {
+ ui_vp_sideplayer_char->raise();
+ ui_vp_player_char->raise();
+ }
+ else {
+ ui_vp_player_char->raise();
+ ui_vp_sideplayer_char->raise();
+ }
+ ui_vp_desk->raise();
+ ui_vp_legacy_desk->raise();
+ }
+ else if (side == "pro") {
+ // Almost the same thing happens here, but in reverse.
+ int hor_offset = m_chatmessage[SELF_OFFSET].toInt();
+ int vert_offset = 0;
+ if (hor_offset < 0) {
+ // We don't want to RAISE the char off the floor.
+ vert_offset = -1 * hor_offset / 10;
+ }
+ ui_vp_player_char->move(ui_viewport->width() * hor_offset / 100,
+ ui_viewport->height() * vert_offset / 100);
+
+ // We do the same with the second character.
+ int hor2_offset = m_chatmessage[OTHER_OFFSET].toInt();
+ int vert2_offset = 0;
+ if (hor2_offset < 0) {
+ vert2_offset = -1 * hor2_offset / 10;
+ }
+ ui_vp_sideplayer_char->move(ui_viewport->width() * hor2_offset / 100,
+ ui_viewport->height() * vert2_offset /
+ 100);
+
+ // Finally, we reorder them based on who is more to the right.
+ if (hor2_offset <= hor_offset) {
+ ui_vp_sideplayer_char->raise();
+ ui_vp_player_char->raise();
+ }
+ else {
+ ui_vp_player_char->raise();
+ ui_vp_sideplayer_char->raise();
+ }
+ ui_vp_desk->raise();
+ ui_vp_legacy_desk->raise();
+ }
+ else {
+ // In every other case, the person more to the left is on top.
+ // These cases also don't move the characters down.
+ int hor_offset = m_chatmessage[SELF_OFFSET].toInt();
+ ui_vp_player_char->move(ui_viewport->width() * hor_offset / 100, 0);
+
+ // We do the same with the second character.
+ int hor2_offset = m_chatmessage[OTHER_OFFSET].toInt();
+ ui_vp_sideplayer_char->move(ui_viewport->width() * hor2_offset / 100,
+ 0);
+
+ // Finally, we reorder them based on who is more to the left.
+ // The person more to the left is more in the front.
+ if (hor2_offset >= hor_offset) {
+ ui_vp_sideplayer_char->raise();
+ ui_vp_player_char->raise();
+ }
+ else {
+ ui_vp_player_char->raise();
+ ui_vp_sideplayer_char->raise();
+ }
+ ui_vp_desk->raise();
+ ui_vp_legacy_desk->raise();
+ }
+ // We should probably also play the other character's idle emote.
+ if (ao_app->flipping_enabled && m_chatmessage[OTHER_FLIP].toInt() == 1)
+ ui_vp_sideplayer_char->set_flipped(true);
+ else
+ ui_vp_sideplayer_char->set_flipped(false);
+ ui_vp_sideplayer_char->play_idle(m_chatmessage[OTHER_NAME],
+ m_chatmessage[OTHER_EMOTE]);
+ ui_vp_sideplayer_char->use_networked_framehell = false;
+ }
+ else {
+ // If the server understands other characters, but there
+ // really is no second character, hide 'em, and center the first.
+ ui_vp_sideplayer_char->hide();
+ ui_vp_sideplayer_char->stop();
+ ui_vp_sideplayer_char->move(0, 0);
+
+ ui_vp_player_char->move(0, 0);
+ }
+ }
+ }
+ if (m_chatmessage[SCREENSHAKE] == "1") {
+ this->doScreenShake();
+ }
+ switch (emote_mod) {
+ case 1:
+ case 2:
+ case 6:
+ play_preanim(false);
+ break;
+ case 0:
+ case 5:
+ if (m_chatmessage[NONINTERRUPTING_PRE].toInt() == 0)
+ handle_chatmessage_3();
+ else {
+
+ play_preanim(true);
+ }
+ break;
+ default:
+ qDebug() << "W: invalid emote mod: " << QString::number(emote_mod);
+ }
+}
void Courtroom::realization_done() { ui_vp_realization->hide(); }
-
-void Courtroom::doScreenShake()
-{
- if(!ao_app->is_shakeandflash_enabled())
- return;
- screenshake_group = new QParallelAnimationGroup;
- screenshake_animation = new QPropertyAnimation(ui_viewport, "pos", this);
- chatbox_screenshake_animation = new QPropertyAnimation(ui_vp_chatbox, "pos", this);
- int screen_x = get_theme_pos("viewport").x();
- int screen_y = get_theme_pos("viewport").y();
- QPoint pos_default = QPoint(screen_x, screen_y);
- QPoint pos1 = QPoint(screen_x + 3, screen_y + -5);
- QPoint pos2 = QPoint(screen_x + 3, screen_y + -5);
- QPoint pos3 = QPoint(screen_x + -3, screen_y + 5);
- QPoint pos4 = QPoint(screen_x + 3, screen_y + -5);
- QPoint pos5 = QPoint(screen_x + -3,screen_y + -5);
-
- int chatbox_x = get_theme_pos("ao2_chatbox").x();
- int chatbox_y = get_theme_pos("ao2_chatbox").y();
- QPoint chatbox_pos_default = QPoint(chatbox_x, chatbox_y);
- QPoint chatbox_pos1 = QPoint(chatbox_x + 3, chatbox_y + -5);
- QPoint chatbox_pos2 = QPoint(chatbox_x + 3, chatbox_y + -5);
- QPoint chatbox_pos3 = QPoint(chatbox_x + -3, chatbox_y + 5);
- QPoint chatbox_pos4 = QPoint(chatbox_x + 3, chatbox_y + -5);
- QPoint chatbox_pos5 = QPoint(chatbox_x + -3,chatbox_y + -5);
-
- screenshake_animation->setDuration(200);
- screenshake_animation->setKeyValueAt(0, pos_default);
- screenshake_animation->setKeyValueAt(0.1, pos1);
- screenshake_animation->setKeyValueAt(0.3, pos2);
- screenshake_animation->setKeyValueAt(0.5, pos3);
- screenshake_animation->setKeyValueAt(0.7, pos4);
- screenshake_animation->setKeyValueAt(0.9, pos5);
- screenshake_animation->setEndValue(pos_default);
- screenshake_animation->setEasingCurve(QEasingCurve::Linear);
- chatbox_screenshake_animation->setDuration(200);
- chatbox_screenshake_animation->setKeyValueAt(0, chatbox_pos_default);
- chatbox_screenshake_animation->setKeyValueAt(0.1, chatbox_pos3);
- chatbox_screenshake_animation->setKeyValueAt(0.3, chatbox_pos5);
- chatbox_screenshake_animation->setKeyValueAt(0.5, chatbox_pos2);
- chatbox_screenshake_animation->setKeyValueAt(0.7, chatbox_pos1);
- chatbox_screenshake_animation->setKeyValueAt(0.9, chatbox_pos4);
- chatbox_screenshake_animation->setEndValue(chatbox_pos_default);
- chatbox_screenshake_animation->setEasingCurve(QEasingCurve::Linear);
-
- screenshake_group->addAnimation(screenshake_animation);
- screenshake_group->addAnimation(chatbox_screenshake_animation);
- screenshake_group->start(QAbstractAnimation::DeletionPolicy::DeleteWhenStopped);
-}
-
-void Courtroom::handle_chatmessage_3()
-{
+
+void Courtroom::doScreenShake()
+{
+ if (!ao_app->is_shakeandflash_enabled())
+ return;
+ screenshake_group = new QParallelAnimationGroup;
+ screenshake_animation = new QPropertyAnimation(ui_viewport, "pos", this);
+ chatbox_screenshake_animation =
+ new QPropertyAnimation(ui_vp_chatbox, "pos", this);
+ int screen_x = get_theme_pos("viewport").x();
+ int screen_y = get_theme_pos("viewport").y();
+ QPoint pos_default = QPoint(screen_x, screen_y);
+ QPoint pos1 = QPoint(screen_x + 3, screen_y + -5);
+ QPoint pos2 = QPoint(screen_x + 3, screen_y + -5);
+ QPoint pos3 = QPoint(screen_x + -3, screen_y + 5);
+ QPoint pos4 = QPoint(screen_x + 3, screen_y + -5);
+ QPoint pos5 = QPoint(screen_x + -3, screen_y + -5);
+
+ int chatbox_x = get_theme_pos("ao2_chatbox").x();
+ int chatbox_y = get_theme_pos("ao2_chatbox").y();
+ QPoint chatbox_pos_default = QPoint(chatbox_x, chatbox_y);
+ QPoint chatbox_pos1 = QPoint(chatbox_x + 3, chatbox_y + -5);
+ QPoint chatbox_pos2 = QPoint(chatbox_x + 3, chatbox_y + -5);
+ QPoint chatbox_pos3 = QPoint(chatbox_x + -3, chatbox_y + 5);
+ QPoint chatbox_pos4 = QPoint(chatbox_x + 3, chatbox_y + -5);
+ QPoint chatbox_pos5 = QPoint(chatbox_x + -3, chatbox_y + -5);
+
+ screenshake_animation->setDuration(200);
+ screenshake_animation->setKeyValueAt(0, pos_default);
+ screenshake_animation->setKeyValueAt(0.1, pos1);
+ screenshake_animation->setKeyValueAt(0.3, pos2);
+ screenshake_animation->setKeyValueAt(0.5, pos3);
+ screenshake_animation->setKeyValueAt(0.7, pos4);
+ screenshake_animation->setKeyValueAt(0.9, pos5);
+ screenshake_animation->setEndValue(pos_default);
+ screenshake_animation->setEasingCurve(QEasingCurve::Linear);
+ chatbox_screenshake_animation->setDuration(200);
+ chatbox_screenshake_animation->setKeyValueAt(0, chatbox_pos_default);
+ chatbox_screenshake_animation->setKeyValueAt(0.1, chatbox_pos3);
+ chatbox_screenshake_animation->setKeyValueAt(0.3, chatbox_pos5);
+ chatbox_screenshake_animation->setKeyValueAt(0.5, chatbox_pos2);
+ chatbox_screenshake_animation->setKeyValueAt(0.7, chatbox_pos1);
+ chatbox_screenshake_animation->setKeyValueAt(0.9, chatbox_pos4);
+ chatbox_screenshake_animation->setEndValue(chatbox_pos_default);
+ chatbox_screenshake_animation->setEasingCurve(QEasingCurve::Linear);
+
+ screenshake_group->addAnimation(screenshake_animation);
+ screenshake_group->addAnimation(chatbox_screenshake_animation);
+ screenshake_group->start(
+ QAbstractAnimation::DeletionPolicy::DeleteWhenStopped);
+}
+
+void Courtroom::handle_chatmessage_3()
+{
if (!log_goes_downwards && mirror_iclog)
ui_ic_chatlog->moveCursor(QTextCursor::Start);
else if (mirror_iclog)
ui_ic_chatlog->moveCursor(QTextCursor::End);
ui_ic_chatlog->setTextInteractionFlags(Qt::TextSelectableByMouse);
-
+
if (mirror_iclog) {
if (!ui_showname_enable->isChecked() || m_chatmessage[SHOWNAME] == "") {
if (first_message_sent && log_goes_downwards)
@@ -2150,229 +2189,219 @@ void Courtroom::handle_chatmessage_3()
}
}
start_chat_ticking();
- int f_evi_id = m_chatmessage[EVIDENCE_ID].toInt();
- QString f_side = m_chatmessage[SIDE];
-
- if (f_evi_id > 0 && f_evi_id <= local_evidence_list.size())
- {
- //shifted by 1 because 0 is no evidence per legacy standards
- QString f_image = local_evidence_list.at(f_evi_id - 1).image;
- //def jud and hlp should display the evidence icon on the RIGHT side
- bool is_left_side = !(f_side == "def" || f_side == "hlp" || f_side == "jud" || f_side == "jur");
- ui_vp_evidence_display->show_evidence(f_image, is_left_side, ui_sfx_slider->value());
- }
-
- int emote_mod = m_chatmessage[EMOTE_MOD].toInt();
-
- QString side = m_chatmessage[SIDE];
-
- if (emote_mod == 5 ||
- emote_mod == 6)
- {
- ui_vp_desk->hide();
- ui_vp_legacy_desk->hide();
-
- // Since we're zooming, hide the second character, and centre the first.
- ui_vp_sideplayer_char->hide();
- ui_vp_player_char->move(0,0);
-
- if (side == "pro" ||
- side == "hlp" ||
- side == "wit")
- ui_vp_speedlines->play("prosecution_speedlines");
- else
- ui_vp_speedlines->play("defense_speedlines");
-
- }
-
- int f_anim_state = 0;
- //BLUE is from an enum in datatypes.h
- bool text_is_blue = m_chatmessage[TEXT_COLOR].toInt() == BLUE;
-
- if (!text_is_blue && text_state == 1)
- {
- //talking
- f_anim_state = 2;
- entire_message_is_blue = false;
- }
- else
- {
- //idle
- f_anim_state = 3;
- entire_message_is_blue = true;
- }
-
- if (f_anim_state <= anim_state)
- return;
-
- ui_vp_player_char->stop();
+ int f_evi_id = m_chatmessage[EVIDENCE_ID].toInt();
+ QString f_side = m_chatmessage[SIDE];
+
+ if (f_evi_id > 0 && f_evi_id <= local_evidence_list.size()) {
+ // shifted by 1 because 0 is no evidence per legacy standards
+ QString f_image = local_evidence_list.at(f_evi_id - 1).image;
+ // def jud and hlp should display the evidence icon on the RIGHT side
+ bool is_left_side = !(f_side == "def" || f_side == "hlp" ||
+ f_side == "jud" || f_side == "jur");
+ ui_vp_evidence_display->show_evidence(f_image, is_left_side,
+ ui_sfx_slider->value());
+ }
+
+ int emote_mod = m_chatmessage[EMOTE_MOD].toInt();
+
+ QString side = m_chatmessage[SIDE];
+
+ if (emote_mod == 5 || emote_mod == 6) {
+ ui_vp_desk->hide();
+ ui_vp_legacy_desk->hide();
+
+ // Since we're zooming, hide the second character, and centre the first.
+ ui_vp_sideplayer_char->hide();
+ ui_vp_player_char->move(0, 0);
+
+ if (side == "pro" || side == "hlp" || side == "wit")
+ ui_vp_speedlines->play("prosecution_speedlines");
+ else
+ ui_vp_speedlines->play("defense_speedlines");
+ }
+
+ int f_anim_state = 0;
+ // BLUE is from an enum in datatypes.h
+ bool text_is_blue = m_chatmessage[TEXT_COLOR].toInt() == BLUE;
+
+ if (!text_is_blue && text_state == 1) {
+ // talking
+ f_anim_state = 2;
+ entire_message_is_blue = false;
+ }
+ else {
+ // idle
+ f_anim_state = 3;
+ entire_message_is_blue = true;
+ }
+
+ if (f_anim_state <= anim_state)
+ return;
+
+ ui_vp_player_char->stop();
QString f_char = "";
f_char = m_chatmessage[CHAR_NAME];
- QString f_emote = m_chatmessage[EMOTE];
-
- if (f_anim_state == 2) {
- ui_vp_player_char->play_talking(f_char, f_emote);
- anim_state = 2;
- }
- else
- {
- ui_vp_player_char->play_idle(f_char, f_emote);
- anim_state = 3;
- }
-
- QString f_message = m_chatmessage[MESSAGE];
- QStringList call_words = ao_app->get_call_words();
-
- for (QString word : call_words)
- {
- if (f_message.contains(word, Qt::CaseInsensitive))
- {
- modcall_player->play(ao_app->get_sfx("word_call"));
- ao_app->alert(this);
-
- break;
- }
- }
-
-}
-
+ QString f_emote = m_chatmessage[EMOTE];
+
+ if (f_anim_state == 2) {
+ ui_vp_player_char->play_talking(f_char, f_emote);
+ anim_state = 2;
+ }
+ else {
+ ui_vp_player_char->play_idle(f_char, f_emote);
+ anim_state = 3;
+ }
+
+ QString f_message = m_chatmessage[MESSAGE];
+ QStringList call_words = ao_app->get_call_words();
+
+ for (QString word : call_words) {
+ if (f_message.contains(word, Qt::CaseInsensitive)) {
+ modcall_player->play(ao_app->get_sfx("word_call"));
+ ao_app->alert(this);
+
+ break;
+ }
+ }
+}
+
QString Courtroom::filter_ic_text(QString p_text, bool skip_filter,
int chat_color)
-{
+{
// BMKCOMMENT
- // Get rid of centering.
+ // Get rid of centering.
if (p_text.startsWith(": ~~")) {
- // Don't forget, the p_text part actually everything after the name!
- // Hence why we check for ': ~~'.
-
- // Let's remove those two tildes, then.
- // : _ ~ ~
- // 0 1 2 3
- p_text.remove(2,2);
- }
-
- // Get rid of the inline-colouring.
- // I know, I know, excessive code duplication.
- // Nobody looks in here, I'm fine.
+ // Don't forget, the p_text part actually everything after the name!
+ // Hence why we check for ': ~~'.
+
+ // Let's remove those two tildes, then.
+ // : _ ~ ~
+ // 0 1 2 3
+ p_text.remove(2, 2);
+ }
+
+ // Get rid of the inline-colouring.
+ // I know, I know, excessive code duplication.
+ // Nobody looks in here, I'm fine.
int trick_check_pos = 1;
- bool ic_next_is_not_special = false;
- QString f_character = p_text.at(trick_check_pos);
- std::stack<INLINE_COLOURS> ic_colour_stack;
+ bool ic_next_is_not_special = false;
+ QString f_character = p_text.at(trick_check_pos);
+ std::stack<INLINE_COLOURS> ic_colour_stack;
QString final_text = ": ";
bool delay_pop = false;
while (trick_check_pos < p_text.size()) {
- f_character = p_text.at(trick_check_pos);
+ f_character = p_text.at(trick_check_pos);
if (!skip_filter) {
if (f_character == "<")
f_character = "&lt;";
else if (f_character == ">")
f_character = "&gt;";
}
- // Escape character.
+ // Escape character.
if (f_character == "\\" and !ic_next_is_not_special) {
- ic_next_is_not_special = true;
- p_text.remove(trick_check_pos,1);
+ ic_next_is_not_special = true;
+ p_text.remove(trick_check_pos, 1);
f_character = "";
if (p_text[trick_check_pos] == 'n') {
p_text[trick_check_pos] = ' ';
f_character = " ";
}
- }
-
- // Text speed modifier.
+ }
+
+ // Text speed modifier.
else if ((f_character == "{" || f_character == "}") &&
!ic_next_is_not_special) {
- p_text.remove(trick_check_pos,1);
+ p_text.remove(trick_check_pos, 1);
f_character = "";
- }
+ }
else if (f_character == "$" and !ic_next_is_not_special) {
- p_text.remove(trick_check_pos,1);
+ p_text.remove(trick_check_pos, 1);
f_character = "";
- }
+ }
else if (f_character == "@" and !ic_next_is_not_special) {
- p_text.remove(trick_check_pos,1);
+ p_text.remove(trick_check_pos, 1);
f_character = "";
- }
-
- // Orange inline colourisation.
+ }
+
+ // Orange inline colourisation.
else if (f_character == "|" and !ic_next_is_not_special) {
if (!ic_colour_stack.empty()) {
if (ic_colour_stack.top() == INLINE_ORANGE) {
- ic_colour_stack.pop();
- p_text.remove(trick_check_pos,1);
- }
+ ic_colour_stack.pop();
+ p_text.remove(trick_check_pos, 1);
+ }
else {
- ic_colour_stack.push(INLINE_ORANGE);
- p_text.remove(trick_check_pos,1);
- }
- }
+ ic_colour_stack.push(INLINE_ORANGE);
+ p_text.remove(trick_check_pos, 1);
+ }
+ }
else {
- ic_colour_stack.push(INLINE_ORANGE);
- p_text.remove(trick_check_pos,1);
- }
+ ic_colour_stack.push(INLINE_ORANGE);
+ p_text.remove(trick_check_pos, 1);
+ }
f_character = "";
- }
-
- // Blue inline colourisation.
+ }
+
+ // Blue inline colourisation.
else if (f_character == "(" and !ic_next_is_not_special) {
- ic_colour_stack.push(INLINE_BLUE);
+ ic_colour_stack.push(INLINE_BLUE);
if (!colorf_iclog)
- trick_check_pos++;
- }
+ trick_check_pos++;
+ }
else if (f_character == ")" and !ic_next_is_not_special and
!ic_colour_stack.empty()) {
if (ic_colour_stack.top() == INLINE_BLUE) {
// ic_colour_stack.pop();
delay_pop = true;
if (!colorf_iclog)
- trick_check_pos++;
- }
+ trick_check_pos++;
+ }
else {
- ic_next_is_not_special = true;
- }
- }
-
- // Grey inline colourisation.
+ ic_next_is_not_special = true;
+ }
+ }
+
+ // Grey inline colourisation.
else if (f_character == "[" and !ic_next_is_not_special) {
- ic_colour_stack.push(INLINE_GREY);
+ ic_colour_stack.push(INLINE_GREY);
if (!colorf_iclog)
- trick_check_pos++;
- }
+ trick_check_pos++;
+ }
else if (f_character == "]" and !ic_next_is_not_special and
!ic_colour_stack.empty()) {
if (ic_colour_stack.top() == INLINE_GREY) {
// ic_colour_stack.pop();
delay_pop = true;
if (!colorf_iclog)
- trick_check_pos++;
- }
+ trick_check_pos++;
+ }
else {
- ic_next_is_not_special = true;
- }
- }
-
- // Green inline colourisation.
+ ic_next_is_not_special = true;
+ }
+ }
+
+ // Green inline colourisation.
else if (f_character == "`" and !ic_next_is_not_special) {
if (!ic_colour_stack.empty()) {
if (ic_colour_stack.top() == INLINE_GREEN) {
- ic_colour_stack.pop();
- p_text.remove(trick_check_pos,1);
- }
+ ic_colour_stack.pop();
+ p_text.remove(trick_check_pos, 1);
+ }
else {
- ic_colour_stack.push(INLINE_GREEN);
- p_text.remove(trick_check_pos,1);
- }
- }
+ ic_colour_stack.push(INLINE_GREEN);
+ p_text.remove(trick_check_pos, 1);
+ }
+ }
else {
- ic_colour_stack.push(INLINE_GREEN);
- p_text.remove(trick_check_pos,1);
- }
+ ic_colour_stack.push(INLINE_GREEN);
+ p_text.remove(trick_check_pos, 1);
+ }
f_character = "";
- }
+ }
if (colorf_iclog && f_character != "") {
- ic_next_is_not_special = false;
+ ic_next_is_not_special = false;
if (!ic_colour_stack.empty()) {
// p_text.remove(trick_check_pos,1);
trick_check_pos++;
@@ -2467,14 +2496,14 @@ QString Courtroom::filter_ic_text(QString p_text, bool skip_filter,
}
else if (f_character != "") {
trick_check_pos++;
- }
- }
-
+ }
+ }
+
if (colorf_iclog)
return final_text;
else {
- return p_text;
-}
+ return p_text;
+ }
}
/*
* Appends text to the ic log.
@@ -2486,29 +2515,29 @@ QString Courtroom::filter_ic_text(QString p_text, bool skip_filter,
* skip_filter If we are sending appending text such as html so we skip the
* filter \param chat_color The color of the message sent
*/
-
+
void Courtroom::append_ic_text(QString p_text, QString p_name,
bool is_songchange, bool force_filter,
bool skip_filter, int chat_color)
-{
-
- QTextCharFormat bold;
- QTextCharFormat normal;
- QTextCharFormat italics;
- bold.setFontWeight(QFont::Bold);
- normal.setFontWeight(QFont::Normal);
- italics.setFontItalic(true);
- const QTextCursor old_cursor = ui_ic_chatlog->textCursor();
- const int old_scrollbar_value = ui_ic_chatlog->verticalScrollBar()->value();
-
+{
+
+ QTextCharFormat bold;
+ QTextCharFormat normal;
+ QTextCharFormat italics;
+ bold.setFontWeight(QFont::Bold);
+ normal.setFontWeight(QFont::Normal);
+ italics.setFontItalic(true);
+ const QTextCursor old_cursor = ui_ic_chatlog->textCursor();
+ const int old_scrollbar_value = ui_ic_chatlog->verticalScrollBar()->value();
+
if ((!is_songchange && !mirror_iclog) || force_filter)
p_text = filter_ic_text(p_text, skip_filter, chat_color);
-
+
if (log_goes_downwards) {
const bool is_scrolled_down =
old_scrollbar_value == ui_ic_chatlog->verticalScrollBar()->maximum();
-
- ui_ic_chatlog->moveCursor(QTextCursor::End);
+
+ ui_ic_chatlog->moveCursor(QTextCursor::End);
if (!(is_songchange && mirror_iclog)) {
// The only case where no new log entry should be made is when there is a
// music entry while mirror log is active This is to protect the log, as
@@ -2517,63 +2546,63 @@ void Courtroom::append_ic_text(QString p_text, QString p_name,
// If the first message hasn't been sent, and we are handling basic
// text, we put the name without the newline.
- if (!first_message_sent)
- ui_ic_chatlog->textCursor().insertText(p_name, bold);
+ if (!first_message_sent)
+ ui_ic_chatlog->textCursor().insertText(p_name, bold);
else if (force_filter || is_songchange || !mirror_iclog) {
// Otherwise we just add the plaintext with the new line.
- ui_ic_chatlog->textCursor().insertText('\n' + p_name, bold);
- }
+ ui_ic_chatlog->textCursor().insertText('\n' + p_name, bold);
+ }
first_message_sent = true;
-
+
if (is_songchange) {
// If its a song with mirror mode enabled, we do not need to repeat it
// as it is already shown in the ooc.
- ui_ic_chatlog->textCursor().insertText(" has played a song: ", normal);
- ui_ic_chatlog->textCursor().insertText(p_text + ".", italics);
- }
+ ui_ic_chatlog->textCursor().insertText(" has played a song: ", normal);
+ ui_ic_chatlog->textCursor().insertText(p_text + ".", italics);
+ }
else if (colorf_iclog && (!mirror_iclog || force_filter)) {
// if we are handling already formatted text and we have enabled colors
// in the iclog, then we insert the text
ui_ic_chatlog->textCursor().insertHtml(p_text);
- }
-
+ }
+
else if ((!colorf_iclog && !mirror_iclog) || force_filter) {
// If html is not enabled then we insert it as plain text.
ui_ic_chatlog->textCursor().insertText(p_text, normal);
}
}
- // If we got too many blocks in the current log, delete some from the top.
+ // If we got too many blocks in the current log, delete some from the top.
while (ui_ic_chatlog->document()->blockCount() > log_maximum_blocks &&
log_maximum_blocks > 0) {
- ui_ic_chatlog->moveCursor(QTextCursor::Start);
- ui_ic_chatlog->textCursor().select(QTextCursor::BlockUnderCursor);
- ui_ic_chatlog->textCursor().removeSelectedText();
- ui_ic_chatlog->textCursor().deleteChar();
+ ui_ic_chatlog->moveCursor(QTextCursor::Start);
+ ui_ic_chatlog->textCursor().select(QTextCursor::BlockUnderCursor);
+ ui_ic_chatlog->textCursor().removeSelectedText();
+ ui_ic_chatlog->textCursor().deleteChar();
// qDebug() << ui_ic_chatlog->document()->blockCount() << " < " <<
// log_maximum_blocks;
- }
-
+ }
+
if (old_cursor.hasSelection() || !is_scrolled_down) {
// The user has selected text or scrolled away from the bottom: maintain
// position.
- ui_ic_chatlog->setTextCursor(old_cursor);
- ui_ic_chatlog->verticalScrollBar()->setValue(old_scrollbar_value);
- }
+ ui_ic_chatlog->setTextCursor(old_cursor);
+ ui_ic_chatlog->verticalScrollBar()->setValue(old_scrollbar_value);
+ }
else {
// The user hasn't selected any text and the scrollbar is at the bottom:
// scroll to the bottom.
- ui_ic_chatlog->moveCursor(QTextCursor::End);
+ ui_ic_chatlog->moveCursor(QTextCursor::End);
ui_ic_chatlog->verticalScrollBar()->setValue(
ui_ic_chatlog->verticalScrollBar()->maximum());
- }
- }
+ }
+ }
else {
const bool is_scrolled_up =
old_scrollbar_value == ui_ic_chatlog->verticalScrollBar()->minimum();
-
- ui_ic_chatlog->moveCursor(QTextCursor::Start);
+
+ ui_ic_chatlog->moveCursor(QTextCursor::Start);
if (!(is_songchange && mirror_iclog)) {
// The only case where no new log entry should be made is when there is a
// music entry while mirror log is active This is to protect the log, as
@@ -2591,15 +2620,15 @@ void Courtroom::append_ic_text(QString p_text, QString p_name,
if (!first_message_sent)
first_message_sent = true;
-
- ui_ic_chatlog->textCursor().insertText(p_name, bold);
+
+ ui_ic_chatlog->textCursor().insertText(p_name, bold);
}
-
+
if (is_songchange) {
- ui_ic_chatlog->textCursor().insertText(" has played a song: ", normal);
- ui_ic_chatlog->textCursor().insertText(p_text + "." + '\n', italics);
- }
-
+ ui_ic_chatlog->textCursor().insertText(" has played a song: ", normal);
+ ui_ic_chatlog->textCursor().insertText(p_text + "." + '\n', italics);
+ }
+
else if (colorf_iclog && (!mirror_iclog || force_filter)) {
ui_ic_chatlog->textCursor().insertHtml(p_text);
}
@@ -2613,174 +2642,174 @@ void Courtroom::append_ic_text(QString p_text, QString p_name,
// bottom.
while (ui_ic_chatlog->document()->blockCount() > log_maximum_blocks &&
log_maximum_blocks > 0) {
- ui_ic_chatlog->moveCursor(QTextCursor::End);
- ui_ic_chatlog->textCursor().select(QTextCursor::BlockUnderCursor);
- ui_ic_chatlog->textCursor().removeSelectedText();
- ui_ic_chatlog->textCursor().deletePreviousChar();
+ ui_ic_chatlog->moveCursor(QTextCursor::End);
+ ui_ic_chatlog->textCursor().select(QTextCursor::BlockUnderCursor);
+ ui_ic_chatlog->textCursor().removeSelectedText();
+ ui_ic_chatlog->textCursor().deletePreviousChar();
// qDebug() << ui_ic_chatlog->document()->blockCount() << " < " <<
// log_maximum_blocks;
- }
-
+ }
+
if (old_cursor.hasSelection() || !is_scrolled_up) {
// The user has selected text or scrolled away from the top: maintain
// position.
- ui_ic_chatlog->setTextCursor(old_cursor);
- ui_ic_chatlog->verticalScrollBar()->setValue(old_scrollbar_value);
- }
+ ui_ic_chatlog->setTextCursor(old_cursor);
+ ui_ic_chatlog->verticalScrollBar()->setValue(old_scrollbar_value);
+ }
else {
// The user hasn't selected any text and the scrollbar is at the top:
// scroll to the top.
- ui_ic_chatlog->moveCursor(QTextCursor::Start);
+ ui_ic_chatlog->moveCursor(QTextCursor::Start);
ui_ic_chatlog->verticalScrollBar()->setValue(
ui_ic_chatlog->verticalScrollBar()->minimum());
- }
- }
-}
-
-void Courtroom::play_preanim(bool noninterrupting)
-{
- QString f_char = m_chatmessage[CHAR_NAME];
- QString f_preanim = m_chatmessage[PRE_EMOTE];
-
- //all time values in char.inis are multiplied by a constant(time_mod) to get the actual time
- int ao2_duration = ao_app->get_ao2_preanim_duration(f_char, f_preanim);
- int text_delay = ao_app->get_text_delay(f_char, f_preanim) * time_mod;
- int sfx_delay = m_chatmessage[SFX_DELAY].toInt() * 60;
- bool looping_sfx = m_chatmessage[LOOPING_SFX] == "1";
- int preanim_duration;
-
- if (ao2_duration < 0)
- preanim_duration = ao_app->get_preanim_duration(f_char, f_preanim);
- else
- preanim_duration = ao2_duration;
- sfx_player->setLooping(looping_sfx);
- sfx_delay_timer->start(sfx_delay);
- QString anim_to_find = ao_app->get_image_suffix(ao_app->get_character_path(f_char, f_preanim));
- if (!file_exists(anim_to_find) ||
- preanim_duration < 0)
- {
- if (noninterrupting)
- anim_state = 4;
- else
- anim_state = 1;
- preanim_done();
- qDebug() << "could not find " + anim_to_find;
- return;
- }
-
- ui_vp_player_char->play_pre(f_char, f_preanim, preanim_duration);
- if (noninterrupting)
- anim_state = 4;
- else
- anim_state = 1;
-
- if (text_delay >= 0)
- text_delay_timer->start(text_delay);
-
- if (noninterrupting)
- handle_chatmessage_3();
-}
-
-void Courtroom::preanim_done()
-{
- anim_state = 1;
- handle_chatmessage_3();
-}
-
-void Courtroom::doRealization()
-{
+ }
+ }
+}
+
+void Courtroom::play_preanim(bool noninterrupting)
+{
+ QString f_char = m_chatmessage[CHAR_NAME];
+ QString f_preanim = m_chatmessage[PRE_EMOTE];
+
+ // all time values in char.inis are multiplied by a constant(time_mod) to get
+ // the actual time
+ int ao2_duration = ao_app->get_ao2_preanim_duration(f_char, f_preanim);
+ int text_delay = ao_app->get_text_delay(f_char, f_preanim) * time_mod;
+ int sfx_delay = m_chatmessage[SFX_DELAY].toInt() * 60;
+ bool looping_sfx = m_chatmessage[LOOPING_SFX] == "1";
+ int preanim_duration;
+
+ if (ao2_duration < 0)
+ preanim_duration = ao_app->get_preanim_duration(f_char, f_preanim);
+ else
+ preanim_duration = ao2_duration;
+ sfx_player->setLooping(looping_sfx);
+ sfx_delay_timer->start(sfx_delay);
+ QString anim_to_find =
+ ao_app->get_image_suffix(ao_app->get_character_path(f_char, f_preanim));
+ if (!file_exists(anim_to_find) || preanim_duration < 0) {
+ if (noninterrupting)
+ anim_state = 4;
+ else
+ anim_state = 1;
+ preanim_done();
+ qDebug() << "could not find " + anim_to_find;
+ return;
+ }
+
+ ui_vp_player_char->play_pre(f_char, f_preanim, preanim_duration);
+ if (noninterrupting)
+ anim_state = 4;
+ else
+ anim_state = 1;
+
+ if (text_delay >= 0)
+ text_delay_timer->start(text_delay);
+
+ if (noninterrupting)
+ handle_chatmessage_3();
+}
+
+void Courtroom::preanim_done()
+{
+ anim_state = 1;
+ handle_chatmessage_3();
+}
+
+void Courtroom::doRealization()
+{
realization_timer->stop();
- if(!ao_app->is_shakeandflash_enabled())
- return;
+ if (!ao_app->is_shakeandflash_enabled())
+ return;
ui_vp_realization->play("realizationflash", "", "", 90);
-}
-
-void Courtroom::start_chat_ticking()
-{
- //we need to ensure that the text isn't already ticking because this function can be called by two logic paths
- if (text_state != 0)
- return;
-
- if (m_chatmessage[REALIZATION] == "1")
- {
- this->doRealization();
- misc_sfx_player->play(ao_app->get_custom_realization(m_chatmessage[CHAR_NAME]));
- }
- if (m_chatmessage[SCREENSHAKE] == "1")
- {
- this->doScreenShake();
- }
- ui_vp_message->clear();
- set_text_color();
- rainbow_counter = 0;
-
- if (chatmessage_is_empty)
- {
- //since the message is empty, it's technically done ticking
- text_state = 2;
- return;
- }
-
- // At this point, we'd do well to clear the inline colour stack.
- // This stops it from flowing into next messages.
- while (!inline_colour_stack.empty())
- {
- inline_colour_stack.pop();
- }
-
- ui_vp_chatbox->show();
-
- tick_pos = 0;
- blip_pos = 0;
-
- // Just in case we somehow got inline blue text left over from a previous message,
- // let's set it to false.
- inline_blue_depth = 0;
-
- // At the start of every new message, we set the text speed to the default.
- current_display_speed = 3;
- chat_tick_timer->start(message_display_speed[current_display_speed]);
-
+}
+
+void Courtroom::start_chat_ticking()
+{
+ // we need to ensure that the text isn't already ticking because this function
+ // can be called by two logic paths
+ if (text_state != 0)
+ return;
+
+ if (m_chatmessage[REALIZATION] == "1") {
+ this->doRealization();
+ misc_sfx_player->play(
+ ao_app->get_custom_realization(m_chatmessage[CHAR_NAME]));
+ }
+ if (m_chatmessage[SCREENSHAKE] == "1") {
+ this->doScreenShake();
+ }
+ if (m_chatmessage[SCREENSHAKE] == "1") {
+ this->doScreenShake();
+ }
+ ui_vp_message->clear();
+ set_text_color();
+ rainbow_counter = 0;
+
+ if (chatmessage_is_empty) {
+ // since the message is empty, it's technically done ticking
+ text_state = 2;
+ return;
+ }
+
+ // At this point, we'd do well to clear the inline colour stack.
+ // This stops it from flowing into next messages.
+ while (!inline_colour_stack.empty()) {
+ inline_colour_stack.pop();
+ }
+
+ ui_vp_chatbox->show();
+
+ tick_pos = 0;
+ blip_pos = 0;
+
+ // Just in case we somehow got inline blue text left over from a previous
+ // message, let's set it to false.
+ inline_blue_depth = 0;
+
+ // At the start of every new message, we set the text speed to the default.
+ current_display_speed = 3;
+ chat_tick_timer->start(message_display_speed[current_display_speed]);
+
QString f_char = m_chatmessage[CHAR_NAME];
QString f_gender = ao_app->get_gender(f_char);
-
- blip_player->set_blips(ao_app->get_sfx_suffix("sfx-blip" + f_gender));
-
- //means text is currently ticking
- text_state = 1;
-}
-
-void Courtroom::chat_tick()
-{
- //note: this is called fairly often(every 60 ms when char is talking)
- //do not perform heavy operations here
+
+ blip_player->set_blips(ao_app->get_sfx_suffix("sfx-blip" + f_gender));
+
+ // means text is currently ticking
+ text_state = 1;
+}
+
+void Courtroom::chat_tick()
+{
+ // note: this is called fairly often(every 60 ms when char is talking)
+ // do not perform heavy operations here
QString timem = QString::number(realization_timer->remainingTime());
qDebug() << "TIME: " << timem;
- QString f_message = m_chatmessage[MESSAGE];
-
+ QString f_message = m_chatmessage[MESSAGE];
+
// f_message.remove(0, tick_pos); SAFECHECK
- // Due to our new text speed system, we always need to stop the timer now.
- chat_tick_timer->stop();
+ // Due to our new text speed system, we always need to stop the timer now.
+ chat_tick_timer->stop();
int msg_delay = message_display_speed[current_display_speed];
- // Stops blips from playing when we have a formatting option.
- bool formatting_char = false;
-
- // If previously, we have detected that the message is centered, now
- // is the time to remove those two tildes at the start.
- if (message_is_centered)
- {
- f_message.remove(0,2);
- }
+ // Stops blips from playing when we have a formatting option.
+ bool formatting_char = false;
+
+ // If previously, we have detected that the message is centered, now
+ // is the time to remove those two tildes at the start.
+ if (message_is_centered) {
+ f_message.remove(0, 2);
+ }
QString f_char = m_chatmessage[CHAR_NAME];
if (log_goes_downwards && mirror_iclog)
ui_ic_chatlog->moveCursor(QTextCursor::End);
else if (!log_goes_downwards && mirror_iclog)
// ui_ic_chatlog->setTextCursor();
ui_ic_chatlog->moveCursor(QTextCursor::EndOfLine);
-
+
if (tick_pos >= f_message.size()) {
- text_state = 2;
+ text_state = 2;
if (mirror_iclog) {
// After we are finished printing the text we log it in the ic log.
append_ic_text(m_chatmessage[MESSAGE], m_chatmessage[CHAR_NAME], false);
@@ -2790,22 +2819,22 @@ void Courtroom::chat_tick()
ui_ic_chatlog->moveCursor(QTextCursor::Start);
}
if (anim_state != 4) {
- anim_state = 3;
+ anim_state = 3;
ui_vp_player_char->play_idle(f_char, m_chatmessage[EMOTE]);
- }
- }
-
+ }
+ }
+
else {
- QString f_character = f_message.at(tick_pos);
+ QString f_character = f_message.at(tick_pos);
- f_character = f_character.toHtmlEscaped();
+ f_character = f_character.toHtmlEscaped();
if (punctuation_chars.contains(f_character)) {
msg_delay *= punctuation_modifier;
// ui_vp_message->insertPlainText(f_character);
}
-
+
if (f_character == " ") {
- ui_vp_message->insertPlainText(" ");
+ ui_vp_message->insertPlainText(" ");
if (mirror_iclog)
ui_ic_chatlog->insertPlainText(" ");
}
@@ -2813,13 +2842,13 @@ void Courtroom::chat_tick()
this->doScreenShake();
formatting_char = true;
}
-
+
else if (f_character == "^" and !next_character_is_not_special) {
this->doRealization();
formatting_char = true;
}
- // Escape character.
+ // Escape character.
else if (f_character == "\\") {
if (f_message[tick_pos + 1] == 'n') {
ui_vp_message->insertHtml("<br>");
@@ -2830,56 +2859,56 @@ void Courtroom::chat_tick()
formatting_char = true;
}
else
- next_character_is_not_special = true;
- formatting_char = true;
+ next_character_is_not_special = true;
+ formatting_char = true;
msg_delay++;
- }
-
- // Text speed modifier.
+ }
+
+ // Text speed modifier.
else if (f_character == "{" and !next_character_is_not_special) {
- // ++, because it INCREASES delay!
- current_display_speed++;
+ // ++, because it INCREASES delay!
+ current_display_speed++;
msg_delay++;
- formatting_char = true;
- }
+ formatting_char = true;
+ }
else if (f_character == "}" and !next_character_is_not_special) {
- current_display_speed--;
+ current_display_speed--;
msg_delay++;
- formatting_char = true;
- }
-
+ formatting_char = true;
+ }
+
else if (f_character == "@" and !next_character_is_not_special) {
- this->doScreenShake();
- formatting_char = true;
- }
-
+ this->doScreenShake();
+ formatting_char = true;
+ }
+
else if (f_character == "$" and !next_character_is_not_special) {
- this->doRealization();
- formatting_char = true;
- }
-
- // Orange inline colourisation.
+ this->doRealization();
+ formatting_char = true;
+ }
+
+ // Orange inline colourisation.
else if (f_character == "|" and !next_character_is_not_special) {
if (!inline_colour_stack.empty()) {
if (inline_colour_stack.top() == INLINE_ORANGE) {
- inline_colour_stack.pop();
- }
+ inline_colour_stack.pop();
+ }
else {
- inline_colour_stack.push(INLINE_ORANGE);
- }
- }
+ inline_colour_stack.push(INLINE_ORANGE);
+ }
+ }
else {
- inline_colour_stack.push(INLINE_ORANGE);
- }
- formatting_char = true;
+ inline_colour_stack.push(INLINE_ORANGE);
+ }
+ formatting_char = true;
msg_delay++;
- }
-
- // Blue inline colourisation.
+ }
+
+ // Blue inline colourisation.
else if (f_character == "(" and
!next_character_is_not_special) // EXAMPLE HERE
- {
- inline_colour_stack.push(INLINE_BLUE);
+ {
+ inline_colour_stack.push(INLINE_BLUE);
ui_vp_message->insertHtml("<font color=\"" +
get_text_color(QString::number(BLUE)).name() +
"\">" + f_character + "</font>");
@@ -2887,21 +2916,21 @@ void Courtroom::chat_tick()
ui_ic_chatlog->insertHtml("<font color=\"" +
get_text_color(QString::number(BLUE)).name() +
"\">" + f_character + "</font>");
- // Increase how deep we are in inline blues.
- inline_blue_depth++;
-
- // Here, we check if the entire message is blue.
- // If it isn't, we stop talking.
+ // Increase how deep we are in inline blues.
+ inline_blue_depth++;
+
+ // Here, we check if the entire message is blue.
+ // If it isn't, we stop talking.
if (!entire_message_is_blue and anim_state != 4) {
f_char = m_chatmessage[CHAR_NAME];
- QString f_emote = m_chatmessage[EMOTE];
- ui_vp_player_char->play_idle(f_char, f_emote);
- }
- }
+ QString f_emote = m_chatmessage[EMOTE];
+ ui_vp_player_char->play_idle(f_char, f_emote);
+ }
+ }
else if (f_character == ")" and !next_character_is_not_special and
!inline_colour_stack.empty()) {
if (inline_colour_stack.top() == INLINE_BLUE) {
- inline_colour_stack.pop();
+ inline_colour_stack.pop();
ui_vp_message->insertHtml("<font color=\"" +
get_text_color(QString::number(BLUE)).name() +
"\">" + f_character + "</font>");
@@ -2909,11 +2938,11 @@ void Courtroom::chat_tick()
ui_ic_chatlog->insertHtml(
"<font color=\"" + get_text_color(QString::number(BLUE)).name() +
"\">" + f_character + "</font>");
- // Decrease how deep we are in inline blues.
- // Just in case, we do a check if we're above zero, but we should be.
+ // Decrease how deep we are in inline blues.
+ // Just in case, we do a check if we're above zero, but we should be.
if (inline_blue_depth > 0) {
- inline_blue_depth--;
- // Here, we check if the entire message is blue.
+ inline_blue_depth--;
+ // Here, we check if the entire message is blue.
// If it isn't, we start talking if we have completely climbed out of
// inline blues.
if (!entire_message_is_blue) {
@@ -2923,21 +2952,21 @@ void Courtroom::chat_tick()
!(tick_pos + 1 >= f_message.size())) {
QString f_char = char_name;
f_char = m_chatmessage[CHAR_NAME];
- QString f_emote = m_chatmessage[EMOTE];
- ui_vp_player_char->play_talking(f_char, f_emote);
- }
- }
- }
- }
+ QString f_emote = m_chatmessage[EMOTE];
+ ui_vp_player_char->play_talking(f_char, f_emote);
+ }
+ }
+ }
+ }
else {
- next_character_is_not_special = true;
- tick_pos--;
- }
- }
-
- // Grey inline colourisation.
+ next_character_is_not_special = true;
+ tick_pos--;
+ }
+ }
+
+ // Grey inline colourisation.
else if (f_character == "[" and !next_character_is_not_special) {
- inline_colour_stack.push(INLINE_GREY);
+ inline_colour_stack.push(INLINE_GREY);
ui_vp_message->insertHtml("<font color=\"" +
get_text_color("_inline_grey").name() + "\">" +
f_character + "</font>");
@@ -2949,7 +2978,7 @@ void Courtroom::chat_tick()
else if (f_character == "]" and !next_character_is_not_special and
!inline_colour_stack.empty()) {
if (inline_colour_stack.top() == INLINE_GREY) {
- inline_colour_stack.pop();
+ inline_colour_stack.pop();
ui_vp_message->insertHtml("<font color=\"" +
get_text_color("_inline_grey").name() +
"\">" + f_character + "</font>");
@@ -2959,33 +2988,33 @@ void Courtroom::chat_tick()
"\">" + f_character + "</font>");
}
else {
- next_character_is_not_special = true;
- tick_pos--;
- }
- }
-
- // Green inline colourisation.
+ next_character_is_not_special = true;
+ tick_pos--;
+ }
+ }
+
+ // Green inline colourisation.
else if (f_character == "`" and !next_character_is_not_special) {
if (!inline_colour_stack.empty()) {
if (inline_colour_stack.top() == INLINE_GREEN) {
- inline_colour_stack.pop();
- }
+ inline_colour_stack.pop();
+ }
else {
- inline_colour_stack.push(INLINE_GREEN);
- }
- }
+ inline_colour_stack.push(INLINE_GREEN);
+ }
+ }
else {
- inline_colour_stack.push(INLINE_GREEN);
- }
+ inline_colour_stack.push(INLINE_GREEN);
+ }
msg_delay++;
formatting_char = true;
- }
+ }
else {
- next_character_is_not_special = false;
+ next_character_is_not_special = false;
if (!inline_colour_stack.empty()) {
- switch (inline_colour_stack.top()) {
- case INLINE_ORANGE:
+ switch (inline_colour_stack.top()) {
+ case INLINE_ORANGE:
ui_vp_message->insertHtml(
"<font color=\"" +
get_text_color(QString::number(ORANGE)).name() + "\">" +
@@ -2995,8 +3024,8 @@ void Courtroom::chat_tick()
"<font color=\"" +
get_text_color(QString::number(ORANGE)).name() + "\">" +
f_character + "</font>");
- break;
- case INLINE_BLUE:
+ break;
+ case INLINE_BLUE:
ui_vp_message->insertHtml(
"<font color=\"" + get_text_color(QString::number(BLUE)).name() +
"\">" + f_character + "</font>");
@@ -3005,8 +3034,8 @@ void Courtroom::chat_tick()
"<font color=\"" +
get_text_color(QString::number(BLUE)).name() + "\">" +
f_character + "</font>");
- break;
- case INLINE_GREEN:
+ break;
+ case INLINE_GREEN:
ui_vp_message->insertHtml(
"<font color=\"" + get_text_color(QString::number(GREEN)).name() +
"\">" + f_character + "</font>");
@@ -3015,8 +3044,8 @@ void Courtroom::chat_tick()
"<font color=\"" +
get_text_color(QString::number(GREEN)).name() + "\">" +
f_character + "</font>");
- break;
- case INLINE_GREY:
+ break;
+ case INLINE_GREY:
ui_vp_message->insertHtml("<font color=\"" +
get_text_color("_inline_grey").name() +
"\">" + f_character + "</font>");
@@ -3024,33 +3053,33 @@ void Courtroom::chat_tick()
ui_ic_chatlog->insertHtml("<font color=\"" +
get_text_color("_inline_grey").name() +
"\">" + f_character + "</font>");
- break;
- }
- }
+ break;
+ }
+ }
else {
if (m_chatmessage[TEXT_COLOR].toInt() == RAINBOW) {
- QString html_color;
-
+ QString html_color;
+
switch (rainbow_counter) {
- case 0:
- html_color = get_text_color(QString::number(RED)).name();
- break;
- case 1:
- html_color = get_text_color(QString::number(ORANGE)).name();
- break;
- case 2:
- html_color = get_text_color(QString::number(YELLOW)).name();
- break;
- case 3:
- html_color = get_text_color(QString::number(GREEN)).name();
- break;
- default:
- html_color = get_text_color(QString::number(BLUE)).name();
- rainbow_counter = -1;
- }
-
- ++rainbow_counter;
-
+ case 0:
+ html_color = get_text_color(QString::number(RED)).name();
+ break;
+ case 1:
+ html_color = get_text_color(QString::number(ORANGE)).name();
+ break;
+ case 2:
+ html_color = get_text_color(QString::number(YELLOW)).name();
+ break;
+ case 3:
+ html_color = get_text_color(QString::number(GREEN)).name();
+ break;
+ default:
+ html_color = get_text_color(QString::number(BLUE)).name();
+ rainbow_counter = -1;
+ }
+
+ ++rainbow_counter;
+
ui_vp_message->insertHtml("<font color=\"" + html_color + "\">" +
f_character + "</font>");
if (mirror_iclog && colorf_iclog && !colorf_limit)
@@ -3074,269 +3103,252 @@ void Courtroom::chat_tick()
if (mirror_iclog && colorf_iclog)
ui_ic_chatlog->insertHtml("<font color=\"" + html_color + "\">" +
f_character + "</font>");
- }
- }
-
+ }
+ }
+
if (mirror_iclog && !colorf_iclog) {
ui_ic_chatlog->textCursor().insertHtml(f_character);
}
if (message_is_centered) {
- ui_vp_message->setAlignment(Qt::AlignCenter);
- }
+ ui_vp_message->setAlignment(Qt::AlignCenter);
+ }
else {
- ui_vp_message->setAlignment(Qt::AlignLeft);
- }
- }
-
- QScrollBar *scroll = ui_vp_message->verticalScrollBar();
- scroll->setValue(scroll->maximum());
-
- if(blank_blip)
- qDebug() << "blank_blip found true";
-
+ ui_vp_message->setAlignment(Qt::AlignLeft);
+ }
+ }
+
+ QScrollBar *scroll = ui_vp_message->verticalScrollBar();
+ scroll->setValue(scroll->maximum());
+
+ if (blank_blip)
+ qDebug() << "blank_blip found true";
+
if (f_message.at(tick_pos) != ' ' || blank_blip) {
-
+
if (blip_pos % blip_rate == 0 && !formatting_char) {
- blip_pos = 0;
- blip_player->blip_tick();
- }
-
- ++blip_pos;
- }
-
- ++tick_pos;
-
+ blip_pos = 0;
+ blip_player->blip_tick();
+ }
+
+ ++blip_pos;
+ }
+
+ ++tick_pos;
+
// Restart the timer, but according to the newly set speeds, if there were
// any. Keep the speed at bay.
if (current_display_speed < 0) {
- current_display_speed = 0;
- }
-
+ current_display_speed = 0;
+ }
+
if (current_display_speed > 6) {
- current_display_speed = 6;
- }
+ current_display_speed = 6;
+ }
if (formatting_char) {
- chat_tick_timer->start(1);
- }
+ chat_tick_timer->start(1);
+ }
else {
chat_tick_timer->start(msg_delay);
-}
-
-void Courtroom::play_sfx()
-{
- QString sfx_name = m_chatmessage[SFX_NAME];
-
- if (sfx_name == "1")
- return;
-
- sfx_player->play(ao_app->get_sfx_suffix(sfx_name));
-}
-
-void Courtroom::set_scene()
-{
-
- //witness is default if pos is invalid
- QString f_background = "witnessempty";
- QString f_desk_image = "stand";
- QString f_desk_mod = m_chatmessage[DESK_MOD];
- QString f_side = m_chatmessage[SIDE];
-
- if (f_side == "def")
- {
- f_background = "defenseempty";
- if (is_ao2_bg)
- f_desk_image = "defensedesk";
- else
- f_desk_image = "bancodefensa";
- }
- else if (f_side == "pro")
- {
- f_background = "prosecutorempty";
- if (is_ao2_bg)
- f_desk_image = "prosecutiondesk";
- else
- f_desk_image = "bancoacusacion";
- }
- else if (f_side == "jud")
- {
- f_background = "judgestand";
- f_desk_image = "judgedesk";
- }
- else if (f_side == "hld")
- {
- f_background = "helperstand";
- f_desk_image = "helperdesk";
- }
- else if (f_side == "hlp")
- {
- f_background = "prohelperstand";
- f_desk_image = "prohelperdesk";
- }
+ }
+ }
+}
+
+void Courtroom::play_sfx()
+{
+ QString sfx_name = m_chatmessage[SFX_NAME];
+
+ if (sfx_name == "1")
+ return;
+
+ sfx_player->play(ao_app->get_sfx_suffix(sfx_name));
+}
+
+void Courtroom::set_scene()
+{
+
+ // witness is default if pos is invalid
+ QString f_background = "witnessempty";
+ QString f_desk_image = "stand";
+ QString f_desk_mod = m_chatmessage[DESK_MOD];
+ QString f_side = m_chatmessage[SIDE];
+
+ if (f_side == "def") {
+ f_background = "defenseempty";
+ if (is_ao2_bg)
+ f_desk_image = "defensedesk";
+ else
+ f_desk_image = "bancodefensa";
+ }
+ else if (f_side == "pro") {
+ f_background = "prosecutorempty";
+ if (is_ao2_bg)
+ f_desk_image = "prosecutiondesk";
+ else
+ f_desk_image = "bancoacusacion";
+ }
+ else if (f_side == "jud") {
+ f_background = "judgestand";
+ f_desk_image = "judgedesk";
+ }
+ else if (f_side == "hld") {
+ f_background = "helperstand";
+ f_desk_image = "helperdesk";
+ }
+ else if (f_side == "hlp") {
+ f_background = "prohelperstand";
+ f_desk_image = "prohelperdesk";
+ }
else if (f_side == "jur" && (file_exists(ao_app->get_image_suffix(
ao_app->get_background_path("jurystand"))))) {
- f_background = "jurystand";
- f_desk_image = "jurydesk";
- }
+ f_background = "jurystand";
+ f_desk_image = "jurydesk";
+ }
else if (f_side == "sea" &&
(file_exists(ao_app->get_image_suffix(
ao_app->get_background_path("seancestand"))))) {
- f_background = "seancestand";
- f_desk_image = "seancedesk";
- }
- else
- {
- if (is_ao2_bg)
- f_desk_image = "stand";
- else
- f_desk_image = "estrado";
- }
-
- ui_vp_background->set_image(f_background);
- ui_vp_desk->set_image(f_desk_image);
- ui_vp_legacy_desk->set_legacy_desk(f_desk_image);
-
- if (f_desk_mod == "0" || (f_desk_mod != "1" &&
- (f_side == "jud" ||
- f_side == "hld" ||
- f_side == "hlp")))
- {
- ui_vp_desk->hide();
- ui_vp_legacy_desk->hide();
- }
- else if (is_ao2_bg || (f_side == "jud" ||
- f_side == "hld" ||
- f_side == "hlp"))
- {
- ui_vp_legacy_desk->hide();
- ui_vp_desk->show();
- }
- else
- {
- if (f_side == "wit")
- {
- ui_vp_desk->show();
- ui_vp_legacy_desk->hide();
- }
- else
- {
- ui_vp_desk->hide();
- ui_vp_legacy_desk->show();
- }
- }
-}
-
-void Courtroom::set_text_color()
-{
+ f_background = "seancestand";
+ f_desk_image = "seancedesk";
+ }
+ else {
+ if (is_ao2_bg)
+ f_desk_image = "stand";
+ else
+ f_desk_image = "estrado";
+ }
+
+ ui_vp_background->set_image(f_background);
+ ui_vp_desk->set_image(f_desk_image);
+ ui_vp_legacy_desk->set_legacy_desk(f_desk_image);
+
+ if (f_desk_mod == "0" ||
+ (f_desk_mod != "1" &&
+ (f_side == "jud" || f_side == "hld" || f_side == "hlp"))) {
+ ui_vp_desk->hide();
+ ui_vp_legacy_desk->hide();
+ }
+ else if (is_ao2_bg ||
+ (f_side == "jud" || f_side == "hld" || f_side == "hlp")) {
+ ui_vp_legacy_desk->hide();
+ ui_vp_desk->show();
+ }
+ else {
+ if (f_side == "wit") {
+ ui_vp_desk->show();
+ ui_vp_legacy_desk->hide();
+ }
+ else {
+ ui_vp_desk->hide();
+ ui_vp_legacy_desk->show();
+ }
+ }
+}
+
+void Courtroom::set_text_color()
+{
QString f_char = m_chatmessage[CHAR_NAME];
QColor textcolor = ao_app->get_chat_color(m_chatmessage[TEXT_COLOR],
ao_app->get_chat(f_char));
-
- ui_vp_message->setTextBackgroundColor(QColor(0,0,0,0));
- ui_vp_message->setTextColor(textcolor);
-
- QString style = "background-color: rgba(0, 0, 0, 0);";
- style.append("color: rgb(");
- style.append(QString::number(textcolor.red()));
- style.append(", ");
- style.append(QString::number(textcolor.green()));
- style.append(", ");
- style.append(QString::number(textcolor.blue()));
- style.append(")");
-
- ui_vp_message->setStyleSheet(style);
-}
-
-QColor Courtroom::get_text_color(QString color)
-{
+
+ ui_vp_message->setTextBackgroundColor(QColor(0, 0, 0, 0));
+ ui_vp_message->setTextColor(textcolor);
+
+ QString style = "background-color: rgba(0, 0, 0, 0);";
+ style.append("color: rgb(");
+ style.append(QString::number(textcolor.red()));
+ style.append(", ");
+ style.append(QString::number(textcolor.green()));
+ style.append(", ");
+ style.append(QString::number(textcolor.blue()));
+ style.append(")");
+
+ ui_vp_message->setStyleSheet(style);
+}
+
+QColor Courtroom::get_text_color(QString color)
+{
QString f_char = m_chatmessage[CHAR_NAME];
return ao_app->get_chat_color(color, ao_app->get_chat(f_char));
-}
-
-void Courtroom::set_ip_list(QString p_list)
-{
- QString f_list = p_list.replace("|", ":").replace("*", "\n");
-
- ui_server_chatlog->append(f_list);
-}
-
-void Courtroom::set_mute(bool p_muted, int p_cid)
-{
- if (p_cid != m_cid && p_cid != -1)
- return;
-
- if (p_muted)
- ui_muted->show();
- else
- {
- ui_muted->hide();
- ui_ic_chat_message->setFocus();
- }
-
- ui_muted->resize(ui_ic_chat_message->width(), ui_ic_chat_message->height());
- ui_muted->set_image("muted.png");
-
- is_muted = p_muted;
- ui_ic_chat_message->setEnabled(!p_muted);
-}
-
-void Courtroom::set_ban(int p_cid)
-{
- if (p_cid != m_cid && p_cid != -1)
- return;
-
- call_notice(tr("You have been banned."));
-
- ao_app->construct_lobby();
- ao_app->destruct_courtroom();
-}
-
-void Courtroom::handle_song(QStringList *p_contents)
-{
- QStringList f_contents = *p_contents;
-
- if (f_contents.size() < 2)
- return;
-
- QString f_song = f_contents.at(0);
- QString f_song_clear = f_song;
- int n_char = f_contents.at(1).toInt();
-
- qDebug() << "playing song "+ao_app->get_music_path(f_song);
-
+}
+
+void Courtroom::set_ip_list(QString p_list)
+{
+ QString f_list = p_list.replace("|", ":").replace("*", "\n");
+
+ ui_server_chatlog->append(f_list);
+}
+
+void Courtroom::set_mute(bool p_muted, int p_cid)
+{
+ if (p_cid != m_cid && p_cid != -1)
+ return;
+
+ if (p_muted)
+ ui_muted->show();
+ else {
+ ui_muted->hide();
+ ui_ic_chat_message->setFocus();
+ }
+
+ ui_muted->resize(ui_ic_chat_message->width(), ui_ic_chat_message->height());
+ ui_muted->set_image("muted.png");
+
+ is_muted = p_muted;
+ ui_ic_chat_message->setEnabled(!p_muted);
+}
+
+void Courtroom::set_ban(int p_cid)
+{
+ if (p_cid != m_cid && p_cid != -1)
+ return;
+
+ call_notice(tr("You have been banned."));
+
+ ao_app->construct_lobby();
+ ao_app->destruct_courtroom();
+}
+
+void Courtroom::handle_song(QStringList *p_contents)
+{
+ QStringList f_contents = *p_contents;
+
+ if (f_contents.size() < 2)
+ return;
+
+ QString f_song = f_contents.at(0);
+ QString f_song_clear = f_song;
+ int n_char = f_contents.at(1).toInt();
+
+ qDebug() << "playing song " + ao_app->get_music_path(f_song);
+
if (n_char < 0 || n_char >= char_list.size()) {
music_player->play(ao_app->get_music_prefix(f_song));
- }
+ }
else {
- QString str_char = char_list.at(n_char).name;
- QString str_show = char_list.at(n_char).name;
-
- if (p_contents->length() > 2)
- {
- if(p_contents->at(2) != "")
- {
- str_show = p_contents->at(2);
- }
- }
- if (p_contents->length() > 3)
- {
- if(p_contents->at(3) != "-1")
- {
- music_player->enable_looping = false;
- }
- else
- {
- music_player->enable_looping = true;
- }
- }
+ QString str_char = char_list.at(n_char).name;
+ QString str_show = char_list.at(n_char).name;
+
+ if (p_contents->length() > 2) {
+ if (p_contents->at(2) != "") {
+ str_show = p_contents->at(2);
+ }
+ }
+ if (p_contents->length() > 3) {
+ if (p_contents->at(3) != "-1") {
+ music_player->enable_looping = false;
+ }
+ else {
+ music_player->enable_looping = true;
+ }
+ }
if (!mute_map.value(n_char)) {
chatlogpiece *temp = new chatlogpiece(str_char, str_show, f_song, true,
m_chatmessage[TEXT_COLOR].toInt());
- ic_chatlog_history.append(*temp);
-
+ ic_chatlog_history.append(*temp);
+
while (ic_chatlog_history.size() > log_maximum_blocks &&
log_maximum_blocks > 0) {
- ic_chatlog_history.removeFirst();
- }
+ ic_chatlog_history.removeFirst();
+ }
if (mirror_iclog) // If mirror is enabled, we display the song in the ooc
// chat rather than ic log for a more realistic
// expierence.
@@ -3349,380 +3361,406 @@ void Courtroom::handle_song(QStringList *p_contents)
}
append_ic_text(f_song_clear, str_show, true);
music_player->play(ao_app->get_music_prefix(f_song));
- }
- }
-}
-void Courtroom::handle_failed_login()
-{
- modcall_player->play("./music/failed_login"); // aov memes
-}
-void Courtroom::handle_wtce(QString p_wtce, int variant)
-{
- QString sfx_file = "courtroom_sounds.ini";
-
- //witness testimony
+ }
+ }
+}
+void Courtroom::handle_failed_login()
+{
+ modcall_player->play("./music/failed_login"); // aov memes
+}
+void Courtroom::handle_wtce(QString p_wtce, int variant)
+{
+ QString sfx_file = "courtroom_sounds.ini";
+
+ // witness testimony
if (p_wtce == "testimony1") {
- misc_sfx_player->play(ao_app->get_sfx("witness_testimony"));
+ misc_sfx_player->play(ao_app->get_sfx("witness_testimony"));
ui_vp_wtce->play("witnesstestimony", "", "", wtce_stay_time);
ui_vp_testimony->play("testimony");
- }
- //cross examination
+ }
+ // cross examination
else if (p_wtce == "testimony2") {
- misc_sfx_player->play(ao_app->get_sfx("cross_examination"));
+ misc_sfx_player->play(ao_app->get_sfx("cross_examination"));
ui_vp_wtce->play("crossexamination", "", "", wtce_stay_time);
ui_vp_testimony->stop();
- }
+ }
else if (p_wtce == "judgeruling") {
if (variant == 0) {
- misc_sfx_player->play(ao_app->get_sfx("not_guilty"));
+ misc_sfx_player->play(ao_app->get_sfx("not_guilty"));
ui_vp_wtce->play("notguilty", "", "", verdict_stay_time);
ui_vp_testimony->stop();
- }
- else if (variant == 1) {
- misc_sfx_player->play(ao_app->get_sfx("guilty"));
+ }
+ else if (variant == 1) {
+ misc_sfx_player->play(ao_app->get_sfx("guilty"));
ui_vp_wtce->play("guilty", "", "", verdict_stay_time);
ui_vp_testimony->stop();
- }
- }
-}
-
-void Courtroom::set_hp_bar(int p_bar, int p_state)
-{
- if (p_state < 0 || p_state > 10)
- return;
-
- if (p_bar == 1)
- {
- ui_defense_bar->set_image("defensebar" + QString::number(p_state) + ".png");
- defense_bar_state = p_state;
- }
- else if (p_bar == 2)
- {
- ui_prosecution_bar->set_image("prosecutionbar" + QString::number(p_state) + ".png");
- prosecution_bar_state = p_state;
- }
-}
-
-void Courtroom::toggle_judge_buttons(bool is_on)
-{
- if (is_on)
- {
- ui_witness_testimony->show();
- ui_cross_examination->show();
- ui_guilty->show();
- ui_not_guilty->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_guilty->hide();
- ui_not_guilty->hide();
- ui_defense_minus->hide();
- ui_defense_plus->hide();
- ui_prosecution_minus->hide();
- ui_prosecution_plus->hide();
- }
-}
-
-void Courtroom::mod_called(QString p_ip)
-{
- ui_server_chatlog->append(p_ip);
- if (!ui_guard->isChecked())
- {
- modcall_player->play(ao_app->get_sfx("mod_call"));
- ao_app->alert(this);
- }
-}
-
-void Courtroom::case_called(QString msg, bool def, bool pro, bool jud, bool jur, bool steno, bool witness)
-{
- if (ui_casing->isChecked())
- {
- ui_server_chatlog->append(msg);
- if ((ao_app->get_casing_defence_enabled() && def) ||
- (ao_app->get_casing_prosecution_enabled() && pro) ||
- (ao_app->get_casing_judge_enabled() && jud) ||
- (ao_app->get_casing_juror_enabled() && jur) ||
- (ao_app->get_casing_steno_enabled() && steno) ||
- (ao_app->get_casing_wit_enabled() && witness))
- {
- modcall_player->play(ao_app->get_sfx("case_call"));
- ao_app->alert(this);
- }
- }
-}
-
-void Courtroom::on_ooc_return_pressed()
-{
- QString ooc_message = ui_ooc_chat_message->text();
-
- if (ooc_message == "" || ui_ooc_chat_name->text() == "")
- return;
-
- if (ooc_message.startsWith("/pos"))
- {
- if (ooc_message == "/pos jud")
- {
- toggle_judge_buttons(true);
- }
- else
- {
- toggle_judge_buttons(false);
- }
- }
- else if (ooc_message.startsWith("/login"))
- {
- ui_guard->show();
- append_server_chatmessage("CLIENT", tr("You were granted the Disable Modcalls button."), "1");
- }
- else if (ooc_message.startsWith("/rainbow") && ao_app->yellow_text_enabled && !rainbow_appended)
- {
- //ui_text_color->addItem("Rainbow");
- ui_ooc_chat_message->clear();
- //rainbow_appended = true;
- append_server_chatmessage("CLIENT", tr("This does nothing, but there you go."), "1");
- return;
- }
- else if (ooc_message.startsWith("/settings"))
- {
- ui_ooc_chat_message->clear();
- ao_app->call_settings_menu();
- append_server_chatmessage("CLIENT", tr("You opened the settings menu."), "1");
- return;
- }
- else if (ooc_message.startsWith("/pair"))
- {
- ui_ooc_chat_message->clear();
- ooc_message.remove(0,6);
-
- bool ok;
- int whom = ooc_message.toInt(&ok);
- if (ok)
- {
- if (whom > -1)
- {
- other_charid = whom;
- QString msg = tr("You will now pair up with ");
- msg.append(char_list.at(whom).name);
- msg.append(tr(" if they also choose your character in return."));
- append_server_chatmessage("CLIENT", msg, "1");
- }
- else
- {
- other_charid = -1;
- append_server_chatmessage("CLIENT", tr("You are no longer paired with anyone."), "1");
- }
- }
- else
- {
- append_server_chatmessage("CLIENT", tr("Are you sure you typed that well? The char ID could not be recognised."), "1");
- }
- return;
- }
- else if (ooc_message.startsWith("/offset"))
- {
- ui_ooc_chat_message->clear();
- ooc_message.remove(0,8);
-
- bool ok;
- int off = ooc_message.toInt(&ok);
- if (ok)
- {
- if (off >= -100 && off <= 100)
- {
- offset_with_pair = off;
- QString msg = tr("You have set your offset to ");
- msg.append(QString::number(off));
- msg.append("%.");
- append_server_chatmessage("CLIENT", msg, "1");
- }
- else
- {
- append_server_chatmessage("CLIENT", tr("Your offset must be between -100% and 100%!"), "1");
- }
- }
- else
- {
- append_server_chatmessage("CLIENT", tr("That offset does not look like one."), "1");
- }
- return;
- }
- else if (ooc_message.startsWith("/switch_am"))
- {
- append_server_chatmessage("CLIENT", tr("You switched your music and area list."), "1");
- on_switch_area_music_clicked();
- ui_ooc_chat_message->clear();
- return;
- }
- else if (ooc_message.startsWith("/enable_blocks"))
- {
- append_server_chatmessage("CLIENT", tr("You have forcefully enabled features that the server may not support. You may not be able to talk IC, or worse, because of this."), "1");
- ao_app->cccc_ic_support_enabled = true;
- ao_app->arup_enabled = true;
- ao_app->modcall_reason_enabled = true;
- on_reload_theme_clicked();
- ui_ooc_chat_message->clear();
- return;
- }
- else if (ooc_message.startsWith("/non_int_pre"))
- {
- if (ui_pre_non_interrupt->isChecked())
- append_server_chatmessage("CLIENT", tr("Your pre-animations interrupt again."), "1");
- else
- append_server_chatmessage("CLIENT", tr("Your pre-animations will not interrupt text."), "1");
- ui_pre_non_interrupt->setChecked(!ui_pre_non_interrupt->isChecked());
- ui_ooc_chat_message->clear();
- return;
- }
- else if (ooc_message.startsWith("/save_chatlog"))
- {
- QFile file("chatlog.txt");
-
- if (!file.open(QIODevice::WriteOnly | QIODevice::Text | QIODevice::Truncate))
- {
- append_server_chatmessage("CLIENT", tr("Couldn't open chatlog.txt to write into."), "1");
- ui_ooc_chat_message->clear();
- return;
- }
-
- QTextStream out(&file);
-
- foreach (chatlogpiece item, ic_chatlog_history) {
- out << item.get_full() << '\n';
- }
-
- file.close();
-
- append_server_chatmessage("CLIENT", tr("The IC chatlog has been saved."), "1");
- ui_ooc_chat_message->clear();
- return;
- }
- else if (ooc_message.startsWith("/load_case"))
- {
- QStringList command = ooc_message.split(" ", QString::SkipEmptyParts);
-
- QDir casefolder("base/cases");
- if (!casefolder.exists())
- {
- QDir::current().mkdir("base/" + casefolder.dirName());
- append_server_chatmessage("CLIENT", tr("You don't have a `base/cases/` folder! It was just made for you, but seeing as it WAS just made for you, it's likely the case file you're looking for can't be found in there."), "1");
- ui_ooc_chat_message->clear();
- return;
- }
- QStringList caseslist = casefolder.entryList();
- caseslist.removeOne(".");
- caseslist.removeOne("..");
- caseslist.replaceInStrings(".ini","");
-
- if (command.size() < 2)
- {
- append_server_chatmessage("CLIENT", tr("You need to give a filename to load (extension not needed)! Make sure that it is in the `base/cases/` folder, and that it is a correctly formatted ini.\nCases you can load: %1").arg(caseslist.join(", ")), "1");
- ui_ooc_chat_message->clear();
- return;
- }
-
-
- if (command.size() > 2)
- {
- append_server_chatmessage("CLIENT", tr("Too many arguments to load a case! You only need one filename, without extension."), "1");
- ui_ooc_chat_message->clear();
- return;
- }
-
- QSettings casefile("base/cases/" + command[1] + ".ini", QSettings::IniFormat);
-
- QString caseauth = casefile.value("author", "").value<QString>();
- QString casedoc = casefile.value("doc", "").value<QString>();
- QString cmdoc = casefile.value("cmdoc", "").value<QString>();
- QString casestatus = casefile.value("status", "").value<QString>();
-
- if (!caseauth.isEmpty())
- append_server_chatmessage("CLIENT", tr("Case made by %1.").arg(caseauth), "1");
- if (!casedoc.isEmpty())
- ao_app->send_server_packet(new AOPacket("CT#" + ui_ooc_chat_name->text() + "#/doc " + casedoc + "#%"));
- if (!casestatus.isEmpty())
- ao_app->send_server_packet(new AOPacket("CT#" + ui_ooc_chat_name->text() + "#/status " + casestatus + "#%"));
- if (!cmdoc.isEmpty())
- append_server_chatmessage("CLIENT", tr("Navigate to %1 for the CM doc.").arg(cmdoc), "1");
-
- for (int i = local_evidence_list.size() - 1; i >= 0; i--) {
- ao_app->send_server_packet(new AOPacket("DE#" + QString::number(i) + "#%"));
- }
-
- foreach (QString evi, casefile.childGroups()) {
- if (evi == "General")
- continue;
-
- QStringList f_contents;
-
- f_contents.append(casefile.value(evi + "/name", "UNKNOWN").value<QString>());
- f_contents.append(casefile.value(evi + "/description", "UNKNOWN").value<QString>());
- f_contents.append(casefile.value(evi + "/image", "UNKNOWN.png").value<QString>());
-
- ao_app->send_server_packet(new AOPacket("PE", f_contents));
- }
-
- append_server_chatmessage("CLIENT", tr("Your case \"%1\" was loaded!").arg(command[1]), "1");
- ui_ooc_chat_message->clear();
- return;
- }
- else if(ooc_message.startsWith("/save_case"))
- {
- QStringList command = ooc_message.split(" ", QString::SkipEmptyParts);
-
- QDir casefolder("base/cases");
- if (!casefolder.exists())
- {
- QDir::current().mkdir("base/" + casefolder.dirName());
- append_server_chatmessage("CLIENT", tr("You don't have a `base/cases/` folder! It was just made for you, but seeing as it WAS just made for you, it's likely that you somehow deleted it."), "1");
- ui_ooc_chat_message->clear();
- return;
- }
- QStringList caseslist = casefolder.entryList();
- caseslist.removeOne(".");
- caseslist.removeOne("..");
- caseslist.replaceInStrings(".ini","");
-
- if (command.size() < 3)
- {
- append_server_chatmessage("CLIENT", tr("You need to give a filename to save (extension not needed) and the courtroom status!"), "1");
- ui_ooc_chat_message->clear();
- return;
- }
-
-
- if (command.size() > 3)
- {
- append_server_chatmessage("CLIENT", tr("Too many arguments to save a case! You only need a filename without extension and the courtroom status!"), "1");
- ui_ooc_chat_message->clear();
- return;
- }
- QSettings casefile("base/cases/" + command[1] + ".ini", QSettings::IniFormat);
- casefile.setValue("author",ui_ooc_chat_name->text());
- casefile.setValue("cmdoc","");
- casefile.setValue("doc", "");
- casefile.setValue("status",command[2]);
- casefile.sync();
- for(int i = local_evidence_list.size() - 1; i >= 0; i--)
- {
- QString clean_evidence_dsc = local_evidence_list[i].description.replace(QRegularExpression("<owner = ...>..."), "");
- clean_evidence_dsc = clean_evidence_dsc.replace(clean_evidence_dsc.lastIndexOf(">"), 1, "");
- casefile.beginGroup(QString::number(i));
- casefile.sync();
- casefile.setValue("name",local_evidence_list[i].name);
- casefile.setValue("description",local_evidence_list[i].description);
- casefile.setValue("image",local_evidence_list[i].image);
- casefile.endGroup();
- }
- casefile.sync();
+ }
+ }
+}
+
+void Courtroom::set_hp_bar(int p_bar, int p_state)
+{
+ if (p_state < 0 || p_state > 10)
+ return;
+
+ if (p_bar == 1) {
+ ui_defense_bar->set_image("defensebar" + QString::number(p_state) + ".png");
+ defense_bar_state = p_state;
+ }
+ else if (p_bar == 2) {
+ ui_prosecution_bar->set_image("prosecutionbar" + QString::number(p_state) +
+ ".png");
+ prosecution_bar_state = p_state;
+ }
+}
+
+void Courtroom::toggle_judge_buttons(bool is_on)
+{
+ if (is_on) {
+ ui_witness_testimony->show();
+ ui_cross_examination->show();
+ ui_guilty->show();
+ ui_not_guilty->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_guilty->hide();
+ ui_not_guilty->hide();
+ ui_defense_minus->hide();
+ ui_defense_plus->hide();
+ ui_prosecution_minus->hide();
+ ui_prosecution_plus->hide();
+ }
+}
+
+void Courtroom::mod_called(QString p_ip)
+{
+ ui_server_chatlog->append(p_ip);
+ if (!ui_guard->isChecked()) {
+ modcall_player->play(ao_app->get_sfx("mod_call"));
+ ao_app->alert(this);
+ }
+}
+
+void Courtroom::case_called(QString msg, bool def, bool pro, bool jud, bool jur,
+ bool steno, bool witness)
+{
+ if (ui_casing->isChecked()) {
+ ui_server_chatlog->append(msg);
+ if ((ao_app->get_casing_defence_enabled() && def) ||
+ (ao_app->get_casing_prosecution_enabled() && pro) ||
+ (ao_app->get_casing_judge_enabled() && jud) ||
+ (ao_app->get_casing_juror_enabled() && jur) ||
+ (ao_app->get_casing_steno_enabled() && steno) ||
+ (ao_app->get_casing_wit_enabled() && witness)) {
+ modcall_player->play(ao_app->get_sfx("case_call"));
+ ao_app->alert(this);
+ }
+ }
+}
+
+void Courtroom::on_ooc_return_pressed()
+{
+ QString ooc_message = ui_ooc_chat_message->text();
+
+ if (ooc_message == "" || ui_ooc_chat_name->text() == "")
+ return;
+
+ if (ooc_message.startsWith("/pos")) {
+ if (ooc_message == "/pos jud") {
+ toggle_judge_buttons(true);
+ }
+ else {
+ toggle_judge_buttons(false);
+ }
+ }
+ else if (ooc_message.startsWith("/login")) {
+ ui_guard->show();
+
+ append_server_chatmessage(
+ "CLIENT", tr("You were granted the Disable Modcalls button."), "1");
+ }
+ else if (ooc_message.startsWith("/rainbow") && ao_app->yellow_text_enabled &&
+ !rainbow_appended) {
+ // ui_text_color->addItem("Rainbow");
+ ui_ooc_chat_message->clear();
+ // rainbow_appended = true;
+ append_server_chatmessage("CLIENT",
+ tr("This does nothing, but there you go."), "1");
+ return;
+ }
+ else if (ooc_message.startsWith("/settings")) {
+ ui_ooc_chat_message->clear();
+ ao_app->call_settings_menu();
+ append_server_chatmessage("CLIENT", tr("You opened the settings menu."),
+ "1");
+ return;
+ }
+ else if (ooc_message.startsWith("/pair")) {
+ ui_ooc_chat_message->clear();
+ ooc_message.remove(0, 6);
+
+ bool ok;
+ int whom = ooc_message.toInt(&ok);
+ if (ok) {
+ if (whom > -1) {
+ other_charid = whom;
+ QString msg = tr("You will now pair up with ");
+ msg.append(char_list.at(whom).name);
+ msg.append(tr(" if they also choose your character in return."));
+ append_server_chatmessage("CLIENT", msg, "1");
+ }
+ else {
+ other_charid = -1;
+ append_server_chatmessage(
+ "CLIENT", tr("You are no longer paired with anyone."), "1");
+ }
+ }
+ else {
+ append_server_chatmessage("CLIENT",
+ tr("Are you sure you typed that well? The char "
+ "ID could not be recognised."),
+ "1");
+ }
+ return;
+ }
+ else if (ooc_message.startsWith("/offset")) {
+ ui_ooc_chat_message->clear();
+ ooc_message.remove(0, 8);
+
+ bool ok;
+ int off = ooc_message.toInt(&ok);
+ if (ok) {
+ if (off >= -100 && off <= 100) {
+ offset_with_pair = off;
+ QString msg = tr("You have set your offset to ");
+ msg.append(QString::number(off));
+ msg.append("%.");
+ append_server_chatmessage("CLIENT", msg, "1");
+ }
+ else {
+ append_server_chatmessage(
+ "CLIENT", tr("Your offset must be between -100% and 100%!"), "1");
+ }
+ }
+ else {
+ append_server_chatmessage("CLIENT",
+ tr("That offset does not look like one."), "1");
+ }
+ return;
+ }
+ else if (ooc_message.startsWith("/switch_am")) {
+ append_server_chatmessage(
+ "CLIENT", tr("You switched your music and area list."), "1");
+ on_switch_area_music_clicked();
+ ui_ooc_chat_message->clear();
+ return;
+ }
+ else if (ooc_message.startsWith("/enable_blocks")) {
+ append_server_chatmessage("CLIENT",
+ tr("You have forcefully enabled features that "
+ "the server may not support. You may not be "
+ "able to talk IC, or worse, because of this."),
+ "1");
+ ao_app->cccc_ic_support_enabled = true;
+ ao_app->arup_enabled = true;
+ ao_app->modcall_reason_enabled = true;
+ on_reload_theme_clicked();
+ ui_ooc_chat_message->clear();
+ return;
+ }
+ else if (ooc_message.startsWith("/non_int_pre")) {
+ if (ui_pre_non_interrupt->isChecked())
+ append_server_chatmessage(
+ "CLIENT", tr("Your pre-animations interrupt again."), "1");
+ else
+ append_server_chatmessage(
+ "CLIENT", tr("Your pre-animations will not interrupt text."), "1");
+ ui_pre_non_interrupt->setChecked(!ui_pre_non_interrupt->isChecked());
+ ui_ooc_chat_message->clear();
+ return;
+ }
+ else if (ooc_message.startsWith("/save_chatlog")) {
+ QFile file("chatlog.txt");
+
+ if (!file.open(QIODevice::WriteOnly | QIODevice::Text |
+ QIODevice::Truncate)) {
+ append_server_chatmessage(
+ "CLIENT", tr("Couldn't open chatlog.txt to write into."), "1");
+ ui_ooc_chat_message->clear();
+ return;
+ }
+
+ QTextStream out(&file);
+
+ foreach (chatlogpiece item, ic_chatlog_history) {
+ out << item.get_full() << '\n';
+ }
+
+ file.close();
+
+ append_server_chatmessage("CLIENT", tr("The IC chatlog has been saved."),
+ "1");
+ ui_ooc_chat_message->clear();
+ return;
+ }
+ else if (ooc_message.startsWith("/load_case")) {
+ QStringList command = ooc_message.split(" ", QString::SkipEmptyParts);
+
+ QDir casefolder("base/cases");
+ if (!casefolder.exists()) {
+ QDir::current().mkdir("base/" + casefolder.dirName());
+ append_server_chatmessage(
+ "CLIENT",
+ tr("You don't have a `base/cases/` folder! It was just made for you, "
+ "but seeing as it WAS just made for you, it's likely the case "
+ "file you're looking for can't be found in there."),
+ "1");
+ ui_ooc_chat_message->clear();
+ return;
+ }
+ QStringList caseslist = casefolder.entryList();
+ caseslist.removeOne(".");
+ caseslist.removeOne("..");
+ caseslist.replaceInStrings(".ini", "");
+
+ if (command.size() < 2) {
+ append_server_chatmessage(
+ "CLIENT",
+ tr("You need to give a filename to load (extension not needed)! Make "
+ "sure that it is in the `base/cases/` folder, and that it is a "
+ "correctly formatted ini.\nCases you can load: %1")
+ .arg(caseslist.join(", ")),
+ "1");
+ ui_ooc_chat_message->clear();
+ return;
+ }
+
+ if (command.size() > 2) {
+ append_server_chatmessage(
+ "CLIENT",
+ tr("Too many arguments to load a case! You only need one filename, "
+ "without extension."),
+ "1");
+ ui_ooc_chat_message->clear();
+ return;
+ }
+
+ QSettings casefile("base/cases/" + command[1] + ".ini",
+ QSettings::IniFormat);
+
+ QString caseauth = casefile.value("author", "").value<QString>();
+ QString casedoc = casefile.value("doc", "").value<QString>();
+ QString cmdoc = casefile.value("cmdoc", "").value<QString>();
+ QString casestatus = casefile.value("status", "").value<QString>();
+
+ if (!caseauth.isEmpty())
+ append_server_chatmessage("CLIENT", tr("Case made by %1.").arg(caseauth),
+ "1");
+ if (!casedoc.isEmpty())
+ ao_app->send_server_packet(new AOPacket("CT#" + ui_ooc_chat_name->text() +
+ "#/doc " + casedoc + "#%"));
+ if (!casestatus.isEmpty())
+ ao_app->send_server_packet(new AOPacket("CT#" + ui_ooc_chat_name->text() +
+ "#/status " + casestatus + "#%"));
+ if (!cmdoc.isEmpty())
+ append_server_chatmessage(
+ "CLIENT", tr("Navigate to %1 for the CM doc.").arg(cmdoc), "1");
+
+ for (int i = local_evidence_list.size() - 1; i >= 0; i--) {
+ ao_app->send_server_packet(
+ new AOPacket("DE#" + QString::number(i) + "#%"));
+ }
+
+ foreach (QString evi, casefile.childGroups()) {
+ if (evi == "General")
+ continue;
+
+ QStringList f_contents;
+
+ f_contents.append(
+ casefile.value(evi + "/name", "UNKNOWN").value<QString>());
+ f_contents.append(
+ casefile.value(evi + "/description", "UNKNOWN").value<QString>());
+ f_contents.append(
+ casefile.value(evi + "/image", "UNKNOWN.png").value<QString>());
+
+ ao_app->send_server_packet(new AOPacket("PE", f_contents));
+ }
+ append_server_chatmessage(
+ "CLIENT", tr("Your case \"%1\" was loaded!").arg(command[1]), "1");
+ ui_ooc_chat_message->clear();
+ return;
+ }
+ else if (ooc_message.startsWith("/save_case")) {
+ QStringList command = ooc_message.split(" ", QString::SkipEmptyParts);
+
+ QDir casefolder("base/cases");
+ if (!casefolder.exists()) {
+ QDir::current().mkdir("base/" + casefolder.dirName());
+ append_server_chatmessage(
+ "CLIENT",
+ tr("You don't have a `base/cases/` folder! It was just made for you, "
+ "but seeing as it WAS just made for you, it's likely that you "
+ "somehow deleted it."),
+ "1");
+ ui_ooc_chat_message->clear();
+ return;
+ }
+ QStringList caseslist = casefolder.entryList();
+ caseslist.removeOne(".");
+ caseslist.removeOne("..");
+ caseslist.replaceInStrings(".ini", "");
+
+ if (command.size() < 3) {
+ append_server_chatmessage(
+ "CLIENT",
+ tr("You need to give a filename to save (extension not needed) and "
+ "the courtroom status!"),
+ "1");
+ ui_ooc_chat_message->clear();
+ return;
+ }
+
+ if (command.size() > 3) {
+ append_server_chatmessage(
+ "CLIENT",
+ tr("Too many arguments to save a case! You only need a filename "
+ "without extension and the courtroom status!"),
+ "1");
+ ui_ooc_chat_message->clear();
+ return;
+ }
+ QSettings casefile("base/cases/" + command[1] + ".ini",
+ QSettings::IniFormat);
+ casefile.setValue("author", ui_ooc_chat_name->text());
+ casefile.setValue("cmdoc", "");
+ casefile.setValue("doc", "");
+ casefile.setValue("status", command[2]);
+ casefile.sync();
+ for (int i = local_evidence_list.size() - 1; i >= 0; i--) {
+ QString clean_evidence_dsc = local_evidence_list[i].description.replace(
+ QRegularExpression("<owner = ...>..."), "");
+ clean_evidence_dsc = clean_evidence_dsc.replace(
+ clean_evidence_dsc.lastIndexOf(">"), 1, "");
+ casefile.beginGroup(QString::number(i));
+ casefile.sync();
+ casefile.setValue("name", local_evidence_list[i].name);
+ casefile.setValue("description", local_evidence_list[i].description);
+ casefile.setValue("image", local_evidence_list[i].image);
+ casefile.endGroup();
+ }
+ casefile.sync();
append_server_chatmessage(
"CLIENT", tr("Succesfully saved, edit doc and cmdoc link on the ini!"),
"1");
+ ui_ooc_chat_message->clear();
+ return;
}
else if (ooc_message.startsWith("/clearooc")) {
ui_server_chatlog->clear();
@@ -3731,54 +3769,50 @@ void Courtroom::on_ooc_return_pressed()
}
else if (ooc_message.startsWith("/version")) {
append_server_chatmessage("CLIENT", ao_app->get_version_string(), "1");
- ui_ooc_chat_message->clear();
- return;
- }
-
- QStringList packet_contents;
- packet_contents.append(ui_ooc_chat_name->text());
- packet_contents.append(ooc_message);
-
- 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();
-
- ui_ooc_chat_message->setFocus();
-}
-
-void Courtroom::on_ooc_toggle_clicked()
-{
- if (server_ooc)
- {
- ui_ms_chatlog->show();
- ui_server_chatlog->hide();
- ui_ooc_toggle->setText(tr(""));
- ui_ooc_toggle->set_image("ooc_toggle_ms.png");
- if (ooc_toggle_fallback)
- {
- ui_ooc_toggle->setText(tr("Master"));
- }
- server_ooc = false;
- }
- else
- {
- ui_ms_chatlog->hide();
- ui_server_chatlog->show();
- ui_ooc_toggle->setText(tr(""));
- ui_ooc_toggle->set_image("ooc_toggle_server.png");
- if (ooc_toggle_fallback)
- {
- ui_ooc_toggle->setText(tr("Server"));
- }
- server_ooc = true;
- }
-}
-
+ ui_ooc_chat_message->clear();
+ return;
+ }
+
+ QStringList packet_contents;
+ packet_contents.append(ui_ooc_chat_name->text());
+ packet_contents.append(ooc_message);
+
+ 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();
+
+ ui_ooc_chat_message->setFocus();
+}
+
+void Courtroom::on_ooc_toggle_clicked()
+{
+ if (server_ooc) {
+ ui_ms_chatlog->show();
+ ui_server_chatlog->hide();
+ ui_ooc_toggle->setText(tr(""));
+ ui_ooc_toggle->set_image("ooc_toggle_ms.png");
+ if (ooc_toggle_fallback) {
+ ui_ooc_toggle->setText(tr("Master"));
+ }
+ server_ooc = false;
+ }
+ else {
+ ui_ms_chatlog->hide();
+ ui_server_chatlog->show();
+ ui_ooc_toggle->setText(tr(""));
+ ui_ooc_toggle->set_image("ooc_toggle_server.png");
+ if (ooc_toggle_fallback) {
+ ui_ooc_toggle->setText(tr("Server"));
+ }
+ server_ooc = true;
+ }
+}
+
void Courtroom::on_music_search_keypr()
{
if (ui_music_search->text() == "") {
@@ -3786,155 +3820,143 @@ void Courtroom::on_music_search_keypr()
}
}
-void Courtroom::on_music_search_edited(QString p_text)
-{
- //preventing compiler warnings
- p_text += "a";
- list_music();
- list_areas();
-}
-
-void Courtroom::on_pos_dropdown_changed(int p_index)
-{
- ui_ic_chat_message->setFocus();
-
- if (p_index < 0 || p_index > 7)
- return;
-
- toggle_judge_buttons(false);
-
- QString f_pos;
-
- switch (p_index)
- {
- case 0:
- f_pos = "wit";
- break;
- case 1:
- f_pos = "def";
- break;
- case 2:
- f_pos = "pro";
- break;
- case 3:
- f_pos = "jud";
- toggle_judge_buttons(true);
- break;
- case 4:
- f_pos = "hld";
- break;
- case 5:
- f_pos = "hlp";
- break;
- case 6:
- f_pos = "jur";
- break;
- case 7:
- f_pos = "sea";
- break;
- default:
- f_pos = "";
- }
-
- if (f_pos == "" || ui_ooc_chat_name->text() == "")
- return;
-
- ao_app->send_server_packet(new AOPacket("CT#" + ui_ooc_chat_name->text() + "#/pos " + f_pos + "#%"));
-}
-
-void Courtroom::on_mute_list_clicked(QModelIndex p_index)
-{
- QListWidgetItem *f_item = ui_mute_list->item(p_index.row());
- QString f_char = f_item->text();
- QString real_char;
-
- if (f_char.endsWith(" [x]"))
- real_char = f_char.left(f_char.size() - 4);
- else
- real_char = f_char;
-
- int f_cid = -1;
-
- for (int n_char = 0 ; n_char < char_list.size() ; n_char++)
- {
- if (char_list.at(n_char).name == real_char)
- f_cid = n_char;
- }
-
- if (f_cid < 0 || f_cid >= char_list.size())
- {
- qDebug() << "W: " << real_char << " not present in char_list";
- return;
- }
-
- if (mute_map.value(f_cid))
- {
- mute_map.insert(f_cid, false);
- f_item->setText(real_char);
- }
- else
- {
- mute_map.insert(f_cid, true);
- f_item->setText(real_char + " [x]");
- }
-}
-
-void Courtroom::on_pair_list_clicked(QModelIndex p_index)
-{
- QListWidgetItem *f_item = ui_pair_list->item(p_index.row());
- QString f_char = f_item->text();
- QString real_char;
- int f_cid = -1;
-
- if (f_char.endsWith(" [x]"))
- {
- real_char = f_char.left(f_char.size() - 4);
- f_item->setText(real_char);
- }
- else
- {
- real_char = f_char;
- for (int n_char = 0 ; n_char < char_list.size() ; n_char++)
- {
- if (char_list.at(n_char).name == real_char)
- f_cid = n_char;
- }
- }
-
-
-
-
- if (f_cid < -2 || f_cid >= char_list.size())
- {
- qDebug() << "W: " << real_char << " not present in char_list";
- return;
- }
-
- other_charid = f_cid;
-
- // Redo the character list.
- QStringList sorted_pair_list;
-
- for (char_type i_char : char_list)
- sorted_pair_list.append(i_char.name);
-
- sorted_pair_list.sort();
-
- for (int i = 0; i < ui_pair_list->count(); i++) {
- ui_pair_list->item(i)->setText(sorted_pair_list.at(i));
- }
- if(other_charid != -1)
- {
- f_item->setText(real_char + " [x]");
- }
-}
-
+void Courtroom::on_music_search_edited(QString p_text)
+{
+ // preventing compiler warnings
+ p_text += "a";
+ list_music();
+ list_areas();
+}
+
+void Courtroom::on_pos_dropdown_changed(int p_index)
+{
+ ui_ic_chat_message->setFocus();
+
+ if (p_index < 0 || p_index > 7)
+ return;
+
+ toggle_judge_buttons(false);
+
+ QString f_pos;
+
+ switch (p_index) {
+ case 0:
+ f_pos = "wit";
+ break;
+ case 1:
+ f_pos = "def";
+ break;
+ case 2:
+ f_pos = "pro";
+ break;
+ case 3:
+ f_pos = "jud";
+ toggle_judge_buttons(true);
+ break;
+ case 4:
+ f_pos = "hld";
+ break;
+ case 5:
+ f_pos = "hlp";
+ break;
+ case 6:
+ f_pos = "jur";
+ break;
+ case 7:
+ f_pos = "sea";
+ break;
+ default:
+ f_pos = "";
+ }
+
+ if (f_pos == "" || ui_ooc_chat_name->text() == "")
+ return;
+
+ ao_app->send_server_packet(
+ new AOPacket("CT#" + ui_ooc_chat_name->text() + "#/pos " + f_pos + "#%"));
+}
+
+void Courtroom::on_mute_list_clicked(QModelIndex p_index)
+{
+ QListWidgetItem *f_item = ui_mute_list->item(p_index.row());
+ QString f_char = f_item->text();
+ QString real_char;
+
+ if (f_char.endsWith(" [x]"))
+ real_char = f_char.left(f_char.size() - 4);
+ else
+ real_char = f_char;
+
+ int f_cid = -1;
+
+ for (int n_char = 0; n_char < char_list.size(); n_char++) {
+ if (char_list.at(n_char).name == real_char)
+ f_cid = n_char;
+ }
+
+ if (f_cid < 0 || f_cid >= char_list.size()) {
+ qDebug() << "W: " << real_char << " not present in char_list";
+ return;
+ }
+
+ if (mute_map.value(f_cid)) {
+ mute_map.insert(f_cid, false);
+ f_item->setText(real_char);
+ }
+ else {
+ mute_map.insert(f_cid, true);
+ f_item->setText(real_char + " [x]");
+ }
+}
+
+void Courtroom::on_pair_list_clicked(QModelIndex p_index)
+{
+ QListWidgetItem *f_item = ui_pair_list->item(p_index.row());
+ QString f_char = f_item->text();
+ QString real_char;
+ int f_cid = -1;
+
+ if (f_char.endsWith(" [x]")) {
+ real_char = f_char.left(f_char.size() - 4);
+ f_item->setText(real_char);
+ }
+ else {
+ real_char = f_char;
+ for (int n_char = 0; n_char < char_list.size(); n_char++) {
+ if (char_list.at(n_char).name == real_char)
+ f_cid = n_char;
+ }
+ }
+
+ if (f_cid < -2 || f_cid >= char_list.size()) {
+ qDebug() << "W: " << real_char << " not present in char_list";
+ return;
+ }
+
+ other_charid = f_cid;
+
+ // Redo the character list.
+ QStringList sorted_pair_list;
+
+ for (char_type i_char : char_list)
+ sorted_pair_list.append(i_char.name);
+
+ sorted_pair_list.sort();
+
+ for (int i = 0; i < ui_pair_list->count(); i++) {
+ ui_pair_list->item(i)->setText(sorted_pair_list.at(i));
+ }
+ if (other_charid != -1) {
+ f_item->setText(real_char + " [x]");
+ }
+}
+
void Courtroom::on_music_list_double_clicked(QTreeWidgetItem *p_item,
int column)
-{
- if (is_muted)
- return;
-
+{
+ if (is_muted)
+ return;
+
column = 1; // Column 1 is always the metadata (which we want)
QString p_song = p_item->text(column);
if (!ui_ic_chat_name->text().isEmpty() && ao_app->cccc_ic_support_enabled) {
@@ -3942,103 +3964,99 @@ void Courtroom::on_music_list_double_clicked(QTreeWidgetItem *p_item,
QString::number(m_cid) + "#" +
ui_ic_chat_name->text() + "#%"),
false);
- }
+ }
else {
ao_app->send_server_packet(
new AOPacket("MC#" + p_song + "#" + QString::number(m_cid) + "#%"),
false);
- }
-}
-
-void Courtroom::on_area_list_double_clicked(QModelIndex p_model)
-{
- QString p_area = area_list.at(area_row_to_number.at(p_model.row()));
- ao_app->send_server_packet(new AOPacket("MC#" + p_area + "#" + QString::number(m_cid) + "#%"), false);
-}
-
-void Courtroom::on_hold_it_clicked()
-{
- if (objection_state == 1)
- {
- ui_hold_it->set_image("holdit.png");
- objection_state = 0;
- }
- else
- {
- ui_objection->set_image("objection.png");
- ui_take_that->set_image("takethat.png");
- ui_custom_objection->set_image("custom.png");
-
- ui_hold_it->set_image("holdit_selected.png");
- objection_state = 1;
- }
-
- ui_ic_chat_message->setFocus();
-}
-
-void Courtroom::on_objection_clicked()
-{
- if (objection_state == 2)
- {
- ui_objection->set_image("objection.png");
- objection_state = 0;
- }
- else
- {
- ui_hold_it->set_image("holdit.png");
- ui_take_that->set_image("takethat.png");
- ui_custom_objection->set_image("custom.png");
-
- ui_objection->set_image("objection_selected.png");
- objection_state = 2;
- }
-
- ui_ic_chat_message->setFocus();
-}
-
-void Courtroom::on_take_that_clicked()
-{
- if (objection_state == 3)
- {
- ui_take_that->set_image("takethat.png");
- objection_state = 0;
- }
- else
- {
- ui_objection->set_image("objection.png");
- ui_hold_it->set_image("holdit.png");
- ui_custom_objection->set_image("custom.png");
-
- ui_take_that->set_image("takethat_selected.png");
- objection_state = 3;
- }
-
- ui_ic_chat_message->setFocus();
-}
-
-void Courtroom::on_custom_objection_clicked()
-{
- if (objection_state == 4)
- {
- ui_custom_objection->set_image("custom.png");
- objection_state = 0;
+ }
+}
+
+void Courtroom::on_area_list_double_clicked(QModelIndex p_model)
+
+{
+
+ QString p_area = area_list.at(area_row_to_number.at(p_model.row()));
+
+ ao_app->send_server_packet(
+ new AOPacket("MC#" + p_area + "#" + QString::number(m_cid) + "#%"),
+ false);
+}
+
+void Courtroom::on_hold_it_clicked()
+{
+ if (objection_state == 1) {
+ ui_hold_it->set_image("holdit.png");
+ objection_state = 0;
+ }
+ else {
+ ui_objection->set_image("objection.png");
+ ui_take_that->set_image("takethat.png");
+ ui_custom_objection->set_image("custom.png");
+
+ ui_hold_it->set_image("holdit_selected.png");
+ objection_state = 1;
+ }
+
+ ui_ic_chat_message->setFocus();
+}
+
+void Courtroom::on_objection_clicked()
+{
+ if (objection_state == 2) {
+ ui_objection->set_image("objection.png");
+ objection_state = 0;
+ }
+ else {
+ ui_hold_it->set_image("holdit.png");
+ ui_take_that->set_image("takethat.png");
+ ui_custom_objection->set_image("custom.png");
+
+ ui_objection->set_image("objection_selected.png");
+ objection_state = 2;
+ }
+
+ ui_ic_chat_message->setFocus();
+}
+
+void Courtroom::on_take_that_clicked()
+{
+ if (objection_state == 3) {
+ ui_take_that->set_image("takethat.png");
+ objection_state = 0;
+ }
+ else {
+ ui_objection->set_image("objection.png");
+ ui_hold_it->set_image("holdit.png");
+ ui_custom_objection->set_image("custom.png");
+
+ ui_take_that->set_image("takethat_selected.png");
+ objection_state = 3;
+ }
+
+ ui_ic_chat_message->setFocus();
+}
+
+void Courtroom::on_custom_objection_clicked()
+{
+ if (objection_state == 4) {
+ ui_custom_objection->set_image("custom.png");
+ objection_state = 0;
objection_custom = "";
- }
- else
- {
- ui_objection->set_image("objection.png");
- ui_take_that->set_image("takethat.png");
- ui_hold_it->set_image("holdit.png");
-
- ui_custom_objection->set_image("custom_selected.png");
- objection_state = 4;
- }
-
- ui_ic_chat_message->setFocus();
-}
-
+ }
+ else {
+ ui_objection->set_image("objection.png");
+ ui_take_that->set_image("takethat.png");
+ ui_hold_it->set_image("holdit.png");
+ ui_custom_objection->set_image("custom_selected.png");
+ objection_state = 4;
+ }
+
+ ui_ic_chat_message->setFocus();
+}
+
void Courtroom::ShowContextMenu(const QPoint &pos)
-{
+{
QPoint globalPos = ui_custom_objection->mapToGlobal(pos);
QAction *selecteditem = custom_obj_menu->exec(globalPos);
if (selecteditem) {
@@ -4052,390 +4070,367 @@ void Courtroom::ShowContextMenu(const QPoint &pos)
}
void Courtroom::on_realization_clicked()
- {
+{
if (realization_state == 0) {
- realization_state = 1;
- ui_realization->set_image("realization_pressed.png");
- }
- else
- {
- realization_state = 0;
- ui_realization->set_image("realization.png");
- }
-
- ui_ic_chat_message->setFocus();
-}
-
-void Courtroom::on_screenshake_clicked()
-{
- if (screenshake_state == 0)
- {
- screenshake_state = 1;
- ui_screenshake->set_image("screenshake_pressed.png");
- }
- else
- {
- screenshake_state = 0;
- ui_screenshake->set_image("screenshake.png");
- }
-
- ui_ic_chat_message->setFocus();
-}
-
-void Courtroom::on_mute_clicked()
-{
- if (ui_mute_list->isHidden())
- {
- ui_mute_list->show();
- ui_pair_list->hide();
- ui_pair_offset_spinbox->hide();
- ui_pair_button->set_image("pair_button.png");
- ui_mute->set_image("mute_pressed.png");
- }
- else
- {
- ui_mute_list->hide();
- ui_mute->set_image("mute.png");
- }
-}
-
-void Courtroom::on_pair_clicked()
-{
- if (ui_pair_list->isHidden())
- {
- ui_pair_list->show();
- ui_pair_offset_spinbox->show();
- ui_mute_list->hide();
- ui_mute->set_image("mute.png");
- ui_pair_button->set_image("pair_button_pressed.png");
- }
- else
- {
- ui_pair_list->hide();
- ui_pair_offset_spinbox->hide();
- ui_pair_button->set_image("pair_button.png");
- }
-}
-
-void Courtroom::on_defense_minus_clicked()
-{
- int f_state = defense_bar_state - 1;
-
- if (f_state >= 0)
- ao_app->send_server_packet(new AOPacket("HP#1#" + QString::number(f_state) + "#%"));
-}
-
-void Courtroom::on_defense_plus_clicked()
-{
- int f_state = defense_bar_state + 1;
-
- if (f_state <= 10)
- ao_app->send_server_packet(new AOPacket("HP#1#" + QString::number(f_state) + "#%"));
-}
-
-void Courtroom::on_prosecution_minus_clicked()
-{
- int f_state = prosecution_bar_state - 1;
-
- if (f_state >= 0)
- ao_app->send_server_packet(new AOPacket("HP#2#" + QString::number(f_state) + "#%"));
-}
-
-void Courtroom::on_prosecution_plus_clicked()
-{
- int f_state = prosecution_bar_state + 1;
-
- if (f_state <= 10)
- ao_app->send_server_packet(new AOPacket("HP#2#" + QString::number(f_state) + "#%"));
-}
-
-void Courtroom::on_text_color_changed(int p_color)
-{
- text_color = p_color;
- ui_ic_chat_message->setFocus();
-}
-
-void Courtroom::on_music_slider_moved(int p_value)
-{
- music_player->set_volume(p_value);
- ui_ic_chat_message->setFocus();
-}
-
-void Courtroom::on_sfx_slider_moved(int p_value)
-{
- sfx_player->set_volume(p_value);
- objection_player->set_volume(p_value);
- misc_sfx_player->set_volume(p_value);
- frame_emote_sfx_player->set_volume(p_value);
- pair_frame_emote_sfx_player->set_volume(p_value);
- ui_ic_chat_message->setFocus();
-}
-
-void Courtroom::on_blip_slider_moved(int p_value)
-{
- blip_player->set_volume(p_value);
- ui_ic_chat_message->setFocus();
-}
-
-void Courtroom::on_log_limit_changed(int value)
-{
- log_maximum_blocks = value;
-}
-
-void Courtroom::on_pair_offset_changed(int value)
-{
- offset_with_pair = value;
-}
-
-void Courtroom::on_witness_testimony_clicked()
-{
- if (is_muted)
- return;
-
- ao_app->send_server_packet(new AOPacket("RT#testimony1#%"));
-
- ui_ic_chat_message->setFocus();
-}
-
-void Courtroom::on_cross_examination_clicked()
-{
- if (is_muted)
- return;
-
- ao_app->send_server_packet(new AOPacket("RT#testimony2#%"));
-
- ui_ic_chat_message->setFocus();
-}
-
-void Courtroom::on_not_guilty_clicked()
-{
- if (is_muted)
- return;
-
- ao_app->send_server_packet(new AOPacket("RT#judgeruling#0#%"));
-
- ui_ic_chat_message->setFocus();
-}
-
-void Courtroom::on_guilty_clicked()
-{
- if (is_muted)
- return;
-
- ao_app->send_server_packet(new AOPacket("RT#judgeruling#1#%"));
-
- ui_ic_chat_message->setFocus();
-}
-
-void Courtroom::on_change_character_clicked()
-{
- music_player->set_volume(0);
- sfx_player->set_volume(0);
- sfx_player->set_volume(0);
- blip_player->set_volume(0);
-
- set_char_select();
-
- ui_char_select_background->show();
- ui_spectator->hide();
-}
-
-void Courtroom::on_reload_theme_clicked()
-{
- ao_app->reload_theme();
+ realization_state = 1;
+ ui_realization->set_image("realization_pressed.png");
+ }
+ else {
+ realization_state = 0;
+ ui_realization->set_image("realization.png");
+ }
+
+ ui_ic_chat_message->setFocus();
+}
+void Courtroom::on_screenshake_clicked()
+{
+ if (screenshake_state == 0) {
+ screenshake_state = 1;
+ ui_screenshake->set_image("screenshake_pressed.png");
+ }
+ else {
+ screenshake_state = 0;
+ ui_screenshake->set_image("screenshake.png");
+ }
+
+ ui_ic_chat_message->setFocus();
+}
+void Courtroom::on_mute_clicked()
+{
+ if (ui_mute_list->isHidden()) {
+ ui_mute_list->show();
+ ui_pair_list->hide();
+ ui_pair_offset_spinbox->hide();
+ ui_pair_button->set_image("pair_button.png");
+ ui_mute->set_image("mute_pressed.png");
+ }
+ else {
+ ui_mute_list->hide();
+ ui_mute->set_image("mute.png");
+ }
+}
+
+void Courtroom::on_pair_clicked()
+{
+ if (ui_pair_list->isHidden()) {
+ ui_pair_list->show();
+ ui_pair_offset_spinbox->show();
+ ui_mute_list->hide();
+ ui_mute->set_image("mute.png");
+ ui_pair_button->set_image("pair_button_pressed.png");
+ }
+ else {
+ ui_pair_list->hide();
+ ui_pair_offset_spinbox->hide();
+ ui_pair_button->set_image("pair_button.png");
+ }
+}
+
+void Courtroom::on_defense_minus_clicked()
+{
+ int f_state = defense_bar_state - 1;
+
+ if (f_state >= 0)
+ ao_app->send_server_packet(
+ new AOPacket("HP#1#" + QString::number(f_state) + "#%"));
+}
+
+void Courtroom::on_defense_plus_clicked()
+{
+ int f_state = defense_bar_state + 1;
+
+ if (f_state <= 10)
+ ao_app->send_server_packet(
+ new AOPacket("HP#1#" + QString::number(f_state) + "#%"));
+}
+
+void Courtroom::on_prosecution_minus_clicked()
+{
+ int f_state = prosecution_bar_state - 1;
+
+ if (f_state >= 0)
+ ao_app->send_server_packet(
+ new AOPacket("HP#2#" + QString::number(f_state) + "#%"));
+}
+
+void Courtroom::on_prosecution_plus_clicked()
+{
+ int f_state = prosecution_bar_state + 1;
+
+ if (f_state <= 10)
+ ao_app->send_server_packet(
+ new AOPacket("HP#2#" + QString::number(f_state) + "#%"));
+}
+
+void Courtroom::on_text_color_changed(int p_color)
+{
+ text_color = p_color;
+ ui_ic_chat_message->setFocus();
+}
+
+void Courtroom::on_music_slider_moved(int p_value)
+{
+ music_player->set_volume(p_value);
+ ui_ic_chat_message->setFocus();
+}
+
+void Courtroom::on_sfx_slider_moved(int p_value)
+{
+ sfx_player->set_volume(p_value);
+ objection_player->set_volume(p_value);
+ misc_sfx_player->set_volume(p_value);
+ frame_emote_sfx_player->set_volume(p_value);
+ pair_frame_emote_sfx_player->set_volume(p_value);
+ ui_ic_chat_message->setFocus();
+}
+
+void Courtroom::on_blip_slider_moved(int p_value)
+{
+ blip_player->set_volume(p_value);
+ ui_ic_chat_message->setFocus();
+}
+
+void Courtroom::on_log_limit_changed(int value) { log_maximum_blocks = value; }
+
+void Courtroom::on_pair_offset_changed(int value) { offset_with_pair = value; }
+
+void Courtroom::on_witness_testimony_clicked()
+{
+ if (is_muted)
+ return;
+
+ ao_app->send_server_packet(new AOPacket("RT#testimony1#%"));
+
+ ui_ic_chat_message->setFocus();
+}
+
+void Courtroom::on_cross_examination_clicked()
+{
+ if (is_muted)
+ return;
+
+ ao_app->send_server_packet(new AOPacket("RT#testimony2#%"));
+
+ ui_ic_chat_message->setFocus();
+}
+
+void Courtroom::on_not_guilty_clicked()
+{
+ if (is_muted)
+ return;
+
+ ao_app->send_server_packet(new AOPacket("RT#judgeruling#0#%"));
+
+ ui_ic_chat_message->setFocus();
+}
+
+void Courtroom::on_guilty_clicked()
+{
+ if (is_muted)
+ return;
+
+ ao_app->send_server_packet(new AOPacket("RT#judgeruling#1#%"));
+
+ ui_ic_chat_message->setFocus();
+}
+
+void Courtroom::on_change_character_clicked()
+{
+ music_player->set_volume(0);
+ sfx_player->set_volume(0);
+ sfx_player->set_volume(0);
+ blip_player->set_volume(0);
+
+ set_char_select();
+
+ ui_char_select_background->show();
+ ui_spectator->hide();
+}
+
+void Courtroom::on_reload_theme_clicked()
+{
+ ao_app->reload_theme();
punctuation_modifier = ao_app->get_pundelay();
colorf_iclog = ao_app->get_colored_iclog_enabled();
mirror_iclog = ao_app->get_iclmir_enabled();
colorf_limit = ao_app->colorlog_restricted_enabled();
keep_evidence_display = ao_app->is_keepevi_enabled();
- //to update status on the background
- set_background(current_background);
- //to update fallback text bools
- detect_fallback_text();
- enter_courtroom(m_cid);
-
- anim_state = 4;
- text_state = 3;
-}
-
-void Courtroom::on_back_to_lobby_clicked()
-{
- ao_app->construct_lobby();
- 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()
-{
- this->set_character(-1);
-
- ui_emotes->hide();
-
- ui_char_select_background->hide();
-}
-
-void Courtroom::on_call_mod_clicked()
-{
- if (ao_app->modcall_reason_enabled) {
- QMessageBox errorBox;
- QInputDialog input;
-
- input.setWindowFlags(Qt::WindowSystemMenuHint);
- input.setLabelText(tr("Reason:"));
- input.setWindowTitle(tr("Call Moderator"));
- auto code = input.exec();
-
- if (code != QDialog::Accepted)
- return;
-
- QString text = input.textValue();
- if (text.isEmpty()) {
- errorBox.critical(nullptr, tr("Error"), tr("You must provide a reason."));
- return;
- } else if (text.length() > 256) {
- errorBox.critical(nullptr, tr("Error"), tr("The message is too long."));
- return;
- }
-
- QStringList mod_reason;
- mod_reason.append(text);
-
- ao_app->send_server_packet(new AOPacket("ZZ", mod_reason));
- } else {
- ao_app->send_server_packet(new AOPacket("ZZ#%"));
- }
-
- ui_ic_chat_message->setFocus();
-}
-
-void Courtroom::on_settings_clicked()
-{
- ao_app->call_settings_menu();
-}
-
-void Courtroom::on_announce_casing_clicked()
-{
- ao_app->call_announce_menu(this);
-}
-
-void Courtroom::on_pre_clicked()
-{
- ui_ic_chat_message->setFocus();
-}
-
-void Courtroom::on_flip_clicked()
-{
- ui_ic_chat_message->setFocus();
-}
-
-void Courtroom::on_guard_clicked()
-{
- ui_ic_chat_message->setFocus();
-}
-
-void Courtroom::on_showname_enable_clicked()
-{
-
+ // to update status on the background
+ set_background(current_background);
+ // to update fallback text bools
+ detect_fallback_text();
+ enter_courtroom(m_cid);
+
+ anim_state = 4;
+ text_state = 3;
+}
+
+void Courtroom::on_back_to_lobby_clicked()
+{
+ ao_app->construct_lobby();
+ 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()
+{
+ this->set_character(-1);
+
+ ui_emotes->hide();
+
+ ui_char_select_background->hide();
+}
+
+void Courtroom::on_call_mod_clicked()
+{
+ if (ao_app->modcall_reason_enabled) {
+ QMessageBox errorBox;
+ QInputDialog input;
+
+ input.setWindowFlags(Qt::WindowSystemMenuHint);
+ input.setLabelText(tr("Reason:"));
+ input.setWindowTitle(tr("Call Moderator"));
+ auto code = input.exec();
+
+ if (code != QDialog::Accepted)
+ return;
+
+ QString text = input.textValue();
+ if (text.isEmpty()) {
+ errorBox.critical(nullptr, tr("Error"), tr("You must provide a reason."));
+ return;
+ }
+ else if (text.length() > 256) {
+ errorBox.critical(nullptr, tr("Error"), tr("The message is too long."));
+ return;
+ }
+
+ QStringList mod_reason;
+ mod_reason.append(text);
+
+ ao_app->send_server_packet(new AOPacket("ZZ", mod_reason));
+ }
+ else {
+ ao_app->send_server_packet(new AOPacket("ZZ#%"));
+ }
+
+ ui_ic_chat_message->setFocus();
+}
+
+void Courtroom::on_settings_clicked() { ao_app->call_settings_menu(); }
+
+void Courtroom::on_announce_casing_clicked()
+{
+ ao_app->call_announce_menu(this);
+}
+
+void Courtroom::on_pre_clicked() { ui_ic_chat_message->setFocus(); }
+
+void Courtroom::on_flip_clicked() { ui_ic_chat_message->setFocus(); }
+
+void Courtroom::on_guard_clicked() { ui_ic_chat_message->setFocus(); }
+
+void Courtroom::on_showname_enable_clicked()
+{
+
refresh_iclog(false);
- ui_ic_chat_message->setFocus();
-}
-
-void Courtroom::on_evidence_button_clicked()
-{
- if (ui_evidence->isHidden())
- {
- ui_evidence->show();
- ui_evidence_overlay->hide();
- }
- else
- {
- ui_evidence->hide();
- }
-}
-
-void Courtroom::on_switch_area_music_clicked()
-{
+ ui_ic_chat_message->setFocus();
+}
+
+void Courtroom::on_evidence_button_clicked()
+{
+ if (ui_evidence->isHidden()) {
+ ui_evidence->show();
+ ui_evidence_overlay->hide();
+ }
+ else {
+ ui_evidence->hide();
+ }
+}
+
+void Courtroom::on_switch_area_music_clicked()
+{
if (ui_area_list->isHidden()) {
music_search_par = ui_music_search->text();
ui_music_search->setText(area_search_par);
- ui_area_list->show();
- ui_music_list->hide();
- }
+ ui_area_list->show();
+ ui_music_list->hide();
+ }
else {
area_search_par = ui_music_search->text();
ui_music_search->setText(music_search_par);
- ui_area_list->hide();
- ui_music_list->show();
- }
-}
-
-void Courtroom::ping_server()
-{
- ao_app->send_server_packet(new AOPacket("CH#" + QString::number(m_cid) + "#%"));
-}
-
-void Courtroom::on_casing_clicked()
-{
- if (ao_app->casing_alerts_enabled)
- {
- if (ui_casing->isChecked())
- {
- QStringList f_packet;
-
- f_packet.append(ao_app->get_casing_can_host_cases());
- f_packet.append(QString::number(ao_app->get_casing_cm_enabled()));
- f_packet.append(QString::number(ao_app->get_casing_defence_enabled()));
- f_packet.append(QString::number(ao_app->get_casing_prosecution_enabled()));
- f_packet.append(QString::number(ao_app->get_casing_judge_enabled()));
- f_packet.append(QString::number(ao_app->get_casing_juror_enabled()));
- f_packet.append(QString::number(ao_app->get_casing_steno_enabled()));
- f_packet.append(QString::number(ao_app->get_casing_wit_enabled()));
-
- ao_app->send_server_packet(new AOPacket("SETCASE", f_packet));
- }
- else
- ao_app->send_server_packet(new AOPacket("SETCASE#\"\"#0#0#0#0#0#0#0#%"));
- }
-}
-
-void Courtroom::announce_case(QString title, bool def, bool pro, bool jud, bool jur, bool steno, bool wit)
-{
- if (ao_app->casing_alerts_enabled)
- {
- QStringList f_packet;
-
- f_packet.append(title);
- f_packet.append(QString::number(def));
- f_packet.append(QString::number(pro));
- f_packet.append(QString::number(jud));
- f_packet.append(QString::number(jur));
- f_packet.append(QString::number(steno));
- f_packet.append(QString::number(wit));
-
- ao_app->send_server_packet(new AOPacket("CASEA", f_packet));
- }
-}
-
-Courtroom::~Courtroom()
-{
- delete music_player;
- delete sfx_player;
- delete objection_player;
- delete blip_player;
-}
-
+ ui_area_list->hide();
+ ui_music_list->show();
+ }
+}
+
+void Courtroom::ping_server()
+{
+ ao_app->send_server_packet(
+ new AOPacket("CH#" + QString::number(m_cid) + "#%"));
+}
+
+void Courtroom::on_casing_clicked()
+{
+ if (ao_app->casing_alerts_enabled) {
+ if (ui_casing->isChecked()) {
+ QStringList f_packet;
+
+ f_packet.append(ao_app->get_casing_can_host_cases());
+ f_packet.append(QString::number(ao_app->get_casing_cm_enabled()));
+ f_packet.append(QString::number(ao_app->get_casing_defence_enabled()));
+ f_packet.append(
+ QString::number(ao_app->get_casing_prosecution_enabled()));
+ f_packet.append(QString::number(ao_app->get_casing_judge_enabled()));
+ f_packet.append(QString::number(ao_app->get_casing_juror_enabled()));
+ f_packet.append(QString::number(ao_app->get_casing_steno_enabled()));
+ f_packet.append(QString::number(ao_app->get_casing_wit_enabled()));
+
+ ao_app->send_server_packet(new AOPacket("SETCASE", f_packet));
+ }
+ else
+ ao_app->send_server_packet(new AOPacket("SETCASE#\"\"#0#0#0#0#0#0#0#%"));
+ }
+}
+
+void Courtroom::announce_case(QString title, bool def, bool pro, bool jud,
+ bool jur, bool steno, bool wit)
+{
+ if (ao_app->casing_alerts_enabled) {
+ QStringList f_packet;
+
+ f_packet.append(title);
+ f_packet.append(QString::number(def));
+ f_packet.append(QString::number(pro));
+ f_packet.append(QString::number(jud));
+ f_packet.append(QString::number(jur));
+ f_packet.append(QString::number(steno));
+ f_packet.append(QString::number(wit));
+
+ ao_app->send_server_packet(new AOPacket("CASEA", f_packet));
+ }
+}
+
+Courtroom::~Courtroom()
+{
+ delete music_player;
+ delete sfx_player;
+ delete objection_player;
+ delete blip_player;
+}
+
void Courtroom::refresh_iclog(bool skiplast)
{
ui_ic_chatlog->clear();
@@ -4452,7 +4447,7 @@ void Courtroom::refresh_iclog(bool skiplast)
else
append_ic_text(item.get_message(), item.get_showname(), false, true,
true, item.get_chat_color());
-}
+ }
else {
if (item.get_is_song())
append_ic_text(item.get_message(), item.get_name(), true, false, true);
@@ -4463,22 +4458,23 @@ void Courtroom::refresh_iclog(bool skiplast)
}
}
-#elif (defined (LINUX) || defined (__linux__))
-void Courtroom::load_bass_opus_plugin()
-{
- BASS_PluginLoad("libbassopus.so", 0);
-}
-#elif defined __APPLE__
-void Courtroom::load_bass_opus_plugin()
-{
- QString libpath = ao_app->get_base_path() + "../../Frameworks/libbassopus.dylib";
- QByteArray ba = libpath.toLocal8Bit();
- BASS_PluginLoad(ba.data(), 0);
-}
-#else
-#error This operating system is unsupported for bass plugins.
-#endif
-#endif
#ifdef BASSAUDIO
#if (defined(_WIN32) || defined(_WIN64))
void Courtroom::load_bass_opus_plugin() { BASS_PluginLoad("bassopus.dll", 0); }
+#elif (defined(LINUX) || defined(__linux__))
+void Courtroom::load_bass_opus_plugin()
+{
+ BASS_PluginLoad("libbassopus.so", 0);
+}
+#elif defined __APPLE__
+void Courtroom::load_bass_opus_plugin()
+{
+ QString libpath =
+ ao_app->get_base_path() + "../../Frameworks/libbassopus.dylib";
+ QByteArray ba = libpath.toLocal8Bit();
+ BASS_PluginLoad(ba.data(), 0);
+}
+#else
+#error This operating system is unsupported for bass plugins.
+#endif
+#endif
diff --git a/src/debug_functions.cpp b/src/debug_functions.cpp
index a790610d..6186b9da 100644
--- a/src/debug_functions.cpp
+++ b/src/debug_functions.cpp
@@ -1,5 +1,5 @@
-#include <QMessageBox>
#include <QCoreApplication>
+#include <QMessageBox>
#include "debug_functions.h"
@@ -7,11 +7,12 @@ void call_error(QString p_message)
{
QMessageBox *msgBox = new QMessageBox;
- msgBox->setText(QCoreApplication::translate("debug_functions", "Error: %1").arg(p_message));
- msgBox->setWindowTitle(QCoreApplication::translate("debug_functions", "Error"));
-
+ msgBox->setText(QCoreApplication::translate("debug_functions", "Error: %1")
+ .arg(p_message));
+ msgBox->setWindowTitle(
+ QCoreApplication::translate("debug_functions", "Error"));
- //msgBox->setWindowModality(Qt::NonModal);
+ // msgBox->setWindowModality(Qt::NonModal);
msgBox->exec();
}
@@ -20,9 +21,10 @@ void call_notice(QString p_message)
QMessageBox *msgBox = new QMessageBox;
msgBox->setText(p_message);
- msgBox->setWindowTitle(QCoreApplication::translate("debug_functions", "Notice"));
+ msgBox->setWindowTitle(
+ QCoreApplication::translate("debug_functions", "Notice"));
- //msgBox->setWindowModality(Qt::NonModal);
+ // msgBox->setWindowModality(Qt::NonModal);
msgBox->exec();
}
diff --git a/src/discord_rich_presence.cpp b/src/discord_rich_presence.cpp
index 95a824a1..aea07e5e 100644
--- a/src/discord_rich_presence.cpp
+++ b/src/discord_rich_presence.cpp
@@ -8,23 +8,18 @@ Discord::Discord()
DiscordEventHandlers handlers;
std::memset(&handlers, 0, sizeof(handlers));
handlers = {};
- handlers.ready = [] {
- qInfo() << "Discord RPC ready";
- };
- handlers.disconnected = [](int errorCode, const char* message) {
+ handlers.ready = [] { qInfo() << "Discord RPC ready"; };
+ handlers.disconnected = [](int errorCode, const char *message) {
qInfo() << "Discord RPC disconnected! " << message << errorCode;
};
- handlers.errored = [](int errorCode, const char* message) {
+ handlers.errored = [](int errorCode, const char *message) {
qWarning() << "Discord RPC errored out! " << message << errorCode;
};
qInfo() << "Initializing Discord RPC";
Discord_Initialize(APPLICATION_ID, &handlers, 1, nullptr);
}
-Discord::~Discord()
-{
- Discord_Shutdown();
-}
+Discord::~Discord() { Discord_Shutdown(); }
void Discord::state_lobby()
{
@@ -64,10 +59,12 @@ void Discord::state_server(std::string name, std::string server_id)
void Discord::state_character(std::string name)
{
- auto name_internal = QString(name.c_str()).toLower().replace(' ', '_').toStdString();
+ auto name_internal =
+ QString(name.c_str()).toLower().replace(' ', '_').toStdString();
auto name_friendly = QString(name.c_str()).replace('_', ' ').toStdString();
const std::string playing_as = "Playing as " + name_friendly;
- qDebug() << "Discord RPC: Setting character state (" << playing_as.c_str() << ")";
+ qDebug() << "Discord RPC: Setting character state (" << playing_as.c_str()
+ << ")";
DiscordRichPresence presence;
std::memset(&presence, 0, sizeof(presence));
@@ -101,20 +98,11 @@ void Discord::state_spectate()
Discord_UpdatePresence(&presence);
}
#else
-Discord::Discord()
-{
-
-}
-
-Discord::~Discord()
-{
-
-}
+Discord::Discord() {}
-void Discord::state_lobby()
-{
+Discord::~Discord() {}
-}
+void Discord::state_lobby() {}
void Discord::state_server(std::string name, std::string server_id)
{
@@ -129,7 +117,6 @@ void Discord::state_character(std::string name)
void Discord::state_spectate()
{
qDebug() << "Discord RPC: Setting specator state";
-
}
#endif
-}
+} // namespace AttorneyOnline
diff --git a/src/emotes.cpp b/src/emotes.cpp
index b6a217e6..bbe2f5c9 100644
--- a/src/emotes.cpp
+++ b/src/emotes.cpp
@@ -8,7 +8,8 @@ void Courtroom::construct_emotes()
set_size_and_pos(ui_emotes, "emotes");
- QPoint f_spacing = ao_app->get_button_spacing("emote_button_spacing", "courtroom_design.ini");
+ QPoint f_spacing = ao_app->get_button_spacing("emote_button_spacing",
+ "courtroom_design.ini");
const int button_width = 40;
int x_spacing = f_spacing.x();
@@ -18,13 +19,14 @@ void Courtroom::construct_emotes()
int y_spacing = f_spacing.y();
int y_mod_count = 0;
- emote_columns = ((ui_emotes->width() - button_width) / (x_spacing + button_width)) + 1;
- emote_rows = ((ui_emotes->height() - button_height) / (y_spacing + button_height)) + 1;
+ emote_columns =
+ ((ui_emotes->width() - button_width) / (x_spacing + button_width)) + 1;
+ emote_rows =
+ ((ui_emotes->height() - button_height) / (y_spacing + button_height)) + 1;
max_emotes_on_page = emote_columns * emote_rows;
- for (int n = 0 ; n < max_emotes_on_page ; ++n)
- {
+ for (int n = 0; n < max_emotes_on_page; ++n) {
int x_pos = (button_width + x_spacing) * x_mod_count;
int y_pos = (button_height + y_spacing) * y_mod_count;
@@ -34,12 +36,12 @@ void Courtroom::construct_emotes()
f_emote->set_id(n);
- connect(f_emote, SIGNAL(emote_clicked(int)), this, SLOT(on_emote_clicked(int)));
+ connect(f_emote, SIGNAL(emote_clicked(int)), this,
+ SLOT(on_emote_clicked(int)));
++x_mod_count;
- if (x_mod_count == emote_columns)
- {
+ if (x_mod_count == emote_columns) {
++y_mod_count;
x_mod_count = 0;
}
@@ -56,23 +58,20 @@ void Courtroom::set_emote_page()
ui_emote_left->hide();
ui_emote_right->hide();
- for (AOEmoteButton *i_button : ui_emote_list)
- {
+ for (AOEmoteButton *i_button : ui_emote_list) {
i_button->hide();
}
int total_pages = total_emotes / max_emotes_on_page;
int emotes_on_page = 0;
- if (total_emotes % max_emotes_on_page != 0)
- {
+ if (total_emotes % max_emotes_on_page != 0) {
++total_pages;
- //i. e. not on the last page
+ // i. e. not on the last page
if (total_pages > current_emote_page + 1)
emotes_on_page = max_emotes_on_page;
else
emotes_on_page = total_emotes % max_emotes_on_page;
-
}
else
emotes_on_page = max_emotes_on_page;
@@ -83,8 +82,7 @@ void Courtroom::set_emote_page()
if (current_emote_page > 0)
ui_emote_left->show();
- for (int n_emote = 0 ; n_emote < emotes_on_page ; ++n_emote)
- {
+ for (int n_emote = 0; n_emote < emotes_on_page; ++n_emote) {
int n_real_emote = n_emote + current_emote_page * max_emotes_on_page;
AOEmoteButton *f_emote = ui_emote_list.at(n_emote);
@@ -95,7 +93,6 @@ void Courtroom::set_emote_page()
f_emote->show();
}
-
}
void Courtroom::set_emote_dropdown()
@@ -105,8 +102,7 @@ void Courtroom::set_emote_dropdown()
int total_emotes = ao_app->get_emote_number(current_char);
QStringList emote_list;
- for (int n = 0 ; n < total_emotes ; ++n)
- {
+ for (int n = 0; n < total_emotes; ++n) {
emote_list.append(ao_app->get_emote_comment(current_char, n));
}
@@ -119,19 +115,20 @@ void Courtroom::select_emote(int p_id)
int max = (max_emotes_on_page - 1) + current_emote_page * max_emotes_on_page;
if (current_emote >= min && current_emote <= max)
- ui_emote_list.at(current_emote % max_emotes_on_page)->set_image(current_char, current_emote, "_off.png");
+ ui_emote_list.at(current_emote % max_emotes_on_page)
+ ->set_image(current_char, current_emote, "_off.png");
int old_emote = current_emote;
current_emote = p_id;
if (current_emote >= min && current_emote <= max)
- ui_emote_list.at(current_emote % max_emotes_on_page)->set_image(current_char, current_emote, "_on.png");
+ ui_emote_list.at(current_emote % max_emotes_on_page)
+ ->set_image(current_char, current_emote, "_on.png");
int emote_mod = ao_app->get_emote_mod(current_char, current_emote);
- if (old_emote == current_emote)
- {
+ if (old_emote == current_emote) {
ui_pre->setChecked(!ui_pre->isChecked());
}
else if (emote_mod == 1)
diff --git a/src/encryption_functions.cpp b/src/encryption_functions.cpp
index ffbe0cdb..6669fe15 100644
--- a/src/encryption_functions.cpp
+++ b/src/encryption_functions.cpp
@@ -4,8 +4,8 @@
QString fanta_encrypt(QString temp_input, unsigned int p_key)
{
- //using standard stdlib types is actually easier here because of implicit char<->int conversion
- //which in turn makes encryption arithmetic easier
+ // using standard stdlib types is actually easier here because of implicit
+ // char<->int conversion which in turn makes encryption arithmetic easier
unsigned int key = p_key;
unsigned int C1 = 53761;
@@ -14,8 +14,7 @@ QString fanta_encrypt(QString temp_input, unsigned int p_key)
QVector<uint_fast8_t> temp_result;
std::string input = temp_input.toUtf8().constData();
- for (unsigned int pos = 0 ; pos < input.size() ; ++pos)
- {
+ for (unsigned int pos = 0; pos < input.size(); ++pos) {
uint_fast8_t output = input.at(pos) ^ (key >> 8) % 256;
temp_result.append(output);
key = (temp_result.at(pos) + key) * C1 + C2;
@@ -23,8 +22,7 @@ QString fanta_encrypt(QString temp_input, unsigned int p_key)
std::string result = "";
- for (uint_fast8_t i_int : temp_result)
- {
+ for (uint_fast8_t i_int : temp_result) {
result += omni::int_to_hex(i_int);
}
@@ -39,9 +37,8 @@ QString fanta_decrypt(QString temp_input, unsigned int key)
QVector<unsigned int> unhexed_vector;
- for(unsigned int i=0; i< input.length(); i+=2)
- {
- std::string byte = input.substr(i,2);
+ for (unsigned int i = 0; i < input.length(); i += 2) {
+ std::string byte = input.substr(i, 2);
unsigned int hex_int = strtoul(byte.c_str(), nullptr, 16);
unhexed_vector.append(hex_int);
}
@@ -51,13 +48,11 @@ QString fanta_decrypt(QString temp_input, unsigned int key)
std::string result = "";
- for (int pos = 0 ; pos < unhexed_vector.size() ; ++pos)
- {
+ for (int pos = 0; pos < unhexed_vector.size(); ++pos) {
unsigned char output = unhexed_vector.at(pos) ^ (key >> 8) % 256;
result += output;
key = (unhexed_vector.at(pos) + key) * C1 + C2;
}
return QString::fromStdString(result);
-
}
diff --git a/src/evidence.cpp b/src/evidence.cpp
index 341bed0f..502fae76 100644
--- a/src/evidence.cpp
+++ b/src/evidence.cpp
@@ -4,7 +4,7 @@ void Courtroom::construct_evidence()
{
ui_evidence = new AOImage(this, ao_app);
- //ui_evidence_name = new QLabel(ui_evidence);
+ // ui_evidence_name = new QLabel(ui_evidence);
ui_evidence_name = new AOLineEdit(ui_evidence);
ui_evidence_name->setAlignment(Qt::AlignCenter);
ui_evidence_name->setFont(QFont("Arial", 14, QFont::Bold));
@@ -32,7 +32,8 @@ void Courtroom::construct_evidence()
set_size_and_pos(ui_evidence, "evidence_background");
set_size_and_pos(ui_evidence_buttons, "evidence_buttons");
- QPoint f_spacing = ao_app->get_button_spacing("evidence_button_spacing", "courtroom_design.ini");
+ QPoint f_spacing = ao_app->get_button_spacing("evidence_button_spacing",
+ "courtroom_design.ini");
const int button_width = 70;
int x_spacing = f_spacing.x();
@@ -42,43 +43,57 @@ void Courtroom::construct_evidence()
int y_spacing = f_spacing.y();
int y_mod_count = 0;
- evidence_columns = ((ui_evidence_buttons->width() - button_width) / (x_spacing + button_width)) + 1;
- evidence_rows = ((ui_evidence_buttons->height() - button_height) / (y_spacing + button_height)) + 1;
+ evidence_columns = ((ui_evidence_buttons->width() - button_width) /
+ (x_spacing + button_width)) +
+ 1;
+ evidence_rows = ((ui_evidence_buttons->height() - button_height) /
+ (y_spacing + button_height)) +
+ 1;
max_evidence_on_page = evidence_columns * evidence_rows;
- for (int n = 0 ; n < max_evidence_on_page ; ++n)
- {
+ for (int n = 0; n < max_evidence_on_page; ++n) {
int x_pos = (button_width + x_spacing) * x_mod_count;
int y_pos = (button_height + y_spacing) * y_mod_count;
- AOEvidenceButton *f_evidence = new AOEvidenceButton(ui_evidence_buttons, ao_app, x_pos, y_pos);
+ AOEvidenceButton *f_evidence =
+ new AOEvidenceButton(ui_evidence_buttons, ao_app, x_pos, y_pos);
ui_evidence_list.append(f_evidence);
f_evidence->set_id(n);
- connect(f_evidence, SIGNAL(evidence_clicked(int)), this, SLOT(on_evidence_clicked(int)));
- connect(f_evidence, SIGNAL(evidence_double_clicked(int)), this, SLOT(on_evidence_double_clicked(int)));
- connect(f_evidence, SIGNAL(on_hover(int, bool)), this, SLOT(on_evidence_hover(int, bool)));
+ connect(f_evidence, SIGNAL(evidence_clicked(int)), this,
+ SLOT(on_evidence_clicked(int)));
+ connect(f_evidence, SIGNAL(evidence_double_clicked(int)), this,
+ SLOT(on_evidence_double_clicked(int)));
+ connect(f_evidence, SIGNAL(on_hover(int, bool)), this,
+ SLOT(on_evidence_hover(int, bool)));
++x_mod_count;
- if (x_mod_count == evidence_columns)
- {
+ if (x_mod_count == evidence_columns) {
++y_mod_count;
x_mod_count = 0;
}
}
- connect(ui_evidence_name, SIGNAL(returnPressed()), this, SLOT(on_evidence_name_edited()));
- connect(ui_evidence_left, SIGNAL(clicked()), this, SLOT(on_evidence_left_clicked()));
- connect(ui_evidence_right, SIGNAL(clicked()), this, SLOT(on_evidence_right_clicked()));
- connect(ui_evidence_present, SIGNAL(clicked()), this, SLOT(on_evidence_present_clicked()));
- connect(ui_evidence_delete, SIGNAL(clicked()), this, SLOT(on_evidence_delete_clicked()));
- connect(ui_evidence_image_name, SIGNAL(returnPressed()), this, SLOT(on_evidence_image_name_edited()));
- connect(ui_evidence_image_button, SIGNAL(clicked()), this, SLOT(on_evidence_image_button_clicked()));
- connect(ui_evidence_x, SIGNAL(clicked()), this, SLOT(on_evidence_x_clicked()));
+ connect(ui_evidence_name, SIGNAL(returnPressed()), this,
+ SLOT(on_evidence_name_edited()));
+ connect(ui_evidence_left, SIGNAL(clicked()), this,
+ SLOT(on_evidence_left_clicked()));
+ connect(ui_evidence_right, SIGNAL(clicked()), this,
+ SLOT(on_evidence_right_clicked()));
+ connect(ui_evidence_present, SIGNAL(clicked()), this,
+ SLOT(on_evidence_present_clicked()));
+ connect(ui_evidence_delete, SIGNAL(clicked()), this,
+ SLOT(on_evidence_delete_clicked()));
+ connect(ui_evidence_image_name, SIGNAL(returnPressed()), this,
+ SLOT(on_evidence_image_name_edited()));
+ connect(ui_evidence_image_button, SIGNAL(clicked()), this,
+ SLOT(on_evidence_image_button_clicked()));
+ connect(ui_evidence_x, SIGNAL(clicked()), this,
+ SLOT(on_evidence_x_clicked()));
ui_evidence->hide();
}
@@ -98,26 +113,23 @@ void Courtroom::set_evidence_page()
ui_evidence_left->hide();
ui_evidence_right->hide();
- for (AOEvidenceButton *i_button : ui_evidence_list)
- {
+ for (AOEvidenceButton *i_button : ui_evidence_list) {
i_button->reset();
}
- //to account for the "add evidence" button
+ // to account for the "add evidence" button
++total_evidence;
int total_pages = total_evidence / max_evidence_on_page;
int evidence_on_page = 0;
- if ((total_evidence % max_evidence_on_page) != 0)
- {
+ if ((total_evidence % max_evidence_on_page) != 0) {
++total_pages;
- //i. e. not on the last page
+ // i. e. not on the last page
if (total_pages > current_evidence_page + 1)
evidence_on_page = max_evidence_on_page;
else
evidence_on_page = total_evidence % max_evidence_on_page;
-
}
else
evidence_on_page = max_evidence_on_page;
@@ -128,17 +140,19 @@ void Courtroom::set_evidence_page()
if (current_evidence_page > 0)
ui_evidence_left->show();
- for (int n_evidence_button = 0 ; n_evidence_button < evidence_on_page ; ++n_evidence_button)
- {
- int n_real_evidence = n_evidence_button + current_evidence_page * max_evidence_on_page;
- AOEvidenceButton *f_evidence_button = ui_evidence_list.at(n_evidence_button);
+ for (int n_evidence_button = 0; n_evidence_button < evidence_on_page;
+ ++n_evidence_button) {
+ int n_real_evidence =
+ n_evidence_button + current_evidence_page * max_evidence_on_page;
+ AOEvidenceButton *f_evidence_button =
+ ui_evidence_list.at(n_evidence_button);
- //ie. the add evidence button
+ // ie. the add evidence button
if (n_real_evidence == (total_evidence - 1))
f_evidence_button->set_theme_image("addevidence.png");
- else if (n_real_evidence < (total_evidence - 1))
- {
- f_evidence_button->set_image(local_evidence_list.at(n_real_evidence).image);
+ else if (n_real_evidence < (total_evidence - 1)) {
+ f_evidence_button->set_image(
+ local_evidence_list.at(n_real_evidence).image);
if (n_real_evidence == current_evidence)
f_evidence_button->set_selected(true);
@@ -198,7 +212,7 @@ void Courtroom::on_evidence_image_button_clicked()
QStringList filenames;
if (dialog.exec())
- filenames = dialog.selectedFiles();
+ filenames = dialog.selectedFiles();
if (filenames.size() != 1)
return;
@@ -215,9 +229,9 @@ void Courtroom::on_evidence_clicked(int p_id)
int f_real_id = p_id + max_evidence_on_page * current_evidence_page;
- if (f_real_id == local_evidence_list.size())
- {
- ao_app->send_server_packet(new AOPacket("PE#<name>#<description>#empty.png#%"));
+ if (f_real_id == local_evidence_list.size()) {
+ ao_app->send_server_packet(
+ new AOPacket("PE#<name>#<description>#empty.png#%"));
return;
}
else if (f_real_id > local_evidence_list.size())
@@ -233,7 +247,6 @@ void Courtroom::on_evidence_clicked(int p_id)
current_evidence = f_real_id;
ui_ic_chat_message->setFocus();
-
}
void Courtroom::on_evidence_double_clicked(int p_id)
@@ -262,8 +275,7 @@ void Courtroom::on_evidence_hover(int p_id, bool p_state)
ui_evidence_name->setReadOnly(true);
int final_id = p_id + max_evidence_on_page * current_evidence_page;
- if (p_state)
- {
+ if (p_state) {
if (final_id == local_evidence_list.size())
ui_evidence_name->setText(tr("Add new evidence..."));
else if (final_id < local_evidence_list.size())
@@ -310,7 +322,8 @@ void Courtroom::on_evidence_delete_clicked()
ui_evidence_description->setReadOnly(true);
ui_evidence_overlay->hide();
- ao_app->send_server_packet(new AOPacket("DE#" + QString::number(current_evidence) + "#%"));
+ ao_app->send_server_packet(
+ new AOPacket("DE#" + QString::number(current_evidence) + "#%"));
current_evidence = 0;
@@ -338,4 +351,3 @@ void Courtroom::on_evidence_x_clicked()
ui_ic_chat_message->setFocus();
}
-
diff --git a/src/file_functions.cpp b/src/file_functions.cpp
index f93ee15d..e64a46bf 100644
--- a/src/file_functions.cpp
+++ b/src/file_functions.cpp
@@ -14,7 +14,8 @@ bool dir_exists(QString dir_path)
return check_dir.exists();
}
-bool exists(QString p_path) {
+bool exists(QString p_path)
+{
QFile file(p_path);
return file.exists();
diff --git a/src/hardware_functions.cpp b/src/hardware_functions.cpp
index bd6a6c3c..96c72eb5 100644
--- a/src/hardware_functions.cpp
+++ b/src/hardware_functions.cpp
@@ -2,7 +2,7 @@
#include <QDebug>
-#if (defined (_WIN32) || defined (_WIN64))
+#if (defined(_WIN32) || defined(_WIN64))
#include <windows.h>
static DWORD dwVolSerial;
@@ -10,17 +10,18 @@ static BOOL bIsRetrieved;
QString get_hdid()
{
- bIsRetrieved = GetVolumeInformation(TEXT("C:\\"), nullptr, 0, &dwVolSerial, nullptr, nullptr, nullptr, 0);
+ bIsRetrieved = GetVolumeInformation(TEXT("C:\\"), nullptr, 0, &dwVolSerial,
+ nullptr, nullptr, nullptr, 0);
if (bIsRetrieved)
return QString::number(dwVolSerial, 16);
else
- //a totally random string
- //what could possibly go wrong
+ // a totally random string
+ // what could possibly go wrong
return "gxsps32sa9fnwic92mfbs0";
}
-#elif (defined (LINUX) || defined (__linux__))
+#elif (defined(LINUX) || defined(__linux__))
#include <QFile>
#include <QTextStream>
@@ -33,12 +34,10 @@ QString get_hdid()
QTextStream in(&fstab_file);
- while(!in.atEnd())
- {
+ while (!in.atEnd()) {
QString line = in.readLine();
- if (line.startsWith("UUID"))
- {
+ if (line.startsWith("UUID")) {
QStringList line_elements = line.split("=");
if (line_elements.size() > 1)
@@ -55,26 +54,25 @@ QString get_hdid()
QString get_hdid()
{
- CFStringRef serial;
- char buffer[64] = {0};
- QString hdid;
- io_service_t platformExpert = IOServiceGetMatchingService(kIOMasterPortDefault,
- IOServiceMatching("IOPlatformExpertDevice"));
- if (platformExpert)
- {
- CFTypeRef serialNumberAsCFString = IORegistryEntryCreateCFProperty(platformExpert,
- CFSTR(kIOPlatformSerialNumberKey),
- kCFAllocatorDefault, 0);
- if (serialNumberAsCFString) {
- serial = (CFStringRef)serialNumberAsCFString;
- }
- if (CFStringGetCString(serial, buffer, 64, kCFStringEncodingUTF8)) {
- hdid = buffer;
- }
-
- IOObjectRelease(platformExpert);
- }
- return hdid;
+ CFStringRef serial;
+ char buffer[64] = {0};
+ QString hdid;
+ io_service_t platformExpert = IOServiceGetMatchingService(
+ kIOMasterPortDefault, IOServiceMatching("IOPlatformExpertDevice"));
+ if (platformExpert) {
+ CFTypeRef serialNumberAsCFString = IORegistryEntryCreateCFProperty(
+ platformExpert, CFSTR(kIOPlatformSerialNumberKey), kCFAllocatorDefault,
+ 0);
+ if (serialNumberAsCFString) {
+ serial = (CFStringRef)serialNumberAsCFString;
+ }
+ if (CFStringGetCString(serial, buffer, 64, kCFStringEncodingUTF8)) {
+ hdid = buffer;
+ }
+
+ IOObjectRelease(platformExpert);
+ }
+ return hdid;
}
#else
diff --git a/src/hex_functions.cpp b/src/hex_functions.cpp
index 4a58d2b4..1e35718f 100644
--- a/src/hex_functions.cpp
+++ b/src/hex_functions.cpp
@@ -1,18 +1,17 @@
#include "hex_functions.h"
-namespace omni
+namespace omni {
+std::string int_to_hex(unsigned int input)
{
- std::string int_to_hex(unsigned int input)
- {
- if (input > 255)
- return "FF";
+ if (input > 255)
+ return "FF";
- std::stringstream stream;
- stream << std::setfill('0') << std::setw(sizeof(char)*2)
- << std::hex << input;
- std::string result(stream.str());
- std::transform(result.begin(), result.end(), result.begin(), ::toupper);
+ std::stringstream stream;
+ stream << std::setfill('0') << std::setw(sizeof(char) * 2) << std::hex
+ << input;
+ std::string result(stream.str());
+ std::transform(result.begin(), result.end(), result.begin(), ::toupper);
- return result;
- }
+ return result;
}
+} // namespace omni
diff --git a/src/lobby.cpp b/src/lobby.cpp
index c590ad5c..853b6ae7 100644
--- a/src/lobby.cpp
+++ b/src/lobby.cpp
@@ -1,410 +1,403 @@
-#include "lobby.h"
-
-#include "debug_functions.h"
-#include "aoapplication.h"
-#include "networkmanager.h"
-#include "aosfxplayer.h"
-
-Lobby::Lobby(AOApplication *p_ao_app) : QMainWindow()
-{
- ao_app = p_ao_app;
-
- this->setWindowTitle(tr("Attorney Online 2"));
- this->setWindowIcon(QIcon(":/logo.png"));
-
- ui_background = new AOImage(this, ao_app);
- ui_public_servers = new AOButton(this, ao_app);
- ui_favorites = new AOButton(this, ao_app);
- ui_refresh = new AOButton(this, ao_app);
- ui_add_to_fav = new AOButton(this, ao_app);
- ui_connect = new AOButton(this, ao_app);
- ui_version = new QLabel(this);
- ui_about = new AOButton(this, ao_app);
- ui_server_list = new QListWidget(this);
- ui_player_count = new QLabel(this);
- ui_description = new AOTextArea(this);
- ui_chatbox = new AOTextArea(this);
- ui_chatbox->setOpenExternalLinks(true);
- ui_chatname = new QLineEdit(this);
- ui_chatname->setPlaceholderText(tr("Name"));
- ui_chatname->setText(ao_app->get_ooc_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_progress_bar->setMinimum(0);
- ui_progress_bar->setMaximum(100);
- ui_progress_bar->setStyleSheet("QProgressBar{ color: white; }");
- 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()));
- connect(ui_refresh, SIGNAL(pressed()), this, SLOT(on_refresh_pressed()));
- connect(ui_refresh, SIGNAL(released()), this, SLOT(on_refresh_released()));
- connect(ui_add_to_fav, SIGNAL(pressed()), this, SLOT(on_add_to_fav_pressed()));
- connect(ui_add_to_fav, SIGNAL(released()), this, SLOT(on_add_to_fav_released()));
- connect(ui_connect, SIGNAL(pressed()), this, SLOT(on_connect_pressed()));
- connect(ui_connect, SIGNAL(released()), this, SLOT(on_connect_released()));
- 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_server_list, SIGNAL(activated(QModelIndex)), this, SLOT(on_server_list_doubleclicked(QModelIndex)));
- connect(ui_chatmessage, SIGNAL(returnPressed()), this, SLOT(on_chatfield_return_pressed()));
- connect(ui_cancel, SIGNAL(clicked()), ao_app, SLOT(loading_cancelled()));
-
- ui_connect->setEnabled(false);
-
- list_servers();
-
- set_widgets();
-}
-
-//sets images, position and size
-void Lobby::set_widgets()
-{
- ao_app->reload_theme();
-
- QString filename = "lobby_design.ini";
-
- pos_size_type f_lobby = ao_app->get_element_dimensions("lobby", filename);
-
- if (f_lobby.width < 0 || f_lobby.height < 0)
- {
- qDebug() << "W: did not find lobby width or height in " << ao_app->get_theme_path(filename);
-
- // Most common symptom of bad config files and missing assets.
- call_notice(tr("It doesn't look like your client is set up correctly.\n"
- "Did you download all resources correctly from tiny.cc/getao, "
- "including the large 'base' folder?"));
-
- this->resize(517, 666);
- }
- else
- {
- this->resize(f_lobby.width, f_lobby.height);
- }
-
- set_size_and_pos(ui_background, "lobby");
- ui_background->set_image("lobbybackground.png");
-
- set_size_and_pos(ui_public_servers, "public_servers");
- ui_public_servers->set_image("publicservers_selected.png");
-
- set_size_and_pos(ui_favorites, "favorites");
- ui_favorites->set_image("favorites.png");
-
- set_size_and_pos(ui_refresh, "refresh");
- ui_refresh->set_image("refresh.png");
-
- set_size_and_pos(ui_add_to_fav, "add_to_fav");
- ui_add_to_fav->set_image("addtofav.png");
-
- set_size_and_pos(ui_connect, "connect");
- ui_connect->set_image("connect.png");
-
- set_size_and_pos(ui_version, "version");
- ui_version->setText(tr("Version: %1").arg(ao_app->get_version_string()));
-
- set_size_and_pos(ui_about, "about");
- ui_about->set_image("about.png");
-
- set_size_and_pos(ui_server_list, "server_list");
- ui_server_list->setStyleSheet("background-color: rgba(0, 0, 0, 0);"
- "font: bold;");
-
- set_size_and_pos(ui_player_count, "player_count");
- ui_player_count->setText(tr("Offline"));
- ui_player_count->setStyleSheet("font: bold;"
- "color: white;"
- "qproperty-alignment: AlignCenter;");
-
- set_size_and_pos(ui_description, "description");
- ui_description->setReadOnly(true);
- ui_description->setStyleSheet("background-color: rgba(0, 0, 0, 0);"
- "color: white;");
-
- set_size_and_pos(ui_chatbox, "chatbox");
- ui_chatbox->setReadOnly(true);
- ui_chatbox->setStyleSheet("QTextBrowser{background-color: rgba(0, 0, 0, 0);}");
-
- 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);");
-
- 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->resize(this->width(), this->height());
- ui_loading_background->set_image("loadingbackground.png");
-
-
- 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->setFrameStyle(QFrame::NoFrame);
- ui_loading_text->setStyleSheet("background-color: rgba(0, 0, 0, 0);"
- "color: rgba(255, 128, 0, 255);");
- ui_loading_text->append(tr("Loading"));
-
- set_size_and_pos(ui_progress_bar, "progress_bar");
- set_size_and_pos(ui_cancel, "cancel");
- ui_cancel->setText(tr("Cancel"));
-
- ui_loading_background->hide();
-
-}
-
-void Lobby::set_size_and_pos(QWidget *p_widget, QString p_identifier)
-{
- QString filename = "lobby_design.ini";
-
- pos_size_type design_ini_result = ao_app->get_element_dimensions(p_identifier, filename);
-
- if (design_ini_result.width < 0 || design_ini_result.height < 0)
- {
- qDebug() << "W: could not find " << p_identifier << " in " << filename;
- p_widget->hide();
- }
- else
- {
- p_widget->move(design_ini_result.x, design_ini_result.y);
- p_widget->resize(design_ini_result.width, design_ini_result.height);
- }
-}
-
-void Lobby::lobbyThreadHandler(QString loadingText){
- this->set_loading_text(loadingText);
-}
-
-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;
-}
-
-int Lobby::get_selected_server()
-{
- return ui_server_list->currentRow();
-}
-
-void Lobby::set_loading_value(int p_value)
-{
- ui_progress_bar->setValue(p_value);
-}
-
-void Lobby::on_public_servers_clicked()
-{
- ui_public_servers->set_image("publicservers_selected.png");
- ui_favorites->set_image("favorites.png");
-
- list_servers();
-
- public_servers_selected = true;
-}
-
-void Lobby::on_favorites_clicked()
-{
- ui_favorites->set_image("favorites_selected.png");
- ui_public_servers->set_image("publicservers.png");
-
- ao_app->set_favorite_list();
- //ao_app->favorite_list = read_serverlist_txt();
-
- list_favorites();
-
- public_servers_selected = false;
-}
-
-void Lobby::on_refresh_pressed()
-{
- ui_refresh->set_image("refresh_pressed.png");
-}
-
-void Lobby::on_refresh_released()
-{
- ui_refresh->set_image("refresh.png");
-
- AOPacket *f_packet = new AOPacket("ALL#%");
-
- ao_app->send_ms_packet(f_packet);
-}
-
-void Lobby::on_add_to_fav_pressed()
-{
- ui_add_to_fav->set_image("addtofav_pressed.png");
-}
-
-void Lobby::on_add_to_fav_released()
-{
- ui_add_to_fav->set_image("addtofav.png");
-
- //you cant add favorites from favorites m8
- if (!public_servers_selected)
- return;
-
- ao_app->add_favorite_server(ui_server_list->currentRow());
-}
-
-void Lobby::on_connect_pressed()
-{
- ui_connect->set_image("connect_pressed.png");
-}
-
-void Lobby::on_connect_released()
-{
- ui_connect->set_image("connect.png");
-
- AOPacket *f_packet;
-
- f_packet = new AOPacket("askchaa#%");
-
- ao_app->send_server_packet(f_packet);
-}
-
-void Lobby::on_about_clicked()
-{
+#include "lobby.h"
+
+#include "aoapplication.h"
+#include "aosfxplayer.h"
+#include "debug_functions.h"
+#include "networkmanager.h"
+
+Lobby::Lobby(AOApplication *p_ao_app) : QMainWindow()
+{
+ ao_app = p_ao_app;
+
+ this->setWindowTitle(tr("Attorney Online 2"));
+ this->setWindowIcon(QIcon(":/logo.png"));
+
+ ui_background = new AOImage(this, ao_app);
+ ui_public_servers = new AOButton(this, ao_app);
+ ui_favorites = new AOButton(this, ao_app);
+ ui_refresh = new AOButton(this, ao_app);
+ ui_add_to_fav = new AOButton(this, ao_app);
+ ui_connect = new AOButton(this, ao_app);
+ ui_version = new QLabel(this);
+ ui_about = new AOButton(this, ao_app);
+ ui_server_list = new QListWidget(this);
+ ui_player_count = new QLabel(this);
+ ui_description = new AOTextArea(this);
+ ui_chatbox = new AOTextArea(this);
+ ui_chatbox->setOpenExternalLinks(true);
+ ui_chatname = new QLineEdit(this);
+ ui_chatname->setPlaceholderText(tr("Name"));
+ ui_chatname->setText(ao_app->get_ooc_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_progress_bar->setMinimum(0);
+ ui_progress_bar->setMaximum(100);
+ ui_progress_bar->setStyleSheet("QProgressBar{ color: white; }");
+ 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()));
+ connect(ui_refresh, SIGNAL(pressed()), this, SLOT(on_refresh_pressed()));
+ connect(ui_refresh, SIGNAL(released()), this, SLOT(on_refresh_released()));
+ connect(ui_add_to_fav, SIGNAL(pressed()), this,
+ SLOT(on_add_to_fav_pressed()));
+ connect(ui_add_to_fav, SIGNAL(released()), this,
+ SLOT(on_add_to_fav_released()));
+ connect(ui_connect, SIGNAL(pressed()), this, SLOT(on_connect_pressed()));
+ connect(ui_connect, SIGNAL(released()), this, SLOT(on_connect_released()));
+ 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_server_list, SIGNAL(activated(QModelIndex)), this,
+ SLOT(on_server_list_doubleclicked(QModelIndex)));
+ connect(ui_chatmessage, SIGNAL(returnPressed()), this,
+ SLOT(on_chatfield_return_pressed()));
+ connect(ui_cancel, SIGNAL(clicked()), ao_app, SLOT(loading_cancelled()));
+
+ ui_connect->setEnabled(false);
+
+ list_servers();
+
+ set_widgets();
+}
+
+// sets images, position and size
+void Lobby::set_widgets()
+{
+ ao_app->reload_theme();
+
+ QString filename = "lobby_design.ini";
+
+ pos_size_type f_lobby = ao_app->get_element_dimensions("lobby", filename);
+
+ if (f_lobby.width < 0 || f_lobby.height < 0) {
+ qDebug() << "W: did not find lobby width or height in "
+ << ao_app->get_theme_path(filename);
+
+ // Most common symptom of bad config files and missing assets.
+ call_notice(
+ tr("It doesn't look like your client is set up correctly.\n"
+ "Did you download all resources correctly from tiny.cc/getao, "
+ "including the large 'base' folder?"));
+
+ this->resize(517, 666);
+ }
+ else {
+ this->resize(f_lobby.width, f_lobby.height);
+ }
+
+ set_size_and_pos(ui_background, "lobby");
+ ui_background->set_image("lobbybackground.png");
+
+ set_size_and_pos(ui_public_servers, "public_servers");
+ ui_public_servers->set_image("publicservers_selected.png");
+
+ set_size_and_pos(ui_favorites, "favorites");
+ ui_favorites->set_image("favorites.png");
+
+ set_size_and_pos(ui_refresh, "refresh");
+ ui_refresh->set_image("refresh.png");
+
+ set_size_and_pos(ui_add_to_fav, "add_to_fav");
+ ui_add_to_fav->set_image("addtofav.png");
+
+ set_size_and_pos(ui_connect, "connect");
+ ui_connect->set_image("connect.png");
+
+ set_size_and_pos(ui_version, "version");
+ ui_version->setText(tr("Version: %1").arg(ao_app->get_version_string()));
+
+ set_size_and_pos(ui_about, "about");
+ ui_about->set_image("about.png");
+
+ set_size_and_pos(ui_server_list, "server_list");
+ ui_server_list->setStyleSheet("background-color: rgba(0, 0, 0, 0);"
+ "font: bold;");
+
+ set_size_and_pos(ui_player_count, "player_count");
+ ui_player_count->setText(tr("Offline"));
+ ui_player_count->setStyleSheet("font: bold;"
+ "color: white;"
+ "qproperty-alignment: AlignCenter;");
+
+ set_size_and_pos(ui_description, "description");
+ ui_description->setReadOnly(true);
+ ui_description->setStyleSheet("background-color: rgba(0, 0, 0, 0);"
+ "color: white;");
+
+ set_size_and_pos(ui_chatbox, "chatbox");
+ ui_chatbox->setReadOnly(true);
+ ui_chatbox->setStyleSheet(
+ "QTextBrowser{background-color: rgba(0, 0, 0, 0);}");
+
+ 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);");
+
+ 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->resize(this->width(), this->height());
+ ui_loading_background->set_image("loadingbackground.png");
+
+ 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->setFrameStyle(QFrame::NoFrame);
+ ui_loading_text->setStyleSheet("background-color: rgba(0, 0, 0, 0);"
+ "color: rgba(255, 128, 0, 255);");
+ ui_loading_text->append(tr("Loading"));
+
+ set_size_and_pos(ui_progress_bar, "progress_bar");
+ set_size_and_pos(ui_cancel, "cancel");
+ ui_cancel->setText(tr("Cancel"));
+
+ ui_loading_background->hide();
+}
+
+void Lobby::lobbyThreadHandler(QString loadingText)
+{
+ this->set_loading_text(loadingText);
+}
+
+void Lobby::set_size_and_pos(QWidget *p_widget, QString p_identifier)
+{
+ QString filename = "lobby_design.ini";
+
+ pos_size_type design_ini_result =
+ ao_app->get_element_dimensions(p_identifier, filename);
+
+ if (design_ini_result.width < 0 || design_ini_result.height < 0) {
+ qDebug() << "W: could not find " << p_identifier << " in " << filename;
+ p_widget->hide();
+ }
+ else {
+ 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;
+}
+
+int Lobby::get_selected_server() { return ui_server_list->currentRow(); }
+
+void Lobby::set_loading_value(int p_value)
+{
+ ui_progress_bar->setValue(p_value);
+}
+
+void Lobby::on_public_servers_clicked()
+{
+ ui_public_servers->set_image("publicservers_selected.png");
+ ui_favorites->set_image("favorites.png");
+
+ list_servers();
+
+ public_servers_selected = true;
+}
+
+void Lobby::on_favorites_clicked()
+{
+ ui_favorites->set_image("favorites_selected.png");
+ ui_public_servers->set_image("publicservers.png");
+
+ ao_app->set_favorite_list();
+ // ao_app->favorite_list = read_serverlist_txt();
+
+ list_favorites();
+
+ public_servers_selected = false;
+}
+
+void Lobby::on_refresh_pressed()
+{
+ ui_refresh->set_image("refresh_pressed.png");
+}
+
+void Lobby::on_refresh_released()
+{
+ ui_refresh->set_image("refresh.png");
+
+ AOPacket *f_packet = new AOPacket("ALL#%");
+
+ ao_app->send_ms_packet(f_packet);
+}
+
+void Lobby::on_add_to_fav_pressed()
+{
+ ui_add_to_fav->set_image("addtofav_pressed.png");
+}
+
+void Lobby::on_add_to_fav_released()
+{
+ ui_add_to_fav->set_image("addtofav.png");
+
+ // you cant add favorites from favorites m8
+ if (!public_servers_selected)
+ return;
+
+ ao_app->add_favorite_server(ui_server_list->currentRow());
+}
+
+void Lobby::on_connect_pressed()
+{
+ ui_connect->set_image("connect_pressed.png");
+}
+
+void Lobby::on_connect_released()
+{
+ ui_connect->set_image("connect.png");
+
+ AOPacket *f_packet;
+
+ f_packet = new AOPacket("askchaa#%");
+
+ ao_app->send_server_packet(f_packet);
+}
+
+void Lobby::on_about_clicked()
+{
QString msg =
tr("<h2>Attorney Online %1</h2>"
- "The courtroom drama simulator"
- "<p><b>Source code:</b> "
- "<a href='https://github.com/AttorneyOnline/AO2-Client'>"
- "https://github.com/AttorneyOnline/AO2-Client</a>"
- "<p><b>Major development:</b><br>"
+ "The courtroom drama simulator"
+ "<p><b>Source code:</b> "
+ "<a href='https://github.com/AttorneyOnline/AO2-Client'>"
+ "https://github.com/AttorneyOnline/AO2-Client</a>"
+ "<p><b>Major development:</b><br>"
"OmniTroid, stonedDiscord, longbyte1, gameboyprinter, Cerapter, "
"Cents02"
- "<p><b>Special thanks:</b><br>"
- "Remy, Iamgoofball, Hibiki, Qubrick (webAO), Ruekasu (UI design), "
- "Draxirch (UI design), Unishred, Argoneus (tsuserver), Fiercy, "
+ "<p><b>Special thanks:</b><br>"
+ "Remy, Iamgoofball, Hibiki, Qubrick (webAO), Ruekasu (UI design), "
+ "Draxirch (UI design), Unishred, Argoneus (tsuserver), Fiercy, "
"Noevain, Cronnicossy, Raidensnake")
- .arg(ao_app->get_version_string());
- QMessageBox::about(this, "About", msg);
-}
-
-//clicked on an item in the serverlist
-void Lobby::on_server_list_clicked(QModelIndex p_model)
-{
- if (p_model != last_model)
- {
- server_type f_server;
- last_model = p_model;
- int n_server = p_model.row();
-
- if (n_server < 0)
- return;
-
- if (public_servers_selected)
- {
- QVector<server_type> f_server_list = ao_app->get_server_list();
-
- if (n_server >= f_server_list.size())
- return;
-
- f_server = f_server_list.at(p_model.row());
- }
- else
- {
- if (n_server >= ao_app->get_favorite_list().size())
- return;
-
- f_server = ao_app->get_favorite_list().at(p_model.row());
- }
-
- ui_description->clear();
- ui_description->append(f_server.desc);
-
- ui_description->moveCursor(QTextCursor::Start);
- ui_description->ensureCursorVisible();
-
- ui_player_count->setText(tr("Offline"));
-
- ui_connect->setEnabled(false);
-
- ao_app->net_manager->connect_to_server(f_server);
- }
-}
-
-//doubleclicked on an item in the serverlist so we'll connect right away
-void Lobby::on_server_list_doubleclicked(QModelIndex p_model)
-{
- on_server_list_clicked(p_model);
- on_connect_released();
-}
-
-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()};
-
- AOPacket *f_packet = new AOPacket(f_header, f_contents);
-
- ao_app->send_ms_packet(f_packet);
-
- ui_chatmessage->clear();
-}
-
-void Lobby::list_servers()
-{
- public_servers_selected = true;
- ui_favorites->set_image("favorites.png");
- ui_public_servers->set_image("publicservers_selected.png");
-
- ui_server_list->clear();
-
- for (server_type i_server : ao_app->get_server_list())
- {
- ui_server_list->addItem(i_server.name);
- }
-}
-
-void Lobby::list_favorites()
-{
- ui_server_list->clear();
-
- for (server_type i_server : ao_app->get_favorite_list())
- {
- ui_server_list->addItem(i_server.name);
- }
-}
-
-void Lobby::append_chatmessage(QString f_name, QString f_message)
-{
+ .arg(ao_app->get_version_string());
+ QMessageBox::about(this, "About", msg);
+}
+
+// clicked on an item in the serverlist
+void Lobby::on_server_list_clicked(QModelIndex p_model)
+{
+ if (p_model != last_model) {
+ server_type f_server;
+ last_model = p_model;
+ int n_server = p_model.row();
+
+ if (n_server < 0)
+ return;
+
+ if (public_servers_selected) {
+ QVector<server_type> f_server_list = ao_app->get_server_list();
+
+ if (n_server >= f_server_list.size())
+ return;
+
+ f_server = f_server_list.at(p_model.row());
+ }
+ else {
+ if (n_server >= ao_app->get_favorite_list().size())
+ return;
+
+ f_server = ao_app->get_favorite_list().at(p_model.row());
+ }
+
+ ui_description->clear();
+ ui_description->append(f_server.desc);
+
+ ui_description->moveCursor(QTextCursor::Start);
+ ui_description->ensureCursorVisible();
+
+ ui_player_count->setText(tr("Offline"));
+
+ ui_connect->setEnabled(false);
+
+ ao_app->net_manager->connect_to_server(f_server);
+ }
+}
+
+// doubleclicked on an item in the serverlist so we'll connect right away
+void Lobby::on_server_list_doubleclicked(QModelIndex p_model)
+{
+ on_server_list_clicked(p_model);
+ on_connect_released();
+}
+
+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()};
+
+ AOPacket *f_packet = new AOPacket(f_header, f_contents);
+
+ ao_app->send_ms_packet(f_packet);
+
+ ui_chatmessage->clear();
+}
+
+void Lobby::list_servers()
+{
+ public_servers_selected = true;
+ ui_favorites->set_image("favorites.png");
+ ui_public_servers->set_image("publicservers_selected.png");
+
+ ui_server_list->clear();
+
+ for (server_type i_server : ao_app->get_server_list()) {
+ ui_server_list->addItem(i_server.name);
+ }
+}
+
+void Lobby::list_favorites()
+{
+ ui_server_list->clear();
+
+ for (server_type i_server : ao_app->get_favorite_list()) {
+ ui_server_list->addItem(i_server.name);
+ }
+}
+
+void Lobby::append_chatmessage(QString f_name, QString f_message)
+{
ui_chatbox->append_chatmessage(
f_name, f_message,
ao_app->get_color("ooc_default_color", "courtroom_design.ini").name(),
false);
-}
-
-void Lobby::append_error(QString f_message)
-{
- ui_chatbox->append_error(f_message);
-}
-
-void Lobby::set_player_count(int players_online, int max_players)
-{
- QString f_string = tr("Online: %1/%2").arg(QString::number(players_online)).arg(QString::number(max_players));
- ui_player_count->setText(f_string);
-}
-
-void Lobby::enable_connect_button()
-{
- ui_connect->setEnabled(true);
-}
-
-Lobby::~Lobby()
-{
-
-}
+}
+
+void Lobby::append_error(QString f_message)
+{
+ ui_chatbox->append_error(f_message);
+}
+
+void Lobby::set_player_count(int players_online, int max_players)
+{
+ QString f_string = tr("Online: %1/%2")
+ .arg(QString::number(players_online))
+ .arg(QString::number(max_players));
+ ui_player_count->setText(f_string);
+}
+
+void Lobby::enable_connect_button() { ui_connect->setEnabled(true); }
+
+Lobby::~Lobby() {}
diff --git a/src/main.cpp b/src/main.cpp
index 778323fc..1b105c34 100644
--- a/src/main.cpp
+++ b/src/main.cpp
@@ -1,43 +1,44 @@
#include "aoapplication.h"
+#include "courtroom.h"
#include "datatypes.h"
-#include "networkmanager.h"
#include "lobby.h"
-#include "courtroom.h"
-#include <QPluginLoader>
+#include "networkmanager.h"
#include <QDebug>
-#include <QTranslator>
#include <QLibraryInfo>
+#include <QPluginLoader>
+#include <QTranslator>
int main(int argc, char *argv[])
{
#if QT_VERSION > QT_VERSION_CHECK(5, 6, 0)
- // High-DPI support is for Qt version >=5.6.
- // However, many Linux distros still haven't brought their stable/LTS
- // packages up to Qt 5.6, so this is conditional.
- AOApplication::setAttribute(Qt::AA_EnableHighDpiScaling);
+ // High-DPI support is for Qt version >=5.6.
+ // However, many Linux distros still haven't brought their stable/LTS
+ // packages up to Qt 5.6, so this is conditional.
+ AOApplication::setAttribute(Qt::AA_EnableHighDpiScaling);
#endif
- AOApplication main_app(argc, argv);
+ AOApplication main_app(argc, argv);
- QSettings *configini = main_app.configini;
+ QSettings *configini = main_app.configini;
- QString p_language = configini->value("language", QLocale::system().name()).toString();
- if (p_language == " " || p_language == "")
- p_language = QLocale::system().name();
+ QString p_language =
+ configini->value("language", QLocale::system().name()).toString();
+ if (p_language == " " || p_language == "")
+ p_language = QLocale::system().name();
- QTranslator qtTranslator;
- qtTranslator.load("qt_" + p_language,
- QLibraryInfo::location(QLibraryInfo::TranslationsPath));
- main_app.installTranslator(&qtTranslator);
+ QTranslator qtTranslator;
+ qtTranslator.load("qt_" + p_language,
+ QLibraryInfo::location(QLibraryInfo::TranslationsPath));
+ main_app.installTranslator(&qtTranslator);
- QTranslator appTranslator;
- qDebug() << ":/resource/translations/ao_" + p_language;
- appTranslator.load("ao_" + p_language, ":/resource/translations/");
- main_app.installTranslator(&appTranslator);
+ QTranslator appTranslator;
+ qDebug() << ":/resource/translations/ao_" + p_language;
+ appTranslator.load("ao_" + p_language, ":/resource/translations/");
+ main_app.installTranslator(&appTranslator);
- main_app.construct_lobby();
- main_app.w_lobby->show();
- main_app.net_manager->connect_to_master();
- return main_app.exec();
+ main_app.construct_lobby();
+ main_app.w_lobby->show();
+ main_app.net_manager->connect_to_master();
+ return main_app.exec();
}
diff --git a/src/misc_functions.cpp b/src/misc_functions.cpp
index 23520551..cc144153 100644
--- a/src/misc_functions.cpp
+++ b/src/misc_functions.cpp
@@ -4,6 +4,6 @@ void delay(int p_milliseconds)
{
QTime dieTime = QTime::currentTime().addMSecs(p_milliseconds);
- while(QTime::currentTime() < dieTime)
+ while (QTime::currentTime() < dieTime)
QCoreApplication::processEvents(QEventLoop::AllEvents, 100);
}
diff --git a/src/networkmanager.cpp b/src/networkmanager.cpp
index b029eabe..cf89d0ab 100644
--- a/src/networkmanager.cpp
+++ b/src/networkmanager.cpp
@@ -13,21 +13,23 @@ NetworkManager::NetworkManager(AOApplication *parent) : QObject(parent)
ms_reconnect_timer = new QTimer(this);
ms_reconnect_timer->setSingleShot(true);
- QObject::connect(ms_reconnect_timer, SIGNAL(timeout()), this, SLOT(retry_ms_connect()));
-
- QObject::connect(ms_socket, SIGNAL(readyRead()), this, SLOT(handle_ms_packet()));
- QObject::connect(server_socket, SIGNAL(readyRead()), this, SLOT(handle_server_packet()));
- QObject::connect(server_socket, SIGNAL(disconnected()), ao_app, SLOT(server_disconnected()));
-
- QString master_config = ao_app->configini->value("master", "").value<QString>();
+ QObject::connect(ms_reconnect_timer, SIGNAL(timeout()), this,
+ SLOT(retry_ms_connect()));
+
+ QObject::connect(ms_socket, SIGNAL(readyRead()), this,
+ SLOT(handle_ms_packet()));
+ QObject::connect(server_socket, SIGNAL(readyRead()), this,
+ SLOT(handle_server_packet()));
+ QObject::connect(server_socket, SIGNAL(disconnected()), ao_app,
+ SLOT(server_disconnected()));
+
+ QString master_config =
+ ao_app->configini->value("master", "").value<QString>();
if (master_config != "")
ms_nosrv_hostname = master_config;
}
-NetworkManager::~NetworkManager()
-{
-
-}
+NetworkManager::~NetworkManager() {}
void NetworkManager::connect_to_master()
{
@@ -43,11 +45,11 @@ void NetworkManager::connect_to_master()
void NetworkManager::connect_to_master_nosrv()
{
- QObject::connect(ms_socket, SIGNAL(error(QAbstractSocket::SocketError)),
- this, SLOT(on_ms_socket_error(QAbstractSocket::SocketError)));
+ QObject::connect(ms_socket, SIGNAL(error(QAbstractSocket::SocketError)), this,
+ SLOT(on_ms_socket_error(QAbstractSocket::SocketError)));
- QObject::connect(ms_socket, SIGNAL(connected()),
- this, SLOT(on_ms_nosrv_connect_success()));
+ QObject::connect(ms_socket, SIGNAL(connected()), this,
+ SLOT(on_ms_nosrv_connect_success()));
ms_socket->connectToHost(ms_nosrv_hostname, ms_port);
}
@@ -61,12 +63,10 @@ void NetworkManager::connect_to_server(server_type p_server)
void NetworkManager::ship_ms_packet(QString p_packet)
{
- if (!ms_socket->isOpen())
- {
+ if (!ms_socket->isOpen()) {
retry_ms_connect();
}
- else
- {
+ else {
ms_socket->write(p_packet.toUtf8());
}
}
@@ -81,93 +81,86 @@ void NetworkManager::handle_ms_packet()
QByteArray buffer = ms_socket->readAll();
QString in_data = QString::fromUtf8(buffer, buffer.size());
- if (!in_data.endsWith("%"))
- {
+ if (!in_data.endsWith("%")) {
ms_partial_packet = true;
ms_temp_packet += in_data;
return;
}
- else
- {
- if (ms_partial_packet)
- {
+ else {
+ if (ms_partial_packet) {
in_data = ms_temp_packet + in_data;
ms_temp_packet = "";
ms_partial_packet = false;
}
}
- QStringList packet_list = in_data.split("%", QString::SplitBehavior(QString::SkipEmptyParts));
+ QStringList packet_list =
+ in_data.split("%", QString::SplitBehavior(QString::SkipEmptyParts));
- for (QString packet : packet_list)
- {
+ for (QString packet : packet_list) {
AOPacket *f_packet = new AOPacket(packet);
ao_app->ms_packet_received(f_packet);
}
}
-
void NetworkManager::perform_srv_lookup()
{
- #ifdef MS_FAILOVER_SUPPORTED
+#ifdef MS_FAILOVER_SUPPORTED
ms_dns = new QDnsLookup(QDnsLookup::SRV, ms_srv_hostname, this);
connect(ms_dns, SIGNAL(finished()), this, SLOT(on_srv_lookup()));
ms_dns->lookup();
- #endif
+#endif
}
void NetworkManager::on_srv_lookup()
{
- #ifdef MS_FAILOVER_SUPPORTED
+#ifdef MS_FAILOVER_SUPPORTED
bool connected = false;
- if (ms_dns->error() != QDnsLookup::NoError)
- {
+ if (ms_dns->error() != QDnsLookup::NoError) {
qWarning("SRV lookup of the master server DNS failed.");
ms_dns->deleteLater();
}
- else
- {
+ else {
const auto srv_records = ms_dns->serviceRecords();
- for (const QDnsServiceRecord &record : srv_records)
- {
- #ifdef DEBUG_NETWORK
+ for (const QDnsServiceRecord &record : srv_records) {
+#ifdef DEBUG_NETWORK
qDebug() << "Connecting to " << record.target() << ":" << record.port();
- #endif
+#endif
ms_socket->connectToHost(record.target(), record.port());
QTime timer;
timer.start();
- do
- {
+ do {
ao_app->processEvents();
- if (ms_socket->state() == QAbstractSocket::ConnectedState)
- {
+ if (ms_socket->state() == QAbstractSocket::ConnectedState) {
connected = true;
break;
}
- else if (ms_socket->state() != QAbstractSocket::ConnectingState
- && ms_socket->state() != QAbstractSocket::HostLookupState
- && ms_socket->error() != -1)
- {
+ else if (ms_socket->state() != QAbstractSocket::ConnectingState &&
+ ms_socket->state() != QAbstractSocket::HostLookupState &&
+ ms_socket->error() != -1) {
qDebug() << ms_socket->error();
- qWarning() << "Error connecting to master server:" << ms_socket->errorString();
+ qWarning() << "Error connecting to master server:"
+ << ms_socket->errorString();
ms_socket->abort();
ms_socket->close();
break;
}
- } while (timer.elapsed() < timeout_milliseconds); // Very expensive spin-wait loop - it will bring CPU to 100%!
- if (connected)
- {
- // Connect a one-shot signal in case the master server disconnects randomly
- QObject::connect(ms_socket, SIGNAL(error(QAbstractSocket::SocketError)),
- this, SLOT(on_ms_socket_error(QAbstractSocket::SocketError)));
+ } while (timer.elapsed() <
+ timeout_milliseconds); // Very expensive spin-wait loop - it will
+ // bring CPU to 100%!
+ if (connected) {
+ // Connect a one-shot signal in case the master server disconnects
+ // randomly
+ QObject::connect(
+ ms_socket, SIGNAL(error(QAbstractSocket::SocketError)), this,
+ SLOT(on_ms_socket_error(QAbstractSocket::SocketError)));
break;
}
- else
- {
+ else {
ms_socket->abort();
ms_socket->close();
}
@@ -179,29 +172,30 @@ void NetworkManager::on_srv_lookup()
connect_to_master_nosrv();
else
emit ms_connect_finished(connected, false);
- #endif
+#endif
}
void NetworkManager::on_ms_nosrv_connect_success()
{
emit ms_connect_finished(true, false);
- QObject::disconnect(ms_socket, SIGNAL(connected()),
- this, SLOT(on_ms_nosrv_connect_success()));
+ QObject::disconnect(ms_socket, SIGNAL(connected()), this,
+ SLOT(on_ms_nosrv_connect_success()));
- QObject::connect(ms_socket, SIGNAL(error(QAbstractSocket::SocketError)),
- this, SLOT(on_ms_socket_error(QAbstractSocket::SocketError)));
+ QObject::connect(ms_socket, SIGNAL(error(QAbstractSocket::SocketError)), this,
+ SLOT(on_ms_socket_error(QAbstractSocket::SocketError)));
}
void NetworkManager::on_ms_socket_error(QAbstractSocket::SocketError error)
{
- qWarning() << "Master server socket error:" << ms_socket->errorString()
- << "(" << error << ")";
+ qWarning() << "Master server socket error:" << ms_socket->errorString() << "("
+ << error << ")";
// Disconnect the one-shot signal - this way, failover connect attempts
// don't trigger a full retry
QObject::disconnect(ms_socket, SIGNAL(error(QAbstractSocket::SocketError)),
- this, SLOT(on_ms_socket_error(QAbstractSocket::SocketError)));
+ this,
+ SLOT(on_ms_socket_error(QAbstractSocket::SocketError)));
emit ms_connect_finished(false, true);
@@ -210,7 +204,8 @@ void NetworkManager::on_ms_socket_error(QAbstractSocket::SocketError error)
void NetworkManager::retry_ms_connect()
{
- if (!ms_reconnect_timer->isActive() && ms_socket->state() != QAbstractSocket::ConnectingState)
+ if (!ms_reconnect_timer->isActive() &&
+ ms_socket->state() != QAbstractSocket::ConnectingState)
connect_to_master();
}
@@ -219,27 +214,24 @@ void NetworkManager::handle_server_packet()
QByteArray buffer = server_socket->readAll();
QString in_data = QString::fromUtf8(buffer, buffer.size());
- if (!in_data.endsWith("%"))
- {
+ if (!in_data.endsWith("%")) {
partial_packet = true;
temp_packet += in_data;
return;
}
- else
- {
- if (partial_packet)
- {
+ else {
+ if (partial_packet) {
in_data = temp_packet + in_data;
temp_packet = "";
partial_packet = false;
}
}
- QStringList packet_list = in_data.split("%", QString::SplitBehavior(QString::SkipEmptyParts));
+ QStringList packet_list =
+ in_data.split("%", QString::SplitBehavior(QString::SkipEmptyParts));
- for (QString packet : packet_list)
- {
+ for (QString packet : packet_list) {
AOPacket *f_packet = new AOPacket(packet);
ao_app->server_packet_received(f_packet);
diff --git a/src/packet_distribution.cpp b/src/packet_distribution.cpp
index d6518a34..a110ec4b 100644
--- a/src/packet_distribution.cpp
+++ b/src/packet_distribution.cpp
@@ -1,493 +1,484 @@
-#include "aoapplication.h"
-
-#include "lobby.h"
-#include "courtroom.h"
-#include "networkmanager.h"
-#include "encryption_functions.h"
-#include "hardware_functions.h"
-#include "debug_functions.h"
-
+#include "aoapplication.h"
+
+#include "courtroom.h"
+#include "debug_functions.h"
+#include "encryption_functions.h"
+#include "hardware_functions.h"
+#include "lobby.h"
+#include "networkmanager.h"
+
void AOPacketLoadMusic(AOApplication *my_app, QString file_name, bool is_music)
- {
+{
if (is_music) {
my_app->w_courtroom->append_music(file_name);
- }
+ }
else {
my_app->w_courtroom->append_area(file_name);
my_app->area_count++;
- }
+ }
for (int area_n = 0; area_n < my_app->area_count; area_n++) {
my_app->w_courtroom->arup_append(0, "Unknown", "Unknown", "Unknown");
- }
- }
-
-void AOApplication::ms_packet_received(AOPacket *p_packet)
-{
- p_packet->net_decode();
-
- QString header = p_packet->get_header();
- QStringList f_contents = p_packet->get_contents();
-
-#ifdef DEBUG_NETWORK
- if (header != "CHECK")
- qDebug() << "R(ms):" << p_packet->to_string();
-#endif
-
- if (header == "ALL")
- {
- server_list.clear();
-
- for (QString i_string : p_packet->get_contents())
- {
- server_type f_server;
- QStringList sub_contents = i_string.split("&");
-
- if (sub_contents.size() < 4)
- {
- qDebug() << "W: malformed packet";
- continue;
- }
-
- f_server.name = sub_contents.at(0);
- f_server.desc = sub_contents.at(1);
- f_server.ip = sub_contents.at(2);
- f_server.port = sub_contents.at(3).toInt();
-
- server_list.append(f_server);
- }
-
- if (lobby_constructed)
- {
- w_lobby->list_servers();
- }
- }
- else if (header == "CT")
- {
- QString f_name, f_message;
-
- if (f_contents.size() == 1)
- {
- f_name = "";
- f_message = f_contents.at(0);
- }
- else if (f_contents.size() >= 2)
- {
- f_name = f_contents.at(0);
- f_message = f_contents.at(1);
- }
- else
- goto end;
-
- if (lobby_constructed)
- {
- w_lobby->append_chatmessage(f_name, f_message);
- }
- if (courtroom_constructed && courtroom_loaded)
- {
- w_courtroom->append_ms_chatmessage(f_name, f_message);
- }
- }
- else if (header == "AO2CHECK")
- {
- send_ms_packet(new AOPacket("ID#AO2#" + get_version_string() + "#%"));
- send_ms_packet(new AOPacket("HI#" + get_hdid() + "#%"));
-
- if (f_contents.size() < 1)
- goto end;
-
- QStringList version_contents = f_contents.at(0).split(".");
-
- if (version_contents.size() < 3)
- goto end;
-
- int f_release = version_contents.at(0).toInt();
- int f_major = version_contents.at(1).toInt();
- int f_minor = version_contents.at(2).toInt();
-
- if (get_release() > f_release)
- goto end;
- else if (get_release() == f_release)
- {
- if (get_major_version() > f_major)
- goto end;
- else if (get_major_version() == f_major)
- {
- if (get_minor_version() >= f_minor)
- goto end;
- }
- }
-
- call_notice(tr("Outdated version! Your version: %1\n"
- "Please go to aceattorneyonline.com to update.")
- .arg(get_version_string()));
- destruct_courtroom();
- destruct_lobby();
- }
- else if (header == "DOOM")
- {
- call_notice(tr("You have been exiled from AO.\n"
- "Have a nice day."));
- destruct_courtroom();
- destruct_lobby();
- }
-
- end:
-
- delete p_packet;
-}
-
-bool AOApplication::is_music_track(QString trackname)
-{
- return (trackname.startsWith("==") ||
- trackname.endsWith(".wav") ||
- trackname.endsWith(".mp3") ||
- trackname.endsWith(".mp4") ||
- trackname.endsWith(".ogg") ||
- trackname.endsWith(".opus"));
-}
-
-void AOApplication::server_packet_received(AOPacket *p_packet)
-{
- p_packet->net_decode();
-
- QString header = p_packet->get_header();
- QStringList f_contents = p_packet->get_contents();
- QString f_packet = p_packet->to_string();
-
-#ifdef DEBUG_NETWORK
- if (header != "checkconnection")
- qDebug() << "R:" << f_packet;
-#endif
-
- if (header == "decryptor")
- {
- if (f_contents.size() == 0)
- goto end;
-
- //you may ask where 322 comes from. that would be a good question.
- s_decryptor = fanta_decrypt(f_contents.at(0), 322).toUInt();
-
- //default(legacy) values
- encryption_needed = true;
- yellow_text_enabled = false;
- prezoom_enabled = false;
- flipping_enabled = false;
- custom_objection_enabled = false;
- improved_loading_enabled = false;
- desk_mod_enabled = false;
- evidence_enabled = false;
- cccc_ic_support_enabled = false;
- arup_enabled = false;
- casing_alerts_enabled = false;
- modcall_reason_enabled = false;
- looping_sfx_support_enabled = false;
-
- //workaround for tsuserver4
- if (f_contents.at(0) == "NOENCRYPT")
- encryption_needed = false;
-
- QString f_hdid;
- f_hdid = get_hdid();
-
- AOPacket *hi_packet = new AOPacket("HI#" + f_hdid + "#%");
- send_server_packet(hi_packet);
- }
- else if (header == "ID")
- {
- if (f_contents.size() < 2)
- goto end;
-
- s_pv = f_contents.at(0).toInt();
- server_software = f_contents.at(1);
-
- w_lobby->enable_connect_button();
-
- send_server_packet(new AOPacket("ID#AO2#" + get_version_string() + "#%"));
- }
- else if (header == "CT")
- {
- if (f_contents.size() < 2)
- goto end;
-
- if (courtroom_constructed)
- {
- if (f_contents.size() == 3)
- w_courtroom->append_server_chatmessage(f_contents.at(0), f_contents.at(1), f_contents.at(2));
- else
- w_courtroom->append_server_chatmessage(f_contents.at(0), f_contents.at(1), "0");
- }
- }
- else if (header == "FL")
- {
- if (f_packet.contains("yellowtext",Qt::CaseInsensitive))
- yellow_text_enabled = true;
- if (f_packet.contains("flipping",Qt::CaseInsensitive))
- flipping_enabled = true;
- if (f_packet.contains("customobjections",Qt::CaseInsensitive))
- custom_objection_enabled = true;
- if (f_packet.contains("fastloading",Qt::CaseInsensitive))
- improved_loading_enabled = true;
- if (f_packet.contains("noencryption",Qt::CaseInsensitive))
- encryption_needed = false;
- if (f_packet.contains("deskmod",Qt::CaseInsensitive))
- desk_mod_enabled = true;
- if (f_packet.contains("evidence",Qt::CaseInsensitive))
- evidence_enabled = true;
- if (f_packet.contains("cccc_ic_support",Qt::CaseInsensitive))
- cccc_ic_support_enabled = true;
- if (f_packet.contains("arup",Qt::CaseInsensitive))
- arup_enabled = true;
- if (f_packet.contains("casing_alerts",Qt::CaseInsensitive))
- casing_alerts_enabled = true;
- if (f_packet.contains("modcall_reason",Qt::CaseInsensitive))
- modcall_reason_enabled = true;
- if (f_packet.contains("looping_sfx",Qt::CaseInsensitive))
- looping_sfx_support_enabled = true;
-
- w_lobby->enable_connect_button();
- }
- else if (header == "PN")
- {
- if (f_contents.size() < 2)
- goto end;
-
- w_lobby->set_player_count(f_contents.at(0).toInt(), f_contents.at(1).toInt());
- }
- else if (header == "SI")
- {
- if (f_contents.size() != 3)
- goto end;
-
- char_list_size = f_contents.at(0).toInt();
- evidence_list_size = f_contents.at(1).toInt();
- music_list_size = f_contents.at(2).toInt();
-
- if (char_list_size < 1 || evidence_list_size < 0 || music_list_size < 0)
- goto end;
-
- loaded_chars = 0;
- loaded_evidence = 0;
- loaded_music = 0;
- generated_chars = 0;
-
- destruct_courtroom();
- construct_courtroom();
-
- courtroom_loaded = false;
-
- QString window_title = tr("Attorney Online 2");
- int selected_server = w_lobby->get_selected_server();
-
- QString server_address = "", server_name = "";
- if (w_lobby->public_servers_selected)
- {
- if (selected_server >= 0 && selected_server < server_list.size()) {
- auto info = server_list.at(selected_server);
- server_name = info.name;
- server_address = QString("%1:%2").arg(info.ip, info.port);
- window_title += ": " + server_name;
- }
- }
- else
- {
- if (selected_server >= 0 && selected_server < favorite_list.size()) {
- auto info = favorite_list.at(selected_server);
- server_name = info.name;
- server_address = info.ip + info.port;
- window_title += ": " + server_name;
- }
- }
-
- w_courtroom->set_window_title(window_title);
-
- w_lobby->show_loading_overlay();
- w_lobby->set_loading_text(tr("Loading"));
- w_lobby->set_loading_value(0);
-
- AOPacket *f_packet;
-
- if(improved_loading_enabled)
- f_packet = new AOPacket("RC#%");
- else
- f_packet = new AOPacket("askchar2#%");
-
- send_server_packet(f_packet);
-
- QCryptographicHash hash(QCryptographicHash::Algorithm::Sha256);
- hash.addData(server_address.toUtf8());
- if (is_discord_enabled())
- discord->state_server(server_name.toStdString(), hash.result().toBase64().toStdString());
- }
- else if (header == "CI")
- {
- if (!courtroom_constructed)
- goto end;
-
- 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);
- f_char.evidence_string = sub_elements.at(3);
- //temporary. the CharsCheck packet sets this properly
- f_char.taken = false;
-
- ++loaded_chars;
-
- w_lobby->set_loading_text(tr("Loading chars:\n%1/%2").arg(QString::number(loaded_chars)).arg(QString::number(char_list_size)));
-
- w_courtroom->append_char(f_char);
-
- int total_loading_size = char_list_size * 2 + evidence_list_size + music_list_size;
- int loading_value = int(((loaded_chars + generated_chars + loaded_music + loaded_evidence) / static_cast<double>(total_loading_size)) * 100);
- w_lobby->set_loading_value(loading_value);
- }
-
- if (improved_loading_enabled)
- send_server_packet(new AOPacket("RE#%"));
- else
- {
- QString next_packet_number = QString::number(((loaded_chars - 1) / 10) + 1);
- send_server_packet(new AOPacket("AN#" + next_packet_number + "#%"));
- }
-
- }
- else if (header == "EI")
- {
- if (!courtroom_constructed)
- goto end;
-
-
- // +1 because evidence starts at 1 rather than 0 for whatever reason
- //enjoy fanta
- if (f_contents.at(0).toInt() != loaded_evidence + 1)
- goto end;
-
- if (f_contents.size() < 2)
- goto end;
-
- QStringList sub_elements = f_contents.at(1).split("&");
- if (sub_elements.size() < 4)
- goto end;
-
- 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(tr("Loading evidence:\n%1/%2").arg(QString::number(loaded_evidence)).arg(QString::number(evidence_list_size)));
-
- w_courtroom->append_evidence(f_evi);
-
- int total_loading_size = char_list_size * 2 + evidence_list_size + music_list_size;
- int loading_value = int(((loaded_chars + generated_chars + loaded_music + loaded_evidence) / static_cast<double>(total_loading_size)) * 100);
- w_lobby->set_loading_value(loading_value);
-
- QString next_packet_number = QString::number(loaded_evidence);
- send_server_packet(new AOPacket("AE#" + next_packet_number + "#%"));
-
- }
- else if (header == "EM")
- {
- if (!courtroom_constructed)
- goto end;
-
- bool musiclist_start = false;
- int areas = 0;
-
- 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(tr("Loading music:\n%1/%2").arg(QString::number(loaded_music)).arg(QString::number(music_list_size)));
-
- for (int area_n = 0; area_n < areas; area_n++)
- {
- w_courtroom->arup_append(0, "Unknown", "Unknown", "Unknown");
- }
-
- int total_loading_size = char_list_size * 2 + evidence_list_size + music_list_size;
- int loading_value = int(((loaded_chars + generated_chars + loaded_music + loaded_evidence) / static_cast<double>(total_loading_size)) * 100);
- w_lobby->set_loading_value(loading_value);
- }
-
- QString next_packet_number = QString::number(((loaded_music - 1) / 10) + 1);
- send_server_packet(new AOPacket("AM#" + next_packet_number + "#%"));
- }
- else if (header == "CharsCheck")
- {
- if (!courtroom_constructed)
- goto end;
-
- 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);
- }
- }
-
- else if (header == "SC")
- {
- if (!courtroom_constructed)
- goto end;
-
- for (int n_element = 0 ; n_element < f_contents.size() ; ++n_element)
- {
- QStringList sub_elements = f_contents.at(n_element).split("&");
-
- char_type f_char;
- f_char.name = sub_elements.at(0);
- if (sub_elements.size() >= 2)
- 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(tr("Loading chars:\n%1/%2").arg(QString::number(loaded_chars)).arg(QString::number(char_list_size)));
-
- w_courtroom->append_char(f_char);
-
- int total_loading_size = char_list_size * 2 + evidence_list_size + music_list_size;
- int loading_value = int(((loaded_chars + generated_chars + loaded_music + loaded_evidence) / static_cast<double>(total_loading_size)) * 100);
- w_lobby->set_loading_value(loading_value);
- }
-
- send_server_packet(new AOPacket("RM#%"));
- }
+ }
+}
+
+void AOApplication::ms_packet_received(AOPacket *p_packet)
+{
+ p_packet->net_decode();
+
+ QString header = p_packet->get_header();
+ QStringList f_contents = p_packet->get_contents();
+
+#ifdef DEBUG_NETWORK
+ if (header != "CHECK")
+ qDebug() << "R(ms):" << p_packet->to_string();
+#endif
+
+ if (header == "ALL") {
+ server_list.clear();
+
+ for (QString i_string : p_packet->get_contents()) {
+ server_type f_server;
+ QStringList sub_contents = i_string.split("&");
+
+ if (sub_contents.size() < 4) {
+ qDebug() << "W: malformed packet";
+ continue;
+ }
+
+ f_server.name = sub_contents.at(0);
+ f_server.desc = sub_contents.at(1);
+ f_server.ip = sub_contents.at(2);
+ f_server.port = sub_contents.at(3).toInt();
+
+ server_list.append(f_server);
+ }
+
+ if (lobby_constructed) {
+ w_lobby->list_servers();
+ }
+ }
+ else if (header == "CT") {
+ QString f_name, f_message;
+
+ if (f_contents.size() == 1) {
+ f_name = "";
+ f_message = f_contents.at(0);
+ }
+ else if (f_contents.size() >= 2) {
+ f_name = f_contents.at(0);
+ f_message = f_contents.at(1);
+ }
+ else
+ goto end;
+
+ if (lobby_constructed) {
+ w_lobby->append_chatmessage(f_name, f_message);
+ }
+ if (courtroom_constructed && courtroom_loaded) {
+ w_courtroom->append_ms_chatmessage(f_name, f_message);
+ }
+ }
+ else if (header == "AO2CHECK") {
+ send_ms_packet(new AOPacket("ID#AO2#" + get_version_string() + "#%"));
+ send_ms_packet(new AOPacket("HI#" + get_hdid() + "#%"));
+
+ if (f_contents.size() < 1)
+ goto end;
+
+ QStringList version_contents = f_contents.at(0).split(".");
+
+ if (version_contents.size() < 3)
+ goto end;
+
+ int f_release = version_contents.at(0).toInt();
+ int f_major = version_contents.at(1).toInt();
+ int f_minor = version_contents.at(2).toInt();
+
+ if (get_release() > f_release)
+ goto end;
+ else if (get_release() == f_release) {
+ if (get_major_version() > f_major)
+ goto end;
+ else if (get_major_version() == f_major) {
+ if (get_minor_version() >= f_minor)
+ goto end;
+ }
+ }
+
+ call_notice(tr("Outdated version! Your version: %1\n"
+ "Please go to aceattorneyonline.com to update.")
+ .arg(get_version_string()));
+ destruct_courtroom();
+ destruct_lobby();
+ }
+ else if (header == "DOOM") {
+ call_notice(tr("You have been exiled from AO.\n"
+ "Have a nice day."));
+ destruct_courtroom();
+ destruct_lobby();
+ }
+
+end:
+
+ delete p_packet;
+}
+
+bool AOApplication::is_music_track(QString trackname)
+{
+ return (trackname.startsWith("==") || trackname.endsWith(".wav") ||
+ trackname.endsWith(".mp3") || trackname.endsWith(".mp4") ||
+ trackname.endsWith(".ogg") || trackname.endsWith(".opus"));
+}
+
+void AOApplication::server_packet_received(AOPacket *p_packet)
+{
+ p_packet->net_decode();
+
+ QString header = p_packet->get_header();
+ QStringList f_contents = p_packet->get_contents();
+ QString f_packet = p_packet->to_string();
+
+#ifdef DEBUG_NETWORK
+ if (header != "checkconnection")
+ qDebug() << "R:" << f_packet;
+#endif
+
+ if (header == "decryptor") {
+ if (f_contents.size() == 0)
+ goto end;
+
+ // you may ask where 322 comes from. that would be a good question.
+ s_decryptor = fanta_decrypt(f_contents.at(0), 322).toUInt();
+
+ // default(legacy) values
+ encryption_needed = true;
+ yellow_text_enabled = false;
+ prezoom_enabled = false;
+ flipping_enabled = false;
+ custom_objection_enabled = false;
+ improved_loading_enabled = false;
+ desk_mod_enabled = false;
+ evidence_enabled = false;
+ cccc_ic_support_enabled = false;
+ arup_enabled = false;
+ casing_alerts_enabled = false;
+ modcall_reason_enabled = false;
+ looping_sfx_support_enabled = false;
+
+ // workaround for tsuserver4
+ if (f_contents.at(0) == "NOENCRYPT")
+ encryption_needed = false;
+
+ QString f_hdid;
+ f_hdid = get_hdid();
+
+ AOPacket *hi_packet = new AOPacket("HI#" + f_hdid + "#%");
+ send_server_packet(hi_packet);
+ }
+ else if (header == "ID") {
+ if (f_contents.size() < 2)
+ goto end;
+
+ s_pv = f_contents.at(0).toInt();
+ server_software = f_contents.at(1);
+
+ w_lobby->enable_connect_button();
+
+ send_server_packet(new AOPacket("ID#AO2#" + get_version_string() + "#%"));
+ }
+ else if (header == "CT") {
+ if (f_contents.size() < 2)
+ goto end;
+
+ if (courtroom_constructed) {
+ if (f_contents.size() == 3)
+ w_courtroom->append_server_chatmessage(
+ f_contents.at(0), f_contents.at(1), f_contents.at(2));
+ else
+ w_courtroom->append_server_chatmessage(f_contents.at(0),
+ f_contents.at(1), "0");
+ }
+ }
+ else if (header == "FL") {
+ if (f_packet.contains("yellowtext", Qt::CaseInsensitive))
+ yellow_text_enabled = true;
+ if (f_packet.contains("flipping", Qt::CaseInsensitive))
+ flipping_enabled = true;
+ if (f_packet.contains("customobjections", Qt::CaseInsensitive))
+ custom_objection_enabled = true;
+ if (f_packet.contains("fastloading", Qt::CaseInsensitive))
+ improved_loading_enabled = true;
+ if (f_packet.contains("noencryption", Qt::CaseInsensitive))
+ encryption_needed = false;
+ if (f_packet.contains("deskmod", Qt::CaseInsensitive))
+ desk_mod_enabled = true;
+ if (f_packet.contains("evidence", Qt::CaseInsensitive))
+ evidence_enabled = true;
+ if (f_packet.contains("cccc_ic_support", Qt::CaseInsensitive))
+ cccc_ic_support_enabled = true;
+ if (f_packet.contains("arup", Qt::CaseInsensitive))
+ arup_enabled = true;
+ if (f_packet.contains("casing_alerts", Qt::CaseInsensitive))
+ casing_alerts_enabled = true;
+ if (f_packet.contains("modcall_reason", Qt::CaseInsensitive))
+ modcall_reason_enabled = true;
+ if (f_packet.contains("looping_sfx", Qt::CaseInsensitive))
+ looping_sfx_support_enabled = true;
+
+ w_lobby->enable_connect_button();
+ }
+ else if (header == "PN") {
+ if (f_contents.size() < 2)
+ goto end;
+
+ w_lobby->set_player_count(f_contents.at(0).toInt(),
+ f_contents.at(1).toInt());
+ }
+ else if (header == "SI") {
+ if (f_contents.size() != 3)
+ goto end;
+
+ char_list_size = f_contents.at(0).toInt();
+ evidence_list_size = f_contents.at(1).toInt();
+ music_list_size = f_contents.at(2).toInt();
+
+ if (char_list_size < 1 || evidence_list_size < 0 || music_list_size < 0)
+ goto end;
+
+ loaded_chars = 0;
+ loaded_evidence = 0;
+ loaded_music = 0;
+ generated_chars = 0;
+
+ destruct_courtroom();
+ construct_courtroom();
+
+ courtroom_loaded = false;
+
+ QString window_title = tr("Attorney Online 2");
+ int selected_server = w_lobby->get_selected_server();
+
+ QString server_address = "", server_name = "";
+ if (w_lobby->public_servers_selected) {
+ if (selected_server >= 0 && selected_server < server_list.size()) {
+ auto info = server_list.at(selected_server);
+ server_name = info.name;
+ server_address = QString("%1:%2").arg(info.ip, info.port);
+ window_title += ": " + server_name;
+ }
+ }
+ else {
+ if (selected_server >= 0 && selected_server < favorite_list.size()) {
+ auto info = favorite_list.at(selected_server);
+ server_name = info.name;
+ server_address = info.ip + info.port;
+ window_title += ": " + server_name;
+ }
+ }
+
+ w_courtroom->set_window_title(window_title);
+
+ w_lobby->show_loading_overlay();
+ w_lobby->set_loading_text(tr("Loading"));
+ w_lobby->set_loading_value(0);
+
+ AOPacket *f_packet;
+
+ if (improved_loading_enabled)
+ f_packet = new AOPacket("RC#%");
+ else
+ f_packet = new AOPacket("askchar2#%");
+
+ send_server_packet(f_packet);
+
+ QCryptographicHash hash(QCryptographicHash::Algorithm::Sha256);
+ hash.addData(server_address.toUtf8());
+ if (is_discord_enabled())
+ discord->state_server(server_name.toStdString(),
+ hash.result().toBase64().toStdString());
+ }
+ else if (header == "CI") {
+ if (!courtroom_constructed)
+ goto end;
+
+ 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);
+ f_char.evidence_string = sub_elements.at(3);
+ // temporary. the CharsCheck packet sets this properly
+ f_char.taken = false;
+
+ ++loaded_chars;
+
+ w_lobby->set_loading_text(tr("Loading chars:\n%1/%2")
+ .arg(QString::number(loaded_chars))
+ .arg(QString::number(char_list_size)));
+
+ w_courtroom->append_char(f_char);
+
+ int total_loading_size =
+ char_list_size * 2 + evidence_list_size + music_list_size;
+ int loading_value = int(
+ ((loaded_chars + generated_chars + loaded_music + loaded_evidence) /
+ static_cast<double>(total_loading_size)) *
+ 100);
+ w_lobby->set_loading_value(loading_value);
+ }
+
+ if (improved_loading_enabled)
+ send_server_packet(new AOPacket("RE#%"));
+ else {
+ QString next_packet_number =
+ QString::number(((loaded_chars - 1) / 10) + 1);
+ send_server_packet(new AOPacket("AN#" + next_packet_number + "#%"));
+ }
+ }
+ else if (header == "EI") {
+ if (!courtroom_constructed)
+ goto end;
+
+ // +1 because evidence starts at 1 rather than 0 for whatever reason
+ // enjoy fanta
+ if (f_contents.at(0).toInt() != loaded_evidence + 1)
+ goto end;
+
+ if (f_contents.size() < 2)
+ goto end;
+
+ QStringList sub_elements = f_contents.at(1).split("&");
+ if (sub_elements.size() < 4)
+ goto end;
+
+ 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(tr("Loading evidence:\n%1/%2")
+ .arg(QString::number(loaded_evidence))
+ .arg(QString::number(evidence_list_size)));
+
+ w_courtroom->append_evidence(f_evi);
+
+ int total_loading_size =
+ char_list_size * 2 + evidence_list_size + music_list_size;
+ int loading_value =
+ int(((loaded_chars + generated_chars + loaded_music + loaded_evidence) /
+ static_cast<double>(total_loading_size)) *
+ 100);
+ w_lobby->set_loading_value(loading_value);
+
+ QString next_packet_number = QString::number(loaded_evidence);
+ send_server_packet(new AOPacket("AE#" + next_packet_number + "#%"));
+ }
+ else if (header == "EM") {
+ if (!courtroom_constructed)
+ goto end;
+
+ bool musiclist_start = false;
+ int areas = 0;
+
+ 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(tr("Loading music:\n%1/%2")
+ .arg(QString::number(loaded_music))
+ .arg(QString::number(music_list_size)));
+
+ for (int area_n = 0; area_n < areas; area_n++) {
+ w_courtroom->arup_append(0, "Unknown", "Unknown", "Unknown");
+ }
+
+ int total_loading_size =
+ char_list_size * 2 + evidence_list_size + music_list_size;
+ int loading_value = int(
+ ((loaded_chars + generated_chars + loaded_music + loaded_evidence) /
+ static_cast<double>(total_loading_size)) *
+ 100);
+ w_lobby->set_loading_value(loading_value);
+ }
+
+ QString next_packet_number = QString::number(((loaded_music - 1) / 10) + 1);
+ send_server_packet(new AOPacket("AM#" + next_packet_number + "#%"));
+ }
+ else if (header == "CharsCheck") {
+ if (!courtroom_constructed)
+ goto end;
+
+ 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);
+ }
+ }
+
+ else if (header == "SC") {
+ if (!courtroom_constructed)
+ goto end;
+
+ for (int n_element = 0; n_element < f_contents.size(); ++n_element) {
+ QStringList sub_elements = f_contents.at(n_element).split("&");
+
+ char_type f_char;
+ f_char.name = sub_elements.at(0);
+ if (sub_elements.size() >= 2)
+ 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(tr("Loading chars:\n%1/%2")
+ .arg(QString::number(loaded_chars))
+ .arg(QString::number(char_list_size)));
+
+ w_courtroom->append_char(f_char);
+
+ int total_loading_size =
+ char_list_size * 2 + evidence_list_size + music_list_size;
+ int loading_value = int(
+ ((loaded_chars + generated_chars + loaded_music + loaded_evidence) /
+ static_cast<double>(total_loading_size)) *
+ 100);
+ w_lobby->set_loading_value(loading_value);
+ }
+
+ send_server_packet(new AOPacket("RM#%"));
+ }
else if (header == "SM") {
- if (!courtroom_constructed)
- goto end;
-
+ if (!courtroom_constructed)
+ goto end;
+
bool musics_time = false;
- area_count = 0;
-
+ area_count = 0;
+
for (int n_element = 0; n_element < f_contents.size(); ++n_element) {
int element2check = n_element + 1;
if (element2check > f_contents.size()) {
@@ -500,244 +491,220 @@ void AOApplication::server_packet_received(AOPacket *p_packet)
f_contents.at(element2check).endsWith(".ogg") ||
f_contents.at(element2check).endsWith(".opus"))) {
musics_time = true;
- }
+ }
// Not everything needs to have a thread.
AOPacketLoadMusic(this, f_contents.at(n_element), musics_time);
- ++loaded_music;
+ ++loaded_music;
int total_loading_size =
char_list_size * 2 + evidence_list_size + music_list_size;
int loading_value = int(
((loaded_chars + generated_chars + loaded_music + loaded_evidence) /
static_cast<double>(total_loading_size)) *
100);
- w_lobby->set_loading_value(loading_value);
+ w_lobby->set_loading_value(loading_value);
w_lobby->set_loading_text(tr("Loading music:\n%1/%2")
.arg(QString::number(loaded_music))
.arg(QString::number(music_list_size)));
- }
-
- send_server_packet(new AOPacket("RD#%"));
- }
- else if (header == "DONE")
- {
- if (!courtroom_constructed)
- goto end;
-
- if (lobby_constructed)
- w_courtroom->append_ms_chatmessage("", w_lobby->get_chatlog());
-
- w_courtroom->character_loading_finished();
- w_courtroom->done_received();
-
- courtroom_loaded = true;
-
- destruct_lobby();
- }
- else if (header == "REFMUSIC")
- {
- if (courtroom_constructed)
- w_courtroom->reset_music_list();
- for (int n_element = 0 ; n_element < f_contents.size() ; ++n_element)
- {
- w_courtroom->append_music(f_contents.at(n_element));
- }
- w_courtroom->list_music();
- }
- else if (header == "BN")
- {
- if (f_contents.size() < 1)
- goto end;
-
- if (courtroom_constructed)
- w_courtroom->set_background(f_contents.at(0));
- }
- //server accepting char request(CC) packet
- else if (header == "PV")
- {
- if (f_contents.size() < 3)
- goto end;
- if(f_contents.size() < 4){
- if (courtroom_constructed)
- w_courtroom->enter_courtroom(f_contents.at(2).toInt());
- }
- else
- {
- if (courtroom_constructed)
- {
- if(f_contents.at(3) == "True")
- {
- w_courtroom->set_character(f_contents.at(2).toInt());
- }
- else
- {
- w_courtroom->enter_courtroom(f_contents.at(2).toInt());
- }
- }
- }
- }
- else if (header == "MS")
- {
- if (courtroom_constructed && courtroom_loaded)
- w_courtroom->handle_chatmessage(&p_packet->get_contents());
- }
- else if (header == "MC")
- {
- if (courtroom_constructed && courtroom_loaded)
- w_courtroom->handle_song(&p_packet->get_contents());
- }
- else if (header == "RT")
- {
- if (f_contents.size() < 1)
- goto end;
- if (courtroom_constructed)
- {
- if (f_contents.size() == 1)
- w_courtroom->handle_wtce(f_contents.at(0), 0);
- else if (f_contents.size() == 2) {
- w_courtroom->handle_wtce(f_contents.at(0), f_contents.at(1).toInt());
- }
- }
- }
- else if (header == "HP")
- {
- if (courtroom_constructed && f_contents.size() > 1)
- w_courtroom->set_hp_bar(f_contents.at(0).toInt(), f_contents.at(1).toInt());
- }
- else if (header == "LE")
- {
- if (courtroom_constructed)
- {
- QVector<evi_type> f_evi_list;
-
- for (QString f_string : f_contents)
- {
- QStringList sub_contents = f_string.split("&");
-
- if (sub_contents.size() < 3)
- continue;
-
- evi_type f_evi;
- f_evi.name = sub_contents.at(0);
- f_evi.description = sub_contents.at(1);
- f_evi.image = sub_contents.at(2);
-
- f_evi_list.append(f_evi);
- }
-
- w_courtroom->set_evidence_list(f_evi_list);
- }
- }
- else if (header == "ARUP")
- {
- if (courtroom_constructed)
- {
- int arup_type = f_contents.at(0).toInt();
- for (int n_element = 1 ; n_element < f_contents.size() ; n_element++)
- {
- w_courtroom->arup_modify(arup_type, n_element - 1, f_contents.at(n_element));
- }
- }
- }
- else if (header == "FAILEDLOGIN")
- {
- if (courtroom_constructed)
- w_courtroom->handle_failed_login();
- }
- else if (header == "IL")
- {
- if (courtroom_constructed && f_contents.size() > 0)
- w_courtroom->set_ip_list(f_contents.at(0));
- }
- else if (header == "MU")
- {
- if (courtroom_constructed && f_contents.size() > 0)
- w_courtroom->set_mute(true, f_contents.at(0).toInt());
- }
- else if (header == "UM")
- {
- if (courtroom_constructed && f_contents.size() > 0)
- w_courtroom->set_mute(false, f_contents.at(0).toInt());
- }
- else if (header == "KK")
- {
- if (courtroom_constructed && f_contents.size() >= 1)
- {
- call_notice(tr("You have been kicked from the server.\nReason: %1").arg(f_contents.at(0)));
- construct_lobby();
- destruct_courtroom();
- }
- }
- else if (header == "KB")
- {
- if (courtroom_constructed && f_contents.size() >= 1)
- {
- call_notice(tr("You have been banned from the server.\nReason: %1").arg(f_contents.at(0)));
- construct_lobby();
- destruct_courtroom();
- }
-
- }
- else if (header == "BD")
- {
- call_notice(tr("You are banned on this server.\nReason: %1").arg(f_contents.at(0)));
- }
- else if (header == "ZZ")
- {
- if (courtroom_constructed && f_contents.size() > 0)
- w_courtroom->mod_called(f_contents.at(0));
- }
- else if (header == "CASEA")
- {
- if (courtroom_constructed && f_contents.size() > 7)
- w_courtroom->case_called(f_contents.at(0), f_contents.at(1) == "1", f_contents.at(2) == "1", f_contents.at(3) == "1", f_contents.at(4) == "1", f_contents.at(5) == "1", f_contents.at(6) == "1");
- }
-
- end:
-
- delete p_packet;
-}
-
-void AOApplication::send_ms_packet(AOPacket *p_packet)
-{
- p_packet->net_encode();
-
- QString f_packet = p_packet->to_string();
-
- net_manager->ship_ms_packet(f_packet);
-
-#ifdef DEBUG_NETWORK
- qDebug() << "S(ms):" << f_packet;
-#endif
-
- delete p_packet;
-}
-
-void AOApplication::send_server_packet(AOPacket *p_packet, bool encoded)
-{
- if (encoded)
- p_packet->net_encode();
-
- QString f_packet = p_packet->to_string();
-
- if (encryption_needed)
- {
-#ifdef DEBUG_NETWORK
- qDebug() << "S(e):" << f_packet;
-#endif
-
- p_packet->encrypt_header(s_decryptor);
- f_packet = p_packet->to_string();
- }
- else
- {
+ }
+
+ send_server_packet(new AOPacket("RD#%"));
+ }
+ else if (header == "DONE") {
+
+ if (!courtroom_constructed)
+ goto end;
+
+ if (lobby_constructed)
+ w_courtroom->append_ms_chatmessage("", w_lobby->get_chatlog());
+
+ w_courtroom->character_loading_finished();
+ w_courtroom->done_received();
+
+ courtroom_loaded = true;
+
+ destruct_lobby();
+ }
+ else if (header == "REFMUSIC") {
+ if (courtroom_constructed)
+ w_courtroom->reset_music_list();
+ for (int n_element = 0; n_element < f_contents.size(); ++n_element) {
+ w_courtroom->append_music(f_contents.at(n_element));
+ }
+ w_courtroom->list_music();
+ }
+ else if (header == "BN") {
+
+ if (f_contents.size() < 1)
+ goto end;
+
+ if (courtroom_constructed)
+ w_courtroom->set_background(f_contents.at(0));
+ }
+ // server accepting char request(CC) packet
+ else if (header == "PV") {
+ if (f_contents.size() < 3)
+ goto end;
+ if (f_contents.size() < 4) {
+ if (courtroom_constructed)
+ w_courtroom->enter_courtroom(f_contents.at(2).toInt());
+ }
+ else {
+ if (courtroom_constructed) {
+ if (f_contents.at(3) == "True") {
+ w_courtroom->set_character(f_contents.at(2).toInt());
+ }
+ else {
+ w_courtroom->enter_courtroom(f_contents.at(2).toInt());
+ }
+ }
+ }
+ }
+ else if (header == "MS") {
+ if (courtroom_constructed && courtroom_loaded)
+ w_courtroom->handle_chatmessage(&p_packet->get_contents());
+ }
+ else if (header == "MC") {
+ if (courtroom_constructed && courtroom_loaded)
+ w_courtroom->handle_song(&p_packet->get_contents());
+ }
+ else if (header == "RT") {
+ if (f_contents.size() < 1)
+ goto end;
+ if (courtroom_constructed) {
+ if (f_contents.size() == 1)
+ w_courtroom->handle_wtce(f_contents.at(0), 0);
+ else if (f_contents.size() == 2) {
+ w_courtroom->handle_wtce(f_contents.at(0), f_contents.at(1).toInt());
+ }
+ }
+ }
+ else if (header == "HP") {
+ if (courtroom_constructed && f_contents.size() > 1)
+ w_courtroom->set_hp_bar(f_contents.at(0).toInt(),
+ f_contents.at(1).toInt());
+ }
+ else if (header == "LE") {
+ if (courtroom_constructed) {
+ QVector<evi_type> f_evi_list;
+
+ for (QString f_string : f_contents) {
+ QStringList sub_contents = f_string.split("&");
+
+ if (sub_contents.size() < 3)
+ continue;
+
+ evi_type f_evi;
+ f_evi.name = sub_contents.at(0);
+ f_evi.description = sub_contents.at(1);
+ f_evi.image = sub_contents.at(2);
+
+ f_evi_list.append(f_evi);
+ }
+
+ w_courtroom->set_evidence_list(f_evi_list);
+ }
+ }
+ else if (header == "ARUP") {
+ if (courtroom_constructed) {
+ int arup_type = f_contents.at(0).toInt();
+ for (int n_element = 1; n_element < f_contents.size(); n_element++) {
+ w_courtroom->arup_modify(arup_type, n_element - 1,
+ f_contents.at(n_element));
+ }
+ }
+ }
+ else if (header == "FAILEDLOGIN") {
+ if (courtroom_constructed)
+ w_courtroom->handle_failed_login();
+ }
+ else if (header == "IL") {
+ if (courtroom_constructed && f_contents.size() > 0)
+ w_courtroom->set_ip_list(f_contents.at(0));
+ }
+ else if (header == "MU") {
+ if (courtroom_constructed && f_contents.size() > 0)
+ w_courtroom->set_mute(true, f_contents.at(0).toInt());
+ }
+ else if (header == "UM") {
+ if (courtroom_constructed && f_contents.size() > 0)
+ w_courtroom->set_mute(false, f_contents.at(0).toInt());
+ }
+ else if (header == "KK") {
+ if (courtroom_constructed && f_contents.size() >= 1) {
+ call_notice(tr("You have been kicked from the server.\nReason: %1")
+ .arg(f_contents.at(0)));
+ construct_lobby();
+ destruct_courtroom();
+ }
+ }
+ else if (header == "KB") {
+ if (courtroom_constructed && f_contents.size() >= 1) {
+ call_notice(tr("You have been banned from the server.\nReason: %1")
+ .arg(f_contents.at(0)));
+ construct_lobby();
+ destruct_courtroom();
+ }
+ }
+ else if (header == "BD") {
+ call_notice(
+ tr("You are banned on this server.\nReason: %1").arg(f_contents.at(0)));
+ }
+ else if (header == "ZZ") {
+ if (courtroom_constructed && f_contents.size() > 0)
+ w_courtroom->mod_called(f_contents.at(0));
+ }
+ else if (header == "CASEA") {
+ if (courtroom_constructed && f_contents.size() > 7)
+ w_courtroom->case_called(f_contents.at(0), f_contents.at(1) == "1",
+ f_contents.at(2) == "1", f_contents.at(3) == "1",
+ f_contents.at(4) == "1", f_contents.at(5) == "1",
+ f_contents.at(6) == "1");
+ }
+
+end:
+
+ delete p_packet;
+}
+
+void AOApplication::send_ms_packet(AOPacket *p_packet)
+{
+ p_packet->net_encode();
+
+ QString f_packet = p_packet->to_string();
+
+ net_manager->ship_ms_packet(f_packet);
+
+#ifdef DEBUG_NETWORK
+ qDebug() << "S(ms):" << f_packet;
+#endif
+
+ delete p_packet;
+}
+
+void AOApplication::send_server_packet(AOPacket *p_packet, bool encoded)
+{
+ if (encoded)
+ p_packet->net_encode();
+
+ QString f_packet = p_packet->to_string();
+
+ if (encryption_needed) {
+#ifdef DEBUG_NETWORK
+ qDebug() << "S(e):" << f_packet;
+#endif
+
+ p_packet->encrypt_header(s_decryptor);
+ f_packet = p_packet->to_string();
+ }
+ else {
+ qDebug() << "S:" << f_packet;
+#ifdef DEBUG_NETWORK
qDebug() << "S:" << f_packet;
-#ifdef DEBUG_NETWORK
- qDebug() << "S:" << f_packet;
-#endif
- }
-
- net_manager->ship_server_packet(f_packet);
-
- delete p_packet;
-}
+#endif
+ }
+
+ net_manager->ship_server_packet(f_packet);
+
+ delete p_packet;
+}
diff --git a/src/path_functions.cpp b/src/path_functions.cpp
index 37231927..678543ee 100644
--- a/src/path_functions.cpp
+++ b/src/path_functions.cpp
@@ -1,191 +1,191 @@
-#include "aoapplication.h"
-#include "courtroom.h"
-#include "file_functions.h"
-
-#include <QDir>
-#include <QStandardPaths>
-#include <QRegExp>
-
-#ifdef BASE_OVERRIDE
-#include "base_override.h"
-#endif
-
-//this is a quite broad generalization
-//the most common OSes(mac and windows) are _usually_ case insensitive
-//however, there do exist mac installations with case sensitive filesystems
-//in that case, define CASE_SENSITIVE_FILESYSTEM and compile on a mac
-#if (defined (LINUX) || defined (__linux__))
-#define CASE_SENSITIVE_FILESYSTEM
-#endif
-
-QString AOApplication::get_base_path()
-{
- QString base_path = "";
-#ifdef ANDROID
- QString sdcard_storage = getenv("SECONDARY_STORAGE");
- if (dir_exists(sdcard_storage + "/AO2/")){
- base_path = sdcard_storage + "/AO2/";
- }
- else {
- QString external_storage = getenv("EXTERNAL_STORAGE");
- base_path = external_storage + "/AO2/";
- }
-#elif defined __APPLE__
- base_path = applicationDirPath() + "/../../../base/";
-#else
- base_path = applicationDirPath() + "/base/";
-#endif
-
- return base_path;
-}
-
-QString AOApplication::get_data_path()
-{
- return get_base_path() + "data/";
-}
-
-QString AOApplication::get_default_theme_path(QString p_file)
-{
- QString path = get_base_path() + "themes/default/" + p_file;
-#ifndef CASE_SENSITIVE_FILESYSTEM
- return path;
-#else
- return get_case_sensitive_path(path);
-#endif
-}
-
-QString AOApplication::get_custom_theme_path(QString p_theme, QString p_file)
-{
- QString path = get_base_path() + "themes/" + p_theme + "/" + p_file;
-#ifndef CASE_SENSITIVE_FILESYSTEM
- return path;
-#else
- return get_case_sensitive_path(path);
-#endif
-}
-
-QString AOApplication::get_theme_path(QString p_file)
-{
- QString path = get_base_path() + "themes/" + current_theme + "/" + p_file;
-#ifndef CASE_SENSITIVE_FILESYSTEM
- return path;
-#else
- return get_case_sensitive_path(path);
-#endif
-}
-
-QString AOApplication::get_character_path(QString p_char, QString p_file)
-{
- QString path = get_base_path() + "characters/" + p_char + "/" + p_file;
-#ifndef CASE_SENSITIVE_FILESYSTEM
- return path;
-#else
- return get_case_sensitive_path(path);
-#endif
-}
-
-QString AOApplication::get_sounds_path(QString p_file)
-{
- QString path = get_base_path() + "sounds/general/" + p_file;
-#ifndef CASE_SENSITIVE_FILESYSTEM
- return path;
-#else
- return get_case_sensitive_path(path);
-#endif
-}
-
-QString AOApplication::get_music_path(QString p_song)
-{
- QString withending_check = get_base_path() + "sounds/music/" + p_song;
- QString mp3_check = get_base_path() + "sounds/music/" + p_song + ".mp3";
- QString opus_check = get_base_path() + "sounds/music/" + p_song + ".opus";
- if (file_exists(opus_check))
- {
- #ifndef CASE_SENSITIVE_FILESYSTEM
- return opus_check;
- #else
- return get_case_sensitive_path(opus_check);
- #endif
- }
- else if (file_exists(mp3_check))
- {
- #ifndef CASE_SENSITIVE_FILESYSTEM
- return mp3_check;
- #else
- return get_case_sensitive_path(mp3_check);
- #endif
- }
- else if (file_exists(withending_check))
- {
- #ifndef CASE_SENSITIVE_FILESYSTEM
- return withending_check;
- #else
- return get_case_sensitive_path(withending_check);
- #endif
- }
-#ifndef CASE_SENSITIVE_FILESYSTEM
- return get_base_path() + "sounds/music/" + p_song + ".wav";
+#include "aoapplication.h"
+#include "courtroom.h"
+#include "file_functions.h"
+
+#include <QDir>
+#include <QRegExp>
+#include <QStandardPaths>
+
+#ifdef BASE_OVERRIDE
+#include "base_override.h"
+#endif
+
+// this is a quite broad generalization
+// the most common OSes(mac and windows) are _usually_ case insensitive
+// however, there do exist mac installations with case sensitive filesystems
+// in that case, define CASE_SENSITIVE_FILESYSTEM and compile on a mac
+#if (defined(LINUX) || defined(__linux__))
+#define CASE_SENSITIVE_FILESYSTEM
+#endif
+
+QString AOApplication::get_base_path()
+{
+ QString base_path = "";
+#ifdef ANDROID
+ QString sdcard_storage = getenv("SECONDARY_STORAGE");
+ if (dir_exists(sdcard_storage + "/AO2/")) {
+ base_path = sdcard_storage + "/AO2/";
+ }
+ else {
+ QString external_storage = getenv("EXTERNAL_STORAGE");
+ base_path = external_storage + "/AO2/";
+ }
+#elif defined __APPLE__
+ base_path = applicationDirPath() + "/../../../base/";
+#else
+ base_path = applicationDirPath() + "/base/";
+#endif
+
+ return base_path;
+}
+
+QString AOApplication::get_data_path() { return get_base_path() + "data/"; }
+
+QString AOApplication::get_default_theme_path(QString p_file)
+{
+ QString path = get_base_path() + "themes/default/" + p_file;
+#ifndef CASE_SENSITIVE_FILESYSTEM
+ return path;
+#else
+ return get_case_sensitive_path(path);
+#endif
+}
+
+QString AOApplication::get_custom_theme_path(QString p_theme, QString p_file)
+{
+ QString path = get_base_path() + "themes/" + p_theme + "/" + p_file;
+#ifndef CASE_SENSITIVE_FILESYSTEM
+ return path;
+#else
+ return get_case_sensitive_path(path);
+#endif
+}
+
+QString AOApplication::get_theme_path(QString p_file)
+{
+ QString path = get_base_path() + "themes/" + current_theme + "/" + p_file;
+#ifndef CASE_SENSITIVE_FILESYSTEM
+ return path;
+#else
+ return get_case_sensitive_path(path);
+#endif
+}
+
+QString AOApplication::get_character_path(QString p_char, QString p_file)
+{
+ QString path = get_base_path() + "characters/" + p_char + "/" + p_file;
+#ifndef CASE_SENSITIVE_FILESYSTEM
+ return path;
+#else
+ return get_case_sensitive_path(path);
+#endif
+}
+
+QString AOApplication::get_sounds_path(QString p_file)
+{
+ QString path = get_base_path() + "sounds/general/" + p_file;
+#ifndef CASE_SENSITIVE_FILESYSTEM
+ return path;
+#else
+ return get_case_sensitive_path(path);
+#endif
+}
+
+QString AOApplication::get_music_path(QString p_song)
+{
+ QString withending_check = get_base_path() + "sounds/music/" + p_song;
+ QString mp3_check = get_base_path() + "sounds/music/" + p_song + ".mp3";
+ QString opus_check = get_base_path() + "sounds/music/" + p_song + ".opus";
+ if (file_exists(opus_check)) {
+#ifndef CASE_SENSITIVE_FILESYSTEM
+ return opus_check;
+#else
+ return get_case_sensitive_path(opus_check);
+#endif
+ }
+ else if (file_exists(mp3_check)) {
+#ifndef CASE_SENSITIVE_FILESYSTEM
+ return mp3_check;
+#else
+ return get_case_sensitive_path(mp3_check);
+#endif
+ }
+ else if (file_exists(withending_check)) {
+#ifndef CASE_SENSITIVE_FILESYSTEM
+ return withending_check;
+#else
+ return get_case_sensitive_path(withending_check);
+#endif
+ }
+#ifndef CASE_SENSITIVE_FILESYSTEM
+ return get_base_path() + "sounds/music/" + p_song + ".wav";
;
-#else
- return get_case_sensitive_path(get_base_path() + "sounds/music/" + p_song + ".wav");
-#endif
-}
-
-QString AOApplication::get_background_path(QString p_file)
-{
- QString path = get_base_path() + "background/" + w_courtroom->get_current_background() + "/" + p_file;
- if (courtroom_constructed) {
-#ifndef CASE_SENSITIVE_FILESYSTEM
- return path;
-#else
- return get_case_sensitive_path(path);
-#endif
- }
- return get_default_background_path(p_file);
-}
-
-QString AOApplication::get_default_background_path(QString p_file)
-{
- QString path = get_base_path() + "background/default/" + p_file;
-#ifndef CASE_SENSITIVE_FILESYSTEM
- return path;
-#else
- return get_case_sensitive_path(path);
-#endif
-}
-
-QString AOApplication::get_evidence_path(QString p_file)
-{
- QString path = get_base_path() + "evidence/" + p_file;
-#ifndef CASE_SENSITIVE_FILESYSTEM
- return path;
-#else
- return get_case_sensitive_path(path);
-#endif
-}
-
-QString AOApplication::get_case_sensitive_path(QString p_file) {
- //first, check to see if it's actually there (also serves as base case for recursion)
- if (exists(p_file)) return p_file;
-
- QFileInfo file(p_file);
-
- QString file_basename = file.fileName();
- QString file_parent_dir = get_case_sensitive_path(file.absolutePath());
-
- //second, does it exist in the new parent dir?
- if (exists(file_parent_dir + "/" + file_basename))
- return file_parent_dir + "/" + file_basename;
-
- //last resort, dirlist parent dir and find case insensitive match
- QRegExp file_rx = QRegExp(file_basename, Qt::CaseInsensitive, QRegExp::FixedString);
- QStringList files = QDir(file_parent_dir).entryList();
-
- int result = files.indexOf(file_rx);
-
- if (result != -1)
- return file_parent_dir + "/" + files.at(result);
-
- //if nothing is found, let the caller handle the missing file
- return file_parent_dir + "/" + file_basename;
-}
+#else
+ return get_case_sensitive_path(get_base_path() + "sounds/music/" + p_song +
+ ".wav");
+#endif
+}
+
+QString AOApplication::get_background_path(QString p_file)
+{
+ QString path = get_base_path() + "background/" +
+ w_courtroom->get_current_background() + "/" + p_file;
+ if (courtroom_constructed) {
+#ifndef CASE_SENSITIVE_FILESYSTEM
+ return path;
+#else
+ return get_case_sensitive_path(path);
+#endif
+ }
+ return get_default_background_path(p_file);
+}
+
+QString AOApplication::get_default_background_path(QString p_file)
+{
+ QString path = get_base_path() + "background/default/" + p_file;
+#ifndef CASE_SENSITIVE_FILESYSTEM
+ return path;
+#else
+ return get_case_sensitive_path(path);
+#endif
+}
+
+QString AOApplication::get_evidence_path(QString p_file)
+{
+ QString path = get_base_path() + "evidence/" + p_file;
+#ifndef CASE_SENSITIVE_FILESYSTEM
+ return path;
+#else
+ return get_case_sensitive_path(path);
+#endif
+}
+
+QString AOApplication::get_case_sensitive_path(QString p_file)
+{
+ // first, check to see if it's actually there (also serves as base case for
+ // recursion)
+ if (exists(p_file))
+ return p_file;
+
+ QFileInfo file(p_file);
+
+ QString file_basename = file.fileName();
+ QString file_parent_dir = get_case_sensitive_path(file.absolutePath());
+
+ // second, does it exist in the new parent dir?
+ if (exists(file_parent_dir + "/" + file_basename))
+ return file_parent_dir + "/" + file_basename;
+
+ // last resort, dirlist parent dir and find case insensitive match
+ QRegExp file_rx =
+ QRegExp(file_basename, Qt::CaseInsensitive, QRegExp::FixedString);
+ QStringList files = QDir(file_parent_dir).entryList();
+
+ int result = files.indexOf(file_rx);
+
+ if (result != -1)
+ return file_parent_dir + "/" + files.at(result);
+
+ // if nothing is found, let the caller handle the missing file
+ return file_parent_dir + "/" + file_basename;
+}
diff --git a/src/text_file_functions.cpp b/src/text_file_functions.cpp
index 1fbb0b53..29c5c42b 100644
--- a/src/text_file_functions.cpp
+++ b/src/text_file_functions.cpp
@@ -1,51 +1,51 @@
-#include "text_file_functions.h"
-
-QString AOApplication::read_theme()
-{
- QString result = configini->value("theme", "default").value<QString>();
- return result;
-}
-
-int AOApplication::read_blip_rate()
-{
- int result = configini->value("blip_rate", 2).toInt();
-
- if (result < 1)
- return 1;
-
- return result;
-}
-
-QString AOApplication::get_ooc_name()
-{
- QString result = configini->value("ooc_name").value<QString>();
- return result;
-}
-
-int AOApplication::get_default_music()
-{
- int result = configini->value("default_music", 50).toInt();
- return result;
-}
-
-int AOApplication::get_default_sfx()
-{
- int result = configini->value("default_sfx", 50).toInt();
- return result;
-}
-
-int AOApplication::get_default_blip()
-{
- int result = configini->value("default_blip", 50).toInt();
- return result;
-}
-
-int AOApplication::get_max_log_size()
-{
- int result = configini->value("log_maximum", 200).toInt();
- return result;
-}
-
+#include "text_file_functions.h"
+
+QString AOApplication::read_theme()
+{
+ QString result = configini->value("theme", "default").value<QString>();
+ return result;
+}
+
+int AOApplication::read_blip_rate()
+{
+ int result = configini->value("blip_rate", 2).toInt();
+
+ if (result < 1)
+ return 1;
+
+ return result;
+}
+
+QString AOApplication::get_ooc_name()
+{
+ QString result = configini->value("ooc_name").value<QString>();
+ return result;
+}
+
+int AOApplication::get_default_music()
+{
+ int result = configini->value("default_music", 50).toInt();
+ return result;
+}
+
+int AOApplication::get_default_sfx()
+{
+ int result = configini->value("default_sfx", 50).toInt();
+ return result;
+}
+
+int AOApplication::get_default_blip()
+{
+ int result = configini->value("default_blip", 50).toInt();
+ return result;
+}
+
+int AOApplication::get_max_log_size()
+{
+ int result = configini->value("log_maximum", 200).toInt();
+ return result;
+}
+
int AOApplication::get_pundelay()
{
int result = configini->value("punctuation_delay", 2).toInt();
@@ -55,114 +55,114 @@ int AOApplication::get_pundelay()
return result;
}
-bool AOApplication::get_log_goes_downwards()
-{
- QString result = configini->value("log_goes_downwards", "false").value<QString>();
- return result.startsWith("true");
-}
-
-bool AOApplication::get_showname_enabled_by_default()
-{
- QString result = configini->value("show_custom_shownames", "true").value<QString>();
- return result.startsWith("true");
-}
-
-QString AOApplication::get_default_username()
-{
- QString result = configini->value("default_username", "").value<QString>();
- if (result.isEmpty())
- return get_ooc_name();
- else
- return result;
-}
-
-QString AOApplication::get_audio_output_device()
-{
- QString result = configini->value("default_audio_device", "default").value<QString>();
- return result;
-}
-
-QStringList AOApplication::get_call_words()
-{
- QStringList return_value;
-
- QFile callwords_ini;
-
- callwords_ini.setFileName(get_base_path() + "callwords.ini");
-
- if (!callwords_ini.open(QIODevice::ReadOnly))
- return return_value;
-
- QTextStream in(&callwords_ini);
-
- while (!in.atEnd())
- {
- QString line = in.readLine();
- return_value.append(line);
- }
-
- return return_value;
-}
-
-void AOApplication::write_to_serverlist_txt(QString p_line)
-{
- QFile serverlist_txt;
- QString serverlist_txt_path = get_base_path() + "serverlist.txt";
-
- serverlist_txt.setFileName(serverlist_txt_path);
-
- if (!serverlist_txt.open(QIODevice::WriteOnly | QIODevice::Append))
- {
- return;
- }
-
- QTextStream out(&serverlist_txt);
-
- out << "\r\n" << p_line;
-
- serverlist_txt.close();
-}
-
-QVector<server_type> AOApplication::read_serverlist_txt()
-{
- QVector<server_type> f_server_list;
-
- QFile serverlist_txt;
- QString serverlist_txt_path = get_base_path() + "serverlist.txt";
-
- serverlist_txt.setFileName(serverlist_txt_path);
-
- if (!serverlist_txt.open(QIODevice::ReadOnly))
- {
- return f_server_list;
- }
-
- QTextStream in(&serverlist_txt);
-
- while(!in.atEnd())
- {
- QString line = in.readLine();
- server_type f_server;
- QStringList line_contents = line.split(":");
-
- if (line_contents.size() < 3)
- continue;
-
- f_server.ip = line_contents.at(0);
- f_server.port = line_contents.at(1).toInt();
- f_server.name = line_contents.at(2);
- f_server.desc = "";
-
- f_server_list.append(f_server);
- }
-
- return f_server_list;
-}
-
-QString AOApplication::read_design_ini(QString p_identifier, QString p_design_path)
-{
- QSettings settings(p_design_path, QSettings::IniFormat);
- QVariant value = settings.value(p_identifier);
+bool AOApplication::get_log_goes_downwards()
+{
+ QString result =
+ configini->value("log_goes_downwards", "false").value<QString>();
+ return result.startsWith("true");
+}
+
+bool AOApplication::get_showname_enabled_by_default()
+{
+ QString result =
+ configini->value("show_custom_shownames", "true").value<QString>();
+ return result.startsWith("true");
+}
+
+QString AOApplication::get_default_username()
+{
+ QString result = configini->value("default_username", "").value<QString>();
+ if (result.isEmpty())
+ return get_ooc_name();
+ else
+ return result;
+}
+
+QString AOApplication::get_audio_output_device()
+{
+ QString result =
+ configini->value("default_audio_device", "default").value<QString>();
+ return result;
+}
+
+QStringList AOApplication::get_call_words()
+{
+ QStringList return_value;
+
+ QFile callwords_ini;
+
+ callwords_ini.setFileName(get_base_path() + "callwords.ini");
+
+ if (!callwords_ini.open(QIODevice::ReadOnly))
+ return return_value;
+
+ QTextStream in(&callwords_ini);
+
+ while (!in.atEnd()) {
+ QString line = in.readLine();
+ return_value.append(line);
+ }
+
+ return return_value;
+}
+
+void AOApplication::write_to_serverlist_txt(QString p_line)
+{
+ QFile serverlist_txt;
+ QString serverlist_txt_path = get_base_path() + "serverlist.txt";
+
+ serverlist_txt.setFileName(serverlist_txt_path);
+
+ if (!serverlist_txt.open(QIODevice::WriteOnly | QIODevice::Append)) {
+ return;
+ }
+
+ QTextStream out(&serverlist_txt);
+
+ out << "\r\n" << p_line;
+
+ serverlist_txt.close();
+}
+
+QVector<server_type> AOApplication::read_serverlist_txt()
+{
+ QVector<server_type> f_server_list;
+
+ QFile serverlist_txt;
+ QString serverlist_txt_path = get_base_path() + "serverlist.txt";
+
+ serverlist_txt.setFileName(serverlist_txt_path);
+
+ if (!serverlist_txt.open(QIODevice::ReadOnly)) {
+ return f_server_list;
+ }
+
+ QTextStream in(&serverlist_txt);
+
+ while (!in.atEnd()) {
+ QString line = in.readLine();
+ server_type f_server;
+ QStringList line_contents = line.split(":");
+
+ if (line_contents.size() < 3)
+ continue;
+
+ f_server.ip = line_contents.at(0);
+ f_server.port = line_contents.at(1).toInt();
+ f_server.name = line_contents.at(2);
+ f_server.desc = "";
+
+ f_server_list.append(f_server);
+ }
+
+ return f_server_list;
+}
+
+QString AOApplication::read_design_ini(QString p_identifier,
+ QString p_design_path)
+{
+ QSettings settings(p_design_path, QSettings::IniFormat);
+ QVariant value = settings.value(p_identifier);
if (value.isNull()) // Since the value wasn't found, maybe it uses the proper
// config system
{
@@ -183,220 +183,213 @@ QString AOApplication::read_design_ini(QString p_identifier, QString p_design_pa
value = settings.value(p_identifier + "/size");
}
}
- if (value.type() == QVariant::StringList) {
- return value.toStringList().join(",");
- } else {
- return value.toString();
- }
-}
-
-QPoint AOApplication::get_button_spacing(QString p_identifier, QString p_file)
-{
- QString design_ini_path = get_theme_path(p_file);
- QString default_path = get_default_theme_path(p_file);
- QString f_result = read_design_ini(p_identifier, design_ini_path);
-
- QPoint return_value;
-
- return_value.setX(0);
- return_value.setY(0);
-
- if (f_result == "")
- {
- f_result = read_design_ini(p_identifier, default_path);
-
- if (f_result == "")
- return return_value;
- }
-
- QStringList sub_line_elements = f_result.split(",");
-
- if (sub_line_elements.size() < 2)
- return return_value;
-
- return_value.setX(sub_line_elements.at(0).toInt());
- return_value.setY(sub_line_elements.at(1).toInt());
-
- return return_value;
-}
-
-pos_size_type AOApplication::get_element_dimensions(QString p_identifier, QString p_file)
-{
- QString design_ini_path = get_theme_path(p_file);
- QString default_path = get_default_theme_path(p_file);
- QString f_result = read_design_ini(p_identifier, design_ini_path);
-
- pos_size_type return_value;
-
- return_value.x = 0;
- return_value.y = 0;
- return_value.width = -1;
- return_value.height = -1;
-
- if (f_result == "")
- {
- f_result = read_design_ini(p_identifier, default_path);
-
- if (f_result == "")
- return return_value;
- }
-
- QStringList sub_line_elements = f_result.split(",");
-
- if (sub_line_elements.size() < 4)
- return return_value;
-
- return_value.x = sub_line_elements.at(0).toInt();
- return_value.y = sub_line_elements.at(1).toInt();
- return_value.width = sub_line_elements.at(2).toInt();
- return_value.height = sub_line_elements.at(3).toInt();
-
- return return_value;
-}
-QString AOApplication::get_font_name(QString p_identifier, QString p_file)
-{
- QString design_ini_path = get_theme_path(p_file);
- QString f_result = read_design_ini(p_identifier, design_ini_path);
- QString default_path = get_default_theme_path(p_file);
- if (f_result == "")
- {
- f_result = read_design_ini(p_identifier, default_path);
- if (f_result == "")
- return "Sans";
- }
- return f_result;
-}
-int AOApplication::get_font_size(QString p_identifier, QString p_file)
-{
- QString design_ini_path = get_theme_path(p_file);
- QString default_path = get_default_theme_path(p_file);
- QString f_result = read_design_ini(p_identifier, design_ini_path);
-
- if (f_result == "")
- {
- f_result = read_design_ini(p_identifier, default_path);
-
- if (f_result == "")
- return 10;
- }
-
- return f_result.toInt();
-}
-
-QColor AOApplication::get_color(QString p_identifier, QString p_file)
-{
- QString design_ini_path = get_theme_path(p_file);
- QString default_path = get_default_theme_path(p_file);
- QString f_result = read_design_ini(p_identifier, design_ini_path);
-
- QColor return_color(0, 0, 0);
-
- if (f_result == "")
- {
- f_result = read_design_ini(p_identifier, default_path);
-
- if (f_result == "")
- return return_color;
- }
-
- QStringList color_list = f_result.split(",");
-
- if (color_list.size() < 3)
- return return_color;
-
- return_color.setRed(color_list.at(0).toInt());
- return_color.setGreen(color_list.at(1).toInt());
- return_color.setBlue(color_list.at(2).toInt());
-
- return return_color;
-}
-
-QColor AOApplication::get_chat_color(QString p_identifier, QString p_chat)
-{
- QColor return_color(255, 255, 255);
-
- if (p_identifier == "_inline_grey")
- {
- return_color = QColor(187, 187, 187);
- }
- else
- {
- switch (p_identifier.toInt()) {
- case 1:
- return_color = QColor(0, 255, 0);
- break;
- case 2:
- return_color = QColor(255, 0, 0);
- break;
- case 3:
- return_color = QColor(255, 165, 0);
- break;
- case 4:
- return_color = QColor(45, 150, 255);
- break;
- case 5:
- return_color = QColor(255, 255, 0);
- break;
- case 7:
- return_color = QColor(255, 192, 203);
- break;
- case 8:
- return_color = QColor(0, 255, 255);
- break;
- case 0:
- case 6: // 6 is rainbow.
- default:
- return_color = QColor(255, 255, 255);
- break;
- }
- }
-
- p_identifier = p_identifier.prepend("c");
- QString design_ini_path = get_base_path() + "misc/" + p_chat + "/config.ini";
- QString default_path = get_base_path() + "misc/default/config.ini";
- QString f_result = read_design_ini(p_identifier, design_ini_path);
-
- if (f_result == "")
- {
- f_result = read_design_ini(p_identifier, default_path);
-
- if (f_result == "")
- return return_color;
- }
-
- QStringList color_list = f_result.split(",");
-
- if (color_list.size() < 3)
- return return_color;
-
- return_color.setRed(color_list.at(0).toInt());
- return_color.setGreen(color_list.at(1).toInt());
- return_color.setBlue(color_list.at(2).toInt());
-
- return return_color;
-}
-
-QString AOApplication::get_sfx(QString p_identifier)
-{
- QString design_ini_path = get_theme_path("courtroom_sounds.ini");
- QString default_path = get_default_theme_path("courtroom_sounds.ini");
- QString f_result = read_design_ini(p_identifier, design_ini_path);
-
- QString return_sfx = "";
-
- if (f_result == "")
- {
- f_result = read_design_ini(p_identifier, default_path);
-
- if (f_result == "")
- return return_sfx;
- }
-
- return_sfx = f_result;
-
- return return_sfx;
-}
-
+ if (value.type() == QVariant::StringList) {
+ return value.toStringList().join(",");
+ }
+ else {
+ return value.toString();
+ }
+}
+
+QPoint AOApplication::get_button_spacing(QString p_identifier, QString p_file)
+{
+ QString design_ini_path = get_theme_path(p_file);
+ QString default_path = get_default_theme_path(p_file);
+ QString f_result = read_design_ini(p_identifier, design_ini_path);
+
+ QPoint return_value;
+
+ return_value.setX(0);
+ return_value.setY(0);
+
+ if (f_result == "") {
+ f_result = read_design_ini(p_identifier, default_path);
+
+ if (f_result == "")
+ return return_value;
+ }
+
+ QStringList sub_line_elements = f_result.split(",");
+
+ if (sub_line_elements.size() < 2)
+ return return_value;
+
+ return_value.setX(sub_line_elements.at(0).toInt());
+ return_value.setY(sub_line_elements.at(1).toInt());
+
+ return return_value;
+}
+
+pos_size_type AOApplication::get_element_dimensions(QString p_identifier,
+ QString p_file)
+{
+ QString design_ini_path = get_theme_path(p_file);
+ QString default_path = get_default_theme_path(p_file);
+ QString f_result = read_design_ini(p_identifier, design_ini_path);
+
+ pos_size_type return_value;
+
+ return_value.x = 0;
+ return_value.y = 0;
+ return_value.width = -1;
+ return_value.height = -1;
+
+ if (f_result == "") {
+ f_result = read_design_ini(p_identifier, default_path);
+
+ if (f_result == "")
+ return return_value;
+ }
+
+ QStringList sub_line_elements = f_result.split(",");
+
+ if (sub_line_elements.size() < 4)
+ return return_value;
+
+ return_value.x = sub_line_elements.at(0).toInt();
+ return_value.y = sub_line_elements.at(1).toInt();
+ return_value.width = sub_line_elements.at(2).toInt();
+ return_value.height = sub_line_elements.at(3).toInt();
+
+ return return_value;
+}
+QString AOApplication::get_font_name(QString p_identifier, QString p_file)
+{
+ QString design_ini_path = get_theme_path(p_file);
+ QString f_result = read_design_ini(p_identifier, design_ini_path);
+ QString default_path = get_default_theme_path(p_file);
+ if (f_result == "") {
+ f_result = read_design_ini(p_identifier, default_path);
+ if (f_result == "")
+ return "Sans";
+ }
+ return f_result;
+}
+int AOApplication::get_font_size(QString p_identifier, QString p_file)
+{
+ QString design_ini_path = get_theme_path(p_file);
+ QString default_path = get_default_theme_path(p_file);
+ QString f_result = read_design_ini(p_identifier, design_ini_path);
+
+ if (f_result == "") {
+ f_result = read_design_ini(p_identifier, default_path);
+
+ if (f_result == "")
+ return 10;
+ }
+
+ return f_result.toInt();
+}
+
+QColor AOApplication::get_color(QString p_identifier, QString p_file)
+{
+ QString design_ini_path = get_theme_path(p_file);
+ QString default_path = get_default_theme_path(p_file);
+ QString f_result = read_design_ini(p_identifier, design_ini_path);
+
+ QColor return_color(0, 0, 0);
+
+ if (f_result == "") {
+ f_result = read_design_ini(p_identifier, default_path);
+
+ if (f_result == "")
+ return return_color;
+ }
+
+ QStringList color_list = f_result.split(",");
+
+ if (color_list.size() < 3)
+ return return_color;
+
+ return_color.setRed(color_list.at(0).toInt());
+ return_color.setGreen(color_list.at(1).toInt());
+ return_color.setBlue(color_list.at(2).toInt());
+
+ return return_color;
+}
+
+QColor AOApplication::get_chat_color(QString p_identifier, QString p_chat)
+{
+ QColor return_color(255, 255, 255);
+
+ if (p_identifier == "_inline_grey") {
+ return_color = QColor(187, 187, 187);
+ }
+ else {
+ switch (p_identifier.toInt()) {
+ case 1:
+ return_color = QColor(0, 255, 0);
+ break;
+ case 2:
+ return_color = QColor(255, 0, 0);
+ break;
+ case 3:
+ return_color = QColor(255, 165, 0);
+ break;
+ case 4:
+ return_color = QColor(45, 150, 255);
+ break;
+ case 5:
+ return_color = QColor(255, 255, 0);
+ break;
+ case 7:
+ return_color = QColor(255, 192, 203);
+ break;
+ case 8:
+ return_color = QColor(0, 255, 255);
+ break;
+ case 0:
+ case 6: // 6 is rainbow.
+ default:
+ return_color = QColor(255, 255, 255);
+ break;
+ }
+ }
+
+ p_identifier = p_identifier.prepend("c");
+ QString design_ini_path = get_base_path() + "misc/" + p_chat + "/config.ini";
+ QString default_path = get_base_path() + "misc/default/config.ini";
+ QString f_result = read_design_ini(p_identifier, design_ini_path);
+
+ if (f_result == "") {
+ f_result = read_design_ini(p_identifier, default_path);
+
+ if (f_result == "")
+ return return_color;
+ }
+
+ QStringList color_list = f_result.split(",");
+
+ if (color_list.size() < 3)
+ return return_color;
+
+ return_color.setRed(color_list.at(0).toInt());
+ return_color.setGreen(color_list.at(1).toInt());
+ return_color.setBlue(color_list.at(2).toInt());
+
+ return return_color;
+}
+
+QString AOApplication::get_sfx(QString p_identifier)
+{
+ QString design_ini_path = get_theme_path("courtroom_sounds.ini");
+ QString default_path = get_default_theme_path("courtroom_sounds.ini");
+ QString f_result = read_design_ini(p_identifier, design_ini_path);
+
+ QString return_sfx = "";
+
+ if (f_result == "") {
+ f_result = read_design_ini(p_identifier, default_path);
+
+ if (f_result == "")
+ return return_sfx;
+ }
+
+ return_sfx = f_result;
+
+ return return_sfx;
+}
+
QString AOApplication::get_music_prefix(QString song_to_check)
{
if (!file_exists(get_music_path(song_to_check))) {
@@ -415,359 +408,398 @@ QString AOApplication::get_music_prefix(QString song_to_check)
}
}
-QString AOApplication::get_sfx_suffix(QString sound_to_check)
-{
+QString AOApplication::get_sfx_suffix(QString sound_to_check)
+{
if (!file_exists(get_sounds_path(sound_to_check))) {
- QString mp3_check = get_sounds_path(sound_to_check + ".mp3");
- QString opus_check = get_sounds_path(sound_to_check + ".opus");
- if (file_exists(opus_check))
- {
- return sound_to_check + ".opus";
- }
- else if (file_exists(mp3_check))
- {
- return sound_to_check + ".mp3";
- }
- return sound_to_check + ".wav";
+ QString mp3_check = get_sounds_path(sound_to_check + ".mp3");
+ QString opus_check = get_sounds_path(sound_to_check + ".opus");
+ if (file_exists(opus_check)) {
+ return sound_to_check + ".opus";
+ }
+ else if (file_exists(mp3_check)) {
+ return sound_to_check + ".mp3";
+ }
+ return sound_to_check + ".wav";
}
else {
return sound_to_check;
}
}
-
-QString AOApplication::get_image_suffix(QString path_to_check)
-{
+
+QString AOApplication::get_image_suffix(QString path_to_check)
+{
if (file_exists(path_to_check + ".webp"))
return path_to_check + ".webp";
if (file_exists(path_to_check + ".apng"))
return path_to_check + ".apng";
if (file_exists(path_to_check + ".gif"))
- return path_to_check + ".gif";
+ return path_to_check + ".gif";
return path_to_check + ".png";
-}
-
-
-//returns whatever is to the right of "search_line =" within target_tag and terminator_tag, trimmed
-//returns the empty string if the search line couldnt be found
-QString AOApplication::read_char_ini(QString p_char, QString p_search_line, QString target_tag)
-{
- QSettings settings(get_character_path(p_char, "char.ini"), QSettings::IniFormat);
- settings.beginGroup(target_tag);
- QString value = settings.value(p_search_line).toString();
- settings.endGroup();
- return value;
-}
-
-QString AOApplication::get_char_name(QString p_char)
-{
- QString f_result = read_char_ini(p_char, "name", "Options");
-
- if (f_result == "")
- return p_char;
- else return f_result;
-}
-
-QString AOApplication::get_showname(QString p_char)
-{
- QString f_result = read_char_ini(p_char, "showname", "Options");
- QString f_needed = read_char_ini(p_char, "needs_showname", "Options");
-
- if (f_needed.startsWith("false"))
- return "";
- if (f_result == "")
- return p_char;
- else return f_result;
-}
-
-QString AOApplication::get_char_side(QString p_char)
-{
- QString f_result = read_char_ini(p_char, "side", "Options");
-
- if (f_result == "")
- return "wit";
- else return f_result;
-}
-
-QString AOApplication::get_gender(QString p_char)
-{
- QString f_result = read_char_ini(p_char, "gender", "Options");
-
- if (f_result == "")
- return "male";
- else return f_result;
-}
-
-QString AOApplication::get_chat(QString p_char)
-{
- QString f_result = read_char_ini(p_char, "chat", "Options");
-
- //handling the correct order of chat is a bit complicated, we let the caller do it
- return f_result;
-}
-
-QString AOApplication::get_char_shouts(QString p_char)
-{
- QString f_result = read_char_ini(p_char, "shouts", "Options");
- if (f_result == "")
- return "default";
- else return f_result;
-}
-
-int AOApplication::get_preanim_duration(QString p_char, QString p_emote)
-{
- QString f_result = read_char_ini(p_char, p_emote, "Time");
-
- if (f_result == "")
- return -1;
- else return f_result.toInt();
-}
-
-int AOApplication::get_ao2_preanim_duration(QString p_char, QString p_emote)
-{
- QString f_result = read_char_ini(p_char, "%" + p_emote, "Time");
-
- if (f_result == "")
- return -1;
- else return f_result.toInt();
-}
-
-int AOApplication::get_emote_number(QString p_char)
-{
- QString f_result = read_char_ini(p_char, "number", "Emotions");
-
- if (f_result == "")
- return 0;
- else return f_result.toInt();
-}
-
-QString AOApplication::get_emote_comment(QString p_char, int p_emote)
-{
- QString f_result = read_char_ini(p_char, QString::number(p_emote + 1), "Emotions");
-
- QStringList result_contents = f_result.split("#");
-
- if (result_contents.size() < 4)
- {
- qDebug() << "W: misformatted char.ini: " << p_char << ", " << p_emote;
- return "normal";
- }
- else return result_contents.at(0);
-}
-
-QString AOApplication::get_pre_emote(QString p_char, int p_emote)
-{
- QString f_result = read_char_ini(p_char, QString::number(p_emote + 1), "Emotions");
-
- QStringList result_contents = f_result.split("#");
-
- if (result_contents.size() < 4)
- {
- qDebug() << "W: misformatted char.ini: " << p_char << ", " << p_emote;
- return "";
- }
- else return result_contents.at(1);
-}
-
-QString AOApplication::get_emote(QString p_char, int p_emote)
-{
- QString f_result = read_char_ini(p_char, QString::number(p_emote + 1), "Emotions");
-
- QStringList result_contents = f_result.split("#");
-
- if (result_contents.size() < 4)
- {
- qDebug() << "W: misformatted char.ini: " << p_char << ", " << p_emote;
- return "normal";
- }
- else return result_contents.at(2);
-}
-
-int AOApplication::get_emote_mod(QString p_char, int p_emote)
-{
- QString f_result = read_char_ini(p_char, QString::number(p_emote + 1), "Emotions");
-
- QStringList result_contents = f_result.split("#");
-
- if (result_contents.size() < 4)
- {
- qDebug() << "W: misformatted char.ini: " << p_char << ", " << QString::number(p_emote);
- return 0;
- }
- else return result_contents.at(3).toInt();
-}
-
-int AOApplication::get_desk_mod(QString p_char, int p_emote)
-{
- QString f_result = read_char_ini(p_char, QString::number(p_emote + 1), "Emotions");
-
- QStringList result_contents = f_result.split("#");
-
- if (result_contents.size() < 5)
- return -1;
-
- QString string_result = result_contents.at(4);
- if (string_result == "")
- return -1;
-
- else return string_result.toInt();
-}
-
-QString AOApplication::get_sfx_name(QString p_char, int p_emote)
-{
- QString f_result = read_char_ini(p_char, QString::number(p_emote + 1), "SoundN");
-
- if (f_result == "")
- return "1";
- else return f_result;
-}
-
-QString AOApplication::get_sfx_looping(QString p_char, int p_emote)
-{
- QString f_result = read_char_ini(p_char, QString::number(p_emote + 1), "SoundL");
-
- if (f_result == "")
- return "0";
- else return f_result;
-}
-
-QString AOApplication::get_frame_sfx_name(QString p_char, QString p_emote, int n_frame)
-{
- QString f_result = read_char_ini(p_char, QString::number(n_frame), p_emote.append("_FrameSFX"));
- if (f_result == "")
- return "";
- else return f_result;
-}
-
-QString AOApplication::get_screenshake_frame(QString p_char, QString p_emote, int n_frame)
-{
- QString f_result = read_char_ini(p_char, QString::number(n_frame), p_emote.append("_FrameScreenshake"));
- if (f_result == "")
- return "";
- else return f_result;
-}
-
-
-QString AOApplication::get_realization_frame(QString p_char, QString p_emote, int n_frame)
-{
- QString f_result = read_char_ini(p_char, QString::number(n_frame), p_emote.append("_FrameRealization"));
- if (f_result == "")
- return "";
- else return f_result;
-}
-
-
-
-int AOApplication::get_sfx_delay(QString p_char, int p_emote)
-{
- QString f_result = read_char_ini(p_char, QString::number(p_emote + 1), "SoundT");
-
- if (f_result == "")
- return 1;
- else return f_result.toInt();
-}
-
-int AOApplication::get_text_delay(QString p_char, QString p_emote)
-{
- QString f_result = read_char_ini(p_char, p_emote, "TextDelay");
-
- if (f_result == "")
- return -1;
- else return f_result.toInt();
-}
-
-QString AOApplication::get_custom_realization(QString p_char)
-{
- QString f_result = read_char_ini(p_char, "realization", "Options");
-
- if (f_result == "")
- return get_sfx("realization");
- else return f_result;
-}
-
-bool AOApplication::get_blank_blip()
-{
- QString result = configini->value("blank_blip", "false").value<QString>();
- return result.startsWith("true");
-}
-
-bool AOApplication::get_looping_sfx()
-{
- QString result = configini->value("looping_sfx", "true").value<QString>();
- return result.startsWith("true");
-}
-
-bool AOApplication::get_objectmusic()
-{
- QString result = configini->value("kill_music_on_object", "false").value<QString>();
- return result.startsWith("true");
-}
-
-bool AOApplication::is_discord_enabled()
-{
- QString result = configini->value("discord", "true").value<QString>();
- return result.startsWith("true");
-}
-
+}
+
+// returns whatever is to the right of "search_line =" within target_tag and
+// terminator_tag, trimmed returns the empty string if the search line couldnt
+// be found
+QString AOApplication::read_char_ini(QString p_char, QString p_search_line,
+ QString target_tag)
+{
+ QSettings settings(get_character_path(p_char, "char.ini"),
+ QSettings::IniFormat);
+ settings.beginGroup(target_tag);
+ QString value = settings.value(p_search_line).toString();
+ settings.endGroup();
+ return value;
+}
+
+QString AOApplication::get_char_name(QString p_char)
+{
+ QString f_result = read_char_ini(p_char, "name", "Options");
+
+ if (f_result == "")
+ return p_char;
+ else
+ return f_result;
+}
+
+QString AOApplication::get_showname(QString p_char)
+{
+ QString f_result = read_char_ini(p_char, "showname", "Options");
+ QString f_needed = read_char_ini(p_char, "needs_showname", "Options");
+
+ if (f_needed.startsWith("false"))
+ return "";
+ if (f_result == "")
+ return p_char;
+ else
+ return f_result;
+}
+
+QString AOApplication::get_char_side(QString p_char)
+{
+ QString f_result = read_char_ini(p_char, "side", "Options");
+
+ if (f_result == "")
+ return "wit";
+ else
+ return f_result;
+}
+
+QString AOApplication::get_gender(QString p_char)
+{
+ QString f_result = read_char_ini(p_char, "gender", "Options");
+
+ if (f_result == "")
+ return "male";
+ else
+ return f_result;
+}
+
+QString AOApplication::get_chat(QString p_char)
+{
+ QString f_result = read_char_ini(p_char, "chat", "Options");
+
+ // handling the correct order of chat is a bit complicated, we let the caller
+ // do it
+ return f_result;
+}
+
+QString AOApplication::get_char_shouts(QString p_char)
+{
+ QString f_result = read_char_ini(p_char, "shouts", "Options");
+ if (f_result == "")
+ return "default";
+ else
+ return f_result;
+}
+
+int AOApplication::get_preanim_duration(QString p_char, QString p_emote)
+{
+ QString f_result = read_char_ini(p_char, p_emote, "Time");
+
+ if (f_result == "")
+ return -1;
+ else
+ return f_result.toInt();
+}
+
+int AOApplication::get_ao2_preanim_duration(QString p_char, QString p_emote)
+{
+ QString f_result = read_char_ini(p_char, "%" + p_emote, "Time");
+
+ if (f_result == "")
+ return -1;
+ else
+ return f_result.toInt();
+}
+
+int AOApplication::get_emote_number(QString p_char)
+{
+ QString f_result = read_char_ini(p_char, "number", "Emotions");
+
+ if (f_result == "")
+ return 0;
+ else
+ return f_result.toInt();
+}
+
+QString AOApplication::get_emote_comment(QString p_char, int p_emote)
+{
+ QString f_result =
+ read_char_ini(p_char, QString::number(p_emote + 1), "Emotions");
+
+ QStringList result_contents = f_result.split("#");
+
+ if (result_contents.size() < 4) {
+ qDebug() << "W: misformatted char.ini: " << p_char << ", " << p_emote;
+ return "normal";
+ }
+ else
+ return result_contents.at(0);
+}
+
+QString AOApplication::get_pre_emote(QString p_char, int p_emote)
+{
+ QString f_result =
+ read_char_ini(p_char, QString::number(p_emote + 1), "Emotions");
+
+ QStringList result_contents = f_result.split("#");
+
+ if (result_contents.size() < 4) {
+ qDebug() << "W: misformatted char.ini: " << p_char << ", " << p_emote;
+ return "";
+ }
+ else
+ return result_contents.at(1);
+}
+
+QString AOApplication::get_emote(QString p_char, int p_emote)
+{
+ QString f_result =
+ read_char_ini(p_char, QString::number(p_emote + 1), "Emotions");
+
+ QStringList result_contents = f_result.split("#");
+
+ if (result_contents.size() < 4) {
+ qDebug() << "W: misformatted char.ini: " << p_char << ", " << p_emote;
+ return "normal";
+ }
+ else
+ return result_contents.at(2);
+}
+
+int AOApplication::get_emote_mod(QString p_char, int p_emote)
+{
+ QString f_result =
+ read_char_ini(p_char, QString::number(p_emote + 1), "Emotions");
+
+ QStringList result_contents = f_result.split("#");
+
+ if (result_contents.size() < 4) {
+ qDebug() << "W: misformatted char.ini: " << p_char << ", "
+ << QString::number(p_emote);
+ return 0;
+ }
+ else
+ return result_contents.at(3).toInt();
+}
+
+int AOApplication::get_desk_mod(QString p_char, int p_emote)
+{
+ QString f_result =
+ read_char_ini(p_char, QString::number(p_emote + 1), "Emotions");
+
+ QStringList result_contents = f_result.split("#");
+
+ if (result_contents.size() < 5)
+ return -1;
+
+ QString string_result = result_contents.at(4);
+ if (string_result == "")
+ return -1;
+
+ else
+ return string_result.toInt();
+}
+
+QString AOApplication::get_sfx_name(QString p_char, int p_emote)
+{
+ QString f_result =
+ read_char_ini(p_char, QString::number(p_emote + 1), "SoundN");
+
+ if (f_result == "")
+ return "1";
+ else
+ return f_result;
+}
+
+QString AOApplication::get_sfx_looping(QString p_char, int p_emote)
+{
+ QString f_result =
+ read_char_ini(p_char, QString::number(p_emote + 1), "SoundL");
+
+ if (f_result == "")
+ return "0";
+ else
+ return f_result;
+}
+
+QString AOApplication::get_frame_sfx_name(QString p_char, QString p_emote,
+ int n_frame)
+{
+ QString f_result = read_char_ini(p_char, QString::number(n_frame),
+ p_emote.append("_FrameSFX"));
+ if (f_result == "")
+ return "";
+ else
+ return f_result;
+}
+
+QString AOApplication::get_screenshake_frame(QString p_char, QString p_emote,
+ int n_frame)
+{
+ QString f_result = read_char_ini(p_char, QString::number(n_frame),
+ p_emote.append("_FrameScreenshake"));
+ if (f_result == "")
+ return "";
+ else
+ return f_result;
+}
+
+QString AOApplication::get_realization_frame(QString p_char, QString p_emote,
+ int n_frame)
+{
+ QString f_result = read_char_ini(p_char, QString::number(n_frame),
+ p_emote.append("_FrameRealization"));
+ if (f_result == "")
+ return "";
+ else
+ return f_result;
+}
+
+int AOApplication::get_sfx_delay(QString p_char, int p_emote)
+{
+ QString f_result =
+ read_char_ini(p_char, QString::number(p_emote + 1), "SoundT");
+
+ if (f_result == "")
+ return 1;
+ else
+ return f_result.toInt();
+}
+
+int AOApplication::get_text_delay(QString p_char, QString p_emote)
+{
+ QString f_result = read_char_ini(p_char, p_emote, "TextDelay");
+
+ if (f_result == "")
+ return -1;
+ else
+ return f_result.toInt();
+}
+
+QString AOApplication::get_custom_realization(QString p_char)
+{
+ QString f_result = read_char_ini(p_char, "realization", "Options");
+
+ if (f_result == "")
+ return get_sfx("realization");
+ else
+ return get_sfx_suffix(f_result);
+}
+
+bool AOApplication::get_blank_blip()
+{
+ QString result = configini->value("blank_blip", "false").value<QString>();
+ return result.startsWith("true");
+}
+
+bool AOApplication::get_looping_sfx()
+{
+ QString result = configini->value("looping_sfx", "true").value<QString>();
+ return result.startsWith("true");
+}
+
+bool AOApplication::get_objectmusic()
+{
+ QString result =
+ configini->value("kill_music_on_object", "false").value<QString>();
+ return result.startsWith("true");
+}
+
+bool AOApplication::is_discord_enabled()
+{
+ QString result = configini->value("discord", "true").value<QString>();
+ return result.startsWith("true");
+}
+
bool AOApplication::is_keepevi_enabled()
-{
+{
QString result = configini->value("keep_evidence", "false").value<QString>();
- return result.startsWith("true");
-}
-
-
-bool AOApplication::get_casing_enabled()
-{
- QString result = configini->value("casing_enabled", "false").value<QString>();
- return result.startsWith("true");
-}
-
-bool AOApplication::get_casing_defence_enabled()
-{
- QString result = configini->value("casing_defence_enabled", "false").value<QString>();
- return result.startsWith("true");
-}
-
-bool AOApplication::get_casing_prosecution_enabled()
-{
- QString result = configini->value("casing_prosecution_enabled", "false").value<QString>();
- return result.startsWith("true");
-}
-
-bool AOApplication::get_casing_judge_enabled()
-{
- QString result = configini->value("casing_judge_enabled", "false").value<QString>();
- return result.startsWith("true");
-}
-
-bool AOApplication::get_casing_juror_enabled()
-{
- QString result = configini->value("casing_juror_enabled", "false").value<QString>();
- return result.startsWith("true");
-}
-
-bool AOApplication::get_casing_steno_enabled()
-{
- QString result = configini->value("casing_steno_enabled", "false").value<QString>();
- return result.startsWith("true");
-}
-
-bool AOApplication::get_casing_wit_enabled()
-{
- QString result = configini->value("casing_wit_enabled", "false").value<QString>();
- return result.startsWith("true");
-}
-
-bool AOApplication::get_casing_cm_enabled()
-{
- QString result = configini->value("casing_cm_enabled", "false").value<QString>();
- return result.startsWith("true");
-}
-
-QString AOApplication::get_casing_can_host_cases()
-{
- QString result = configini->value("casing_can_host_cases", "Turnabout Check Your Settings").value<QString>();
- return result;
-}
+ return result.startsWith("true");
+}
+
+bool AOApplication::get_casing_enabled()
+{
+ QString result = configini->value("casing_enabled", "false").value<QString>();
+ return result.startsWith("true");
+}
+
+bool AOApplication::get_casing_defence_enabled()
+{
+ QString result =
+ configini->value("casing_defence_enabled", "false").value<QString>();
+ return result.startsWith("true");
+}
+
+bool AOApplication::get_casing_prosecution_enabled()
+{
+ QString result =
+ configini->value("casing_prosecution_enabled", "false").value<QString>();
+ return result.startsWith("true");
+}
+
+bool AOApplication::get_casing_judge_enabled()
+{
+ QString result =
+ configini->value("casing_judge_enabled", "false").value<QString>();
+ return result.startsWith("true");
+}
+
+bool AOApplication::get_casing_juror_enabled()
+{
+ QString result =
+ configini->value("casing_juror_enabled", "false").value<QString>();
+ return result.startsWith("true");
+}
+
+bool AOApplication::get_casing_steno_enabled()
+{
+ QString result =
+ configini->value("casing_steno_enabled", "false").value<QString>();
+ return result.startsWith("true");
+}
+
+bool AOApplication::get_casing_wit_enabled()
+{
+ QString result =
+ configini->value("casing_wit_enabled", "false").value<QString>();
+ return result.startsWith("true");
+}
+
+bool AOApplication::get_casing_cm_enabled()
+{
+ QString result =
+ configini->value("casing_cm_enabled", "false").value<QString>();
+ return result.startsWith("true");
+}
+
+QString AOApplication::get_casing_can_host_cases()
+{
+ QString result =
+ configini->value("casing_can_host_cases", "Turnabout Check Your Settings")
+ .value<QString>();
+ return result;
+}
bool AOApplication::get_colored_iclog_enabled()
{