#include "part.h"
#include "audio.h"
#include "config.h"
+#include "video.h"
#include "st_resol.h"
{
int r = 1;
+ audio_play("snd/menu.ogg", 1.0f);
+
switch (i)
{
case RESOL_BACK:
default:
goto_state(&st_null);
- r = config_mode(config_get_d(CONFIG_FULLSCREEN),
- modes[i]->w, modes[i]->h);
+ r = video_mode(config_get_d(CONFIG_FULLSCREEN),
+ modes[i]->w, modes[i]->h);
goto_state(&st_resol);
break;
}
return r;
}
+static int fill_row(int id, SDL_Rect **modes, int i, int n)
+{
+ int complete;
+
+ if (n == 0)
+ return 1;
+
+ if (modes[i])
+ {
+ 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
+ {
+ for (; n; gui_space(id), n--);
+ complete = 0;
+ }
+
+ return complete;
+}
+
static int resol_enter(void)
{
int id, jd;
- int i;
back_init("back/gui.png", config_get_d(CONFIG_GEOMETRY));
modes = SDL_ListModes(NULL, SDL_OPENGL | SDL_FULLSCREEN);
- if ((int) modes == -1)
+ if (modes == (SDL_Rect **) -1)
modes = NULL;
if ((id = gui_vstack(0)))
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);
+ gui_space(jd);
+ gui_start(jd, _("Back"), GUI_SML, RESOL_BACK, 0);
}
+ gui_space(id);
+
if (modes)
{
- for(i = 0; modes[i]; i++)
- {
- 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);
- }
+ int i;
- for(; i % 4 != 0; i++)
- gui_space(jd);
+ for (i = 0; fill_row(gui_harray(id), modes, i, 4); i += 4);
}
gui_layout(id, 0, 0);
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)
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;
}
resol_timer,
resol_point,
resol_stick,
+ NULL,
resol_click,
resol_keybd,
resol_buttn,