components/prboom/st_lib.c
/*
 * STlib_drawNum()
 *
 * A fairly efficient way to draw a number based on differences from the
 * old number.
 *
 * Passed a st_number_t widget, a color range for output, and a flag
 * indicating whether refresh is needed.
 * Returns nothing
 *
 * jff 2/16/98 add color translation to digit output
 * cphipps 10/99 - const pointer to colour trans table, made function static
 */
STlib_drawNum()
A fairly efficient way to draw a number based on differences from the
old number.

Passed a st_number_t widget, a color range for output, and a flag
indicating whether refresh is needed.
Returns nothing

jff 2/16/98 add color translation to digit output
cphipps 10/99 - const pointer to colour trans table, made function static
STlib_drawNum () A fairly efficient way to draw a number based on differences from the old number . Passed a st_number_t widget a color range for output and a flag indicating whether refresh is needed . Returns nothing jff 2 / 16 / 98 add color translation to digit output cphipps 10 / 99 - const pointer to colour trans table made function static
static void STlib_drawNum
( st_number_t*  n,
  int cm,
  boolean refresh )
{
  int   numdigits = n->width;
  int   num = *n->num;
  int   w = n->p[0].width;
  int   h = n->p[0].height;
  int   x = n->x;
  int   neg;
  if(n->oldnum == num && !refresh)
    return;
  if ((neg = (n->oldnum = num) < 0))
  {
    if (numdigits == 2 && num < -9)
      num = -9;
    else if (numdigits == 3 && num < -99)
      num = -99;
    num = -num;
  }
  x = n->x - numdigits*w;
#ifdef RANGECHECK
  if (n->y - ST_Y < 0)
    I_Error("STlib_drawNum: n->y - ST_Y < 0");
#endif
  V_CopyRect(x, n->y - ST_Y, BG, w*numdigits, h, x, n->y, FG, VPT_STRETCH);
  if (num == 1994)
    return;
  x = n->x;
  if (!num)
    V_DrawNumPatch(x - w, n->y, FG, n->p[0].lumpnum, cm,
       (((cm!=CR_DEFAULT) && !sts_always_red) ? VPT_TRANS : VPT_NONE) | VPT_STRETCH);
  while (num && numdigits--) {
    x -= w;
    V_DrawNumPatch(x, n->y, FG, n->p[num % 10].lumpnum, cm,
       (((cm!=CR_DEFAULT) && !sts_always_red) ? VPT_TRANS : VPT_NONE) | VPT_STRETCH);
    num /= 10;
  }
  if (neg)
    V_DrawNamePatch(x - w, n->y, FG, "STTMINUS", cm,
       (((cm!=CR_DEFAULT) && !sts_always_red) ? VPT_TRANS : VPT_NONE) | VPT_STRETCH);
}
static void STlib_drawNum ( st_number_t * n , int cm , boolean refresh ) { int numdigits = n -> width ; int num = * n -> num ; int w = n -> p [ 0 ] . width ; int h = n -> p [ 0 ] . height ; int x = n -> x ; int neg ; if ( n -> oldnum == num && ! refresh ) return ; if ( ( neg = ( n -> oldnum = num ) < 0 ) ) { if ( numdigits == 2 && num < -9 ) num = -9 ; else if ( numdigits == 3 && num < -99 ) num = -99 ; num = - num ; } x = n -> x - numdigits * w ; #ifdef RANGECHECK if ( n -> y - ST_Y < 0 ) I_Error ( " " ) ; #endif V_CopyRect ( x , n -> y - ST_Y , BG , w * numdigits , h , x , n -> y , FG , VPT_STRETCH ) ; if ( num == 1994 ) return ; x = n -> x ; if ( ! num ) V_DrawNumPatch ( x - w , n -> y , FG , n -> p [ 0 ] . lumpnum , cm , ( ( ( cm != CR_DEFAULT ) && ! sts_always_red ) ? VPT_TRANS : VPT_NONE ) | VPT_STRETCH ) ; while ( num && numdigits -- ) { x -= w ; V_DrawNumPatch ( x , n -> y , FG , n -> p [ num % 10 ] . lumpnum , cm , ( ( ( cm != CR_DEFAULT ) && ! sts_always_red ) ? VPT_TRANS : VPT_NONE ) | VPT_STRETCH ) ; num /= 10 ; } if ( neg ) V_DrawNamePatch ( x - w , n -> y , FG , " " , cm , ( ( ( cm != CR_DEFAULT ) && ! sts_always_red ) ? VPT_TRANS : VPT_NONE ) | VPT_STRETCH ) ; }
STlib_drawNum()
 A fairly efficient way to draw a number based on differences from the
 old number.
STlib_drawNum () A fairly efficient way to draw a number based on differences from the old number .
// leban 1/20/99: // strange that somebody went through all the work to draw only the // differences, and then went and constantly redrew all the numbers. // return without drawing if the number didn't change and the bar // isn't refreshing. // CPhipps - compact some code, use num instead of *n->num // clear the area // if non-number, do not draw it //jff 2/16/98 add color translation to digit output // in the special case of 0, you draw 0 // CPhipps - patch drawing updated, reformatted // draw the new number //jff 2/16/98 add color translation to digit output // CPhipps - patch drawing updated, reformatted // draw a minus sign if necessary //jff 2/16/98 add color translation to digit output // cph - patch drawing updated, load by name instead of acquiring pointer earlier