]> de.git.xonotic.org Git - xonotic/darkplaces.git/commitdiff
patch from div0 to make DrawQ_ColoredString return the length of the printed text
authorhavoc <havoc@d7cf8633-e32d-0410-b094-e92efae38249>
Sun, 14 Jan 2007 09:53:31 +0000 (09:53 +0000)
committerhavoc <havoc@d7cf8633-e32d-0410-b094-e92efae38249>
Sun, 14 Jan 2007 09:53:31 +0000 (09:53 +0000)
git-svn-id: svn://svn.icculus.org/twilight/trunk/darkplaces@6688 d7cf8633-e32d-0410-b094-e92efae38249

draw.h
gl_draw.c

diff --git a/draw.h b/draw.h
index 62e9d585e2a19871e8b473fffb23349b7e584fd2..6d6f4e3f14cb73e80b188ab5fadd200deb4687ae 100644 (file)
--- a/draw.h
+++ b/draw.h
@@ -81,7 +81,7 @@ void DrawQ_Pic(float x, float y, cachepic_t *pic, float width, float height, flo
 // draw a text string
 void DrawQ_String(float x, float y, const char *string, int maxlen, float scalex, float scaley, float red, float green, float blue, float alpha, int flags);
 // draw a text string that supports color tags (colorindex can either be NULL, -1 to make it choose the default color or valid index to start with)
-void DrawQ_ColoredString( float x, float y, const char *text, int maxlen, float scalex, float scaley, float basered, float basegreen, float baseblue, float basealpha, int flags, int *outcolor );
+float DrawQ_ColoredString( float x, float y, const char *text, int maxlen, float scalex, float scaley, float basered, float basegreen, float baseblue, float basealpha, int flags, int *outcolor );
 // 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
index 9184ace7fdb464c086a1b210b381f5fc7e3a2c80..217bf22d37525f0fa3bfdd76285f4eecf8551c90 100644 (file)
--- a/gl_draw.c
+++ b/gl_draw.c
@@ -683,7 +683,7 @@ static vec4_t string_colors[] =
 #define STRING_COLORS_COUNT    (sizeof(string_colors) / sizeof(vec4_t))
 
 // color is read and changed in the end
-void DrawQ_ColoredString( float x, float y, const char *text, int maxlen, float scalex, float scaley, float basered, float basegreen, float baseblue, float basealpha, int flags, int *outcolor )
+float DrawQ_ColoredString( float x, float y, const char *text, int maxlen, float scalex, float scaley, float basered, float basegreen, float baseblue, float basealpha, int flags, int *outcolor )
 {
        vec_t *color;
        int len;
@@ -754,10 +754,22 @@ void DrawQ_ColoredString( float x, float y, const char *text, int maxlen, float
                }
        }
 
+       if( start != current ) {
+               // draw the string
+               DrawQ_String( x, y, start, current - start, scalex, scaley, basered * color[0], basegreen * color[1], baseblue * color[2], basealpha * color[3], flags );
+               // update x to be at the new start position
+               x += (current - start) * scalex;
+               // set start accordingly
+               start = current;
+       }
+
        // return the last colorindex
        if( outcolor ) {
                *outcolor = colorindex;
        }
+
+       // return the new x position
+       return x;
 }
 
 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)