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 static SDL_Rect **modes;
33 /*---------------------------------------------------------------------------*/
37 static int resol_action(int i)
49 r = config_mode(config_get_d(CONFIG_FULLSCREEN),
50 modes[i]->w, modes[i]->h);
51 goto_state(&st_resol);
58 static int resol_enter(void)
62 back_init("back/gui.png", config_get_d(CONFIG_GEOMETRY));
64 modes = SDL_ListModes(NULL, SDL_OPENGL | SDL_FULLSCREEN);
66 if (modes == (SDL_Rect **) -1)
69 if ((id = gui_vstack(0)))
71 if ((jd = gui_harray(id)))
73 gui_label(jd, _("Resolution"), GUI_SML, GUI_ALL, 0, 0);
75 gui_start(jd, _("Back"), GUI_SML, RESOL_BACK, 0);
84 for (i = 0; modes[i]; i++)
88 sprintf(s, "%d x %d", modes[i]->w, modes[i]->h);
93 gui_state(jd, s, GUI_SML, i,
94 config_get_d(CONFIG_WIDTH) == modes[i]->w &&
95 config_get_d(CONFIG_HEIGHT) == modes[i]->h);
98 for(; i % 4 != 0; i++)
102 gui_layout(id, 0, 0);
105 audio_music_fade_to(0.5f, "bgm/inter.ogg");
110 static void resol_leave(int id)
116 static void resol_paint(int id, float st)
118 config_push_persp((float) config_get_d(CONFIG_VIEW_FOV), 0.1f, FAR_DIST);
126 static void resol_timer(int id, float dt)
131 static void resol_point(int id, int x, int y, int dx, int dy)
133 gui_pulse(gui_point(id, x, y), 1.2f);
136 static void resol_stick(int id, int a, int v)
138 if (config_tst_d(CONFIG_JOYSTICK_AXIS_X, a))
139 gui_pulse(gui_stick(id, v, 0), 1.2f);
140 if (config_tst_d(CONFIG_JOYSTICK_AXIS_Y, a))
141 gui_pulse(gui_stick(id, 0, v), 1.2f);
144 static int resol_click(int b, int d)
147 return resol_action(gui_token(gui_click()));
151 static int resol_keybd(int c, int d)
153 return (d && c == SDLK_ESCAPE) ? goto_state(&st_conf) : 1;
156 static int resol_buttn(int b, int d)
160 if (config_tst_d(CONFIG_JOYSTICK_BUTTON_A, b))
161 return resol_action(gui_token(gui_click()));
162 if (config_tst_d(CONFIG_JOYSTICK_BUTTON_B, b))
163 return goto_state(&st_conf);
164 if (config_tst_d(CONFIG_JOYSTICK_BUTTON_EXIT, b))
165 return goto_state(&st_conf);
170 /*---------------------------------------------------------------------------*/
173 struct state st_resol = {