|
@@ -191,18 +191,18 @@ static void InitBlocksizeForVehicles(Veh
|
|
|
|
|
|
int min_extend = ScaleGUITrad(16);
|
|
|
int max_extend = ScaleGUITrad(98);
|
|
|
|
|
|
switch (image_type) {
|
|
|
case EIT_IN_DEPOT:
|
|
|
_base_block_sizes_depot[type].height = max<uint>(ScaleGUITrad(GetVehicleHeight(type)), max_height);
|
|
|
_base_block_sizes_depot[type].height = std::max<uint>(ScaleGUITrad(GetVehicleHeight(type)), max_height);
|
|
|
_base_block_sizes_depot[type].extend_left = Clamp(max_extend_left, min_extend, max_extend);
|
|
|
_base_block_sizes_depot[type].extend_right = Clamp(max_extend_right, min_extend, max_extend);
|
|
|
break;
|
|
|
case EIT_PURCHASE:
|
|
|
_base_block_sizes_purchase[type].height = max<uint>(ScaleGUITrad(GetVehicleHeight(type)), max_height);
|
|
|
_base_block_sizes_purchase[type].height = std::max<uint>(ScaleGUITrad(GetVehicleHeight(type)), max_height);
|
|
|
_base_block_sizes_purchase[type].extend_left = Clamp(max_extend_left, min_extend, max_extend);
|
|
|
_base_block_sizes_purchase[type].extend_right = Clamp(max_extend_right, min_extend, max_extend);
|
|
|
break;
|
|
|
|
|
|
default: NOT_REACHED();
|
|
|
}
|
|
@@ -392,13 +392,13 @@ struct DepotWindow : Window {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
uint16 rows_in_display = wid->current_y / wid->resize_y;
|
|
|
|
|
|
uint16 num = this->vscroll->GetPosition() * this->num_columns;
|
|
|
int maxval = min((uint)this->vehicle_list.size(), num + (rows_in_display * this->num_columns));
|
|
|
uint maxval = static_cast<uint>(std::min<size_t>(this->vehicle_list.size(), num + (rows_in_display * this->num_columns)));
|
|
|
int y;
|
|
|
for (y = r.top + 1; num < maxval; y += this->resize.step_height) { // Draw the rows
|
|
|
for (byte i = 0; i < this->num_columns && num < maxval; i++, num++) {
|
|
|
/* Draw all vehicles in the current row */
|
|
|
const Vehicle *v = this->vehicle_list[num];
|
|
|
if (this->num_columns == 1) {
|
|
@@ -407,13 +407,13 @@ struct DepotWindow : Window {
|
|
|
int x = r.left + (rtl ? (this->num_columns - i - 1) : i) * this->resize.step_width;
|
|
|
this->DrawVehicleInDepot(v, x, x + this->resize.step_width - 1, y);
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
|
|
|
maxval = min((uint)this->vehicle_list.size() + (uint)this->wagon_list.size(), (this->vscroll->GetPosition() * this->num_columns) + (rows_in_display * this->num_columns));
|
|
|
maxval = static_cast<uint>(std::min<size_t>(this->vehicle_list.size() + this->wagon_list.size(), (this->vscroll->GetPosition() * this->num_columns) + (rows_in_display * this->num_columns)));
|
|
|
|
|
|
/* Draw the train wagons without an engine in front. */
|
|
|
for (; num < maxval; num++, y += this->resize.step_height) {
|
|
|
const Vehicle *v = this->wagon_list[num - this->vehicle_list.size()];
|
|
|
this->DrawVehicleInDepot(v, r.left, r.right, y);
|
|
|
}
|
|
@@ -665,21 +665,21 @@ struct DepotWindow : Window {
|
|
|
Dimension unumber = GetStringBoundingBox(STR_BLACK_COMMA);
|
|
|
const Sprite *spr = GetSprite(SPR_FLAG_VEH_STOPPED, ST_NORMAL);
|
|
|
this->flag_width = UnScaleGUI(spr->width) + WD_FRAMERECT_RIGHT;
|
|
|
this->flag_height = UnScaleGUI(spr->height);
|
|
|
|
|
|
if (this->type == VEH_TRAIN || this->type == VEH_ROAD) {
|
|
|
min_height = max<uint>(unumber.height + WD_MATRIX_TOP, UnScaleGUI(spr->height));
|
|
|
min_height = std::max<uint>(unumber.height + WD_MATRIX_TOP, UnScaleGUI(spr->height));
|
|
|
this->header_width = unumber.width + this->flag_width + WD_FRAMERECT_LEFT;
|
|
|
} else {
|
|
|
min_height = unumber.height + UnScaleGUI(spr->height) + WD_MATRIX_TOP + WD_PAR_VSEP_NORMAL + WD_MATRIX_BOTTOM;
|
|
|
this->header_width = max<uint>(unumber.width, this->flag_width) + WD_FRAMERECT_RIGHT;
|
|
|
this->header_width = std::max<uint>(unumber.width, this->flag_width) + WD_FRAMERECT_RIGHT;
|
|
|
}
|
|
|
int base_width = this->count_width + this->header_width;
|
|
|
|
|
|
resize->height = max<uint>(GetVehicleImageCellSize(this->type, EIT_IN_DEPOT).height, min_height);
|
|
|
resize->height = std::max<uint>(GetVehicleImageCellSize(this->type, EIT_IN_DEPOT).height, min_height);
|
|
|
if (this->type == VEH_TRAIN) {
|
|
|
resize->width = 1;
|
|
|
size->width = base_width + 2 * ScaleGUITrad(29); // about 2 parts
|
|
|
size->height = resize->height * 6;
|
|
|
} else {
|
|
|
resize->width = base_width + GetVehicleImageCellSize(this->type, EIT_IN_DEPOT).extend_left + GetVehicleImageCellSize(this->type, EIT_IN_DEPOT).extend_right;
|
|
@@ -725,13 +725,13 @@ struct DepotWindow : Window {
|
|
|
uint max_width = ScaleGUITrad(VEHICLEINFO_FULL_VEHICLE_WIDTH);
|
|
|
for (uint num = 0; num < this->vehicle_list.size(); num++) {
|
|
|
uint width = 0;
|
|
|
for (const Train *v = Train::From(this->vehicle_list[num]); v != nullptr; v = v->Next()) {
|
|
|
width += v->GetDisplayImageWidth();
|
|
|
}
|
|
|
max_width = max(max_width, width);
|
|
|
max_width = std::max(max_width, width);
|
|
|
}
|
|
|
/* Always have 1 empty row, so people can change the setting of the train */
|
|
|
this->vscroll->SetCount((uint)this->vehicle_list.size() + (uint)this->wagon_list.size() + 1);
|
|
|
/* Always make it longer than the longest train, so you can attach vehicles at the end, and also see the next vertical tile separator line */
|
|
|
this->hscroll->SetCount(max_width + ScaleGUITrad(2 * VEHICLEINFO_FULL_VEHICLE_WIDTH + 1));
|
|
|
} else {
|