2005-02-28 07:16:19 +00:00
|
|
|
//read menu.h
|
|
|
|
|
2004-08-23 00:15:46 +00:00
|
|
|
#include "quakedef.h"
|
2009-11-04 21:16:50 +00:00
|
|
|
#include "shader.h"
|
2004-08-23 00:15:46 +00:00
|
|
|
|
|
|
|
int omousex;
|
|
|
|
int omousey;
|
|
|
|
qboolean mousemoved;
|
2004-09-07 18:19:22 +00:00
|
|
|
qboolean bindingactive;
|
2006-01-21 00:06:49 +00:00
|
|
|
extern cvar_t cl_cursor;
|
|
|
|
extern cvar_t cl_cursorsize;
|
|
|
|
extern cvar_t cl_cursorbias;
|
2004-08-23 00:15:46 +00:00
|
|
|
|
|
|
|
void Draw_TextBox (int x, int y, int width, int lines)
|
|
|
|
{
|
2004-12-24 08:45:56 +00:00
|
|
|
mpic_t *p;
|
2004-08-23 00:15:46 +00:00
|
|
|
int cx, cy;
|
|
|
|
int n;
|
|
|
|
|
|
|
|
// draw left side
|
|
|
|
cx = x;
|
|
|
|
cy = y;
|
2011-03-31 01:14:01 +00:00
|
|
|
p = R2D_SafeCachePic ("gfx/box_tl.lmp");
|
2004-08-23 00:15:46 +00:00
|
|
|
|
|
|
|
if (!p) //assume none exist
|
2009-04-19 10:50:31 +00:00
|
|
|
{
|
2011-03-31 01:14:01 +00:00
|
|
|
R2D_ImageColours(0.0, 0.0, 0.0, 1.0);
|
|
|
|
R2D_FillBlock(x, y, width + 16, 8 * (2 + lines));
|
|
|
|
R2D_ImageColours(1.0, 1.0, 1.0, 1.0);
|
2004-08-23 00:15:46 +00:00
|
|
|
return;
|
2009-04-19 10:50:31 +00:00
|
|
|
}
|
2004-08-23 00:15:46 +00:00
|
|
|
|
|
|
|
if (p)
|
2011-03-31 01:14:01 +00:00
|
|
|
R2D_ScalePic (cx, cy, 8, 8, p);
|
|
|
|
p = R2D_SafeCachePic ("gfx/box_ml.lmp");
|
2004-08-23 00:15:46 +00:00
|
|
|
for (n = 0; n < lines; n++)
|
|
|
|
{
|
|
|
|
cy += 8;
|
|
|
|
if (p)
|
2011-03-31 01:14:01 +00:00
|
|
|
R2D_ScalePic (cx, cy, 8, 8, p);
|
2004-08-23 00:15:46 +00:00
|
|
|
}
|
2011-03-31 01:14:01 +00:00
|
|
|
p = R2D_SafeCachePic ("gfx/box_bl.lmp");
|
2004-08-23 00:15:46 +00:00
|
|
|
if (p)
|
2011-03-31 01:14:01 +00:00
|
|
|
R2D_ScalePic (cx, cy+8, 8, 8, p);
|
2004-08-23 00:15:46 +00:00
|
|
|
|
|
|
|
// draw middle
|
|
|
|
cx += 8;
|
|
|
|
while (width > 0)
|
|
|
|
{
|
|
|
|
cy = y;
|
2011-03-31 01:14:01 +00:00
|
|
|
p = R2D_SafeCachePic ("gfx/box_tm.lmp");
|
2004-08-23 00:15:46 +00:00
|
|
|
if (p)
|
2011-03-31 01:14:01 +00:00
|
|
|
R2D_ScalePic (cx, cy, 16, 8, p);
|
|
|
|
p = R2D_SafeCachePic ("gfx/box_mm.lmp");
|
2004-08-23 00:15:46 +00:00
|
|
|
for (n = 0; n < lines; n++)
|
|
|
|
{
|
|
|
|
cy += 8;
|
|
|
|
if (n == 1)
|
2011-03-31 01:14:01 +00:00
|
|
|
p = R2D_SafeCachePic ("gfx/box_mm2.lmp");
|
2004-08-23 00:15:46 +00:00
|
|
|
if (p)
|
2011-03-31 01:14:01 +00:00
|
|
|
R2D_ScalePic (cx, cy, 16, 8, p);
|
2004-08-23 00:15:46 +00:00
|
|
|
}
|
2011-03-31 01:14:01 +00:00
|
|
|
p = R2D_SafeCachePic ("gfx/box_bm.lmp");
|
2004-08-23 00:15:46 +00:00
|
|
|
if (p)
|
2011-03-31 01:14:01 +00:00
|
|
|
R2D_ScalePic (cx, cy+8, 16, 8, p);
|
2004-08-23 00:15:46 +00:00
|
|
|
width -= 2;
|
|
|
|
cx += 16;
|
|
|
|
}
|
|
|
|
|
|
|
|
// draw right side
|
|
|
|
cy = y;
|
2011-03-31 01:14:01 +00:00
|
|
|
p = R2D_SafeCachePic ("gfx/box_tr.lmp");
|
2004-08-23 00:15:46 +00:00
|
|
|
if (p)
|
2011-03-31 01:14:01 +00:00
|
|
|
R2D_ScalePic (cx, cy, 8, 8, p);
|
|
|
|
p = R2D_SafeCachePic ("gfx/box_mr.lmp");
|
2004-08-23 00:15:46 +00:00
|
|
|
for (n = 0; n < lines; n++)
|
|
|
|
{
|
|
|
|
cy += 8;
|
|
|
|
if (p)
|
2011-03-31 01:14:01 +00:00
|
|
|
R2D_ScalePic (cx, cy, 8, 8, p);
|
2004-08-23 00:15:46 +00:00
|
|
|
}
|
2011-03-31 01:14:01 +00:00
|
|
|
p = R2D_SafeCachePic ("gfx/box_br.lmp");
|
2004-08-23 00:15:46 +00:00
|
|
|
if (p)
|
2011-03-31 01:14:01 +00:00
|
|
|
R2D_ScalePic (cx, cy+8, 8, 8, p);
|
2004-08-23 00:15:46 +00:00
|
|
|
}
|
|
|
|
|
2006-03-06 01:41:09 +00:00
|
|
|
void Draw_Hexen2BigFontString(int x, int y, const char *text)
|
2004-08-23 00:15:46 +00:00
|
|
|
{
|
|
|
|
int sx, sy;
|
2004-12-24 08:45:56 +00:00
|
|
|
mpic_t *p;
|
2010-08-12 00:48:05 +00:00
|
|
|
unsigned int hack;
|
|
|
|
hack = d_8to24rgbtable[0];
|
|
|
|
d_8to24rgbtable[0] = 0;
|
2011-03-31 01:14:01 +00:00
|
|
|
p = R2D_SafeCachePic ("gfx/menu/bigfont.lmp");
|
2010-08-12 00:48:05 +00:00
|
|
|
d_8to24rgbtable[0] = hack;
|
2004-08-23 00:15:46 +00:00
|
|
|
|
|
|
|
while(*text)
|
|
|
|
{
|
|
|
|
if (*text >= 'a' && *text <= 'z')
|
|
|
|
{
|
|
|
|
sx = ((*text-'a')%8)*20;
|
|
|
|
sy = ((*text-'a')/8)*20;
|
|
|
|
}
|
|
|
|
else if (*text >= 'A' && *text <= 'Z')
|
|
|
|
{
|
|
|
|
sx = ((*text-'A')%8)*20;
|
|
|
|
sy = ((*text-'A')/8)*20;
|
|
|
|
}
|
|
|
|
else// if (*text <= ' ')
|
|
|
|
{
|
|
|
|
sx=-1;
|
|
|
|
sy=-1;
|
|
|
|
}
|
|
|
|
if(sx>=0)
|
2011-03-31 01:14:01 +00:00
|
|
|
R2D_SubPic(x, y, 20, 20, p, sx, sy, 20*8, 20*4);
|
2004-08-23 00:15:46 +00:00
|
|
|
x+=20;
|
|
|
|
text++;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2006-03-06 01:41:09 +00:00
|
|
|
mpic_t *QBigFontWorks(void)
|
|
|
|
{
|
|
|
|
mpic_t *p;
|
2011-03-31 01:14:01 +00:00
|
|
|
p = R2D_SafeCachePic ("gfx/mcharset.lmp");
|
2006-03-06 01:41:09 +00:00
|
|
|
if (p)
|
|
|
|
return p;
|
2011-03-31 01:14:01 +00:00
|
|
|
p = R2D_SafeCachePic ("mcharset.lmp");
|
2006-03-06 01:41:09 +00:00
|
|
|
if (p)
|
|
|
|
return p;
|
2011-03-31 01:14:01 +00:00
|
|
|
p = R2D_SafeCachePic ("textures/gfx/mcharset.lmp");
|
2006-03-06 01:41:09 +00:00
|
|
|
if (p)
|
|
|
|
return p;
|
2011-03-31 01:14:01 +00:00
|
|
|
p = R2D_SafeCachePic ("textures/mcharset.lmp");
|
2006-03-06 01:41:09 +00:00
|
|
|
if (p)
|
|
|
|
return p;
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
void Draw_BigFontString(int x, int y, const char *text)
|
|
|
|
{
|
|
|
|
int sx, sy;
|
|
|
|
mpic_t *p;
|
|
|
|
p = QBigFontWorks();
|
|
|
|
if (!p)
|
|
|
|
return;
|
|
|
|
|
|
|
|
if (qrenderer == QR_OPENGL)
|
|
|
|
{ //a hack for scaling
|
|
|
|
p->width = 20*8;
|
|
|
|
p->height = 20*8;
|
|
|
|
}
|
|
|
|
|
|
|
|
while(*text)
|
|
|
|
{
|
|
|
|
if (*text >= 'A' && *text <= 'Z')
|
|
|
|
{
|
|
|
|
sx = ((*text-'A')%8)*(p->width>>3);
|
|
|
|
sy = ((*text-'A')/8)*(p->height>>3);
|
|
|
|
}
|
|
|
|
else if (*text >= 'a' && *text <= 'z')
|
|
|
|
{
|
|
|
|
sx = ((*text-'a'+26)%8)*(p->width>>3);
|
|
|
|
sy = ((*text-'a'+26)/8)*(p->height>>3);
|
|
|
|
}
|
|
|
|
else if (*text >= '0' && *text <= '1')
|
|
|
|
{
|
|
|
|
sx = ((*text-'0'+26*2)%8)*(p->width>>3);
|
|
|
|
sy = ((*text-'0'+26*2)/8)*(p->height>>3);
|
|
|
|
}
|
|
|
|
else if (*text == ':')
|
|
|
|
{
|
|
|
|
sx = ((*text-'0'+26*2+10)%8)*(p->width>>3);
|
|
|
|
sy = ((*text-'0'+26*2+10)/8)*(p->height>>3);
|
|
|
|
}
|
|
|
|
else if (*text == '/')
|
|
|
|
{
|
|
|
|
sx = ((*text-'0'+26*2+11)%8)*(p->width>>3);
|
|
|
|
sy = ((*text-'0'+26*2+11)/8)*(p->height>>3);
|
|
|
|
}
|
|
|
|
else// if (*text <= ' ')
|
|
|
|
{
|
|
|
|
sx=-1;
|
|
|
|
sy=-1;
|
|
|
|
}
|
|
|
|
if(sx>=0)
|
2011-03-31 01:14:01 +00:00
|
|
|
R2D_SubPic(x, y, 20, 20, p, sx, sy, 20*8, 20*8);
|
2006-03-06 01:41:09 +00:00
|
|
|
x+=(p->width>>3);
|
|
|
|
text++;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2004-08-23 00:15:46 +00:00
|
|
|
char *menudotstyle;
|
|
|
|
int maxdots;
|
|
|
|
int mindot;
|
|
|
|
int dotofs;
|
|
|
|
|
2009-04-19 10:50:31 +00:00
|
|
|
void MenuTooltipSplit(menu_t *menu, const char *text)
|
|
|
|
{
|
|
|
|
char buf[1024];
|
|
|
|
char *c, *space;
|
|
|
|
int lines, lnsize, txsize;
|
|
|
|
int lnmax;
|
|
|
|
menutooltip_t *mtt;
|
|
|
|
|
|
|
|
if (menu->tooltip)
|
|
|
|
{
|
|
|
|
Z_Free(menu->tooltip);
|
|
|
|
menu->tooltip = NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!text || !text[0] || vid.width < 320 || vid.height < 200)
|
|
|
|
return;
|
|
|
|
|
|
|
|
// calc a line maximum, use a third of the screen or 30 characters, whichever is bigger
|
2010-01-15 05:35:27 +00:00
|
|
|
lnmax = (vid.width / 24) - 2;
|
2009-04-19 10:50:31 +00:00
|
|
|
if (lnmax < 30)
|
|
|
|
lnmax = 30;
|
|
|
|
// word wrap
|
|
|
|
lines = 1;
|
|
|
|
lnsize = txsize = 0;
|
|
|
|
space = NULL;
|
|
|
|
for (c = buf; *text && txsize < sizeof(buf) - 1; text++)
|
|
|
|
{
|
|
|
|
if (lnsize >= lnmax)
|
|
|
|
{
|
|
|
|
if (space)
|
|
|
|
{
|
|
|
|
lnsize = (c - space) - 1;
|
|
|
|
*space = '\n';
|
|
|
|
space = NULL;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
lnsize = 0;
|
|
|
|
*c = '\n';
|
|
|
|
c++;
|
|
|
|
txsize++;
|
|
|
|
if (txsize >= sizeof(buf) - 1)
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
lines++;
|
|
|
|
}
|
|
|
|
|
|
|
|
*c = *text;
|
|
|
|
switch (*c)
|
|
|
|
{
|
|
|
|
case '\n':
|
|
|
|
lines++;
|
|
|
|
lnsize = 0;
|
|
|
|
space = NULL;
|
|
|
|
break;
|
|
|
|
case ' ':
|
|
|
|
space = c;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
c++;
|
|
|
|
txsize++;
|
|
|
|
lnsize++;
|
|
|
|
}
|
|
|
|
// remove stray newlines at end and terminate string
|
|
|
|
while (txsize > 0 && buf[txsize - 1] == '\n')
|
|
|
|
{
|
|
|
|
lines--;
|
|
|
|
txsize--;
|
|
|
|
}
|
|
|
|
buf[txsize] = '\0';
|
|
|
|
|
|
|
|
// allocate new tooltip structure, copy text to structure
|
|
|
|
mtt = (menutooltip_t *)Z_Malloc(sizeof(menutooltip_t) + sizeof(char *)*lines + txsize + 1);
|
|
|
|
mtt->lines = (char **)(mtt + 1);
|
|
|
|
mtt->rows = lines;
|
|
|
|
Q_memcpy(mtt->lines + lines, buf, txsize + 1);
|
|
|
|
mtt->lines[0] = (char *)(mtt->lines + lines);
|
|
|
|
|
|
|
|
// rescan text, get max column length, convert \n to \0
|
|
|
|
lines = lnmax = txsize = 0;
|
|
|
|
for (c = mtt->lines[0]; *c; c++)
|
|
|
|
{
|
|
|
|
if (*c == '\n')
|
|
|
|
{
|
|
|
|
if (lnmax < txsize)
|
|
|
|
lnmax = txsize;
|
|
|
|
txsize = 0;
|
|
|
|
*c = '\0';
|
|
|
|
mtt->lines[++lines] = c + 1;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
txsize++;
|
|
|
|
}
|
|
|
|
if (lnmax < txsize)
|
|
|
|
lnmax = txsize;
|
|
|
|
mtt->columns = lnmax;
|
|
|
|
|
|
|
|
menu->tooltip = mtt;
|
|
|
|
}
|
|
|
|
|
2009-11-04 21:16:50 +00:00
|
|
|
qboolean MI_Selectable(menuoption_t *op)
|
|
|
|
{
|
|
|
|
switch(op->common.type)
|
|
|
|
{
|
|
|
|
case mt_text:
|
|
|
|
return false;
|
|
|
|
case mt_button:
|
|
|
|
return true;
|
|
|
|
case mt_hexen2buttonbigfont:
|
|
|
|
return true;
|
|
|
|
case mt_qbuttonbigfont:
|
|
|
|
return true;
|
|
|
|
case mt_menudot:
|
|
|
|
return false;
|
|
|
|
case mt_picturesel:
|
|
|
|
return true;
|
|
|
|
case mt_picture:
|
|
|
|
return false;
|
|
|
|
case mt_childwindow:
|
|
|
|
return true;
|
|
|
|
case mt_box:
|
|
|
|
return false;
|
|
|
|
case mt_slider:
|
|
|
|
return true;
|
|
|
|
case mt_checkbox:
|
|
|
|
return true;
|
|
|
|
case mt_edit:
|
|
|
|
return true;
|
|
|
|
case mt_bind:
|
|
|
|
return true;
|
|
|
|
case mt_combo:
|
|
|
|
return true;
|
|
|
|
case mt_custom:
|
|
|
|
return true;
|
|
|
|
default:
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2004-08-23 00:15:46 +00:00
|
|
|
void MenuDrawItems(int xpos, int ypos, menuoption_t *option, menu_t *menu)
|
|
|
|
{
|
|
|
|
int i;
|
2010-01-15 05:35:27 +00:00
|
|
|
mpic_t *p;
|
2010-01-16 04:59:13 +00:00
|
|
|
|
|
|
|
int mgt;
|
|
|
|
|
|
|
|
mgt = M_GameType();
|
|
|
|
|
2004-08-23 00:15:46 +00:00
|
|
|
while (option)
|
|
|
|
{
|
2011-06-07 23:54:58 +00:00
|
|
|
if (mousemoved && !bindingactive && !option->common.ishidden)
|
2004-08-23 00:15:46 +00:00
|
|
|
{
|
2011-06-16 21:41:05 +00:00
|
|
|
if (omousex > xpos+option->common.posx-option->common.extracollide && omousex < xpos+option->common.posx+option->common.width)
|
2010-07-11 02:22:39 +00:00
|
|
|
{
|
2004-08-23 00:15:46 +00:00
|
|
|
if (omousey > ypos+option->common.posy && omousey < ypos+option->common.posy+option->common.height)
|
|
|
|
{
|
2009-11-04 21:16:50 +00:00
|
|
|
if (MI_Selectable(option))
|
2004-09-07 18:19:22 +00:00
|
|
|
{
|
2009-11-04 21:16:50 +00:00
|
|
|
if (menu->selecteditem != option)
|
|
|
|
{
|
|
|
|
if (!option->common.noselectionsound)
|
2010-07-11 02:22:39 +00:00
|
|
|
{
|
|
|
|
if (mgt == MGT_HEXEN2)
|
|
|
|
S_LocalSound ("raven/menu1.wav");
|
|
|
|
else
|
|
|
|
S_LocalSound ("misc/menu1.wav");
|
|
|
|
}
|
|
|
|
|
2009-11-04 21:16:50 +00:00
|
|
|
menu->selecteditem = option;
|
|
|
|
menu->tooltiptime = realtime + 1;
|
|
|
|
MenuTooltipSplit(menu, menu->selecteditem->common.tooltip);
|
|
|
|
}
|
|
|
|
if (menu->cursoritem)
|
|
|
|
menu->cursoritem->common.posy = menu->selecteditem->common.posy;
|
2004-09-07 18:19:22 +00:00
|
|
|
}
|
2004-08-23 00:15:46 +00:00
|
|
|
}
|
2010-07-11 02:22:39 +00:00
|
|
|
}
|
2004-08-23 00:15:46 +00:00
|
|
|
}
|
2005-01-26 18:56:49 +00:00
|
|
|
if (!option->common.ishidden)
|
2004-08-23 00:15:46 +00:00
|
|
|
switch(option->common.type)
|
|
|
|
{
|
|
|
|
case mt_text:
|
|
|
|
if (!option->text.text)
|
2009-11-04 21:16:50 +00:00
|
|
|
{
|
|
|
|
if ((int)(realtime*4)&1)
|
|
|
|
Draw_FunString(xpos+option->common.posx, ypos+option->common.posy, "^Ue00d");
|
|
|
|
}
|
2004-08-23 00:15:46 +00:00
|
|
|
else if (option->text.isred)
|
2009-11-04 21:16:50 +00:00
|
|
|
Draw_AltFunString(xpos+option->common.posx, ypos+option->common.posy, option->text.text);
|
2004-08-23 00:15:46 +00:00
|
|
|
else
|
2009-11-04 21:16:50 +00:00
|
|
|
Draw_FunString(xpos+option->common.posx, ypos+option->common.posy, option->text.text);
|
2004-08-23 00:15:46 +00:00
|
|
|
break;
|
|
|
|
case mt_button:
|
|
|
|
if (!menu->cursoritem && menu->selecteditem == option)
|
2009-11-04 21:16:50 +00:00
|
|
|
Draw_AltFunString(xpos+option->common.posx, ypos+option->common.posy, option->button.text);
|
2004-08-23 00:15:46 +00:00
|
|
|
else
|
2009-11-04 21:16:50 +00:00
|
|
|
Draw_FunString(xpos+option->common.posx, ypos+option->common.posy, option->button.text);
|
2004-08-23 00:15:46 +00:00
|
|
|
break;
|
2006-03-06 01:41:09 +00:00
|
|
|
case mt_hexen2buttonbigfont:
|
|
|
|
Draw_Hexen2BigFontString(xpos+option->common.posx, ypos+option->common.posy, option->button.text);
|
|
|
|
break;
|
|
|
|
case mt_qbuttonbigfont:
|
2004-08-23 00:15:46 +00:00
|
|
|
Draw_BigFontString(xpos+option->common.posx, ypos+option->common.posy, option->button.text);
|
|
|
|
break;
|
|
|
|
case mt_menudot:
|
|
|
|
i = (int)(realtime * 10)%maxdots;
|
2011-03-31 01:14:01 +00:00
|
|
|
p = R2D_SafeCachePic(va(menudotstyle, i+mindot ));
|
|
|
|
R2D_ScalePic(xpos+option->common.posx, ypos+option->common.posy+dotofs, 20, 20, p);
|
2004-08-23 00:15:46 +00:00
|
|
|
break;
|
2006-05-11 00:41:47 +00:00
|
|
|
case mt_picturesel:
|
2004-08-23 00:15:46 +00:00
|
|
|
p = NULL;
|
|
|
|
if (menu->selecteditem && menu->selecteditem->common.posx == option->common.posx && menu->selecteditem->common.posy == option->common.posy)
|
2006-01-21 00:06:49 +00:00
|
|
|
{
|
|
|
|
char selname[MAX_QPATH];
|
|
|
|
Q_strncpyz(selname, option->picture.picturename, sizeof(selname));
|
2006-03-11 03:12:10 +00:00
|
|
|
COM_StripExtension(selname, selname, sizeof(selname));
|
2006-05-11 00:41:47 +00:00
|
|
|
Q_strncatz(selname, "_sel", sizeof(selname));
|
2011-03-31 01:14:01 +00:00
|
|
|
p = R2D_SafeCachePic(selname);
|
2006-01-21 00:06:49 +00:00
|
|
|
}
|
2004-08-23 00:15:46 +00:00
|
|
|
if (!p)
|
2011-03-31 01:14:01 +00:00
|
|
|
p = R2D_SafeCachePic(option->picture.picturename);
|
2004-08-23 00:15:46 +00:00
|
|
|
|
2011-03-31 01:14:01 +00:00
|
|
|
R2D_ScalePic(xpos+option->common.posx, ypos+option->common.posy, option->common.width?option->common.width:p->width, option->common.height?option->common.height:p->height, p);
|
2004-08-23 00:15:46 +00:00
|
|
|
break;
|
2006-05-11 00:41:47 +00:00
|
|
|
case mt_picture:
|
2011-03-31 01:14:01 +00:00
|
|
|
p = R2D_SafeCachePic(option->picture.picturename);
|
|
|
|
if (p) R2D_ScalePic(xpos+option->common.posx, ypos+option->common.posy, option->common.width, option->common.height, p);
|
2006-02-28 00:46:04 +00:00
|
|
|
break;
|
2004-08-23 00:15:46 +00:00
|
|
|
case mt_childwindow:
|
|
|
|
MenuDrawItems(xpos+option->common.posx, ypos+option->common.posy, ((menu_t *)option->custom.data)->options, (menu_t *)option->custom.data);
|
|
|
|
break;
|
|
|
|
case mt_box:
|
|
|
|
Draw_TextBox(xpos+option->common.posx, ypos+option->common.posy, option->box.width, option->box.height);
|
|
|
|
break;
|
|
|
|
case mt_slider:
|
|
|
|
if (option->slider.var)
|
|
|
|
{
|
|
|
|
#define SLIDER_RANGE 10
|
2004-09-07 23:15:19 +00:00
|
|
|
float range;
|
2004-08-23 00:15:46 +00:00
|
|
|
int i;
|
|
|
|
int x = xpos+option->common.posx;
|
|
|
|
int y = ypos+option->common.posy;
|
2009-11-04 21:16:50 +00:00
|
|
|
int s;
|
2004-08-23 00:15:46 +00:00
|
|
|
|
2004-09-07 23:15:19 +00:00
|
|
|
range = (option->slider.current - option->slider.min)/(option->slider.max-option->slider.min);
|
|
|
|
|
2004-08-23 00:15:46 +00:00
|
|
|
if (option->slider.text)
|
|
|
|
{
|
|
|
|
if (!menu->cursoritem && menu->selecteditem == option)
|
2009-11-04 21:16:50 +00:00
|
|
|
Draw_AltFunString(x, y, option->slider.text);
|
2004-08-23 00:15:46 +00:00
|
|
|
else
|
2009-11-04 21:16:50 +00:00
|
|
|
Draw_FunString(x, y, option->slider.text);
|
2004-08-23 00:15:46 +00:00
|
|
|
x += strlen(option->slider.text)*8+28;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (range < 0)
|
|
|
|
range = 0;
|
|
|
|
if (range > 1)
|
|
|
|
range = 1;
|
2009-11-04 21:16:50 +00:00
|
|
|
x -= 8;
|
|
|
|
Font_BeginString(font_conchar, x, y, &x, &y);
|
|
|
|
x = Font_DrawChar(x, y, 0xe080 | CON_WHITEMASK);
|
|
|
|
s = x;
|
2004-08-23 00:15:46 +00:00
|
|
|
for (i=0 ; i<SLIDER_RANGE ; i++)
|
2009-11-04 21:16:50 +00:00
|
|
|
x = Font_DrawChar(x, y, 0xe081 | CON_WHITEMASK);
|
|
|
|
Font_DrawChar(x, y, 0xe082 | CON_WHITEMASK);
|
|
|
|
Font_DrawChar(s + (x-s) * range - Font_CharWidth(0xe083 | CON_WHITEMASK)/2, y, 0xe083 | CON_WHITEMASK);
|
|
|
|
Font_EndString(font_conchar);
|
2004-08-23 00:15:46 +00:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
case mt_checkbox:
|
|
|
|
{
|
|
|
|
int x = xpos+option->common.posx;
|
|
|
|
int y = ypos+option->common.posy;
|
|
|
|
qboolean on;
|
|
|
|
if (option->check.func)
|
2006-02-28 00:46:04 +00:00
|
|
|
on = option->check.func(&option->check, menu, CHK_CHECKED);
|
2004-08-23 00:15:46 +00:00
|
|
|
else if (!option->check.var)
|
2004-09-13 03:10:10 +00:00
|
|
|
on = option->check.value;
|
|
|
|
else if (option->check.bits) //bits is a bitmask for use with cvars (users can be clumsy, so bittage of 0 uses non-zero as true, but sets only bit 1)
|
|
|
|
{
|
|
|
|
if (option->check.var->latched_string)
|
|
|
|
on = atoi(option->check.var->latched_string)&option->check.bits;
|
|
|
|
else
|
|
|
|
on = (int)(option->check.var->value)&option->check.bits;
|
|
|
|
}
|
2004-08-23 00:15:46 +00:00
|
|
|
else
|
2004-09-13 03:10:10 +00:00
|
|
|
{
|
|
|
|
if (option->check.var->latched_string)
|
|
|
|
on = !!atof(option->check.var->latched_string);
|
|
|
|
else
|
|
|
|
on = !!option->check.var->value;
|
|
|
|
}
|
2004-08-23 00:15:46 +00:00
|
|
|
|
|
|
|
if (option->check.text)
|
|
|
|
{
|
|
|
|
if (!menu->cursoritem && menu->selecteditem == option)
|
2009-11-04 21:16:50 +00:00
|
|
|
Draw_AltFunString(x, y, option->check.text);
|
2004-08-23 00:15:46 +00:00
|
|
|
else
|
2009-11-04 21:16:50 +00:00
|
|
|
Draw_FunString(x, y, option->check.text);
|
2004-08-23 00:15:46 +00:00
|
|
|
x += strlen(option->check.text)*8+28;
|
|
|
|
}
|
|
|
|
#if 0
|
|
|
|
if (on)
|
|
|
|
Draw_Character (x, y, 131);
|
|
|
|
else
|
|
|
|
Draw_Character (x, y, 129);
|
|
|
|
#endif
|
2006-03-23 06:45:17 +00:00
|
|
|
if (!menu->cursoritem && menu->selecteditem == option)
|
2009-11-04 21:16:50 +00:00
|
|
|
Draw_AltFunString (x, y, on ? "on" : "off");
|
2004-08-23 00:15:46 +00:00
|
|
|
else
|
2009-11-04 21:16:50 +00:00
|
|
|
Draw_FunString (x, y, on ? "on" : "off");
|
2004-08-23 00:15:46 +00:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
case mt_edit:
|
|
|
|
{
|
|
|
|
int x = xpos+option->common.posx;
|
|
|
|
int y = ypos+option->common.posy;
|
|
|
|
|
2009-11-04 21:16:50 +00:00
|
|
|
//Fixme: variable width fonts
|
2004-08-23 00:15:46 +00:00
|
|
|
if (!menu->cursoritem && menu->selecteditem == option)
|
2009-11-04 21:16:50 +00:00
|
|
|
Draw_AltFunString(x, y, option->edit.caption);
|
2004-08-23 00:15:46 +00:00
|
|
|
else
|
2009-11-04 21:16:50 +00:00
|
|
|
Draw_FunString(x, y, option->edit.caption);
|
2004-08-23 00:15:46 +00:00
|
|
|
x+=strlen(option->edit.caption)*8+8;
|
2011-06-07 23:54:58 +00:00
|
|
|
if (option->edit.slim)
|
|
|
|
x += 8; // more space for cursor
|
|
|
|
else
|
|
|
|
Draw_TextBox(x-8, y-8, 16, 1);
|
2009-11-04 21:16:50 +00:00
|
|
|
Draw_FunString(x, y, option->edit.text);
|
2004-08-23 00:15:46 +00:00
|
|
|
|
|
|
|
if (menu->selecteditem == option && (int)(realtime*4) & 1)
|
|
|
|
{
|
|
|
|
x += strlen(option->edit.text)*8;
|
2009-11-04 21:16:50 +00:00
|
|
|
Draw_FunString(x, y, "^Ue00b");
|
2004-08-23 00:15:46 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
break;
|
2004-09-07 18:19:22 +00:00
|
|
|
case mt_bind:
|
|
|
|
{
|
|
|
|
int x = xpos+option->common.posx;
|
|
|
|
int y = ypos+option->common.posy;
|
|
|
|
int l;
|
|
|
|
int keys[2];
|
|
|
|
char *keyname;
|
|
|
|
|
|
|
|
if (!menu->cursoritem && menu->selecteditem == option)
|
2009-11-04 21:16:50 +00:00
|
|
|
Draw_AltFunString(x, y, option->bind.caption);
|
2004-09-07 18:19:22 +00:00
|
|
|
else
|
2009-11-04 21:16:50 +00:00
|
|
|
Draw_FunString(x, y, option->bind.caption);
|
2004-09-07 18:19:22 +00:00
|
|
|
x += strlen(option->bind.caption)*8+28;
|
|
|
|
{
|
2010-08-16 02:03:02 +00:00
|
|
|
extern cvar_t cl_forcesplitclient;
|
2004-09-07 18:19:22 +00:00
|
|
|
l = strlen (option->bind.command);
|
2010-01-15 05:35:27 +00:00
|
|
|
|
2010-08-16 02:03:02 +00:00
|
|
|
M_FindKeysForCommand (cl_forcesplitclient.ival, option->bind.command, keys);
|
2010-01-15 05:35:27 +00:00
|
|
|
|
2004-09-07 18:19:22 +00:00
|
|
|
if (bindingactive && menu->selecteditem == option)
|
|
|
|
{
|
2009-11-04 21:16:50 +00:00
|
|
|
Draw_FunString (x, y, "Press key");
|
2004-09-07 18:19:22 +00:00
|
|
|
}
|
|
|
|
else if (keys[0] == -1)
|
|
|
|
{
|
2009-11-04 21:16:50 +00:00
|
|
|
Draw_FunString (x, y, "???");
|
2004-09-07 18:19:22 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
keyname = Key_KeynumToString (keys[0]);
|
2009-11-04 21:16:50 +00:00
|
|
|
Draw_FunString (x, y, keyname);
|
2004-09-07 18:19:22 +00:00
|
|
|
x += strlen(keyname) * 8;
|
|
|
|
if (keys[1] != -1)
|
2009-11-04 21:16:50 +00:00
|
|
|
{ /*these offsets are wrong*/
|
|
|
|
Draw_FunString (x + 8, y, "or");
|
|
|
|
Draw_FunString (x + 32, y, Key_KeynumToString (keys[1]));
|
2004-09-07 18:19:22 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
2004-08-23 00:15:46 +00:00
|
|
|
case mt_combo:
|
|
|
|
{
|
|
|
|
int x = xpos+option->common.posx;
|
|
|
|
int y = ypos+option->common.posy;
|
|
|
|
|
2007-01-08 03:13:03 +00:00
|
|
|
if (!menu->cursoritem && menu->selecteditem == option)
|
2009-11-04 21:16:50 +00:00
|
|
|
Draw_AltFunString(x, y, option->combo.caption);
|
2007-01-08 03:13:03 +00:00
|
|
|
else
|
2009-11-04 21:16:50 +00:00
|
|
|
Draw_FunString(x, y, option->combo.caption);
|
2004-08-23 00:15:46 +00:00
|
|
|
x += strlen(option->combo.caption)*8+24;
|
2007-01-08 03:13:03 +00:00
|
|
|
if (option->combo.numoptions)
|
|
|
|
{
|
|
|
|
if (!menu->cursoritem && menu->selecteditem == option)
|
2009-11-04 21:16:50 +00:00
|
|
|
Draw_AltFunString(x, y, option->combo.options[option->combo.selectedoption]);
|
2007-01-08 03:13:03 +00:00
|
|
|
else
|
2009-11-04 21:16:50 +00:00
|
|
|
Draw_FunString(x, y, option->combo.options[option->combo.selectedoption]);
|
2007-01-08 03:13:03 +00:00
|
|
|
}
|
2004-08-23 00:15:46 +00:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
case mt_custom:
|
|
|
|
option->custom.draw(xpos+option->common.posx, ypos+option->common.posy, &option->custom, menu);
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
Sys_Error("Bad item type\n");
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
option = option->common.next;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void MenuDraw(menu_t *menu)
|
|
|
|
{
|
|
|
|
if (menu->event)
|
|
|
|
menu->event(menu);
|
2006-02-28 00:46:04 +00:00
|
|
|
if (!menu->dontexpand)
|
|
|
|
menu->xpos = ((vid.width - 320)>>1);
|
2004-08-23 00:15:46 +00:00
|
|
|
MenuDrawItems(menu->xpos, menu->ypos, menu->options, menu);
|
2009-04-19 10:50:31 +00:00
|
|
|
// draw tooltip
|
|
|
|
if (menu->selecteditem && menu->tooltip && realtime > menu->tooltiptime)
|
|
|
|
{
|
|
|
|
menuoption_t *option = menu->selecteditem;
|
|
|
|
if (omousex > menu->xpos+option->common.posx && omousex < menu->xpos+option->common.posx+option->common.width)
|
|
|
|
if (omousey > menu->ypos+option->common.posy && omousey < menu->ypos+option->common.posy+option->common.height)
|
|
|
|
{
|
|
|
|
int x = omousex;
|
|
|
|
int y = omousey;
|
|
|
|
int w = (menu->tooltip->columns + 3) * 8;
|
|
|
|
int h = (menu->tooltip->rows + 2) * 8;
|
|
|
|
int l, lines;
|
|
|
|
|
|
|
|
// keep the tooltip within view
|
|
|
|
if (x + w >= vid.width)
|
|
|
|
x = vid.width - w - 1;
|
|
|
|
if (y + h >= vid.height)
|
|
|
|
y -= h;
|
|
|
|
|
|
|
|
// draw tooltip
|
|
|
|
Draw_TextBox(x, y, menu->tooltip->columns, menu->tooltip->rows);
|
|
|
|
lines = menu->tooltip->rows;
|
|
|
|
x += 8;
|
|
|
|
y += 8;
|
|
|
|
for (l = 0; l < lines; l++)
|
|
|
|
{
|
2009-11-04 21:16:50 +00:00
|
|
|
Draw_FunString(x, y, menu->tooltip->lines[l]);
|
2009-04-19 10:50:31 +00:00
|
|
|
y += 8;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2004-08-23 00:15:46 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
menutext_t *MC_AddWhiteText(menu_t *menu, int x, int y, const char *text, qboolean rightalign)
|
|
|
|
{
|
|
|
|
menutext_t *n = Z_Malloc(sizeof(menutext_t));
|
|
|
|
n->common.type = mt_text;
|
2010-01-15 05:35:27 +00:00
|
|
|
n->common.iszone = true;
|
2004-08-23 00:15:46 +00:00
|
|
|
n->common.posx = x;
|
|
|
|
n->common.posy = y;
|
|
|
|
n->text = text;
|
|
|
|
|
|
|
|
if (rightalign && text)
|
|
|
|
n->common.posx -= strlen(text)*8;
|
|
|
|
|
|
|
|
n->common.next = menu->options;
|
|
|
|
menu->options = (menuoption_t *)n;
|
|
|
|
return n;
|
|
|
|
}
|
|
|
|
|
|
|
|
menutext_t *MC_AddBufferedText(menu_t *menu, int x, int y, const char *text, qboolean rightalign, qboolean red)
|
|
|
|
{
|
|
|
|
menutext_t *n = Z_Malloc(sizeof(menutext_t) + strlen(text)+1);
|
|
|
|
n->common.type = mt_text;
|
2010-01-15 05:35:27 +00:00
|
|
|
n->common.iszone = true;
|
2004-08-23 00:15:46 +00:00
|
|
|
n->common.posx = x;
|
|
|
|
n->common.posy = y;
|
|
|
|
n->text = (char *)(n+1);
|
|
|
|
strcpy((char *)(n+1), text);
|
|
|
|
n->isred = red;
|
|
|
|
|
|
|
|
if (rightalign && text)
|
|
|
|
n->common.posx -= strlen(text)*8;
|
|
|
|
|
|
|
|
n->common.next = menu->options;
|
|
|
|
menu->options = (menuoption_t *)n;
|
|
|
|
return n;
|
|
|
|
}
|
|
|
|
|
|
|
|
menutext_t *MC_AddRedText(menu_t *menu, int x, int y, const char *text, qboolean rightalign)
|
|
|
|
{
|
|
|
|
menutext_t *n;
|
|
|
|
n = MC_AddWhiteText(menu, x, y, text, false);
|
|
|
|
n->isred = true;
|
|
|
|
return n;
|
|
|
|
}
|
|
|
|
|
2004-09-07 18:19:22 +00:00
|
|
|
menubind_t *MC_AddBind(menu_t *menu, int x, int y, const char *caption, char *command)
|
|
|
|
{
|
|
|
|
menubind_t *n = Z_Malloc(sizeof(menutext_t) + strlen(caption)+1 + strlen(command)+1);
|
|
|
|
n->common.type = mt_bind;
|
2010-01-15 05:35:27 +00:00
|
|
|
n->common.iszone = true;
|
2004-09-07 18:19:22 +00:00
|
|
|
n->common.posx = x;
|
|
|
|
n->common.posy = y;
|
|
|
|
n->caption = (char *)(n+1);
|
|
|
|
strcpy(n->caption, caption);
|
|
|
|
n->command = n->caption+strlen(n->caption)+1;
|
|
|
|
strcpy(n->command, command);
|
2006-01-28 06:41:20 +00:00
|
|
|
n->common.width = strlen(caption)*8 + 64;
|
|
|
|
n->common.height = 8;
|
2004-09-07 18:19:22 +00:00
|
|
|
|
|
|
|
n->common.next = menu->options;
|
|
|
|
menu->options = (menuoption_t *)n;
|
|
|
|
return n;
|
|
|
|
}
|
|
|
|
|
2006-05-11 00:41:47 +00:00
|
|
|
menupicture_t *MC_AddSelectablePicture(menu_t *menu, int x, int y, char *picname)
|
|
|
|
{
|
|
|
|
char selname[MAX_QPATH];
|
|
|
|
menupicture_t *n;
|
|
|
|
|
2010-02-06 01:25:04 +00:00
|
|
|
if (qrenderer == QR_NONE)
|
2006-05-11 00:41:47 +00:00
|
|
|
return NULL;
|
|
|
|
|
|
|
|
Q_strncpyz(selname, picname, sizeof(selname));
|
|
|
|
COM_StripExtension(selname, selname, sizeof(selname));
|
|
|
|
Q_strncatz(selname, "_sel", sizeof(selname));
|
|
|
|
|
2011-03-31 01:14:01 +00:00
|
|
|
R2D_SafeCachePic(picname);
|
|
|
|
R2D_SafeCachePic(selname);
|
2006-05-11 00:41:47 +00:00
|
|
|
|
|
|
|
n = Z_Malloc(sizeof(menupicture_t) + strlen(picname)+1);
|
|
|
|
n->common.type = mt_picturesel;
|
|
|
|
n->common.iszone = true;
|
|
|
|
n->common.posx = x;
|
|
|
|
n->common.posy = y;
|
|
|
|
n->picturename = (char *)(n+1);
|
|
|
|
strcpy(n->picturename, picname);
|
|
|
|
|
|
|
|
n->common.next = menu->options;
|
|
|
|
menu->options = (menuoption_t *)n;
|
|
|
|
return n;
|
|
|
|
}
|
|
|
|
|
2009-11-04 21:16:50 +00:00
|
|
|
menupicture_t *MC_AddPicture(menu_t *menu, int x, int y, int width, int height, char *picname)
|
2004-08-23 00:15:46 +00:00
|
|
|
{
|
|
|
|
menupicture_t *n;
|
2010-02-06 01:25:04 +00:00
|
|
|
if (qrenderer == QR_NONE)
|
2004-08-23 00:15:46 +00:00
|
|
|
return NULL;
|
|
|
|
|
2011-03-31 01:14:01 +00:00
|
|
|
R2D_SafeCachePic(picname);
|
2004-08-23 00:15:46 +00:00
|
|
|
|
|
|
|
n = Z_Malloc(sizeof(menupicture_t) + strlen(picname)+1);
|
|
|
|
n->common.type = mt_picture;
|
|
|
|
n->common.iszone = true;
|
|
|
|
n->common.posx = x;
|
|
|
|
n->common.posy = y;
|
2006-02-28 00:46:04 +00:00
|
|
|
n->common.width = width;
|
|
|
|
n->common.height = height;
|
|
|
|
n->picturename = (char *)(n+1);
|
|
|
|
strcpy(n->picturename, picname);
|
|
|
|
|
|
|
|
n->common.next = menu->options;
|
|
|
|
menu->options = (menuoption_t *)n;
|
|
|
|
return n;
|
|
|
|
}
|
|
|
|
|
2009-11-04 21:16:50 +00:00
|
|
|
menupicture_t *MC_AddCenterPicture(menu_t *menu, int y, int height, char *picname)
|
2004-08-23 00:15:46 +00:00
|
|
|
{
|
|
|
|
int x;
|
2009-11-04 21:16:50 +00:00
|
|
|
int width;
|
2004-12-24 08:45:56 +00:00
|
|
|
mpic_t *p;
|
2004-08-23 00:15:46 +00:00
|
|
|
|
2010-02-06 01:25:04 +00:00
|
|
|
if (qrenderer == QR_NONE)
|
2004-08-23 00:15:46 +00:00
|
|
|
return NULL;
|
2011-03-31 01:14:01 +00:00
|
|
|
p = R2D_SafeCachePic(picname);
|
2004-08-23 00:15:46 +00:00
|
|
|
if (!p)
|
2009-11-04 21:16:50 +00:00
|
|
|
{
|
2004-08-23 00:15:46 +00:00
|
|
|
x = 320/2;
|
2009-11-04 21:16:50 +00:00
|
|
|
width = 64;
|
|
|
|
}
|
2004-08-23 00:15:46 +00:00
|
|
|
else
|
2009-11-04 21:16:50 +00:00
|
|
|
{
|
|
|
|
width = (p->width * (float)height) / p->height;
|
|
|
|
x = (320-(int)width)/2;
|
|
|
|
}
|
2004-08-23 00:15:46 +00:00
|
|
|
|
2009-11-04 21:16:50 +00:00
|
|
|
return MC_AddPicture(menu, x, y, width, height, picname);
|
2004-08-23 00:15:46 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
menupicture_t *MC_AddCursor(menu_t *menu, int x, int y)
|
|
|
|
{
|
2005-03-15 22:51:01 +00:00
|
|
|
int mgt;
|
2004-08-23 00:15:46 +00:00
|
|
|
menupicture_t *n = Z_Malloc(sizeof(menupicture_t));
|
|
|
|
n->common.type = mt_menudot;
|
|
|
|
n->common.iszone = true;
|
|
|
|
n->common.posx = x;
|
|
|
|
n->common.posy = y;
|
|
|
|
|
|
|
|
n->common.next = menu->options;
|
|
|
|
menu->options = (menuoption_t *)n;
|
|
|
|
|
|
|
|
|
2005-03-15 22:51:01 +00:00
|
|
|
mgt = M_GameType();
|
|
|
|
if (mgt == MGT_QUAKE2)
|
2004-08-23 00:15:46 +00:00
|
|
|
{ //AND QUAKE 2 WINS!!!
|
|
|
|
menudotstyle = "m_cursor%i";
|
|
|
|
mindot = 0;
|
|
|
|
maxdots = 15;
|
|
|
|
dotofs=0;
|
|
|
|
}
|
2005-03-15 22:51:01 +00:00
|
|
|
else if (mgt == MGT_HEXEN2)
|
2004-08-23 00:15:46 +00:00
|
|
|
{ //AND THE WINNER IS HEXEN 2!!!
|
|
|
|
menudotstyle = "gfx/menu/menudot%i.lmp";
|
|
|
|
mindot = 1;
|
|
|
|
maxdots = 8;
|
2010-08-12 00:48:05 +00:00
|
|
|
dotofs=-2;
|
2004-08-23 00:15:46 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{ //QUAKE 1 WINS BY DEFAULT!
|
|
|
|
menudotstyle = "gfx/menudot%i.lmp";
|
|
|
|
mindot = 1;
|
|
|
|
maxdots = 6;
|
|
|
|
dotofs=0;
|
|
|
|
}
|
|
|
|
return n;
|
|
|
|
}
|
|
|
|
|
|
|
|
menuedit_t *MC_AddEdit(menu_t *menu, int x, int y, char *text, char *def)
|
|
|
|
{
|
|
|
|
menuedit_t *n = Z_Malloc(sizeof(menuedit_t));
|
|
|
|
n->common.type = mt_edit;
|
2010-01-15 05:35:27 +00:00
|
|
|
n->common.iszone = true;
|
2004-08-23 00:15:46 +00:00
|
|
|
n->common.posx = x;
|
|
|
|
n->common.posy = y;
|
2005-02-12 18:56:04 +00:00
|
|
|
n->modified = true;
|
2004-08-23 00:15:46 +00:00
|
|
|
n->caption = text;
|
|
|
|
Q_strncpyz(n->text, def, sizeof(n->text));
|
|
|
|
|
|
|
|
n->common.next = menu->options;
|
|
|
|
menu->options = (menuoption_t *)n;
|
|
|
|
return n;
|
|
|
|
}
|
|
|
|
|
2011-06-07 23:54:58 +00:00
|
|
|
menuedit_t *MC_AddEditCvar_Full(menu_t *menu, int x, int y, char *text, char *name, qboolean isslim)
|
2004-08-23 00:15:46 +00:00
|
|
|
{
|
|
|
|
menuedit_t *n = Z_Malloc(sizeof(menuedit_t)+strlen(text)+1);
|
|
|
|
cvar_t *cvar;
|
|
|
|
cvar = Cvar_Get(name, "", CVAR_USERCREATED|CVAR_ARCHIVE, NULL); //well, this is a menu/
|
|
|
|
n->common.type = mt_edit;
|
2010-01-15 05:35:27 +00:00
|
|
|
n->common.iszone = true;
|
2004-08-23 00:15:46 +00:00
|
|
|
n->common.posx = x;
|
|
|
|
n->common.posy = y;
|
|
|
|
n->common.width = (strlen(text)+17)*8;
|
|
|
|
n->common.height = 8;
|
2010-07-11 02:22:39 +00:00
|
|
|
n->common.tooltip = cvar->description;
|
2005-02-12 18:56:04 +00:00
|
|
|
n->modified = true;
|
2004-08-23 00:15:46 +00:00
|
|
|
n->caption = (char *)(n+1);
|
|
|
|
strcpy((char *)(n+1), text);
|
|
|
|
n->cvar = cvar;
|
2006-03-06 01:41:09 +00:00
|
|
|
if (!(cvar->flags & CVAR_ARCHIVE))
|
|
|
|
Con_Printf("Warning: %s is not set for archiving\n", cvar->name);
|
2004-08-23 00:15:46 +00:00
|
|
|
Q_strncpyz(n->text, cvar->string, sizeof(n->text));
|
|
|
|
|
|
|
|
n->common.next = menu->options;
|
2011-06-07 23:54:58 +00:00
|
|
|
n->slim = isslim;
|
2004-08-23 00:15:46 +00:00
|
|
|
menu->options = (menuoption_t *)n;
|
|
|
|
return n;
|
|
|
|
}
|
|
|
|
|
2011-06-07 23:54:58 +00:00
|
|
|
menuedit_t *MC_AddEditCvarSlim(menu_t *menu, int x, int y, char *text, char *name)
|
|
|
|
{
|
|
|
|
return MC_AddEditCvar_Full(menu, x, y, text, name, true);
|
|
|
|
}
|
|
|
|
|
|
|
|
menuedit_t *MC_AddEditCvar(menu_t *menu, int x, int y, char *text, char *name)
|
|
|
|
{
|
|
|
|
return MC_AddEditCvar_Full(menu, x, y, text, name, false);
|
|
|
|
}
|
|
|
|
|
2004-08-23 00:15:46 +00:00
|
|
|
menubox_t *MC_AddBox(menu_t *menu, int x, int y, int width, int height)
|
|
|
|
{
|
2005-06-19 09:08:47 +00:00
|
|
|
menubox_t *n = Z_Malloc(sizeof(menubox_t));
|
2004-08-23 00:15:46 +00:00
|
|
|
n->common.type = mt_box;
|
|
|
|
n->common.iszone = true;
|
|
|
|
n->common.posx = x;
|
|
|
|
n->common.posy = y;
|
|
|
|
n->width = width;
|
|
|
|
n->height = height;
|
|
|
|
|
|
|
|
n->common.next = menu->options;
|
|
|
|
menu->options = (menuoption_t *)n;
|
|
|
|
return n;
|
|
|
|
}
|
|
|
|
|
2006-01-28 06:41:20 +00:00
|
|
|
menucustom_t *MC_AddCustom(menu_t *menu, int x, int y, void *data)
|
2004-08-23 00:15:46 +00:00
|
|
|
{
|
|
|
|
menucustom_t *n = Z_Malloc(sizeof(menucustom_t));
|
|
|
|
n->common.type = mt_custom;
|
|
|
|
n->common.iszone = true;
|
|
|
|
n->common.posx = x;
|
|
|
|
n->common.posy = y;
|
2006-01-28 06:41:20 +00:00
|
|
|
n->data = data;
|
2004-08-23 00:15:46 +00:00
|
|
|
|
|
|
|
n->common.next = menu->options;
|
|
|
|
menu->options = (menuoption_t *)n;
|
|
|
|
return n;
|
|
|
|
}
|
|
|
|
|
2004-09-13 03:10:10 +00:00
|
|
|
menucheck_t *MC_AddCheckBox(menu_t *menu, int x, int y, const char *text, cvar_t *var, int bits)
|
2004-08-23 00:15:46 +00:00
|
|
|
{
|
|
|
|
menucheck_t *n = Z_Malloc(sizeof(menucheck_t)+strlen(text)+1);
|
|
|
|
n->common.type = mt_checkbox;
|
2010-01-15 05:35:27 +00:00
|
|
|
n->common.iszone = true;
|
2004-08-23 00:15:46 +00:00
|
|
|
n->common.posx = x;
|
|
|
|
n->common.posy = y;
|
|
|
|
n->common.height = 8;
|
|
|
|
n->common.width = (strlen(text)+7)*8;
|
2010-07-11 02:22:39 +00:00
|
|
|
n->common.tooltip = var?var->description:NULL;
|
2004-08-23 00:15:46 +00:00
|
|
|
n->text = (char *)(n+1);
|
|
|
|
strcpy((char *)(n+1), text);
|
|
|
|
n->var = var;
|
2004-09-13 03:10:10 +00:00
|
|
|
n->bits = bits;
|
2004-08-23 00:15:46 +00:00
|
|
|
|
2010-01-15 05:35:27 +00:00
|
|
|
#ifdef _DEBUG
|
2006-03-06 01:41:09 +00:00
|
|
|
if (var)
|
|
|
|
if (!(var->flags & CVAR_ARCHIVE))
|
|
|
|
Con_Printf("Warning: %s is not set for archiving\n", var->name);
|
2010-01-15 05:35:27 +00:00
|
|
|
else if (var->flags & CVAR_RENDERERLATCH)
|
2009-12-29 14:00:56 +00:00
|
|
|
Con_Printf("Warning: %s requires a vid_restart\n", var->name);
|
2010-01-15 05:35:27 +00:00
|
|
|
#endif
|
2006-03-06 01:41:09 +00:00
|
|
|
|
2004-08-23 00:15:46 +00:00
|
|
|
n->common.next = menu->options;
|
|
|
|
menu->options = (menuoption_t *)n;
|
|
|
|
return n;
|
|
|
|
}
|
2006-02-28 00:46:04 +00:00
|
|
|
menucheck_t *MC_AddCheckBoxFunc(menu_t *menu, int x, int y, const char *text, qboolean (*func) (menucheck_t *option, menu_t *menu, chk_set_t set), int bits)
|
|
|
|
{
|
|
|
|
menucheck_t *n = Z_Malloc(sizeof(menucheck_t)+strlen(text)+1);
|
|
|
|
n->common.type = mt_checkbox;
|
2010-01-15 05:35:27 +00:00
|
|
|
n->common.iszone = true;
|
2006-02-28 00:46:04 +00:00
|
|
|
n->common.posx = x;
|
|
|
|
n->common.posy = y;
|
|
|
|
n->common.height = 8;
|
|
|
|
n->common.width = (strlen(text)+7)*8;
|
|
|
|
n->text = (char *)(n+1);
|
|
|
|
strcpy((char *)(n+1), text);
|
|
|
|
n->func = func;
|
|
|
|
n->bits = bits;
|
|
|
|
|
|
|
|
n->common.next = menu->options;
|
|
|
|
menu->options = (menuoption_t *)n;
|
|
|
|
return n;
|
|
|
|
}
|
|
|
|
|
2007-05-25 22:16:29 +00:00
|
|
|
//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)
|
2010-01-15 05:35:27 +00:00
|
|
|
{
|
2004-08-23 00:15:46 +00:00
|
|
|
menuslider_t *n = Z_Malloc(sizeof(menuslider_t)+strlen(text)+1);
|
|
|
|
n->common.type = mt_slider;
|
2010-01-15 05:35:27 +00:00
|
|
|
n->common.iszone = true;
|
2004-08-23 00:15:46 +00:00
|
|
|
n->common.posx = x;
|
|
|
|
n->common.posy = y;
|
|
|
|
n->common.height = 8;
|
|
|
|
n->common.width = (strlen(text)+SLIDER_RANGE+5)*8;
|
2010-07-11 02:22:39 +00:00
|
|
|
n->common.tooltip = var->description;
|
2004-08-23 00:15:46 +00:00
|
|
|
n->var = var;
|
|
|
|
n->text = (char *)(n+1);
|
|
|
|
strcpy((char *)(n+1), text);
|
|
|
|
|
|
|
|
if (var)
|
2006-03-06 01:41:09 +00:00
|
|
|
{
|
2004-08-23 00:15:46 +00:00
|
|
|
n->current = var->value;
|
|
|
|
|
2010-01-15 05:35:27 +00:00
|
|
|
#ifdef _DEBUG
|
2006-03-06 01:41:09 +00:00
|
|
|
if (!(var->flags & CVAR_ARCHIVE))
|
|
|
|
Con_Printf("Warning: %s is not set for archiving\n", var->name);
|
2010-01-15 05:35:27 +00:00
|
|
|
#endif
|
2006-03-06 01:41:09 +00:00
|
|
|
}
|
|
|
|
|
2004-08-23 00:15:46 +00:00
|
|
|
n->min = min;
|
|
|
|
n->max = max;
|
2007-05-25 22:16:29 +00:00
|
|
|
n->smallchange = delta;
|
|
|
|
n->largechange = delta*5;
|
2004-08-23 00:15:46 +00:00
|
|
|
|
|
|
|
n->common.next = menu->options;
|
|
|
|
menu->options = (menuoption_t *)n;
|
|
|
|
|
|
|
|
return n;
|
|
|
|
}
|
|
|
|
|
|
|
|
menucombo_t *MC_AddCombo(menu_t *menu, int x, int y, const char *caption, const char **ops, int initialvalue)
|
|
|
|
{
|
2007-01-08 03:13:03 +00:00
|
|
|
int numopts;
|
|
|
|
int optlen;
|
|
|
|
int maxoptlen;
|
|
|
|
int optbufsize;
|
|
|
|
menucombo_t *n;
|
|
|
|
char **newops;
|
|
|
|
char *optbuf;
|
|
|
|
int i;
|
|
|
|
|
|
|
|
maxoptlen = 0;
|
|
|
|
optbufsize = sizeof(char*);
|
|
|
|
numopts = 0;
|
|
|
|
optlen = 0;
|
|
|
|
while(ops[numopts])
|
|
|
|
{
|
|
|
|
optlen = strlen(ops[numopts]);
|
|
|
|
if (maxoptlen < optlen)
|
|
|
|
maxoptlen = optlen;
|
|
|
|
optbufsize += optlen+1+sizeof(char*);
|
|
|
|
numopts++;
|
|
|
|
}
|
2010-01-15 05:35:27 +00:00
|
|
|
|
|
|
|
|
2007-01-08 03:13:03 +00:00
|
|
|
n = Z_Malloc(sizeof(*n) + optbufsize);
|
|
|
|
newops = (char **)(n+1);
|
|
|
|
optbuf = (char*)(newops + numopts+1);
|
2004-08-23 00:15:46 +00:00
|
|
|
n->common.type = mt_combo;
|
2010-01-15 05:35:27 +00:00
|
|
|
n->common.iszone = true;
|
2004-08-23 00:15:46 +00:00
|
|
|
n->common.posx = x;
|
2010-01-15 05:35:27 +00:00
|
|
|
n->common.posy = y;
|
2004-08-23 00:15:46 +00:00
|
|
|
n->common.height = 8;
|
2007-01-08 03:13:03 +00:00
|
|
|
n->common.width = strlen(caption)*8 + maxoptlen*8;
|
2004-08-23 00:15:46 +00:00
|
|
|
n->caption = caption;
|
2007-08-20 02:13:51 +00:00
|
|
|
n->options = (const char **)newops;
|
2004-08-23 00:15:46 +00:00
|
|
|
|
|
|
|
n->common.next = menu->options;
|
|
|
|
menu->options = (menuoption_t *)n;
|
|
|
|
|
2007-01-08 03:13:03 +00:00
|
|
|
n->numoptions = numopts;
|
|
|
|
for (i = 0; i < numopts; i++)
|
2004-08-23 00:15:46 +00:00
|
|
|
{
|
2007-01-08 03:13:03 +00:00
|
|
|
strcpy(optbuf, ops[i]);
|
|
|
|
newops[i] = optbuf;
|
|
|
|
optbuf += strlen(optbuf)+1;
|
2004-08-23 00:15:46 +00:00
|
|
|
}
|
2007-01-08 03:13:03 +00:00
|
|
|
newops[i] = NULL;
|
2004-08-23 00:15:46 +00:00
|
|
|
|
2010-01-15 05:35:27 +00:00
|
|
|
if (initialvalue >= n->numoptions)
|
2004-08-23 00:15:46 +00:00
|
|
|
{
|
|
|
|
Con_Printf("WARNING: Fixed initialvalue for %s\n", caption);
|
|
|
|
initialvalue = n->numoptions-1;
|
|
|
|
}
|
|
|
|
n->selectedoption = initialvalue;
|
|
|
|
|
|
|
|
return n;
|
|
|
|
}
|
|
|
|
menucombo_t *MC_AddCvarCombo(menu_t *menu, int x, int y, const char *caption, cvar_t *cvar, const char **ops, const char **values)
|
|
|
|
{
|
2007-01-08 03:13:03 +00:00
|
|
|
int numopts;
|
|
|
|
int optlen;
|
|
|
|
int maxoptlen;
|
|
|
|
int optbufsize;
|
|
|
|
menucombo_t *n;
|
|
|
|
char **newops;
|
|
|
|
char **newvalues;
|
|
|
|
char *optbuf;
|
|
|
|
int i;
|
|
|
|
|
|
|
|
maxoptlen = 0;
|
|
|
|
optbufsize = sizeof(char*)*2 + strlen(caption)+1;
|
|
|
|
numopts = 0;
|
|
|
|
optlen = 0;
|
|
|
|
while(ops[numopts])
|
|
|
|
{
|
|
|
|
optlen = strlen(ops[numopts]);
|
|
|
|
if (maxoptlen < optlen)
|
|
|
|
maxoptlen = optlen;
|
|
|
|
optbufsize += optlen+1+sizeof(char*);
|
|
|
|
optbufsize += strlen(values[numopts])+1+sizeof(char*);
|
|
|
|
numopts++;
|
|
|
|
}
|
2010-01-15 05:35:27 +00:00
|
|
|
|
|
|
|
|
2007-01-08 03:13:03 +00:00
|
|
|
|
|
|
|
n = Z_Malloc(sizeof(*n) + optbufsize);
|
|
|
|
newops = (char **)(n+1);
|
|
|
|
newvalues = (char**)(newops + numopts+1);
|
|
|
|
optbuf = (char*)(newvalues + numopts+1);
|
2004-08-23 00:15:46 +00:00
|
|
|
n->common.type = mt_combo;
|
2010-01-15 05:35:27 +00:00
|
|
|
n->common.iszone = true;
|
2004-08-23 00:15:46 +00:00
|
|
|
n->common.posx = x;
|
2010-01-15 05:35:27 +00:00
|
|
|
n->common.posy = y;
|
2004-08-23 00:15:46 +00:00
|
|
|
n->common.height = 8;
|
2007-01-08 03:13:03 +00:00
|
|
|
n->common.width = strlen(caption)*8 + maxoptlen*8;
|
2010-07-11 02:22:39 +00:00
|
|
|
n->common.tooltip = cvar->description;
|
2007-01-08 03:13:03 +00:00
|
|
|
|
|
|
|
strcpy(optbuf, caption);
|
|
|
|
n->caption = optbuf;
|
|
|
|
optbuf += strlen(optbuf)+1;
|
|
|
|
|
2007-08-20 02:13:51 +00:00
|
|
|
n->options = (const char **)newops;
|
|
|
|
n->values = (const char **)newvalues;
|
2004-08-23 00:15:46 +00:00
|
|
|
n->cvar = cvar;
|
|
|
|
|
2007-01-08 03:13:03 +00:00
|
|
|
// if (!(cvar->flags & CVAR_ARCHIVE))
|
|
|
|
// Con_Printf("Warning: %s is not set for archiving\n", cvar->name);
|
2006-03-06 01:41:09 +00:00
|
|
|
|
2004-08-23 00:15:46 +00:00
|
|
|
n->selectedoption = 0;
|
|
|
|
|
|
|
|
n->common.next = menu->options;
|
|
|
|
menu->options = (menuoption_t *)n;
|
|
|
|
|
2007-01-08 03:13:03 +00:00
|
|
|
n->numoptions = numopts;
|
|
|
|
for (i = 0; i < numopts; i++)
|
2004-08-23 00:15:46 +00:00
|
|
|
{
|
2007-01-08 03:13:03 +00:00
|
|
|
if (!strcmp(values[i], cvar->string))
|
|
|
|
n->selectedoption = i;
|
|
|
|
|
|
|
|
strcpy(optbuf, ops[i]);
|
|
|
|
newops[i] = optbuf;
|
|
|
|
optbuf += strlen(optbuf)+1;
|
|
|
|
|
|
|
|
strcpy(optbuf, values[i]);
|
|
|
|
newvalues[i] = optbuf;
|
|
|
|
optbuf += strlen(optbuf)+1;
|
2004-08-23 00:15:46 +00:00
|
|
|
}
|
2007-01-08 03:13:03 +00:00
|
|
|
newops[i] = NULL;
|
|
|
|
newvalues[i] = NULL;
|
2004-08-23 00:15:46 +00:00
|
|
|
|
|
|
|
return n;
|
|
|
|
}
|
|
|
|
|
|
|
|
menubutton_t *MC_AddConsoleCommand(menu_t *menu, int x, int y, const char *text, const char *command)
|
|
|
|
{
|
|
|
|
menubutton_t *n = Z_Malloc(sizeof(menubutton_t)+strlen(text)+1+strlen(command)+1);
|
|
|
|
n->common.type = mt_button;
|
2010-01-15 05:35:27 +00:00
|
|
|
n->common.iszone = true;
|
2004-08-23 00:15:46 +00:00
|
|
|
n->common.posx = x;
|
|
|
|
n->common.posy = y;
|
|
|
|
n->common.height = 8;
|
|
|
|
n->common.width = strlen(text)*8;
|
|
|
|
n->text = (char *)(n+1);
|
|
|
|
strcpy((char *)(n+1), text);
|
|
|
|
n->command = n->text + strlen(n->text)+1;
|
|
|
|
strcpy((char *)n->command, command);
|
|
|
|
|
|
|
|
n->common.next = menu->options;
|
|
|
|
menu->options = (menuoption_t *)n;
|
|
|
|
return n;
|
|
|
|
}
|
2006-03-06 01:41:09 +00:00
|
|
|
|
|
|
|
menubutton_t *MC_AddConsoleCommandQBigFont(menu_t *menu, int x, int y, const char *text, const char *command)
|
2004-08-23 00:15:46 +00:00
|
|
|
{
|
|
|
|
menubutton_t *n = Z_Malloc(sizeof(menubutton_t)+strlen(text)+1+strlen(command)+1);
|
2006-03-06 01:41:09 +00:00
|
|
|
n->common.type = mt_qbuttonbigfont;
|
2010-01-15 05:35:27 +00:00
|
|
|
n->common.iszone = true;
|
2006-03-06 01:41:09 +00:00
|
|
|
n->common.posx = x;
|
|
|
|
n->common.posy = y;
|
|
|
|
n->common.height = 20;
|
|
|
|
n->common.width = strlen(text)*20;
|
|
|
|
n->text = (char *)(n+1);
|
|
|
|
strcpy((char *)(n+1), text);
|
|
|
|
n->command = n->text + strlen(n->text)+1;
|
|
|
|
strcpy((char *)n->command, command);
|
|
|
|
|
|
|
|
n->common.next = menu->options;
|
|
|
|
menu->options = (menuoption_t *)n;
|
|
|
|
return n;
|
|
|
|
}
|
|
|
|
menubutton_t *MC_AddConsoleCommandHexen2BigFont(menu_t *menu, int x, int y, const char *text, const char *command)
|
|
|
|
{
|
|
|
|
menubutton_t *n = Z_Malloc(sizeof(menubutton_t)+strlen(text)+1+strlen(command)+1);
|
|
|
|
n->common.type = mt_hexen2buttonbigfont;
|
2010-01-15 05:35:27 +00:00
|
|
|
n->common.iszone = true;
|
2004-08-23 00:15:46 +00:00
|
|
|
n->common.posx = x;
|
|
|
|
n->common.posy = y;
|
2010-08-28 17:14:38 +00:00
|
|
|
n->common.height = 20;
|
|
|
|
n->common.width = strlen(text)*20;
|
2004-08-23 00:15:46 +00:00
|
|
|
n->text = (char *)(n+1);
|
|
|
|
strcpy((char *)(n+1), text);
|
|
|
|
n->command = n->text + strlen(n->text)+1;
|
|
|
|
strcpy((char *)n->command, command);
|
|
|
|
|
|
|
|
n->common.next = menu->options;
|
|
|
|
menu->options = (menuoption_t *)n;
|
|
|
|
return n;
|
|
|
|
}
|
|
|
|
|
|
|
|
menubutton_t *MC_AddCommand(menu_t *menu, int x, int y, char *text, qboolean (*command) (union menuoption_s *,struct menu_s *,int))
|
|
|
|
{
|
|
|
|
menubutton_t *n = Z_Malloc(sizeof(menubutton_t));
|
|
|
|
n->common.type = mt_button;
|
2010-01-15 05:35:27 +00:00
|
|
|
n->common.iszone = true;
|
2004-08-23 00:15:46 +00:00
|
|
|
n->common.posx = x;
|
|
|
|
n->common.posy = y;
|
|
|
|
n->text = text;
|
|
|
|
n->command = NULL;
|
|
|
|
n->key = command;
|
2006-01-28 06:41:20 +00:00
|
|
|
n->common.height = 8;
|
|
|
|
n->common.width = strlen(text)*8;
|
2004-08-23 00:15:46 +00:00
|
|
|
|
|
|
|
n->common.next = menu->options;
|
|
|
|
menu->options = (menuoption_t *)n;
|
|
|
|
return n;
|
|
|
|
}
|
|
|
|
|
|
|
|
menubutton_t *VARGS MC_AddConsoleCommandf(menu_t *menu, int x, int y, const char *text, char *command, ...)
|
|
|
|
{
|
|
|
|
va_list argptr;
|
|
|
|
static char string[1024];
|
|
|
|
menubutton_t *n;
|
2010-01-15 05:35:27 +00:00
|
|
|
|
2004-08-23 00:15:46 +00:00
|
|
|
va_start (argptr, command);
|
2006-03-06 01:41:09 +00:00
|
|
|
vsnprintf (string,sizeof(string)-1, command,argptr);
|
2010-01-15 05:35:27 +00:00
|
|
|
va_end (argptr);
|
2004-08-23 00:15:46 +00:00
|
|
|
|
|
|
|
n = Z_Malloc(sizeof(menubutton_t) + strlen(string)+1);
|
|
|
|
n->common.type = mt_button;
|
2010-01-15 05:35:27 +00:00
|
|
|
n->common.iszone = true;
|
2004-08-23 00:15:46 +00:00
|
|
|
n->common.posx = x;
|
|
|
|
n->common.posy = y;
|
2010-01-15 05:35:27 +00:00
|
|
|
n->text = text;
|
2004-08-23 00:15:46 +00:00
|
|
|
n->command = (char *)(n+1);
|
|
|
|
strcpy((char *)(n+1), string);
|
|
|
|
|
|
|
|
n->common.next = menu->options;
|
|
|
|
menu->options = (menuoption_t *)n;
|
|
|
|
return n;
|
|
|
|
}
|
|
|
|
|
|
|
|
void MC_Slider_Key(menuslider_t *option, int key)
|
|
|
|
{
|
2007-05-25 22:16:29 +00:00
|
|
|
float range = option->current;
|
|
|
|
float delta;
|
|
|
|
|
|
|
|
if (option->smallchange)
|
|
|
|
delta = option->smallchange;
|
|
|
|
else
|
|
|
|
delta = 0.1;
|
2004-08-23 00:15:46 +00:00
|
|
|
|
2006-02-22 23:37:51 +00:00
|
|
|
if (key == K_LEFTARROW || key == K_MWHEELDOWN)
|
2004-08-23 00:15:46 +00:00
|
|
|
{
|
2007-05-25 22:16:29 +00:00
|
|
|
range -= delta;
|
|
|
|
if (range < option->min)
|
|
|
|
range = option->min;
|
|
|
|
option->current = range;
|
2004-08-23 00:15:46 +00:00
|
|
|
if (option->var)
|
2004-09-07 23:15:19 +00:00
|
|
|
Cvar_SetValue(option->var, range);
|
2004-08-23 00:15:46 +00:00
|
|
|
}
|
2006-02-22 23:37:51 +00:00
|
|
|
else if (key == K_RIGHTARROW || key == K_MWHEELUP)
|
2004-08-23 00:15:46 +00:00
|
|
|
{
|
2007-05-25 22:16:29 +00:00
|
|
|
range += delta;
|
|
|
|
if (range > option->max)
|
|
|
|
range = option->max;
|
|
|
|
option->current = range;
|
2004-08-23 00:15:46 +00:00
|
|
|
if (option->var)
|
2004-09-07 23:15:19 +00:00
|
|
|
Cvar_SetValue(option->var, range);
|
2004-08-23 00:15:46 +00:00
|
|
|
}
|
|
|
|
else if (key == K_ENTER || key == K_MOUSE1)
|
|
|
|
{
|
2007-05-25 22:16:29 +00:00
|
|
|
range += delta;
|
2004-08-23 00:15:46 +00:00
|
|
|
|
2007-05-25 22:16:29 +00:00
|
|
|
if (range >= option->max + delta/2)
|
|
|
|
range = option->min;
|
|
|
|
if (range > option->max)
|
|
|
|
range = option->max;
|
|
|
|
option->current = range;
|
2004-08-23 00:15:46 +00:00
|
|
|
if (option->var)
|
|
|
|
Cvar_SetValue(option->var, range);
|
|
|
|
}
|
2004-09-07 18:19:22 +00:00
|
|
|
else
|
|
|
|
return;
|
2004-08-23 00:15:46 +00:00
|
|
|
|
2004-09-07 18:19:22 +00:00
|
|
|
S_LocalSound ("misc/menu2.wav");
|
2004-08-23 00:15:46 +00:00
|
|
|
}
|
|
|
|
|
2006-02-28 00:46:04 +00:00
|
|
|
void MC_CheckBox_Key(menucheck_t *option, menu_t *menu, int key)
|
2004-08-23 00:15:46 +00:00
|
|
|
{
|
|
|
|
if (key != K_ENTER && key != K_LEFTARROW && key != K_RIGHTARROW && key != K_MOUSE1)
|
|
|
|
return;
|
|
|
|
if (option->func)
|
2006-02-28 00:46:04 +00:00
|
|
|
option->func(option, menu, CHK_TOGGLE);
|
2004-08-23 00:15:46 +00:00
|
|
|
else if (!option->var)
|
|
|
|
option->value = !option->value;
|
|
|
|
else
|
2004-09-07 18:19:22 +00:00
|
|
|
{
|
2004-09-13 03:10:10 +00:00
|
|
|
if (option->bits)
|
|
|
|
{
|
|
|
|
int old;
|
|
|
|
if (option->var->latched_string)
|
|
|
|
old = atoi(option->var->latched_string);
|
|
|
|
else
|
|
|
|
old = option->var->value;
|
|
|
|
|
|
|
|
if (old & option->bits)
|
|
|
|
Cvar_SetValue(option->var, old&~option->bits);
|
|
|
|
else
|
|
|
|
Cvar_SetValue(option->var, old|option->bits);
|
|
|
|
}
|
2004-09-07 23:15:19 +00:00
|
|
|
else
|
2004-09-13 03:10:10 +00:00
|
|
|
{
|
|
|
|
if (option->var->latched_string)
|
|
|
|
Cvar_SetValue(option->var, !atof(option->var->latched_string));
|
|
|
|
else
|
|
|
|
Cvar_SetValue(option->var, !option->var->value);
|
|
|
|
}
|
2004-09-07 18:19:22 +00:00
|
|
|
S_LocalSound ("misc/menu2.wav");
|
|
|
|
}
|
2004-08-23 00:15:46 +00:00
|
|
|
}
|
|
|
|
|
2009-11-04 21:16:50 +00:00
|
|
|
void MC_EditBox_Key(menuedit_t *edit, int key, unsigned int unicode)
|
2004-08-23 00:15:46 +00:00
|
|
|
{
|
|
|
|
int len = strlen(edit->text);
|
|
|
|
if (key == K_DEL || key == K_BACKSPACE)
|
|
|
|
{
|
|
|
|
if (!len)
|
|
|
|
return;
|
|
|
|
edit->text[len-1] = '\0';
|
|
|
|
}
|
2009-11-04 21:16:50 +00:00
|
|
|
else if (!unicode)
|
2004-08-23 00:15:46 +00:00
|
|
|
return;
|
|
|
|
else
|
|
|
|
{
|
2009-11-04 21:16:50 +00:00
|
|
|
if (unicode < 128)
|
|
|
|
{
|
|
|
|
if (len < sizeof(edit->text))
|
|
|
|
{
|
|
|
|
edit->text[len] = unicode;
|
|
|
|
edit->text[len+1] = '\0';
|
|
|
|
}
|
|
|
|
}
|
2004-08-23 00:15:46 +00:00
|
|
|
}
|
|
|
|
|
2005-02-12 18:56:04 +00:00
|
|
|
edit->modified = true;
|
|
|
|
|
2004-08-23 00:15:46 +00:00
|
|
|
if (edit->cvar)
|
2004-09-07 18:19:22 +00:00
|
|
|
{
|
2004-08-23 00:15:46 +00:00
|
|
|
Cvar_Set(edit->cvar, edit->text);
|
2004-09-07 18:19:22 +00:00
|
|
|
S_LocalSound ("misc/menu2.wav");
|
|
|
|
}
|
2004-08-23 00:15:46 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void MC_Combo_Key(menucombo_t *combo, int key)
|
|
|
|
{
|
|
|
|
if (key == K_ENTER || key == K_RIGHTARROW || key == K_MOUSE1)
|
|
|
|
{
|
|
|
|
combo->selectedoption++;
|
|
|
|
if (combo->selectedoption >= combo->numoptions)
|
|
|
|
combo->selectedoption = 0;
|
|
|
|
|
|
|
|
changed:
|
2007-01-08 03:13:03 +00:00
|
|
|
if (combo->cvar && combo->numoptions)
|
2004-08-23 00:15:46 +00:00
|
|
|
Cvar_Set(combo->cvar, (char *)combo->values[combo->selectedoption]);
|
|
|
|
}
|
|
|
|
else if (key == K_LEFTARROW)
|
|
|
|
{
|
|
|
|
combo->selectedoption--;
|
|
|
|
if (combo->selectedoption < 0)
|
|
|
|
combo->selectedoption = combo->numoptions-1;
|
|
|
|
goto changed;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
menu_t *currentmenu;
|
|
|
|
menu_t *firstmenu;
|
|
|
|
|
|
|
|
void M_AddMenuFront (menu_t *menu)
|
|
|
|
{
|
|
|
|
menu_t *pmenu;
|
|
|
|
m_state = m_complex;
|
|
|
|
if (!firstmenu)
|
|
|
|
{
|
|
|
|
M_AddMenu(menu);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
pmenu = firstmenu;
|
|
|
|
while(pmenu->parent)
|
|
|
|
pmenu = pmenu->parent;
|
|
|
|
pmenu->parent = menu;
|
|
|
|
menu->child = pmenu;
|
|
|
|
menu->parent = NULL;
|
|
|
|
|
|
|
|
menu->exclusive = true;
|
|
|
|
|
|
|
|
menu->xpos = ((vid.width - 320)>>1);
|
|
|
|
|
|
|
|
currentmenu = menu;
|
|
|
|
}
|
|
|
|
|
|
|
|
void M_AddMenu (menu_t *menu)
|
|
|
|
{
|
|
|
|
m_state = m_complex;
|
|
|
|
menu->parent = firstmenu;
|
|
|
|
if (firstmenu)
|
|
|
|
firstmenu->child = menu;
|
|
|
|
menu->child = NULL;
|
|
|
|
firstmenu = menu;
|
|
|
|
|
|
|
|
menu->exclusive = true;
|
|
|
|
|
|
|
|
currentmenu = menu;
|
|
|
|
}
|
|
|
|
menu_t *M_CreateMenu (int extrasize)
|
|
|
|
{
|
|
|
|
menu_t *menu;
|
|
|
|
menu = Z_Malloc(sizeof(menu_t)+extrasize);
|
|
|
|
menu->iszone=true;
|
|
|
|
menu->data = menu+1;
|
|
|
|
|
|
|
|
M_AddMenu(menu);
|
|
|
|
|
|
|
|
return menu;
|
|
|
|
}
|
|
|
|
void M_HideMenu (menu_t *menu)
|
|
|
|
{
|
|
|
|
if (menu == firstmenu)
|
|
|
|
firstmenu = menu->parent;
|
|
|
|
else
|
|
|
|
{
|
|
|
|
menu_t *prev;
|
|
|
|
prev = menu->child;
|
|
|
|
if (prev)
|
|
|
|
prev->parent = menu->parent;
|
|
|
|
if (menu->parent)
|
|
|
|
menu->parent->child = menu;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
void M_RemoveMenu (menu_t *menu)
|
2010-01-15 05:35:27 +00:00
|
|
|
{
|
2004-08-23 00:15:46 +00:00
|
|
|
menuoption_t *op, *oop;
|
|
|
|
if (menu->remove)
|
|
|
|
menu->remove(menu);
|
|
|
|
if (menu == firstmenu)
|
|
|
|
firstmenu = menu->parent;
|
|
|
|
else
|
|
|
|
{
|
|
|
|
menu_t *prev;
|
|
|
|
prev = menu->child;
|
|
|
|
if (prev)
|
|
|
|
prev->parent = menu->parent;
|
|
|
|
if (menu->parent)
|
|
|
|
menu->parent->child = menu;
|
|
|
|
}
|
|
|
|
|
|
|
|
op = menu->options;
|
|
|
|
while(op)
|
|
|
|
{
|
|
|
|
oop = op;
|
|
|
|
op = op->common.next;
|
|
|
|
if (oop->common.iszone)
|
|
|
|
Z_Free(oop);
|
|
|
|
}
|
|
|
|
menu->options=NULL;
|
|
|
|
|
2009-04-19 10:50:31 +00:00
|
|
|
if (menu->tooltip)
|
|
|
|
Z_Free(menu->tooltip);
|
|
|
|
|
2004-08-23 00:15:46 +00:00
|
|
|
if (menu->iszone)
|
|
|
|
{
|
|
|
|
menu->iszone=false;
|
|
|
|
Z_Free(menu);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (menu == currentmenu)
|
|
|
|
currentmenu = firstmenu;
|
|
|
|
}
|
|
|
|
|
|
|
|
void M_RemoveAllMenus (void)
|
|
|
|
{
|
|
|
|
if (!firstmenu)
|
|
|
|
return;
|
|
|
|
|
|
|
|
while(firstmenu)
|
|
|
|
M_RemoveMenu(firstmenu);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
2006-02-06 01:06:17 +00:00
|
|
|
|
2009-11-04 21:16:50 +00:00
|
|
|
void DrawCursor(int prydoncursornum)
|
2006-02-06 01:06:17 +00:00
|
|
|
{
|
|
|
|
extern int mousecursor_x, mousecursor_y;
|
|
|
|
mpic_t *p;
|
|
|
|
if (!*cl_cursor.string)
|
|
|
|
p = NULL;
|
|
|
|
else
|
2011-03-31 01:14:01 +00:00
|
|
|
p = R2D_SafeCachePic(cl_cursor.string);
|
2006-02-06 01:06:17 +00:00
|
|
|
if (p)
|
|
|
|
{
|
2011-03-31 01:14:01 +00:00
|
|
|
R2D_ImageColours(1, 1, 1, 1);
|
|
|
|
R2D_Image(mousecursor_x-cl_cursorbias.value, mousecursor_y-cl_cursorbias.value, cl_cursorsize.value, cl_cursorsize.value, 0, 0, 1, 1, p);
|
2006-02-06 01:06:17 +00:00
|
|
|
}
|
|
|
|
else
|
2009-11-04 21:16:50 +00:00
|
|
|
{
|
|
|
|
int x, y;
|
|
|
|
Font_BeginString(font_conchar, mousecursor_x, mousecursor_y, &x, &y);
|
|
|
|
x -= Font_CharWidth('+' | 0xe000 | CON_WHITEMASK)/2;
|
|
|
|
y -= Font_CharHeight()/2;
|
|
|
|
Font_DrawChar(x, y, '+' | 0xe000 | CON_WHITEMASK);
|
|
|
|
Font_EndString(font_conchar);
|
|
|
|
}
|
2006-02-06 01:06:17 +00:00
|
|
|
|
|
|
|
}
|
|
|
|
|
2004-08-23 00:15:46 +00:00
|
|
|
void M_Complex_Draw(void)
|
|
|
|
{
|
|
|
|
extern int mousecursor_x, mousecursor_y;
|
|
|
|
menu_t *menu, *cmenu;
|
|
|
|
qboolean foundexclusive = false;
|
|
|
|
|
|
|
|
if (omousex != mousecursor_x || omousey != mousecursor_y)
|
|
|
|
mousemoved = true;
|
|
|
|
else
|
|
|
|
mousemoved = false;
|
|
|
|
omousex = mousecursor_x;
|
|
|
|
omousey = mousecursor_y;
|
|
|
|
|
|
|
|
if (!firstmenu)
|
|
|
|
{
|
|
|
|
key_dest = key_game;
|
|
|
|
m_state = m_none;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
for (menu = firstmenu; menu; )
|
|
|
|
{
|
|
|
|
cmenu = menu;
|
|
|
|
menu = menu->parent; //this way we can remove the currently drawn menu easily (if needed)
|
|
|
|
|
|
|
|
if (cmenu->exclusive)
|
|
|
|
{
|
|
|
|
if (foundexclusive)
|
|
|
|
continue;
|
|
|
|
foundexclusive=true;
|
|
|
|
}
|
|
|
|
MenuDraw(cmenu);
|
|
|
|
}
|
2006-01-21 00:06:49 +00:00
|
|
|
|
2009-11-04 21:16:50 +00:00
|
|
|
SCR_DrawCursor(0);
|
2004-08-23 00:15:46 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
menuoption_t *M_NextItem(menu_t *m, menuoption_t *old)
|
|
|
|
{
|
|
|
|
menuoption_t *op = m->options;
|
|
|
|
while(op->common.next)
|
|
|
|
{
|
|
|
|
if (op->common.next == old)
|
|
|
|
return op;
|
|
|
|
|
|
|
|
op = op->common.next;
|
|
|
|
}
|
|
|
|
return op;
|
|
|
|
}
|
|
|
|
menuoption_t *M_NextSelectableItem(menu_t *m, menuoption_t *old)
|
|
|
|
{
|
|
|
|
menuoption_t *op;
|
|
|
|
|
|
|
|
if (!old)
|
|
|
|
old = M_NextItem(m, old);
|
2010-01-15 05:35:27 +00:00
|
|
|
|
2004-08-23 00:15:46 +00:00
|
|
|
op = old;
|
|
|
|
|
|
|
|
while (1)
|
|
|
|
{
|
|
|
|
if (!op)
|
|
|
|
op = currentmenu->options;
|
|
|
|
|
|
|
|
op = M_NextItem(m, op);
|
|
|
|
if (!op)
|
|
|
|
op = currentmenu->options;
|
|
|
|
|
|
|
|
if (op == old)
|
|
|
|
{
|
2010-08-12 00:48:05 +00:00
|
|
|
if (op->common.type == mt_slider || op->common.type == mt_checkbox || op->common.type == mt_button || op->common.type == mt_hexen2buttonbigfont || op->common.type == mt_qbuttonbigfont || op->common.type == mt_edit || op->common.type == mt_combo || op->common.type == mt_bind || (op->common.type == mt_custom && op->custom.key))
|
2004-08-23 00:15:46 +00:00
|
|
|
return op;
|
|
|
|
return NULL; //whoops.
|
|
|
|
}
|
|
|
|
|
2010-08-12 00:48:05 +00:00
|
|
|
if (op->common.type == mt_slider || op->common.type == mt_checkbox || op->common.type == mt_button || op->common.type == mt_hexen2buttonbigfont || op->common.type == mt_qbuttonbigfont || op->common.type == mt_edit || op->common.type == mt_combo || op->common.type == mt_bind || (op->common.type == mt_custom && op->custom.key))
|
2005-01-26 18:56:49 +00:00
|
|
|
if (!op->common.ishidden)
|
|
|
|
return op;
|
2004-08-23 00:15:46 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
menuoption_t *M_PrevSelectableItem(menu_t *m, menuoption_t *old)
|
|
|
|
{
|
2010-01-15 05:35:27 +00:00
|
|
|
menuoption_t *op;
|
2004-08-23 00:15:46 +00:00
|
|
|
|
|
|
|
if (!old)
|
|
|
|
old = currentmenu->options;
|
2010-01-15 05:35:27 +00:00
|
|
|
|
2004-08-23 00:15:46 +00:00
|
|
|
op = old;
|
|
|
|
|
|
|
|
while (1)
|
|
|
|
{
|
|
|
|
if (!op)
|
|
|
|
op = currentmenu->options;
|
|
|
|
|
|
|
|
op = op->common.next;
|
|
|
|
if (!op)
|
|
|
|
op = currentmenu->options;
|
|
|
|
|
|
|
|
if (op == old)
|
|
|
|
return old; //whoops.
|
|
|
|
|
2010-08-12 00:48:05 +00:00
|
|
|
if (op->common.type == mt_slider || op->common.type == mt_checkbox || op->common.type == mt_button || op->common.type == mt_hexen2buttonbigfont || op->common.type == mt_qbuttonbigfont || op->common.type == mt_edit || op->common.type == mt_combo || op->common.type == mt_bind || (op->common.type == mt_custom && op->custom.key))
|
2005-01-26 18:56:49 +00:00
|
|
|
if (!op->common.ishidden)
|
|
|
|
return op;
|
2004-08-23 00:15:46 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2009-11-04 21:16:50 +00:00
|
|
|
void M_Complex_Key(int key, int unicode)
|
2004-08-23 00:15:46 +00:00
|
|
|
{
|
2010-01-16 04:59:13 +00:00
|
|
|
int mgt;
|
|
|
|
mgt = M_GameType();
|
|
|
|
|
2004-08-23 00:15:46 +00:00
|
|
|
if (!currentmenu)
|
|
|
|
return; //erm...
|
2010-01-15 05:35:27 +00:00
|
|
|
|
2004-08-23 00:15:46 +00:00
|
|
|
if (currentmenu->key)
|
|
|
|
if (currentmenu->key(key, currentmenu))
|
|
|
|
return;
|
|
|
|
|
|
|
|
if (currentmenu->selecteditem && currentmenu->selecteditem->common.type == mt_custom && (key == K_DOWNARROW || key == K_UPARROW || key == K_TAB))
|
2006-02-11 18:06:54 +00:00
|
|
|
if (currentmenu->selecteditem->custom.key)
|
|
|
|
if (currentmenu->selecteditem->custom.key(¤tmenu->selecteditem->custom, currentmenu, key))
|
|
|
|
return;
|
2004-09-07 18:19:22 +00:00
|
|
|
|
|
|
|
if (currentmenu->selecteditem && currentmenu->selecteditem->common.type == mt_bind)
|
|
|
|
{
|
|
|
|
if (bindingactive)
|
|
|
|
{
|
2010-01-16 04:59:13 +00:00
|
|
|
if (mgt == MGT_HEXEN2)
|
|
|
|
S_LocalSound ("raven/menu1.wav");
|
|
|
|
else
|
|
|
|
S_LocalSound ("misc/menu1.wav");
|
2004-09-07 18:19:22 +00:00
|
|
|
|
|
|
|
if (key != K_ESCAPE && key != '`')
|
|
|
|
{
|
2009-06-23 21:49:44 +00:00
|
|
|
Cbuf_InsertText (va("bind \"%s\" \"%s\"\n", Key_KeynumToString (key), currentmenu->selecteditem->bind.command), RESTRICT_LOCAL, false);
|
2004-09-07 18:19:22 +00:00
|
|
|
}
|
|
|
|
bindingactive = false;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
2010-01-15 05:35:27 +00:00
|
|
|
|
2004-08-23 00:15:46 +00:00
|
|
|
switch(key)
|
|
|
|
{
|
2006-01-28 06:41:20 +00:00
|
|
|
case K_MOUSE2:
|
2004-08-23 00:15:46 +00:00
|
|
|
case K_ESCAPE:
|
|
|
|
//remove
|
|
|
|
M_RemoveMenu(currentmenu);
|
2010-01-16 04:59:13 +00:00
|
|
|
if (mgt == MGT_HEXEN2)
|
|
|
|
S_LocalSound ("raven/menu3.wav");
|
|
|
|
else
|
|
|
|
S_LocalSound ("misc/menu3.wav");
|
2004-08-23 00:15:46 +00:00
|
|
|
break;
|
|
|
|
case K_TAB:
|
|
|
|
case K_DOWNARROW:
|
|
|
|
currentmenu->selecteditem = M_NextSelectableItem(currentmenu, currentmenu->selecteditem);
|
|
|
|
|
2010-01-15 05:35:27 +00:00
|
|
|
if (currentmenu->selecteditem)
|
2004-08-23 00:15:46 +00:00
|
|
|
{
|
2010-01-16 04:59:13 +00:00
|
|
|
if (mgt == MGT_HEXEN2)
|
|
|
|
S_LocalSound ("raven/menu1.wav");
|
|
|
|
else
|
|
|
|
S_LocalSound ("misc/menu1.wav");
|
|
|
|
|
2004-08-23 00:15:46 +00:00
|
|
|
if (currentmenu->cursoritem)
|
|
|
|
currentmenu->cursoritem->common.posy = currentmenu->selecteditem->common.posy;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case K_UPARROW:
|
|
|
|
currentmenu->selecteditem = M_PrevSelectableItem(currentmenu, currentmenu->selecteditem);
|
|
|
|
|
2010-01-15 05:35:27 +00:00
|
|
|
if (currentmenu->selecteditem)
|
2004-08-23 00:15:46 +00:00
|
|
|
{
|
2010-01-16 04:59:13 +00:00
|
|
|
if (mgt == MGT_HEXEN2)
|
|
|
|
S_LocalSound ("raven/menu1.wav");
|
|
|
|
else
|
|
|
|
S_LocalSound ("misc/menu1.wav");
|
|
|
|
|
2004-08-23 00:15:46 +00:00
|
|
|
if (currentmenu->cursoritem)
|
|
|
|
currentmenu->cursoritem->common.posy = currentmenu->selecteditem->common.posy;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
if (!currentmenu->selecteditem)
|
|
|
|
{
|
|
|
|
if (!currentmenu->options)
|
|
|
|
return;
|
|
|
|
currentmenu->selecteditem = currentmenu->options;
|
|
|
|
}
|
|
|
|
switch(currentmenu->selecteditem->common.type)
|
|
|
|
{
|
|
|
|
case mt_slider:
|
|
|
|
MC_Slider_Key(¤tmenu->selecteditem->slider, key);
|
|
|
|
break;
|
|
|
|
case mt_checkbox:
|
2006-02-28 00:46:04 +00:00
|
|
|
MC_CheckBox_Key(¤tmenu->selecteditem->check, currentmenu, key);
|
2004-08-23 00:15:46 +00:00
|
|
|
break;
|
|
|
|
case mt_button:
|
2006-03-06 01:41:09 +00:00
|
|
|
case mt_hexen2buttonbigfont:
|
|
|
|
case mt_qbuttonbigfont:
|
2004-08-23 00:15:46 +00:00
|
|
|
if (!currentmenu->selecteditem->button.command)
|
|
|
|
currentmenu->selecteditem->button.key(currentmenu->selecteditem, currentmenu, key);
|
|
|
|
else if (key == K_ENTER || key == K_MOUSE1)
|
2004-09-07 18:19:22 +00:00
|
|
|
{
|
2004-08-23 00:15:46 +00:00
|
|
|
Cbuf_AddText(currentmenu->selecteditem->button.command, RESTRICT_LOCAL);
|
2010-01-16 04:59:13 +00:00
|
|
|
if (mgt == MGT_HEXEN2)
|
|
|
|
S_LocalSound ("raven/menu2.wav");
|
|
|
|
else
|
|
|
|
S_LocalSound ("misc/menu2.wav");
|
2004-09-07 18:19:22 +00:00
|
|
|
}
|
2004-08-23 00:15:46 +00:00
|
|
|
break;
|
|
|
|
case mt_custom:
|
2006-02-11 18:06:54 +00:00
|
|
|
if (currentmenu->selecteditem->custom.key)
|
|
|
|
currentmenu->selecteditem->custom.key(¤tmenu->selecteditem->custom, currentmenu, key);
|
2004-08-23 00:15:46 +00:00
|
|
|
break;
|
|
|
|
case mt_edit:
|
2009-11-04 21:16:50 +00:00
|
|
|
MC_EditBox_Key(¤tmenu->selecteditem->edit, key, unicode);
|
2004-08-23 00:15:46 +00:00
|
|
|
break;
|
|
|
|
case mt_combo:
|
|
|
|
MC_Combo_Key(¤tmenu->selecteditem->combo, key);
|
|
|
|
break;
|
2004-09-07 18:19:22 +00:00
|
|
|
case mt_bind:
|
2006-01-28 06:41:20 +00:00
|
|
|
if (key == K_ENTER || key == K_MOUSE1)
|
2004-09-07 18:19:22 +00:00
|
|
|
bindingactive = true;
|
|
|
|
else if (key == K_BACKSPACE || key == K_DEL)
|
|
|
|
M_UnbindCommand (currentmenu->selecteditem->bind.command);
|
2004-08-23 00:15:46 +00:00
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
typedef struct {
|
|
|
|
int itemselected;
|
|
|
|
menu_t *dropout;
|
|
|
|
menutext_t *op[64];
|
|
|
|
char *text[64];
|
|
|
|
|
|
|
|
menu_t *parent;
|
|
|
|
} guiinfo_t;
|
|
|
|
|
|
|
|
qboolean MC_GuiKey(int key, menu_t *menu)
|
|
|
|
{
|
|
|
|
guiinfo_t *info = (guiinfo_t *)menu->data;
|
|
|
|
switch(key)
|
|
|
|
{
|
2010-01-15 05:35:27 +00:00
|
|
|
case K_ESCAPE:
|
2004-08-23 00:15:46 +00:00
|
|
|
if (info->dropout)
|
|
|
|
MC_GuiKey(key, info->dropout);
|
|
|
|
else
|
|
|
|
{
|
|
|
|
guiinfo_t *gui;
|
|
|
|
M_RemoveMenu(menu);
|
|
|
|
if (menu->parent)
|
|
|
|
{
|
|
|
|
gui = (guiinfo_t *)menu->parent->data;
|
|
|
|
gui->dropout = NULL;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
case K_ENTER:
|
|
|
|
case K_RIGHTARROW:
|
|
|
|
if (info->dropout)
|
|
|
|
MC_GuiKey(key, info->dropout);
|
|
|
|
else
|
|
|
|
{
|
|
|
|
int y, i;
|
|
|
|
guiinfo_t *gui;
|
|
|
|
info->dropout = M_CreateMenu(sizeof(guiinfo_t));
|
|
|
|
currentmenu = info->dropout;
|
|
|
|
info->dropout->key = MC_GuiKey;
|
|
|
|
info->dropout->exclusive = false;
|
|
|
|
info->dropout->parent = menu;
|
|
|
|
info->dropout->xpos = 0;
|
|
|
|
info->dropout->ypos = menu->ypos+info->itemselected*8;
|
|
|
|
for (i = 0; info->text[i]; i++)
|
|
|
|
if (info->dropout->xpos < strlen(info->text[i]))
|
|
|
|
info->dropout->xpos = strlen(info->text[i]);
|
|
|
|
info->dropout->xpos*=8;
|
|
|
|
info->dropout->xpos+=menu->xpos;
|
|
|
|
gui = (guiinfo_t *)info->dropout->data;
|
|
|
|
gui->text[0] = "Hello";
|
|
|
|
gui->text[1] = "Hello again";
|
|
|
|
gui->text[2] = "Hello yet again";
|
|
|
|
for (y = 0, i = 0; gui->text[i]; i++, y+=1*8)
|
2010-01-15 05:35:27 +00:00
|
|
|
{
|
2004-08-23 00:15:46 +00:00
|
|
|
info->op[i] = MC_AddRedText(info->dropout, 0, y, gui->text[i], false);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case K_LEFTARROW:
|
|
|
|
if (info->dropout)
|
|
|
|
MC_GuiKey(key, info->dropout);
|
|
|
|
else
|
|
|
|
{
|
|
|
|
guiinfo_t *gui;
|
|
|
|
M_RemoveMenu(menu);
|
|
|
|
if (menu->parent)
|
|
|
|
{
|
|
|
|
gui = (guiinfo_t *)menu->parent->data;
|
|
|
|
gui->dropout = NULL;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case K_UPARROW:
|
|
|
|
info->op[info->itemselected]->isred = true;
|
|
|
|
if (info->itemselected)
|
|
|
|
info->itemselected--;
|
|
|
|
info->op[info->itemselected]->isred = false;
|
|
|
|
break;
|
|
|
|
case K_DOWNARROW:
|
|
|
|
if (!info->op[info->itemselected])
|
|
|
|
break;
|
|
|
|
info->op[info->itemselected]->isred = true;
|
|
|
|
if (info->text[info->itemselected+1])
|
|
|
|
info->itemselected++;
|
|
|
|
info->op[info->itemselected]->isred = false;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
qboolean MC_Main_Key (int key, menu_t *menu) //here purly to restart demos.
|
|
|
|
{
|
|
|
|
if (key == K_ESCAPE)
|
|
|
|
{
|
|
|
|
extern int m_save_demonum;
|
|
|
|
key_dest = key_game;
|
|
|
|
m_state = m_none;
|
|
|
|
cls.demonum = m_save_demonum;
|
2004-11-26 06:05:59 +00:00
|
|
|
if (cls.demonum != -1 && !cls.demoplayback && cls.state == ca_disconnected && COM_CheckParm("-demos"))
|
2004-08-23 00:15:46 +00:00
|
|
|
CL_NextDemo ();
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
void M_Menu_Main_f (void)
|
|
|
|
{
|
|
|
|
extern cvar_t m_helpismedia;
|
|
|
|
menubutton_t *b;
|
|
|
|
menu_t *mainm;
|
2004-12-24 08:45:56 +00:00
|
|
|
mpic_t *p;
|
2004-08-23 00:15:46 +00:00
|
|
|
|
2005-03-15 22:51:01 +00:00
|
|
|
int mgt;
|
2004-08-23 00:15:46 +00:00
|
|
|
|
|
|
|
SCR_EndLoadingPlaque(); //just in case...
|
|
|
|
|
|
|
|
/*
|
|
|
|
if (0)
|
|
|
|
{
|
|
|
|
int x, i;
|
|
|
|
guiinfo_t *gui;
|
|
|
|
m_state = m_complex;
|
|
|
|
key_dest = key_menu;
|
|
|
|
m_entersound = true;
|
|
|
|
|
|
|
|
mainm = M_CreateMenu(sizeof(guiinfo_t));
|
|
|
|
mainm->key = MC_GuiKey;
|
|
|
|
mainm->xpos=0;
|
2010-01-15 05:35:27 +00:00
|
|
|
gui = (guiinfo_t *)mainm->data;
|
2004-08-23 00:15:46 +00:00
|
|
|
gui->text[0] = "Single";
|
|
|
|
gui->text[1] = "Multiplayer";
|
|
|
|
gui->text[2] = "Quit";
|
|
|
|
for (x = 0, i = 0; gui->text[i]; i++)
|
|
|
|
{
|
|
|
|
gui->op[i] = MC_AddRedText(mainm, x, 0, gui->text[i], false);
|
|
|
|
x+=(strlen(gui->text[i])+1)*8;
|
2010-01-15 05:35:27 +00:00
|
|
|
}
|
2004-08-23 00:15:46 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
*/
|
|
|
|
|
2006-01-01 09:01:15 +00:00
|
|
|
S_LocalSound ("misc/menu2.wav");
|
|
|
|
|
2005-03-15 22:51:01 +00:00
|
|
|
mgt = M_GameType();
|
|
|
|
if (mgt == MGT_QUAKE2) //quake2 main menu.
|
2004-08-23 00:15:46 +00:00
|
|
|
{
|
2011-03-31 01:14:01 +00:00
|
|
|
if (R2D_SafeCachePic("pics/m_main_game"))
|
2010-01-15 05:35:27 +00:00
|
|
|
{
|
2004-08-23 00:15:46 +00:00
|
|
|
m_state = m_complex;
|
|
|
|
key_dest = key_menu;
|
|
|
|
|
2010-01-15 05:35:27 +00:00
|
|
|
mainm = M_CreateMenu(0);
|
|
|
|
mainm->key = MC_Main_Key;
|
2004-08-23 00:15:46 +00:00
|
|
|
|
2009-11-04 21:16:50 +00:00
|
|
|
MC_AddPicture(mainm, 0, 4, 38, 166, "pics/m_main_plaque");
|
2011-03-31 01:14:01 +00:00
|
|
|
p = R2D_SafeCachePic("pics/m_main_logo");
|
2004-08-23 00:15:46 +00:00
|
|
|
if (!p)
|
|
|
|
return;
|
2009-11-04 21:16:50 +00:00
|
|
|
MC_AddPicture(mainm, 0, 173, 36, 42, "pics/m_main_logo");
|
2009-04-01 22:03:56 +00:00
|
|
|
#ifndef CLIENTONLY
|
2006-05-11 00:41:47 +00:00
|
|
|
MC_AddSelectablePicture(mainm, 68, 13, "pics/m_main_game");
|
2009-04-01 22:03:56 +00:00
|
|
|
#endif
|
2006-05-11 00:41:47 +00:00
|
|
|
MC_AddSelectablePicture(mainm, 68, 53, "pics/m_main_multiplayer");
|
|
|
|
MC_AddSelectablePicture(mainm, 68, 93, "pics/m_main_options");
|
|
|
|
MC_AddSelectablePicture(mainm, 68, 133, "pics/m_main_video");
|
|
|
|
MC_AddSelectablePicture(mainm, 68, 173, "pics/m_main_quit");
|
2004-08-23 00:15:46 +00:00
|
|
|
|
2009-04-01 22:03:56 +00:00
|
|
|
#ifndef CLIENTONLY
|
2006-01-28 19:34:21 +00:00
|
|
|
b = MC_AddConsoleCommand (mainm, 68, 13, "", "menu_single\n");
|
2006-01-28 22:49:10 +00:00
|
|
|
mainm->selecteditem = (menuoption_t *)b;
|
2006-01-28 19:34:21 +00:00
|
|
|
b->common.width = 12*20;
|
|
|
|
b->common.height = 20;
|
2009-04-01 22:03:56 +00:00
|
|
|
#endif
|
2006-01-28 19:34:21 +00:00
|
|
|
b = MC_AddConsoleCommand (mainm, 68, 53, "", "menu_multi\n");
|
2009-04-01 22:03:56 +00:00
|
|
|
#ifdef CLIENTONLY
|
|
|
|
mainm->selecteditem = (menuoption_t *)b;
|
|
|
|
#endif
|
2006-01-28 19:34:21 +00:00
|
|
|
b->common.width = 12*20;
|
|
|
|
b->common.height = 20;
|
|
|
|
b = MC_AddConsoleCommand (mainm, 68, 93, "", "menu_options\n");
|
|
|
|
b->common.width = 12*20;
|
|
|
|
b->common.height = 20;
|
|
|
|
b = MC_AddConsoleCommand (mainm, 68, 133, "", "menu_video\n");
|
|
|
|
b->common.width = 12*20;
|
|
|
|
b->common.height = 20;
|
|
|
|
b = MC_AddConsoleCommand (mainm, 68, 173, "", "menu_quit\n");
|
|
|
|
b->common.width = 12*20;
|
|
|
|
b->common.height = 20;
|
2004-08-23 00:15:46 +00:00
|
|
|
|
2009-04-01 22:03:56 +00:00
|
|
|
mainm->cursoritem = (menuoption_t *)MC_AddCursor(mainm, 42, mainm->selecteditem->common.posy);
|
2004-08-23 00:15:46 +00:00
|
|
|
}
|
|
|
|
return;
|
|
|
|
}
|
2005-03-15 22:51:01 +00:00
|
|
|
else if (mgt == MGT_HEXEN2)
|
2004-08-23 00:15:46 +00:00
|
|
|
{
|
|
|
|
m_state = m_complex;
|
|
|
|
key_dest = key_menu;
|
2010-01-15 05:35:27 +00:00
|
|
|
mainm = M_CreateMenu(0);
|
|
|
|
mainm->key = MC_Main_Key;
|
2004-08-23 00:15:46 +00:00
|
|
|
|
2009-11-04 21:16:50 +00:00
|
|
|
MC_AddPicture(mainm, 16, 0, 35, 176, "gfx/menu/hplaque.lmp");
|
2011-03-31 01:14:01 +00:00
|
|
|
p = R2D_SafeCachePic("gfx/menu/title0.lmp");
|
2004-08-23 00:15:46 +00:00
|
|
|
if (!p)
|
|
|
|
return;
|
2009-11-04 21:16:50 +00:00
|
|
|
MC_AddCenterPicture(mainm, 0, 60, "gfx/menu/title0.lmp");
|
2004-08-23 00:15:46 +00:00
|
|
|
|
2010-08-12 00:48:05 +00:00
|
|
|
#ifndef CLIENTONLY
|
2006-03-06 01:41:09 +00:00
|
|
|
b=MC_AddConsoleCommandHexen2BigFont (mainm, 80, 64, "Single Player", "menu_single\n");
|
2010-08-12 00:48:05 +00:00
|
|
|
mainm->selecteditem = (menuoption_t *)b;
|
2004-08-23 00:15:46 +00:00
|
|
|
b->common.width = 12*20;
|
|
|
|
b->common.height = 20;
|
2010-08-12 00:48:05 +00:00
|
|
|
#endif
|
2006-03-06 01:41:09 +00:00
|
|
|
b=MC_AddConsoleCommandHexen2BigFont (mainm, 80, 64+20, "MultiPlayer", "menu_multi\n");
|
2010-08-12 00:48:05 +00:00
|
|
|
#ifdef CLIENTONLY
|
|
|
|
mainm->selecteditem = (menuoption_t *)b;
|
|
|
|
#endif
|
2004-08-23 00:15:46 +00:00
|
|
|
b->common.width = 12*20;
|
|
|
|
b->common.height = 20;
|
2006-03-06 01:41:09 +00:00
|
|
|
b=MC_AddConsoleCommandHexen2BigFont (mainm, 80, 64+40, "Options", "menu_options\n");
|
2004-08-23 00:15:46 +00:00
|
|
|
b->common.width = 12*20;
|
|
|
|
b->common.height = 20;
|
|
|
|
if (m_helpismedia.value)
|
2006-03-06 01:41:09 +00:00
|
|
|
b=MC_AddConsoleCommandHexen2BigFont (mainm, 80, 64+60, "Media", "menu_media\n");
|
2004-08-23 00:15:46 +00:00
|
|
|
else
|
2006-03-06 01:41:09 +00:00
|
|
|
b=MC_AddConsoleCommandHexen2BigFont (mainm, 80, 64+60, "Help", "help\n");
|
2004-08-23 00:15:46 +00:00
|
|
|
b->common.width = 12*20;
|
|
|
|
b->common.height = 20;
|
2006-03-06 01:41:09 +00:00
|
|
|
b=MC_AddConsoleCommandHexen2BigFont (mainm, 80, 64+80, "Quit", "menu_quit\n");
|
2004-08-23 00:15:46 +00:00
|
|
|
b->common.width = 12*20;
|
|
|
|
b->common.height = 20;
|
|
|
|
|
2010-08-12 00:48:05 +00:00
|
|
|
mainm->cursoritem = (menuoption_t *)MC_AddCursor(mainm, 56, mainm->selecteditem->common.posy);
|
2004-08-23 00:15:46 +00:00
|
|
|
}
|
2006-03-06 01:41:09 +00:00
|
|
|
else if (QBigFontWorks())
|
|
|
|
{
|
|
|
|
m_state = m_complex;
|
|
|
|
key_dest = key_menu;
|
2010-01-15 05:35:27 +00:00
|
|
|
mainm = M_CreateMenu(0);
|
2006-03-06 01:41:09 +00:00
|
|
|
|
2011-03-31 01:14:01 +00:00
|
|
|
p = R2D_SafeCachePic("gfx/ttl_main.lmp");
|
2006-03-06 01:41:09 +00:00
|
|
|
if (!p)
|
|
|
|
{
|
|
|
|
MC_AddRedText(mainm, 16, 0, "MAIN MENU", false);
|
|
|
|
|
|
|
|
mainm->selecteditem = (menuoption_t *)
|
|
|
|
MC_AddConsoleCommand (mainm, 64, 32, "Join server", "menu_servers\n");
|
|
|
|
MC_AddConsoleCommand (mainm, 64, 40, "Options", "menu_options\n");
|
|
|
|
MC_AddConsoleCommand (mainm, 64, 48, "Quit", "menu_quit\n");
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
mainm->key = MC_Main_Key;
|
2009-11-04 21:16:50 +00:00
|
|
|
MC_AddPicture(mainm, 16, 4, 32, 144, "gfx/qplaque.lmp");
|
2006-03-06 01:41:09 +00:00
|
|
|
|
2009-11-04 21:16:50 +00:00
|
|
|
MC_AddCenterPicture(mainm, 4, 24, "gfx/ttl_main.lmp");
|
2006-03-06 01:41:09 +00:00
|
|
|
|
|
|
|
mainm->selecteditem = (menuoption_t *)
|
|
|
|
MC_AddConsoleCommandQBigFont (mainm, 72, 32, "Single ", "menu_single\n");
|
|
|
|
MC_AddConsoleCommandQBigFont (mainm, 72, 52, "Multiplayer", "menu_multi\n");
|
|
|
|
MC_AddConsoleCommandQBigFont (mainm, 72, 72, "Options ", "menu_options\n");
|
|
|
|
if (m_helpismedia.value)
|
|
|
|
MC_AddConsoleCommandQBigFont(mainm, 72, 92, "Media ", "menu_media\n");
|
|
|
|
else
|
|
|
|
MC_AddConsoleCommandQBigFont(mainm, 72, 92, "Help ", "help\n");
|
|
|
|
MC_AddConsoleCommandQBigFont (mainm, 72, 112,"Quit ", "menu_quit\n");
|
|
|
|
|
|
|
|
mainm->cursoritem = (menuoption_t *)MC_AddCursor(mainm, 54, 32);
|
|
|
|
}
|
2004-08-23 00:15:46 +00:00
|
|
|
else
|
|
|
|
{
|
|
|
|
m_state = m_complex;
|
|
|
|
key_dest = key_menu;
|
2010-01-15 05:35:27 +00:00
|
|
|
mainm = M_CreateMenu(0);
|
2004-08-23 00:15:46 +00:00
|
|
|
|
2011-03-31 01:14:01 +00:00
|
|
|
p = R2D_SafeCachePic("gfx/ttl_main.lmp");
|
2004-08-23 00:15:46 +00:00
|
|
|
if (!p)
|
2004-12-15 19:39:21 +00:00
|
|
|
{
|
2005-01-13 16:29:20 +00:00
|
|
|
MC_AddRedText(mainm, 16, 0, "MAIN MENU", false);
|
|
|
|
|
|
|
|
mainm->selecteditem = (menuoption_t *)
|
|
|
|
MC_AddConsoleCommand (mainm, 64, 32, "Join server", "menu_servers\n");
|
|
|
|
MC_AddConsoleCommand (mainm, 64, 40, "Options", "menu_options\n");
|
|
|
|
MC_AddConsoleCommand (mainm, 64, 48, "Quit", "menu_quit\n");
|
2004-08-23 00:15:46 +00:00
|
|
|
return;
|
2004-12-15 19:39:21 +00:00
|
|
|
}
|
2005-01-13 16:29:20 +00:00
|
|
|
mainm->key = MC_Main_Key;
|
2009-11-04 21:16:50 +00:00
|
|
|
MC_AddPicture(mainm, 16, 4, 32, 144, "gfx/qplaque.lmp");
|
2005-01-13 16:29:20 +00:00
|
|
|
|
2009-11-04 21:16:50 +00:00
|
|
|
MC_AddCenterPicture(mainm, 4, 24, "gfx/ttl_main.lmp");
|
|
|
|
MC_AddPicture(mainm, 72, 32, 240, 112, "gfx/mainmenu.lmp");
|
2004-08-23 00:15:46 +00:00
|
|
|
|
2006-01-21 00:06:49 +00:00
|
|
|
|
2011-03-31 01:14:01 +00:00
|
|
|
p = R2D_SafeCachePic("gfx/mainmenu.lmp");
|
2006-01-21 00:06:49 +00:00
|
|
|
|
|
|
|
b=MC_AddConsoleCommand (mainm, 72, 32, "", "menu_single\n");
|
2004-08-23 00:15:46 +00:00
|
|
|
mainm->selecteditem = (menuoption_t *)b;
|
|
|
|
b->common.width = p->width;
|
|
|
|
b->common.height = 20;
|
2006-01-21 00:06:49 +00:00
|
|
|
b=MC_AddConsoleCommand (mainm, 72, 52, "", "menu_multi\n");
|
2004-08-23 00:15:46 +00:00
|
|
|
b->common.width = p->width;
|
|
|
|
b->common.height = 20;
|
2006-01-21 00:06:49 +00:00
|
|
|
b=MC_AddConsoleCommand (mainm, 72, 72, "", "menu_options\n");
|
2004-08-23 00:15:46 +00:00
|
|
|
b->common.width = p->width;
|
|
|
|
b->common.height = 20;
|
|
|
|
if (m_helpismedia.value)
|
2009-04-19 10:50:31 +00:00
|
|
|
{
|
2006-01-21 00:06:49 +00:00
|
|
|
b=MC_AddConsoleCommand(mainm, 72, 92, "", "menu_media\n");
|
2009-04-19 10:50:31 +00:00
|
|
|
}
|
2004-08-23 00:15:46 +00:00
|
|
|
else
|
2009-04-19 10:50:31 +00:00
|
|
|
{
|
2006-01-21 00:06:49 +00:00
|
|
|
b=MC_AddConsoleCommand(mainm, 72, 92, "", "help\n");
|
2009-04-19 10:50:31 +00:00
|
|
|
}
|
2004-08-23 00:15:46 +00:00
|
|
|
b->common.width = p->width;
|
|
|
|
b->common.height = 20;
|
2006-01-21 00:06:49 +00:00
|
|
|
b=MC_AddConsoleCommand (mainm, 72, 112, "", "menu_quit\n");
|
2004-08-23 00:15:46 +00:00
|
|
|
b->common.width = p->width;
|
|
|
|
b->common.height = 20;
|
|
|
|
|
|
|
|
mainm->cursoritem = (menuoption_t *)MC_AddCursor(mainm, 54, 32);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2011-06-07 23:54:58 +00:00
|
|
|
int MC_AddBulk(struct menu_s *menu, menubulk_t *bulk, int xstart, int xtextend, int y)
|
|
|
|
{
|
|
|
|
int selectedy = y;
|
|
|
|
menuoption_t *selected = NULL;
|
|
|
|
|
|
|
|
while (bulk)
|
|
|
|
{
|
2011-06-16 21:41:05 +00:00
|
|
|
qboolean selectable = true;
|
|
|
|
menuoption_t *control;
|
|
|
|
int x = xtextend;
|
|
|
|
int xleft;
|
|
|
|
|
|
|
|
if (bulk->text)
|
|
|
|
x -= strlen(bulk->text) * 8;
|
|
|
|
xleft = x - xstart;
|
|
|
|
|
2011-06-07 23:54:58 +00:00
|
|
|
switch (bulk->type)
|
|
|
|
{
|
|
|
|
case mt_text:
|
|
|
|
switch (bulk->variant)
|
|
|
|
{
|
|
|
|
case -1: // end of menu
|
|
|
|
bulk = NULL;
|
|
|
|
continue;
|
|
|
|
case 0: // white text
|
2011-06-16 21:41:05 +00:00
|
|
|
control = (union menuoption_s *)MC_AddWhiteText(menu, x, y, bulk->text, bulk->rightalign);
|
|
|
|
selectable = false;
|
2011-06-07 23:54:58 +00:00
|
|
|
break;
|
|
|
|
case 1: // red text
|
2011-06-16 21:41:05 +00:00
|
|
|
control = (union menuoption_s *)MC_AddRedText(menu, x, y, bulk->text, bulk->rightalign);
|
|
|
|
selectable = false;
|
2011-06-07 23:54:58 +00:00
|
|
|
break;
|
|
|
|
case 2: // spacing
|
|
|
|
y += bulk->spacing;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case mt_button:
|
2011-06-16 21:41:05 +00:00
|
|
|
switch (bulk->variant)
|
2011-06-07 23:54:58 +00:00
|
|
|
{
|
2011-06-16 21:41:05 +00:00
|
|
|
default:
|
|
|
|
case 0: // console command
|
|
|
|
control = (union menuoption_s *)MC_AddConsoleCommand(menu, x, y, bulk->text, bulk->consolecmd);
|
|
|
|
break;
|
|
|
|
case 1: // function command
|
|
|
|
control = (union menuoption_s *)MC_AddCommand(menu, x, y, bulk->text, bulk->command);
|
|
|
|
break;
|
2011-06-07 23:54:58 +00:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
case mt_checkbox:
|
2011-06-16 21:41:05 +00:00
|
|
|
control = (union menuoption_s *)MC_AddCheckBox(menu, x, y, bulk->text, bulk->cvar, bulk->flags);
|
|
|
|
control->check.func = bulk->func;
|
2011-06-07 23:54:58 +00:00
|
|
|
break;
|
|
|
|
case mt_slider:
|
2011-06-16 21:41:05 +00:00
|
|
|
control = (union menuoption_s *)MC_AddSlider(menu, x, y, bulk->text, bulk->cvar, bulk->min, bulk->max, bulk->delta);
|
2011-06-07 23:54:58 +00:00
|
|
|
break;
|
|
|
|
case mt_combo:
|
2011-06-16 21:41:05 +00:00
|
|
|
switch (bulk->variant)
|
2011-06-07 23:54:58 +00:00
|
|
|
{
|
2011-06-16 21:41:05 +00:00
|
|
|
default:
|
|
|
|
case 0: // cvar combo
|
|
|
|
control = (union menuoption_s *)MC_AddCvarCombo(menu, x, y, bulk->text, bulk->cvar, bulk->options, bulk->values);
|
|
|
|
break;
|
|
|
|
case 1: // combo with return value
|
|
|
|
control = (union menuoption_s *)MC_AddCombo(menu, x, y, bulk->text, bulk->options, bulk->selectedoption);
|
|
|
|
break;
|
2011-06-07 23:54:58 +00:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
case mt_edit:
|
2011-06-16 21:41:05 +00:00
|
|
|
switch (bulk->variant)
|
2011-06-07 23:54:58 +00:00
|
|
|
{
|
2011-06-16 21:41:05 +00:00
|
|
|
default:
|
|
|
|
case 0:
|
|
|
|
y += 4;
|
|
|
|
control = (union menuoption_s *)MC_AddEditCvar(menu, x, y, bulk->text, bulk->cvarname);
|
|
|
|
y += 4;
|
|
|
|
break;
|
|
|
|
case 1:
|
|
|
|
control = (union menuoption_s *)MC_AddEditCvarSlim(menu, x, y, bulk->text, bulk->cvarname);
|
|
|
|
break;
|
2011-06-07 23:54:58 +00:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
Con_Printf(CON_ERROR "Invalid type in bulk menu!\n");
|
|
|
|
bulk = NULL;
|
|
|
|
continue;
|
|
|
|
}
|
2011-06-16 21:41:05 +00:00
|
|
|
|
|
|
|
if (bulk->ret)
|
|
|
|
*bulk->ret = control;
|
|
|
|
if (selectable && !selected)
|
|
|
|
selected = control;
|
|
|
|
if (bulk->tooltip)
|
|
|
|
control->common.tooltip = bulk->tooltip;
|
|
|
|
if (xleft > 0)
|
|
|
|
control->common.extracollide = xleft;
|
|
|
|
y += 8;
|
|
|
|
|
2011-06-07 23:54:58 +00:00
|
|
|
bulk++;
|
|
|
|
}
|
|
|
|
|
|
|
|
menu->selecteditem = selected;
|
|
|
|
if (selected)
|
|
|
|
selectedy = selected->common.posy;
|
|
|
|
menu->cursoritem = (menuoption_t*)MC_AddWhiteText(menu, xtextend + 8, selectedy, NULL, false);
|
|
|
|
return y;
|
|
|
|
}
|