diff --git a/include/QF/draw.h b/include/QF/draw.h index b91f2eec2..489adee7b 100644 --- a/include/QF/draw.h +++ b/include/QF/draw.h @@ -48,6 +48,7 @@ void Draw_TileClear (int x, int y, int w, int h); void Draw_Fill (int x, int y, int w, int h, int c); void Draw_FadeScreen (void); void Draw_String (int x, int y, const char *str); +void Draw_nString (int x, int y, const char *str, int count); void Draw_AltString (int x, int y, const char *str); qpic_t *Draw_PicFromWad (const char *name); qpic_t *Draw_CachePic (const char *path, qboolean alpha); diff --git a/libs/video/renderer/gl/gl_draw.c b/libs/video/renderer/gl/gl_draw.c index 86de431bd..cac4a805c 100644 --- a/libs/video/renderer/gl/gl_draw.c +++ b/libs/video/renderer/gl/gl_draw.c @@ -346,6 +346,40 @@ Draw_String (int x, int y, const char *str) qfglEnd (); } +void +Draw_nString (int x, int y, const char *str, int count) +{ + unsigned char num; + float frow, fcol; + int size; + + if (!str || !str[0]) + return; + if (y <= -8) + return; // totally off screen + + qfglBindTexture (GL_TEXTURE_2D, char_texture); + qfglBegin (GL_QUADS); + + for (size = 0; size < count; size++, x+=8) { + if ((num = *str++) != 32) // Don't render spaces + { + frow = (num >> 4) * CELL_SIZE; + fcol = (num & 15) * CELL_SIZE; + + qfglTexCoord2f (fcol, frow); + qfglVertex2f (x, y); + qfglTexCoord2f (fcol + CELL_SIZE, frow); + qfglVertex2f (x + 8, y); + qfglTexCoord2f (fcol + CELL_SIZE, frow + CELL_SIZE); + qfglVertex2f (x + 8, y + 8); + qfglTexCoord2f (fcol, frow + CELL_SIZE); + qfglVertex2f (x, y + 8); + } + } + qfglEnd (); +} + void Draw_AltString (int x, int y, const char *str) { diff --git a/libs/video/renderer/gl/gl_screen.c b/libs/video/renderer/gl/gl_screen.c index d325aa138..7e5370343 100644 --- a/libs/video/renderer/gl/gl_screen.c +++ b/libs/video/renderer/gl/gl_screen.c @@ -708,7 +708,7 @@ void SCR_DrawNotifyString (void) { char *start; - int j, l, x, y; + int l, x, y; start = scr_notifystring; @@ -720,8 +720,7 @@ SCR_DrawNotifyString (void) if (start[l] == '\n' || !start[l]) break; x = (vid.width - l * 8) / 2; - for (j = 0; j < l; j++, x += 8) - Draw_Character (x, y, start[j]); + Draw_nString (x, y, start, l); y += 8; diff --git a/libs/video/renderer/sw/draw.c b/libs/video/renderer/sw/draw.c index caf2e53f2..9bfdda3fa 100644 --- a/libs/video/renderer/sw/draw.c +++ b/libs/video/renderer/sw/draw.c @@ -262,6 +262,16 @@ Draw_String (int x, int y, const char *str) } +void +Draw_nString (int x, int y, const char *str, int count) +{ + int size; + for (size = 0; size < count; size++, x +=8) { + Draw_Character (x, y, *str++); + } +} + + void Draw_AltString (int x, int y, const char *str) { diff --git a/libs/video/renderer/sw/screen.c b/libs/video/renderer/sw/screen.c index 08ec97b33..16d435266 100644 --- a/libs/video/renderer/sw/screen.c +++ b/libs/video/renderer/sw/screen.c @@ -767,7 +767,6 @@ SCR_DrawNotifyString (void) { char *start; int l; - int j; int x, y; start = scr_notifystring; @@ -780,8 +779,7 @@ SCR_DrawNotifyString (void) if (start[l] == '\n' || !start[l]) break; x = (vid.width - l * 8) / 2; - for (j = 0; j < l; j++, x += 8) - Draw_Character (x, y, start[j]); + Draw_nString (x, y, start, l); y += 8; diff --git a/libs/video/renderer/sw32/draw.c b/libs/video/renderer/sw32/draw.c index 90b11d179..951f9ad8f 100644 --- a/libs/video/renderer/sw32/draw.c +++ b/libs/video/renderer/sw32/draw.c @@ -324,6 +324,15 @@ Draw_String (int x, int y, const char *str) } } +void +Draw_nString (int x, int y, const char *str, int count) +{ + int size; + for (size = 0; size < count; size++, x += 8) { + Draw_Character (x, y, *str++); + } +} + void Draw_AltString (int x, int y, const char *str) diff --git a/libs/video/renderer/sw32/screen.c b/libs/video/renderer/sw32/screen.c index 9db48070b..2e8bcd2cd 100644 --- a/libs/video/renderer/sw32/screen.c +++ b/libs/video/renderer/sw32/screen.c @@ -787,7 +787,6 @@ SCR_DrawNotifyString (void) { char *start; int l; - int j; int x, y; start = scr_notifystring; @@ -800,10 +799,7 @@ SCR_DrawNotifyString (void) if (start[l] == '\n' || !start[l]) break; x = (vid.width - l * 8) / 2; - for (j = 0; j < l; j++, x += 8) - Draw_Character (x, y, start[j]); - - y += 8; + Draw_nString (x, y, start, l); while (*start && *start != '\n') start++; diff --git a/nq/source/console.c b/nq/source/console.c index fb23b2dfb..db1dd9d3c 100644 --- a/nq/source/console.c +++ b/nq/source/console.c @@ -373,8 +373,7 @@ Con_DrawInput (void) // draw it y = con_vislines - 22; - for (i = 0; i < con_linewidth; i++) - Draw_Character ((i + 1) << 3, con_vislines - 22, text[i]); + Draw_nString (3, y, text, con_linewidth); } /* @@ -404,8 +403,7 @@ Con_DrawNotify (void) clearnotify = 0; scr_copytop = 1; - for (x = 0; x < con_linewidth; x++) - Draw_Character ((x + 1) << 3, v, text[x]); + Draw_nString (3, v, text, con_linewidth); v += 8; } @@ -426,11 +424,8 @@ Con_DrawNotify (void) if (chat_bufferlen > (vid.width >> 3) - (skip + 1)) s += chat_bufferlen - ((vid.width >> 3) - (skip + 1)); x = 0; - while (s[x]) { - Draw_Character ((x + skip) << 3, v, s[x]); - x++; - } - Draw_Character ((x + skip) << 3, v, + Draw_String (skip >> 3, v, s); + Draw_Character ((strlen(s) + skip) << 3, v, 10 + ((int) (realtime * con_cursorspeed) & 1)); v += 8; } @@ -483,8 +478,7 @@ Con_DrawConsole (int lines) text = con->text + (row % con_totallines) * con_linewidth; - for (x = 0; x < con_linewidth; x++) - Draw_Character ((x + 1) << 3, y, text[x]); + Draw_nString (3, y, text, con_linewidth); } // draw the input prompt, user text, and cursor if desired @@ -533,8 +527,7 @@ Con_DrawDownload (int lines) " %02d%%", cls.downloadpercent); // draw it y = lines - 22 + 8; - for (i = 0; i < strlen (dlbar); i++) - Draw_Character ((i + 1) << 3, y, dlbar[i]); + Draw_nString (3, y, dlbar, strlen (dlbar)); } /* diff --git a/nq/source/sbar.c b/nq/source/sbar.c index 0d68013c8..e0e87cc29 100644 --- a/nq/source/sbar.c +++ b/nq/source/sbar.c @@ -953,9 +953,7 @@ Sbar_DeathmatchOverlay (void) f = s->frags; snprintf (num, sizeof (num), "%3i", f); - Draw_Character (x + 8, y, num[0]); - Draw_Character (x + 16, y, num[1]); - Draw_Character (x + 24, y, num[2]); + Draw_nString (x + 8, y, num, 3); if (k == cl.viewentity - 1) Draw_Character (x - 8, y, 12); @@ -1028,10 +1026,8 @@ Sbar_MiniDeathmatchOverlay (void) f = s->frags; snprintf (num, sizeof (num), "%3i", f); - Draw_Character (x + 8, y, num[0]); - Draw_Character (x + 16, y, num[1]); - Draw_Character (x + 24, y, num[2]); - + Draw_nString (x + 8, y, num, 3); + if (k == cl.viewentity - 1) { Draw_Character (x, y, 16); Draw_Character (x + 32, y, 17); diff --git a/qw/source/console.c b/qw/source/console.c index 4bc83e2b9..daf11caf4 100644 --- a/qw/source/console.c +++ b/qw/source/console.c @@ -419,8 +419,7 @@ Con_DrawInput (void) // draw it y = con_vislines - 22; - for (i = 0; i < con_linewidth; i++) - Draw_Character ((i + 1) << 3, con_vislines - 22, text[i]); + Draw_nString (3, y, text, con_linewidth); } /* @@ -450,9 +449,7 @@ Con_DrawNotify (void) clearnotify = 0; scr_copytop = 1; - for (x = 0; x < con_linewidth; x++) - Draw_Character ((x + 1) << 3, v, text[x]); - + Draw_nString (3, v, text, con_linewidth); v += 8; } @@ -472,11 +469,8 @@ Con_DrawNotify (void) if (chat_bufferlen > (vid.width >> 3) - (skip + 1)) s += chat_bufferlen - ((vid.width >> 3) - (skip + 1)); x = 0; - while (s[x]) { - Draw_Character ((x + skip) << 3, v, s[x]); - x++; - } - Draw_Character ((x + skip) << 3, v, + Draw_String (skip >> 3, v, s); + Draw_Character ((strlen(s) + skip) << 3, v, 10 + ((int) (realtime * con_cursorspeed) & 1)); v += 8; } @@ -529,8 +523,7 @@ Con_DrawConsole (int lines) text = con->text + (row % con_totallines) * con_linewidth; - for (x = 0; x < con_linewidth; x++) - Draw_Character ((x + 1) << 3, y, text[x]); + Draw_nString(3, y, text, con_linewidth); } // draw the input prompt, user text, and cursor if desired @@ -579,8 +572,7 @@ Con_DrawDownload (int lines) " %02d%%", cls.downloadpercent); // draw it y = lines - 22 + 8; - for (i = 0; i < strlen (dlbar); i++) - Draw_Character ((i + 1) << 3, y, dlbar[i]); + Draw_nString (3, y, dlbar, strlen (dlbar)); } /* diff --git a/qw/source/sbar.c b/qw/source/sbar.c index 7bb1871a6..ecc2c44c5 100644 --- a/qw/source/sbar.c +++ b/qw/source/sbar.c @@ -1015,9 +1015,7 @@ Sbar_DeathmatchOverlay (int start) f = s->frags; snprintf (num, sizeof (num), "%3i", f); - Draw_Character (x + 112, y, num[0]); - Draw_Character (x + 120, y, num[1]); - Draw_Character (x + 128, y, num[2]); + Draw_nString (x + 112, y, num, 3); if (k == cl.playernum) { Draw_Character (x + 104, y, 16); @@ -1114,9 +1112,7 @@ Sbar_MiniDeathmatchOverlay (void) f = s->frags; snprintf (num, sizeof (num), "%3i", f); - Draw_Character (x + 8, y, num[0]); - Draw_Character (x + 16, y, num[1]); - Draw_Character (x + 24, y, num[2]); + Draw_nString (x + 8, y, num, 3); if (k == cl.playernum) { Draw_Character (x, y, 16);