aboutsummaryrefslogtreecommitdiff
path: root/src/aocharmovie.cpp
diff options
context:
space:
mode:
authorCrystalwarrior <varsash@gmail.com>2019-09-15 17:44:02 +0300
committerCrystalwarrior <varsash@gmail.com>2019-09-15 17:44:02 +0300
commita2f9df4042585ab0849b54e2bb0b9699f9064aed (patch)
treee2ae5b98111959c75232ab24b9f909b742658e9c /src/aocharmovie.cpp
parent4db114007456f12c77f002cac4e26cd3f6917638 (diff)
Finally implement frame-specific effects such as screenshake, realization flash, sound effects, etc.
Fix screenshake animation modifying the default positions of shook elements Fix aomovie sometimes not playing the last frame and causing lagspikes due to the delay() method
Diffstat (limited to 'src/aocharmovie.cpp')
-rw-r--r--src/aocharmovie.cpp57
1 files changed, 57 insertions, 0 deletions
diff --git a/src/aocharmovie.cpp b/src/aocharmovie.cpp
index 0c389b1e..efe24735 100644
--- a/src/aocharmovie.cpp
+++ b/src/aocharmovie.cpp
@@ -47,6 +47,7 @@ void AOCharMovie::load_image(QString p_char, QString p_emote, QString emote_pref
preanim_timer->stop();
movie_frames.clear();
movie_delays.clear();
+ movie_effects.clear();
m_reader->setFileName(emote_path);
QPixmap f_pixmap = this->get_pixmap(m_reader->read());
@@ -62,6 +63,32 @@ void AOCharMovie::load_image(QString p_char, QString p_emote, QString emote_pref
movie_frames.append(f_pixmap);
movie_delays.append(f_delay);
}
+
+ movie_effects.resize(max_frames);
+ for (int e_frame = 0; e_frame < max_frames; ++e_frame)
+ {
+ qDebug() << p_char << p_emote << e_frame;
+ QString effect = ao_app->get_screenshake_frame(p_char, emote_prefix + p_emote, e_frame);
+ if (effect != "")
+ {
+ movie_effects[e_frame].append("shake");
+ qDebug() << e_frame << "shake";
+ }
+
+ effect = ao_app->get_flash_frame(p_char, emote_prefix + p_emote, e_frame);
+ if (effect != "")
+ {
+ movie_effects[e_frame].append("flash");
+ qDebug() << e_frame << "flash";
+ }
+
+ effect = ao_app->get_sfx_frame(p_char, emote_prefix + p_emote, e_frame);
+ if (effect != "")
+ {
+ movie_effects[e_frame].append("sfx^"+effect);
+ qDebug() << e_frame << effect;
+ }
+ }
#ifdef DEBUG_CHARMOVIE
qDebug() << max_frames << "Setting image to " << emote_path << "Time taken to process image:" << actual_time.elapsed();
@@ -71,6 +98,7 @@ void AOCharMovie::load_image(QString p_char, QString p_emote, QString emote_pref
void AOCharMovie::play()
{
+ play_frame_effect(frame);
if (max_frames <= 1)
return;
ticker->start(this->get_frame_delay(movie_delays[frame]));
@@ -101,6 +129,34 @@ void AOCharMovie::play_idle(QString p_char, QString p_emote)
play();
}
+void AOCharMovie::play_frame_effect(int frame)
+{
+ if(frame < max_frames)
+ {
+ foreach (QString effect, movie_effects[frame])
+ {
+ if(effect == "shake")
+ {
+ shake();
+ qDebug() << "Attempting to play shake on frame" << frame;
+ }
+
+ if(effect == "flash")
+ {
+ flash();
+ qDebug() << "Attempting to play flash on frame" << frame;
+ }
+
+ if(effect.startsWith("sfx^"))
+ {
+ QString sfx = effect.section("^", 1);
+ play_sfx(sfx);
+ qDebug() << "Attempting to play sfx" << sfx << "on frame" << frame;
+ }
+ }
+ }
+}
+
void AOCharMovie::stop()
{
//for all intents and purposes, stopping is the same as hiding. at no point do we want a frozen gif to display
@@ -182,6 +238,7 @@ void AOCharMovie::movie_ticker()
#endif
this->set_frame(movie_frames[frame]);
+ play_frame_effect(frame);
ticker->setInterval(this->get_frame_delay(movie_delays[frame]));
}