Allow AOMovie to have timers that take priority over the animated image frame count
Set it up so feeding the timer value when playing the AOMovie would use the timer but only in cases where a non-animated image is used Update shouts and wtce to pass the 'duration' argument which will be used if the image used is non-animated. Otherwise, prioritize the animated image duration.
This commit is contained in:
parent
961563daf3
commit
e76a83ddfe
@ -15,13 +15,15 @@ public:
|
|||||||
AOMovie(QWidget *p_parent, AOApplication *p_ao_app);
|
AOMovie(QWidget *p_parent, AOApplication *p_ao_app);
|
||||||
|
|
||||||
void set_play_once(bool p_play_once);
|
void set_play_once(bool p_play_once);
|
||||||
void play(QString p_gif, QString p_char = "", QString p_custom_theme = "");
|
void start_timer(int delay);
|
||||||
|
void play(QString p_gif, QString p_char = "", QString p_custom_theme = "", int duration = 0);
|
||||||
void combo_resize(int w, int h);
|
void combo_resize(int w, int h);
|
||||||
void stop();
|
void stop();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
QMovie *m_movie;
|
QMovie *m_movie;
|
||||||
AOApplication *ao_app;
|
AOApplication *ao_app;
|
||||||
|
QTimer *timer;
|
||||||
bool play_once = true;
|
bool play_once = true;
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
@ -29,6 +31,7 @@ signals:
|
|||||||
|
|
||||||
private slots:
|
private slots:
|
||||||
void frame_change(int n_frame);
|
void frame_change(int n_frame);
|
||||||
|
void timer_done();
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // AOMOVIE_H
|
#endif // AOMOVIE_H
|
||||||
|
@ -12,7 +12,11 @@ AOMovie::AOMovie(QWidget *p_parent, AOApplication *p_ao_app) : QLabel(p_parent)
|
|||||||
|
|
||||||
this->setMovie(m_movie);
|
this->setMovie(m_movie);
|
||||||
|
|
||||||
|
timer = new QTimer(this);
|
||||||
|
timer->setSingleShot(true);
|
||||||
|
|
||||||
connect(m_movie, SIGNAL(frameChanged(int)), this, SLOT(frame_change(int)));
|
connect(m_movie, SIGNAL(frameChanged(int)), this, SLOT(frame_change(int)));
|
||||||
|
connect(timer, SIGNAL(timeout()), this, SLOT(timer_done()));
|
||||||
}
|
}
|
||||||
|
|
||||||
void AOMovie::set_play_once(bool p_play_once)
|
void AOMovie::set_play_once(bool p_play_once)
|
||||||
@ -20,46 +24,44 @@ void AOMovie::set_play_once(bool p_play_once)
|
|||||||
play_once = p_play_once;
|
play_once = p_play_once;
|
||||||
}
|
}
|
||||||
|
|
||||||
void AOMovie::play(QString p_gif, QString p_char, QString p_custom_theme)
|
void AOMovie::start_timer(int delay)
|
||||||
|
{
|
||||||
|
timer->start(delay);
|
||||||
|
}
|
||||||
|
|
||||||
|
void AOMovie::play(QString p_gif, QString p_char, QString p_custom_theme, int duration)
|
||||||
{
|
{
|
||||||
m_movie->stop();
|
m_movie->stop();
|
||||||
|
|
||||||
QString gif_path;
|
QString shout_path;
|
||||||
|
QList<QString> pathlist;
|
||||||
QString custom_path;
|
|
||||||
if (p_gif == "custom")
|
if (p_gif == "custom")
|
||||||
custom_path = ao_app->get_image_suffix(ao_app->get_character_path(p_char, p_gif));
|
pathlist << ao_app->get_image_suffix(ao_app->get_character_path(p_char, p_gif));
|
||||||
else
|
else
|
||||||
custom_path = ao_app->get_image_suffix(ao_app->get_character_path(p_char, p_gif + "_bubble"));
|
pathlist << 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";
|
pathlist << ao_app->get_image_suffix(ao_app->get_base_path() + "misc/" + p_custom_theme + "/" + p_gif + "_bubble") << //Misc path
|
||||||
QString custom_theme_path = ao_app->get_custom_theme_path(p_custom_theme, p_gif + ".gif");
|
ao_app->get_image_suffix(ao_app->get_custom_theme_path(p_custom_theme, p_gif)) << //Custom theme path
|
||||||
QString theme_path = ao_app->get_theme_path(p_gif + ".gif");
|
ao_app->get_image_suffix(ao_app->get_theme_path(p_gif)) << //Theme path
|
||||||
QString default_theme_path = ao_app->get_default_theme_path(p_gif + ".gif");
|
ao_app->get_image_suffix(ao_app->get_default_theme_path(p_gif)) << //Default theme path
|
||||||
QString placeholder_path = ao_app->get_theme_path("placeholder.gif");
|
ao_app->get_image_suffix(ao_app->get_theme_path("placeholder")) << //Placeholder path
|
||||||
QString default_placeholder_path = ao_app->get_default_theme_path("placeholder.gif");
|
ao_app->get_image_suffix( ao_app->get_default_theme_path("placeholder")); //Default placeholder path
|
||||||
|
|
||||||
if (file_exists(custom_path))
|
for (QString path : pathlist)
|
||||||
gif_path = custom_path;
|
{
|
||||||
else if (file_exists(misc_path))
|
if (file_exists(path))
|
||||||
gif_path = misc_path;
|
{
|
||||||
else if (file_exists(custom_theme_path))
|
shout_path = path;
|
||||||
gif_path = custom_theme_path;
|
break;
|
||||||
else if (file_exists(theme_path))
|
}
|
||||||
gif_path = theme_path;
|
}
|
||||||
else if (file_exists(default_theme_path))
|
|
||||||
gif_path = default_theme_path;
|
|
||||||
else if (file_exists(placeholder_path))
|
|
||||||
gif_path = placeholder_path;
|
|
||||||
else if (file_exists(default_placeholder_path))
|
|
||||||
gif_path = default_placeholder_path;
|
|
||||||
else
|
|
||||||
gif_path = "";
|
|
||||||
|
|
||||||
m_movie->setFileName(gif_path);
|
m_movie->setFileName(shout_path);
|
||||||
|
|
||||||
this->show();
|
this->show();
|
||||||
m_movie->start();
|
m_movie->start();
|
||||||
|
if (m_movie->frameCount() == 0 && duration > 0)
|
||||||
|
this->start_timer(duration);
|
||||||
}
|
}
|
||||||
|
|
||||||
void AOMovie::stop()
|
void AOMovie::stop()
|
||||||
@ -70,16 +72,23 @@ void AOMovie::stop()
|
|||||||
|
|
||||||
void AOMovie::frame_change(int n_frame)
|
void AOMovie::frame_change(int n_frame)
|
||||||
{
|
{
|
||||||
if (n_frame == (m_movie->frameCount() - 1) && play_once)
|
//If it's a "static movie" (only one frame - png image), we can't change frames - ignore this function (use timer instead).
|
||||||
{
|
//If the frame didn't reach the last frame or the movie is continuous, don't stop the movie.
|
||||||
//we need this or else the last frame wont show
|
if (m_movie->frameCount() == 0 || n_frame < (m_movie->frameCount() - 1) || !play_once)
|
||||||
delay(m_movie->nextFrameDelay());
|
return;
|
||||||
|
//we need this or else the last frame wont show
|
||||||
|
delay(m_movie->nextFrameDelay());
|
||||||
|
|
||||||
this->stop();
|
this->stop();
|
||||||
|
|
||||||
//signal connected to courtroom object, let it figure out what to do
|
//signal connected to courtroom object, let it figure out what to do
|
||||||
done();
|
done();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void AOMovie::timer_done()
|
||||||
|
{
|
||||||
|
this->stop();
|
||||||
|
done();
|
||||||
}
|
}
|
||||||
|
|
||||||
void AOMovie::combo_resize(int w, int h)
|
void AOMovie::combo_resize(int w, int h)
|
||||||
|
@ -1350,20 +1350,20 @@ void Courtroom::handle_chatmessage(QStringList *p_contents)
|
|||||||
switch (objection_mod)
|
switch (objection_mod)
|
||||||
{
|
{
|
||||||
case 1:
|
case 1:
|
||||||
ui_vp_objection->play("holdit", f_char, f_custom_theme);
|
ui_vp_objection->play("holdit", f_char, f_custom_theme, 724);
|
||||||
objection_player->play("holdit.wav", f_char, f_custom_theme);
|
objection_player->play("holdit.wav", f_char, f_custom_theme);
|
||||||
break;
|
break;
|
||||||
case 2:
|
case 2:
|
||||||
ui_vp_objection->play("objection", f_char, f_custom_theme);
|
ui_vp_objection->play("objection", f_char, f_custom_theme, 724);
|
||||||
objection_player->play("objection.wav", f_char, f_custom_theme);
|
objection_player->play("objection.wav", f_char, f_custom_theme);
|
||||||
break;
|
break;
|
||||||
case 3:
|
case 3:
|
||||||
ui_vp_objection->play("takethat", f_char, f_custom_theme);
|
ui_vp_objection->play("takethat", f_char, f_custom_theme, 724);
|
||||||
objection_player->play("takethat.wav", f_char, f_custom_theme);
|
objection_player->play("takethat.wav", f_char, f_custom_theme);
|
||||||
break;
|
break;
|
||||||
//case 4 is AO2 only
|
//case 4 is AO2 only
|
||||||
case 4:
|
case 4:
|
||||||
ui_vp_objection->play("custom", f_char, f_custom_theme);
|
ui_vp_objection->play("custom", f_char, f_custom_theme, 724);
|
||||||
objection_player->play("custom.wav", f_char, f_custom_theme);
|
objection_player->play("custom.wav", f_char, f_custom_theme);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
@ -2574,7 +2574,7 @@ void Courtroom::handle_wtce(QString p_wtce, int variant)
|
|||||||
if (p_wtce == "testimony1")
|
if (p_wtce == "testimony1")
|
||||||
{
|
{
|
||||||
sfx_player->play(ao_app->get_sfx("witness_testimony"));
|
sfx_player->play(ao_app->get_sfx("witness_testimony"));
|
||||||
ui_vp_wtce->play("witnesstestimony");
|
ui_vp_wtce->play("witnesstestimony", "", "", 1500);
|
||||||
testimony_in_progress = true;
|
testimony_in_progress = true;
|
||||||
show_testimony();
|
show_testimony();
|
||||||
}
|
}
|
||||||
@ -2582,7 +2582,7 @@ void Courtroom::handle_wtce(QString p_wtce, int variant)
|
|||||||
else if (p_wtce == "testimony2")
|
else if (p_wtce == "testimony2")
|
||||||
{
|
{
|
||||||
sfx_player->play(ao_app->get_sfx("cross_examination"));
|
sfx_player->play(ao_app->get_sfx("cross_examination"));
|
||||||
ui_vp_wtce->play("crossexamination");
|
ui_vp_wtce->play("crossexamination", "", "", 1500);
|
||||||
testimony_in_progress = false;
|
testimony_in_progress = false;
|
||||||
}
|
}
|
||||||
else if (p_wtce == "judgeruling")
|
else if (p_wtce == "judgeruling")
|
||||||
@ -2590,12 +2590,12 @@ void Courtroom::handle_wtce(QString p_wtce, int variant)
|
|||||||
if (variant == 0)
|
if (variant == 0)
|
||||||
{
|
{
|
||||||
sfx_player->play(ao_app->get_sfx("not_guilty"));
|
sfx_player->play(ao_app->get_sfx("not_guilty"));
|
||||||
ui_vp_wtce->play("notguilty");
|
ui_vp_wtce->play("notguilty", "", "", 3000);
|
||||||
testimony_in_progress = false;
|
testimony_in_progress = false;
|
||||||
}
|
}
|
||||||
else if (variant == 1) {
|
else if (variant == 1) {
|
||||||
sfx_player->play(ao_app->get_sfx("guilty"));
|
sfx_player->play(ao_app->get_sfx("guilty"));
|
||||||
ui_vp_wtce->play("guilty");
|
ui_vp_wtce->play("guilty", "", "", 3000);
|
||||||
testimony_in_progress = false;
|
testimony_in_progress = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user