2 * Copyright (C) 2007 Robert Kooima
4 * NEVERBALL is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published
6 * by the Free Software Foundation; either version 2 of the License,
7 * or (at your option) any later version.
9 * This program is distributed in the hope that it will be useful, but
10 * WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * General Public License for more details.
26 #include "st_time_out.h"
28 #include "st_shared.h"
30 /*---------------------------------------------------------------------------*/
32 #define TIME_OUT_NEXT 1
33 #define TIME_OUT_SAME 2
34 #define TIME_OUT_SAVE 3
35 #define TIME_OUT_BACK 4
36 #define TIME_OUT_OVER 5
38 static int time_out_action(int i)
40 audio_play(AUD_MENU, 1.0f);
49 return goto_state(&st_over);
53 return goto_save(&st_time_out, &st_time_out);
57 return goto_state(&st_level);
61 return goto_state(&st_level);
67 static int time_out_enter(void)
71 const struct level_game *lg = curr_lg();
73 if ((id = gui_vstack(0)))
75 kd = gui_label(id, _("Time's Up!"), GUI_LRG, GUI_ALL, gui_gry, gui_red);
79 if ((jd = gui_harray(id)))
81 int next_id = 0, retry_id = 0;
83 next_id = gui_maybe(jd, _("Next Level"), TIME_OUT_NEXT,
84 lg->next_level != NULL);
87 gui_start(jd, _("Game Over"), GUI_SML, TIME_OUT_OVER, 0);
90 retry_id = gui_state(jd, _("Retry Level"), GUI_SML,
94 gui_maybe(jd, _("Save Replay"), TIME_OUT_SAVE, demo_saved());
96 /* Default is next if the next level is newly unlocked. */
98 if (next_id && lg->unlock)
106 gui_layout(id, 0, 0);
109 audio_music_fade_out(2.0f);
110 /* audio_play(AUD_TIME, 1.0f); */
117 static int time_out_buttn(int b, int d)
121 if (config_tst_d(CONFIG_JOYSTICK_BUTTON_A, b))
122 return time_out_action(gui_token(gui_click()));
123 if (config_tst_d(CONFIG_JOYSTICK_BUTTON_EXIT, b))
124 return time_out_action(TIME_OUT_BACK);
129 /*---------------------------------------------------------------------------*/
131 struct state st_time_out = {