Outro: fixed text being shown for approx 2.5 seconds longer than specified

I was performing a value check on fade_step in the timer, and then multiplying it fivefold in the alpha
calculation, meaning full alpha was reached long before the fade in sequence stopped and the duration timer
was initialized.
This commit is contained in:
Charles Dang 2017-04-11 03:19:17 +11:00
parent 142ced01e1
commit 15daebd149
2 changed files with 11 additions and 5 deletions

View file

@ -31,7 +31,7 @@
maximum_width = "(width)"
font_size = {GUI_FONT_SIZE_HUGE}
color = "([215, 215, 215, min(fade_step * 5, 255)])"
color = "([215, 215, 215, min(ceil(as_decimal(fade_step * 25.5)), 255)])"
text = "(outro_text)"
text_markup = true

View file

@ -57,8 +57,14 @@ void outro::pre_show(window& window)
void outro::timer_callback(window& window)
{
// If we've faded fully in...
if(fading_in_ && fade_step_ == 255) {
/* If we've faded fully in...
*
* NOTE: we want the fade in to happen in around half a second. Given this timer runs every
* 50 ms, we limit ourselves to a reasonable 10 fade steps (500 ms / 50) with an alpha increase
* (rounded up) of 25.5 each cycle. The actual calculation for alpha is done in the window
* definition in WFL.
*/
if(fading_in_ && fade_step_ > 10) {
// Schedule the fadeout after the provided delay.
if(timer_id_secondary_ == 0) {
timer_id_secondary_ = add_timer(duration_, [this](size_t) { fading_in_ = false; });
@ -81,9 +87,9 @@ void outro::timer_callback(window& window)
window.set_is_dirty(true);
if(fading_in_) {
fade_step_ += 5;
fade_step_ ++;
} else {
fade_step_ -= 5;
fade_step_ --;
}
}