From 503ab368a2fb8a6d2b4432856dba87cefc3a0c95 Mon Sep 17 00:00:00 2001 From: Yamagi Burmeister Date: Wed, 30 Aug 2017 15:05:02 +0200 Subject: [PATCH] Decouple horplus and fov in the video menu. Until now the video menu enforced: * fov set to 90 and horplus set to 1 * fov set to something other than 90 and horplus to 0 If the user hat configured another configuration through the console the menu would reset it, even if only unrelated changes are applied. With this change horplus is ignored by the menu and only fov is altered. The rationale behind this is that most users want horplus enabled and all others can disable it through the console. This is believed to fix issue #225. --- src/client/menu/videomenu.c | 112 ++++++------------------------------ 1 file changed, 16 insertions(+), 96 deletions(-) diff --git a/src/client/menu/videomenu.c b/src/client/menu/videomenu.c index 2a5f4d97..331dbf78 100644 --- a/src/client/menu/videomenu.c +++ b/src/client/menu/videomenu.c @@ -49,9 +49,9 @@ static menuframework_s s_opengl_menu; static menulist_s s_renderer_list; static menulist_s s_mode_list; -static menulist_s s_aspect_list; static menulist_s s_uiscale_list; static menuslider_s s_brightness_slider; +static menuslider_s s_fov_slider; static menulist_s s_fs_box; static menulist_s s_vsync_list; static menulist_s s_af_list; @@ -109,6 +109,12 @@ BrightnessCallback(void *s) Cvar_SetValue("vid_gamma", gamma); } +static void +FOVCallback(void *s) { + menuslider_s *slider = (menuslider_s *)s; + Cvar_SetValue("fov", slider->curvalue); +} + static void AnisotropicCallback(void *s) { @@ -165,56 +171,6 @@ ApplyChanges(void *unused) Cvar_SetValue("gl_mode", -1); } - /* horplus */ - if (s_aspect_list.curvalue == 0) - { - if (horplus->value != 1) - { - Cvar_SetValue("horplus", 1); - } - } - else - { - if (horplus->value != 0) - { - Cvar_SetValue("horplus", 0); - } - } - - /* fov */ - if (s_aspect_list.curvalue == 0 || s_aspect_list.curvalue == 1) - { - if (fov->value != 90) - { - /* Restarts automatically */ - Cvar_SetValue("fov", 90); - } - } - else if (s_aspect_list.curvalue == 2) - { - if (fov->value != 86) - { - /* Restarts automatically */ - Cvar_SetValue("fov", 86); - } - } - else if (s_aspect_list.curvalue == 3) - { - if (fov->value != 100) - { - /* Restarts automatically */ - Cvar_SetValue("fov", 100); - } - } - else if (s_aspect_list.curvalue == 4) - { - if (fov->value != 106) - { - /* Restarts automatically */ - Cvar_SetValue("fov", 106); - } - } - /* UI scaling */ if (s_uiscale_list.curvalue == 0) { @@ -309,16 +265,6 @@ VID_MenuInit(void) 0 }; - static const char *aspect_names[] = { - "auto", - "4:3", - "5:4", - "16:10", - "16:9", - "custom", - 0 - }; - static const char *uiscale_names[] = { "auto", "1x", @@ -378,11 +324,6 @@ VID_MenuInit(void) crosshair_scale = Cvar_Get("crosshair_scale", "-1", CVAR_ARCHIVE); } - if (!horplus) - { - horplus = Cvar_Get("horplus", "1", CVAR_ARCHIVE); - } - if (!fov) { fov = Cvar_Get("fov", "90", CVAR_USERINFO | CVAR_ARCHIVE); @@ -446,35 +387,14 @@ VID_MenuInit(void) s_brightness_slider.maxvalue = 20; s_brightness_slider.curvalue = vid_gamma->value * 10; - s_aspect_list.generic.type = MTYPE_SPINCONTROL; - s_aspect_list.generic.name = "aspect ratio"; - s_aspect_list.generic.x = 0; - s_aspect_list.generic.y = (y += 20); - s_aspect_list.itemnames = aspect_names; - if (horplus->value == 1) - { - s_aspect_list.curvalue = 0; - } - else if (fov->value == 90) - { - s_aspect_list.curvalue = 1; - } - else if (fov->value == 86) - { - s_aspect_list.curvalue = 2; - } - else if (fov->value == 100) - { - s_aspect_list.curvalue = 3; - } - else if (fov->value == 106) - { - s_aspect_list.curvalue = 4; - } - else - { - s_aspect_list.curvalue = GetCustomValue(&s_aspect_list); - } + s_fov_slider.generic.type = MTYPE_SLIDER; + s_fov_slider.generic.x = 0; + s_fov_slider.generic.y = (y += 10); + s_fov_slider.generic.name = "field of view"; + s_fov_slider.generic.callback = FOVCallback; + s_fov_slider.minvalue = 60; + s_fov_slider.maxvalue = 120; + s_fov_slider.curvalue = fov->value; s_uiscale_list.generic.type = MTYPE_SPINCONTROL; s_uiscale_list.generic.name = "ui scale"; @@ -564,7 +484,7 @@ VID_MenuInit(void) Menu_AddItem(&s_opengl_menu, (void *)&s_renderer_list); Menu_AddItem(&s_opengl_menu, (void *)&s_mode_list); Menu_AddItem(&s_opengl_menu, (void *)&s_brightness_slider); - Menu_AddItem(&s_opengl_menu, (void *)&s_aspect_list); + Menu_AddItem(&s_opengl_menu, (void *)&s_fov_slider); Menu_AddItem(&s_opengl_menu, (void *)&s_uiscale_list); Menu_AddItem(&s_opengl_menu, (void *)&s_fs_box); Menu_AddItem(&s_opengl_menu, (void *)&s_vsync_list);