diff options
| author | Crystalwarrior <varsash@gmail.com> | 2019-09-12 15:40:19 +0300 |
|---|---|---|
| committer | Crystalwarrior <varsash@gmail.com> | 2019-09-12 15:40:19 +0300 |
| commit | 3b415f5a7005fd0b42ba7ccbb9a8836746a72d41 (patch) | |
| tree | 2b2547988abf6db0fd314ea2cd2f4fb56008b577 /src/aoscene.cpp | |
| parent | 7e2ec58c7eb62077733f354764d0b729fe0e0a93 (diff) | |
Expand get_image_suffix to fall back on .png last
Reorganize the file_exists checks to be an array iterator instead for much less code duplication and easier ordering of priority
Reorganize desk and set_image loading on AOScene class, resolve issues with last_image setting to prevent animations from being restarted when characters talk on the same pos in succession
Apply get_image_suffix for seancestand and jurystand searches
TODO: At the moment, if you feed a .png shout, it will send the "Done" signal on the first frame (frame 0), not showing you the .png image at all. The shout code should be reorganized to allow static images to be displayed for exactly 720ms - the standard AA objection length. Usage of the timer similarly to the realizationflash.png might be possible.
Diffstat (limited to 'src/aoscene.cpp')
| -rw-r--r-- | src/aoscene.cpp | 53 |
1 files changed, 18 insertions, 35 deletions
diff --git a/src/aoscene.cpp b/src/aoscene.cpp index 0f4e7458..c9314258 100644 --- a/src/aoscene.cpp +++ b/src/aoscene.cpp @@ -12,16 +12,13 @@ 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 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)); + QString background_path = ao_app->get_image_suffix(ao_app->get_background_path(p_image)); + if (!file_exists(background_path)) + background_path = ao_app->get_image_suffix(ao_app->get_default_background_path(p_image)); //Default path - if (file_exists(animated_background_path) && animated_background_path == last_image) + if (file_exists(background_path) && background_path == last_image) return; - QPixmap background(background_path); - QPixmap default_bg(default_path); - int w = this->width(); int h = this->height(); @@ -29,74 +26,60 @@ void AOScene::set_image(QString p_image) this->setMovie(nullptr); m_movie->stop(); - m_movie->setFileName(animated_background_path); + m_movie->setFileName(background_path); m_movie->setScaledSize(QSize(w, h)); if (m_movie->isValid()) { this->setMovie(m_movie); m_movie->start(); - last_image = animated_background_path; - } - else if (file_exists(background_path)) - { - this->setPixmap(background.scaled(w, h)); } else { - this->setPixmap(default_bg.scaled(w, h)); + QPixmap background(background_path); + this->setPixmap(background.scaled(w, h)); } + last_image = background_path; } 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 + ".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)); + QString desk_path = ao_app->get_image_suffix(ao_app->get_background_path(p_image)); + if (!file_exists(desk_path)) + desk_path = ao_app->get_image_suffix(ao_app->get_default_background_path(p_image)); //Default path - if (file_exists(animated_desk_path) && animated_desk_path == last_image) + if (file_exists(desk_path) && desk_path == last_image) return; - QPixmap f_desk; + QPixmap f_desk(desk_path); + //vanilla desks vary in both width and height. in order to make that work with viewport rescaling, + //some INTENSE math is needed. int vp_width = m_parent->width(); int vp_height = m_parent->height(); - //double y_modifier = 147 / 192; - //double w_modifier = vp_width / 256; double h_modifier = vp_height / 192; - //int final_y = y_modifier * vp_height; - //int final_w = w_modifier * f_desk.width(); int final_h = static_cast<int>(h_modifier * f_desk.height()); this->clear(); this->setMovie(nullptr); m_movie->stop(); - m_movie->setFileName(animated_desk_path); + m_movie->setFileName(desk_path); - m_movie->setScaledSize(QSize(vp_width, vp_height)); + m_movie->setScaledSize(QSize(vp_width, final_h)); if (m_movie->isValid()) { this->setMovie(m_movie); m_movie->start(); - last_image = animated_desk_path; } 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)); } + last_image = desk_path; } |
