diff options
Diffstat (limited to 'src')
| -rw-r--r-- | src/aolayer.cpp | 38 | ||||
| -rw-r--r-- | src/courtroom.cpp | 165 | ||||
| -rw-r--r-- | src/packet_distribution.cpp | 2 |
3 files changed, 116 insertions, 89 deletions
diff --git a/src/aolayer.cpp b/src/aolayer.cpp index efa0e447..f037b219 100644 --- a/src/aolayer.cpp +++ b/src/aolayer.cpp @@ -28,10 +28,6 @@ BackgroundLayer::BackgroundLayer(QWidget *p_parent, AOApplication *p_ao_app) : AOLayer(p_parent, p_ao_app) { } -ForegroundLayer::ForegroundLayer(QWidget *p_parent, AOApplication *p_ao_app) - : AOLayer(p_parent, p_ao_app) -{ -} CharLayer::CharLayer(QWidget *p_parent, AOApplication *p_ao_app) : AOLayer(p_parent, p_ao_app) { @@ -40,7 +36,7 @@ EffectLayer::EffectLayer(QWidget *p_parent, AOApplication *p_ao_app) : AOLayer(p_parent, p_ao_app) { } -InterjectionLayer::InterjectionLayer(QWidget *p_parent, AOApplication *p_ao_app) +SplashLayer::SplashLayer(QWidget *p_parent, AOApplication *p_ao_app) : AOLayer(p_parent, p_ao_app) { } @@ -48,7 +44,6 @@ InterfaceLayer::InterfaceLayer(QWidget *p_parent, AOApplication *p_ao_app) : AOLayer(p_parent, p_ao_app) { } - StickerLayer::StickerLayer(QWidget *p_parent, AOApplication *p_ao_app) : AOLayer(p_parent, p_ao_app) { @@ -135,27 +130,6 @@ void BackgroundLayer::load_image(QString p_filename) start_playback(ao_app->get_image_suffix(ao_app->get_background_path(p_filename))); } -void ForegroundLayer::load_image(QString p_filename, QString p_charname) -{ - play_once = false; - cull_image = false; - miscname = ao_app->get_char_shouts(p_charname); - qDebug() << "[ForegroundLayer] FG loaded: " << p_filename; - QList<QString> pathlist = { - ao_app->get_image_suffix(ao_app->get_character_path( - p_charname, p_filename)), // first check the character folder - ao_app->get_image_suffix(ao_app->get_theme_path( - "misc/" + miscname + "/" + - p_filename)), // then check our theme's misc directory - ao_app->get_image_suffix(ao_app->get_misc_path( - miscname, p_filename)), // then check our global misc folder - ao_app->get_image_suffix( - ao_app->get_theme_path(p_filename)), // then check the user's theme - ao_app->get_image_suffix(ao_app->get_default_theme_path( - p_filename))}; // and finally check the default theme - start_playback(find_image(pathlist)); -} - void CharLayer::load_image(QString p_filename, QString p_charname, int p_duration, bool p_is_preanim) { @@ -219,12 +193,9 @@ void CharLayer::load_image(QString p_filename, QString p_charname, this->start_playback(find_image(pathlist)); } -void InterjectionLayer::load_image(QString p_filename, QString p_charname, +void SplashLayer::load_image(QString p_filename, QString p_charname, QString p_miscname) { - continuous = false; - force_continuous = true; - play_once = true; transform_mode = ao_app->get_misc_scaling(p_miscname); QList<QString> pathlist = { ao_app->get_image_suffix(ao_app->get_character_path( @@ -269,7 +240,7 @@ void EffectLayer::load_image(QString p_filename, bool p_looping) void InterfaceLayer::load_image(QString p_filename, QString p_miscname) { - transform_mode = ao_app->get_misc_scaling(p_miscname); + stretch = true; QList<QString> pathlist = { ao_app->get_image_suffix(ao_app->get_theme_path( "misc/" + p_miscname + "/" + @@ -371,12 +342,9 @@ void AOLayer::start_playback(QString p_image) int l_delay = m_reader.nextImageDelay(); movie_frames.append(l_pixmap); movie_delays.append(l_delay); - // qDebug() << "appending delay of " << l_delay; } } last_path = p_image; - // qDebug() << "CONT: " << continuous << " MAX: " << max_frames - // << " LAST MAX: " << last_max_frames << " FRAME: " << frame; QPixmap f_pixmap = this->get_pixmap(m_reader.read()); int f_delay = m_reader.nextImageDelay(); diff --git a/src/courtroom.cpp b/src/courtroom.cpp index 0e2c2805..e8b58a49 100644 --- a/src/courtroom.cpp +++ b/src/courtroom.cpp @@ -44,7 +44,7 @@ Courtroom::Courtroom(AOApplication *p_ao_app) : QMainWindow() ui_viewport = new QWidget(this); ui_vp_background = new BackgroundLayer(ui_viewport, ao_app); - ui_vp_speedlines = new ForegroundLayer(ui_viewport, ao_app); + ui_vp_speedlines = new SplashLayer(ui_viewport, ao_app); ui_vp_player_char = new CharLayer(ui_viewport, ao_app); ui_vp_sideplayer_char = new CharLayer(ui_viewport, ao_app); ui_vp_sideplayer_char->hide(); @@ -67,13 +67,18 @@ Courtroom::Courtroom(AOApplication *p_ao_app) : QMainWindow() ui_vp_message->setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff); ui_vp_message->setReadOnly(true); - ui_vp_testimony = new InterfaceLayer(this, ao_app); + ui_vp_testimony = new SplashLayer(this, ao_app); ui_vp_testimony->set_play_once(false); ui_vp_testimony->setAttribute(Qt::WA_TransparentForMouseEvents); - ui_vp_wtce = new InterjectionLayer(this, ao_app); + ui_vp_wtce = new SplashLayer(this, ao_app); ui_vp_wtce->set_play_once(true); + ui_vp_wtce->continuous = false; + ui_vp_wtce->force_continuous = true; ui_vp_wtce->setAttribute(Qt::WA_TransparentForMouseEvents); - ui_vp_objection = new InterjectionLayer(this, ao_app); + ui_vp_objection = new SplashLayer(this, ao_app); + ui_vp_objection->set_play_once(true); + ui_vp_objection->continuous = false; + ui_vp_objection->force_continuous = true; ui_vp_objection->setAttribute(Qt::WA_TransparentForMouseEvents); ui_ic_chatlog = new QTextEdit(this); @@ -115,6 +120,7 @@ Courtroom::Courtroom(AOApplication *p_ao_app) : QMainWindow() ui_music_display = new InterfaceLayer(this, ao_app); ui_music_display->set_play_once(false); + ui_music_display->transform_mode = Qt::SmoothTransformation; ui_music_display->setAttribute(Qt::WA_TransparentForMouseEvents); ui_music_name = new ScrollText(ui_music_display); @@ -165,6 +171,7 @@ Courtroom::Courtroom(AOApplication *p_ao_app) : QMainWindow() initialize_emotes(); ui_pos_dropdown = new QComboBox(this); + ui_pos_remove = new AOButton(this, ao_app); ui_iniswap_dropdown = new QComboBox(this); ui_iniswap_dropdown->setContextMenuPolicy(Qt::CustomContextMenu); @@ -301,6 +308,7 @@ Courtroom::Courtroom(AOApplication *p_ao_app) : QMainWindow() connect(ui_pos_dropdown, SIGNAL(currentIndexChanged(int)), this, SLOT(on_pos_dropdown_changed(int))); + connect(ui_pos_remove, SIGNAL(clicked()), this, SLOT(on_pos_remove_clicked())); connect(ui_iniswap_dropdown, SIGNAL(currentIndexChanged(int)), this, SLOT(on_iniswap_dropdown_changed(int))); @@ -726,6 +734,15 @@ void Courtroom::set_widgets() ui_pos_dropdown->setToolTip( tr("Set your character's supplementary background.")); + set_size_and_pos(ui_pos_remove, "pos_remove"); + ui_pos_remove->setText("X"); + ui_pos_remove->set_image("evidencex"); + ui_pos_remove->setToolTip(tr("Reset your character's supplementary background to its default.")); + if (current_side == "") + ui_pos_remove->hide(); + else + ui_pos_remove->show(); + set_size_and_pos(ui_iniswap_dropdown, "iniswap_dropdown"); ui_iniswap_dropdown->setEditable(true); ui_iniswap_dropdown->setInsertPolicy(QComboBox::InsertAtBottom); @@ -1285,26 +1302,50 @@ void Courtroom::set_background(QString p_background, bool display) } } -void Courtroom::set_side(QString p_side) +void Courtroom::set_side(QString p_side, bool block_signals) { + QString f_side; if (p_side == "") - current_side = ao_app->get_char_side(current_char); + f_side = ao_app->get_char_side(current_char); else - current_side = p_side; + f_side = p_side; + + if (f_side == "jud") { + ui_witness_testimony->show(); + ui_cross_examination->show(); + ui_not_guilty->show(); + ui_guilty->show(); + ui_defense_minus->show(); + ui_defense_plus->show(); + ui_prosecution_minus->show(); + ui_prosecution_plus->show(); + } + else { + ui_witness_testimony->hide(); + ui_cross_examination->hide(); + ui_guilty->hide(); + ui_not_guilty->hide(); + ui_defense_minus->hide(); + ui_defense_plus->hide(); + ui_prosecution_minus->hide(); + ui_prosecution_plus->hide(); + } for (int i = 0; i < ui_pos_dropdown->count(); ++i) { QString pos = ui_pos_dropdown->itemText(i); - if (pos == current_side) { + if (pos == f_side) { // Block the signals to prevent setCurrentIndex from triggering a pos // change - ui_pos_dropdown->blockSignals(true); + if (block_signals) + ui_pos_dropdown->blockSignals(true); // Set the index on dropdown ui element to let you know what pos you're on // right now ui_pos_dropdown->setCurrentIndex(i); // Unblock the signals so the element can be used for setting pos again - ui_pos_dropdown->blockSignals(false); + if (block_signals) + ui_pos_dropdown->blockSignals(false); // alright we dun, jobs done here boyos break; @@ -1321,6 +1362,7 @@ void Courtroom::set_pos_dropdown(QStringList pos_dropdowns) ui_pos_dropdown->addItems(pos_dropdown_list); // Unblock the signals so the element can be used for setting pos again ui_pos_dropdown->blockSignals(false); + set_side(current_side); } void Courtroom::update_character(int p_cid) @@ -1344,7 +1386,7 @@ void Courtroom::update_character(int p_cid) } current_char = f_char; - current_side = ao_app->get_char_side(current_char); + set_side(current_side); set_text_color_dropdown(); @@ -1366,27 +1408,6 @@ void Courtroom::update_character(int p_cid) if (newchar) // Avoid infinite loop of death and suffering set_iniswap_dropdown(); - if (current_side == "jud") { - ui_witness_testimony->show(); - ui_cross_examination->show(); - ui_not_guilty->show(); - ui_guilty->show(); - ui_defense_minus->show(); - ui_defense_plus->show(); - ui_prosecution_minus->show(); - ui_prosecution_plus->show(); - } - else { - ui_witness_testimony->hide(); - ui_cross_examination->hide(); - ui_guilty->hide(); - ui_not_guilty->hide(); - ui_defense_minus->hide(); - ui_defense_plus->hide(); - ui_prosecution_minus->hide(); - ui_prosecution_plus->hide(); - } - ui_custom_objection->hide(); if (ao_app->custom_objection_enabled) // if setting is enabled { @@ -1693,9 +1714,12 @@ void Courtroom::on_chat_return_pressed() // immediate_preanim#% QStringList packet_contents; + QString f_side; if (current_side == "") - current_side = ao_app->get_char_side(current_char); + f_side = ao_app->get_char_side(current_char); + else + f_side = current_side; QString f_desk_mod = "chat"; @@ -1722,7 +1746,7 @@ void Courtroom::on_chat_return_pressed() packet_contents.append(ui_ic_chat_message->text()); - packet_contents.append(current_side); + packet_contents.append(f_side); packet_contents.append(get_char_sfx()); @@ -1980,6 +2004,7 @@ void Courtroom::chatmessage_dequeue() QString f_char = m_chatmessage[CHAR_NAME]; f_custom_theme = ao_app->get_chat(f_char); } + ui_vp_chat_arrow->transform_mode = ao_app->get_misc_scaling(f_custom_theme); ui_vp_chat_arrow->load_image("chat_arrow", f_custom_theme); // Nothing to parse in the queue @@ -2518,7 +2543,7 @@ void Courtroom::do_effect(QString fx_name, QString fx_sound, QString p_char, // Static effects will linger. ui_vp_effect->set_static_duration(0); ui_vp_effect->set_max_duration(0); - ui_vp_effect->load_image(effect, false); + ui_vp_effect->load_image(effect, true); } void Courtroom::play_char_sfx(QString sfx_name) @@ -2574,18 +2599,16 @@ void Courtroom::initialize_chatbox() // This should probably be called only if any change from the last chat // arrow was actually detected. - if (current_misc != last_misc) { - pos_size_type design_ini_result = ao_app->get_element_dimensions( - "chat_arrow", "courtroom_design.ini", customchar); - if (design_ini_result.width < 0 || design_ini_result.height < 0) { - qDebug() << "W: could not find \"chat_arrow\" in courtroom_design.ini"; - ui_vp_chat_arrow->hide(); - } - else { - ui_vp_chat_arrow->move(design_ini_result.x + ui_vp_chatbox->x(), design_ini_result.y + ui_vp_chatbox->y()); - ui_vp_chat_arrow->combo_resize(design_ini_result.width, - design_ini_result.height); - } + pos_size_type design_ini_result = ao_app->get_element_dimensions( + "chat_arrow", "courtroom_design.ini", customchar); + if (design_ini_result.width < 0 || design_ini_result.height < 0) { + qDebug() << "W: could not find \"chat_arrow\" in courtroom_design.ini"; + ui_vp_chat_arrow->hide(); + } + else { + ui_vp_chat_arrow->move(design_ini_result.x + ui_vp_chatbox->x(), design_ini_result.y + ui_vp_chatbox->y()); + ui_vp_chat_arrow->combo_resize(design_ini_result.width, + design_ini_result.height); } pos_size_type default_width = ao_app->get_element_dimensions( @@ -2701,7 +2724,7 @@ void Courtroom::handle_ic_speaking() filename = "prosecution_speedlines"; else filename = "defense_speedlines"; - ui_vp_speedlines->load_image(filename, m_chatmessage[CHAR_NAME]); + ui_vp_speedlines->load_image(filename, m_chatmessage[CHAR_NAME], ao_app->get_char_shouts(m_chatmessage[CHAR_NAME])); } // Check if this is a talking color (white text, etc.) @@ -3290,12 +3313,14 @@ void Courtroom::chat_tick() f_char = m_chatmessage[CHAR_NAME]; f_custom_theme = ao_app->get_chat(f_char); } - ui_vp_chat_arrow->load_image("chat_arrow",f_custom_theme); // Chat stopped being processed, indicate that. + ui_vp_chat_arrow->transform_mode = ao_app->get_misc_scaling(f_custom_theme); + ui_vp_chat_arrow->load_image("chat_arrow", f_custom_theme); // Chat stopped being processed, indicate that. additive_previous = additive_previous + filter_ic_text(f_message, true, -1, m_chatmessage[TEXT_COLOR].toInt()); QString f_message_filtered = filter_ic_text(f_message, true, -1, m_chatmessage[TEXT_COLOR].toInt()); for (int c = 0; c < max_colors; ++c) { + additive_previous = additive_previous.replace("$c" + QString::number(c), char_color_rgb_list.at(c).name(QColor::HexRgb)); f_message_filtered = f_message_filtered.replace("$c" + QString::number(c), char_color_rgb_list.at(c).name(QColor::HexRgb)); } additive_previous = additive_previous + f_message_filtered; @@ -3430,6 +3455,7 @@ void Courtroom::chat_tick() // Do the colors, gradual showing, etc. in here QString f_message_filtered = filter_ic_text(f_message, true, tick_pos, m_chatmessage[TEXT_COLOR].toInt()); for (int c = 0; c < max_colors; ++c) { + additive_previous = additive_previous.replace("$c" + QString::number(c), char_color_rgb_list.at(c).name(QColor::HexRgb)); f_message_filtered = f_message_filtered.replace("$c" + QString::number(c), char_color_rgb_list.at(c).name(QColor::HexRgb)); } ui_vp_message->setHtml(additive_previous + f_message_filtered); @@ -3659,6 +3685,11 @@ void Courtroom::handle_song(QStringList *p_contents) QString f_song = f_contents.at(0); QString f_song_clear = f_song.left(f_song.lastIndexOf(".")); + if (f_song.startsWith("http")) { + QByteArray f_song_bytearray = f_song.toUtf8(); + QString f_song_decoded = QUrl::fromPercentEncoding(f_song_bytearray); + f_song_clear = f_song_decoded.left(f_song_decoded.lastIndexOf(".")); + } f_song_clear = f_song_clear.right(f_song_clear.length() - (f_song_clear.lastIndexOf("/") + 1)); int n_char = f_contents.at(1).toInt(); @@ -3691,8 +3722,10 @@ void Courtroom::handle_song(QStringList *p_contents) if (f_song == "~stop.mp3") ui_music_name->setText(tr("None")); else if (channel == 0) { - if (file_exists(ao_app->get_sfx_suffix(ao_app->get_music_path(f_song)))) + if (file_exists(ao_app->get_sfx_suffix(ao_app->get_music_path(f_song))) & !f_song.startsWith("http")) ui_music_name->setText(f_song_clear); + else if (f_song.startsWith("http")) + ui_music_name->setText(tr("[STREAM] %1").arg(f_song_clear)); else ui_music_name->setText(tr("[MISSING] %1").arg(f_song_clear)); } @@ -3733,8 +3766,10 @@ void Courtroom::handle_song(QStringList *p_contents) if (f_song == "~stop.mp3") ui_music_name->setText(tr("None")); else if (channel == 0) { - if (file_exists(ao_app->get_sfx_suffix(ao_app->get_music_path(f_song)))) + if (file_exists(ao_app->get_sfx_suffix(ao_app->get_music_path(f_song))) & !f_song.startsWith("http")) ui_music_name->setText(f_song_clear); + else if (f_song.startsWith("http")) + ui_music_name->setText(tr("[STREAM] %1").arg(f_song_clear)); else ui_music_name->setText(tr("[MISSING] %1").arg(f_song_clear)); } @@ -3745,6 +3780,7 @@ void Courtroom::handle_song(QStringList *p_contents) void Courtroom::handle_wtce(QString p_wtce, int variant) { QString sfx_file = "courtroom_sounds.ini"; + QString bg_misc = ao_app->read_design_ini("misc", ao_app->get_background_path("design.ini")); QString sfx_name; QString filename; ui_vp_wtce->set_static_duration(wtce_static_time); @@ -3753,7 +3789,7 @@ void Courtroom::handle_wtce(QString p_wtce, int variant) if (p_wtce == "testimony1") { sfx_name = "witness_testimony"; filename = "witnesstestimony"; - ui_vp_testimony->load_image("testimony", ""); + ui_vp_testimony->load_image("testimony", "", bg_misc); } // cross examination else if (p_wtce == "testimony2") { @@ -3775,7 +3811,6 @@ void Courtroom::handle_wtce(QString p_wtce, int variant) ui_vp_testimony->stop(); } } - QString bg_misc = ao_app->read_design_ini("misc", ao_app->get_background_path("design.ini")); sfx_player->play(ao_app->get_sfx(sfx_name, bg_misc)); ui_vp_wtce->load_image(filename, "", bg_misc); ui_vp_wtce->set_play_once(true); @@ -4260,12 +4295,36 @@ void Courtroom::on_pos_dropdown_changed(int p_index) if (f_pos == "jud") toggle_judge_buttons(true); + + ui_pos_remove->show(); + + current_side = f_pos; // YEAH SENDING LIKE 20 PACKETS IF THE USER SCROLLS THROUGH, GREAT IDEA // how about this instead set_side(f_pos); } +void Courtroom::on_pos_remove_clicked() +{ + QString default_side = ao_app->get_char_side(current_char); + + for (int i = 0; i < ui_pos_dropdown->count(); ++i) { + QString pos = ui_pos_dropdown->itemText(i); + if (pos == default_side) { + ui_pos_dropdown->setCurrentIndex(i); + break; + } + } + int wit_index = ui_pos_dropdown->findText("wit"); + if ((ui_pos_dropdown->currentText() != default_side) & (wit_index != -1)) //i.e. this bg doesn't have our pos + ui_pos_dropdown->setCurrentIndex(wit_index); // fall back to "wit" + else if (ui_pos_dropdown->currentText() != default_side) // we don't have "wit" either? + ui_pos_dropdown->setCurrentIndex(0); // as a last resort, choose the first item in the dropdown + current_side = ""; + ui_pos_remove->hide(); +} + void Courtroom::set_iniswap_dropdown() { ui_iniswap_dropdown->blockSignals(true); diff --git a/src/packet_distribution.cpp b/src/packet_distribution.cpp index 5a093e3c..53f6deb1 100644 --- a/src/packet_distribution.cpp +++ b/src/packet_distribution.cpp @@ -475,7 +475,7 @@ void AOApplication::server_packet_received(AOPacket *p_packet) if (courtroom_constructed) // We were sent a "set position" packet { - w_courtroom->set_side(f_contents.at(0)); + w_courtroom->set_side(f_contents.at(0), false); append_to_demofile(p_packet->to_string(true)); } } |
