2 * Copyright (C) 2003 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.
15 #include <SDL_mixer.h>
26 #include "st_shared.h"
29 #define PAUSE_CONTINUE 1
30 #define PAUSE_RESTART 2
33 /*---------------------------------------------------------------------------*/
35 static struct state *st_continue;
40 st_continue = curr_state();
42 return goto_state(&st_pause);
50 void clear_pause(void)
55 /*---------------------------------------------------------------------------*/
57 static int pause_action(int i)
59 audio_play(AUD_MENU, 1.0f);
66 return goto_state(st_continue);
69 level_stop(GAME_NONE, 0, curr_clock(), curr_coins());
74 return goto_state(&st_play_ready);
77 level_stop(GAME_NONE, 0, curr_clock(), curr_coins());
79 return goto_state(&st_start);
86 static int pause_enter(void)
94 /* Build the pause GUI. */
96 if ((id = gui_vstack(0)))
98 title_id = gui_label(id, _("Paused"), GUI_LRG, GUI_ALL, 0, 0);
102 if ((jd = gui_harray(id)))
104 gui_state(jd, _("Quit"), GUI_SML, PAUSE_EXIT, 0);
106 if (curr_lg()->mode != MODE_CHALLENGE)
107 gui_state(jd, _("Restart"), GUI_SML, PAUSE_RESTART, 0);
110 int ld = gui_state(jd, _("Restart"), GUI_SML, 0, 0);
111 gui_set_color(ld, gui_gry, gui_gry);
114 gui_start(jd, _("Continue"), GUI_SML, PAUSE_CONTINUE, 1);
117 gui_pulse(title_id, 1.2f);
118 gui_layout(id, 0, 0);
126 void pause_paint(int id, float st)
128 shared_paint(id, st);
132 void pause_timer(int id, float dt)
138 static int pause_keybd(int c, int d)
142 if (config_tst_d(CONFIG_KEY_PAUSE, c))
143 return pause_action(PAUSE_CONTINUE);
145 if (config_tst_d(CONFIG_KEY_RESTART, c)
146 && curr_lg()->mode != MODE_CHALLENGE)
147 return pause_action(PAUSE_RESTART);
152 static int pause_buttn(int b, int d)
156 if (config_tst_d(CONFIG_JOYSTICK_BUTTON_A, b))
157 return pause_action(gui_token(gui_click()));
159 if (config_tst_d(CONFIG_JOYSTICK_BUTTON_EXIT, b))
161 if (SDL_GetModState() & (KMOD_SHIFT | KMOD_CTRL | KMOD_ALT | KMOD_META))
162 return pause_action(PAUSE_EXIT);
164 return pause_action(PAUSE_CONTINUE);
170 /*---------------------------------------------------------------------------*/
172 struct state st_pause = {