Skip to content

Commit c87e390

Browse files
authored
Merge branch 'master' into logfix
2 parents cf81436 + 461fb81 commit c87e390

1 file changed

Lines changed: 37 additions & 5 deletions

File tree

src/courtroom.cpp

Lines changed: 37 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3506,6 +3506,29 @@ void Courtroom::handle_ic_speaking()
35063506
start_chat_ticking();
35073507
}
35083508

3509+
struct PauseInfo
3510+
{
3511+
int ms;
3512+
int digit_count;
3513+
};
3514+
3515+
static std::optional<PauseInfo> parse_pause_duration(const QString &text, int start_pos)
3516+
{
3517+
int pos = start_pos;
3518+
while (pos < text.length() && text[pos].isDigit())
3519+
{
3520+
pos++;
3521+
}
3522+
3523+
if (pos == start_pos)
3524+
{
3525+
return PauseInfo{1000, 0};
3526+
}
3527+
3528+
int value = qMin(10000, text.mid(start_pos, pos - start_pos).toInt());
3529+
return std::optional<PauseInfo>{PauseInfo{value, pos - start_pos}};
3530+
}
3531+
35093532
QString Courtroom::filter_ic_text(QString p_text, bool html, int target_pos, int default_color)
35103533
{
35113534
QString p_text_escaped;
@@ -3723,6 +3746,13 @@ QString Courtroom::filter_ic_text(QString p_text, bool html, int target_pos, int
37233746
if (f_character == "s" || f_character == "f" || f_character == "p") // screenshake/flash/pause
37243747
{
37253748
skip = true;
3749+
if (f_character == "p") // also skip any following digits
3750+
{
3751+
if (auto info = parse_pause_duration(p_text, check_pos + f_char_bytes))
3752+
{
3753+
check_pos += info->digit_count;
3754+
}
3755+
}
37263756
}
37273757

37283758
parse_escape_seq = false;
@@ -4420,6 +4450,13 @@ void Courtroom::chat_tick()
44204450
if (f_character == "p")
44214451
{
44224452
formatting_char = true;
4453+
if (auto info = parse_pause_duration(f_message, tick_pos))
4454+
{
4455+
tick_pos += info->digit_count;
4456+
real_tick_pos += f_char_length;
4457+
chat_tick_timer->start(info->ms);
4458+
return;
4459+
}
44234460
}
44244461
next_character_is_not_special = false;
44254462
}
@@ -4441,11 +4478,6 @@ void Courtroom::chat_tick()
44414478

44424479
if ((msg_delay <= 0 && tick_pos < f_message.size() - 1) || formatting_char)
44434480
{
4444-
if (f_character == "p")
4445-
{
4446-
chat_tick_timer->start(100); // wait the pause lol
4447-
}
4448-
else
44494481
{
44504482
chat_tick_timer->start(0); // Don't bother rendering anything out as we're
44514483
// doing the SPEED. (there's latency otherwise)

0 commit comments

Comments
 (0)