summaryrefslogtreecommitdiff
path: root/src/newgrf_gui.cpp
diff options
context:
space:
mode:
authoryexo <yexo@openttd.org>2012-01-12 19:11:51 +0000
committeryexo <yexo@openttd.org>2012-01-12 19:11:51 +0000
commitb1a830491aa01218cf0ec699269bd5d6a107f6f8 (patch)
tree8d7a388597837627e9bba12460d25777fac50885 /src/newgrf_gui.cpp
parent1ea634fcba9a2a03b0cfe07c05d307ee0e0152c6 (diff)
downloadopenttd-b1a830491aa01218cf0ec699269bd5d6a107f6f8.tar.xz
(svn r23791) -Fix [FS#4960]: resize text panel for parameter description if it doesn't fit in 4 lines.
If you resize the window so it's smaller than default the text might still not fit
Diffstat (limited to 'src/newgrf_gui.cpp')
-rw-r--r--src/newgrf_gui.cpp12
1 files changed, 11 insertions, 1 deletions
diff --git a/src/newgrf_gui.cpp b/src/newgrf_gui.cpp
index 95d88abd1..79a845ad0 100644
--- a/src/newgrf_gui.cpp
+++ b/src/newgrf_gui.cpp
@@ -211,7 +211,17 @@ struct NewGRFParametersWindow : public Window {
break;
case WID_NP_DESCRIPTION:
- size->height = max<uint>(size->height, FONT_HEIGHT_NORMAL * 4 + WD_TEXTPANEL_TOP + WD_TEXTPANEL_BOTTOM);
+ /* Minimum size of 4 lines. The 500 is the default size of the window. */
+ Dimension suggestion = {500 - WD_FRAMERECT_LEFT - WD_FRAMERECT_RIGHT, FONT_HEIGHT_NORMAL * 4 + WD_TEXTPANEL_TOP + WD_TEXTPANEL_BOTTOM};
+ for (uint i = 0; i < this->grf_config->param_info.Length(); i++) {
+ const GRFParameterInfo *par_info = this->grf_config->param_info[i];
+ if (par_info == NULL) continue;
+ const char *desc = GetGRFStringFromGRFText(par_info->desc);
+ if (desc == NULL) continue;
+ const Dimension d = GetStringMultiLineBoundingBox(desc, suggestion);
+ suggestion = maxdim(d, suggestion);
+ }
+ size->height = suggestion.height;
break;
}
}