add a separate flag to indicate that the loading screen is being shown

This commit is contained in:
Sebastian Krzyszkowiak 2018-12-07 06:14:52 +01:00
parent 0ebb85a660
commit ad26fe14ad
No known key found for this signature in database
GPG key ID: E8F235CF3BDBC3FF
3 changed files with 4 additions and 1 deletions

View file

@ -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);
}
}

View file

@ -165,6 +165,7 @@ struct Game {
int progress;
int loaded, toLoad;
volatile bool inProgress;
bool shown;
double time;
} loading;

View file

@ -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);