|
2 | 2 |
|
3 | 3 | #include "aoapplication.h" |
4 | 4 | #include "options.h" |
| 5 | +#include "webcache.h" |
5 | 6 |
|
6 | 7 | #include <QRectF> |
7 | 8 | #include <QThreadPool> |
@@ -452,12 +453,23 @@ void CharacterAnimationLayer::loadCharacterEmote(QString character, QString file |
452 | 453 | } |
453 | 454 |
|
454 | 455 | int index = -1; |
| 456 | + int non_placeholder_count = placeholder_fallback ? path_list.size() - 2 : path_list.size(); |
455 | 457 | QString file_path = ao_app->get_image_path(path_list, index); |
456 | 458 | if (index != -1) |
457 | 459 | { |
458 | 460 | m_resolved_emote = prefixed_emote_list[index]; |
459 | 461 | } |
460 | 462 |
|
| 463 | + // Trigger webcache download if actual character emote not found (fell back to placeholder or not found at all) |
| 464 | + if ((index == -1 || index >= non_placeholder_count) && Options::getInstance().webcacheEnabled()) |
| 465 | + { |
| 466 | + static const QStringList image_suffixes{".webp", ".apng", ".gif", ".png"}; |
| 467 | + for (int i = 0; i < non_placeholder_count; ++i) |
| 468 | + { |
| 469 | + ao_app->webcache()->resolveOrDownload(path_list[i].toQString(), image_suffixes); |
| 470 | + } |
| 471 | + } |
| 472 | + |
461 | 473 | setFileName(file_path); |
462 | 474 | setPlayOnce(play_once); |
463 | 475 | setResizeMode(ao_app->get_scaling(ao_app->get_emote_property(character, fileName, "scaling"))); |
@@ -589,7 +601,15 @@ BackgroundAnimationLayer::BackgroundAnimationLayer(AOApplication *ao_app, QWidge |
589 | 601 |
|
590 | 602 | void BackgroundAnimationLayer::loadAndPlayAnimation(QString fileName) |
591 | 603 | { |
592 | | - QString file_path = ao_app->get_image_suffix(ao_app->get_background_path(fileName)); |
| 604 | + VPath vpath = ao_app->get_background_path(fileName); |
| 605 | + QString file_path = ao_app->get_image_suffix(vpath); |
| 606 | + |
| 607 | + // Trigger webcache download if file not found locally |
| 608 | + if (file_path.isEmpty() && Options::getInstance().webcacheEnabled()) |
| 609 | + { |
| 610 | + ao_app->webcache()->resolveOrDownload(vpath.toQString(), {".webp", ".apng", ".gif", ".png"}); |
| 611 | + } |
| 612 | + |
593 | 613 | #ifdef DEBUG_MOVIE |
594 | 614 | if (file_path.isEmpty()) |
595 | 615 | { |
|
0 commit comments