From faac191f0b9e99b82614ed3959ec5c67f56a1fc3 Mon Sep 17 00:00:00 2001 From: oldmud0 Date: Fri, 17 Apr 2020 21:48:34 -0500 Subject: Mega-merge of CR fork CR likely stands for "CentsRaidensnake." Like the Case Cafe mega-merge before it, this was not a clean merge, and it had to be split up into two parts: the actual changes, and the attempt it made to reformat the entire code via clang-format. This branch had a complicated set of changes that would be difficult to describe in this commit message. It would be better described in a proper changelog. --- src/aomovie.cpp | 111 +++++++++++++++++++++++++++++++++++--------------------- 1 file changed, 70 insertions(+), 41 deletions(-) (limited to 'src/aomovie.cpp') diff --git a/src/aomovie.cpp b/src/aomovie.cpp index edf5bdb..bb8e53d 100644 --- a/src/aomovie.cpp +++ b/src/aomovie.cpp @@ -1,7 +1,7 @@ #include "aomovie.h" -#include "file_functions.h" #include "courtroom.h" +#include "file_functions.h" #include "misc_functions.h" AOMovie::AOMovie(QWidget *p_parent, AOApplication *p_ao_app) : QLabel(p_parent) @@ -11,55 +11,80 @@ AOMovie::AOMovie(QWidget *p_parent, AOApplication *p_ao_app) : QLabel(p_parent) m_movie = new QMovie(); this->setMovie(m_movie); - + 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())); } void AOMovie::set_play_once(bool p_play_once) { play_once = p_play_once; } +void AOMovie::start_timer(int delay) { timer->start(delay); } -void AOMovie::play(QString p_gif, QString p_char, QString p_custom_theme) +void AOMovie::play(QString p_gif, QString p_char, QString p_custom_theme, + int duration) { - m_movie->stop(); - - QString gif_path; - QString custom_path; - if (p_gif == "custom") - custom_path = ao_app->get_image_suffix(ao_app->get_character_path(p_char, p_gif)); + m_movie->stop(); + // this->timer_done(); + QString shout_path = p_gif; + QList pathlist; + + if (ao_app->get_character_path(p_char, p_gif) + .contains( + "custom_objections")) // checks if the file is located within the + // folder of custom objections + pathlist << ao_app->get_character_path( + p_char, + p_gif); // get_image_suffix is unecessery as it is already given. + else if (p_gif == "custom") + pathlist << ao_app->get_image_suffix( + ao_app->get_character_path(p_char, p_gif)); else - custom_path = ao_app->get_image_suffix(ao_app->get_character_path(p_char, p_gif + "_bubble")); + pathlist << ao_app->get_image_suffix( + ao_app->get_character_path(p_char, p_gif + "_bubble")); - QString misc_path = ao_app->get_base_path() + "misc/" + p_custom_theme + "/" + p_gif + "_bubble.gif"; - QString custom_theme_path = ao_app->get_custom_theme_path(p_custom_theme, p_gif + ".gif"); + QString misc_path = ao_app->get_base_path() + "misc/" + p_custom_theme + "/" + + p_gif + "_bubble.gif"; + QString custom_theme_path = + ao_app->get_custom_theme_path(p_custom_theme, p_gif + ".gif"); QString theme_path = ao_app->get_theme_path(p_gif + ".gif"); QString default_theme_path = ao_app->get_default_theme_path(p_gif + ".gif"); QString placeholder_path = ao_app->get_theme_path("placeholder.gif"); - QString default_placeholder_path = ao_app->get_default_theme_path("placeholder.gif"); - - if (file_exists(custom_path)) - gif_path = custom_path; - else if (file_exists(misc_path)) - gif_path = misc_path; - else if (file_exists(custom_theme_path)) - gif_path = custom_theme_path; - else if (file_exists(theme_path)) - gif_path = theme_path; - else if (file_exists(default_theme_path)) - gif_path = default_theme_path; - else if (file_exists(placeholder_path)) - gif_path = placeholder_path; - else if (file_exists(default_placeholder_path)) - gif_path = default_placeholder_path; - else - gif_path = ""; - - m_movie->setFileName(gif_path); + QString default_placeholder_path = + ao_app->get_default_theme_path("placeholder.gif"); + + pathlist << ao_app->get_image_suffix(ao_app->get_base_path() + "misc/" + + p_custom_theme + "/" + p_gif + "_bubble") + << // Misc path + ao_app->get_image_suffix( + ao_app->get_custom_theme_path(p_custom_theme, p_gif)) + << // Custom theme path + ao_app->get_image_suffix(ao_app->get_theme_path(p_gif)) << // Theme path + ao_app->get_image_suffix(ao_app->get_default_theme_path(p_gif)) + << // 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); + if (m_movie->loopCount() == 0) + play_once = true; this->show(); m_movie->start(); + if (m_movie->frameCount() == 0 && duration > 0) + timer->start(duration); } void AOMovie::stop() @@ -70,16 +95,20 @@ void AOMovie::stop() void AOMovie::frame_change(int n_frame) { - if (n_frame == (m_movie->frameCount() - 1) && play_once) - { - //we need this or else the last frame wont show - delay(m_movie->nextFrameDelay()); - - this->stop(); + // 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()); +} - //signal connected to courtroom object, let it figure out what to do - done(); - } +void AOMovie::timer_done() +{ + this->stop(); + done(); } void AOMovie::combo_resize(int w, int h) -- cgit From 13942345c6a3e7e1625c6c26cc2f2f368a3bff23 Mon Sep 17 00:00:00 2001 From: oldmud0 Date: Fri, 17 Apr 2020 21:57:16 -0500 Subject: Run clang-format on entire project Indentation fixed to 2 spaces per tab. Braces set to Stroustrup style. Lines reflow at 80 characters. One-line method bodies are on the same line as the signature. Space always after `//`. No indentation on preprocessor macros. Includes are sorted lexicographically. If you don't want to see this commit on blames, use the hidden whitespace option on GitHub, or use `-w` in git-blame. --- src/aomovie.cpp | 233 ++++++++++++++++++++++++++++---------------------------- 1 file changed, 115 insertions(+), 118 deletions(-) (limited to 'src/aomovie.cpp') diff --git a/src/aomovie.cpp b/src/aomovie.cpp index bb8e53d..9ffd62f 100644 --- a/src/aomovie.cpp +++ b/src/aomovie.cpp @@ -1,119 +1,116 @@ -#include "aomovie.h" - -#include "courtroom.h" +#include "aomovie.h" + +#include "courtroom.h" #include "file_functions.h" -#include "misc_functions.h" - -AOMovie::AOMovie(QWidget *p_parent, AOApplication *p_ao_app) : QLabel(p_parent) -{ - ao_app = p_ao_app; - - m_movie = new QMovie(); - - this->setMovie(m_movie); - 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())); -} - -void AOMovie::set_play_once(bool p_play_once) -{ - play_once = p_play_once; -} -void AOMovie::start_timer(int delay) { timer->start(delay); } - -void AOMovie::play(QString p_gif, QString p_char, QString p_custom_theme, - int duration) -{ - - m_movie->stop(); - // this->timer_done(); - QString shout_path = p_gif; - QList pathlist; - - if (ao_app->get_character_path(p_char, p_gif) - .contains( - "custom_objections")) // checks if the file is located within the - // folder of custom objections - pathlist << ao_app->get_character_path( - p_char, - p_gif); // get_image_suffix is unecessery as it is already given. - else if (p_gif == "custom") - pathlist << ao_app->get_image_suffix( - ao_app->get_character_path(p_char, p_gif)); - else - pathlist << ao_app->get_image_suffix( - ao_app->get_character_path(p_char, p_gif + "_bubble")); - - QString misc_path = ao_app->get_base_path() + "misc/" + p_custom_theme + "/" + - p_gif + "_bubble.gif"; - QString custom_theme_path = - ao_app->get_custom_theme_path(p_custom_theme, p_gif + ".gif"); - QString theme_path = ao_app->get_theme_path(p_gif + ".gif"); - QString default_theme_path = ao_app->get_default_theme_path(p_gif + ".gif"); - QString placeholder_path = ao_app->get_theme_path("placeholder.gif"); - QString default_placeholder_path = - ao_app->get_default_theme_path("placeholder.gif"); - - pathlist << ao_app->get_image_suffix(ao_app->get_base_path() + "misc/" + - p_custom_theme + "/" + p_gif + "_bubble") - << // Misc path - ao_app->get_image_suffix( - ao_app->get_custom_theme_path(p_custom_theme, p_gif)) - << // Custom theme path - ao_app->get_image_suffix(ao_app->get_theme_path(p_gif)) << // Theme path - ao_app->get_image_suffix(ao_app->get_default_theme_path(p_gif)) - << // 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); - if (m_movie->loopCount() == 0) - play_once = true; - - this->show(); - m_movie->start(); - if (m_movie->frameCount() == 0 && duration > 0) - timer->start(duration); -} - -void AOMovie::stop() -{ - 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()); -} - -void AOMovie::timer_done() -{ - this->stop(); - done(); -} - -void AOMovie::combo_resize(int w, int h) -{ - QSize f_size(w, h); - this->resize(f_size); - m_movie->setScaledSize(f_size); -} +#include "misc_functions.h" + +AOMovie::AOMovie(QWidget *p_parent, AOApplication *p_ao_app) : QLabel(p_parent) +{ + ao_app = p_ao_app; + + m_movie = new QMovie(); + + this->setMovie(m_movie); + 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())); +} + +void AOMovie::set_play_once(bool p_play_once) { play_once = p_play_once; } +void AOMovie::start_timer(int delay) { timer->start(delay); } + +void AOMovie::play(QString p_gif, QString p_char, QString p_custom_theme, + int duration) +{ + + m_movie->stop(); + // this->timer_done(); + QString shout_path = p_gif; + QList pathlist; + + if (ao_app->get_character_path(p_char, p_gif) + .contains( + "custom_objections")) // checks if the file is located within the + // folder of custom objections + pathlist << ao_app->get_character_path( + p_char, + p_gif); // get_image_suffix is unecessery as it is already given. + else if (p_gif == "custom") + pathlist << ao_app->get_image_suffix( + ao_app->get_character_path(p_char, p_gif)); + else + pathlist << ao_app->get_image_suffix( + ao_app->get_character_path(p_char, p_gif + "_bubble")); + + QString misc_path = ao_app->get_base_path() + "misc/" + p_custom_theme + "/" + + p_gif + "_bubble.gif"; + QString custom_theme_path = + ao_app->get_custom_theme_path(p_custom_theme, p_gif + ".gif"); + QString theme_path = ao_app->get_theme_path(p_gif + ".gif"); + QString default_theme_path = ao_app->get_default_theme_path(p_gif + ".gif"); + QString placeholder_path = ao_app->get_theme_path("placeholder.gif"); + QString default_placeholder_path = + ao_app->get_default_theme_path("placeholder.gif"); + + pathlist << ao_app->get_image_suffix(ao_app->get_base_path() + "misc/" + + p_custom_theme + "/" + p_gif + "_bubble") + << // Misc path + ao_app->get_image_suffix( + ao_app->get_custom_theme_path(p_custom_theme, p_gif)) + << // Custom theme path + ao_app->get_image_suffix(ao_app->get_theme_path(p_gif)) << // Theme path + ao_app->get_image_suffix(ao_app->get_default_theme_path(p_gif)) + << // 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); + if (m_movie->loopCount() == 0) + play_once = true; + + this->show(); + m_movie->start(); + if (m_movie->frameCount() == 0 && duration > 0) + timer->start(duration); +} + +void AOMovie::stop() +{ + 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()); +} + +void AOMovie::timer_done() +{ + this->stop(); + done(); +} + +void AOMovie::combo_resize(int w, int h) +{ + QSize f_size(w, h); + this->resize(f_size); + m_movie->setScaledSize(f_size); +} -- cgit