Skip to content

Commit 1d80972

Browse files
authored
Merge pull request #542 from AttorneyOnline/fix/aolayer-crap
Fix AOLayer-related regressions, deprecate BS no one uses and return sane behavior
2 parents f08a293 + 8d9331a commit 1d80972

5 files changed

Lines changed: 31 additions & 48 deletions

File tree

include/aoapplication.h

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -378,10 +378,6 @@ class AOApplication : public QApplication {
378378
// Returns the preanim duration of p_char's p_emote
379379
int get_preanim_duration(QString p_char, QString p_emote);
380380

381-
// Same as above, but only returns if it has a % in front(refer to Preanims
382-
// section in the manual)
383-
int get_ao2_preanim_duration(QString p_char, QString p_emote);
384-
385381
// Not in use
386382
int get_text_delay(QString p_char, QString p_emote);
387383

include/aolayer.h

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -104,10 +104,6 @@ class AOLayer : public QLabel {
104104

105105
QElapsedTimer actual_time;
106106

107-
// Usually used to turn seconds into milliseconds such as for [Time] tag in
108-
// char.ini (which is no longer used)
109-
const int tick_ms = 60;
110-
111107
// These are the X and Y values before they are fixed based on the sprite's
112108
// width.
113109
int x = 0;

src/aolayer.cpp

Lines changed: 22 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -146,6 +146,7 @@ void BackgroundLayer::load_image(QString p_filename)
146146
qDebug() << "[BackgroundLayer] BG loaded: " << p_filename;
147147
#endif
148148
start_playback(ao_app->get_image_suffix(ao_app->get_background_path(p_filename)));
149+
play();
149150
}
150151

151152
void CharLayer::load_image(QString p_filename, QString p_charname,
@@ -189,7 +190,7 @@ void CharLayer::load_image(QString p_filename, QString p_charname,
189190
}
190191
is_preanim = true;
191192
play_once = true;
192-
preanim_timer->start(duration * tick_ms);
193+
preanim_timer->start(duration);
193194
}
194195
#ifdef DEBUG_MOVIE
195196
qDebug() << "[CharLayer] anim loaded: prefix " << prefix << " filename "
@@ -211,6 +212,7 @@ void CharLayer::load_image(QString p_filename, QString p_charname,
211212
ao_app->get_theme_path(
212213
"placeholder", ao_app->default_theme)}; // Default theme placeholder path
213214
start_playback(ao_app->get_image_path(pathlist));
215+
play();
214216
}
215217

216218
void SplashLayer::load_image(QString p_filename, QString p_charname,
@@ -219,6 +221,7 @@ void SplashLayer::load_image(QString p_filename, QString p_charname,
219221
transform_mode = ao_app->get_misc_scaling(p_miscname);
220222
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");
221223
start_playback(final_image);
224+
play();
222225
}
223226

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

235239
void InterfaceLayer::load_image(QString p_filename, QString p_miscname)
236240
{
241+
last_path = "";
237242
stretch = true;
238243
QString final_image = ao_app->get_image(p_filename, ao_app->current_theme, ao_app->get_subtheme(), ao_app->default_theme, p_miscname);
239244
start_playback(final_image);
245+
play();
240246
}
241247

242248
void StickerLayer::load_image(QString p_charname)
@@ -247,6 +253,7 @@ void StickerLayer::load_image(QString p_charname)
247253
transform_mode = ao_app->get_misc_scaling(p_miscname);
248254
QString final_image = ao_app->get_image("sticker/" + p_charname, ao_app->current_theme, ao_app->get_subtheme(), ao_app->default_theme, p_miscname);
249255
start_playback(final_image);
256+
play();
250257
}
251258

252259
void CharLayer::start_playback(QString p_image)
@@ -257,6 +264,7 @@ void CharLayer::start_playback(QString p_image)
257264
load_network_effects();
258265
else // Use default ini FX
259266
load_effects();
267+
play();
260268
}
261269

262270
void AOLayer::start_playback(QString p_image)
@@ -275,7 +283,7 @@ void AOLayer::start_playback(QString p_image)
275283
actual_time.restart();
276284
#endif
277285
this->clear();
278-
freeze();
286+
this->freeze();
279287
movie_frames.clear();
280288
movie_delays.clear();
281289
QString scaling_override =
@@ -329,14 +337,12 @@ void AOLayer::start_playback(QString p_image)
329337
}
330338
else if (max_frames <= 1) {
331339
duration = static_duration;
332-
play_once = false;
333340
#ifdef DEBUG_MOVIE
334341
qDebug() << "max_frames is <= 1, using static duration";
335342
#endif
336343
}
337344
if (duration > 0 && cull_image == true)
338345
shfx_timer->start(duration);
339-
play();
340346
#ifdef DEBUG_MOVIE
341347
qDebug() << max_frames << "Setting image to " << image_path
342348
<< "Time taken to process image:" << actual_time.elapsed();
@@ -347,15 +353,25 @@ void AOLayer::start_playback(QString p_image)
347353

348354
void CharLayer::play()
349355
{
356+
if (max_frames <= 1) {
357+
if (play_once) {
358+
preanim_timer->start(qMax(0, duration));
359+
}
360+
return;
361+
}
350362
play_frame_effect(frame);
351363
AOLayer::play();
352364
}
353365

354366
void AOLayer::play()
355367
{
356368
if (max_frames <= 1) {
357-
if (play_once)
358-
ticker->start(tick_ms);
369+
if (play_once) {
370+
if (duration > 0)
371+
ticker->start(duration);
372+
else
373+
preanim_done();
374+
}
359375
else
360376
this->freeze();
361377
}

src/courtroom.cpp

Lines changed: 9 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -3223,17 +3223,10 @@ void Courtroom::play_preanim(bool immediate)
32233223
QString f_preanim = m_chatmessage[PRE_EMOTE];
32243224
// all time values in char.inis are multiplied by a constant(time_mod) to get
32253225
// the actual time
3226-
int ao2_duration = ao_app->get_ao2_preanim_duration(f_char, f_preanim);
3226+
int preanim_duration = ao_app->get_preanim_duration(f_char, f_preanim);
32273227
int stay_time = ao_app->get_text_delay(f_char, f_preanim) * time_mod;
32283228
int sfx_delay = m_chatmessage[SFX_DELAY].toInt() * time_mod;
32293229

3230-
int preanim_duration;
3231-
3232-
if (ao2_duration < 0)
3233-
preanim_duration = ao_app->get_preanim_duration(f_char, f_preanim);
3234-
else
3235-
preanim_duration = ao2_duration;
3236-
32373230
sfx_delay_timer->start(sfx_delay);
32383231
QString anim_to_find =
32393232
ao_app->get_image_suffix(ao_app->get_character_path(f_char, f_preanim));
@@ -3246,15 +3239,6 @@ void Courtroom::play_preanim(bool immediate)
32463239
qDebug() << "W: could not find " + anim_to_find;
32473240
return;
32483241
}
3249-
else {
3250-
QImageReader s_reader(anim_to_find);
3251-
int image_count = s_reader.imageCount();
3252-
if (image_count <= 1) {
3253-
preanim_done();
3254-
qDebug() << "W: tried to play static preanim " + anim_to_find;
3255-
return;
3256-
}
3257-
}
32583242
ui_vp_player_char->set_static_duration(preanim_duration);
32593243
ui_vp_player_char->set_play_once(true);
32603244
ui_vp_player_char->load_image(f_preanim, f_char, preanim_duration, true);
@@ -3276,16 +3260,15 @@ void Courtroom::play_preanim(bool immediate)
32763260
break;
32773261
}
32783262

3279-
if (immediate)
3263+
if (immediate) {
32803264
anim_state = 4;
3281-
else
3282-
anim_state = 1;
3283-
3284-
if (stay_time >= 0)
3285-
text_delay_timer->start(stay_time);
3286-
3287-
if (immediate)
32883265
handle_ic_speaking();
3266+
}
3267+
else {
3268+
anim_state = 1;
3269+
if (stay_time >= 0)
3270+
text_delay_timer->start(stay_time);
3271+
}
32893272
}
32903273

32913274
void Courtroom::preanim_done()
@@ -3317,6 +3300,7 @@ void Courtroom::preanim_done()
33173300

33183301
void Courtroom::start_chat_ticking()
33193302
{
3303+
text_delay_timer->stop();
33203304
// we need to ensure that the text isn't already ticking because this function
33213305
// can be called by two logic paths
33223306
if (text_state != 0)

src/text_file_functions.cpp

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -672,15 +672,6 @@ int AOApplication::get_preanim_duration(QString p_char, QString p_emote)
672672
return f_result.toInt();
673673
}
674674

675-
int AOApplication::get_ao2_preanim_duration(QString p_char, QString p_emote)
676-
{
677-
QString f_result = read_char_ini(p_char, "%" + p_emote, "Time");
678-
679-
if (f_result == "")
680-
return -1;
681-
return f_result.toInt();
682-
}
683-
684675
int AOApplication::get_emote_number(QString p_char)
685676
{
686677
QString f_result = read_char_ini(p_char, "number", "Emotions");

0 commit comments

Comments
 (0)