Skip to content

Commit

Permalink
Outro: fixed text being shown for approx 2.5 seconds longer than spec…
Browse files Browse the repository at this point in the history
…ified

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.
  • Loading branch information
Vultraz committed Apr 10, 2017
1 parent 142ced0 commit 15daebd
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 5 deletions.
2 changes: 1 addition & 1 deletion data/gui/window/outro.cfg
Expand Up @@ -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
Expand Down
14 changes: 10 additions & 4 deletions src/gui/dialogs/outro.cpp
Expand Up @@ -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; });
Expand All @@ -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_ --;
}
}

Expand Down

0 comments on commit 15daebd

Please sign in to comment.