Mega-merge of CR fork

CR likely stands for "CentsRaidensnake." Like the Case Cafe mega-merge
before it, this was not a clean merge, and it had to be split up into
two parts: the actual changes, and the attempt it made to reformat the
entire code via clang-format.

This branch had a complicated set of changes that would be difficult to
describe in this commit message. It would be better described in a
proper changelog.
This commit is contained in:
oldmud0 2020-04-17 21:48:34 -05:00
parent 5901733650
commit faac191f0b
22 changed files with 1846 additions and 1147 deletions

2
.gitignore vendored
View File

@ -33,3 +33,5 @@ discord/
moc* moc*
/Attorney_Online_CC_resource.rc /Attorney_Online_CC_resource.rc
/attorney_online_cc_plugin_import.cpp /attorney_online_cc_plugin_import.cpp
*.autosave

View File

@ -182,10 +182,16 @@ public:
// from the config.ini. // from the config.ini.
bool is_shakeandflash_enabled(); bool is_shakeandflash_enabled();
// Returns whether evidence should be maintained ic
bool is_keepevi_enabled();
// Returns the value of the maximum amount of lines the IC chatlog // Returns the value of the maximum amount of lines the IC chatlog
// may contain, from config.ini. // may contain, from config.ini.
int get_max_log_size(); int get_max_log_size();
// Gets the punctuation delay modifier
int get_pundelay();
// Returns whether the log should go upwards (new behaviour) // Returns whether the log should go upwards (new behaviour)
// or downwards (vanilla behaviour). // or downwards (vanilla behaviour).
bool get_log_goes_downwards(); bool get_log_goes_downwards();
@ -238,7 +244,11 @@ public:
//Figure out if we can opus this or if we should fall back to wav //Figure out if we can opus this or if we should fall back to wav
QString get_sfx_suffix(QString sound_to_check); QString get_sfx_suffix(QString sound_to_check);
// Can we use APNG for this? If not, fall back to a gif. // figure out if we can find what prefix this song uses
QString get_music_prefix(QString song_to_check);
// Can we use APNG for this? If not, WEBP? if not, GIF? If not, fall back to a
// gif.
QString get_image_suffix(QString path_to_check); QString get_image_suffix(QString path_to_check);
//Returns the value of p_search_line within target_tag and terminator_tag //Returns the value of p_search_line within target_tag and terminator_tag
@ -341,6 +351,15 @@ public:
// Get the message for the CM for casing alerts. // Get the message for the CM for casing alerts.
QString get_casing_can_host_cases(); QString get_casing_can_host_cases();
// Get if html for ic log is enabled
bool get_colored_iclog_enabled();
// Get if ic log mirror is enabled
bool get_iclmir_enabled();
// Get if only inline coloring should be shown in log
bool colorlog_restricted_enabled();
private: private:
const int RELEASE = 2; const int RELEASE = 2;
const int MAJOR_VERSION = 7; const int MAJOR_VERSION = 7;

View File

@ -15,13 +15,16 @@ public:
AOMovie(QWidget *p_parent, AOApplication *p_ao_app); AOMovie(QWidget *p_parent, AOApplication *p_ao_app);
void set_play_once(bool p_play_once); void set_play_once(bool p_play_once);
void play(QString p_gif, QString p_char = "", QString p_custom_theme = ""); void start_timer(int delay);
void play(QString p_gif, QString p_char = "", QString p_custom_theme = "",
int default_duration = 0);
void combo_resize(int w, int h); void combo_resize(int w, int h);
void stop(); void stop();
private: private:
QMovie *m_movie; QMovie *m_movie;
AOApplication *ao_app; AOApplication *ao_app;
QTimer *timer;
bool play_once = true; bool play_once = true;
signals: signals:
@ -29,6 +32,7 @@ signals:
private slots: private slots:
void frame_change(int n_frame); void frame_change(int n_frame);
void timer_done();
}; };
#endif // AOMOVIE_H #endif // AOMOVIE_H

View File

@ -51,6 +51,8 @@ private:
QCheckBox *ui_downwards_cb; QCheckBox *ui_downwards_cb;
QLabel *ui_length_lbl; QLabel *ui_length_lbl;
QSpinBox *ui_length_spinbox; QSpinBox *ui_length_spinbox;
QLabel *ui_pun_delay;
QSpinBox *ui_pun_delay_spinbox;
QFrame *ui_log_names_divider; QFrame *ui_log_names_divider;
QLineEdit *ui_username_textbox; QLineEdit *ui_username_textbox;
QLabel *ui_username_lbl; QLabel *ui_username_lbl;
@ -66,6 +68,12 @@ private:
QLabel *ui_language_label; QLabel *ui_language_label;
QComboBox *ui_language_combobox; QComboBox *ui_language_combobox;
QLabel *ui_keepevi_lbl;
QCheckBox *ui_keepevi_cb;
QLabel *ui_keepcobj_lbl;
QCheckBox *ui_keepcobj_cb;
QWidget *ui_callwords_tab; QWidget *ui_callwords_tab;
QWidget *ui_callwords_widget; QWidget *ui_callwords_widget;
QVBoxLayout *ui_callwords_layout; QVBoxLayout *ui_callwords_layout;
@ -119,6 +127,17 @@ private:
QLabel *ui_casing_cm_cases_lbl; QLabel *ui_casing_cm_cases_lbl;
QLineEdit *ui_casing_cm_cases_textbox; QLineEdit *ui_casing_cm_cases_textbox;
QWidget *ui_other_tab;
QWidget *ui_other_widget;
QFormLayout *ui_other_layout;
QLabel *ui_other_fancy_icl_enabled_lb;
QCheckBox *ui_other_fancy_icl_enabled_cb;
QLabel *ui_other_mirror_icl_enabled_lb;
QCheckBox *ui_other_mirror_icl_enabled_cb;
QLabel *ui_other_fancy_icl_limit_lb;
QCheckBox *ui_other_fancy_icl_limit_cb;
bool needs_default_audiodev(); bool needs_default_audiodev();
signals: signals:

View File

@ -21,7 +21,7 @@ private:
QWidget *m_parent; QWidget *m_parent;
QMovie *m_movie; QMovie *m_movie;
AOApplication *ao_app; AOApplication *ao_app;
QString last_image;
}; };
#endif // AOSCENE_H #endif // AOSCENE_H

View File

@ -12,7 +12,8 @@ class AOTextArea : public QTextBrowser
public: public:
AOTextArea(QWidget *p_parent = nullptr); AOTextArea(QWidget *p_parent = nullptr);
void append_chatmessage(QString p_name, QString p_message, QString p_colour); void append_chatmessage(QString p_name, QString p_message, QString p_colour,
bool song);
void append_error(QString p_message); void append_error(QString p_message);
private: private:

View File

@ -8,15 +8,17 @@ class chatlogpiece
{ {
public: public:
chatlogpiece(); chatlogpiece();
chatlogpiece(QString p_name, QString p_showname, QString p_message, bool p_song); chatlogpiece(QString p_name, QString p_showname, QString p_message,
chatlogpiece(QString p_name, QString p_showname, QString p_message, bool p_song, QDateTime p_datetime); bool p_song, int color);
chatlogpiece(QString p_name, QString p_showname, QString p_message,
bool p_song, int color, QDateTime p_datetime);
QString get_name(); QString get_name();
QString get_showname(); QString get_showname();
QString get_message(); QString get_message();
bool get_is_song(); bool get_is_song();
QDateTime get_datetime(); QDateTime get_datetime();
QString get_datetime_as_string(); QString get_datetime_as_string();
int get_chat_color();
QString get_full(); QString get_full();
@ -26,6 +28,7 @@ private:
QString message; QString message;
QDateTime datetime; QDateTime datetime;
bool is_song; bool is_song;
int color;
}; };
#endif // CHATLOGPIECE_H #endif // CHATLOGPIECE_H

View File

@ -223,15 +223,18 @@ public:
//This function filters out the common CC inline text trickery, for appending to //This function filters out the common CC inline text trickery, for appending to
//the IC chatlog. //the IC chatlog.
QString filter_ic_text(QString p_text); QString filter_ic_text(QString p_text, bool skip_filter, int chat_color);
//adds text to the IC chatlog. p_name first as bold then p_text then a newlin //adds text to the IC chatlog. p_name first as bold then p_text then a newlin
//this function keeps the chatlog scrolled to the top unless there's text selected //this function keeps the chatlog scrolled to the top unless there's text selected
// or the user isn't already scrolled to the top // or the user isn't already scrolled to the top
void append_ic_text(QString p_text, QString p_name = "", bool is_songchange = false); void append_ic_text(QString p_text, QString p_name = "",
bool is_songchange = false, bool force_filter = false,
bool skip_filter = false, int chat_color = 0);
//prints who played the song to IC chat and plays said song(if found on local filesystem) // prints who played the song to IC chat and plays said song(if found on local
//takes in a list where the first element is the song name and the second is the char id of who played it // filesystem) takes in a list where the first element is the song name and
// the second is the char id of who played it
void handle_song(QStringList *p_contents); void handle_song(QStringList *p_contents);
void play_preanim(bool noninterrupting); void play_preanim(bool noninterrupting);
@ -251,6 +254,7 @@ public:
void check_connection_received(); void check_connection_received();
void doScreenShake(); void doScreenShake();
void doRealization(); void doRealization();
void refresh_iclog(bool skiplast);
~Courtroom(); ~Courtroom();
@ -331,6 +335,8 @@ private:
bool rainbow_appended = false; bool rainbow_appended = false;
bool blank_blip = false; bool blank_blip = false;
// The cursor to write with in mirror mode
QTextCursor *mirror_cursor;
// Used for getting the current maximum blocks allowed in the IC chatlog. // Used for getting the current maximum blocks allowed in the IC chatlog.
int log_maximum_blocks = 0; int log_maximum_blocks = 0;
@ -346,28 +352,27 @@ private:
//keeps track of how long realization is visible(it's just a white square and should be visible less than a second) //keeps track of how long realization is visible(it's just a white square and should be visible less than a second)
QTimer *realization_timer; QTimer *realization_timer;
//times how long the blinking testimony should be shown(green one in the corner)
QTimer *testimony_show_timer;
//times how long the blinking testimony should be hidden
QTimer *testimony_hide_timer;
//every time point in char.inis times this equals the final time //every time point in char.inis times this equals the final time
const int time_mod = 40; const int time_mod = 40;
// the amount of time non-animated objection/hold it/takethat images stay
// onscreen for in ms
const int shout_stay_time = 724;
// the amount of time non-animated guilty/not guilty images stay onscreen for
// in ms
const int verdict_stay_time = 3000;
// the amount of time non-animated witness testimony/cross-examination images
// stay onscreen for in ms
const int wtce_stay_time = 1500;
static const int chatmessage_size = 28; static const int chatmessage_size = 28;
QString m_chatmessage[chatmessage_size]; QString m_chatmessage[chatmessage_size];
bool chatmessage_is_empty = false; bool chatmessage_is_empty = false;
QString previous_ic_message = ""; QString previous_ic_message = "";
bool testimony_in_progress = false;
//in milliseconds
const int testimony_show_time = 1500;
//in milliseconds
const int testimony_hide_time = 500;
//char id, muted or not //char id, muted or not
QMap<int, bool> mute_map; QMap<int, bool> mute_map;
@ -381,10 +386,21 @@ private:
//state of text ticking, 0 = not yet ticking, 1 = ticking in progress, 2 = ticking done //state of text ticking, 0 = not yet ticking, 1 = ticking in progress, 2 = ticking done
int text_state = 2; int text_state = 2;
//character id, which index of the char_list the player is // characters we consider punctuation
const QString punctuation_chars = ".,?!:;";
// amount by which we multiply the delay when we parse punctuation chars
int punctuation_modifier = 2;
// character id, which index of the char_list the player is
int m_cid = -1; int m_cid = -1;
// cid and this may differ in cases of ini-editing
QString char_name = "";
int objection_state = 0; int objection_state = 0;
bool keep_custom_objection = false;
QString objection_custom = "";
int realization_state = 0; int realization_state = 0;
int screenshake_state = 0; int screenshake_state = 0;
int text_color = 0; int text_color = 0;
@ -429,6 +445,8 @@ private:
//whether the ooc chat is server or master chat, true is server //whether the ooc chat is server or master chat, true is server
bool server_ooc = true; bool server_ooc = true;
// Is AFK enabled
bool isafk = false;
QString current_background = "default"; QString current_background = "default";
AOMusicPlayer *music_player; AOMusicPlayer *music_player;
@ -454,10 +472,17 @@ private:
AOImage *ui_vp_chatbox; AOImage *ui_vp_chatbox;
QLabel *ui_vp_showname; QLabel *ui_vp_showname;
QTextEdit *ui_vp_message; QTextEdit *ui_vp_message;
AOImage *ui_vp_testimony; AOMovie *ui_vp_realization;
AOImage *ui_vp_realization; AOMovie *ui_vp_testimony;
AOMovie *ui_vp_wtce; AOMovie *ui_vp_wtce;
AOMovie *ui_vp_objection; AOMovie *ui_vp_objection;
void realization_done();
bool colorf_iclog = false;
bool mirror_iclog = false;
bool colorf_limit = false;
bool keep_evidence_display = false;
QTextEdit *ui_ic_chatlog; QTextEdit *ui_ic_chatlog;
@ -466,7 +491,7 @@ private:
QListWidget *ui_mute_list; QListWidget *ui_mute_list;
QListWidget *ui_area_list; QListWidget *ui_area_list;
QListWidget *ui_music_list; QTreeWidget *ui_music_list;
AOButton *ui_pair_button; AOButton *ui_pair_button;
QListWidget *ui_pair_list; QListWidget *ui_pair_list;
@ -480,6 +505,8 @@ private:
//QLineEdit *ui_area_password; //QLineEdit *ui_area_password;
QLineEdit *ui_music_search; QLineEdit *ui_music_search;
QString music_search_par = "";
QString area_search_par = "";
QWidget *ui_emotes; QWidget *ui_emotes;
QVector<AOEmoteButton*> ui_emote_list; QVector<AOEmoteButton*> ui_emote_list;
@ -527,6 +554,8 @@ private:
AOButton *ui_screenshake; AOButton *ui_screenshake;
AOButton *ui_mute; AOButton *ui_mute;
QMenu *custom_obj_menu;
AOButton *ui_defense_plus; AOButton *ui_defense_plus;
AOButton *ui_defense_minus; AOButton *ui_defense_minus;
@ -589,11 +618,6 @@ public slots:
void objection_done(); void objection_done();
void preanim_done(); void preanim_done();
void realization_done();
void show_testimony();
void hide_testimony();
void mod_called(QString p_ip); void mod_called(QString p_ip);
void case_called(QString msg, bool def, bool pro, bool jud, bool jur, bool steno, bool witness); void case_called(QString msg, bool def, bool pro, bool jud, bool jur, bool steno, bool witness);
@ -611,8 +635,9 @@ private slots:
void on_ooc_return_pressed(); void on_ooc_return_pressed();
void on_music_search_keypr();
void on_music_search_edited(QString p_text); void on_music_search_edited(QString p_text);
void on_music_list_double_clicked(QModelIndex p_model); void on_music_list_double_clicked(QTreeWidgetItem *p_item, int column);
void on_area_list_double_clicked(QModelIndex p_model); void on_area_list_double_clicked(QModelIndex p_model);
void select_emote(int p_id); void select_emote(int p_id);
@ -641,6 +666,7 @@ private slots:
void on_objection_clicked(); void on_objection_clicked();
void on_take_that_clicked(); void on_take_that_clicked();
void on_custom_objection_clicked(); void on_custom_objection_clicked();
void ShowContextMenu(const QPoint &pos);
void on_realization_clicked(); void on_realization_clicked();
void on_screenshake_clicked(); void on_screenshake_clicked();

View File

@ -38,7 +38,7 @@ public:
QString get_chatlog(); QString get_chatlog();
int get_selected_server(); int get_selected_server();
void enable_connect_button(); void enable_connect_button();
void check_update();
void set_loading_value(int p_value); void set_loading_value(int p_value);
bool public_servers_selected = true; bool public_servers_selected = true;

View File

@ -135,6 +135,7 @@ void AOApplication::server_disconnected()
{ {
if (courtroom_constructed) if (courtroom_constructed)
{ {
beep();
call_notice(tr("Disconnected from server.")); call_notice(tr("Disconnected from server."));
construct_lobby(); construct_lobby();
destruct_courtroom(); destruct_courtroom();

View File

@ -154,9 +154,6 @@ void AOCharMovie::sfx_two_network_boogaloo()
void AOCharMovie::movie_ticker() void AOCharMovie::movie_ticker()
{ {
if(apng){
ticker->start(m_movie->nextFrameDelay());
}
if(m_movie->currentFrameNumber() == m_movie->frameCount() - 1) if(m_movie->currentFrameNumber() == m_movie->frameCount() - 1)
{ {
delete m_movie; delete m_movie;

View File

@ -1,7 +1,7 @@
#include "aomovie.h" #include "aomovie.h"
#include "file_functions.h"
#include "courtroom.h" #include "courtroom.h"
#include "file_functions.h"
#include "misc_functions.h" #include "misc_functions.h"
AOMovie::AOMovie(QWidget *p_parent, AOApplication *p_ao_app) : QLabel(p_parent) AOMovie::AOMovie(QWidget *p_parent, AOApplication *p_ao_app) : QLabel(p_parent)
@ -11,55 +11,80 @@ AOMovie::AOMovie(QWidget *p_parent, AOApplication *p_ao_app) : QLabel(p_parent)
m_movie = new QMovie(); m_movie = new QMovie();
this->setMovie(m_movie); 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(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) void AOMovie::set_play_once(bool p_play_once)
{ {
play_once = 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) void AOMovie::play(QString p_gif, QString p_char, QString p_custom_theme,
int duration)
{ {
m_movie->stop(); m_movie->stop();
// this->timer_done();
QString shout_path = p_gif;
QList<QString> pathlist;
QString gif_path; if (ao_app->get_character_path(p_char, p_gif)
.contains(
QString custom_path; "custom_objections")) // checks if the file is located within the
if (p_gif == "custom") // folder of custom objections
custom_path = ao_app->get_image_suffix(ao_app->get_character_path(p_char, p_gif)); 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 else
custom_path = ao_app->get_image_suffix(ao_app->get_character_path(p_char, p_gif + "_bubble")); 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 misc_path = ao_app->get_base_path() + "misc/" + p_custom_theme + "/" +
QString custom_theme_path = ao_app->get_custom_theme_path(p_custom_theme, p_gif + ".gif"); 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 theme_path = ao_app->get_theme_path(p_gif + ".gif");
QString default_theme_path = ao_app->get_default_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 placeholder_path = ao_app->get_theme_path("placeholder.gif");
QString default_placeholder_path = ao_app->get_default_theme_path("placeholder.gif"); QString default_placeholder_path =
ao_app->get_default_theme_path("placeholder.gif");
if (file_exists(custom_path)) pathlist << ao_app->get_image_suffix(ao_app->get_base_path() + "misc/" +
gif_path = custom_path; p_custom_theme + "/" + p_gif + "_bubble")
else if (file_exists(misc_path)) << // Misc path
gif_path = misc_path; ao_app->get_image_suffix(
else if (file_exists(custom_theme_path)) ao_app->get_custom_theme_path(p_custom_theme, p_gif))
gif_path = custom_theme_path; << // Custom theme path
else if (file_exists(theme_path)) ao_app->get_image_suffix(ao_app->get_theme_path(p_gif)) << // Theme path
gif_path = theme_path; ao_app->get_image_suffix(ao_app->get_default_theme_path(p_gif))
else if (file_exists(default_theme_path)) << // Default theme path
gif_path = default_theme_path; ao_app->get_image_suffix(ao_app->get_theme_path("placeholder"))
else if (file_exists(placeholder_path)) << // Placeholder path
gif_path = placeholder_path; ao_app->get_image_suffix(ao_app->get_default_theme_path(
else if (file_exists(default_placeholder_path)) "placeholder")); // Default placeholder path
gif_path = default_placeholder_path;
else
gif_path = "";
m_movie->setFileName(gif_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(); this->show();
m_movie->start(); m_movie->start();
if (m_movie->frameCount() == 0 && duration > 0)
timer->start(duration);
} }
void AOMovie::stop() void AOMovie::stop()
@ -70,16 +95,20 @@ void AOMovie::stop()
void AOMovie::frame_change(int n_frame) void AOMovie::frame_change(int n_frame)
{ {
if (n_frame == (m_movie->frameCount() - 1) && play_once) // 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
//we need this or else the last frame wont show // reach the last frame or the movie is continuous, don't stop the movie.
delay(m_movie->nextFrameDelay()); 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(); this->stop();
//signal connected to courtroom object, let it figure out what to do
done(); done();
}
} }
void AOMovie::combo_resize(int w, int h) void AOMovie::combo_resize(int w, int h)

View File

@ -1,27 +1,32 @@
#include "aooptionsdialog.h" #include "aooptionsdialog.h"
#include "aoapplication.h" #include "aoapplication.h"
AOOptionsDialog::AOOptionsDialog(QWidget *parent, AOApplication *p_ao_app) : QDialog(parent) AOOptionsDialog::AOOptionsDialog(QWidget *parent, AOApplication *p_ao_app)
: QDialog(parent)
{ {
ao_app = p_ao_app; ao_app = p_ao_app;
// Setting up the basics. // Setting up the basics.
// setAttribute(Qt::WA_DeleteOnClose); // setAttribute(Qt::WA_DeleteOnClose);
setWindowTitle(tr("Settings")); setWindowTitle(tr("Settings"));
resize(398, 320); resize(398, 360);
ui_settings_buttons = new QDialogButtonBox(this); ui_settings_buttons = new QDialogButtonBox(this);
QSizePolicy sizePolicy1(QSizePolicy::Expanding, QSizePolicy::Fixed); QSizePolicy sizePolicy1(QSizePolicy::Expanding, QSizePolicy::Fixed);
sizePolicy1.setHorizontalStretch(0); sizePolicy1.setHorizontalStretch(0);
sizePolicy1.setVerticalStretch(0); sizePolicy1.setVerticalStretch(0);
sizePolicy1.setHeightForWidth(ui_settings_buttons->sizePolicy().hasHeightForWidth()); sizePolicy1.setHeightForWidth(
ui_settings_buttons->sizePolicy().hasHeightForWidth());
ui_settings_buttons->setSizePolicy(sizePolicy1); ui_settings_buttons->setSizePolicy(sizePolicy1);
ui_settings_buttons->setOrientation(Qt::Horizontal); ui_settings_buttons->setOrientation(Qt::Horizontal);
ui_settings_buttons->setStandardButtons(QDialogButtonBox::Cancel | QDialogButtonBox::Save); ui_settings_buttons->setStandardButtons(QDialogButtonBox::Cancel |
QDialogButtonBox::Save);
QObject::connect(ui_settings_buttons, SIGNAL(accepted()), this, SLOT(save_pressed())); QObject::connect(ui_settings_buttons, SIGNAL(accepted()), this,
QObject::connect(ui_settings_buttons, SIGNAL(rejected()), this, SLOT(discard_pressed())); SLOT(save_pressed()));
QObject::connect(ui_settings_buttons, SIGNAL(rejected()), this,
SLOT(discard_pressed()));
// We'll stop updates so that the window won't flicker while it's being made. // We'll stop updates so that the window won't flicker while it's being made.
setUpdatesEnabled(false); setUpdatesEnabled(false);
@ -34,21 +39,28 @@ AOOptionsDialog::AOOptionsDialog(QWidget *parent, AOApplication *p_ao_app) : QDi
ui_vertical_layout->addWidget(ui_settings_buttons); ui_vertical_layout->addWidget(ui_settings_buttons);
// Let's add the tabs one by one. // Let's add the tabs one by one.
// First, we'll start with 'Gameplay'.
//
// GAMEPLAY
//
ui_gameplay_tab = new QWidget(); ui_gameplay_tab = new QWidget();
ui_settings_tabs->addTab(ui_gameplay_tab, tr("Gameplay")); ui_settings_tabs->addTab(ui_gameplay_tab, tr("Gameplay"));
ui_form_layout_widget = new QWidget(ui_gameplay_tab); ui_form_layout_widget = new QWidget(ui_gameplay_tab);
ui_form_layout_widget->setGeometry(QRect(10, 10, 361, 211)); ui_form_layout_widget->setGeometry(QRect(10, 10, 361, 240));
ui_gameplay_form = new QFormLayout(ui_form_layout_widget); ui_gameplay_form = new QFormLayout(ui_form_layout_widget);
ui_gameplay_form->setLabelAlignment(Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter); ui_gameplay_form->setLabelAlignment(Qt::AlignLeading | Qt::AlignLeft |
ui_gameplay_form->setFormAlignment(Qt::AlignLeading|Qt::AlignLeft|Qt::AlignTop); Qt::AlignVCenter);
ui_gameplay_form->setFormAlignment(Qt::AlignLeading | Qt::AlignLeft |
Qt::AlignTop);
ui_gameplay_form->setContentsMargins(0, 0, 0, 0); ui_gameplay_form->setContentsMargins(0, 0, 0, 0);
ui_theme_label = new QLabel(ui_form_layout_widget); ui_theme_label = new QLabel(ui_form_layout_widget);
ui_theme_label->setText(tr("Theme:")); ui_theme_label->setText(tr("Theme:"));
ui_theme_label->setToolTip(tr("Sets the theme used in-game. If the new theme changes " ui_theme_label->setToolTip(
tr("Sets the theme used in-game. If the new theme changes "
"the lobby's look as well, you'll need to reload the " "the lobby's look as well, you'll need to reload the "
"lobby for the changes to take effect, such as by joining " "lobby for the changes to take effect, such as by joining "
"a server and leaving it.")); "a server and leaving it."));
@ -57,14 +69,14 @@ AOOptionsDialog::AOOptionsDialog(QWidget *parent, AOApplication *p_ao_app) : QDi
ui_theme_combobox = new QComboBox(ui_form_layout_widget); ui_theme_combobox = new QComboBox(ui_form_layout_widget);
// Fill the combobox with the names of the themes. // Fill the combobox with the names of the themes.
QDirIterator it(p_ao_app->get_base_path() + "themes", QDir::Dirs, QDirIterator::NoIteratorFlags); QDirIterator it(p_ao_app->get_base_path() + "themes", QDir::Dirs,
while (it.hasNext()) QDirIterator::NoIteratorFlags);
{ while (it.hasNext()) {
QString actualname = QDir(it.next()).dirName(); QString actualname = QDir(it.next()).dirName();
if (actualname != "." && actualname != "..") if (actualname != "." && actualname != "..")
ui_theme_combobox->addItem(actualname); ui_theme_combobox->addItem(actualname);
if (actualname == p_ao_app->read_theme()) if (actualname == p_ao_app->read_theme())
ui_theme_combobox->setCurrentIndex(ui_theme_combobox->count()-1); ui_theme_combobox->setCurrentIndex(ui_theme_combobox->count() - 1);
} }
ui_gameplay_form->setWidget(0, QFormLayout::FieldRole, ui_theme_combobox); ui_gameplay_form->setWidget(0, QFormLayout::FieldRole, ui_theme_combobox);
@ -78,7 +90,8 @@ AOOptionsDialog::AOOptionsDialog(QWidget *parent, AOApplication *p_ao_app) : QDi
ui_downwards_lbl = new QLabel(ui_form_layout_widget); ui_downwards_lbl = new QLabel(ui_form_layout_widget);
ui_downwards_lbl->setText(tr("Log goes downwards:")); ui_downwards_lbl->setText(tr("Log goes downwards:"));
ui_downwards_lbl->setToolTip(tr("If ticked, new messages will appear at " ui_downwards_lbl->setToolTip(
tr("If ticked, new messages will appear at "
"the bottom (like the OOC chatlog). The traditional " "the bottom (like the OOC chatlog). The traditional "
"(AO1) behaviour is equivalent to this being unticked.")); "(AO1) behaviour is equivalent to this being unticked."));
@ -91,7 +104,8 @@ AOOptionsDialog::AOOptionsDialog(QWidget *parent, AOApplication *p_ao_app) : QDi
ui_length_lbl = new QLabel(ui_form_layout_widget); ui_length_lbl = new QLabel(ui_form_layout_widget);
ui_length_lbl->setText(tr("Log length:")); ui_length_lbl->setText(tr("Log length:"));
ui_length_lbl->setToolTip(tr("The amount of messages the IC chatlog will keep before " ui_length_lbl->setToolTip(tr(
"The amount of messages the IC chatlog will keep before "
"deleting older messages. A value of 0 or below counts as 'infinite'.")); "deleting older messages. A value of 0 or below counts as 'infinite'."));
ui_gameplay_form->setWidget(3, QFormLayout::LabelRole, ui_length_lbl); ui_gameplay_form->setWidget(3, QFormLayout::LabelRole, ui_length_lbl);
@ -110,7 +124,8 @@ AOOptionsDialog::AOOptionsDialog(QWidget *parent, AOApplication *p_ao_app) : QDi
ui_username_lbl = new QLabel(ui_form_layout_widget); ui_username_lbl = new QLabel(ui_form_layout_widget);
ui_username_lbl->setText(tr("Default username:")); ui_username_lbl->setText(tr("Default username:"));
ui_username_lbl->setToolTip(tr("Your OOC name will be automatically set to this value " ui_username_lbl->setToolTip(
tr("Your OOC name will be automatically set to this value "
"when you join a server.")); "when you join a server."));
ui_gameplay_form->setWidget(5, QFormLayout::LabelRole, ui_username_lbl); ui_gameplay_form->setWidget(5, QFormLayout::LabelRole, ui_username_lbl);
@ -123,7 +138,8 @@ AOOptionsDialog::AOOptionsDialog(QWidget *parent, AOApplication *p_ao_app) : QDi
ui_showname_lbl = new QLabel(ui_form_layout_widget); ui_showname_lbl = new QLabel(ui_form_layout_widget);
ui_showname_lbl->setText(tr("Custom shownames:")); ui_showname_lbl->setText(tr("Custom shownames:"));
ui_showname_lbl->setToolTip(tr("Gives the default value for the in-game 'Custom shownames' " ui_showname_lbl->setToolTip(
tr("Gives the default value for the in-game 'Custom shownames' "
"tickbox, which in turn determines whether the client should " "tickbox, which in turn determines whether the client should "
"display custom in-character names.")); "display custom in-character names."));
@ -142,12 +158,13 @@ AOOptionsDialog::AOOptionsDialog(QWidget *parent, AOApplication *p_ao_app) : QDi
ui_ms_lbl = new QLabel(ui_form_layout_widget); ui_ms_lbl = new QLabel(ui_form_layout_widget);
ui_ms_lbl->setText(tr("Backup MS:")); ui_ms_lbl->setText(tr("Backup MS:"));
ui_ms_lbl->setToolTip(tr("If the built-in server lookups fail, the game will try the " ui_ms_lbl->setToolTip(
tr("If the built-in server lookups fail, the game will try the "
"address given here and use it as a backup master server address.")); "address given here and use it as a backup master server address."));
ui_gameplay_form->setWidget(8, QFormLayout::LabelRole, ui_ms_lbl); ui_gameplay_form->setWidget(8, QFormLayout::LabelRole, ui_ms_lbl);
QSettings* configini = ao_app->configini; QSettings *configini = ao_app->configini;
ui_ms_textbox = new QLineEdit(ui_form_layout_widget); ui_ms_textbox = new QLineEdit(ui_form_layout_widget);
ui_ms_textbox->setText(configini->value("master", "").value<QString>()); ui_ms_textbox->setText(configini->value("master", "").value<QString>());
@ -155,7 +172,8 @@ AOOptionsDialog::AOOptionsDialog(QWidget *parent, AOApplication *p_ao_app) : QDi
ui_discord_lbl = new QLabel(ui_form_layout_widget); ui_discord_lbl = new QLabel(ui_form_layout_widget);
ui_discord_lbl->setText(tr("Discord:")); ui_discord_lbl->setText(tr("Discord:"));
ui_discord_lbl->setToolTip(tr("Allows others on Discord to see what server you are in, " ui_discord_lbl->setToolTip(
tr("Allows others on Discord to see what server you are in, "
"what character are you playing, and how long you have " "what character are you playing, and how long you have "
"been playing for.")); "been playing for."));
@ -168,7 +186,9 @@ AOOptionsDialog::AOOptionsDialog(QWidget *parent, AOApplication *p_ao_app) : QDi
ui_epilepsy_lbl = new QLabel(ui_form_layout_widget); ui_epilepsy_lbl = new QLabel(ui_form_layout_widget);
ui_epilepsy_lbl->setText(tr("Allow Shake/Flash:")); ui_epilepsy_lbl->setText(tr("Allow Shake/Flash:"));
ui_epilepsy_lbl->setToolTip(tr("Allows screenshaking and flashing. Disable this if you have concerns or issues with photosensitivity and/or seizures.")); ui_epilepsy_lbl->setToolTip(
tr("Allows screenshaking and flashing. Disable this if you have concerns "
"or issues with photosensitivity and/or seizures."));
ui_gameplay_form->setWidget(10, QFormLayout::LabelRole, ui_epilepsy_lbl); ui_gameplay_form->setWidget(10, QFormLayout::LabelRole, ui_epilepsy_lbl);
@ -179,11 +199,14 @@ AOOptionsDialog::AOOptionsDialog(QWidget *parent, AOApplication *p_ao_app) : QDi
ui_language_label = new QLabel(ui_form_layout_widget); ui_language_label = new QLabel(ui_form_layout_widget);
ui_language_label->setText(tr("Language:")); ui_language_label->setText(tr("Language:"));
ui_language_label->setToolTip(tr("Sets the language if you don't want to use your system language.")); ui_language_label->setToolTip(
tr("Sets the language if you don't want to use your system language."));
ui_gameplay_form->setWidget(11, QFormLayout::LabelRole, ui_language_label); ui_gameplay_form->setWidget(11, QFormLayout::LabelRole, ui_language_label);
ui_language_combobox = new QComboBox(ui_form_layout_widget); ui_language_combobox = new QComboBox(ui_form_layout_widget);
ui_language_combobox->addItem(configini->value("language", " ").value<QString>() + " - Keep current setting"); ui_language_combobox->addItem(
configini->value("language", " ").value<QString>() +
" - Keep current setting");
ui_language_combobox->addItem(" - Default"); ui_language_combobox->addItem(" - Default");
ui_language_combobox->addItem("en - English"); ui_language_combobox->addItem("en - English");
ui_language_combobox->addItem("de - Deutsch"); ui_language_combobox->addItem("de - Deutsch");
@ -201,13 +224,14 @@ AOOptionsDialog::AOOptionsDialog(QWidget *parent, AOApplication *p_ao_app) : QDi
ui_callwords_widget->setGeometry(QRect(10, 10, 361, 211)); ui_callwords_widget->setGeometry(QRect(10, 10, 361, 211));
ui_callwords_layout = new QVBoxLayout(ui_callwords_widget); ui_callwords_layout = new QVBoxLayout(ui_callwords_widget);
ui_callwords_layout->setContentsMargins(0,0,0,0); ui_callwords_layout->setContentsMargins(0, 0, 0, 0);
ui_callwords_textbox = new QPlainTextEdit(ui_callwords_widget); ui_callwords_textbox = new QPlainTextEdit(ui_callwords_widget);
QSizePolicy sizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding); QSizePolicy sizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
sizePolicy.setHorizontalStretch(0); sizePolicy.setHorizontalStretch(0);
sizePolicy.setVerticalStretch(0); sizePolicy.setVerticalStretch(0);
sizePolicy.setHeightForWidth(ui_callwords_textbox->sizePolicy().hasHeightForWidth()); sizePolicy.setHeightForWidth(
ui_callwords_textbox->sizePolicy().hasHeightForWidth());
ui_callwords_textbox->setSizePolicy(sizePolicy); ui_callwords_textbox->setSizePolicy(sizePolicy);
// Let's fill the callwords text edit with the already present callwords. // Let's fill the callwords text edit with the already present callwords.
@ -220,7 +244,12 @@ AOOptionsDialog::AOOptionsDialog(QWidget *parent, AOApplication *p_ao_app) : QDi
ui_callwords_explain_lbl = new QLabel(ui_callwords_widget); ui_callwords_explain_lbl = new QLabel(ui_callwords_widget);
ui_callwords_explain_lbl->setWordWrap(true); ui_callwords_explain_lbl->setWordWrap(true);
ui_callwords_explain_lbl->setText(tr("<html><head/><body>Enter as many callwords as you would like. These are case insensitive. Make sure to leave every callword in its own line!<br>Do not leave a line with a space at the end -- you will be alerted everytime someone uses a space in their messages.</body></html>")); ui_callwords_explain_lbl->setText(
tr("<html><head/><body>Enter as many callwords as you would like. These "
"are case insensitive. Make sure to leave every callword in its own "
"line!<br>Do not leave a line with a space at the end -- you will be "
"alerted everytime someone uses a space in their "
"messages.</body></html>"));
ui_callwords_layout->addWidget(ui_callwords_explain_lbl); ui_callwords_layout->addWidget(ui_callwords_explain_lbl);
@ -232,8 +261,10 @@ AOOptionsDialog::AOOptionsDialog(QWidget *parent, AOApplication *p_ao_app) : QDi
ui_audio_widget->setGeometry(QRect(10, 10, 361, 211)); ui_audio_widget->setGeometry(QRect(10, 10, 361, 211));
ui_audio_layout = new QFormLayout(ui_audio_widget); ui_audio_layout = new QFormLayout(ui_audio_widget);
ui_audio_layout->setLabelAlignment(Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter); ui_audio_layout->setLabelAlignment(Qt::AlignLeading | Qt::AlignLeft |
ui_audio_layout->setFormAlignment(Qt::AlignLeading|Qt::AlignLeft|Qt::AlignTop); Qt::AlignVCenter);
ui_audio_layout->setFormAlignment(Qt::AlignLeading | Qt::AlignLeft |
Qt::AlignTop);
ui_audio_layout->setContentsMargins(0, 0, 0, 0); ui_audio_layout->setContentsMargins(0, 0, 0, 0);
ui_audio_device_lbl = new QLabel(ui_audio_widget); ui_audio_device_lbl = new QLabel(ui_audio_widget);
@ -244,37 +275,39 @@ AOOptionsDialog::AOOptionsDialog(QWidget *parent, AOApplication *p_ao_app) : QDi
ui_audio_device_combobox = new QComboBox(ui_audio_widget); ui_audio_device_combobox = new QComboBox(ui_audio_widget);
// Let's fill out the combobox with the available audio devices. Or don't if there is no audio // Let's fill out the combobox with the available audio devices. Or don't if
if (needs_default_audiodev()) // there is no audio
{ if (needs_default_audiodev()) {
ui_audio_device_combobox->addItem("default"); ui_audio_device_combobox->addItem("default");
} }
#ifdef BASSAUDIO #ifdef BASSAUDIO
BASS_DEVICEINFO info; BASS_DEVICEINFO info;
int a = 0; int a = 0;
for (a = 0; BASS_GetDeviceInfo(a, &info); a++) for (a = 0; BASS_GetDeviceInfo(a, &info); a++) {
{
ui_audio_device_combobox->addItem(info.name); ui_audio_device_combobox->addItem(info.name);
if (p_ao_app->get_audio_output_device() == info.name) if (p_ao_app->get_audio_output_device() == info.name)
ui_audio_device_combobox->setCurrentIndex(ui_audio_device_combobox->count()-1); ui_audio_device_combobox->setCurrentIndex(
ui_audio_device_combobox->count() - 1);
} }
#elif defined QTAUDIO #elif defined QTAUDIO
foreach (const QAudioDeviceInfo &deviceInfo, QAudioDeviceInfo::availableDevices(QAudio::AudioOutput)) foreach (const QAudioDeviceInfo &deviceInfo,
{ QAudioDeviceInfo::availableDevices(QAudio::AudioOutput)) {
ui_audio_device_combobox->addItem(deviceInfo.deviceName()); ui_audio_device_combobox->addItem(deviceInfo.deviceName());
if (p_ao_app->get_audio_output_device() == deviceInfo.deviceName()) if (p_ao_app->get_audio_output_device() == deviceInfo.deviceName())
ui_audio_device_combobox->setCurrentIndex(ui_audio_device_combobox->count()-1); ui_audio_device_combobox->setCurrentIndex(
ui_audio_device_combobox->count() - 1);
} }
#endif #endif
ui_audio_layout->setWidget(0, QFormLayout::FieldRole, ui_audio_device_combobox); ui_audio_layout->setWidget(0, QFormLayout::FieldRole,
ui_audio_device_combobox);
ui_audio_volume_divider = new QFrame(ui_audio_widget); ui_audio_volume_divider = new QFrame(ui_audio_widget);
ui_audio_volume_divider->setFrameShape(QFrame::HLine); ui_audio_volume_divider->setFrameShape(QFrame::HLine);
ui_audio_volume_divider->setFrameShadow(QFrame::Sunken); ui_audio_volume_divider->setFrameShadow(QFrame::Sunken);
ui_audio_layout->setWidget(1, QFormLayout::FieldRole, ui_audio_volume_divider); ui_audio_layout->setWidget(1, QFormLayout::FieldRole,
ui_audio_volume_divider);
ui_music_volume_lbl = new QLabel(ui_audio_widget); ui_music_volume_lbl = new QLabel(ui_audio_widget);
ui_music_volume_lbl->setText(tr("Music:")); ui_music_volume_lbl->setText(tr("Music:"));
@ -287,11 +320,13 @@ AOOptionsDialog::AOOptionsDialog(QWidget *parent, AOApplication *p_ao_app) : QDi
ui_music_volume_spinbox->setMaximum(100); ui_music_volume_spinbox->setMaximum(100);
ui_music_volume_spinbox->setSuffix("%"); ui_music_volume_spinbox->setSuffix("%");
ui_audio_layout->setWidget(2, QFormLayout::FieldRole, ui_music_volume_spinbox); ui_audio_layout->setWidget(2, QFormLayout::FieldRole,
ui_music_volume_spinbox);
ui_sfx_volume_lbl = new QLabel(ui_audio_widget); ui_sfx_volume_lbl = new QLabel(ui_audio_widget);
ui_sfx_volume_lbl->setText(tr("SFX:")); ui_sfx_volume_lbl->setText(tr("SFX:"));
ui_sfx_volume_lbl->setToolTip(tr("Sets the SFX's default volume. " ui_sfx_volume_lbl->setToolTip(
tr("Sets the SFX's default volume. "
"Interjections and actual sound effects count as 'SFX'.")); "Interjections and actual sound effects count as 'SFX'."));
ui_audio_layout->setWidget(3, QFormLayout::LabelRole, ui_sfx_volume_lbl); ui_audio_layout->setWidget(3, QFormLayout::LabelRole, ui_sfx_volume_lbl);
@ -305,7 +340,8 @@ AOOptionsDialog::AOOptionsDialog(QWidget *parent, AOApplication *p_ao_app) : QDi
ui_blips_volume_lbl = new QLabel(ui_audio_widget); ui_blips_volume_lbl = new QLabel(ui_audio_widget);
ui_blips_volume_lbl->setText(tr("Blips:")); ui_blips_volume_lbl->setText(tr("Blips:"));
ui_blips_volume_lbl->setToolTip(tr("Sets the volume of the blips, the talking sound effects.")); ui_blips_volume_lbl->setToolTip(
tr("Sets the volume of the blips, the talking sound effects."));
ui_audio_layout->setWidget(4, QFormLayout::LabelRole, ui_blips_volume_lbl); ui_audio_layout->setWidget(4, QFormLayout::LabelRole, ui_blips_volume_lbl);
@ -314,7 +350,8 @@ AOOptionsDialog::AOOptionsDialog(QWidget *parent, AOApplication *p_ao_app) : QDi
ui_blips_volume_spinbox->setMaximum(100); ui_blips_volume_spinbox->setMaximum(100);
ui_blips_volume_spinbox->setSuffix("%"); ui_blips_volume_spinbox->setSuffix("%");
ui_audio_layout->setWidget(4, QFormLayout::FieldRole, ui_blips_volume_spinbox); ui_audio_layout->setWidget(4, QFormLayout::FieldRole,
ui_blips_volume_spinbox);
ui_volume_blip_divider = new QFrame(ui_audio_widget); ui_volume_blip_divider = new QFrame(ui_audio_widget);
ui_volume_blip_divider->setFrameShape(QFrame::HLine); ui_volume_blip_divider->setFrameShape(QFrame::HLine);
@ -324,7 +361,8 @@ AOOptionsDialog::AOOptionsDialog(QWidget *parent, AOApplication *p_ao_app) : QDi
ui_bliprate_lbl = new QLabel(ui_audio_widget); ui_bliprate_lbl = new QLabel(ui_audio_widget);
ui_bliprate_lbl->setText(tr("Blip rate:")); ui_bliprate_lbl->setText(tr("Blip rate:"));
ui_bliprate_lbl->setToolTip(tr("Sets the delay between playing the blip sounds.")); ui_bliprate_lbl->setToolTip(
tr("Sets the delay between playing the blip sounds."));
ui_audio_layout->setWidget(6, QFormLayout::LabelRole, ui_bliprate_lbl); ui_audio_layout->setWidget(6, QFormLayout::LabelRole, ui_bliprate_lbl);
@ -336,7 +374,8 @@ AOOptionsDialog::AOOptionsDialog(QWidget *parent, AOApplication *p_ao_app) : QDi
ui_blank_blips_lbl = new QLabel(ui_audio_widget); ui_blank_blips_lbl = new QLabel(ui_audio_widget);
ui_blank_blips_lbl->setText(tr("Blank blips:")); ui_blank_blips_lbl->setText(tr("Blank blips:"));
ui_blank_blips_lbl->setToolTip(tr("If true, the game will play a blip sound even " ui_blank_blips_lbl->setToolTip(
tr("If true, the game will play a blip sound even "
"when a space is 'being said'.")); "when a space is 'being said'."));
ui_audio_layout->setWidget(7, QFormLayout::LabelRole, ui_blank_blips_lbl); ui_audio_layout->setWidget(7, QFormLayout::LabelRole, ui_blank_blips_lbl);
@ -348,7 +387,8 @@ AOOptionsDialog::AOOptionsDialog(QWidget *parent, AOApplication *p_ao_app) : QDi
ui_loopsfx_lbl = new QLabel(ui_audio_widget); ui_loopsfx_lbl = new QLabel(ui_audio_widget);
ui_loopsfx_lbl->setText(tr("Enable Looping SFX:")); ui_loopsfx_lbl->setText(tr("Enable Looping SFX:"));
ui_loopsfx_lbl->setToolTip(tr("If true, the game will allow looping sound effects to play on preanimations.")); ui_loopsfx_lbl->setToolTip(tr("If true, the game will allow looping sound "
"effects to play on preanimations."));
ui_audio_layout->setWidget(8, QFormLayout::LabelRole, ui_loopsfx_lbl); ui_audio_layout->setWidget(8, QFormLayout::LabelRole, ui_loopsfx_lbl);
@ -357,10 +397,11 @@ AOOptionsDialog::AOOptionsDialog(QWidget *parent, AOApplication *p_ao_app) : QDi
ui_audio_layout->setWidget(8, QFormLayout::FieldRole, ui_loopsfx_cb); ui_audio_layout->setWidget(8, QFormLayout::FieldRole, ui_loopsfx_cb);
ui_objectmusic_lbl = new QLabel(ui_audio_widget); ui_objectmusic_lbl = new QLabel(ui_audio_widget);
ui_objectmusic_lbl->setText(tr("Kill Music On Objection:")); ui_objectmusic_lbl->setText(tr("Kill Music On Objection:"));
ui_objectmusic_lbl->setToolTip(tr("If true, the game will stop music when someone objects, like in the actual games.")); ui_objectmusic_lbl->setToolTip(
tr("If true, the game will stop music when someone objects, like in the "
"actual games."));
ui_audio_layout->setWidget(9, QFormLayout::LabelRole, ui_objectmusic_lbl); ui_audio_layout->setWidget(9, QFormLayout::LabelRole, ui_objectmusic_lbl);
@ -369,16 +410,20 @@ AOOptionsDialog::AOOptionsDialog(QWidget *parent, AOApplication *p_ao_app) : QDi
ui_audio_layout->setWidget(9, QFormLayout::FieldRole, ui_objectmusic_cb); ui_audio_layout->setWidget(9, QFormLayout::FieldRole, ui_objectmusic_cb);
// The casing tab! //
// CASING
//
ui_casing_tab = new QWidget(); ui_casing_tab = new QWidget();
ui_settings_tabs->addTab(ui_casing_tab, tr("Casing")); ui_settings_tabs->addTab(ui_casing_tab, tr("Casing"));
ui_casing_widget = new QWidget(ui_casing_tab); ui_casing_widget = new QWidget(ui_casing_tab);
ui_casing_widget->setGeometry(QRect(10,10, 361, 211)); ui_casing_widget->setGeometry(QRect(10, 10, 361, 211));
ui_casing_layout = new QFormLayout(ui_casing_widget); ui_casing_layout = new QFormLayout(ui_casing_widget);
ui_casing_layout->setLabelAlignment(Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter); ui_casing_layout->setLabelAlignment(Qt::AlignLeading | Qt::AlignLeft |
ui_casing_layout->setFormAlignment(Qt::AlignLeading|Qt::AlignLeft|Qt::AlignTop); Qt::AlignVCenter);
ui_casing_layout->setFormAlignment(Qt::AlignLeading | Qt::AlignLeft |
Qt::AlignTop);
ui_casing_layout->setContentsMargins(0, 0, 0, 0); ui_casing_layout->setContentsMargins(0, 0, 0, 0);
// -- SERVER SUPPORTS CASING // -- SERVER SUPPORTS CASING
@ -387,16 +432,19 @@ AOOptionsDialog::AOOptionsDialog(QWidget *parent, AOApplication *p_ao_app) : QDi
if (ao_app->casing_alerts_enabled) if (ao_app->casing_alerts_enabled)
ui_casing_supported_lbl->setText(tr("This server supports case alerts.")); ui_casing_supported_lbl->setText(tr("This server supports case alerts."));
else else
ui_casing_supported_lbl->setText(tr("This server does not support case alerts.")); ui_casing_supported_lbl->setText(
tr("This server does not support case alerts."));
ui_casing_supported_lbl->setToolTip(tr("Pretty self-explanatory.")); ui_casing_supported_lbl->setToolTip(tr("Pretty self-explanatory."));
ui_casing_layout->setWidget(0, QFormLayout::FieldRole, ui_casing_supported_lbl); ui_casing_layout->setWidget(0, QFormLayout::FieldRole,
ui_casing_supported_lbl);
// -- CASE ANNOUNCEMENTS // -- CASE ANNOUNCEMENTS
ui_casing_enabled_lbl = new QLabel(ui_casing_widget); ui_casing_enabled_lbl = new QLabel(ui_casing_widget);
ui_casing_enabled_lbl->setText(tr("Casing:")); ui_casing_enabled_lbl->setText(tr("Casing:"));
ui_casing_enabled_lbl->setToolTip(tr("If checked, you will get alerts about case " ui_casing_enabled_lbl->setToolTip(
tr("If checked, you will get alerts about case "
"announcements.")); "announcements."));
ui_casing_layout->setWidget(1, QFormLayout::LabelRole, ui_casing_enabled_lbl); ui_casing_layout->setWidget(1, QFormLayout::LabelRole, ui_casing_enabled_lbl);
@ -424,7 +472,8 @@ AOOptionsDialog::AOOptionsDialog(QWidget *parent, AOApplication *p_ao_app) : QDi
ui_casing_pro_lbl = new QLabel(ui_casing_widget); ui_casing_pro_lbl = new QLabel(ui_casing_widget);
ui_casing_pro_lbl->setText(tr("Prosecution:")); ui_casing_pro_lbl->setText(tr("Prosecution:"));
ui_casing_pro_lbl->setToolTip(tr("If checked, you will get alerts about case " ui_casing_pro_lbl->setToolTip(
tr("If checked, you will get alerts about case "
"announcements if a prosecutor spot is open.")); "announcements if a prosecutor spot is open."));
ui_casing_layout->setWidget(3, QFormLayout::LabelRole, ui_casing_pro_lbl); ui_casing_layout->setWidget(3, QFormLayout::LabelRole, ui_casing_pro_lbl);
@ -466,7 +515,8 @@ AOOptionsDialog::AOOptionsDialog(QWidget *parent, AOApplication *p_ao_app) : QDi
ui_casing_steno_lbl = new QLabel(ui_casing_widget); ui_casing_steno_lbl = new QLabel(ui_casing_widget);
ui_casing_steno_lbl->setText(tr("Stenographer:")); ui_casing_steno_lbl->setText(tr("Stenographer:"));
ui_casing_steno_lbl->setToolTip(tr("If checked, you will get alerts about case " ui_casing_steno_lbl->setToolTip(
tr("If checked, you will get alerts about case "
"announcements if a stenographer spot is open.")); "announcements if a stenographer spot is open."));
ui_casing_layout->setWidget(6, QFormLayout::LabelRole, ui_casing_steno_lbl); ui_casing_layout->setWidget(6, QFormLayout::LabelRole, ui_casing_steno_lbl);
@ -480,7 +530,8 @@ AOOptionsDialog::AOOptionsDialog(QWidget *parent, AOApplication *p_ao_app) : QDi
ui_casing_cm_lbl = new QLabel(ui_casing_widget); ui_casing_cm_lbl = new QLabel(ui_casing_widget);
ui_casing_cm_lbl->setText(tr("CM:")); ui_casing_cm_lbl->setText(tr("CM:"));
ui_casing_cm_lbl->setToolTip(tr("If checked, you will appear amongst the potential " ui_casing_cm_lbl->setToolTip(
tr("If checked, you will appear amongst the potential "
"CMs on the server.")); "CMs on the server."));
ui_casing_layout->setWidget(7, QFormLayout::LabelRole, ui_casing_cm_lbl); ui_casing_layout->setWidget(7, QFormLayout::LabelRole, ui_casing_cm_lbl);
@ -492,7 +543,8 @@ AOOptionsDialog::AOOptionsDialog(QWidget *parent, AOApplication *p_ao_app) : QDi
ui_casing_wit_lbl = new QLabel(ui_casing_widget); ui_casing_wit_lbl = new QLabel(ui_casing_widget);
ui_casing_wit_lbl->setText(tr("Witness:")); ui_casing_wit_lbl->setText(tr("Witness:"));
ui_casing_wit_lbl->setToolTip(tr("If checked, you will appear amongst the potential " ui_casing_wit_lbl->setToolTip(
tr("If checked, you will appear amongst the potential "
"witnesses on the server.")); "witnesses on the server."));
ui_casing_layout->setWidget(8, QFormLayout::LabelRole, ui_casing_wit_lbl); ui_casing_layout->setWidget(8, QFormLayout::LabelRole, ui_casing_wit_lbl);
@ -506,15 +558,100 @@ AOOptionsDialog::AOOptionsDialog(QWidget *parent, AOApplication *p_ao_app) : QDi
ui_casing_cm_cases_lbl = new QLabel(ui_casing_widget); ui_casing_cm_cases_lbl = new QLabel(ui_casing_widget);
ui_casing_cm_cases_lbl->setText(tr("Hosting cases:")); ui_casing_cm_cases_lbl->setText(tr("Hosting cases:"));
ui_casing_cm_cases_lbl->setToolTip(tr("If you're a CM, enter what cases you are " ui_casing_cm_cases_lbl->setToolTip(
tr("If you're a CM, enter what cases you are "
"willing to host.")); "willing to host."));
ui_casing_layout->setWidget(9, QFormLayout::LabelRole, ui_casing_cm_cases_lbl); ui_casing_layout->setWidget(9, QFormLayout::LabelRole,
ui_casing_cm_cases_lbl);
ui_casing_cm_cases_textbox = new QLineEdit(ui_casing_widget); ui_casing_cm_cases_textbox = new QLineEdit(ui_casing_widget);
ui_casing_cm_cases_textbox->setText(ao_app->get_casing_can_host_cases()); ui_casing_cm_cases_textbox->setText(ao_app->get_casing_can_host_cases());
ui_casing_layout->setWidget(9, QFormLayout::FieldRole, ui_casing_cm_cases_textbox); ui_casing_layout->setWidget(9, QFormLayout::FieldRole,
ui_casing_cm_cases_textbox);
// ICLOG
ui_other_tab = new QWidget();
ui_settings_tabs->addTab(ui_other_tab, tr("IC_Log"));
ui_other_widget = new QWidget(ui_other_tab);
ui_other_widget->setGeometry(QRect(10, 10, 361, 211));
ui_other_layout = new QFormLayout(ui_other_widget);
ui_other_layout->setLabelAlignment(Qt::AlignLeading | Qt::AlignLeft |
Qt::AlignVCenter);
ui_other_layout->setFormAlignment(Qt::AlignLeading | Qt::AlignLeft |
Qt::AlignTop);
ui_other_layout->setContentsMargins(0, 0, 0, 0);
ui_other_fancy_icl_enabled_lb = new QLabel(ui_other_widget);
ui_other_fancy_icl_enabled_lb->setText(tr("Colorful IC log:"));
ui_other_fancy_icl_enabled_lb->setToolTip(
tr("Enables colored text in the log."));
ui_other_layout->setWidget(1, QFormLayout::LabelRole,
ui_other_fancy_icl_enabled_lb);
ui_other_fancy_icl_enabled_cb = new QCheckBox(ui_other_widget);
ui_other_fancy_icl_enabled_cb->setChecked(
ao_app->get_colored_iclog_enabled());
ui_other_layout->setWidget(1, QFormLayout::FieldRole,
ui_other_fancy_icl_enabled_cb);
ui_other_fancy_icl_limit_lb = new QLabel(ui_other_widget);
ui_other_fancy_icl_limit_lb->setText(tr("Only inline coloring:"));
ui_other_fancy_icl_limit_lb->setToolTip(
tr("Only inline coloring will be shown such as <>,|| etc"));
ui_other_layout->setWidget(2, QFormLayout::LabelRole,
ui_other_fancy_icl_limit_lb);
ui_other_fancy_icl_limit_cb = new QCheckBox(ui_other_widget);
ui_other_fancy_icl_limit_cb->setChecked(
ao_app->colorlog_restricted_enabled());
ui_other_layout->setWidget(2, QFormLayout::FieldRole,
ui_other_fancy_icl_limit_cb);
ui_other_mirror_icl_enabled_lb = new QLabel(ui_other_widget);
ui_other_mirror_icl_enabled_lb->setText(tr("Mirror IC log:"));
ui_other_mirror_icl_enabled_lb->setToolTip(
tr("IC log will mirror the IC box. "
"Meaning that if somebody gets interupted nobody will know what they "
"wanted to say. "
"Enable for a more realistic expierence"));
ui_other_layout->setWidget(3, QFormLayout::LabelRole,
ui_other_mirror_icl_enabled_lb);
ui_other_mirror_icl_enabled_cb = new QCheckBox(ui_other_widget);
ui_other_mirror_icl_enabled_cb->setChecked(ao_app->get_iclmir_enabled());
ui_other_layout->setWidget(3, QFormLayout::FieldRole,
ui_other_mirror_icl_enabled_cb);
ui_downwards_lbl = new QLabel(ui_other_widget);
ui_downwards_lbl->setText(tr("Log goes downwards:"));
ui_downwards_lbl->setToolTip(
tr("If ticked, new messages will appear at "
"the bottom (like the OOC chatlog). The traditional "
"(AO1) behaviour is equivalent to this being unticked."));
ui_other_layout->setWidget(4, QFormLayout::LabelRole, ui_downwards_lbl);
ui_downwards_cb = new QCheckBox(ui_other_widget);
ui_downwards_cb->setChecked(p_ao_app->get_log_goes_downwards());
ui_other_layout->setWidget(4, QFormLayout::FieldRole, ui_downwards_cb);
ui_length_lbl = new QLabel(ui_other_widget);
ui_length_lbl->setText(tr("Log length:"));
ui_length_lbl->setToolTip(tr(
"The amount of messages the IC chatlog will keep before "
"deleting older messages. A value of 0 or below counts as 'infinite'."));
ui_other_layout->setWidget(5, QFormLayout::LabelRole, ui_length_lbl);
ui_length_spinbox = new QSpinBox(ui_other_widget);
ui_length_spinbox->setMaximum(10000);
ui_length_spinbox->setValue(p_ao_app->get_max_log_size());
ui_other_layout->setWidget(5, QFormLayout::FieldRole, ui_length_spinbox);
// When we're done, we should continue the updates! // When we're done, we should continue the updates!
setUpdatesEnabled(true); setUpdatesEnabled(true);
@ -523,7 +660,7 @@ AOOptionsDialog::AOOptionsDialog(QWidget *parent, AOApplication *p_ao_app) : QDi
void AOOptionsDialog::save_pressed() void AOOptionsDialog::save_pressed()
{ {
// Save everything into the config.ini. // Save everything into the config.ini.
QSettings* configini = ao_app->configini; QSettings *configini = ao_app->configini;
configini->setValue("theme", ui_theme_combobox->currentText()); configini->setValue("theme", ui_theme_combobox->currentText());
configini->setValue("log_goes_downwards", ui_downwards_cb->isChecked()); configini->setValue("log_goes_downwards", ui_downwards_cb->isChecked());
@ -534,21 +671,22 @@ void AOOptionsDialog::save_pressed()
configini->setValue("discord", ui_discord_cb->isChecked()); configini->setValue("discord", ui_discord_cb->isChecked());
configini->setValue("shakeandflash", ui_epilepsy_cb->isChecked()); configini->setValue("shakeandflash", ui_epilepsy_cb->isChecked());
configini->setValue("language", ui_language_combobox->currentText().left(2)); configini->setValue("language", ui_language_combobox->currentText().left(2));
configini->setValue("punctuation_delay", ui_pun_delay_spinbox->value());
configini->setValue("keep_evidence", ui_keepevi_cb->isChecked());
QFile *callwordsini = new QFile(ao_app->get_base_path() + "callwords.ini");
QFile* callwordsini = new QFile(ao_app->get_base_path() + "callwords.ini"); if (!callwordsini->open(QIODevice::WriteOnly | QIODevice::Truncate |
QIODevice::Text)) {
if (!callwordsini->open(QIODevice::WriteOnly | QIODevice::Truncate | QIODevice::Text))
{
// Nevermind! // Nevermind!
} }
else else {
{
QTextStream out(callwordsini); QTextStream out(callwordsini);
out << ui_callwords_textbox->toPlainText(); out << ui_callwords_textbox->toPlainText();
callwordsini->close(); callwordsini->close();
} }
configini->setValue("default_audio_device", ui_audio_device_combobox->currentText()); configini->setValue("default_audio_device",
ui_audio_device_combobox->currentText());
configini->setValue("default_music", ui_music_volume_spinbox->value()); configini->setValue("default_music", ui_music_volume_spinbox->value());
configini->setValue("default_sfx", ui_sfx_volume_spinbox->value()); configini->setValue("default_sfx", ui_sfx_volume_spinbox->value());
configini->setValue("default_blip", ui_blips_volume_spinbox->value()); configini->setValue("default_blip", ui_blips_volume_spinbox->value());
@ -559,38 +697,35 @@ void AOOptionsDialog::save_pressed()
configini->setValue("casing_enabled", ui_casing_enabled_cb->isChecked()); configini->setValue("casing_enabled", ui_casing_enabled_cb->isChecked());
configini->setValue("casing_defence_enabled", ui_casing_def_cb->isChecked()); configini->setValue("casing_defence_enabled", ui_casing_def_cb->isChecked());
configini->setValue("casing_prosecution_enabled", ui_casing_pro_cb->isChecked()); configini->setValue("casing_prosecution_enabled",
ui_casing_pro_cb->isChecked());
configini->setValue("casing_judge_enabled", ui_casing_jud_cb->isChecked()); configini->setValue("casing_judge_enabled", ui_casing_jud_cb->isChecked());
configini->setValue("casing_juror_enabled", ui_casing_jur_cb->isChecked()); configini->setValue("casing_juror_enabled", ui_casing_jur_cb->isChecked());
configini->setValue("casing_steno_enabled", ui_casing_steno_cb->isChecked()); configini->setValue("casing_steno_enabled", ui_casing_steno_cb->isChecked());
configini->setValue("casing_cm_enabled", ui_casing_cm_cb->isChecked()); configini->setValue("casing_cm_enabled", ui_casing_cm_cb->isChecked());
configini->setValue("casing_wit_enabled", ui_casing_wit_cb->isChecked()); configini->setValue("casing_wit_enabled", ui_casing_wit_cb->isChecked());
configini->setValue("casing_can_host_cases", ui_casing_cm_cases_textbox->text()); configini->setValue("casing_can_host_cases",
ui_casing_cm_cases_textbox->text());
configini->setValue("color_iclog_enabled",
ui_other_fancy_icl_enabled_cb->isChecked());
configini->setValue("mirror_iclog_enabled",
ui_other_mirror_icl_enabled_cb->isChecked());
configini->setValue("mirror_iclog_restricted",
ui_other_fancy_icl_limit_cb->isChecked());
callwordsini->close(); callwordsini->close();
done(0); done(0);
} }
void AOOptionsDialog::discard_pressed() void AOOptionsDialog::discard_pressed() { done(0); }
{
done(0);
}
#if (defined (_WIN32) || defined (_WIN64)) #if (defined(_WIN32) || defined(_WIN64))
bool AOOptionsDialog::needs_default_audiodev() bool AOOptionsDialog::needs_default_audiodev() { return true; }
{ #elif (defined(LINUX) || defined(__linux__))
return true; bool AOOptionsDialog::needs_default_audiodev() { return false; }
}
#elif (defined (LINUX) || defined (__linux__))
bool AOOptionsDialog::needs_default_audiodev()
{
return false;
}
#elif defined __APPLE__ #elif defined __APPLE__
bool AOOptionsDialog::needs_default_audiodev() bool AOOptionsDialog::needs_default_audiodev() { return true; }
{
return true;
}
#else #else
#error This operating system is not supported. #error This operating system is not supported.
#endif #endif

View File

@ -7,16 +7,19 @@ AOScene::AOScene(QWidget *parent, AOApplication *p_ao_app) : QLabel(parent)
m_parent = parent; m_parent = parent;
ao_app = p_ao_app; ao_app = p_ao_app;
m_movie = new QMovie(this); m_movie = new QMovie(this);
last_image = "";
} }
void AOScene::set_image(QString p_image) void AOScene::set_image(QString p_image)
{ {
QString background_path = ao_app->get_background_path(p_image + ".png"); QString background_path =
QString animated_background_path = ao_app->get_background_path(p_image + ".gif"); ao_app->get_image_suffix(ao_app->get_background_path(p_image));
QString default_path = ao_app->get_default_background_path(p_image + ".png"); if (!file_exists(background_path))
background_path = ao_app->get_image_suffix(
ao_app->get_default_background_path(p_image)); // Default path
QPixmap background(background_path); if (file_exists(background_path) && background_path == last_image)
QPixmap default_bg(default_path); return;
int w = this->width(); int w = this->width();
int h = this->height(); int h = this->height();
@ -25,52 +28,58 @@ void AOScene::set_image(QString p_image)
this->setMovie(nullptr); this->setMovie(nullptr);
m_movie->stop(); m_movie->stop();
m_movie->setFileName(animated_background_path); m_movie->setFileName(background_path);
m_movie->setScaledSize(QSize(w, h)); m_movie->setScaledSize(QSize(w, h));
if (m_movie->isValid()) if (m_movie->isValid()) {
{
this->setMovie(m_movie); this->setMovie(m_movie);
m_movie->start(); m_movie->start();
} }
else if (file_exists(background_path)) else {
{ QPixmap background(background_path);
this->setPixmap(background.scaled(w, h)); this->setPixmap(background.scaled(w, h));
} }
else last_image = background_path;
{
this->setPixmap(default_bg.scaled(w, h));
}
} }
void AOScene::set_legacy_desk(QString p_image) void AOScene::set_legacy_desk(QString p_image)
{ {
//vanilla desks vary in both width and height. in order to make that work with viewport rescaling,
//some INTENSE math is needed.
QString desk_path = ao_app->get_background_path(p_image); QString desk_path =
QString default_path = ao_app->get_default_background_path(p_image); ao_app->get_image_suffix(ao_app->get_background_path(p_image));
if (!file_exists(desk_path))
desk_path = ao_app->get_image_suffix(
ao_app->get_default_background_path(p_image)); // Default path
QPixmap f_desk; if (file_exists(desk_path) && desk_path == last_image)
return;
QPixmap f_desk(desk_path);
if (file_exists(desk_path)) // vanilla desks vary in both width and height. in order to make that work
f_desk.load(desk_path); // with viewport rescaling, some INTENSE math is needed.
else
f_desk.load(default_path);
int vp_width = m_parent->width(); int vp_width = m_parent->width();
int vp_height = m_parent->height(); int vp_height = m_parent->height();
//double y_modifier = 147 / 192;
//double w_modifier = vp_width / 256;
double h_modifier = vp_height / 192; double h_modifier = vp_height / 192;
//int final_y = y_modifier * vp_height;
//int final_w = w_modifier * f_desk.width();
int final_h = static_cast<int>(h_modifier * f_desk.height()); int final_h = static_cast<int>(h_modifier * f_desk.height());
//this->resize(final_w, final_h); this->clear();
//this->setPixmap(f_desk.scaled(final_w, final_h)); this->setMovie(nullptr);
m_movie->stop();
m_movie->setFileName(desk_path);
m_movie->setScaledSize(QSize(vp_width, final_h));
if (m_movie->isValid()) {
this->setMovie(m_movie);
m_movie->start();
}
else {
this->resize(vp_width, final_h); this->resize(vp_width, final_h);
this->setPixmap(f_desk.scaled(vp_width, final_h)); this->setPixmap(f_desk.scaled(vp_width, final_h));
}
last_image = desk_path;
} }

View File

@ -5,7 +5,8 @@ AOTextArea::AOTextArea(QWidget *p_parent) : QTextBrowser(p_parent)
} }
void AOTextArea::append_chatmessage(QString p_name, QString p_message, QString p_colour) void AOTextArea::append_chatmessage(QString p_name, QString p_message,
QString p_colour, bool song)
{ {
const QTextCursor old_cursor = this->textCursor(); const QTextCursor old_cursor = this->textCursor();
const int old_scrollbar_value = this->verticalScrollBar()->value(); const int old_scrollbar_value = this->verticalScrollBar()->value();
@ -14,7 +15,12 @@ void AOTextArea::append_chatmessage(QString p_name, QString p_message, QString p
this->moveCursor(QTextCursor::End); this->moveCursor(QTextCursor::End);
this->append(""); this->append("");
this->insertHtml("<b><font color=" + p_colour + ">" + p_name.toHtmlEscaped() + "</font></b>:&nbsp;"); if (song)
this->insertHtml("<b><font color=" + p_colour + ">" +
p_name.toHtmlEscaped() + "</font></b>&nbsp;");
else
this->insertHtml("<b><font color=" + p_colour + ">" +
p_name.toHtmlEscaped() + "</font></b>:&nbsp;");
//cheap workarounds ahoy //cheap workarounds ahoy
p_message += " "; p_message += " ";

View File

@ -11,41 +11,38 @@ public:
Courtroom *thisCourtroom; Courtroom *thisCourtroom;
int char_num; int char_num;
AOCharButton *char_button; AOCharButton *char_button;
AOCharSelectGenerationThreading(Courtroom *my_courtroom, int character_number, AOCharButton *charbut){ AOCharSelectGenerationThreading(Courtroom *my_courtroom, int character_number)
{
thisCourtroom = my_courtroom; thisCourtroom = my_courtroom;
char_num = character_number; char_num = character_number;
char_button = charbut;
} }
void run() void run()
{ {
AOCharButton* thisCharacterButton = char_button; // we take the button we are supposed to mess with, and not whatever comes
// first
AOCharButton *thisCharacterButton =
thisCourtroom->ui_char_button_list.at(char_num);
thisCharacterButton->reset(); thisCharacterButton->reset();
thisCharacterButton->hide(); thisCharacterButton->hide();
thisCharacterButton->set_image(thisCourtroom->char_list.at(char_num).name); thisCharacterButton->set_image(thisCourtroom->char_list.at(char_num).name);
thisCourtroom->ui_char_button_list.append(thisCharacterButton);
thisCourtroom->connect(thisCharacterButton, SIGNAL(clicked()), thisCourtroom->char_button_mapper, SLOT(map())); thisCourtroom->connect(thisCharacterButton, SIGNAL(clicked()),
thisCourtroom->char_button_mapper->setMapping(thisCharacterButton, thisCourtroom->ui_char_button_list.size() - 1); thisCourtroom->char_button_mapper, SLOT(map()));
thisCourtroom->char_button_mapper->setMapping(thisCharacterButton,
char_num);
} }
}; };
class AOCharSelectFilterThreading : public QRunnable void AOCharSelectFilter(Courtroom *thisCourtroom, int char_num)
{ {
public: AOCharButton *current_char = thisCourtroom->ui_char_button_list.at(char_num);
Courtroom *thisCourtroom;
int char_num;
AOCharSelectFilterThreading(Courtroom *my_courtroom, int character_number){
thisCourtroom = my_courtroom;
char_num = character_number;
}
void run()
{
AOCharButton* current_char = thisCourtroom->ui_char_button_list.at(char_num);
if (!thisCourtroom->ui_char_taken->isChecked() && thisCourtroom->char_list.at(char_num).taken) if (!thisCourtroom->ui_char_taken->isChecked() &&
thisCourtroom->char_list.at(char_num).taken)
return; return;
if (!thisCourtroom->char_list.at(char_num).name.contains(thisCourtroom->ui_char_search->text(), Qt::CaseInsensitive)) if (!thisCourtroom->char_list.at(char_num).name.contains(
thisCourtroom->ui_char_search->text(), Qt::CaseInsensitive))
return; return;
// We only really need to update the fact that a character is taken // We only really need to update the fact that a character is taken
@ -55,8 +52,7 @@ public:
current_char->set_taken(thisCourtroom->char_list.at(char_num).taken); current_char->set_taken(thisCourtroom->char_list.at(char_num).taken);
thisCourtroom->ui_char_button_list_filtered.append(current_char); thisCourtroom->ui_char_button_list_filtered.append(current_char);
} }
};
void Courtroom::construct_char_select() void Courtroom::construct_char_select()
{ {
@ -247,15 +243,23 @@ void Courtroom::character_loading_finished()
} }
// First, we'll make all the character buttons in the very beginning. // 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,
// we assign the buttons their locations in the list according to the
// character list.
for (int n = 0; n < char_list.size(); n++) {
AOCharButton *characterButton =
new AOCharButton(ui_char_buttons, ao_app, 0, 0, char_list.at(n).taken);
ui_char_button_list.append(characterButton);
}
// We also hide them all, so they can't be accidentally clicked. // We also hide them all, so they can't be accidentally clicked.
// Later on, we'll be revealing buttons as we need them. // Later on, we'll be revealing buttons as we need them.
for (int n = 0; n < char_list.size(); n++) for (int n = 0; n < char_list.size(); n++) {
{ AOCharSelectGenerationThreading *char_generate =
AOCharButton* characterButton = new AOCharButton(ui_char_buttons, ao_app, 0, 0, char_list.at(n).taken); new AOCharSelectGenerationThreading(this, n);
AOCharSelectGenerationThreading *char_generate = new AOCharSelectGenerationThreading(this, n, characterButton);
QThreadPool::globalInstance()->start(char_generate); QThreadPool::globalInstance()->start(char_generate);
if(QThreadPool::globalInstance()->activeThreadCount() == QThreadPool::globalInstance()->maxThreadCount()) if (QThreadPool::globalInstance()->activeThreadCount() ==
{ QThreadPool::globalInstance()->maxThreadCount()) {
QThreadPool::globalInstance()->waitForDone(); QThreadPool::globalInstance()->waitForDone();
} }
} }
@ -266,16 +270,9 @@ void Courtroom::character_loading_finished()
void Courtroom::filter_character_list() void Courtroom::filter_character_list()
{ {
ui_char_button_list_filtered.clear(); ui_char_button_list_filtered.clear();
for (int i = 0; i < char_list.size(); i++) for (int i = 0; i < char_list.size(); i++) {
{ AOCharSelectFilter(this, i);
AOCharSelectFilterThreading *char_filter = new AOCharSelectFilterThreading(this, i);
QThreadPool::globalInstance()->start(char_filter);
if(QThreadPool::globalInstance()->activeThreadCount() == QThreadPool::globalInstance()->maxThreadCount())
{
QThreadPool::globalInstance()->waitForDone();
} }
}
QThreadPool::globalInstance()->waitForDone();
current_char_page = 0; current_char_page = 0;
set_char_select_page(); set_char_select_page();

View File

@ -5,25 +5,31 @@ chatlogpiece::chatlogpiece()
name = "UNKNOWN"; name = "UNKNOWN";
showname = "UNKNOWN"; showname = "UNKNOWN";
message = "UNKNOWN"; message = "UNKNOWN";
color = 0;
is_song = false; is_song = false;
datetime = QDateTime::currentDateTime().toUTC(); datetime = QDateTime::currentDateTime().toUTC();
} }
chatlogpiece::chatlogpiece(QString p_name, QString p_showname, QString p_message, bool p_song) chatlogpiece::chatlogpiece(QString p_name, QString p_showname,
QString p_message, bool p_song, int p_color)
{ {
name = p_name; name = p_name;
showname = p_showname; showname = p_showname;
message = p_message; message = p_message;
is_song = p_song; is_song = p_song;
color = p_color;
datetime = QDateTime::currentDateTime().toUTC(); datetime = QDateTime::currentDateTime().toUTC();
} }
chatlogpiece::chatlogpiece(QString p_name, QString p_showname, QString p_message, bool p_song, QDateTime p_datetime) chatlogpiece::chatlogpiece(QString p_name, QString p_showname,
QString p_message, bool p_song, int p_color,
QDateTime p_datetime)
{ {
name = p_name; name = p_name;
showname = p_showname; showname = p_showname;
message = p_message; message = p_message;
is_song = p_song; is_song = p_song;
color = p_color;
datetime = p_datetime.toUTC(); datetime = p_datetime.toUTC();
} }
@ -57,6 +63,7 @@ QString chatlogpiece::get_datetime_as_string()
return datetime.toString(); return datetime.toString();
} }
int chatlogpiece::get_chat_color() { return color; }
QString chatlogpiece::get_full() QString chatlogpiece::get_full()
{ {

File diff suppressed because it is too large Load Diff

View File

@ -272,17 +272,19 @@ void Lobby::on_connect_released()
void Lobby::on_about_clicked() void Lobby::on_about_clicked()
{ {
QString msg = tr("<h2>Attorney Online %1</h2>" QString msg =
tr("<h2>Attorney Online %1</h2>"
"The courtroom drama simulator" "The courtroom drama simulator"
"<p><b>Source code:</b> " "<p><b>Source code:</b> "
"<a href='https://github.com/AttorneyOnline/AO2-Client'>" "<a href='https://github.com/AttorneyOnline/AO2-Client'>"
"https://github.com/AttorneyOnline/AO2-Client</a>" "https://github.com/AttorneyOnline/AO2-Client</a>"
"<p><b>Major development:</b><br>" "<p><b>Major development:</b><br>"
"OmniTroid, stonedDiscord, longbyte1, gameboyprinter, Cerapter" "OmniTroid, stonedDiscord, longbyte1, gameboyprinter, Cerapter, "
"Cents02"
"<p><b>Special thanks:</b><br>" "<p><b>Special thanks:</b><br>"
"Remy, Iamgoofball, Hibiki, Qubrick (webAO), Ruekasu (UI design), " "Remy, Iamgoofball, Hibiki, Qubrick (webAO), Ruekasu (UI design), "
"Draxirch (UI design), Unishred, Argoneus (tsuserver), Fiercy, " "Draxirch (UI design), Unishred, Argoneus (tsuserver), Fiercy, "
"Noevain, Cronnicossy") "Noevain, Cronnicossy, Raidensnake")
.arg(ao_app->get_version_string()); .arg(ao_app->get_version_string());
QMessageBox::about(this, "About", msg); QMessageBox::about(this, "About", msg);
} }
@ -380,7 +382,10 @@ void Lobby::list_favorites()
void Lobby::append_chatmessage(QString f_name, QString f_message) 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()); 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) void Lobby::append_error(QString f_message)

View File

@ -7,34 +7,19 @@
#include "hardware_functions.h" #include "hardware_functions.h"
#include "debug_functions.h" #include "debug_functions.h"
class AOPacketLoadMusicThreading : public QRunnable void AOPacketLoadMusic(AOApplication *my_app, QString file_name, bool is_music)
{
public:
AOApplication *myapp;
QString filename;
bool ismusic;
AOPacketLoadMusicThreading(AOApplication *my_app, QString file_name, bool is_music){
myapp = my_app;
filename = file_name;
ismusic = is_music;
}
void run()
{ {
if(ismusic) if (is_music) {
{ my_app->w_courtroom->append_music(file_name);
myapp->w_courtroom->append_music(filename);
} }
else else {
{ my_app->w_courtroom->append_area(file_name);
myapp->w_courtroom->append_area(filename); my_app->area_count++;
myapp->area_count++;
} }
for (int area_n = 0; area_n < myapp->area_count; area_n++) for (int area_n = 0; area_n < my_app->area_count; area_n++) {
{ my_app->w_courtroom->arup_append(0, "Unknown", "Unknown", "Unknown");
myapp->w_courtroom->arup_append(0, "Unknown", "Unknown", "Unknown");
} }
} }
};
void AOApplication::ms_packet_received(AOPacket *p_packet) void AOApplication::ms_packet_received(AOPacket *p_packet)
{ {
@ -438,26 +423,6 @@ void AOApplication::server_packet_received(AOPacket *p_packet)
w_lobby->set_loading_text(tr("Loading music:\n%1/%2").arg(QString::number(loaded_music)).arg(QString::number(music_list_size))); w_lobby->set_loading_text(tr("Loading music:\n%1/%2").arg(QString::number(loaded_music)).arg(QString::number(music_list_size)));
if (musiclist_start)
{
w_courtroom->append_music(f_music);
}
else
{
if (is_music_track(f_music))
{
musiclist_start = true;
areas--;
//w_courtroom->fix_last_area();
w_courtroom->append_music(f_music);
}
else
{
w_courtroom->append_area(f_music);
areas++;
}
}
for (int area_n = 0; area_n < areas; area_n++) for (int area_n = 0; area_n < areas; area_n++)
{ {
w_courtroom->arup_append(0, "Unknown", "Unknown", "Unknown"); w_courtroom->arup_append(0, "Unknown", "Unknown", "Unknown");
@ -515,38 +480,43 @@ void AOApplication::server_packet_received(AOPacket *p_packet)
send_server_packet(new AOPacket("RM#%")); send_server_packet(new AOPacket("RM#%"));
} }
else if (header == "SM" || header == "FM")
{ else if (header == "SM") {
if (!courtroom_constructed) if (!courtroom_constructed)
goto end; goto end;
w_courtroom->clear_music(); bool musics_time = false;
w_courtroom->clear_areas();
bool musiclist_start = false;
area_count = 0; area_count = 0;
for (int n_element = 0 ; n_element < f_contents.size() ; ++n_element) for (int n_element = 0; n_element < f_contents.size(); ++n_element) {
{ int element2check = n_element + 1;
if (!musiclist_start && is_music_track(f_contents.at(n_element))) if (element2check > f_contents.size()) {
{ element2check = n_element; // I know this is very lazy code but cba
musiclist_start = true;
continue;
} }
AOPacketLoadMusicThreading *music_load = new AOPacketLoadMusicThreading(this, f_contents.at(n_element), musiclist_start); if (!musics_time && (f_contents.at(n_element).startsWith("==") ||
QThreadPool::globalInstance()->start(music_load); f_contents.at(element2check).endsWith(".wav") ||
f_contents.at(element2check).endsWith(".mp3") ||
f_contents.at(element2check).endsWith(".mp4") ||
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 total_loading_size =
int loading_value = int(((loaded_chars + generated_chars + loaded_music + loaded_evidence) / static_cast<double>(total_loading_size)) * 100); 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))); w_lobby->set_loading_text(tr("Loading music:\n%1/%2")
if(QThreadPool::globalInstance()->activeThreadCount() == QThreadPool::globalInstance()->maxThreadCount()) .arg(QString::number(loaded_music))
{ .arg(QString::number(music_list_size)));
QThreadPool::globalInstance()->waitForDone(); //out of order music is bad
} }
}
QThreadPool::globalInstance()->waitForDone();
if (header == "SM")
send_server_packet(new AOPacket("RD#%")); send_server_packet(new AOPacket("RD#%"));
} }
else if (header == "DONE") else if (header == "DONE")
@ -761,6 +731,7 @@ void AOApplication::send_server_packet(AOPacket *p_packet, bool encoded)
} }
else else
{ {
qDebug() << "S:" << f_packet;
#ifdef DEBUG_NETWORK #ifdef DEBUG_NETWORK
qDebug() << "S:" << f_packet; qDebug() << "S:" << f_packet;
#endif #endif

View File

@ -125,6 +125,7 @@ QString AOApplication::get_music_path(QString p_song)
} }
#ifndef CASE_SENSITIVE_FILESYSTEM #ifndef CASE_SENSITIVE_FILESYSTEM
return get_base_path() + "sounds/music/" + p_song + ".wav"; return get_base_path() + "sounds/music/" + p_song + ".wav";
;
#else #else
return get_case_sensitive_path(get_base_path() + "sounds/music/" + p_song + ".wav"); return get_case_sensitive_path(get_base_path() + "sounds/music/" + p_song + ".wav");
#endif #endif

View File

@ -46,6 +46,15 @@ int AOApplication::get_max_log_size()
return result; return result;
} }
int AOApplication::get_pundelay()
{
int result = configini->value("punctuation_delay", 2).toInt();
if (result < 1 || result > 3) {
result = 2;
}
return result;
}
bool AOApplication::get_log_goes_downwards() bool AOApplication::get_log_goes_downwards()
{ {
QString result = configini->value("log_goes_downwards", "false").value<QString>(); QString result = configini->value("log_goes_downwards", "false").value<QString>();
@ -154,6 +163,26 @@ QString AOApplication::read_design_ini(QString p_identifier, QString p_design_pa
{ {
QSettings settings(p_design_path, QSettings::IniFormat); QSettings settings(p_design_path, QSettings::IniFormat);
QVariant value = settings.value(p_identifier); QVariant value = settings.value(p_identifier);
if (value.isNull()) // Since the value wasn't found, maybe it uses the proper
// config system
{
int last_underscore_index = p_identifier.lastIndexOf(
'_'); // we will use this in order to check wether it is just showname
// or showname_something
if (last_underscore_index != -1) {
p_identifier.replace(
last_underscore_index, 1,
'/'); // we replace the last dash in order to access the category, e.g
// from showname_font -> showname/font
value = settings.value(p_identifier);
}
else if (!settings.value(p_identifier + "/size")
.isNull()) // This is to check whether showname/size exists,
// because size is defined as widgetname = x
{
value = settings.value(p_identifier + "/size");
}
}
if (value.type() == QVariant::StringList) { if (value.type() == QVariant::StringList) {
return value.toStringList().join(","); return value.toStringList().join(",");
} else { } else {
@ -368,8 +397,27 @@ QString AOApplication::get_sfx(QString p_identifier)
return return_sfx; return return_sfx;
} }
QString AOApplication::get_music_prefix(QString song_to_check)
{
if (!file_exists(get_music_path(song_to_check))) {
QString mp3_check = get_music_path(song_to_check + ".mp3");
QString opus_check = get_music_path(song_to_check + ".opus");
if (file_exists(opus_check)) {
return song_to_check + ".opus";
}
else if (file_exists(mp3_check)) {
return song_to_check + ".mp3";
}
return song_to_check + ".wav";
}
else {
return 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 mp3_check = get_sounds_path(sound_to_check + ".mp3");
QString opus_check = get_sounds_path(sound_to_check + ".opus"); QString opus_check = get_sounds_path(sound_to_check + ".opus");
if (file_exists(opus_check)) if (file_exists(opus_check))
@ -381,16 +429,21 @@ QString AOApplication::get_sfx_suffix(QString sound_to_check)
return sound_to_check + ".mp3"; return sound_to_check + ".mp3";
} }
return sound_to_check + ".wav"; 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)
{ {
QString apng_check = path_to_check + ".apng"; if (file_exists(path_to_check + ".webp"))
if (file_exists(apng_check)) return path_to_check + ".webp";
{ if (file_exists(path_to_check + ".apng"))
return apng_check; 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";
} }
@ -655,9 +708,9 @@ bool AOApplication::is_discord_enabled()
return result.startsWith("true"); return result.startsWith("true");
} }
bool AOApplication::is_shakeandflash_enabled() bool AOApplication::is_keepevi_enabled()
{ {
QString result = configini->value("shakeandflash", "true").value<QString>(); QString result = configini->value("keep_evidence", "false").value<QString>();
return result.startsWith("true"); return result.startsWith("true");
} }
@ -715,3 +768,29 @@ QString AOApplication::get_casing_can_host_cases()
QString result = configini->value("casing_can_host_cases", "Turnabout Check Your Settings").value<QString>(); QString result = configini->value("casing_can_host_cases", "Turnabout Check Your Settings").value<QString>();
return result; return result;
} }
bool AOApplication::get_colored_iclog_enabled()
{
QString result =
configini->value("color_iclog_enabled", "false").value<QString>();
return result.startsWith("true");
}
bool AOApplication::get_iclmir_enabled()
{
QString result =
configini->value("mirror_iclog_enabled", "false").value<QString>();
return result.startsWith("true");
}
bool AOApplication::colorlog_restricted_enabled()
{
QString result =
configini->value("mirror_iclog_restricted", "false").value<QString>();
return result.startsWith("true");
}
bool AOApplication::is_shakeandflash_enabled()
{
QString result = configini->value("shakeandflash", "true").value<QString>();
return result.startsWith("true");
}