mirror of https://github.com/OpenTTD/OpenTTD.git
(svn r25517) -Fix-ish (r25515) / Feature-ish [FS#5623]: properly align the statistics as well when the infra sharing is turned on
This commit is contained in:
parent
ba1e42d057
commit
4356510408
|
@ -1692,15 +1692,19 @@ struct CompanyInfrastructureWindow : Window
|
||||||
max_cost = max(max_cost, AirportMaintenanceCost(c->index));
|
max_cost = max(max_cost, AirportMaintenanceCost(c->index));
|
||||||
|
|
||||||
SetDParamMaxValue(0, max_val);
|
SetDParamMaxValue(0, max_val);
|
||||||
SetDParamMaxValue(1, max_cost * 12); // Convert to per year
|
uint count_width = GetStringBoundingBox(STR_WHITE_COMMA).width + 20; // Reserve some wiggle room
|
||||||
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.
|
|
||||||
|
|
||||||
if (_settings_game.economy.infrastructure_maintenance) {
|
if (_settings_game.economy.infrastructure_maintenance) {
|
||||||
SetDParamMaxValue(0, this->GetTotalMaintenanceCost() * 12); // Convert to per year
|
SetDParamMaxValue(0, this->GetTotalMaintenanceCost() * 12); // Convert to per year
|
||||||
this->total_width = GetStringBoundingBox(STR_COMPANY_INFRASTRUCTURE_VIEW_TOTAL).width + 20;
|
this->total_width = GetStringBoundingBox(STR_COMPANY_INFRASTRUCTURE_VIEW_TOTAL).width + 20;
|
||||||
size->width = max(size->width, this->total_width);
|
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. */
|
/* Set height of the total line. */
|
||||||
if (widget == WID_CI_TOTAL) {
|
if (widget == WID_CI_TOTAL) {
|
||||||
size->height = _settings_game.economy.infrastructure_maintenance ? max(size->height, EXP_LINESPACE + FONT_HEIGHT_NORMAL) : 0;
|
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
|
void DrawCountLine(const Rect &r, int &y, int count, Money monthly_cost) const
|
||||||
{
|
{
|
||||||
SetDParam(0, count);
|
SetDParam(0, count);
|
||||||
SetDParam(1, monthly_cost * 12); // Convert to per year
|
DrawString(r.left, r.right, y += FONT_HEIGHT_NORMAL, STR_WHITE_COMMA, TC_FROMSTRING, SA_RIGHT);
|
||||||
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);
|
|
||||||
|
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
|
virtual void DrawWidget(const Rect &r, int widget) const
|
||||||
|
@ -1799,10 +1808,11 @@ struct CompanyInfrastructureWindow : Window
|
||||||
|
|
||||||
case WID_CI_TOTAL:
|
case WID_CI_TOTAL:
|
||||||
if (_settings_game.economy.infrastructure_maintenance) {
|
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;
|
y += EXP_LINESPACE;
|
||||||
SetDParam(0, this->GetTotalMaintenanceCost() * 12); // Convert to per year
|
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;
|
break;
|
||||||
|
|
||||||
|
|
|
@ -3205,7 +3205,6 @@ STR_COMPANY_INFRASTRUCTURE_VIEW_CANALS :{WHITE}Canals
|
||||||
STR_COMPANY_INFRASTRUCTURE_VIEW_STATION_SECT :{GOLD}Stations:
|
STR_COMPANY_INFRASTRUCTURE_VIEW_STATION_SECT :{GOLD}Stations:
|
||||||
STR_COMPANY_INFRASTRUCTURE_VIEW_STATIONS :{WHITE}Station tiles
|
STR_COMPANY_INFRASTRUCTURE_VIEW_STATIONS :{WHITE}Station tiles
|
||||||
STR_COMPANY_INFRASTRUCTURE_VIEW_AIRPORTS :{WHITE}Airports
|
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
|
STR_COMPANY_INFRASTRUCTURE_VIEW_TOTAL :{WHITE}{CURRENCY_LONG}/yr
|
||||||
|
|
||||||
# Industry directory
|
# Industry directory
|
||||||
|
|
Loading…
Reference in New Issue