From 8c24ebd9820d10e5a9bfb1f944ef2fb84c31c0f3 Mon Sep 17 00:00:00 2001 From: Sebastian Krzyszkowiak Date: Fri, 28 Sep 2012 03:11:45 +0200 Subject: [PATCH] implement progress bar on fulscreen toggling --- src/gamestates/level.c | 1 - src/gamestates/pause.c | 15 ++++++++++++--- 2 files changed, 12 insertions(+), 4 deletions(-) diff --git a/src/gamestates/level.c b/src/gamestates/level.c index bd793f1..f594e43 100644 --- a/src/gamestates/level.c +++ b/src/gamestates/level.c @@ -331,7 +331,6 @@ void Level_PreloadBitmaps(struct Game *game, void (*progress)(struct Game*, floa game->level.derpy = al_create_bitmap(al_get_bitmap_width(*(game->level.derpy_sheet))/game->level.sheet_cols, al_get_bitmap_height(*(game->level.derpy_sheet))/game->level.sheet_rows); //TODO: load proper bitmap files for each level - //TODO: maybe handle strange display aspects game->level.clouds = LoadScaledBitmap("levels/1/clouds.png", game->viewportHeight*4.73307291666666666667, game->viewportHeight); PROGRESS; game->level.foreground = LoadScaledBitmap("levels/1/foreground.png", game->viewportHeight*4.73307291666666666667, game->viewportHeight); diff --git a/src/gamestates/pause.c b/src/gamestates/pause.c index 1d8d76f..5a1dea3 100644 --- a/src/gamestates/pause.c +++ b/src/gamestates/pause.c @@ -44,14 +44,23 @@ int Pause_Keydown(struct Game *game, ALLEGRO_EVENT *ev) { al_flip_display(); SetupViewport(game); Shared_Load(game); - al_draw_text_with_shadow(game->font, al_map_rgb(255,255,255), game->viewportWidth*0.0234, game->viewportHeight*0.85, ALLEGRO_ALIGN_LEFT, "Loading..."); - al_flip_display(); + + void Progress(struct Game *game, float p) { + al_set_target_bitmap(al_get_backbuffer(game->display)); + al_clear_to_color(al_map_rgb(0,0,0)); + al_draw_text_with_shadow(game->font, al_map_rgb(255,255,255), game->viewportWidth*0.0234, game->viewportHeight*0.84, ALLEGRO_ALIGN_LEFT, "Loading..."); + al_draw_filled_rectangle(0, game->viewportHeight*0.985, game->viewportWidth, game->viewportHeight, al_map_rgba(128,128,128,128)); + al_draw_filled_rectangle(0, game->viewportHeight*0.985, p*game->viewportWidth, game->viewportHeight, al_map_rgba(255,255,255,255)); + al_flip_display(); + } + Progress(game, 0); + Loading_Unload(game); Loading_Load(game); Menu_Unload(game); Menu_Preload(game, NULL); Level_UnloadBitmaps(game); - Level_PreloadBitmaps(game, NULL); + Level_PreloadBitmaps(game, &Progress); Pause_Unload_Real(game); Pause_Preload(game); Pause_Load(game);