summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorplanetmaker <planetmaker@openttd.org>2011-09-02 15:55:52 +0000
committerplanetmaker <planetmaker@openttd.org>2011-09-02 15:55:52 +0000
commita2ebe437e6c11fede99ec3e2e39d5b80b1587a62 (patch)
tree7479985839b7ef1ccae8a9f1a80cd953bbe92d1c
parentc9765caf6ae71a6ead2695258842d13ea8d205b8 (diff)
downloadopenttd-a2ebe437e6c11fede99ec3e2e39d5b80b1587a62.tar.xz
(svn r22868) -Change: Resize the company league window according to the company icon's size
-rw-r--r--src/graph_gui.cpp15
1 files changed, 11 insertions, 4 deletions
diff --git a/src/graph_gui.cpp b/src/graph_gui.cpp
index e852e2f88..e87560dfa 100644
--- a/src/graph_gui.cpp
+++ b/src/graph_gui.cpp
@@ -1155,6 +1155,8 @@ private:
GUIList<const Company*> companies;
uint ordinal_width; ///< The width of the ordinal number
uint text_width; ///< The width of the actual text
+ uint icon_width; ///< The width of the company icon
+ int line_height; ///< Height of the text lines
/**
* (Re)Build the company league list
@@ -1200,8 +1202,8 @@ public:
{
if (widget != CLW_BACKGROUND) return;
- uint y = r.top + WD_FRAMERECT_TOP;
- int icon_y_offset = 1 + (FONT_HEIGHT_NORMAL - 10) / 2;
+ int icon_y_offset = 1 + (FONT_HEIGHT_NORMAL - this->line_height) / 2;
+ uint y = r.top + WD_FRAMERECT_TOP - icon_y_offset;
bool rtl = _current_text_dir == TD_RTL;
uint ordinal_left = rtl ? r.right - WD_FRAMERECT_LEFT - this->ordinal_width : r.left + WD_FRAMERECT_LEFT;
@@ -1220,7 +1222,7 @@ public:
SetDParam(1, c->index);
SetDParam(2, GetPerformanceTitleFromValue(c->old_economy[0].performance_history));
DrawString(text_left, text_right, y, STR_COMPANY_LEAGUE_COMPANY_NAME);
- y += FONT_HEIGHT_NORMAL;
+ y += this->line_height;
}
}
@@ -1244,6 +1246,10 @@ public:
}
}
+ Dimension d = GetSpriteSize(SPR_COMPANY_ICON);
+ this->icon_width = d.width + 2;
+ this->line_height = max<int>(d.height + 2, FONT_HEIGHT_NORMAL);
+
const Company *c;
FOR_ALL_COMPANIES(c) {
SetDParam(0, c->index);
@@ -1254,7 +1260,8 @@ public:
this->text_width = widest_width + 30; // Keep some extra spacing
- size->width = WD_FRAMERECT_LEFT + this->ordinal_width + WD_FRAMERECT_RIGHT + 16 + WD_FRAMERECT_LEFT + this->text_width + WD_FRAMERECT_RIGHT;
+ size->width = WD_FRAMERECT_LEFT + this->ordinal_width + WD_FRAMERECT_RIGHT + this->icon_width + WD_FRAMERECT_LEFT + this->text_width + WD_FRAMERECT_RIGHT;
+ size->height = WD_FRAMERECT_TOP + this->line_height * MAX_COMPANIES + WD_FRAMERECT_BOTTOM;
}