From 034e8677adb327a8f98d6ae0a3214a65a5c1dc24 Mon Sep 17 00:00:00 2001 From: Juanjo Date: Fri, 2 Aug 2013 19:22:04 +0000 Subject: [PATCH] Center company icon on league table. --- src/graph_gui.cpp | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/graph_gui.cpp b/src/graph_gui.cpp index 10779502da..99cff0eaaf 100644 --- a/src/graph_gui.cpp +++ b/src/graph_gui.cpp @@ -1128,6 +1128,7 @@ private: 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 + uint icon_y_offset; ///< The vertical offset for drawing the company icon. int line_height; ///< Height of the text lines /** @@ -1174,8 +1175,7 @@ public: { if (widget != WID_CL_BACKGROUND) return; - int icon_y_offset = 1 + (FONT_HEIGHT_NORMAL - this->line_height) / 2; - uint y = r.top + WD_FRAMERECT_TOP - icon_y_offset; + uint y = r.top + WD_FRAMERECT_TOP; bool rtl = _current_text_dir == TD_RTL; uint ordinal_left = rtl ? r.right - WD_FRAMERECT_LEFT - this->ordinal_width : r.left + WD_FRAMERECT_LEFT; @@ -1188,7 +1188,7 @@ public: const Company *c = this->companies[i]; DrawString(ordinal_left, ordinal_right, y, i + STR_ORDINAL_NUMBER_1ST, i == 0 ? TC_WHITE : TC_YELLOW); - DrawCompanyIcon(c->index, icon_left, y + icon_y_offset); + DrawCompanyIcon(c->index, icon_left, y + this->icon_y_offset); SetDParam(0, c->index); SetDParam(1, c->index); @@ -1221,6 +1221,7 @@ public: Dimension d = GetSpriteSize(SPR_COMPANY_ICON); this->icon_width = d.width + 2; this->line_height = max(d.height + 2, FONT_HEIGHT_NORMAL); + this->icon_y_offset = Center(1, this->line_height, d.height); const Company *c; FOR_ALL_COMPANIES(c) {