Skip to content

Commit

Permalink
Merge branch 'fix/aolayer-crap' into 2.9.1-ea
Browse files Browse the repository at this point in the history
  • Loading branch information
Crystalwarrior committed Apr 23, 2021
2 parents 60dae51 + 8d9331a commit c1e40f0
Show file tree
Hide file tree
Showing 5 changed files with 31 additions and 48 deletions.
4 changes: 0 additions & 4 deletions include/aoapplication.h
Original file line number Diff line number Diff line change
Expand Up @@ -378,10 +378,6 @@ class AOApplication : public QApplication {
// Returns the preanim duration of p_char's p_emote
int get_preanim_duration(QString p_char, QString p_emote);

// Same as above, but only returns if it has a % in front(refer to Preanims
// section in the manual)
int get_ao2_preanim_duration(QString p_char, QString p_emote);

// Not in use
int get_text_delay(QString p_char, QString p_emote);

Expand Down
4 changes: 0 additions & 4 deletions include/aolayer.h
Original file line number Diff line number Diff line change
Expand Up @@ -104,10 +104,6 @@ class AOLayer : public QLabel {

QElapsedTimer actual_time;

// Usually used to turn seconds into milliseconds such as for [Time] tag in
// char.ini (which is no longer used)
const int tick_ms = 60;

// These are the X and Y values before they are fixed based on the sprite's
// width.
int x = 0;
Expand Down
28 changes: 22 additions & 6 deletions src/aolayer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,7 @@ void BackgroundLayer::load_image(QString p_filename)
qDebug() << "[BackgroundLayer] BG loaded: " << p_filename;
#endif
start_playback(ao_app->get_image_suffix(ao_app->get_background_path(p_filename)));
play();
}

void CharLayer::load_image(QString p_filename, QString p_charname,
Expand Down Expand Up @@ -189,7 +190,7 @@ void CharLayer::load_image(QString p_filename, QString p_charname,
}
is_preanim = true;
play_once = true;
preanim_timer->start(duration * tick_ms);
preanim_timer->start(duration);
}
#ifdef DEBUG_MOVIE
qDebug() << "[CharLayer] anim loaded: prefix " << prefix << " filename "
Expand All @@ -211,6 +212,7 @@ void CharLayer::load_image(QString p_filename, QString p_charname,
ao_app->get_theme_path(
"placeholder", ao_app->default_theme)}; // Default theme placeholder path
start_playback(ao_app->get_image_path(pathlist));
play();
}

void SplashLayer::load_image(QString p_filename, QString p_charname,
Expand All @@ -219,6 +221,7 @@ void SplashLayer::load_image(QString p_filename, QString p_charname,
transform_mode = ao_app->get_misc_scaling(p_miscname);
QString final_image = ao_app->get_image(p_filename, ao_app->current_theme, ao_app->get_subtheme(), ao_app->default_theme, p_miscname, p_charname, "placeholder");
start_playback(final_image);
play();
}

void EffectLayer::load_image(QString p_filename, bool p_looping)
Expand All @@ -230,13 +233,16 @@ void EffectLayer::load_image(QString p_filename, bool p_looping)
continuous = false;
force_continuous = true;
start_playback(p_filename); // handled in its own file before we see it
play();
}

void InterfaceLayer::load_image(QString p_filename, QString p_miscname)
{
last_path = "";
stretch = true;
QString final_image = ao_app->get_image(p_filename, ao_app->current_theme, ao_app->get_subtheme(), ao_app->default_theme, p_miscname);
start_playback(final_image);
play();
}

void StickerLayer::load_image(QString p_charname)
Expand All @@ -247,6 +253,7 @@ void StickerLayer::load_image(QString p_charname)
transform_mode = ao_app->get_misc_scaling(p_miscname);
QString final_image = ao_app->get_image("sticker/" + p_charname, ao_app->current_theme, ao_app->get_subtheme(), ao_app->default_theme, p_miscname);
start_playback(final_image);
play();
}

void CharLayer::start_playback(QString p_image)
Expand All @@ -257,6 +264,7 @@ void CharLayer::start_playback(QString p_image)
load_network_effects();
else // Use default ini FX
load_effects();
play();
}

void AOLayer::start_playback(QString p_image)
Expand All @@ -275,7 +283,7 @@ void AOLayer::start_playback(QString p_image)
actual_time.restart();
#endif
this->clear();
freeze();
this->freeze();
movie_frames.clear();
movie_delays.clear();
QString scaling_override =
Expand Down Expand Up @@ -329,14 +337,12 @@ void AOLayer::start_playback(QString p_image)
}
else if (max_frames <= 1) {
duration = static_duration;
play_once = false;
#ifdef DEBUG_MOVIE
qDebug() << "max_frames is <= 1, using static duration";
#endif
}
if (duration > 0 && cull_image == true)
shfx_timer->start(duration);
play();
#ifdef DEBUG_MOVIE
qDebug() << max_frames << "Setting image to " << image_path
<< "Time taken to process image:" << actual_time.elapsed();
Expand All @@ -347,15 +353,25 @@ void AOLayer::start_playback(QString p_image)

void CharLayer::play()
{
if (max_frames <= 1) {
if (play_once) {
preanim_timer->start(qMax(0, duration));
}
return;
}
play_frame_effect(frame);
AOLayer::play();
}

void AOLayer::play()
{
if (max_frames <= 1) {
if (play_once)
ticker->start(tick_ms);
if (play_once) {
if (duration > 0)
ticker->start(duration);
else
preanim_done();
}
else
this->freeze();
}
Expand Down
34 changes: 9 additions & 25 deletions src/courtroom.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3220,17 +3220,10 @@ void Courtroom::play_preanim(bool immediate)
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 ao2_duration = ao_app->get_ao2_preanim_duration(f_char, f_preanim);
int preanim_duration = ao_app->get_preanim_duration(f_char, f_preanim);
int stay_time = ao_app->get_text_delay(f_char, f_preanim) * time_mod;
int sfx_delay = m_chatmessage[SFX_DELAY].toInt() * time_mod;

int preanim_duration;

if (ao2_duration < 0)
preanim_duration = ao_app->get_preanim_duration(f_char, f_preanim);
else
preanim_duration = ao2_duration;

sfx_delay_timer->start(sfx_delay);
QString anim_to_find =
ao_app->get_image_suffix(ao_app->get_character_path(f_char, f_preanim));
Expand All @@ -3243,15 +3236,6 @@ void Courtroom::play_preanim(bool immediate)
qDebug() << "W: could not find " + anim_to_find;
return;
}
else {
QImageReader s_reader(anim_to_find);
int image_count = s_reader.imageCount();
if (image_count <= 1) {
preanim_done();
qDebug() << "W: tried to play static preanim " + anim_to_find;
return;
}
}
ui_vp_player_char->set_static_duration(preanim_duration);
ui_vp_player_char->set_play_once(true);
ui_vp_player_char->load_image(f_preanim, f_char, preanim_duration, true);
Expand All @@ -3273,16 +3257,15 @@ void Courtroom::play_preanim(bool immediate)
break;
}

if (immediate)
if (immediate) {
anim_state = 4;
else
anim_state = 1;

if (stay_time >= 0)
text_delay_timer->start(stay_time);

if (immediate)
handle_ic_speaking();
}
else {
anim_state = 1;
if (stay_time >= 0)
text_delay_timer->start(stay_time);
}
}

void Courtroom::preanim_done()
Expand Down Expand Up @@ -3314,6 +3297,7 @@ void Courtroom::preanim_done()

void Courtroom::start_chat_ticking()
{
text_delay_timer->stop();
// we need to ensure that the text isn't already ticking because this function
// can be called by two logic paths
if (text_state != 0)
Expand Down
9 changes: 0 additions & 9 deletions src/text_file_functions.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -672,15 +672,6 @@ int AOApplication::get_preanim_duration(QString p_char, QString p_emote)
return f_result.toInt();
}

int AOApplication::get_ao2_preanim_duration(QString p_char, QString p_emote)
{
QString f_result = read_char_ini(p_char, "%" + p_emote, "Time");

if (f_result == "")
return -1;
return f_result.toInt();
}

int AOApplication::get_emote_number(QString p_char)
{
QString f_result = read_char_ini(p_char, "number", "Emotions");
Expand Down

0 comments on commit c1e40f0

Please sign in to comment.