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"
27 #include "st_fall_out.h"
32 #include "st_shared.h"
35 /*---------------------------------------------------------------------------*/
37 #define FALL_OUT_NEXT 1
38 #define FALL_OUT_SAME 2
39 #define FALL_OUT_SAVE 3
40 #define FALL_OUT_BACK 4
41 #define FALL_OUT_OVER 5
45 static int fall_out_action(int i)
47 audio_play(AUD_MENU, 1.0f);
56 return goto_state(&st_over);
62 return goto_save(&st_fall_out, &st_fall_out);
66 return goto_state(&st_level);
71 return goto_state(&st_level);
78 static int fall_out_enter(void)
85 if ((id = gui_vstack(0)))
87 kd = gui_label(id, _("Fall-out!"), GUI_LRG, GUI_ALL, gui_gry, gui_red);
91 if ((jd = gui_harray(id)))
94 gui_start(jd, _("Exit"), GUI_SML, FALL_OUT_OVER, 0);
96 if (progress_next_avail())
97 gui_start(jd, _("Next Level"), GUI_SML, FALL_OUT_NEXT, 0);
99 if (progress_same_avail())
100 gui_start(jd, _("Retry Level"), GUI_SML, FALL_OUT_SAME, 0);
103 gui_state(jd, _("Save Replay"), GUI_SML, FALL_OUT_SAVE, 0);
109 gui_layout(id, 0, 0);
112 audio_music_fade_out(2.0f);
113 /* audio_play(AUD_FALL, 1.0f); */
120 static void fall_out_timer(int id, float dt)
122 if (time_state() < 2.f)
124 game_server_step(dt);
125 game_client_step(demo_file());
131 static int fall_out_keybd(int c, int d)
135 if (config_tst_d(CONFIG_KEY_RESTART, c) && progress_same_avail())
138 goto_state(&st_play_ready);
144 static int fall_out_buttn(int b, int d)
148 if (config_tst_d(CONFIG_JOYSTICK_BUTTON_A, b))
149 return fall_out_action(gui_token(gui_click()));
150 if (config_tst_d(CONFIG_JOYSTICK_BUTTON_EXIT, b))
151 return fall_out_action(FALL_OUT_BACK);
156 static void fall_out_leave(int id)
158 /* HACK: don't run animation if only "visiting" a state. */
159 st_fall_out.timer = resume ? shared_timer : fall_out_timer;
164 /*---------------------------------------------------------------------------*/
166 struct state st_fall_out = {