about summary refs log tree commit diff
path: root/src/engine/client/gfx.cpp
diff options
context:
space:
mode:
authorMagnus Auvinen <magnus.auvinen@gmail.com>2007-07-15 13:25:10 +0000
committerMagnus Auvinen <magnus.auvinen@gmail.com>2007-07-15 13:25:10 +0000
commitf2611cad8bf1c1f4664ae5f328ffa6934a4d1d16 (patch)
tree89d1dd650f4f57428ff87c8771d5b6c3c6c94e19 /src/engine/client/gfx.cpp
parent07c8ff2e537958c6f6217b4fd48ddaa85882e068 (diff)
downloadzcatch-f2611cad8bf1c1f4664ae5f328ffa6934a4d1d16.tar.gz
zcatch-f2611cad8bf1c1f4664ae5f328ffa6934a4d1d16.zip
fixed so that the editor works again
Diffstat (limited to 'src/engine/client/gfx.cpp')
-rw-r--r--src/engine/client/gfx.cpp62
1 files changed, 41 insertions, 21 deletions
diff --git a/src/engine/client/gfx.cpp b/src/engine/client/gfx.cpp
index c30ad0f1..5280ef5d 100644
--- a/src/engine/client/gfx.cpp
+++ b/src/engine/client/gfx.cpp
@@ -544,19 +544,28 @@ void gfx_quads_draw_freeform(
 void gfx_quads_text(float x, float y, float size, const char *text)
 {
 	gfx_quads_begin();
+	float startx = x;
 	while(*text)
 	{
 		char c = *text;
 		text++;
 		
-		gfx_quads_setsubset(
-			(c%16)/16.0f,
-			(c/16)/16.0f,
-			(c%16)/16.0f+1.0f/16.0f,
-			(c/16)/16.0f+1.0f/16.0f);
-		
-		gfx_quads_drawTL(x,y,size,size);
-		x += size/2;
+		if(c == '\n')
+		{
+			x = startx;
+			y += size;
+		}
+		else
+		{
+			gfx_quads_setsubset(
+				(c%16)/16.0f,
+				(c/16)/16.0f,
+				(c%16)/16.0f+1.0f/16.0f,
+				(c/16)/16.0f+1.0f/16.0f);
+			
+			gfx_quads_drawTL(x,y,size,size);
+			x += size/2;
+		}
 	}
 	
 	gfx_quads_end();
@@ -620,26 +629,37 @@ void gfx_pretty_text(float x, float y, float size, const char *text)
 	gfx_texture_set(current_font->font_texture);
 	gfx_quads_begin();
 	
+	float startx = x;
+	
 	while (*text)
 	{
 		const int c = *text;
-		const float width = current_font->m_CharEndTable[c] - current_font->m_CharStartTable[c];
-
-		x -= size * current_font->m_CharStartTable[c];
 		
-		gfx_quads_setsubset(
-			(c%16)/16.0f, // startx
-			(c/16)/16.0f, // starty
-			(c%16)/16.0f+1.0f/16.0f, // endx
-			(c/16)/16.0f+1.0f/16.0f); // endy
+		if(c == '\n')
+		{
+			x = startx;
+			y += size;
+		}
+		else
+		{
+			const float width = current_font->m_CharEndTable[c] - current_font->m_CharStartTable[c];
 
-		gfx_quads_drawTL(x, y, size, size);
+			x -= size * current_font->m_CharStartTable[c];
+			
+			gfx_quads_setsubset(
+				(c%16)/16.0f, // startx
+				(c/16)/16.0f, // starty
+				(c%16)/16.0f+1.0f/16.0f, // endx
+				(c/16)/16.0f+1.0f/16.0f); // endy
 
-		double x_nudge = 0;
-		if (text[1])
-			x_nudge = extra_kerning[text[0] + text[1] * 256];
+			gfx_quads_drawTL(x, y, size, size);
 
-		x += (width + current_font->m_CharStartTable[c] + spacing + x_nudge) * size;
+			double x_nudge = 0;
+			if (text[1])
+				x_nudge = extra_kerning[text[0] + text[1] * 256];
+
+			x += (width + current_font->m_CharStartTable[c] + spacing + x_nudge) * size;
+		}
 
 		text++;
 	}