Merge tag '1.11.0-beta2' into master

This commit is contained in:
Sergii Pylypenko
2021-03-03 00:51:28 +02:00
284 changed files with 26442 additions and 7539 deletions

View File

@@ -185,7 +185,7 @@ void BaseVehicleListWindow::BuildVehicleList()
if (this->grouping == GB_NONE) {
uint max_unitnumber = 0;
for (auto it = this->vehicles.begin(); it != this->vehicles.end(); ++it) {
this->vehgroups.emplace_back(it, it + 1, (*it)->GetDisplayProfitThisYear(), (*it)->GetDisplayProfitLastYear(), (*it)->age);
this->vehgroups.emplace_back(it, it + 1);
max_unitnumber = std::max<uint>(max_unitnumber, (*it)->unitnumber);
}
@@ -204,17 +204,7 @@ void BaseVehicleListWindow::BuildVehicleList()
return v->FirstShared() == first_shared;
});
Money display_profit_this_year = 0;
Money display_profit_last_year = 0;
Date age = 0;
for (auto it = begin; it != end; ++it) {
const Vehicle * const v = (*it);
display_profit_this_year += v->GetDisplayProfitThisYear();
display_profit_last_year += v->GetDisplayProfitLastYear();
age = std::max<Date>(age, v->age);
}
this->vehgroups.emplace_back(begin, end, display_profit_this_year, display_profit_last_year, age);
this->vehgroups.emplace_back(begin, end);
max_num_vehicles = std::max<uint>(max_num_vehicles, static_cast<uint>(end - begin));
@@ -1184,25 +1174,25 @@ static bool VehicleGroupLengthSorter(const GUIVehicleGroup &a, const GUIVehicleG
/** Sort vehicle groups by the total profit this year */
static bool VehicleGroupTotalProfitThisYearSorter(const GUIVehicleGroup &a, const GUIVehicleGroup &b)
{
return a.display_profit_this_year < b.display_profit_this_year;
return a.GetDisplayProfitThisYear() < b.GetDisplayProfitThisYear();
}
/** Sort vehicle groups by the total profit last year */
static bool VehicleGroupTotalProfitLastYearSorter(const GUIVehicleGroup &a, const GUIVehicleGroup &b)
{
return a.display_profit_last_year < b.display_profit_last_year;
return a.GetDisplayProfitLastYear() < b.GetDisplayProfitLastYear();
}
/** Sort vehicle groups by the average profit this year */
static bool VehicleGroupAverageProfitThisYearSorter(const GUIVehicleGroup &a, const GUIVehicleGroup &b)
{
return a.display_profit_this_year * static_cast<uint>(b.NumVehicles()) < b.display_profit_this_year * static_cast<uint>(a.NumVehicles());
return a.GetDisplayProfitThisYear() * static_cast<uint>(b.NumVehicles()) < b.GetDisplayProfitThisYear() * static_cast<uint>(a.NumVehicles());
}
/** Sort vehicle groups by the average profit last year */
static bool VehicleGroupAverageProfitLastYearSorter(const GUIVehicleGroup &a, const GUIVehicleGroup &b)
{
return a.display_profit_last_year * static_cast<uint>(b.NumVehicles()) < b.display_profit_last_year * static_cast<uint>(a.NumVehicles());
return a.GetDisplayProfitLastYear() * static_cast<uint>(b.NumVehicles()) < b.GetDisplayProfitLastYear() * static_cast<uint>(a.NumVehicles());
}
/** Sort vehicles by their number */
@@ -1539,11 +1529,11 @@ void BaseVehicleListWindow::DrawVehicleListItems(VehicleID selected_vehicle, int
const GUIVehicleGroup &vehgroup = this->vehgroups[i];
SetDParam(0, vehgroup.display_profit_this_year);
SetDParam(1, vehgroup.display_profit_last_year);
SetDParam(0, vehgroup.GetDisplayProfitThisYear());
SetDParam(1, vehgroup.GetDisplayProfitLastYear());
DrawString(text_left, text_right, y + line_height - FONT_HEIGHT_SMALL - WD_FRAMERECT_BOTTOM - 1, STR_VEHICLE_LIST_PROFIT_THIS_YEAR_LAST_YEAR);
DrawVehicleProfitButton(vehgroup.age, vehgroup.display_profit_last_year, vehgroup.NumVehicles(), vehicle_button_x, y + FONT_HEIGHT_NORMAL + 3);
DrawVehicleProfitButton(vehgroup.GetOldestVehicleAge(), vehgroup.GetDisplayProfitLastYear(), vehgroup.NumVehicles(), vehicle_button_x, y + FONT_HEIGHT_NORMAL + 3);
switch (this->grouping) {
case GB_NONE: {
@@ -1576,7 +1566,6 @@ void BaseVehicleListWindow::DrawVehicleListItems(VehicleID selected_vehicle, int
}
case GB_SHARED_ORDERS:
assert(vehgroup.NumVehicles() > 0);
for (int i = 0; i < static_cast<int>(vehgroup.NumVehicles()); ++i) {
@@ -3153,7 +3142,7 @@ void SetMouseCursorVehicle(const Vehicle *v, EngineImageType image_type)
_cursor.sprite_count = 0;
int total_width = 0;
for (; v != nullptr; v = v->HasArticulatedPart() ? v->GetNextArticulatedPart() : nullptr) {
if (total_width >= 2 * (int)VEHICLEINFO_FULL_VEHICLE_WIDTH) break;
if (total_width >= ScaleGUITrad(2 * (int)VEHICLEINFO_FULL_VEHICLE_WIDTH)) break;
PaletteID pal = (v->vehstatus & VS_CRASHED) ? PALETTE_CRASH : GetVehiclePalette(v);
VehicleSpriteSeq seq;
@@ -3173,7 +3162,7 @@ void SetMouseCursorVehicle(const Vehicle *v, EngineImageType image_type)
total_width += GetSingleVehicleWidth(v, image_type);
}
int offs = ((int)VEHICLEINFO_FULL_VEHICLE_WIDTH - total_width) / 2;
int offs = (ScaleGUITrad(VEHICLEINFO_FULL_VEHICLE_WIDTH) - total_width) / 2;
if (rtl) offs = -offs;
for (uint i = 0; i < _cursor.sprite_count; ++i) {
_cursor.sprite_pos[i].x += offs;