2 * Copyright (C) 2003 Robert Kooima
4 * NEVERBALL 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.
26 extern struct state st_conf;
27 extern struct state st_null;
29 SDL_Rect ** resolutions;
31 /*---------------------------------------------------------------------------*/
35 static int resol_action(int i)
37 int f = config_get_d(CONFIG_FULLSCREEN);
48 r = config_mode(f, resolutions[i-1]->w, resolutions[i-1]->h);
56 static int resol_enter(void)
64 back_init("back/gui.png", config_get_d(CONFIG_GEOMETRY));
66 /* Get the current resolution. */
67 w = config_get_d(CONFIG_WIDTH);
68 h = config_get_d(CONFIG_HEIGHT);
70 /* Get the resolution list. */
71 resolutions = SDL_ListModes(NULL, SDL_OPENGL | SDL_FULLSCREEN);
73 if ((int)resolutions == -1)
76 printf("Any resolution\n");
78 else if (resolutions == NULL)
80 printf("No resolution\n");
83 if ((id = gui_harray(0)))
85 if ((jd = gui_varray(id)))
87 if ((kd = gui_harray(jd)))
89 gui_label(kd, _("Resolution"), GUI_SML, GUI_ALL, 0, 0);
91 gui_start(kd, _("Back"), GUI_SML, LANG_BACK, 0);
94 if (resolutions != NULL)
98 for(i=0; resolutions[i]; i++)
100 if (wp!=resolutions[i]->w || hp!=resolutions[i]->h)
103 wp = resolutions[i]->w;
104 hp = resolutions[i]->h;
105 sprintf(st, "%d x %d", wp, hp);
108 gui_state(kd, st, GUI_SML, i+1, (w==wp) && (h==hp));
117 gui_layout(id, 0, 0);
120 audio_music_fade_to(0.5f, "bgm/inter.ogg");
125 static void resol_leave(int id)
131 static void resol_paint(int id, float st)
133 config_push_persp((float) config_get_d(CONFIG_VIEW_FOV), 0.1f, FAR_DIST);
141 static void resol_timer(int id, float dt)
147 static void resol_point(int id, int x, int y, int dx, int dy)
149 gui_pulse(gui_point(id, x, y), 1.2f);
152 static void resol_stick(int id, int a, int v)
154 if (config_tst_d(CONFIG_JOYSTICK_AXIS_X, a))
155 gui_pulse(gui_stick(id, v, 0), 1.2f);
156 if (config_tst_d(CONFIG_JOYSTICK_AXIS_Y, a))
157 gui_pulse(gui_stick(id, 0, v), 1.2f);
160 static int resol_click(int b, int d)
163 return resol_action(gui_token(gui_click()));
167 static int resol_keybd(int c, int d)
169 return (d && c == SDLK_ESCAPE) ? goto_state(&st_conf) : 1;
172 static int resol_buttn(int b, int d)
176 if (config_tst_d(CONFIG_JOYSTICK_BUTTON_A, b))
177 return resol_action(gui_token(gui_click()));
178 if (config_tst_d(CONFIG_JOYSTICK_BUTTON_B, b))
179 return goto_state(&st_conf);
180 if (config_tst_d(CONFIG_JOYSTICK_BUTTON_EXIT, b))
181 return goto_state(&st_conf);
186 /*---------------------------------------------------------------------------*/
189 struct state st_resol = {