about summary refs log tree commit diff
path: root/src/engine
diff options
context:
space:
mode:
authorJakob Fries <jakob.fries@gmail.com>2007-07-28 17:44:12 +0000
committerJakob Fries <jakob.fries@gmail.com>2007-07-28 17:44:12 +0000
commite6d5379a7240909dda863260bfef59503c9835a8 (patch)
tree11ec17981962d6b568e3df3a4ac41a89c88be7c9 /src/engine
parentc24b86c1f4e54afc171d71ffd9beb5157971da11 (diff)
downloadzcatch-e6d5379a7240909dda863260bfef59503c9835a8.tar.gz
zcatch-e6d5379a7240909dda863260bfef59503c9835a8.zip
editbox is now easier to edit
Diffstat (limited to 'src/engine')
-rw-r--r--src/engine/client/gfx.cpp10
-rw-r--r--src/engine/interface.h2
2 files changed, 9 insertions, 3 deletions
diff --git a/src/engine/client/gfx.cpp b/src/engine/client/gfx.cpp
index f6295620..7b0b421e 100644
--- a/src/engine/client/gfx.cpp
+++ b/src/engine/client/gfx.cpp
@@ -731,12 +731,18 @@ void gfx_pretty_text(float x, float y, float size, const char *text)
 	gfx_quads_end();
 }
 
-float gfx_pretty_text_width(float size, const char *text)
+float gfx_pretty_text_width(float size, const char *text, int length)
 {
 	const float spacing = 0.05f;
 	float w = 0.0f;
 
-	while (*text)
+	const char *stop;
+	if (length == -1)
+		stop = text + strlen(text);
+	else
+		stop = text + length;
+
+	while (text < stop)
 	{
 		const int c = *text;
 		const float width = current_font->m_CharEndTable[c] - current_font->m_CharStartTable[c];
diff --git a/src/engine/interface.h b/src/engine/interface.h
index 10a8794b..ba8dacce 100644
--- a/src/engine/interface.h
+++ b/src/engine/interface.h
@@ -750,7 +750,7 @@ float client_intratick();
 int client_tickspeed();
 
 void gfx_pretty_text(float x, float y, float size, const char *text);
-float gfx_pretty_text_width(float size, const char *text);
+float gfx_pretty_text_width(float size, const char *text, int length = -1);
 
 void gfx_getscreen(float *tl_x, float *tl_y, float *br_x, float *br_y);