aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCrystalwarrior <varsash@gmail.com>2019-09-10 21:57:06 +0300
committerCrystalwarrior <varsash@gmail.com>2019-09-10 21:57:06 +0300
commit73782055237ee8948b26935348e8ca2b8a71a95a (patch)
tree23bb2cdb6f994deab925d7337c7a0f94fd54fcf5
parent961563daf3af7fd0167b281ed101d11c67a4eaf7 (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
-rw-r--r--include/aoapplication.h2
-rw-r--r--src/aocharmovie.cpp11
-rw-r--r--src/aomovie.cpp14
-rw-r--r--src/aoscene.cpp45
-rw-r--r--src/courtroom.cpp11
-rw-r--r--src/text_file_functions.cpp5
6 files changed, 52 insertions, 36 deletions
diff --git a/include/aoapplication.h b/include/aoapplication.h
index 5475eb7b..68e82ce3 100644
--- a/include/aoapplication.h
+++ b/include/aoapplication.h
@@ -219,7 +219,7 @@ public:
//Figure out if we can opus this or if we should fall back to wav
QString get_sfx_suffix(QString sound_to_check);
- // Can we use APNG for this? If not, fall back to a gif.
+ // Can we use APNG for this? If not, WEBP? If not, fall back to gif.
QString get_image_suffix(QString path_to_check);
//Returns the value of p_search_line within target_tag and terminator_tag
diff --git a/src/aocharmovie.cpp b/src/aocharmovie.cpp
index 57487233..eacf8530 100644
--- a/src/aocharmovie.cpp
+++ b/src/aocharmovie.cpp
@@ -19,16 +19,13 @@ 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 original_path = ao_app->get_image_suffix(ao_app->get_character_path(p_char, emote_prefix + p_emote));
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 placeholder_path = ao_app->get_image_suffix(ao_app->get_theme_path("placeholder"));
+ QString placeholder_default_path = ao_app->get_image_suffix(ao_app->get_default_theme_path("placeholder"));
QString gif_path;
- if (file_exists(apng_path))
- gif_path = apng_path;
- else if (file_exists(original_path))
+ if (file_exists(original_path))
gif_path = original_path;
else if (file_exists(alt_path))
gif_path = alt_path;
diff --git a/src/aomovie.cpp b/src/aomovie.cpp
index edf5bdb0..71a5a76a 100644
--- a/src/aomovie.cpp
+++ b/src/aomovie.cpp
@@ -32,12 +32,12 @@ void AOMovie::play(QString p_gif, QString p_char, QString p_custom_theme)
else
custom_path = 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");
+ QString misc_path = ao_app->get_image_suffix(ao_app->get_base_path() + "misc/" + p_custom_theme + "/" + p_gif + "_bubble");
+ QString custom_theme_path = ao_app->get_image_suffix(ao_app->get_custom_theme_path(p_custom_theme, p_gif));
+ QString theme_path = ao_app->get_image_suffix(ao_app->get_theme_path(p_gif));
+ QString default_theme_path = ao_app->get_image_suffix(ao_app->get_default_theme_path(p_gif));
+ QString placeholder_path = ao_app->get_image_suffix(ao_app->get_theme_path("placeholder"));
+ QString default_placeholder_path =ao_app->get_image_suffix( ao_app->get_default_theme_path("placeholder"));
if (file_exists(custom_path))
gif_path = custom_path;
@@ -70,7 +70,7 @@ void AOMovie::stop()
void AOMovie::frame_change(int n_frame)
{
- if (n_frame == (m_movie->frameCount() - 1) && play_once)
+ if (n_frame >= (m_movie->frameCount() - 1) && play_once)
{
//we need this or else the last frame wont show
delay(m_movie->nextFrameDelay());
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));
+ }
}
diff --git a/src/courtroom.cpp b/src/courtroom.cpp
index a1714163..cc69a1ee 100644
--- a/src/courtroom.cpp
+++ b/src/courtroom.cpp
@@ -909,7 +909,8 @@ void Courtroom::enter_courtroom(int p_cid)
if (ao_app->custom_objection_enabled &&
(file_exists(ao_app->get_character_path(current_char, "custom.gif")) ||
- file_exists(ao_app->get_character_path(current_char, "custom.apng"))) &&
+ file_exists(ao_app->get_character_path(current_char, "custom.apng")) ||
+ file_exists(ao_app->get_character_path(current_char, "custom.webp"))) &&
file_exists(ao_app->get_character_path(current_char, "custom.wav")))
ui_custom_objection->show();
else
@@ -2409,13 +2410,17 @@ void Courtroom::set_scene()
f_desk_image = "prohelperdesk";
}
else if (f_side == "jur" && (file_exists(ao_app->get_background_path("jurystand.png")) ||
- file_exists(ao_app->get_background_path("jurystand.gif"))))
+ file_exists(ao_app->get_background_path("jurystand.gif")) ||
+ file_exists(ao_app->get_background_path("jurystand.apng")) ||
+ file_exists(ao_app->get_background_path("jurystand.webp"))))
{
f_background = "jurystand";
f_desk_image = "jurydesk";
}
else if (f_side == "sea" && (file_exists(ao_app->get_background_path("seancestand.png")) ||
- file_exists(ao_app->get_background_path("seancestand.gif"))))
+ file_exists(ao_app->get_background_path("seancestand.gif")) ||
+ file_exists(ao_app->get_background_path("seancestand.apng")) ||
+ file_exists(ao_app->get_background_path("seancestand.webp"))))
{
f_background = "seancestand";
f_desk_image = "seancedesk";
diff --git a/src/text_file_functions.cpp b/src/text_file_functions.cpp
index 5a34ac8b..904e212f 100644
--- a/src/text_file_functions.cpp
+++ b/src/text_file_functions.cpp
@@ -385,11 +385,12 @@ QString AOApplication::get_sfx_suffix(QString sound_to_check)
QString AOApplication::get_image_suffix(QString path_to_check)
{
+ QString webp_check = path_to_check + ".webp";
QString apng_check = path_to_check + ".apng";
+ if (file_exists(webp_check))
+ return webp_check;
if (file_exists(apng_check))
- {
return apng_check;
- }
return path_to_check + ".gif";
}