OpenTTD
road_gui.cpp
Go to the documentation of this file.
1 /* $Id$ */
2 
3 /*
4  * This file is part of OpenTTD.
5  * OpenTTD is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, version 2.
6  * OpenTTD is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
7  * See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with OpenTTD. If not, see <http://www.gnu.org/licenses/>.
8  */
9 
12 #include "stdafx.h"
13 #include "gui.h"
14 #include "window_gui.h"
15 #include "station_gui.h"
16 #include "terraform_gui.h"
17 #include "viewport_func.h"
18 #include "command_func.h"
19 #include "road_cmd.h"
20 #include "station_func.h"
21 #include "window_func.h"
22 #include "vehicle_func.h"
23 #include "sound_func.h"
24 #include "company_func.h"
25 #include "tunnelbridge.h"
26 #include "tunnelbridge_map.h"
27 #include "tilehighlight_func.h"
28 #include "company_base.h"
29 #include "hotkeys.h"
30 #include "road_gui.h"
31 #include "zoom_func.h"
32 
33 #include "widgets/road_widget.h"
34 
35 #include "table/strings.h"
36 
37 #include "safeguards.h"
38 
39 static void ShowRVStationPicker(Window *parent, RoadStopType rs);
40 static void ShowRoadDepotPicker(Window *parent);
41 
42 static bool _remove_button_clicked;
43 static bool _one_way_button_clicked;
44 
49 enum RoadFlags {
50  RF_NONE = 0x00,
51  RF_START_HALFROAD_Y = 0x01, // The start tile in Y-dir should have only a half road
52  RF_END_HALFROAD_Y = 0x02, // The end tile in Y-dir should have only a half road
53  RF_DIR_Y = 0x04, // The direction is Y-dir
54  RF_DIR_X = RF_NONE, // Dummy; Dir X is set when RF_DIR_Y is not set
55  RF_START_HALFROAD_X = 0x08, // The start tile in X-dir should have only a half road
56  RF_END_HALFROAD_X = 0x10, // The end tile in X-dir should have only a half road
57 };
59 
60 static RoadFlags _place_road_flag;
61 
62 static RoadType _cur_roadtype;
63 
64 static DiagDirection _road_depot_orientation;
65 static DiagDirection _road_station_picker_orientation;
66 
67 void CcPlaySound_SPLAT_OTHER(const CommandCost &result, TileIndex tile, uint32 p1, uint32 p2, uint32 cmd)
68 {
69  if (result.Succeeded() && _settings_client.sound.confirm) SndPlayTileFx(SND_1F_SPLAT_OTHER, tile);
70 }
71 
76 static void PlaceRoad_Bridge(TileIndex tile, Window *w)
77 {
78  if (IsBridgeTile(tile)) {
79  TileIndex other_tile = GetOtherTunnelBridgeEnd(tile);
80  Point pt = {0, 0};
81  w->OnPlaceMouseUp(VPM_X_OR_Y, DDSP_BUILD_BRIDGE, pt, other_tile, tile);
82  } else {
84  }
85 }
86 
97 void CcBuildRoadTunnel(const CommandCost &result, TileIndex start_tile, uint32 p1, uint32 p2, uint32 cmd)
98 {
99  if (result.Succeeded()) {
100  if (_settings_client.sound.confirm) SndPlayTileFx(SND_1F_SPLAT_OTHER, start_tile);
102 
103  DiagDirection start_direction = ReverseDiagDir(GetTunnelBridgeDirection(start_tile));
104  ConnectRoadToStructure(start_tile, start_direction);
105 
106  TileIndex end_tile = GetOtherTunnelBridgeEnd(start_tile);
107  DiagDirection end_direction = ReverseDiagDir(GetTunnelBridgeDirection(end_tile));
108  ConnectRoadToStructure(end_tile, end_direction);
109  } else {
111  }
112 }
113 
115 struct RoadTypeInfo {
121 
124 
128 };
129 
131 static const RoadTypeInfo _road_type_infos[] = {
132  {
133  STR_ERROR_CAN_T_BUILD_ROAD_HERE,
134  STR_ERROR_CAN_T_REMOVE_ROAD_FROM,
135  STR_ERROR_CAN_T_BUILD_ROAD_DEPOT,
136  { STR_ERROR_CAN_T_BUILD_BUS_STATION, STR_ERROR_CAN_T_BUILD_TRUCK_STATION },
137  { STR_ERROR_CAN_T_REMOVE_BUS_STATION, STR_ERROR_CAN_T_REMOVE_TRUCK_STATION },
138  { STR_STATION_BUILD_BUS_ORIENTATION, STR_STATION_BUILD_TRUCK_ORIENTATION },
139  { STR_STATION_BUILD_BUS_ORIENTATION_TOOLTIP, STR_STATION_BUILD_TRUCK_ORIENTATION_TOOLTIP },
140 
141  SPR_CURSOR_ROAD_NESW,
142  SPR_CURSOR_ROAD_NWSE,
143  SPR_CURSOR_AUTOROAD,
144  },
145  {
146  STR_ERROR_CAN_T_BUILD_TRAMWAY_HERE,
147  STR_ERROR_CAN_T_REMOVE_TRAMWAY_FROM,
148  STR_ERROR_CAN_T_BUILD_TRAM_DEPOT,
149  { STR_ERROR_CAN_T_BUILD_PASSENGER_TRAM_STATION, STR_ERROR_CAN_T_BUILD_CARGO_TRAM_STATION },
150  { STR_ERROR_CAN_T_REMOVE_PASSENGER_TRAM_STATION, STR_ERROR_CAN_T_REMOVE_CARGO_TRAM_STATION },
151  { STR_STATION_BUILD_PASSENGER_TRAM_ORIENTATION, STR_STATION_BUILD_CARGO_TRAM_ORIENTATION },
152  { STR_STATION_BUILD_PASSENGER_TRAM_ORIENTATION_TOOLTIP, STR_STATION_BUILD_CARGO_TRAM_ORIENTATION_TOOLTIP },
153 
154  SPR_CURSOR_TRAMWAY_NESW,
155  SPR_CURSOR_TRAMWAY_NWSE,
156  SPR_CURSOR_AUTOTRAM,
157  },
158 };
159 
166 {
167  tile += TileOffsByDiagDir(direction);
168  /* if there is a roadpiece just outside of the station entrance, build a connecting route */
169  if (IsNormalRoadTile(tile)) {
170  if (GetRoadBits(tile, _cur_roadtype) != ROAD_NONE) {
171  DoCommandP(tile, _cur_roadtype << 4 | DiagDirToRoadBits(ReverseDiagDir(direction)), 0, CMD_BUILD_ROAD);
172  }
173  }
174 }
175 
176 void CcRoadDepot(const CommandCost &result, TileIndex tile, uint32 p1, uint32 p2, uint32 cmd)
177 {
178  if (result.Failed()) return;
179 
180  DiagDirection dir = (DiagDirection)GB(p1, 0, 2);
181  if (_settings_client.sound.confirm) SndPlayTileFx(SND_1F_SPLAT_OTHER, tile);
183  ConnectRoadToStructure(tile, dir);
184 }
185 
201 void CcRoadStop(const CommandCost &result, TileIndex tile, uint32 p1, uint32 p2, uint32 cmd)
202 {
203  if (result.Failed()) return;
204 
205  DiagDirection dir = (DiagDirection)GB(p2, 6, 2);
206  if (_settings_client.sound.confirm) SndPlayTileFx(SND_1F_SPLAT_OTHER, tile);
208  TileArea roadstop_area(tile, GB(p1, 0, 8), GB(p1, 8, 8));
209  TILE_AREA_LOOP(cur_tile, roadstop_area) {
210  ConnectRoadToStructure(cur_tile, dir);
211  /* For a drive-through road stop build connecting road for other entrance. */
212  if (HasBit(p2, 1)) ConnectRoadToStructure(cur_tile, ReverseDiagDir(dir));
213  }
214 }
215 
226 static void PlaceRoadStop(TileIndex start_tile, TileIndex end_tile, uint32 p2, uint32 cmd)
227 {
228  uint8 ddir = _road_station_picker_orientation;
229  SB(p2, 16, 16, INVALID_STATION); // no station to join
230 
231  if (ddir >= DIAGDIR_END) {
232  SetBit(p2, 1); // It's a drive-through stop.
233  ddir -= DIAGDIR_END; // Adjust picker result to actual direction.
234  }
235  p2 |= ddir << 6; // Set the DiagDirecion into p2 bits 6 and 7.
236 
237  TileArea ta(start_tile, end_tile);
238  CommandContainer cmdcont = { ta.tile, (uint32)(ta.w | ta.h << 8), p2, cmd, CcRoadStop, "" };
239  ShowSelectStationIfNeeded(cmdcont, ta);
240 }
241 
247 {
250  } else {
251  if (_road_station_picker_orientation < DIAGDIR_END) { // Not a drive-through stop.
252  VpStartPlaceSizing(tile, (DiagDirToAxis(_road_station_picker_orientation) == AXIS_X) ? VPM_X_LIMITED : VPM_Y_LIMITED, DDSP_BUILD_BUSSTOP);
253  } else {
255  }
256  VpSetPlaceSizingLimit(_settings_game.station.station_spread);
257  }
258 }
259 
265 {
268  } else {
269  if (_road_station_picker_orientation < DIAGDIR_END) { // Not a drive-through stop.
270  VpStartPlaceSizing(tile, (DiagDirToAxis(_road_station_picker_orientation) == AXIS_X) ? VPM_X_LIMITED : VPM_Y_LIMITED, DDSP_BUILD_TRUCKSTOP);
271  } else {
273  }
274  VpSetPlaceSizingLimit(_settings_game.station.station_spread);
275  }
276 }
277 
278 typedef void OnButtonClick(Window *w);
279 
285 {
289  SetSelectionRed(_remove_button_clicked);
290 }
291 
298 {
299  if (w->IsWidgetDisabled(WID_ROT_REMOVE)) return false;
300 
301  /* allow ctrl to switch remove mode only for these widgets */
302  for (uint i = WID_ROT_ROAD_X; i <= WID_ROT_AUTOROAD; i++) {
303  if (w->IsWidgetLowered(i)) {
305  return true;
306  }
307  }
308 
309  return false;
310 }
311 
315 
316  BuildRoadToolbarWindow(WindowDesc *desc, WindowNumber window_number) : Window(desc)
317  {
318  this->InitNested(window_number);
319  this->SetWidgetsDisabledState(true,
323 
324  this->OnInvalidateData();
325  this->last_started_action = WIDGET_LIST_END;
326 
328  }
329 
331  {
333  }
334 
340  virtual void OnInvalidateData(int data = 0, bool gui_scope = true)
341  {
342  if (!gui_scope) return;
343 
344  bool can_build = CanBuildVehicleInfrastructure(VEH_ROAD);
345  this->SetWidgetsDisabledState(!can_build,
350  if (!can_build) {
354  }
355  }
356 
363  {
364  /* The remove and the one way button state is driven
365  * by the other buttons so they don't act on themselves.
366  * Both are only valid if they are able to apply as options. */
367  switch (clicked_widget) {
368  case WID_ROT_REMOVE:
369  this->RaiseWidget(WID_ROT_ONE_WAY);
370  this->SetWidgetDirty(WID_ROT_ONE_WAY);
371  break;
372 
373  case WID_ROT_ONE_WAY:
374  this->RaiseWidget(WID_ROT_REMOVE);
375  this->SetWidgetDirty(WID_ROT_REMOVE);
376  break;
377 
378  case WID_ROT_BUS_STATION:
380  this->DisableWidget(WID_ROT_ONE_WAY);
381  this->SetWidgetDisabledState(WID_ROT_REMOVE, !this->IsWidgetLowered(clicked_widget));
382  break;
383 
384  case WID_ROT_ROAD_X:
385  case WID_ROT_ROAD_Y:
386  case WID_ROT_AUTOROAD:
387  this->SetWidgetsDisabledState(!this->IsWidgetLowered(clicked_widget),
391  break;
392 
393  default:
394  /* When any other buttons than road/station, raise and
395  * disable the removal button */
396  this->SetWidgetsDisabledState(true,
400  this->SetWidgetsLoweredState(false,
404  break;
405  }
406  }
407 
408  virtual void OnClick(Point pt, int widget, int click_count)
409  {
410  _remove_button_clicked = false;
411  _one_way_button_clicked = false;
412  switch (widget) {
413  case WID_ROT_ROAD_X:
414  HandlePlacePushButton(this, WID_ROT_ROAD_X, _road_type_infos[_cur_roadtype].cursor_nwse, HT_RECT);
415  this->last_started_action = widget;
416  break;
417 
418  case WID_ROT_ROAD_Y:
419  HandlePlacePushButton(this, WID_ROT_ROAD_Y, _road_type_infos[_cur_roadtype].cursor_nesw, HT_RECT);
420  this->last_started_action = widget;
421  break;
422 
423  case WID_ROT_AUTOROAD:
424  HandlePlacePushButton(this, WID_ROT_AUTOROAD, _road_type_infos[_cur_roadtype].cursor_autoroad, HT_RECT);
425  this->last_started_action = widget;
426  break;
427 
428  case WID_ROT_DEMOLISH:
430  this->last_started_action = widget;
431  break;
432 
433  case WID_ROT_DEPOT:
434  if (_game_mode == GM_EDITOR || !CanBuildVehicleInfrastructure(VEH_ROAD)) return;
435  if (HandlePlacePushButton(this, WID_ROT_DEPOT, SPR_CURSOR_ROAD_DEPOT, HT_RECT)) {
436  ShowRoadDepotPicker(this);
437  this->last_started_action = widget;
438  }
439  break;
440 
441  case WID_ROT_BUS_STATION:
442  if (_game_mode == GM_EDITOR || !CanBuildVehicleInfrastructure(VEH_ROAD)) return;
443  if (HandlePlacePushButton(this, WID_ROT_BUS_STATION, SPR_CURSOR_BUS_STATION, HT_RECT)) {
444  ShowRVStationPicker(this, ROADSTOP_BUS);
445  this->last_started_action = widget;
446  }
447  break;
448 
450  if (_game_mode == GM_EDITOR || !CanBuildVehicleInfrastructure(VEH_ROAD)) return;
451  if (HandlePlacePushButton(this, WID_ROT_TRUCK_STATION, SPR_CURSOR_TRUCK_STATION, HT_RECT)) {
452  ShowRVStationPicker(this, ROADSTOP_TRUCK);
453  this->last_started_action = widget;
454  }
455  break;
456 
457  case WID_ROT_ONE_WAY:
458  if (this->IsWidgetDisabled(WID_ROT_ONE_WAY)) return;
459  this->SetDirty();
460  this->ToggleWidgetLoweredState(WID_ROT_ONE_WAY);
461  SetSelectionRed(false);
462  break;
463 
465  HandlePlacePushButton(this, WID_ROT_BUILD_BRIDGE, SPR_CURSOR_BRIDGE, HT_RECT);
466  this->last_started_action = widget;
467  break;
468 
470  HandlePlacePushButton(this, WID_ROT_BUILD_TUNNEL, SPR_CURSOR_ROAD_TUNNEL, HT_SPECIAL);
471  this->last_started_action = widget;
472  break;
473 
474  case WID_ROT_REMOVE:
475  if (this->IsWidgetDisabled(WID_ROT_REMOVE)) return;
476 
479  if (_settings_client.sound.click_beep) SndPlayFx(SND_15_BEEP);
480  break;
481 
482  default: NOT_REACHED();
483  }
484  this->UpdateOptionWidgetStatus((RoadToolbarWidgets)widget);
486  }
487 
488  virtual EventState OnHotkey(int hotkey)
489  {
490  MarkTileDirtyByTile(TileVirtXY(_thd.pos.x, _thd.pos.y)); // redraw tile selection
491  return Window::OnHotkey(hotkey);
492  }
493 
494  virtual void OnPlaceObject(Point pt, TileIndex tile)
495  {
496  _remove_button_clicked = this->IsWidgetLowered(WID_ROT_REMOVE);
497  _one_way_button_clicked = this->IsWidgetLowered(WID_ROT_ONE_WAY);
498  switch (this->last_started_action) {
499  case WID_ROT_ROAD_X:
500  _place_road_flag = RF_DIR_X;
501  if (_tile_fract_coords.x >= 8) _place_road_flag |= RF_START_HALFROAD_X;
503  break;
504 
505  case WID_ROT_ROAD_Y:
506  _place_road_flag = RF_DIR_Y;
507  if (_tile_fract_coords.y >= 8) _place_road_flag |= RF_START_HALFROAD_Y;
509  break;
510 
511  case WID_ROT_AUTOROAD:
512  _place_road_flag = RF_NONE;
513  if (_tile_fract_coords.x >= 8) _place_road_flag |= RF_START_HALFROAD_X;
514  if (_tile_fract_coords.y >= 8) _place_road_flag |= RF_START_HALFROAD_Y;
516  break;
517 
518  case WID_ROT_DEMOLISH:
520  break;
521 
522  case WID_ROT_DEPOT:
523  DoCommandP(tile, _cur_roadtype << 2 | _road_depot_orientation, 0,
524  CMD_BUILD_ROAD_DEPOT | CMD_MSG(_road_type_infos[_cur_roadtype].err_depot), CcRoadDepot);
525  break;
526 
527  case WID_ROT_BUS_STATION:
528  PlaceRoad_BusStation(tile);
529  break;
530 
533  break;
534 
536  PlaceRoad_Bridge(tile, this);
537  break;
538 
540  DoCommandP(tile, RoadTypeToRoadTypes(_cur_roadtype) | (TRANSPORT_ROAD << 8), 0,
541  CMD_BUILD_TUNNEL | CMD_MSG(STR_ERROR_CAN_T_BUILD_TUNNEL_HERE), CcBuildRoadTunnel);
542  break;
543 
544  default: NOT_REACHED();
545  }
546  }
547 
548  virtual void OnPlaceObjectAbort()
549  {
550  this->RaiseButtons();
551  this->SetWidgetsDisabledState(true,
555  this->SetWidgetDirty(WID_ROT_REMOVE);
556  this->SetWidgetDirty(WID_ROT_ONE_WAY);
557 
563  }
564 
565  virtual void OnPlaceDrag(ViewportPlaceMethod select_method, ViewportDragDropSelectionProcess select_proc, Point pt)
566  {
567  /* Here we update the end tile flags
568  * of the road placement actions.
569  * At first we reset the end halfroad
570  * bits and if needed we set them again. */
571  switch (select_proc) {
573  _place_road_flag &= ~RF_END_HALFROAD_X;
574  if (pt.x & 8) _place_road_flag |= RF_END_HALFROAD_X;
575  break;
576 
578  _place_road_flag &= ~RF_END_HALFROAD_Y;
579  if (pt.y & 8) _place_road_flag |= RF_END_HALFROAD_Y;
580  break;
581 
582  case DDSP_PLACE_AUTOROAD:
583  _place_road_flag &= ~(RF_END_HALFROAD_Y | RF_END_HALFROAD_X);
584  if (pt.y & 8) _place_road_flag |= RF_END_HALFROAD_Y;
585  if (pt.x & 8) _place_road_flag |= RF_END_HALFROAD_X;
586 
587  /* For autoroad we need to update the
588  * direction of the road */
589  if (_thd.size.x > _thd.size.y || (_thd.size.x == _thd.size.y &&
590  ( (_tile_fract_coords.x < _tile_fract_coords.y && (_tile_fract_coords.x + _tile_fract_coords.y) < 16) ||
591  (_tile_fract_coords.x > _tile_fract_coords.y && (_tile_fract_coords.x + _tile_fract_coords.y) > 16) ))) {
592  /* Set dir = X */
593  _place_road_flag &= ~RF_DIR_Y;
594  } else {
595  /* Set dir = Y */
596  _place_road_flag |= RF_DIR_Y;
597  }
598 
599  break;
600 
601  default:
602  break;
603  }
604 
605  VpSelectTilesWithMethod(pt.x, pt.y, select_method);
606  }
607 
608  virtual void OnPlaceMouseUp(ViewportPlaceMethod select_method, ViewportDragDropSelectionProcess select_proc, Point pt, TileIndex start_tile, TileIndex end_tile)
609  {
610  if (pt.x != -1) {
611  switch (select_proc) {
612  default: NOT_REACHED();
613  case DDSP_BUILD_BRIDGE:
615  ShowBuildBridgeWindow(start_tile, end_tile, TRANSPORT_ROAD, RoadTypeToRoadTypes(_cur_roadtype));
616  break;
617 
618  case DDSP_DEMOLISH_AREA:
619  GUIPlaceProcDragXY(select_proc, start_tile, end_tile);
620  break;
621 
624  case DDSP_PLACE_AUTOROAD:
625  /* Flag description:
626  * Use the first three bits (0x07) if dir == Y
627  * else use the last 2 bits (X dir has
628  * not the 3rd bit set) */
629  _place_road_flag = (RoadFlags)((_place_road_flag & RF_DIR_Y) ? (_place_road_flag & 0x07) : (_place_road_flag >> 3));
630 
631  DoCommandP(start_tile, end_tile, _place_road_flag | (_cur_roadtype << 3) | (_one_way_button_clicked << 5),
633  CMD_REMOVE_LONG_ROAD | CMD_MSG(_road_type_infos[_cur_roadtype].err_remove_road) :
634  CMD_BUILD_LONG_ROAD | CMD_MSG(_road_type_infos[_cur_roadtype].err_build_road), CcPlaySound_SPLAT_OTHER);
635  break;
636 
637  case DDSP_BUILD_BUSSTOP:
638  case DDSP_REMOVE_BUSSTOP:
639  if (this->IsWidgetLowered(WID_ROT_BUS_STATION)) {
641  TileArea ta(start_tile, end_tile);
642  DoCommandP(ta.tile, ta.w | ta.h << 8, (_ctrl_pressed << 1) | ROADSTOP_BUS, CMD_REMOVE_ROAD_STOP | CMD_MSG(_road_type_infos[_cur_roadtype].err_remove_station[ROADSTOP_BUS]), CcPlaySound_SPLAT_OTHER);
643  } else {
644  PlaceRoadStop(start_tile, end_tile, (_ctrl_pressed << 5) | RoadTypeToRoadTypes(_cur_roadtype) << 2 | ROADSTOP_BUS, CMD_BUILD_ROAD_STOP | CMD_MSG(_road_type_infos[_cur_roadtype].err_build_station[ROADSTOP_BUS]));
645  }
646  }
647  break;
648 
651  if (this->IsWidgetLowered(WID_ROT_TRUCK_STATION)) {
653  TileArea ta(start_tile, end_tile);
654  DoCommandP(ta.tile, ta.w | ta.h << 8, (_ctrl_pressed << 1) | ROADSTOP_TRUCK, CMD_REMOVE_ROAD_STOP | CMD_MSG(_road_type_infos[_cur_roadtype].err_remove_station[ROADSTOP_TRUCK]), CcPlaySound_SPLAT_OTHER);
655  } else {
656  PlaceRoadStop(start_tile, end_tile, (_ctrl_pressed << 5) | RoadTypeToRoadTypes(_cur_roadtype) << 2 | ROADSTOP_TRUCK, CMD_BUILD_ROAD_STOP | CMD_MSG(_road_type_infos[_cur_roadtype].err_build_station[ROADSTOP_TRUCK]));
657  }
658  }
659  break;
660  }
661  }
662  }
663 
664  virtual void OnPlacePresize(Point pt, TileIndex tile)
665  {
666  DoCommand(tile, RoadTypeToRoadTypes(_cur_roadtype) | (TRANSPORT_ROAD << 8), 0, DC_AUTO, CMD_BUILD_TUNNEL);
668  }
669 
671  {
672  if (RoadToolbar_CtrlChanged(this)) return ES_HANDLED;
673  return ES_NOT_HANDLED;
674  }
675 
676  static HotkeyList hotkeys;
677 };
678 
685 {
686  Window *w = NULL;
687  switch (_game_mode) {
688  case GM_NORMAL: {
689  extern RoadType _last_built_roadtype;
690  w = ShowBuildRoadToolbar(_last_built_roadtype);
691  break;
692  }
693 
694  case GM_EDITOR:
696  break;
697 
698  default:
699  break;
700  }
701 
702  if (w == NULL) return ES_NOT_HANDLED;
703  return w->OnHotkey(hotkey);
704 }
705 
706 static Hotkey roadtoolbar_hotkeys[] = {
707  Hotkey('1', "build_x", WID_ROT_ROAD_X),
708  Hotkey('2', "build_y", WID_ROT_ROAD_Y),
709  Hotkey('3', "autoroad", WID_ROT_AUTOROAD),
710  Hotkey('4', "demolish", WID_ROT_DEMOLISH),
711  Hotkey('5', "depot", WID_ROT_DEPOT),
712  Hotkey('6', "bus_station", WID_ROT_BUS_STATION),
713  Hotkey('7', "truck_station", WID_ROT_TRUCK_STATION),
714  Hotkey('8', "oneway", WID_ROT_ONE_WAY),
715  Hotkey('B', "bridge", WID_ROT_BUILD_BRIDGE),
716  Hotkey('T', "tunnel", WID_ROT_BUILD_TUNNEL),
717  Hotkey('R', "remove", WID_ROT_REMOVE),
718  HOTKEY_LIST_END
719 };
720 HotkeyList BuildRoadToolbarWindow::hotkeys("roadtoolbar", roadtoolbar_hotkeys, RoadToolbarGlobalHotkeys);
721 
722 
723 static const NWidgetPart _nested_build_road_widgets[] = {
725  NWidget(WWT_CLOSEBOX, COLOUR_DARK_GREEN),
726  NWidget(WWT_CAPTION, COLOUR_DARK_GREEN), SetDataTip(STR_ROAD_TOOLBAR_ROAD_CONSTRUCTION_CAPTION, STR_TOOLTIP_WINDOW_TITLE_DRAG_THIS),
727  NWidget(WWT_STICKYBOX, COLOUR_DARK_GREEN),
728  EndContainer(),
730  NWidget(WWT_IMGBTN, COLOUR_DARK_GREEN, WID_ROT_ROAD_X),
731  SetFill(0, 1), SetMinimalSize(22, 22), SetDataTip(SPR_IMG_ROAD_X_DIR, STR_ROAD_TOOLBAR_TOOLTIP_BUILD_ROAD_SECTION),
732  NWidget(WWT_IMGBTN, COLOUR_DARK_GREEN, WID_ROT_ROAD_Y),
733  SetFill(0, 1), SetMinimalSize(22, 22), SetDataTip(SPR_IMG_ROAD_Y_DIR, STR_ROAD_TOOLBAR_TOOLTIP_BUILD_ROAD_SECTION),
734  NWidget(WWT_IMGBTN, COLOUR_DARK_GREEN, WID_ROT_AUTOROAD),
735  SetFill(0, 1), SetMinimalSize(22, 22), SetDataTip(SPR_IMG_AUTOROAD, STR_ROAD_TOOLBAR_TOOLTIP_BUILD_AUTOROAD),
736  NWidget(WWT_IMGBTN, COLOUR_DARK_GREEN, WID_ROT_DEMOLISH),
737  SetFill(0, 1), SetMinimalSize(22, 22), SetDataTip(SPR_IMG_DYNAMITE, STR_TOOLTIP_DEMOLISH_BUILDINGS_ETC),
738  NWidget(WWT_IMGBTN, COLOUR_DARK_GREEN, WID_ROT_DEPOT),
739  SetFill(0, 1), SetMinimalSize(22, 22), SetDataTip(SPR_IMG_ROAD_DEPOT, STR_ROAD_TOOLBAR_TOOLTIP_BUILD_ROAD_VEHICLE_DEPOT),
740  NWidget(WWT_IMGBTN, COLOUR_DARK_GREEN, WID_ROT_BUS_STATION),
741  SetFill(0, 1), SetMinimalSize(22, 22), SetDataTip(SPR_IMG_BUS_STATION, STR_ROAD_TOOLBAR_TOOLTIP_BUILD_BUS_STATION),
742  NWidget(WWT_IMGBTN, COLOUR_DARK_GREEN, WID_ROT_TRUCK_STATION),
743  SetFill(0, 1), SetMinimalSize(22, 22), SetDataTip(SPR_IMG_TRUCK_BAY, STR_ROAD_TOOLBAR_TOOLTIP_BUILD_TRUCK_LOADING_BAY),
744  NWidget(WWT_PANEL, COLOUR_DARK_GREEN, -1), SetMinimalSize(0, 22), SetFill(1, 1), EndContainer(),
745  NWidget(WWT_IMGBTN, COLOUR_DARK_GREEN, WID_ROT_ONE_WAY),
746  SetFill(0, 1), SetMinimalSize(22, 22), SetDataTip(SPR_IMG_ROAD_ONE_WAY, STR_ROAD_TOOLBAR_TOOLTIP_TOGGLE_ONE_WAY_ROAD),
747  NWidget(WWT_IMGBTN, COLOUR_DARK_GREEN, WID_ROT_BUILD_BRIDGE),
748  SetFill(0, 1), SetMinimalSize(43, 22), SetDataTip(SPR_IMG_BRIDGE, STR_ROAD_TOOLBAR_TOOLTIP_BUILD_ROAD_BRIDGE),
749  NWidget(WWT_IMGBTN, COLOUR_DARK_GREEN, WID_ROT_BUILD_TUNNEL),
750  SetFill(0, 1), SetMinimalSize(22, 22), SetDataTip(SPR_IMG_ROAD_TUNNEL, STR_ROAD_TOOLBAR_TOOLTIP_BUILD_ROAD_TUNNEL),
751  NWidget(WWT_IMGBTN, COLOUR_DARK_GREEN, WID_ROT_REMOVE),
752  SetFill(0, 1), SetMinimalSize(22, 22), SetDataTip(SPR_IMG_REMOVE, STR_ROAD_TOOLBAR_TOOLTIP_TOGGLE_BUILD_REMOVE_FOR_ROAD),
753  EndContainer(),
754 };
755 
756 static WindowDesc _build_road_desc(
757  WDP_ALIGN_TOOLBAR, "toolbar_road", 0, 0,
760  _nested_build_road_widgets, lengthof(_nested_build_road_widgets),
761  &BuildRoadToolbarWindow::hotkeys
762 );
763 
764 static const NWidgetPart _nested_build_tramway_widgets[] = {
766  NWidget(WWT_CLOSEBOX, COLOUR_DARK_GREEN),
767  NWidget(WWT_CAPTION, COLOUR_DARK_GREEN), SetDataTip(STR_ROAD_TOOLBAR_TRAM_CONSTRUCTION_CAPTION, STR_TOOLTIP_WINDOW_TITLE_DRAG_THIS),
768  NWidget(WWT_STICKYBOX, COLOUR_DARK_GREEN),
769  EndContainer(),
771  NWidget(WWT_IMGBTN, COLOUR_DARK_GREEN, WID_ROT_ROAD_X),
772  SetFill(0, 1), SetMinimalSize(22, 22), SetDataTip(SPR_IMG_TRAMWAY_X_DIR, STR_ROAD_TOOLBAR_TOOLTIP_BUILD_TRAMWAY_SECTION),
773  NWidget(WWT_IMGBTN, COLOUR_DARK_GREEN, WID_ROT_ROAD_Y),
774  SetFill(0, 1), SetMinimalSize(22, 22), SetDataTip(SPR_IMG_TRAMWAY_Y_DIR, STR_ROAD_TOOLBAR_TOOLTIP_BUILD_TRAMWAY_SECTION),
775  NWidget(WWT_IMGBTN, COLOUR_DARK_GREEN, WID_ROT_AUTOROAD),
776  SetFill(0, 1), SetMinimalSize(22, 22), SetDataTip(SPR_IMG_AUTOTRAM, STR_ROAD_TOOLBAR_TOOLTIP_BUILD_AUTOTRAM),
777  NWidget(WWT_IMGBTN, COLOUR_DARK_GREEN, WID_ROT_DEMOLISH),
778  SetFill(0, 1), SetMinimalSize(22, 22), SetDataTip(SPR_IMG_DYNAMITE, STR_TOOLTIP_DEMOLISH_BUILDINGS_ETC),
779  NWidget(WWT_IMGBTN, COLOUR_DARK_GREEN, WID_ROT_DEPOT),
780  SetFill(0, 1), SetMinimalSize(22, 22), SetDataTip(SPR_IMG_ROAD_DEPOT, STR_ROAD_TOOLBAR_TOOLTIP_BUILD_TRAM_VEHICLE_DEPOT),
781  NWidget(WWT_IMGBTN, COLOUR_DARK_GREEN, WID_ROT_BUS_STATION),
782  SetFill(0, 1), SetMinimalSize(22, 22), SetDataTip(SPR_IMG_BUS_STATION, STR_ROAD_TOOLBAR_TOOLTIP_BUILD_PASSENGER_TRAM_STATION),
783  NWidget(WWT_IMGBTN, COLOUR_DARK_GREEN, WID_ROT_TRUCK_STATION),
784  SetFill(0, 1), SetMinimalSize(22, 22), SetDataTip(SPR_IMG_TRUCK_BAY, STR_ROAD_TOOLBAR_TOOLTIP_BUILD_CARGO_TRAM_STATION),
785  NWidget(WWT_PANEL, COLOUR_DARK_GREEN, -1), SetMinimalSize(0, 22), SetFill(1, 1), EndContainer(),
786  NWidget(WWT_EMPTY, COLOUR_DARK_GREEN, WID_ROT_ONE_WAY), SetMinimalSize(0, 0),
787  NWidget(WWT_IMGBTN, COLOUR_DARK_GREEN, WID_ROT_BUILD_BRIDGE),
788  SetFill(0, 1), SetMinimalSize(43, 22), SetDataTip(SPR_IMG_BRIDGE, STR_ROAD_TOOLBAR_TOOLTIP_BUILD_TRAMWAY_BRIDGE),
789  NWidget(WWT_IMGBTN, COLOUR_DARK_GREEN, WID_ROT_BUILD_TUNNEL),
790  SetFill(0, 1), SetMinimalSize(22, 22), SetDataTip(SPR_IMG_ROAD_TUNNEL, STR_ROAD_TOOLBAR_TOOLTIP_BUILD_TRAMWAY_TUNNEL),
791  NWidget(WWT_IMGBTN, COLOUR_DARK_GREEN, WID_ROT_REMOVE),
792  SetFill(0, 1), SetMinimalSize(22, 22), SetDataTip(SPR_IMG_REMOVE, STR_ROAD_TOOLBAR_TOOLTIP_TOGGLE_BUILD_REMOVE_FOR_TRAMWAYS),
793  EndContainer(),
794 };
795 
796 static WindowDesc _build_tramway_desc(
797  WDP_ALIGN_TOOLBAR, "toolbar_tramway", 0, 0,
800  _nested_build_tramway_widgets, lengthof(_nested_build_tramway_widgets),
801  &BuildRoadToolbarWindow::hotkeys
802 );
803 
812 {
813  if (!Company::IsValidID(_local_company)) return NULL;
814  _cur_roadtype = roadtype;
815 
817  return AllocateWindowDescFront<BuildRoadToolbarWindow>(roadtype == ROADTYPE_ROAD ? &_build_road_desc : &_build_tramway_desc, TRANSPORT_ROAD);
818 }
819 
820 static const NWidgetPart _nested_build_road_scen_widgets[] = {
822  NWidget(WWT_CLOSEBOX, COLOUR_DARK_GREEN),
823  NWidget(WWT_CAPTION, COLOUR_DARK_GREEN), SetDataTip(STR_ROAD_TOOLBAR_ROAD_CONSTRUCTION_CAPTION, STR_TOOLTIP_WINDOW_TITLE_DRAG_THIS),
824  NWidget(WWT_STICKYBOX, COLOUR_DARK_GREEN),
825  EndContainer(),
827  NWidget(WWT_IMGBTN, COLOUR_DARK_GREEN, WID_ROT_ROAD_X),
828  SetFill(0, 1), SetMinimalSize(22, 22), SetDataTip(SPR_IMG_ROAD_X_DIR, STR_ROAD_TOOLBAR_TOOLTIP_BUILD_ROAD_SECTION),
829  NWidget(WWT_IMGBTN, COLOUR_DARK_GREEN, WID_ROT_ROAD_Y),
830  SetFill(0, 1), SetMinimalSize(22, 22), SetDataTip(SPR_IMG_ROAD_Y_DIR, STR_ROAD_TOOLBAR_TOOLTIP_BUILD_ROAD_SECTION),
831  NWidget(WWT_IMGBTN, COLOUR_DARK_GREEN, WID_ROT_AUTOROAD),
832  SetFill(0, 1), SetMinimalSize(22, 22), SetDataTip(SPR_IMG_AUTOROAD, STR_ROAD_TOOLBAR_TOOLTIP_BUILD_AUTOROAD),
833  NWidget(WWT_IMGBTN, COLOUR_DARK_GREEN, WID_ROT_DEMOLISH),
834  SetFill(0, 1), SetMinimalSize(22, 22), SetDataTip(SPR_IMG_DYNAMITE, STR_TOOLTIP_DEMOLISH_BUILDINGS_ETC),
835  NWidget(WWT_PANEL, COLOUR_DARK_GREEN, -1), SetMinimalSize(0, 22), SetFill(1, 1), EndContainer(),
836  NWidget(WWT_IMGBTN, COLOUR_DARK_GREEN, WID_ROT_ONE_WAY),
837  SetFill(0, 1), SetMinimalSize(22, 22), SetDataTip(SPR_IMG_ROAD_ONE_WAY, STR_ROAD_TOOLBAR_TOOLTIP_TOGGLE_ONE_WAY_ROAD),
838  NWidget(WWT_IMGBTN, COLOUR_DARK_GREEN, WID_ROT_BUILD_BRIDGE),
839  SetFill(0, 1), SetMinimalSize(43, 22), SetDataTip(SPR_IMG_BRIDGE, STR_ROAD_TOOLBAR_TOOLTIP_BUILD_ROAD_BRIDGE),
840  NWidget(WWT_IMGBTN, COLOUR_DARK_GREEN, WID_ROT_BUILD_TUNNEL),
841  SetFill(0, 1), SetMinimalSize(22, 22), SetDataTip(SPR_IMG_ROAD_TUNNEL, STR_ROAD_TOOLBAR_TOOLTIP_BUILD_ROAD_TUNNEL),
842  NWidget(WWT_IMGBTN, COLOUR_DARK_GREEN, WID_ROT_REMOVE),
843  SetFill(0, 1), SetMinimalSize(22, 22), SetDataTip(SPR_IMG_REMOVE, STR_ROAD_TOOLBAR_TOOLTIP_TOGGLE_BUILD_REMOVE_FOR_ROAD),
844  EndContainer(),
845 };
846 
847 static WindowDesc _build_road_scen_desc(
848  WDP_AUTO, "toolbar_road_scen", 0, 0,
851  _nested_build_road_scen_widgets, lengthof(_nested_build_road_scen_widgets),
852  &BuildRoadToolbarWindow::hotkeys
853 );
854 
860 {
861  _cur_roadtype = ROADTYPE_ROAD;
862  return AllocateWindowDescFront<BuildRoadToolbarWindow>(&_build_road_scen_desc, TRANSPORT_ROAD);
863 }
864 
866  BuildRoadDepotWindow(WindowDesc *desc, Window *parent) : PickerWindowBase(desc, parent)
867  {
868  this->CreateNestedTree();
869 
870  this->LowerWidget(_road_depot_orientation + WID_BROD_DEPOT_NE);
871  if ( _cur_roadtype == ROADTYPE_TRAM) {
872  this->GetWidget<NWidgetCore>(WID_BROD_CAPTION)->widget_data = STR_BUILD_DEPOT_TRAM_ORIENTATION_CAPTION;
873  for (int i = WID_BROD_DEPOT_NE; i <= WID_BROD_DEPOT_NW; i++) this->GetWidget<NWidgetCore>(i)->tool_tip = STR_BUILD_DEPOT_TRAM_ORIENTATION_SELECT_TOOLTIP;
874  }
875 
876  this->FinishInitNested(TRANSPORT_ROAD);
877  }
878 
879  virtual void UpdateWidgetSize(int widget, Dimension *size, const Dimension &padding, Dimension *fill, Dimension *resize)
880  {
881  if (!IsInsideMM(widget, WID_BROD_DEPOT_NE, WID_BROD_DEPOT_NW + 1)) return;
882 
883  size->width = ScaleGUITrad(64) + 2;
884  size->height = ScaleGUITrad(48) + 2;
885  }
886 
887  virtual void DrawWidget(const Rect &r, int widget) const
888  {
889  if (!IsInsideMM(widget, WID_BROD_DEPOT_NE, WID_BROD_DEPOT_NW + 1)) return;
890 
891  DrawRoadDepotSprite(r.left + 1 + ScaleGUITrad(31), r.bottom - ScaleGUITrad(31), (DiagDirection)(widget - WID_BROD_DEPOT_NE + DIAGDIR_NE), _cur_roadtype);
892  }
893 
894  virtual void OnClick(Point pt, int widget, int click_count)
895  {
896  switch (widget) {
897  case WID_BROD_DEPOT_NW:
898  case WID_BROD_DEPOT_NE:
899  case WID_BROD_DEPOT_SW:
900  case WID_BROD_DEPOT_SE:
901  this->RaiseWidget(_road_depot_orientation + WID_BROD_DEPOT_NE);
902  _road_depot_orientation = (DiagDirection)(widget - WID_BROD_DEPOT_NE);
903  this->LowerWidget(_road_depot_orientation + WID_BROD_DEPOT_NE);
904  if (_settings_client.sound.click_beep) SndPlayFx(SND_15_BEEP);
905  this->SetDirty();
906  break;
907 
908  default:
909  break;
910  }
911  }
912 };
913 
914 static const NWidgetPart _nested_build_road_depot_widgets[] = {
916  NWidget(WWT_CLOSEBOX, COLOUR_DARK_GREEN),
917  NWidget(WWT_CAPTION, COLOUR_DARK_GREEN, WID_BROD_CAPTION), SetDataTip(STR_BUILD_DEPOT_ROAD_ORIENTATION_CAPTION, STR_TOOLTIP_WINDOW_TITLE_DRAG_THIS),
918  EndContainer(),
919  NWidget(WWT_PANEL, COLOUR_DARK_GREEN),
922  NWidget(NWID_SPACER), SetMinimalSize(3, 0), SetFill(1, 0),
924  NWidget(WWT_PANEL, COLOUR_GREY, WID_BROD_DEPOT_NW), SetMinimalSize(66, 50), SetDataTip(0x0, STR_BUILD_DEPOT_ROAD_ORIENTATION_SELECT_TOOLTIP),
925  EndContainer(),
927  NWidget(WWT_PANEL, COLOUR_GREY, WID_BROD_DEPOT_SW), SetMinimalSize(66, 50), SetDataTip(0x0, STR_BUILD_DEPOT_ROAD_ORIENTATION_SELECT_TOOLTIP),
928  EndContainer(),
929  EndContainer(),
932  NWidget(WWT_PANEL, COLOUR_GREY, WID_BROD_DEPOT_NE), SetMinimalSize(66, 50), SetDataTip(0x0, STR_BUILD_DEPOT_ROAD_ORIENTATION_SELECT_TOOLTIP),
933  EndContainer(),
935  NWidget(WWT_PANEL, COLOUR_GREY, WID_BROD_DEPOT_SE), SetMinimalSize(66, 50), SetDataTip(0x0, STR_BUILD_DEPOT_ROAD_ORIENTATION_SELECT_TOOLTIP),
936  EndContainer(),
937  EndContainer(),
938  NWidget(NWID_SPACER), SetMinimalSize(3, 0), SetFill(1, 0),
939  EndContainer(),
941  EndContainer(),
942 };
943 
944 static WindowDesc _build_road_depot_desc(
945  WDP_AUTO, NULL, 0, 0,
948  _nested_build_road_depot_widgets, lengthof(_nested_build_road_depot_widgets)
949 );
950 
951 static void ShowRoadDepotPicker(Window *parent)
952 {
953  new BuildRoadDepotWindow(&_build_road_depot_desc, parent);
954 }
955 
957  BuildRoadStationWindow(WindowDesc *desc, Window *parent, RoadStopType rs) : PickerWindowBase(desc, parent)
958  {
959  this->CreateNestedTree();
960 
961  /* Trams don't have non-drivethrough stations */
962  if (_cur_roadtype == ROADTYPE_TRAM && _road_station_picker_orientation < DIAGDIR_END) {
963  _road_station_picker_orientation = DIAGDIR_END;
964  }
965 
966  this->GetWidget<NWidgetCore>(WID_BROS_CAPTION)->widget_data = _road_type_infos[_cur_roadtype].picker_title[rs];
967  for (uint i = (_cur_roadtype == ROADTYPE_TRAM ? WID_BROS_STATION_X : WID_BROS_STATION_NE); i < WID_BROS_LT_OFF; i++) {
968  this->GetWidget<NWidgetCore>(i)->tool_tip = _road_type_infos[_cur_roadtype].picker_tooltip[rs];
969  }
970 
971  this->LowerWidget(_road_station_picker_orientation + WID_BROS_STATION_NE);
972  this->LowerWidget(_settings_client.gui.station_show_coverage + WID_BROS_LT_OFF);
973 
974  this->FinishInitNested(TRANSPORT_ROAD);
975 
976  this->window_class = (rs == ROADSTOP_BUS) ? WC_BUS_STATION : WC_TRUCK_STATION;
977  }
978 
979  virtual ~BuildRoadStationWindow()
980  {
982  }
983 
984  virtual void OnPaint()
985  {
986  this->DrawWidgets();
987 
988  int rad = _settings_game.station.modified_catchment ? ((this->window_class == WC_BUS_STATION) ? CA_BUS : CA_TRUCK) : CA_UNMODIFIED;
990  SetTileSelectBigSize(-rad, -rad, 2 * rad, 2 * rad);
991  } else {
992  SetTileSelectSize(1, 1);
993  }
994 
995  /* 'Accepts' and 'Supplies' texts. */
997  int top = this->GetWidget<NWidgetBase>(WID_BROS_LT_ON)->pos_y + this->GetWidget<NWidgetBase>(WID_BROS_LT_ON)->current_y + WD_PAR_VSEP_NORMAL;
998  NWidgetBase *back_nwi = this->GetWidget<NWidgetBase>(WID_BROS_BACKGROUND);
999  int right = back_nwi->pos_x + back_nwi->current_x;
1000  int bottom = back_nwi->pos_y + back_nwi->current_y;
1001  top = DrawStationCoverageAreaText(back_nwi->pos_x + WD_FRAMERECT_LEFT, right - WD_FRAMERECT_RIGHT, top, sct, rad, false) + WD_PAR_VSEP_NORMAL;
1002  top = DrawStationCoverageAreaText(back_nwi->pos_x + WD_FRAMERECT_LEFT, right - WD_FRAMERECT_RIGHT, top, sct, rad, true) + WD_PAR_VSEP_NORMAL;
1003  /* Resize background if the window is too small.
1004  * Never make the window smaller to avoid oscillating if the size change affects the acceptance.
1005  * (This is the case, if making the window bigger moves the mouse into the window.) */
1006  if (top > bottom) {
1007  ResizeWindow(this, 0, top - bottom, false);
1008  }
1009  }
1010 
1011  virtual void UpdateWidgetSize(int widget, Dimension *size, const Dimension &padding, Dimension *fill, Dimension *resize)
1012  {
1013  if (!IsInsideMM(widget, WID_BROS_STATION_NE, WID_BROS_STATION_Y + 1)) return;
1014 
1015  size->width = ScaleGUITrad(64) + 2;
1016  size->height = ScaleGUITrad(48) + 2;
1017  }
1018 
1019  virtual void DrawWidget(const Rect &r, int widget) const
1020  {
1021  if (!IsInsideMM(widget, WID_BROS_STATION_NE, WID_BROS_STATION_Y + 1)) return;
1022 
1023  StationType st = (this->window_class == WC_BUS_STATION) ? STATION_BUS : STATION_TRUCK;
1024  StationPickerDrawSprite(r.left + 1 + ScaleGUITrad(31), r.bottom - ScaleGUITrad(31), st, INVALID_RAILTYPE, widget < WID_BROS_STATION_X ? ROADTYPE_ROAD : _cur_roadtype, widget - WID_BROS_STATION_NE);
1025  }
1026 
1027  virtual void OnClick(Point pt, int widget, int click_count)
1028  {
1029  switch (widget) {
1030  case WID_BROS_STATION_NE:
1031  case WID_BROS_STATION_SE:
1032  case WID_BROS_STATION_SW:
1033  case WID_BROS_STATION_NW:
1034  case WID_BROS_STATION_X:
1035  case WID_BROS_STATION_Y:
1036  this->RaiseWidget(_road_station_picker_orientation + WID_BROS_STATION_NE);
1037  _road_station_picker_orientation = (DiagDirection)(widget - WID_BROS_STATION_NE);
1038  this->LowerWidget(_road_station_picker_orientation + WID_BROS_STATION_NE);
1039  if (_settings_client.sound.click_beep) SndPlayFx(SND_15_BEEP);
1040  this->SetDirty();
1042  break;
1043 
1044  case WID_BROS_LT_OFF:
1045  case WID_BROS_LT_ON:
1049  if (_settings_client.sound.click_beep) SndPlayFx(SND_15_BEEP);
1050  this->SetDirty();
1051  break;
1052 
1053  default:
1054  break;
1055  }
1056  }
1057 
1058  virtual void OnRealtimeTick(uint delta_ms)
1059  {
1061  }
1062 };
1063 
1067  NWidget(WWT_CLOSEBOX, COLOUR_DARK_GREEN),
1068  NWidget(WWT_CAPTION, COLOUR_DARK_GREEN, WID_BROS_CAPTION),
1069  EndContainer(),
1070  NWidget(WWT_PANEL, COLOUR_DARK_GREEN, WID_BROS_BACKGROUND),
1072  NWidget(NWID_HORIZONTAL), SetPIP(0, 2, 0),
1073  NWidget(NWID_SPACER), SetFill(1, 0),
1074  NWidget(WWT_PANEL, COLOUR_GREY, WID_BROS_STATION_NW), SetMinimalSize(66, 50), SetFill(0, 0), EndContainer(),
1075  NWidget(WWT_PANEL, COLOUR_GREY, WID_BROS_STATION_NE), SetMinimalSize(66, 50), SetFill(0, 0), EndContainer(),
1076  NWidget(WWT_PANEL, COLOUR_GREY, WID_BROS_STATION_X), SetMinimalSize(66, 50), SetFill(0, 0), EndContainer(),
1077  NWidget(NWID_SPACER), SetFill(1, 0),
1078  EndContainer(),
1080  NWidget(NWID_HORIZONTAL), SetPIP(0, 2, 0),
1081  NWidget(NWID_SPACER), SetFill(1, 0),
1082  NWidget(WWT_PANEL, COLOUR_GREY, WID_BROS_STATION_SW), SetMinimalSize(66, 50), SetFill(0, 0), EndContainer(),
1083  NWidget(WWT_PANEL, COLOUR_GREY, WID_BROS_STATION_SE), SetMinimalSize(66, 50), SetFill(0, 0), EndContainer(),
1084  NWidget(WWT_PANEL, COLOUR_GREY, WID_BROS_STATION_Y), SetMinimalSize(66, 50), SetFill(0, 0), EndContainer(),
1085  NWidget(NWID_SPACER), SetFill(1, 0),
1086  EndContainer(),
1088  NWidget(NWID_HORIZONTAL), SetPIP(2, 0, 2),
1089  NWidget(WWT_LABEL, COLOUR_DARK_GREEN, WID_BROS_INFO), SetMinimalSize(140, 14), SetDataTip(STR_STATION_BUILD_COVERAGE_AREA_TITLE, STR_NULL),
1090  NWidget(NWID_SPACER), SetFill(1, 0),
1091  EndContainer(),
1092  NWidget(NWID_HORIZONTAL), SetPIP(2, 0, 2),
1093  NWidget(NWID_SPACER), SetFill(1, 0),
1094  NWidget(WWT_TEXTBTN, COLOUR_GREY, WID_BROS_LT_OFF), SetMinimalSize(60, 12),
1095  SetDataTip(STR_STATION_BUILD_COVERAGE_OFF, STR_STATION_BUILD_COVERAGE_AREA_OFF_TOOLTIP),
1096  NWidget(WWT_TEXTBTN, COLOUR_GREY, WID_BROS_LT_ON), SetMinimalSize(60, 12),
1097  SetDataTip(STR_STATION_BUILD_COVERAGE_ON, STR_STATION_BUILD_COVERAGE_AREA_ON_TOOLTIP),
1098  NWidget(NWID_SPACER), SetFill(1, 0),
1099  EndContainer(),
1100  NWidget(NWID_SPACER), SetMinimalSize(0, 10), SetResize(0, 1),
1101  EndContainer(),
1102 };
1103 
1104 static WindowDesc _road_station_picker_desc(
1105  WDP_AUTO, NULL, 0, 0,
1108  _nested_road_station_picker_widgets, lengthof(_nested_road_station_picker_widgets)
1109 );
1110 
1114  NWidget(WWT_CLOSEBOX, COLOUR_DARK_GREEN),
1115  NWidget(WWT_CAPTION, COLOUR_DARK_GREEN, WID_BROS_CAPTION),
1116  EndContainer(),
1117  NWidget(WWT_PANEL, COLOUR_DARK_GREEN, WID_BROS_BACKGROUND),
1119  NWidget(NWID_HORIZONTAL), SetPIP(0, 2, 0),
1120  NWidget(NWID_SPACER), SetFill(1, 0),
1121  NWidget(WWT_PANEL, COLOUR_GREY, WID_BROS_STATION_X), SetMinimalSize(66, 50), SetFill(0, 0), EndContainer(),
1122  NWidget(WWT_PANEL, COLOUR_GREY, WID_BROS_STATION_Y), SetMinimalSize(66, 50), SetFill(0, 0), EndContainer(),
1123  NWidget(NWID_SPACER), SetFill(1, 0),
1124  EndContainer(),
1126  NWidget(NWID_HORIZONTAL), SetPIP(2, 0, 2),
1127  NWidget(WWT_LABEL, COLOUR_DARK_GREEN, WID_BROS_INFO), SetMinimalSize(140, 14), SetDataTip(STR_STATION_BUILD_COVERAGE_AREA_TITLE, STR_NULL),
1128  NWidget(NWID_SPACER), SetFill(1, 0),
1129  EndContainer(),
1130  NWidget(NWID_HORIZONTAL), SetPIP(2, 0, 2),
1131  NWidget(NWID_SPACER), SetFill(1, 0),
1132  NWidget(WWT_TEXTBTN, COLOUR_GREY, WID_BROS_LT_OFF), SetMinimalSize(60, 12),
1133  SetDataTip(STR_STATION_BUILD_COVERAGE_OFF, STR_STATION_BUILD_COVERAGE_AREA_OFF_TOOLTIP),
1134  NWidget(WWT_TEXTBTN, COLOUR_GREY, WID_BROS_LT_ON), SetMinimalSize(60, 12),
1135  SetDataTip(STR_STATION_BUILD_COVERAGE_ON, STR_STATION_BUILD_COVERAGE_AREA_ON_TOOLTIP),
1136  NWidget(NWID_SPACER), SetFill(1, 0),
1137  EndContainer(),
1138  NWidget(NWID_SPACER), SetMinimalSize(0, 10), SetResize(0, 1),
1139  EndContainer(),
1140 };
1141 
1142 static WindowDesc _tram_station_picker_desc(
1143  WDP_AUTO, NULL, 0, 0,
1146  _nested_tram_station_picker_widgets, lengthof(_nested_tram_station_picker_widgets)
1147 );
1148 
1149 static void ShowRVStationPicker(Window *parent, RoadStopType rs)
1150 {
1151  new BuildRoadStationWindow(_cur_roadtype == ROADTYPE_ROAD ? &_road_station_picker_desc : &_tram_station_picker_desc, parent, rs);
1152 }
1153 
1154 void InitializeRoadGui()
1155 {
1156  _road_depot_orientation = DIAGDIR_NW;
1157  _road_station_picker_orientation = DIAGDIR_NW;
1158 }
EventState
State of handling an event.
Definition: window_type.h:713
virtual void DrawWidget(const Rect &r, int widget) const
Draw the contents of a nested widget.
Definition: road_gui.cpp:887
ViewportDragDropSelectionProcess
Drag and drop selection process, or, what to do with an area of land when you&#39;ve selected it...
Definition: viewport_type.h:97
don&#39;t allow building on structures
Definition: command_type.h:346
Empty widget, place holder to reserve space in widget array.
Definition: widget_type.h:48
DECLARE_ENUM_AS_BIT_SET(GenderEthnicity) enum CompanyManagerFaceVariable
Bitgroups of the CompanyManagerFace variable.
GameSettings _settings_game
Game settings of a running game or the scenario editor.
Definition: settings.cpp:77
int last_started_action
Last started user action.
Definition: road_gui.cpp:314
Definition of stuff that is very close to a company, like the company struct itself.
static void PlaceRoad_Bridge(TileIndex tile, Window *w)
Callback to start placing a bridge.
Definition: road_gui.cpp:76
Select station (when joining stations); Window numbers:
Definition: window_type.h:237
A standard stop for trucks.
Definition: station_type.h:48
bool link_terraform_toolbar
display terraform toolbar when displaying rail, road, water and airport toolbars
Definition: settings_type.h:96
virtual EventState OnHotkey(int hotkey)
A hotkey has been pressed.
Definition: window.cpp:594
Demolish.
Definition: road_widget.h:21
static NWidgetPart SetResize(int16 dx, int16 dy)
Widget part function for setting the resize step.
Definition: widget_type.h:930
void CheckRedrawStationCoverage(const Window *w)
Check whether we need to redraw the station coverage text.
Definition: station_gui.cpp:88
Point pos
Location, in tile "units", of the northern tile of the selected area.
Terminal station with NE entry.
Definition: road_widget.h:46
area of land of limited size
Definition: viewport_type.h:83
All data for a single hotkey.
Definition: hotkeys.h:24
High level window description.
Definition: window_gui.h:168
Road stop placement (trucks)
Build depot.
Definition: road_widget.h:22
build a complete road (not a "half" one)
Definition: command_type.h:201
static const CursorID ANIMCURSOR_DEMOLISH
704 - 707 - demolish dynamite
Definition: sprites.h:1478
static EventState RoadToolbarGlobalHotkeys(int hotkey)
Handler for global hotkeys of the BuildRoadToolbarWindow.
Definition: road_gui.cpp:684
Landscape generation (in Scenario Editor); Window numbers:
Definition: window_type.h:444
void ConnectRoadToStructure(TileIndex tile, DiagDirection direction)
If required, connects a new structure to an existing road or tram by building the missing roadbit...
Definition: road_gui.cpp:165
bool station_show_coverage
whether to highlight coverage area
Scenario build toolbar; Window numbers:
Definition: window_type.h:75
static bool IsBridgeTile(TileIndex t)
checks if there is a bridge on this tile
Definition: bridge_map.h:35
Hotkey related functions.
static bool IsInsideMM(const T x, const uint min, const uint max)
Checks if a value is in an interval.
Definition: math_func.hpp:266
Terminal station with NW entry.
Definition: road_widget.h:49
Centered label.
Definition: widget_type.h:57
Basic road type.
Definition: road_type.h:24
void ShowSelectStationIfNeeded(const CommandContainer &cmd, TileArea ta)
Show the station selection window when needed.
Contains enums and function declarations connected with stations GUI.
remove a complete road (not a "half" one)
Definition: command_type.h:202
Window * ShowTerraformToolbar(Window *link)
Show the toolbar for terraforming in the game.
void SetWidgetDirty(byte widget_index) const
Invalidate a widget, i.e.
Definition: window.cpp:581
Road stop removal (trucks)
Normal amount of vertical space between two paragraphs of text.
Definition: window_gui.h:139
static T SetBit(T &x, const uint8 y)
Set a bit in a variable.
Draw only passenger class cargoes.
Definition: station_gui.h:22
Horizontal container.
Definition: widget_type.h:75
Functions/types related to the road GUIs.
The passed event is not handled.
Definition: window_type.h:715
void SetTileSelectSize(int w, int h)
Highlight w by h tiles at the cursor.
Definition: viewport.cpp:2160
drag only in X axis
Definition: viewport_type.h:80
static int ScaleGUITrad(int value)
Scale traditional pixel dimensions to GUI zoom level.
Definition: zoom_func.h:82
Turn on area highlight.
Definition: road_widget.h:53
Autorail.
Definition: road_widget.h:20
Drag only in X axis with limited size.
Definition: viewport_type.h:86
virtual void OnPlaceMouseUp(ViewportPlaceMethod select_method, ViewportDragDropSelectionProcess select_proc, Point pt, TileIndex start_tile, TileIndex end_tile)
The user has dragged over the map when the tile highlight mode has been set.
Definition: road_gui.cpp:608
Point size
Size, in tile "units", of the white/red selection area.
Window * ShowBuildRoadToolbar(RoadType roadtype)
Open the build road toolbar window.
Definition: road_gui.cpp:811
drag only in Y axis
Definition: viewport_type.h:81
Drag only in Y axis with limited size.
Definition: viewport_type.h:87
Functions related to vehicles.
Turn off area highlight.
Definition: road_widget.h:52
Drive-through station in y-direction.
Definition: road_widget.h:51
A standard stop for buses.
Definition: station_type.h:47
void DrawRoadDepotSprite(int x, int y, DiagDirection dir, RoadType rt)
Draw the road depot sprite.
Definition: road_cmd.cpp:1429
static RoadTypes RoadTypeToRoadTypes(RoadType rt)
Maps a RoadType to the corresponding RoadTypes value.
Definition: road_func.h:56
byte station_spread
amount a station may spread
Build depot; Window numbers:
Definition: window_type.h:412
void ToggleWidgetLoweredState(byte widget_index)
Invert the lowered/raised status of a widget.
Definition: window_gui.h:465
static RoadBits GetRoadBits(TileIndex t, RoadType rt)
Get the present road bits for a specific road type.
Definition: road_map.h:111
Northeast, upper right on your monitor.
Close box (at top-left of a window)
Definition: widget_type.h:69
void VpSetPresizeRange(TileIndex from, TileIndex to)
Highlights all tiles between a set of two tiles.
Definition: viewport.cpp:2383
Build bridge.
Definition: road_widget.h:26
build a "half" road
Definition: command_type.h:203
Road stop removal (buses)
bool CanBuildVehicleInfrastructure(VehicleType type)
Check whether we can build infrastructure for the given vehicle type.
Definition: vehicle.cpp:1756
Caption of the window.
Definition: road_widget.h:44
Build road in x-direction.
Definition: road_widget.h:18
virtual void OnPlaceObject(Point pt, TileIndex tile)
The user clicked some place on the map when a tile highlight mode has been set.
Definition: road_gui.cpp:494
Station acceptance info.
Definition: road_widget.h:54
virtual void OnRealtimeTick(uint delta_ms)
Called periodically.
Definition: road_gui.cpp:1058
bool persistent_buildingtools
keep the building tools active after usage
Common return value for all commands.
Definition: command_type.h:25
Catchment for bus stops with "modified catchment" enabled.
Definition: station_type.h:81
RoadType
The different roadtypes we support.
Definition: road_type.h:22
StringID picker_title[2]
Title for the station picker for bus or truck stations.
Definition: road_gui.cpp:122
uint16 w
The width of the area.
Definition: tilearea_type.h:20
StationSettings station
settings related to station management
void UpdateOptionWidgetStatus(RoadToolbarWidgets clicked_widget)
Update the remove button lowered state of the road toolbar.
Definition: road_gui.cpp:362
RoadStopType
Types of RoadStops.
Definition: station_type.h:46
RoadToolbarWidgets
Widgets of the BuildRoadToolbarWindow class.
Definition: road_widget.h:16
static T SB(T &x, const uint8 s, const uint8 n, const U d)
Set n bits in x starting at bit s to d.
Functions, definitions and such used only by the GUI.
static void ToggleRoadButton_Remove(Window *w)
Toggles state of the Remove button of Build road toolbar.
Definition: road_gui.cpp:284
virtual void UpdateWidgetSize(int widget, Dimension *size, const Dimension &padding, Dimension *fill, Dimension *resize)
Update size and resize step of a widget in the window.
Definition: road_gui.cpp:1011
CompanyByte _local_company
Company controlled by the human player at this client. Can also be COMPANY_SPECTATOR.
Definition: company_cmd.cpp:46
Terminal station with SE entry.
Definition: road_widget.h:47
StringID err_remove_road
Removing a normal piece of road.
Definition: road_gui.cpp:117
Partial widget specification to allow NWidgets to be written nested.
Definition: widget_type.h:910
Functions related to (drawing on) viewports.
Data structure for an opened window.
Definition: window_gui.h:278
Clear area.
Definition: viewport_type.h:98
Depot with NE entry.
Definition: road_widget.h:35
bool _ctrl_pressed
Is Ctrl pressed?
Definition: gfx.cpp:36
Road placement (X axis)
virtual void OnPaint()
The window must be repainted.
Definition: road_gui.cpp:984
virtual EventState OnHotkey(int hotkey)
A hotkey has been pressed.
Definition: road_gui.cpp:488
static RoadBits DiagDirToRoadBits(DiagDirection d)
Create the road-part which belongs to the given DiagDirection.
Definition: road_func.h:144
Build truck station.
Definition: road_widget.h:24
Structure holding information per roadtype for several functions.
Definition: road_gui.cpp:115
static TileIndexDiff TileOffsByDiagDir(DiagDirection dir)
Convert a DiagDirection to a TileIndexDiff.
Definition: map_func.h:343
Invisible widget that takes some space.
Definition: widget_type.h:79
static const NWidgetPart _nested_road_station_picker_widgets[]
Widget definition of the build road station window.
Definition: road_gui.cpp:1065
int DrawStationCoverageAreaText(int left, int right, int top, StationCoverageType sct, int rad, bool supplies)
Calculates and draws the accepted or supplied cargo around the selected tile(s)
Definition: station_gui.cpp:56
CommandCost DoCommand(const CommandContainer *container, DoCommandFlag flags)
Shorthand for calling the long DoCommand with a container.
Definition: command.cpp:440
uint pos_y
Vertical position of top-left corner of the widget in the window.
Definition: widget_type.h:178
This window is used for construction; close it whenever changing company.
Definition: window_gui.h:210
Road toolbar window handler.
Definition: road_gui.cpp:313
bool IsWidgetLowered(byte widget_index) const
Gets the lowered state of a widget.
Definition: window_gui.h:495
SoundSettings sound
sound effect settings
Header file for things common for tunnels and bridges.
void SetRedErrorSquare(TileIndex tile)
Set a tile to display a red error square.
Definition: viewport.cpp:2142
Depot with SE entry.
Definition: road_widget.h:36
uint current_y
Current vertical size (after resizing).
Definition: widget_type.h:175
ViewportPlaceMethod
Viewport place method (type of highlighted area and placed objects)
Definition: viewport_type.h:78
static DiagDirection ReverseDiagDir(DiagDirection d)
Returns the reverse direction of the given DiagDirection.
Structure for buffering the build command when selecting a station to join.
Definition: command_type.h:475
static NWidgetPart SetDataTip(uint32 data, StringID tip)
Widget part function for setting the data and tooltip.
Definition: widget_type.h:1014
build a tunnel
Definition: command_type.h:190
drag in X or Y direction
Definition: viewport_type.h:79
ClientSettings _settings_client
The current settings for this game.
Definition: settings.cpp:76
static NWidgetPart SetMinimalSize(int16 x, int16 y)
Widget part function for setting the minimal size.
Definition: widget_type.h:947
bool Succeeded() const
Did this command succeed?
Definition: command_type.h:152
StationCoverageType
Types of cargo to display for station coverage.
Definition: station_gui.h:21
#define TILE_AREA_LOOP(var, ta)
A loop which iterates over the tiles of a TileArea.
Definition of base types and functions in a cross-platform compatible way.
A number of safeguards to prevent using unsafe methods.
virtual void OnInvalidateData(int data=0, bool gui_scope=true)
Some data on this window has become invalid.
Definition: road_gui.cpp:340
Trams.
Definition: road_type.h:25
List of hotkeys for a window.
Definition: hotkeys.h:42
rectangle (stations, depots, ...)
Depot with SW entry.
Definition: road_widget.h:37
Simple depressed panel.
Definition: widget_type.h:50
Road stop placement (buses)
Build one-way road.
Definition: road_widget.h:25
bool IsWidgetDisabled(byte widget_index) const
Gets the enabled/disabled status of a widget.
Definition: window_gui.h:423
Used for iterations.
No road-part is build.
Definition: road_type.h:56
Represents the covered area of e.g.
Definition: tilearea_type.h:18
void CcBuildRoadTunnel(const CommandCost &result, TileIndex start_tile, uint32 p1, uint32 p2, uint32 cmd)
Callback executed after a build road tunnel command has been called.
Definition: road_gui.cpp:97
GUI stuff related to terraforming.
virtual void OnClick(Point pt, int widget, int click_count)
A click with the left mouse button has been made on the window.
Definition: road_gui.cpp:408
static NWidgetPart NWidget(WidgetType tp, Colours col, int16 idx=-1)
Widget part function for starting a new &#39;real&#39; widget.
Definition: widget_type.h:1114
Northwest.
void MarkTileDirtyByTile(TileIndex tile, int bridge_level_offset, int tile_height_override)
Mark a tile given by its index dirty for repaint.
Definition: viewport.cpp:1785
TileIndex _build_tunnel_endtile
The end of a tunnel; as hidden return from the tunnel build command for GUI purposes.
Baseclass for nested widgets.
Definition: widget_type.h:126
virtual void OnPlacePresize(Point pt, TileIndex tile)
The user moves over the map when a tile highlight mode has been set when the special mouse mode has b...
Definition: road_gui.cpp:664
Functions related to stations.
bool DoCommandP(const CommandContainer *container, bool my_cmd)
Shortcut for the long DoCommandP when having a container with the data.
Definition: command.cpp:531
DiagDirection
Enumeration for diagonal directions.
void VpStartPlaceSizing(TileIndex tile, ViewportPlaceMethod method, ViewportDragDropSelectionProcess process)
highlighting tiles while only going over them with the mouse
Definition: viewport.cpp:2340
Catchment for truck stops with "modified catchment" enabled.
Definition: station_type.h:82
Catchment for all stations with "modified catchment" disabled.
Definition: station_type.h:86
#define lengthof(x)
Return the length of an fixed size array.
Definition: depend.cpp:42
void ShowBuildBridgeWindow(TileIndex start, TileIndex end, TransportType transport_type, byte road_rail_type)
Prepare the data for the build a bridge window.
Definition: bridge_gui.cpp:362
Build bridge; Window numbers:
Definition: window_type.h:384
void PlaceProc_DemolishArea(TileIndex tile)
Start a drag for demolishing an area.
Road vehicle type.
Definition: vehicle_type.h:27
Bridge placement.
uint pos_x
Horizontal position of top-left corner of the widget in the window.
Definition: widget_type.h:177
Also allow &#39;diagonal rectangles&#39;. Only usable in combination with HT_RECT or HT_POINT.
Functions related to sound.
StringID err_build_road
Building a normal piece of road.
Definition: road_gui.cpp:116
static DiagDirection GetTunnelBridgeDirection(TileIndex t)
Get the direction pointing to the other end.
build a road depot
Definition: command_type.h:204
uint32 StringID
Numeric value that represents a string, independent of the selected language.
Definition: strings_type.h:18
bool GUIPlaceProcDragXY(ViewportDragDropSelectionProcess proc, TileIndex start_tile, TileIndex end_tile)
A central place to handle all X_AND_Y dragged GUI functions.
void DeleteWindowByClass(WindowClass cls)
Delete all windows of a given class.
Definition: window.cpp:1159
bool Failed() const
Did this command fail?
Definition: command_type.h:161
static const RoadTypeInfo _road_type_infos[]
What errors/cursors must be shown for several types of roads.
Definition: road_gui.cpp:131
void VpSelectTilesWithMethod(int x, int y, ViewportPlaceMethod method)
Selects tiles while dragging.
Definition: viewport.cpp:2813
virtual void OnPlaceDrag(ViewportPlaceMethod select_method, ViewportDragDropSelectionProcess select_proc, Point pt)
The user is dragging over the map when the tile highlight mode has been set.
Definition: road_gui.cpp:565
Road placement (auto)
static const int WIDGET_LIST_END
indicate the end of widgets&#39; list for vararg functions
Definition: widget_type.h:22
virtual void DrawWidget(const Rect &r, int widget) const
Draw the contents of a nested widget.
Definition: road_gui.cpp:1019
Build toolbar; Window numbers:
Definition: window_type.h:68
Road related functions.
TileIndex tile
The base tile of the area.
Definition: tilearea_type.h:19
Types related to the road widgets.
The X axis.
No window, redirects to WC_MAIN_WINDOW.
Definition: window_type.h:40
void DeleteWindowById(WindowClass cls, WindowNumber number, bool force)
Delete a window by its class and window number (if it is open).
Definition: window.cpp:1146
static Axis DiagDirToAxis(DiagDirection d)
Convert a DiagDirection to the axis.
static TileIndex GetOtherTunnelBridgeEnd(TileIndex t)
Determines type of the wormhole and returns its other end.
Functions related to companies.
SpriteID cursor_autoroad
Cursor for building autoroad.
Definition: road_gui.cpp:127
build a road stop
Definition: command_type.h:199
static TileIndex TileVirtXY(uint x, uint y)
Get a tile from the virtual XY-coordinate.
Definition: map_func.h:196
static bool _remove_button_clicked
Flag whether &#39;remove&#39; toggle-button is currently enabled.
Definition: rail_gui.cpp:47
StationType
Station types.
Definition: station_type.h:34
StringID err_depot
Building a depot.
Definition: road_gui.cpp:118
Build road in y-direction.
Definition: road_widget.h:19
area of land in X and Y directions
Definition: viewport_type.h:82
static bool IsNormalRoadTile(TileIndex t)
Return whether a tile is a normal road tile.
Definition: road_map.h:57
GUISettings gui
settings related to the GUI
Align toward the toolbar.
Definition: window_gui.h:158
Window caption (window title between closebox and stickybox)
Definition: widget_type.h:61
uint32 SpriteID
The number of a sprite, without mapping bits and colourtables.
Definition: gfx_type.h:19
static void PlaceRoad_BusStation(TileIndex tile)
Callback for placing a bus station.
Definition: road_gui.cpp:246
SpriteID cursor_nwse
Cursor for building NW and SE bits.
Definition: road_gui.cpp:126
uint32 TileIndex
The index/ID of a Tile.
Definition: tile_type.h:80
bool HandlePlacePushButton(Window *w, int widget, CursorID cursor, HighLightStyle mode)
This code is shared for the majority of the pushbuttons.
Definition: main_gui.cpp:104
Draw all non-passenger class cargoes.
Definition: station_gui.h:23
bool modified_catchment
different-size catchment areas
Build bus station.
Definition: road_widget.h:23
Vertical container.
Definition: widget_type.h:77
Build truck station; Window numbers:
Definition: window_type.h:404
static NWidgetPart EndContainer()
Widget part function for denoting the end of a container (horizontal, vertical, WWT_FRAME, WWT_INSET, or WWT_PANEL).
Definition: widget_type.h:999
static uint GB(const T x, const uint8 s, const uint8 n)
Fetch n bits from x, started at bit s.
Functions related to zooming.
Drive-through station in x-direction.
Definition: road_widget.h:50
uint current_x
Current horizontal size (after resizing).
Definition: widget_type.h:174
Transport by road vehicle.
StringID picker_tooltip[2]
Tooltip for the station picker for bus or truck stations.
Definition: road_gui.cpp:123
bool confirm
Play sound effect on succesful constructions or other actions.
Non-water non-rail construction.
Definition: sound_type.h:70
Functions related to commands.
Coordinates of a point in 2D.
static bool IsValidID(size_t index)
Tests whether given index can be used to get valid (non-NULL) Titem.
Definition: pool_type.hpp:235
special mode used for highlighting while dragging (and for tunnels/docks)
StringID err_build_station[2]
Building a bus or truck station.
Definition: road_gui.cpp:119
virtual EventState OnCTRLStateChange()
The state of the control key has changed.
Definition: road_gui.cpp:670
Functions that have tunnels and bridges in common.
Terminal station with SW entry.
Definition: road_widget.h:48
Build tunnel.
Definition: road_widget.h:27
Offset at right to draw the frame rectangular area.
Definition: window_gui.h:63
Road placement (Y axis)
Sticky box (at top-right of a window, after WWT_DEFSIZEBOX)
Definition: widget_type.h:66
Window * ShowBuildRoadScenToolbar()
Show the road building toolbar in the scenario editor.
Definition: road_gui.cpp:859
static NWidgetPart SetFill(uint fill_x, uint fill_y)
Widget part function for setting filling.
Definition: widget_type.h:983
static bool HasBit(const T x, const uint8 y)
Checks if a bit in a value is set.
Remove road.
Definition: road_widget.h:28
virtual void UpdateWidgetSize(int widget, Dimension *size, const Dimension &padding, Dimension *fill, Dimension *resize)
Update size and resize step of a widget in the window.
Definition: road_gui.cpp:879
static void PlaceRoad_TruckStation(TileIndex tile)
Callback for placing a truck station.
Definition: road_gui.cpp:264
#define CMD_MSG(x)
Used to combine a StringID with the command.
Definition: command_type.h:369
Build bus station; Window numbers:
Definition: window_type.h:398
int32 WindowNumber
Number to differentiate different windows of the same class.
Definition: window_type.h:707
void ResetObjectToPlace()
Reset the cursor and mouse mode handling back to default (normal cursor, only clicking in windows)...
Definition: viewport.cpp:3088
Specification of a rectangle with absolute coordinates of all edges.
The passed event is handled.
Definition: window_type.h:714
Flag for invalid railtype.
Definition: rail_type.h:36
Functions related to tile highlights.
Window functions not directly related to making/drawing windows.
Background of the window.
Definition: road_widget.h:45
Find a place automatically.
Definition: window_gui.h:156
static void PlaceRoadStop(TileIndex start_tile, TileIndex end_tile, uint32 p2, uint32 cmd)
Place a new road stop.
Definition: road_gui.cpp:226
(Toggle) Button with image
Definition: widget_type.h:52
SpriteID cursor_nesw
Cursor for building NE and SW bits.
Definition: road_gui.cpp:125
GUI functions that shouldn&#39;t be here.
virtual void OnClick(Point pt, int widget, int click_count)
A click with the left mouse button has been made on the window.
Definition: road_gui.cpp:894
uint16 h
The height of the area.
Definition: tilearea_type.h:21
static bool RoadToolbar_CtrlChanged(Window *w)
Updates the Remove button because of Ctrl state change.
Definition: road_gui.cpp:297
void CcRoadStop(const CommandCost &result, TileIndex tile, uint32 p1, uint32 p2, uint32 cmd)
Command callback for building road stops.
Definition: road_gui.cpp:201
void ResizeWindow(Window *w, int delta_x, int delta_y, bool clamp_to_screen)
Resize the window.
Definition: window.cpp:2126
RoadFlags
Define the values of the RoadFlags.
Definition: road_gui.cpp:49
virtual void OnClick(Point pt, int widget, int click_count)
A click with the left mouse button has been made on the window.
Definition: road_gui.cpp:1027
virtual void OnPlaceObjectAbort()
The user cancelled a tile highlight mode that has been set.
Definition: road_gui.cpp:548
Dimensions (a width and height) of a rectangle in 2D.
bool click_beep
Beep on a random selection of buttons.
Offset at left to draw the frame rectangular area.
Definition: window_gui.h:62
Depot with NW entry.
Definition: road_widget.h:38
remove a road stop
Definition: command_type.h:200
StringID err_remove_station[2]
Removing of a bus or truck station.
Definition: road_gui.cpp:120
Horizontal container that doesn&#39;t change the order of the widgets for RTL languages.
Definition: widget_type.h:76
static NWidgetPart SetPIP(uint8 pre, uint8 inter, uint8 post)
Widget part function for setting a pre/inter/post spaces.
Definition: widget_type.h:1076
Base class for windows opened from a toolbar.
Definition: window_gui.h:856
static const NWidgetPart _nested_tram_station_picker_widgets[]
Widget definition of the build tram station window.
Definition: road_gui.cpp:1112
virtual void OnPlaceMouseUp(ViewportPlaceMethod select_method, ViewportDragDropSelectionProcess select_proc, Point pt, TileIndex start_tile, TileIndex end_tile)
The user has dragged over the map when the tile highlight mode has been set.
Definition: window_gui.h:789
(Toggle) Button with text
Definition: widget_type.h:55
Caption of the window.
Definition: road_widget.h:34