Cleanup the video menu, remove support for different refresher

This commit is contained in:
Yamagi Burmeister 2012-08-02 14:39:33 +02:00
parent c6eaf5c876
commit 3ab4e58df5
2 changed files with 70 additions and 240 deletions

View file

@ -58,23 +58,17 @@ qboolean reflib_active = 0;
#define VID_NUM_MODES (sizeof(vid_modes) / sizeof(vid_modes[0]))
/* INPUT */
void Do_Key_Event(int key, qboolean down);
void (*IN_Update_fp)(void);
void (*IN_KeyboardInit_fp)(Key_Event_fp_t fp);
void (*IN_Close_fp)(void);
in_state_t in_state;
void (*IN_BackendInit_fp)(in_state_t *in_state_p);
void (*IN_BackendShutdown_fp)(void);
void (*IN_BackendMouseButtons_fp)(void);
void (*IN_BackendMove_fp)(usercmd_t *cmd);
extern void VID_MenuShutdown(void);
/* DLL GLUE */
in_state_t in_state;
#define MAXPRINTMSG 4096
@ -402,26 +396,10 @@ VID_Shutdown(void)
re.Shutdown();
VID_FreeReflib();
}
VID_MenuShutdown();
}
/*
* Checks to see if the given ref_NAME.so exists.
* Placed here to avoid complicating other code if
* the library .so files ever have their names changed.
*
* In Yamagi Quake II this is just a dummy, to
* satisfy dependencies in the menu system.
*/
qboolean
VID_CheckRefExists(const char *ref)
{
return true;
}
/* INPUT */
void
IN_Shutdown(void)
{

View file

@ -20,8 +20,7 @@
* =======================================================================
*
* This is the refresher dependend video menu. If you add a new
* refresher this menu must be altered. A lot stuff here are preworkings
* for that and aren't needed at this time since we've only refresher.
* refresher this menu must be altered.
*
* =======================================================================
*/
@ -29,26 +28,9 @@
#include "../../client/header/client.h"
#include "../../client/menu/header/qmenu.h"
/* this will have to be updated if ref's are added/removed from ref_t */
#define NUMBER_OF_REFS 1
#define CUSTOM_MODE 20
/* all the refs should be initially set to 0 */
static char *refs[NUMBER_OF_REFS + 1] = {0};
/* make all these have illegal values, as they will be redefined */
static int REF_GL = NUMBER_OF_REFS;
static int GL_REF_START = NUMBER_OF_REFS;
typedef struct
{
char menuname[32];
char realname[32];
int *pointer;
} ref_t;
static const ref_t possible_refs[NUMBER_OF_REFS] = {
{"[OpenGL ]", "gl", &REF_GL},
};
extern void M_ForceMenuOff(void);
extern cvar_t *vid_ref;
extern cvar_t *vid_fullscreen;
@ -62,37 +44,16 @@ static cvar_t *gl_ext_palettedtexture;
static cvar_t *windowed_mouse;
extern void M_ForceMenuOff(void);
extern qboolean VID_CheckRefExists(const char *name);
/* MENU INTERACTION */
#define SOFTWARE_MENU 0
#define OPENGL_MENU 1
#define CUSTOM_MODE 20
static menuframework_s s_opengl_menu;
static menuframework_s *s_current_menu;
static int s_current_menu_index;
static menulist_s s_mode_list[2];
static menulist_s s_ref_list[2];
static menulist_s s_mode_list;
static menuslider_s s_tq_slider;
static menuslider_s s_screensize_slider[2];
static menuslider_s s_brightness_slider[2];
static menulist_s s_fs_box[2];
static menuslider_s s_screensize_slider;
static menuslider_s s_brightness_slider;
static menulist_s s_fs_box;
static menulist_s s_paletted_texture_box;
static menuaction_s s_apply_action[2];
static menuaction_s s_defaults_action[2];
static void
DriverCallback(void *unused)
{
s_ref_list[!s_current_menu_index].curvalue =
s_ref_list[s_current_menu_index].curvalue;
s_current_menu = &s_opengl_menu;
s_current_menu_index = 1;
}
static menuaction_s s_apply_action;
static menuaction_s s_defaults_action;
static void
ScreenSizeCallback(void *s)
@ -107,15 +68,6 @@ BrightnessCallback(void *s)
{
menuslider_s *slider = (menuslider_s *)s;
if (s_current_menu_index == 0)
{
s_brightness_slider[1].curvalue = s_brightness_slider[0].curvalue;
}
else
{
s_brightness_slider[0].curvalue = s_brightness_slider[1].curvalue;
}
float gamma = slider->curvalue / 10.0;
Cvar_SetValue("vid_gamma", gamma);
}
@ -129,56 +81,26 @@ ResetDefaults(void *unused)
static void
ApplyChanges(void *unused)
{
int ref;
/* make values consistent */
s_fs_box[!s_current_menu_index].curvalue =
s_fs_box[s_current_menu_index].curvalue;
s_brightness_slider[!s_current_menu_index].curvalue =
s_brightness_slider[s_current_menu_index].curvalue;
s_ref_list[!s_current_menu_index].curvalue =
s_ref_list[s_current_menu_index].curvalue;
Cvar_SetValue("gl_picmip", 3 - s_tq_slider.curvalue);
Cvar_SetValue("vid_fullscreen", s_fs_box[s_current_menu_index].curvalue);
Cvar_SetValue("vid_fullscreen", s_fs_box.curvalue);
Cvar_SetValue("gl_ext_palettedtexture", s_paletted_texture_box.curvalue);
/* custom mode */
if (s_mode_list[OPENGL_MENU].curvalue != CUSTOM_MODE)
if (s_mode_list.curvalue != CUSTOM_MODE)
{
printf("DEBUG: %i\n", s_mode_list[OPENGL_MENU].curvalue);
Cvar_SetValue("gl_mode", s_mode_list[OPENGL_MENU].curvalue);
Cvar_SetValue("gl_mode", s_mode_list.curvalue);
}
else
{
Cvar_SetValue("gl_mode", -1);
}
/* must use an if here (instead of a switch), since the
REF_'s are now variables and not #DEFINE's (constants) */
ref = s_ref_list[s_current_menu_index].curvalue;
if (ref == REF_GL)
{
Cvar_Set("vid_ref", "gl");
/* below is wrong if we use different libs for different GL reflibs */
Cvar_Get("gl_driver", LIBGL, CVAR_ARCHIVE);
if (gl_driver->modified)
{
vid_ref->modified = true;
}
}
M_ForceMenuOff();
}
void
VID_MenuInit(void)
{
int i, counter;
static const char *resolutions[] = {
"[320 240 ]",
"[400 300 ]",
@ -212,46 +134,9 @@ VID_MenuInit(void)
0
};
/* make sure these are invalided before showing the menu again */
REF_GL = NUMBER_OF_REFS;
GL_REF_START = NUMBER_OF_REFS;
/* now test to see which ref's are present */
i = counter = 0;
while (i < NUMBER_OF_REFS)
{
if (VID_CheckRefExists(possible_refs[i].realname))
{
*(possible_refs[i].pointer) = counter;
/* free any previous string */
if (refs[i])
{
free(refs[i]);
}
refs[counter] = strdup(possible_refs[i].menuname);
/* if we reach the 1rd item in the list, this indicates that a
GL ref has been found; this will change if more software
modes are added to the possible_ref's array */
if (i == 0)
{
GL_REF_START = counter;
}
counter++;
}
i++;
}
refs[counter] = (char *)0;
if (!gl_driver)
{
gl_driver = Cvar_Get("gl_driver", "libGL.so.1", 0);
gl_driver = Cvar_Get("gl_driver", LIBGL, 0);
}
if (!gl_picmip)
@ -261,7 +146,7 @@ VID_MenuInit(void)
if (!gl_mode)
{
gl_mode = Cvar_Get("gl_mode", "3", 0);
gl_mode = Cvar_Get("gl_mode", "4", 0);
}
if (!gl_ext_palettedtexture)
@ -279,11 +164,11 @@ VID_MenuInit(void)
/* custom mode */
if (gl_mode->value >= 1.0)
{
s_mode_list[OPENGL_MENU].curvalue = gl_mode->value;
s_mode_list.curvalue = gl_mode->value;
}
else
{
s_mode_list[OPENGL_MENU].curvalue = CUSTOM_MODE;
s_mode_list.curvalue = CUSTOM_MODE;
}
if (!scr_viewsize)
@ -291,72 +176,44 @@ VID_MenuInit(void)
scr_viewsize = Cvar_Get("viewsize", "100", CVAR_ARCHIVE);
}
s_screensize_slider[OPENGL_MENU].curvalue = scr_viewsize->value / 10;
if (strcmp(vid_ref->string, "gl") == 0)
{
s_current_menu_index = OPENGL_MENU;
s_ref_list[s_current_menu_index].curvalue = REF_GL;
}
s_screensize_slider.curvalue = scr_viewsize->value / 10;
s_opengl_menu.x = viddef.width * 0.50;
s_opengl_menu.nitems = 0;
for (i = 0; i < 2; i++)
{
s_ref_list[i].generic.type = MTYPE_SPINCONTROL;
s_ref_list[i].generic.name = "driver";
s_ref_list[i].generic.x = 0;
s_ref_list[i].generic.y = 0;
s_ref_list[i].generic.callback = DriverCallback;
s_ref_list[i].itemnames = (const char **)refs;
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 = 0;
s_mode_list.itemnames = resolutions;
s_mode_list[i].generic.type = MTYPE_SPINCONTROL;
s_mode_list[i].generic.name = "video mode";
s_mode_list[i].generic.x = 0;
s_mode_list[i].generic.y = 10;
s_mode_list[i].itemnames = resolutions;
s_screensize_slider.generic.type = MTYPE_SLIDER;
s_screensize_slider.generic.x = 0;
s_screensize_slider.generic.y = 10;
s_screensize_slider.generic.name = "screen size";
s_screensize_slider.minvalue = 3;
s_screensize_slider.maxvalue = 12;
s_screensize_slider.generic.callback = ScreenSizeCallback;
s_screensize_slider[i].generic.type = MTYPE_SLIDER;
s_screensize_slider[i].generic.x = 0;
s_screensize_slider[i].generic.y = 20;
s_screensize_slider[i].generic.name = "screen size";
s_screensize_slider[i].minvalue = 3;
s_screensize_slider[i].maxvalue = 12;
s_screensize_slider[i].generic.callback = ScreenSizeCallback;
s_brightness_slider.generic.type = MTYPE_SLIDER;
s_brightness_slider.generic.x = 0;
s_brightness_slider.generic.y = 20;
s_brightness_slider.generic.name = "brightness";
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_brightness_slider[i].generic.type = MTYPE_SLIDER;
s_brightness_slider[i].generic.x = 0;
s_brightness_slider[i].generic.y = 30;
s_brightness_slider[i].generic.name = "brightness";
s_brightness_slider[i].generic.callback = BrightnessCallback;
s_brightness_slider[i].minvalue = 1;
s_brightness_slider[i].maxvalue = 20;
s_brightness_slider[i].curvalue = vid_gamma->value * 10;
s_fs_box[i].generic.type = MTYPE_SPINCONTROL;
s_fs_box[i].generic.x = 0;
s_fs_box[i].generic.y = 40;
s_fs_box[i].generic.name = "fullscreen";
s_fs_box[i].itemnames = yesno_names;
s_fs_box[i].curvalue = vid_fullscreen->value;
s_defaults_action[i].generic.type = MTYPE_ACTION;
s_defaults_action[i].generic.name = "reset to default";
s_defaults_action[i].generic.x = 0;
s_defaults_action[i].generic.y = 90;
s_defaults_action[i].generic.callback = ResetDefaults;
s_apply_action[i].generic.type = MTYPE_ACTION;
s_apply_action[i].generic.name = "apply";
s_apply_action[i].generic.x = 0;
s_apply_action[i].generic.y = 100;
s_apply_action[i].generic.callback = ApplyChanges;
}
s_fs_box.generic.type = MTYPE_SPINCONTROL;
s_fs_box.generic.x = 0;
s_fs_box.generic.y = 30;
s_fs_box.generic.name = "fullscreen";
s_fs_box.itemnames = yesno_names;
s_fs_box.curvalue = vid_fullscreen->value;
s_tq_slider.generic.type = MTYPE_SLIDER;
s_tq_slider.generic.x = 0;
s_tq_slider.generic.y = 60;
s_tq_slider.generic.y = 50;
s_tq_slider.generic.name = "texture quality";
s_tq_slider.minvalue = 0;
s_tq_slider.maxvalue = 3;
@ -364,56 +221,51 @@ VID_MenuInit(void)
s_paletted_texture_box.generic.type = MTYPE_SPINCONTROL;
s_paletted_texture_box.generic.x = 0;
s_paletted_texture_box.generic.y = 70;
s_paletted_texture_box.generic.y = 60;
s_paletted_texture_box.generic.name = "8-bit textures";
s_paletted_texture_box.itemnames = yesno_names;
s_paletted_texture_box.curvalue = gl_ext_palettedtexture->value;
Menu_AddItem(&s_opengl_menu, (void *)&s_ref_list[OPENGL_MENU]);
Menu_AddItem(&s_opengl_menu, (void *)&s_mode_list[OPENGL_MENU]);
Menu_AddItem(&s_opengl_menu, (void *)&s_screensize_slider[OPENGL_MENU]);
Menu_AddItem(&s_opengl_menu, (void *)&s_brightness_slider[OPENGL_MENU]);
Menu_AddItem(&s_opengl_menu, (void *)&s_fs_box[OPENGL_MENU]);
s_defaults_action.generic.type = MTYPE_ACTION;
s_defaults_action.generic.name = "reset to default";
s_defaults_action.generic.x = 0;
s_defaults_action.generic.y = 80;
s_defaults_action.generic.callback = ResetDefaults;
s_apply_action.generic.type = MTYPE_ACTION;
s_apply_action.generic.name = "apply";
s_apply_action.generic.x = 0;
s_apply_action.generic.y = 90;
s_apply_action.generic.callback = ApplyChanges;
Menu_AddItem(&s_opengl_menu, (void *)&s_mode_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_tq_slider);
Menu_AddItem(&s_opengl_menu, (void *)&s_paletted_texture_box);
Menu_AddItem(&s_opengl_menu, (void *)&s_defaults_action[OPENGL_MENU]);
Menu_AddItem(&s_opengl_menu, (void *)&s_apply_action[OPENGL_MENU]);
Menu_AddItem(&s_opengl_menu, (void *)&s_defaults_action);
Menu_AddItem(&s_opengl_menu, (void *)&s_apply_action);
Menu_Center(&s_opengl_menu);
s_opengl_menu.x -= 8;
}
void
VID_MenuShutdown(void)
{
int i;
for (i = 0; i < NUMBER_OF_REFS; i++)
{
if (refs[i])
{
free(refs[i]);
}
}
}
void
VID_MenuDraw(void)
{
int w, h;
s_current_menu = &s_opengl_menu;
/* draw the banner */
re.DrawGetPicSize(&w, &h, "m_banner_video");
re.DrawPic(viddef.width / 2 - w / 2, viddef.height / 2 - 110,
"m_banner_video");
/* move cursor to a reasonable starting position */
Menu_AdjustCursor(s_current_menu, 1);
Menu_AdjustCursor(&s_opengl_menu, 1);
/* draw the menu */
Menu_Draw(s_current_menu);
Menu_Draw(&s_opengl_menu);
}
const char *
@ -421,7 +273,7 @@ VID_MenuKey(int key)
{
extern void M_PopMenu(void);
menuframework_s *m = s_current_menu;
menuframework_s *m = &s_opengl_menu;
static const char *sound = "misc/menu1.wav";
switch (key)