summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorrubidium <rubidium@openttd.org>2009-03-22 23:54:36 +0000
committerrubidium <rubidium@openttd.org>2009-03-22 23:54:36 +0000
commit4012549c5ea5c9192189b6cc29000a9634c38798 (patch)
tree1aa0afeae92dd38c51abe028a32ca640a90596a2
parent3b231810ee7321390bf396e81b595ff110e95fb3 (diff)
downloadopenttd-4012549c5ea5c9192189b6cc29000a9634c38798.tar.xz
(svn r15824) -Fix: determine the actual length of the strings to draw in the viewport
-rw-r--r--src/viewport.cpp8
1 files changed, 6 insertions, 2 deletions
diff --git a/src/viewport.cpp b/src/viewport.cpp
index 666708b71..2ee1726e3 100644
--- a/src/viewport.cpp
+++ b/src/viewport.cpp
@@ -1460,11 +1460,15 @@ static void ViewportDrawStrings(DrawPixelInfo *dpi, const StringSpriteToDrawVect
/* The maximum width of the string */
int w = GB(ss->width, 0, 15);
- if (w == 0) w = UINT16_MAX;
+ if (w == 0) {
+ char buffer[DRAW_STRING_BUFFER];
+ GetString(buffer, ss->string, lastof(buffer));
+ w = GetStringBoundingBox(buffer).width;
+ }
DrawString(
UnScaleByZoom(ss->x, zoom), UnScaleByZoom(ss->x, zoom) + w, UnScaleByZoom(ss->y, zoom) - (ss->width & 0x8000 ? 2 : 0),
- ss->string, colour
+ ss->string, colour, SA_CENTER
);
}
}