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>
27 #include "st_shared.h"
30 #define PAUSE_CONTINUE 1
31 #define PAUSE_RESTART 2
34 /*---------------------------------------------------------------------------*/
36 static struct state *st_continue;
41 st_continue = curr_state();
43 return goto_state(&st_pause);
51 void clear_pause(void)
56 /*---------------------------------------------------------------------------*/
58 static int pause_action(int i)
60 audio_play(AUD_MENU, 1.0f);
67 return goto_state(st_continue);
74 return goto_state(&st_play_ready);
77 level_stat(GAME_NONE, curr_clock(), curr_coins());
82 return goto_state(&st_over);
88 /*---------------------------------------------------------------------------*/
90 static int pause_enter(void)
97 /* Build the pause GUI. */
99 if ((id = gui_vstack(0)))
101 title_id = gui_label(id, _("Paused"), GUI_LRG, GUI_ALL, 0, 0);
105 if ((jd = gui_harray(id)))
107 gui_state(jd, _("Quit"), GUI_SML, PAUSE_EXIT, 0);
109 if (curr_lg()->mode != MODE_CHALLENGE)
110 gui_state(jd, _("Restart"), GUI_SML, PAUSE_RESTART, 0);
113 int ld = gui_state(jd, _("Restart"), GUI_SML, 0, 0);
114 gui_set_color(ld, gui_gry, gui_gry);
117 gui_start(jd, _("Continue"), GUI_SML, PAUSE_CONTINUE, 1);
120 gui_pulse(title_id, 1.2f);
121 gui_layout(id, 0, 0);
129 static void pause_paint(int id, float st)
131 shared_paint(id, st);
135 static void pause_timer(int id, float dt)
141 static int pause_keybd(int c, int d)
145 if (config_tst_d(CONFIG_KEY_PAUSE, c))
146 return pause_action(PAUSE_CONTINUE);
148 if (config_tst_d(CONFIG_KEY_RESTART, c)
149 && curr_lg()->mode != MODE_CHALLENGE)
150 return pause_action(PAUSE_RESTART);
155 static int pause_buttn(int b, int d)
159 if (config_tst_d(CONFIG_JOYSTICK_BUTTON_A, b))
160 return pause_action(gui_token(gui_click()));
162 if (config_tst_d(CONFIG_JOYSTICK_BUTTON_EXIT, b))
164 if (SDL_GetModState() & KMOD_SHIFT)
165 return pause_action(PAUSE_EXIT);
167 return pause_action(PAUSE_CONTINUE);
173 /*---------------------------------------------------------------------------*/
175 struct state st_pause = {