Merge upstream branch 1.8

This commit is contained in:
Sergii Pylypenko
2018-05-31 22:59:50 +03:00
240 changed files with 9656 additions and 2536 deletions

View File

@@ -54,6 +54,7 @@ static const NWidgetPart _nested_group_widgets[] = {
SetFill(1, 0), SetResize(0, 1), SetScrollbar(WID_GL_LIST_GROUP_SCROLLBAR),
NWidget(NWID_VSCROLLBAR, COLOUR_GREY, WID_GL_LIST_GROUP_SCROLLBAR),
EndContainer(),
NWidget(WWT_PANEL, COLOUR_GREY, WID_GL_INFO), SetFill(1, 0), EndContainer(),
NWidget(NWID_HORIZONTAL),
NWidget(WWT_PUSHIMGBTN, COLOUR_GREY, WID_GL_CREATE_GROUP), SetFill(0, 1),
SetDataTip(SPR_GROUP_CREATE_TRAIN, STR_GROUP_CREATE_TOOLTIP),
@@ -366,6 +367,9 @@ public:
/* Minimum height is the height of the list widget minus all and default vehicles... */
size->height = (this->vli.vtype >= VEH_SHIP ? 3.5 : 7) * GetVehicleListHeight(this->vli.vtype, this->tiny_step_height) - 2 * this->tiny_step_height;
/* ... minus the height of the group info ... */
max_icon_height += (FONT_HEIGHT_NORMAL * 3) + WD_FRAMERECT_TOP + WD_FRAMERECT_BOTTOM;
/* Get a multiple of tiny_step_height of that amount */
size->height = Ceil(size->height, tiny_step_height);
break;
@@ -398,6 +402,11 @@ public:
*size = maxdim(*size, d);
break;
}
case WID_GL_INFO: {
size->height = (FONT_HEIGHT_NORMAL * 3) + WD_FRAMERECT_TOP + WD_FRAMERECT_BOTTOM;
break;
}
}
}
@@ -522,6 +531,44 @@ public:
DrawGroupInfo(r.top + WD_FRAMERECT_TOP, r.left, r.right, DEFAULT_GROUP);
break;
case WID_GL_INFO: {
Money this_year = 0;
Money last_year = 0;
uint32 occupancy = 0;
uint32 vehicle_count = this->vehicles.Length();
for (uint i = 0; i < vehicle_count; i++) {
const Vehicle *v = this->vehicles[i];
assert(v->owner == this->owner);
this_year += v->GetDisplayProfitThisYear();
last_year += v->GetDisplayProfitLastYear();
occupancy += v->trip_occupancy;
}
const int left = r.left + WD_FRAMERECT_LEFT + 8;
const int right = r.right - WD_FRAMERECT_RIGHT - 8;
int y = r.top + WD_FRAMERECT_TOP;
DrawString(left, right, y, STR_GROUP_PROFIT_THIS_YEAR, TC_BLACK);
SetDParam(0, this_year);
DrawString(left, right, y, STR_JUST_CURRENCY_LONG, TC_BLACK, SA_RIGHT);
y += FONT_HEIGHT_NORMAL;
DrawString(left, right, y, STR_GROUP_PROFIT_LAST_YEAR, TC_BLACK);
SetDParam(0, last_year);
DrawString(left, right, y, STR_JUST_CURRENCY_LONG, TC_BLACK, SA_RIGHT);
y += FONT_HEIGHT_NORMAL;
DrawString(left, right, y, STR_GROUP_OCCUPANCY, TC_BLACK);
if (vehicle_count > 0) {
SetDParam(0, occupancy / vehicle_count);
DrawString(left, right, y, STR_GROUP_OCCUPANCY_VALUE, TC_BLACK, SA_RIGHT);
}
break;
}
case WID_GL_LIST_GROUP: {
int y1 = r.top + WD_FRAMERECT_TOP;
int max = min(this->group_sb->GetPosition() + this->group_sb->GetCapacity(), this->groups.Length());