diff options
Diffstat (limited to 'src')
| -rw-r--r-- | src/aooptionsdialog.cpp | 4 | ||||
| -rw-r--r-- | src/charselect.cpp | 2 | ||||
| -rw-r--r-- | src/chatlogpiece.cpp | 20 | ||||
| -rw-r--r-- | src/courtroom.cpp | 139 | ||||
| -rw-r--r-- | src/demoserver.cpp | 60 | ||||
| -rw-r--r-- | src/packet_distribution.cpp | 36 | ||||
| -rw-r--r-- | src/text_file_functions.cpp | 4 |
7 files changed, 174 insertions, 91 deletions
diff --git a/src/aooptionsdialog.cpp b/src/aooptionsdialog.cpp index 589bc924..6af93ede 100644 --- a/src/aooptionsdialog.cpp +++ b/src/aooptionsdialog.cpp @@ -751,10 +751,10 @@ AOOptionsDialog::AOOptionsDialog(QWidget *parent, AOApplication *p_ao_app) ui_audio_layout->setWidget(row, QFormLayout::LabelRole, ui_bliprate_lbl); ui_bliprate_spinbox = new QSpinBox(ui_audio_widget); - ui_bliprate_spinbox->setMinimum(1); + ui_bliprate_spinbox->setMinimum(0); ui_bliprate_spinbox->setToolTip( tr("Play a blip sound \"once per every X symbols\", where " - "X is the blip rate.")); + "X is the blip rate. 0 plays a blip sound only once.")); ui_audio_layout->setWidget(row, QFormLayout::FieldRole, ui_bliprate_spinbox); diff --git a/src/charselect.cpp b/src/charselect.cpp index ea0a4c46..dce675a5 100644 --- a/src/charselect.cpp +++ b/src/charselect.cpp @@ -243,6 +243,7 @@ void Courtroom::character_loading_finished() delete item; } ui_char_button_list.clear(); + ui_char_list->clear(); } // First, we'll make all the character buttons in the very beginning. @@ -305,7 +306,6 @@ void Courtroom::character_loading_finished() } } ui_char_list->expandAll(); - filter_character_list(); } void Courtroom::filter_character_list() diff --git a/src/chatlogpiece.cpp b/src/chatlogpiece.cpp index f4cb2259..64ffefe8 100644 --- a/src/chatlogpiece.cpp +++ b/src/chatlogpiece.cpp @@ -11,18 +11,19 @@ chatlogpiece::chatlogpiece() } chatlogpiece::chatlogpiece(QString p_name, QString p_showname, - QString p_message, QString p_action, int p_color) + QString p_message, QString p_action, int p_color, bool p_selfname) { name = p_name; showname = p_showname; message = p_message; action = p_action; color = p_color; + selfname = p_selfname; datetime = QDateTime::currentDateTimeUtc(); } chatlogpiece::chatlogpiece(QString p_name, QString p_showname, - QString p_message, QString p_action, int p_color, + QString p_message, QString p_action, int p_color, bool p_selfname, QDateTime p_datetime) { name = p_name; @@ -30,23 +31,10 @@ chatlogpiece::chatlogpiece(QString p_name, QString p_showname, message = p_message; action = p_action; color = p_color; + selfname = p_selfname; datetime = p_datetime.toUTC(); } -QString chatlogpiece::get_name() { return name; } - -QString chatlogpiece::get_showname() { return showname; } - -QString chatlogpiece::get_message() { return message; } - -QDateTime chatlogpiece::get_datetime() { return datetime; } - -QString chatlogpiece::get_action() { return action; } - -QString chatlogpiece::get_datetime_as_string() { return datetime.toString(); } - -int chatlogpiece::get_chat_color() { return color; } - QString chatlogpiece::get_full() { QString full = "["; diff --git a/src/courtroom.cpp b/src/courtroom.cpp index b972e00c..0afbeb24 100644 --- a/src/courtroom.cpp +++ b/src/courtroom.cpp @@ -725,8 +725,9 @@ void Courtroom::set_widgets() log_margin = ao_app->get_log_margin(); log_timestamp = ao_app->get_log_timestamp(); log_timestamp_format = ao_app->get_log_timestamp_format(); - if (regenerate) + if (regenerate) { regenerate_ic_chatlog(); + } set_size_and_pos(ui_ic_chatlog, "ic_chatlog"); ui_ic_chatlog->setFrameShape(QFrame::NoFrame); @@ -1309,13 +1310,13 @@ void Courtroom::done_received() if (char_list.size() > 0) { - set_char_select_page(); set_char_select(); } else { update_character(m_cid); enter_courtroom(); + set_courtroom_size(); } set_mute_list(); @@ -1869,30 +1870,72 @@ void Courtroom::on_chat_return_pressed() packet_contents.append(f_side); - packet_contents.append(get_char_sfx()); - int f_emote_mod = ao_app->get_emote_mod(current_char, current_emote); + QString f_sfx = "1"; +// EMOTE MOD OVERRIDES: + // Emote_mod 2 is only used by objection check later, having it in the char.ini does nothing + if (f_emote_mod == 2) { + f_emote_mod = PREANIM; + } + // No clue what emote_mod 3 is even supposed to be. + if (f_emote_mod == 3) { + f_emote_mod = IDLE; + } + // Emote_mod 4 seems to be a legacy bugfix that just refers it to emote_mod 5 which is zoom emote + if (f_emote_mod == 4) { + f_emote_mod = ZOOM; + } + // If we have "pre" on, and immediate is not checked + if (ui_pre->isChecked() && !ui_immediate->isChecked()) { + // Turn idle into preanim + if (f_emote_mod == IDLE) { + f_emote_mod = PREANIM; + } + // Turn zoom into preanim zoom + else if (f_emote_mod == ZOOM && ao_app->prezoom_enabled) { + f_emote_mod = PREANIM_ZOOM; + } + // Play the sfx + f_sfx = get_char_sfx(); + } + // If we have "pre" off, or immediate is checked + else { + // Turn preanim into idle + if (f_emote_mod == PREANIM) { + f_emote_mod = IDLE; + } + // Turn preanim zoom into zoom + else if (f_emote_mod == PREANIM_ZOOM) { + f_emote_mod = ZOOM; + } - // needed or else legacy won't understand what we're saying - if (objection_state > 0 && ui_pre->isChecked()) { - if (f_emote_mod == 4 || f_emote_mod == 5) - f_emote_mod = 6; - else - f_emote_mod = 2; + // Play the sfx if pre is checked + if (ui_pre->isChecked()) { + f_sfx = get_char_sfx(); + } } - else if (ui_pre->isChecked() && !ui_immediate->isChecked()) { - if (f_emote_mod == 0) - f_emote_mod = 1; - else if (f_emote_mod == 5 && ao_app->prezoom_enabled) - f_emote_mod = 6; + +// TODO: deprecate this garbage. See https://github.com/AttorneyOnline/AO2-Client/issues/692 + // If our objection is enabled + if (objection_state > 0) { + // Turn preanim zoom emote mod into non-pre + if (f_emote_mod == ZOOM) { + f_emote_mod = PREANIM_ZOOM; + } + // Turn it into preanim objection emote mod + else { + f_emote_mod = 2; + } + // Play the sfx + f_sfx = get_char_sfx(); } - else { - if (f_emote_mod == 1) - f_emote_mod = 0; - else if (f_emote_mod == 4) - f_emote_mod = 5; + + // Custom sfx override via sound list dropdown. + if (!custom_sfx.isEmpty() || ui_sfx_dropdown->currentIndex() != 0) { + f_sfx = get_char_sfx(); } + packet_contents.append(f_sfx); packet_contents.append(QString::number(f_emote_mod)); packet_contents.append(QString::number(m_cid)); @@ -2058,7 +2101,7 @@ void Courtroom::reset_ui() ui_screenshake->set_image("screenshake"); ui_evidence_present->set_image("present"); - if (ui_pre->isChecked() && !ao_app->is_stickysounds_enabled()) { + if (!ao_app->is_stickysounds_enabled()) { ui_sfx_dropdown->setCurrentIndex(0); ui_sfx_remove->hide(); custom_sfx = ""; @@ -2205,6 +2248,8 @@ void Courtroom::log_chatmessage(QString f_message, int f_char_id, QString f_show if (f_displayname.trimmed().isEmpty()) f_displayname = f_showname; + bool selfname = f_char_id == m_cid; + if (log_ic_actions) { // Check if a custom objection is in use int objection_mod = 0; @@ -2253,13 +2298,13 @@ void Courtroom::log_chatmessage(QString f_message, int f_char_id, QString f_show } switch (f_log_mode) { case IO_ONLY: - log_ic_text(f_char, f_displayname, shout_message, tr("shouts")); + log_ic_text(f_char, f_displayname, shout_message, tr("shouts"), 0, selfname); break; case DISPLAY_AND_IO: - log_ic_text(f_char, f_displayname, shout_message, tr("shouts")); + log_ic_text(f_char, f_displayname, shout_message, tr("shouts"), 0, selfname); [[fallthrough]]; case DISPLAY_ONLY: - append_ic_text(shout_message, f_displayname, tr("shouts")); + append_ic_text(shout_message, f_displayname, tr("shouts"), 0, selfname); break; } } @@ -2270,13 +2315,13 @@ void Courtroom::log_chatmessage(QString f_message, int f_char_id, QString f_show QString f_evi_name = local_evidence_list.at(f_evi_id - 1).name; switch (f_log_mode) { case IO_ONLY: - log_ic_text(f_showname, f_displayname, f_evi_name, tr("has presented evidence")); + log_ic_text(f_showname, f_displayname, f_evi_name, tr("has presented evidence"), 0, selfname); break; case DISPLAY_AND_IO: - log_ic_text(f_showname, f_displayname, f_evi_name, tr("has presented evidence")); + log_ic_text(f_showname, f_displayname, f_evi_name, tr("has presented evidence"), 0, selfname); [[fallthrough]]; case DISPLAY_ONLY: - append_ic_text(f_evi_name, f_displayname, tr("has presented evidence")); + append_ic_text(f_evi_name, f_displayname, tr("has presented evidence"), 0, selfname); break; } } @@ -2290,13 +2335,13 @@ void Courtroom::log_chatmessage(QString f_message, int f_char_id, QString f_show return; // Skip adding message switch (f_log_mode) { case IO_ONLY: - log_ic_text(f_showname, f_displayname, f_message, "",f_color); + log_ic_text(f_showname, f_displayname, f_message, "", f_color, selfname); break; case DISPLAY_AND_IO: - log_ic_text(f_showname, f_displayname, f_message, "",f_color); + log_ic_text(f_showname, f_displayname, f_message, "", f_color, selfname); [[fallthrough]]; case DISPLAY_ONLY: - append_ic_text(f_message, f_displayname, "",f_color); + append_ic_text(f_message, f_displayname, "", f_color, selfname); break; } if (!ui_showname_enable->isChecked()) @@ -2501,6 +2546,7 @@ void Courtroom::handle_emote_mod(int emote_mod, bool p_immediate) // If immediate is not ticked on... if (!p_immediate) { + play_sfx(); // Skip preanim. handle_ic_speaking(); } @@ -3104,9 +3150,9 @@ QString Courtroom::filter_ic_text(QString p_text, bool html, int target_pos, } void Courtroom::log_ic_text(QString p_name, QString p_showname, - QString p_message, QString p_action, int p_color) + QString p_message, QString p_action, int p_color, bool p_selfname) { - chatlogpiece log_entry(p_name, p_showname, p_message, p_action, p_color); + chatlogpiece log_entry(p_name, p_showname, p_message, p_action, p_color, p_selfname); ic_chatlog_history.append(log_entry); if (ao_app->get_text_logging_enabled() && !ao_app->log_filename.isEmpty()) ao_app->append_to_file(log_entry.get_full(), ao_app->log_filename, true); @@ -3118,16 +3164,22 @@ void Courtroom::log_ic_text(QString p_name, QString p_showname, } void Courtroom::append_ic_text(QString p_text, QString p_name, QString p_action, - int color, QDateTime timestamp) + int color, bool selfname, QDateTime timestamp) { last_ic_message = p_name + ":" + p_text; QTextCharFormat bold; QTextCharFormat normal; QTextCharFormat italics; + QTextCharFormat own_name; + QTextCharFormat other_name; QTextBlockFormat format; bold.setFontWeight(QFont::Bold); normal.setFontWeight(QFont::Normal); italics.setFontItalic(true); + own_name.setFontWeight(QFont::Bold); + own_name.setForeground(ao_app->get_color("ic_chatlog_selfname_color", "courtroom_fonts.ini")); + other_name.setFontWeight(QFont::Bold); + other_name.setForeground(ao_app->get_color("ic_chatlog_showname_color", "courtroom_fonts.ini")); format.setTopMargin(log_margin); const QTextCursor old_cursor = ui_ic_chatlog->textCursor(); const int old_scrollbar_value = ui_ic_chatlog->verticalScrollBar()->value(); @@ -3155,7 +3207,8 @@ void Courtroom::append_ic_text(QString p_text, QString p_name, QString p_action, } // Format the name of the actor - ui_ic_chatlog->textCursor().insertText(p_name, bold); + QTextCharFormat name_format = selfname ? own_name : other_name; + ui_ic_chatlog->textCursor().insertText(p_name, name_format); // Special case for stopping the music if (p_action == tr("has stopped the music")) { ui_ic_chatlog->textCursor().insertText(" " + p_action + ".", normal); @@ -3623,7 +3676,7 @@ void Courtroom::chat_tick() // ! ! ! ! // where ! is the blip sound int b_rate = blip_rate; - // Earrape prevention without using timers, this method is more consistent. + // Overwhelming blip spam prevention, this method is more consistent than timers if (msg_delay != 0 && msg_delay <= 25) { // The default blip speed is 40ms, and if current msg_delay is 25ms, // the formula will result in the blip rate of: @@ -3634,7 +3687,7 @@ void Courtroom::chat_tick() qMax(b_rate, qRound(static_cast<float>(text_crawl) / msg_delay)); } - if (blip_ticker % b_rate == 0) { + if ((blip_rate <= 0 && blip_ticker < 1) || (b_rate > 0 && blip_ticker % b_rate == 0)) { // ignoring white space unless blank_blip is enabled. if (!formatting_char && (f_character != ' ' || blank_blip)) { blip_player->blip_tick(); @@ -3894,13 +3947,14 @@ void Courtroom::handle_song(QStringList *p_contents) } } if (!mute_map.value(n_char)) { + bool selfname = n_char == m_cid; if (is_stop) { - log_ic_text(str_char, str_show, "", tr("has stopped the music")); - append_ic_text("", str_show, tr("has stopped the music")); + log_ic_text(str_char, str_show, "", tr("has stopped the music"), 0, selfname); + append_ic_text("", str_show, tr("has stopped the music"), 0, selfname); } else { - log_ic_text(str_char, str_show, f_song, tr("has played a song")); - append_ic_text(f_song_clear, str_show, tr("has played a song")); + log_ic_text(str_char, str_show, f_song, tr("has played a song"), 0, selfname); + append_ic_text(f_song_clear, str_show, tr("has played a song"), 0, selfname); } } } @@ -4636,8 +4690,9 @@ QString Courtroom::get_char_sfx() if (!custom_sfx.isEmpty()) return custom_sfx; int index = ui_sfx_dropdown->currentIndex(); - if (index == 0) // Default + if (index == 0) { // Default return ao_app->get_sfx_name(current_char, current_emote); + } if (index == 1) // Nothing return "1"; QString sfx = sound_list[index-2].split("=")[0].trimmed(); @@ -5376,7 +5431,7 @@ void Courtroom::regenerate_ic_chatlog() append_ic_text(message, name, item.get_action(), item.get_chat_color(), - item.get_datetime().toLocalTime()); + item.get_selfname(), item.get_datetime().toLocalTime()); } } diff --git a/src/demoserver.cpp b/src/demoserver.cpp index 800d282e..c4f8c158 100644 --- a/src/demoserver.cpp +++ b/src/demoserver.cpp @@ -233,9 +233,39 @@ void DemoServer::handle_packet(AOPacket packet) QString packet = "CT#DEMO#" + tr("min_wait is deprecated. Use the client Settings for minimum wait instead!") + "#1#%"; client_sock->write(packet.toUtf8()); } + else if (contents[1].startsWith("/debug")) + { + QStringList args = contents[1].split(" "); + if (args.size() > 1) + { + bool ok; + int toggle = args.at(1).toInt(&ok); + if (ok && (toggle == 0 || toggle == 1)) { + debug_mode = toggle == 1; + QString packet = "CT#DEMO#" + tr("Setting debug mode to %1").arg(static_cast<int>(debug_mode)) + "#1#%"; + client_sock->write(packet.toUtf8()); + // Debug mode disabled? + if (!debug_mode) { + // Reset the timer + client_sock->write("TI#4#1#0#%"); + client_sock->write("TI#4#3#0#%"); + } + } + else + { + QString packet = "CT#DEMO#" + tr("Valid values are 1 or 0!") + "#1#%"; + client_sock->write(packet.toUtf8()); + } + } + else + { + QString packet = "CT#DEMO#" + tr("Set debug mode using /debug 1 to enable, and /debug 0 to disable, which will use the fifth timer (TI#4) to show the remaining time until next demo line.") + "#1#%"; + client_sock->write(packet.toUtf8()); + } + } else if (contents[1].startsWith("/help")) { - QString packet = "CT#DEMO#" + tr("Available commands:\nload, reload, play, pause, max_wait, help") + "#1#%"; + QString packet = "CT#DEMO#" + tr("Available commands:\nload, reload, play, pause, max_wait, debug, help") + "#1#%"; client_sock->write(packet.toUtf8()); } } @@ -321,8 +351,8 @@ void DemoServer::reset_state() client_sock->write("LE##%"); // Reset timers - client_sock->write("TI#0#3#0#%"); client_sock->write("TI#0#1#0#%"); + client_sock->write("TI#0#3#0#%"); client_sock->write("TI#1#1#0#%"); client_sock->write("TI#1#3#0#%"); client_sock->write("TI#2#1#0#%"); @@ -359,19 +389,25 @@ void DemoServer::playback() AOPacket wait_packet = AOPacket(current_packet); int duration = wait_packet.get_contents().at(0).toInt(); - if (max_wait != -1) { - if (duration + elapsed_time > max_wait) { - duration = qMax(0, max_wait - elapsed_time); - // Skip the difference on the timers - emit skip_timers(wait_packet.get_contents().at(0).toInt() - duration); - } - else if (timer->interval() != 0 && duration + elapsed_time > timer->interval()) { - duration = qMax(0, timer->interval() - elapsed_time); - emit skip_timers(wait_packet.get_contents().at(0).toInt() - duration); - } + // Max wait reached + if (max_wait != -1 && duration + elapsed_time > max_wait) { + duration = qMax(0, max_wait - elapsed_time); + qDebug() << "Max_wait of " << max_wait << " reached. Forcing duration to " << duration << "ms"; + // Skip the difference on the timers + emit skip_timers(wait_packet.get_contents().at(0).toInt() - duration); + } + // Manual user skip, such as with > + else if (timer->remainingTime() > 0) { + qDebug() << "Timer of interval " << timer->interval() << " is being skipped. Forcing to skip " << timer->remainingTime() << "ms on TI# clocks"; + emit skip_timers(timer->remainingTime()); } elapsed_time += duration; timer->start(duration); + if (debug_mode) { + client_sock->write("TI#4#2#%"); + QString debug_timer = "TI#4#0#" + QString::number(duration) + "#%"; + client_sock->write(debug_timer.toUtf8()); + } } else { QString end_packet = "CT#DEMO#" + tr("Reached the end of the demo file. Send /play or > in OOC to restart, or /load to open a new file.") + "#1#%"; diff --git a/src/packet_distribution.cpp b/src/packet_distribution.cpp index 0ddadd8c..0fe25dc5 100644 --- a/src/packet_distribution.cpp +++ b/src/packet_distribution.cpp @@ -240,9 +240,9 @@ void AOApplication::server_packet_received(AOPacket *p_packet) } else if (header == "SC") { - if (!courtroom_constructed || courtroom_loaded) + if (!courtroom_constructed) goto end; - + w_courtroom->clear_chars(); for (int n_element = 0; n_element < f_contents.size(); ++n_element) { QStringList sub_elements = f_contents.at(n_element).split("&"); @@ -256,24 +256,28 @@ void AOApplication::server_packet_received(AOPacket *p_packet) // temporary. the CharsCheck packet sets this properly f_char.taken = false; - ++loaded_chars; - - w_lobby->set_loading_text(tr("Loading chars:\n%1/%2") - .arg(QString::number(loaded_chars)) - .arg(QString::number(char_list_size))); - w_courtroom->append_char(f_char); - int total_loading_size = - char_list_size * 2 + evidence_list_size + music_list_size; - int loading_value = int( - ((loaded_chars + generated_chars + loaded_music + loaded_evidence) / - static_cast<double>(total_loading_size)) * - 100); - w_lobby->set_loading_value(loading_value); + if (!courtroom_loaded) { + ++loaded_chars; + w_lobby->set_loading_text(tr("Loading chars:\n%1/%2") + .arg(QString::number(loaded_chars)) + .arg(QString::number(char_list_size))); + + int total_loading_size = + char_list_size * 2 + evidence_list_size + music_list_size; + int loading_value = int( + ((loaded_chars + generated_chars + loaded_music + loaded_evidence) / + static_cast<double>(total_loading_size)) * + 100); + w_lobby->set_loading_value(loading_value); + } } - send_server_packet(new AOPacket("RM#%")); + if (!courtroom_loaded) + send_server_packet(new AOPacket("RM#%")); + else + w_courtroom->character_loading_finished(); append_to_demofile(f_packet_encoded); } else if (header == "SM") { diff --git a/src/text_file_functions.cpp b/src/text_file_functions.cpp index a0caf9b8..e3a285d4 100644 --- a/src/text_file_functions.cpp +++ b/src/text_file_functions.cpp @@ -10,8 +10,8 @@ int AOApplication::read_blip_rate() { int result = configini->value("blip_rate", 2).toInt(); - if (result < 1) - return 1; + if (result < 0) + return 0; return result; } |
