From 0a17a95383fc2dc61cc0aae03f5d36099c0e3569 Mon Sep 17 00:00:00 2001 From: Sebastian Krzyszkowiak Date: Fri, 18 May 2012 18:34:07 +0200 Subject: [PATCH] implement progress bar on loading screen --- SuperDerpy.creator.user | 2 +- src/about.c | 15 ++++++++++++--- src/about.h | 2 +- src/intro.c | 22 +++++++++++++++++++--- src/intro.h | 2 +- src/level.c | 28 ++++++++++++++++++++++++---- src/level.h | 4 ++-- src/loading.c | 18 +++++++++++++++--- src/loading.h | 2 +- src/main.c | 6 +++--- src/main.h | 5 ++++- src/map.c | 11 ++++++++++- src/map.h | 2 +- src/menu.c | 19 +++++++++++++++++-- src/menu.h | 2 +- src/pause.c | 8 ++++---- 16 files changed, 116 insertions(+), 32 deletions(-) diff --git a/SuperDerpy.creator.user b/SuperDerpy.creator.user index 1e65e03..c314f9f 100644 --- a/SuperDerpy.creator.user +++ b/SuperDerpy.creator.user @@ -1,6 +1,6 @@ - + GenericProjectManager.GenericProject.Toolchain diff --git a/src/about.c b/src/about.c index 3a314e3..964fbde 100644 --- a/src/about.c +++ b/src/about.c @@ -63,18 +63,24 @@ int About_Keydown(struct Game *game, ALLEGRO_EVENT *ev) { return 0; } -void About_Preload(struct Game *game) { +void About_Preload(struct Game *game, void (*progress)(struct Game*, float)) { + PROGRESS_INIT(7); + game->about.image =LoadScaledBitmap("table.png", al_get_display_width(game->display), al_get_display_height(game->display)); + PROGRESS; game->about.letter = LoadScaledBitmap("about/letter.png", al_get_display_width(game->display), al_get_display_height(game->display) ); + PROGRESS; game->about.sample = al_load_sample( "data/about/about.flac" ); - + PROGRESS; + game->about.music = al_create_sample_instance(game->about.sample); al_attach_sample_instance_to_mixer(game->about.music, game->audio.music); al_set_sample_instance_playmode(game->about.music, ALLEGRO_PLAYMODE_LOOP); al_set_sample_instance_position(game->about.music, game->music ? 420000 : 700000); game->about.font = al_load_ttf_font("data/ShadowsIntoLight.ttf",al_get_display_height(game->display)*0.035,0 ); + PROGRESS; game->about.x = -0.1; if (!game->about.sample){ fprintf(stderr, "Audio clip sample not loaded!\n" ); @@ -91,7 +97,8 @@ void About_Preload(struct Game *game) { al_draw_text(game->about.font, al_map_rgb(255,255,255), 0, y*al_get_bitmap_height(game->about.text_bitmap), ALLEGRO_ALIGN_LEFT, text); y+=0.0128; } - + PROGRESS; + draw_text("Written by:"); draw_text(" - Sebastian Krzyszkowiak"); draw_text(" http://dosowisko.net/"); @@ -163,6 +170,7 @@ void About_Preload(struct Game *game) { draw_text("Author of Super Derpy is not"); draw_text("affiliated to Hasbro, The Hub"); draw_text("or its associates."); + PROGRESS; game->about.fade_bitmap = al_create_bitmap(al_get_display_width(game->display), al_get_display_height(game->display)); @@ -172,6 +180,7 @@ void About_Preload(struct Game *game) { al_draw_bitmap_region(game->about.text_bitmap, 0, 0, al_get_bitmap_width(game->about.text_bitmap), al_get_display_height(game->display)*0.8, al_get_display_width(game->display)*0.5, al_get_display_height(game->display)*0.1, 0); al_set_target_bitmap(al_get_backbuffer(game->display)); + PROGRESS; } void About_Unload(struct Game *game) { diff --git a/src/about.h b/src/about.h index cf455c2..2d93b32 100644 --- a/src/about.h +++ b/src/about.h @@ -21,7 +21,7 @@ #include "main.h" void About_Draw(struct Game *game); -void About_Preload(struct Game *game); +void About_Preload(struct Game *game, void (*progress)(struct Game*, float)); void About_Unload(struct Game *game); void About_Load(struct Game *game); int About_Keydown(struct Game *game, ALLEGRO_EVENT *ev); diff --git a/src/intro.c b/src/intro.c index c923929..90593ad 100644 --- a/src/intro.c +++ b/src/intro.c @@ -201,7 +201,9 @@ int Intro_Keydown(struct Game *game, ALLEGRO_EVENT *ev) { return 0; } -void Intro_Preload(struct Game *game) { +void Intro_Preload(struct Game *game, void (*progress)(struct Game*, float)) { + PROGRESS_INIT(16); + game->intro.audiostream = NULL; game->intro.position = 0; game->intro.page = 0; @@ -209,15 +211,23 @@ void Intro_Preload(struct Game *game) { game->intro.anim = 0; game->intro.animsprites[0] = LoadScaledBitmap("intro/1.png", al_get_display_width(game->display)*0.3125*3, al_get_display_height(game->display)*0.63*3); + PROGRESS; game->intro.animsprites[1] = LoadScaledBitmap("levels/derpy/walk.png", al_get_display_width(game->display)*0.3125*3, al_get_display_height(game->display)*0.63*3); + PROGRESS; game->intro.animsprites[2] = LoadScaledBitmap("intro/3.png", al_get_display_width(game->display)*0.3125*3, al_get_display_height(game->display)*0.63*3); + PROGRESS; game->intro.animsprites[3] = LoadScaledBitmap("loading.png", al_get_display_width(game->display)*0.3125*3, al_get_display_height(game->display)*0.63*3); + PROGRESS; game->intro.animsprites[4] = LoadScaledBitmap("about/letter.png", al_get_display_width(game->display)*0.3125*3, al_get_display_height(game->display)*0.63*3); + PROGRESS; game->intro.table_bitmap =LoadScaledBitmap("intro/paper.png", al_get_display_width(game->display), al_get_display_height(game->display)); + PROGRESS; game->intro.frame =LoadScaledBitmap("intro/frame.png", al_get_display_width(game->display), al_get_display_height(game->display)); - + PROGRESS; + game->intro.sample = al_load_sample( "data/intro/intro.flac" ); + PROGRESS; game->intro.music = al_create_sample_instance(game->intro.sample); al_attach_sample_instance_to_mixer(game->intro.music, game->audio.music); @@ -233,9 +243,15 @@ void Intro_Preload(struct Game *game) { game->intro.font = al_load_ttf_font("data/ShadowsIntoLight.ttf",al_get_display_height(game->display)*0.04,0 ); FillPage(game, 1); + PROGRESS; al_set_target_bitmap(al_get_backbuffer(game->display)); PrintConsole(game, "Chainpreloading GAMESTATE_MAP..."); - Map_Preload(game); + PROGRESS; + void MapProgress(struct Game* game, float p) { + /* if (progress) (*progress)(game, load_p+=1/load_a); */ + if (progress) (*progress)(game, 0.625+0.375*p); + } + Map_Preload(game, &MapProgress); } void Intro_Unload(struct Game *game) { diff --git a/src/intro.h b/src/intro.h index 1862414..6f1a1e0 100644 --- a/src/intro.h +++ b/src/intro.h @@ -21,7 +21,7 @@ #include "main.h" void Intro_Draw(struct Game *game); -void Intro_Preload(struct Game *game); +void Intro_Preload(struct Game *game, void (*progress)(struct Game*, float)); void Intro_Unload(struct Game *game); void Intro_Load(struct Game *game); int Intro_Keydown(struct Game *game, ALLEGRO_EVENT *ev); diff --git a/src/level.c b/src/level.c index fa8c754..36e4e04 100644 --- a/src/level.c +++ b/src/level.c @@ -522,7 +522,7 @@ void Level_ProcessLogic(struct Game *game, ALLEGRO_EVENT *ev) { } -void Level_Preload(struct Game *game) { +void Level_Preload(struct Game *game, void (*progress)(struct Game*, float)) { game->level.derpy_sheets = NULL; game->level.derpy = NULL; Pause_Preload(game); @@ -542,7 +542,7 @@ void Level_Preload(struct Game *game) { exit(-1); } } - Level_PreloadBitmaps(game); + Level_PreloadBitmaps(game, progress); } void Level_Unload(struct Game *game) { @@ -591,15 +591,26 @@ void Level_UnloadBitmaps(struct Game *game) { } } -void Level_PreloadBitmaps(struct Game *game) { +void Level_PreloadBitmaps(struct Game *game, void (*progress)(struct Game*, float)) { + PROGRESS_INIT(10); + int x = 0; struct Spritesheet *tmp = game->level.derpy_sheets; + while (tmp) { + x++; + tmp = tmp->next; + } + if (game->level.current_level==1) load_a+=x; + else load_a=2+x; + + tmp = game->level.derpy_sheets; while (tmp) { char filename[255] = { }; sprintf(filename, "levels/derpy/%s.png", tmp->name); tmp->bitmap = LoadScaledBitmap(filename, al_get_display_height(game->display)*0.25*tmp->aspect*tmp->cols*tmp->scale, al_get_display_height(game->display)*0.25*tmp->rows*tmp->scale); + PROGRESS; tmp = tmp->next; } - + PROGRESS; if (!game->level.derpy) SelectDerpySpritesheet(game, "stand"); 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); @@ -608,19 +619,28 @@ void Level_PreloadBitmaps(struct Game *game) { else { /* TODO: handle strange display aspects */ game->level.clouds = LoadScaledBitmap("levels/1/clouds.png", al_get_display_height(game->display)*4.73307291666666666667, al_get_display_height(game->display)); + PROGRESS; game->level.foreground = LoadScaledBitmap("levels/1/foreground.png", al_get_display_height(game->display)*4.73307291666666666667, al_get_display_height(game->display)); + PROGRESS; game->level.background = LoadScaledBitmap("levels/1/background.png", al_get_display_height(game->display)*4.73307291666666666667, al_get_display_height(game->display)); + PROGRESS; game->level.stage = LoadScaledBitmap("levels/1/stage.png", al_get_display_height(game->display)*4.73307291666666666667, al_get_display_height(game->display)); + PROGRESS; game->level.obst_bmps.pie = LoadScaledBitmap("menu/pie.png", al_get_display_width(game->display)*0.1, al_get_display_height(game->display)*0.1); + PROGRESS; game->level.welcome = al_create_bitmap(al_get_display_width(game->display), al_get_display_height(game->display)/2); + PROGRESS; al_set_target_bitmap(game->level.welcome); al_clear_to_color(al_map_rgba(0,0,0,0)); al_draw_text_with_shadow(game->menu.font_title, al_map_rgb(255,255,255), al_get_display_width(game->display)*0.5, al_get_display_height(game->display)*0.1, ALLEGRO_ALIGN_CENTRE, "Level 1"); al_draw_text_with_shadow(game->menu.font_subtitle, al_map_rgb(255,255,255), al_get_display_width(game->display)*0.5, al_get_display_height(game->display)*0.275, ALLEGRO_ALIGN_CENTRE, "Fluttershy"); + PROGRESS; game->level.meter_image = LoadScaledBitmap("levels/meter.png", al_get_display_width(game->display)*0.075, al_get_display_width(game->display)*0.075*0.96470588235294117647); + PROGRESS; game->level.meter_bmp = al_create_bitmap(al_get_display_width(game->display)*0.2+al_get_bitmap_width(game->level.meter_image), al_get_bitmap_height(game->level.meter_image)); al_set_target_bitmap(al_get_backbuffer(game->display)); } + PROGRESS; } diff --git a/src/level.h b/src/level.h index f379c01..87f7826 100644 --- a/src/level.h +++ b/src/level.h @@ -23,10 +23,10 @@ void SelectDerpySpritesheet(struct Game *game, char* name); void Level_Passed(struct Game *game); void Level_Draw(struct Game *game); -void Level_Preload(struct Game *game); +void Level_Preload(struct Game *game, void (*progress)(struct Game*, float)); void Level_Unload(struct Game *game); void Level_Load(struct Game *game); void Level_ProcessLogic(struct Game *game, ALLEGRO_EVENT *ev); int Level_Keydown(struct Game *game, ALLEGRO_EVENT *ev); void Level_UnloadBitmaps(struct Game *game); -void Level_PreloadBitmaps(struct Game *game); \ No newline at end of file +void Level_PreloadBitmaps(struct Game *game, void (*progress)(struct Game*, float)); diff --git a/src/loading.c b/src/loading.c index 90659f4..cb5585c 100644 --- a/src/loading.c +++ b/src/loading.c @@ -18,8 +18,18 @@ * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA. */ +#include #include "loading.h" +void Progress(struct Game *game, float p) { + if (game->debug) { printf("%f\n", p); fflush(stdout); } + al_set_target_bitmap(al_get_backbuffer(game->display)); + al_draw_bitmap(game->loading.loading_bitmap,0,0,0); + al_draw_filled_rectangle(0, al_get_display_height(game->display)*0.985, p*al_get_display_width(game->display), al_get_display_height(game->display), al_map_rgba(255,255,255,255)); + DrawConsole(game); + al_flip_display(); +} + void Loading_Draw(struct Game *game) { ALLEGRO_EVENT ev; float fadeloop; @@ -34,7 +44,7 @@ void Loading_Draw(struct Game *game) { al_stop_timer(game->timer); - PreloadGameState(game); + PreloadGameState(game, &Progress); al_wait_for_vsync(); al_start_timer(game->timer); @@ -42,6 +52,7 @@ void Loading_Draw(struct Game *game) { for(fadeloop=255; fadeloop>0; fadeloop-=tps(game, 600)){ al_wait_for_event(game->event_queue, &ev); al_draw_tinted_bitmap(game->loading.loading_bitmap,al_map_rgba_f(fadeloop/255.0,fadeloop/255.0,fadeloop/255.0,1),0,0,0); + al_draw_filled_rectangle(0, al_get_display_height(game->display)*0.985, al_get_display_width(game->display), al_get_display_height(game->display), al_map_rgba(fadeloop,fadeloop,fadeloop,255)); DrawConsole(game); al_flip_display(); } @@ -60,11 +71,12 @@ void Loading_Load(struct Game *game) { al_set_target_bitmap(game->loading.loading_bitmap); al_draw_bitmap(game->loading.image, 0, 0, 0); - al_draw_text_with_shadow(game->font, al_map_rgb(255,255,255), al_get_display_width(game->display)*0.0234, al_get_display_height(game->display)*0.85, ALLEGRO_ALIGN_LEFT, "Loading..."); + al_draw_text_with_shadow(game->font, al_map_rgb(255,255,255), al_get_display_width(game->display)*0.0234, al_get_display_height(game->display)*0.84, ALLEGRO_ALIGN_LEFT, "Loading..."); + al_draw_filled_rectangle(0, al_get_display_height(game->display)*0.985, al_get_display_width(game->display), al_get_display_height(game->display), al_map_rgba(128,128,128,128)); al_set_target_bitmap(al_get_backbuffer(game->display)); al_destroy_bitmap(game->loading.image); } int Loading_Keydown(struct Game *game, ALLEGRO_EVENT *ev) { return 0; } -void Loading_Preload(struct Game *game) {} +void Loading_Preload(struct Game *game, void (*progress)(struct Game*, float)) {} void Loading_Unload(struct Game *game) { al_destroy_bitmap(game->loading.loading_bitmap); } diff --git a/src/loading.h b/src/loading.h index 5113fda..657e5e7 100644 --- a/src/loading.h +++ b/src/loading.h @@ -21,7 +21,7 @@ #include "main.h" void Loading_Draw(struct Game *game); -void Loading_Preload(struct Game *game); +void Loading_Preload(struct Game *game, void (*progress)(struct Game*, float)); void Loading_Unload(struct Game *game); void Loading_Load(struct Game *game); int Loading_Keydown(struct Game *game, ALLEGRO_EVENT *ev); diff --git a/src/main.c b/src/main.c index 05d5bcb..6729d90 100644 --- a/src/main.c +++ b/src/main.c @@ -37,7 +37,7 @@ * Preloading of state happens when loading screen is displayed. */ #define PRELOAD_STATE(state, name) case state:\ - PrintConsole(game, "Preload %s...", #state); DrawConsole(game); al_flip_display(); name ## _Preload(game); break; + PrintConsole(game, "Preload %s...", #state); DrawConsole(game); al_flip_display(); name ## _Preload(game, progress); break; /*! \brief Macro for unloading gamestate. * * Unloading of state happens after it's fadeout. @@ -94,7 +94,7 @@ void DrawConsole(struct Game *game) { frames_done++; } -void PreloadGameState(struct Game *game) { +void PreloadGameState(struct Game *game, void (*progress)(struct Game*, float)) { if ((game->loadstate==GAMESTATE_MENU) && (game->menu.loaded)) { PrintConsole(game, "GAMESTATE_MENU already loaded, skipping..."); return; @@ -416,7 +416,7 @@ int main(int argc, char **argv){ game.menu.loaded = false; game.restart = false; game.loadstate = GAMESTATE_LOADING; - PreloadGameState(&game); + PreloadGameState(&game, NULL); LoadGameState(&game); game.loadstate = GAMESTATE_MENU; diff --git a/src/main.h b/src/main.h index 14111b3..d41c7aa 100644 --- a/src/main.h +++ b/src/main.h @@ -31,6 +31,9 @@ #include #include "allegro_utils.h" +#define PROGRESS_INIT(a) float load_p = 0, load_a = a; +#define PROGRESS if (progress) (*progress)(game, load_p+=1/load_a); + struct Game; /*! \brief Enum of all available gamestates. */ @@ -249,7 +252,7 @@ struct Game { void al_draw_text_with_shadow(ALLEGRO_FONT *font, ALLEGRO_COLOR color, float x, float y, int flags, char const *text); /*! \brief Preloads gamestate set in game->loadstate. */ -void PreloadGameState(struct Game *game); +void PreloadGameState(struct Game *game, void (*progress)(struct Game*, float)); /*! \brief Unloads gamestate set in game->gamestate. */ void UnloadGameState(struct Game *game); diff --git a/src/map.c b/src/map.c index 51ab31b..b48cce9 100644 --- a/src/map.c +++ b/src/map.c @@ -97,7 +97,9 @@ int Map_Keydown(struct Game *game, ALLEGRO_EVENT *ev) { return 0; } -void Map_Preload(struct Game *game) { +void Map_Preload(struct Game *game, void (*progress)(struct Game*, float)) { + PROGRESS_INIT(7); + game->map.available = atoi(GetConfigOptionDefault("MuffinAttack", "level", "1")); if ((game->map.available<1) || (game->map.available>6)) game->map.available=1; game->map.selected = game->map.available; @@ -105,14 +107,19 @@ void Map_Preload(struct Game *game) { game->map.arrowpos = 0; game->map.map_bg = LoadScaledBitmap("map/background.png", al_get_display_width(game->display), al_get_display_height(game->display)); + PROGRESS; char filename[30] = { }; sprintf(filename, "map/highlight%d.png", game->map.available); game->map.highlight = LoadScaledBitmap(filename, al_get_display_width(game->display), al_get_display_height(game->display)); + PROGRESS; game->map.arrow = al_load_bitmap( "data/map/arrow.png" ); + PROGRESS; game->map.click_sample = al_load_sample( "data/menu/click.flac" ); + PROGRESS; game->map.sample = al_load_sample( "data/map/map.flac" ); + PROGRESS; game->map.music = al_create_sample_instance(game->map.sample); al_attach_sample_instance_to_mixer(game->map.music, game->audio.music); @@ -132,10 +139,12 @@ void Map_Preload(struct Game *game) { } game->map.map = LoadScaledBitmap("table.png", al_get_display_width(game->display), al_get_display_height(game->display)); + PROGRESS; al_set_target_bitmap(game->map.map); al_draw_bitmap(game->map.map_bg, 0, 0 ,0); al_draw_bitmap(game->map.highlight, 0, 0 ,0); al_set_target_bitmap(al_get_backbuffer(game->display)); + PROGRESS; } void Map_Unload(struct Game *game) { diff --git a/src/map.h b/src/map.h index be4c26b..793136f 100644 --- a/src/map.h +++ b/src/map.h @@ -21,7 +21,7 @@ #include "main.h" void Map_Draw(struct Game *game); -void Map_Preload(struct Game *game); +void Map_Preload(struct Game *game, void (*progress)(struct Game*, float)); void Map_Unload(struct Game *game); void Map_Load(struct Game *game); int Map_Keydown(struct Game *game, ALLEGRO_EVENT *ev); diff --git a/src/menu.c b/src/menu.c index d486b73..7b6e45d 100644 --- a/src/menu.c +++ b/src/menu.c @@ -142,25 +142,37 @@ void Menu_Draw(struct Game *game) { if (game->menu.cloud2_position<0) { game->menu.cloud2_position=100; PrintConsole(game, "cloud2_position"); } } -void Menu_Preload(struct Game *game) { +void Menu_Preload(struct Game *game, void (*progress)(struct Game*, float)) { + PROGRESS_INIT(13); + game->menu.options.fullscreen = game->fullscreen; game->menu.options.fps = game->fps; game->menu.options.width = game->width; game->menu.options.height = game->height; game->menu.loaded = true; game->menu.image = LoadScaledBitmap( "menu/menu.png", al_get_display_width(game->display), al_get_display_height(game->display)*0.45); + PROGRESS; game->menu.mountain = LoadScaledBitmap( "menu/mountain.png", al_get_display_width(game->display)*0.055, al_get_display_height(game->display)/9 ); + PROGRESS; game->menu.cloud = LoadScaledBitmap( "menu/cloud.png", al_get_display_width(game->display)*0.5, al_get_display_height(game->display)*0.25 ); + PROGRESS; game->menu.cloud2 = LoadScaledBitmap( "menu/cloud2.png", al_get_display_width(game->display)*0.2, al_get_display_height(game->display)*0.1 ); + PROGRESS; game->menu.pinkcloud = LoadScaledBitmap( "menu/pinkcloud.png", al_get_display_width(game->display)*0.33125, al_get_display_height(game->display)*0.8122); + PROGRESS; al_set_new_bitmap_flags(ALLEGRO_MEMORY_BITMAP); game->menu.rain = al_load_bitmap( "data/menu/rain.png" ); + PROGRESS; game->menu.pie = al_load_bitmap( "data/menu/pie.png" ); al_set_new_bitmap_flags(ALLEGRO_MAG_LINEAR | ALLEGRO_MIN_LINEAR); + PROGRESS; game->menu.sample = al_load_sample( "data/menu/menu.flac" ); + PROGRESS; game->menu.rain_sample = al_load_sample( "data/menu/rain.flac" ); + PROGRESS; game->menu.click_sample = al_load_sample( "data/menu/click.flac" ); + PROGRESS; game->menu.mountain_position = al_get_display_width(game->display)*0.7; game->menu.music = al_create_sample_instance(game->menu.sample); @@ -179,7 +191,8 @@ void Menu_Preload(struct Game *game) { game->menu.font_subtitle = al_load_ttf_font("data/ShadowsIntoLight.ttf",al_get_display_height(game->display)*0.08,0 ); game->menu.font = al_load_ttf_font("data/ShadowsIntoLight.ttf",al_get_display_height(game->display)*0.05,0 ); game->menu.font_selected = al_load_ttf_font("data/ShadowsIntoLight.ttf",al_get_display_height(game->display)*0.065,0 ); - + PROGRESS; + if (!game->menu.sample){ fprintf(stderr, "Audio clip sample not loaded!\n" ); exit(-1); @@ -204,6 +217,7 @@ void Menu_Preload(struct Game *game) { al_draw_scaled_bitmap(game->menu.pie, 0, 0, al_get_bitmap_width(game->menu.pie), al_get_bitmap_height(game->menu.pie), al_get_bitmap_width(game->menu.pie_bitmap)*0.1, al_get_bitmap_height(game->menu.pie_bitmap)*0.3, al_get_display_width(game->display)*0.09, al_get_display_height(game->display)*0.06, ALLEGRO_FLIP_HORIZONTAL); al_draw_scaled_bitmap(game->menu.pie, 0, 0, al_get_bitmap_width(game->menu.pie), al_get_bitmap_height(game->menu.pie), al_get_bitmap_width(game->menu.pie_bitmap)*0.3, al_get_bitmap_height(game->menu.pie_bitmap)*0.6, al_get_display_width(game->display)*0.13, al_get_display_height(game->display)*0.1, 0); al_destroy_bitmap(game->menu.pie); + PROGRESS; al_set_new_bitmap_flags(ALLEGRO_VIDEO_BITMAP); game->menu.rain_bitmap = al_create_bitmap(al_get_bitmap_width(game->menu.pinkcloud_bitmap)*0.5, al_get_bitmap_height(game->menu.pinkcloud_bitmap)*0.1); @@ -212,6 +226,7 @@ void Menu_Preload(struct Game *game) { al_clear_to_color(al_map_rgba(0,0,0,0)); al_draw_scaled_bitmap(game->menu.rain,0, 0, al_get_bitmap_width(game->menu.rain), al_get_bitmap_height(game->menu.rain), 0, 0, al_get_bitmap_width(game->menu.rain_bitmap), al_get_bitmap_height(game->menu.rain_bitmap),0); al_destroy_bitmap(game->menu.rain); + PROGRESS; } void Menu_Stop(struct Game* game) { diff --git a/src/menu.h b/src/menu.h index dff2530..25feedb 100644 --- a/src/menu.h +++ b/src/menu.h @@ -22,7 +22,7 @@ void DrawMenuState(struct Game *game); void Menu_Draw(struct Game *game); -void Menu_Preload(struct Game *game); +void Menu_Preload(struct Game *game, void (*progress)(struct Game*, float)); void Menu_Stop(struct Game *game); void Menu_Unload(struct Game *game); void Menu_Load(struct Game *game); diff --git a/src/pause.c b/src/pause.c index 502f36d..ea21613 100644 --- a/src/pause.c +++ b/src/pause.c @@ -47,9 +47,9 @@ int Pause_Keydown(struct Game *game, ALLEGRO_EVENT *ev) { Loading_Unload(game); Loading_Load(game); Menu_Unload(game); - Menu_Preload(game); + Menu_Preload(game, NULL); Level_UnloadBitmaps(game); - Level_PreloadBitmaps(game); + Level_PreloadBitmaps(game, NULL); Pause_Unload_Real(game); Pause_Preload(game); Pause_Load(game); @@ -64,7 +64,7 @@ void Pause_Preload(struct Game* game) { PrintConsole(game,"Pause preloaded."); if (!game->menu.loaded) { PrintConsole(game,"Pause: Preloading GAMESTATE_MENU..."); - Menu_Preload(game); + Menu_Preload(game, NULL); } } @@ -109,4 +109,4 @@ void Pause_Unload(struct Game* game) { UnloadGameState(game); PrintConsole(game, "Pause: Unloading GAMESTATE_MENU..."); Menu_Unload(game); -} \ No newline at end of file +}