diff options
| author | Crystalwarrior <varsash@gmail.com> | 2020-05-22 02:14:54 +0300 |
|---|---|---|
| committer | Crystalwarrior <varsash@gmail.com> | 2020-05-22 02:14:54 +0300 |
| commit | 88de4cde0433ef5e606f38a2f1e6041f0d24a87e (patch) | |
| tree | ce57adab0e3a236a93d112f33235638b74502040 /src/aomovie.cpp | |
| parent | c8e12558cdd3fd0769b81679ad09edf1f29b780f (diff) | |
clang 2 electric boogaloo
{ BasedOnStyle: LLVM, BreakBeforeBraces: Stroustrup}
Diffstat (limited to 'src/aomovie.cpp')
| -rw-r--r-- | src/aomovie.cpp | 118 |
1 files changed, 62 insertions, 56 deletions
diff --git a/src/aomovie.cpp b/src/aomovie.cpp index 7e3bbae0..ac949219 100644 --- a/src/aomovie.cpp +++ b/src/aomovie.cpp @@ -6,88 +6,94 @@ AOMovie::AOMovie(QWidget *p_parent, AOApplication *p_ao_app) : QLabel(p_parent) { - ao_app = p_ao_app; + ao_app = p_ao_app; - m_movie = new QMovie(); + m_movie = new QMovie(); - this->setMovie(m_movie); + this->setMovie(m_movie); - timer = new QTimer(this); - timer->setTimerType(Qt::PreciseTimer); - timer->setSingleShot(true); + timer = new QTimer(this); + timer->setTimerType(Qt::PreciseTimer); + timer->setSingleShot(true); - connect(m_movie, SIGNAL(frameChanged(int)), this, SLOT(frame_change(int))); - connect(timer, SIGNAL(timeout()), this, SLOT(timer_done())); + connect(m_movie, SIGNAL(frameChanged(int)), this, SLOT(frame_change(int))); + connect(timer, SIGNAL(timeout()), this, SLOT(timer_done())); } -void AOMovie::set_play_once(bool p_play_once) -{ - play_once = p_play_once; -} +void AOMovie::set_play_once(bool p_play_once) { play_once = p_play_once; } -void AOMovie::play(QString p_image, QString p_char, QString p_custom_theme, int duration) +void AOMovie::play(QString p_image, QString p_char, QString p_custom_theme, + int duration) { - m_movie->stop(); - - QString shout_path = p_image; - if (!file_exists(p_image)) { - QList<QString> pathlist; - - pathlist = { - ao_app->get_image_suffix(ao_app->get_character_path(p_char, p_image)), //Character folder - ao_app->get_image_suffix(ao_app->get_base_path() + "misc/" + p_custom_theme + "/" + p_image), //Misc path - ao_app->get_image_suffix(ao_app->get_custom_theme_path(p_custom_theme, p_image)), //Custom theme path - ao_app->get_image_suffix(ao_app->get_theme_path(p_image)), //Theme path - ao_app->get_image_suffix(ao_app->get_default_theme_path(p_image)), //Default theme path - ao_app->get_image_suffix(ao_app->get_theme_path("placeholder")), //Placeholder path - ao_app->get_image_suffix(ao_app->get_default_theme_path("placeholder")), //Default placeholder path - }; - - for (QString path : pathlist) { - if (file_exists(path)) { - shout_path = path; - break; - } - } + m_movie->stop(); + + QString shout_path = p_image; + if (!file_exists(p_image)) { + QList<QString> pathlist; + + pathlist = { + ao_app->get_image_suffix( + ao_app->get_character_path(p_char, p_image)), // Character folder + ao_app->get_image_suffix(ao_app->get_base_path() + "misc/" + + p_custom_theme + "/" + p_image), // Misc path + ao_app->get_image_suffix(ao_app->get_custom_theme_path( + p_custom_theme, p_image)), // Custom theme path + ao_app->get_image_suffix(ao_app->get_theme_path(p_image)), // Theme path + ao_app->get_image_suffix( + ao_app->get_default_theme_path(p_image)), // Default theme path + ao_app->get_image_suffix( + ao_app->get_theme_path("placeholder")), // Placeholder path + ao_app->get_image_suffix(ao_app->get_default_theme_path( + "placeholder")), // Default placeholder path + }; + + for (QString path : pathlist) { + if (file_exists(path)) { + shout_path = path; + break; + } } + } - m_movie->setFileName(shout_path); + m_movie->setFileName(shout_path); - if (m_movie->loopCount() == 0) - play_once = true; + if (m_movie->loopCount() == 0) + play_once = true; - this->show(); - m_movie->start(); - if (m_movie->frameCount() == 0 && duration > 0) - timer->start(duration); + this->show(); + m_movie->start(); + if (m_movie->frameCount() == 0 && duration > 0) + timer->start(duration); } void AOMovie::stop() { - m_movie->stop(); - this->hide(); + m_movie->stop(); + this->hide(); } void AOMovie::frame_change(int n_frame) { - //If it's a "static movie" (only one frame - png image), we can't change frames - ignore this function (use timer instead). - //If the frame didn't reach the last frame or the movie is continuous, don't stop the movie. - if (m_movie->frameCount() == 0 || n_frame < (m_movie->frameCount() - 1) || !play_once) - return; - //we need this or else the last frame wont show - timer->start(m_movie->nextFrameDelay()); + // If it's a "static movie" (only one frame - png image), we can't change + // frames - ignore this function (use timer instead). If the frame didn't reach + // the last frame or the movie is continuous, don't stop the movie. + if (m_movie->frameCount() == 0 || n_frame < (m_movie->frameCount() - 1) || + !play_once) + return; + // we need this or else the last frame wont show + timer->start(m_movie->nextFrameDelay()); } void AOMovie::timer_done() { - this->stop(); - //signal connected to courtroom object, let it figure out what to do - done(); + this->stop(); + // signal connected to courtroom object, let it figure out what to do + done(); } void AOMovie::combo_resize(int w, int h) { - QSize f_size(w, h); - this->resize(f_size); - m_movie->setScaledSize(f_size); + QSize f_size(w, h); + this->resize(f_size); + m_movie->setScaledSize(f_size); } |
