2 * Copyright (C) 2003 Robert Kooima - 2006 Jean Privat
3 * Part of the Neverball Project http://icculus.org/neverball/
5 * NEVERBALL is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published
7 * by the Free Software Foundation; either version 2 of the License,
8 * or (at your option) any later version.
10 * This program is distributed in the hope that it will be useful, but
11 * WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 * General Public License for more details.
28 extern struct state st_null;
29 static struct state *st_back;
31 static SDL_Rect **modes;
33 /*---------------------------------------------------------------------------*/
37 static int resol_action(int i)
41 audio_play("snd/menu.ogg", 1.0f);
52 r = video_mode(config_get_d(CONFIG_FULLSCREEN),
53 modes[i]->w, modes[i]->h);
54 goto_state(&st_resol);
61 static int fill_row(int id, SDL_Rect **modes, int i, int n)
72 sprintf(label, "%d x %d", modes[i]->w, modes[i]->h);
74 complete = fill_row(id, modes, i + 1, n - 1);
76 gui_state(id, label, GUI_SML, i,
77 config_get_d(CONFIG_WIDTH) == modes[i]->w &&
78 config_get_d(CONFIG_HEIGHT) == modes[i]->h);
82 for (; n; gui_space(id), n--);
89 static int resol_gui(void)
93 if ((id = gui_vstack(0)))
95 if ((jd = gui_harray(id)))
97 gui_label(jd, _("Resolution"), GUI_SML, GUI_ALL, 0, 0);
99 gui_start(jd, _("Back"), GUI_SML, RESOL_BACK, 0);
108 for (i = 0; fill_row(gui_harray(id), modes, i, 4); i += 4);
111 gui_layout(id, 0, 0);
117 static int resol_enter(struct state *st, struct state *prev)
121 /* Note the parent screen if not done yet. */
126 back_init("back/gui.png");
128 modes = SDL_ListModes(NULL, SDL_OPENGL | SDL_FULLSCREEN);
130 if (modes == (SDL_Rect **) -1)
133 audio_music_fade_to(0.5f, "bgm/inter.ogg");
138 static void resol_leave(struct state *st, struct state *next, int id)
144 static void resol_paint(int id, float st)
146 video_push_persp((float) config_get_d(CONFIG_VIEW_FOV), 0.1f, FAR_DIST);
154 static void resol_timer(int id, float dt)
159 static void resol_point(int id, int x, int y, int dx, int dy)
161 gui_pulse(gui_point(id, x, y), 1.2f);
164 static void resol_stick(int id, int a, float v, int bump)
166 gui_pulse(gui_stick(id, a, v, bump), 1.2f);
169 static int resol_click(int b, int d)
171 if (b == SDL_BUTTON_LEFT && d == 1)
172 return resol_action(gui_token(gui_click()));
176 static int resol_keybd(int c, int d)
178 return (d && c == SDLK_ESCAPE) ? resol_action(RESOL_BACK) : 1;
181 static int resol_buttn(int b, int d)
185 if (config_tst_d(CONFIG_JOYSTICK_BUTTON_A, b))
186 return resol_action(gui_token(gui_click()));
187 if (config_tst_d(CONFIG_JOYSTICK_BUTTON_B, b))
188 return resol_action(RESOL_BACK);
189 if (config_tst_d(CONFIG_JOYSTICK_BUTTON_EXIT, b))
190 return resol_action(RESOL_BACK);
195 /*---------------------------------------------------------------------------*/
198 struct state st_resol = {