summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorrubidium <rubidium@openttd.org>2007-09-07 21:15:32 +0000
committerrubidium <rubidium@openttd.org>2007-09-07 21:15:32 +0000
commita208f83e8bc2d10e98a3d76c0bfc99a45898b3e1 (patch)
treedf4dc95645ae5f279aebadb6782ae3cb5116930a
parent8daaea03981bf6b33bde84d805eac69c3cc8a324 (diff)
downloadopenttd-a208f83e8bc2d10e98a3d76c0bfc99a45898b3e1.tar.xz
(svn r11055) -Fix [FS#1214]: loading indicators would sometimes glitch due to a bounding box that was too small. Patch by frosch.
-rw-r--r--src/texteff.cpp10
1 files changed, 10 insertions, 0 deletions
diff --git a/src/texteff.cpp b/src/texteff.cpp
index 256d20455..e754a2f28 100644
--- a/src/texteff.cpp
+++ b/src/texteff.cpp
@@ -259,6 +259,7 @@ void DrawChatMessage()
/** Text Effects */
static void MarkTextEffectAreaDirty(TextEffect *te)
{
+ /* Width and height of the text effect are doubled, so they are correct in both zoom out levels 1x and 2x. */
MarkAllViewportsDirty(
te->x,
te->y - 1,
@@ -321,6 +322,15 @@ void UpdateTextEffect(TextEffectID te_id, StringID msg)
te->params_1 = GetDParam(0);
te->params_2 = GetDParam(4);
+ /* Update width of text effect */
+ char buffer[100];
+ GetString(buffer, msg, lastof(buffer));
+ int w = GetStringBoundingBox(buffer).width;
+
+ /* Only allow to make it broader, so it completely covers the old text. That avoids remnants of the old text. */
+ int right_new = te->x + w;
+ if (te->right < right_new) te->right = right_new;
+
MarkTextEffectAreaDirty(te);
}