X-Git-Url: http://vcs.maemo.org/git/?a=blobdiff_plain;f=ball%2Fst_fall_out.c;h=7a887c98e9823ba62c9c5c41471cde0fa6e01176;hb=9294fad7c4d92dcad1737bf871957ae8111b5078;hp=bd49d3cbe8a25ea758a65eead589686c2858d791;hpb=826adcdb14e08c3cad1e37233704d6215752690c;p=neverball diff --git a/ball/st_fall_out.c b/ball/st_fall_out.c index bd49d3c..7a887c9 100644 --- a/ball/st_fall_out.c +++ b/ball/st_fall_out.c @@ -13,19 +13,24 @@ */ #include "gui.h" -#include "game.h" #include "util.h" -#include "levels.h" +#include "progress.h" #include "audio.h" #include "config.h" +#include "video.h" #include "demo.h" +#include "game_common.h" +#include "game_server.h" +#include "game_client.h" + #include "st_fall_out.h" #include "st_save.h" #include "st_over.h" #include "st_start.h" #include "st_level.h" #include "st_shared.h" +#include "st_play.h" /*---------------------------------------------------------------------------*/ @@ -35,7 +40,7 @@ #define FALL_OUT_BACK 4 #define FALL_OUT_OVER 5 -static int be_back_soon; +static int resume; static int fall_out_action(int i) { @@ -47,23 +52,24 @@ static int fall_out_action(int i) /* Fall through. */ case FALL_OUT_OVER: - if (curr_lg()->mode == MODE_CHALLENGE) - return goto_state(&st_over); - else - return goto_state(&st_start); + progress_stop(); + return goto_state(&st_over); case FALL_OUT_SAVE: - be_back_soon = 1; + resume = 1; + + progress_stop(); return goto_save(&st_fall_out, &st_fall_out); case FALL_OUT_NEXT: - level_next(); - level_play(curr_lg()->level, curr_lg()->mode); - return goto_state(&st_level); + if (progress_next()) + return goto_state(&st_level); + break; case FALL_OUT_SAME: - level_play(curr_lg()->level, curr_lg()->mode); - return goto_state(&st_level); + if (progress_same()) + return goto_state(&st_level); + break; } return 1; @@ -73,10 +79,8 @@ static int fall_out_enter(void) { int id, jd, kd; - const struct level_game *lg = curr_lg(); - /* Reset hack. */ - be_back_soon = 0; + resume = 0; if ((id = gui_vstack(0))) { @@ -86,29 +90,17 @@ static int fall_out_enter(void) if ((jd = gui_harray(id))) { - int next_id = 0, retry_id = 0; - - next_id = gui_maybe(jd, _("Next Level"), FALL_OUT_NEXT, - lg->next_level != NULL); - - if (lg->dead) - { - gui_start(jd, _("Game Over"), GUI_SML, FALL_OUT_OVER, 0); - } - else - { - retry_id = gui_maybe(jd, _("Retry Level"), FALL_OUT_SAME, - lg->mode != MODE_CHALLENGE); - } + if (progress_dead()) + gui_start(jd, _("Exit"), GUI_SML, FALL_OUT_OVER, 0); - gui_maybe(jd, _("Save Replay"), FALL_OUT_SAVE, demo_play_saved()); + if (progress_next_avail()) + gui_start(jd, _("Next Level"), GUI_SML, FALL_OUT_NEXT, 0); - /* Default is next if the next level is newly unlocked. */ + if (progress_same_avail()) + gui_start(jd, _("Retry Level"), GUI_SML, FALL_OUT_SAME, 0); - if (next_id && lg->unlock) - gui_focus(next_id); - else if (lg->mode != MODE_CHALLENGE) - gui_focus(retry_id); + if (demo_saved()) + gui_state(jd, _("Save Replay"), GUI_SML, FALL_OUT_SAVE, 0); } gui_space(id); @@ -120,23 +112,33 @@ static int fall_out_enter(void) audio_music_fade_out(2.0f); /* audio_play(AUD_FALL, 1.0f); */ - config_clr_grab(); + video_clr_grab(); return id; } static void fall_out_timer(int id, float dt) { - float g[3] = { 0.0f, -9.8f, 0.0f }; - if (time_state() < 2.f) { - game_step(g, dt, 0); - /* demo_play_step(dt); */ + game_server_step(dt); + game_client_step(demo_file()); } gui_timer(id, dt); - audio_timer(dt); +} + +static int fall_out_keybd(int c, int d) +{ + if (d) + { + if (config_tst_d(CONFIG_KEY_RESTART, c) && progress_same_avail()) + { + if (progress_same()) + goto_state(&st_play_ready); + } + } + return 1; } static int fall_out_buttn(int b, int d) @@ -151,10 +153,10 @@ static int fall_out_buttn(int b, int d) return 1; } -void fall_out_leave(int id) +static void fall_out_leave(int id) { /* HACK: don't run animation if only "visiting" a state. */ - st_fall_out.timer = be_back_soon ? shared_timer : fall_out_timer; + st_fall_out.timer = resume ? shared_timer : fall_out_timer; gui_delete(id); } @@ -168,8 +170,9 @@ struct state st_fall_out = { fall_out_timer, shared_point, shared_stick, - shared_click, NULL, + shared_click, + fall_out_keybd, fall_out_buttn, 1, 0 };