Changeset - r22716:c0f09e528ee1
[Not reviewed]
master
0 1 0
frosch - 6 years ago 2017-12-10 13:48:06
frosch@openttd.org
(svn r27937) -Change: When train depots have a horizontal scrollbar, allow scrolling 1 tile beyond the longest train, so you can actually attach a wagon at the end.
1 file changed with 4 insertions and 3 deletions:
0 comments (0 inline, 0 general)
src/depot_gui.cpp
Show inline comments
 
@@ -375,29 +375,29 @@ struct DepotWindow : Window {
 

	
 
		/* Draw vertical separators at whole tiles.
 
		 * This only works in two cases:
 
		 *  - All vehicles use VEHICLEINFO_FULL_VEHICLE_WIDTH as reference width.
 
		 *  - All vehicles are 8/8. This cannot be checked for NewGRF, so instead we check for "all vehicles are original vehicles".
 
		 */
 
		if (this->type == VEH_TRAIN && _consistent_train_width != 0) {
 
			int w = ScaleGUITrad(2 * _consistent_train_width);
 
			int col = _colour_gradient[wid->colour][4];
 
			int image_left  = rtl ? r.left  + this->count_width  : r.left  + this->header_width;
 
			int image_right = rtl ? r.right - this->header_width : r.right - this->count_width;
 
			if (rtl) {
 
				for (int x = image_right - w; x > image_left; x -= w) {
 
				for (int x = image_right - w; x >= image_left; x -= w) {
 
					GfxDrawLine(x, r.top, x, r.bottom, col, 1, 3);
 
				}
 
			} else {
 
				for (int x = image_left + w; x < image_right; x += w) {
 
				for (int x = image_left + w; x <= image_right; x += w) {
 
					GfxDrawLine(x, r.top, x, r.bottom, col, 1, 3);
 
				}
 
			}
 
		}
 

	
 
		uint16 rows_in_display = wid->current_y / wid->resize_y;
 

	
 
		uint16 num = this->vscroll->GetPosition() * this->num_columns;
 
		int maxval = min(this->vehicle_list.Length(), 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++) {
 
@@ -725,25 +725,26 @@ struct DepotWindow : Window {
 
		/* determine amount of items for scroller */
 
		if (this->type == VEH_TRAIN) {
 
			uint max_width = ScaleGUITrad(VEHICLEINFO_FULL_VEHICLE_WIDTH);
 
			for (uint num = 0; num < this->vehicle_list.Length(); num++) {
 
				uint width = 0;
 
				for (const Train *v = Train::From(this->vehicle_list[num]); v != NULL; v = v->Next()) {
 
					width += v->GetDisplayImageWidth();
 
				}
 
				max_width = max(max_width, width);
 
			}
 
			/* Always have 1 empty row, so people can change the setting of the train */
 
			this->vscroll->SetCount(this->vehicle_list.Length() + this->wagon_list.Length() + 1);
 
			this->hscroll->SetCount(max_width);
 
			/* 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 {
 
			this->vscroll->SetCount(CeilDiv(this->vehicle_list.Length(), this->num_columns));
 
		}
 

	
 
		/* Setup disabled buttons. */
 
		TileIndex tile = this->window_number;
 
		this->SetWidgetsDisabledState(!IsTileOwner(tile, _local_company),
 
			WID_D_STOP_ALL,
 
			WID_D_START_ALL,
 
			WID_D_SELL,
 
			WID_D_SELL_CHAIN,
 
			WID_D_SELL_ALL,
0 comments (0 inline, 0 general)