#include "gui.h"
#include "game.h"
#include "util.h"
-#include "levels.h"
+#include "progress.h"
#include "audio.h"
#include "config.h"
#include "demo.h"
#include "st_start.h"
#include "st_level.h"
#include "st_shared.h"
+#include "st_play.h"
/*---------------------------------------------------------------------------*/
#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)
{
/* Fall through. */
case FALL_OUT_OVER:
- level_stop();
+ progress_stop();
return goto_state(&st_over);
case FALL_OUT_SAVE:
- be_back_soon = 1;
+ resume = 1;
- level_stop();
+ progress_stop();
return goto_save(&st_fall_out, &st_fall_out);
case FALL_OUT_NEXT:
- level_next();
- return goto_state(&st_level);
+ if (progress_next())
+ return goto_state(&st_level);
+ break;
case FALL_OUT_SAME:
- level_same();
- return goto_state(&st_level);
+ if (progress_same())
+ return goto_state(&st_level);
+ break;
}
return 1;
{
int id, jd, kd;
- const struct level_game *lg = curr_lg();
-
/* Reset hack. */
- be_back_soon = 0;
+ resume = 0;
if ((id = gui_vstack(0)))
{
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 (progress_dead())
+ gui_start(jd, _("Exit"), GUI_SML, FALL_OUT_OVER, 0);
- if (lg->dead)
- {
- gui_start(jd, _("Game Over"), GUI_SML, FALL_OUT_OVER, 0);
- }
- else
- {
- retry_id = gui_state(jd, _("Retry Level"), GUI_SML,
- FALL_OUT_SAME, 0);
- }
+ if (progress_next_avail())
+ gui_start(jd, _("Next Level"), GUI_SML, FALL_OUT_NEXT, 0);
- gui_maybe(jd, _("Save Replay"), FALL_OUT_SAVE, demo_saved());
+ if (progress_same_avail())
+ gui_start(jd, _("Retry Level"), GUI_SML, FALL_OUT_SAME, 0);
- /* Default is next if the next level is newly unlocked. */
-
- 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);
if (time_state() < 2.f)
{
+ demo_play_step();
game_step(g, dt, 0);
- demo_play_step(dt);
}
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)
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);
}
fall_out_timer,
shared_point,
shared_stick,
- shared_click,
NULL,
+ shared_click,
+ fall_out_keybd,
fall_out_buttn,
1, 0
};