2 * Copyright (C) 2003 Robert Kooima
4 * NEVERPUTT 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.
29 /*---------------------------------------------------------------------------*/
43 static int music_id[11];
44 static int sound_id[11];
46 static int conf_action(int i)
48 int w = config_get_d(CONFIG_WIDTH);
49 int h = config_get_d(CONFIG_HEIGHT);
50 int s = config_get_d(CONFIG_SOUND_VOLUME);
51 int m = config_get_d(CONFIG_MUSIC_VOLUME);
54 audio_play(AUD_MENU, 1.0f);
60 r = video_mode(1, w, h);
66 r = video_mode(0, w, h);
72 config_set_d(CONFIG_TEXTURES, 1);
78 config_set_d(CONFIG_TEXTURES, 2);
84 config_set_d(CONFIG_SHADOW, 1);
90 config_set_d(CONFIG_SHADOW, 0);
95 goto_state(&st_title);
99 goto_state(&st_resol);
103 if (100 <= i && i <= 110)
107 config_set_d(CONFIG_SOUND_VOLUME, n);
109 audio_play(AUD_BUMP, 1.f);
111 gui_toggle(sound_id[n]);
112 gui_toggle(sound_id[s]);
114 if (200 <= i && i <= 210)
118 config_set_d(CONFIG_MUSIC_VOLUME, n);
120 audio_play(AUD_BUMP, 1.f);
122 gui_toggle(music_id[n]);
123 gui_toggle(music_id[m]);
130 static int conf_enter(struct state *st, struct state *prev)
134 back_init("back/gui.png");
136 /* Initialize the configuration GUI. */
138 if ((id = gui_vstack(0)))
140 int f = config_get_d(CONFIG_FULLSCREEN);
141 int t = config_get_d(CONFIG_TEXTURES);
142 int h = config_get_d(CONFIG_SHADOW);
143 int s = config_get_d(CONFIG_SOUND_VOLUME);
144 int m = config_get_d(CONFIG_MUSIC_VOLUME);
148 sprintf(resolution, "%d x %d",
149 config_get_d(CONFIG_WIDTH),
150 config_get_d(CONFIG_HEIGHT));
152 if ((jd = gui_harray(id)))
154 gui_label(jd, _("Options"), GUI_SML, GUI_ALL, 0, 0);
156 gui_start(jd, _("Back"), GUI_SML, CONF_BACK, 0);
161 if ((jd = gui_harray(id)) &&
162 (kd = gui_harray(jd)))
164 gui_state(kd, _("No"), GUI_SML, CONF_WIN, (f == 0));
165 gui_state(kd, _("Yes"), GUI_SML, CONF_FULL, (f == 1));
167 gui_label(jd, _("Fullscreen"), GUI_SML, GUI_ALL, 0, 0);
170 if ((jd = gui_harray(id)) &&
171 (kd = gui_harray(jd)))
173 gui_state(kd, resolution, GUI_SML, CONF_RESOL, 0);
175 gui_label(jd, _("Resolution"), GUI_SML, GUI_ALL, 0, 0);
180 if ((jd = gui_harray(id)) &&
181 (kd = gui_harray(jd)))
183 gui_state(kd, _("Low"), GUI_SML, CONF_TEXLO, (t == 2));
184 gui_state(kd, _("High"), GUI_SML, CONF_TEXHI, (t == 1));
186 gui_label(jd, _("Textures"), GUI_SML, GUI_ALL, 0, 0);
189 if ((jd = gui_harray(id)) &&
190 (kd = gui_harray(jd)))
192 gui_state(kd, _("Off"), GUI_SML, CONF_SHDOF, (h == 0));
193 gui_state(kd, _("On"), GUI_SML, CONF_SHDON, (h == 1));
195 gui_label(jd, _("Shadow"), GUI_SML, GUI_ALL, 0, 0);
200 if ((jd = gui_harray(id)) &&
201 (kd = gui_harray(jd)))
203 /* A series of empty buttons forms the sound volume control. */
205 sound_id[10] = gui_state(kd, NULL, GUI_SML, 110, (s == 10));
206 sound_id[ 9] = gui_state(kd, NULL, GUI_SML, 109, (s == 9));
207 sound_id[ 8] = gui_state(kd, NULL, GUI_SML, 108, (s == 8));
208 sound_id[ 7] = gui_state(kd, NULL, GUI_SML, 107, (s == 7));
209 sound_id[ 6] = gui_state(kd, NULL, GUI_SML, 106, (s == 6));
210 sound_id[ 5] = gui_state(kd, NULL, GUI_SML, 105, (s == 5));
211 sound_id[ 4] = gui_state(kd, NULL, GUI_SML, 104, (s == 4));
212 sound_id[ 3] = gui_state(kd, NULL, GUI_SML, 103, (s == 3));
213 sound_id[ 2] = gui_state(kd, NULL, GUI_SML, 102, (s == 2));
214 sound_id[ 1] = gui_state(kd, NULL, GUI_SML, 101, (s == 1));
215 sound_id[ 0] = gui_state(kd, NULL, GUI_SML, 100, (s == 0));
217 gui_label(jd, _("Sound Volume"), GUI_SML, GUI_ALL, 0, 0);
220 if ((jd = gui_harray(id)) &&
221 (kd = gui_harray(jd)))
223 /* A series of empty buttons forms the music volume control. */
225 music_id[10] = gui_state(kd, NULL, GUI_SML, 210, (m == 10));
226 music_id[ 9] = gui_state(kd, NULL, GUI_SML, 209, (m == 9));
227 music_id[ 8] = gui_state(kd, NULL, GUI_SML, 208, (m == 8));
228 music_id[ 7] = gui_state(kd, NULL, GUI_SML, 207, (m == 7));
229 music_id[ 6] = gui_state(kd, NULL, GUI_SML, 206, (m == 6));
230 music_id[ 5] = gui_state(kd, NULL, GUI_SML, 205, (m == 5));
231 music_id[ 4] = gui_state(kd, NULL, GUI_SML, 204, (m == 4));
232 music_id[ 3] = gui_state(kd, NULL, GUI_SML, 203, (m == 3));
233 music_id[ 2] = gui_state(kd, NULL, GUI_SML, 202, (m == 2));
234 music_id[ 1] = gui_state(kd, NULL, GUI_SML, 201, (m == 1));
235 music_id[ 0] = gui_state(kd, NULL, GUI_SML, 200, (m == 0));
237 gui_label(jd, _("Music Volume"), GUI_SML, GUI_ALL, 0, 0);
240 gui_layout(id, 0, 0);
243 audio_music_fade_to(0.5f, "bgm/inter.ogg");
248 static void conf_leave(struct state *st, struct state *next, int id)
253 static void conf_paint(int id, float st)
255 video_push_persp((float) config_get_d(CONFIG_VIEW_FOV), 0.1f, FAR_DIST);
263 static void conf_timer(int id, float dt)
268 static void conf_point(int id, int x, int y, int dx, int dy)
270 gui_pulse(gui_point(id, x, y), 1.2f);
273 static void conf_stick(int id, int a, float v, int bump)
275 gui_pulse(gui_stick(id, a, v, bump), 1.2f);
278 static int conf_click(int b, int d)
280 if (b == SDL_BUTTON_LEFT && d == 1)
281 return conf_action(gui_token(gui_click()));
285 static int conf_keybd(int c, int d)
287 return (d && c == SDLK_ESCAPE) ? goto_state(&st_title) : 1;
290 static int conf_buttn(int b, int d)
294 if (config_tst_d(CONFIG_JOYSTICK_BUTTON_A, b))
295 return conf_action(gui_token(gui_click()));
296 if (config_tst_d(CONFIG_JOYSTICK_BUTTON_B, b))
297 return goto_state(&st_title);
298 if (config_tst_d(CONFIG_JOYSTICK_BUTTON_EXIT, b))
299 return goto_state(&st_title);
304 /*---------------------------------------------------------------------------*/
306 static int null_enter(struct state *st, struct state *prev)
316 static void null_leave(struct state *st, struct state *next, int id)
324 /*---------------------------------------------------------------------------*/
326 struct state st_conf = {
339 struct state st_null = {