diff options
| author | Crystalwarrior <varsash@gmail.com> | 2019-09-10 21:57:06 +0300 |
|---|---|---|
| committer | Crystalwarrior <varsash@gmail.com> | 2019-09-10 21:57:06 +0300 |
| commit | 73782055237ee8948b26935348e8ca2b8a71a95a (patch) | |
| tree | 23bb2cdb6f994deab925d7337c7a0f94fd54fcf5 /src/aoscene.cpp | |
| parent | 961563daf3af7fd0167b281ed101d11c67a4eaf7 (diff) | |
Expand .apng and .webp support for get_image_suffix
Add get_image_suffix for all .gif's so that all animated pieces can be .webp or .apng instead
Expand on .webp .apng support and clean up the code somewhat
Diffstat (limited to 'src/aoscene.cpp')
| -rw-r--r-- | src/aoscene.cpp | 45 |
1 files changed, 29 insertions, 16 deletions
diff --git a/src/aoscene.cpp b/src/aoscene.cpp index 344522b6..6d2dc890 100644 --- a/src/aoscene.cpp +++ b/src/aoscene.cpp @@ -12,8 +12,8 @@ AOScene::AOScene(QWidget *parent, AOApplication *p_ao_app) : QLabel(parent) void AOScene::set_image(QString p_image) { QString background_path = ao_app->get_background_path(p_image + ".png"); - QString animated_background_path = ao_app->get_background_path(p_image + ".gif"); QString default_path = ao_app->get_default_background_path(p_image + ".png"); + QString animated_background_path = ao_app->get_image_suffix(ao_app->get_background_path(p_image)); QPixmap background(background_path); QPixmap default_bg(default_path); @@ -34,13 +34,9 @@ void AOScene::set_image(QString p_image) m_movie->start(); } else if (file_exists(background_path)) - { this->setPixmap(background.scaled(w, h)); - } else - { this->setPixmap(default_bg.scaled(w, h)); - } } void AOScene::set_legacy_desk(QString p_image) @@ -48,16 +44,12 @@ void AOScene::set_legacy_desk(QString p_image) //vanilla desks vary in both width and height. in order to make that work with viewport rescaling, //some INTENSE math is needed. - QString desk_path = ao_app->get_background_path(p_image); - QString default_path = ao_app->get_default_background_path(p_image); + QString desk_path = ao_app->get_background_path(p_image + ".png"); + QString animated_desk_path = ao_app->get_image_suffix(ao_app->get_background_path(p_image)); + QString default_path = ao_app->get_image_suffix(ao_app->get_default_background_path(p_image)); QPixmap f_desk; - if (file_exists(desk_path)) - f_desk.load(desk_path); - else - f_desk.load(default_path); - int vp_width = m_parent->width(); int vp_height = m_parent->height(); @@ -69,8 +61,29 @@ void AOScene::set_legacy_desk(QString p_image) //int final_w = w_modifier * f_desk.width(); int final_h = static_cast<int>(h_modifier * f_desk.height()); - //this->resize(final_w, final_h); - //this->setPixmap(f_desk.scaled(final_w, final_h)); - this->resize(vp_width, final_h); - this->setPixmap(f_desk.scaled(vp_width, final_h)); + this->clear(); + this->setMovie(nullptr); + + m_movie->stop(); + m_movie->setFileName(animated_desk_path); + + m_movie->setScaledSize(QSize(vp_width, vp_height)); + + if (m_movie->isValid()) + { + this->setMovie(m_movie); + m_movie->start(); + } + else + { + if (file_exists(desk_path)) + f_desk.load(desk_path); + else + f_desk.load(default_path); + + //this->resize(final_w, final_h); + //this->setPixmap(f_desk.scaled(final_w, final_h)); + this->resize(vp_width, final_h); + this->setPixmap(f_desk.scaled(vp_width, final_h)); + } } |
