summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRoman Tetelman <kevlarman@gmail.com>2009-10-03 12:00:40 +0000
committerTim Angus <tim@ngus.net>2013-01-03 00:15:36 +0000
commit33f9c3de4cc37723e847d78c2a5922bbeb1a314a (patch)
tree39bd63db22f4af1c779dbda90f06dddb4fabeb41
parentcfee798a10d895fd2e11d6304236eef400e4751d (diff)
* redo changeset r250 to avoid hardcoding colors
-rw-r--r--src/cgame/cg_draw.c34
-rw-r--r--src/cgame/cg_local.h2
-rw-r--r--ui/menudef.h1
-rw-r--r--ui/tremulous_common_hud.h10
4 files changed, 29 insertions, 18 deletions
diff --git a/src/cgame/cg_draw.c b/src/cgame/cg_draw.c
index f7c1f188..223bba86 100644
--- a/src/cgame/cg_draw.c
+++ b/src/cgame/cg_draw.c
@@ -2140,20 +2140,13 @@ CROSSHAIR
*/
-const vec4_t crosshairColours[ ] =
-{
- { 1.0f, 0.0f, 0.0f, 0.35f }, // alien normal
- { 0.5f, 0.0f, 0.0f, 0.35f }, // alien team
- { 0.0f, 0.8f, 1.0f, 0.35f }, // human normal
- { 0.0f, 0.4f, 0.5f, 0.35f } // human team
-};
/*
=================
CG_DrawCrosshair
=================
*/
-static void CG_DrawCrosshair( void )
+static void CG_DrawCrosshair( rectDef_t *rect, vec4_t color )
{
float w, h;
qhandle_t hShader;
@@ -2182,22 +2175,27 @@ static void CG_DrawCrosshair( void )
w = h = wi->crossHairSize * cg_crosshairSize.value;
w *= cgDC.aspectScale;
-
+
+ //FIXME: find a way to use rect from the hud instead of cg_crosshair[XY]
+ //the different sizes of the crosshairs make this a pain
x = 320 + cg_crosshairX.integer - ( w / 2 );
y = 240 + cg_crosshairY.integer - ( h / 2 );
hShader = wi->crossHair;
+
+ //aiming at a friendly player/buildable, dim the crosshair
+ if( cg.time == cg.crosshairClientTime || cg.crosshairBuildable >= 0 )
+ {
+ int i;
+ for( i = 0; i < 3; i++ )
+ color[i] *= .5f;
+
+ }
if( hShader != 0 )
{
- int colour = 0;
- if( cg.snap->ps.stats[ STAT_TEAM ] == TEAM_HUMANS )
- colour += 2;
-
- if( cg.time == cg.crosshairClientTime || cg.crosshairBuildable >= 0 )
- colour += 1;
- trap_R_SetColor( crosshairColours[ colour ] );
+ trap_R_SetColor( color );
CG_DrawPic( x, y, w, h, hShader );
trap_R_SetColor( NULL );
}
@@ -2408,6 +2406,9 @@ void CG_OwnerDraw( float x, float y, float w, float h, float text_x,
case CG_PLAYER_CROSSHAIRNAMES:
CG_DrawCrosshairNames( &rect, scale, textStyle );
break;
+ case CG_PLAYER_CROSSHAIR:
+ CG_DrawCrosshair( &rect, color );
+ break;
case CG_STAGE_REPORT_TEXT:
CG_DrawStageReport( &rect, text_x, text_y, color, scale, textalign, textvalign, textStyle );
break;
@@ -3021,7 +3022,6 @@ static void CG_Draw2D( void )
if( cg_drawStatus.integer )
Menu_Paint( menu, qtrue );
- CG_DrawCrosshair( );
}
else if( cg_drawStatus.integer )
Menu_Paint( defaultMenu, qtrue );
diff --git a/src/cgame/cg_local.h b/src/cgame/cg_local.h
index bcb7ed70..72a61fc2 100644
--- a/src/cgame/cg_local.h
+++ b/src/cgame/cg_local.h
@@ -1034,7 +1034,7 @@ typedef struct
// kill timers for carnage reward
int lastKillTime;
- // targeted entity
+ // crosshair client ID
int crosshairBuildable;
int crosshairClientNum;
int crosshairClientTime;
diff --git a/ui/menudef.h b/ui/menudef.h
index 6b9705e1..629655bf 100644
--- a/ui/menudef.h
+++ b/ui/menudef.h
@@ -177,5 +177,6 @@
#define CG_PLAYER_CHARGE_BAR_BG 76
#define CG_PLAYER_CHARGE_BAR 77
+#define CG_PLAYER_CROSSHAIR 78
#endif
diff --git a/ui/tremulous_common_hud.h b/ui/tremulous_common_hud.h
index 19647ff9..c4dfcf1c 100644
--- a/ui/tremulous_common_hud.h
+++ b/ui/tremulous_common_hud.h
@@ -161,3 +161,13 @@ itemDef
textstyle ITEM_TEXTSTYLE_SHADOWED
}
+//CROSSHAIR
+
+itemDef
+{
+ name "crosshair"
+ visible MENU_TRUE
+ decoration
+ forecolor COMMON_HUD_R COMMON_HUD_G COMMON_HUD_B .35
+ ownerdraw CG_PLAYER_CROSSHAIR
+}