shithub: choc

Download patch

ref: 83fb03a0e09920ec324734e9ae3a6cd15fb041e7
parent: afb3bd1405e8c9543be4c1db529c9c8f84c6bd69
author: Simon Howard <[email protected]>
date: Sun Jan 30 20:25:47 EST 2011

When large numbers of screen resolutions are detected, increase the
number of columns in the mode list to fit them all on-screen. Remove
superfluous left-side spacing from the checkbox and radio button widgets
so that the modes can be packed closer together.

Subversion-branch: /trunk/chocolate-doom
Subversion-revision: 2242

--- a/setup/display.c
+++ b/setup/display.c
@@ -89,6 +89,7 @@
 // List of fullscreen modes generated at runtime
 
 static screen_mode_t *screen_modes_fullscreen = NULL;
+static int num_screen_modes_fullscreen;
 
 static int vidmode = 0;
 
@@ -403,6 +404,8 @@
         memcpy(m1, m2, sizeof(screen_mode_t));
         memcpy(m2, &m, sizeof(screen_mode_t));
     }
+
+    num_screen_modes_fullscreen = num_modes;
 }
 
 static int FindBestMode(screen_mode_t *modes)
@@ -469,7 +472,7 @@
     // Build the table
  
     TXT_ClearTable(modes_table);
-    TXT_SetColumnWidths(modes_table, 15, 15, 15);
+    TXT_SetColumnWidths(modes_table, 14, 14, 14, 14, 14);
 
     for (i=0; modes[i].w != 0; ++i) 
     {
@@ -573,6 +576,8 @@
     txt_checkbox_t *fs_checkbox;
     txt_checkbox_t *ar_checkbox;
     txt_dropdown_list_t *bpp_selector;
+    int num_columns;
+    int window_y;
 
     // What color depths are supported?  Generate supported_bpps array
     // and set selected_bpp to match the current value of screen_bpp.
@@ -592,9 +597,6 @@
     
     window = TXT_NewWindow("Display Configuration");
 
-    TXT_SetWindowPosition(window, TXT_HORIZ_CENTER, TXT_VERT_TOP, 
-                                  TXT_SCREEN_W / 2, 5);
-
     TXT_AddWidgets(window, 
                    fs_checkbox = TXT_NewCheckBox("Fullscreen", &fullscreen),
                    ar_checkbox = TXT_NewCheckBox("Correct aspect ratio",
@@ -601,7 +603,37 @@
                                                  &aspect_ratio_correct),
                    NULL);
 
-    modes_table = TXT_NewTable(3);
+    // Some machines can have lots of video modes.  This tries to
+    // keep a limit of six lines by increasing the number of
+    // columns.  In extreme cases, the window is moved up slightly.
+
+    BuildFullscreenModesList();
+
+    window_y = 5;
+
+    if (num_screen_modes_fullscreen <= 18)
+    {
+        num_columns = 3;
+    }
+    else if (num_screen_modes_fullscreen <= 24)
+    {
+        num_columns = 4;
+    }
+    else
+    {
+        num_columns = 5;
+        window_y -= 3;
+    }
+
+    modes_table = TXT_NewTable(num_columns);
+
+    // The window is set at a fixed vertical position.  This keeps
+    // the top of the window stationary when switching between
+    // fullscreen and windowed mode (which causes the window's
+    // height to change).
+
+    TXT_SetWindowPosition(window, TXT_HORIZ_CENTER, TXT_VERT_TOP, 
+                                  TXT_SCREEN_W / 2, window_y);
 
     // On Windows, there is an extra control to change between 
     // the Windows GDI and DirectX video drivers.
--- a/textscreen/txt_checkbox.c
+++ b/textscreen/txt_checkbox.c
@@ -34,9 +34,9 @@
 {
     TXT_CAST_ARG(txt_checkbox_t, checkbox);
 
-    // Minimum width is the string length + two spaces for padding
+    // Minimum width is the string length + right-side space for padding
 
-    checkbox->widget.w = strlen(checkbox->label) + 6;
+    checkbox->widget.w = strlen(checkbox->label) + 5;
     checkbox->widget.h = 1;
 }
 
@@ -50,7 +50,7 @@
 
     TXT_BGColor(TXT_COLOR_BLUE, 0);
     TXT_FGColor(TXT_COLOR_BRIGHT_CYAN);
-    TXT_DrawString(" (");
+    TXT_DrawString("(");
 
     TXT_FGColor(TXT_COLOR_BRIGHT_WHITE);
 
@@ -76,7 +76,7 @@
 
     TXT_DrawString(checkbox->label);
     
-    for (i=strlen(checkbox->label); i < w-6; ++i)
+    for (i=strlen(checkbox->label); i < w-5; ++i)
     {
         TXT_DrawString(" ");
     }
--- a/textscreen/txt_radiobutton.c
+++ b/textscreen/txt_radiobutton.c
@@ -34,9 +34,9 @@
 {
     TXT_CAST_ARG(txt_radiobutton_t, radiobutton);
 
-    // Minimum width is the string length + two spaces for padding
+    // Minimum width is the string length + right-side spaces for padding
 
-    radiobutton->widget.w = strlen(radiobutton->label) + 6;
+    radiobutton->widget.w = strlen(radiobutton->label) + 5;
     radiobutton->widget.h = 1;
 }
 
@@ -50,7 +50,7 @@
 
     TXT_BGColor(TXT_COLOR_BLUE, 0);
     TXT_FGColor(TXT_COLOR_BRIGHT_CYAN);
-    TXT_DrawString(" (");
+    TXT_DrawString("(");
 
     TXT_FGColor(TXT_COLOR_BRIGHT_WHITE);
 
@@ -76,7 +76,7 @@
 
     TXT_DrawString(radiobutton->label);
     
-    for (i=strlen(radiobutton->label); i < w-6; ++i)
+    for (i=strlen(radiobutton->label); i < w-5; ++i)
     {
         TXT_DrawString(" ");
     }