aboutsummaryrefslogtreecommitdiff
path: root/src/aocharmovie.cpp
diff options
context:
space:
mode:
authoriamgoofball <iamgoofball@gmail.com>2019-01-18 19:08:56 -0800
committeroldmud0 <oldmud0@users.noreply.github.com>2019-01-18 23:08:46 -0600
commit3c0cedbe922c9fcacd0d171423f83e375f66e178 (patch)
treebdc797518ee7b53ae4c9c7c290d4eb557c578a96 /src/aocharmovie.cpp
parentd62ff4d3afbfe3f17aaafc4c01a483ee87123219 (diff)
Add screenshake, frame-specific effects, looping SFX, and clientside music looping
Committed by patch since Goof is currently banned on GitHub for no good reason.
Diffstat (limited to 'src/aocharmovie.cpp')
-rw-r--r--src/aocharmovie.cpp240
1 files changed, 138 insertions, 102 deletions
diff --git a/src/aocharmovie.cpp b/src/aocharmovie.cpp
index 57487233..a5beefb9 100644
--- a/src/aocharmovie.cpp
+++ b/src/aocharmovie.cpp
@@ -7,25 +7,26 @@
AOCharMovie::AOCharMovie(QWidget *p_parent, AOApplication *p_ao_app) : QLabel(p_parent)
{
ao_app = p_ao_app;
-
m_movie = new QMovie(this);
-
preanim_timer = new QTimer(this);
+ ticker = new QTimer(this);
preanim_timer->setSingleShot(true);
-
- connect(m_movie, SIGNAL(frameChanged(int)), this, SLOT(frame_change(int)));
+ ticker->setSingleShot(true);
+ connect(ticker, SIGNAL(timeout()), this, SLOT(movie_ticker()));
connect(preanim_timer, SIGNAL(timeout()), this, SLOT(timer_done()));
+ this->setUpdatesEnabled(true);
}
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 alt_path = ao_app->get_character_path(p_char, emote_prefix + 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;
-
+ current_emote = emote_prefix + p_emote;
+ current_char = p_char;
if (file_exists(apng_path))
gif_path = apng_path;
else if (file_exists(original_path))
@@ -36,27 +37,139 @@ void AOCharMovie::play(QString p_char, QString p_emote, QString emote_prefix)
gif_path = placeholder_path;
else
gif_path = placeholder_default_path;
-
+ delete m_movie;
+ m_movie = new QMovie(this);
m_movie->stop();
+ this->clear();
m_movie->setFileName(gif_path);
+ m_movie->jumpToFrame(0);
+ this->LoadImageWithStupidMethodForFlipSupport(m_movie->currentImage());
+ qDebug() << "playing file path: " << gif_path;
+ this->show();
+ this->play_frame_sfx();
+ ticker->start(m_movie->nextFrameDelay());
+}
- QImageReader *reader = new QImageReader(gif_path);
-
- movie_frames.clear();
- QImage f_image = reader->read();
- while (!f_image.isNull())
+void AOCharMovie::play_frame_sfx()
+{
+ int current_frame = m_movie->currentFrameNumber();
+ QString sfx_to_play = ao_app->get_frame_sfx_name(current_char, current_emote, current_frame);
+ QString screenshake_to_play = ao_app->get_screenshake_frame(current_char, current_emote, current_frame);
+ QString realization_to_play = ao_app->get_realization_frame(current_char, current_emote, current_frame);
+ if(sfx_to_play != "" && !use_networked_framehell)
{
- if (m_flipped)
- movie_frames.append(f_image.mirrored(true, false));
- else
- movie_frames.append(f_image);
- f_image = reader->read();
+ frame_specific_sfx_player->play(ao_app->get_sfx_suffix(sfx_to_play));
}
+ else if(use_networked_framehell)
+ {
+ this->sfx_two_network_boogaloo();
+ }
+ if(screenshake_to_play != "" && !use_networked_framehell)
+ {
+ mycourtroom->doScreenShake();
+ }
+ else if(use_networked_framehell)
+ {
+ this->screenshake_two_network_boogaloo();
+ }
+ if(realization_to_play != "" && !use_networked_framehell)
+ {
+ mycourtroom->doRealization();
+ }
+ else if(use_networked_framehell)
+ {
+ this->realization_two_network_boogaloo();
+ }
+}
- delete reader;
+void AOCharMovie::realization_two_network_boogaloo()
+{
+ int current_frame = m_movie->currentFrameNumber();
+ QStringList fucking_garbage = this->frame_realization_hellstring.split("^");
+ for (int i = 0; i < fucking_garbage.length(); i++) {
+ QString fucking_christ = fucking_garbage.at(i);
+ QStringList extra_garbage = fucking_christ.split("|");
+ if(extra_garbage.at(0) != current_emote){
+ continue;
+ }
+ for (int ii = 1; ii < extra_garbage.length(); ii++) {
+ QString levels_of_garbage = extra_garbage.at(ii);
+ QStringList that_shouldnt_be_possible = levels_of_garbage.split("=");
+ if(that_shouldnt_be_possible.at(0).toInt() == current_frame && that_shouldnt_be_possible.at(1) != "") {
+ mycourtroom->doRealization();
+ }
+ }
+ }
+}
- this->show();
- m_movie->start();
+void AOCharMovie::screenshake_two_network_boogaloo()
+{
+ int current_frame = m_movie->currentFrameNumber();
+ QStringList fucking_garbage = this->frame_screenshake_hellstring.split("^");
+ for (int i = 0; i < fucking_garbage.length(); i++) {
+ QString fucking_christ = fucking_garbage.at(i);
+ QStringList extra_garbage = fucking_christ.split("|");
+ if(extra_garbage.at(0) != current_emote){
+ continue;
+ }
+ for (int ii = 1; ii < extra_garbage.length(); ii++) {
+ QString levels_of_garbage = extra_garbage.at(ii);
+ QStringList that_shouldnt_be_possible = levels_of_garbage.split("=");
+ if(that_shouldnt_be_possible.at(0).toInt() == current_frame && that_shouldnt_be_possible.at(1) != "") {
+ mycourtroom->doScreenShake();
+ }
+ }
+ }
+}
+
+void AOCharMovie::sfx_two_network_boogaloo()
+{
+ int current_frame = m_movie->currentFrameNumber();
+ QStringList fucking_garbage = this->frame_sfx_hellstring.split("^");
+ for (int i = 0; i < fucking_garbage.length(); i++) {
+ QString fucking_christ = fucking_garbage.at(i);
+ QStringList extra_garbage = fucking_christ.split("|");
+ if(extra_garbage.at(0) != current_emote){
+ continue;
+ }
+ for (int ii = 1; ii < extra_garbage.length(); ii++) {
+ QString levels_of_garbage = extra_garbage.at(ii);
+ QStringList that_shouldnt_be_possible = levels_of_garbage.split("=");
+ if(that_shouldnt_be_possible.at(0).toInt() == current_frame && that_shouldnt_be_possible.at(1) != "") {
+ frame_specific_sfx_player->play(ao_app->get_sfx_suffix(that_shouldnt_be_possible.at(1)));
+ }
+ }
+ }
+}
+
+
+void AOCharMovie::movie_ticker()
+{
+ m_movie->jumpToNextFrame();
+ this->LoadImageWithStupidMethodForFlipSupport(m_movie->currentImage()); // imagine if QT had sane stuff like "mirror on QMovie" or "resize the image on QT" or "interface with the current QMovie image" or anything else
+ // ps: fuck private functions/variables as a concept, freedom 2 do dangerous things 5ever
+ this->play_frame_sfx();
+ ticker->start(m_movie->nextFrameDelay());
+}
+
+void AOCharMovie::LoadImageWithStupidMethodForFlipSupport(QImage image)
+{
+ QPixmap f_pixmap;
+ if(m_flipped) // imagine if QT wasn't handicapped harder than people who think MLP is good
+ f_pixmap = QPixmap::fromImage(image.mirrored(true, false));
+ else
+ f_pixmap = QPixmap::fromImage(image);
+ auto aspect_ratio = Qt::KeepAspectRatio;
+
+ if (f_pixmap.size().width() > f_pixmap.size().height())
+ aspect_ratio = Qt::KeepAspectRatioByExpanding;
+
+ if (f_pixmap.size().width() > this->size().width() || f_pixmap.size().height() > this->size().height())
+ this->setPixmap(f_pixmap.scaled(this->width(), this->height(), aspect_ratio, Qt::SmoothTransformation));
+ else
+ this->setPixmap(f_pixmap.scaled(this->width(), this->height(), aspect_ratio, Qt::FastTransformation));
+
+ QLabel::move(x + (this->width() - this->pixmap()->width())/2, y);
}
void AOCharMovie::play_pre(QString p_char, QString p_emote, int duration)
@@ -64,79 +177,29 @@ void AOCharMovie::play_pre(QString p_char, QString p_emote, int duration)
QString gif_path = ao_app->get_character_path(p_char, p_emote);
m_movie->stop();
- this->clear();
m_movie->setFileName(gif_path);
m_movie->jumpToFrame(0);
-
- int full_duration = duration * time_mod;
int real_duration = 0;
-
- play_once = false;
-
for (int n_frame = 0 ; n_frame < m_movie->frameCount() ; ++n_frame)
{
+ qDebug() << "frame " << n_frame << " delay of " << m_movie->nextFrameDelay();
real_duration += m_movie->nextFrameDelay();
m_movie->jumpToFrame(n_frame + 1);
}
-
-#ifdef DEBUG_GIF
- qDebug() << "full_duration: " << full_duration;
- qDebug() << "real_duration: " << real_duration;
-#endif
-
- double percentage_modifier = 100.0;
-
- if (real_duration != 0 && duration != 0)
- {
- double modifier = full_duration / static_cast<double>(real_duration);
- percentage_modifier = 100 / modifier;
-
- if (percentage_modifier > 100.0)
- percentage_modifier = 100.0;
- }
-
-#ifdef DEBUG_GIF
- qDebug() << "% mod: " << percentage_modifier;
-#endif
-
- if (full_duration == 0 || full_duration >= real_duration)
- {
- play_once = true;
- }
- else
- {
- play_once = false;
- preanim_timer->start(full_duration);
- }
-
-
- m_movie->setSpeed(static_cast<int>(percentage_modifier));
+ play_once = true;
+ preanim_timer->start(real_duration);
play(p_char, p_emote, "");
}
void AOCharMovie::play_talking(QString p_char, QString p_emote)
{
- QString gif_path = ao_app->get_character_path(p_char, "(b)" + p_emote);
-
- m_movie->stop();
- this->clear();
- m_movie->setFileName(gif_path);
-
play_once = false;
- m_movie->setSpeed(100);
play(p_char, p_emote, "(b)");
}
void AOCharMovie::play_idle(QString p_char, QString p_emote)
{
- QString gif_path = ao_app->get_character_path(p_char, "(a)" + p_emote);
-
- m_movie->stop();
- this->clear();
- m_movie->setFileName(gif_path);
-
play_once = false;
- m_movie->setSpeed(100);
play(p_char, p_emote, "(a)");
}
@@ -145,6 +208,7 @@ 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
m_movie->stop();
preanim_timer->stop();
+ frame_specific_sfx_player->stop();
this->hide();
}
@@ -152,9 +216,8 @@ void AOCharMovie::combo_resize(int w, int h)
{
QSize f_size(w, h);
this->resize(f_size);
- m_movie->setScaledSize(f_size);
+ m_movie->setScaledSize(this->size());
}
-
void AOCharMovie::move(int ax, int ay)
{
x = ax;
@@ -162,34 +225,7 @@ void AOCharMovie::move(int ax, int ay)
QLabel::move(x, y);
}
-void AOCharMovie::frame_change(int n_frame)
-{
-
- if (movie_frames.size() > n_frame)
- {
- QPixmap f_pixmap = QPixmap::fromImage(movie_frames.at(n_frame));
- auto aspect_ratio = Qt::KeepAspectRatio;
-
- if (f_pixmap.size().width() > f_pixmap.size().height())
- aspect_ratio = Qt::KeepAspectRatioByExpanding;
-
- if (f_pixmap.size().width() > this->size().width() || f_pixmap.size().height() > this->size().height())
- this->setPixmap(f_pixmap.scaled(this->width(), this->height(), aspect_ratio, Qt::SmoothTransformation));
- else
- this->setPixmap(f_pixmap.scaled(this->width(), this->height(), aspect_ratio, Qt::FastTransformation));
-
- QLabel::move(x + (this->width() - this->pixmap()->width())/2, y);
- }
-
- if (m_movie->frameCount() - 1 == n_frame && play_once)
- {
- preanim_timer->start(m_movie->nextFrameDelay());
- m_movie->stop();
- }
-}
-
void AOCharMovie::timer_done()
{
-
done();
}