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.
23 #include "game_common.h"
24 #include "game_server.h"
25 #include "game_client.h"
31 #include "st_shared.h"
33 /*---------------------------------------------------------------------------*/
44 static int fail_action(int i)
46 audio_play(AUD_MENU, 1.0f);
55 return goto_state(&st_exit);
59 return goto_save(&st_fail, &st_fail);
63 return goto_state(&st_level);
68 return goto_state(&st_level);
75 static int fail_gui(void)
79 const char *label = "";
81 if (status == GAME_FALL)
82 label = _("Fall-out!");
83 else if (status == GAME_TIME)
84 label = _("Time's Up!");
86 if ((id = gui_vstack(0)))
88 kd = gui_label(id, label, GUI_LRG, GUI_ALL, gui_gry, gui_red);
92 if ((jd = gui_harray(id)))
95 gui_start(jd, _("Exit"), GUI_SML, FAIL_OVER, 0);
97 if (progress_next_avail())
98 gui_start(jd, _("Next Level"), GUI_SML, FAIL_NEXT, 0);
100 if (progress_same_avail())
101 gui_start(jd, _("Retry Level"), GUI_SML, FAIL_SAME, 0);
104 gui_state(jd, _("Save Replay"), GUI_SML, FAIL_SAVE, 0);
110 gui_layout(id, 0, 0);
116 static int fail_enter(struct state *st, struct state *prev)
118 audio_music_fade_out(2.0f);
121 /* Check if we came from a known previous state. */
123 resume = (prev == &st_fail || prev == &st_save);
125 /* Note the current status if we got here from elsewhere. */
128 status = curr_status();
133 static void fail_timer(int id, float dt)
135 if (status == GAME_FALL)
137 if (!resume && time_state() < 2.f)
139 game_server_step(dt);
140 game_client_sync(demo_fp);
141 game_client_blend(game_server_blend());
148 static int fail_keybd(int c, int d)
152 if (config_tst_d(CONFIG_KEY_RESTART, c) && progress_same_avail())
155 goto_state(&st_play_ready);
161 static int fail_buttn(int b, int d)
165 if (config_tst_d(CONFIG_JOYSTICK_BUTTON_A, b))
166 return fail_action(gui_token(gui_click()));
167 if (config_tst_d(CONFIG_JOYSTICK_BUTTON_EXIT, b))
168 return fail_action(FAIL_BACK);
173 /*---------------------------------------------------------------------------*/
175 struct state st_fail = {