Add the renderer selection back to the video menu.

Remove the 'viewsize' slider to free one row. Use this row for the new
renderer selection. While at it reorder the items.
This commit is contained in:
Yamagi Burmeister 2017-04-10 21:37:08 +02:00 committed by Daniel Gibson
parent df86c46e57
commit b48108cf37

View file

@ -27,6 +27,7 @@
#include "../../client/header/client.h"
#include "../../client/menu/header/qmenu.h"
#include "header/qmenu.h"
extern void M_ForceMenuOff(void);
@ -39,16 +40,17 @@ static cvar_t *fov;
extern cvar_t *scr_viewsize;
extern cvar_t *vid_gamma;
extern cvar_t *vid_fullscreen;
extern cvar_t *vid_renderer;
static cvar_t *gl_swapinterval;
static cvar_t *gl_anisotropic;
static cvar_t *gl_msaa_samples;
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_screensize_slider;
static menuslider_s s_brightness_slider;
static menulist_s s_fs_box;
static menulist_s s_vsync_list;
@ -57,6 +59,26 @@ static menulist_s s_msaa_list;
static menuaction_s s_defaults_action;
static menuaction_s s_apply_action;
static int
GetRenderer(void)
{
/* First element in array is 'OpenGL 1.4' aka gl1.
Second element in array is 'OpenGL 3.2' aka gl3.
Third element in array is unknown renderer. */
if (Q_stricmp(vid_renderer->string, "gl1") == 0)
{
return 0;
}
else if (Q_stricmp(vid_renderer->string, "gl3") == 0)
{
return 1;
}
else
{
return 2;
}
}
static int
GetCustomValue(menulist_s *list)
{
@ -78,14 +100,6 @@ GetCustomValue(menulist_s *list)
return i;
}
static void
ScreenSizeCallback(void *s)
{
menuslider_s *slider = (menuslider_s *)s;
Cvar_SetValue("viewsize", slider->curvalue * 10);
}
static void
BrightnessCallback(void *s)
{
@ -121,6 +135,24 @@ ApplyChanges(void *unused)
{
qboolean restart = false;
/* Renderer */
if (s_renderer_list.curvalue != GetRenderer())
{
/* First element in array is 'OpenGL 1.4' aka gl1.
Second element in array is 'OpenGL 3.2' aka gl3.
Third element in array is unknown renderer. */
if (s_renderer_list.curvalue == 0)
{
Cvar_Set("vid_renderer", "gl1");
restart = true;
}
else if (s_renderer_list.curvalue == 1)
{
Cvar_Set("vid_renderer", "gl3");
restart = true;
}
}
/* custom mode */
if (s_mode_list.curvalue != GetCustomValue(&s_mode_list))
{
@ -241,32 +273,39 @@ VID_MenuInit(void)
{
int y = 0;
static const char *renderers[] = {
"[OpenGL 1.4]",
"[OpenGL 3.2]",
"[Custom ]",
0
};
static const char *resolutions[] = {
"[320 240 ]",
"[400 300 ]",
"[512 384 ]",
"[640 400 ]",
"[640 480 ]",
"[800 500 ]",
"[800 600 ]",
"[960 720 ]",
"[1024 480 ]",
"[1024 640 ]",
"[1024 768 ]",
"[1152 768 ]",
"[1152 864 ]",
"[1280 800 ]",
"[1280 720 ]",
"[1280 960 ]",
"[1280 1024]",
"[1366 768 ]",
"[1440 900 ]",
"[1600 1200]",
"[1680 1050]",
"[1920 1080]",
"[1920 1200]",
"[2048 1536]",
"[custom ]",
"[320 240 ]",
"[400 300 ]",
"[512 384 ]",
"[640 400 ]",
"[640 480 ]",
"[800 500 ]",
"[800 600 ]",
"[960 720 ]",
"[1024 480 ]",
"[1024 640 ]",
"[1024 768 ]",
"[1152 768 ]",
"[1152 864 ]",
"[1280 800 ]",
"[1280 720 ]",
"[1280 960 ]",
"[1280 1024 ]",
"[1366 768 ]",
"[1440 900 ]",
"[1600 1200 ]",
"[1680 1050 ]",
"[1920 1080 ]",
"[1920 1200 ]",
"[2048 1536 ]",
"[custom ]",
0
};
@ -316,14 +355,17 @@ VID_MenuInit(void)
{
gl_hudscale = Cvar_Get("gl_hudscale", "-1", CVAR_ARCHIVE);
}
if (!gl_consolescale)
{
gl_consolescale = Cvar_Get("gl_consolescale", "-1", CVAR_ARCHIVE);
}
if (!gl_menuscale)
{
gl_menuscale = Cvar_Get("gl_menuscale", "-1", CVAR_ARCHIVE);
}
if (!crosshair_scale)
{
crosshair_scale = Cvar_Get("crosshair_scale", "-1", CVAR_ARCHIVE);
@ -339,16 +381,16 @@ VID_MenuInit(void)
fov = Cvar_Get("fov", "90", CVAR_USERINFO | CVAR_ARCHIVE);
}
if (!scr_viewsize)
{
scr_viewsize = Cvar_Get("viewsize", "100", CVAR_ARCHIVE);
}
if (!vid_gamma)
{
vid_gamma = Cvar_Get("vid_gamma", "1.2", CVAR_ARCHIVE);
}
if (!vid_renderer)
{
vid_renderer = Cvar_Get("vid_renderer", "gl1", CVAR_ARCHIVE);
}
if (!gl_swapinterval)
{
gl_swapinterval = Cvar_Get("gl_swapinterval", "1", CVAR_ARCHIVE);
@ -367,10 +409,17 @@ VID_MenuInit(void)
s_opengl_menu.x = viddef.width * 0.50;
s_opengl_menu.nitems = 0;
s_renderer_list.generic.type = MTYPE_SPINCONTROL;
s_renderer_list.generic.name = "renderer";
s_renderer_list.generic.x = 0;
s_renderer_list.generic.y = (y = 0);
s_renderer_list.itemnames = renderers;
s_renderer_list.curvalue = GetRenderer();
s_mode_list.generic.type = MTYPE_SPINCONTROL;
s_mode_list.generic.name = "video mode";
s_mode_list.generic.x = 0;
s_mode_list.generic.y = (y = 0);
s_mode_list.generic.y = (y += 10);
s_mode_list.itemnames = resolutions;
if (gl_mode->value >= 0)
{
@ -381,10 +430,19 @@ VID_MenuInit(void)
s_mode_list.curvalue = GetCustomValue(&s_mode_list);
}
s_brightness_slider.generic.type = MTYPE_SLIDER;
s_brightness_slider.generic.name = "brightness";
s_brightness_slider.generic.x = 0;
s_brightness_slider.generic.y = (y += 20);
s_brightness_slider.generic.callback = BrightnessCallback;
s_brightness_slider.minvalue = 1;
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 += 10);
s_aspect_list.generic.y = (y += 20);
s_aspect_list.itemnames = aspect_names;
if (horplus->value == 1)
{
@ -437,24 +495,6 @@ VID_MenuInit(void)
s_uiscale_list.curvalue = GetCustomValue(&s_uiscale_list);
}
s_screensize_slider.generic.type = MTYPE_SLIDER;
s_screensize_slider.generic.name = "screen size";
s_screensize_slider.generic.x = 0;
s_screensize_slider.generic.y = (y += 10);
s_screensize_slider.minvalue = 4;
s_screensize_slider.maxvalue = 10;
s_screensize_slider.generic.callback = ScreenSizeCallback;
s_screensize_slider.curvalue = scr_viewsize->value / 10;
s_brightness_slider.generic.type = MTYPE_SLIDER;
s_brightness_slider.generic.name = "brightness";
s_brightness_slider.generic.x = 0;
s_brightness_slider.generic.y = (y += 10);
s_brightness_slider.generic.callback = BrightnessCallback;
s_brightness_slider.minvalue = 1;
s_brightness_slider.maxvalue = 20;
s_brightness_slider.curvalue = vid_gamma->value * 10;
s_fs_box.generic.type = MTYPE_SPINCONTROL;
s_fs_box.generic.name = "fullscreen";
s_fs_box.generic.x = 0;
@ -472,7 +512,7 @@ VID_MenuInit(void)
s_af_list.generic.type = MTYPE_SPINCONTROL;
s_af_list.generic.name = "aniso filtering";
s_af_list.generic.x = 0;
s_af_list.generic.y = (y += 20);
s_af_list.generic.y = (y += 10);
s_af_list.generic.callback = AnisotropicCallback;
s_af_list.itemnames = pow2_names;
s_af_list.curvalue = 0;
@ -514,10 +554,10 @@ VID_MenuInit(void)
s_apply_action.generic.y = (y += 10);
s_apply_action.generic.callback = ApplyChanges;
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_aspect_list);
Menu_AddItem(&s_opengl_menu, (void *)&s_uiscale_list);
Menu_AddItem(&s_opengl_menu, (void *)&s_screensize_slider);
Menu_AddItem(&s_opengl_menu, (void *)&s_brightness_slider);
Menu_AddItem(&s_opengl_menu, (void *)&s_fs_box);
Menu_AddItem(&s_opengl_menu, (void *)&s_vsync_list);