Changeset - r14921:f28746b8a042
[Not reviewed]
master
0 2 0
terkhen - 14 years ago 2010-04-01 18:30:00
terkhen@openttd.org
(svn r19533) -Fix [FS#3720]: Vehicle details window did not resize correctly after refitting a road vehicle to a longer variant.
2 files changed with 36 insertions and 11 deletions:
0 comments (0 inline, 0 general)
src/roadveh_cmd.cpp
Show inline comments
 
@@ -1770,7 +1770,7 @@ CommandCost CmdRefitRoadVeh(TileIndex ti
 
		RoadVehicle *front = v->First();
 
		RoadVehUpdateCache(front);
 
		if (_settings_game.vehicle.roadveh_acceleration_model != AM_ORIGINAL) front->CargoChanged();
 
		SetWindowDirty(WC_VEHICLE_DETAILS, front->index);
 
		InvalidateWindowData(WC_VEHICLE_DETAILS, front->index);
 
		SetWindowDirty(WC_VEHICLE_DEPOT, front->tile);
 
		InvalidateWindowClassesData(WC_ROADVEH_LIST, 0);
 
	} else {
src/vehicle_gui.cpp
Show inline comments
 
@@ -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:
0 comments (0 inline, 0 general)