From 07e1127096d4e47f39facc43ecbf94007c8e08b8 Mon Sep 17 00:00:00 2001 From: windrammer <31085911+likeawindrammer@users.noreply.github.com> Date: Tue, 4 Aug 2020 09:03:40 -0600 Subject: Fix current_display_speed overflow (#232) --- src/courtroom.cpp | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) (limited to 'src/courtroom.cpp') diff --git a/src/courtroom.cpp b/src/courtroom.cpp index 98b6a9c3..d727b81a 100644 --- a/src/courtroom.cpp +++ b/src/courtroom.cpp @@ -2914,6 +2914,12 @@ void Courtroom::chat_tick() next_character_is_not_special = false; } + // 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 ((message_display_speed[current_display_speed] <= 0 && tick_pos < f_message.size() - 1) || formatting_char) { @@ -2942,12 +2948,6 @@ void Courtroom::chat_tick() ui_vp_message->ensureCursorVisible(); - // Keep the speed at bay. - if (current_display_speed < 0) - current_display_speed = 0; - else if (current_display_speed > 6) - current_display_speed = 6; - // Blip player and real tick pos ticker if (!formatting_char && (f_character != ' ' || blank_blip)) { if (blip_ticker % blip_rate == 0) { -- cgit From 630518020a385391469f0b710a8a59cd2984c2c7 Mon Sep 17 00:00:00 2001 From: windrammer <31085911+likeawindrammer@users.noreply.github.com> Date: Tue, 4 Aug 2020 09:09:27 -0600 Subject: Fix music display disappearing on theme reload (#233) --- src/courtroom.cpp | 1 + 1 file changed, 1 insertion(+) (limited to 'src/courtroom.cpp') diff --git a/src/courtroom.cpp b/src/courtroom.cpp index d727b81a..8223024d 100644 --- a/src/courtroom.cpp +++ b/src/courtroom.cpp @@ -636,6 +636,7 @@ void Courtroom::set_widgets() } ui_music_display->play("music_display"); + ui_music_display->set_play_once(false); if (is_ao2_bg) { set_size_and_pos(ui_ic_chat_message, "ao2_ic_chat_message"); -- cgit From 0ce60d66a779ee91f85ebc9f92b2fe52c632b868 Mon Sep 17 00:00:00 2001 From: windrammer <31085911+likeawindrammer@users.noreply.github.com> Date: Wed, 5 Aug 2020 08:18:08 -0600 Subject: Fix not using custom chatbox's colors (#228) * Fix not using custom chatbox's colors Moved set_text_color_dropdown() to after current_char is actually updated with the selected char. Otherwise set_text_color_dropdown will try to update the colors with either nothing as character, or with the previously selected character. Use get_chat() so it actually gets the name of the custom chatbox instead of using the same name as the character. Remove the extra "c" since get_chat_color it's already called with this "c" in place. * Fix previous fix crashing the client on DRO servers For some reason the client would work just fine if set_text_color_dropdown() was called only once after updating the character selected by the user. But when joining a DRO server the client would crash just before loading the music. * Improve comment with where crash happens * Fix get_chat_markdown to get the custom chatbox on misc of the char instead of trying to find the character folder on misc * Fix client using the current character colors on other people's messages Also remove the comment explaining the crash if set_text_color_dropdown is removed from set_widgets * Fix loading custom colors loading after the message was added to the log --- src/courtroom.cpp | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) (limited to 'src/courtroom.cpp') diff --git a/src/courtroom.cpp b/src/courtroom.cpp index 8223024d..a0c7e2c1 100644 --- a/src/courtroom.cpp +++ b/src/courtroom.cpp @@ -1238,6 +1238,8 @@ void Courtroom::update_character(int p_cid) current_char = f_char; current_side = ao_app->get_char_side(current_char); + set_text_color_dropdown(); + current_emote_page = 0; current_emote = 0; @@ -1879,11 +1881,19 @@ void Courtroom::handle_chatmessage(QStringList *p_contents) ic_chatlog_history.removeFirst(); } - append_ic_text(m_chatmessage[MESSAGE], f_showname, "", m_chatmessage[TEXT_COLOR].toInt()); - QString f_char = m_chatmessage[CHAR_NAME]; QString f_custom_theme = ao_app->get_char_shouts(f_char); + // Load the colors in case it's using a custom chatbox with custom colors. + // Or reload the default ones in case it's not using custom colors + color_rgb_list.clear(); + for (int c = 0; c < max_colors; ++c) { + QColor color = ao_app->get_chat_color("c" + QString::number(c), f_char); + color_rgb_list.append(color); + } + + append_ic_text(m_chatmessage[MESSAGE], f_showname, "", m_chatmessage[TEXT_COLOR].toInt()); + // if an objection is used if (objection_mod <= 4 && objection_mod >= 1) { switch (objection_mod) { -- cgit From 102ca4d64143ecb9401fdb1627ada00194d58dd1 Mon Sep 17 00:00:00 2001 From: scatterflower Date: Sat, 15 Aug 2020 19:47:24 -0500 Subject: Create brushes for area list once --- src/courtroom.cpp | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) (limited to 'src/courtroom.cpp') diff --git a/src/courtroom.cpp b/src/courtroom.cpp index 98b6a9c3..54034f84 100644 --- a/src/courtroom.cpp +++ b/src/courtroom.cpp @@ -70,6 +70,14 @@ Courtroom::Courtroom(AOApplication *p_ao_app) : QMainWindow() ui_background = new AOImage(this, ao_app); + free_brush = *new QBrush(ao_app->get_color("area_free_color", "courtroom_design.ini")); + lfp_brush = *new QBrush(ao_app->get_color("area_lfp_color", "courtroom_design.ini")); + casing_brush = *new QBrush(ao_app->get_color("area_casing_color", "courtroom_design.ini")); + recess_brush = *new QBrush(ao_app->get_color("area_recess_color", "courtroom_design.ini")); + rp_brush = *new QBrush(ao_app->get_color("area_rp_color", "courtroom_design.ini")); + gaming_brush = *new QBrush(ao_app->get_color("area_gaming_color", "courtroom_design.ini")); + locked_brush = *new QBrush(ao_app->get_color("area_locked_color", "courtroom_design.ini")); + ui_viewport = new QWidget(this); ui_vp_background = new AOScene(ui_viewport, ao_app); ui_vp_speedlines = new AOMovie(ui_viewport, ao_app); @@ -1433,15 +1441,6 @@ void Courtroom::list_areas() ui_area_list->clear(); // ui_music_search->setText(""); - QString f_file = "courtroom_design.ini"; - - QBrush free_brush(ao_app->get_color("area_free_color", f_file)); - QBrush lfp_brush(ao_app->get_color("area_lfp_color", f_file)); - QBrush casing_brush(ao_app->get_color("area_casing_color", f_file)); - QBrush recess_brush(ao_app->get_color("area_recess_color", f_file)); - QBrush rp_brush(ao_app->get_color("area_rp_color", f_file)); - QBrush gaming_brush(ao_app->get_color("area_gaming_color", f_file)); - QBrush locked_brush(ao_app->get_color("area_locked_color", f_file)); int n_listed_areas = 0; -- cgit From 11250e13864dc5e3cdd799b02498905c58db55ea Mon Sep 17 00:00:00 2001 From: scatterflower Date: Sun, 16 Aug 2020 06:50:19 -0500 Subject: Ensure consistent behavior in IC log, clarify showname logic, and define constants for minimum and maximum packet sizes --- src/courtroom.cpp | 34 +++++++++++++++------------------- 1 file changed, 15 insertions(+), 19 deletions(-) (limited to 'src/courtroom.cpp') diff --git a/src/courtroom.cpp b/src/courtroom.cpp index 98b6a9c3..5f7a6134 100644 --- a/src/courtroom.cpp +++ b/src/courtroom.cpp @@ -1765,19 +1765,16 @@ void Courtroom::handle_chatmessage(QStringList *p_contents) // Instead of checking for whether a message has at least chatmessage_size // amount of packages, we'll check if it has at least 15. // That was the original chatmessage_size. - if (p_contents->size() < 15) + if (p_contents->size() < MS_MINIMUM) return; - for (int n_string = 0; n_string < chatmessage_size; ++n_string) { - // m_chatmessage[n_string] = p_contents->at(n_string); - + for (int n_string = 0; n_string < MS_MAXIMUM; ++n_string) { // Note that we have added stuff that vanilla clients and servers simply // won't send. So now, we have to check if the thing we want even exists // amongst the packet's content. We also have to check if the server even // supports CCCC's IC features, or if it's just japing us. Also, don't // forget! A size 15 message will have indices from 0 to 14. - if (n_string < p_contents->size() && - (n_string < 15 || ao_app->cccc_ic_support_enabled)) { + if (n_string < p_contents->size() && (n_string < MS_MINIMUM || ao_app->cccc_ic_support_enabled)) { m_chatmessage[n_string] = p_contents->at(n_string); } else { @@ -1786,27 +1783,26 @@ void Courtroom::handle_chatmessage(QStringList *p_contents) } int f_char_id = m_chatmessage[CHAR_ID].toInt(); + const bool is_spectator = (f_char_id == -1); - if (f_char_id >= 0 && f_char_id >= char_list.size()) + if (f_char_id >= char_list.size()) return; - if (mute_map.value(m_chatmessage[CHAR_ID].toInt())) return; - QString f_showname; - if (f_char_id > -1 && - (m_chatmessage[SHOWNAME].isEmpty() || !ui_showname_enable->isChecked())) { - f_showname = ao_app->get_showname(char_list.at(f_char_id).name); + QString f_displayname; + if (!is_spectator && (m_chatmessage[SHOWNAME].isEmpty() || !ui_showname_enable->isChecked())) { + f_displayname = ao_app->get_showname(char_list.at(f_char_id).name); } else { - f_showname = m_chatmessage[SHOWNAME]; + f_displayname = m_chatmessage[SHOWNAME]; } - if (f_showname.trimmed() - .isEmpty()) // Pure whitespace showname, get outta here. - f_showname = m_chatmessage[CHAR_NAME]; + // If chatblank is enabled, use the character's name for logs + if (f_displayname.trimmed().isEmpty()) + f_displayname = ao_app->get_showname(char_list.at(f_char_id).name); - QString f_message = f_showname + ": " + m_chatmessage[MESSAGE] + '\n'; + QString f_message = f_displayname + ": " + m_chatmessage[MESSAGE] + '\n'; // Remove undesired newline chars m_chatmessage[MESSAGE].remove("\n"); chatmessage_is_empty = @@ -1868,7 +1864,7 @@ void Courtroom::handle_chatmessage(QStringList *p_contents) f_charname = ao_app->get_showname(char_list.at(f_char_id).name); chatlogpiece *temp = - new chatlogpiece(f_charname, f_showname, m_chatmessage[MESSAGE], false, m_chatmessage[TEXT_COLOR].toInt()); + new chatlogpiece(f_charname, f_displayname, m_chatmessage[MESSAGE], false, m_chatmessage[TEXT_COLOR].toInt()); ic_chatlog_history.append(*temp); if (ao_app->get_auto_logging_enabled()) ao_app->append_to_file(temp->get_full(), ao_app->log_filename, true); @@ -1878,7 +1874,7 @@ void Courtroom::handle_chatmessage(QStringList *p_contents) ic_chatlog_history.removeFirst(); } - append_ic_text(m_chatmessage[MESSAGE], f_showname, "", m_chatmessage[TEXT_COLOR].toInt()); + append_ic_text(m_chatmessage[MESSAGE], f_displayname, "", m_chatmessage[TEXT_COLOR].toInt()); QString f_char = m_chatmessage[CHAR_NAME]; QString f_custom_theme = ao_app->get_char_shouts(f_char); -- cgit From 079ce93b85ecc25e338d61614318fb6ed6cce696 Mon Sep 17 00:00:00 2001 From: scatterflower Date: Sun, 16 Aug 2020 07:06:53 -0500 Subject: Remove clientside doublepost checking --- src/courtroom.cpp | 15 ++------------- 1 file changed, 2 insertions(+), 13 deletions(-) (limited to 'src/courtroom.cpp') diff --git a/src/courtroom.cpp b/src/courtroom.cpp index 5f7a6134..f26645ff 100644 --- a/src/courtroom.cpp +++ b/src/courtroom.cpp @@ -1792,9 +1792,11 @@ void Courtroom::handle_chatmessage(QStringList *p_contents) QString f_displayname; if (!is_spectator && (m_chatmessage[SHOWNAME].isEmpty() || !ui_showname_enable->isChecked())) { + // If the users is not a spectator and showname is disabled, use the character's name f_displayname = ao_app->get_showname(char_list.at(f_char_id).name); } else { + // Otherwise, use the showname f_displayname = m_chatmessage[SHOWNAME]; } @@ -1803,20 +1805,7 @@ void Courtroom::handle_chatmessage(QStringList *p_contents) f_displayname = ao_app->get_showname(char_list.at(f_char_id).name); QString f_message = f_displayname + ": " + m_chatmessage[MESSAGE] + '\n'; - // Remove undesired newline chars - m_chatmessage[MESSAGE].remove("\n"); - chatmessage_is_empty = - m_chatmessage[MESSAGE] == " " || m_chatmessage[MESSAGE] == ""; - if (f_char_id >= 0 && !chatmessage_is_empty && - f_message == previous_ic_message) // Not a system message - return; - - if (f_char_id <= -1) - previous_ic_message = - ""; // System messages don't care about repeating themselves - else - previous_ic_message = f_message; bool ok; int objection_mod = m_chatmessage[OBJECTION_MOD].toInt( &ok, 10); // checks if its a custom obj. -- cgit From cd3ddfe16c423fede1164aa95a36b65caab100e4 Mon Sep 17 00:00:00 2001 From: scatterflower Date: Sun, 16 Aug 2020 07:21:49 -0500 Subject: Update brushes on theme reload --- src/courtroom.cpp | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) (limited to 'src/courtroom.cpp') diff --git a/src/courtroom.cpp b/src/courtroom.cpp index 54034f84..0b0f6226 100644 --- a/src/courtroom.cpp +++ b/src/courtroom.cpp @@ -70,14 +70,6 @@ Courtroom::Courtroom(AOApplication *p_ao_app) : QMainWindow() ui_background = new AOImage(this, ao_app); - free_brush = *new QBrush(ao_app->get_color("area_free_color", "courtroom_design.ini")); - lfp_brush = *new QBrush(ao_app->get_color("area_lfp_color", "courtroom_design.ini")); - casing_brush = *new QBrush(ao_app->get_color("area_casing_color", "courtroom_design.ini")); - recess_brush = *new QBrush(ao_app->get_color("area_recess_color", "courtroom_design.ini")); - rp_brush = *new QBrush(ao_app->get_color("area_rp_color", "courtroom_design.ini")); - gaming_brush = *new QBrush(ao_app->get_color("area_gaming_color", "courtroom_design.ini")); - locked_brush = *new QBrush(ao_app->get_color("area_locked_color", "courtroom_design.ini")); - ui_viewport = new QWidget(this); ui_vp_background = new AOScene(ui_viewport, ao_app); ui_vp_speedlines = new AOMovie(ui_viewport, ao_app); @@ -942,6 +934,14 @@ void Courtroom::set_widgets() ui_spectator->setToolTip(tr("Become a spectator. You won't be able to " "interact with the in-character screen.")); + free_brush = *new QBrush(ao_app->get_color("area_free_color", "courtroom_design.ini")); + lfp_brush = *new QBrush(ao_app->get_color("area_lfp_color", "courtroom_design.ini")); + casing_brush = *new QBrush(ao_app->get_color("area_casing_color", "courtroom_design.ini")); + recess_brush = *new QBrush(ao_app->get_color("area_recess_color", "courtroom_design.ini")); + rp_brush = *new QBrush(ao_app->get_color("area_rp_color", "courtroom_design.ini")); + gaming_brush = *new QBrush(ao_app->get_color("area_gaming_color", "courtroom_design.ini")); + locked_brush = *new QBrush(ao_app->get_color("area_locked_color", "courtroom_design.ini")); + refresh_evidence(); } -- cgit From 507180d164e2b96653522f81d737f9ef3d7b9483 Mon Sep 17 00:00:00 2001 From: scatterflower Date: Sun, 16 Aug 2020 08:37:12 -0500 Subject: Clean up logic in handle_chatmessage() --- src/courtroom.cpp | 47 ++++++++++++++++------------------------------- 1 file changed, 16 insertions(+), 31 deletions(-) (limited to 'src/courtroom.cpp') diff --git a/src/courtroom.cpp b/src/courtroom.cpp index f26645ff..3f723974 100644 --- a/src/courtroom.cpp +++ b/src/courtroom.cpp @@ -1804,29 +1804,27 @@ void Courtroom::handle_chatmessage(QStringList *p_contents) if (f_displayname.trimmed().isEmpty()) f_displayname = ao_app->get_showname(char_list.at(f_char_id).name); - QString f_message = f_displayname + ": " + m_chatmessage[MESSAGE] + '\n'; - - bool ok; - int objection_mod = m_chatmessage[OBJECTION_MOD].toInt( - &ok, 10); // checks if its a custom obj. + // Check if a custom objection is in use + int objection_mod = 0; QString custom_objection = ""; - if (!ok && m_chatmessage[OBJECTION_MOD].contains("4&")) { + if (m_chatmessage[OBJECTION_MOD].contains("4&")) { objection_mod = 4; - custom_objection = m_chatmessage[OBJECTION_MOD].split( - "4&")[1]; // takes the name of custom objection. + custom_objection = m_chatmessage[OBJECTION_MOD].split("4&")[1]; // takes the name of custom objection. + } + else{ + objection_mod = m_chatmessage[OBJECTION_MOD].toInt(); } - // Stop the chat arrow from animating - ui_vp_chat_arrow->stop(); + // Reset IC display + ui_vp_chat_arrow->stop(); text_state = 0; anim_state = 0; ui_vp_objection->stop(); chat_tick_timer->stop(); ui_vp_evidence_display->reset(); - // Hey, our message showed up! Cool! - if (m_chatmessage[MESSAGE] == ui_ic_chat_message->text().remove("\n") && - m_chatmessage[CHAR_ID].toInt() == m_cid) { + // Reset UI elements after client message gets sent + if (m_chatmessage[CHAR_ID].toInt() == m_cid) { ui_ic_chat_message->clear(); if (ui_additive->isChecked()) ui_ic_chat_message->insert(" "); @@ -1848,12 +1846,8 @@ void Courtroom::handle_chatmessage(QStringList *p_contents) // Let the server handle actually checking if they're allowed to do this. is_additive = m_chatmessage[ADDITIVE].toInt() == 1; - QString f_charname = ""; - if (f_char_id >= 0) - f_charname = ao_app->get_showname(char_list.at(f_char_id).name); - chatlogpiece *temp = - new chatlogpiece(f_charname, f_displayname, m_chatmessage[MESSAGE], false, m_chatmessage[TEXT_COLOR].toInt()); + new chatlogpiece(f_displayname, f_displayname, m_chatmessage[MESSAGE], false, m_chatmessage[TEXT_COLOR].toInt()); ic_chatlog_history.append(*temp); if (ao_app->get_auto_logging_enabled()) ao_app->append_to_file(temp->get_full(), ao_app->log_filename, true); @@ -1888,26 +1882,17 @@ void Courtroom::handle_chatmessage(QStringList *p_contents) // case 4 is AO2 only case 4: if (custom_objection != "") { - ui_vp_objection->play("custom_objections/" + custom_objection, f_char, - f_custom_theme, shout_stay_time); - objection_player->play("custom_objections/" + - custom_objection.split('.')[0], - f_char, f_custom_theme); + ui_vp_objection->play("custom_objections/" + custom_objection, f_char, f_custom_theme, shout_stay_time); + objection_player->play("custom_objections/" + custom_objection.split('.')[0], f_char, f_custom_theme); } else { - ui_vp_objection->play("custom", f_char, f_custom_theme, - shout_stay_time); + ui_vp_objection->play("custom", f_char, f_custom_theme, shout_stay_time); objection_player->play("custom", f_char, f_custom_theme); } break; - default: - qDebug() << "W: Logic error in objection switch statement!"; + m_chatmessage[EMOTE_MOD] = 1; } sfx_player->clear(); // Objection played! Cut all sfx. - int emote_mod = m_chatmessage[EMOTE_MOD].toInt(); - - if (emote_mod == 0) - m_chatmessage[EMOTE_MOD] = 1; } else handle_chatmessage_2(); -- cgit From 42d939614f2ebe30b087405bed49dd7f3ebc172a Mon Sep 17 00:00:00 2001 From: scatterflower Date: Sun, 16 Aug 2020 10:59:06 -0500 Subject: Fix improper bolding behavior due to malformed string literal --- src/courtroom.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/courtroom.cpp') diff --git a/src/courtroom.cpp b/src/courtroom.cpp index 98b6a9c3..de1273b6 100644 --- a/src/courtroom.cpp +++ b/src/courtroom.cpp @@ -975,7 +975,7 @@ void Courtroom::set_font(QWidget *widget, QString class_name, } } bool bold = ao_app->get_design_element(p_identifier + "_bold", design_file, p_char) == - 1; // is the font bold or not? + "1"; // is the font bold or not? bool antialias = ao_app->get_design_element(p_identifier + "_sharp", design_file, p_char) != "1"; // is the font anti-aliased or not? -- cgit From 1c5b097f654d16e0dde47f7ae62d236427077cb7 Mon Sep 17 00:00:00 2001 From: scatterflower Date: Sun, 16 Aug 2020 12:43:26 -0500 Subject: further cleanup of chat handler --- src/courtroom.cpp | 58 +++++++++++++++++++++++++++++++------------------------ 1 file changed, 33 insertions(+), 25 deletions(-) (limited to 'src/courtroom.cpp') diff --git a/src/courtroom.cpp b/src/courtroom.cpp index 3b3f6991..bc8405ce 100644 --- a/src/courtroom.cpp +++ b/src/courtroom.cpp @@ -1762,6 +1762,36 @@ void Courtroom::on_chat_return_pressed() ao_app->send_server_packet(new AOPacket("MS", packet_contents)); } +void Courtroom::reset_ic(){ + ui_vp_chat_arrow->stop(); + text_state = 0; + anim_state = 0; + ui_vp_objection->stop(); + chat_tick_timer->stop(); + ui_vp_evidence_display->reset(); +} + +void Courtroom::reset_ui(){ + if (m_chatmessage[CHAR_ID].toInt() == m_cid) { + ui_ic_chat_message->clear(); + if (ui_additive->isChecked()) + ui_ic_chat_message->insert(" "); + objection_state = 0; + realization_state = 0; + screenshake_state = 0; + is_presenting_evidence = false; + if (!ao_app->is_stickypres_enabled()) + ui_pre->setChecked(false); + ui_hold_it->set_image("holdit"); + ui_objection->set_image("objection"); + ui_take_that->set_image("takethat"); + ui_custom_objection->set_image("custom"); + ui_realization->set_image("realization"); + ui_screenshake->set_image("screenshake"); + ui_evidence_present->set_image("present"); + } +} + void Courtroom::handle_chatmessage(QStringList *p_contents) { // Instead of checking for whether a message has at least chatmessage_size @@ -1818,32 +1848,10 @@ void Courtroom::handle_chatmessage(QStringList *p_contents) } // Reset IC display - ui_vp_chat_arrow->stop(); - text_state = 0; - anim_state = 0; - ui_vp_objection->stop(); - chat_tick_timer->stop(); - ui_vp_evidence_display->reset(); + reset_ic(); // Reset UI elements after client message gets sent - if (m_chatmessage[CHAR_ID].toInt() == m_cid) { - ui_ic_chat_message->clear(); - if (ui_additive->isChecked()) - ui_ic_chat_message->insert(" "); - objection_state = 0; - realization_state = 0; - screenshake_state = 0; - is_presenting_evidence = false; - if (!ao_app->is_stickypres_enabled()) - ui_pre->setChecked(false); - ui_hold_it->set_image("holdit"); - ui_objection->set_image("objection"); - ui_take_that->set_image("takethat"); - ui_custom_objection->set_image("custom"); - ui_realization->set_image("realization"); - ui_screenshake->set_image("screenshake"); - ui_evidence_present->set_image("present"); - } + reset_ui(); // Let the server handle actually checking if they're allowed to do this. is_additive = m_chatmessage[ADDITIVE].toInt() == 1; @@ -1870,7 +1878,7 @@ void Courtroom::handle_chatmessage(QStringList *p_contents) color_rgb_list.append(color); } - append_ic_text(m_chatmessage[MESSAGE], f_showname, "", m_chatmessage[TEXT_COLOR].toInt()); + append_ic_text(m_chatmessage[MESSAGE], f_displayname, "", m_chatmessage[TEXT_COLOR].toInt()); // if an objection is used if (objection_mod <= 4 && objection_mod >= 1) { -- cgit From 95725eb129f72231b0615a35cee2299c74c9a6a8 Mon Sep 17 00:00:00 2001 From: scatterflower Date: Sun, 16 Aug 2020 13:53:16 -0500 Subject: fix incorrect emote modifier --- src/courtroom.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'src/courtroom.cpp') diff --git a/src/courtroom.cpp b/src/courtroom.cpp index bc8405ce..04a79605 100644 --- a/src/courtroom.cpp +++ b/src/courtroom.cpp @@ -1613,7 +1613,7 @@ void Courtroom::on_chat_return_pressed() if (f_emote_mod == 0) f_emote_mod = 1; else if (f_emote_mod == 5 && ao_app->prezoom_enabled) - f_emote_mod = 4; + f_emote_mod = 6; } else { if (f_emote_mod == 1) @@ -1772,7 +1772,6 @@ void Courtroom::reset_ic(){ } void Courtroom::reset_ui(){ - if (m_chatmessage[CHAR_ID].toInt() == m_cid) { ui_ic_chat_message->clear(); if (ui_additive->isChecked()) ui_ic_chat_message->insert(" "); @@ -1789,7 +1788,6 @@ void Courtroom::reset_ui(){ ui_realization->set_image("realization"); ui_screenshake->set_image("screenshake"); ui_evidence_present->set_image("present"); - } } void Courtroom::handle_chatmessage(QStringList *p_contents) @@ -1851,7 +1849,9 @@ void Courtroom::handle_chatmessage(QStringList *p_contents) reset_ic(); // Reset UI elements after client message gets sent - reset_ui(); + if (m_chatmessage[CHAR_ID].toInt() == m_cid) { + reset_ui(); + } // Let the server handle actually checking if they're allowed to do this. is_additive = m_chatmessage[ADDITIVE].toInt() == 1; -- cgit From 3c031db2ea3bfe56072b32ce240875b597014c16 Mon Sep 17 00:00:00 2001 From: scatterflower Date: Sun, 16 Aug 2020 14:14:26 -0500 Subject: fix check for negative char_id --- src/courtroom.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/courtroom.cpp') diff --git a/src/courtroom.cpp b/src/courtroom.cpp index 04a79605..943c2d4f 100644 --- a/src/courtroom.cpp +++ b/src/courtroom.cpp @@ -1815,7 +1815,7 @@ void Courtroom::handle_chatmessage(QStringList *p_contents) int f_char_id = m_chatmessage[CHAR_ID].toInt(); const bool is_spectator = (f_char_id == -1); - if (f_char_id >= char_list.size()) + if (f_char_id < 0 || f_char_id >= char_list.size()) return; if (mute_map.value(m_chatmessage[CHAR_ID].toInt())) return; -- cgit From 4b7efc8536f4ea518eb43483e3805255f36ada75 Mon Sep 17 00:00:00 2001 From: scatterflower Date: Sun, 16 Aug 2020 14:17:58 -0500 Subject: allow -1 charid for system messages --- src/courtroom.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/courtroom.cpp') diff --git a/src/courtroom.cpp b/src/courtroom.cpp index 943c2d4f..fa55ba8e 100644 --- a/src/courtroom.cpp +++ b/src/courtroom.cpp @@ -1815,7 +1815,7 @@ void Courtroom::handle_chatmessage(QStringList *p_contents) int f_char_id = m_chatmessage[CHAR_ID].toInt(); const bool is_spectator = (f_char_id == -1); - if (f_char_id < 0 || f_char_id >= char_list.size()) + if (f_char_id < -1 || f_char_id >= char_list.size()) return; if (mute_map.value(m_chatmessage[CHAR_ID].toInt())) return; -- cgit From 8712ed3ca14dfe571101dcc35c3b3a7206aaa1fc Mon Sep 17 00:00:00 2001 From: scatterflower Date: Sun, 16 Aug 2020 17:47:05 -0500 Subject: Don't hang IC due to invalid emote mod --- src/courtroom.cpp | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'src/courtroom.cpp') diff --git a/src/courtroom.cpp b/src/courtroom.cpp index fa55ba8e..164537d1 100644 --- a/src/courtroom.cpp +++ b/src/courtroom.cpp @@ -2058,6 +2058,13 @@ void Courtroom::handle_chatmessage_2() set_scene(m_chatmessage[DESK_MOD], m_chatmessage[SIDE]); int emote_mod = m_chatmessage[EMOTE_MOD].toInt(); + // Deal with invalid emote modifiers + if(emote_mod < 0 || (emote_mod > 2 && emote_mod < 5) || emote_mod > 6){ + if(emote_mod == 4) + emote_mod = 6; // Addresses issue with an old bug that sent the wrong emote modifier for zoompre + else + emote_mod = 0; + } if (ao_app->flipping_enabled && m_chatmessage[FLIP].toInt() == 1) ui_vp_player_char->set_flipped(true); -- cgit From c5f8fc8f96a58d6059781136c6ea37f332ea2ead Mon Sep 17 00:00:00 2001 From: scatterflower Date: Sun, 16 Aug 2020 21:48:50 -0500 Subject: make suggested changes from code review --- src/courtroom.cpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'src/courtroom.cpp') diff --git a/src/courtroom.cpp b/src/courtroom.cpp index 164537d1..a31bd0a7 100644 --- a/src/courtroom.cpp +++ b/src/courtroom.cpp @@ -2059,8 +2059,9 @@ void Courtroom::handle_chatmessage_2() int emote_mod = m_chatmessage[EMOTE_MOD].toInt(); // Deal with invalid emote modifiers - if(emote_mod < 0 || (emote_mod > 2 && emote_mod < 5) || emote_mod > 6){ - if(emote_mod == 4) + if (emote_mod != 0 && emote_mod != 1 && emote_mod != 2 \ + && emote_mod != 5 && emote_mod != 6) { + if (emote_mod == 4) emote_mod = 6; // Addresses issue with an old bug that sent the wrong emote modifier for zoompre else emote_mod = 0; -- cgit From ae7c36e609d5571afc62193e5158f98c6cf5b4e7 Mon Sep 17 00:00:00 2001 From: scatterflower Date: Sun, 16 Aug 2020 21:53:05 -0500 Subject: use proper syntax to instansiate qbrush --- src/courtroom.cpp | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) (limited to 'src/courtroom.cpp') diff --git a/src/courtroom.cpp b/src/courtroom.cpp index a31bd0a7..b0699cb5 100644 --- a/src/courtroom.cpp +++ b/src/courtroom.cpp @@ -935,13 +935,13 @@ void Courtroom::set_widgets() ui_spectator->setToolTip(tr("Become a spectator. You won't be able to " "interact with the in-character screen.")); - free_brush = *new QBrush(ao_app->get_color("area_free_color", "courtroom_design.ini")); - lfp_brush = *new QBrush(ao_app->get_color("area_lfp_color", "courtroom_design.ini")); - casing_brush = *new QBrush(ao_app->get_color("area_casing_color", "courtroom_design.ini")); - recess_brush = *new QBrush(ao_app->get_color("area_recess_color", "courtroom_design.ini")); - rp_brush = *new QBrush(ao_app->get_color("area_rp_color", "courtroom_design.ini")); - gaming_brush = *new QBrush(ao_app->get_color("area_gaming_color", "courtroom_design.ini")); - locked_brush = *new QBrush(ao_app->get_color("area_locked_color", "courtroom_design.ini")); + free_brush = QBrush(ao_app->get_color("area_free_color", "courtroom_design.ini")); + lfp_brush = QBrush(ao_app->get_color("area_lfp_color", "courtroom_design.ini")); + casing_brush = QBrush(ao_app->get_color("area_casing_color", "courtroom_design.ini")); + recess_brush = QBrush(ao_app->get_color("area_recess_color", "courtroom_design.ini")); + rp_brush = QBrush(ao_app->get_color("area_rp_color", "courtroom_design.ini")); + gaming_brush = QBrush(ao_app->get_color("area_gaming_color", "courtroom_design.ini")); + locked_brush = QBrush(ao_app->get_color("area_locked_color", "courtroom_design.ini")); refresh_evidence(); } -- cgit From 359cad73d40fff68ee51a8a81d37e9d18a8b7407 Mon Sep 17 00:00:00 2001 From: scatterflower Date: Sun, 16 Aug 2020 21:55:14 -0500 Subject: use shownames in log properly --- src/courtroom.cpp | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'src/courtroom.cpp') diff --git a/src/courtroom.cpp b/src/courtroom.cpp index b0699cb5..5100ee80 100644 --- a/src/courtroom.cpp +++ b/src/courtroom.cpp @@ -1856,8 +1856,12 @@ void Courtroom::handle_chatmessage(QStringList *p_contents) // Let the server handle actually checking if they're allowed to do this. is_additive = m_chatmessage[ADDITIVE].toInt() == 1; + QString f_charname = ""; + if (f_char_id >= 0) + f_charname = ao_app->get_showname(char_list.at(f_char_id).name); + chatlogpiece *temp = - new chatlogpiece(f_displayname, f_displayname, m_chatmessage[MESSAGE], false, m_chatmessage[TEXT_COLOR].toInt()); + new chatlogpiece(f_charname, f_displayname, m_chatmessage[MESSAGE], false, m_chatmessage[TEXT_COLOR].toInt()); ic_chatlog_history.append(*temp); if (ao_app->get_auto_logging_enabled()) ao_app->append_to_file(temp->get_full(), ao_app->log_filename, true); -- cgit From ecb0ee42a3a399c092eafdf2ac60faaad4bf119f Mon Sep 17 00:00:00 2001 From: scatterflower Date: Sun, 16 Aug 2020 21:59:44 -0500 Subject: clang format --- src/courtroom.cpp | 196 +++++++++++++++++++++++++++++------------------------- 1 file changed, 106 insertions(+), 90 deletions(-) (limited to 'src/courtroom.cpp') diff --git a/src/courtroom.cpp b/src/courtroom.cpp index 5100ee80..be7588a5 100644 --- a/src/courtroom.cpp +++ b/src/courtroom.cpp @@ -935,13 +935,19 @@ void Courtroom::set_widgets() ui_spectator->setToolTip(tr("Become a spectator. You won't be able to " "interact with the in-character screen.")); - free_brush = QBrush(ao_app->get_color("area_free_color", "courtroom_design.ini")); - lfp_brush = QBrush(ao_app->get_color("area_lfp_color", "courtroom_design.ini")); - casing_brush = QBrush(ao_app->get_color("area_casing_color", "courtroom_design.ini")); - recess_brush = QBrush(ao_app->get_color("area_recess_color", "courtroom_design.ini")); + free_brush = + QBrush(ao_app->get_color("area_free_color", "courtroom_design.ini")); + lfp_brush = + QBrush(ao_app->get_color("area_lfp_color", "courtroom_design.ini")); + casing_brush = + QBrush(ao_app->get_color("area_casing_color", "courtroom_design.ini")); + recess_brush = + QBrush(ao_app->get_color("area_recess_color", "courtroom_design.ini")); rp_brush = QBrush(ao_app->get_color("area_rp_color", "courtroom_design.ini")); - gaming_brush = QBrush(ao_app->get_color("area_gaming_color", "courtroom_design.ini")); - locked_brush = QBrush(ao_app->get_color("area_locked_color", "courtroom_design.ini")); + gaming_brush = + QBrush(ao_app->get_color("area_gaming_color", "courtroom_design.ini")); + locked_brush = + QBrush(ao_app->get_color("area_locked_color", "courtroom_design.ini")); refresh_evidence(); } @@ -966,28 +972,29 @@ void Courtroom::set_font(QWidget *widget, QString class_name, { QString design_file = "courtroom_fonts.ini"; if (f_pointsize <= 0) - f_pointsize = ao_app->get_design_element(p_identifier, design_file, p_char).toInt(); + f_pointsize = + ao_app->get_design_element(p_identifier, design_file, p_char).toInt(); if (font_name == "") font_name = - ao_app->get_design_element(p_identifier + "_font", design_file, p_char); - QString f_color_result = ao_app->get_design_element(p_identifier + "_color", design_file, p_char); + ao_app->get_design_element(p_identifier + "_font", design_file, p_char); + QString f_color_result = + ao_app->get_design_element(p_identifier + "_color", design_file, p_char); QColor f_color(0, 0, 0); - if (f_color_result != "") - { + if (f_color_result != "") { QStringList color_list = f_color_result.split(","); - if (color_list.size() >= 3) - { + if (color_list.size() >= 3) { f_color.setRed(color_list.at(0).toInt()); f_color.setGreen(color_list.at(1).toInt()); f_color.setBlue(color_list.at(2).toInt()); } } - bool bold = ao_app->get_design_element(p_identifier + "_bold", design_file, p_char) == - "1"; // is the font bold or not? - bool antialias = - ao_app->get_design_element(p_identifier + "_sharp", design_file, p_char) != - "1"; // is the font anti-aliased or not? + bool bold = + ao_app->get_design_element(p_identifier + "_bold", design_file, p_char) == + "1"; // is the font bold or not? + bool antialias = ao_app->get_design_element(p_identifier + "_sharp", + design_file, p_char) != + "1"; // is the font anti-aliased or not? this->set_qfont(widget, class_name, get_qfont(font_name, f_pointsize, antialias), f_color, bold); @@ -1138,8 +1145,8 @@ void Courtroom::set_background(QString p_background, bool display) // Populate the dropdown list with all pos that exist on this bg QStringList pos_list = {}; for (QString key : default_pos.keys()) { - if (file_exists(ao_app->get_image_suffix( - ao_app->get_background_path(key)))) { + if (file_exists( + ao_app->get_image_suffix(ao_app->get_background_path(key)))) { pos_list.append(default_pos[key]); } } @@ -1293,8 +1300,7 @@ void Courtroom::update_character(int p_cid) { custom_obj_menu->clear(); if (file_exists(ao_app->get_image_suffix( - ao_app->get_character_path(current_char, "custom")))) - { + ao_app->get_character_path(current_char, "custom")))) { ui_custom_objection->show(); QAction *action = custom_obj_menu->addAction("Default"); custom_obj_menu->setDefaultAction(action); @@ -1312,8 +1318,7 @@ void Courtroom::update_character(int p_cid) QDir::Files); for (const QString &filename : custom_obj) { QAction *action = custom_obj_menu->addAction(filename); - if (custom_obj_menu->defaultAction() == nullptr) - { + if (custom_obj_menu->defaultAction() == nullptr) { custom_obj_menu->setDefaultAction(action); objection_custom = action->text(); } @@ -1444,7 +1449,6 @@ void Courtroom::list_areas() ui_area_list->clear(); // ui_music_search->setText(""); - int n_listed_areas = 0; for (int n_area = 0; n_area < area_list.size(); ++n_area) { @@ -1762,32 +1766,34 @@ void Courtroom::on_chat_return_pressed() ao_app->send_server_packet(new AOPacket("MS", packet_contents)); } -void Courtroom::reset_ic(){ - ui_vp_chat_arrow->stop(); - text_state = 0; - anim_state = 0; - ui_vp_objection->stop(); - chat_tick_timer->stop(); - ui_vp_evidence_display->reset(); +void Courtroom::reset_ic() +{ + ui_vp_chat_arrow->stop(); + text_state = 0; + anim_state = 0; + ui_vp_objection->stop(); + chat_tick_timer->stop(); + ui_vp_evidence_display->reset(); } -void Courtroom::reset_ui(){ - ui_ic_chat_message->clear(); - if (ui_additive->isChecked()) - ui_ic_chat_message->insert(" "); - objection_state = 0; - realization_state = 0; - screenshake_state = 0; - is_presenting_evidence = false; - if (!ao_app->is_stickypres_enabled()) - ui_pre->setChecked(false); - ui_hold_it->set_image("holdit"); - ui_objection->set_image("objection"); - ui_take_that->set_image("takethat"); - ui_custom_objection->set_image("custom"); - ui_realization->set_image("realization"); - ui_screenshake->set_image("screenshake"); - ui_evidence_present->set_image("present"); +void Courtroom::reset_ui() +{ + ui_ic_chat_message->clear(); + if (ui_additive->isChecked()) + ui_ic_chat_message->insert(" "); + objection_state = 0; + realization_state = 0; + screenshake_state = 0; + is_presenting_evidence = false; + if (!ao_app->is_stickypres_enabled()) + ui_pre->setChecked(false); + ui_hold_it->set_image("holdit"); + ui_objection->set_image("objection"); + ui_take_that->set_image("takethat"); + ui_custom_objection->set_image("custom"); + ui_realization->set_image("realization"); + ui_screenshake->set_image("screenshake"); + ui_evidence_present->set_image("present"); } void Courtroom::handle_chatmessage(QStringList *p_contents) @@ -1804,7 +1810,8 @@ void Courtroom::handle_chatmessage(QStringList *p_contents) // amongst the packet's content. We also have to check if the server even // supports CCCC's IC features, or if it's just japing us. Also, don't // forget! A size 15 message will have indices from 0 to 14. - if (n_string < p_contents->size() && (n_string < MS_MINIMUM || ao_app->cccc_ic_support_enabled)) { + if (n_string < p_contents->size() && + (n_string < MS_MINIMUM || ao_app->cccc_ic_support_enabled)) { m_chatmessage[n_string] = p_contents->at(n_string); } else { @@ -1821,8 +1828,10 @@ void Courtroom::handle_chatmessage(QStringList *p_contents) return; QString f_displayname; - if (!is_spectator && (m_chatmessage[SHOWNAME].isEmpty() || !ui_showname_enable->isChecked())) { - // If the users is not a spectator and showname is disabled, use the character's name + if (!is_spectator && + (m_chatmessage[SHOWNAME].isEmpty() || !ui_showname_enable->isChecked())) { + // If the users is not a spectator and showname is disabled, use the + // character's name f_displayname = ao_app->get_showname(char_list.at(f_char_id).name); } else { @@ -1839,10 +1848,11 @@ void Courtroom::handle_chatmessage(QStringList *p_contents) QString custom_objection = ""; if (m_chatmessage[OBJECTION_MOD].contains("4&")) { objection_mod = 4; - custom_objection = m_chatmessage[OBJECTION_MOD].split("4&")[1]; // takes the name of custom objection. + custom_objection = m_chatmessage[OBJECTION_MOD].split( + "4&")[1]; // takes the name of custom objection. } - else{ - objection_mod = m_chatmessage[OBJECTION_MOD].toInt(); + else { + objection_mod = m_chatmessage[OBJECTION_MOD].toInt(); } // Reset IC display @@ -1861,7 +1871,8 @@ void Courtroom::handle_chatmessage(QStringList *p_contents) f_charname = ao_app->get_showname(char_list.at(f_char_id).name); chatlogpiece *temp = - new chatlogpiece(f_charname, f_displayname, m_chatmessage[MESSAGE], false, m_chatmessage[TEXT_COLOR].toInt()); + new chatlogpiece(f_charname, f_displayname, m_chatmessage[MESSAGE], false, + m_chatmessage[TEXT_COLOR].toInt()); ic_chatlog_history.append(*temp); if (ao_app->get_auto_logging_enabled()) ao_app->append_to_file(temp->get_full(), ao_app->log_filename, true); @@ -1870,7 +1881,7 @@ void Courtroom::handle_chatmessage(QStringList *p_contents) log_maximum_blocks > 0) { ic_chatlog_history.removeFirst(); } - + QString f_char = m_chatmessage[CHAR_NAME]; QString f_custom_theme = ao_app->get_char_shouts(f_char); @@ -1882,7 +1893,8 @@ void Courtroom::handle_chatmessage(QStringList *p_contents) color_rgb_list.append(color); } - append_ic_text(m_chatmessage[MESSAGE], f_displayname, "", m_chatmessage[TEXT_COLOR].toInt()); + append_ic_text(m_chatmessage[MESSAGE], f_displayname, "", + m_chatmessage[TEXT_COLOR].toInt()); // if an objection is used if (objection_mod <= 4 && objection_mod >= 1) { @@ -1904,11 +1916,15 @@ void Courtroom::handle_chatmessage(QStringList *p_contents) // case 4 is AO2 only case 4: if (custom_objection != "") { - ui_vp_objection->play("custom_objections/" + custom_objection, f_char, f_custom_theme, shout_stay_time); - objection_player->play("custom_objections/" + custom_objection.split('.')[0], f_char, f_custom_theme); + ui_vp_objection->play("custom_objections/" + custom_objection, f_char, + f_custom_theme, shout_stay_time); + objection_player->play("custom_objections/" + + custom_objection.split('.')[0], + f_char, f_custom_theme); } else { - ui_vp_objection->play("custom", f_char, f_custom_theme, shout_stay_time); + ui_vp_objection->play("custom", f_char, f_custom_theme, + shout_stay_time); objection_player->play("custom", f_char, f_custom_theme); } break; @@ -2003,11 +2019,10 @@ void Courtroom::handle_chatmessage_2() ->get_design_element("showname_extra_width", "courtroom_design.ini", customchar) .toInt(); - QString align = - ao_app - ->get_design_element("showname_align", "courtroom_design.ini", - customchar) - .toLower(); + QString align = ao_app + ->get_design_element("showname_align", + "courtroom_design.ini", customchar) + .toLower(); if (align == "right") ui_vp_showname->setAlignment(Qt::AlignRight); else if (align == "center") @@ -2039,8 +2054,7 @@ void Courtroom::handle_chatmessage_2() set_font(ui_vp_showname, "", "showname", customchar); } - else - { + else { ui_vp_showname->resize(default_width.width, ui_vp_showname->height()); } } @@ -2063,12 +2077,13 @@ void Courtroom::handle_chatmessage_2() int emote_mod = m_chatmessage[EMOTE_MOD].toInt(); // Deal with invalid emote modifiers - if (emote_mod != 0 && emote_mod != 1 && emote_mod != 2 \ - && emote_mod != 5 && emote_mod != 6) { - if (emote_mod == 4) - emote_mod = 6; // Addresses issue with an old bug that sent the wrong emote modifier for zoompre - else - emote_mod = 0; + if (emote_mod != 0 && emote_mod != 1 && emote_mod != 2 && emote_mod != 5 && + emote_mod != 6) { + if (emote_mod == 4) + emote_mod = 6; // Addresses issue with an old bug that sent the wrong + // emote modifier for zoompre + else + emote_mod = 0; } if (ao_app->flipping_enabled && m_chatmessage[FLIP].toInt() == 1) @@ -2574,7 +2589,8 @@ QString Courtroom::filter_ic_text(QString p_text, bool html, int target_pos, return p_text_escaped; } -void Courtroom::append_ic_text(QString p_text, QString p_name, QString p_action, int color) +void Courtroom::append_ic_text(QString p_text, QString p_name, QString p_action, + int color) { QTextCharFormat bold; QTextCharFormat normal; @@ -2586,8 +2602,7 @@ void Courtroom::append_ic_text(QString p_text, QString p_name, QString p_action, const int old_scrollbar_value = ui_ic_chatlog->verticalScrollBar()->value(); if (p_action == "") - p_text = filter_ic_text(p_text, ao_app->is_colorlog_enabled(), -1, - color); + p_text = filter_ic_text(p_text, ao_app->is_colorlog_enabled(), -1, color); if (log_goes_downwards) { const bool is_scrolled_down = @@ -2810,8 +2825,7 @@ void Courtroom::chat_tick() } QString f_char; QString f_custom_theme; - if (ao_app->is_customchat_enabled()) - { + if (ao_app->is_customchat_enabled()) { f_char = m_chatmessage[CHAR_NAME]; f_custom_theme = ao_app->get_chat(f_char); } @@ -3174,7 +3188,8 @@ void Courtroom::handle_song(QStringList *p_contents) } if (!mute_map.value(n_char)) { - chatlogpiece *temp = new chatlogpiece(str_char, str_show, f_song, true, m_chatmessage[TEXT_COLOR].toInt()); + chatlogpiece *temp = new chatlogpiece(str_char, str_show, f_song, true, + m_chatmessage[TEXT_COLOR].toInt()); ic_chatlog_history.append(*temp); if (ao_app->get_auto_logging_enabled()) ao_app->append_to_file(temp->get_full(), ao_app->log_filename, true); @@ -4100,8 +4115,7 @@ void Courtroom::on_music_list_context_menu_requested(const QPoint &pos) { QMenu *menu = new QMenu(); - menu->addAction(QString(tr("Play Random Song")), this, - SLOT(music_random())); + menu->addAction(QString(tr("Play Random Song")), this, SLOT(music_random())); menu->addSeparator(); menu->addAction(QString(tr("Expand All Categories")), this, SLOT(music_list_expand_all())); @@ -4157,7 +4171,9 @@ void Courtroom::music_synchronize(bool toggle) void Courtroom::music_random() { QList clist; - QTreeWidgetItemIterator it(ui_music_list, QTreeWidgetItemIterator::NotHidden | QTreeWidgetItemIterator::NoChildren); + QTreeWidgetItemIterator it(ui_music_list, + QTreeWidgetItemIterator::NotHidden | + QTreeWidgetItemIterator::NoChildren); while (*it) { clist += (*it); ++it; @@ -4402,7 +4418,8 @@ 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), current_char); + QColor color = + ao_app->get_chat_color("c" + QString::number(c), current_char); color_rgb_list.append(color); color_markdown_start_list.append(ao_app->get_chat_markdown( "c" + QString::number(c) + "_start", current_char)); @@ -4578,10 +4595,7 @@ 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() { @@ -4654,14 +4668,16 @@ void Courtroom::on_showname_enable_clicked() append_ic_text(item.get_message(), item.get_showname(), tr("has played a song")); else - append_ic_text(item.get_message(), item.get_showname(), "", item.get_chat_color()); + append_ic_text(item.get_message(), item.get_showname(), "", + item.get_chat_color()); } else { if (item.is_song()) append_ic_text(item.get_message(), item.get_name(), tr("has played a song")); else - append_ic_text(item.get_message(), item.get_name(), "", item.get_chat_color()); + append_ic_text(item.get_message(), item.get_name(), "", + item.get_chat_color()); } } -- cgit From da002085abf3deab2c51cbabcfb910e78c81656e Mon Sep 17 00:00:00 2001 From: scatterflower Date: Mon, 17 Aug 2020 07:05:37 -0500 Subject: Do not update colors in log for each IC message --- src/courtroom.cpp | 8 -------- 1 file changed, 8 deletions(-) (limited to 'src/courtroom.cpp') diff --git a/src/courtroom.cpp b/src/courtroom.cpp index be7588a5..978cc04d 100644 --- a/src/courtroom.cpp +++ b/src/courtroom.cpp @@ -1885,14 +1885,6 @@ void Courtroom::handle_chatmessage(QStringList *p_contents) QString f_char = m_chatmessage[CHAR_NAME]; QString f_custom_theme = ao_app->get_char_shouts(f_char); - // Load the colors in case it's using a custom chatbox with custom colors. - // Or reload the default ones in case it's not using custom colors - color_rgb_list.clear(); - for (int c = 0; c < max_colors; ++c) { - QColor color = ao_app->get_chat_color("c" + QString::number(c), f_char); - color_rgb_list.append(color); - } - append_ic_text(m_chatmessage[MESSAGE], f_displayname, "", m_chatmessage[TEXT_COLOR].toInt()); -- cgit From 4ada75a3bd0cf57007458b2af6f44c76ac33e575 Mon Sep 17 00:00:00 2001 From: scatterflower Date: Mon, 17 Aug 2020 13:06:35 -0500 Subject: fix statement after break; from case --- src/courtroom.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/courtroom.cpp') diff --git a/src/courtroom.cpp b/src/courtroom.cpp index 978cc04d..cc35a7bd 100644 --- a/src/courtroom.cpp +++ b/src/courtroom.cpp @@ -1919,8 +1919,8 @@ void Courtroom::handle_chatmessage(QStringList *p_contents) shout_stay_time); objection_player->play("custom", f_char, f_custom_theme); } - break; m_chatmessage[EMOTE_MOD] = 1; + break; } sfx_player->clear(); // Objection played! Cut all sfx. } -- cgit From 475a572c3bdb0f1d4a7353b9c61bbfac71888ef9 Mon Sep 17 00:00:00 2001 From: Crystalwarrior Date: Tue, 18 Aug 2020 18:02:53 +0300 Subject: Improved blankposting (#256) * Consolidate blankposting into singular log entries of "no message" instead of spamming the logs repeatedly when someone decides to keep switching emotes Return proper blankpost checking to 2.8.5 (chatmessage_is_empty bool makes sure the chatbox doesn't appear - branch broke that behavior by never setting it) More robust blankpost checking, meaning that passing a competely empty "" string will also count as a blankpost Fix screenshake not working with blankposting by moving it before the chatmessage_is_empty check in start_chack_ticking() stage of the message parsing * Allow user to send blankposts without even having to input a single spacebar, but only if last m_chatmessage CID matches ours. * Reviews are cool and good:ok_hand: allow sending no-text chat message to server without weird cid checks (let the server validate if they want to do STR_OR_EMPTY or just STR) - doesn't break existing behavior and lets servers introduce the new one if they want to Treat all blank/whitespace messages as blankposting and not just single-whitespace. Remove chatmessage_is_empty bool because why the fuck would you even need it if you have m_chatmessage[MESSAGE] already Simplify chatlogpiece log entry to not be a *temp pointer by suggestion * another useless bool destroyed Make "additive" have a very awesome emergent behavior with blankposting - keep showing the chatbox+message while only changing the emotes. Works with preanims too! --- src/courtroom.cpp | 54 +++++++++++++++++++++++++++++++----------------------- 1 file changed, 31 insertions(+), 23 deletions(-) (limited to 'src/courtroom.cpp') diff --git a/src/courtroom.cpp b/src/courtroom.cpp index cc35a7bd..b76a4a63 100644 --- a/src/courtroom.cpp +++ b/src/courtroom.cpp @@ -1538,7 +1538,7 @@ void Courtroom::append_server_chatmessage(QString p_name, QString p_message, void Courtroom::on_chat_return_pressed() { - if (ui_ic_chat_message->text() == "" || is_muted) + if (is_muted) return; if ((anim_state < 3 || text_state < 2) && objection_state == 0) @@ -1863,31 +1863,35 @@ void Courtroom::handle_chatmessage(QStringList *p_contents) reset_ui(); } - // Let the server handle actually checking if they're allowed to do this. - is_additive = m_chatmessage[ADDITIVE].toInt() == 1; - QString f_charname = ""; if (f_char_id >= 0) f_charname = ao_app->get_showname(char_list.at(f_char_id).name); - chatlogpiece *temp = - new chatlogpiece(f_charname, f_displayname, m_chatmessage[MESSAGE], false, - m_chatmessage[TEXT_COLOR].toInt()); - ic_chatlog_history.append(*temp); - if (ao_app->get_auto_logging_enabled()) - ao_app->append_to_file(temp->get_full(), ao_app->log_filename, true); + if (m_chatmessage[MESSAGE].trimmed().isEmpty()) // User-created blankpost + { + m_chatmessage[MESSAGE] = ""; // Turn it into true blankpost + } + + if (!m_chatmessage[MESSAGE].isEmpty() || ic_chatlog_history.isEmpty() || ic_chatlog_history.last().get_message() != "") + { + chatlogpiece log_entry(f_charname, f_displayname, m_chatmessage[MESSAGE], false, + m_chatmessage[TEXT_COLOR].toInt()); + ic_chatlog_history.append(log_entry); + if (ao_app->get_auto_logging_enabled()) + 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) { - ic_chatlog_history.removeFirst(); + while (ic_chatlog_history.size() > log_maximum_blocks && + log_maximum_blocks > 0) { + ic_chatlog_history.removeFirst(); + } + + append_ic_text(m_chatmessage[MESSAGE], f_displayname, "", + m_chatmessage[TEXT_COLOR].toInt()); } QString f_char = m_chatmessage[CHAR_NAME]; QString f_custom_theme = ao_app->get_char_shouts(f_char); - append_ic_text(m_chatmessage[MESSAGE], f_displayname, "", - m_chatmessage[TEXT_COLOR].toInt()); - // if an objection is used if (objection_mod <= 4 && objection_mod >= 1) { switch (objection_mod) { @@ -2763,16 +2767,25 @@ void Courtroom::start_chat_ticking() this->do_flash(); sfx_player->play(ao_app->get_custom_realization(m_chatmessage[CHAR_NAME])); } - if (chatmessage_is_empty) { + int emote_mod = m_chatmessage[EMOTE_MOD].toInt(); // text meme bonanza + if ((emote_mod == 0 || emote_mod == 5) && m_chatmessage[SCREENSHAKE] == "1") { + this->do_screenshake(); + } + if (m_chatmessage[MESSAGE].isEmpty()) { // since the message is empty, it's technically done ticking text_state = 2; + if (m_chatmessage[ADDITIVE] == "1") { + // Cool behavior + ui_vp_chatbox->show(); + ui_vp_message->show(); + } return; } ui_vp_chatbox->show(); ui_vp_message->show(); - if (!is_additive) { + if (m_chatmessage[ADDITIVE] != "1") { ui_vp_message->clear(); real_tick_pos = 0; additive_previous = ""; @@ -2789,11 +2802,6 @@ void Courtroom::start_chat_ticking() blip_player->set_blips(f_gender); - int emote_mod = m_chatmessage[EMOTE_MOD].toInt(); // text meme bonanza - if ((emote_mod == 0 || emote_mod == 5) && m_chatmessage[SCREENSHAKE] == "1") { - this->do_screenshake(); - } - // means text is currently ticking text_state = 1; } -- cgit From cef0ebc6eb2ac549a5475bee332be35ab7f565fc Mon Sep 17 00:00:00 2001 From: Crystalwarrior Date: Wed, 19 Aug 2020 19:16:41 +0300 Subject: IC log rewrite (#259) * Rewrite the IC Log code to drastically reduce code duplication and have both downward and upward mode in the same function Regenerate the IC Log in set_widgets() function, making sure the maximum_blocks is accounted for and clearing the log to prepare for different log mode (upwards/downwards) if it's different from previous Add placeholder text telling the user the direction in which the log will go Remove useless first_message_sent global boolean, a remnant from a w e a k e r c o d e r m a n * Add log_colors boolean to reduce color I/O happening in append_ic_text (optimization meme) Clear the IC log when log_colors setting changes and reload theme is pressed Fix https://github.com/AttorneyOnline/AO2-Client/issues/221 * Add configurable margin between IC log entries Add configurable newline/singleline log mode Options in settings for these * Add optional timestamps * Un-hardcode "played music" from the chatlogpiece and introduce the "action" argument so that "presented evidence" is fully supported now Translate "has presented evidence" Regenerate IC chatlog instead of clearing it, properly updating every element with the new configurations * Go away *temp, code duplication making me shid and cry rn Why is this not done in append_ic_text, or why isn't there a dedicated ic logging func aAAAaaaaAAAaa Fix presenting evidence not being properly logged Fix timestamp being UTC instead of local time (local time will not be as confusing) * okok it was a joke a big ol bamboozle you got gnomed haha rick rolled beaned stickbugged I did NOT copy paste code, no, I actually intended to fix copy pasted code all along. log_ic_text was always planned. (Fix copypasted code for ic_chatlog_history and consolidate it into a single log_ic_text func) --- src/courtroom.cpp | 241 ++++++++++++++++++++++++++---------------------------- 1 file changed, 115 insertions(+), 126 deletions(-) (limited to 'src/courtroom.cpp') diff --git a/src/courtroom.cpp b/src/courtroom.cpp index b76a4a63..fe10e134 100644 --- a/src/courtroom.cpp +++ b/src/courtroom.cpp @@ -109,6 +109,10 @@ Courtroom::Courtroom(AOApplication *p_ao_app) : QMainWindow() log_maximum_blocks = ao_app->get_max_log_size(); log_goes_downwards = ao_app->get_log_goes_downwards(); + log_colors = ao_app->is_colorlog_enabled(); + log_newline = ao_app->get_log_newline(); + log_margin = ao_app->get_log_margin(); + log_timestamp = ao_app->get_log_timestamp(); ui_ms_chatlog = new AOTextArea(this); ui_ms_chatlog->setReadOnly(true); @@ -581,8 +585,20 @@ void Courtroom::set_widgets() ui_vp_objection->move(ui_viewport->x(), ui_viewport->y()); ui_vp_objection->combo_resize(ui_viewport->width(), ui_viewport->height()); + log_maximum_blocks = ao_app->get_max_log_size(); + + bool regenerate = log_goes_downwards != ao_app->get_log_goes_downwards() || log_colors != ao_app->is_colorlog_enabled() || log_newline != ao_app->get_log_newline() || log_margin != ao_app->get_log_margin() || log_timestamp != ao_app->get_log_timestamp(); + log_goes_downwards = ao_app->get_log_goes_downwards(); + log_colors = ao_app->is_colorlog_enabled(); + log_newline = ao_app->get_log_newline(); + log_margin = ao_app->get_log_margin(); + log_timestamp = ao_app->get_log_timestamp(); + if (regenerate) + regenerate_ic_chatlog(); + set_size_and_pos(ui_ic_chatlog, "ic_chatlog"); ui_ic_chatlog->setFrameShape(QFrame::NoFrame); + ui_ic_chatlog->setPlaceholderText(log_goes_downwards ? "▼ Log goes down ▼" : "▲ Log goes up ▲"); set_size_and_pos(ui_ms_chatlog, "ms_chatlog"); ui_ms_chatlog->setFrameShape(QFrame::NoFrame); @@ -1874,17 +1890,8 @@ void Courtroom::handle_chatmessage(QStringList *p_contents) if (!m_chatmessage[MESSAGE].isEmpty() || ic_chatlog_history.isEmpty() || ic_chatlog_history.last().get_message() != "") { - chatlogpiece log_entry(f_charname, f_displayname, m_chatmessage[MESSAGE], false, + log_ic_text(f_charname, f_displayname, m_chatmessage[MESSAGE], "", m_chatmessage[TEXT_COLOR].toInt()); - ic_chatlog_history.append(log_entry); - if (ao_app->get_auto_logging_enabled()) - 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) { - ic_chatlog_history.removeFirst(); - } - append_ic_text(m_chatmessage[MESSAGE], f_displayname, "", m_chatmessage[TEXT_COLOR].toInt()); } @@ -2275,13 +2282,16 @@ void Courtroom::handle_chatmessage_3() if (f_evi_id > 0 && f_evi_id <= local_evidence_list.size()) { // shifted by 1 because 0 is no evidence per legacy standards QString f_image = local_evidence_list.at(f_evi_id - 1).image; - QString f_name = local_evidence_list.at(f_evi_id - 1).name; + QString f_evi_name = local_evidence_list.at(f_evi_id - 1).name; // def jud and hlp should display the evidence icon on the RIGHT side bool is_left_side = !(f_side == "def" || f_side == "hlp" || f_side == "jud" || f_side == "jur"); ui_vp_evidence_display->show_evidence(f_image, is_left_side, ui_sfx_slider->value()); - append_ic_text(f_name, f_showname, "has presented evidence"); + + log_ic_text(m_chatmessage[CHAR_NAME], m_chatmessage[SHOWNAME], f_evi_name, tr("has presented evidence"), + m_chatmessage[TEXT_COLOR].toInt()); + append_ic_text(f_evi_name, f_showname, tr("has presented evidence")); } int emote_mod = m_chatmessage[EMOTE_MOD].toInt(); @@ -2585,107 +2595,107 @@ QString Courtroom::filter_ic_text(QString p_text, bool html, int target_pos, return p_text_escaped; } +void Courtroom::log_ic_text(QString p_name, QString p_showname, + QString p_message, QString p_action, int p_color) +{ + chatlogpiece log_entry(p_name, p_showname, p_message, p_action, + p_color); + ic_chatlog_history.append(log_entry); + if (ao_app->get_auto_logging_enabled()) + 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) { + ic_chatlog_history.removeFirst(); + } +} + void Courtroom::append_ic_text(QString p_text, QString p_name, QString p_action, int color) { QTextCharFormat bold; QTextCharFormat normal; QTextCharFormat italics; + QTextBlockFormat format; bold.setFontWeight(QFont::Bold); normal.setFontWeight(QFont::Normal); italics.setFontItalic(true); + format.setTopMargin(log_margin); const QTextCursor old_cursor = ui_ic_chatlog->textCursor(); const int old_scrollbar_value = ui_ic_chatlog->verticalScrollBar()->value(); - - if (p_action == "") - p_text = filter_ic_text(p_text, ao_app->is_colorlog_enabled(), -1, color); - - if (log_goes_downwards) { - const bool is_scrolled_down = - old_scrollbar_value == ui_ic_chatlog->verticalScrollBar()->maximum(); - - ui_ic_chatlog->moveCursor(QTextCursor::End); - - if (!first_message_sent) { - ui_ic_chatlog->textCursor().insertText(p_name, bold); - first_message_sent = true; - } - else { - ui_ic_chatlog->textCursor().insertText('\n' + p_name, bold); - } - - if (p_action != "") { - ui_ic_chatlog->textCursor().insertText(" " + p_action + ": ", normal); - ui_ic_chatlog->textCursor().insertText(p_text + ".", italics); - } - else { + 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(); + + ui_ic_chatlog->moveCursor(log_goes_downwards ? QTextCursor::End : QTextCursor::Start); + + // Only prepend with newline if log goes downwards + if (log_goes_downwards && need_newline) { + ui_ic_chatlog->textCursor().insertBlock(format); + } + + // Timestamp if we're doing that meme + if (log_timestamp) + ui_ic_chatlog->textCursor().insertText("[" + QDateTime::currentDateTime().toString("h:mm:ss AP") + "] ", normal); + + // Format the name of the actor + ui_ic_chatlog->textCursor().insertText(p_name, bold); + // If action not blank: + if (p_action != "") { + // 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); - ui_ic_chatlog->textCursor().insertHtml(p_text); - } - - // If we got too many blocks in the current log, delete some from the top. - while (ui_ic_chatlog->document()->blockCount() > log_maximum_blocks && - log_maximum_blocks > 0) { - ui_ic_chatlog->moveCursor(QTextCursor::Start); - ui_ic_chatlog->textCursor().select(QTextCursor::BlockUnderCursor); - ui_ic_chatlog->textCursor().removeSelectedText(); - ui_ic_chatlog->textCursor().deleteChar(); - } - - if (old_cursor.hasSelection() || !is_scrolled_down) { - // The user has selected text or scrolled away from the bottom: maintain - // position. - ui_ic_chatlog->setTextCursor(old_cursor); - ui_ic_chatlog->verticalScrollBar()->setValue(old_scrollbar_value); - } - else { - // The user hasn't selected any text and the scrollbar is at the bottom: - // scroll to the bottom. - ui_ic_chatlog->moveCursor(QTextCursor::End); - ui_ic_chatlog->verticalScrollBar()->setValue( - ui_ic_chatlog->verticalScrollBar()->maximum()); - } + // Format the result in italics + ui_ic_chatlog->textCursor().insertText(p_text + ".", italics); } else { - const bool is_scrolled_up = - old_scrollbar_value == ui_ic_chatlog->verticalScrollBar()->minimum(); - - ui_ic_chatlog->moveCursor(QTextCursor::Start); - - ui_ic_chatlog->textCursor().insertText(p_name, bold); - - if (p_action != "") { - ui_ic_chatlog->textCursor().insertText(" " + p_action + ": ", normal); - ui_ic_chatlog->textCursor().insertText(p_text + "." + '\n', italics); - } - 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); - ui_ic_chatlog->textCursor().insertHtml(p_text + "
"); - } + // Format the result according to html + if (log_colors) + ui_ic_chatlog->textCursor().insertHtml(filter_ic_text(p_text, true, -1, color)); + else + ui_ic_chatlog->textCursor().insertText(filter_ic_text(p_text, false), normal); + } - // If we got too many blocks in the current log, delete some from the - // bottom. - while (ui_ic_chatlog->document()->blockCount() > log_maximum_blocks && - log_maximum_blocks > 0) { - ui_ic_chatlog->moveCursor(QTextCursor::End); - ui_ic_chatlog->textCursor().select(QTextCursor::BlockUnderCursor); - ui_ic_chatlog->textCursor().removeSelectedText(); + // Only append with newline if log goes upwards + 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) { + ui_ic_chatlog->moveCursor(log_goes_downwards ? QTextCursor::Start : QTextCursor::End); + ui_ic_chatlog->textCursor().select(QTextCursor::BlockUnderCursor); + ui_ic_chatlog->textCursor().removeSelectedText(); + if (log_goes_downwards) + ui_ic_chatlog->textCursor().deleteChar(); + else ui_ic_chatlog->textCursor().deletePreviousChar(); - } + } - if (old_cursor.hasSelection() || !is_scrolled_up) { - // The user has selected text or scrolled away from the top: maintain - // position. - ui_ic_chatlog->setTextCursor(old_cursor); - ui_ic_chatlog->verticalScrollBar()->setValue(old_scrollbar_value); - } - else { - // The user hasn't selected any text and the scrollbar is at the top: - // scroll to the top. - ui_ic_chatlog->moveCursor(QTextCursor::Start); - ui_ic_chatlog->verticalScrollBar()->setValue( - ui_ic_chatlog->verticalScrollBar()->minimum()); - } + // Finally, scroll the scrollbar to the correct position. + 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 { + // The user hasn't selected any text and the scrollbar is at the bottom: + // scroll to the bottom. + ui_ic_chatlog->moveCursor(log_goes_downwards ? QTextCursor::End : QTextCursor::Start); + ui_ic_chatlog->verticalScrollBar()->setValue( + ui_ic_chatlog->verticalScrollBar()->maximum()); } } @@ -3188,17 +3198,8 @@ void Courtroom::handle_song(QStringList *p_contents) } if (!mute_map.value(n_char)) { - chatlogpiece *temp = new chatlogpiece(str_char, str_show, f_song, true, - m_chatmessage[TEXT_COLOR].toInt()); - ic_chatlog_history.append(*temp); - if (ao_app->get_auto_logging_enabled()) - ao_app->append_to_file(temp->get_full(), ao_app->log_filename, true); - - while (ic_chatlog_history.size() > log_maximum_blocks && - log_maximum_blocks > 0) { - ic_chatlog_history.removeFirst(); - } - + log_ic_text(str_char, str_show, f_song, tr("has played a song"), + m_chatmessage[TEXT_COLOR].toInt()); append_ic_text(f_song_clear, str_show, tr("has played a song")); music_player->play(f_song, channel, looping, effect_flags); @@ -4659,29 +4660,17 @@ void Courtroom::on_guard_clicked() { ui_ic_chat_message->setFocus(); } void Courtroom::on_showname_enable_clicked() { - ui_ic_chatlog->clear(); - first_message_sent = false; + regenerate_ic_chatlog(); + ui_ic_chat_message->setFocus(); +} +void Courtroom::regenerate_ic_chatlog() +{ + ui_ic_chatlog->clear(); foreach (chatlogpiece item, ic_chatlog_history) { - if (ui_showname_enable->isChecked()) { - if (item.is_song()) - append_ic_text(item.get_message(), item.get_showname(), - tr("has played a song")); - else - append_ic_text(item.get_message(), item.get_showname(), "", - item.get_chat_color()); - } - else { - if (item.is_song()) - append_ic_text(item.get_message(), item.get_name(), - tr("has played a song")); - else - append_ic_text(item.get_message(), item.get_name(), "", - item.get_chat_color()); - } + append_ic_text(item.get_message(), ui_showname_enable->isChecked() ? item.get_showname() : item.get_name(), + item.get_action(), item.get_chat_color()); } - - ui_ic_chat_message->setFocus(); } void Courtroom::on_evidence_button_clicked() -- cgit From 9eb0f53db1ae87058458eae267f2a72e3a0a8091 Mon Sep 17 00:00:00 2001 From: scatterflower <2956568+scatterflower@users.noreply.github.com> Date: Wed, 19 Aug 2020 16:40:37 -0500 Subject: Reset BASS when switching devices; drop Qt Multimedia support (#262) * Allow changing audio device on the fly while in a server * Use default audio device if device in config doesn't exist * Automatically change audio device to default when current one is invalid * Destroy Qt Multimedia support It was decided that there was not enough attention being given to Qt Multimedia support to justify its continued maintenance simply as a libre alternative to BASS. While substantial changes to audio were being made in 2.8, the Qt Multimedia support code fell behind in disrepair. It's clear that there is no vested interest in implementing audio features twice for the sake of licensing. When it's time to switch to another audio library, it will be done unilaterally. * CI: Use BASS for Linux build Co-authored-by: oldmud0 --- src/courtroom.cpp | 62 +------------------------------------------------------ 1 file changed, 1 insertion(+), 61 deletions(-) (limited to 'src/courtroom.cpp') diff --git a/src/courtroom.cpp b/src/courtroom.cpp index fe10e134..2484bcb0 100644 --- a/src/courtroom.cpp +++ b/src/courtroom.cpp @@ -3,42 +3,7 @@ Courtroom::Courtroom(AOApplication *p_ao_app) : QMainWindow() { ao_app = p_ao_app; -#ifdef BASSAUDIO - // Change the default audio output device to be the one the user has given - // in his config.ini file for now. - unsigned int a = 0; - BASS_DEVICEINFO info; - - if (ao_app->get_audio_output_device() == "default") { - BASS_Init(-1, 48000, BASS_DEVICE_LATENCY, nullptr, nullptr); - load_bass_opus_plugin(); - } - else { - for (a = 0; BASS_GetDeviceInfo(a, &info); a++) { - if (ao_app->get_audio_output_device() == info.name) { - BASS_SetDevice(a); - BASS_Init(static_cast(a), 48000, BASS_DEVICE_LATENCY, nullptr, - nullptr); - load_bass_opus_plugin(); - qDebug() << info.name << "was set as the default audio output device."; - break; - } - } - } -#elif defined QTAUDIO - - if (ao_app->get_audio_output_device() != "default") { - foreach (const QAudioDeviceInfo &deviceInfo, - QAudioDeviceInfo::availableDevices(QAudio::AudioOutput)) { - if (ao_app->get_audio_output_device() == deviceInfo.deviceName()) { - ao_app->QtAudioDevice = deviceInfo; - qDebug() << deviceInfo.deviceName() - << "was set as the default audio output device."; - break; - } - } - } -#endif + ao_app->initBASS(); qsrand(static_cast(QDateTime::currentMSecsSinceEpoch() / 1000)); @@ -4750,28 +4715,3 @@ Courtroom::~Courtroom() delete objection_player; delete blip_player; } - -#if (defined(_WIN32) || defined(_WIN64)) -void Courtroom::load_bass_opus_plugin() -{ -#ifdef BASSAUDIO - BASS_PluginLoad("bassopus.dll", 0); -#endif -} -#elif (defined(LINUX) || defined(__linux__)) -void Courtroom::load_bass_opus_plugin() -{ -#ifdef BASSAUDIO - BASS_PluginLoad("libbassopus.so", 0); -#endif -} -#elif defined __APPLE__ -void Courtroom::load_bass_opus_plugin() -{ -#ifdef BASSAUDIO - BASS_PluginLoad("libbassopus.dylib", 0); -#endif -} -#else -#error This operating system is unsupported for bass plugins. -#endif -- cgit