Add a new crosshair.

Now all 4 slots of the crosshair table are used :)

Also, fix the offset for pic based crosshairs in glsl, and use just one
func for them.
This commit is contained in:
Bill Currie 2012-12-12 19:36:18 +09:00
parent 07d348fbd8
commit a372efee5c
5 changed files with 173 additions and 53 deletions

View file

@ -65,6 +65,15 @@ byte crosshair_data[CROSSHAIR_WIDTH * CROSSHAIR_HEIGHT * CROSSHAIR_COUNT] = {
255,255,255, 7, 8, 2,255,255,
255,255,255,255, 2, 2,255,255,
255,255,255,255,255,255,255,255,
0xff,0xff,0xfe,0xfe,0xfe,0xff,0xff,0xff,
0xff,0xfe,0xff,0xff,0xff,0xfe,0xff,0xff,
0xfe,0xff,0xff,0xff,0xff,0xff,0xfe,0xff,
0xfe,0xff,0xff,0xfe,0xff,0xff,0xfe,0xff,
0xfe,0xff,0xff,0xff,0xff,0xff,0xfe,0xff,
0xff,0xfe,0xff,0xff,0xff,0xfe,0xff,0xff,
0xff,0xff,0xfe,0xfe,0xfe,0xff,0xff,0xff,
0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
};
qpic_t *

View file

@ -519,67 +519,35 @@ glsl_Draw_AltString (int x, int y, const char *str)
}
static void
crosshair_1 (int x, int y)
draw_crosshair_plus (int ch, int x, int y)
{
glsl_Draw_Character (x - 4, y - 4, '+');
}
//FIXME these should use an index to select the region.
static void
crosshair_2 (int x, int y)
draw_crosshair_pic (int ch, int x, int y)
{
draw_pic (x, y, CROSSHAIR_WIDTH, CROSSHAIR_HEIGHT, crosshair_pic,
0, 0, CROSSHAIR_WIDTH, CROSSHAIR_HEIGHT, crosshair_color);
static const int pos[CROSSHAIR_COUNT][4] = {
{0, 0, CROSSHAIR_WIDTH, CROSSHAIR_HEIGHT},
{CROSSHAIR_WIDTH, 0, CROSSHAIR_WIDTH, CROSSHAIR_HEIGHT},
{0, CROSSHAIR_HEIGHT, CROSSHAIR_WIDTH, CROSSHAIR_HEIGHT},
{CROSSHAIR_WIDTH, CROSSHAIR_HEIGHT, CROSSHAIR_WIDTH, CROSSHAIR_HEIGHT},
};
const int *p = pos[ch - 1];
draw_pic (x - CROSSHAIR_WIDTH / 2, y - CROSSHAIR_HEIGHT / 2,
CROSSHAIR_WIDTH, CROSSHAIR_HEIGHT, crosshair_pic,
p[0], p[1], p[2], p[3], crosshair_color);
}
static void
crosshair_3 (int x, int y)
{
draw_pic (x, y, CROSSHAIR_WIDTH, CROSSHAIR_HEIGHT, crosshair_pic,
CROSSHAIR_WIDTH, 0,
CROSSHAIR_WIDTH, CROSSHAIR_HEIGHT, crosshair_color);
}
static void
crosshair_4 (int x, int y)
{
draw_pic (x, y, CROSSHAIR_WIDTH, CROSSHAIR_HEIGHT, crosshair_pic,
0, CROSSHAIR_HEIGHT,
CROSSHAIR_WIDTH, CROSSHAIR_HEIGHT, crosshair_color);
}
static void
crosshair_5 (int x, int y)
{
draw_pic (x, y, CROSSHAIR_WIDTH, CROSSHAIR_HEIGHT, crosshair_pic,
CROSSHAIR_WIDTH, CROSSHAIR_HEIGHT,
CROSSHAIR_WIDTH, CROSSHAIR_HEIGHT, crosshair_color);
}
static void (*crosshair_func[]) (int x, int y) = {
crosshair_1,
crosshair_2,
crosshair_3,
crosshair_4,
crosshair_5,
static void (*crosshair_func[]) (int ch, int x, int y) = {
draw_crosshair_plus,
draw_crosshair_pic,
draw_crosshair_pic,
draw_crosshair_pic,
draw_crosshair_pic,
};
void
glsl_Draw_Crosshair (void)
{
int x, y;
size_t ch;
ch = crosshair->int_val - 1;
if (ch >= sizeof (crosshair_func) / sizeof (crosshair_func[0]))
return;
x = vid.conwidth / 2 + cl_crossx->int_val;
y = vid.conheight / 2 + cl_crossy->int_val;
crosshair_func[ch] (x, y);
}
void
glsl_Draw_CrosshairAt (int ch, int x, int y)
{
@ -588,7 +556,18 @@ glsl_Draw_CrosshairAt (int ch, int x, int y)
if (c >= sizeof (crosshair_func) / sizeof (crosshair_func[0]))
return;
crosshair_func[c] (x, y);
crosshair_func[c] (c, x, y);
}
void
glsl_Draw_Crosshair (void)
{
int x, y;
x = vid.conwidth / 2 + cl_crossx->int_val;
y = vid.conheight / 2 + cl_crossy->int_val;
glsl_Draw_CrosshairAt (crosshair->int_val, x, y);
}
void

View file

@ -379,10 +379,76 @@ crosshair_3 (int x, int y)
Draw_Pixel (x + 3, y + 3, c);
}
static void
crosshair_4 (int x, int y)
{
//byte c = crosshaircolor->int_val;
Draw_Pixel (x, y - 2, 8);
Draw_Pixel (x + 1, y - 2, 9);
Draw_Pixel (x, y - 1, 6);
Draw_Pixel (x + 1, y - 1, 8);
Draw_Pixel (x + 2, y - 1, 2);
Draw_Pixel (x - 2, y, 6);
Draw_Pixel (x - 1, y, 8);
Draw_Pixel (x, y, 8);
Draw_Pixel (x + 1, y, 6);
Draw_Pixel (x + 2, y, 8);
Draw_Pixel (x + 3, y, 8);
Draw_Pixel (x - 1, y + 1, 2);
Draw_Pixel (x, y + 1, 8);
Draw_Pixel (x + 1, y + 1, 8);
Draw_Pixel (x + 2, y + 1, 2);
Draw_Pixel (x + 3, y + 1, 2);
Draw_Pixel (x + 4, y + 1, 2);
Draw_Pixel (x, y + 2, 7);
Draw_Pixel (x + 1, y + 2, 8);
Draw_Pixel (x + 2, y + 2, 2);
Draw_Pixel (x + 1, y + 3, 2);
Draw_Pixel (x + 2, y + 3, 2);
}
static void
crosshair_5 (int x, int y)
{
byte c = crosshaircolor->int_val;
Draw_Pixel (x - 1, y - 3, c);
Draw_Pixel (x + 0, y - 3, c);
Draw_Pixel (x + 1, y - 3, c);
Draw_Pixel (x - 2, y - 2, c);
Draw_Pixel (x + 2, y - 2, c);
Draw_Pixel (x - 3, y - 1, c);
Draw_Pixel (x + 3, y - 1, c);
Draw_Pixel (x - 3, y, c);
Draw_Pixel (x, y, c);
Draw_Pixel (x + 3, y, c);
Draw_Pixel (x - 3, y + 1, c);
Draw_Pixel (x + 3, y + 1, c);
Draw_Pixel (x - 2, y + 2, c);
Draw_Pixel (x + 2, y + 2, c);
Draw_Pixel (x - 1, y + 3, c);
Draw_Pixel (x + 0, y + 3, c);
Draw_Pixel (x + 1, y + 3, c);
}
static void (*crosshair_func[]) (int x, int y) = {
crosshair_1,
crosshair_2,
crosshair_3,
crosshair_4,
crosshair_5,
};
void

View file

@ -456,10 +456,76 @@ crosshair_3 (int x, int y)
Draw_Pixel (x + 3, y + 3, c);
}
static void
crosshair_4 (int x, int y)
{
//byte c = crosshaircolor->int_val;
Draw_Pixel (x, y - 2, 8);
Draw_Pixel (x + 1, y - 2, 9);
Draw_Pixel (x, y - 1, 6);
Draw_Pixel (x + 1, y - 1, 8);
Draw_Pixel (x + 2, y - 1, 2);
Draw_Pixel (x - 2, y, 6);
Draw_Pixel (x - 1, y, 8);
Draw_Pixel (x, y, 8);
Draw_Pixel (x + 1, y, 6);
Draw_Pixel (x + 2, y, 8);
Draw_Pixel (x + 3, y, 8);
Draw_Pixel (x - 1, y + 1, 2);
Draw_Pixel (x, y + 1, 8);
Draw_Pixel (x + 1, y + 1, 8);
Draw_Pixel (x + 2, y + 1, 2);
Draw_Pixel (x + 3, y + 1, 2);
Draw_Pixel (x + 4, y + 1, 2);
Draw_Pixel (x, y + 2, 7);
Draw_Pixel (x + 1, y + 2, 8);
Draw_Pixel (x + 2, y + 2, 2);
Draw_Pixel (x + 1, y + 3, 2);
Draw_Pixel (x + 2, y + 3, 2);
}
static void
crosshair_5 (int x, int y)
{
byte c = crosshaircolor->int_val;
Draw_Pixel (x - 1, y - 3, c);
Draw_Pixel (x + 0, y - 3, c);
Draw_Pixel (x + 1, y - 3, c);
Draw_Pixel (x - 2, y - 2, c);
Draw_Pixel (x + 2, y - 2, c);
Draw_Pixel (x - 3, y - 1, c);
Draw_Pixel (x + 3, y - 1, c);
Draw_Pixel (x - 3, y, c);
Draw_Pixel (x, y, c);
Draw_Pixel (x + 3, y, c);
Draw_Pixel (x - 3, y + 1, c);
Draw_Pixel (x + 3, y + 1, c);
Draw_Pixel (x - 2, y + 2, c);
Draw_Pixel (x + 2, y + 2, c);
Draw_Pixel (x - 1, y + 3, c);
Draw_Pixel (x + 0, y + 3, c);
Draw_Pixel (x + 1, y + 3, c);
}
static void (*crosshair_func[]) (int x, int y) = {
crosshair_1,
crosshair_2,
crosshair_3,
crosshair_4,
crosshair_5,
};
void

View file

@ -6,7 +6,7 @@
-(void) next
{
local int val = Cvar_GetInteger (name);
Cvar_SetInteger (name, (val + 1) % 4);
Cvar_SetInteger (name, (val + 1) % 6);
}
-(int) crosshair