Menu work in progress, additions, tweaks etc, still more to do

git-svn-id: https://svn.code.sf.net/p/fteqw/code/trunk@3495 fc73d0e0-1445-4013-8a0c-d673dee63da5
This commit is contained in:
Lance 2010-01-15 05:35:27 +00:00
parent 8901f51133
commit d55c03b072
3 changed files with 187 additions and 125 deletions

View file

@ -204,7 +204,7 @@ void MenuTooltipSplit(menu_t *menu, const char *text)
return; return;
// calc a line maximum, use a third of the screen or 30 characters, whichever is bigger // calc a line maximum, use a third of the screen or 30 characters, whichever is bigger
lnmax = (vid.width / 24) - 2; lnmax = (vid.width / 24) - 2;
if (lnmax < 30) if (lnmax < 30)
lnmax = 30; lnmax = 30;
// word wrap // word wrap
@ -289,7 +289,7 @@ void MenuTooltipSplit(menu_t *menu, const char *text)
void MenuDrawItems(int xpos, int ypos, menuoption_t *option, menu_t *menu) void MenuDrawItems(int xpos, int ypos, menuoption_t *option, menu_t *menu)
{ {
int i; int i;
mpic_t *p; mpic_t *p;
while (option) while (option)
{ {
if (mousemoved && !bindingactive) if (mousemoved && !bindingactive)
@ -476,9 +476,9 @@ void MenuDrawItems(int xpos, int ypos, menuoption_t *option, menu_t *menu)
x += strlen(option->bind.caption)*8+28; x += strlen(option->bind.caption)*8+28;
{ {
l = strlen (option->bind.command); l = strlen (option->bind.command);
M_FindKeysForCommand (option->bind.command, keys); M_FindKeysForCommand (option->bind.command, keys);
if (bindingactive && menu->selecteditem == option) if (bindingactive && menu->selecteditem == option)
{ {
Draw_String (x, y, "Press key"); Draw_String (x, y, "Press key");
@ -577,7 +577,7 @@ menutext_t *MC_AddWhiteText(menu_t *menu, int x, int y, const char *text, qboole
{ {
menutext_t *n = Z_Malloc(sizeof(menutext_t)); menutext_t *n = Z_Malloc(sizeof(menutext_t));
n->common.type = mt_text; n->common.type = mt_text;
n->common.iszone = true; n->common.iszone = true;
n->common.posx = x; n->common.posx = x;
n->common.posy = y; n->common.posy = y;
n->text = text; n->text = text;
@ -594,7 +594,7 @@ menutext_t *MC_AddBufferedText(menu_t *menu, int x, int y, const char *text, qbo
{ {
menutext_t *n = Z_Malloc(sizeof(menutext_t) + strlen(text)+1); menutext_t *n = Z_Malloc(sizeof(menutext_t) + strlen(text)+1);
n->common.type = mt_text; n->common.type = mt_text;
n->common.iszone = true; n->common.iszone = true;
n->common.posx = x; n->common.posx = x;
n->common.posy = y; n->common.posy = y;
n->text = (char *)(n+1); n->text = (char *)(n+1);
@ -621,7 +621,7 @@ menubind_t *MC_AddBind(menu_t *menu, int x, int y, const char *caption, char *co
{ {
menubind_t *n = Z_Malloc(sizeof(menutext_t) + strlen(caption)+1 + strlen(command)+1); menubind_t *n = Z_Malloc(sizeof(menutext_t) + strlen(caption)+1 + strlen(command)+1);
n->common.type = mt_bind; n->common.type = mt_bind;
n->common.iszone = true; n->common.iszone = true;
n->common.posx = x; n->common.posx = x;
n->common.posy = y; n->common.posy = y;
n->caption = (char *)(n+1); n->caption = (char *)(n+1);
@ -766,7 +766,7 @@ menuedit_t *MC_AddEdit(menu_t *menu, int x, int y, char *text, char *def)
{ {
menuedit_t *n = Z_Malloc(sizeof(menuedit_t)); menuedit_t *n = Z_Malloc(sizeof(menuedit_t));
n->common.type = mt_edit; n->common.type = mt_edit;
n->common.iszone = true; n->common.iszone = true;
n->common.posx = x; n->common.posx = x;
n->common.posy = y; n->common.posy = y;
n->modified = true; n->modified = true;
@ -784,7 +784,7 @@ menuedit_t *MC_AddEditCvar(menu_t *menu, int x, int y, char *text, char *name)
cvar_t *cvar; cvar_t *cvar;
cvar = Cvar_Get(name, "", CVAR_USERCREATED|CVAR_ARCHIVE, NULL); //well, this is a menu/ cvar = Cvar_Get(name, "", CVAR_USERCREATED|CVAR_ARCHIVE, NULL); //well, this is a menu/
n->common.type = mt_edit; n->common.type = mt_edit;
n->common.iszone = true; n->common.iszone = true;
n->common.posx = x; n->common.posx = x;
n->common.posy = y; n->common.posy = y;
n->common.width = (strlen(text)+17)*8; n->common.width = (strlen(text)+17)*8;
@ -835,7 +835,7 @@ menucheck_t *MC_AddCheckBox(menu_t *menu, int x, int y, const char *text, cvar_t
{ {
menucheck_t *n = Z_Malloc(sizeof(menucheck_t)+strlen(text)+1); menucheck_t *n = Z_Malloc(sizeof(menucheck_t)+strlen(text)+1);
n->common.type = mt_checkbox; n->common.type = mt_checkbox;
n->common.iszone = true; n->common.iszone = true;
n->common.posx = x; n->common.posx = x;
n->common.posy = y; n->common.posy = y;
n->common.height = 8; n->common.height = 8;
@ -845,11 +845,13 @@ menucheck_t *MC_AddCheckBox(menu_t *menu, int x, int y, const char *text, cvar_t
n->var = var; n->var = var;
n->bits = bits; n->bits = bits;
#ifdef _DEBUG
if (var) if (var)
if (!(var->flags & CVAR_ARCHIVE)) if (!(var->flags & CVAR_ARCHIVE))
Con_Printf("Warning: %s is not set for archiving\n", var->name); Con_Printf("Warning: %s is not set for archiving\n", var->name);
else if (var->flags & CVAR_RENDERERLATCH) else if (var->flags & CVAR_RENDERERLATCH)
Con_Printf("Warning: %s requires a vid_restart\n", var->name); Con_Printf("Warning: %s requires a vid_restart\n", var->name);
#endif
n->common.next = menu->options; n->common.next = menu->options;
menu->options = (menuoption_t *)n; menu->options = (menuoption_t *)n;
@ -859,7 +861,7 @@ menucheck_t *MC_AddCheckBoxFunc(menu_t *menu, int x, int y, const char *text, qb
{ {
menucheck_t *n = Z_Malloc(sizeof(menucheck_t)+strlen(text)+1); menucheck_t *n = Z_Malloc(sizeof(menucheck_t)+strlen(text)+1);
n->common.type = mt_checkbox; n->common.type = mt_checkbox;
n->common.iszone = true; n->common.iszone = true;
n->common.posx = x; n->common.posx = x;
n->common.posy = y; n->common.posy = y;
n->common.height = 8; n->common.height = 8;
@ -876,10 +878,10 @@ menucheck_t *MC_AddCheckBoxFunc(menu_t *menu, int x, int y, const char *text, qb
//delta may be 0 //delta may be 0
menuslider_t *MC_AddSlider(menu_t *menu, int x, int y, const char *text, cvar_t *var, float min, float max, float delta) menuslider_t *MC_AddSlider(menu_t *menu, int x, int y, const char *text, cvar_t *var, float min, float max, float delta)
{ {
menuslider_t *n = Z_Malloc(sizeof(menuslider_t)+strlen(text)+1); menuslider_t *n = Z_Malloc(sizeof(menuslider_t)+strlen(text)+1);
n->common.type = mt_slider; n->common.type = mt_slider;
n->common.iszone = true; n->common.iszone = true;
n->common.posx = x; n->common.posx = x;
n->common.posy = y; n->common.posy = y;
n->common.height = 8; n->common.height = 8;
@ -892,8 +894,10 @@ menuslider_t *MC_AddSlider(menu_t *menu, int x, int y, const char *text, cvar_t
{ {
n->current = var->value; n->current = var->value;
#ifdef _DEBUG
if (!(var->flags & CVAR_ARCHIVE)) if (!(var->flags & CVAR_ARCHIVE))
Con_Printf("Warning: %s is not set for archiving\n", var->name); Con_Printf("Warning: %s is not set for archiving\n", var->name);
#endif
} }
n->min = min; n->min = min;
@ -930,15 +934,15 @@ menucombo_t *MC_AddCombo(menu_t *menu, int x, int y, const char *caption, const
optbufsize += optlen+1+sizeof(char*); optbufsize += optlen+1+sizeof(char*);
numopts++; numopts++;
} }
n = Z_Malloc(sizeof(*n) + optbufsize); n = Z_Malloc(sizeof(*n) + optbufsize);
newops = (char **)(n+1); newops = (char **)(n+1);
optbuf = (char*)(newops + numopts+1); optbuf = (char*)(newops + numopts+1);
n->common.type = mt_combo; n->common.type = mt_combo;
n->common.iszone = true; n->common.iszone = true;
n->common.posx = x; n->common.posx = x;
n->common.posy = y; n->common.posy = y;
n->common.height = 8; n->common.height = 8;
n->common.width = strlen(caption)*8 + maxoptlen*8; n->common.width = strlen(caption)*8 + maxoptlen*8;
n->caption = caption; n->caption = caption;
@ -956,7 +960,7 @@ menucombo_t *MC_AddCombo(menu_t *menu, int x, int y, const char *caption, const
} }
newops[i] = NULL; newops[i] = NULL;
if (initialvalue >= n->numoptions) if (initialvalue >= n->numoptions)
{ {
Con_Printf("WARNING: Fixed initialvalue for %s\n", caption); Con_Printf("WARNING: Fixed initialvalue for %s\n", caption);
initialvalue = n->numoptions-1; initialvalue = n->numoptions-1;
@ -990,17 +994,17 @@ menucombo_t *MC_AddCvarCombo(menu_t *menu, int x, int y, const char *caption, cv
optbufsize += strlen(values[numopts])+1+sizeof(char*); optbufsize += strlen(values[numopts])+1+sizeof(char*);
numopts++; numopts++;
} }
n = Z_Malloc(sizeof(*n) + optbufsize); n = Z_Malloc(sizeof(*n) + optbufsize);
newops = (char **)(n+1); newops = (char **)(n+1);
newvalues = (char**)(newops + numopts+1); newvalues = (char**)(newops + numopts+1);
optbuf = (char*)(newvalues + numopts+1); optbuf = (char*)(newvalues + numopts+1);
n->common.type = mt_combo; n->common.type = mt_combo;
n->common.iszone = true; n->common.iszone = true;
n->common.posx = x; n->common.posx = x;
n->common.posy = y; n->common.posy = y;
n->common.height = 8; n->common.height = 8;
n->common.width = strlen(caption)*8 + maxoptlen*8; n->common.width = strlen(caption)*8 + maxoptlen*8;
@ -1044,7 +1048,7 @@ menubutton_t *MC_AddConsoleCommand(menu_t *menu, int x, int y, const char *text,
{ {
menubutton_t *n = Z_Malloc(sizeof(menubutton_t)+strlen(text)+1+strlen(command)+1); menubutton_t *n = Z_Malloc(sizeof(menubutton_t)+strlen(text)+1+strlen(command)+1);
n->common.type = mt_button; n->common.type = mt_button;
n->common.iszone = true; n->common.iszone = true;
n->common.posx = x; n->common.posx = x;
n->common.posy = y; n->common.posy = y;
n->common.height = 8; n->common.height = 8;
@ -1063,7 +1067,7 @@ menubutton_t *MC_AddConsoleCommandQBigFont(menu_t *menu, int x, int y, const cha
{ {
menubutton_t *n = Z_Malloc(sizeof(menubutton_t)+strlen(text)+1+strlen(command)+1); menubutton_t *n = Z_Malloc(sizeof(menubutton_t)+strlen(text)+1+strlen(command)+1);
n->common.type = mt_qbuttonbigfont; n->common.type = mt_qbuttonbigfont;
n->common.iszone = true; n->common.iszone = true;
n->common.posx = x; n->common.posx = x;
n->common.posy = y; n->common.posy = y;
n->common.height = 20; n->common.height = 20;
@ -1081,7 +1085,7 @@ menubutton_t *MC_AddConsoleCommandHexen2BigFont(menu_t *menu, int x, int y, cons
{ {
menubutton_t *n = Z_Malloc(sizeof(menubutton_t)+strlen(text)+1+strlen(command)+1); menubutton_t *n = Z_Malloc(sizeof(menubutton_t)+strlen(text)+1+strlen(command)+1);
n->common.type = mt_hexen2buttonbigfont; n->common.type = mt_hexen2buttonbigfont;
n->common.iszone = true; n->common.iszone = true;
n->common.posx = x; n->common.posx = x;
n->common.posy = y; n->common.posy = y;
n->common.height = 8; n->common.height = 8;
@ -1100,7 +1104,7 @@ menubutton_t *MC_AddCommand(menu_t *menu, int x, int y, char *text, qboolean (*c
{ {
menubutton_t *n = Z_Malloc(sizeof(menubutton_t)); menubutton_t *n = Z_Malloc(sizeof(menubutton_t));
n->common.type = mt_button; n->common.type = mt_button;
n->common.iszone = true; n->common.iszone = true;
n->common.posx = x; n->common.posx = x;
n->common.posy = y; n->common.posy = y;
n->text = text; n->text = text;
@ -1119,17 +1123,17 @@ menubutton_t *VARGS MC_AddConsoleCommandf(menu_t *menu, int x, int y, const char
va_list argptr; va_list argptr;
static char string[1024]; static char string[1024];
menubutton_t *n; menubutton_t *n;
va_start (argptr, command); va_start (argptr, command);
vsnprintf (string,sizeof(string)-1, command,argptr); vsnprintf (string,sizeof(string)-1, command,argptr);
va_end (argptr); va_end (argptr);
n = Z_Malloc(sizeof(menubutton_t) + strlen(string)+1); n = Z_Malloc(sizeof(menubutton_t) + strlen(string)+1);
n->common.type = mt_button; n->common.type = mt_button;
n->common.iszone = true; n->common.iszone = true;
n->common.posx = x; n->common.posx = x;
n->common.posy = y; n->common.posy = y;
n->text = text; n->text = text;
n->command = (char *)(n+1); n->command = (char *)(n+1);
strcpy((char *)(n+1), string); strcpy((char *)(n+1), string);
@ -1330,7 +1334,7 @@ void M_HideMenu (menu_t *menu)
} }
} }
void M_RemoveMenu (menu_t *menu) void M_RemoveMenu (menu_t *menu)
{ {
menuoption_t *op, *oop; menuoption_t *op, *oop;
if (menu->remove) if (menu->remove)
menu->remove(menu); menu->remove(menu);
@ -1454,7 +1458,7 @@ menuoption_t *M_NextSelectableItem(menu_t *m, menuoption_t *old)
if (!old) if (!old)
old = M_NextItem(m, old); old = M_NextItem(m, old);
op = old; op = old;
while (1) while (1)
@ -1481,11 +1485,11 @@ menuoption_t *M_NextSelectableItem(menu_t *m, menuoption_t *old)
menuoption_t *M_PrevSelectableItem(menu_t *m, menuoption_t *old) menuoption_t *M_PrevSelectableItem(menu_t *m, menuoption_t *old)
{ {
menuoption_t *op; menuoption_t *op;
if (!old) if (!old)
old = currentmenu->options; old = currentmenu->options;
op = old; op = old;
while (1) while (1)
@ -1510,7 +1514,7 @@ void M_Complex_Key(int key)
{ {
if (!currentmenu) if (!currentmenu)
return; //erm... return; //erm...
if (currentmenu->key) if (currentmenu->key)
if (currentmenu->key(key, currentmenu)) if (currentmenu->key(key, currentmenu))
return; return;
@ -1534,7 +1538,7 @@ void M_Complex_Key(int key)
return; return;
} }
} }
switch(key) switch(key)
{ {
case K_MOUSE2: case K_MOUSE2:
@ -1547,7 +1551,7 @@ void M_Complex_Key(int key)
case K_DOWNARROW: case K_DOWNARROW:
currentmenu->selecteditem = M_NextSelectableItem(currentmenu, currentmenu->selecteditem); currentmenu->selecteditem = M_NextSelectableItem(currentmenu, currentmenu->selecteditem);
if (currentmenu->selecteditem) if (currentmenu->selecteditem)
{ {
S_LocalSound ("misc/menu1.wav"); S_LocalSound ("misc/menu1.wav");
if (currentmenu->cursoritem) if (currentmenu->cursoritem)
@ -1557,7 +1561,7 @@ void M_Complex_Key(int key)
case K_UPARROW: case K_UPARROW:
currentmenu->selecteditem = M_PrevSelectableItem(currentmenu, currentmenu->selecteditem); currentmenu->selecteditem = M_PrevSelectableItem(currentmenu, currentmenu->selecteditem);
if (currentmenu->selecteditem) if (currentmenu->selecteditem)
{ {
S_LocalSound ("misc/menu1.wav"); S_LocalSound ("misc/menu1.wav");
if (currentmenu->cursoritem) if (currentmenu->cursoritem)
@ -1630,7 +1634,7 @@ qboolean MC_GuiKey(int key, menu_t *menu)
guiinfo_t *info = (guiinfo_t *)menu->data; guiinfo_t *info = (guiinfo_t *)menu->data;
switch(key) switch(key)
{ {
case K_ESCAPE: case K_ESCAPE:
if (info->dropout) if (info->dropout)
MC_GuiKey(key, info->dropout); MC_GuiKey(key, info->dropout);
else else
@ -1670,7 +1674,7 @@ qboolean MC_GuiKey(int key, menu_t *menu)
gui->text[1] = "Hello again"; gui->text[1] = "Hello again";
gui->text[2] = "Hello yet again"; gui->text[2] = "Hello yet again";
for (y = 0, i = 0; gui->text[i]; i++, y+=1*8) for (y = 0, i = 0; gui->text[i]; i++, y+=1*8)
{ {
info->op[i] = MC_AddRedText(info->dropout, 0, y, gui->text[i], false); info->op[i] = MC_AddRedText(info->dropout, 0, y, gui->text[i], false);
} }
} }
@ -1753,7 +1757,7 @@ void M_Menu_Main_f (void)
mainm = M_CreateMenu(sizeof(guiinfo_t)); mainm = M_CreateMenu(sizeof(guiinfo_t));
mainm->key = MC_GuiKey; mainm->key = MC_GuiKey;
mainm->xpos=0; mainm->xpos=0;
gui = (guiinfo_t *)mainm->data; gui = (guiinfo_t *)mainm->data;
gui->text[0] = "Single"; gui->text[0] = "Single";
gui->text[1] = "Multiplayer"; gui->text[1] = "Multiplayer";
gui->text[2] = "Quit"; gui->text[2] = "Quit";
@ -1761,7 +1765,7 @@ void M_Menu_Main_f (void)
{ {
gui->op[i] = MC_AddRedText(mainm, x, 0, gui->text[i], false); gui->op[i] = MC_AddRedText(mainm, x, 0, gui->text[i], false);
x+=(strlen(gui->text[i])+1)*8; x+=(strlen(gui->text[i])+1)*8;
} }
return; return;
} }
*/ */
@ -1772,12 +1776,12 @@ void M_Menu_Main_f (void)
if (mgt == MGT_QUAKE2) //quake2 main menu. if (mgt == MGT_QUAKE2) //quake2 main menu.
{ {
if (Draw_SafeCachePic("pics/m_main_game")) if (Draw_SafeCachePic("pics/m_main_game"))
{ {
m_state = m_complex; m_state = m_complex;
key_dest = key_menu; key_dest = key_menu;
mainm = M_CreateMenu(0); mainm = M_CreateMenu(0);
mainm->key = MC_Main_Key; mainm->key = MC_Main_Key;
MC_AddPicture(mainm, 0, 4, "pics/m_main_plaque"); MC_AddPicture(mainm, 0, 4, "pics/m_main_plaque");
p = Draw_SafeCachePic("pics/m_main_logo"); p = Draw_SafeCachePic("pics/m_main_logo");
@ -1822,8 +1826,8 @@ void M_Menu_Main_f (void)
{ {
m_state = m_complex; m_state = m_complex;
key_dest = key_menu; key_dest = key_menu;
mainm = M_CreateMenu(0); mainm = M_CreateMenu(0);
mainm->key = MC_Main_Key; mainm->key = MC_Main_Key;
MC_AddPicture(mainm, 16, 0, "gfx/menu/hplaque.lmp"); MC_AddPicture(mainm, 16, 0, "gfx/menu/hplaque.lmp");
p = Draw_SafeCachePic("gfx/menu/title0.lmp"); p = Draw_SafeCachePic("gfx/menu/title0.lmp");
@ -1856,7 +1860,7 @@ void M_Menu_Main_f (void)
{ {
m_state = m_complex; m_state = m_complex;
key_dest = key_menu; key_dest = key_menu;
mainm = M_CreateMenu(0); mainm = M_CreateMenu(0);
p = Draw_SafeCachePic("gfx/ttl_main.lmp"); p = Draw_SafeCachePic("gfx/ttl_main.lmp");
if (!p) if (!p)
@ -1890,7 +1894,7 @@ void M_Menu_Main_f (void)
{ {
m_state = m_complex; m_state = m_complex;
key_dest = key_menu; key_dest = key_menu;
mainm = M_CreateMenu(0); mainm = M_CreateMenu(0);
p = Draw_SafeCachePic("gfx/ttl_main.lmp"); p = Draw_SafeCachePic("gfx/ttl_main.lmp");
if (!p) if (!p)

View file

@ -913,12 +913,12 @@ void M_Menu_Textures_f (void)
menu->cursoritem = (menuoption_t*)MC_AddWhiteText(menu, 220, 32, NULL, false); menu->cursoritem = (menuoption_t*)MC_AddWhiteText(menu, 220, 32, NULL, false);
} }
typedef struct { /*typedef struct {
} shadowlightingmenuinfo_t; } shadowlightingmenuinfo_t;*/
qboolean M_VideoApplyShadowLighting (union menuoption_s *op,struct menu_s *menu,int key) qboolean M_VideoApplyShadowLighting (union menuoption_s *op,struct menu_s *menu,int key)
{ {
shadowlightingmenuinfo_t *info = menu->data; //shadowlightingmenuinfo_t *info = menu->data;
if (key != K_ENTER) if (key != K_ENTER)
return false; return false;
@ -965,7 +965,7 @@ void M_Menu_Shadow_Lighting_f (void)
MC_AddCheckBox(menu, 16, y, " Alias Model Shadows", &r_noaliasshadows,0); y+=8; MC_AddCheckBox(menu, 16, y, " Alias Model Shadows", &r_noaliasshadows,0); y+=8;
MC_AddSlider(menu, 16, y, " Shadows", &r_shadows,0,2,1); y+=8; MC_AddCheckBox(menu, 16, y, " Shadows", &r_shadows,0); y+=8;
MC_AddCheckBox(menu, 16, y, "Realtime World Shadows & Lighting", &r_shadow_realtime_world,0); y+=8; MC_AddCheckBox(menu, 16, y, "Realtime World Shadows & Lighting", &r_shadow_realtime_world,0); y+=8;
MC_AddCheckBox(menu, 16, y, " Realtime World Lightmaps", &r_shadow_realtime_world_lightmaps,0); y+=8; MC_AddCheckBox(menu, 16, y, " Realtime World Lightmaps", &r_shadow_realtime_world_lightmaps,0); y+=8;
MC_AddCheckBox(menu, 16, y, " GLSL Shadow Offsetmapping", &r_shadow_glsl_offsetmapping,0); y+=8; MC_AddCheckBox(menu, 16, y, " GLSL Shadow Offsetmapping", &r_shadow_glsl_offsetmapping,0); y+=8;
@ -1284,4 +1284,4 @@ void M_Menu_Teamplay_Items_f (void)
MC_AddConsoleCommand(menu, 16, y, "<- Teamplay Options", "menu_teamplay\n"); y+=8; MC_AddConsoleCommand(menu, 16, y, "<- Teamplay Options", "menu_teamplay\n"); y+=8;
menu->cursoritem = (menuoption_t*)MC_AddWhiteText(menu, 200, 32, NULL, false); menu->cursoritem = (menuoption_t*)MC_AddWhiteText(menu, 200, 32, NULL, false);
} }

View file

@ -3,6 +3,7 @@
#ifdef RGLQUAKE #ifdef RGLQUAKE
#include "gl_draw.h" #include "gl_draw.h"
#endif #endif
#include <string.h>
qboolean vid_isfullscreen; qboolean vid_isfullscreen;
@ -986,42 +987,42 @@ typedef struct vidmode_s
vidmode_t vid_modes[] = vidmode_t vid_modes[] =
{ {
{ "320x200 (16:10)", 320, 200}, // CGA, MCGA { "320x200\n16:10", 320, 200}, // CGA, MCGA
{ "320x240 (4:3)", 320, 240}, // QVGA { "320x240\n4:3", 320, 240}, // QVGA
{ "400x300 (4:3)", 400, 300}, // Quarter SVGA { "400x300\n4:3", 400, 300}, // Quarter SVGA
{ "512x384 (4:3)", 512, 384}, // Mac LC { "512x384\n4:3", 512, 384}, // Mac LC
{ "640x400 (16:10)", 640, 400}, // Atari ST mono, Amiga OCS NTSC Hires interlace { "640x400\n16:10", 640, 400}, // Atari ST mono, Amiga OCS NTSC Hires interlace
{ "640x480 (4:3)", 640, 480}, // VGA, MCGA { "640x480\n4:3", 640, 480}, // VGA, MCGA
{ "800x600 (4:3)", 800, 600}, // SVGA { "800x600\n4:3", 800, 600}, // SVGA
{ "856x480 (16:9)", 856, 480}, // WVGA { "856x480\n16:9", 856, 480}, // WVGA
{ "960x720 (4:3)", 960, 720}, // unnamed { "960x720\n4:3", 960, 720}, // unnamed
{ "1024x576 (16:9)", 1024, 576}, // WSVGA { "1024x576\n16:9", 1024, 576}, // WSVGA
{ "1024x640 (16:10)", 1024, 640}, // unnamed { "1024x640\n16:10", 1024, 640}, // unnamed
{ "1024x768 (4:3)", 1024, 768}, // XGA { "1024x768\n4:3", 1024, 768}, // XGA
{ "1152x720 (16:10)", 1152, 720}, // XGA+ { "1152x720\n16:10", 1152, 720}, // XGA+
{ "1152x864 (4:3)", 1152, 864}, // XGA+ { "1152x864\n4:3", 1152, 864}, // XGA+
{ "1280x720 (16:9)", 1280, 720}, // WXGA min. { "1280x720\n16:9", 1280, 720}, // WXGA min.
{ "1280x800 (16:10)", 1280, 800}, // WXGA avg (native resolution of 17" widescreen LCDs) { "1280x800\n16:10", 1280, 800}, // WXGA avg native resolution of 17" widescreen LCDs
{ "1280x960 (4:3)", 1280, 960}, //SXGA- { "1280x960\n4:3", 1280, 960}, //SXGA-
{ "1280x1024 (5:4)", 1280, 1024}, // SXGA (native resolution of 17-19" LCDs) { "1280x1024\n5:4", 1280, 1024}, // SXGA native resolution of 17-19" LCDs
{ "1366x768 (16:9)", 1366, 768}, // WXGA { "1366x768\n16:9", 1366, 768}, // WXGA
{ "1400x1050 (4:3)", 1400, 1050}, // SXGA+ { "1400x1050\n4:3", 1400, 1050}, // SXGA+
{ "1440x900 (16:10)", 1440, 900}, // WXGA+ (native resolution of 19" widescreen LCDs) { "1440x900\n16:10", 1440, 900}, // WXGA+ native resolution of 19" widescreen LCDs
{ "1440x1080 (4:3)", 1440, 1080}, // unnamed { "1440x1080\n4:3", 1440, 1080}, // unnamed
{ "1600x900 (16:9)", 1600, 900}, // 900p { "1600x900\n16:9", 1600, 900}, // 900p
{ "1600x1200 (4:3)", 1600, 1200}, // UXGA (native resolution of 20"+ LCDs) //sw height is bound to 200 to 1024 { "1600x1200\n4:3", 1600, 1200}, // UXGA native resolution of 20"+ LCDs //sw height is bound to 200 to 1024
{ "1680x1050 (16:10)", 1680, 1050}, // WSXGA+ (native resolution of 22" widescreen LCDs) { "1680x1050\n16:10", 1680, 1050}, // WSXGA+ native resolution of 22" widescreen LCDs
{ "1792x1344 (4:3)", 1792, 1344}, // unnamed { "1792x1344\n4:3", 1792, 1344}, // unnamed
{ "1800x1440 (5:4)", 1800, 1440}, // unnamed { "1800x1440\n5:4", 1800, 1440}, // unnamed
{ "1856x1392 (4:3)", 1856, 1392}, //unnamed { "1856x1392\n4:3", 1856, 1392}, //unnamed
{ "1920x1080 (16:9)", 1920, 1080}, // 1080p (native resolution of cheap 24" LCDs, which really are 23.6") { "1920x1080\n16:9", 1920, 1080}, // 1080p native resolution of cheap 24" LCDs, which really are 23.6"
{ "1920x1200 (16:10)", 1920, 1200}, // WUXGA (native resolution of good 24" widescreen LCDs) { "1920x1200\n16:10", 1920, 1200}, // WUXGA native resolution of good 24" widescreen LCDs
{ "1920x1440 (4:3)", 1920, 1440}, // TXGA { "1920x1440\n4:3", 1920, 1440}, // TXGA
{ "2048x1152 (16:9)", 2048, 1152}, // QWXGA (native resolution of 23" ultra-widescreen LCDs) { "2048x1152\n16:9", 2048, 1152}, // QWXGA native resolution of 23" ultra-widescreen LCDs
{ "2048x1536 (4:3)", 2048, 1536}, // QXGA //too much width will disable water warping (>1280) (but at that resolution, it's almost unnoticable) { "2048x1536\n4:3", 2048, 1536}, // QXGA //too much width will disable water warping >1280 but at that resolution, it's almost unnoticable
{ "2304x1440 (16:10)", 2304, 1440}, // (unnamed; maximum resolution of the Sony GDM-FW900 and Hewlett Packard A7217A) { "2304x1440\n16:10", 2304, 1440}, // unnamed; maximum resolution of the Sony GDM-FW900 and Hewlett Packard A7217A
{ "2560x1600 (16:10)", 2560, 1600}, // WQXGA (maximum resolution of 30" widescreen LCDs, Dell for example) { "2560x1600\n16:10", 2560, 1600}, // WQXGA maximum resolution of 30" widescreen LCDs, Dell for example
{ "2560x2048 (5:4)", 2560, 2048} // QSXGA { "2560x2048\n5:4", 2560, 2048} // QSXGA
}; };
#define NUMVIDMODES sizeof(vid_modes)/sizeof(vid_modes[0]) #define NUMVIDMODES sizeof(vid_modes)/sizeof(vid_modes[0])
@ -1233,8 +1234,15 @@ void M_Menu_Video_f (void)
int currentbpp; int currentbpp;
int currentrefreshrate; int currentrefreshrate;
int currentvsync; int currentvsync;
int aspectratio; int aspectratio3d;
char *aspectratio2; int aspectratio2d;
char *aspectratio23d;
char *aspectratio22d;
char *rendererstring;
static char current3dres[10]; // enough to fit 1920x1200
static char current2dres[10]; // same as above
static char colordepth[6]; // enough to fit 32bit
static char currenthz[6]; // enough to fit 120hz
extern cvar_t _vid_wait_override; extern cvar_t _vid_wait_override;
@ -1290,49 +1298,99 @@ void M_Menu_Video_f (void)
else else
currentrefreshrate = 0; currentrefreshrate = 0;
aspectratio = (vid_width.value / vid_height.value * 100); // times by 100 so don't have to deal with floats aspectratio3d = (vid_width.value / vid_height.value * 100); // times by 100 so don't have to deal with floats
if (aspectratio == 125) // 1.25 if (aspectratio3d == 125) // 1.25
aspectratio2 = "5:4"; aspectratio23d = "5:4";
else if (aspectratio == 160) // 1.6 else if (aspectratio3d == 160) // 1.6
aspectratio2 = "16:10"; aspectratio23d = "16:10";
else if (aspectratio == 133) // 1.333333 else if (aspectratio3d == 133) // 1.333333
aspectratio2 = "4:3"; aspectratio23d = "4:3";
else if (aspectratio == 177) // 1.777778 else if (aspectratio3d == 177) // 1.777778
aspectratio2 = "16:9"; aspectratio23d = "16:9";
else else
aspectratio2 = "Unknown Ratio"; aspectratio23d = "Non-standard Ratio";
aspectratio2d = (vid_conwidth.value / vid_conheight.value * 100); // times by 100 so don't have to deal with floats
if (aspectratio2d == 125) // 1.25
aspectratio22d = "5:4";
else if (aspectratio2d == 160) // 1.6
aspectratio22d = "16:10";
else if (aspectratio2d == 133) // 1.333333
aspectratio22d = "4:3";
else if (aspectratio2d == 177) // 1.777778
aspectratio22d = "16:9";
else
aspectratio22d = "Non-standard Ratio";
currentvsync = _vid_wait_override.value; currentvsync = _vid_wait_override.value;
snprintf(current3dres, sizeof(current3dres), "%sx%s", vid_width.string, vid_height.string);
snprintf(current2dres, sizeof(current2dres), "%sx%s", vid_conwidth.string, vid_conheight.string);
snprintf(currenthz, sizeof(currenthz), "%sHz", vid_refreshrate.string);
if ( stricmp(vid_renderer.string,"gl" ) == 0 )
rendererstring = "OpenGL";
else if ( stricmp(vid_renderer.string,"d3d7") == 0 )
rendererstring = "DirectX 7";
else if ( stricmp(vid_renderer.string,"d3d9") == 0 )
rendererstring = "DirectX 9";
else if ( stricmp(vid_renderer.string,"d3d") == 0)
rendererstring = "DirectX";
else if ( stricmp(vid_renderer.string,"sw") == 0)
rendererstring = "Software";
else
rendererstring = "Unknown Renderer?";
sprintf(colordepth,"%sbit", vid_bpp.string);
MC_AddCenterPicture(menu, 4, "vidmodes"); MC_AddCenterPicture(menu, 4, "vidmodes");
y = 32; y = 32;
info->renderer = MC_AddCombo(menu, 16, y, " Renderer", rendererops, i); y+=8;
info->bppcombo = MC_AddCombo(menu, 16, y, " Color Depth", bppnames, currentbpp); y+=8; MC_AddRedText(menu, 0, y, " Current Renderer", false);
info->refreshratecombo = MC_AddCombo(menu, 16, y, " Refresh Rate", refreshrates, currentrefreshrate); y+=8; MC_AddRedText(menu, 180, y, rendererstring, false); y+=8;
info->modecombo = MC_AddCombo(menu, 16, y, " Video Size", modenames, prefabmode+1); y+=8; MC_AddRedText(menu, 0, y, " Current Color Depth", false);
MC_AddWhiteText(menu, 16, y, " Current A/R", false); MC_AddRedText(menu, 180, y, colordepth, false); y+=8;
MC_AddWhiteText(menu, 160, y, aspectratio2, false); y+=8; MC_AddRedText(menu, 0, y, " Current 3D Res", false);
info->conscalecombo = MC_AddCombo(menu, 16, y, " 2D Size", modenames, prefab2dmode+1); y+=8; MC_AddRedText(menu, 180, y, current3dres, false); y+=8;
MC_AddCheckBox(menu, 16, y, " Fullscreen", &vid_fullscreen,0); y+=8; MC_AddRedText(menu, 0, y, " Current 3D A/R", false);
y+=4;info->customwidth = MC_AddEdit(menu, 16, y, " Custom width", vid_width.string); y+=8; MC_AddRedText(menu, 180, y, aspectratio23d, false); y+=8;
y+=4;info->customheight = MC_AddEdit(menu, 16, y, " Custom height", vid_height.string); y+=12; MC_AddRedText(menu, 0, y, " Current 2D Res", false);
info->vsynccombo = MC_AddCombo(menu, 16, y, " VSync", vsyncoptions, currentvsync); y+=8; MC_AddRedText(menu, 180, y, current2dres, false); y+=8;
//MC_AddCheckBox(menu, 16, y, " Override VSync", &_vid_wait_override,0); y+=8; MC_AddRedText(menu, 0, y, " Current 2D A/R", false);
MC_AddRedText(menu, 180, y, aspectratio22d, false); y+=8;
MC_AddRedText(menu, 0, y, "Current Refresh Rate", false);
MC_AddRedText(menu, 180, y, currenthz, false); y+=8;
MC_AddRedText(menu, 0, y, "---------------------------------------------", false); y+=8;
y+=8; y+=8;
MC_AddCommand(menu, 16, y, " Apply", M_VideoApply); y+=8; info->renderer = MC_AddCombo(menu, 16, y, " Renderer", rendererops, i); y+=8;
info->bppcombo = MC_AddCombo(menu, 16, y, " Color Depth", bppnames, currentbpp); y+=8;
info->refreshratecombo = MC_AddCombo(menu, 16, y, " Refresh Rate", refreshrates, currentrefreshrate); y+=8;
info->modecombo = MC_AddCombo(menu, 16, y, " Video Size", modenames, prefabmode+1); y+=8;
MC_AddWhiteText(menu, 16, y, " 3D Aspect Ratio", false); y+=8;
info->conscalecombo = MC_AddCombo(menu, 16, y, " 2D Size", modenames, prefab2dmode+1); y+=8;
MC_AddWhiteText(menu, 16, y, " 2D Aspect Ratio", false); y+=8;
MC_AddCheckBox(menu, 16, y, " Fullscreen", &vid_fullscreen,0); y+=8;
y+=4;info->customwidth = MC_AddEdit(menu, 16, y, " Custom width", vid_width.string); y+=8;
y+=4;info->customheight = MC_AddEdit(menu, 16, y, " Custom height", vid_height.string); y+=12;
info->vsynccombo = MC_AddCombo(menu, 16, y, " VSync", vsyncoptions, currentvsync); y+=8;
//MC_AddCheckBox(menu, 16, y, " Override VSync", &_vid_wait_override,0); y+=8;
y+=8; y+=8;
MC_AddSlider(menu, 16, y, " Screen size", &scr_viewsize, 30, 120, 1);y+=8; MC_AddCommand(menu, 16, y, "= Apply Changes =", M_VideoApply); y+=8;
MC_AddSlider(menu, 16, y, " Gamma", &v_gamma, 0.3, 1, 0.05); y+=8;
MC_AddCheckBox(menu, 16, y, " Desktop Gamma", &vid_desktopgamma,0); y+=8;
MC_AddCheckBox(menu, 16, y, " Hardware Gamma", &vid_hardwaregamma,0); y+=8;
MC_AddCheckBox(menu, 16, y, " Preserve Gamma", &vid_preservegamma,0); y+=8;
MC_AddSlider(menu, 16, y, " Contrast", &v_contrast, 1, 3, 0.05); y+=8;
y+=8; y+=8;
MC_AddCheckBox(menu, 16, y, " Stretching", &vid_stretch,0); y+=8; MC_AddSlider(menu, 16, y, " Screen size", &scr_viewsize, 30, 120, 1);y+=8;
MC_AddCheckBox(menu, 16, y, " Allow ModeX", &vid_allow_modex,0); y+=8; MC_AddSlider(menu, 16, y, "Console Autoscale",&vid_conautoscale, 0, 6, 0.25); y+=8;
MC_AddCheckBox(menu, 16, y, " Windowed Mouse", &_windowed_mouse,0); y+=8; MC_AddSlider(menu, 16, y, " Gamma", &v_gamma, 0.3, 1, 0.05); y+=8;
MC_AddCheckBox(menu, 16, y, " Desktop Gamma", &vid_desktopgamma,0); y+=8;
MC_AddCheckBox(menu, 16, y, " Hardware Gamma", &vid_hardwaregamma,0); y+=8;
MC_AddCheckBox(menu, 16, y, " Preserve Gamma", &vid_preservegamma,0); y+=8;
MC_AddSlider(menu, 16, y, " Contrast", &v_contrast, 1, 3, 0.05); y+=8;
y+=8;
MC_AddCheckBox(menu, 16, y, " Stretching", &vid_stretch,0); y+=8;
MC_AddCheckBox(menu, 16, y, " Allow ModeX", &vid_allow_modex,0); y+=8;
MC_AddCheckBox(menu, 16, y, " Windowed Mouse", &_windowed_mouse,0); y+=8;
menu->cursoritem = (menuoption_t*)MC_AddWhiteText(menu, 152, 32, NULL, false); menu->cursoritem = (menuoption_t*)MC_AddWhiteText(menu, 152, 32, NULL, false);
menu->selecteditem = (union menuoption_s *)info->renderer; menu->selecteditem = (union menuoption_s *)info->renderer;