Skip to content

Commit 433b7f3

Browse files
Deprecate tick_ms and use actual milliseconds rather than arbitrary 60ms ticks for char.ini [Time]
Fix an extremely weird case where CharLayer::Play() was not called even on the CharLayer class (I don't understand why inheritance was straight up just ignored) Fix using preanims with static images just breaking everything Deprecate weird insanity [Time] with the % sign BS (What was this for again? Literally no one used this nor was aware of it) Fix text_stay_time timer firing even if we're immediate Just in case, stop the text delay timer when start_chat_ticking is called
1 parent 0a1a47c commit 433b7f3

5 files changed

Lines changed: 30 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: 21 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,15 @@ 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
{
237241
stretch = true;
238242
QString final_image = ao_app->get_image(p_filename, ao_app->current_theme, ao_app->get_subtheme(), ao_app->default_theme, p_miscname);
239243
start_playback(final_image);
244+
play();
240245
}
241246

242247
void StickerLayer::load_image(QString p_charname)
@@ -247,6 +252,7 @@ void StickerLayer::load_image(QString p_charname)
247252
transform_mode = ao_app->get_misc_scaling(p_miscname);
248253
QString final_image = ao_app->get_image("sticker/" + p_charname, ao_app->current_theme, ao_app->get_subtheme(), ao_app->default_theme, p_miscname);
249254
start_playback(final_image);
255+
play();
250256
}
251257

252258
void CharLayer::start_playback(QString p_image)
@@ -257,6 +263,7 @@ void CharLayer::start_playback(QString p_image)
257263
load_network_effects();
258264
else // Use default ini FX
259265
load_effects();
266+
play();
260267
}
261268

262269
void AOLayer::start_playback(QString p_image)
@@ -275,7 +282,7 @@ void AOLayer::start_playback(QString p_image)
275282
actual_time.restart();
276283
#endif
277284
this->clear();
278-
freeze();
285+
this->freeze();
279286
movie_frames.clear();
280287
movie_delays.clear();
281288
QString scaling_override =
@@ -329,14 +336,12 @@ void AOLayer::start_playback(QString p_image)
329336
}
330337
else if (max_frames <= 1) {
331338
duration = static_duration;
332-
play_once = false;
333339
#ifdef DEBUG_MOVIE
334340
qDebug() << "max_frames is <= 1, using static duration";
335341
#endif
336342
}
337343
if (duration > 0 && cull_image == true)
338344
shfx_timer->start(duration);
339-
play();
340345
#ifdef DEBUG_MOVIE
341346
qDebug() << max_frames << "Setting image to " << image_path
342347
<< "Time taken to process image:" << actual_time.elapsed();
@@ -347,15 +352,25 @@ void AOLayer::start_playback(QString p_image)
347352

348353
void CharLayer::play()
349354
{
355+
if (max_frames <= 1) {
356+
if (play_once) {
357+
preanim_timer->start(qMax(0, duration));
358+
}
359+
return;
360+
}
350361
play_frame_effect(frame);
351362
AOLayer::play();
352363
}
353364

354365
void AOLayer::play()
355366
{
356367
if (max_frames <= 1) {
357-
if (play_once)
358-
ticker->start(tick_ms);
368+
if (play_once) {
369+
if (duration > 0)
370+
ticker->start(duration);
371+
else
372+
preanim_done();
373+
}
359374
else
360375
this->freeze();
361376
}

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
@@ -669,15 +669,6 @@ int AOApplication::get_preanim_duration(QString p_char, QString p_emote)
669669
return f_result.toInt();
670670
}
671671

672-
int AOApplication::get_ao2_preanim_duration(QString p_char, QString p_emote)
673-
{
674-
QString f_result = read_char_ini(p_char, "%" + p_emote, "Time");
675-
676-
if (f_result == "")
677-
return -1;
678-
return f_result.toInt();
679-
}
680-
681672
int AOApplication::get_emote_number(QString p_char)
682673
{
683674
QString f_result = read_char_ini(p_char, "number", "Emotions");

0 commit comments

Comments
 (0)