1 // Emacs style mode select -*- C++ -*-
2 //-----------------------------------------------------------------------------
6 // Copyright (C) 1993-1996 by id Software, Inc.
8 // This source is available for distribution and/or modification
9 // only under the terms of the DOOM Source Code License as
10 // published by id Software. All rights reserved.
12 // The source is distributed in the hope that it will be useful,
13 // but WITHOUT ANY WARRANTY; without even the implied warranty of
14 // FITNESS FOR A PARTICULAR PURPOSE. See the DOOM Source Code License
20 // The status bar widget code.
22 //-----------------------------------------------------------------------------
26 rcsid[] = "$Id: st_lib.c,v 1.4 1997/02/03 16:47:56 b1 Exp $";
47 extern boolean automapactive;
53 // Hack display negative frags.
54 // Loads and store the stminus lump.
60 sttminus = (patch_t *) W_CacheLumpName("STTMINUS", PU_STATIC);
86 // A fairly efficient way to draw a number
87 // based on differences from the old number.
88 // Note: worth the trouble?
96 int numdigits = n->width;
99 int w = SHORT(n->p[0]->width);
100 int h = SHORT(n->p[0]->height);
111 if (numdigits == 2 && num < -9)
113 else if (numdigits == 3 && num < -99)
120 x = n->x - numdigits*w;
123 I_Error("drawNum: n->y - ST_Y < 0");
125 V_CopyRect(x, n->y - ST_Y, BG, w*numdigits, h, x, n->y, FG);
127 // if non-number, do not draw it
133 // in the special case of 0, you draw 0
135 V_DrawPatch(x - w, n->y, FG, n->p[ 0 ]);
137 // draw the new number
138 while (num && numdigits--)
141 V_DrawPatch(x, n->y, FG, n->p[ num % 10 ]);
145 // draw a minus sign if necessary
147 V_DrawPatch(x - 8, n->y, FG, sttminus);
157 if (*n->on) STlib_drawNum(n, refresh);
172 STlib_initNum(&p->n, x, y, pl, num, on, 3);
184 if (refresh && *per->n.on)
185 V_DrawPatch(per->n.x, per->n.y, FG, per->p);
187 STlib_updateNum(&per->n, refresh);
222 && (mi->oldinum != *mi->inum || refresh)
225 if (mi->oldinum != -1)
227 x = mi->x - SHORT(mi->p[mi->oldinum]->leftoffset);
228 y = mi->y - SHORT(mi->p[mi->oldinum]->topoffset);
229 w = SHORT(mi->p[mi->oldinum]->width);
230 h = SHORT(mi->p[mi->oldinum]->height);
233 I_Error("updateMultIcon: y - ST_Y < 0");
235 V_CopyRect(x, y-ST_Y, BG, w, h, x, y, FG);
237 V_DrawPatch(mi->x, mi->y, FG, mi->p[*mi->inum]);
238 mi->oldinum = *mi->inum;
274 && (bi->oldval != *bi->val || refresh))
276 x = bi->x - SHORT(bi->p->leftoffset);
277 y = bi->y - SHORT(bi->p->topoffset);
278 w = SHORT(bi->p->width);
279 h = SHORT(bi->p->height);
282 I_Error("updateBinIcon: y - ST_Y < 0");
285 V_DrawPatch(bi->x, bi->y, FG, bi->p);
287 V_CopyRect(x, y-ST_Y, BG, w, h, x, y, FG);
289 bi->oldval = *bi->val;