|
|
|
@ -1398,6 +1398,40 @@ struct VehicleDetailsWindow : Window {
|
|
|
|
|
this->tab = TDW_TAB_CARGO;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
virtual void OnInvalidateData(int data)
|
|
|
|
|
{
|
|
|
|
|
const Vehicle *v = Vehicle::Get(this->window_number);
|
|
|
|
|
if (v->type == VEH_ROAD) {
|
|
|
|
|
const NWidgetBase *nwid_info = this->GetWidget<NWidgetBase>(VLD_WIDGET_MIDDLE_DETAILS);
|
|
|
|
|
uint aimed_height = this->GetRoadVehDetailsHeight(v);
|
|
|
|
|
/* If the number of articulated parts changes, the size of the window must change too. */
|
|
|
|
|
if (aimed_height != nwid_info->current_y) {
|
|
|
|
|
this->ReInit();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Gets the desired height for the road vehicle details panel.
|
|
|
|
|
* @param v Road vehicle being shown.
|
|
|
|
|
* @return Desired height in pixels.
|
|
|
|
|
*/
|
|
|
|
|
uint GetRoadVehDetailsHeight(const Vehicle *v)
|
|
|
|
|
{
|
|
|
|
|
uint desired_height;
|
|
|
|
|
if (RoadVehicle::From(v)->HasArticulatedPart()) {
|
|
|
|
|
/* An articulated RV has its text drawn under the sprite instead of after it, hence 15 pixels extra. */
|
|
|
|
|
desired_height = WD_FRAMERECT_TOP + 15 + 3 * FONT_HEIGHT_NORMAL + 2 + WD_FRAMERECT_BOTTOM;
|
|
|
|
|
/* Add space for the cargo amount for each part. */
|
|
|
|
|
for (const Vehicle *u = v; u != NULL; u = u->Next()) {
|
|
|
|
|
if (u->cargo_cap != 0) desired_height += FONT_HEIGHT_NORMAL + 1;
|
|
|
|
|
}
|
|
|
|
|
} else {
|
|
|
|
|
desired_height = WD_FRAMERECT_TOP + 4 * FONT_HEIGHT_NORMAL + 3 + WD_FRAMERECT_BOTTOM;
|
|
|
|
|
}
|
|
|
|
|
return desired_height;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
virtual void UpdateWidgetSize(int widget, Dimension *size, const Dimension &padding, Dimension *fill, Dimension *resize)
|
|
|
|
|
{
|
|
|
|
|
switch (widget) {
|
|
|
|
@ -1425,16 +1459,7 @@ struct VehicleDetailsWindow : Window {
|
|
|
|
|
const Vehicle *v = Vehicle::Get(this->window_number);
|
|
|
|
|
switch (v->type) {
|
|
|
|
|
case VEH_ROAD:
|
|
|
|
|
if (RoadVehicle::From(v)->HasArticulatedPart()) {
|
|
|
|
|
/* An articulated RV has its text drawn under the sprite instead of after it, hence 15 pixels extra. */
|
|
|
|
|
size->height = WD_FRAMERECT_TOP + 15 + 3 * FONT_HEIGHT_NORMAL + 2 + WD_FRAMERECT_BOTTOM;
|
|
|
|
|
/* Add space for the cargo amount for each part. */
|
|
|
|
|
for (const Vehicle *u = v; u != NULL; u = u->Next()) {
|
|
|
|
|
if (u->cargo_cap != 0) size->height += FONT_HEIGHT_NORMAL + 1;
|
|
|
|
|
}
|
|
|
|
|
} else {
|
|
|
|
|
size->height = WD_FRAMERECT_TOP + 4 * FONT_HEIGHT_NORMAL + 3 + WD_FRAMERECT_BOTTOM;
|
|
|
|
|
}
|
|
|
|
|
size->height = this->GetRoadVehDetailsHeight(v);
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case VEH_SHIP:
|
|
|
|
|