X-Git-Url: http://vcs.maemo.org/git/?a=blobdiff_plain;f=share%2Fst_resol.c;h=e2940469130f4aeb5a2070ce1a86c01d2dc190ea;hb=c02ae9f8fce350c74e6ac7d281f03857c44964a7;hp=1301ae5612ade1d9689afedbfa22c045a3bc0b5f;hpb=57bccfdd5bbc6aca65b3bfe233a3c2f33120777e;p=neverball diff --git a/share/st_resol.c b/share/st_resol.c index 1301ae5..e294046 100644 --- a/share/st_resol.c +++ b/share/st_resol.c @@ -1,5 +1,6 @@ -/* - * Copyright (C) 2003 Robert Kooima +/* + * Copyright (C) 2003 Robert Kooima - 2006 Jean Privat + * Part of the Neverball Project http://icculus.org/neverball/ * * NEVERBALL is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published @@ -12,6 +13,7 @@ * General Public License for more details. */ + #include #include "gui.h" @@ -26,27 +28,27 @@ extern struct state st_conf; extern struct state st_null; -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); + goto_state(&st_null); + r = config_mode(config_get_d(CONFIG_FULLSCREEN), + modes[i]->w, modes[i]->h); + goto_state(&st_resol); break; } @@ -55,65 +57,45 @@ static int resol_action(int i) 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); - - /* Get the resolution list. */ - resolutions = SDL_ListModes(NULL, SDL_OPENGL | SDL_FULLSCREEN); + modes = SDL_ListModes(NULL, SDL_OPENGL | SDL_FULLSCREEN); - if ((int)resolutions == -1) - { - resolutions = NULL; - printf("Any resolution\n"); - } - else if (resolutions == NULL) - { - printf("No resolution\n"); - } + if ((int) modes == -1) + modes = NULL; - if ((id = gui_harray(0))) + if ((id = gui_vstack(0))) { - if ((jd = gui_varray(id))) + 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 (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]; + + 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); } - - 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); - } + + for(; i % 4 != 0; i++) + gui_space(jd); } + gui_layout(id, 0, 0); } @@ -141,7 +123,6 @@ static void resol_paint(int id, float st) 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)