highly experimental and complex preanim algorithm testing in progress

This commit is contained in:
David Skoland 2017-02-16 22:29:10 +01:00
parent d328838288
commit 00e491bb26
4 changed files with 57 additions and 17 deletions

View File

@ -37,11 +37,10 @@ void AOCharMovie::play(QString p_char, QString p_emote, QString emote_prefix)
gif_path = placeholder_default_path; gif_path = placeholder_default_path;
m_movie->stop(); m_movie->stop();
this->clear();
qDebug() << "gif_path: " << gif_path;
m_movie->setFileName(gif_path); m_movie->setFileName(gif_path);
qDebug() << "framecount: " << m_movie->frameCount();
if (m_flipped) if (m_flipped)
{ {
QImageReader *reader = new QImageReader(gif_path); QImageReader *reader = new QImageReader(gif_path);
@ -67,26 +66,61 @@ void AOCharMovie::play(QString p_char, QString p_emote, QString emote_prefix)
void AOCharMovie::play_pre(QString p_char, QString p_emote, int duration) void AOCharMovie::play_pre(QString p_char, QString p_emote, int duration)
{ {
if (duration == 0) QString gif_path = ao_app->get_character_path(p_char) + p_emote.toLower();
play_once = true;
m_movie->stop();
this->clear();
m_movie->setFileName(gif_path);
int real_duration = 0;
else
{
play_once = false; play_once = false;
preanim_timer->start(duration);
for (int n_frame = 0 ; n_frame < m_movie->frameCount() ; ++n_frame)
{
real_duration += m_movie->nextFrameDelay();
m_movie->jumpToFrame(n_frame);
} }
qDebug() << "real_duration: " << real_duration;
qDebug() << "duration: " << duration;
double percentage_modifier = 100.0;
if (real_duration != 0 && duration != 0)
{
percentage_modifier = (duration / static_cast<double>(real_duration)) * 100.0;
}
qDebug() << "% mod: " << percentage_modifier;
play_once = true;
//m_movie->jumpToFrame(m_movie->frameCount() - 1);
m_movie->setSpeed(static_cast<int>(percentage_modifier));
play(p_char, p_emote, ""); play(p_char, p_emote, "");
} }
void AOCharMovie::play_talking(QString p_char, QString 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.toLower();
m_movie->stop();
this->clear();
m_movie->setFileName(gif_path);
play_once = false; play_once = false;
m_movie->setSpeed(100);
play(p_char, p_emote, "(b)"); play(p_char, p_emote, "(b)");
} }
void AOCharMovie::play_idle(QString p_char, QString p_emote) void AOCharMovie::play_idle(QString p_char, QString p_emote)
{ {
QString gif_path = ao_app->get_character_path(p_char) + "(a)" + p_emote.toLower();
m_movie->stop();
this->clear();
m_movie->setFileName(gif_path);
play_once = false; play_once = false;
m_movie->setSpeed(100);
play(p_char, p_emote, "(a)"); play(p_char, p_emote, "(a)");
} }
@ -112,11 +146,12 @@ void AOCharMovie::frame_change(int n_frame)
if (m_movie->frameCount() - 1 == n_frame && play_once) if (m_movie->frameCount() - 1 == n_frame && play_once)
{ {
preanim_timer->start(m_movie->nextFrameDelay()); preanim_timer->start(m_movie->nextFrameDelay());
done(); //done();
} }
} }
void AOCharMovie::timer_done() void AOCharMovie::timer_done()
{ {
qDebug() << "timer done called";
done(); done();
} }

View File

@ -343,7 +343,6 @@ void Courtroom::set_widgets()
m_courtroom_height = f_courtroom.height; m_courtroom_height = f_courtroom.height;
this->resize(m_courtroom_width, m_courtroom_height); this->resize(m_courtroom_width, m_courtroom_height);
this->setFixedSize(m_courtroom_width, m_courtroom_height);
ui_background->move(0, 0); ui_background->move(0, 0);
ui_background->resize(m_courtroom_width, m_courtroom_height); ui_background->resize(m_courtroom_width, m_courtroom_height);
@ -648,7 +647,6 @@ void Courtroom::set_char_select()
} }
this->resize(f_charselect.width, f_charselect.height); this->resize(f_charselect.width, f_charselect.height);
this->setFixedSize(f_charselect.width, f_charselect.height);
ui_char_select_background->resize(f_charselect.width, f_charselect.height); ui_char_select_background->resize(f_charselect.width, f_charselect.height);
@ -1205,13 +1203,14 @@ void Courtroom::play_preanim()
QString f_preanim = m_chatmessage[PRE_EMOTE]; QString f_preanim = m_chatmessage[PRE_EMOTE];
//all time values in char.inis are multiplied by a constant(time_mod) to get the actual time //all time values in char.inis are multiplied by a constant(time_mod) to get the actual time
int preanim_duration = ao_app->get_ao2_preanim_duration(f_char, f_preanim) * time_mod; int preanim_duration = ao_app->get_preanim_duration(f_char, f_preanim) * time_mod;
int text_delay = ao_app->get_text_delay(f_char, f_preanim) * time_mod; int text_delay = ao_app->get_text_delay(f_char, f_preanim) * time_mod;
int sfx_delay = m_chatmessage[SFX_DELAY].toInt() * time_mod; int sfx_delay = m_chatmessage[SFX_DELAY].toInt() * time_mod;
sfx_delay_timer->start(sfx_delay); sfx_delay_timer->start(sfx_delay);
if (!file_exists(ao_app->get_character_path(f_char) + f_preanim.toLower() + ".gif")) if (!file_exists(ao_app->get_character_path(f_char) + f_preanim.toLower() + ".gif") ||
preanim_duration < 0)
{ {
anim_state = 1; anim_state = 1;
preanim_done(); preanim_done();

View File

@ -108,13 +108,19 @@ void Courtroom::on_emote_clicked(int p_id)
if (current_emote >= min && current_emote <= max) if (current_emote >= min && current_emote <= max)
ui_emote_list.at(current_emote % max_emotes_on_page)->set_image(current_char, current_emote, "_off.png"); ui_emote_list.at(current_emote % max_emotes_on_page)->set_image(current_char, current_emote, "_off.png");
int old_emote = current_emote;
current_emote = p_id + max_emotes_on_page * current_emote_page; current_emote = p_id + max_emotes_on_page * current_emote_page;
ui_emote_list.at(current_emote % max_emotes_on_page)->set_image(current_char, current_emote, "_on.png"); ui_emote_list.at(current_emote % max_emotes_on_page)->set_image(current_char, current_emote, "_on.png");
int emote_mod = ao_app->get_emote_mod(current_char, current_emote); int emote_mod = ao_app->get_emote_mod(current_char, current_emote);
if (emote_mod == 1) if (old_emote == current_emote)
{
ui_pre->setChecked(!ui_pre->isChecked());
}
else if (emote_mod == 1)
ui_pre->setChecked(true); ui_pre->setChecked(true);
else else
ui_pre->setChecked(false); ui_pre->setChecked(false);

View File

@ -233,7 +233,7 @@ QString AOApplication::get_chat(QString p_char)
QString f_result = read_char_ini(p_char, "chat", "[Options]", "[Time]"); QString f_result = read_char_ini(p_char, "chat", "[Options]", "[Time]");
//handling the correct order of chat is a bit complicated, we let the caller do it //handling the correct order of chat is a bit complicated, we let the caller do it
return f_result; return f_result.toLower();
} }
int AOApplication::get_preanim_duration(QString p_char, QString p_emote) int AOApplication::get_preanim_duration(QString p_char, QString p_emote)
@ -241,7 +241,7 @@ int AOApplication::get_preanim_duration(QString p_char, QString p_emote)
QString f_result = read_char_ini(p_char, p_emote, "[Time]", "[Emotions]"); QString f_result = read_char_ini(p_char, p_emote, "[Time]", "[Emotions]");
if (f_result == "") if (f_result == "")
return 0; return -1;
else return f_result.toInt(); else return f_result.toInt();
} }
@ -250,7 +250,7 @@ int AOApplication::get_ao2_preanim_duration(QString p_char, QString p_emote)
QString f_result = read_char_ini(p_char, "%" + p_emote, "[Time]", "[Emotions]"); QString f_result = read_char_ini(p_char, "%" + p_emote, "[Time]", "[Emotions]");
if (f_result == "") if (f_result == "")
return 0; return -1;
else return f_result.toInt(); else return f_result.toInt();
} }