From ad26fe14ad0b4d40742318b5601e1a68fc4f066b Mon Sep 17 00:00:00 2001 From: Sebastian Krzyszkowiak Date: Fri, 7 Dec 2018 06:14:52 +0100 Subject: [PATCH] add a separate flag to indicate that the loading screen is being shown --- src/internal.c | 2 +- src/libsuperderpy.h | 1 + src/mainloop.c | 2 ++ 3 files changed, 4 insertions(+), 1 deletion(-) diff --git a/src/internal.c b/src/internal.c index c5adf3c..9a7a0b9 100644 --- a/src/internal.c +++ b/src/internal.c @@ -30,7 +30,7 @@ SYMBOL_INTERNAL void SimpleCompositor(struct Game* game, struct Gamestate* games } tmp = tmp->next; } - if (game->_priv.loading.inProgress) { + if (game->_priv.loading.shown) { al_draw_bitmap(game->loading_fb, game->_priv.clip_rect.x, game->_priv.clip_rect.y, 0); } } diff --git a/src/libsuperderpy.h b/src/libsuperderpy.h index 9184d08..3bb9273 100644 --- a/src/libsuperderpy.h +++ b/src/libsuperderpy.h @@ -165,6 +165,7 @@ struct Game { int progress; int loaded, toLoad; volatile bool inProgress; + bool shown; double time; } loading; diff --git a/src/mainloop.c b/src/mainloop.c index 3d5e626..51d3fb2 100644 --- a/src/mainloop.c +++ b/src/mainloop.c @@ -256,6 +256,7 @@ static inline bool MainloopTick(struct Game* game) { while (game->_priv.loading.inProgress) { double delta = al_get_time() - game->_priv.loading.time; if (tmp->showLoading) { + game->_priv.loading.shown = true; (*game->_priv.loading.gamestate->api->Gamestate_Logic)(game, game->_priv.loading.gamestate->data, delta); DrawGamestates(game); } @@ -306,6 +307,7 @@ static inline bool MainloopTick(struct Game* game) { } if (tmp->showLoading) { (*game->_priv.loading.gamestate->api->Gamestate_Stop)(game, game->_priv.loading.gamestate->data); + game->_priv.loading.shown = false; } tmp->showLoading = true; al_resume_timer(game->_priv.timer);