Skip to content

Commit

Permalink
Support score higher than 99 in HUD
Browse files Browse the repository at this point in the history
git-svn-id: https://smokinguns.svn.sourceforge.net/svnroot/smokinguns/trunk@656 07eb42f0-b032-4355-afd3-42b1f3832223
  • Loading branch information
sg_tequila committed Dec 15, 2012
1 parent 43e8946 commit 036053b
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 4 deletions.
36 changes: 35 additions & 1 deletion code/cgame/cg_draw.c
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
===========================================================================
Copyright (C) 1999-2005 Id Software, Inc.
Copyright (C) 2000-2003 Iron Claw Interactive
Copyright (C) 2005-2010 Smokin' Guns
Copyright (C) 2005-2012 Smokin' Guns
This file is part of Smokin' Guns.
Expand Down Expand Up @@ -352,6 +352,40 @@ void CG_DrawMoneyField (int x, int y, int width, int value) {
l--;
}
}

#define SCORE_WIDTH2 10
#define SCORE_WIDTH3 8
#define SCORE_HEIGHT2 14
#define SCORE_HEIGHT3 12
void CG_DrawScoreField (int x, int y, int value) {
char num[16], *ptr;
int l,w,h;

value = value < 0 ? 0 : value;
value = value > 999 ? 999 : value;

Com_sprintf (num, sizeof(num), "%i", value);
l = strlen(num);
x += 2 ;
if (l>2) {
w = SCORE_WIDTH3 ;
h = SCORE_HEIGHT3 ;
y += (SCORE_HEIGHT2-SCORE_HEIGHT3)/2 ;
} else {
w = SCORE_WIDTH2 ;
h = SCORE_HEIGHT2 ;
x += w * (2 - l);
}

ptr = num;
while (*ptr && l)
{
CG_DrawPic( x, y, w, h, cgs.media.numbermoneyShaders[*ptr -'0'] );
x += w ;
ptr++;
l--;
}
}
#endif

/*
Expand Down
7 changes: 4 additions & 3 deletions code/cgame/cg_newdraw.c
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
===========================================================================
Copyright (C) 1999-2005 Id Software, Inc.
Copyright (C) 2000-2003 Iron Claw Interactive
Copyright (C) 2005-2010 Smokin' Guns
Copyright (C) 2005-2012 Smokin' Guns
This file is part of Smokin' Guns.
Expand Down Expand Up @@ -34,6 +34,7 @@ extern displayContextDef_t cgDC;
#ifdef SMOKINGUNS
void CG_DrawField (int x, int y, int width, int value);
void CG_DrawMoneyField (int x, int y, int width, int value);
void CG_DrawScoreField (int x, int y, int value);
#endif

// set in CG_ParseTeamInfo
Expand Down Expand Up @@ -2023,7 +2024,7 @@ void CG_OwnerDraw(itemDef_t *item, float x, float y, float w, float h, float tex
}
if(!(cgs.gametype == GT_DUEL && cg.snap->ps.pm_flags & PMF_FOLLOW &&
cg.snap->ps.pm_type != PM_CHASECAM) && score != SCORE_NOT_PRESENT) {
CG_DrawMoneyField (rect.x, rect.y, 2, score);
CG_DrawScoreField (rect.x, rect.y, score);
}
break;
case CG_FIELD_SCORE2:
Expand All @@ -2035,7 +2036,7 @@ void CG_OwnerDraw(itemDef_t *item, float x, float y, float w, float h, float tex
}
if(!(cgs.gametype == GT_DUEL && cg.snap->ps.pm_flags & PMF_FOLLOW &&
cg.snap->ps.pm_type != PM_CHASECAM) && score != SCORE_NOT_PRESENT) {
CG_DrawMoneyField (rect.x, rect.y, 2, score);
CG_DrawScoreField (rect.x, rect.y, score);
}
trap_R_SetColor(NULL);
break;
Expand Down

0 comments on commit 036053b

Please sign in to comment.