about summary refs log tree commit diff
diff options
context:
space:
mode:
-rw-r--r--src/engine/client/ec_gfx.c5
-rw-r--r--src/engine/e_if_gfx.h4
-rw-r--r--src/game/client/gc_client.cpp24
3 files changed, 24 insertions, 9 deletions
diff --git a/src/engine/client/ec_gfx.c b/src/engine/client/ec_gfx.c
index d7a0733a..c1bf4112 100644
--- a/src/engine/client/ec_gfx.c
+++ b/src/engine/client/ec_gfx.c
@@ -1017,8 +1017,9 @@ float gfx_text_raw(void *font_set_v, float x, float y, float size, const char *t
     return draw_x;
 }
 
-void gfx_text(void *font_set_v, float x, float y, float size, const char *text, int max_width)
+int gfx_text(void *font_set_v, float x, float y, float size, const char *text, int max_width)
 {
+	int lines = 1;
 	if(max_width == -1)
 		gfx_text_raw(font_set_v, x, y, size, text, -1);
 	else
@@ -1030,6 +1031,7 @@ void gfx_text(void *font_set_v, float x, float y, float size, const char *text,
 			float w = gfx_text_width(font_set_v, size, text, wlen);
 			if(x+w-startx > max_width)
 			{
+				lines++;
 				y += size;
 				x = startx;
 			}
@@ -1040,6 +1042,7 @@ void gfx_text(void *font_set_v, float x, float y, float size, const char *text,
 		}
 	}
     gfx_text_raw(font_set_v, x, y, size, text, -1);
+    return lines;
 }
 
 float gfx_text_width(void *font_set_v, float size, const char *text, int length)
diff --git a/src/engine/e_if_gfx.h b/src/engine/e_if_gfx.h
index d49a3cda..71a9628e 100644
--- a/src/engine/e_if_gfx.h
+++ b/src/engine/e_if_gfx.h
@@ -243,11 +243,11 @@ void gfx_lines_end();
 		arg1 - desc
 	
 	Returns:
-
+		returns the number of lines written
 	See Also:
 		<other_func>
 */
-void gfx_text(void *font, float x, float y, float size, const char *text, int max_width);
+int gfx_text(void *font, float x, float y, float size, const char *text, int max_width);
 
 /*
 	Function: gfx_text_width
diff --git a/src/game/client/gc_client.cpp b/src/game/client/gc_client.cpp
index 48712e5d..ed26427d 100644
--- a/src/game/client/gc_client.cpp
+++ b/src/game/client/gc_client.cpp
@@ -1182,7 +1182,7 @@ void render_game()
 	{
 		gfx_mapscreen(0,0,300*gfx_screenaspect(),300);
 		float x = 10.0f;
-		float y = 300.0f-50.0f;
+		float y = 300.0f-30.0f;
 		float starty = -1;
 		if(chat_mode != CHATMODE_NONE)
 		{
@@ -1209,6 +1209,16 @@ void render_game()
 
 			float begin = x;
 
+
+			float fontsize = 8.0f;
+			
+			// turn of alpha so we can render once and just get the number of lines
+			// TODO: this is ugly, but have to do for now
+			gfx_text_color(1,1,1,0);
+			int lines = gfx_text(0, begin, y, fontsize, chat_lines[r].text, 300);
+
+			y -= fontsize * (lines);
+
 			// render name
 			gfx_text_color(0.8f,0.8f,0.8f,1);
 			if(chat_lines[r].client_id == -1)
@@ -1223,10 +1233,13 @@ void render_game()
 				gfx_text_color(0.75f,0.5f,0.75f, 1); // spectator
 				
 			// render line
-			int lines = int(gfx_text_width(0, 10, chat_lines[r].text, -1)) / 300 + 1;
 			
-			gfx_text(0, begin, y - 8 * (lines - 1), 8, chat_lines[r].name, -1);
-			begin += gfx_text_width(0, 10, chat_lines[r].name, -1);
+			//int lines = int(gfx_text_width(0, fontsize, chat_lines[r].text, -1)) / 300 + 1;
+
+			
+			gfx_text(0, begin, y, fontsize, chat_lines[r].name, -1);
+			begin += gfx_text_width(0, fontsize, chat_lines[r].name, -1);
+
 
 			gfx_text_color(1,1,1,1);
 			if(chat_lines[r].client_id == -1)
@@ -1234,8 +1247,7 @@ void render_game()
 			else if(chat_lines[r].team)
 				gfx_text_color(0.65f,1,0.65f,1); // team message
 
-			gfx_text(0, begin, y - 8 * (lines - 1), 8, chat_lines[r].text, 300);
-			y -= 6 * lines;
+			gfx_text(0, begin, y, fontsize, chat_lines[r].text, 300);
 		}
 
 		gfx_text_color(1,1,1,1);