diff options
| author | oldmud0 <oldmud0@users.noreply.github.com> | 2021-12-23 20:45:57 -0600 |
|---|---|---|
| committer | oldmud0 <oldmud0@users.noreply.github.com> | 2021-12-23 20:45:57 -0600 |
| commit | 3c7f5619dbd2702c4234e085604139569c000eb3 (patch) | |
| tree | 174034307f6753640eb798b9a78d85907f44f4f6 /src | |
| parent | 26851be53600483a4a35f14d7096ce85a64af97d (diff) | |
Fix emote buttons not generating due to bad VPath lookup
Diffstat (limited to 'src')
| -rw-r--r-- | src/aoemotebutton.cpp | 48 | ||||
| -rw-r--r-- | src/emotes.cpp | 8 |
2 files changed, 30 insertions, 26 deletions
diff --git a/src/aoemotebutton.cpp b/src/aoemotebutton.cpp index 638d49da..82149aff 100644 --- a/src/aoemotebutton.cpp +++ b/src/aoemotebutton.cpp @@ -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); } diff --git a/src/emotes.cpp b/src/emotes.cpp index 541a6e20..67a243ba 100644 --- a/src/emotes.cpp +++ b/src/emotes.cpp @@ -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); |
