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.
22 #include "game_common.h"
23 #include "game_server.h"
24 #include "game_client.h"
26 #include "st_fall_out.h"
31 #include "st_shared.h"
34 /*---------------------------------------------------------------------------*/
36 #define FALL_OUT_NEXT 1
37 #define FALL_OUT_SAME 2
38 #define FALL_OUT_SAVE 3
39 #define FALL_OUT_BACK 4
40 #define FALL_OUT_OVER 5
44 static int fall_out_action(int i)
46 audio_play(AUD_MENU, 1.0f);
55 return goto_state(&st_over);
61 return goto_save(&st_fall_out, &st_fall_out);
65 return goto_state(&st_level);
70 return goto_state(&st_level);
77 static int fall_out_enter(void)
84 if ((id = gui_vstack(0)))
86 kd = gui_label(id, _("Fall-out!"), GUI_LRG, GUI_ALL, gui_gry, gui_red);
90 if ((jd = gui_harray(id)))
93 gui_start(jd, _("Exit"), GUI_SML, FALL_OUT_OVER, 0);
95 if (progress_next_avail())
96 gui_start(jd, _("Next Level"), GUI_SML, FALL_OUT_NEXT, 0);
98 if (progress_same_avail())
99 gui_start(jd, _("Retry Level"), GUI_SML, FALL_OUT_SAME, 0);
102 gui_state(jd, _("Save Replay"), GUI_SML, FALL_OUT_SAVE, 0);
108 gui_layout(id, 0, 0);
111 audio_music_fade_out(2.0f);
112 /* audio_play(AUD_FALL, 1.0f); */
119 static void fall_out_timer(int id, float dt)
121 if (time_state() < 2.f)
123 game_server_step(dt);
124 game_client_step(demo_file());
130 static int fall_out_keybd(int c, int d)
134 if (config_tst_d(CONFIG_KEY_RESTART, c) && progress_same_avail())
137 goto_state(&st_play_ready);
143 static int fall_out_buttn(int b, int d)
147 if (config_tst_d(CONFIG_JOYSTICK_BUTTON_A, b))
148 return fall_out_action(gui_token(gui_click()));
149 if (config_tst_d(CONFIG_JOYSTICK_BUTTON_EXIT, b))
150 return fall_out_action(FALL_OUT_BACK);
155 static void fall_out_leave(int id)
157 /* HACK: don't run animation if only "visiting" a state. */
158 st_fall_out.timer = resume ? shared_timer : fall_out_timer;
163 /*---------------------------------------------------------------------------*/
165 struct state st_fall_out = {