HUD ammo/clips alignment.

This commit is contained in:
Andrei Drexler 2009-06-30 13:51:07 +00:00
parent 91503e431c
commit d18feb88ec
2 changed files with 11 additions and 30 deletions

View file

@ -496,15 +496,6 @@ static void CG_DrawStatusBar(void)
//Makro - added x and y for weapon drawing
int i, x = cgs.screenXMax - SMICON_SIZE - 8, y = 400;
//Makro - old values
/*
static float colors[4][4] = {
{0.0f, 1.0f, 0.0f, 1.0f}, // full green
{0.6f, 0.6f, 0.6f, 1.0f}, // firing
{0.8f, 0.8f, 0.0f, 1.0f}, // not maximum
{0.8f, 0.0f, 0.0f, 1.0f}
}; // out of ammo
*/
//Makro - now using the same colors for both health and ammo
static float colors[5][4] = {
{1.0f, 1.0f, 1.0f, 1.0f}, // full green
@ -513,6 +504,7 @@ static void CG_DrawStatusBar(void)
{0.8f, 0.0f, 0.0f, 1.0f}, // out of ammo
{0.0f, 1.0f, 0.0f, 1.0f} //Makro - reloading
};
//Makro - health colors
static float hcolors[3][4] = {
{1.0f, 1.0f, 1.0f, 1.0f},
@ -541,12 +533,6 @@ static void CG_DrawStatusBar(void)
//Blends from green to yellow to red algebraically
//100 - Green, 50 - Yellow, 25 - Red, 0 - Faded Red
//Note: These formulas are clamped from 0.0 to 1.0 algebraically
/*
hcolor[0] = (value > 50) * (-0.02 * value + 2.0) + (value <= 50) * 1;
hcolor[1] = (value > 25 && value <= 50) * (0.04 * value - 1.0) + (value > 50) * 1;
hcolor[2] = 0;
hcolor[3] = (value <= 25) * (0.01 * value + 0.75) + (value > 25) * 1;
*/
if (value > 50) {
float frac = (value - 50) / 50.0f, ifrac = (1.0f - frac);
hcolor[0] = frac * hcolors[0][0] + ifrac * hcolors[1][0];
@ -561,18 +547,6 @@ static void CG_DrawStatusBar(void)
hcolor[3] = frac * hcolors[1][3] + ifrac * hcolors[2][3];
}
/* Elder: Old clamp routine for reference -- more efficient since less stack usage?
for (i = 0; i < 4; i++) {
if (hcolor[i] > 1.0) {
CG_Printf ("Over one on %i\n",i);
hcolor[i] = 1.0;
}
else if (hcolor[i] < 0.0) {
CG_Printf ("Below zero on %i\n",i);
hcolor[i] = 0.0;
}
} */
CG_DrawPic(cgs.screenXMin + 8, 440, SMICON_SIZE, SMICON_SIZE, hicon);
//CG_DrawStringExt(44, 444, va("%d", value), hcolor, qtrue, qtrue, 24, 24, 3);
//UI_DrawProportionalString(44, 444, va("%d", value), style, hcolor);
@ -596,7 +570,7 @@ static void CG_DrawStatusBar(void)
//if (icon && cg.predictedPlayerState.weapon != WP_KNIFE && cg.predictedPlayerState.weapon != WP_GRENADE)
if (icon)
//CG_DrawPic(252, 440, SMICON_SIZE, SMICON_SIZE, icon);
CG_DrawPic(cgs.screenXMin + 288, 440, SMICON_SIZE, SMICON_SIZE, icon);
CG_DrawPic(288, 440, SMICON_SIZE, SMICON_SIZE, icon);
if (cent->currentState.weapon) {
value = ps->ammo[cent->currentState.weapon];
@ -637,7 +611,11 @@ static void CG_DrawStatusBar(void)
}
if (value >= 0)
UI_DrawProportionalString(cgs.screenXMin + 200, 444, va("%d", value), style, hcolor);
{
const char* str = va("%d", value);
int width = UI_ProportionalStringWidth(str) * UI_ProportionalSizeScale(style);
UI_DrawProportionalString(288 - width, 444, str, style, hcolor);
}
#endif
//UI_DrawProportionalString(188, 444, "/"), style, colors[0]);
@ -646,7 +624,7 @@ static void CG_DrawStatusBar(void)
if (value > -1 &&
cg.predictedPlayerState.weapon != WP_KNIFE && cg.predictedPlayerState.weapon != WP_GRENADE)
//Makro - pretty colours !
UI_DrawProportionalString(cgs.screenXMin + 320, 444, va("%d", value), style, (value != 0) ? colors[0] : colors[3]);
UI_DrawProportionalString(320, 444, va("%d", value), style, (value != 0) ? colors[0] : colors[3]);
}
// Elder: temporary
//if (cg.snap->ps.stats[STAT_RELOADTIME] > 0)

View file

@ -2124,6 +2124,9 @@ void CG_ColorForHealth(vec4_t hcolor);
void CG_GetColorForHealth(int health, int armor, vec4_t hcolor);
void UI_DrawProportionalString(int x, int y, const char *str, int style, vec4_t color);
int UI_ProportionalStringWidth(const char *str);
float UI_ProportionalSizeScale(int style);
void CG_DrawRect(float x, float y, float width, float height, float size, const float *color);
void CG_DrawSides(float x, float y, float w, float h, float size);
void CG_DrawTopBottom(float x, float y, float w, float h, float size);