Merge pull request #622 from AttorneyOnline/fix/emote-button-gen
Fix emote buttons not generating due to bad VPath lookup
This commit is contained in:
commit
d1fb7fde16
@ -14,7 +14,7 @@ public:
|
||||
int p_w, int p_h);
|
||||
|
||||
void set_image(QString p_image, QString p_emote_comment);
|
||||
void set_char_image(QString p_char, int p_emote, QString suffix);
|
||||
void set_char_image(QString p_char, int p_emote, bool on);
|
||||
|
||||
void set_id(int p_id) { m_id = p_id; }
|
||||
int get_id() { return m_id; }
|
||||
|
@ -25,11 +25,27 @@ void AOEmoteButton::set_image(QString p_image, QString p_emote_comment)
|
||||
"\") 0 0 0 0 stretch stretch; }"
|
||||
"QToolTip { color: #000000; background-color: #ffffff; border: 0px; }");
|
||||
}
|
||||
else if ((p_image.contains("_on") &&
|
||||
file_exists(tmp_p_image.replace("_on", "_off"))) ||
|
||||
(p_image.contains("_off") &&
|
||||
file_exists(tmp_p_image.replace("_off", "_on")))) {
|
||||
QImage tmpImage(tmp_p_image);
|
||||
else {
|
||||
this->setText(p_emote_comment);
|
||||
this->setStyleSheet("QPushButton { border-image: url(); }"
|
||||
"QToolTip { background-image: url(); color: #000000; "
|
||||
"background-color: #ffffff; border: 0px; }");
|
||||
}
|
||||
}
|
||||
|
||||
void AOEmoteButton::set_char_image(QString p_char, int p_emote, bool on)
|
||||
{
|
||||
QString emotion_number = QString::number(p_emote + 1);
|
||||
QStringList suffixes { "_off", "_on" };
|
||||
QStringList suffixedPaths;
|
||||
for (const QString &suffix : suffixes) {
|
||||
suffixedPaths.append(ao_app->get_image_suffix(ao_app->get_character_path(
|
||||
p_char, "emotions/button" + emotion_number + suffix)));
|
||||
}
|
||||
|
||||
QString emoteComment = ao_app->get_emote_comment(p_char, p_emote);
|
||||
if (!file_exists(suffixedPaths[on]) && file_exists(suffixedPaths[!on])) {
|
||||
QImage tmpImage(suffixedPaths[!on]);
|
||||
tmpImage = tmpImage.convertToFormat(QImage::Format_ARGB32);
|
||||
QPoint p1, p2;
|
||||
p2.setY(tmpImage.height());
|
||||
@ -46,25 +62,13 @@ void AOEmoteButton::set_image(QString p_image, QString p_emote_comment)
|
||||
p.fillRect(0, 0, tmpImage.width(), tmpImage.height(), gradient);
|
||||
|
||||
p.end();
|
||||
tmpImage.save(p_image, "png");
|
||||
set_image(p_image, p_emote_comment);
|
||||
}
|
||||
else {
|
||||
this->setText(p_emote_comment);
|
||||
this->setStyleSheet("QPushButton { border-image: url(); }"
|
||||
"QToolTip { background-image: url(); color: #000000; "
|
||||
"background-color: #ffffff; border: 0px; }");
|
||||
}
|
||||
}
|
||||
|
||||
void AOEmoteButton::set_char_image(QString p_char, int p_emote, QString suffix)
|
||||
{
|
||||
QString emotion_number = QString::number(p_emote + 1);
|
||||
QString image_path =
|
||||
ao_app->get_image_suffix(ao_app->get_character_path(
|
||||
p_char, "emotions/button" + emotion_number + suffix));
|
||||
// Original suffixed path may be empty, so create the path again
|
||||
suffixedPaths[on] = QString(suffixedPaths[!on]).replace(suffixes[!on], suffixes[on]);
|
||||
tmpImage.save(suffixedPaths[on], "png");
|
||||
}
|
||||
|
||||
this->set_image(image_path, ao_app->get_emote_comment(p_char, p_emote));
|
||||
set_image(suffixedPaths[on], emoteComment);
|
||||
}
|
||||
|
||||
void AOEmoteButton::on_clicked() { emit emote_clicked(m_id); }
|
||||
|
@ -126,9 +126,9 @@ void Courtroom::set_emote_page()
|
||||
AOEmoteButton *f_emote = ui_emote_list.at(n_emote);
|
||||
|
||||
if (n_real_emote == current_emote)
|
||||
f_emote->set_char_image(current_char, n_real_emote, "_on");
|
||||
f_emote->set_char_image(current_char, n_real_emote, true);
|
||||
else
|
||||
f_emote->set_char_image(current_char, n_real_emote, "_off");
|
||||
f_emote->set_char_image(current_char, n_real_emote, false);
|
||||
|
||||
f_emote->show();
|
||||
f_emote->setToolTip(QString::number(n_real_emote + 1) + ": " +
|
||||
@ -158,7 +158,7 @@ void Courtroom::select_emote(int p_id)
|
||||
|
||||
if (current_emote >= min && current_emote <= max)
|
||||
ui_emote_list.at(current_emote % max_emotes_on_page)
|
||||
->set_char_image(current_char, current_emote, "_off");
|
||||
->set_char_image(current_char, current_emote, false);
|
||||
|
||||
int old_emote = current_emote;
|
||||
|
||||
@ -166,7 +166,7 @@ void Courtroom::select_emote(int p_id)
|
||||
|
||||
if (current_emote >= min && current_emote <= max)
|
||||
ui_emote_list.at(current_emote % max_emotes_on_page)
|
||||
->set_char_image(current_char, current_emote, "_on");
|
||||
->set_char_image(current_char, current_emote, true);
|
||||
|
||||
int emote_mod = ao_app->get_emote_mod(current_char, current_emote);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user