From eca2cd02f41ae5496a0cb1f393fe82c44e593603 Mon Sep 17 00:00:00 2001 From: Cerapter Date: Tue, 7 Aug 2018 21:10:47 +0200 Subject: [PATCH] Inline blue text now stops the character from talking. --- courtroom.cpp | 40 ++++++++++++++++++++++++++++++++++++++++ courtroom.h | 8 ++++++++ 2 files changed, 48 insertions(+) diff --git a/courtroom.cpp b/courtroom.cpp index 7c11834..3a5173c 100644 --- a/courtroom.cpp +++ b/courtroom.cpp @@ -1195,11 +1195,17 @@ void Courtroom::handle_chatmessage_3() bool text_is_blue = m_chatmessage[TEXT_COLOR].toInt() == BLUE; if (!text_is_blue && text_state == 1) + { //talking f_anim_state = 2; + entire_message_is_blue = false; + } else + { //idle f_anim_state = 3; + entire_message_is_blue = true; + } if (f_anim_state <= anim_state) return; @@ -1536,6 +1542,10 @@ void Courtroom::start_chat_ticking() tick_pos = 0; blip_pos = 0; + // Just in case we somehow got inline blue text left over from a previous message, + // let's set it to false. + inline_blue_depth = 0; + // At the start of every new message, we set the text speed to the default. current_display_speed = 3; chat_tick_timer->start(message_display_speed[current_display_speed]); @@ -1656,6 +1666,18 @@ void Courtroom::chat_tick() { inline_colour_stack.push(INLINE_BLUE); ui_vp_message->insertHtml("" + f_character + ""); + + // Increase how deep we are in inline blues. + inline_blue_depth++; + + // Here, we check if the entire message is blue. + // If it isn't, we stop talking. + if (!entire_message_is_blue) + { + QString f_char = m_chatmessage[CHAR_NAME]; + QString f_emote = m_chatmessage[EMOTE]; + ui_vp_player_char->play_idle(f_char, f_emote); + } } else if (f_character == ")" and !next_character_is_not_special and !inline_colour_stack.empty()) @@ -1664,6 +1686,24 @@ void Courtroom::chat_tick() { inline_colour_stack.pop(); ui_vp_message->insertHtml("" + f_character + ""); + + // Decrease how deep we are in inline blues. + // Just in case, we do a check if we're above zero, but we should be. + if (inline_blue_depth > 0) + { + inline_blue_depth--; + // Here, we check if the entire message is blue. + // If it isn't, we start talking if we have completely climbed out of inline blues. + if (!entire_message_is_blue) + { + if (inline_blue_depth == 0) + { + QString f_char = m_chatmessage[CHAR_NAME]; + QString f_emote = m_chatmessage[EMOTE]; + ui_vp_player_char->play_talking(f_char, f_emote); + } + } + } } else { diff --git a/courtroom.h b/courtroom.h index b3342db..df0883c 100644 --- a/courtroom.h +++ b/courtroom.h @@ -172,6 +172,14 @@ private: int current_display_speed = 3; int message_display_speed[7] = {30, 40, 50, 60, 75, 100, 120}; + // This is for checking if the character should start talking again + // when an inline blue text ends. + bool entire_message_is_blue = false; + + // And this is the inline 'talking checker'. Counts how 'deep' we are + // in inline blues. + int inline_blue_depth = 0; + QVector char_list; QVector evidence_list; QVector music_list;