";
if (!align.isEmpty())
+ {
appendage.prepend("");
+ }
p_text_escaped.insert(check_pos_escaped, appendage);
check_pos_escaped += appendage.size();
@@ -3099,7 +3352,8 @@ QString Courtroom::filter_ic_text(QString p_text, bool html, int target_pos,
// Current issue: does not properly escape html stuff.
// Solution: probably parse p_text and export into a different string
// separately, perform some mumbo jumbo to properly adjust string indexes.
- while (check_pos < p_text.size()) {
+ while (check_pos < p_text.size())
+ {
QString f_rest = p_text.right(p_text.size() - check_pos);
QTextBoundaryFinder tbf(QTextBoundaryFinder::Grapheme, f_rest);
QString f_character;
@@ -3109,9 +3363,13 @@ QString Courtroom::filter_ic_text(QString p_text, bool html, int target_pos,
tbf.toNextBoundary();
if (tbf.position() == -1)
+ {
f_character = f_rest;
+ }
else
+ {
f_character = f_rest.left(tbf.position());
+ }
// if (f_character == "&") //oh shit it's probably an escaped html
// {
@@ -3128,7 +3386,8 @@ QString Courtroom::filter_ic_text(QString p_text, bool html, int target_pos,
f_char_bytes = f_char_length = f_character.length();
- if (html) {
+ if (html)
+ {
f_character = f_character.toHtmlEscaped();
f_char_length = f_character.length();
}
@@ -3137,43 +3396,50 @@ QString Courtroom::filter_ic_text(QString p_text, bool html, int target_pos,
bool is_end = false;
bool skip = false;
- if (!parse_escape_seq) {
- if (f_character == "\\") {
+ if (!parse_escape_seq)
+ {
+ if (f_character == "\\")
+ {
parse_escape_seq = true;
skip = true;
}
// Nothing related to colors here
- else if (f_character == "{" ||
- f_character ==
- "}") //|| f_character == "@" || f_character == "$")
+ else if (f_character == "{" || f_character == "}") //|| f_character == "@" || f_character == "$")
{
skip = true;
}
// Parse markdown colors
- else {
- for (int c = 0; c < max_colors; ++c) {
+ else
+ {
+ for (int c = 0; c < max_colors; ++c)
+ {
// Clear the stored optimization information
QString markdown_start = color_markdown_start_list.at(c);
QString markdown_end = color_markdown_end_list.at(c);
- if (html) {
+ if (html)
+ {
markdown_start = markdown_start.toHtmlEscaped();
markdown_end = markdown_end.toHtmlEscaped();
}
bool markdown_remove = color_markdown_remove_list.at(c);
if (markdown_start.isEmpty()) // Not defined
- continue;
-
- if (markdown_end.isEmpty() ||
- markdown_end == markdown_start) //"toggle switch" type
{
- if (f_character == markdown_start) {
- if (html) {
- if (!ic_color_stack.empty() && ic_color_stack.top() == c &&
- default_color != c) {
+ continue;
+ }
+
+ if (markdown_end.isEmpty() || markdown_end == markdown_start) //"toggle switch" type
+ {
+ if (f_character == markdown_start)
+ {
+ if (html)
+ {
+ if (!ic_color_stack.empty() && ic_color_stack.top() == c && default_color != c)
+ {
ic_color_stack.pop(); // Cease our coloring
is_end = true;
}
- else {
+ else
+ {
ic_color_stack.push(c); // Begin our coloring
}
color_update = true;
@@ -3182,15 +3448,17 @@ QString Courtroom::filter_ic_text(QString p_text, bool html, int target_pos,
break; // Prevent it from looping forward for whatever reason
}
}
- else if (f_character == markdown_start ||
- (f_character == markdown_end && !ic_color_stack.empty() &&
- ic_color_stack.top() == c)) {
- if (html) {
- if (f_character == markdown_end) {
+ else if (f_character == markdown_start || (f_character == markdown_end && !ic_color_stack.empty() && ic_color_stack.top() == c))
+ {
+ if (html)
+ {
+ if (f_character == markdown_end)
+ {
ic_color_stack.pop(); // Cease our coloring
is_end = true;
}
- else if (f_character == markdown_start) {
+ else if (f_character == markdown_start)
+ {
ic_color_stack.push(c); // Begin our coloring
}
color_update = true;
@@ -3200,20 +3468,22 @@ QString Courtroom::filter_ic_text(QString p_text, bool html, int target_pos,
}
}
// Parse the newest color stack
- if (color_update && (target_pos <= -1 || check_pos < target_pos)) {
- if (!parse_escape_seq) {
+ if (color_update && (target_pos <= -1 || check_pos < target_pos))
+ {
+ if (!parse_escape_seq)
+ {
QString appendage = "";
if (!ic_color_stack.empty())
- appendage +=
- "";
+ {
+ appendage += "";
+ }
- if (is_end && !skip) {
+ if (is_end && !skip)
+ {
p_text_escaped.insert(check_pos_escaped,
f_character); // Add that char right now
- check_pos_escaped +=
- f_char_length; // So the closing char is captured too
+ check_pos_escaped += f_char_length; // So the closing char is captured too
skip = true;
}
p_text_escaped.insert(check_pos_escaped, appendage);
@@ -3222,11 +3492,13 @@ QString Courtroom::filter_ic_text(QString p_text, bool html, int target_pos,
}
}
}
- else {
+ else
+ {
if (f_character == "n") // \n, that's a line break son
{
QString appendage = "
";
- if (!html) {
+ if (!html)
+ {
// actual newline commented out
// appendage = "\n";
// size = 1; //yeah guess what \n is a "single character"
@@ -3238,48 +3510,55 @@ QString Courtroom::filter_ic_text(QString p_text, bool html, int target_pos,
skip = true;
}
if (f_character == "s" || f_character == "f" || f_character == "p") // screenshake/flash/pause
+ {
skip = true;
+ }
parse_escape_seq = false;
}
// Make all chars we're not supposed to see invisible
- if (target_pos > -1 && check_pos == target_pos) {
- QString appendage = "";
- if (!ic_color_stack.empty()) {
+ if (target_pos > -1 && check_pos == target_pos)
+ {
+ QString appendage;
+ if (!ic_color_stack.empty())
+ {
if (!is_end) // Was our last coloring char ending the color stack or nah
{
// God forgive me for my transgressions but I have refactored this
// whole thing about 25 times and having to refactor it again to more
// elegantly support this will finally make me go insane.
- color_is_talking =
- color_markdown_talking_list.at(ic_color_stack.top());
+ color_is_talking = color_markdown_talking_list.at(ic_color_stack.top());
}
// Clean it up, we're done here
while (!ic_color_stack.empty())
+ {
ic_color_stack.pop();
+ }
appendage += "";
}
- ic_color_stack.push(
- -1); // Dummy colorstack push for maximum appendage
+ ic_color_stack.push(-1); // Dummy colorstack push for maximum appendage
appendage += "";
p_text_escaped.insert(check_pos_escaped, appendage);
check_pos_escaped += appendage.size();
}
- if (!skip) {
+ if (!skip)
+ {
p_text_escaped.insert(check_pos_escaped, f_character);
check_pos_escaped += f_char_length;
}
check_pos += f_char_bytes;
}
- if (!ic_color_stack.empty() && html) {
+ if (!ic_color_stack.empty() && html)
+ {
p_text_escaped.append("");
}
- if (html) {
+ if (html)
+ {
// Example: https://regex101.com/r/oL4nM9/37 - this replaces
// excessive/trailing/etc. whitespace with non-breaking space. I WOULD use
// white-space: pre; stylesheet tag, but for whataver reason it doesn't work
@@ -3287,28 +3566,30 @@ QString Courtroom::filter_ic_text(QString p_text, bool html, int target_pos,
// memery to work, please do.
p_text_escaped.replace(QRegularExpression("^\\s|(?<=\\s)\\s"), " ");
if (!align.isEmpty())
+ {
p_text_escaped.append("
");
+ }
}
return p_text_escaped;
}
-void Courtroom::log_ic_text(QString p_name, QString p_showname,
- QString p_message, QString p_action, int p_color, bool p_selfname)
+void Courtroom::log_ic_text(QString p_name, QString p_showname, QString p_message, QString p_action, int p_color, bool p_selfname)
{
- chatlogpiece log_entry(p_name, p_showname, p_message, p_action, p_color, p_selfname);
+ ChatLogPiece log_entry(p_name, p_showname, p_message, p_action, p_color, p_selfname);
ic_chatlog_history.append(log_entry);
if (Options::getInstance().logToTextFileEnabled() && !ao_app->log_filename.isEmpty())
+ {
ao_app->append_to_file(log_entry.get_full(), ao_app->log_filename, true);
+ }
- while (ic_chatlog_history.size() > log_maximum_blocks &&
- log_maximum_blocks > 0) {
+ while (ic_chatlog_history.size() > log_maximum_blocks && log_maximum_blocks > 0)
+ {
ic_chatlog_history.removeFirst();
}
}
-void Courtroom::append_ic_text(QString p_text, QString p_name, QString p_action,
- int color, bool selfname, QDateTime timestamp, bool ghost)
+void Courtroom::append_ic_text(QString p_text, QString p_name, QString p_action, int color, bool selfname, QDateTime timestamp, bool ghost)
{
QColor chatlog_color = ao_app->get_color("ic_chatlog_color", "courtroom_fonts.ini");
QTextCharFormat bold;
@@ -3332,47 +3613,49 @@ void Courtroom::append_ic_text(QString p_text, QString p_name, QString p_action,
const QTextCursor old_cursor = ui_ic_chatlog->textCursor();
const int old_scrollbar_value = ui_ic_chatlog->verticalScrollBar()->value();
const bool need_newline = !ui_ic_chatlog->document()->isEmpty();
- const int scrollbar_target_value =
- log_goes_downwards ? ui_ic_chatlog->verticalScrollBar()->maximum()
- : ui_ic_chatlog->verticalScrollBar()->minimum();
+ const int scrollbar_target_value = log_goes_downwards ? ui_ic_chatlog->verticalScrollBar()->maximum() : ui_ic_chatlog->verticalScrollBar()->minimum();
- if (ghost) {
+ if (ghost)
+ {
ghost_blocks++;
chatlog_color.setAlpha(128);
bold.setForeground(chatlog_color);
normal.setForeground(chatlog_color);
italics.setForeground(chatlog_color);
}
- else {
+ else
+ {
last_ic_message = p_name + ":" + p_text;
}
- ui_ic_chatlog->moveCursor(log_goes_downwards ? QTextCursor::End
- : QTextCursor::Start);
+ ui_ic_chatlog->moveCursor(log_goes_downwards ? QTextCursor::End : QTextCursor::Start);
- if (!ghost && ghost_blocks > 0) {
- for (int i = 0; i < ghost_blocks; ++i) {
- ui_ic_chatlog->moveCursor(log_goes_downwards ? QTextCursor::PreviousBlock
- : QTextCursor::NextBlock);
+ if (!ghost && ghost_blocks > 0)
+ {
+ for (int i = 0; i < ghost_blocks; ++i)
+ {
+ ui_ic_chatlog->moveCursor(log_goes_downwards ? QTextCursor::PreviousBlock : QTextCursor::NextBlock);
}
- ui_ic_chatlog->moveCursor(log_goes_downwards ? QTextCursor::EndOfBlock
- : QTextCursor::StartOfBlock);
+ ui_ic_chatlog->moveCursor(log_goes_downwards ? QTextCursor::EndOfBlock : QTextCursor::StartOfBlock);
}
// Only prepend with newline if log goes downwards
- if (log_goes_downwards && need_newline) {
+ if (log_goes_downwards && need_newline)
+ {
ui_ic_chatlog->textCursor().insertBlock(format);
}
-
// Timestamp if we're doing that meme
- if (log_timestamp) {
+ if (log_timestamp)
+ {
// Format the timestamp
QTextCharFormat format = selfname ? selftimestamp_format : timestamp_format;
- if (timestamp.isValid()) {
- ui_ic_chatlog->textCursor().insertText(
- "[" + timestamp.toString(log_timestamp_format) + "] ", format);
- } else {
+ if (timestamp.isValid())
+ {
+ ui_ic_chatlog->textCursor().insertText("[" + timestamp.toString(log_timestamp_format) + "] ", format);
+ }
+ else
+ {
qCritical() << "could not insert invalid timestamp" << timestamp;
}
}
@@ -3381,53 +3664,65 @@ void Courtroom::append_ic_text(QString p_text, QString p_name, QString p_action,
QTextCharFormat name_format = selfname ? own_name : other_name;
ui_ic_chatlog->textCursor().insertText(p_name, name_format);
// Special case for stopping the music
- if (p_action == tr("has stopped the music")) {
+ if (p_action == tr("has stopped the music"))
+ {
ui_ic_chatlog->textCursor().insertText(" " + p_action + ".", normal);
}
// Make shout text bold
- else if (p_action == tr("shouts") && log_ic_actions) {
+ else if (p_action == tr("shouts") && log_ic_actions)
+ {
ui_ic_chatlog->textCursor().insertText(" " + p_action + " ", normal);
- if (log_colors && !ghost) {
- ui_ic_chatlog->textCursor().insertHtml(
- "" +
- filter_ic_text(p_text, true, -1, 0)
- .replace(
- "$c0",
- chatlog_color.name(QColor::HexArgb)) +
- "");
+ if (log_colors && !ghost)
+ {
+ ui_ic_chatlog->textCursor().insertHtml("" + filter_ic_text(p_text, true, -1, 0).replace("$c0", chatlog_color.name(QColor::HexArgb)) + "");
}
else
+ {
ui_ic_chatlog->textCursor().insertText(" " + p_text, italics);
+ }
}
// If action not blank:
- else if (p_action != "" && log_ic_actions) {
+ else if (p_action != "" && log_ic_actions)
+ {
// Format the action in normal
ui_ic_chatlog->textCursor().insertText(" " + p_action, normal);
if (log_newline)
+ {
// For some reason, we're forced to use
instead of the more sensible
// \n. Why? Because \n is treated as a new Block instead of a soft newline
// within a paragraph!
ui_ic_chatlog->textCursor().insertHtml("
");
+ }
else
+ {
ui_ic_chatlog->textCursor().insertText(": ", normal);
+ }
// Format the result in italics
ui_ic_chatlog->textCursor().insertText(p_text + ".", italics);
}
- else {
+ else
+ {
if (log_newline)
+ {
// For some reason, we're forced to use
instead of the more sensible
// \n. Why? Because \n is treated as a new Block instead of a soft newline
// within a paragraph!
ui_ic_chatlog->textCursor().insertHtml("
");
+ }
else
+ {
ui_ic_chatlog->textCursor().insertText(": ", normal);
+ }
// Format the result according to html
- if (log_colors) {
+ if (log_colors)
+ {
QString p_text_filtered = filter_ic_text(p_text, true, -1, color);
p_text_filtered = p_text_filtered.replace("$c0", chatlog_color.name(QColor::HexArgb));
- for (int c = 1; c < max_colors; ++c) {
+ for (int c = 1; c < max_colors; ++c)
+ {
QColor color_result = default_color_rgb_list.at(c);
- if (ghost) {
+ if (ghost)
+ {
color_result.setAlpha(128);
}
p_text_filtered = p_text_filtered.replace("$c" + QString::number(c), color_result.name(QColor::HexArgb));
@@ -3435,55 +3730,62 @@ void Courtroom::append_ic_text(QString p_text, QString p_name, QString p_action,
ui_ic_chatlog->textCursor().insertHtml(p_text_filtered);
}
else
+ {
ui_ic_chatlog->textCursor().insertText(filter_ic_text(p_text, false), normal);
+ }
}
// Only append with newline if log goes upwards
- if (!log_goes_downwards && need_newline) {
+ if (!log_goes_downwards && need_newline)
+ {
ui_ic_chatlog->textCursor().insertBlock(format);
}
// If we got too many blocks in the current log, delete some.
- while (ui_ic_chatlog->document()->blockCount() > log_maximum_blocks &&
- log_maximum_blocks > 0) {
+ while (ui_ic_chatlog->document()->blockCount() > log_maximum_blocks && log_maximum_blocks > 0)
+ {
QTextCursor temp_curs = ui_ic_chatlog->textCursor();
- temp_curs.movePosition(log_goes_downwards ? QTextCursor::Start
- : QTextCursor::End);
+ temp_curs.movePosition(log_goes_downwards ? QTextCursor::Start : QTextCursor::End);
temp_curs.select(QTextCursor::BlockUnderCursor);
temp_curs.removeSelectedText();
if (log_goes_downwards)
+ {
temp_curs.deleteChar();
+ }
else
+ {
temp_curs.deletePreviousChar();
+ }
}
// Finally, scroll the scrollbar to the correct position.
- if (old_cursor.hasSelection() ||
- old_scrollbar_value != scrollbar_target_value) {
+ if (old_cursor.hasSelection() || old_scrollbar_value != scrollbar_target_value)
+ {
// The user has selected text or scrolled away from the bottom: maintain
// position.
ui_ic_chatlog->setTextCursor(old_cursor);
ui_ic_chatlog->verticalScrollBar()->setValue(old_scrollbar_value);
}
- else {
- ui_ic_chatlog->verticalScrollBar()->setValue(
- log_goes_downwards ? ui_ic_chatlog->verticalScrollBar()->maximum() : 0);
+ else
+ {
+ ui_ic_chatlog->verticalScrollBar()->setValue(log_goes_downwards ? ui_ic_chatlog->verticalScrollBar()->maximum() : 0);
}
}
void Courtroom::pop_ic_ghost()
{
QTextCursor ghost = ui_ic_chatlog->textCursor();
- ghost.movePosition(log_goes_downwards ? QTextCursor::End
- : QTextCursor::Start);
- for (int i = 1; i < ghost_blocks; ++i) {
- ghost.movePosition(log_goes_downwards ? QTextCursor::PreviousBlock
- : QTextCursor::NextBlock);
+ ghost.movePosition(log_goes_downwards ? QTextCursor::End : QTextCursor::Start);
+ for (int i = 1; i < ghost_blocks; ++i)
+ {
+ ghost.movePosition(log_goes_downwards ? QTextCursor::PreviousBlock : QTextCursor::NextBlock);
}
ghost.select(QTextCursor::BlockUnderCursor);
ghost.removeSelectedText();
if (ghost_blocks <= 1 && !log_goes_downwards)
+ {
ghost.deleteChar();
+ }
ghost_blocks--;
}
@@ -3498,13 +3800,17 @@ void Courtroom::play_preanim(bool immediate)
int sfx_delay = m_chatmessage[SFX_DELAY].toInt() * time_mod;
sfx_delay_timer->start(sfx_delay);
- QString anim_to_find =
- ao_app->get_image_suffix(ao_app->get_character_path(f_char, f_preanim));
- if (!file_exists(anim_to_find)) {
+ QString anim_to_find = ao_app->get_image_suffix(ao_app->get_character_path(f_char, f_preanim));
+ if (!file_exists(anim_to_find))
+ {
if (immediate)
+ {
anim_state = 4;
+ }
else
+ {
anim_state = 1;
+ }
preanim_done();
qWarning() << "could not find preanim" << f_preanim << "for character" << f_char;
return;
@@ -3513,31 +3819,36 @@ void Courtroom::play_preanim(bool immediate)
ui_vp_player_char->set_play_once(true);
ui_vp_player_char->load_image(f_preanim, f_char, preanim_duration, true);
- switch (m_chatmessage[DESK_MOD].toInt()) {
- case DESK_EMOTE_ONLY_EX:
- ui_vp_sideplayer_char->hide();
- ui_vp_player_char->move_and_center(0, 0);
- [[fallthrough]];
- case DESK_EMOTE_ONLY:
- case DESK_HIDE:
- set_scene(false, m_chatmessage[SIDE]);
- break;
+ switch (m_chatmessage[DESK_MOD].toInt())
+ {
+ case DESK_EMOTE_ONLY_EX:
+ ui_vp_sideplayer_char->hide();
+ ui_vp_player_char->move_and_center(0, 0);
+ [[fallthrough]];
+ case DESK_EMOTE_ONLY:
+ case DESK_HIDE:
+ set_scene(false, m_chatmessage[SIDE]);
+ break;
- case DESK_PRE_ONLY_EX:
- case DESK_PRE_ONLY:
- case DESK_SHOW:
- set_scene(true, m_chatmessage[SIDE]);
- break;
+ case DESK_PRE_ONLY_EX:
+ case DESK_PRE_ONLY:
+ case DESK_SHOW:
+ set_scene(true, m_chatmessage[SIDE]);
+ break;
}
- if (immediate) {
+ if (immediate)
+ {
anim_state = 4;
handle_ic_speaking();
}
- else {
+ else
+ {
anim_state = 1;
if (stay_time >= 0)
+ {
text_delay_timer->start(stay_time);
+ }
}
}
@@ -3545,7 +3856,9 @@ void Courtroom::preanim_done()
{
// Currently, someone's talking over us mid-preanim...
if (anim_state != 1 && anim_state != 4 && anim_state != 5)
+ {
return;
+ }
anim_state = 1;
handle_ic_speaking();
@@ -3557,77 +3870,94 @@ void Courtroom::start_chat_ticking()
// we need to ensure that the text isn't already ticking because this function
// can be called by two logic paths
if (text_state != 0)
+ {
return;
+ }
// Display the evidence
display_evidence_image();
// handle expanded desk mods
- switch(m_chatmessage[DESK_MOD].toInt()) {
- case DESK_EMOTE_ONLY_EX:
- set_self_offset(m_chatmessage[SELF_OFFSET]);
- [[fallthrough]];
- case DESK_EMOTE_ONLY:
- case DESK_SHOW:
- set_scene(true, m_chatmessage[SIDE]);
- break;
+ switch (m_chatmessage[DESK_MOD].toInt())
+ {
+ case DESK_EMOTE_ONLY_EX:
+ set_self_offset(m_chatmessage[SELF_OFFSET]);
+ [[fallthrough]];
+ case DESK_EMOTE_ONLY:
+ case DESK_SHOW:
+ set_scene(true, m_chatmessage[SIDE]);
+ break;
- case DESK_PRE_ONLY_EX:
- ui_vp_sideplayer_char->hide();
- ui_vp_player_char->move_and_center(0, 0);
- [[fallthrough]];
- case DESK_PRE_ONLY:
- case DESK_HIDE:
- set_scene(false, m_chatmessage[SIDE]);
- break;
+ case DESK_PRE_ONLY_EX:
+ ui_vp_sideplayer_char->hide();
+ ui_vp_player_char->move_and_center(0, 0);
+ [[fallthrough]];
+ case DESK_PRE_ONLY:
+ case DESK_HIDE:
+ set_scene(false, m_chatmessage[SIDE]);
+ break;
}
- if (m_chatmessage[EFFECTS] != "") {
+ if (m_chatmessage[EFFECTS] != "")
+ {
QStringList fx_list = m_chatmessage[EFFECTS].split("|");
QString fx = fx_list[0];
QString fx_sound;
QString fx_folder;
if (fx_list.length() > 1)
+ {
fx_sound = fx_list[1];
+ }
- if (fx_list.length() > 2) {
+ if (fx_list.length() > 2)
+ {
fx_folder = fx_list[1];
fx_sound = fx_list[2];
}
this->do_effect(fx, fx_sound, m_chatmessage[CHAR_NAME], fx_folder);
}
- else if (m_chatmessage[REALIZATION] == "1") {
+ else if (m_chatmessage[REALIZATION] == "1")
+ {
this->do_flash();
sfx_player->play(ao_app->get_custom_realization(m_chatmessage[CHAR_NAME]));
}
int emote_mod = m_chatmessage[EMOTE_MOD].toInt(); // text meme bonanza
- if ((emote_mod == IDLE || emote_mod == ZOOM) && m_chatmessage[SCREENSHAKE] == "1") {
+ if ((emote_mod == IDLE || emote_mod == ZOOM) && m_chatmessage[SCREENSHAKE] == "1")
+ {
this->do_screenshake();
}
- if (m_chatmessage[MESSAGE].isEmpty()) {
+ if (m_chatmessage[MESSAGE].isEmpty())
+ {
// since the message is empty, it's technically done ticking
text_state = 2;
- if (m_chatmessage[ADDITIVE] == "1") {
+ if (m_chatmessage[ADDITIVE] == "1")
+ {
// Cool behavior
ui_vp_chatbox->show();
ui_vp_message->show();
}
- else {
+ else
+ {
ui_vp_chatbox->setVisible(chatbox_always_show);
ui_vp_message->hide();
// Show it if chatbox always shows
if (Options::getInstance().characterStickerEnabled() && chatbox_always_show)
+ {
ui_vp_sticker->load_image(m_chatmessage[CHAR_NAME]);
+ }
// Hide the face sticker
- else {
+ else
+ {
ui_vp_sticker->stop();
}
}
// If we're not already waiting on the next message, start the timer. We could be overriden if there's an objection planned.
int delay = Options::getInstance().textStayTime();
if (delay > 0 && !text_queue_timer->isActive())
+ {
text_queue_timer->start(delay);
+ }
return;
}
@@ -3635,9 +3965,12 @@ void Courtroom::start_chat_ticking()
ui_vp_message->show();
if (Options::getInstance().characterStickerEnabled())
+ {
ui_vp_sticker->load_image(m_chatmessage[CHAR_NAME]);
+ }
- if (m_chatmessage[ADDITIVE] != "1") {
+ if (m_chatmessage[ADDITIVE] != "1")
+ {
ui_vp_message->clear();
real_tick_pos = 0;
additive_previous = "";
@@ -3656,7 +3989,9 @@ void Courtroom::start_chat_ticking()
last_misc = current_misc;
current_misc = ao_app->get_chat(m_chatmessage[CHAR_NAME]);
if (last_misc != current_misc || char_color_rgb_list.size() < max_colors)
+ {
gen_char_rgb_list(current_misc);
+ }
QString f_blips = ao_app->get_blips(m_chatmessage[CHAR_NAME]);
blip_player->set_blips(f_blips);
@@ -3679,54 +4014,60 @@ void Courtroom::chat_tick()
ui_vp_player_char->set_static_duration(0);
QString filename;
- if (tick_pos >= f_message.size()) {
+ if (tick_pos >= f_message.size())
+ {
text_state = 2;
// Check if we're a narrator msg
- if (m_chatmessage[EMOTE] != "") {
- if (anim_state < 3) {
- QStringList c_paths = {
- ao_app->get_image_suffix(ao_app->get_character_path(m_chatmessage[CHAR_NAME], "(c)" + m_chatmessage[EMOTE])),
- ao_app->get_image_suffix(ao_app->get_character_path(m_chatmessage[CHAR_NAME], "(c)/" + m_chatmessage[EMOTE]))
- };
+ if (m_chatmessage[EMOTE] != "")
+ {
+ if (anim_state < 3)
+ {
+ QStringList c_paths = {ao_app->get_image_suffix(ao_app->get_character_path(m_chatmessage[CHAR_NAME], "(c)" + m_chatmessage[EMOTE])), ao_app->get_image_suffix(ao_app->get_character_path(m_chatmessage[CHAR_NAME], "(c)/" + m_chatmessage[EMOTE]))};
// if there is a (c) animation for this emote and we haven't played it already
- if (file_exists(ui_vp_player_char->find_image(c_paths)) &&(!c_played)) {
+ if (file_exists(ui_vp_player_char->find_image(c_paths)) && (!c_played))
+ {
anim_state = 5;
ui_vp_player_char->set_play_once(true);
filename = "(c)" + m_chatmessage[EMOTE];
c_played = true;
}
- else {
+ else
+ {
anim_state = 3;
ui_vp_player_char->set_play_once(false);
filename = "(a)" + m_chatmessage[EMOTE];
}
- ui_vp_player_char->load_image(filename, m_chatmessage[CHAR_NAME], 0,
- false);
+ ui_vp_player_char->load_image(filename, m_chatmessage[CHAR_NAME], 0, false);
}
}
else // We're a narrator msg
+ {
anim_state = 3;
+ }
QString f_char;
QString f_custom_theme;
- if (Options::getInstance().customChatboxEnabled()) {
+ if (Options::getInstance().customChatboxEnabled())
+ {
f_char = m_chatmessage[CHAR_NAME];
f_custom_theme = ao_app->get_chat(f_char);
}
ui_vp_chat_arrow->transform_mode = ao_app->get_misc_scaling(f_custom_theme);
ui_vp_chat_arrow->load_image("chat_arrow", f_custom_theme); // Chat stopped being processed, indicate that.
QString f_message_filtered = filter_ic_text(f_message, true, -1, m_chatmessage[TEXT_COLOR].toInt());
- for (int c = 0; c < max_colors; ++c) {
+ for (int c = 0; c < max_colors; ++c)
+ {
additive_previous = additive_previous.replace("$c" + QString::number(c), char_color_rgb_list.at(c).name(QColor::HexRgb));
f_message_filtered = f_message_filtered.replace("$c" + QString::number(c), char_color_rgb_list.at(c).name(QColor::HexRgb));
}
additive_previous = additive_previous + f_message_filtered;
real_tick_pos = ui_vp_message->toPlainText().size();
-
// If we're not already waiting on the next message, start the timer. We could be overriden if there's an objection planned.
int delay = Options::getInstance().textStayTime();
if (delay > 0 && !text_queue_timer->isActive())
+ {
text_queue_timer->start(delay);
+ }
// if we have instant objections disabled, and queue is not empty, check if next message after this is an objection.
if (!Options::getInstance().objectionSkipQueueEnabled() && chatmessage_queue.size() > 0)
@@ -3736,7 +4077,9 @@ void Courtroom::chat_tick()
bool is_objection = objection_mod >= 1 && objection_mod <= 5;
// If this is an objection, we'll need to interrupt our current message.
if (is_objection)
+ {
chatmessage_dequeue();
+ }
}
return;
}
@@ -3747,9 +4090,12 @@ void Courtroom::chat_tick()
QString f_rest = f_message;
// Alignment characters
- if (tick_pos < 2) {
+ if (tick_pos < 2)
+ {
if (f_rest.startsWith("~~") || f_rest.startsWith("~>") || f_rest.startsWith("<>"))
+ {
tick_pos += 2;
+ }
}
f_rest.remove(0, tick_pos);
QTextBoundaryFinder tbf(QTextBoundaryFinder::Grapheme, f_rest);
@@ -3760,52 +4106,70 @@ void Courtroom::chat_tick()
tbf.toNextBoundary();
if (tbf.position() == -1)
+ {
f_character = f_rest;
+ }
else
+ {
f_character = f_rest.left(tbf.position());
+ }
f_char_length = f_character.length();
tick_pos += f_char_length;
// Escape character.
- if (!next_character_is_not_special) {
- if (f_character == "\\") {
+ if (!next_character_is_not_special)
+ {
+ if (f_character == "\\")
+ {
next_character_is_not_special = true;
formatting_char = true;
}
// Text speed modifier.
- else if (f_character == "{") {
+ else if (f_character == "{")
+ {
// ++, because it INCREASES delay!
current_display_speed++;
formatting_char = true;
}
- else if (f_character == "}") {
+ else if (f_character == "}")
+ {
current_display_speed--;
formatting_char = true;
}
- else {
+ else
+ {
// Parse markdown colors
- for (int c = 0; c < max_colors; ++c) {
+ for (int c = 0; c < max_colors; ++c)
+ {
QString markdown_start = color_markdown_start_list.at(c);
QString markdown_end = color_markdown_end_list.at(c);
bool markdown_remove = color_markdown_remove_list.at(c);
if (markdown_start.isEmpty())
+ {
continue;
+ }
- if (f_character == markdown_start || f_character == markdown_end) {
+ if (f_character == markdown_start || f_character == markdown_end)
+ {
if (markdown_remove)
+ {
formatting_char = true;
+ }
break;
}
}
}
}
- else {
+ else
+ {
if (f_character == "n")
+ {
formatting_char = true; // it's a newline
- if (f_character == "s") // Screenshake.
+ }
+ if (f_character == "s") // Screenshake.
{
this->do_screenshake();
formatting_char = true;
@@ -3824,30 +4188,42 @@ void Courtroom::chat_tick()
// Keep the speed at bay.
if (current_display_speed < 0)
+ {
current_display_speed = 0;
+ }
else if (current_display_speed > 6)
+ {
current_display_speed = 6;
+ }
if (msg_delay == 0)
+ {
msg_delay = text_crawl * message_display_mult[current_display_speed];
+ }
- if ((msg_delay <= 0 &&
- tick_pos < f_message.size() - 1) ||
- formatting_char) {
+ if ((msg_delay <= 0 && tick_pos < f_message.size() - 1) || formatting_char)
+ {
if (f_character == "p")
+ {
chat_tick_timer->start(100); // wait the pause lol
+ }
else
+ {
chat_tick_timer->start(0); // Don't bother rendering anything out as we're
// doing the SPEED. (there's latency otherwise)
- if (!formatting_char || f_character == "n" || f_character == "f" ||
- f_character == "s" || f_character == "p")
+ }
+ if (!formatting_char || f_character == "n" || f_character == "f" || f_character == "s" || f_character == "p")
+ {
real_tick_pos += f_char_length; // Adjust the tick position for the
// scrollbar convenience
+ }
}
- else {
+ else
+ {
// Do the colors, gradual showing, etc. in here
QString f_message_filtered = filter_ic_text(f_message, true, tick_pos, m_chatmessage[TEXT_COLOR].toInt());
- for (int c = 0; c < max_colors; ++c) {
+ for (int c = 0; c < max_colors; ++c)
+ {
additive_previous = additive_previous.replace("$c" + QString::number(c), char_color_rgb_list.at(c).name(QColor::HexRgb));
f_message_filtered = f_message_filtered.replace("$c" + QString::number(c), char_color_rgb_list.at(c).name(QColor::HexRgb));
}
@@ -3871,24 +4247,26 @@ void Courtroom::chat_tick()
// where ! is the blip sound
int b_rate = blip_rate;
// Overwhelming blip spam prevention, this method is more consistent than timers
- if (msg_delay != 0 && msg_delay <= 25) {
+ if (msg_delay != 0 && msg_delay <= 25)
+ {
// The default blip speed is 40ms, and if current msg_delay is 25ms,
// the formula will result in the blip rate of:
// 40/25 = 1.6 = 2
// And if it's faster than that:
// 40/10 = 4
- b_rate =
- qMax(b_rate, qRound(static_cast(text_crawl) /
- msg_delay));
+ b_rate = qMax(b_rate, qRound(static_cast(text_crawl) / msg_delay));
}
- if ((blip_rate <= 0 && blip_ticker < 1) || (b_rate > 0 && blip_ticker % b_rate == 0)) {
+ if ((blip_rate <= 0 && blip_ticker < 1) || (b_rate > 0 && blip_ticker % b_rate == 0))
+ {
// ignoring white space unless blank_blip is enabled.
- if (!formatting_char && (f_character != ' ' || blank_blip)) {
+ if (!formatting_char && (f_character != ' ' || blank_blip))
+ {
blip_player->blip_tick();
++blip_ticker;
}
}
- else {
+ else
+ {
// Don't fully ignore whitespace still, keep ticking until
// we reached the need to play a blip sound - we also just
// need to wait for a letter to play it on.
@@ -3896,35 +4274,32 @@ void Courtroom::chat_tick()
}
// Punctuation delayer, only kicks in on speed ticks less than }}
- if (current_display_speed > 1 && punctuation_chars.contains(f_character)) {
+ if (current_display_speed > 1 && punctuation_chars.contains(f_character))
+ {
// Making the user have to wait any longer than 1.5 of the slowest speed
// is downright unreasonable
int max_delay = text_crawl * message_display_mult[6] * 1.5;
msg_delay = qMin(max_delay, msg_delay * punctuation_modifier);
}
- if (m_chatmessage[EMOTE] != "") {
+ if (m_chatmessage[EMOTE] != "")
+ {
// If this color is talking
- if (color_is_talking && anim_state != 2 &&
- anim_state <
- 4) // Set it to talking as we're not on that already (though we have
- // to avoid interrupting a non-interrupted preanim)
+ if (color_is_talking && anim_state != 2 && anim_state < 4) // Set it to talking as we're not on that already (though we have
+ // to avoid interrupting a non-interrupted preanim)
{
ui_vp_player_char->stop();
ui_vp_player_char->set_play_once(false);
filename = "(b)" + m_chatmessage[EMOTE];
- ui_vp_player_char->load_image(filename, m_chatmessage[CHAR_NAME], 0,
- false);
+ ui_vp_player_char->load_image(filename, m_chatmessage[CHAR_NAME], 0, false);
anim_state = 2;
}
- else if (!color_is_talking && anim_state < 3 &&
- anim_state != 3) // Set it to idle as we're not on that already
+ else if (!color_is_talking && anim_state < 3 && anim_state != 3) // Set it to idle as we're not on that already
{
ui_vp_player_char->stop();
ui_vp_player_char->set_play_once(false);
filename = "(a)" + m_chatmessage[EMOTE];
- ui_vp_player_char->load_image(filename, m_chatmessage[CHAR_NAME], 0,
- false);
+ ui_vp_player_char->load_image(filename, m_chatmessage[CHAR_NAME], 0, false);
anim_state = 3;
}
}
@@ -3936,18 +4311,20 @@ void Courtroom::chat_tick()
void Courtroom::play_sfx()
{
QString sfx_name = m_chatmessage[SFX_NAME];
- if (m_chatmessage[SCREENSHAKE] ==
- "1") // Screenshake dependant on preanim sfx delay meme
+ if (m_chatmessage[SCREENSHAKE] == "1") // Screenshake dependant on preanim sfx delay meme
{
this->do_screenshake();
}
if (sfx_name == "1")
+ {
return;
+ }
sfx_player->play(sfx_name);
if (Options::getInstance().loopingSfx())
- sfx_player->set_looping(
- ao_app->get_sfx_looping(current_char, current_emote) == "1");
+ {
+ sfx_player->set_looping(ao_app->get_sfx_looping(current_char, current_emote) == "1");
+ }
}
void Courtroom::set_scene(bool show_desk, const QString f_side)
@@ -3956,23 +4333,29 @@ void Courtroom::set_scene(bool show_desk, const QString f_side)
ui_vp_desk->load_image(ao_app->get_pos_path(f_side, true));
if (show_desk)
+ {
ui_vp_desk->show();
+ }
else
+ {
ui_vp_desk->hide();
+ }
}
-void Courtroom::set_self_offset(const QString& p_list) {
- QStringList self_offsets = p_list.split("&");
- int self_offset = self_offsets[0].toInt();
- int self_offset_v;
- if (self_offsets.length() <= 1) {
- self_offset_v = 0;
- }
- else {
- self_offset_v = self_offsets[1].toInt();
- }
- ui_vp_player_char->move_and_center(ui_viewport->width() * self_offset / 100,
- ui_viewport->height() * self_offset_v / 100);
+void Courtroom::set_self_offset(const QString &p_list)
+{
+ QStringList self_offsets = p_list.split("&");
+ int self_offset = self_offsets[0].toInt();
+ int self_offset_v;
+ if (self_offsets.length() <= 1)
+ {
+ self_offset_v = 0;
+ }
+ else
+ {
+ self_offset_v = self_offsets[1].toInt();
+ }
+ ui_vp_player_char->move_and_center(ui_viewport->width() * self_offset / 100, ui_viewport->height() * self_offset_v / 100);
}
void Courtroom::set_ip_list(QString p_list)
@@ -3985,11 +4368,16 @@ void Courtroom::set_ip_list(QString p_list)
void Courtroom::set_mute(bool p_muted, int p_cid)
{
if (p_cid != m_cid && p_cid != -1)
+ {
return;
+ }
if (p_muted)
+ {
ui_muted->show();
- else {
+ }
+ else
+ {
ui_muted->hide();
ui_ic_chat_message->setFocus();
}
@@ -4001,15 +4389,14 @@ void Courtroom::set_mute(bool p_muted, int p_cid)
ui_ic_chat_message->setEnabled(!p_muted);
}
-void Courtroom::set_ban(int p_cid)
+QString Courtroom::get_current_char()
{
- if (p_cid != m_cid && p_cid != -1)
- return;
+ return current_char;
+}
- call_notice(tr("You have been banned."));
-
- ao_app->construct_lobby();
- ao_app->destruct_courtroom();
+QString Courtroom::get_current_background()
+{
+ return current_background;
}
void Courtroom::handle_song(QStringList *p_contents)
@@ -4017,11 +4404,13 @@ void Courtroom::handle_song(QStringList *p_contents)
QStringList f_contents = *p_contents;
if (f_contents.size() < 2)
+ {
return;
+ }
- bool ok; // Used for charID, channel, effect check
+ bool ok; // Used for charID, channel, effect check
bool looping = false; // No loop due to outdated server using serverside looping
- int channel = 0; // Channel 0 is 'master music', other for ambient
+ int channel = 0; // Channel 0 is 'master music', other for ambient
int effect_flags = 0; // No effects by default - vanilla functionality
QString f_song = f_contents.at(0);
@@ -4030,129 +4419,158 @@ void Courtroom::handle_song(QStringList *p_contents)
int n_char = f_contents.at(1).toInt(&ok);
if (!ok)
+ {
return;
+ }
if (p_contents->length() > 3 && p_contents->at(3) == "1")
+ {
looping = true;
+ }
- if (p_contents->length() > 4) {
+ if (p_contents->length() > 4)
+ {
// eyyy we want to change this song's CHANNEL huh
// let the music player handle it if it's bigger than the channel list
channel = p_contents->at(4).toInt(&ok);
if (!ok)
+ {
return;
+ }
}
- if (p_contents->length() > 5) {
+ if (p_contents->length() > 5)
+ {
// Flags provided to us by server such as Fade In, Fade Out, Sync Pos etc.
effect_flags = p_contents->at(5).toInt(&ok);
if (!ok)
+ {
return;
+ }
}
- if(!file_exists(ao_app->get_sfx_suffix(ao_app->get_music_path(f_song))) && !f_song.startsWith("http")
- && f_song != "~stop.mp3" && !ao_app->asset_url.isEmpty()) {
- f_song = (ao_app->asset_url + "sounds/music/" + f_song).toLower();
+ if (!file_exists(ao_app->get_sfx_suffix(ao_app->get_music_path(f_song))) && !f_song.startsWith("http") && f_song != "~stop.mp3" && !ao_app->asset_url.isEmpty())
+ {
+ f_song = (ao_app->asset_url + "sounds/music/" + f_song).toLower();
}
bool is_stop = (f_song == "~stop.mp3");
- if (n_char >= 0 && n_char < char_list.size()) {
+ if (n_char >= 0 && n_char < char_list.size())
+ {
QString str_char = char_list.at(n_char).name;
QString str_show = ao_app->get_showname(str_char);
- if (p_contents->length() > 2) {
- if (p_contents->at(2) != "") {
+ if (p_contents->length() > 2)
+ {
+ if (p_contents->at(2) != "")
+ {
str_show = p_contents->at(2);
}
}
- if (!mute_map.value(n_char)) {
+ if (!mute_map.value(n_char))
+ {
bool selfname = n_char == m_cid;
- if (is_stop) {
+ if (is_stop)
+ {
log_ic_text(str_char, str_show, "", tr("has stopped the music"), 0, selfname);
append_ic_text("", str_show, tr("has stopped the music"), 0, selfname);
}
- else {
+ else
+ {
log_ic_text(str_char, str_show, f_song, tr("has played a song"), 0, selfname);
append_ic_text(f_song_clear, str_show, tr("has played a song"), 0, selfname);
}
}
}
- if (channel == 0) {
+ if (channel == 0)
+ {
// Current song UI only displays the song playing, not other channels.
// Any other music playing is irrelevant.
- if (music_player->music_watcher.isRunning()) {
- music_player->music_watcher.cancel();
+ if (music_player->music_watcher.isRunning())
+ {
+ music_player->music_watcher.cancel();
}
ui_music_name->setText(tr("[LOADING] %1").arg(f_song_clear));
}
#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
- music_player->music_watcher.setFuture(QtConcurrent::run(music_player, &AOMusicPlayer::play, f_song, channel,
- looping, effect_flags));
+ music_player->music_watcher.setFuture(QtConcurrent::run(music_player, &AOMusicPlayer::play, f_song, channel, looping, effect_flags));
#else
- music_player->music_watcher.setFuture(QtConcurrent::run(&AOMusicPlayer::play, music_player, f_song, channel,
- looping, effect_flags));
+ music_player->music_watcher.setFuture(QtConcurrent::run(&AOMusicPlayer::play, music_player, f_song, channel, looping, effect_flags));
#endif
}
void Courtroom::update_ui_music_name()
{
- QString result = music_player->music_watcher.result();
- if (result.isEmpty())
- return;
- ui_music_name->setText(result);
+ QString result = music_player->music_watcher.result();
+ if (result.isEmpty())
+ {
+ return;
+ }
+ ui_music_name->setText(result);
}
void Courtroom::handle_wtce(QString p_wtce, int variant)
{
- //QString sfx_file = "courtroom_sounds.ini";
+ // QString sfx_file = "courtroom_sounds.ini";
QString bg_misc = ao_app->read_design_ini("misc", ao_app->get_background_path("design.ini"));
QString sfx_name;
QString filename;
ui_vp_wtce->set_static_duration(wtce_static_time);
ui_vp_wtce->set_max_duration(wtce_max_time);
// witness testimony
- if (p_wtce == "testimony1") {
+ if (p_wtce == "testimony1")
+ {
// End testimony indicator
- if (variant == 1) {
+ if (variant == 1)
+ {
ui_vp_testimony->kill();
return;
}
sfx_name = ao_app->get_court_sfx("witness_testimony", bg_misc);
- if (sfx_name == "") {
+ if (sfx_name == "")
+ {
sfx_name = ao_app->get_court_sfx("witnesstestimony", bg_misc);
}
filename = "witnesstestimony_bubble";
ui_vp_testimony->load_image("testimony", "", bg_misc);
}
// cross examination
- else if (p_wtce == "testimony2") {
- sfx_name = ao_app->get_court_sfx("cross_examination", bg_misc);
- if (sfx_name == "") {
+ else if (p_wtce == "testimony2")
+ {
+ sfx_name = ao_app->get_court_sfx("cross_examination", bg_misc);
+ if (sfx_name == "")
+ {
sfx_name = ao_app->get_court_sfx("crossexamination", bg_misc);
}
filename = "crossexamination_bubble";
ui_vp_testimony->kill();
}
- else {
+ else
+ {
ui_vp_wtce->set_static_duration(verdict_static_time);
ui_vp_wtce->set_max_duration(verdict_max_time);
// Verdict?
- if (p_wtce == "judgeruling") {
- if (variant == 0) {
+ if (p_wtce == "judgeruling")
+ {
+ if (variant == 0)
+ {
sfx_name = ao_app->get_court_sfx("not_guilty", bg_misc);
- if (sfx_name == "") {
+ if (sfx_name == "")
+ {
sfx_name = ao_app->get_court_sfx("notguilty", bg_misc);
}
filename = "notguilty_bubble";
ui_vp_testimony->kill();
}
- else if (variant == 1) {
+ else if (variant == 1)
+ {
sfx_name = ao_app->get_court_sfx("guilty", bg_misc);
filename = "guilty_bubble";
ui_vp_testimony->kill();
}
}
// Completely custom WTCE
- else {
+ else
+ {
sfx_name = p_wtce;
filename = p_wtce;
}
@@ -4165,15 +4583,19 @@ void Courtroom::handle_wtce(QString p_wtce, int variant)
void Courtroom::set_hp_bar(int p_bar, int p_state)
{
if (p_state < 0 || p_state > 10)
+ {
return;
+ }
int prev_state = p_state;
- if (p_bar == 1) {
+ if (p_bar == 1)
+ {
ui_defense_bar->set_image("defensebar" + QString::number(p_state));
prev_state = defense_bar_state;
defense_bar_state = p_state;
}
- else if (p_bar == 2) {
+ else if (p_bar == 2)
+ {
ui_prosecution_bar->set_image("prosecutionbar" + QString::number(p_state));
prev_state = prosecution_bar_state;
prosecution_bar_state = p_state;
@@ -4181,62 +4603,66 @@ void Courtroom::set_hp_bar(int p_bar, int p_state)
QString sfx_name;
QString effect_name;
- if (p_state > prev_state) {
+ if (p_state > prev_state)
+ {
sfx_name = ao_app->get_penalty_value("hp_increased_sfx");
effect_name = ao_app->get_penalty_value("hp_increased_effect").toLower();
}
- else if (p_state < prev_state) {
+ else if (p_state < prev_state)
+ {
sfx_name = ao_app->get_penalty_value("hp_decreased_sfx");
effect_name = ao_app->get_penalty_value("hp_decreased_effect").toLower();
}
- else {
+ else
+ {
return;
}
- if (effect_name == "screenshake") {
+ if (effect_name == "screenshake")
+ {
do_screenshake();
}
- else if (effect_name == "flash") {
+ else if (effect_name == "flash")
+ {
do_flash();
}
- else {
+ else
+ {
do_effect(effect_name, "", "", "");
}
- if (!sfx_name.isEmpty()) {
+ if (!sfx_name.isEmpty())
+ {
sfx_player->play(sfx_name);
}
}
void Courtroom::show_judge_controls(bool visible)
{
- if (judge_state != POS_DEPENDENT) {
+ if (judge_state != POS_DEPENDENT)
+ {
visible = judge_state == SHOW_CONTROLS; // Server-side override
}
- QList judge_controls =
- {
- ui_witness_testimony,
- ui_cross_examination,
- ui_guilty,
- ui_not_guilty,
- ui_defense_minus,
- ui_defense_plus,
- ui_prosecution_minus,
- ui_prosecution_plus
- };
+ QList judge_controls = {ui_witness_testimony, ui_cross_examination, ui_guilty, ui_not_guilty, ui_defense_minus, ui_defense_plus, ui_prosecution_minus, ui_prosecution_plus};
- for (QWidget* control : judge_controls) {
- if (visible)
- control->show();
- else
- control->hide();
+ for (QWidget *control : judge_controls)
+ {
+ if (visible)
+ {
+ control->show();
+ }
+ else
+ {
+ control->hide();
+ }
}
}
void Courtroom::mod_called(QString p_ip)
{
ui_server_chatlog->append(p_ip);
- if (!ui_guard->isChecked()) {
+ if (!ui_guard->isChecked())
+ {
modcall_player->play(ao_app->get_court_sfx("mod_call"));
ao_app->alert(this);
}
@@ -4246,32 +4672,36 @@ void Courtroom::on_ooc_return_pressed()
{
QString ooc_message = ui_ooc_chat_message->text();
- //We ignore it when the server is compatible with 2.8
- //Using an arbitrary 2.8 feature flag certainly won't cause issues someday.
- if (ooc_message.startsWith("/pos") & !ao_app->effects_supported) {
- if (ooc_message == "/pos jud") {
+ // We ignore it when the server is compatible with 2.8
+ // Using an arbitrary 2.8 feature flag certainly won't cause issues someday.
+ if (ooc_message.startsWith("/pos") & !ao_app->effects_supported)
+ {
+ if (ooc_message == "/pos jud")
+ {
show_judge_controls(true);
}
- else {
+ else
+ {
show_judge_controls(false);
}
}
- if (ooc_message.startsWith("/load_case")) {
+ if (ooc_message.startsWith("/load_case"))
+ {
#if QT_VERSION < QT_VERSION_CHECK(5, 14, 0)
QStringList command = ooc_message.split(" ", QString::SkipEmptyParts);
#else
QStringList command = ooc_message.split(" ", Qt::SkipEmptyParts);
#endif
- QDir casefolder(get_base_path()+"/cases");
- if (!casefolder.exists()) {
+ QDir casefolder(get_base_path() + "/cases");
+ if (!casefolder.exists())
+ {
QDir::current().mkdir(get_base_path() + casefolder.dirName());
- append_server_chatmessage(
- "CLIENT",
- tr("You don't have a `base/cases/` folder! It was just made for you, "
- "but seeing as it WAS just made for you, it's likely the case "
- "file you're looking for can't be found in there."),
- "1");
+ append_server_chatmessage("CLIENT",
+ tr("You don't have a `base/cases/` folder! It was just made for you, "
+ "but seeing as it WAS just made for you, it's likely the case "
+ "file you're looking for can't be found in there."),
+ "1");
ui_ooc_chat_message->clear();
return;
}
@@ -4280,30 +4710,29 @@ void Courtroom::on_ooc_return_pressed()
caseslist.removeOne("..");
caseslist.replaceInStrings(".ini", "");
- if (command.size() < 2) {
- append_server_chatmessage(
- "CLIENT",
- tr("You need to give a filename to load (extension not needed)! Make "
- "sure that it is in the `base/cases/` folder, and that it is a "
- "correctly formatted ini.\nCases you can load: %1")
- .arg(caseslist.join(", ")),
- "1");
+ if (command.size() < 2)
+ {
+ append_server_chatmessage("CLIENT",
+ tr("You need to give a filename to load (extension not needed)! Make "
+ "sure that it is in the `base/cases/` folder, and that it is a "
+ "correctly formatted ini.\nCases you can load: %1")
+ .arg(caseslist.join(", ")),
+ "1");
ui_ooc_chat_message->clear();
return;
}
- if (command.size() > 2) {
- append_server_chatmessage(
- "CLIENT",
- tr("Too many arguments to load a case! You only need one filename, "
- "without extension."),
- "1");
+ if (command.size() > 2)
+ {
+ append_server_chatmessage("CLIENT",
+ tr("Too many arguments to load a case! You only need one filename, "
+ "without extension."),
+ "1");
ui_ooc_chat_message->clear();
return;
}
- QSettings casefile(get_base_path() + "/cases/" + command[1] + ".ini",
- QSettings::IniFormat);
+ QSettings casefile(get_base_path() + "/cases/" + command[1] + ".ini", QSettings::IniFormat);
QString caseauth = casefile.value("author", "").value();
QString casedoc = casefile.value("doc", "").value();
@@ -4311,67 +4740,68 @@ void Courtroom::on_ooc_return_pressed()
QString casestatus = casefile.value("status", "").value();
if (!caseauth.isEmpty())
- append_server_chatmessage(tr("CLIENT"),
- tr("Case made by %1.").arg(caseauth), "1");
- if (!casedoc.isEmpty()) {
- ao_app->send_server_packet(new AOPacket("CT", {ui_ooc_chat_name->text(), "/doc " + casedoc}));
+ {
+ append_server_chatmessage(tr("CLIENT"), tr("Case made by %1.").arg(caseauth), "1");
}
- if (!casestatus.isEmpty()) {
- ao_app->send_server_packet(new AOPacket("CT", {ui_ooc_chat_name->text(), "/status " + casestatus}));
+ if (!casedoc.isEmpty())
+ {
+ ao_app->send_server_packet(AOPacket("CT", {ui_ooc_chat_name->text(), "/doc " + casedoc}));
+ }
+ if (!casestatus.isEmpty())
+ {
+ ao_app->send_server_packet(AOPacket("CT", {ui_ooc_chat_name->text(), "/status " + casestatus}));
}
if (!cmdoc.isEmpty())
- append_server_chatmessage(
- "CLIENT", tr("Navigate to %1 for the CM doc.").arg(cmdoc), "1");
+ {
+ append_server_chatmessage("CLIENT", tr("Navigate to %1 for the CM doc.").arg(cmdoc), "1");
+ }
- for (int i = local_evidence_list.size() - 1; i >= 0; i--) {
- ao_app->send_server_packet(
- new AOPacket("DE", {QString::number(i)}));
+ for (int i = local_evidence_list.size() - 1; i >= 0; i--)
+ {
+ ao_app->send_server_packet(AOPacket("DE", {QString::number(i)}));
}
// sort the case_evidence numerically
QStringList case_evidence = casefile.childGroups();
- std::sort(case_evidence.begin(), case_evidence.end(),
- [] (const QString &a, const QString &b) {
- return a.toInt() < b.toInt();
- });
+ std::sort(case_evidence.begin(), case_evidence.end(), [](const QString &a, const QString &b) { return a.toInt() < b.toInt(); });
// load evidence
- foreach (QString evi, case_evidence) {
+ foreach (QString evi, case_evidence)
+ {
if (evi == "General")
+ {
continue;
+ }
QStringList f_contents;
- f_contents.append(
- casefile.value(evi + "/name", tr("UNKNOWN")).value());
- f_contents.append(
- casefile.value(evi + "/description", tr("UNKNOWN")).value());
- f_contents.append(
- casefile.value(evi + "/image", "UNKNOWN.png").value());
+ f_contents.append(casefile.value(evi + "/name", tr("UNKNOWN")).value());
+ f_contents.append(casefile.value(evi + "/description", tr("UNKNOWN")).value());
+ f_contents.append(casefile.value(evi + "/image", "UNKNOWN.png").value());
- ao_app->send_server_packet(new AOPacket("PE", f_contents));
+ ao_app->send_server_packet(AOPacket("PE", f_contents));
}
- append_server_chatmessage(
- "CLIENT", tr("Your case \"%1\" was loaded!").arg(command[1]), "1");
+ append_server_chatmessage("CLIENT", tr("Your case \"%1\" was loaded!").arg(command[1]), "1");
ui_ooc_chat_message->clear();
return;
}
- else if (ooc_message.startsWith("/save_case")) {
+ else if (ooc_message.startsWith("/save_case"))
+ {
#if QT_VERSION < QT_VERSION_CHECK(5, 14, 0)
QStringList command = ooc_message.split(" ", QString::SkipEmptyParts);
#else
QStringList command = ooc_message.split(" ", Qt::SkipEmptyParts);
#endif
QDir casefolder(get_base_path() + "cases");
- if (!casefolder.exists()) {
+ if (!casefolder.exists())
+ {
QDir(get_base_path()).mkdir(casefolder.dirName());
- append_server_chatmessage(
- "CLIENT",
- tr("You don't have a `base/cases/` folder! It was just made for you, "
- "but seeing as it WAS just made for you, it's likely that you "
- "somehow deleted it."),
- "1");
+ append_server_chatmessage("CLIENT",
+ tr("You don't have a `base/cases/` folder! It was just made for you, "
+ "but seeing as it WAS just made for you, it's likely that you "
+ "somehow deleted it."),
+ "1");
ui_ooc_chat_message->clear();
return;
}
@@ -4380,37 +4810,35 @@ void Courtroom::on_ooc_return_pressed()
caseslist.removeOne("..");
caseslist.replaceInStrings(".ini", "");
- if (command.size() < 3) {
- append_server_chatmessage(
- "CLIENT",
- tr("You need to give a filename to save (extension not needed) and "
- "the courtroom status!"),
- "1");
+ if (command.size() < 3)
+ {
+ append_server_chatmessage("CLIENT",
+ tr("You need to give a filename to save (extension not needed) and "
+ "the courtroom status!"),
+ "1");
ui_ooc_chat_message->clear();
return;
}
- if (command.size() > 3) {
- append_server_chatmessage(
- "CLIENT",
- tr("Too many arguments to save a case! You only need a filename "
- "without extension and the courtroom status!"),
- "1");
+ if (command.size() > 3)
+ {
+ append_server_chatmessage("CLIENT",
+ tr("Too many arguments to save a case! You only need a filename "
+ "without extension and the courtroom status!"),
+ "1");
ui_ooc_chat_message->clear();
return;
}
- QSettings casefile(get_base_path() + "/cases/" + command[1] + ".ini",
- QSettings::IniFormat);
+ QSettings casefile(get_base_path() + "/cases/" + command[1] + ".ini", QSettings::IniFormat);
casefile.setValue("author", ui_ooc_chat_name->text());
casefile.setValue("cmdoc", "");
casefile.setValue("doc", "");
casefile.setValue("status", command[2]);
casefile.sync();
- for (int i = 0; i < local_evidence_list.size(); i++) {
- QString clean_evidence_dsc = local_evidence_list[i].description.replace(
- QRegularExpression("..."), "");
- clean_evidence_dsc = clean_evidence_dsc.replace(
- clean_evidence_dsc.lastIndexOf(">"), 1, "");
+ for (int i = 0; i < local_evidence_list.size(); i++)
+ {
+ QString clean_evidence_dsc = local_evidence_list[i].description.replace(QRegularExpression("..."), "");
+ clean_evidence_dsc = clean_evidence_dsc.replace(clean_evidence_dsc.lastIndexOf(">"), 1, "");
casefile.beginGroup(QString::number(i));
casefile.sync();
casefile.setValue("name", local_evidence_list[i].name);
@@ -4419,9 +4847,7 @@ void Courtroom::on_ooc_return_pressed()
casefile.endGroup();
}
casefile.sync();
- append_server_chatmessage(
- "CLIENT", tr("Succesfully saved, edit doc and cmdoc link on the ini!"),
- "1");
+ append_server_chatmessage("CLIENT", tr("Succesfully saved, edit doc and cmdoc link on the ini!"), "1");
ui_ooc_chat_message->clear();
return;
}
@@ -4430,10 +4856,12 @@ void Courtroom::on_ooc_return_pressed()
packet_contents.append(ui_ooc_chat_name->text());
packet_contents.append(ooc_message);
- AOPacket *f_packet = new AOPacket("CT", packet_contents);
+ AOPacket f_packet("CT", packet_contents);
if (server_ooc)
+ {
ao_app->send_server_packet(f_packet);
+ }
ui_ooc_chat_message->clear();
@@ -4442,14 +4870,16 @@ void Courtroom::on_ooc_return_pressed()
void Courtroom::on_ooc_toggle_clicked()
{
- if (server_ooc) {
+ if (server_ooc)
+ {
ui_debug_log->show();
ui_server_chatlog->hide();
ui_ooc_toggle->setText(tr("Debug"));
server_ooc = false;
}
- else {
+ else
+ {
ui_debug_log->hide();
ui_server_chatlog->show();
ui_ooc_toggle->setText(tr("Server"));
@@ -4462,43 +4892,54 @@ void Courtroom::on_ooc_toggle_clicked()
void Courtroom::on_music_search_edited(QString p_text)
{
// Iterate through all QTreeWidgetItem items
- if (!ui_music_list->isHidden()) {
+ if (!ui_music_list->isHidden())
+ {
QTreeWidgetItemIterator it(ui_music_list);
- while (*it) {
+ while (*it)
+ {
(*it)->setHidden(p_text != "");
++it;
}
last_music_search = p_text;
}
- if (!ui_area_list->isHidden()) {
+ if (!ui_area_list->isHidden())
+ {
QTreeWidgetItemIterator ait(ui_area_list);
- while (*ait) {
+ while (*ait)
+ {
(*ait)->setHidden(p_text != "");
++ait;
}
last_area_search = p_text;
}
- if (p_text != "") {
- if (!ui_music_list->isHidden()) {
+ if (p_text != "")
+ {
+ if (!ui_music_list->isHidden())
+ {
// Search in metadata
- QList clist = ui_music_list->findItems(
- ui_music_search->text(), Qt::MatchContains | Qt::MatchRecursive, 1);
- foreach (QTreeWidgetItem *item, clist) {
+ QList clist = ui_music_list->findItems(ui_music_search->text(), Qt::MatchContains | Qt::MatchRecursive, 1);
+ foreach (QTreeWidgetItem *item, clist)
+ {
if (item->parent() != nullptr) // So the category shows up too
+ {
item->parent()->setHidden(false);
+ }
item->setHidden(false);
}
}
- if (!ui_area_list->isHidden()) {
+ if (!ui_area_list->isHidden())
+ {
// Search in metadata
- QList alist = ui_area_list->findItems(
- ui_music_search->text(), Qt::MatchContains | Qt::MatchRecursive, 1);
- foreach (QTreeWidgetItem *item, alist) {
+ QList alist = ui_area_list->findItems(ui_music_search->text(), Qt::MatchContains | Qt::MatchRecursive, 1);
+ foreach (QTreeWidgetItem *item, alist)
+ {
if (item->parent() != nullptr) // So the category shows up too
+ {
item->parent()->setHidden(false);
+ }
item->setHidden(false);
}
}
@@ -4507,7 +4948,8 @@ void Courtroom::on_music_search_edited(QString p_text)
void Courtroom::on_music_search_return_pressed()
{
- if (ui_music_search->text() == "") {
+ if (ui_music_search->text() == "")
+ {
ui_music_list->collapseAll();
}
}
@@ -4515,7 +4957,9 @@ void Courtroom::on_music_search_return_pressed()
void Courtroom::on_pos_dropdown_changed(int p_index)
{
if (p_index < 0)
+ {
return;
+ }
on_pos_dropdown_changed(ui_pos_dropdown->itemText(p_index));
}
@@ -4531,15 +4975,14 @@ void Courtroom::on_pos_dropdown_context_menu_requested(const QPoint &pos)
menu->setAttribute(Qt::WA_DeleteOnClose);
menu->addSeparator();
- menu->addAction(QString("Open background " + current_background), this,
- [=] {
+ menu->addAction(QString("Open background " + current_background), this, [=] {
QString p_path = ao_app->get_real_path(VPath("background/" + current_background + "/"));
- if (!dir_exists(p_path)) {
- return;
+ if (!dir_exists(p_path))
+ {
+ return;
}
QDesktopServices::openUrl(QUrl::fromLocalFile(p_path));
- }
- );
+ });
menu->popup(ui_iniswap_dropdown->mapToGlobal(pos));
}
@@ -4550,18 +4993,24 @@ void Courtroom::on_pos_remove_clicked()
show_judge_controls(ao_app->get_pos_is_judge(default_side));
- for (int i = 0; i < ui_pos_dropdown->count(); ++i) {
+ for (int i = 0; i < ui_pos_dropdown->count(); ++i)
+ {
QString pos = ui_pos_dropdown->itemText(i);
- if (pos == default_side) {
+ if (pos == default_side)
+ {
ui_pos_dropdown->setCurrentIndex(i);
break;
}
}
int wit_index = ui_pos_dropdown->findText("wit");
- if (ui_pos_dropdown->currentText() != default_side && wit_index != -1) //i.e. this bg doesn't have our pos
+ if (ui_pos_dropdown->currentText() != default_side && wit_index != -1) // i.e. this bg doesn't have our pos
+ {
ui_pos_dropdown->setCurrentIndex(wit_index); // fall back to "wit"
+ }
else if (ui_pos_dropdown->currentText() != default_side) // we don't have "wit" either?
+ {
ui_pos_dropdown->setCurrentIndex(0); // as a last resort, choose the first item in the dropdown
+ }
ui_pos_dropdown->blockSignals(false);
current_side = "";
ui_pos_remove->hide();
@@ -4572,34 +5021,39 @@ void Courtroom::set_iniswap_dropdown()
{
ui_iniswap_dropdown->blockSignals(true);
ui_iniswap_dropdown->clear();
- if (m_cid == -1) {
+ if (m_cid == -1)
+ {
ui_iniswap_dropdown->hide();
ui_iniswap_remove->hide();
return;
}
- QStringList iniswaps =
- ao_app->get_list_file(ao_app->get_character_path(char_list.at(m_cid).name, "iniswaps.ini")) +
- ao_app->get_list_file(VPath("iniswaps.ini"));
+ QStringList iniswaps = ao_app->get_list_file(ao_app->get_character_path(char_list.at(m_cid).name, "iniswaps.ini")) + ao_app->get_list_file(VPath("iniswaps.ini"));
iniswaps.prepend(char_list.at(m_cid).name);
iniswaps.removeDuplicates();
- if (iniswaps.size() <= 0) {
+ if (iniswaps.size() <= 0)
+ {
ui_iniswap_dropdown->hide();
ui_iniswap_remove->hide();
return;
}
ui_iniswap_dropdown->show();
- for (int i = 0; i < iniswaps.size(); ++i) {
+ for (int i = 0; i < iniswaps.size(); ++i)
+ {
ui_iniswap_dropdown->addItem(iniswaps.at(i));
- QString icon_path = ao_app->get_image_suffix(ao_app->get_character_path(
- iniswaps.at(i), "char_icon"));
+ QString icon_path = ao_app->get_image_suffix(ao_app->get_character_path(iniswaps.at(i), "char_icon"));
ui_iniswap_dropdown->setItemIcon(i, QIcon(icon_path));
- if (iniswaps.at(i) == current_char) {
+ if (iniswaps.at(i) == current_char)
+ {
ui_iniswap_dropdown->setCurrentIndex(i);
if (i != 0)
+ {
ui_iniswap_remove->show();
+ }
else
+ {
ui_iniswap_remove->hide();
+ }
}
}
ui_iniswap_dropdown->blockSignals(false);
@@ -4612,13 +5066,17 @@ void Courtroom::on_iniswap_dropdown_changed(int p_index)
QStringList swaplist;
QStringList defswaplist = ao_app->get_list_file(ao_app->get_character_path(char_list.at(m_cid).name, "iniswaps.ini"));
- for (int i = 0; i < ui_iniswap_dropdown->count(); ++i) {
+ for (int i = 0; i < ui_iniswap_dropdown->count(); ++i)
+ {
QString entry = ui_iniswap_dropdown->itemText(i);
if (!swaplist.contains(entry) && entry != char_list.at(m_cid).name && !defswaplist.contains(entry))
+ {
swaplist.append(entry);
+ }
}
QString p_path = ao_app->get_real_path(VPath("iniswaps.ini"));
- if (!file_exists(p_path)) {
+ if (!file_exists(p_path))
+ {
p_path = get_base_path() + "iniswaps.ini";
}
ao_app->write_to_file(swaplist.join("\n"), p_path);
@@ -4626,13 +5084,16 @@ void Courtroom::on_iniswap_dropdown_changed(int p_index)
ui_iniswap_dropdown->setCurrentIndex(p_index);
ui_iniswap_dropdown->blockSignals(false);
update_character(m_cid, iniswap, true);
- QString icon_path = ao_app->get_image_suffix(ao_app->get_character_path(
- iniswap, "char_icon"));
+ QString icon_path = ao_app->get_image_suffix(ao_app->get_character_path(iniswap, "char_icon"));
ui_iniswap_dropdown->setItemIcon(p_index, QIcon(icon_path));
if (p_index != 0)
+ {
ui_iniswap_remove->show();
+ }
else
+ {
ui_iniswap_remove->hide();
+ }
}
void Courtroom::on_iniswap_context_menu_requested(const QPoint &pos)
@@ -4641,33 +5102,33 @@ void Courtroom::on_iniswap_context_menu_requested(const QPoint &pos)
menu->setAttribute(Qt::WA_DeleteOnClose);
menu->addSeparator();
- if (file_exists(ao_app->get_real_path(
- ao_app->get_character_path(current_char, "char.ini"))))
- menu->addAction(QString("Edit " + current_char + "/char.ini"), this,
- &Courtroom::on_iniswap_edit_requested);
- if (ui_iniswap_dropdown->itemText(ui_iniswap_dropdown->currentIndex()) !=
- char_list.at(m_cid).name)
- menu->addAction(QString("Remove " + current_char), this,
- &Courtroom::on_iniswap_remove_clicked);
+ if (file_exists(ao_app->get_real_path(ao_app->get_character_path(current_char, "char.ini"))))
+ {
+ menu->addAction(QString("Edit " + current_char + "/char.ini"), this, &Courtroom::on_iniswap_edit_requested);
+ }
+ if (ui_iniswap_dropdown->itemText(ui_iniswap_dropdown->currentIndex()) != char_list.at(m_cid).name)
+ {
+ menu->addAction(QString("Remove " + current_char), this, &Courtroom::on_iniswap_remove_clicked);
+ }
menu->addSeparator();
- menu->addAction(QString("Open character folder " + current_char), this,
- [=] {
+ menu->addAction(QString("Open character folder " + current_char), this, [=] {
QString p_path = ao_app->get_real_path(VPath("characters/" + current_char + "/"));
- if (!dir_exists(p_path)) {
+ if (!dir_exists(p_path))
+ {
return;
}
QDesktopServices::openUrl(QUrl::fromLocalFile(p_path));
- }
- );
+ });
menu->popup(ui_iniswap_dropdown->mapToGlobal(pos));
}
void Courtroom::on_iniswap_edit_requested()
{
QString p_path = ao_app->get_real_path(ao_app->get_character_path(current_char, "char.ini"));
- if (!file_exists(p_path)) {
+ if (!file_exists(p_path))
+ {
return;
}
QDesktopServices::openUrl(QUrl::fromLocalFile(p_path));
@@ -4675,14 +5136,16 @@ void Courtroom::on_iniswap_edit_requested()
void Courtroom::on_iniswap_remove_clicked()
{
- if (ui_iniswap_dropdown->count() <= 0) {
+ if (ui_iniswap_dropdown->count() <= 0)
+ {
ui_iniswap_remove->hide(); // We're not supposed to see it. Do this or the
// client will crash
return;
}
QStringList defswaplist = ao_app->get_list_file(ao_app->get_character_path(char_list.at(m_cid).name, "iniswaps.ini"));
QString iniswap = ui_iniswap_dropdown->itemText(ui_iniswap_dropdown->currentIndex());
- if (iniswap != char_list.at(m_cid).name && !defswaplist.contains(iniswap)) {
+ if (iniswap != char_list.at(m_cid).name && !defswaplist.contains(iniswap))
+ {
ui_iniswap_dropdown->removeItem(ui_iniswap_dropdown->currentIndex());
}
on_iniswap_dropdown_changed(0); // Reset back to original
@@ -4693,29 +5156,31 @@ void Courtroom::set_sfx_dropdown()
{
ui_sfx_dropdown->blockSignals(true);
ui_sfx_dropdown->clear();
- if (m_cid == -1) {
+ if (m_cid == -1)
+ {
ui_sfx_dropdown->hide();
ui_sfx_remove->hide();
return;
}
// Initialzie character sound list first. Will be empty if not found.
- sound_list = ao_app->get_list_file(
- ao_app->get_character_path(current_char, "soundlist.ini"));
+ sound_list = ao_app->get_list_file(ao_app->get_character_path(current_char, "soundlist.ini"));
// If AO2 sound list is empty, try to find the DRO one.
- if (sound_list.isEmpty()) {
- sound_list = ao_app->get_list_file(
- ao_app->get_character_path(current_char, "sounds.ini"));
+ if (sound_list.isEmpty())
+ {
+ sound_list = ao_app->get_list_file(ao_app->get_character_path(current_char, "sounds.ini"));
}
// Append default sound list after the character sound list.
sound_list += ao_app->get_list_file(VPath("soundlist.ini"));
QStringList display_sounds;
- for (const QString &sound : qAsConst(sound_list)) {
+ for (const QString &sound : qAsConst(sound_list))
+ {
QStringList unpacked = sound.split("=");
QString display = unpacked[0].trimmed();
- if (unpacked.size() > 1) {
+ if (unpacked.size() > 1)
+ {
display = unpacked[1].trimmed();
}
@@ -4735,8 +5200,9 @@ void Courtroom::on_sfx_dropdown_changed(int p_index)
{
custom_sfx = "";
ui_ic_chat_message->setFocus();
- if (p_index == 0) {
- ui_sfx_remove->hide();
+ if (p_index == 0)
+ {
+ ui_sfx_remove->hide();
}
}
@@ -4753,29 +5219,32 @@ void Courtroom::on_sfx_context_menu_requested(const QPoint &pos)
menu->setAttribute(Qt::WA_DeleteOnClose);
menu->addSeparator();
// SFX is not "Nothing" or "Default"?
- if (get_char_sfx() != "0" && get_char_sfx() != "1" && get_char_sfx() != "-") {
+ if (get_char_sfx() != "0" && get_char_sfx() != "1" && get_char_sfx() != "-")
+ {
// Add an option to play the SFX
- menu->addAction(QString("Play " + get_char_sfx()), this, &Courtroom::on_sfx_play_clicked);;
+ menu->addAction(QString("Play " + get_char_sfx()), this, &Courtroom::on_sfx_play_clicked);
+ }
+ if (file_exists(ao_app->get_real_path(ao_app->get_character_path(current_char, "soundlist.ini"))))
+ {
+ menu->addAction(QString("Edit " + current_char + "/soundlist.ini"), this, &Courtroom::on_sfx_edit_requested);
}
- if (file_exists(ao_app->get_real_path(
- ao_app->get_character_path(current_char, "soundlist.ini"))))
- menu->addAction(QString("Edit " + current_char + "/soundlist.ini"), this,
- &Courtroom::on_sfx_edit_requested);
else
- menu->addAction(QString("Edit base soundlist.ini"), this,
- &Courtroom::on_sfx_edit_requested);
+ {
+ menu->addAction(QString("Edit base soundlist.ini"), this, &Courtroom::on_sfx_edit_requested);
+ }
if (!custom_sfx.isEmpty())
+ {
menu->addAction(QString("Clear Edit Text"), this, &Courtroom::on_sfx_remove_clicked);
+ }
menu->addSeparator();
- menu->addAction(QString("Open base sounds folder"), this,
- [=] {
+ menu->addAction(QString("Open base sounds folder"), this, [=] {
QString p_path = get_base_path() + "sounds/general/";
- if (!dir_exists(p_path)) {
+ if (!dir_exists(p_path))
+ {
return;
}
QDesktopServices::openUrl(QUrl::fromLocalFile(p_path));
- }
- );
+ });
menu->popup(ui_sfx_dropdown->mapToGlobal(pos));
}
@@ -4787,15 +5256,18 @@ void Courtroom::on_sfx_play_clicked()
void Courtroom::on_sfx_edit_requested()
{
QString p_path = ao_app->get_real_path(ao_app->get_character_path(current_char, "soundlist.ini"));
- if (!file_exists(p_path)) {
+ if (!file_exists(p_path))
+ {
p_path = ao_app->get_real_path(ao_app->get_character_path(current_char, "sounds.ini"));
}
- if (!file_exists(p_path)) {
+ if (!file_exists(p_path))
+ {
p_path = ao_app->get_real_path(VPath("soundlist.ini"));
}
- if (!file_exists(p_path)) {
+ if (!file_exists(p_path))
+ {
p_path = get_base_path() + "soundlist.ini";
}
QDesktopServices::openUrl(QUrl::fromLocalFile(p_path));
@@ -4812,14 +5284,16 @@ void Courtroom::set_effects_dropdown()
{
ui_effects_dropdown->blockSignals(true);
ui_effects_dropdown->clear();
- if (m_cid == -1) {
+ if (m_cid == -1)
+ {
ui_effects_dropdown->hide();
return;
}
QStringList effectslist;
effectslist.append(ao_app->get_effects(current_char));
- if (effectslist.empty()) {
+ if (effectslist.empty())
+ {
ui_effects_dropdown->hide();
return;
}
@@ -4830,7 +5304,8 @@ void Courtroom::set_effects_dropdown()
ui_effects_dropdown->addItems(effectslist);
// Make the icons
- for (int i = 0; i < ui_effects_dropdown->count(); ++i) {
+ for (int i = 0; i < ui_effects_dropdown->count(); ++i)
+ {
QString iconpath = ao_app->get_effect("icons/" + ui_effects_dropdown->itemText(i), current_char, "");
ui_effects_dropdown->setItemIcon(i, QIcon(iconpath));
}
@@ -4842,24 +5317,23 @@ void Courtroom::set_effects_dropdown()
void Courtroom::on_effects_context_menu_requested(const QPoint &pos)
{
QMenu *menu = new QMenu(this);
-
menu->setAttribute(Qt::WA_DeleteOnClose);
+
if (!ao_app->read_char_ini(current_char, "effects", "Options").isEmpty())
- menu->addAction(
- QString("Open misc/" +
- ao_app->read_char_ini(current_char, "effects", "Options") +
- " folder"),
- this, &Courtroom::on_character_effects_edit_requested);
- menu->addAction(QString("Open theme's effects folder"), this,
- &Courtroom::on_effects_edit_requested);
+ {
+ menu->addAction(QString("Open misc/" + ao_app->read_char_ini(current_char, "effects", "Options") + " folder"), this, &Courtroom::on_character_effects_edit_requested);
+ }
+ menu->addAction(QString("Open theme's effects folder"), this, &Courtroom::on_effects_edit_requested);
menu->popup(ui_effects_dropdown->mapToGlobal(pos));
}
void Courtroom::on_effects_edit_requested()
{
QString p_path = ao_app->get_real_path(ao_app->get_theme_path("effects/"));
- if (!dir_exists(p_path)) {
+ if (!dir_exists(p_path))
+ {
p_path = ao_app->get_real_path(ao_app->get_theme_path("effects/", "default"));
- if (!dir_exists(p_path)) {
+ if (!dir_exists(p_path))
+ {
return;
}
}
@@ -4870,7 +5344,9 @@ void Courtroom::on_character_effects_edit_requested()
QString p_effect = ao_app->read_char_ini(current_char, "effects", "Options");
QString p_path = ao_app->get_real_path(VPath("misc/" + p_effect + "/"));
if (!dir_exists(p_path))
+ {
return;
+ }
QDesktopServices::openUrl(QUrl::fromLocalFile(p_path));
}
@@ -4883,9 +5359,11 @@ void Courtroom::on_effects_dropdown_changed(int p_index)
bool Courtroom::effects_dropdown_find_and_set(QString effect)
{
- for (int i = 0; i < ui_effects_dropdown->count(); ++i) {
+ for (int i = 0; i < ui_effects_dropdown->count(); ++i)
+ {
QString entry = ui_effects_dropdown->itemText(i);
- if (entry == effect) {
+ if (entry == effect)
+ {
ui_effects_dropdown->setCurrentIndex(i);
return true;
}
@@ -4896,17 +5374,23 @@ bool Courtroom::effects_dropdown_find_and_set(QString effect)
QString Courtroom::get_char_sfx()
{
if (!custom_sfx.isEmpty())
+ {
return custom_sfx;
+ }
int index = ui_sfx_dropdown->currentIndex();
- if (index == 0) { // Default
+ if (index == 0)
+ { // Default
return ao_app->get_sfx_name(current_char, current_emote);
}
- if (index == 1) { // Nothing
+ if (index == 1)
+ { // Nothing
return "1";
}
- QString sfx = sound_list[index-2].split("=")[0].trimmed();
+ QString sfx = sound_list[index - 2].split("=")[0].trimmed();
if (sfx == "")
+ {
return "1";
+ }
return sfx;
}
@@ -4922,27 +5406,37 @@ void Courtroom::on_mute_list_clicked(QModelIndex p_index)
QString real_char;
if (f_char.endsWith(" [x]"))
+ {
real_char = f_char.left(f_char.size() - 4);
+ }
else
+ {
real_char = f_char;
+ }
int f_cid = -1;
- for (int n_char = 0; n_char < char_list.size(); n_char++) {
+ for (int n_char = 0; n_char < char_list.size(); n_char++)
+ {
if (char_list.at(n_char).name == real_char)
+ {
f_cid = n_char;
+ }
}
- if (f_cid < 0 || f_cid >= char_list.size()) {
+ if (f_cid < 0 || f_cid >= char_list.size())
+ {
qWarning() << "" << real_char << " not present in char_list";
return;
}
- if (mute_map.value(f_cid)) {
+ if (mute_map.value(f_cid))
+ {
mute_map.insert(f_cid, false);
f_item->setText(real_char);
}
- else {
+ else
+ {
mute_map.insert(f_cid, true);
f_item->setText(real_char + " [x]");
}
@@ -4955,19 +5449,25 @@ void Courtroom::on_pair_list_clicked(QModelIndex p_index)
QString real_char;
int f_cid = -1;
- if (f_char.endsWith(" [x]")) {
+ if (f_char.endsWith(" [x]"))
+ {
real_char = f_char.left(f_char.size() - 4);
f_item->setText(real_char);
}
- else {
+ else
+ {
real_char = f_char;
- for (int n_char = 0; n_char < char_list.size(); n_char++) {
+ for (int n_char = 0; n_char < char_list.size(); n_char++)
+ {
if (char_list.at(n_char).name == real_char)
+ {
f_cid = n_char;
+ }
}
}
- if (f_cid < -2 || f_cid >= char_list.size()) {
+ if (f_cid < -2 || f_cid >= char_list.size())
+ {
qWarning() << "" << real_char << " not present in char_list";
return;
}
@@ -4978,79 +5478,84 @@ void Courtroom::on_pair_list_clicked(QModelIndex p_index)
QStringList sorted_pair_list;
for (const char_type &i_char : qAsConst(char_list))
+ {
sorted_pair_list.append(i_char.name);
+ }
sorted_pair_list.sort();
- for (int i = 0; i < ui_pair_list->count(); i++) {
+ for (int i = 0; i < ui_pair_list->count(); i++)
+ {
ui_pair_list->item(i)->setText(sorted_pair_list.at(i));
}
- if (other_charid != -1) {
+ if (other_charid != -1)
+ {
f_item->setText(real_char + " [x]");
}
}
-void Courtroom::on_music_list_double_clicked(QTreeWidgetItem *p_item,
- int column)
+void Courtroom::on_music_list_double_clicked(QTreeWidgetItem *p_item, int column)
{
if (is_muted)
+ {
return;
+ }
if (!Options::getInstance().stopMusicOnCategoryEnabled() && p_item->parent() == nullptr)
+ {
return;
+ }
column = 1; // Column 1 is always the metadata (which we want)
QString p_song = p_item->text(column);
QStringList packet_contents;
packet_contents.append(p_song);
packet_contents.append(QString::number(m_cid));
- if ((!ui_ic_chat_name->text().isEmpty() && ao_app->cccc_ic_supported) ||
- ao_app->effects_supported)
+ if ((!ui_ic_chat_name->text().isEmpty() && ao_app->cccc_ic_supported) || ao_app->effects_supported)
+ {
packet_contents.append(ui_ic_chat_name->text());
+ }
if (ao_app->effects_supported)
+ {
packet_contents.append(QString::number(music_flags));
- ao_app->send_server_packet(new AOPacket("MC", packet_contents));
+ }
+ ao_app->send_server_packet(AOPacket("MC", packet_contents));
}
void Courtroom::on_music_list_context_menu_requested(const QPoint &pos)
{
QMenu *menu = new QMenu(this);
menu->setAttribute(Qt::WA_DeleteOnClose);
+
menu->addAction(QString(tr("Stop Current Song")), this, &Courtroom::music_stop);
menu->addAction(QString(tr("Play Random Song")), this, &Courtroom::music_random);
menu->addSeparator();
- menu->addAction(QString(tr("Expand All Categories")), this,
- &Courtroom::music_list_expand_all);
- menu->addAction(QString(tr("Collapse All Categories")), this,
- &Courtroom::music_list_collapse_all);
+ menu->addAction(QString(tr("Expand All Categories")), this, &Courtroom::music_list_expand_all);
+ menu->addAction(QString(tr("Collapse All Categories")), this, &Courtroom::music_list_collapse_all);
menu->addSeparator();
menu->addAction(new QAction(tr("Fade Out Previous"), this));
menu->actions().back()->setCheckable(true);
menu->actions().back()->setChecked(music_flags & FADE_OUT);
- connect(menu->actions().back(), &QAction::toggled, this,
- &Courtroom::music_fade_out);
+ connect(menu->actions().back(), &QAction::toggled, this, &Courtroom::music_fade_out);
menu->addAction(new QAction(tr("Fade In"), this));
menu->actions().back()->setCheckable(true);
menu->actions().back()->setChecked(music_flags & FADE_IN);
- connect(menu->actions().back(), &QAction::toggled, this,
- &Courtroom::music_fade_in);
+ connect(menu->actions().back(), &QAction::toggled, this, &Courtroom::music_fade_in);
menu->addAction(new QAction(tr("Synchronize"), this));
menu->actions().back()->setCheckable(true);
menu->actions().back()->setChecked(music_flags & SYNC_POS);
- connect(menu->actions().back(), &QAction::toggled, this,
- &Courtroom::music_synchronize);
+ connect(menu->actions().back(), &QAction::toggled, this, &Courtroom::music_synchronize);
menu->addSeparator();
- menu->addAction(QString("Open base music folder"), this,
- [=] {
+ menu->addAction(QString("Open base music folder"), this, [=] {
QString p_path = get_base_path() + "sounds/music/";
- if (!dir_exists(p_path)) {
+ if (!dir_exists(p_path))
+ {
return;
}
QDesktopServices::openUrl(QUrl::fromLocalFile(p_path));
- }
- );
+ });
menu->popup(ui_music_list->mapToGlobal(pos));
}
@@ -5058,41 +5563,55 @@ void Courtroom::on_music_list_context_menu_requested(const QPoint &pos)
void Courtroom::music_fade_out(bool toggle)
{
if (toggle)
+ {
music_flags |= FADE_OUT;
+ }
else
+ {
music_flags &= ~FADE_OUT;
+ }
}
void Courtroom::music_fade_in(bool toggle)
{
if (toggle)
+ {
music_flags |= FADE_IN;
+ }
else
+ {
music_flags &= ~FADE_IN;
+ }
}
void Courtroom::music_synchronize(bool toggle)
{
if (toggle)
+ {
music_flags |= SYNC_POS;
+ }
else
+ {
music_flags &= ~SYNC_POS;
+ }
}
void Courtroom::music_random()
{
QList clist;
- QTreeWidgetItemIterator it(ui_music_list,
- QTreeWidgetItemIterator::NotHidden |
- QTreeWidgetItemIterator::NoChildren);
- while (*it) {
- if (!(*it)->parent() || (*it)->parent()->isExpanded()) { // add top level songs and songs in expanded categories
+ QTreeWidgetItemIterator it(ui_music_list, QTreeWidgetItemIterator::NotHidden | QTreeWidgetItemIterator::NoChildren);
+ while (*it)
+ {
+ if (!(*it)->parent() || (*it)->parent()->isExpanded())
+ { // add top level songs and songs in expanded categories
clist += (*it);
}
++it;
}
if (clist.length() == 0)
- return;
+ {
+ return;
+ }
#if QT_VERSION < QT_VERSION_CHECK(5, 10, 0)
on_music_list_double_clicked(clist.at(qrand() % clist.length()), 1);
#else
@@ -5100,69 +5619,86 @@ void Courtroom::music_random()
#endif
}
-void Courtroom::music_list_expand_all() { ui_music_list->expandAll(); }
+void Courtroom::music_list_expand_all()
+{
+ ui_music_list->expandAll();
+}
void Courtroom::music_list_collapse_all()
{
ui_music_list->collapseAll();
QTreeWidgetItem *current = ui_music_list->selectedItems()[0];
if (current->parent() != nullptr)
+ {
current = current->parent();
+ }
ui_music_list->setCurrentItem(current);
}
void Courtroom::music_stop(bool no_effects)
{
if (is_muted)
+ {
return;
+ }
// Default fake song is a song present in Vanilla content, the ~stop.mp3
QString fake_song = "~stop.mp3";
// If the fake song is not present in the music list
- if (!music_list.contains(fake_song)) {
- // Loop through our music list
- for (const QString &song : qAsConst(music_list)) {
- // Pick first song that does not contain a file extension
- if (!song.contains('.')) {
- // Use it as a fake song as the server we're working with must recognize song categories
- fake_song = song;
- break;
- }
+ if (!music_list.contains(fake_song))
+ {
+ // Loop through our music list
+ for (const QString &song : qAsConst(music_list))
+ {
+ // Pick first song that does not contain a file extension
+ if (!song.contains('.'))
+ {
+ // Use it as a fake song as the server we're working with must recognize song categories
+ fake_song = song;
+ break;
}
+ }
}
- QStringList packet_contents; // its music list
- packet_contents.append(
- fake_song); // this is our fake song, playing it triggers special code
+ QStringList packet_contents; // its music list
+ packet_contents.append(fake_song); // this is our fake song, playing it triggers special code
packet_contents.append(QString::number(m_cid));
- if ((!ui_ic_chat_name->text().isEmpty() && ao_app->cccc_ic_supported) ||
- ao_app->effects_supported)
+ if ((!ui_ic_chat_name->text().isEmpty() && ao_app->cccc_ic_supported) || ao_app->effects_supported)
+ {
packet_contents.append(ui_ic_chat_name->text());
- if (ao_app->effects_supported) {
- if (no_effects)
- packet_contents.append("0");
- else
- packet_contents.append(QString::number(music_flags));
}
- ao_app->send_server_packet(new AOPacket("MC", packet_contents));
+ if (ao_app->effects_supported)
+ {
+ if (no_effects)
+ {
+ packet_contents.append("0");
+ }
+ else
+ {
+ packet_contents.append(QString::number(music_flags));
+ }
+ }
+ ao_app->send_server_packet(AOPacket("MC", packet_contents));
}
void Courtroom::on_area_list_double_clicked(QTreeWidgetItem *p_item, int column)
{
- column = 0; // The metadata
+ column = 0; // The metadata
Q_UNUSED(column); // so gcc shuts up
QString p_area = p_item->text(0);
QStringList packet_contents;
packet_contents.append(p_area);
packet_contents.append(QString::number(m_cid));
- ao_app->send_server_packet(new AOPacket("MC", packet_contents));
+ ao_app->send_server_packet(AOPacket("MC", packet_contents));
}
void Courtroom::on_hold_it_clicked()
{
- if (objection_state == 1) {
+ if (objection_state == 1)
+ {
ui_hold_it->set_image("holdit");
objection_state = 0;
}
- else {
+ else
+ {
ui_objection->set_image("objection");
ui_take_that->set_image("takethat");
ui_custom_objection->set_image("custom");
@@ -5176,11 +5712,13 @@ void Courtroom::on_hold_it_clicked()
void Courtroom::on_objection_clicked()
{
- if (objection_state == 2) {
+ if (objection_state == 2)
+ {
ui_objection->set_image("objection");
objection_state = 0;
}
- else {
+ else
+ {
ui_hold_it->set_image("holdit");
ui_take_that->set_image("takethat");
ui_custom_objection->set_image("custom");
@@ -5194,11 +5732,13 @@ void Courtroom::on_objection_clicked()
void Courtroom::on_take_that_clicked()
{
- if (objection_state == 3) {
+ if (objection_state == 3)
+ {
ui_take_that->set_image("takethat");
objection_state = 0;
}
- else {
+ else
+ {
ui_objection->set_image("objection");
ui_hold_it->set_image("holdit");
ui_custom_objection->set_image("custom");
@@ -5212,11 +5752,13 @@ void Courtroom::on_take_that_clicked()
void Courtroom::on_custom_objection_clicked()
{
- if (objection_state == 4) {
+ if (objection_state == 4)
+ {
ui_custom_objection->set_image("custom");
objection_state = 0;
}
- else {
+ else
+ {
ui_objection->set_image("objection");
ui_take_that->set_image("takethat");
ui_hold_it->set_image("holdit");
@@ -5232,16 +5774,22 @@ void Courtroom::show_custom_objection_menu(const QPoint &pos)
{
QPoint globalPos = ui_custom_objection->mapToGlobal(pos);
QAction *selecteditem = custom_obj_menu->exec(globalPos);
- if (selecteditem) {
+ if (selecteditem)
+ {
ui_objection->set_image("objection");
ui_take_that->set_image("takethat");
ui_hold_it->set_image("holdit");
ui_custom_objection->set_image("custom_selected");
if (selecteditem->text() == ao_app->read_char_ini(current_char, "custom_name", "Shouts") || selecteditem->text() == "Default")
+ {
objection_custom = "";
- else {
- foreach (CustomObjection custom_objection, custom_objections_list) {
- if (custom_objection.name == selecteditem->text()) {
+ }
+ else
+ {
+ foreach (CustomObjection custom_objection, custom_objections_list)
+ {
+ if (custom_objection.name == selecteditem->text())
+ {
objection_custom = custom_objection.filename;
break;
}
@@ -5254,14 +5802,18 @@ void Courtroom::show_custom_objection_menu(const QPoint &pos)
void Courtroom::on_realization_clicked()
{
- if (realization_state == 0) {
+ if (realization_state == 0)
+ {
realization_state = 1;
if (effects_dropdown_find_and_set("realization"))
+ {
on_effects_dropdown_changed(ui_effects_dropdown->currentIndex());
+ }
ui_realization->set_image("realization_pressed");
}
- else {
+ else
+ {
realization_state = 0;
ui_effects_dropdown->setCurrentIndex(0);
on_effects_dropdown_changed(ui_effects_dropdown->currentIndex());
@@ -5273,11 +5825,13 @@ void Courtroom::on_realization_clicked()
void Courtroom::on_screenshake_clicked()
{
- if (screenshake_state == 0) {
+ if (screenshake_state == 0)
+ {
screenshake_state = 1;
ui_screenshake->set_image("screenshake_pressed");
}
- else {
+ else
+ {
screenshake_state = 0;
ui_screenshake->set_image("screenshake");
}
@@ -5287,7 +5841,8 @@ void Courtroom::on_screenshake_clicked()
void Courtroom::on_mute_clicked()
{
- if (ui_mute_list->isHidden()) {
+ if (ui_mute_list->isHidden())
+ {
ui_mute_list->show();
ui_pair_list->hide();
ui_pair_offset_spinbox->hide();
@@ -5296,7 +5851,8 @@ void Courtroom::on_mute_clicked()
ui_pair_button->set_image("pair_button");
ui_mute->set_image("mute_pressed");
}
- else {
+ else
+ {
ui_mute_list->hide();
ui_mute->set_image("mute");
}
@@ -5304,17 +5860,21 @@ void Courtroom::on_mute_clicked()
void Courtroom::on_pair_clicked()
{
- if (ui_pair_list->isHidden()) {
+ if (ui_pair_list->isHidden())
+ {
ui_pair_list->show();
ui_pair_offset_spinbox->show();
- if(ao_app->y_offset_supported)
- ui_pair_vert_offset_spinbox->show();
+ if (ao_app->y_offset_supported)
+ {
+ ui_pair_vert_offset_spinbox->show();
+ }
ui_pair_order_dropdown->show();
ui_mute_list->hide();
ui_mute->set_image("mute");
ui_pair_button->set_image("pair_button_pressed");
}
- else {
+ else
+ {
ui_pair_list->hide();
ui_pair_offset_spinbox->hide();
ui_pair_vert_offset_spinbox->hide();
@@ -5333,8 +5893,9 @@ void Courtroom::on_defense_minus_clicked()
int f_state = defense_bar_state - 1;
if (f_state >= 0)
- ao_app->send_server_packet(
- new AOPacket("HP", {"1", QString::number(f_state)}));
+ {
+ ao_app->send_server_packet(AOPacket("HP", {"1", QString::number(f_state)}));
+ }
}
void Courtroom::on_defense_plus_clicked()
@@ -5342,8 +5903,9 @@ void Courtroom::on_defense_plus_clicked()
int f_state = defense_bar_state + 1;
if (f_state <= 10)
- ao_app->send_server_packet(
- new AOPacket("HP", {"1", QString::number(f_state)}));
+ {
+ ao_app->send_server_packet(AOPacket("HP", {"1", QString::number(f_state)}));
+ }
}
void Courtroom::on_prosecution_minus_clicked()
@@ -5351,8 +5913,9 @@ void Courtroom::on_prosecution_minus_clicked()
int f_state = prosecution_bar_state - 1;
if (f_state >= 0)
- ao_app->send_server_packet(
- new AOPacket("HP", {"2", QString::number(f_state)}));
+ {
+ ao_app->send_server_packet(AOPacket("HP", {"2", QString::number(f_state)}));
+ }
}
void Courtroom::on_prosecution_plus_clicked()
@@ -5360,23 +5923,24 @@ void Courtroom::on_prosecution_plus_clicked()
int f_state = prosecution_bar_state + 1;
if (f_state <= 10)
- ao_app->send_server_packet(
- new AOPacket("HP", {"2", QString::number(f_state)}));
+ {
+ ao_app->send_server_packet(AOPacket("HP", {"2", QString::number(f_state)}));
+ }
}
void Courtroom::on_text_color_context_menu_requested(const QPoint &pos)
{
QMenu *menu = new QMenu(this);
+ menu->setAttribute(Qt::WA_DeleteOnClose);
- menu->addAction(QString("Open currently used chat_config.ini"), this,
- [=] {
+ menu->addAction(QString("Open currently used chat_config.ini"), this, [=] {
QString p_path = ao_app->get_asset("chat_config.ini", Options::getInstance().theme(), Options::getInstance().subTheme(), ao_app->default_theme, ao_app->get_chat(current_char));
- if (!file_exists(p_path)) {
- return;
+ if (!file_exists(p_path))
+ {
+ return;
}
QDesktopServices::openUrl(QUrl::fromLocalFile(p_path));
- }
- );
+ });
menu->popup(ui_text_color->mapToGlobal(pos));
}
@@ -5396,27 +5960,22 @@ void Courtroom::set_text_color_dropdown()
// Update markdown colors. TODO: make a loading function that only loads the
// config file once instead of several times
- for (int c = 0; c < max_colors; ++c) {
- QColor color =
- ao_app->get_chat_color("c" + QString::number(c), ao_app->get_chat(current_char));
+ for (int c = 0; c < max_colors; ++c)
+ {
+ QColor color = ao_app->get_chat_color("c" + QString::number(c), ao_app->get_chat(current_char));
color_rgb_list.append(color);
- color_markdown_start_list.append(ao_app->get_chat_markup(
- "c" + QString::number(c) + "_start", ao_app->get_chat(current_char)));
- color_markdown_end_list.append(ao_app->get_chat_markup(
- "c" + QString::number(c) + "_end", ao_app->get_chat(current_char)));
- color_markdown_remove_list.append(
- ao_app->get_chat_markup("c" + QString::number(c) + "_remove",
- ao_app->get_chat(current_char)) == "1");
- color_markdown_talking_list.append(
- ao_app->get_chat_markup("c" + QString::number(c) + "_talking",
- ao_app->get_chat(current_char)) != "0");
+ color_markdown_start_list.append(ao_app->get_chat_markup("c" + QString::number(c) + "_start", ao_app->get_chat(current_char)));
+ color_markdown_end_list.append(ao_app->get_chat_markup("c" + QString::number(c) + "_end", ao_app->get_chat(current_char)));
+ color_markdown_remove_list.append(ao_app->get_chat_markup("c" + QString::number(c) + "_remove", ao_app->get_chat(current_char)) == "1");
+ color_markdown_talking_list.append(ao_app->get_chat_markup("c" + QString::number(c) + "_talking", ao_app->get_chat(current_char)) != "0");
- QString color_name = ao_app->get_chat_markup(
- "c" + QString::number(c) + "_name", ao_app->get_chat(current_char));
+ QString color_name = ao_app->get_chat_markup("c" + QString::number(c) + "_name", ao_app->get_chat(current_char));
if (color_name.isEmpty()) // Not defined
{
if (c > 0)
+ {
continue;
+ }
color_name = tr("Default");
}
ui_text_color->addItem(color_name);
@@ -5425,15 +5984,18 @@ void Courtroom::set_text_color_dropdown()
ui_text_color->setItemIcon(ui_text_color->count() - 1, pixmap);
color_row_to_number.append(c);
}
- for (int c = 0; c < max_colors; ++c) {
+ for (int c = 0; c < max_colors; ++c)
+ {
QColor color = ao_app->get_chat_color("c" + QString::number(c), "");
default_color_rgb_list.append(color);
}
}
-void Courtroom::gen_char_rgb_list(QString p_misc) {
+void Courtroom::gen_char_rgb_list(QString p_misc)
+{
char_color_rgb_list.clear();
- for (int c = 0; c < max_colors; ++c) {
+ for (int c = 0; c < max_colors; ++c)
+ {
QColor color = ao_app->get_chat_color("c" + QString::number(c), p_misc);
char_color_rgb_list.append(color);
}
@@ -5445,14 +6007,17 @@ void Courtroom::on_text_color_changed(int p_color)
{
int c = color_row_to_number.at(p_color);
QString markdown_start = color_markdown_start_list.at(c);
- if (markdown_start.isEmpty()) {
+ if (markdown_start.isEmpty())
+ {
qWarning() << "Color list dropdown selected a non-existent markdown "
- "start character";
+ "start character";
return;
}
QString markdown_end = color_markdown_end_list.at(c);
if (markdown_end.isEmpty())
+ {
markdown_end = markdown_start;
+ }
int start = ui_ic_chat_message->selectionStart();
#if QT_VERSION >= QT_VERSION_CHECK(5, 10, 0)
int end = ui_ic_chat_message->selectionEnd() + 1;
@@ -5467,11 +6032,16 @@ void Courtroom::on_text_color_changed(int p_color)
// ui_ic_chat_message->end(false);
ui_text_color->setCurrentIndex(0);
}
- else {
+ else
+ {
if (p_color != -1 && p_color < color_row_to_number.size())
+ {
text_color = color_row_to_number.at(p_color);
+ }
else
+ {
text_color = 0;
+ }
}
ui_ic_chat_message->setFocus();
}
@@ -5486,7 +6056,8 @@ void Courtroom::on_sfx_slider_moved(int p_value)
{
sfx_player->set_volume(p_value);
// Set the ambience and other misc. music layers
- for (int i = 1; i < music_player->m_channelmax; ++i) {
+ for (int i = 1; i < music_player->CHANNEL_COUNT; ++i)
+ {
music_player->set_volume(p_value, i);
}
objection_player->set_volume(p_value);
@@ -5499,9 +6070,15 @@ void Courtroom::on_blip_slider_moved(int p_value)
ui_ic_chat_message->setFocus();
}
-void Courtroom::on_log_limit_changed(int value) { log_maximum_blocks = value; }
+void Courtroom::on_log_limit_changed(int value)
+{
+ log_maximum_blocks = value;
+}
-void Courtroom::on_pair_offset_changed(int value) { char_offset = value; }
+void Courtroom::on_pair_offset_changed(int value)
+{
+ char_offset = value;
+}
void Courtroom::on_pair_vert_offset_changed(int value)
{
@@ -5511,9 +6088,11 @@ void Courtroom::on_pair_vert_offset_changed(int value)
void Courtroom::on_witness_testimony_clicked()
{
if (is_muted)
+ {
return;
+ }
- ao_app->send_server_packet(new AOPacket("RT", {"testimony1"}));
+ ao_app->send_server_packet(AOPacket("RT", {"testimony1"}));
ui_ic_chat_message->setFocus();
}
@@ -5521,9 +6100,11 @@ void Courtroom::on_witness_testimony_clicked()
void Courtroom::on_cross_examination_clicked()
{
if (is_muted)
+ {
return;
+ }
- ao_app->send_server_packet(new AOPacket("RT", {"testimony2"}));
+ ao_app->send_server_packet(AOPacket("RT", {"testimony2"}));
ui_ic_chat_message->setFocus();
}
@@ -5531,9 +6112,11 @@ void Courtroom::on_cross_examination_clicked()
void Courtroom::on_not_guilty_clicked()
{
if (is_muted)
+ {
return;
+ }
- ao_app->send_server_packet(new AOPacket("RT", {"judgeruling", "0"}));
+ ao_app->send_server_packet(AOPacket("RT", {"judgeruling", "0"}));
ui_ic_chat_message->setFocus();
}
@@ -5541,9 +6124,11 @@ void Courtroom::on_not_guilty_clicked()
void Courtroom::on_guilty_clicked()
{
if (is_muted)
+ {
return;
+ }
- ao_app->send_server_packet(new AOPacket("RT", {"judgeruling", "1"}));
+ ao_app->send_server_packet(AOPacket("RT", {"judgeruling", "1"}));
ui_ic_chat_message->setFocus();
}
@@ -5588,11 +6173,15 @@ void Courtroom::on_char_select_right_clicked()
set_char_select_page();
}
-void Courtroom::on_spectator_clicked() { char_clicked(-1); }
+void Courtroom::on_spectator_clicked()
+{
+ char_clicked(-1);
+}
void Courtroom::on_call_mod_clicked()
{
- if (ao_app->modcall_reason_supported) {
+ if (ao_app->modcall_reason_supported)
+ {
QMessageBox errorBox;
QInputDialog input;
@@ -5602,14 +6191,18 @@ void Courtroom::on_call_mod_clicked()
auto code = input.exec();
if (code != QDialog::Accepted)
+ {
return;
+ }
QString text = input.textValue();
- if (text.isEmpty()) {
+ if (text.isEmpty())
+ {
errorBox.critical(nullptr, tr("Error"), tr("You must provide a reason."));
return;
}
- else if (text.length() > 256) {
+ else if (text.length() > 256)
+ {
errorBox.critical(nullptr, tr("Error"), tr("The message is too long."));
return;
}
@@ -5617,24 +6210,35 @@ void Courtroom::on_call_mod_clicked()
QStringList mod_reason;
mod_reason.append(text);
- ao_app->send_server_packet(new AOPacket("ZZ", mod_reason));
+ ao_app->send_server_packet(AOPacket("ZZ", mod_reason));
}
- else {
- ao_app->send_server_packet(new AOPacket("ZZ"));
+ else
+ {
+ ao_app->send_server_packet(AOPacket("ZZ"));
}
ui_ic_chat_message->setFocus();
}
-void Courtroom::on_settings_clicked() { ao_app->call_settings_menu(); }
+void Courtroom::on_settings_clicked()
+{
+ ao_app->call_settings_menu();
+}
-void Courtroom::on_pre_clicked() { ui_ic_chat_message->setFocus(); }
+void Courtroom::on_pre_clicked()
+{
+ ui_ic_chat_message->setFocus();
+}
-void Courtroom::on_flip_clicked() { ui_ic_chat_message->setFocus(); }
+void Courtroom::on_flip_clicked()
+{
+ ui_ic_chat_message->setFocus();
+}
void Courtroom::on_additive_clicked()
{
- if (ui_additive->isChecked()) {
+ if (ui_additive->isChecked())
+ {
ui_ic_chat_message->home(false); // move cursor to the start of the message
ui_ic_chat_message->insert(" "); // preface the message by whitespace
ui_ic_chat_message->end(false); // move cursor to the end of the message
@@ -5643,7 +6247,10 @@ void Courtroom::on_additive_clicked()
ui_ic_chat_message->setFocus();
}
-void Courtroom::on_guard_clicked() { ui_ic_chat_message->setFocus(); }
+void Courtroom::on_guard_clicked()
+{
+ ui_ic_chat_message->setFocus();
+}
void Courtroom::on_showname_enable_clicked()
{
@@ -5655,24 +6262,23 @@ void Courtroom::regenerate_ic_chatlog()
{
ui_ic_chatlog->clear();
last_ic_message = "";
- foreach (chatlogpiece item, ic_chatlog_history) {
- QString message = item.get_message();
- QString name = ui_showname_enable->isChecked() ? item.get_showname()
- : item.get_name();
- append_ic_text(message,
- name,
- item.get_action(), item.get_chat_color(),
- item.get_selfname(), item.get_datetime().toLocalTime());
+ foreach (ChatLogPiece item, ic_chatlog_history)
+ {
+ QString message = item.message;
+ QString name = ui_showname_enable->isChecked() ? item.showname : item.name;
+ append_ic_text(message, name, item.action, item.color, item.selfname, item.datetime.toLocalTime());
}
}
void Courtroom::on_evidence_button_clicked()
{
- if (ui_evidence->isHidden()) {
+ if (ui_evidence->isHidden())
+ {
ui_evidence->show();
ui_evidence_overlay->hide();
}
- else {
+ else
+ {
ui_evidence->hide();
}
}
@@ -5680,61 +6286,55 @@ void Courtroom::on_evidence_button_clicked()
void Courtroom::on_evidence_context_menu_requested(const QPoint &pos)
{
QMenu *menu = new QMenu(this);
- menu->addAction(QString("Open base evidence folder"), this,
- [=] {
+ menu->setAttribute(Qt::WA_DeleteOnClose, true);
+ menu->addAction(QString("Open base evidence folder"), this, [=] {
QString p_path = get_base_path() + "evidence/";
- if (!dir_exists(p_path)) {
+ if (!dir_exists(p_path))
+ {
return;
}
QDesktopServices::openUrl(QUrl::fromLocalFile(p_path));
- }
- );
+ });
menu->popup(ui_evidence_button->mapToGlobal(pos));
}
void Courtroom::on_switch_area_music_clicked()
{
- if (ui_area_list->isHidden()) {
+ if (ui_area_list->isHidden())
+ {
ui_area_list->show();
ui_music_list->hide();
last_music_search = ui_music_search->text();
ui_music_search->setText(last_area_search);
}
- else {
+ else
+ {
ui_area_list->hide();
ui_music_list->show();
last_area_search = ui_music_search->text();
ui_music_search->setText(last_music_search);
}
on_music_search_edited(ui_music_search->text());
-
}
void Courtroom::ping_server()
{
ping_timer.start();
is_pinging = true;
- ao_app->send_server_packet(
- new AOPacket("CH", {QString::number(m_cid)}));
+ ao_app->send_server_packet(AOPacket("CH", {QString::number(m_cid)}));
}
qint64 Courtroom::pong()
{
if (!is_pinging)
+ {
return -1;
+ }
is_pinging = false;
return ping_timer.elapsed();
}
-void Courtroom::start_clock(int id)
-{
- if (id >= 0 && id < max_clocks && ui_clock[id] != nullptr)
- {
- ui_clock[id]->start();
- }
-}
-
void Courtroom::start_clock(int id, qint64 msecs)
{
if (id >= 0 && id < max_clocks && ui_clock[id] != nullptr)
@@ -5755,10 +6355,13 @@ void Courtroom::set_clock(int id, qint64 msecs)
void Courtroom::skip_clocks(qint64 msecs)
{
// Loop through all the timers
- for (int i = 0; i < max_clocks; i++) {
+ for (int i = 0; i < max_clocks; i++)
+ {
// Only skip time on active clocks
if (ui_clock[i]->active())
+ {
ui_clock[i]->skip(msecs);
+ }
}
}
@@ -5789,25 +6392,22 @@ void Courtroom::set_clock_visibility(int id, bool visible)
void Courtroom::truncate_label_text(QWidget *p_widget, QString p_identifier)
{
QString filename = "courtroom_design.ini";
- pos_size_type design_ini_result =
- ao_app->get_element_dimensions(p_identifier, filename);
+ pos_size_type design_ini_result = ao_app->get_element_dimensions(p_identifier, filename);
// Get the width of the element as defined by the current theme
// Cast to make sure we're working with one of the two supported widget types
QLabel *p_label = qobject_cast(p_widget);
QCheckBox *p_checkbox = qobject_cast(p_widget);
- if (p_checkbox == nullptr &&
- p_label ==
- nullptr) { // i.e. the given p_widget isn't a QLabel or a QCheckBox
+ if (p_checkbox == nullptr && p_label == nullptr)
+ { // i.e. the given p_widget isn't a QLabel or a QCheckBox
qWarning() << "Tried to truncate an unsupported widget:" << p_identifier;
return;
}
// translate the text for the widget we're working with so we truncate the right string
- QString label_text_tr =
- QCoreApplication::translate(p_widget->metaObject()->className(), "%1")
- .arg((p_label != nullptr ? p_label->text() : p_checkbox->text()));
- if (label_text_tr.endsWith("…") || label_text_tr.endsWith("…")) {
+ QString label_text_tr = QCoreApplication::translate(p_widget->metaObject()->className(), "%1").arg((p_label != nullptr ? p_label->text() : p_checkbox->text()));
+ if (label_text_tr.endsWith("…") || label_text_tr.endsWith("…"))
+ {
qInfo() << "Truncation aborted for label text" << label_text_tr << ", label text was already truncated!";
return;
}
@@ -5815,54 +6415,43 @@ void Courtroom::truncate_label_text(QWidget *p_widget, QString p_identifier)
int checkbox_width = AOApplication::style()->pixelMetric(QStyle::PM_IndicatorWidth) + AOApplication::style()->pixelMetric(QStyle::PM_CheckBoxLabelSpacing);
int label_theme_width = (p_label != nullptr ? design_ini_result.width : (design_ini_result.width - checkbox_width));
- int label_px_width =
- p_widget->fontMetrics().boundingRect(label_text_tr).width(); // pixel width of our translated text
- if (!p_widget->toolTip().startsWith(label_text_tr)) // don't want to append this multiple times
+ int label_px_width = p_widget->fontMetrics().boundingRect(label_text_tr).width(); // pixel width of our translated text
+ if (!p_widget->toolTip().startsWith(label_text_tr)) // don't want to append this multiple times
+ {
p_widget->setToolTip(label_text_tr + "\n" + p_widget->toolTip());
+ }
// we can't do much with a 0-width widget, and there's no need to truncate if
// the theme gives us enough space
- if (label_theme_width <= 0 || label_px_width < label_theme_width) {
- qDebug().nospace() << "Truncation aborted for label text " << label_text_tr
- << ", either theme width <= 0 or label width < theme width.";
+ if (label_theme_width <= 0 || label_px_width < label_theme_width)
+ {
+ qDebug().nospace() << "Truncation aborted for label text " << label_text_tr << ", either theme width <= 0 or label width < theme width.";
return;
}
QString truncated_label = label_text_tr;
int truncated_px_width = label_px_width;
- while (truncated_px_width > label_theme_width && truncated_label != "…") {
+ while (truncated_px_width > label_theme_width && truncated_label != "…")
+ {
truncated_label.chop(2);
truncated_label.append("…");
- truncated_px_width =
- p_widget->fontMetrics().boundingRect(truncated_label).width();
+ truncated_px_width = p_widget->fontMetrics().boundingRect(truncated_label).width();
}
- if (truncated_label == "…") {
+ if (truncated_label == "…")
+ {
// Safeguard against edge case where label text is shorter in px than '…',
// causing an infinite loop. Additionally, having just an ellipse for a
// label looks strange, so we don't set the new label.
- qWarning() << "Potential infinite loop prevented: Label text "
- << label_text_tr
- << "truncated to '…', so truncation was aborted.";
+ qWarning() << "Potential infinite loop prevented: Label text " << label_text_tr << "truncated to '…', so truncation was aborted.";
return;
}
if (p_label != nullptr)
+ {
p_label->setText(truncated_label);
+ }
else if (p_checkbox != nullptr)
+ {
p_checkbox->setText(truncated_label);
- qDebug().nospace() << "Truncated label text from " << label_text_tr << " ("
- << label_px_width << "px) to " << truncated_label << " ("
- << truncated_px_width << "px)";
-}
-
-Courtroom::~Courtroom()
-{
- //save sound settings
- Options::getInstance().setMusicVolume(ui_music_slider->value());
- Options::getInstance().setSfxVolume(ui_sfx_slider->value());
- Options::getInstance().setBlipVolume(ui_blip_slider->value());
-
- delete music_player;
- delete sfx_player;
- delete objection_player;
- delete blip_player;
+ }
+ qDebug().nospace() << "Truncated label text from " << label_text_tr << " (" << label_px_width << "px) to " << truncated_label << " (" << truncated_px_width << "px)";
}
diff --git a/include/courtroom.h b/src/courtroom.h
similarity index 86%
rename from include/courtroom.h
rename to src/courtroom.h
index 0b26247..cdcd1e1 100644
--- a/include/courtroom.h
+++ b/src/courtroom.h
@@ -1,5 +1,4 @@
-#ifndef COURTROOM_H
-#define COURTROOM_H
+#pragma once
#include "aoapplication.h"
#include "aoblipplayer.h"
@@ -36,12 +35,12 @@
#include
#include
#include
+#include
#include
#include
#include
#include
#include
-#include
#include
#include
@@ -56,11 +55,11 @@
#if QT_VERSION >= QT_VERSION_CHECK(5, 10, 0)
#include //added in Qt 5.10
#endif
+#include
#include