diff --git a/include/aoapplication.h b/include/aoapplication.h index cd9f736..2dc8649 100644 --- a/include/aoapplication.h +++ b/include/aoapplication.h @@ -228,6 +228,9 @@ public: // for settings. bool is_customchat_enabled(); + // Returns the value of characer sticker (avatar) setting + bool is_sticker_enabled(); + // Returns the value of whether continuous playback should be used // from the config.ini. bool is_continuous_enabled(); diff --git a/include/aooptionsdialog.h b/include/aooptionsdialog.h index 31f3d66..e88ce54 100644 --- a/include/aooptionsdialog.h +++ b/include/aooptionsdialog.h @@ -108,6 +108,9 @@ private: QLabel *ui_customchat_lbl; QCheckBox *ui_customchat_cb; + QLabel *ui_sticker_lbl; + QCheckBox *ui_sticker_cb; + QLabel *ui_continuous_lbl; QCheckBox *ui_continuous_cb; diff --git a/include/courtroom.h b/include/courtroom.h index eb1aa7b..6a64deb 100644 --- a/include/courtroom.h +++ b/include/courtroom.h @@ -121,6 +121,9 @@ public: void character_loading_finished(); + // + void set_courtroom_size(); + // sets position of widgets based on theme ini files void set_widgets(); @@ -140,18 +143,15 @@ public: void set_fonts(QString p_char = ""); // sets dropdown menu stylesheet - void set_dropdown(QWidget *widget); + void set_stylesheet(QWidget *widget); // helper funciton that call above function on the relevant widgets - void set_dropdowns(); + void set_stylesheets(); void set_window_title(QString p_title); - // reads theme inis and sets size and pos based on the identifier - void set_size_and_pos(QWidget *p_widget, QString p_identifier); - - // reads theme and char inis and sets size and pos based on the identifier - void set_size_and_pos(QWidget *p_widget, QString p_identifier, QString p_char); + // reads theme and sets size and pos based on the identifier (using p_misc if provided) + void set_size_and_pos(QWidget *p_widget, QString p_identifier, QString p_misc=""); // reads theme inis and returns the size and pos as defined by it QPoint get_theme_pos(QString p_identifier); @@ -165,7 +165,7 @@ public: void set_background(QString p_background, bool display = false); // sets the local character pos/side to use. - void set_side(QString p_side, bool block_signals=true); + void set_side(QString p_side); // sets the pos dropdown void set_pos_dropdown(QStringList pos_dropdowns); @@ -576,10 +576,6 @@ private: int evidence_rows = 3; int max_evidence_on_page = 18; - // is set to true if the bg folder contains defensedesk.png, - // prosecutiondesk.png and stand.png - bool is_ao2_bg = false; - // whether the ooc chat is server or master chat, true is server bool server_ooc = true; @@ -826,7 +822,7 @@ private slots: void music_random(); void music_list_expand_all(); void music_list_collapse_all(); - void music_stop(); + void music_stop(bool no_effects = false); void on_area_list_double_clicked(QTreeWidgetItem *p_item, int column); void select_emote(int p_id); @@ -838,6 +834,7 @@ private slots: void on_emote_dropdown_changed(int p_index); void on_pos_dropdown_changed(int p_index); + void on_pos_dropdown_changed(QString p_text); void on_pos_remove_clicked(); void on_iniswap_dropdown_changed(int p_index); diff --git a/include/lobby.h b/include/lobby.h index 4278534..0f066ab 100644 --- a/include/lobby.h +++ b/include/lobby.h @@ -17,6 +17,7 @@ #include #include +#include class AOApplication; @@ -32,7 +33,7 @@ public: void append_chatmessage(QString f_name, QString f_message); void append_error(QString f_message); void set_player_count(int players_online, int max_players); - void set_stylesheet(QWidget *widget, QString target_tag); + void set_stylesheet(QWidget *widget); void set_stylesheets(); void set_fonts(); void set_font(QWidget *widget, QString p_identifier); diff --git a/src/aolayer.cpp b/src/aolayer.cpp index e766495..f0d5779 100644 --- a/src/aolayer.cpp +++ b/src/aolayer.cpp @@ -240,12 +240,11 @@ void InterfaceLayer::load_image(QString p_filename, QString p_miscname) void StickerLayer::load_image(QString p_charname) { - QString p_miscname = ao_app->get_chat(p_charname); + QString p_miscname; + if (ao_app->is_customchat_enabled()) + p_miscname = ao_app->get_chat(p_charname); transform_mode = ao_app->get_misc_scaling(p_miscname); QString final_image = ao_app->get_image("sticker/" + p_charname, ao_app->current_theme, ao_app->get_subtheme(), ao_app->default_theme, p_miscname); - if (!file_exists((final_image))) - final_image = ao_app->get_image_suffix( - ao_app->get_character_path(p_charname, "showname")), // Scuffed DRO way start_playback(final_image); } @@ -261,6 +260,7 @@ void CharLayer::start_playback(QString p_image) void AOLayer::start_playback(QString p_image) { + this->show(); if (!ao_app->is_continuous_enabled()) { continuous = false; @@ -322,7 +322,6 @@ void AOLayer::start_playback(QString p_image) int f_delay = m_reader.nextImageDelay(); this->set_frame(f_pixmap); - this->show(); if (max_frames > 1) { movie_frames.append(f_pixmap); movie_delays.append(f_delay); @@ -450,6 +449,10 @@ void CharLayer::load_network_effects() void CharLayer::play_frame_effect(int p_frame) { + if (p_frame >= movie_effects.size()) { + qDebug() << "W: Attempted to play a frame effect bigger than the size of movie_effects"; + return; + } if (p_frame < max_frames) { foreach (QString effect, movie_effects[p_frame]) { if (effect == "shake") { diff --git a/src/aooptionsdialog.cpp b/src/aooptionsdialog.cpp index dfd8555..9ca0865 100644 --- a/src/aooptionsdialog.cpp +++ b/src/aooptionsdialog.cpp @@ -485,6 +485,19 @@ AOOptionsDialog::AOOptionsDialog(QWidget *parent, AOApplication *p_ao_app) ui_gameplay_form->setWidget(row, QFormLayout::FieldRole, ui_customchat_cb); + row += 1; + ui_sticker_lbl = new QLabel(ui_form_layout_widget); + ui_sticker_lbl->setText(tr("Stickers:")); + ui_sticker_lbl->setToolTip( + tr("Turn this on to allow characters to define their own " + "stickers (unique images that show up over the chatbox - like avatars or shownames).")); + + ui_gameplay_form->setWidget(row, QFormLayout::LabelRole, ui_sticker_lbl); + + ui_sticker_cb = new QCheckBox(ui_form_layout_widget); + + ui_gameplay_form->setWidget(row, QFormLayout::FieldRole, ui_sticker_cb); + row += 1; ui_continuous_lbl = new QLabel(ui_form_layout_widget); ui_continuous_lbl->setText(tr("Continuous Playback:")); @@ -691,8 +704,7 @@ AOOptionsDialog::AOOptionsDialog(QWidget *parent, AOApplication *p_ao_app) ui_objectmusic_lbl = new QLabel(ui_audio_widget); ui_objectmusic_lbl->setText(tr("Kill Music On Objection:")); ui_objectmusic_lbl->setToolTip( - tr("If true, AO2 will stop the music for you when you or someone else " - "does 'Objection!'.")); + tr("If true, AO2 will ask the server to stop music when you use 'Objection!' ")); ui_audio_layout->setWidget(row, QFormLayout::LabelRole, ui_objectmusic_lbl); @@ -909,6 +921,7 @@ void AOOptionsDialog::update_values() { ui_stickyeffects_cb->setChecked(ao_app->is_stickyeffects_enabled()); ui_stickypres_cb->setChecked(ao_app->is_stickypres_enabled()); ui_customchat_cb->setChecked(ao_app->is_customchat_enabled()); + ui_sticker_cb->setChecked(ao_app->is_sticker_enabled()); ui_continuous_cb->setChecked(ao_app->is_continuous_enabled()); ui_category_stop_cb->setChecked(ao_app->is_category_stop_enabled()); ui_blank_blips_cb->setChecked(ao_app->get_blank_blip()); diff --git a/src/charselect.cpp b/src/charselect.cpp index 4f3ba99..510d8c0 100644 --- a/src/charselect.cpp +++ b/src/charselect.cpp @@ -177,7 +177,8 @@ void Courtroom::char_clicked(int n_char) } else { update_character(n_char); - set_widgets(); // so we don't erroneously keep the charselect's fixedSize + enter_courtroom(); + set_courtroom_size(); } if (n_char != -1) diff --git a/src/courtroom.cpp b/src/courtroom.cpp index b9ca070..c8d8320 100644 --- a/src/courtroom.cpp +++ b/src/courtroom.cpp @@ -308,6 +308,8 @@ Courtroom::Courtroom(AOApplication *p_ao_app) : QMainWindow() connect(ui_pos_dropdown, SIGNAL(currentIndexChanged(int)), this, SLOT(on_pos_dropdown_changed(int))); + connect(ui_pos_dropdown, SIGNAL(editTextChanged(QString)), this, + SLOT(on_pos_dropdown_changed(QString))); connect(ui_pos_remove, SIGNAL(clicked()), this, SLOT(on_pos_remove_clicked())); connect(ui_iniswap_dropdown, SIGNAL(currentIndexChanged(int)), this, @@ -437,6 +439,28 @@ Courtroom::Courtroom(AOApplication *p_ao_app) : QMainWindow() set_char_select(); } +void Courtroom::set_courtroom_size() +{ + QString filename = "courtroom_design.ini"; + pos_size_type f_courtroom = + ao_app->get_element_dimensions("courtroom", filename); + + if (f_courtroom.width < 0 || f_courtroom.height < 0) { + qDebug() << "W: did not find courtroom width or height in " << filename; + + this->setFixedSize(714, 668); + } + else { + m_courtroom_width = f_courtroom.width; + m_courtroom_height = f_courtroom.height; + + this->setFixedSize(f_courtroom.width, f_courtroom.height); + } + ui_background->move(0, 0); + ui_background->resize(m_courtroom_width, m_courtroom_height); + ui_background->set_image("courtroombackground"); +} + void Courtroom::set_mute_list() { mute_map.clear(); @@ -480,27 +504,7 @@ void Courtroom::set_widgets() QSettings settings(ao_app->get_theme_path(filename, ao_app->current_theme), QSettings::IniFormat); ao_app->default_theme = settings.value("default_theme", "default").toString(); - pos_size_type f_courtroom = - ao_app->get_element_dimensions("courtroom", filename); - - if (f_courtroom.width < 0 || f_courtroom.height < 0) { - qDebug() << "W: did not find courtroom width or height in " << filename; - - this->setFixedSize(714, 668); - } - else { - m_courtroom_width = f_courtroom.width; - m_courtroom_height = f_courtroom.height; - - this->setFixedSize(f_courtroom.width, f_courtroom.height); - } - set_fonts(); - - ui_background->move(0, 0); - ui_background->resize(m_courtroom_width, m_courtroom_height); - ui_background->set_image("courtroombackground"); - set_size_and_pos(ui_viewport, "viewport"); // If there is a point to it, show all CCCC features. @@ -680,22 +684,8 @@ void Courtroom::set_widgets() for (int i = 0; i < max_clocks; i++) { set_size_and_pos(ui_clock[i], "clock_" + QString::number(i)); } - - if (is_ao2_bg) { - set_size_and_pos(ui_ic_chat_message, "ao2_ic_chat_message"); - // set_size_and_pos(ui_vp_chatbox, "ao2_chatbox"); - set_size_and_pos(ui_ic_chat_name, "ao2_ic_chat_name"); - } - else { - set_size_and_pos(ui_ic_chat_message, "ic_chat_message"); - // set_size_and_pos(ui_vp_chatbox, "chatbox"); - set_size_and_pos(ui_ic_chat_name, "ic_chat_name"); - } - - ui_ic_chat_message->setStyleSheet( - "QLineEdit{background-color: rgba(100, 100, 100, 255);}"); - ui_ic_chat_name->setStyleSheet( - "QLineEdit{background-color: rgba(180, 180, 180, 255);}"); + set_size_and_pos(ui_ic_chat_message, "ao2_ic_chat_message"); + set_size_and_pos(ui_ic_chat_name, "ao2_ic_chat_name"); ui_vp_chatbox->set_image("chatblank"); ui_vp_chatbox->hide(); @@ -719,21 +709,20 @@ void Courtroom::set_widgets() ui_muted->set_image("muted"); ui_muted->setToolTip(tr("Oops, you're muted!")); - set_size_and_pos(ui_ooc_chat_message, "ooc_chat_message"); - ui_ooc_chat_message->setStyleSheet("background-color: rgba(0, 0, 0, 0);"); + set_size_and_pos(ui_ooc_chat_message, "ooc_chat_message");; set_size_and_pos(ui_ooc_chat_name, "ooc_chat_name"); - ui_ooc_chat_name->setStyleSheet("background-color: rgba(0, 0, 0, 0);"); // set_size_and_pos(ui_area_password, "area_password"); set_size_and_pos(ui_music_search, "music_search"); - ui_music_search->setStyleSheet("background-color: rgba(0, 0, 0, 0);"); set_size_and_pos(ui_emote_dropdown, "emote_dropdown"); ui_emote_dropdown->setToolTip( tr("Set your character's emote to play on your next message.")); set_size_and_pos(ui_pos_dropdown, "pos_dropdown"); + ui_pos_dropdown->setEditable(true); + ui_pos_dropdown->setInsertPolicy(QComboBox::NoInsert); ui_pos_dropdown->setToolTip( tr("Set your character's supplementary background.")); @@ -1046,7 +1035,7 @@ void Courtroom::set_fonts(QString p_char) for (int i = 0; i < max_clocks; i++) set_font(ui_clock[i], "", "clock_" + QString::number(i), p_char); - set_dropdowns(); + set_stylesheets(); } void Courtroom::set_font(QWidget *widget, QString class_name, @@ -1108,13 +1097,13 @@ void Courtroom::set_qfont(QWidget *widget, QString class_name, QFont font, widget->setFont(font); QString style_sheet_string = - class_name + " { background-color: rgba(0, 0, 0, 0);\n" + "color: rgba(" + + class_name + " { color: rgba(" + QString::number(f_color.red()) + ", " + QString::number(f_color.green()) + ", " + QString::number(f_color.blue()) + ", 255);}"; widget->setStyleSheet(style_sheet_string); } -void Courtroom::set_dropdown(QWidget *widget) +void Courtroom::set_stylesheet(QWidget *widget) { QString f_file = "courtroom_stylesheets.css"; QString style_sheet_string = ao_app->get_stylesheet(f_file); @@ -1122,14 +1111,9 @@ void Courtroom::set_dropdown(QWidget *widget) widget->setStyleSheet(style_sheet_string); } -void Courtroom::set_dropdowns() +void Courtroom::set_stylesheets() { - set_dropdown( - this); // EXPERIMENTAL - Read the style-sheet as-is for maximum memeage - // set_dropdown(ui_text_color, "[TEXT COLOR]"); - // set_dropdown(ui_pos_dropdown, "[POS DROPDOWN]"); - // set_dropdown(ui_emote_dropdown, "[EMOTE DROPDOWN]"); - // set_dropdown(ui_mute_list, "[MUTE LIST]"); + set_stylesheet(this); } void Courtroom::set_window_title(QString p_title) @@ -1137,30 +1121,12 @@ void Courtroom::set_window_title(QString p_title) this->setWindowTitle(p_title); } -void Courtroom::set_size_and_pos(QWidget *p_widget, QString p_identifier) +void Courtroom::set_size_and_pos(QWidget *p_widget, QString p_identifier, QString p_misc) { QString filename = "courtroom_design.ini"; pos_size_type design_ini_result = - ao_app->get_element_dimensions(p_identifier, filename); - - if (design_ini_result.width < 0 || design_ini_result.height < 0) { - qDebug() << "W: could not find \"" << p_identifier << "\" in " << filename; - p_widget->hide(); - } - else { - p_widget->move(design_ini_result.x, design_ini_result.y); - p_widget->resize(design_ini_result.width, design_ini_result.height); - } -} - -void Courtroom::set_size_and_pos(QWidget *p_widget, QString p_identifier, - QString p_char) -{ - QString filename = "courtroom_design.ini"; - - pos_size_type design_ini_result = - ao_app->get_element_dimensions(p_identifier, filename, ao_app->get_chat(p_char)); + ao_app->get_element_dimensions(p_identifier, filename, p_misc); if (design_ini_result.width < 0 || design_ini_result.height < 0) { qDebug() << "W: could not find \"" << p_identifier << "\" in " << filename; @@ -1268,19 +1234,8 @@ void Courtroom::set_background(QString p_background, bool display) set_pos_dropdown(pos_list); - is_ao2_bg = true; - - if (is_ao2_bg) { - // set_size_and_pos(ui_vp_chatbox, "ao2_chatbox"); - set_size_and_pos(ui_ic_chat_message, "ao2_ic_chat_message"); - } - else { - // set_size_and_pos(ui_vp_chatbox, "chatbox"); - set_size_and_pos(ui_ic_chat_message, "ic_chat_message"); - } - if (display) { - ui_vp_speedlines->stop(); + ui_vp_speedlines->hide(); ui_vp_player_char->stop(); ui_vp_sideplayer_char->stop(); @@ -1288,7 +1243,7 @@ void Courtroom::set_background(QString p_background, bool display) ui_vp_message->hide(); ui_vp_chatbox->hide(); // Stop the chat arrow from animating - ui_vp_chat_arrow->stop(); + ui_vp_chat_arrow->hide(); // Clear the message queue text_queue_timer->stop(); @@ -1307,55 +1262,47 @@ void Courtroom::set_background(QString p_background, bool display) } } -void Courtroom::set_side(QString p_side, bool block_signals) +void Courtroom::set_side(QString p_side) { QString f_side; - if (p_side == "") + if (p_side == ao_app->get_char_side(current_char)) + p_side = ""; + current_side = p_side; + if (current_side == "") { f_side = ao_app->get_char_side(current_char); - else - 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(); + ui_pos_remove->hide(); } 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(); + f_side = current_side; + ui_pos_remove->show(); } + toggle_judge_buttons(false); + + if (f_side == "jud") + toggle_judge_buttons(true); + + // Block the signals to prevent setCurrentIndex from triggering a pos + // change + ui_pos_dropdown->blockSignals(true); for (int i = 0; i < ui_pos_dropdown->count(); ++i) { QString pos = ui_pos_dropdown->itemText(i); if (pos == f_side) { - // Block the signals to prevent setCurrentIndex from triggering a pos - // change - 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 - if (block_signals) - ui_pos_dropdown->blockSignals(false); + ui_pos_dropdown->blockSignals(false); // alright we dun, jobs done here boyos - break; + return; } } + // We will only get there if we failed the last step + ui_pos_dropdown->setEditText(f_side); + // Unblock the signals so the element can be used for setting pos again + ui_pos_dropdown->blockSignals(false); } void Courtroom::set_pos_dropdown(QStringList pos_dropdowns) @@ -1365,8 +1312,13 @@ void Courtroom::set_pos_dropdown(QStringList pos_dropdowns) pos_dropdown_list = pos_dropdowns; ui_pos_dropdown->clear(); ui_pos_dropdown->addItems(pos_dropdown_list); + + if (current_side != "" && !pos_dropdown_list.contains(current_side)) + ui_pos_dropdown->setEditText(current_side); + // Unblock the signals so the element can be used for setting pos again ui_pos_dropdown->blockSignals(false); + // Don't block the signals when setting side set_side(current_side); } @@ -1461,12 +1413,6 @@ void Courtroom::update_character(int p_cid) } } } - if (is_ao2_bg) { - set_size_and_pos(ui_vp_chatbox, "ao2_chatbox", f_char); - } - else { - set_size_and_pos(ui_vp_chatbox, "chatbox", f_char); - } if (m_cid != -1) // there is no name at char_list -1, and we crash if we try // to find one @@ -1483,8 +1429,6 @@ void Courtroom::update_character(int p_cid) void Courtroom::enter_courtroom() { - set_widgets(); - current_evidence_page = 0; current_evidence = 0; @@ -1803,6 +1747,10 @@ void Courtroom::on_chat_return_pressed() else f_obj_state = QString::number(objection_state); + // We're doing an Objection (custom objections not yet supported) + if (objection_state == 2 && ao_app->objection_stop_music()) + music_stop(true); + packet_contents.append(f_obj_state); if (is_presenting_evidence) @@ -1997,7 +1945,13 @@ void Courtroom::chatmessage_enqueue(QStringList p_contents) // Record the log I/O, log files should be accurate. // If desynced logs are on, display the log IC immediately. LogMode log_mode = ao_app->is_desyncrhonized_logs_enabled() ? DISPLAY_AND_IO : IO_ONLY; - log_chatmessage(p_contents[MESSAGE], f_char_id, p_contents[SHOWNAME], p_contents[TEXT_COLOR].toInt(), log_mode); + + // Use null showname if packet does not support 2.6+ extensions + QString showname = QString(); + if (SHOWNAME < p_contents.size()) + showname = p_contents[SHOWNAME]; + + log_chatmessage(p_contents[MESSAGE], f_char_id, showname, p_contents[TEXT_COLOR].toInt(), log_mode); // Send this boi into the queue chatmessage_queue.enqueue(p_contents); @@ -2057,7 +2011,7 @@ void Courtroom::unpack_chatmessage(QStringList p_contents) handle_callwords(); // Reset the interface to make room for objection handling - ui_vp_chat_arrow->stop(); + ui_vp_chat_arrow->hide(); text_state = 0; anim_state = 0; evidence_presented = false; @@ -2216,8 +2170,6 @@ bool Courtroom::handle_objection() filename = "objection_bubble"; objection_player->play("objection", m_chatmessage[CHAR_NAME], ao_app->get_chat(m_chatmessage[CHAR_NAME])); - if (ao_app->objection_stop_music()) - music_player->stop(); break; case 3: filename = "takethat_bubble"; @@ -2261,7 +2213,7 @@ void Courtroom::effect_done() void Courtroom::display_character() { // Stop all previously playing animations, effects etc. - ui_vp_speedlines->stop(); + ui_vp_speedlines->hide(); ui_vp_player_char->stop(); ui_vp_effect->stop(); // Clear all looping sfx to prevent obnoxiousness @@ -2403,6 +2355,9 @@ void Courtroom::objection_done() { handle_ic_message(); } void Courtroom::handle_ic_message() { + // Update the chatbox information + initialize_chatbox(); + // Display our own character display_character(); @@ -2420,9 +2375,6 @@ void Courtroom::handle_ic_message() // Parse the emote_mod part of the chat message handle_emote_mod(m_chatmessage[EMOTE_MOD].toInt(), m_chatmessage[IMMEDIATE].toInt() == 1); - // Update the chatbox information - initialize_chatbox(); - // if we have instant objections disabled, and queue is not empty, check if next message after this is an objection. if (!ao_app->is_instant_objection_enabled() && chatmessage_queue.size() > 0) { @@ -2546,23 +2498,18 @@ void Courtroom::initialize_chatbox() else { ui_vp_showname->setText(m_chatmessage[SHOWNAME]); } - - if (is_ao2_bg) { - set_size_and_pos(ui_vp_chatbox, "ao2_chatbox", m_chatmessage[CHAR_NAME]); - } - else { - set_size_and_pos(ui_vp_chatbox, "chatbox", m_chatmessage[CHAR_NAME]); - } - set_size_and_pos(ui_vp_showname, "showname", m_chatmessage[CHAR_NAME]); - set_size_and_pos(ui_vp_message, "message", m_chatmessage[CHAR_NAME]); - ui_vp_message->move(ui_vp_message->x() + ui_vp_chatbox->x(), - ui_vp_message->y() + ui_vp_chatbox->y()); - ui_vp_message->setTextInteractionFlags(Qt::NoTextInteraction); - QString customchar; if (ao_app->is_customchat_enabled()) customchar = m_chatmessage[CHAR_NAME]; QString p_misc = ao_app->get_chat(customchar); + + set_size_and_pos(ui_vp_chatbox, "ao2_chatbox", p_misc); + set_size_and_pos(ui_vp_showname, "showname", p_misc); + set_size_and_pos(ui_vp_message, "message", p_misc); + ui_vp_message->move(ui_vp_message->x() + ui_vp_chatbox->x(), + ui_vp_message->y() + ui_vp_chatbox->y()); + ui_vp_message->setTextInteractionFlags(Qt::NoTextInteraction); + if (ui_vp_showname->text().trimmed().isEmpty()) // Whitespace showname { ui_vp_chatbox->set_image("chatblank", p_misc); @@ -3157,6 +3104,15 @@ void Courtroom::play_preanim(bool immediate) qDebug() << "W: could not find " + anim_to_find; return; } + else { + QImageReader s_reader(anim_to_find); + int image_count = s_reader.imageCount(); + if (image_count <= 1) { + preanim_done(); + qDebug() << "W: tried to play static preanim " + anim_to_find; + return; + } + } ui_vp_player_char->set_static_duration(preanim_duration); ui_vp_player_char->set_play_once(true); ui_vp_player_char->load_image(f_preanim, f_char, preanim_duration, true); @@ -3258,7 +3214,8 @@ void Courtroom::start_chat_ticking() ui_vp_chatbox->show(); ui_vp_message->show(); - ui_vp_sticker->load_image(m_chatmessage[CHAR_NAME]); + if (ao_app->is_sticker_enabled()) + ui_vp_sticker->load_image(m_chatmessage[CHAR_NAME]); if (m_chatmessage[ADDITIVE] != "1") { ui_vp_message->clear(); @@ -3736,7 +3693,7 @@ 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))) & !f_song.startsWith("http")) + 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)); @@ -3780,7 +3737,7 @@ void Courtroom::handle_song(QStringList *p_contents) if (is_stop) 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))) & !f_song.startsWith("http")) + 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)); @@ -3806,14 +3763,14 @@ void Courtroom::handle_wtce(QString p_wtce, int variant) ui_vp_testimony->kill(); return; } - sfx_name = ao_app->get_court_sfx("witnesstestimony", bg_misc); - filename = "witnesstestimony"; + sfx_name = ao_app->get_court_sfx("witness_testimony", bg_misc); + filename = "witnesstestimony_bubble"; ui_vp_testimony->load_image("testimony", "", bg_misc); } // cross examination else if (p_wtce == "testimony2") { - sfx_name = ao_app->get_court_sfx("crossexamination", bg_misc); - filename = "crossexamination"; + sfx_name = ao_app->get_court_sfx("cross_examination", bg_misc); + filename = "crossexamination_bubble"; ui_vp_testimony->kill(); } else { @@ -3822,13 +3779,13 @@ void Courtroom::handle_wtce(QString p_wtce, int variant) // Verdict? if (p_wtce == "judgeruling") { if (variant == 0) { - sfx_name = ao_app->get_court_sfx("notguilty", bg_misc); - filename = "notguilty"; + sfx_name = ao_app->get_court_sfx("not_guilty", bg_misc); + filename = "notguilty_bubble"; ui_vp_testimony->kill(); } else if (variant == 1) { sfx_name = ao_app->get_court_sfx("guilty", bg_misc); - filename = "guilty"; + filename = "guilty_bubble"; ui_vp_testimony->kill(); } } @@ -4312,28 +4269,17 @@ void Courtroom::on_pos_dropdown_changed(int p_index) { if (p_index < 0) return; + on_pos_dropdown_changed(ui_pos_dropdown->itemText(p_index)); +} - toggle_judge_buttons(false); - - QString f_pos = ui_pos_dropdown->itemText(p_index); - - if (f_pos == "") - return; - - 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_dropdown_changed(QString p_text) +{ + set_side(p_text); } void Courtroom::on_pos_remove_clicked() { + ui_pos_dropdown->blockSignals(true); QString default_side = ao_app->get_char_side(current_char); for (int i = 0; i < ui_pos_dropdown->count(); ++i) { @@ -4344,10 +4290,11 @@ void Courtroom::on_pos_remove_clicked() } } 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 + 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 + ui_pos_dropdown->blockSignals(false); current_side = ""; ui_pos_remove->hide(); ui_ic_chat_message->setFocus(); @@ -4832,7 +4779,7 @@ void Courtroom::music_list_collapse_all() ui_music_list->setCurrentItem(current); } -void Courtroom::music_stop() +void Courtroom::music_stop(bool no_effects) { if (is_muted) return; @@ -4857,8 +4804,12 @@ void Courtroom::music_stop() if ((!ui_ic_chat_name->text().isEmpty() && ao_app->cccc_ic_support_enabled) || ao_app->effects_enabled) packet_contents.append(ui_ic_chat_name->text()); - if (ao_app->effects_enabled) - packet_contents.append(QString::number(music_flags)); + if (ao_app->effects_enabled) { + if (no_effects) + packet_contents.append("0"); + else + packet_contents.append(QString::number(music_flags)); + } ao_app->send_server_packet(new AOPacket("MC", packet_contents), false); } @@ -5264,8 +5215,10 @@ void Courtroom::on_reload_theme_clicked() { ao_app->reload_theme(); - enter_courtroom(); + set_courtroom_size(); + set_widgets(); update_character(m_cid); + enter_courtroom(); anim_state = 4; text_state = 3; diff --git a/src/evidence.cpp b/src/evidence.cpp index b97607b..8825753 100644 --- a/src/evidence.cpp +++ b/src/evidence.cpp @@ -41,8 +41,6 @@ void Courtroom::initialize_evidence() "evidence and send them to server.")); ui_evidence_description = new AOTextEdit(ui_evidence_overlay); - ui_evidence_description->setStyleSheet("background-color: rgba(0, 0, 0, 0);" - "color: white;"); ui_evidence_description->setFrameStyle(QFrame::NoFrame); ui_evidence_description->setToolTip( tr("Double-click to edit. Press [X] to update your changes.")); diff --git a/src/lobby.cpp b/src/lobby.cpp index 314874e..616e520 100644 --- a/src/lobby.cpp +++ b/src/lobby.cpp @@ -28,8 +28,13 @@ Lobby::Lobby(AOApplication *p_ao_app) : QMainWindow() ui_server_list = new QTreeWidget(this); ui_server_list->setHeaderLabels({"#", "Name"}); //, "Players"}); - ui_server_list->hideColumn(0); - ui_server_list->setHeaderHidden(true); + ui_server_list->setTextElideMode(Qt::ElideNone); + ui_server_list->header()->setMinimumSectionSize(24); + ui_server_list->header()->setSectionsMovable(false); + ui_server_list->setColumnWidth(0, 0); + ui_server_list->setIndentation(0); +// ui_server_list->hideColumn(0); +// ui_server_list->setHeaderHidden(true); ui_server_search = new QLineEdit(this); ui_server_search->setFrame(false); @@ -137,36 +142,21 @@ void Lobby::set_widgets() tr("Allows you to change various aspects of the client.")); set_size_and_pos(ui_server_list, "server_list"); - ui_server_list->setStyleSheet("background-color: rgba(0, 0, 0, 0);" - "font: bold;"); set_size_and_pos(ui_server_search, "server_search"); - ui_server_search->setStyleSheet("background-color: rgba(0, 0, 0, 0);"); set_size_and_pos(ui_player_count, "player_count"); ui_player_count->setText(tr("Offline")); - ui_player_count->setStyleSheet("font: bold;" - "color: white;" - "qproperty-alignment: AlignCenter;"); set_size_and_pos(ui_description, "description"); ui_description->setReadOnly(true); - ui_description->setStyleSheet("background-color: rgba(0, 0, 0, 0);" - "color: white;"); set_size_and_pos(ui_chatbox, "chatbox"); ui_chatbox->setReadOnly(true); - ui_chatbox->setStyleSheet( - "QTextBrowser{background-color: rgba(0, 0, 0, 0);}"); set_size_and_pos(ui_chatname, "chatname"); - ui_chatname->setStyleSheet("background-color: rgba(0, 0, 0, 0);" - "selection-background-color: rgba(0, 0, 0, 0);"); set_size_and_pos(ui_chatmessage, "chatmessage"); - ui_chatmessage->setStyleSheet( - "background-color: rgba(0, 0, 0, 0);" - "selection-background-color: rgba(0, 0, 0, 0);"); ui_loading_background->resize(this->width(), this->height()); ui_loading_background->set_image("loadingbackground"); @@ -176,8 +166,6 @@ void Lobby::set_widgets() ui_loading_text->setReadOnly(true); ui_loading_text->setAlignment(Qt::AlignCenter); ui_loading_text->setFrameStyle(QFrame::NoFrame); - ui_loading_text->setStyleSheet("background-color: rgba(0, 0, 0, 0);" - "color: rgba(255, 128, 0, 255);"); ui_loading_text->append(tr("Loading")); set_size_and_pos(ui_progress_bar, "progress_bar"); @@ -218,24 +206,17 @@ void Lobby::set_fonts() set_font(ui_server_list, "server_list"); } -void Lobby::set_stylesheet(QWidget *widget, QString target_tag) +void Lobby::set_stylesheet(QWidget *widget) { QString f_file = "lobby_stylesheets.css"; - QString style_sheet_string = - ao_app->get_tagged_stylesheet(target_tag, f_file); + QString style_sheet_string = ao_app->get_stylesheet(f_file); if (style_sheet_string != "") widget->setStyleSheet(style_sheet_string); } void Lobby::set_stylesheets() { - set_stylesheet(ui_player_count, "[PLAYER COUNT]"); - set_stylesheet(ui_description, "[DESCRIPTION]"); - set_stylesheet(ui_chatbox, "[CHAT BOX]"); - set_stylesheet(ui_chatname, "[CHAT NAME]"); - set_stylesheet(ui_chatmessage, "[CHAT MESSAGE]"); - set_stylesheet(ui_loading_text, "[LOADING TEXT]"); - set_stylesheet(ui_server_list, "[SERVER LIST]"); + set_stylesheet(this); } void Lobby::set_font(QWidget *widget, QString p_identifier) diff --git a/src/packet_distribution.cpp b/src/packet_distribution.cpp index 1c88120..b2e5d3e 100644 --- a/src/packet_distribution.cpp +++ b/src/packet_distribution.cpp @@ -462,6 +462,7 @@ void AOApplication::server_packet_received(AOPacket *p_packet) goto end; if (courtroom_constructed) { + qDebug() << f_contents; if (f_contents.size() >= 2) // We have a pos included in the background packet! w_courtroom->set_side(f_contents.at(1)); @@ -475,7 +476,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), false); + w_courtroom->set_side(f_contents.at(0)); append_to_demofile(p_packet->to_string(true)); } } @@ -493,8 +494,10 @@ void AOApplication::server_packet_received(AOPacket *p_packet) w_courtroom->enter_courtroom(); - if (courtroom_constructed) + if (courtroom_constructed) { + w_courtroom->set_courtroom_size(); w_courtroom->update_character(f_contents.at(2).toInt()); + } } else if (header == "MS") { if (courtroom_constructed && courtroom_loaded) diff --git a/src/text_file_functions.cpp b/src/text_file_functions.cpp index 45df30d..4718f74 100644 --- a/src/text_file_functions.cpp +++ b/src/text_file_functions.cpp @@ -981,6 +981,12 @@ bool AOApplication::is_customchat_enabled() return result.startsWith("true"); } +bool AOApplication::is_sticker_enabled() +{ + QString result = configini->value("sticker", "true").value(); + return result.startsWith("true"); +} + bool AOApplication::is_continuous_enabled() { QString result = configini->value("continuous_playback", "true").value();