From 5be0860278bc65c188331d7a2ef9996c84ed8448 Mon Sep 17 00:00:00 2001 From: in1tiate <32779090+in1tiate@users.noreply.github.com> Date: Tue, 25 Jun 2024 04:34:23 -0500 Subject: [PATCH] Fix color-related UI not honoring chatbox setting (#984) Co-authored-by: Salanto <62221668+Salanto@users.noreply.github.com> --- src/courtroom.cpp | 62 +++++++++++++++++++++++++++++++++++------------ 1 file changed, 46 insertions(+), 16 deletions(-) diff --git a/src/courtroom.cpp b/src/courtroom.cpp index d1acc43..221b7c7 100644 --- a/src/courtroom.cpp +++ b/src/courtroom.cpp @@ -4195,7 +4195,7 @@ 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) + if ((last_misc != current_misc || char_color_rgb_list.size() < max_colors) && Options::getInstance().customChatboxEnabled()) { gen_char_rgb_list(current_misc); } @@ -4265,10 +4265,21 @@ void Courtroom::chat_tick() ui_vp_chat_arrow->setTransformationMode(ao_app->get_misc_scaling(f_custom_theme)); ui_vp_chat_arrow->loadAndPlayAnimation("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) - { - 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)); + if (Options::getInstance().customChatboxEnabled()) + { // chatbox colors + 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)); + } + } + else + { // default colors + for (int c = 0; c < max_colors; ++c) + { + additive_previous = additive_previous.replace("$c" + QString::number(c), default_color_rgb_list.at(c).name(QColor::HexRgb)); + f_message_filtered = f_message_filtered.replace("$c" + QString::number(c), default_color_rgb_list.at(c).name(QColor::HexRgb)); + } } additive_previous = additive_previous + f_message_filtered; real_tick_pos = ui_vp_message->toPlainText().size(); @@ -4433,10 +4444,21 @@ void Courtroom::chat_tick() { // 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) - { - 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)); + if (Options::getInstance().customChatboxEnabled()) + { // use chatbox colors + 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)); + } + } + else + { // just use default colors + for (int c = 0; c < max_colors; ++c) + { + additive_previous = additive_previous.replace("$c" + QString::number(c), default_color_rgb_list.at(c).name(QColor::HexRgb)); + f_message_filtered = f_message_filtered.replace("$c" + QString::number(c), default_color_rgb_list.at(c).name(QColor::HexRgb)); + } } ui_vp_message->setHtml(additive_previous + f_message_filtered); @@ -6201,16 +6223,21 @@ 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 + QString misc_to_check = ""; // default + if (Options::getInstance().customChatboxEnabled()) + { + misc_to_check = ao_app->get_chat(current_char); // chatbox specific + } 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)); + QColor color = ao_app->get_chat_color("c" + QString::number(c), misc_to_check); 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", misc_to_check)); + color_markdown_end_list.append(ao_app->get_chat_markup("c" + QString::number(c) + "_end", misc_to_check)); + color_markdown_remove_list.append(ao_app->get_chat_markup("c" + QString::number(c) + "_remove", misc_to_check) == "1"); + color_markdown_talking_list.append(ao_app->get_chat_markup("c" + QString::number(c) + "_talking", misc_to_check) != "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", misc_to_check); if (color_name.isEmpty()) // Not defined { if (c > 0) @@ -6386,7 +6413,10 @@ void Courtroom::on_reload_theme_clicked() set_widgets(); update_character(m_cid, ui_iniswap_dropdown->itemText(ui_iniswap_dropdown->currentIndex())); enter_courtroom(); - gen_char_rgb_list(ao_app->get_chat(current_char)); + if (Options::getInstance().customChatboxEnabled()) + { + gen_char_rgb_list(ao_app->get_chat(current_char)); + } // to update status on the background set_background(current_background, true);