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_conf;
29 extern struct state st_null;
31 SDL_Rect ** resolutions;
33 /*---------------------------------------------------------------------------*/
37 static int resol_action(int i)
39 int f = config_get_d(CONFIG_FULLSCREEN);
50 r = config_mode(f, resolutions[i-1]->w, resolutions[i-1]->h);
58 static int resol_enter(void)
66 back_init("back/gui.png", config_get_d(CONFIG_GEOMETRY));
68 /* Get the current resolution. */
69 w = config_get_d(CONFIG_WIDTH);
70 h = config_get_d(CONFIG_HEIGHT);
72 /* Get the resolution list. */
73 resolutions = SDL_ListModes(NULL, SDL_OPENGL | SDL_FULLSCREEN);
75 if ((int)resolutions == -1)
78 printf("Any resolution\n");
80 else if (resolutions == NULL)
82 printf("No resolution\n");
85 if ((id = gui_harray(0)))
87 if ((jd = gui_varray(id)))
89 if ((kd = gui_harray(jd)))
91 gui_label(kd, _("Resolution"), GUI_SML, GUI_ALL, 0, 0);
93 gui_start(kd, _("Back"), GUI_SML, LANG_BACK, 0);
96 if (resolutions != NULL)
100 for(i=0; resolutions[i]; i++)
102 if (wp!=resolutions[i]->w || hp!=resolutions[i]->h)
105 wp = resolutions[i]->w;
106 hp = resolutions[i]->h;
107 sprintf(st, "%d x %d", wp, hp);
110 gui_state(kd, st, GUI_SML, i+1, (w==wp) && (h==hp));
119 gui_layout(id, 0, 0);
122 audio_music_fade_to(0.5f, "bgm/inter.ogg");
127 static void resol_leave(int id)
133 static void resol_paint(int id, float st)
135 config_push_persp((float) config_get_d(CONFIG_VIEW_FOV), 0.1f, FAR_DIST);
143 static void resol_timer(int id, float dt)
149 static void resol_point(int id, int x, int y, int dx, int dy)
151 gui_pulse(gui_point(id, x, y), 1.2f);
154 static void resol_stick(int id, int a, int v)
156 if (config_tst_d(CONFIG_JOYSTICK_AXIS_X, a))
157 gui_pulse(gui_stick(id, v, 0), 1.2f);
158 if (config_tst_d(CONFIG_JOYSTICK_AXIS_Y, a))
159 gui_pulse(gui_stick(id, 0, v), 1.2f);
162 static int resol_click(int b, int d)
165 return resol_action(gui_token(gui_click()));
169 static int resol_keybd(int c, int d)
171 return (d && c == SDLK_ESCAPE) ? goto_state(&st_conf) : 1;
174 static int resol_buttn(int b, int d)
178 if (config_tst_d(CONFIG_JOYSTICK_BUTTON_A, b))
179 return resol_action(gui_token(gui_click()));
180 if (config_tst_d(CONFIG_JOYSTICK_BUTTON_B, b))
181 return goto_state(&st_conf);
182 if (config_tst_d(CONFIG_JOYSTICK_BUTTON_EXIT, b))
183 return goto_state(&st_conf);
188 /*---------------------------------------------------------------------------*/
191 struct state st_resol = {