summaryrefslogtreecommitdiff
path: root/src/company_gui.cpp
diff options
context:
space:
mode:
authorfrosch <frosch@openttd.org>2011-07-02 14:37:03 +0000
committerfrosch <frosch@openttd.org>2011-07-02 14:37:03 +0000
commit1bc1a42ea57c038df25f2e538bea77fa5451c30d (patch)
tree53a4c42bf75225b191967ca5a0c69f5300ed6ec2 /src/company_gui.cpp
parentc544dca5191112bf8a21acff36833c081d304291 (diff)
downloadopenttd-1bc1a42ea57c038df25f2e538bea77fa5451c30d.tar.xz
(svn r22619) -Fix [FS#4662]: Consider the size of the vehicle sprite for the lineheight in the company GUI. This also makes the widget containing the sprite not skip drawing it, if the bounds of the widget are outside of the drawing area though the sprite actually needs drawing.
Diffstat (limited to 'src/company_gui.cpp')
-rw-r--r--src/company_gui.cpp17
1 files changed, 15 insertions, 2 deletions
diff --git a/src/company_gui.cpp b/src/company_gui.cpp
index 92a9d722f..a79ef5eb1 100644
--- a/src/company_gui.cpp
+++ b/src/company_gui.cpp
@@ -1824,6 +1824,15 @@ struct CompanyWindow : Window
virtual void UpdateWidgetSize(int widget, Dimension *size, const Dimension &padding, Dimension *fill, Dimension *resize)
{
switch (widget) {
+ case CW_WIDGET_DESC_COLOUR_SCHEME_EXAMPLE: {
+ Point offset;
+ Dimension d = GetSpriteSize(SPR_VEH_BUS_SW_VIEW, &offset);
+ d.width -= offset.x;
+ d.height -= offset.y;
+ *size = maxdim(*size, d);
+ break;
+ }
+
case CW_WIDGET_DESC_COMPANY_VALUE:
SetDParam(0, INT64_MAX); // Arguably the maximum company value
size->width = GetStringBoundingBox(STR_COMPANY_VIEW_COMPANY_VALUE).width;
@@ -1869,9 +1878,13 @@ struct CompanyWindow : Window
DrawStringMultiLine(r.left, r.right, r.top, r.bottom, STR_COMPANY_VIEW_PRESIDENT_MANAGER_TITLE, TC_FROMSTRING, SA_CENTER);
break;
- case CW_WIDGET_DESC_COLOUR_SCHEME_EXAMPLE:
- DrawSprite(SPR_VEH_BUS_SW_VIEW, COMPANY_SPRITE_COLOUR(c->index), (r.left + r.right) / 2, r.top + FONT_HEIGHT_NORMAL / 10);
+ case CW_WIDGET_DESC_COLOUR_SCHEME_EXAMPLE: {
+ Point offset;
+ Dimension d = GetSpriteSize(SPR_VEH_BUS_SW_VIEW, &offset);
+ d.height -= offset.y;
+ DrawSprite(SPR_VEH_BUS_SW_VIEW, COMPANY_SPRITE_COLOUR(c->index), r.left - offset.x, (r.top + r.bottom - d.height) / 2 - offset.y);
break;
+ }
case CW_WIDGET_DESC_VEHICLE_COUNTS: {
uint amounts[4];