summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorrubidium <rubidium@openttd.org>2009-08-28 15:23:51 +0000
committerrubidium <rubidium@openttd.org>2009-08-28 15:23:51 +0000
commit10b3bcb90c5130e661767443cb391bb9d8645f8f (patch)
treea2359d3edcb3c8c6a3979b66999d84132847f0c7
parentf548a1b3b3c054957b421e88e2122f6f455bf9fc (diff)
downloadopenttd-10b3bcb90c5130e661767443cb391bb9d8645f8f.tar.xz
(svn r17299) -Fix: the tooltip could get truncated under some circumstances due to its custom string height determination
-rw-r--r--src/misc_gui.cpp15
1 files changed, 7 insertions, 8 deletions
diff --git a/src/misc_gui.cpp b/src/misc_gui.cpp
index d6b5d7e83..bec5db162 100644
--- a/src/misc_gui.cpp
+++ b/src/misc_gui.cpp
@@ -768,7 +768,7 @@ struct TooltipsWindow : public Window
for (uint arg = 0; arg < this->paramcount; arg++) {
SetDParam(arg, this->params[arg]);
}
- DrawStringMultiLine(1, this->width - 1, 0, this->height, this->string_id, TC_FROMSTRING, SA_CENTER);
+ DrawStringMultiLine(3, this->width - 3, 0, this->height, this->string_id, TC_FROMSTRING, SA_CENTER);
}
virtual void OnMouseLoop()
@@ -797,14 +797,13 @@ void GuiShowTooltips(StringID str, uint paramcount, const uint64 params[], bool
char buffer[512];
GetString(buffer, str, lastof(buffer));
- Dimension br = GetStringBoundingBox(buffer);
- br.width += 6; br.height += 4; // increase slightly to have some space around the box
+ Dimension br;
+ br.width = min(GetStringBoundingBox(buffer).width, 194);
+ br.height = GetStringHeight(str, br.width);
- /* Cut tooltip length to 200 pixels max, wrap to new line if longer */
- if (br.width > 200) {
- br.height += ((br.width - 4) / 176) * 10;
- br.width = 200;
- }
+ /* increase slightly to have some space around the box */
+ br.width += 6;
+ br.height += 4;
/* Correctly position the tooltip position, watch out for window and cursor size
* Clamp value to below main toolbar and above statusbar. If tooltip would