From b085be5a2a0512c432bc9fd58413a9d8f93d451e Mon Sep 17 00:00:00 2001 From: Crystalwarrior Date: Mon, 16 Sep 2019 21:08:43 +0300 Subject: [PATCH] Add two new helper functions - get_design_element and get_static_image_suffix Modify all set_image calls to utilize said suffix helper function Dynamically change betweehn chatblank, chat, chatmed, chatbig based on the showname's length Use char.ini showname if showname is set to whitespace (doesn't yet check if char.ini showname is also whitespace) --- include/aoapplication.h | 6 + include/aoimage.h | 4 +- src/aobutton.cpp | 4 +- src/aocharbutton.cpp | 6 +- src/aoemotebutton.cpp | 2 +- src/aoevidencebutton.cpp | 4 +- src/aoimage.cpp | 33 +++--- src/charselect.cpp | 2 +- src/courtroom.cpp | 215 +++++++++++++++++++++--------------- src/emotes.cpp | 8 +- src/evidence.cpp | 9 +- src/lobby.cpp | 40 +++---- src/text_file_functions.cpp | 13 +++ 13 files changed, 202 insertions(+), 144 deletions(-) diff --git a/include/aoapplication.h b/include/aoapplication.h index f499faf..052ad08 100644 --- a/include/aoapplication.h +++ b/include/aoapplication.h @@ -226,6 +226,9 @@ public: //Returns the dimensions of widget with specified identifier from p_file pos_size_type get_element_dimensions(QString p_identifier, QString p_file); + //Returns the value to you + QString get_design_element(QString p_identifier, QString p_file); + //Returns the name of the font with p_identifier from p_file QString get_font_name(QString p_identifier, QString p_file); @@ -247,6 +250,9 @@ public: // Can we use APNG for this? If not, WEBP? If not, GIF? If not, fall back to PNG. QString get_image_suffix(QString path_to_check); + // If this image is static and non-animated, return the supported static image formats. Currently only PNG. + QString get_static_image_suffix(QString path_to_check); + //Returns the value of p_search_line within target_tag and terminator_tag QString read_char_ini(QString p_char, QString p_search_line, QString target_tag); diff --git a/include/aoimage.h b/include/aoimage.h index 4713be0..25c8e06 100644 --- a/include/aoimage.h +++ b/include/aoimage.h @@ -17,8 +17,8 @@ public: QWidget *m_parent; AOApplication *ao_app; - void set_image(QString p_image); - void set_image_from_path(QString p_path); + bool set_image(QString p_image); + bool set_chatbox(QString p_path); void set_size_and_pos(QString identifier); }; diff --git a/src/aobutton.cpp b/src/aobutton.cpp index 5be2e67..1459729 100644 --- a/src/aobutton.cpp +++ b/src/aobutton.cpp @@ -15,8 +15,8 @@ AOButton::~AOButton() void AOButton::set_image(QString p_image) { - QString image_path = ao_app->get_theme_path(p_image); - QString default_image_path = ao_app->get_default_theme_path(p_image); + QString image_path = ao_app->get_static_image_suffix(ao_app->get_theme_path(p_image)); + QString default_image_path = ao_app->get_static_image_suffix(ao_app->get_default_theme_path(p_image)); if (file_exists(image_path)) this->setStyleSheet("border-image:url(\"" + image_path + "\")"); diff --git a/src/aocharbutton.cpp b/src/aocharbutton.cpp index 7661027..d571b95 100644 --- a/src/aocharbutton.cpp +++ b/src/aocharbutton.cpp @@ -15,7 +15,7 @@ AOCharButton::AOCharButton(QWidget *parent, AOApplication *p_ao_app, int x_pos, ui_taken = new AOImage(this, ao_app); ui_taken->resize(60, 60); - ui_taken->set_image("char_taken.png"); + ui_taken->set_image("char_taken"); ui_taken->setAttribute(Qt::WA_TransparentForMouseEvents); ui_taken->hide(); @@ -28,7 +28,7 @@ AOCharButton::AOCharButton(QWidget *parent, AOApplication *p_ao_app, int x_pos, ui_selector = new AOImage(parent, ao_app); ui_selector->resize(62, 62); ui_selector->move(x_pos - 1, y_pos - 1); - ui_selector->set_image("char_selector.png"); + ui_selector->set_image("char_selector"); ui_selector->setAttribute(Qt::WA_TransparentForMouseEvents); ui_selector->hide(); } @@ -65,7 +65,7 @@ void AOCharButton::set_passworded() void AOCharButton::set_image(QString p_character) { - QString image_path = ao_app->get_character_path(p_character, "char_icon.png"); + QString image_path = ao_app->get_static_image_suffix(ao_app->get_character_path(p_character, "char_icon")); this->setText(""); diff --git a/src/aoemotebutton.cpp b/src/aoemotebutton.cpp index 9c1d388..ca4d694 100644 --- a/src/aoemotebutton.cpp +++ b/src/aoemotebutton.cpp @@ -16,7 +16,7 @@ AOEmoteButton::AOEmoteButton(QWidget *p_parent, AOApplication *p_ao_app, int p_x void AOEmoteButton::set_image(QString p_char, int p_emote, QString suffix) { QString emotion_number = QString::number(p_emote + 1); - QString image_path = ao_app->get_character_path(p_char, "emotions/button" + emotion_number + suffix); + QString image_path = ao_app->get_static_image_suffix(ao_app->get_character_path(p_char, "emotions/button" + emotion_number + suffix)); if (file_exists(image_path)) { diff --git a/src/aoevidencebutton.cpp b/src/aoevidencebutton.cpp index 15b598f..616f636 100644 --- a/src/aoevidencebutton.cpp +++ b/src/aoevidencebutton.cpp @@ -10,14 +10,14 @@ AOEvidenceButton::AOEvidenceButton(QWidget *p_parent, AOApplication *p_ao_app, i ui_selected = new AOImage(p_parent, ao_app); ui_selected->resize(70, 70); ui_selected->move(p_x, p_y); - ui_selected->set_image("evidence_selected.png"); + ui_selected->set_image("evidence_selected"); ui_selected->setAttribute(Qt::WA_TransparentForMouseEvents); ui_selected->hide(); ui_selector = new AOImage(p_parent, ao_app); ui_selector->resize(71, 71); ui_selector->move(p_x - 1, p_y - 1); - ui_selector->set_image("evidence_selector.png"); + ui_selector->set_image("evidence_selector"); ui_selector->setAttribute(Qt::WA_TransparentForMouseEvents); ui_selector->hide(); diff --git a/src/aoimage.cpp b/src/aoimage.cpp index 7bb56bb..17c2ea6 100644 --- a/src/aoimage.cpp +++ b/src/aoimage.cpp @@ -13,35 +13,40 @@ AOImage::~AOImage() } -void AOImage::set_image(QString p_image) +bool AOImage::set_image(QString p_image) { - QString theme_image_path = ao_app->get_theme_path(p_image); - QString default_image_path = ao_app->get_default_theme_path(p_image); + QString theme_image_path = ao_app->get_static_image_suffix(ao_app->get_theme_path(p_image)); + QString default_image_path = ao_app->get_static_image_suffix(ao_app->get_default_theme_path(p_image)); QString final_image_path; if (file_exists(theme_image_path)) final_image_path = theme_image_path; - else + else if (file_exists(default_image_path)) final_image_path = default_image_path; + else + { + qDebug() << "Warning: Image" << p_image << "not found! Can't set!"; + return false; + } QPixmap f_pixmap(final_image_path); this->setPixmap(f_pixmap.scaled(this->width(), this->height(), Qt::IgnoreAspectRatio)); + return true; } -void AOImage::set_image_from_path(QString p_path) +bool AOImage::set_chatbox(QString p_path) { - QString default_path = ao_app->get_default_theme_path("chatmed.png"); + p_path = ao_app->get_static_image_suffix(p_path); + if (!file_exists(p_path)) + { + qDebug() << "Warning: Chatbox" << p_path << "not found! Can't set!"; + return false; + } - QString final_path; - - if (file_exists(p_path)) - final_path = p_path; - else - final_path = default_path; - - QPixmap f_pixmap(final_path); + QPixmap f_pixmap(p_path); this->setPixmap(f_pixmap.scaled(this->width(), this->height(), Qt::IgnoreAspectRatio)); + return true; } diff --git a/src/charselect.cpp b/src/charselect.cpp index 0cfb775..23b0513 100644 --- a/src/charselect.cpp +++ b/src/charselect.cpp @@ -71,7 +71,7 @@ void Courtroom::set_char_select() this->resize(f_charselect.width, f_charselect.height); ui_char_select_background->resize(f_charselect.width, f_charselect.height); - ui_char_select_background->set_image("charselect_background.png"); + ui_char_select_background->set_image("charselect_background"); filter_character_list(); diff --git a/src/courtroom.cpp b/src/courtroom.cpp index 59d37d3..cfdc8fb 100644 --- a/src/courtroom.cpp +++ b/src/courtroom.cpp @@ -418,7 +418,7 @@ void Courtroom::set_widgets() ui_background->move(0, 0); ui_background->resize(m_courtroom_width, m_courtroom_height); - ui_background->set_image("courtroombackground.png"); + ui_background->set_image("courtroombackground"); set_size_and_pos(ui_viewport, "viewport"); @@ -517,7 +517,7 @@ void Courtroom::set_widgets() set_size_and_pos(ui_pair_offset_spinbox, "pair_offset_spinbox"); ui_pair_offset_spinbox->hide(); set_size_and_pos(ui_pair_button, "pair_button"); - ui_pair_button->set_image("pair_button.png"); + ui_pair_button->set_image("pair_button"); set_size_and_pos(ui_area_list, "music_list"); set_size_and_pos(ui_music_list, "music_list"); @@ -538,11 +538,11 @@ void Courtroom::set_widgets() 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);}"); - ui_vp_chatbox->set_image("chatmed.png"); + ui_vp_chatbox->set_image("chatblank"); ui_vp_chatbox->hide(); ui_muted->resize(ui_ic_chat_message->width(), ui_ic_chat_message->height()); - ui_muted->set_image("muted.png"); + ui_muted->set_image("muted"); set_size_and_pos(ui_ooc_chat_message, "ooc_chat_message"); ui_ooc_chat_message->setStyleSheet("background-color: rgba(0, 0, 0, 0);"); @@ -556,19 +556,19 @@ void Courtroom::set_widgets() set_size_and_pos(ui_emotes, "emotes"); set_size_and_pos(ui_emote_left, "emote_left"); - ui_emote_left->set_image("arrow_left.png"); + ui_emote_left->set_image("arrow_left"); set_size_and_pos(ui_emote_right, "emote_right"); - ui_emote_right->set_image("arrow_right.png"); + ui_emote_right->set_image("arrow_right."); set_size_and_pos(ui_emote_dropdown, "emote_dropdown"); set_size_and_pos(ui_pos_dropdown, "pos_dropdown"); set_size_and_pos(ui_defense_bar, "defense_bar"); - ui_defense_bar->set_image("defensebar" + QString::number(defense_bar_state) + ".png"); + ui_defense_bar->set_image("defensebar" + QString::number(defense_bar_state)); set_size_and_pos(ui_prosecution_bar, "prosecution_bar"); - ui_prosecution_bar->set_image("prosecutionbar" + QString::number(prosecution_bar_state) + ".png"); + ui_prosecution_bar->set_image("prosecutionbar" + QString::number(prosecution_bar_state)); set_size_and_pos(ui_music_label, "music_label"); ui_music_label->setText(tr("Music")); @@ -581,24 +581,24 @@ void Courtroom::set_widgets() ui_log_limit_label->setText(tr("Log limit")); set_size_and_pos(ui_hold_it, "hold_it"); - ui_hold_it->set_image("holdit.png"); + ui_hold_it->set_image("holdit"); set_size_and_pos(ui_objection, "objection"); - ui_objection->set_image("objection.png"); + ui_objection->set_image("objection"); set_size_and_pos(ui_take_that, "take_that"); - ui_take_that->set_image("takethat.png"); + ui_take_that->set_image("takethat"); set_size_and_pos(ui_ooc_toggle, "ooc_toggle"); ui_ooc_toggle->setText(tr("Server")); set_size_and_pos(ui_witness_testimony, "witness_testimony"); - ui_witness_testimony->set_image("witnesstestimony.png"); + ui_witness_testimony->set_image("witnesstestimony"); set_size_and_pos(ui_cross_examination, "cross_examination"); - ui_cross_examination->set_image("crossexamination.png"); + ui_cross_examination->set_image("crossexamination"); set_size_and_pos(ui_guilty, "guilty"); - ui_guilty->set_image("guilty.png"); + ui_guilty->set_image("guilty"); set_size_and_pos(ui_not_guilty, "not_guilty"); - ui_not_guilty->set_image("notguilty.png"); + ui_not_guilty->set_image("notguilty"); set_size_and_pos(ui_change_character, "change_character"); ui_change_character->setText(tr("Change character")); @@ -633,28 +633,28 @@ void Courtroom::set_widgets() set_size_and_pos(ui_showname_enable, "showname_enable"); set_size_and_pos(ui_custom_objection, "custom_objection"); - ui_custom_objection->set_image("custom.png"); + ui_custom_objection->set_image("custom"); set_size_and_pos(ui_realization, "realization"); - ui_realization->set_image("realization.png"); + ui_realization->set_image("realization"); set_size_and_pos(ui_screenshake, "screenshake"); - ui_screenshake->set_image("screenshake.png"); + ui_screenshake->set_image("screenshake"); set_size_and_pos(ui_mute, "mute_button"); - ui_mute->set_image("mute.png"); + ui_mute->set_image("mute"); set_size_and_pos(ui_defense_plus, "defense_plus"); - ui_defense_plus->set_image("defplus.png"); + ui_defense_plus->set_image("defplus"); set_size_and_pos(ui_defense_minus, "defense_minus"); - ui_defense_minus->set_image("defminus.png"); + ui_defense_minus->set_image("defminus"); set_size_and_pos(ui_prosecution_plus, "prosecution_plus"); - ui_prosecution_plus->set_image("proplus.png"); + ui_prosecution_plus->set_image("proplus"); set_size_and_pos(ui_prosecution_minus, "prosecution_minus"); - ui_prosecution_minus->set_image("prominus.png"); + ui_prosecution_minus->set_image("prominus"); set_size_and_pos(ui_text_color, "text_color"); @@ -665,40 +665,40 @@ void Courtroom::set_widgets() set_size_and_pos(ui_log_limit_spinbox, "log_limit_spinbox"); set_size_and_pos(ui_evidence_button, "evidence_button"); - ui_evidence_button->set_image("evidencebutton.png"); + ui_evidence_button->set_image("evidencebutton"); set_size_and_pos(ui_evidence, "evidence_background"); - ui_evidence->set_image("evidencebackground.png"); + ui_evidence->set_image("evidencebackground"); set_size_and_pos(ui_evidence_name, "evidence_name"); set_size_and_pos(ui_evidence_buttons, "evidence_buttons"); set_size_and_pos(ui_evidence_left, "evidence_left"); - ui_evidence_left->set_image("arrow_left.png"); + ui_evidence_left->set_image("arrow_left"); set_size_and_pos(ui_evidence_right, "evidence_right"); - ui_evidence_right->set_image("arrow_right.png"); + ui_evidence_right->set_image("arrow_right"); set_size_and_pos(ui_evidence_present, "evidence_present"); - ui_evidence_present->set_image("present_disabled.png"); + ui_evidence_present->set_image("present_disabled"); set_size_and_pos(ui_evidence_overlay, "evidence_overlay"); - ui_evidence_overlay->set_image("evidenceoverlay.png"); + ui_evidence_overlay->set_image("evidenceoverlay"); set_size_and_pos(ui_evidence_delete, "evidence_delete"); - ui_evidence_delete->set_image("deleteevidence.png"); + ui_evidence_delete->set_image("deleteevidence"); set_size_and_pos(ui_evidence_image_name, "evidence_image_name"); set_size_and_pos(ui_evidence_image_button, "evidence_image_button"); set_size_and_pos(ui_evidence_x, "evidence_x"); - ui_evidence_x->set_image("evidencex.png"); + ui_evidence_x->set_image("evidencex"); set_size_and_pos(ui_evidence_description, "evidence_description"); - ui_selector->set_image("char_selector.png"); + ui_selector->set_image("char_selector"); ui_selector->hide(); set_size_and_pos(ui_back_to_lobby, "back_to_lobby"); @@ -709,10 +709,10 @@ void Courtroom::set_widgets() set_size_and_pos(ui_char_buttons, "char_buttons"); set_size_and_pos(ui_char_select_left, "char_select_left"); - ui_char_select_left->set_image("arrow_left.png"); + ui_char_select_left->set_image("arrow_left"); set_size_and_pos(ui_char_select_right, "char_select_right"); - ui_char_select_right->set_image("arrow_right.png"); + ui_char_select_right->set_image("arrow_right"); set_size_and_pos(ui_spectator, "spectator"); @@ -869,9 +869,9 @@ void Courtroom::set_background(QString p_background) ui_vp_testimony->stop(); current_background = p_background; - is_ao2_bg = file_exists(ao_app->get_background_path("defensedesk.png")) && - file_exists(ao_app->get_background_path("prosecutiondesk.png")) && - file_exists(ao_app->get_background_path("stand.png")); + is_ao2_bg = file_exists(ao_app->get_static_image_suffix(ao_app->get_background_path("defensedesk"))) && + file_exists(ao_app->get_static_image_suffix(ao_app->get_background_path("prosecutiondesk"))) && + file_exists(ao_app->get_static_image_suffix(ao_app->get_background_path("stand"))); if (is_ao2_bg) { @@ -1386,6 +1386,9 @@ void Courtroom::handle_chatmessage(QStringList *p_contents) f_showname = m_chatmessage[SHOWNAME]; } + if(f_showname.trimmed().isEmpty()) //Pure whitespace showname, get outta here. + f_showname = m_chatmessage[CHAR_NAME]; + QString f_message = f_showname + ": " + m_chatmessage[MESSAGE] + '\n'; @@ -1409,13 +1412,13 @@ void Courtroom::handle_chatmessage(QStringList *p_contents) screenshake_state = 0; is_presenting_evidence = false; ui_pre->setChecked(false); - ui_hold_it->set_image("holdit.png"); - ui_objection->set_image("objection.png"); - ui_take_that->set_image("takethat.png"); - ui_custom_objection->set_image("custom.png"); - ui_realization->set_image("realization.png"); - ui_screenshake->set_image("screenshake.png"); - ui_evidence_present->set_image("present_disabled.png"); + ui_hold_it->set_image("holdit"); + ui_objection->set_image("objection"); + ui_take_that->set_image("takethat"); + ui_custom_objection->set_image("custom"); + ui_realization->set_image("realization"); + ui_screenshake->set_image("screenshake"); + ui_evidence_present->set_image("present_disabled"); if (ao_app->additive_enabled && ui_vp_player_char->m_char == m_chatmessage[CHAR_NAME]) @@ -1510,19 +1513,51 @@ void Courtroom::handle_chatmessage_2() ui_vp_showname->setText(m_chatmessage[SHOWNAME]); } + if(ui_vp_showname->text().trimmed().isEmpty()) //Whitespace showname + { + ui_vp_chatbox->set_image("chatblank"); + } + else //Aw yeah dude do some showname resizing magic + { + ui_vp_chatbox->set_image("chat"); + + QFontMetrics fm(ui_vp_showname->font()); + int fm_width=fm.horizontalAdvance(ui_vp_showname->text()); + + qDebug() << "showname shenanigans" << ui_vp_showname->width() << fm_width << ui_vp_showname->text(); + + QString chatbox_path = ao_app->get_theme_path("chat"); + QString chatbox = ao_app->get_chat(m_chatmessage[CHAR_NAME]); + qDebug() << chatbox; + if (chatbox != "") + { + chatbox_path = ao_app->get_base_path() + "misc/" + chatbox + "/chat"; + } + + pos_size_type default_width = ao_app->get_element_dimensions("showname", "courtroom_design.ini"); + int extra_width = ao_app->get_design_element("showname_extra_width", "courtroom_design.ini").toInt(); + qDebug() << extra_width; + + if(extra_width > 0) + { + qDebug() << default_width.width << chatbox_path; + + if (fm_width > default_width.width && ui_vp_chatbox->set_chatbox(chatbox_path + "med")) //This text be big. Let's do some shenanigans. + { + ui_vp_showname->resize(default_width.width+extra_width, ui_vp_showname->height()); + if (fm_width > ui_vp_showname->width() && ui_vp_chatbox->set_chatbox(chatbox_path + "big")) //Biggest possible size for us. + { + ui_vp_showname->resize(static_cast(default_width.width+(extra_width*2)), ui_vp_showname->height()); + } + } + else + ui_vp_showname->resize(default_width.width, ui_vp_showname->height()); + } + } + ui_vp_message->hide(); ui_vp_chatbox->hide(); - QString chatbox = ao_app->get_chat(m_chatmessage[CHAR_NAME]); - - if (chatbox == "") - ui_vp_chatbox->set_image("chatmed.png"); - else - { - QString chatbox_path = ao_app->get_base_path() + "misc/" + chatbox + "/chatbox.png"; - ui_vp_chatbox->set_image_from_path(chatbox_path); - } - QString design_file = "courtroom_fonts.ini"; int f_weight = ao_app->get_font_size("message", design_file); QString font_name = ao_app->get_font_name("message_font", design_file); @@ -2590,14 +2625,12 @@ void Courtroom::set_scene() f_background = "prohelperstand"; f_desk_image = "prohelperdesk"; } - else if (f_side == "jur" && (file_exists(ao_app->get_background_path("jurystand.png")) || - file_exists(ao_app->get_background_path("jurystand.gif")))) + else if (f_side == "jur" && file_exists(ao_app->get_image_suffix(ao_app->get_background_path("jurystand")))) { f_background = "jurystand"; f_desk_image = "jurydesk"; } - else if (f_side == "sea" && (file_exists(ao_app->get_background_path("seancestand.png")) || - file_exists(ao_app->get_background_path("seancestand.gif")))) + else if (f_side == "sea" && file_exists(ao_app->get_image_suffix(ao_app->get_background_path("seancestand")))) { f_background = "seancestand"; f_desk_image = "seancedesk"; @@ -2689,7 +2722,7 @@ void Courtroom::set_mute(bool p_muted, int p_cid) } ui_muted->resize(ui_ic_chat_message->width(), ui_ic_chat_message->height()); - ui_muted->set_image("muted.png"); + ui_muted->set_image("muted"); is_muted = p_muted; ui_ic_chat_message->setEnabled(!p_muted); @@ -2806,12 +2839,12 @@ void Courtroom::set_hp_bar(int p_bar, int p_state) if (p_bar == 1) { - ui_defense_bar->set_image("defensebar" + QString::number(p_state) + ".png"); + ui_defense_bar->set_image("defensebar" + QString::number(p_state)); defense_bar_state = p_state; } else if (p_bar == 2) { - ui_prosecution_bar->set_image("prosecutionbar" + QString::number(p_state) + ".png"); + ui_prosecution_bar->set_image("prosecutionbar" + QString::number(p_state)); prosecution_bar_state = p_state; } } @@ -3333,16 +3366,16 @@ void Courtroom::on_hold_it_clicked() { if (objection_state == 1) { - ui_hold_it->set_image("holdit.png"); + ui_hold_it->set_image("holdit"); objection_state = 0; } else { - ui_objection->set_image("objection.png"); - ui_take_that->set_image("takethat.png"); - ui_custom_objection->set_image("custom.png"); + ui_objection->set_image("objection"); + ui_take_that->set_image("takethat"); + ui_custom_objection->set_image("custom"); - ui_hold_it->set_image("holdit_selected.png"); + ui_hold_it->set_image("holdit_selected"); objection_state = 1; } @@ -3353,16 +3386,16 @@ void Courtroom::on_objection_clicked() { if (objection_state == 2) { - ui_objection->set_image("objection.png"); + ui_objection->set_image("objection"); objection_state = 0; } else { - ui_hold_it->set_image("holdit.png"); - ui_take_that->set_image("takethat.png"); - ui_custom_objection->set_image("custom.png"); + ui_hold_it->set_image("holdit"); + ui_take_that->set_image("takethat"); + ui_custom_objection->set_image("custom"); - ui_objection->set_image("objection_selected.png"); + ui_objection->set_image("objection_selected"); objection_state = 2; } @@ -3373,16 +3406,16 @@ void Courtroom::on_take_that_clicked() { if (objection_state == 3) { - ui_take_that->set_image("takethat.png"); + ui_take_that->set_image("takethat"); objection_state = 0; } else { - ui_objection->set_image("objection.png"); - ui_hold_it->set_image("holdit.png"); - ui_custom_objection->set_image("custom.png"); + ui_objection->set_image("objection"); + ui_hold_it->set_image("holdit"); + ui_custom_objection->set_image("custom"); - ui_take_that->set_image("takethat_selected.png"); + ui_take_that->set_image("takethat_selected"); objection_state = 3; } @@ -3393,16 +3426,16 @@ void Courtroom::on_custom_objection_clicked() { if (objection_state == 4) { - ui_custom_objection->set_image("custom.png"); + ui_custom_objection->set_image("custom"); objection_state = 0; } else { - ui_objection->set_image("objection.png"); - ui_take_that->set_image("takethat.png"); - ui_hold_it->set_image("holdit.png"); + ui_objection->set_image("objection"); + ui_take_that->set_image("takethat"); + ui_hold_it->set_image("holdit"); - ui_custom_objection->set_image("custom_selected.png"); + ui_custom_objection->set_image("custom_selected"); objection_state = 4; } @@ -3414,12 +3447,12 @@ void Courtroom::on_realization_clicked() if (realization_state == 0) { realization_state = 1; - ui_realization->set_image("realization_pressed.png"); + ui_realization->set_image("realization_pressed"); } else { realization_state = 0; - ui_realization->set_image("realization.png"); + ui_realization->set_image("realization"); } ui_ic_chat_message->setFocus(); @@ -3430,12 +3463,12 @@ void Courtroom::on_screenshake_clicked() if (screenshake_state == 0) { screenshake_state = 1; - ui_screenshake->set_image("screenshake_pressed.png"); + ui_screenshake->set_image("screenshake_pressed"); } else { screenshake_state = 0; - ui_screenshake->set_image("screenshake.png"); + ui_screenshake->set_image("screenshake"); } ui_ic_chat_message->setFocus(); @@ -3448,13 +3481,13 @@ void Courtroom::on_mute_clicked() ui_mute_list->show(); ui_pair_list->hide(); ui_pair_offset_spinbox->hide(); - ui_pair_button->set_image("pair_button.png"); - ui_mute->set_image("mute_pressed.png"); + ui_pair_button->set_image("pair_button"); + ui_mute->set_image("mute_pressed"); } else { ui_mute_list->hide(); - ui_mute->set_image("mute.png"); + ui_mute->set_image("mute"); } } @@ -3465,14 +3498,14 @@ void Courtroom::on_pair_clicked() ui_pair_list->show(); ui_pair_offset_spinbox->show(); ui_mute_list->hide(); - ui_mute->set_image("mute.png"); - ui_pair_button->set_image("pair_button_pressed.png"); + ui_mute->set_image("mute"); + ui_pair_button->set_image("pair_button_pressed"); } else { ui_pair_list->hide(); ui_pair_offset_spinbox->hide(); - ui_pair_button->set_image("pair_button.png"); + ui_pair_button->set_image("pair_button"); } } diff --git a/src/emotes.cpp b/src/emotes.cpp index b6a217e..daa8d6d 100644 --- a/src/emotes.cpp +++ b/src/emotes.cpp @@ -89,9 +89,9 @@ void Courtroom::set_emote_page() AOEmoteButton *f_emote = ui_emote_list.at(n_emote); if (n_real_emote == current_emote) - f_emote->set_image(current_char, n_real_emote, "_on.png"); + f_emote->set_image(current_char, n_real_emote, "_on"); else - f_emote->set_image(current_char, n_real_emote, "_off.png"); + f_emote->set_image(current_char, n_real_emote, "_off"); f_emote->show(); } @@ -119,14 +119,14 @@ void Courtroom::select_emote(int p_id) int max = (max_emotes_on_page - 1) + current_emote_page * max_emotes_on_page; if (current_emote >= min && current_emote <= max) - ui_emote_list.at(current_emote % max_emotes_on_page)->set_image(current_char, current_emote, "_off.png"); + ui_emote_list.at(current_emote % max_emotes_on_page)->set_image(current_char, current_emote, "_off"); int old_emote = current_emote; current_emote = p_id; if (current_emote >= min && current_emote <= max) - ui_emote_list.at(current_emote % max_emotes_on_page)->set_image(current_char, current_emote, "_on.png"); + ui_emote_list.at(current_emote % max_emotes_on_page)->set_image(current_char, current_emote, "_on"); int emote_mod = ao_app->get_emote_mod(current_char, current_emote); diff --git a/src/evidence.cpp b/src/evidence.cpp index 7e29b25..7580685 100644 --- a/src/evidence.cpp +++ b/src/evidence.cpp @@ -72,7 +72,7 @@ void Courtroom::construct_evidence() } } - connect(ui_evidence_name, SIGNAL(returnPressed()), this, SLOT(on_evidence_name_edited())); + connect(ui_evidence_name, SIGNAL(textEdited(QString)), this, SLOT(on_evidence_name_edited(QString))); connect(ui_evidence_left, SIGNAL(clicked()), this, SLOT(on_evidence_left_clicked())); connect(ui_evidence_right, SIGNAL(clicked()), this, SLOT(on_evidence_right_clicked())); connect(ui_evidence_present, SIGNAL(clicked()), this, SLOT(on_evidence_present_clicked())); @@ -153,7 +153,7 @@ void Courtroom::set_evidence_page() } } -void Courtroom::on_evidence_name_edited() +void Courtroom::on_evidence_name_edited(QString text) { if (current_evidence >= local_evidence_list.size()) return; @@ -163,6 +163,7 @@ void Courtroom::on_evidence_name_edited() evi_type f_evi = local_evidence_list.at(current_evidence); f_contents.append(QString::number(current_evidence)); + qDebug() << text; f_contents.append(ui_evidence_name->text()); f_contents.append(f_evi.description); f_contents.append(f_evi.image); @@ -297,9 +298,9 @@ void Courtroom::on_evidence_right_clicked() void Courtroom::on_evidence_present_clicked() { if (is_presenting_evidence) - ui_evidence_present->set_image("present_disabled.png"); + ui_evidence_present->set_image("present_disabled"); else - ui_evidence_present->set_image("present.png"); + ui_evidence_present->set_image("present"); is_presenting_evidence = !is_presenting_evidence; diff --git a/src/lobby.cpp b/src/lobby.cpp index 758f0fb..b8e3efd 100644 --- a/src/lobby.cpp +++ b/src/lobby.cpp @@ -84,28 +84,28 @@ void Lobby::set_widgets() } set_size_and_pos(ui_background, "lobby"); - ui_background->set_image("lobbybackground.png"); + ui_background->set_image("lobbybackground"); set_size_and_pos(ui_public_servers, "public_servers"); - ui_public_servers->set_image("publicservers_selected.png"); + ui_public_servers->set_image("publicservers_selected"); set_size_and_pos(ui_favorites, "favorites"); - ui_favorites->set_image("favorites.png"); + ui_favorites->set_image("favorites"); set_size_and_pos(ui_refresh, "refresh"); - ui_refresh->set_image("refresh.png"); + ui_refresh->set_image("refresh"); set_size_and_pos(ui_add_to_fav, "add_to_fav"); - ui_add_to_fav->set_image("addtofav.png"); + ui_add_to_fav->set_image("addtofav"); set_size_and_pos(ui_connect, "connect"); - ui_connect->set_image("connect.png"); + ui_connect->set_image("connect"); set_size_and_pos(ui_version, "version"); ui_version->setText(tr("Version: %1").arg(ao_app->get_version_string())); set_size_and_pos(ui_about, "about"); - ui_about->set_image("about.png"); + ui_about->set_image("about"); set_size_and_pos(ui_server_list, "server_list"); ui_server_list->setStyleSheet("background-color: rgba(0, 0, 0, 0);" @@ -135,7 +135,7 @@ void Lobby::set_widgets() "selection-background-color: rgba(0, 0, 0, 0);"); ui_loading_background->resize(this->width(), this->height()); - ui_loading_background->set_image("loadingbackground.png"); + ui_loading_background->set_image("loadingbackground"); set_size_and_pos(ui_loading_text, "loading_label"); @@ -262,8 +262,8 @@ void Lobby::set_loading_value(int p_value) void Lobby::on_public_servers_clicked() { - ui_public_servers->set_image("publicservers_selected.png"); - ui_favorites->set_image("favorites.png"); + ui_public_servers->set_image("publicservers_selected"); + ui_favorites->set_image("favorites"); list_servers(); @@ -272,8 +272,8 @@ void Lobby::on_public_servers_clicked() void Lobby::on_favorites_clicked() { - ui_favorites->set_image("favorites_selected.png"); - ui_public_servers->set_image("publicservers.png"); + ui_favorites->set_image("favorites_selected"); + ui_public_servers->set_image("publicservers"); ao_app->set_favorite_list(); //ao_app->favorite_list = read_serverlist_txt(); @@ -285,12 +285,12 @@ void Lobby::on_favorites_clicked() void Lobby::on_refresh_pressed() { - ui_refresh->set_image("refresh_pressed.png"); + ui_refresh->set_image("refresh_pressed"); } void Lobby::on_refresh_released() { - ui_refresh->set_image("refresh.png"); + ui_refresh->set_image("refresh"); AOPacket *f_packet = new AOPacket("ALL#%"); @@ -299,12 +299,12 @@ void Lobby::on_refresh_released() void Lobby::on_add_to_fav_pressed() { - ui_add_to_fav->set_image("addtofav_pressed.png"); + ui_add_to_fav->set_image("addtofav_pressed"); } void Lobby::on_add_to_fav_released() { - ui_add_to_fav->set_image("addtofav.png"); + ui_add_to_fav->set_image("addtofav"); //you cant add favorites from favorites m8 if (!public_servers_selected) @@ -315,12 +315,12 @@ void Lobby::on_add_to_fav_released() void Lobby::on_connect_pressed() { - ui_connect->set_image("connect_pressed.png"); + ui_connect->set_image("connect_pressed"); } void Lobby::on_connect_released() { - ui_connect->set_image("connect.png"); + ui_connect->set_image("connect"); AOPacket *f_packet; @@ -416,8 +416,8 @@ void Lobby::on_chatfield_return_pressed() void Lobby::list_servers() { public_servers_selected = true; - ui_favorites->set_image("favorites.png"); - ui_public_servers->set_image("publicservers_selected.png"); + ui_favorites->set_image("favorites"); + ui_public_servers->set_image("publicservers_selected"); ui_server_list->clear(); diff --git a/src/text_file_functions.cpp b/src/text_file_functions.cpp index 02c0b71..48ebeea 100644 --- a/src/text_file_functions.cpp +++ b/src/text_file_functions.cpp @@ -292,6 +292,15 @@ pos_size_type AOApplication::get_element_dimensions(QString p_identifier, QStrin return return_value; } +QString AOApplication::get_design_element(QString p_identifier, QString p_file) +{ + QString design_ini_path = get_theme_path(p_file); + QString f_result = read_design_ini(p_identifier, design_ini_path); + QString default_path = get_default_theme_path(p_file); + if (f_result == "") + f_result = read_design_ini(p_identifier, default_path); + return f_result; +} QString AOApplication::get_font_name(QString p_identifier, QString p_file) { QString design_ini_path = get_theme_path(p_file); @@ -501,6 +510,10 @@ QString AOApplication::get_image_suffix(QString path_to_check) return path_to_check + ".png"; } +QString AOApplication::get_static_image_suffix(QString path_to_check) +{ + return path_to_check + ".png"; +} //returns whatever is to the right of "search_line =" within target_tag and terminator_tag, trimmed //returns the empty string if the search line couldnt be found