summaryrefslogtreecommitdiff
path: root/src/setup/display.c
diff options
context:
space:
mode:
authorSimon Howard2011-09-11 23:40:44 +0000
committerSimon Howard2011-09-11 23:40:44 +0000
commitefd15d965dee947a04727bb62f4e2092cf28732f (patch)
tree730d99c1e88d5e3145e552ad69dec52d30026d01 /src/setup/display.c
parent4d17ab361e90a75dc6deefd37e6eb2ba0610b386 (diff)
parent11024d8214580d63ca7a9e70a121f5ff542a2fce (diff)
downloadchocolate-doom-efd15d965dee947a04727bb62f4e2092cf28732f.tar.gz
chocolate-doom-efd15d965dee947a04727bb62f4e2092cf28732f.tar.bz2
chocolate-doom-efd15d965dee947a04727bb62f4e2092cf28732f.zip
Merge from raven-branch.
Subversion-branch: /branches/strife-branch Subversion-revision: 2367
Diffstat (limited to 'src/setup/display.c')
-rw-r--r--src/setup/display.c222
1 files changed, 145 insertions, 77 deletions
diff --git a/src/setup/display.c b/src/setup/display.c
index df264749..d9b34ccc 100644
--- a/src/setup/display.c
+++ b/src/setup/display.c
@@ -527,25 +527,34 @@ static void UpdateBPP(TXT_UNCAST_ARG(widget), TXT_UNCAST_ARG(modes_table))
GenerateModesTable(NULL, modes_table);
}
-#if defined(_WIN32) && !defined(_WIN32_WCE)
+static void UpdateModeSeparator(TXT_UNCAST_ARG(widget),
+ TXT_UNCAST_ARG(separator))
+{
+ TXT_CAST_ARG(txt_separator_t, separator);
+
+ if (fullscreen)
+ {
+ TXT_SetSeparatorLabel(separator, "Screen mode");
+ }
+ else
+ {
+ TXT_SetSeparatorLabel(separator, "Window size");
+ }
+}
-static int win32_video_driver = 0;
+#if defined(_WIN32) && !defined(_WIN32_WCE)
-static char *win32_video_drivers[] =
-{
- "DirectX",
- "Windows GDI",
-};
+static int use_directx = 1;
static void SetWin32VideoDriver(void)
{
if (!strcmp(video_driver, "windib"))
{
- win32_video_driver = 1;
+ use_directx = 0;
}
else
{
- win32_video_driver = 0;
+ use_directx = 1;
}
}
@@ -553,13 +562,15 @@ static void UpdateVideoDriver(TXT_UNCAST_ARG(widget),
TXT_UNCAST_ARG(modes_table))
{
TXT_CAST_ARG(txt_table_t, modes_table);
- char *drivers[] =
- {
- "",
- "windib",
- };
- video_driver = drivers[win32_video_driver != 0];
+ if (use_directx)
+ {
+ video_driver = "";
+ }
+ else
+ {
+ video_driver = "windib";
+ }
// When the video driver is changed, we need to restart the textscreen
// library.
@@ -579,16 +590,72 @@ static void UpdateVideoDriver(TXT_UNCAST_ARG(widget),
#endif
+static void AdvancedDisplayConfig(TXT_UNCAST_ARG(widget),
+ TXT_UNCAST_ARG(modes_table))
+{
+ TXT_CAST_ARG(txt_table_t, modes_table);
+ txt_window_t *window;
+ txt_checkbox_t *ar_checkbox;
+
+ window = TXT_NewWindow("Advanced display options");
+
+ TXT_SetColumnWidths(window, 35);
+
+ TXT_AddWidgets(window,
+ ar_checkbox = TXT_NewCheckBox("Fix aspect ratio",
+ &aspect_ratio_correct),
+ NULL);
+
+ if (gamemission == heretic || gamemission == hexen)
+ {
+ TXT_AddWidget(window,
+ TXT_NewCheckBox("Graphical startup", &graphical_startup));
+ }
+
+ if (gamemission == doom || gamemission == heretic || gamemission == strife)
+ {
+ TXT_AddWidget(window,
+ TXT_NewCheckBox("Show ENDOOM screen on exit",
+ &show_endoom));
+ }
+
+ TXT_SignalConnect(ar_checkbox, "changed", GenerateModesTable, modes_table);
+
+ // On Windows, there is an extra control to change between
+ // the Windows GDI and DirectX video drivers.
+
+#if defined(_WIN32) && !defined(_WIN32_WCE)
+ {
+ txt_radiobutton_t *dx_button, *gdi_button;
+
+ TXT_AddWidgets(window,
+ TXT_NewSeparator("Windows video driver"),
+ dx_button = TXT_NewRadioButton("DirectX",
+ &use_directx, 1),
+ gdi_button = TXT_NewRadioButton("Windows GDI",
+ &use_directx, 0),
+ NULL);
+
+ TXT_SignalConnect(dx_button, "selected",
+ UpdateVideoDriver, modes_table);
+ TXT_SignalConnect(gdi_button, "selected",
+ UpdateVideoDriver, modes_table);
+ SetWin32VideoDriver();
+ }
+#endif
+}
void ConfigDisplay(void)
{
txt_window_t *window;
txt_table_t *modes_table;
+ txt_separator_t *modes_separator;
txt_table_t *bpp_table;
+ txt_window_action_t *advanced_button;
txt_checkbox_t *fs_checkbox;
- txt_checkbox_t *ar_checkbox;
- txt_dropdown_list_t *bpp_selector;
+ int i;
int num_columns;
+ int num_rows;
int window_y;
// What color depths are supported? Generate supported_bpps array
@@ -606,14 +673,8 @@ void ConfigDisplay(void)
}
// Open the window
-
- window = TXT_NewWindow("Display Configuration");
- TXT_AddWidgets(window,
- fs_checkbox = TXT_NewCheckBox("Fullscreen", &fullscreen),
- ar_checkbox = TXT_NewCheckBox("Correct aspect ratio",
- &aspect_ratio_correct),
- NULL);
+ window = TXT_NewWindow("Display Configuration");
// Some machines can have lots of video modes. This tries to
// keep a limit of six lines by increasing the number of
@@ -621,94 +682,101 @@ void ConfigDisplay(void)
BuildFullscreenModesList();
- window_y = 5;
-
- if (num_screen_modes_fullscreen <= 18)
+ if (num_screen_modes_fullscreen <= 24)
{
num_columns = 3;
}
- else if (num_screen_modes_fullscreen <= 24)
+ else if (num_screen_modes_fullscreen <= 40)
{
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).
+ // Build window:
- TXT_SetWindowPosition(window, TXT_HORIZ_CENTER, TXT_VERT_TOP,
- TXT_SCREEN_W / 2, window_y);
+ TXT_AddWidget(window,
+ fs_checkbox = TXT_NewCheckBox("Full screen", &fullscreen));
- // On Windows, there is an extra control to change between
- // the Windows GDI and DirectX video drivers.
-
-#if defined(_WIN32) && !defined(_WIN32_WCE)
+ if (num_supported_bpps > 1)
{
- txt_table_t *driver_table;
- txt_dropdown_list_t *driver_list;
-
- driver_table = TXT_NewTable(2);
-
- TXT_SetColumnWidths(driver_table, 20, 0);
-
- TXT_AddWidgets(driver_table,
- TXT_NewLabel("Video driver"),
- driver_list = TXT_NewDropdownList(&win32_video_driver,
- win32_video_drivers,
- 2),
+ TXT_AddWidgets(window,
+ TXT_NewSeparator("Color depth"),
+ bpp_table = TXT_NewTable(4),
NULL);
- TXT_SignalConnect(driver_list, "changed",
- UpdateVideoDriver, modes_table);
- SetWin32VideoDriver();
+ for (i = 0; i < num_supported_bpps; ++i)
+ {
+ txt_radiobutton_t *button;
- TXT_AddWidget(window, driver_table);
- }
-#endif
+ button = TXT_NewRadioButton(supported_bpps[i],
+ &selected_bpp, i);
- // Screen modes list
+ TXT_AddWidget(bpp_table, button);
+ TXT_SignalConnect(button, "selected", UpdateBPP, modes_table);
+ }
+ }
TXT_AddWidgets(window,
- TXT_NewSeparator("Screen mode"),
- bpp_table = TXT_NewTable(2),
+ modes_separator = TXT_NewSeparator(""),
modes_table,
- TXT_NewSeparator("Misc."),
NULL);
- if (gamemission == heretic || gamemission == hexen)
+ TXT_SignalConnect(fs_checkbox, "changed",
+ GenerateModesTable, modes_table);
+ TXT_SignalConnect(fs_checkbox, "changed",
+ UpdateModeSeparator, modes_separator);
+
+ // How many rows high will the configuration window be?
+ // Need to take into account number of fullscreen modes, and also
+ // number of supported pixel depths.
+ // The windowed modes list is four rows, so take the maximum of
+ // windowed and fullscreen.
+
+ num_rows = (num_screen_modes_fullscreen + num_columns - 1) / num_columns;
+
+ if (num_rows < 4)
{
- TXT_AddWidget(window,
- TXT_NewCheckBox("Graphical startup", &graphical_startup));
+ num_rows = 4;
}
- if (gamemission == doom || gamemission == heretic
- || gamemission == strife)
+ if (num_supported_bpps > 1)
{
- TXT_AddWidget(window,
- TXT_NewCheckBox("Show ENDOOM screen", &show_endoom));
+ num_rows += 2;
}
- TXT_AddWidgets(bpp_table,
- TXT_NewLabel("Color depth: "),
- bpp_selector = TXT_NewDropdownList(&selected_bpp,
- supported_bpps,
- num_supported_bpps),
- NULL);
+ if (num_rows < 14)
+ {
+ window_y = 8 - ((num_rows + 1) / 2);
+ }
+ else
+ {
+ window_y = 1;
+ }
+ // 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_SignalConnect(bpp_selector, "changed", UpdateBPP, modes_table);
- TXT_SignalConnect(fs_checkbox, "changed", GenerateModesTable, modes_table);
- TXT_SignalConnect(ar_checkbox, "changed", GenerateModesTable, modes_table);
+ TXT_SetWindowPosition(window, TXT_HORIZ_CENTER, TXT_VERT_TOP,
+ TXT_SCREEN_W / 2, window_y);
GenerateModesTable(NULL, modes_table);
+ UpdateModeSeparator(NULL, modes_separator);
+
+ // Button to open "advanced" window.
+ // Need to pass a pointer to the modes table, as some of the options
+ // in there trigger a rebuild of it.
+
+ advanced_button = TXT_NewWindowAction('a', "Advanced");
+ TXT_SetWindowAction(window, TXT_HORIZ_CENTER, advanced_button);
+ TXT_SignalConnect(advanced_button, "pressed",
+ AdvancedDisplayConfig, modes_table);
}
void BindDisplayVariables(void)