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.
30 /*---------------------------------------------------------------------------*/
44 static int music_id[11];
45 static int sound_id[11];
47 static int conf_action(int i)
49 int w = config_get_d(CONFIG_WIDTH);
50 int h = config_get_d(CONFIG_HEIGHT);
51 int s = config_get_d(CONFIG_SOUND_VOLUME);
52 int m = config_get_d(CONFIG_MUSIC_VOLUME);
55 audio_play(AUD_MENU, 1.0f);
61 r = video_mode(1, w, h);
67 r = video_mode(0, w, h);
73 config_set_d(CONFIG_TEXTURES, 1);
79 config_set_d(CONFIG_TEXTURES, 2);
85 config_set_d(CONFIG_SHADOW, 1);
91 config_set_d(CONFIG_SHADOW, 0);
96 goto_state(&st_title);
100 goto_state(&st_resol);
104 if (100 <= i && i <= 110)
108 config_set_d(CONFIG_SOUND_VOLUME, n);
110 audio_play(AUD_BUMP, 1.f);
112 gui_toggle(sound_id[n]);
113 gui_toggle(sound_id[s]);
115 if (200 <= i && i <= 210)
119 config_set_d(CONFIG_MUSIC_VOLUME, n);
121 audio_play(AUD_BUMP, 1.f);
123 gui_toggle(music_id[n]);
124 gui_toggle(music_id[m]);
131 static int conf_enter(struct state *st, struct state *prev)
135 back_init("back/gui.png");
137 /* Initialize the configuration GUI. */
139 if ((id = gui_vstack(0)))
141 int f = config_get_d(CONFIG_FULLSCREEN);
142 int t = config_get_d(CONFIG_TEXTURES);
143 int h = config_get_d(CONFIG_SHADOW);
144 int s = config_get_d(CONFIG_SOUND_VOLUME);
145 int m = config_get_d(CONFIG_MUSIC_VOLUME);
149 sprintf(resolution, "%d x %d",
150 config_get_d(CONFIG_WIDTH),
151 config_get_d(CONFIG_HEIGHT));
153 if ((jd = gui_harray(id)))
155 gui_label(jd, _("Options"), GUI_SML, GUI_ALL, 0, 0);
157 gui_start(jd, _("Back"), GUI_SML, CONF_BACK, 0);
162 if ((jd = gui_harray(id)) &&
163 (kd = gui_harray(jd)))
165 gui_state(kd, _("No"), GUI_SML, CONF_WIN, (f == 0));
166 gui_state(kd, _("Yes"), GUI_SML, CONF_FULL, (f == 1));
168 gui_label(jd, _("Fullscreen"), GUI_SML, GUI_ALL, 0, 0);
171 if ((jd = gui_harray(id)) &&
172 (kd = gui_harray(jd)))
174 gui_state(kd, resolution, GUI_SML, CONF_RESOL, 0);
176 gui_label(jd, _("Resolution"), GUI_SML, GUI_ALL, 0, 0);
181 if ((jd = gui_harray(id)) &&
182 (kd = gui_harray(jd)))
184 gui_state(kd, _("Low"), GUI_SML, CONF_TEXLO, (t == 2));
185 gui_state(kd, _("High"), GUI_SML, CONF_TEXHI, (t == 1));
187 gui_label(jd, _("Textures"), GUI_SML, GUI_ALL, 0, 0);
190 if ((jd = gui_harray(id)) &&
191 (kd = gui_harray(jd)))
193 gui_state(kd, _("Off"), GUI_SML, CONF_SHDOF, (h == 0));
194 gui_state(kd, _("On"), GUI_SML, CONF_SHDON, (h == 1));
196 gui_label(jd, _("Shadow"), GUI_SML, GUI_ALL, 0, 0);
201 if ((jd = gui_harray(id)) &&
202 (kd = gui_harray(jd)))
204 /* A series of empty buttons forms the sound volume control. */
206 sound_id[10] = gui_state(kd, NULL, GUI_SML, 110, (s == 10));
207 sound_id[ 9] = gui_state(kd, NULL, GUI_SML, 109, (s == 9));
208 sound_id[ 8] = gui_state(kd, NULL, GUI_SML, 108, (s == 8));
209 sound_id[ 7] = gui_state(kd, NULL, GUI_SML, 107, (s == 7));
210 sound_id[ 6] = gui_state(kd, NULL, GUI_SML, 106, (s == 6));
211 sound_id[ 5] = gui_state(kd, NULL, GUI_SML, 105, (s == 5));
212 sound_id[ 4] = gui_state(kd, NULL, GUI_SML, 104, (s == 4));
213 sound_id[ 3] = gui_state(kd, NULL, GUI_SML, 103, (s == 3));
214 sound_id[ 2] = gui_state(kd, NULL, GUI_SML, 102, (s == 2));
215 sound_id[ 1] = gui_state(kd, NULL, GUI_SML, 101, (s == 1));
216 sound_id[ 0] = gui_state(kd, NULL, GUI_SML, 100, (s == 0));
218 gui_label(jd, _("Sound Volume"), GUI_SML, GUI_ALL, 0, 0);
221 if ((jd = gui_harray(id)) &&
222 (kd = gui_harray(jd)))
224 /* A series of empty buttons forms the music volume control. */
226 music_id[10] = gui_state(kd, NULL, GUI_SML, 210, (m == 10));
227 music_id[ 9] = gui_state(kd, NULL, GUI_SML, 209, (m == 9));
228 music_id[ 8] = gui_state(kd, NULL, GUI_SML, 208, (m == 8));
229 music_id[ 7] = gui_state(kd, NULL, GUI_SML, 207, (m == 7));
230 music_id[ 6] = gui_state(kd, NULL, GUI_SML, 206, (m == 6));
231 music_id[ 5] = gui_state(kd, NULL, GUI_SML, 205, (m == 5));
232 music_id[ 4] = gui_state(kd, NULL, GUI_SML, 204, (m == 4));
233 music_id[ 3] = gui_state(kd, NULL, GUI_SML, 203, (m == 3));
234 music_id[ 2] = gui_state(kd, NULL, GUI_SML, 202, (m == 2));
235 music_id[ 1] = gui_state(kd, NULL, GUI_SML, 201, (m == 1));
236 music_id[ 0] = gui_state(kd, NULL, GUI_SML, 200, (m == 0));
238 gui_label(jd, _("Music Volume"), GUI_SML, GUI_ALL, 0, 0);
241 gui_layout(id, 0, 0);
244 audio_music_fade_to(0.5f, "bgm/inter.ogg");
249 static void conf_leave(struct state *st, struct state *next, int id)
254 static void conf_paint(int id, float st)
256 video_push_persp((float) config_get_d(CONFIG_VIEW_FOV), 0.1f, FAR_DIST);
264 static void conf_timer(int id, float dt)
269 static void conf_point(int id, int x, int y, int dx, int dy)
271 gui_pulse(gui_point(id, x, y), 1.2f);
274 static void conf_stick(int id, int a, float v, int bump)
276 gui_pulse(gui_stick(id, a, v, bump), 1.2f);
279 static int conf_click(int b, int d)
281 if (b == SDL_BUTTON_LEFT && d == 1)
282 return conf_action(gui_token(gui_click()));
286 static int conf_keybd(int c, int d)
288 return (d && c == SDLK_ESCAPE) ? goto_state(&st_title) : 1;
291 static int conf_buttn(int b, int d)
295 if (config_tst_d(CONFIG_JOYSTICK_BUTTON_A, b))
296 return conf_action(gui_token(gui_click()));
297 if (config_tst_d(CONFIG_JOYSTICK_BUTTON_B, b))
298 return goto_state(&st_title);
299 if (config_tst_d(CONFIG_JOYSTICK_BUTTON_EXIT, b))
300 return goto_state(&st_title);
305 /*---------------------------------------------------------------------------*/
307 static int null_enter(struct state *st, struct state *prev)
318 static void null_leave(struct state *st, struct state *next, int id)
327 /*---------------------------------------------------------------------------*/
329 struct state st_conf = {
342 struct state st_null = {