From 65ed2a3208db93eef0f25f5d9c046c77cb7eb980 Mon Sep 17 00:00:00 2001 From: Simon Howard Date: Mon, 4 Feb 2008 22:43:11 +0000 Subject: Update chocolate-setup to the new screen mode config system. Subversion-branch: /trunk/chocolate-doom Subversion-revision: 1042 --- setup/configfile.c | 3 +- setup/display.c | 258 ++++++++++++++++++++++++++++++++++--------------- setup/display.h | 2 +- textscreen/txt_table.c | 19 +++- textscreen/txt_table.h | 1 + 5 files changed, 198 insertions(+), 85 deletions(-) diff --git a/setup/configfile.c b/setup/configfile.c index b1db1a09..bbde0bbb 100644 --- a/setup/configfile.c +++ b/setup/configfile.c @@ -254,7 +254,8 @@ static default_t extra_defaults_list[] = {"fullscreen", &fullscreen, DEFAULT_INT, 0, 0}, {"aspect_ratio_correct", &aspect_ratio_correct, DEFAULT_INT, 0, 0}, {"startup_delay", &startup_delay, DEFAULT_INT, 0, 0}, - {"screenmultiply", &screenmultiply, DEFAULT_INT, 0, 0}, + {"screen_width", &screen_width, DEFAULT_INT, 0, 0}, + {"screen_height", &screen_height, DEFAULT_INT, 0, 0}, {"grabmouse", &grabmouse, DEFAULT_INT, 0, 0}, {"novert", &novert, DEFAULT_INT, 0, 0}, {"mouse_acceleration", &mouse_acceleration, DEFAULT_FLOAT, 0, 0}, diff --git a/setup/display.c b/setup/display.c index 07be4be9..f4e38d56 100644 --- a/setup/display.c +++ b/setup/display.c @@ -27,44 +27,50 @@ typedef struct { - char *description; - char *description_4_3; - int screenmultiply; - txt_radiobutton_t *widget; -} vidmode_t; + int w, h; +} screen_mode_t; -enum -{ - RATIO_CORRECT_NONE, - RATIO_CORRECT_LETTERBOX, - RATIO_CORRECT_STRETCH, - NUM_RATIO_CORRECT, -}; +// List of aspect ratio-uncorrected modes -static vidmode_t modes[] = +static screen_mode_t screen_modes_unscaled[] = { - { "320x200", "320x240", 1, NULL }, - { "960x600", "960x720", 3, NULL }, - { "640x400", "640x480", 2, NULL }, - { "1280x800", "1280x960", 4, NULL }, - { "1600x1000", "1600x1200", 5, NULL }, - { NULL, NULL, 0, NULL }, + { 320, 200 }, + { 640, 400 }, + { 960, 600 }, + { 1280, 800 }, + { 1600, 1000 }, + { 0, 0}, }; -static char *aspect_ratio_strings[] = +// List of aspect ratio-corrected modes + +static screen_mode_t screen_modes_scaled[] = { - "Disabled", - "Letterbox mode", - "Stretch to 4:3", + { 256, 200 }, + { 320, 240 }, + { 512, 400 }, + { 640, 480 }, + { 800, 600 }, + { 960, 720 }, + { 1024, 800 }, + { 1280, 960 }, + { 1280, 1000 }, + { 1600, 1200 }, + { 0, 0}, }; +// List of fullscreen modes generated at runtime + +static screen_mode_t *screen_modes_fullscreen = NULL; + static int vidmode = 0; char *video_driver = ""; int autoadjust_video_settings = 1; -int aspect_ratio_correct = RATIO_CORRECT_NONE; +int aspect_ratio_correct = 1; int fullscreen = 1; -int screenmultiply = 1; +int screen_width = 320; +int screen_height = 200; int startup_delay = 0; int show_endoom = 1; @@ -103,81 +109,182 @@ static void UpdateVideoDriver(TXT_UNCAST_ARG(widget), TXT_UNCAST_ARG(unused)) #endif -// Given the video settings (fullscreen, screenmultiply, etc), find the -// current video mode +static void ModeSelected(TXT_UNCAST_ARG(widget), TXT_UNCAST_ARG(mode)) +{ + TXT_CAST_ARG(screen_mode_t, mode); -static void SetCurrentMode(void) + screen_width = mode->w; + screen_height = mode->h; +} + +static int GoodFullscreenMode(screen_mode_t *mode) { - int i; + int w, h; - vidmode = 0; + w = mode->w; + h = mode->h; - for (i=0; modes[i].description != NULL; ++i) + // 320x200 and 640x400 are always good + + if ((w == 320 && h == 200) || (w == 640 && h == 400)) { - if (screenmultiply == modes[i].screenmultiply) - { - vidmode = i; - break; - } + return 1; } + + return w >= 640 && h >= 480; } -static void ModeSelected(TXT_UNCAST_ARG(widget), TXT_UNCAST_ARG(mode)) +// Build screen_modes_fullscreen + +static void BuildFullscreenModesList(void) { - TXT_CAST_ARG(vidmode_t, mode); + SDL_Rect **modes; + screen_mode_t *m1; + screen_mode_t *m2; + screen_mode_t m; + int num_modes; + int i; + + if (screen_modes_fullscreen != NULL) + { + return; + } - screenmultiply = mode->screenmultiply; + // Get a list of fullscreen modes and find out how many + // modes are in the list. + + modes = SDL_ListModes(NULL, SDL_FULLSCREEN); + + for (num_modes=0; modes[num_modes] != NULL; ++num_modes); + + // Build the screen_modes_fullscreen array + + screen_modes_fullscreen = malloc(sizeof(screen_mode_t) * (num_modes + 1)); + + for (i=0; iw; + screen_modes_fullscreen[i].h = modes[i]->h; + } + + screen_modes_fullscreen[i].w = 0; + screen_modes_fullscreen[i].h = 0; + + // Reverse the order of the modes list (smallest modes first) + + for (i=0; inum_widgets; ++i) + for (i=table->columns; inum_widgets; ++i) { if (table->widgets[i] != NULL) { @@ -48,9 +52,16 @@ static void TXT_TableDestructor(TXT_UNCAST_ARG(table)) } } - // Free table resources + // Shrink the table to just the column strut widgets + + table->num_widgets = table->columns; +} + +static void TXT_TableDestructor(TXT_UNCAST_ARG(table)) +{ + TXT_CAST_ARG(txt_table_t, table); - free(table->widgets); + TXT_ClearTable(table); } static int TableRows(txt_table_t *table) diff --git a/textscreen/txt_table.h b/textscreen/txt_table.h index c3a3c5a8..d42e9adb 100644 --- a/textscreen/txt_table.h +++ b/textscreen/txt_table.h @@ -53,6 +53,7 @@ void TXT_AddWidget(TXT_UNCAST_ARG(table), TXT_UNCAST_ARG(widget)); void TXT_AddWidgets(TXT_UNCAST_ARG(table), ...); int TXT_SelectWidget(TXT_UNCAST_ARG(table), TXT_UNCAST_ARG(widget)); void TXT_SetColumnWidths(TXT_UNCAST_ARG(table), ...); +void TXT_ClearTable(TXT_UNCAST_ARG(table)); #endif /* #ifndef TXT_TABLE_T */ -- cgit v1.2.3