summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorrubidium <rubidium@openttd.org>2013-06-29 13:19:19 +0000
committerrubidium <rubidium@openttd.org>2013-06-29 13:19:19 +0000
commit435651040800746f38f753ace699d453f802d396 (patch)
treebdee9363a2ea5bc2d069481ed6f320252d3750e2
parentba1e42d057bb85ee08cf05959bccb0dbdd73b24c (diff)
downloadopenttd-435651040800746f38f753ace699d453f802d396.tar.xz
(svn r25517) -Fix-ish (r25515) / Feature-ish [FS#5623]: properly align the statistics as well when the infra sharing is turned on
-rw-r--r--src/company_gui.cpp22
-rw-r--r--src/lang/english.txt1
2 files changed, 16 insertions, 7 deletions
diff --git a/src/company_gui.cpp b/src/company_gui.cpp
index 027de058b..37f1b9987 100644
--- a/src/company_gui.cpp
+++ b/src/company_gui.cpp
@@ -1692,15 +1692,19 @@ struct CompanyInfrastructureWindow : Window
max_cost = max(max_cost, AirportMaintenanceCost(c->index));
SetDParamMaxValue(0, max_val);
- SetDParamMaxValue(1, max_cost * 12); // Convert to per year
- size->width = max(size->width, GetStringBoundingBox(_settings_game.economy.infrastructure_maintenance ? STR_COMPANY_INFRASTRUCTURE_VIEW_COST : STR_WHITE_COMMA).width + 20); // Reserve some wiggle room.
+ uint count_width = GetStringBoundingBox(STR_WHITE_COMMA).width + 20; // Reserve some wiggle room
if (_settings_game.economy.infrastructure_maintenance) {
SetDParamMaxValue(0, this->GetTotalMaintenanceCost() * 12); // Convert to per year
this->total_width = GetStringBoundingBox(STR_COMPANY_INFRASTRUCTURE_VIEW_TOTAL).width + 20;
size->width = max(size->width, this->total_width);
+
+ SetDParamMaxValue(0, max_cost * 12); // Convert to per year
+ count_width += max(this->total_width, GetStringBoundingBox(STR_COMPANY_INFRASTRUCTURE_VIEW_TOTAL).width);
}
+ size->width = max(size->width, count_width);
+
/* Set height of the total line. */
if (widget == WID_CI_TOTAL) {
size->height = _settings_game.economy.infrastructure_maintenance ? max(size->height, EXP_LINESPACE + FONT_HEIGHT_NORMAL) : 0;
@@ -1720,8 +1724,13 @@ struct CompanyInfrastructureWindow : Window
void DrawCountLine(const Rect &r, int &y, int count, Money monthly_cost) const
{
SetDParam(0, count);
- SetDParam(1, monthly_cost * 12); // Convert to per year
- DrawString(r.left, r.right, y += FONT_HEIGHT_NORMAL, _settings_game.economy.infrastructure_maintenance ? STR_COMPANY_INFRASTRUCTURE_VIEW_COST : STR_WHITE_COMMA, TC_FROMSTRING, SA_RIGHT);
+ DrawString(r.left, r.right, y += FONT_HEIGHT_NORMAL, STR_WHITE_COMMA, TC_FROMSTRING, SA_RIGHT);
+
+ if (_settings_game.economy.infrastructure_maintenance) {
+ SetDParam(0, monthly_cost * 12); // Convert to per year
+ int left = _current_text_dir == TD_RTL ? r.right - this->total_width : r.left;
+ DrawString(left, left + this->total_width, y, STR_COMPANY_INFRASTRUCTURE_VIEW_TOTAL, TC_FROMSTRING, SA_RIGHT);
+ }
}
virtual void DrawWidget(const Rect &r, int widget) const
@@ -1799,10 +1808,11 @@ struct CompanyInfrastructureWindow : Window
case WID_CI_TOTAL:
if (_settings_game.economy.infrastructure_maintenance) {
- GfxFillRect(r.left, y, r.left + this->total_width, y, PC_WHITE);
+ int left = _current_text_dir == TD_RTL ? r.right - this->total_width : r.left;
+ GfxFillRect(left, y, left + this->total_width, y, PC_WHITE);
y += EXP_LINESPACE;
SetDParam(0, this->GetTotalMaintenanceCost() * 12); // Convert to per year
- DrawString(r.left, r.left + this->total_width, y, STR_COMPANY_INFRASTRUCTURE_VIEW_TOTAL, TC_FROMSTRING, SA_RIGHT);
+ DrawString(left, left + this->total_width, y, STR_COMPANY_INFRASTRUCTURE_VIEW_TOTAL, TC_FROMSTRING, SA_RIGHT);
}
break;
diff --git a/src/lang/english.txt b/src/lang/english.txt
index 5a00db959..686e705c9 100644
--- a/src/lang/english.txt
+++ b/src/lang/english.txt
@@ -3205,7 +3205,6 @@ STR_COMPANY_INFRASTRUCTURE_VIEW_CANALS :{WHITE}Canals
STR_COMPANY_INFRASTRUCTURE_VIEW_STATION_SECT :{GOLD}Stations:
STR_COMPANY_INFRASTRUCTURE_VIEW_STATIONS :{WHITE}Station tiles
STR_COMPANY_INFRASTRUCTURE_VIEW_AIRPORTS :{WHITE}Airports
-STR_COMPANY_INFRASTRUCTURE_VIEW_COST :{WHITE}{1:CURRENCY_LONG}/yr ({0:COMMA})
STR_COMPANY_INFRASTRUCTURE_VIEW_TOTAL :{WHITE}{CURRENCY_LONG}/yr
# Industry directory