diff options
Diffstat (limited to 'src')
| -rw-r--r-- | src/aooptionsdialog.cpp | 14 | ||||
| -rw-r--r-- | src/aoscene.cpp | 65 | ||||
| -rw-r--r-- | src/packet_distribution.cpp | 42 | ||||
| -rw-r--r-- | src/text_file_functions.cpp | 23 |
4 files changed, 108 insertions, 36 deletions
diff --git a/src/aooptionsdialog.cpp b/src/aooptionsdialog.cpp index 82507a1f..a918c0c9 100644 --- a/src/aooptionsdialog.cpp +++ b/src/aooptionsdialog.cpp @@ -319,6 +319,8 @@ AOOptionsDialog::AOOptionsDialog(QWidget *parent, AOApplication *p_ao_app) : QDi ui_bliprate_spinbox = new QSpinBox(ui_audio_widget); ui_bliprate_spinbox->setValue(p_ao_app->read_blip_rate()); ui_bliprate_spinbox->setMinimum(1); + ui_bliprate_spinbox->setToolTip(tr("Play a blip sound \"once per every X symbols\", where " + "X is the blip rate.")); ui_audio_layout->setWidget(6, QFormLayout::FieldRole, ui_bliprate_spinbox); @@ -334,6 +336,17 @@ AOOptionsDialog::AOOptionsDialog(QWidget *parent, AOApplication *p_ao_app) : QDi ui_audio_layout->setWidget(7, QFormLayout::FieldRole, ui_blank_blips_cb); + ui_objectmusic_lbl = new QLabel(ui_audio_widget); + ui_objectmusic_lbl->setText(tr("Kill Music On Objection:")); + ui_objectmusic_lbl->setToolTip(tr("If true, the game will stop music when someone objects, like in the actual games.")); + + ui_audio_layout->setWidget(9, QFormLayout::LabelRole, ui_objectmusic_lbl); + + ui_objectmusic_cb = new QCheckBox(ui_audio_widget); + ui_objectmusic_cb->setChecked(p_ao_app->objection_stop_music()); + + ui_audio_layout->setWidget(9, QFormLayout::FieldRole, ui_objectmusic_cb); + // The casing tab! ui_casing_tab = new QWidget(); ui_settings_tabs->addTab(ui_casing_tab, tr("Casing")); @@ -506,6 +519,7 @@ void AOOptionsDialog::save_pressed() configini->setValue("default_blip", ui_blips_volume_spinbox->value()); configini->setValue("blip_rate", ui_bliprate_spinbox->value()); configini->setValue("blank_blip", ui_blank_blips_cb->isChecked()); + configini->setValue("objection_stop_music", ui_objectmusic_cb->isChecked()); configini->setValue("casing_enabled", ui_casing_enabled_cb->isChecked()); configini->setValue("casing_defence_enabled", ui_casing_def_cb->isChecked()); diff --git a/src/aoscene.cpp b/src/aoscene.cpp index 344522b6..c9314258 100644 --- a/src/aoscene.cpp +++ b/src/aoscene.cpp @@ -7,16 +7,17 @@ AOScene::AOScene(QWidget *parent, AOApplication *p_ao_app) : QLabel(parent) m_parent = parent; ao_app = p_ao_app; m_movie = new QMovie(this); + last_image = ""; } void AOScene::set_image(QString p_image) { - QString background_path = ao_app->get_background_path(p_image + ".png"); - QString animated_background_path = ao_app->get_background_path(p_image + ".gif"); - QString default_path = ao_app->get_default_background_path(p_image + ".png"); + QString background_path = ao_app->get_image_suffix(ao_app->get_background_path(p_image)); + if (!file_exists(background_path)) + background_path = ao_app->get_image_suffix(ao_app->get_default_background_path(p_image)); //Default path - QPixmap background(background_path); - QPixmap default_bg(default_path); + if (file_exists(background_path) && background_path == last_image) + return; int w = this->width(); int h = this->height(); @@ -25,7 +26,7 @@ void AOScene::set_image(QString p_image) this->setMovie(nullptr); m_movie->stop(); - m_movie->setFileName(animated_background_path); + m_movie->setFileName(background_path); m_movie->setScaledSize(QSize(w, h)); if (m_movie->isValid()) @@ -33,44 +34,52 @@ void AOScene::set_image(QString p_image) this->setMovie(m_movie); m_movie->start(); } - else if (file_exists(background_path)) - { - this->setPixmap(background.scaled(w, h)); - } else { - this->setPixmap(default_bg.scaled(w, h)); + QPixmap background(background_path); + this->setPixmap(background.scaled(w, h)); } + last_image = background_path; } void AOScene::set_legacy_desk(QString p_image) { - //vanilla desks vary in both width and height. in order to make that work with viewport rescaling, - //some INTENSE math is needed. - QString desk_path = ao_app->get_background_path(p_image); - QString default_path = ao_app->get_default_background_path(p_image); + QString desk_path = ao_app->get_image_suffix(ao_app->get_background_path(p_image)); + if (!file_exists(desk_path)) + desk_path = ao_app->get_image_suffix(ao_app->get_default_background_path(p_image)); //Default path - QPixmap f_desk; + if (file_exists(desk_path) && desk_path == last_image) + return; - if (file_exists(desk_path)) - f_desk.load(desk_path); - else - f_desk.load(default_path); + QPixmap f_desk(desk_path); + //vanilla desks vary in both width and height. in order to make that work with viewport rescaling, + //some INTENSE math is needed. int vp_width = m_parent->width(); int vp_height = m_parent->height(); - //double y_modifier = 147 / 192; - //double w_modifier = vp_width / 256; double h_modifier = vp_height / 192; - //int final_y = y_modifier * vp_height; - //int final_w = w_modifier * f_desk.width(); int final_h = static_cast<int>(h_modifier * f_desk.height()); - //this->resize(final_w, final_h); - //this->setPixmap(f_desk.scaled(final_w, final_h)); - this->resize(vp_width, final_h); - this->setPixmap(f_desk.scaled(vp_width, final_h)); + this->clear(); + this->setMovie(nullptr); + + m_movie->stop(); + m_movie->setFileName(desk_path); + + m_movie->setScaledSize(QSize(vp_width, final_h)); + + if (m_movie->isValid()) + { + this->setMovie(m_movie); + m_movie->start(); + } + else + { + this->resize(vp_width, final_h); + this->setPixmap(f_desk.scaled(vp_width, final_h)); + } + last_image = desk_path; } diff --git a/src/packet_distribution.cpp b/src/packet_distribution.cpp index 40015fda..cfd6d8c6 100644 --- a/src/packet_distribution.cpp +++ b/src/packet_distribution.cpp @@ -525,6 +525,48 @@ void AOApplication::server_packet_received(AOPacket *p_packet) send_server_packet(new AOPacket("RD#%")); } + else if (header == "FM") + { + if (!courtroom_constructed) + goto end; + + w_courtroom->clear_music(); + w_courtroom->clear_areas(); + + bool musics_time = false; + int areas = 0; + + for (int n_element = 0 ; n_element < f_contents.size() ; ++n_element) + { + if (musics_time) + { + w_courtroom->append_music(f_contents.at(n_element)); + } + else + { + if (f_contents.at(n_element).endsWith(".wav") || + f_contents.at(n_element).endsWith(".mp3") || + f_contents.at(n_element).endsWith(".mp4") || + f_contents.at(n_element).endsWith(".ogg") || + f_contents.at(n_element).endsWith(".opus")) + { + musics_time = true; + w_courtroom->fix_last_area(); + w_courtroom->append_music(f_contents.at(n_element)); + areas--; +// qDebug() << "wtf!!" << f_contents.at(n_element); + } + else + { + w_courtroom->append_area(f_contents.at(n_element)); + areas++; + } + } + } + + w_courtroom->list_music(); + w_courtroom->list_areas(); + } else if (header == "DONE") { if (!courtroom_constructed) diff --git a/src/text_file_functions.cpp b/src/text_file_functions.cpp index 8f6ee236..9a0cd2fe 100644 --- a/src/text_file_functions.cpp +++ b/src/text_file_functions.cpp @@ -8,7 +8,7 @@ QString AOApplication::read_theme() int AOApplication::read_blip_rate() { - int result = configini->value("blip_rate", 1).toInt(); + int result = configini->value("blip_rate", 2).toInt(); if (result < 1) return 1; @@ -48,7 +48,7 @@ int AOApplication::get_max_log_size() bool AOApplication::get_log_goes_downwards() { - QString result = configini->value("log_goes_downwards", "false").value<QString>(); + QString result = configini->value("log_goes_downwards", "true").value<QString>(); return result.startsWith("true"); } @@ -385,12 +385,13 @@ QString AOApplication::get_sfx_suffix(QString sound_to_check) QString AOApplication::get_image_suffix(QString path_to_check) { - QString apng_check = path_to_check + ".apng"; - if (file_exists(apng_check)) - { - return apng_check; - } - return path_to_check + ".gif"; + if (file_exists(path_to_check + ".webp")) + return path_to_check + ".webp"; + if (file_exists(path_to_check + ".apng")) + return path_to_check + ".apng"; + if (file_exists(path_to_check + ".gif")) + return path_to_check + ".gif"; + return path_to_check + ".png"; } @@ -601,6 +602,12 @@ bool AOApplication::get_blank_blip() return result.startsWith("true"); } +bool AOApplication::objection_stop_music() +{ + QString result = configini->value("objection_stop_music", "false").value<QString>(); + return result.startsWith("true"); +} + bool AOApplication::is_discord_enabled() { QString result = configini->value("discord", "true").value<QString>(); |
