From ab30cca586a05506c3cfb502cee53957409242e8 Mon Sep 17 00:00:00 2001 From: Crystalwarrior Date: Sat, 14 Sep 2019 19:50:46 +0300 Subject: Use a ticker and QImageReader instead of QMovie Issue: absolutely fucking broken, needs shittons of fixing or ditching. Might not be that efficient, anyway. --- include/aocharmovie.h | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) (limited to 'include') diff --git a/include/aocharmovie.h b/include/aocharmovie.h index f54f5105..65ab79fe 100644 --- a/include/aocharmovie.h +++ b/include/aocharmovie.h @@ -1,7 +1,7 @@ #ifndef AOCHARMOVIE_H #define AOCHARMOVIE_H -#include +#include #include #include #include @@ -21,20 +21,24 @@ public: void play_talking(QString p_char, QString p_emote); void play_idle(QString p_char, QString p_emote); - void set_flipped(bool p_flipped) {m_flipped = p_flipped;} + void set_frame(QImage image); void stop(); + void set_flipped(bool p_flipped) {m_flipped = p_flipped;} + void move(int ax, int ay); void combo_resize(int w, int h); + private: AOApplication *ao_app; - QMovie *m_movie; - QVector movie_frames; + QImageReader *m_reader; QTimer *preanim_timer; + QTimer *ticker; + QString last_path; const int time_mod = 60; @@ -50,8 +54,8 @@ signals: void done(); private slots: - void frame_change(int n_frame); - void timer_done(); + void preanim_done(); + void movie_ticker(); }; #endif // AOCHARMOVIE_H -- cgit From 938f1aeea15c6b68495bb1cb0a80467f4e8cf343 Mon Sep 17 00:00:00 2001 From: Crystalwarrior Date: Sat, 14 Sep 2019 22:35:02 +0300 Subject: Optimize the heck out of animated images. There is no lag after the image is loaded now. HOWEVER, there's lag when the image is first loaded due to the aspect ratio and sizing (at least with .apng's). --- include/aocharmovie.h | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) (limited to 'include') diff --git a/include/aocharmovie.h b/include/aocharmovie.h index 65ab79fe..0921bc5f 100644 --- a/include/aocharmovie.h +++ b/include/aocharmovie.h @@ -6,6 +6,7 @@ #include #include #include +#include class AOApplication; @@ -21,7 +22,8 @@ public: void play_talking(QString p_char, QString p_emote); void play_idle(QString p_char, QString p_emote); - void set_frame(QImage image); + QPixmap get_pixmap(QImage image); + void set_frame(QPixmap f_pixmap); void stop(); @@ -35,19 +37,22 @@ public: private: AOApplication *ao_app; - QImageReader *m_reader; + QVector movie_frames; + QVector movie_delays; QTimer *preanim_timer; QTimer *ticker; QString last_path; + QElapsedTimer actual_time; const int time_mod = 60; // These are the X and Y values before they are fixed based on the sprite's width. int x = 0; int y = 0; - bool m_flipped = false; + int frame = 0; + bool m_flipped = false; bool play_once = true; signals: -- cgit From 37d192b4300efd1c2f3e35b2efb40e93ec99fa03 Mon Sep 17 00:00:00 2001 From: Crystalwarrior Date: Sun, 15 Sep 2019 02:14:40 +0300 Subject: Load frames as they're needed instead of loading everything at once, and cache them for optimization. The cache is cleared when a new animation is played. Resolve an issue where if a preanim transitions into (a)idle it would get stuck on the first frame of that (removed the ticker->stop();) --- include/aocharmovie.h | 2 ++ 1 file changed, 2 insertions(+) (limited to 'include') diff --git a/include/aocharmovie.h b/include/aocharmovie.h index 0921bc5f..c852bb36 100644 --- a/include/aocharmovie.h +++ b/include/aocharmovie.h @@ -42,6 +42,7 @@ private: QTimer *preanim_timer; QTimer *ticker; QString last_path; + QImageReader *m_reader = new QImageReader(); QElapsedTimer actual_time; const int time_mod = 60; @@ -51,6 +52,7 @@ private: int y = 0; int frame = 0; + int max_frames = 0; bool m_flipped = false; bool play_once = true; -- cgit