aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDavid Skoland <davidskoland@gmail.com>2017-02-16 22:29:10 +0100
committerDavid Skoland <davidskoland@gmail.com>2017-02-16 22:29:10 +0100
commit00e491bb2638fcfdd9bb81f7bd3a87f614fcd9e4 (patch)
treea06c9a16e632c131dbaf92ab3abfbb51cb8da236
parentd32883828889d7add3ce605cd4bbdddaa8b8d502 (diff)
highly experimental and complex preanim algorithm testing in progress
-rw-r--r--aocharmovie.cpp53
-rw-r--r--courtroom.cpp7
-rw-r--r--emotes.cpp8
-rw-r--r--text_file_functions.cpp6
4 files changed, 57 insertions, 17 deletions
diff --git a/aocharmovie.cpp b/aocharmovie.cpp
index 8be462f5..66c9ef01 100644
--- a/aocharmovie.cpp
+++ b/aocharmovie.cpp
@@ -37,11 +37,10 @@ void AOCharMovie::play(QString p_char, QString p_emote, QString emote_prefix)
gif_path = placeholder_default_path;
m_movie->stop();
- this->clear();
-
- qDebug() << "gif_path: " << gif_path;
m_movie->setFileName(gif_path);
+ qDebug() << "framecount: " << m_movie->frameCount();
+
if (m_flipped)
{
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)
{
- if (duration == 0)
- play_once = true;
+ QString gif_path = ao_app->get_character_path(p_char) + p_emote.toLower();
- else
+ m_movie->stop();
+ this->clear();
+ m_movie->setFileName(gif_path);
+
+ int real_duration = 0;
+
+ play_once = false;
+
+ 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)
{
- play_once = false;
- preanim_timer->start(duration);
+ 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, "");
}
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;
+ 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.toLower();
+
+ m_movie->stop();
+ this->clear();
+ m_movie->setFileName(gif_path);
+
play_once = false;
+ m_movie->setSpeed(100);
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)
{
preanim_timer->start(m_movie->nextFrameDelay());
- done();
+ //done();
}
}
void AOCharMovie::timer_done()
{
+ qDebug() << "timer done called";
done();
}
diff --git a/courtroom.cpp b/courtroom.cpp
index 78ddd9dd..5217e314 100644
--- a/courtroom.cpp
+++ b/courtroom.cpp
@@ -343,7 +343,6 @@ void Courtroom::set_widgets()
m_courtroom_height = f_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->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->setFixedSize(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];
//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 sfx_delay = m_chatmessage[SFX_DELAY].toInt() * time_mod;
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;
preanim_done();
diff --git a/emotes.cpp b/emotes.cpp
index 212b0a3c..4793eec4 100644
--- a/emotes.cpp
+++ b/emotes.cpp
@@ -108,13 +108,19 @@ void Courtroom::on_emote_clicked(int p_id)
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");
+ int old_emote = current_emote;
+
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");
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);
else
ui_pre->setChecked(false);
diff --git a/text_file_functions.cpp b/text_file_functions.cpp
index f51df622..706078c8 100644
--- a/text_file_functions.cpp
+++ b/text_file_functions.cpp
@@ -233,7 +233,7 @@ QString AOApplication::get_chat(QString p_char)
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
- return f_result;
+ return f_result.toLower();
}
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]");
if (f_result == "")
- return 0;
+ return -1;
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]");
if (f_result == "")
- return 0;
+ return -1;
else return f_result.toInt();
}