provide a builtin to draw a crosshair.

This commit is contained in:
Bill Currie 2004-02-13 23:16:33 +00:00
parent efb52dc9f9
commit f34335a0c9
5 changed files with 75 additions and 41 deletions

View file

@ -44,6 +44,7 @@ void Draw_TextBox (int x, int y, int width, int lines, byte alpha);
void Draw_TransPicTranslate (int x, int y, qpic_t *pic, byte *translation);
void Draw_ConsoleBackground (int lines, byte alpha);
void Draw_Crosshair (void);
void Draw_CrosshairAt (int ch, int x, int y);
void Draw_BeginDisc (void);
void Draw_EndDisc (void);
void Draw_TileClear (int x, int y, int w, int h);

View file

@ -563,29 +563,36 @@ crosshair_3 (int x, int y)
qfglColor3ubv (color_white);
}
static void (*crosshair_func[]) (int x, int y) = {
crosshair_1,
crosshair_2,
crosshair_3,
};
void
Draw_Crosshair (void)
{
int x, y;
int ch;
if (!crosshair->int_val)
ch = crosshair->int_val - 1;
if ((unsigned) ch >= sizeof (crosshair_func) / sizeof (crosshair_func[0]))
return;
x = scr_vrect.x + scr_vrect.width / 2 + cl_crossx->int_val;
y = scr_vrect.y + scr_vrect.height / 2 + cl_crossy->int_val;
switch (crosshair->int_val) {
default:
case 1:
crosshair_1 (x, y);
break;
case 2:
crosshair_2 (x, y);
break;
case 3:
crosshair_3 (x, y);
break;
}
crosshair_func[ch] (x, y);
}
void
Draw_CrosshairAt (int ch, int x, int y)
{
ch -= 1;
if ((unsigned) ch >= sizeof (crosshair_func) / sizeof (crosshair_func[0]))
return;
crosshair_func[ch] (x, y);
}
void

View file

@ -198,6 +198,16 @@ bi_Draw_Fill (progs_t *pr)
Draw_Fill (x, y, w, h, color);
}
static void
bi_Draw_Crosshair (progs_t *pr)
{
int ch = P_INT (pr, 0);
int x = P_INT (pr, 1);
int y = P_INT (pr, 2);
Draw_CrosshairAt (ch, x, y);
}
static const char *
bi_draw_get_key (void *p, void *unused)
{
@ -231,6 +241,7 @@ static builtin_t builtins[] = {
{"Draw_nString", bi_Draw_nString, -1},
{"Draw_AltString", bi_Draw_AltString, -1},
{"Draw_Fill", bi_Draw_Fill, -1},
{"Draw_Crosshair", bi_Draw_Crosshair, -1},
{0}
};

View file

@ -328,28 +328,36 @@ crosshair_3 (int x, int y)
Draw_Pixel (x + 3, y + 3, c);
}
static void (*crosshair_func[]) (int x, int y) = {
crosshair_1,
crosshair_2,
crosshair_3,
};
void
Draw_Crosshair (void)
{
int x, y;
int x, y;
int ch;
if (!crosshair->int_val)
ch = crosshair->int_val - 1;
if ((unsigned) ch >= sizeof (crosshair_func) / sizeof (crosshair_func[0]))
return;
x = scr_vrect.x + scr_vrect.width / 2 + cl_crossx->int_val;
y = scr_vrect.y + scr_vrect.height / 2 + cl_crossy->int_val;
switch (crosshair->int_val) {
default:
case 1:
crosshair_1 (x, y);
break;
case 2:
crosshair_2 (x, y);
break;
case 3:
crosshair_3 (x, y);
break;
}
crosshair_func[ch] (x, y);
}
void
Draw_CrosshairAt (int ch, int x, int y)
{
ch -= 1;
if ((unsigned) ch >= sizeof (crosshair_func) / sizeof (crosshair_func[0]))
return;
crosshair_func[ch] (x, y);
}

View file

@ -402,30 +402,37 @@ crosshair_3 (int x, int y)
Draw_Pixel (x + 3, y + 3, c);
}
static void (*crosshair_func[]) (int x, int y) = {
crosshair_1,
crosshair_2,
crosshair_3,
};
void
Draw_Crosshair (void)
{
int x, y;
int x, y;
int ch;
if (!crosshair->int_val)
ch = crosshair->int_val - 1;
if ((unsigned) ch >= sizeof (crosshair_func) / sizeof (crosshair_func[0]))
return;
x = scr_vrect.x + scr_vrect.width / 2 + cl_crossx->int_val;
y = scr_vrect.y + scr_vrect.height / 2 + cl_crossy->int_val;
switch (crosshair->int_val) {
default:
case 1:
crosshair_1 (x, y);
break;
case 2:
crosshair_2 (x, y);
break;
case 3:
crosshair_3 (x, y);
break;
}
crosshair_func[ch] (x, y);
}
void
Draw_CrosshairAt (int ch, int x, int y)
{
ch -= 1;
if ((unsigned) ch >= sizeof (crosshair_func) / sizeof (crosshair_func[0]))
return;
crosshair_func[ch] (x, y);
}
void
Draw_Pic (int x, int y, qpic_t *pic)