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*
/Attorney_Online_CC_resource.rc
/attorney_online_cc_plugin_import.cpp
*.autosave

View File

@ -182,10 +182,16 @@ public:
// from the config.ini.
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
// may contain, from config.ini.
int get_max_log_size();
// Gets the punctuation delay modifier
int get_pundelay();
// Returns whether the log should go upwards (new behaviour)
// or downwards (vanilla behaviour).
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
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);
//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.
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:
const int RELEASE = 2;
const int MAJOR_VERSION = 7;

View File

@ -15,13 +15,16 @@ public:
AOMovie(QWidget *p_parent, AOApplication *p_ao_app);
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 stop();
private:
QMovie *m_movie;
AOApplication *ao_app;
QTimer *timer;
bool play_once = true;
signals:
@ -29,6 +32,7 @@ signals:
private slots:
void frame_change(int n_frame);
void timer_done();
};
#endif // AOMOVIE_H

View File

@ -51,6 +51,8 @@ private:
QCheckBox *ui_downwards_cb;
QLabel *ui_length_lbl;
QSpinBox *ui_length_spinbox;
QLabel *ui_pun_delay;
QSpinBox *ui_pun_delay_spinbox;
QFrame *ui_log_names_divider;
QLineEdit *ui_username_textbox;
QLabel *ui_username_lbl;
@ -66,6 +68,12 @@ private:
QLabel *ui_language_label;
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_widget;
QVBoxLayout *ui_callwords_layout;
@ -119,7 +127,18 @@ private:
QLabel *ui_casing_cm_cases_lbl;
QLineEdit *ui_casing_cm_cases_textbox;
bool needs_default_audiodev();
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();
signals:

View File

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

View File

@ -12,7 +12,8 @@ class AOTextArea : public QTextBrowser
public:
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);
private:

View File

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

View File

@ -223,15 +223,18 @@ public:
//This function filters out the common CC inline text trickery, for appending to
//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
//this function keeps the chatlog scrolled to the top unless there's text selected
// 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)
//takes in a list where the first element is the song name and the second is the char id of who played it
// prints who played the song to IC chat and plays said song(if found on local
// 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 play_preanim(bool noninterrupting);
@ -251,6 +254,7 @@ public:
void check_connection_received();
void doScreenShake();
void doRealization();
void refresh_iclog(bool skiplast);
~Courtroom();
@ -331,6 +335,8 @@ private:
bool rainbow_appended = 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.
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)
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
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;
QString m_chatmessage[chatmessage_size];
bool chatmessage_is_empty = false;
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
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
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;
// cid and this may differ in cases of ini-editing
QString char_name = "";
int objection_state = 0;
bool keep_custom_objection = false;
QString objection_custom = "";
int realization_state = 0;
int screenshake_state = 0;
int text_color = 0;
@ -429,6 +445,8 @@ private:
//whether the ooc chat is server or master chat, true is server
bool server_ooc = true;
// Is AFK enabled
bool isafk = false;
QString current_background = "default";
AOMusicPlayer *music_player;
@ -454,10 +472,17 @@ private:
AOImage *ui_vp_chatbox;
QLabel *ui_vp_showname;
QTextEdit *ui_vp_message;
AOImage *ui_vp_testimony;
AOImage *ui_vp_realization;
AOMovie *ui_vp_realization;
AOMovie *ui_vp_testimony;
AOMovie *ui_vp_wtce;
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;
@ -466,7 +491,7 @@ private:
QListWidget *ui_mute_list;
QListWidget *ui_area_list;
QListWidget *ui_music_list;
QTreeWidget *ui_music_list;
AOButton *ui_pair_button;
QListWidget *ui_pair_list;
@ -480,6 +505,8 @@ private:
//QLineEdit *ui_area_password;
QLineEdit *ui_music_search;
QString music_search_par = "";
QString area_search_par = "";
QWidget *ui_emotes;
QVector<AOEmoteButton*> ui_emote_list;
@ -527,6 +554,8 @@ private:
AOButton *ui_screenshake;
AOButton *ui_mute;
QMenu *custom_obj_menu;
AOButton *ui_defense_plus;
AOButton *ui_defense_minus;
@ -589,11 +618,6 @@ public slots:
void objection_done();
void preanim_done();
void realization_done();
void show_testimony();
void hide_testimony();
void mod_called(QString p_ip);
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_music_search_keypr();
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 select_emote(int p_id);
@ -641,6 +666,7 @@ private slots:
void on_objection_clicked();
void on_take_that_clicked();
void on_custom_objection_clicked();
void ShowContextMenu(const QPoint &pos);
void on_realization_clicked();
void on_screenshake_clicked();

View File

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

View File

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

View File

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

View File

@ -1,7 +1,7 @@
#include "aomovie.h"
#include "file_functions.h"
#include "courtroom.h"
#include "file_functions.h"
#include "misc_functions.h"
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();
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)
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;
QString gif_path;
QString custom_path;
if (p_gif == "custom")
custom_path = ao_app->get_image_suffix(ao_app->get_character_path(p_char, p_gif));
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
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 custom_theme_path = ao_app->get_custom_theme_path(p_custom_theme, p_gif + ".gif");
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");
QString default_placeholder_path =
ao_app->get_default_theme_path("placeholder.gif");
if (file_exists(custom_path))
gif_path = custom_path;
else if (file_exists(misc_path))
gif_path = misc_path;
else if (file_exists(custom_theme_path))
gif_path = custom_theme_path;
else if (file_exists(theme_path))
gif_path = theme_path;
else if (file_exists(default_theme_path))
gif_path = default_theme_path;
else if (file_exists(placeholder_path))
gif_path = placeholder_path;
else if (file_exists(default_placeholder_path))
gif_path = default_placeholder_path;
else
gif_path = "";
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
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();
m_movie->start();
if (m_movie->frameCount() == 0 && duration > 0)
timer->start(duration);
}
void AOMovie::stop()
@ -70,16 +95,20 @@ void AOMovie::stop()
void AOMovie::frame_change(int n_frame)
{
if (n_frame == (m_movie->frameCount() - 1) && play_once)
{
//we need this or else the last frame wont show
delay(m_movie->nextFrameDelay());
// 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());
}
this->stop();
//signal connected to courtroom object, let it figure out what to do
done();
}
void AOMovie::timer_done()
{
this->stop();
done();
}
void AOMovie::combo_resize(int w, int h)

File diff suppressed because it is too large Load Diff

View File

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

View File

@ -8,55 +8,51 @@
class AOCharSelectGenerationThreading : public QRunnable
{
public:
Courtroom *thisCourtroom;
int char_num;
AOCharButton *char_button;
AOCharSelectGenerationThreading(Courtroom *my_courtroom, int character_number, AOCharButton *charbut){
thisCourtroom = my_courtroom;
char_num = character_number;
char_button = charbut;
}
void run()
{
AOCharButton* thisCharacterButton = char_button;
thisCharacterButton->reset();
thisCharacterButton->hide();
thisCharacterButton->set_image(thisCourtroom->char_list.at(char_num).name);
thisCourtroom->ui_char_button_list.append(thisCharacterButton);
Courtroom *thisCourtroom;
int char_num;
AOCharButton *char_button;
AOCharSelectGenerationThreading(Courtroom *my_courtroom, int character_number)
{
thisCourtroom = my_courtroom;
char_num = character_number;
}
void run()
{
// 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->hide();
thisCharacterButton->set_image(thisCourtroom->char_list.at(char_num).name);
thisCourtroom->connect(thisCharacterButton, SIGNAL(clicked()), thisCourtroom->char_button_mapper, SLOT(map()));
thisCourtroom->char_button_mapper->setMapping(thisCharacterButton, thisCourtroom->ui_char_button_list.size() - 1);
}
thisCourtroom->connect(thisCharacterButton, SIGNAL(clicked()),
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:
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);
AOCharButton *current_char = thisCourtroom->ui_char_button_list.at(char_num);
if (!thisCourtroom->ui_char_taken->isChecked() && thisCourtroom->char_list.at(char_num).taken)
return;
if (!thisCourtroom->ui_char_taken->isChecked() &&
thisCourtroom->char_list.at(char_num).taken)
return;
if (!thisCourtroom->char_list.at(char_num).name.contains(thisCourtroom->ui_char_search->text(), Qt::CaseInsensitive))
return;
if (!thisCourtroom->char_list.at(char_num).name.contains(
thisCourtroom->ui_char_search->text(), Qt::CaseInsensitive))
return;
// We only really need to update the fact that a character is taken
// for the buttons that actually appear.
// You'd also update the passwordedness and etc. here later.
current_char->reset();
current_char->set_taken(thisCourtroom->char_list.at(char_num).taken);
// We only really need to update the fact that a character is taken
// for the buttons that actually appear.
// You'd also update the passwordedness and etc. here later.
current_char->reset();
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()
{
@ -246,39 +242,40 @@ void Courtroom::character_loading_finished()
ui_char_button_list.clear();
}
// First, we'll make all the character buttons in the very beginning.
// We also hide them all, so they can't be accidentally clicked.
// Later on, we'll be revealing buttons as we need them.
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);
AOCharSelectGenerationThreading *char_generate = new AOCharSelectGenerationThreading(this, n, characterButton);
QThreadPool::globalInstance()->start(char_generate);
if(QThreadPool::globalInstance()->activeThreadCount() == QThreadPool::globalInstance()->maxThreadCount())
{
QThreadPool::globalInstance()->waitForDone();
}
// 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.
// Later on, we'll be revealing buttons as we need them.
for (int n = 0; n < char_list.size(); n++) {
AOCharSelectGenerationThreading *char_generate =
new AOCharSelectGenerationThreading(this, n);
QThreadPool::globalInstance()->start(char_generate);
if (QThreadPool::globalInstance()->activeThreadCount() ==
QThreadPool::globalInstance()->maxThreadCount()) {
QThreadPool::globalInstance()->waitForDone();
}
QThreadPool::globalInstance()->waitForDone();
filter_character_list();
}
QThreadPool::globalInstance()->waitForDone();
filter_character_list();
}
void Courtroom::filter_character_list()
{
ui_char_button_list_filtered.clear();
for (int i = 0; i < char_list.size(); 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();
ui_char_button_list_filtered.clear();
for (int i = 0; i < char_list.size(); i++) {
AOCharSelectFilter(this, i);
}
current_char_page = 0;
set_char_select_page();
current_char_page = 0;
set_char_select_page();
}
void Courtroom::on_char_search_changed()

View File

@ -5,25 +5,31 @@ chatlogpiece::chatlogpiece()
name = "UNKNOWN";
showname = "UNKNOWN";
message = "UNKNOWN";
color = 0;
is_song = false;
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;
showname = p_showname;
message = p_message;
is_song = p_song;
color = p_color;
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;
showname = p_showname;
message = p_message;
is_song = p_song;
color = p_color;
datetime = p_datetime.toUTC();
}
@ -57,6 +63,7 @@ QString chatlogpiece::get_datetime_as_string()
return datetime.toString();
}
int chatlogpiece::get_chat_color() { return color; }
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()
{
QString msg = tr("<h2>Attorney Online %1</h2>"
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>"
"OmniTroid, stonedDiscord, longbyte1, gameboyprinter, Cerapter"
"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, "
"Noevain, Cronnicossy")
"Noevain, Cronnicossy, Raidensnake")
.arg(ao_app->get_version_string());
QMessageBox::about(this, "About", msg);
}
@ -380,7 +382,10 @@ void Lobby::list_favorites()
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)

View File

@ -7,34 +7,19 @@
#include "hardware_functions.h"
#include "debug_functions.h"
class AOPacketLoadMusicThreading : public QRunnable
{
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)
void AOPacketLoadMusic(AOApplication *my_app, QString file_name, bool is_music)
{
myapp->w_courtroom->append_music(filename);
if (is_music) {
my_app->w_courtroom->append_music(file_name);
}
else
{
myapp->w_courtroom->append_area(filename);
myapp->area_count++;
else {
my_app->w_courtroom->append_area(file_name);
my_app->area_count++;
}
for (int area_n = 0; area_n < myapp->area_count; area_n++)
{
myapp->w_courtroom->arup_append(0, "Unknown", "Unknown", "Unknown");
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)
{
@ -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)));
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++)
{
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#%"));
}
else if (header == "SM" || header == "FM")
{
else if (header == "SM") {
if (!courtroom_constructed)
goto end;
w_courtroom->clear_music();
w_courtroom->clear_areas();
bool musiclist_start = false;
bool musics_time = false;
area_count = 0;
for (int n_element = 0 ; n_element < f_contents.size() ; ++n_element)
{
if (!musiclist_start && is_music_track(f_contents.at(n_element)))
{
musiclist_start = true;
continue;
for (int n_element = 0; n_element < f_contents.size(); ++n_element) {
int element2check = n_element + 1;
if (element2check > f_contents.size()) {
element2check = n_element; // I know this is very lazy code but cba
}
if (!musics_time && (f_contents.at(n_element).startsWith("==") ||
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;
}
AOPacketLoadMusicThreading *music_load = new AOPacketLoadMusicThreading(this, f_contents.at(n_element), musiclist_start);
QThreadPool::globalInstance()->start(music_load);
// Not everything needs to have a thread.
AOPacketLoadMusic(this, f_contents.at(n_element), musics_time);
++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);
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_text(tr("Loading music:\n%1/%2").arg(QString::number(loaded_music)).arg(QString::number(music_list_size)));
if(QThreadPool::globalInstance()->activeThreadCount() == QThreadPool::globalInstance()->maxThreadCount())
{
QThreadPool::globalInstance()->waitForDone(); //out of order music is bad
}
w_lobby->set_loading_text(tr("Loading music:\n%1/%2")
.arg(QString::number(loaded_music))
.arg(QString::number(music_list_size)));
}
QThreadPool::globalInstance()->waitForDone();
if (header == "SM")
send_server_packet(new AOPacket("RD#%"));
}
else if (header == "DONE")
@ -761,6 +731,7 @@ void AOApplication::send_server_packet(AOPacket *p_packet, bool encoded)
}
else
{
qDebug() << "S:" << f_packet;
#ifdef DEBUG_NETWORK
qDebug() << "S:" << f_packet;
#endif

View File

@ -125,6 +125,7 @@ QString AOApplication::get_music_path(QString p_song)
}
#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

View File

@ -46,6 +46,15 @@ int AOApplication::get_max_log_size()
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()
{
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);
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) {
return value.toStringList().join(",");
} else {
@ -368,8 +397,27 @@ QString AOApplication::get_sfx(QString p_identifier)
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)
{
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))
@ -381,16 +429,21 @@ QString AOApplication::get_sfx_suffix(QString sound_to_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 apng_check = path_to_check + ".apng";
if (file_exists(apng_check))
{
return apng_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 + ".png";
}
@ -655,9 +708,9 @@ bool AOApplication::is_discord_enabled()
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");
}
@ -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>();
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");
}