From 5f5a4cb2641ad72d38bb21e55bc375f86af7b2fb Mon Sep 17 00:00:00 2001 From: divverent Date: Wed, 30 Dec 2009 09:14:48 +0000 Subject: [PATCH] remove redundant _Size suffix from textwidth functions, as now all of them would have it git-svn-id: svn://svn.icculus.org/twilight/trunk/darkplaces@9741 d7cf8633-e32d-0410-b094-e92efae38249 --- cl_screen.c | 14 +++++++------- console.c | 8 ++++---- draw.h | 12 ++++-------- gl_draw.c | 17 +---------------- sbar.c | 18 +++++++++--------- 5 files changed, 25 insertions(+), 44 deletions(-) diff --git a/cl_screen.c b/cl_screen.c index 52d395b9..8208ad0d 100644 --- a/cl_screen.c +++ b/cl_screen.c @@ -159,7 +159,7 @@ void SCR_DrawCenterString (void) // scan the number of characters on the line, not counting color codes char *newline = strchr(start, '\n'); int l = newline ? (newline - start) : (int)strlen(start); - float width = DrawQ_TextWidth_Font_Size(start, l, 8, 8, false, FONT_CENTERPRINT); + float width = DrawQ_TextWidth_Font(start, l, 8, 8, false, FONT_CENTERPRINT); x = (int) (vid_conwidth.integer - width)/2; if (l > 0) @@ -468,7 +468,7 @@ static int SCR_DrawQWDownload(int offset) else dpsnprintf(temp, sizeof(temp), "Downloading %s %3i%% (%i/%i) at %i bytes/s\n", cls.qw_downloadname, cls.qw_downloadpercent, cls.qw_downloadmemorycursize, cls.qw_downloadmemorymaxsize, cls.qw_downloadspeedrate); len = (int)strlen(temp); - x = (vid_conwidth.integer - DrawQ_TextWidth_Font_Size(temp, len, size, size, true, FONT_INFOBAR)) / 2; + x = (vid_conwidth.integer - DrawQ_TextWidth_Font(temp, len, size, size, true, FONT_INFOBAR)) / 2; y = vid_conheight.integer - size - offset; DrawQ_Fill(0, y, vid_conwidth.integer, size, 0, 0, 0, cls.signon == SIGNONS ? 0.5 : 1, 0); DrawQ_String_Font(x, y, temp, len, size, size, 1, 1, 1, 1, 0, NULL, true, FONT_INFOBAR); @@ -486,7 +486,7 @@ static int SCR_DrawInfobarString(int offset) float size = 8; len = (int)strlen(scr_infobarstring); - x = (vid_conwidth.integer - DrawQ_TextWidth_Font_Size(scr_infobarstring, len, size, size, false, FONT_INFOBAR)) / 2; + x = (vid_conwidth.integer - DrawQ_TextWidth_Font(scr_infobarstring, len, size, size, false, FONT_INFOBAR)) / 2; y = vid_conheight.integer - size - offset; DrawQ_Fill(0, y, vid_conwidth.integer, size, 0, 0, 0, cls.signon == SIGNONS ? 0.5 : 1, 0); DrawQ_String_Font(x, y, scr_infobarstring, len, size, size, 1, 1, 1, 1, 0, NULL, false, FONT_INFOBAR); @@ -519,7 +519,7 @@ static int SCR_DrawCurlDownload(int offset) if(addinfo) { len = (int)strlen(addinfo); - x = (vid_conwidth.integer - DrawQ_TextWidth_Font_Size(addinfo, len, size, size, true, FONT_INFOBAR)) / 2; + x = (vid_conwidth.integer - DrawQ_TextWidth_Font(addinfo, len, size, size, true, FONT_INFOBAR)) / 2; DrawQ_Fill(0, y - size, vid_conwidth.integer, size, 1, 1, 1, cls.signon == SIGNONS ? 0.8 : 1, 0); DrawQ_String_Font(x, y - size, addinfo, len, size, size, 0, 0, 0, 1, 0, NULL, true, FONT_INFOBAR); } @@ -533,7 +533,7 @@ static int SCR_DrawCurlDownload(int offset) else dpsnprintf(temp, sizeof(temp), "Downloading %s ... %5.1f%% @ %.1f KiB/s\n", downinfo[i].filename, 100.0 * downinfo[i].progress, downinfo[i].speed / 1024.0); len = (int)strlen(temp); - x = (vid_conwidth.integer - DrawQ_TextWidth_Font_Size(temp, len, size, size, true, FONT_INFOBAR)) / 2; + x = (vid_conwidth.integer - DrawQ_TextWidth_Font(temp, len, size, size, true, FONT_INFOBAR)) / 2; DrawQ_Fill(0, y + i * size, vid_conwidth.integer, size, 0, 0, 0, cls.signon == SIGNONS ? 0.5 : 1, 0); DrawQ_String_Font(x, y + i * size, temp, len, size, size, 1, 1, 1, 1, 0, NULL, true, FONT_INFOBAR); } @@ -1817,7 +1817,7 @@ static float SCR_DrawLoadingStack_r(loadingscreenstack_t *s, float y) if(!s->prev || strcmp(s->msg, s->prev->msg)) { len = strlen(s->msg); - x = (vid_conwidth.integer - DrawQ_TextWidth_Font_Size(s->msg, len, size, size, true, FONT_INFOBAR)) / 2; + x = (vid_conwidth.integer - DrawQ_TextWidth_Font(s->msg, len, size, size, true, FONT_INFOBAR)) / 2; y -= size; DrawQ_Fill(0, y, vid_conwidth.integer, size, 0, 0, 0, 1, 0); DrawQ_String_Font(x, y, s->msg, len, size, size, 1, 1, 1, 1, 0, NULL, true, FONT_INFOBAR); @@ -1828,7 +1828,7 @@ static float SCR_DrawLoadingStack_r(loadingscreenstack_t *s, float y) if(s) { len = strlen(s->msg); - x = (vid_conwidth.integer - DrawQ_TextWidth_Font_Size(s->msg, len, size, size, true, FONT_INFOBAR)) / 2; + x = (vid_conwidth.integer - DrawQ_TextWidth_Font(s->msg, len, size, size, true, FONT_INFOBAR)) / 2; y -= size; DrawQ_Fill(0, y, vid_conwidth.integer, size, 0, 0, 0, 1, 0); DrawQ_String_Font(x, y, s->msg, len, size, size, 1, 1, 1, 1, 0, NULL, true, FONT_INFOBAR); diff --git a/console.c b/console.c index 45ac0280..a20486c4 100644 --- a/console.c +++ b/console.c @@ -1410,7 +1410,7 @@ void Con_DrawInput (void) // text[key_linepos + 1] = 0; - x = vid_conwidth.value * 0.95 - DrawQ_TextWidth_Font_Size(text, key_linepos, con_textsize.value, con_textsize.value, false, FONT_CONSOLE); + x = vid_conwidth.value * 0.95 - DrawQ_TextWidth_Font(text, key_linepos, con_textsize.value, con_textsize.value, false, FONT_CONSOLE); if(x >= 0) x = 0; @@ -1448,7 +1448,7 @@ float Con_WordWidthFunc(void *passthrough, const char *w, size_t *length, float if(maxWidth >= 0) return DrawQ_TextWidth_Font_UntilWidth_Size(w, length, ti->fontsize, ti->fontsize, false, ti->font, -maxWidth); // -maxWidth: we want at least one char else if(maxWidth == -1) - return DrawQ_TextWidth_Font_Size(w, *length, ti->fontsize, ti->fontsize, false, ti->font); + return DrawQ_TextWidth_Font(w, *length, ti->fontsize, ti->fontsize, false, ti->font); else { printf("Con_WordWidthFunc: can't get here (maxWidth should never be %f)\n", maxWidth); @@ -1653,7 +1653,7 @@ void Con_DrawNotify (void) // FIXME word wrap inputsize = (numChatlines ? con_chatsize : con_notifysize).value; - x = vid_conwidth.value - DrawQ_TextWidth_Font_Size(temptext, 0, inputsize, inputsize, false, FONT_CHAT); + x = vid_conwidth.value - DrawQ_TextWidth_Font(temptext, 0, inputsize, inputsize, false, FONT_CHAT); if(x > 0) x = 0; DrawQ_String_Font(x, v, temptext, 0, inputsize, inputsize, 1.0, 1.0, 1.0, 1.0, 0, &colorindex, false, FONT_CHAT); @@ -1780,7 +1780,7 @@ void Con_DrawConsole (int lines) // draw the background DrawQ_Pic(0, lines - vid_conheight.integer, scr_conbrightness.value >= 0.01f ? Draw_CachePic ("gfx/conback") : NULL, vid_conwidth.integer, vid_conheight.integer, scr_conbrightness.value, scr_conbrightness.value, scr_conbrightness.value, cls.signon == SIGNONS ? scr_conalpha.value : 1.0, 0); // always full alpha when not in game - DrawQ_String_Font(vid_conwidth.integer - DrawQ_TextWidth_Font_Size(engineversion, con_textsize.value, con_textsize.value, 0, false, FONT_CONSOLE), lines - con_textsize.value, engineversion, 0, con_textsize.value, con_textsize.value, 1, 0, 0, 1, 0, NULL, true, FONT_CONSOLE); + DrawQ_String_Font(vid_conwidth.integer - DrawQ_TextWidth_Font(engineversion, con_textsize.value, con_textsize.value, 0, false, FONT_CONSOLE), lines - con_textsize.value, engineversion, 0, con_textsize.value, con_textsize.value, 1, 0, 0, 1, 0, NULL, true, FONT_CONSOLE); // draw the text #if 0 diff --git a/draw.h b/draw.h index bdb08f11..aeeb39ed 100644 --- a/draw.h +++ b/draw.h @@ -146,14 +146,10 @@ void DrawQ_Fill(float x, float y, float width, float height, float red, float gr float DrawQ_String(float x, float y, const char *text, size_t maxlen, float scalex, float scaley, float basered, float basegreen, float baseblue, float basealpha, int flags, int *outcolor, qboolean ignorecolorcodes); float DrawQ_String_Font(float x, float y, const char *text, size_t maxlen, float scalex, float scaley, float basered, float basegreen, float baseblue, float basealpha, int flags, int *outcolor, qboolean ignorecolorcodes, const dp_font_t *fnt); float DrawQ_String_Font_Scale(float x, float y, const char *text, size_t maxlen, float sizex, float sizey, float scalex, float scaley, float basered, float basegreen, float baseblue, float basealpha, int flags, int *outcolor, qboolean ignorecolorcodes, const dp_font_t *fnt); -// you are STRONGLY DISCOURAGED to use a version without the _Size suffix!!! -// /* don't use: */float DrawQ_TextWidth_Font(const char *text, size_t maxlen, qboolean ignorecolorcodes, const dp_font_t *fnt); -/* use this: */float DrawQ_TextWidth_Font_Size(const char *text, size_t maxlen, float w, float h, qboolean ignorecolorcodes, const dp_font_t *fnt); -// /* don't use: */float DrawQ_TextWidth_Font_UntilWidth(const char *text, size_t *maxlen, qboolean ignorecolorcodes, const dp_font_t *fnt, float maxWidth); -/* use this: */float DrawQ_TextWidth_Font_UntilWidth_Size(const char *text, size_t *maxlen, float w, float h, qboolean ignorecolorcodes, const dp_font_t *fnt, float maxWidth); -// /* don't use: */float DrawQ_TextWidth_Font_UntilWidth_TrackColors(const char *text, size_t *maxlen, int *outcolor, qboolean ignorecolorcodes, const dp_font_t *fnt, float maxwidth); -/* use this: */float DrawQ_TextWidth_Font_UntilWidth_TrackColors_Size(const char *text, size_t *maxlen, float w, float h, int *outcolor, qboolean ignorecolorcodes, const dp_font_t *fnt, float maxwidth); -/* use this: */float DrawQ_TextWidth_Font_UntilWidth_TrackColors_Size_Scale(const char *text, size_t *maxlen, float w, float h, float sw, float sh, int *outcolor, qboolean ignorecolorcodes, const dp_font_t *fnt, float maxwidth); +float DrawQ_TextWidth_Font(const char *text, size_t maxlen, float w, float h, qboolean ignorecolorcodes, const dp_font_t *fnt); +float DrawQ_TextWidth_Font_UntilWidth(const char *text, size_t *maxlen, float w, float h, qboolean ignorecolorcodes, const dp_font_t *fnt, float maxWidth); +float DrawQ_TextWidth_Font_UntilWidth_TrackColors(const char *text, size_t *maxlen, float w, float h, int *outcolor, qboolean ignorecolorcodes, const dp_font_t *fnt, float maxwidth); +float DrawQ_TextWidth_Font_UntilWidth_TrackColors_Scale(const char *text, size_t *maxlen, float w, float h, float sw, float sh, int *outcolor, qboolean ignorecolorcodes, const dp_font_t *fnt, float maxwidth); // draw a very fancy pic (per corner texcoord/color control), the order is tl, tr, bl, br void DrawQ_SuperPic(float x, float y, cachepic_t *pic, float width, float height, float s1, float t1, float r1, float g1, float b1, float a1, float s2, float t2, float r2, float g2, float b2, float a2, float s3, float t3, float r3, float g3, float b3, float a3, float s4, float t4, float r4, float g4, float b4, float a4, int flags); // draw a triangle mesh diff --git a/gl_draw.c b/gl_draw.c index ee605fcf..7a4cad35 100644 --- a/gl_draw.c +++ b/gl_draw.c @@ -1620,31 +1620,16 @@ float DrawQ_TextWidth_Font_UntilWidth_TrackColors_Size(const char *text, size_t return DrawQ_TextWidth_Font_UntilWidth_TrackColors_Size_Scale(text, maxlen, w, h, 1, 1, outcolor, ignorecolorcodes, fnt, maxwidth); } -//float DrawQ_TextWidth_Font(const char *text, size_t maxlen, qboolean ignorecolorcodes, const dp_font_t *fnt) -//{ -// return DrawQ_TextWidth_Font_UntilWidth(text, &maxlen, ignorecolorcodes, fnt, 1000000000); -//} - -float DrawQ_TextWidth_Font_Size(const char *text, size_t maxlen, float w, float h, qboolean ignorecolorcodes, const dp_font_t *fnt) +float DrawQ_TextWidth_Font(const char *text, size_t maxlen, float w, float h, qboolean ignorecolorcodes, const dp_font_t *fnt) { return DrawQ_TextWidth_Font_UntilWidth_Size(text, &maxlen, w, h, ignorecolorcodes, fnt, 1000000000); } -//float DrawQ_TextWidth_Font_UntilWidth(const char *text, size_t *maxlen, qboolean ignorecolorcodes, const dp_font_t *fnt, float maxWidth) -//{ -// return DrawQ_TextWidth_Font_UntilWidth_TrackColors(text, maxlen, NULL, ignorecolorcodes, fnt, maxWidth); -//} - float DrawQ_TextWidth_Font_UntilWidth_Size(const char *text, size_t *maxlen, float w, float h, qboolean ignorecolorcodes, const dp_font_t *fnt, float maxWidth) { return DrawQ_TextWidth_Font_UntilWidth_TrackColors_Size(text, maxlen, w, h, NULL, ignorecolorcodes, fnt, maxWidth); } -//float DrawQ_TextWidth_Font_UntilWidth_TrackColors(const char *text, size_t *maxlen, int *outcolor, qboolean ignorecolorcodes, const dp_font_t *fnt, float maxwidth) -//{ -// return DrawQ_TextWidth_Font_UntilWidth_TrackColors_Size(text, maxlen, 0, 0, outcolor, ignorecolorcodes, fnt, maxwidth); -//} - #if 0 // not used // no ^xrgb management diff --git a/sbar.c b/sbar.c index 1d766fd1..6672aa0f 100644 --- a/sbar.c +++ b/sbar.c @@ -1202,14 +1202,14 @@ void Sbar_ShowFPS(void) fps_y = vid_conheight.integer - sbar_info_pos.integer - fps_height; if (soundstring[0]) { - fps_x = vid_conwidth.integer - DrawQ_TextWidth_Font_Size(soundstring, 0, fps_scalex, fps_scaley, true, FONT_INFOBAR); + fps_x = vid_conwidth.integer - DrawQ_TextWidth_Font(soundstring, 0, fps_scalex, fps_scaley, true, FONT_INFOBAR); DrawQ_Fill(fps_x, fps_y, vid_conwidth.integer - fps_x, fps_scaley, 0, 0, 0, 0.5, 0); DrawQ_String_Font(fps_x, fps_y, soundstring, 0, fps_scalex, fps_scaley, 1, 1, 1, 1, 0, NULL, true, FONT_INFOBAR); fps_y += fps_scaley; } if (fpsstring[0]) { - fps_x = vid_conwidth.integer - DrawQ_TextWidth_Font_Size(fpsstring, 0, fps_scalex, fps_scaley, true, FONT_INFOBAR); + fps_x = vid_conwidth.integer - DrawQ_TextWidth_Font(fpsstring, 0, fps_scalex, fps_scaley, true, FONT_INFOBAR); DrawQ_Fill(fps_x, fps_y, vid_conwidth.integer - fps_x, fps_scaley, 0, 0, 0, 0.5, 0); if (red) DrawQ_String_Font(fps_x, fps_y, fpsstring, 0, fps_scalex, fps_scaley, 1, 0, 0, 1, 0, NULL, true, FONT_INFOBAR); @@ -1219,49 +1219,49 @@ void Sbar_ShowFPS(void) } if (timedemostring1[0]) { - fps_x = vid_conwidth.integer - DrawQ_TextWidth_Font_Size(timedemostring1, 0, fps_scalex, fps_scaley, true, FONT_INFOBAR); + fps_x = vid_conwidth.integer - DrawQ_TextWidth_Font(timedemostring1, 0, fps_scalex, fps_scaley, true, FONT_INFOBAR); DrawQ_Fill(fps_x, fps_y, vid_conwidth.integer - fps_x, fps_scaley, 0, 0, 0, 0.5, 0); DrawQ_String_Font(fps_x, fps_y, timedemostring1, 0, fps_scalex, fps_scaley, 1, 1, 1, 1, 0, NULL, true, FONT_INFOBAR); fps_y += fps_scaley; } if (timedemostring2[0]) { - fps_x = vid_conwidth.integer - DrawQ_TextWidth_Font_Size(timedemostring2, 0, fps_scalex, fps_scaley, true, FONT_INFOBAR); + fps_x = vid_conwidth.integer - DrawQ_TextWidth_Font(timedemostring2, 0, fps_scalex, fps_scaley, true, FONT_INFOBAR); DrawQ_Fill(fps_x, fps_y, vid_conwidth.integer - fps_x, fps_scaley, 0, 0, 0, 0.5, 0); DrawQ_String_Font(fps_x, fps_y, timedemostring2, 0, fps_scalex, fps_scaley, 1, 1, 1, 1, 0, NULL, true, FONT_INFOBAR); fps_y += fps_scaley; } if (timestring[0]) { - fps_x = vid_conwidth.integer - DrawQ_TextWidth_Font_Size(timestring, 0, fps_scalex, fps_scaley, true, FONT_INFOBAR); + fps_x = vid_conwidth.integer - DrawQ_TextWidth_Font(timestring, 0, fps_scalex, fps_scaley, true, FONT_INFOBAR); DrawQ_Fill(fps_x, fps_y, vid_conwidth.integer - fps_x, fps_scaley, 0, 0, 0, 0.5, 0); DrawQ_String_Font(fps_x, fps_y, timestring, 0, fps_scalex, fps_scaley, 1, 1, 1, 1, 0, NULL, true, FONT_INFOBAR); fps_y += fps_scaley; } if (datestring[0]) { - fps_x = vid_conwidth.integer - DrawQ_TextWidth_Font_Size(datestring, 0, fps_scalex, fps_scaley, true, FONT_INFOBAR); + fps_x = vid_conwidth.integer - DrawQ_TextWidth_Font(datestring, 0, fps_scalex, fps_scaley, true, FONT_INFOBAR); DrawQ_Fill(fps_x, fps_y, vid_conwidth.integer - fps_x, fps_scaley, 0, 0, 0, 0.5, 0); DrawQ_String_Font(fps_x, fps_y, datestring, 0, fps_scalex, fps_scaley, 1, 1, 1, 1, 0, NULL, true, FONT_INFOBAR); fps_y += fps_scaley; } if (speedstring[0]) { - fps_x = vid_conwidth.integer - DrawQ_TextWidth_Font_Size(speedstring, 0, fps_scalex, fps_scaley, true, FONT_INFOBAR); + fps_x = vid_conwidth.integer - DrawQ_TextWidth_Font(speedstring, 0, fps_scalex, fps_scaley, true, FONT_INFOBAR); DrawQ_Fill(fps_x, fps_y, vid_conwidth.integer - fps_x, fps_scaley, 0, 0, 0, 0.5, 0); DrawQ_String_Font(fps_x, fps_y, speedstring, 0, fps_scalex, fps_scaley, 1, 1, 1, 1, 0, NULL, true, FONT_INFOBAR); fps_y += fps_scaley; } if (topspeedstring[0]) { - fps_x = vid_conwidth.integer - DrawQ_TextWidth_Font_Size(topspeedstring, 0, fps_scalex, fps_scaley, false, FONT_INFOBAR); + fps_x = vid_conwidth.integer - DrawQ_TextWidth_Font(topspeedstring, 0, fps_scalex, fps_scaley, false, FONT_INFOBAR); DrawQ_Fill(fps_x, fps_y, vid_conwidth.integer - fps_x, fps_scaley, 0, 0, 0, 0.5, 0); DrawQ_String_Font(fps_x, fps_y, topspeedstring, 0, fps_scalex, fps_scaley, 1, 1, 1, 1, 0, NULL, false, FONT_INFOBAR); fps_y += fps_scaley; } if (blurstring[0]) { - fps_x = vid_conwidth.integer - DrawQ_TextWidth_Font_Size(blurstring, 0, fps_scalex, fps_scaley, true, FONT_INFOBAR); + fps_x = vid_conwidth.integer - DrawQ_TextWidth_Font(blurstring, 0, fps_scalex, fps_scaley, true, FONT_INFOBAR); DrawQ_Fill(fps_x, fps_y, vid_conwidth.integer - fps_x, fps_scaley, 0, 0, 0, 0.5, 0); DrawQ_String_Font(fps_x, fps_y, blurstring, 0, fps_scalex, fps_scaley, 1, 1, 1, 1, 0, NULL, true, FONT_INFOBAR); fps_y += fps_scaley; -- 2.39.2