src/road_gui.cpp
branchnoai
changeset 10645 8cbdb511a674
parent 10513 33cb70ff2f5d
child 10715 6bdf79ffb022
equal deleted inserted replaced
10644:6c4314786d68 10645:8cbdb511a674
   398 	'B',
   398 	'B',
   399 	'T',
   399 	'T',
   400 	'R',
   400 	'R',
   401 };
   401 };
   402 
   402 
   403 /**
   403 struct BuildRoadToolbarWindow : Window {
   404  * Update the remove button lowered state of the road toolbar
   404 	BuildRoadToolbarWindow(const WindowDesc *desc, WindowNumber window_number) : Window(desc, window_number)
   405  *
   405 	{
   406  * @param w The toolbar window
   406 		this->SetWidgetsDisabledState(true,
   407  * @param clicked_widget The widget which the player clicked just now
   407 			RTW_REMOVE,
   408  */
   408 			RTW_ONE_WAY,
   409 static void UpdateOptionWidgetStatus(Window *w, RoadToolbarWidgets clicked_widget)
   409 			WIDGET_LIST_END);
   410 {
   410 
   411 	/* The remove and the one way button state is driven
   411 		this->FindWindowPlacementAndResize(desc);
   412 	 * by the other buttons so they don't act on themselfs.
   412 		if (_patches.link_terraform_toolbar) ShowTerraformToolbar(this);
   413 	 * Both are only valid if they are able to apply as options. */
   413 	}
   414 	switch (clicked_widget) {
   414 
   415 		case RTW_REMOVE:
   415 	~BuildRoadToolbarWindow()
   416 			w->RaiseWidget(RTW_ONE_WAY);
   416 	{
   417 			w->InvalidateWidget(RTW_ONE_WAY);
   417 		if (_patches.link_terraform_toolbar) DeleteWindowById(WC_SCEN_LAND_GEN, 0);
   418 			break;
   418 	}
   419 
   419 
   420 		case RTW_ONE_WAY:
   420 	/**
   421 			w->RaiseWidget(RTW_REMOVE);
   421 	 * Update the remove button lowered state of the road toolbar
   422 			w->InvalidateWidget(RTW_REMOVE);
   422 	 *
   423 			break;
   423 	 * @param clicked_widget The widget which the player clicked just now
   424 
   424 	 */
   425 		case RTW_BUS_STATION:
   425 	void UpdateOptionWidgetStatus(RoadToolbarWidgets clicked_widget)
   426 		case RTW_TRUCK_STATION:
   426 	{
   427 			w->DisableWidget(RTW_ONE_WAY);
   427 		/* The remove and the one way button state is driven
   428 			w->SetWidgetDisabledState(RTW_REMOVE, !w->IsWidgetLowered(clicked_widget));
   428 		 * by the other buttons so they don't act on themselfs.
   429 			break;
   429 		 * Both are only valid if they are able to apply as options. */
   430 
   430 		switch (clicked_widget) {
   431 		case RTW_ROAD_X:
   431 			case RTW_REMOVE:
   432 		case RTW_ROAD_Y:
   432 				this->RaiseWidget(RTW_ONE_WAY);
   433 		case RTW_AUTOROAD:
   433 				this->InvalidateWidget(RTW_ONE_WAY);
   434 			w->SetWidgetsDisabledState(!w->IsWidgetLowered(clicked_widget),
   434 				break;
   435 				RTW_REMOVE,
   435 
   436 				RTW_ONE_WAY,
   436 			case RTW_ONE_WAY:
   437 				WIDGET_LIST_END);
   437 				this->RaiseWidget(RTW_REMOVE);
   438 			break;
   438 				this->InvalidateWidget(RTW_REMOVE);
   439 
   439 				break;
   440 		default:
   440 
   441 			/* When any other buttons than road/station, raise and
   441 			case RTW_BUS_STATION:
   442 			 * disable the removal button */
   442 			case RTW_TRUCK_STATION:
   443 			w->SetWidgetsDisabledState(true,
   443 				this->DisableWidget(RTW_ONE_WAY);
   444 				RTW_REMOVE,
   444 				this->SetWidgetDisabledState(RTW_REMOVE, !this->IsWidgetLowered(clicked_widget));
   445 				RTW_ONE_WAY,
   445 				break;
   446 				WIDGET_LIST_END);
   446 
   447 			w->SetWidgetsLoweredState (false,
   447 			case RTW_ROAD_X:
   448 				RTW_REMOVE,
   448 			case RTW_ROAD_Y:
   449 				RTW_ONE_WAY,
   449 			case RTW_AUTOROAD:
   450 				WIDGET_LIST_END);
   450 				this->SetWidgetsDisabledState(!this->IsWidgetLowered(clicked_widget),
   451 			break;
   451 					RTW_REMOVE,
   452 	}
   452 					RTW_ONE_WAY,
   453 }
   453 					WIDGET_LIST_END);
   454 
   454 				break;
   455 static void BuildRoadToolbWndProc(Window *w, WindowEvent *e)
   455 
   456 {
   456 			default:
   457 	switch (e->event) {
   457 				/* When any other buttons than road/station, raise and
   458 		case WE_CREATE:
   458 				 * disable the removal button */
   459 			w->SetWidgetsDisabledState(true,
   459 				this->SetWidgetsDisabledState(true,
   460 				RTW_REMOVE,
   460 					RTW_REMOVE,
   461 				RTW_ONE_WAY,
   461 					RTW_ONE_WAY,
   462 				WIDGET_LIST_END);
   462 					WIDGET_LIST_END);
   463 			break;
   463 				this->SetWidgetsLoweredState (false,
   464 
   464 					RTW_REMOVE,
   465 		case WE_PAINT:
   465 					RTW_ONE_WAY,
   466 			w->SetWidgetsDisabledState(!CanBuildVehicleInfrastructure(VEH_ROAD),
   466 					WIDGET_LIST_END);
   467 				RTW_DEPOT,
   467 				break;
   468 				RTW_BUS_STATION,
   468 		}
   469 				RTW_TRUCK_STATION,
   469 	}
   470 				WIDGET_LIST_END);
   470 
   471 			DrawWindowWidgets(w);
   471 	virtual void OnPaint()
   472 			break;
   472 	{
   473 
   473 		this->SetWidgetsDisabledState(!CanBuildVehicleInfrastructure(VEH_ROAD),
   474 		case WE_CLICK:
   474 			RTW_DEPOT,
   475 			if (e->we.click.widget >= RTW_ROAD_X) {
   475 			RTW_BUS_STATION,
       
   476 			RTW_TRUCK_STATION,
       
   477 			WIDGET_LIST_END);
       
   478 		this->DrawWidgets();
       
   479 	}
       
   480 
       
   481 	virtual void OnClick(Point pt, int widget)
       
   482 	{
       
   483 		if (widget >= RTW_ROAD_X) {
       
   484 			_remove_button_clicked = false;
       
   485 			_one_way_button_clicked = false;
       
   486 			_build_road_button_proc[widget - RTW_ROAD_X](this);
       
   487 		}
       
   488 		this->UpdateOptionWidgetStatus((RoadToolbarWidgets)widget);
       
   489 		if (_ctrl_pressed) RoadToolbar_CtrlChanged(this);
       
   490 	}
       
   491 
       
   492 	virtual EventState OnKeyPress(uint16 key, uint16 keycode)
       
   493 	{
       
   494 		EventState state = ES_NOT_HANDLED;
       
   495 		for (uint i = 0; i != lengthof(_road_keycodes); i++) {
       
   496 			if (keycode == _road_keycodes[i]) {
   476 				_remove_button_clicked = false;
   497 				_remove_button_clicked = false;
   477 				_one_way_button_clicked = false;
   498 				_one_way_button_clicked = false;
   478 				_build_road_button_proc[e->we.click.widget - RTW_ROAD_X](w);
   499 				_build_road_button_proc[i](this);
       
   500 				this->UpdateOptionWidgetStatus((RoadToolbarWidgets)(i + RTW_ROAD_X));
       
   501 				if (_ctrl_pressed) RoadToolbar_CtrlChanged(this);
       
   502 				state = ES_HANDLED;
       
   503 				break;
   479 			}
   504 			}
   480 			UpdateOptionWidgetStatus(w, (RoadToolbarWidgets)e->we.click.widget);
   505 		}
   481 			if (_ctrl_pressed) RoadToolbar_CtrlChanged(w);
   506 		MarkTileDirty(_thd.pos.x, _thd.pos.y); // redraw tile selection
   482 			break;
   507 		return state;
   483 
   508 	}
   484 		case WE_KEYPRESS:
   509 
   485 			for (uint i = 0; i != lengthof(_road_keycodes); i++) {
   510 	virtual void OnPlaceObject(Point pt, TileIndex tile)
   486 				if (e->we.keypress.keycode == _road_keycodes[i]) {
   511 	{
   487 					e->we.keypress.cont = false;
   512 		_remove_button_clicked = this->IsWidgetLowered(RTW_REMOVE);
   488 					_remove_button_clicked = false;
   513 		_one_way_button_clicked = this->IsWidgetLowered(RTW_ONE_WAY);
   489 					_one_way_button_clicked = false;
   514 		_place_proc(tile);
   490 					_build_road_button_proc[i](w);
   515 	}
   491 					UpdateOptionWidgetStatus(w, (RoadToolbarWidgets)(i + RTW_ROAD_X));
   516 
   492 					if (_ctrl_pressed) RoadToolbar_CtrlChanged(w);
   517 	virtual void OnPlaceObjectAbort()
       
   518 	{
       
   519 		this->RaiseButtons();
       
   520 		this->SetWidgetsDisabledState(true,
       
   521 			RTW_REMOVE,
       
   522 			RTW_ONE_WAY,
       
   523 			WIDGET_LIST_END);
       
   524 		this->InvalidateWidget(RTW_REMOVE);
       
   525 		this->InvalidateWidget(RTW_ONE_WAY);
       
   526 
       
   527 		delete FindWindowById(WC_BUS_STATION, 0);
       
   528 		delete FindWindowById(WC_TRUCK_STATION, 0);
       
   529 		delete FindWindowById(WC_BUILD_DEPOT, 0);
       
   530 	}
       
   531 
       
   532 	virtual void OnPlaceDrag(ViewportPlaceMethod select_method, ViewportDragDropSelectionProcess select_proc, Point pt)
       
   533 	{
       
   534 		/* Here we update the end tile flags
       
   535 		 * of the road placement actions.
       
   536 		 * At first we reset the end halfroad
       
   537 		 * bits and if needed we set them again. */
       
   538 		switch (select_proc) {
       
   539 			case DDSP_PLACE_ROAD_X_DIR:
       
   540 				_place_road_flag &= ~RF_END_HALFROAD_X;
       
   541 				if (pt.x & 8) _place_road_flag |= RF_END_HALFROAD_X;
       
   542 				break;
       
   543 
       
   544 			case DDSP_PLACE_ROAD_Y_DIR:
       
   545 				_place_road_flag &= ~RF_END_HALFROAD_Y;
       
   546 				if (pt.y & 8) _place_road_flag |= RF_END_HALFROAD_Y;
       
   547 				break;
       
   548 
       
   549 			case DDSP_PLACE_AUTOROAD:
       
   550 				_place_road_flag &= ~(RF_END_HALFROAD_Y | RF_END_HALFROAD_X);
       
   551 				if (pt.y & 8) _place_road_flag |= RF_END_HALFROAD_Y;
       
   552 				if (pt.x & 8) _place_road_flag |= RF_END_HALFROAD_X;
       
   553 
       
   554 				/* For autoroad we need to update the
       
   555 				 * direction of the road */
       
   556 				if (_thd.size.x > _thd.size.y || (_thd.size.x == _thd.size.y &&
       
   557 						( (_tile_fract_coords.x < _tile_fract_coords.y && (_tile_fract_coords.x + _tile_fract_coords.y) < 16) ||
       
   558 						(_tile_fract_coords.x > _tile_fract_coords.y && (_tile_fract_coords.x + _tile_fract_coords.y) > 16) ))) {
       
   559 					/* Set dir = X */
       
   560 					_place_road_flag &= ~RF_DIR_Y;
       
   561 				} else {
       
   562 					/* Set dir = Y */
       
   563 					_place_road_flag |= RF_DIR_Y;
       
   564 				}
       
   565 
       
   566 				break;
       
   567 
       
   568 			default:
       
   569 				break;
       
   570 		}
       
   571 
       
   572 		VpSelectTilesWithMethod(pt.x, pt.y, select_method);
       
   573 	}
       
   574 
       
   575 	virtual void OnPlaceMouseUp(ViewportPlaceMethod select_method, ViewportDragDropSelectionProcess select_proc, Point pt, TileIndex start_tile, TileIndex end_tile)
       
   576 	{
       
   577 		if (pt.x != -1) {
       
   578 			switch (select_proc) {
       
   579 				default: NOT_REACHED();
       
   580 				case DDSP_BUILD_BRIDGE:
       
   581 					ResetObjectToPlace();
       
   582 					ShowBuildBridgeWindow(start_tile, end_tile, TRANSPORT_ROAD, RoadTypeToRoadTypes(_cur_roadtype));
   493 					break;
   583 					break;
   494 				}
   584 
   495 			}
   585 				case DDSP_DEMOLISH_AREA:
   496 			MarkTileDirty(_thd.pos.x, _thd.pos.y); // redraw tile selection
   586 					GUIPlaceProcDragXY(select_proc, start_tile, end_tile);
   497 			break;
   587 					break;
   498 
   588 
   499 		case WE_PLACE_OBJ:
       
   500 			_remove_button_clicked = w->IsWidgetLowered(RTW_REMOVE);
       
   501 			_one_way_button_clicked = w->IsWidgetLowered(RTW_ONE_WAY);
       
   502 			_place_proc(e->we.place.tile);
       
   503 			break;
       
   504 
       
   505 		case WE_ABORT_PLACE_OBJ:
       
   506 			w->RaiseButtons();
       
   507 			w->SetWidgetsDisabledState(true,
       
   508 				RTW_REMOVE,
       
   509 				RTW_ONE_WAY,
       
   510 				WIDGET_LIST_END);
       
   511 			w->InvalidateWidget(RTW_REMOVE);
       
   512 			w->InvalidateWidget(RTW_ONE_WAY);
       
   513 
       
   514 			w = FindWindowById(WC_BUS_STATION, 0);
       
   515 			if (w != NULL) WP(w, def_d).close = true;
       
   516 			w = FindWindowById(WC_TRUCK_STATION, 0);
       
   517 			if (w != NULL) WP(w, def_d).close = true;
       
   518 			w = FindWindowById(WC_BUILD_DEPOT, 0);
       
   519 			if (w != NULL) WP(w, def_d).close = true;
       
   520 			break;
       
   521 
       
   522 		case WE_PLACE_DRAG:
       
   523 			/* Here we update the end tile flags
       
   524 			* of the road placement actions.
       
   525 			* At first we reset the end halfroad
       
   526 			* bits and if needed we set them again. */
       
   527 			switch (e->we.place.select_proc) {
       
   528 				case DDSP_PLACE_ROAD_X_DIR:
   589 				case DDSP_PLACE_ROAD_X_DIR:
   529 					_place_road_flag &= ~RF_END_HALFROAD_X;
       
   530 					if (e->we.place.pt.x & 8) _place_road_flag |= RF_END_HALFROAD_X;
       
   531 					break;
       
   532 
       
   533 				case DDSP_PLACE_ROAD_Y_DIR:
   590 				case DDSP_PLACE_ROAD_Y_DIR:
   534 					_place_road_flag &= ~RF_END_HALFROAD_Y;
       
   535 					if (e->we.place.pt.y & 8) _place_road_flag |= RF_END_HALFROAD_Y;
       
   536 					break;
       
   537 
       
   538 				case DDSP_PLACE_AUTOROAD:
   591 				case DDSP_PLACE_AUTOROAD:
   539 					_place_road_flag &= ~(RF_END_HALFROAD_Y | RF_END_HALFROAD_X);
   592 					/* Flag description:
   540 					if (e->we.place.pt.y & 8) _place_road_flag |= RF_END_HALFROAD_Y;
   593 					* Use the first three bits (0x07) if dir == Y
   541 					if (e->we.place.pt.x & 8) _place_road_flag |= RF_END_HALFROAD_X;
   594 					* else use the last 2 bits (X dir has
   542 
   595 					* not the 3rd bit set) */
   543 					/* For autoroad we need to update the
   596 					_place_road_flag = (RoadFlags)((_place_road_flag & RF_DIR_Y) ? (_place_road_flag & 0x07) : (_place_road_flag >> 3));
   544 					* direction of the road */
   597 
   545 					if (_thd.size.x > _thd.size.y || (_thd.size.x == _thd.size.y &&
   598 					DoCommandP(end_tile, start_tile, _place_road_flag | (_cur_roadtype << 3) | (_one_way_button_clicked << 5), CcPlaySound1D,
   546 							( (_tile_fract_coords.x < _tile_fract_coords.y && (_tile_fract_coords.x + _tile_fract_coords.y) < 16) ||
   599 						(_ctrl_pressed || _remove_button_clicked) ?
   547 							(_tile_fract_coords.x > _tile_fract_coords.y && (_tile_fract_coords.x + _tile_fract_coords.y) > 16) ))) {
   600 						CMD_REMOVE_LONG_ROAD | CMD_NO_WATER | CMD_MSG(_road_type_infos[_cur_roadtype].err_remove_road) :
   548 						/* Set dir = X */
   601 						CMD_BUILD_LONG_ROAD | CMD_NO_WATER | CMD_MSG(_road_type_infos[_cur_roadtype].err_build_road));
   549 						_place_road_flag &= ~RF_DIR_Y;
       
   550 					} else {
       
   551 						/* Set dir = Y */
       
   552 						_place_road_flag |= RF_DIR_Y;
       
   553 					}
       
   554 
       
   555 					break;
       
   556 
       
   557 				default:
       
   558 					break;
   602 					break;
   559 			}
   603 			}
   560 
   604 		}
   561 			VpSelectTilesWithMethod(e->we.place.pt.x, e->we.place.pt.y, e->we.place.select_method);
   605 	}
   562 			return;
   606 
   563 
   607 	virtual void OnPlacePresize(Point pt, TileIndex tile)
   564 		case WE_PLACE_MOUSEUP:
   608 	{
   565 			if (e->we.place.pt.x != -1) {
   609 		DoCommand(tile, 0x200 | RoadTypeToRoadTypes(_cur_roadtype), 0, DC_AUTO, CMD_BUILD_TUNNEL);
   566 				TileIndex start_tile = e->we.place.starttile;
   610 		VpSetPresizeRange(tile, _build_tunnel_endtile == 0 ? tile : _build_tunnel_endtile);
   567 				TileIndex end_tile = e->we.place.tile;
   611 	}
   568 
   612 
   569 				switch (e->we.place.select_proc) {
   613 	virtual EventState OnCTRLStateChange()
   570 					default: NOT_REACHED();
   614 	{
   571 					case DDSP_BUILD_BRIDGE:
   615 		if (RoadToolbar_CtrlChanged(this)) return ES_HANDLED;
   572 						ResetObjectToPlace();
   616 		return ES_NOT_HANDLED;
   573 						ShowBuildBridgeWindow(start_tile, end_tile, TRANSPORT_ROAD, RoadTypeToRoadTypes(_cur_roadtype));
   617 	}
   574 						break;
   618 };
   575 
       
   576 					case DDSP_DEMOLISH_AREA:
       
   577 						GUIPlaceProcDragXY(e);
       
   578 						break;
       
   579 
       
   580 					case DDSP_PLACE_ROAD_X_DIR:
       
   581 					case DDSP_PLACE_ROAD_Y_DIR:
       
   582 					case DDSP_PLACE_AUTOROAD:
       
   583 						/* Flag description:
       
   584 						* Use the first three bits (0x07) if dir == Y
       
   585 						* else use the last 2 bits (X dir has
       
   586 						* not the 3rd bit set) */
       
   587 						_place_road_flag = (RoadFlags)((_place_road_flag & RF_DIR_Y) ? (_place_road_flag & 0x07) : (_place_road_flag >> 3));
       
   588 
       
   589 						DoCommandP(end_tile, start_tile, _place_road_flag | (_cur_roadtype << 3) | (_one_way_button_clicked << 5), CcPlaySound1D,
       
   590 							(_ctrl_pressed || _remove_button_clicked) ?
       
   591 							CMD_REMOVE_LONG_ROAD | CMD_NO_WATER | CMD_MSG(_road_type_infos[_cur_roadtype].err_remove_road) :
       
   592 							CMD_BUILD_LONG_ROAD | CMD_NO_WATER | CMD_MSG(_road_type_infos[_cur_roadtype].err_build_road));
       
   593 						break;
       
   594 				}
       
   595 			}
       
   596 			break;
       
   597 
       
   598 		case WE_PLACE_PRESIZE: {
       
   599 			TileIndex tile = e->we.place.tile;
       
   600 
       
   601 			DoCommand(tile, 0x200 | RoadTypeToRoadTypes(_cur_roadtype), 0, DC_AUTO, CMD_BUILD_TUNNEL);
       
   602 			VpSetPresizeRange(tile, _build_tunnel_endtile == 0 ? tile : _build_tunnel_endtile);
       
   603 		} break;
       
   604 
       
   605 		case WE_DESTROY:
       
   606 			if (_patches.link_terraform_toolbar) DeleteWindowById(WC_SCEN_LAND_GEN, 0);
       
   607 			break;
       
   608 
       
   609 		case WE_CTRL_CHANGED:
       
   610 			if (RoadToolbar_CtrlChanged(w)) e->we.ctrl.cont = false;
       
   611 			break;
       
   612 
       
   613 		default:
       
   614 			break;
       
   615 	}
       
   616 }
       
   617 
   619 
   618 /** Widget definition of the build road toolbar */
   620 /** Widget definition of the build road toolbar */
   619 static const Widget _build_road_widgets[] = {
   621 static const Widget _build_road_widgets[] = {
   620 {   WWT_CLOSEBOX,   RESIZE_NONE,     7,     0,    10,     0,    13, STR_00C5,                   STR_018B_CLOSE_WINDOW},             // RTW_CLOSEBOX
   622 {   WWT_CLOSEBOX,   RESIZE_NONE,     7,     0,    10,     0,    13, STR_00C5,                   STR_018B_CLOSE_WINDOW},             // RTW_CLOSEBOX
   621 {    WWT_CAPTION,   RESIZE_NONE,     7,    11,   250,     0,    13, STR_1802_ROAD_CONSTRUCTION, STR_018C_WINDOW_TITLE_DRAG_THIS},   // RTW_CAPTION
   623 {    WWT_CAPTION,   RESIZE_NONE,     7,    11,   250,     0,    13, STR_1802_ROAD_CONSTRUCTION, STR_018C_WINDOW_TITLE_DRAG_THIS},   // RTW_CAPTION
   639 static const WindowDesc _build_road_desc = {
   641 static const WindowDesc _build_road_desc = {
   640 	WDP_ALIGN_TBR, 22, 263, 36, 263, 36,
   642 	WDP_ALIGN_TBR, 22, 263, 36, 263, 36,
   641 	WC_BUILD_TOOLBAR, WC_NONE,
   643 	WC_BUILD_TOOLBAR, WC_NONE,
   642 	WDF_STD_TOOLTIPS | WDF_STD_BTN | WDF_DEF_WIDGET | WDF_STICKY_BUTTON,
   644 	WDF_STD_TOOLTIPS | WDF_STD_BTN | WDF_DEF_WIDGET | WDF_STICKY_BUTTON,
   643 	_build_road_widgets,
   645 	_build_road_widgets,
   644 	BuildRoadToolbWndProc
       
   645 };
   646 };
   646 
   647 
   647 /** Widget definition of the build tram toolbar */
   648 /** Widget definition of the build tram toolbar */
   648 static const Widget _build_tramway_widgets[] = {
   649 static const Widget _build_tramway_widgets[] = {
   649 {   WWT_CLOSEBOX,   RESIZE_NONE,     7,     0,    10,     0,    13, STR_00C5,                       STR_018B_CLOSE_WINDOW},                // RTW_CLOSEBOX
   650 {   WWT_CLOSEBOX,   RESIZE_NONE,     7,     0,    10,     0,    13, STR_00C5,                       STR_018B_CLOSE_WINDOW},                // RTW_CLOSEBOX
   668 static const WindowDesc _build_tramway_desc = {
   669 static const WindowDesc _build_tramway_desc = {
   669 	WDP_ALIGN_TBR, 22, 241, 36, 241, 36,
   670 	WDP_ALIGN_TBR, 22, 241, 36, 241, 36,
   670 	WC_BUILD_TOOLBAR, WC_NONE,
   671 	WC_BUILD_TOOLBAR, WC_NONE,
   671 	WDF_STD_TOOLTIPS | WDF_STD_BTN | WDF_DEF_WIDGET | WDF_STICKY_BUTTON,
   672 	WDF_STD_TOOLTIPS | WDF_STD_BTN | WDF_DEF_WIDGET | WDF_STICKY_BUTTON,
   672 	_build_tramway_widgets,
   673 	_build_tramway_widgets,
   673 	BuildRoadToolbWndProc
       
   674 };
   674 };
   675 
   675 
   676 void ShowBuildRoadToolbar(RoadType roadtype)
   676 void ShowBuildRoadToolbar(RoadType roadtype)
   677 {
   677 {
   678 	if (!IsValidPlayer(_current_player)) return;
   678 	if (!IsValidPlayer(_current_player)) return;
   679 	_cur_roadtype = roadtype;
   679 	_cur_roadtype = roadtype;
   680 
   680 
   681 	DeleteWindowByClass(WC_BUILD_TOOLBAR);
   681 	DeleteWindowByClass(WC_BUILD_TOOLBAR);
   682 	Window *w = AllocateWindowDescFront<Window>(roadtype == ROADTYPE_ROAD ? &_build_road_desc : &_build_tramway_desc, TRANSPORT_ROAD);
   682 	AllocateWindowDescFront<BuildRoadToolbarWindow>(roadtype == ROADTYPE_ROAD ? &_build_road_desc : &_build_tramway_desc, TRANSPORT_ROAD);
   683 	if (_patches.link_terraform_toolbar) ShowTerraformToolbar(w);
       
   684 }
   683 }
   685 
   684 
   686 /** Widget definition of the build road toolbar in the scenario editor */
   685 /** Widget definition of the build road toolbar in the scenario editor */
   687 static const Widget _build_road_scen_widgets[] = {
   686 static const Widget _build_road_scen_widgets[] = {
   688 {   WWT_CLOSEBOX,   RESIZE_NONE,     7,     0,    10,     0,    13, STR_00C5,                   STR_018B_CLOSE_WINDOW},            // RTW_CLOSEBOX
   687 {   WWT_CLOSEBOX,   RESIZE_NONE,     7,     0,    10,     0,    13, STR_00C5,                   STR_018B_CLOSE_WINDOW},            // RTW_CLOSEBOX
   706 static const WindowDesc _build_road_scen_desc = {
   705 static const WindowDesc _build_road_scen_desc = {
   707 	WDP_AUTO, WDP_AUTO, 197, 36, 197, 36,
   706 	WDP_AUTO, WDP_AUTO, 197, 36, 197, 36,
   708 	WC_SCEN_BUILD_ROAD, WC_NONE,
   707 	WC_SCEN_BUILD_ROAD, WC_NONE,
   709 	WDF_STD_TOOLTIPS | WDF_STD_BTN | WDF_DEF_WIDGET | WDF_STICKY_BUTTON,
   708 	WDF_STD_TOOLTIPS | WDF_STD_BTN | WDF_DEF_WIDGET | WDF_STICKY_BUTTON,
   710 	_build_road_scen_widgets,
   709 	_build_road_scen_widgets,
   711 	BuildRoadToolbWndProc
       
   712 };
   710 };
   713 
   711 
   714 void ShowBuildRoadScenToolbar()
   712 void ShowBuildRoadScenToolbar()
   715 {
   713 {
   716 	_cur_roadtype = ROADTYPE_ROAD;
   714 	_cur_roadtype = ROADTYPE_ROAD;
   717 	AllocateWindowDescFront<Window>(&_build_road_scen_desc, 0);
   715 	AllocateWindowDescFront<BuildRoadToolbarWindow>(&_build_road_scen_desc, 0);
   718 }
   716 }
   719 
   717 
   720 /** Enum referring to the widgets of the build road depot window */
   718 struct BuildRoadDepotWindow : public PickerWindowBase {
   721 enum BuildRoadDepotWidgets {
   719 private:
   722 	BRDW_CLOSEBOX = 0,
   720 	/** Enum referring to the widgets of the build road depot window */
   723 	BRDW_CAPTION,
   721 	enum BuildRoadDepotWidgets {
   724 	BRDW_BACKGROUND,
   722 		BRDW_CLOSEBOX = 0,
   725 	BRDW_DEPOT_NE,
   723 		BRDW_CAPTION,
   726 	BRDW_DEPOT_SE,
   724 		BRDW_BACKGROUND,
   727 	BRDW_DEPOT_SW,
   725 		BRDW_DEPOT_NE,
   728 	BRDW_DEPOT_NW,
   726 		BRDW_DEPOT_SE,
   729 };
   727 		BRDW_DEPOT_SW,
   730 
   728 		BRDW_DEPOT_NW,
   731 static void BuildRoadDepotWndProc(Window *w, WindowEvent *e)
   729 	};
   732 {
   730 
   733 	switch (e->event) {
   731 public:
   734 		case WE_CREATE:
   732 	BuildRoadDepotWindow(const WindowDesc *desc) : PickerWindowBase(desc)
   735 			w->LowerWidget(_road_depot_orientation + BRDW_DEPOT_NE);
   733 	{
   736 			break;
   734 		this->LowerWidget(_road_depot_orientation + BRDW_DEPOT_NE);
   737 
   735 		if ( _cur_roadtype == ROADTYPE_TRAM) {
   738 		case WE_PAINT:
   736 			this->widget[BRDW_CAPTION].data = STR_TRAM_DEPOT_ORIENTATION;
   739 			DrawWindowWidgets(w);
   737 			for (int i = BRDW_DEPOT_NE; i <= BRDW_DEPOT_NW; i++) this->widget[i].tooltips = STR_SELECT_TRAM_VEHICLE_DEPOT;
   740 
   738 		}
   741 			DrawRoadDepotSprite(70, 17, DIAGDIR_NE, _cur_roadtype);
   739 		this->FindWindowPlacementAndResize(desc);
   742 			DrawRoadDepotSprite(70, 69, DIAGDIR_SE, _cur_roadtype);
   740 	}
   743 			DrawRoadDepotSprite( 2, 69, DIAGDIR_SW, _cur_roadtype);
   741 
   744 			DrawRoadDepotSprite( 2, 17, DIAGDIR_NW, _cur_roadtype);
   742 	virtual void OnPaint()
   745 			break;
   743 	{
   746 
   744 		this->DrawWidgets();
   747 		case WE_CLICK:
   745 
   748 			switch (e->we.click.widget) {
   746 		DrawRoadDepotSprite(70, 17, DIAGDIR_NE, _cur_roadtype);
   749 				case BRDW_DEPOT_NW:
   747 		DrawRoadDepotSprite(70, 69, DIAGDIR_SE, _cur_roadtype);
   750 				case BRDW_DEPOT_NE:
   748 		DrawRoadDepotSprite( 2, 69, DIAGDIR_SW, _cur_roadtype);
   751 				case BRDW_DEPOT_SW:
   749 		DrawRoadDepotSprite( 2, 17, DIAGDIR_NW, _cur_roadtype);
   752 				case BRDW_DEPOT_SE:
   750 	}
   753 					w->RaiseWidget(_road_depot_orientation + BRDW_DEPOT_NE);
   751 
   754 					_road_depot_orientation = (DiagDirection)(e->we.click.widget - BRDW_DEPOT_NE);
   752 	virtual void OnClick(Point pt, int widget)
   755 					w->LowerWidget(_road_depot_orientation + BRDW_DEPOT_NE);
   753 	{
   756 					SndPlayFx(SND_15_BEEP);
   754 		switch (widget) {
   757 					w->SetDirty();
   755 			case BRDW_DEPOT_NW:
   758 					break;
   756 			case BRDW_DEPOT_NE:
   759 
   757 			case BRDW_DEPOT_SW:
   760 				default:
   758 			case BRDW_DEPOT_SE:
   761 					break;
   759 				this->RaiseWidget(_road_depot_orientation + BRDW_DEPOT_NE);
   762 			}
   760 				_road_depot_orientation = (DiagDirection)(widget - BRDW_DEPOT_NE);
   763 			break;
   761 				this->LowerWidget(_road_depot_orientation + BRDW_DEPOT_NE);
   764 
   762 				SndPlayFx(SND_15_BEEP);
   765 		case WE_TICK:
   763 				this->SetDirty();
   766 			if (WP(w, def_d).close) delete w;
   764 				break;
   767 			break;
   765 
   768 
   766 			default:
   769 		case WE_DESTROY:
   767 				break;
   770 			if (!WP(w, def_d).close) ResetObjectToPlace();
   768 		}
   771 			break;
   769 	}
   772 
   770 };
   773 		default:
       
   774 			break;
       
   775 	}
       
   776 }
       
   777 
   771 
   778 /** Widget definition of the build road depot window */
   772 /** Widget definition of the build road depot window */
   779 static const Widget _build_road_depot_widgets[] = {
   773 static const Widget _build_road_depot_widgets[] = {
   780 {   WWT_CLOSEBOX,   RESIZE_NONE,     7,     0,    10,     0,    13, STR_00C5,                        STR_018B_CLOSE_WINDOW},              // BRDW_CLOSEBOX
   774 {   WWT_CLOSEBOX,   RESIZE_NONE,     7,     0,    10,     0,    13, STR_00C5,                        STR_018B_CLOSE_WINDOW},              // BRDW_CLOSEBOX
   781 {    WWT_CAPTION,   RESIZE_NONE,     7,    11,   139,     0,    13, STR_1806_ROAD_DEPOT_ORIENTATION, STR_018C_WINDOW_TITLE_DRAG_THIS},    // BRDW_CAPTION
   775 {    WWT_CAPTION,   RESIZE_NONE,     7,    11,   139,     0,    13, STR_1806_ROAD_DEPOT_ORIENTATION, STR_018C_WINDOW_TITLE_DRAG_THIS},    // BRDW_CAPTION
   785 {      WWT_PANEL,   RESIZE_NONE,    14,     3,    68,    69,   118, 0x0,                             STR_1813_SELECT_ROAD_VEHICLE_DEPOT}, // BRDW_DEPOT_SW
   779 {      WWT_PANEL,   RESIZE_NONE,    14,     3,    68,    69,   118, 0x0,                             STR_1813_SELECT_ROAD_VEHICLE_DEPOT}, // BRDW_DEPOT_SW
   786 {      WWT_PANEL,   RESIZE_NONE,    14,     3,    68,    17,    66, 0x0,                             STR_1813_SELECT_ROAD_VEHICLE_DEPOT}, // BRDW_DEPOT_NW
   780 {      WWT_PANEL,   RESIZE_NONE,    14,     3,    68,    17,    66, 0x0,                             STR_1813_SELECT_ROAD_VEHICLE_DEPOT}, // BRDW_DEPOT_NW
   787 {   WIDGETS_END},
   781 {   WIDGETS_END},
   788 };
   782 };
   789 
   783 
   790 /** Widget definition of the build tram depot window */
       
   791 static const Widget _build_tram_depot_widgets[] = {
       
   792 {   WWT_CLOSEBOX,   RESIZE_NONE,     7,     0,    10,     0,    13, STR_00C5,                        STR_018B_CLOSE_WINDOW},              // BRDW_CLOSEBOX
       
   793 {    WWT_CAPTION,   RESIZE_NONE,     7,    11,   139,     0,    13, STR_TRAM_DEPOT_ORIENTATION,      STR_018C_WINDOW_TITLE_DRAG_THIS},    // BRDW_CAPTION
       
   794 {      WWT_PANEL,   RESIZE_NONE,     7,     0,   139,    14,   121, 0x0,                             STR_NULL},                           // BRDW_BACKGROUND
       
   795 {      WWT_PANEL,   RESIZE_NONE,    14,    71,   136,    17,    66, 0x0,                             STR_SELECT_TRAM_VEHICLE_DEPOT},      // BRDW_DEPOT_NE
       
   796 {      WWT_PANEL,   RESIZE_NONE,    14,    71,   136,    69,   118, 0x0,                             STR_SELECT_TRAM_VEHICLE_DEPOT},      // BRDW_DEPOT_SE
       
   797 {      WWT_PANEL,   RESIZE_NONE,    14,     3,    68,    69,   118, 0x0,                             STR_SELECT_TRAM_VEHICLE_DEPOT},      // BRDW_DEPOT_SW
       
   798 {      WWT_PANEL,   RESIZE_NONE,    14,     3,    68,    17,    66, 0x0,                             STR_SELECT_TRAM_VEHICLE_DEPOT},      // BRDW_DEPOT_NW
       
   799 {   WIDGETS_END},
       
   800 };
       
   801 
       
   802 static const WindowDesc _build_road_depot_desc = {
   784 static const WindowDesc _build_road_depot_desc = {
   803 	WDP_AUTO, WDP_AUTO, 140, 122, 140, 122,
   785 	WDP_AUTO, WDP_AUTO, 140, 122, 140, 122,
   804 	WC_BUILD_DEPOT, WC_BUILD_TOOLBAR,
   786 	WC_BUILD_DEPOT, WC_BUILD_TOOLBAR,
   805 	WDF_STD_TOOLTIPS | WDF_STD_BTN | WDF_DEF_WIDGET,
   787 	WDF_STD_TOOLTIPS | WDF_STD_BTN | WDF_DEF_WIDGET,
   806 	_build_road_depot_widgets,
   788 	_build_road_depot_widgets,
   807 	BuildRoadDepotWndProc
       
   808 };
       
   809 
       
   810 static const WindowDesc _build_tram_depot_desc = {
       
   811 	WDP_AUTO, WDP_AUTO, 140, 122, 140, 122,
       
   812 	WC_BUILD_DEPOT, WC_BUILD_TOOLBAR,
       
   813 	WDF_STD_TOOLTIPS | WDF_STD_BTN | WDF_DEF_WIDGET,
       
   814 	_build_tram_depot_widgets,
       
   815 	BuildRoadDepotWndProc
       
   816 };
   789 };
   817 
   790 
   818 static void ShowRoadDepotPicker()
   791 static void ShowRoadDepotPicker()
   819 {
   792 {
   820 	new Window(_cur_roadtype == ROADTYPE_ROAD ? &_build_road_depot_desc : &_build_tram_depot_desc);
   793 	new BuildRoadDepotWindow(&_build_road_depot_desc);
   821 }
   794 }
   822 
   795 
   823 /** Enum referring to the widgets of the build road station window */
   796 struct BuildRoadStationWindow : public PickerWindowBase {
   824 enum BuildRoadStationWidgets {
   797 private:
   825 	BRSW_CLOSEBOX = 0,
   798 	/** Enum referring to the widgets of the build road station window */
   826 	BRSW_CAPTION,
   799 	enum BuildRoadStationWidgets {
   827 	BRSW_BACKGROUND,
   800 		BRSW_CLOSEBOX = 0,
   828 	BRSW_STATION_NE,
   801 		BRSW_CAPTION,
   829 	BRSW_STATION_SE,
   802 		BRSW_BACKGROUND,
   830 	BRSW_STATION_SW,
   803 		BRSW_STATION_NE,
   831 	BRSW_STATION_NW,
   804 		BRSW_STATION_SE,
   832 	BRSW_STATION_X,
   805 		BRSW_STATION_SW,
   833 	BRSW_STATION_Y,
   806 		BRSW_STATION_NW,
   834 	BRSW_LT_OFF,
   807 		BRSW_STATION_X,
   835 	BRSW_LT_ON,
   808 		BRSW_STATION_Y,
   836 	BRSW_INFO,
   809 		BRSW_LT_OFF,
   837 };
   810 		BRSW_LT_ON,
   838 
   811 		BRSW_INFO,
   839 static void RoadStationPickerWndProc(Window *w, WindowEvent *e)
   812 	};
   840 {
   813 
   841 	switch (e->event) {
   814 public:
   842 		case WE_CREATE:
   815 	BuildRoadStationWindow(const WindowDesc *desc, RoadStopType rs) : PickerWindowBase(desc)
   843 			/* Trams don't have non-drivethrough stations */
   816 	{
   844 			if (_cur_roadtype == ROADTYPE_TRAM && _road_station_picker_orientation < DIAGDIR_END) {
   817 		/* Trams don't have non-drivethrough stations */
   845 				_road_station_picker_orientation = DIAGDIR_END;
   818 		if (_cur_roadtype == ROADTYPE_TRAM && _road_station_picker_orientation < DIAGDIR_END) {
   846 			}
   819 			_road_station_picker_orientation = DIAGDIR_END;
   847 			w->SetWidgetsDisabledState(_cur_roadtype == ROADTYPE_TRAM,
   820 		}
   848 				BRSW_STATION_NE,
   821 		this->SetWidgetsDisabledState(_cur_roadtype == ROADTYPE_TRAM,
   849 				BRSW_STATION_SE,
   822 			BRSW_STATION_NE,
   850 				BRSW_STATION_SW,
   823 			BRSW_STATION_SE,
   851 				BRSW_STATION_NW,
   824 			BRSW_STATION_SW,
   852 				WIDGET_LIST_END);
   825 			BRSW_STATION_NW,
   853 
   826 			WIDGET_LIST_END);
   854 			w->LowerWidget(_road_station_picker_orientation + BRSW_STATION_NE);
   827 
   855 			w->LowerWidget(_station_show_coverage + BRSW_LT_OFF);
   828 		this->window_class = (rs == ROADSTOP_BUS) ? WC_BUS_STATION : WC_TRUCK_STATION;
   856 			break;
   829 		this->widget[BRSW_CAPTION].data = _road_type_infos[_cur_roadtype].picker_title[rs];
   857 
   830 		for (uint i = BRSW_STATION_NE; i < BRSW_LT_OFF; i++) this->widget[i].tooltips = _road_type_infos[_cur_roadtype].picker_tooltip[rs];
   858 		case WE_PAINT: {
   831 
   859 			if (WP(w, def_d).close) return;
   832 		this->LowerWidget(_road_station_picker_orientation + BRSW_STATION_NE);
   860 
   833 		this->LowerWidget(_station_show_coverage + BRSW_LT_OFF);
   861 			DrawWindowWidgets(w);
   834 		this->FindWindowPlacementAndResize(desc);
   862 
   835 	}
   863 			if (_station_show_coverage) {
   836 
   864 				int rad = _patches.modified_catchment ? CA_TRUCK /* = CA_BUS */ : CA_UNMODIFIED;
   837 	virtual void OnPaint()
   865 				SetTileSelectBigSize(-rad, -rad, 2 * rad, 2 * rad);
   838 	{
   866 			} else {
   839 		this->DrawWidgets();
   867 				SetTileSelectSize(1, 1);
   840 
   868 			}
   841 		if (_station_show_coverage) {
   869 
   842 			int rad = _patches.modified_catchment ? CA_TRUCK /* = CA_BUS */ : CA_UNMODIFIED;
   870 			StationType st = (w->window_class == WC_BUS_STATION) ? STATION_BUS : STATION_TRUCK;
   843 			SetTileSelectBigSize(-rad, -rad, 2 * rad, 2 * rad);
   871 
   844 		} else {
   872 			StationPickerDrawSprite(103, 35, st, INVALID_RAILTYPE, ROADTYPE_ROAD, 0);
   845 			SetTileSelectSize(1, 1);
   873 			StationPickerDrawSprite(103, 85, st, INVALID_RAILTYPE, ROADTYPE_ROAD, 1);
   846 		}
   874 			StationPickerDrawSprite( 35, 85, st, INVALID_RAILTYPE, ROADTYPE_ROAD, 2);
   847 
   875 			StationPickerDrawSprite( 35, 35, st, INVALID_RAILTYPE, ROADTYPE_ROAD, 3);
   848 		StationType st = (this->window_class == WC_BUS_STATION) ? STATION_BUS : STATION_TRUCK;
   876 
   849 
   877 			StationPickerDrawSprite(171, 35, st, INVALID_RAILTYPE, _cur_roadtype, 4);
   850 		StationPickerDrawSprite(103, 35, st, INVALID_RAILTYPE, ROADTYPE_ROAD, 0);
   878 			StationPickerDrawSprite(171, 85, st, INVALID_RAILTYPE, _cur_roadtype, 5);
   851 		StationPickerDrawSprite(103, 85, st, INVALID_RAILTYPE, ROADTYPE_ROAD, 1);
   879 
   852 		StationPickerDrawSprite( 35, 85, st, INVALID_RAILTYPE, ROADTYPE_ROAD, 2);
   880 			int text_end = DrawStationCoverageAreaText(2, 146,
   853 		StationPickerDrawSprite( 35, 35, st, INVALID_RAILTYPE, ROADTYPE_ROAD, 3);
   881 				(w->window_class == WC_BUS_STATION) ? SCT_PASSENGERS_ONLY : SCT_NON_PASSENGERS_ONLY,
   854 
   882 				3, false);
   855 		StationPickerDrawSprite(171, 35, st, INVALID_RAILTYPE, _cur_roadtype, 4);
   883 			text_end = DrawStationCoverageAreaText(2, text_end + 4,
   856 		StationPickerDrawSprite(171, 85, st, INVALID_RAILTYPE, _cur_roadtype, 5);
   884 				(w->window_class == WC_BUS_STATION) ? SCT_PASSENGERS_ONLY : SCT_NON_PASSENGERS_ONLY,
   857 
   885 				3, true) + 4;
   858 		int text_end = DrawStationCoverageAreaText(2, 146,
   886 			if (text_end > w->widget[BRSW_BACKGROUND].bottom) {
   859 			(this->window_class == WC_BUS_STATION) ? SCT_PASSENGERS_ONLY : SCT_NON_PASSENGERS_ONLY,
   887 				w->SetDirty();
   860 			3, false);
   888 				ResizeWindowForWidget(w, BRSW_BACKGROUND, 0, text_end - w->widget[BRSW_BACKGROUND].bottom);
   861 		text_end = DrawStationCoverageAreaText(2, text_end + 4,
   889 				w->SetDirty();
   862 			(this->window_class == WC_BUS_STATION) ? SCT_PASSENGERS_ONLY : SCT_NON_PASSENGERS_ONLY,
   890 			}
   863 			3, true) + 4;
   891 		} break;
   864 		if (text_end > this->widget[BRSW_BACKGROUND].bottom) {
   892 
   865 			this->SetDirty();
   893 		case WE_CLICK:
   866 			ResizeWindowForWidget(this, BRSW_BACKGROUND, 0, text_end - this->widget[BRSW_BACKGROUND].bottom);
   894 			switch (e->we.click.widget) {
   867 			this->SetDirty();
   895 				case BRSW_STATION_NE:
   868 		}
   896 				case BRSW_STATION_SE:
   869 	}
   897 				case BRSW_STATION_SW:
   870 
   898 				case BRSW_STATION_NW:
   871 	virtual void OnClick(Point pt, int widget)
   899 				case BRSW_STATION_X:
   872 	{
   900 				case BRSW_STATION_Y:
   873 		switch (widget) {
   901 					w->RaiseWidget(_road_station_picker_orientation + BRSW_STATION_NE);
   874 			case BRSW_STATION_NE:
   902 					_road_station_picker_orientation = (DiagDirection)(e->we.click.widget - BRSW_STATION_NE);
   875 			case BRSW_STATION_SE:
   903 					w->LowerWidget(_road_station_picker_orientation + BRSW_STATION_NE);
   876 			case BRSW_STATION_SW:
   904 					SndPlayFx(SND_15_BEEP);
   877 			case BRSW_STATION_NW:
   905 					w->SetDirty();
   878 			case BRSW_STATION_X:
   906 					break;
   879 			case BRSW_STATION_Y:
   907 
   880 				this->RaiseWidget(_road_station_picker_orientation + BRSW_STATION_NE);
   908 				case BRSW_LT_OFF:
   881 				_road_station_picker_orientation = (DiagDirection)(widget - BRSW_STATION_NE);
   909 				case BRSW_LT_ON:
   882 				this->LowerWidget(_road_station_picker_orientation + BRSW_STATION_NE);
   910 					w->RaiseWidget(_station_show_coverage + BRSW_LT_OFF);
   883 				SndPlayFx(SND_15_BEEP);
   911 					_station_show_coverage = (e->we.click.widget != BRSW_LT_OFF);
   884 				this->SetDirty();
   912 					w->LowerWidget(_station_show_coverage + BRSW_LT_OFF);
   885 				break;
   913 					SndPlayFx(SND_15_BEEP);
   886 
   914 					w->SetDirty();
   887 			case BRSW_LT_OFF:
   915 					break;
   888 			case BRSW_LT_ON:
   916 
   889 				this->RaiseWidget(_station_show_coverage + BRSW_LT_OFF);
   917 				default:
   890 				_station_show_coverage = (widget != BRSW_LT_OFF);
   918 					break;
   891 				this->LowerWidget(_station_show_coverage + BRSW_LT_OFF);
   919 			}
   892 				SndPlayFx(SND_15_BEEP);
   920 			break;
   893 				this->SetDirty();
   921 
   894 				break;
   922 		case WE_TICK:
   895 
   923 			if (WP(w, def_d).close) {
   896 			default:
   924 				delete w;
   897 				break;
   925 				return;
   898 		}
   926 			}
   899 	}
   927 
   900 
   928 			CheckRedrawStationCoverage(w);
   901 	virtual void OnTick()
   929 			break;
   902 	{
   930 
   903 		CheckRedrawStationCoverage(this);
   931 		case WE_DESTROY:
   904 	}
   932 			if (!WP(w, def_d).close) ResetObjectToPlace();
   905 };
   933 			break;
       
   934 
       
   935 		default:
       
   936 			break;
       
   937 	}
       
   938 }
       
   939 
   906 
   940 /** Widget definition of the build raod station window */
   907 /** Widget definition of the build raod station window */
   941 static const Widget _rv_station_picker_widgets[] = {
   908 static const Widget _rv_station_picker_widgets[] = {
   942 {   WWT_CLOSEBOX,   RESIZE_NONE,     7,     0,    10,     0,    13, STR_00C5,                         STR_018B_CLOSE_WINDOW},             // BRSW_CLOSEBOX
   909 {   WWT_CLOSEBOX,   RESIZE_NONE,     7,     0,    10,     0,    13, STR_00C5,                         STR_018B_CLOSE_WINDOW},             // BRSW_CLOSEBOX
   943 {    WWT_CAPTION,   RESIZE_NONE,     7,    11,   206,     0,    13, STR_NULL,                         STR_018C_WINDOW_TITLE_DRAG_THIS},   // BRSW_CAPTION
   910 {    WWT_CAPTION,   RESIZE_NONE,     7,    11,   206,     0,    13, STR_NULL,                         STR_018C_WINDOW_TITLE_DRAG_THIS},   // BRSW_CAPTION
   959 static const WindowDesc _rv_station_picker_desc = {
   926 static const WindowDesc _rv_station_picker_desc = {
   960 	WDP_AUTO, WDP_AUTO, 207, 177, 207, 177,
   927 	WDP_AUTO, WDP_AUTO, 207, 177, 207, 177,
   961 	WC_BUS_STATION, WC_BUILD_TOOLBAR,
   928 	WC_BUS_STATION, WC_BUILD_TOOLBAR,
   962 	WDF_STD_TOOLTIPS | WDF_STD_BTN | WDF_DEF_WIDGET,
   929 	WDF_STD_TOOLTIPS | WDF_STD_BTN | WDF_DEF_WIDGET,
   963 	_rv_station_picker_widgets,
   930 	_rv_station_picker_widgets,
   964 	RoadStationPickerWndProc
       
   965 };
   931 };
   966 
   932 
   967 static void ShowRVStationPicker(RoadStopType rs)
   933 static void ShowRVStationPicker(RoadStopType rs)
   968 {
   934 {
   969 	Window *w = new Window(&_rv_station_picker_desc);
   935 	new BuildRoadStationWindow(&_rv_station_picker_desc, rs);
   970 	if (w == NULL) return;
       
   971 
       
   972 	w->window_class = (rs == ROADSTOP_BUS) ? WC_BUS_STATION : WC_TRUCK_STATION;
       
   973 	w->widget[BRSW_CAPTION].data = _road_type_infos[_cur_roadtype].picker_title[rs];
       
   974 	for (uint i = BRSW_STATION_NE; i < BRSW_LT_OFF; i++) w->widget[i].tooltips = _road_type_infos[_cur_roadtype].picker_tooltip[rs];
       
   975 }
   936 }
   976 
   937 
   977 void InitializeRoadGui()
   938 void InitializeRoadGui()
   978 {
   939 {
   979 	_road_depot_orientation = DIAGDIR_NW;
   940 	_road_depot_orientation = DIAGDIR_NW;