extern struct state st_conf;
extern struct state st_null;
-static SDL_Rect **resolutions;
+static SDL_Rect **modes;
/*---------------------------------------------------------------------------*/
-#define LANG_BACK 100
+#define RESOL_BACK -1
static int resol_action(int i)
{
- int f = config_get_d(CONFIG_FULLSCREEN);
int r = 1;
switch (i)
{
- case LANG_BACK:
+ case RESOL_BACK:
goto_state(&st_conf);
break;
default:
goto_state(&st_null);
- r = config_mode(f, resolutions[i - 1]->w, resolutions[i - 1]->h);
- goto_state(&st_conf);
+ r = config_mode(config_get_d(CONFIG_FULLSCREEN),
+ modes[i]->w, modes[i]->h);
+ goto_state(&st_resol);
break;
}
static int resol_enter(void)
{
- int id, jd, kd;
+ int id, jd;
int i;
- int w, h;
- int wp, hp;
- int c;
back_init("back/gui.png", config_get_d(CONFIG_GEOMETRY));
- /* Get the current resolution. */
- w = config_get_d(CONFIG_WIDTH);
- h = config_get_d(CONFIG_HEIGHT);
+ modes = SDL_ListModes(NULL, SDL_OPENGL | SDL_FULLSCREEN);
- /* Get the resolution list. */
- resolutions = SDL_ListModes(NULL, SDL_OPENGL | SDL_FULLSCREEN);
+ if ((int) modes == -1)
+ modes = NULL;
- if ((int)resolutions == -1)
- {
- resolutions = NULL;
- printf("Any resolution\n");
- }
- else if (resolutions == NULL)
+ if ((id = gui_vstack(0)))
{
- printf("No resolution\n");
- }
+ if ((jd = gui_harray(id)))
+ {
+ gui_label(jd, _("Resolution"), GUI_SML, GUI_ALL, 0, 0);
+ gui_filler(jd);
+ gui_start(jd, _("Back"), GUI_SML, RESOL_BACK, 0);
+ }
- if ((id = gui_harray(0)))
- {
- if ((jd = gui_varray(id)))
+ if (modes)
{
- if ((kd = gui_harray(jd)))
+ for(i = 0; modes[i]; i++)
{
- gui_label(kd, _("Resolution"), GUI_SML, GUI_ALL, 0, 0);
- gui_filler(kd);
- gui_start(kd, _("Back"), GUI_SML, LANG_BACK, 0);
- }
+ char s[20];
- if (resolutions != NULL)
- {
- hp = wp = -1;
- c = 0;
- for(i = 0; resolutions[i]; i++)
- {
- if (wp != resolutions[i]->w || hp != resolutions[i]->h)
- {
- static char st[100];
- wp = resolutions[i]->w;
- hp = resolutions[i]->h;
- sprintf(st, "%d x %d", wp, hp);
-
- if (c % 4 == 0)
- kd = gui_harray(jd);
-
- gui_state(kd, st, GUI_SML, i + 1,
- (w == wp) && (h == hp));
- c++;
- }
- }
-
- for(; c % 4 != 0; c++)
- gui_filler(kd);
+ sprintf(s, "%d x %d", modes[i]->w, modes[i]->h);
+
+ if (i % 4 == 0)
+ jd = gui_harray(id);
+
+ gui_state(jd, s, GUI_SML, i,
+ config_get_d(CONFIG_WIDTH) == modes[i]->w &&
+ config_get_d(CONFIG_HEIGHT) == modes[i]->h);
}
+
+ for(; i % 4 != 0; i++)
+ gui_space(jd);
}
+
gui_layout(id, 0, 0);
}
static void resol_timer(int id, float dt)
{
gui_timer(id, dt);
- audio_timer(dt);
}
static void resol_point(int id, int x, int y, int dx, int dy)