Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 32 additions & 1 deletion src/courtroom.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3506,6 +3506,27 @@ void Courtroom::handle_ic_speaking()
start_chat_ticking();
}

struct PauseInfo
{
int multiplier;
int digit_count;
};

// returns multiplier and number of digits to skip
static PauseInfo parse_pause_multiplier(const QString &text, int start_pos)
{
// matches upto 999 (and 1000) and also prevents leading zeros
static QRegularExpression pause_regex("^([1-9]\\d{0,2}|1000)");
QRegularExpressionMatch match = pause_regex.match(text.mid(start_pos));
if (match.hasMatch())
{
int value = match.captured(1).toInt();
int length = match.capturedLength(0);
return {value, length};
}
return {1, 0}; // default: multiplier=1, no digits to skip
}

QString Courtroom::filter_ic_text(QString p_text, bool html, int target_pos, int default_color)
{
QString p_text_escaped;
Expand Down Expand Up @@ -3723,6 +3744,12 @@ QString Courtroom::filter_ic_text(QString p_text, bool html, int target_pos, int
if (f_character == "s" || f_character == "f" || f_character == "p") // screenshake/flash/pause
{
skip = true;
// also skip any following digits
if (f_character == "p")
{
PauseInfo info = parse_pause_multiplier(p_text, check_pos + f_char_bytes);
check_pos += info.digit_count;
}
}

parse_escape_seq = false;
Expand Down Expand Up @@ -4201,6 +4228,7 @@ void Courtroom::start_chat_ticking()

tick_pos = 0;
blip_ticker = 0;
pause_multiplier = 1;
text_crawl = Options::getInstance().textCrawlSpeed();
blip_rate = Options::getInstance().blipRate();
blank_blip = Options::getInstance().blankBlip();
Expand Down Expand Up @@ -4420,6 +4448,9 @@ void Courtroom::chat_tick()
if (f_character == "p")
{
formatting_char = true;
PauseInfo info = parse_pause_multiplier(f_message, tick_pos);
pause_multiplier = info.multiplier;
tick_pos += info.digit_count;
}
next_character_is_not_special = false;
}
Expand All @@ -4443,7 +4474,7 @@ void Courtroom::chat_tick()
{
if (f_character == "p")
{
chat_tick_timer->start(100); // wait the pause lol
chat_tick_timer->start(pause_base_ms * pause_multiplier);
}
else
{
Expand Down
7 changes: 7 additions & 0 deletions src/courtroom.h
Original file line number Diff line number Diff line change
Expand Up @@ -378,6 +378,8 @@ class Courtroom : public QMainWindow
int real_tick_pos = 0;
// used to determine how often blips sound
int blip_ticker = 0;
// pause multiplier for \p{numbers}
int pause_multiplier = 1;
int blip_rate = 2;
int rainbow_counter = 0;
bool rainbow_appended = false;
Expand Down Expand Up @@ -450,6 +452,11 @@ class Courtroom : public QMainWindow
// amount by which we multiply the delay when we parse punctuation chars
const int punctuation_modifier = 3;

// maximum pause multiplier for \p{numbers} so it does not just pause forever
const int pause_multiplier_max = 1000;
// base pause duration for a \p with no digits
const int pause_base_ms = 100;

// amount of ghost blocks
int ghost_blocks = 0;

Expand Down
Loading