Evidence and emotes reloading when reload_theme is pressed

Update evidence a bit and change the way it sets images to something much better and less confusing
Update the hovering logic a bit so there's less weird occurences happening e.g. evidence button is deleted
This commit is contained in:
Crystalwarrior 2019-09-18 17:34:22 +03:00
parent 04daff7446
commit 0fe94d5d9f
6 changed files with 86 additions and 61 deletions

View File

@ -15,7 +15,6 @@ class AOEvidenceButton : public QPushButton
public:
AOEvidenceButton(QWidget *p_parent, AOApplication *p_ao_app, int p_x, int p_y);
void reset();
void set_image(QString p_image);
void set_theme_image(QString p_image);
void set_id(int p_id) {m_id = p_id;}

View File

@ -571,11 +571,13 @@ private:
void put_button_in_place(int starting, int chars_on_this_page);
void filter_character_list();
void construct_emotes();
void initialize_emotes();
void refresh_emotes();
void set_emote_page();
void set_emote_dropdown();
void construct_evidence();
void initialize_evidence();
void refresh_evidence();
void set_evidence_page();
public slots:

View File

@ -7,48 +7,49 @@ AOEvidenceButton::AOEvidenceButton(QWidget *p_parent, AOApplication *p_ao_app, i
ao_app = p_ao_app;
m_parent = p_parent;
ui_selected = new AOImage(p_parent, ao_app);
//HELLO AND WELCOME TO HARDCODE CENTRAL, MAY I TAKE YOUR FRESH ORDER OF PAIN AND SUFFERING
ui_selected = new AOImage(this, ao_app);
ui_selected->resize(70, 70);
ui_selected->move(p_x, p_y);
// ui_selected->move(p_x, p_y);
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 = new AOImage(this, ao_app);
ui_selector->resize(70, 70);
// ui_selector->move(p_x - 1, p_y - 1);
ui_selector->set_image("evidence_selector");
ui_selector->setAttribute(Qt::WA_TransparentForMouseEvents);
ui_selector->hide();
this->move(p_x, p_y);
this->resize(70, 70);
this->setAcceptDrops(true);
// this->setAcceptDrops(true);
connect(this, SIGNAL(clicked()), this, SLOT(on_clicked()));
}
void AOEvidenceButton::reset()
{
this->hide();
ui_selected->hide();
ui_selector->hide();
}
void AOEvidenceButton::set_image(QString p_image)
{
QString image_path = ao_app->get_evidence_path(p_image);
if (file_exists(image_path))
qDebug() << image_path << p_image;
if (file_exists(p_image))
{
this->setText("");
this->setStyleSheet("border-image:url(\"" + image_path + "\")");
this->setIcon(QIcon(p_image));
}
else if (file_exists(image_path))
{
this->setText("");
this->setIcon(QIcon(image_path));
}
else
{
this->setText(p_image);
this->setStyleSheet("");
this->setIcon(QIcon());
}
this->setIconSize(this->size());
this->setStyleSheet("border:0px");
}
void AOEvidenceButton::set_theme_image(QString p_image)
@ -63,8 +64,7 @@ void AOEvidenceButton::set_theme_image(QString p_image)
else
final_image_path = default_image_path;
this->setText("");
this->setStyleSheet("border-image:url(\"" + final_image_path + "\")");
this->set_image(final_image_path);
}
void AOEvidenceButton::set_selected(bool p_selected)

View File

@ -98,9 +98,13 @@ Courtroom::Courtroom(AOApplication *p_ao_app) : QMainWindow()
ui_vp_testimony = new AOMovie(this, ao_app);
ui_vp_testimony->set_play_once(false);
ui_vp_testimony->setAttribute(Qt::WA_TransparentForMouseEvents);
ui_vp_effect = new AOMovie(this, ao_app);
ui_vp_effect->setAttribute(Qt::WA_TransparentForMouseEvents);
ui_vp_wtce = new AOMovie(this, ao_app);
ui_vp_wtce->setAttribute(Qt::WA_TransparentForMouseEvents);
ui_vp_objection = new AOMovie(this, ao_app);
ui_vp_objection->setAttribute(Qt::WA_TransparentForMouseEvents);
ui_ic_chatlog = new QTextEdit(this);
ui_ic_chatlog->setReadOnly(true);
@ -147,12 +151,8 @@ Courtroom::Courtroom(AOApplication *p_ao_app) : QMainWindow()
ui_music_search->setFrame(false);
ui_music_search->setPlaceholderText(tr("Search"));
construct_emotes();
initialize_emotes();
ui_emote_left = new AOButton(this, ao_app);
ui_emote_right = new AOButton(this, ao_app);
ui_emote_dropdown = new QComboBox(this);
ui_pos_dropdown = new QComboBox(this);
ui_pos_dropdown->addItem("wit");
ui_pos_dropdown->addItem("def");
@ -267,7 +267,7 @@ Courtroom::Courtroom(AOApplication *p_ao_app) : QMainWindow()
ui_evidence_button = new AOButton(this, ao_app);
construct_evidence();
initialize_evidence();
construct_char_select();
@ -284,10 +284,6 @@ Courtroom::Courtroom(AOApplication *p_ao_app) : QMainWindow()
connect(chat_tick_timer, SIGNAL(timeout()), this, SLOT(chat_tick()));
connect(ui_emote_left, SIGNAL(clicked()), this, SLOT(on_emote_left_clicked()));
connect(ui_emote_right, SIGNAL(clicked()), this, SLOT(on_emote_right_clicked()));
connect(ui_emote_dropdown, SIGNAL(activated(int)), this, SLOT(on_emote_dropdown_changed(int)));
connect(ui_pos_dropdown, SIGNAL(currentIndexChanged(int)), this, SLOT(on_pos_dropdown_changed(int)));
connect(ui_iniswap_dropdown, SIGNAL(activated(int)), this, SLOT(on_iniswap_dropdown_changed(int)));
@ -582,14 +578,6 @@ void Courtroom::set_widgets()
//set_size_and_pos(ui_area_password, "area_password");
set_size_and_pos(ui_music_search, "music_search");
set_size_and_pos(ui_emotes, "emotes");
set_size_and_pos(ui_emote_left, "emote_left");
ui_emote_left->set_image("arrow_left");
set_size_and_pos(ui_emote_right, "emote_right");
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");
ui_pos_dropdown->setToolTip(tr("Set your character's supplementary background."));
@ -820,6 +808,9 @@ void Courtroom::set_widgets()
set_size_and_pos(ui_spectator, "spectator");
ui_spectator->setToolTip(tr("Become a spectator. You won't be able to interact with the in-character screen."));
refresh_evidence();
refresh_emotes();
}
void Courtroom::set_fonts()
@ -1060,6 +1051,8 @@ void Courtroom::update_character(int p_cid)
void Courtroom::enter_courtroom()
{
set_widgets();
current_evidence_page = 0;
current_evidence = 0;
@ -1089,9 +1082,6 @@ void Courtroom::enter_courtroom()
blip_player->set_volume(ui_blip_slider->value());
ui_vp_testimony->stop();
set_widgets();
//ui_server_chatlog->setHtml(ui_server_chatlog->toHtml());
}
@ -3789,7 +3779,9 @@ void Courtroom::on_realization_clicked()
if (realization_state == 0)
{
realization_state = 1;
effects_dropdown_find_and_set("realization");
if (effects_dropdown_find_and_set("realization"))
on_effects_dropdown_changed(ui_effects_dropdown->currentIndex());
ui_realization->set_image("realization_pressed");
}
else
@ -3980,8 +3972,8 @@ void Courtroom::on_reload_theme_clicked()
//to update status on the background
set_background(current_background);
update_character(m_cid);
enter_courtroom();
update_character(m_cid);
anim_state = 4;
text_state = 3;

View File

@ -2,12 +2,35 @@
#include "aoemotebutton.h"
void Courtroom::construct_emotes()
void Courtroom::initialize_emotes()
{
ui_emotes = new QWidget(this);
ui_emote_left = new AOButton(this, ao_app);
ui_emote_right = new AOButton(this, ao_app);
ui_emote_dropdown = new QComboBox(this);
connect(ui_emote_left, SIGNAL(clicked()), this, SLOT(on_emote_left_clicked()));
connect(ui_emote_right, SIGNAL(clicked()), this, SLOT(on_emote_right_clicked()));
connect(ui_emote_dropdown, SIGNAL(activated(int)), this, SLOT(on_emote_dropdown_changed(int)));
}
void Courtroom::refresh_emotes()
{
//Should properly refresh the emote list
qDeleteAll(ui_emote_list.begin(), ui_emote_list.end());
ui_emote_list.clear();
set_size_and_pos(ui_emotes, "emotes");
set_size_and_pos(ui_emote_left, "emote_left");
ui_emote_left->set_image("arrow_left");
set_size_and_pos(ui_emote_right, "emote_right");
ui_emote_right->set_image("arrow_right");
QPoint f_spacing = ao_app->get_button_spacing("emote_button_spacing", "courtroom_design.ini");
const int button_width = 40;

View File

@ -1,6 +1,6 @@
#include "courtroom.h"
void Courtroom::construct_evidence()
void Courtroom::initialize_evidence()
{
ui_evidence = new AOImage(this, ao_app);
@ -30,6 +30,24 @@ void Courtroom::construct_evidence()
ui_evidence_description->setStyleSheet("background-color: rgba(0, 0, 0, 0);"
"color: white;");
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()));
connect(ui_evidence_delete, SIGNAL(clicked()), this, SLOT(on_evidence_delete_clicked()));
connect(ui_evidence_image_name, SIGNAL(returnPressed()), this, SLOT(on_evidence_image_name_edited()));
connect(ui_evidence_image_button, SIGNAL(clicked()), this, SLOT(on_evidence_image_button_clicked()));
connect(ui_evidence_x, SIGNAL(clicked()), this, SLOT(on_evidence_x_clicked()));
ui_evidence->hide();
}
void Courtroom::refresh_evidence()
{
//Should properly refresh the evidence list
qDeleteAll(ui_evidence_list.begin(), ui_evidence_list.end());
ui_evidence_list.clear();
set_size_and_pos(ui_evidence, "evidence_background");
set_size_and_pos(ui_evidence_buttons, "evidence_buttons");
@ -71,17 +89,6 @@ void Courtroom::construct_evidence()
x_mod_count = 0;
}
}
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()));
connect(ui_evidence_delete, SIGNAL(clicked()), this, SLOT(on_evidence_delete_clicked()));
connect(ui_evidence_image_name, SIGNAL(returnPressed()), this, SLOT(on_evidence_image_name_edited()));
connect(ui_evidence_image_button, SIGNAL(clicked()), this, SLOT(on_evidence_image_button_clicked()));
connect(ui_evidence_x, SIGNAL(clicked()), this, SLOT(on_evidence_x_clicked()));
ui_evidence->hide();
}
void Courtroom::set_evidence_list(QVector<evi_type> &p_evi_list)
@ -101,7 +108,7 @@ void Courtroom::set_evidence_page()
for (AOEvidenceButton *i_button : ui_evidence_list)
{
i_button->reset();
i_button->hide();
}
//to account for the "add evidence" button
@ -135,20 +142,22 @@ void Courtroom::set_evidence_page()
AOEvidenceButton *f_evidence_button = ui_evidence_list.at(n_evidence_button);
//ie. the add evidence button
f_evidence_button->set_selected(false);
if (n_real_evidence == (total_evidence - 1))
{
f_evidence_button->set_theme_image("addevidence.png");
}
else if (n_real_evidence < (total_evidence - 1))
{
f_evidence_button->set_image(local_evidence_list.at(n_real_evidence).image);
if (n_real_evidence == current_evidence)
f_evidence_button->set_selected(true);
else
f_evidence_button->set_selected(false);
}
else
f_evidence_button->set_image("");
f_evidence_button->show();
}
}