X-Git-Url: http://vcs.maemo.org/git/?a=blobdiff_plain;f=share%2Fst_resol.c;h=522af1eaa2ed933dc9f5365ffb816d555cbe59ac;hb=141b67a7ee425a9bd3aab8831988f52f63ac1859;hp=ad3f75f97b52082f312177b3ec3482ab1b43bdb0;hpb=d2c9bca9aace20e142d510ed84587ac64914eede;p=neverball diff --git a/share/st_resol.c b/share/st_resol.c index ad3f75f..522af1e 100644 --- a/share/st_resol.c +++ b/share/st_resol.c @@ -22,100 +22,99 @@ #include "part.h" #include "audio.h" #include "config.h" +#include "video.h" #include "st_resol.h" 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; - + + audio_play("snd/menu.ogg", 1.0f); + 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 = video_mode(config_get_d(CONFIG_FULLSCREEN), + modes[i]->w, modes[i]->h); + goto_state(&st_resol); break; } return r; } -static int resol_enter(void) +static int fill_row(int id, SDL_Rect **modes, int i, int n) { - int id, jd, kd; - int i; - int w, h; - int wp, hp; - int c; + int complete; - 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); + if (n == 0) + return 1; - if ((int)resolutions == -1) + if (modes[i]) { - resolutions = NULL; - printf("Any resolution\n"); + char label[20]; + + sprintf(label, "%d x %d", modes[i]->w, modes[i]->h); + + complete = fill_row(id, modes, i + 1, n - 1); + + gui_state(id, label, GUI_SML, i, + config_get_d(CONFIG_WIDTH) == modes[i]->w && + config_get_d(CONFIG_HEIGHT) == modes[i]->h); } - else if (resolutions == NULL) + else { - printf("No resolution\n"); + for (; n; gui_space(id), n--); + complete = 0; } - if ((id = gui_harray(0))) + return complete; +} + +static int resol_enter(void) +{ + int id, jd; + + back_init("back/gui.png", config_get_d(CONFIG_GEOMETRY)); + + modes = SDL_ListModes(NULL, SDL_OPENGL | SDL_FULLSCREEN); + + if (modes == (SDL_Rect **) -1) + modes = NULL; + + if ((id = gui_vstack(0))) { - if ((jd = gui_varray(id))) + if ((jd = gui_harray(id))) { - if ((kd = gui_harray(jd))) - { - gui_label(kd, _("Resolution"), GUI_SML, GUI_ALL, 0, 0); - gui_filler(kd); - gui_start(kd, _("Back"), GUI_SML, LANG_BACK, 0); - } - - 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); - } + gui_label(jd, _("Resolution"), GUI_SML, GUI_ALL, 0, 0); + gui_space(jd); + gui_start(jd, _("Back"), GUI_SML, RESOL_BACK, 0); } + + gui_space(id); + + if (modes) + { + int i; + + for (i = 0; fill_row(gui_harray(id), modes, i, 4); i += 4); + } + gui_layout(id, 0, 0); } @@ -132,18 +131,17 @@ static void resol_leave(int id) static void resol_paint(int id, float st) { - config_push_persp((float) config_get_d(CONFIG_VIEW_FOV), 0.1f, FAR_DIST); + video_push_persp((float) config_get_d(CONFIG_VIEW_FOV), 0.1f, FAR_DIST); { back_draw(0); } - config_pop_matrix(); + video_pop_matrix(); gui_paint(id); } 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) @@ -161,7 +159,7 @@ static void resol_stick(int id, int a, int v) static int resol_click(int b, int d) { - if (b < 0 && d == 1) + if (b == SDL_BUTTON_LEFT && d == 1) return resol_action(gui_token(gui_click())); return 1; } @@ -195,6 +193,7 @@ struct state st_resol = { resol_timer, resol_point, resol_stick, + NULL, resol_click, resol_keybd, resol_buttn,