Use brace constructors instead of << append operator for path lists

Rename gif_path into emote_path for charmovie.cpp
Rename p_gif into p_image for aomovie.cpp
This commit is contained in:
Crystalwarrior 2019-09-13 11:37:06 +03:00
parent 3b3507df60
commit 9aa88b1d6e
2 changed files with 39 additions and 35 deletions

View File

@ -19,28 +19,28 @@ AOCharMovie::AOCharMovie(QWidget *p_parent, AOApplication *p_ao_app) : QLabel(p_
void AOCharMovie::play(QString p_char, QString p_emote, QString emote_prefix)
{
QString original_path = ao_app->get_character_path(p_char, emote_prefix + p_emote + ".gif");
QString alt_path = ao_app->get_character_path(p_char, p_emote + ".png");
QString apng_path = ao_app->get_character_path(p_char, emote_prefix + p_emote + ".apng");
QString placeholder_path = ao_app->get_theme_path("placeholder.gif");
QString placeholder_default_path = ao_app->get_default_theme_path("placeholder.gif");
QString gif_path;
QString emote_path;
QList<QString> pathlist;
pathlist = {
ao_app->get_image_suffix(ao_app->get_character_path(p_char, emote_prefix + p_emote)), //Default path
ao_app->get_character_path(p_char, p_emote + ".png"), //Non-animated path if emote_prefix fails
ao_app->get_image_suffix(ao_app->get_theme_path("placeholder")), //Theme placeholder path
ao_app->get_image_suffix(ao_app->get_default_theme_path("placeholder")), //Default theme placeholder path
};
if (file_exists(apng_path))
gif_path = apng_path;
else if (file_exists(original_path))
gif_path = original_path;
else if (file_exists(alt_path))
gif_path = alt_path;
else if (file_exists(placeholder_path))
gif_path = placeholder_path;
else
gif_path = placeholder_default_path;
for (QString path : pathlist)
{
if (file_exists(path))
{
emote_path = path;
break;
}
}
m_movie->stop();
m_movie->setFileName(gif_path);
m_movie->setFileName(emote_path);
QImageReader *reader = new QImageReader(gif_path);
QImageReader *reader = new QImageReader(emote_path);
movie_frames.clear();
QImage f_image = reader->read();
@ -61,11 +61,11 @@ void AOCharMovie::play(QString p_char, QString p_emote, QString emote_prefix)
void AOCharMovie::play_pre(QString p_char, QString p_emote, int duration)
{
QString gif_path = ao_app->get_character_path(p_char, p_emote);
QString emote_path = ao_app->get_character_path(p_char, p_emote);
m_movie->stop();
this->clear();
m_movie->setFileName(gif_path);
m_movie->setFileName(emote_path);
m_movie->jumpToFrame(0);
int full_duration = duration * time_mod;
@ -116,11 +116,11 @@ void AOCharMovie::play_pre(QString p_char, QString p_emote, int duration)
void AOCharMovie::play_talking(QString p_char, QString p_emote)
{
QString gif_path = ao_app->get_character_path(p_char, "(b)" + p_emote);
QString emote_path = ao_app->get_character_path(p_char, "(b)" + p_emote);
m_movie->stop();
this->clear();
m_movie->setFileName(gif_path);
m_movie->setFileName(emote_path);
play_once = false;
m_movie->setSpeed(100);
@ -129,11 +129,11 @@ void AOCharMovie::play_talking(QString p_char, QString p_emote)
void AOCharMovie::play_idle(QString p_char, QString p_emote)
{
QString gif_path = ao_app->get_character_path(p_char, "(a)" + p_emote);
QString emote_path = ao_app->get_character_path(p_char, "(a)" + p_emote);
m_movie->stop();
this->clear();
m_movie->setFileName(gif_path);
m_movie->setFileName(emote_path);
play_once = false;
m_movie->setSpeed(100);

View File

@ -29,23 +29,27 @@ void AOMovie::start_timer(int delay)
timer->start(delay);
}
void AOMovie::play(QString p_gif, 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;
QList<QString> pathlist;
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"));
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
pathlist = {
ao_app->get_image_suffix(ao_app->get_base_path() + "misc/" + p_custom_theme + "/" + p_image + "_bubble"), //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
};
//Add this at the beginning of the list - order matters.
if (p_image == "custom")
pathlist.prepend(ao_app->get_image_suffix(ao_app->get_character_path(p_char, p_image)));
else
pathlist.prepend(ao_app->get_image_suffix(ao_app->get_character_path(p_char, p_image + "_bubble")));
for (QString path : pathlist)
{