OpenTTD Source  20240917-master-g9ab0a47812
road_gui.cpp
Go to the documentation of this file.
1 /*
2  * This file is part of OpenTTD.
3  * 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.
4  * 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.
5  * 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/>.
6  */
7 
10 #include "stdafx.h"
11 #include "gui.h"
12 #include "window_gui.h"
13 #include "station_gui.h"
14 #include "terraform_gui.h"
15 #include "viewport_func.h"
16 #include "command_func.h"
17 #include "road_cmd.h"
18 #include "station_func.h"
19 #include "waypoint_func.h"
20 #include "window_func.h"
21 #include "vehicle_func.h"
22 #include "sound_func.h"
23 #include "company_func.h"
24 #include "tunnelbridge.h"
25 #include "tunnelbridge_map.h"
26 #include "tilehighlight_func.h"
27 #include "company_base.h"
28 #include "hotkeys.h"
29 #include "road_gui.h"
30 #include "zoom_func.h"
31 #include "dropdown_type.h"
32 #include "dropdown_func.h"
33 #include "engine_base.h"
34 #include "station_base.h"
35 #include "waypoint_base.h"
36 #include "strings_func.h"
37 #include "core/geometry_func.hpp"
38 #include "station_cmd.h"
39 #include "waypoint_cmd.h"
40 #include "road_cmd.h"
41 #include "tunnelbridge_cmd.h"
42 #include "newgrf_roadstop.h"
43 #include "picker_gui.h"
44 #include "timer/timer.h"
46 
47 #include "widgets/road_widget.h"
48 
49 #include "table/strings.h"
50 
51 #include "safeguards.h"
52 
53 static void ShowRVStationPicker(Window *parent, RoadStopType rs);
54 static void ShowRoadDepotPicker(Window *parent);
55 static void ShowBuildRoadWaypointPicker(Window *parent);
56 
57 static bool _remove_button_clicked;
58 static bool _one_way_button_clicked;
59 
60 static Axis _place_road_dir;
61 static bool _place_road_start_half_x;
62 static bool _place_road_start_half_y;
63 static bool _place_road_end_half;
64 
65 static RoadType _cur_roadtype;
66 
67 static DiagDirection _road_depot_orientation;
68 
71  uint16_t sel_type;
72 };
74 
77  uint16_t sel_type;
79 };
80 static RoadStopPickerSelection _roadstop_gui;
81 
82 static bool IsRoadStopEverAvailable(const RoadStopSpec *spec, StationType type)
83 {
84  if (spec == nullptr) return true;
85 
86  if (HasBit(spec->flags, RSF_BUILD_MENU_ROAD_ONLY) && !RoadTypeIsRoad(_cur_roadtype)) return false;
87  if (HasBit(spec->flags, RSF_BUILD_MENU_TRAM_ONLY) && !RoadTypeIsTram(_cur_roadtype)) return false;
88 
89  switch (spec->stop_type) {
90  case ROADSTOPTYPE_ALL: return true;
91  case ROADSTOPTYPE_PASSENGER: return type == STATION_BUS;
92  case ROADSTOPTYPE_FREIGHT: return type == STATION_TRUCK;
93  default: NOT_REACHED();
94  }
95 }
96 
101 static bool IsRoadStopAvailable(const RoadStopSpec *spec, StationType type)
102 {
103  if (spec == nullptr) return true;
104  if (!IsRoadStopEverAvailable(spec, type)) return false;
105 
106  if (!HasBit(spec->callback_mask, CBM_ROAD_STOP_AVAIL)) return true;
107 
108  uint16_t cb_res = GetRoadStopCallback(CBID_STATION_AVAILABILITY, 0, 0, spec, nullptr, INVALID_TILE, _cur_roadtype, type, 0);
109  if (cb_res == CALLBACK_FAILED) return true;
110 
112 }
113 
114 void CcPlaySound_CONSTRUCTION_OTHER(Commands, const CommandCost &result, TileIndex tile)
115 {
116  if (result.Succeeded() && _settings_client.sound.confirm) SndPlayTileFx(SND_1F_CONSTRUCTION_OTHER, tile);
117 }
118 
123 static void PlaceRoad_Bridge(TileIndex tile, Window *w)
124 {
125  if (IsBridgeTile(tile)) {
126  TileIndex other_tile = GetOtherTunnelBridgeEnd(tile);
127  Point pt = {0, 0};
128  w->OnPlaceMouseUp(VPM_X_OR_Y, DDSP_BUILD_BRIDGE, pt, other_tile, tile);
129  } else {
131  }
132 }
133 
140 void CcBuildRoadTunnel(Commands, const CommandCost &result, TileIndex start_tile)
141 {
142  if (result.Succeeded()) {
143  if (_settings_client.sound.confirm) SndPlayTileFx(SND_1F_CONSTRUCTION_OTHER, start_tile);
145 
146  DiagDirection start_direction = ReverseDiagDir(GetTunnelBridgeDirection(start_tile));
147  ConnectRoadToStructure(start_tile, start_direction);
148 
149  TileIndex end_tile = GetOtherTunnelBridgeEnd(start_tile);
150  DiagDirection end_direction = ReverseDiagDir(GetTunnelBridgeDirection(end_tile));
151  ConnectRoadToStructure(end_tile, end_direction);
152  } else {
154  }
155 }
156 
163 {
164  tile += TileOffsByDiagDir(direction);
165  /* if there is a roadpiece just outside of the station entrance, build a connecting route */
166  if (IsNormalRoadTile(tile)) {
167  if (GetRoadBits(tile, GetRoadTramType(_cur_roadtype)) != ROAD_NONE) {
168  Command<CMD_BUILD_ROAD>::Post(tile, DiagDirToRoadBits(ReverseDiagDir(direction)), _cur_roadtype, DRD_NONE, 0);
169  }
170  }
171 }
172 
173 void CcRoadDepot(Commands, const CommandCost &result, TileIndex tile, RoadType, DiagDirection dir)
174 {
175  if (result.Failed()) return;
176 
177  if (_settings_client.sound.confirm) SndPlayTileFx(SND_1F_CONSTRUCTION_OTHER, tile);
179  ConnectRoadToStructure(tile, dir);
180 }
181 
194 void CcRoadStop(Commands, const CommandCost &result, TileIndex tile, uint8_t width, uint8_t length, RoadStopType, bool is_drive_through,
195  DiagDirection dir, RoadType, RoadStopClassID spec_class, uint16_t spec_index, StationID, bool)
196 {
197  if (result.Failed()) return;
198 
199  if (_settings_client.sound.confirm) SndPlayTileFx(SND_1F_CONSTRUCTION_OTHER, tile);
201 
202  bool connect_to_road = true;
203  if ((uint)spec_class < RoadStopClass::GetClassCount() && spec_index < RoadStopClass::Get(spec_class)->GetSpecCount()) {
204  const RoadStopSpec *roadstopspec = RoadStopClass::Get(spec_class)->GetSpec(spec_index);
205  if (roadstopspec != nullptr && HasBit(roadstopspec->flags, RSF_NO_AUTO_ROAD_CONNECTION)) connect_to_road = false;
206  }
207 
208  if (connect_to_road) {
209  TileArea roadstop_area(tile, width, length);
210  for (TileIndex cur_tile : roadstop_area) {
211  ConnectRoadToStructure(cur_tile, dir);
212  /* For a drive-through road stop build connecting road for other entrance. */
213  if (is_drive_through) ConnectRoadToStructure(cur_tile, ReverseDiagDir(dir));
214  }
215  }
216 }
217 
228 static void PlaceRoadStop(TileIndex start_tile, TileIndex end_tile, RoadStopType stop_type, bool adjacent, RoadType rt, StringID err_msg)
229 {
230  TileArea ta(start_tile, end_tile);
231  DiagDirection ddir = _roadstop_gui.orientation;
232  bool drive_through = ddir >= DIAGDIR_END;
233  if (drive_through) ddir = static_cast<DiagDirection>(ddir - DIAGDIR_END); // Adjust picker result to actual direction.
234  RoadStopClassID spec_class = _roadstop_gui.sel_class;
235  uint16_t spec_index = _roadstop_gui.sel_type;
236 
237  auto proc = [=](bool test, StationID to_join) -> bool {
238  if (test) {
239  return Command<CMD_BUILD_ROAD_STOP>::Do(CommandFlagsToDCFlags(GetCommandFlags<CMD_BUILD_ROAD_STOP>()), ta.tile, ta.w, ta.h, stop_type, drive_through,
240  ddir, rt, spec_class, spec_index, INVALID_STATION, adjacent).Succeeded();
241  } else {
242  return Command<CMD_BUILD_ROAD_STOP>::Post(err_msg, CcRoadStop, ta.tile, ta.w, ta.h, stop_type, drive_through,
243  ddir, rt, spec_class, spec_index, to_join, adjacent);
244  }
245  };
246 
247  ShowSelectStationIfNeeded(ta, proc);
248 }
249 
254 static void PlaceRoad_Waypoint(TileIndex tile)
255 {
258  return;
259  }
260 
261  Axis axis = GetAxisForNewRoadWaypoint(tile);
262  if (IsValidAxis(axis)) {
263  /* Valid tile for waypoints */
265  VpSetPlaceSizingLimit(_settings_game.station.station_spread);
266  } else {
267  /* Tile where we can't build road waypoints. This is always going to fail,
268  * but provides the user with a proper error message. */
269  Command<CMD_BUILD_ROAD_WAYPOINT>::Post(STR_ERROR_CAN_T_BUILD_ROAD_WAYPOINT, tile, AXIS_X, 1, 1, ROADSTOP_CLASS_WAYP, 0, INVALID_STATION, false);
270  }
271 }
272 
278 {
281  } else {
282  if (_roadstop_gui.orientation < DIAGDIR_END) { // Not a drive-through stop.
284  } else {
286  }
287  VpSetPlaceSizingLimit(_settings_game.station.station_spread);
288  }
289 }
290 
296 {
299  } else {
300  if (_roadstop_gui.orientation < DIAGDIR_END) { // Not a drive-through stop.
302  } else {
304  }
305  VpSetPlaceSizingLimit(_settings_game.station.station_spread);
306  }
307 }
308 
309 typedef void OnButtonClick(Window *w);
310 
316 {
320  SetSelectionRed(_remove_button_clicked);
321 }
322 
329 {
330  if (w->IsWidgetDisabled(WID_ROT_REMOVE)) return false;
331 
332  /* allow ctrl to switch remove mode only for these widgets */
333  for (WidgetID i = WID_ROT_ROAD_X; i <= WID_ROT_AUTOROAD; i++) {
334  if (w->IsWidgetLowered(i)) {
336  return true;
337  }
338  }
339 
340  return false;
341 }
342 
346  const RoadTypeInfo *rti;
348 
350  {
351  this->Initialize(_cur_roadtype);
352  this->CreateNestedTree();
353  this->SetupRoadToolbar();
354  this->FinishInitNested(window_number);
356 
357  if (RoadTypeIsRoad(this->roadtype)) {
359  }
360 
361  this->OnInvalidateData();
362  this->last_started_action = INVALID_WID_ROT;
363 
365  }
366 
367  void Close([[maybe_unused]] int data = 0) override
368  {
369  if (_game_mode == GM_NORMAL && (this->IsWidgetLowered(WID_ROT_BUS_STATION) || this->IsWidgetLowered(WID_ROT_TRUCK_STATION))) SetViewportCatchmentStation(nullptr, true);
371  this->Window::Close();
372  }
373 
379  void OnInvalidateData([[maybe_unused]] int data = 0, [[maybe_unused]] bool gui_scope = true) override
380  {
381  if (!gui_scope) return;
382  RoadTramType rtt = GetRoadTramType(this->roadtype);
383 
384  bool can_build = CanBuildVehicleInfrastructure(VEH_ROAD, rtt);
385  this->SetWidgetsDisabledState(!can_build,
390  if (!can_build) {
395  }
396 
397  if (_game_mode != GM_EDITOR) {
398  if (!can_build) {
399  /* Show in the tooltip why this button is disabled. */
400  this->GetWidget<NWidgetCore>(WID_ROT_DEPOT)->SetToolTip(STR_TOOLBAR_DISABLED_NO_VEHICLE_AVAILABLE);
401  this->GetWidget<NWidgetCore>(WID_ROT_BUILD_WAYPOINT)->SetToolTip(STR_TOOLBAR_DISABLED_NO_VEHICLE_AVAILABLE);
402  this->GetWidget<NWidgetCore>(WID_ROT_BUS_STATION)->SetToolTip(STR_TOOLBAR_DISABLED_NO_VEHICLE_AVAILABLE);
403  this->GetWidget<NWidgetCore>(WID_ROT_TRUCK_STATION)->SetToolTip(STR_TOOLBAR_DISABLED_NO_VEHICLE_AVAILABLE);
404  } else {
405  this->GetWidget<NWidgetCore>(WID_ROT_DEPOT)->SetToolTip(rtt == RTT_ROAD ? STR_ROAD_TOOLBAR_TOOLTIP_BUILD_ROAD_VEHICLE_DEPOT : STR_ROAD_TOOLBAR_TOOLTIP_BUILD_TRAM_VEHICLE_DEPOT);
406  this->GetWidget<NWidgetCore>(WID_ROT_BUILD_WAYPOINT)->SetToolTip(rtt == RTT_ROAD ? STR_ROAD_TOOLBAR_TOOLTIP_CONVERT_ROAD_TO_WAYPOINT : STR_ROAD_TOOLBAR_TOOLTIP_CONVERT_TRAM_TO_WAYPOINT);
407  this->GetWidget<NWidgetCore>(WID_ROT_BUS_STATION)->SetToolTip(rtt == RTT_ROAD ? STR_ROAD_TOOLBAR_TOOLTIP_BUILD_BUS_STATION : STR_ROAD_TOOLBAR_TOOLTIP_BUILD_PASSENGER_TRAM_STATION);
408  this->GetWidget<NWidgetCore>(WID_ROT_TRUCK_STATION)->SetToolTip(rtt == RTT_ROAD ? STR_ROAD_TOOLBAR_TOOLTIP_BUILD_TRUCK_LOADING_BAY : STR_ROAD_TOOLBAR_TOOLTIP_BUILD_CARGO_TRAM_STATION);
409  }
410  }
411  }
412 
413  void Initialize(RoadType roadtype)
414  {
415  assert(roadtype < ROADTYPE_END);
416  this->roadtype = roadtype;
417  this->rti = GetRoadTypeInfo(this->roadtype);
418  }
419 
425  {
426  this->GetWidget<NWidgetCore>(WID_ROT_ROAD_X)->widget_data = rti->gui_sprites.build_x_road;
427  this->GetWidget<NWidgetCore>(WID_ROT_ROAD_Y)->widget_data = rti->gui_sprites.build_y_road;
428  this->GetWidget<NWidgetCore>(WID_ROT_AUTOROAD)->widget_data = rti->gui_sprites.auto_road;
429  if (_game_mode != GM_EDITOR) {
430  this->GetWidget<NWidgetCore>(WID_ROT_DEPOT)->widget_data = rti->gui_sprites.build_depot;
431  }
432  this->GetWidget<NWidgetCore>(WID_ROT_CONVERT_ROAD)->widget_data = rti->gui_sprites.convert_road;
433  this->GetWidget<NWidgetCore>(WID_ROT_BUILD_TUNNEL)->widget_data = rti->gui_sprites.build_tunnel;
434  }
435 
441  {
442  this->Initialize(roadtype);
443  this->SetupRoadToolbar();
444  this->ReInit();
445  }
446 
447  void SetStringParameters(WidgetID widget) const override
448  {
449  if (widget == WID_ROT_CAPTION) {
450  if (this->rti->max_speed > 0) {
451  SetDParam(0, STR_TOOLBAR_RAILTYPE_VELOCITY);
452  SetDParam(1, this->rti->strings.toolbar_caption);
453  SetDParam(2, PackVelocity(this->rti->max_speed / 2, VEH_ROAD));
454  } else {
455  SetDParam(0, this->rti->strings.toolbar_caption);
456  }
457  }
458  }
459 
466  {
467  /* The remove and the one way button state is driven
468  * by the other buttons so they don't act on themselves.
469  * Both are only valid if they are able to apply as options. */
470  switch (clicked_widget) {
471  case WID_ROT_REMOVE:
472  if (RoadTypeIsRoad(this->roadtype)) {
475  }
476 
477  break;
478 
479  case WID_ROT_ONE_WAY:
482  break;
483 
484  case WID_ROT_BUS_STATION:
487  if (RoadTypeIsRoad(this->roadtype)) this->DisableWidget(WID_ROT_ONE_WAY);
488  this->SetWidgetDisabledState(WID_ROT_REMOVE, !this->IsWidgetLowered(clicked_widget));
489  break;
490 
491  case WID_ROT_ROAD_X:
492  case WID_ROT_ROAD_Y:
493  case WID_ROT_AUTOROAD:
494  this->SetWidgetDisabledState(WID_ROT_REMOVE, !this->IsWidgetLowered(clicked_widget));
495  if (RoadTypeIsRoad(this->roadtype)) {
496  this->SetWidgetDisabledState(WID_ROT_ONE_WAY, !this->IsWidgetLowered(clicked_widget));
497  }
498  break;
499 
500  default:
501  /* When any other buttons than road/station, raise and
502  * disable the removal button */
505 
506  if (RoadTypeIsRoad(this->roadtype)) {
509  }
510 
511  break;
512  }
513  }
514 
515  void OnClick([[maybe_unused]] Point pt, WidgetID widget, [[maybe_unused]] int click_count) override
516  {
517  _remove_button_clicked = false;
518  _one_way_button_clicked = false;
519  switch (widget) {
520  case WID_ROT_ROAD_X:
522  this->last_started_action = widget;
523  break;
524 
525  case WID_ROT_ROAD_Y:
527  this->last_started_action = widget;
528  break;
529 
530  case WID_ROT_AUTOROAD:
532  this->last_started_action = widget;
533  break;
534 
535  case WID_ROT_DEMOLISH:
537  this->last_started_action = widget;
538  break;
539 
540  case WID_ROT_DEPOT:
541  if (HandlePlacePushButton(this, WID_ROT_DEPOT, this->rti->cursor.depot, HT_RECT)) {
542  ShowRoadDepotPicker(this);
543  this->last_started_action = widget;
544  }
545  break;
546 
548  this->last_started_action = widget;
549  if (HandlePlacePushButton(this, WID_ROT_BUILD_WAYPOINT, SPR_CURSOR_WAYPOINT, HT_RECT)) {
550  ShowBuildRoadWaypointPicker(this);
551  }
552  break;
553 
554  case WID_ROT_BUS_STATION:
555  if (HandlePlacePushButton(this, WID_ROT_BUS_STATION, SPR_CURSOR_BUS_STATION, HT_RECT)) {
556  ShowRVStationPicker(this, ROADSTOP_BUS);
557  this->last_started_action = widget;
558  }
559  break;
560 
562  if (HandlePlacePushButton(this, WID_ROT_TRUCK_STATION, SPR_CURSOR_TRUCK_STATION, HT_RECT)) {
563  ShowRVStationPicker(this, ROADSTOP_TRUCK);
564  this->last_started_action = widget;
565  }
566  break;
567 
568  case WID_ROT_ONE_WAY:
569  if (this->IsWidgetDisabled(WID_ROT_ONE_WAY)) return;
570  this->SetDirty();
572  SetSelectionRed(false);
573  break;
574 
576  HandlePlacePushButton(this, WID_ROT_BUILD_BRIDGE, SPR_CURSOR_BRIDGE, HT_RECT);
577  this->last_started_action = widget;
578  break;
579 
582  this->last_started_action = widget;
583  break;
584 
585  case WID_ROT_REMOVE:
586  if (this->IsWidgetDisabled(WID_ROT_REMOVE)) return;
587 
591  break;
592 
595  this->last_started_action = widget;
596  break;
597 
598  default: NOT_REACHED();
599  }
602  }
603 
604  EventState OnHotkey(int hotkey) override
605  {
606  MarkTileDirtyByTile(TileVirtXY(_thd.pos.x, _thd.pos.y)); // redraw tile selection
607  return Window::OnHotkey(hotkey);
608  }
609 
610  void OnPlaceObject([[maybe_unused]] Point pt, TileIndex tile) override
611  {
613  _one_way_button_clicked = RoadTypeIsRoad(this->roadtype) ? this->IsWidgetLowered(WID_ROT_ONE_WAY) : false;
614  switch (this->last_started_action) {
615  case WID_ROT_ROAD_X:
616  _place_road_dir = AXIS_X;
617  _place_road_start_half_x = _tile_fract_coords.x >= 8;
619  break;
620 
621  case WID_ROT_ROAD_Y:
622  _place_road_dir = AXIS_Y;
623  _place_road_start_half_y = _tile_fract_coords.y >= 8;
625  break;
626 
627  case WID_ROT_AUTOROAD:
628  _place_road_dir = INVALID_AXIS;
629  _place_road_start_half_x = _tile_fract_coords.x >= 8;
630  _place_road_start_half_y = _tile_fract_coords.y >= 8;
632  break;
633 
634  case WID_ROT_DEMOLISH:
636  break;
637 
638  case WID_ROT_DEPOT:
639  Command<CMD_BUILD_ROAD_DEPOT>::Post(this->rti->strings.err_depot, CcRoadDepot,
640  tile, _cur_roadtype, _road_depot_orientation);
641  break;
642 
644  PlaceRoad_Waypoint(tile);
645  break;
646 
647  case WID_ROT_BUS_STATION:
648  PlaceRoad_BusStation(tile);
649  break;
650 
653  break;
654 
656  PlaceRoad_Bridge(tile, this);
657  break;
658 
660  Command<CMD_BUILD_TUNNEL>::Post(STR_ERROR_CAN_T_BUILD_TUNNEL_HERE, CcBuildRoadTunnel,
661  tile, TRANSPORT_ROAD, _cur_roadtype);
662  break;
663 
666  break;
667 
668  default: NOT_REACHED();
669  }
670  }
671 
672  void OnPlaceObjectAbort() override
673  {
674  if (_game_mode != GM_EDITOR && (this->IsWidgetLowered(WID_ROT_BUS_STATION) || this->IsWidgetLowered(WID_ROT_TRUCK_STATION))) SetViewportCatchmentStation(nullptr, true);
675 
676  this->RaiseButtons();
679 
680  if (RoadTypeIsRoad(this->roadtype)) {
683  }
684 
691  }
692 
693  void OnPlaceDrag(ViewportPlaceMethod select_method, [[maybe_unused]] ViewportDragDropSelectionProcess select_proc, [[maybe_unused]] Point pt) override
694  {
695  /* Here we update the end tile flags
696  * of the road placement actions.
697  * At first we reset the end halfroad
698  * bits and if needed we set them again. */
699  switch (select_proc) {
701  _place_road_end_half = pt.x & 8;
702  break;
703 
705  _place_road_end_half = pt.y & 8;
706  break;
707 
708  case DDSP_PLACE_AUTOROAD:
709  /* For autoroad we need to update the
710  * direction of the road */
711  if (_thd.size.x > _thd.size.y || (_thd.size.x == _thd.size.y &&
712  ( (_tile_fract_coords.x < _tile_fract_coords.y && (_tile_fract_coords.x + _tile_fract_coords.y) < 16) ||
713  (_tile_fract_coords.x > _tile_fract_coords.y && (_tile_fract_coords.x + _tile_fract_coords.y) > 16) ))) {
714  /* Set dir = X */
715  _place_road_dir = AXIS_X;
716  _place_road_end_half = pt.x & 8;
717  } else {
718  /* Set dir = Y */
719  _place_road_dir = AXIS_Y;
720  _place_road_end_half = pt.y & 8;
721  }
722 
723  break;
724 
725  default:
726  break;
727  }
728 
729  VpSelectTilesWithMethod(pt.x, pt.y, select_method);
730  }
731 
732  void OnPlaceMouseUp([[maybe_unused]] ViewportPlaceMethod select_method, ViewportDragDropSelectionProcess select_proc, [[maybe_unused]] Point pt, TileIndex start_tile, TileIndex end_tile) override
733  {
734  if (pt.x != -1) {
735  switch (select_proc) {
736  default: NOT_REACHED();
737  case DDSP_BUILD_BRIDGE:
739  ShowBuildBridgeWindow(start_tile, end_tile, TRANSPORT_ROAD, _cur_roadtype);
740  break;
741 
742  case DDSP_DEMOLISH_AREA:
743  GUIPlaceProcDragXY(select_proc, start_tile, end_tile);
744  break;
745 
748  case DDSP_PLACE_AUTOROAD: {
749  bool start_half = _place_road_dir == AXIS_Y ? _place_road_start_half_y : _place_road_start_half_x;
750 
752  Command<CMD_REMOVE_LONG_ROAD>::Post(this->rti->strings.err_remove_road, CcPlaySound_CONSTRUCTION_OTHER,
753  end_tile, start_tile, _cur_roadtype, _place_road_dir, start_half, _place_road_end_half);
754  } else {
755  Command<CMD_BUILD_LONG_ROAD>::Post(this->rti->strings.err_build_road, CcPlaySound_CONSTRUCTION_OTHER,
756  end_tile, start_tile, _cur_roadtype, _place_road_dir, _one_way_button_clicked ? DRD_NORTHBOUND : DRD_NONE, start_half, _place_road_end_half, false);
757  }
758  break;
759  }
760 
765  Command<CMD_REMOVE_FROM_ROAD_WAYPOINT>::Post(STR_ERROR_CAN_T_REMOVE_ROAD_WAYPOINT, CcPlaySound_CONSTRUCTION_OTHER, end_tile, start_tile);
766  } else {
767  TileArea ta(start_tile, end_tile);
768  Axis axis = select_method == VPM_X_LIMITED ? AXIS_X : AXIS_Y;
769  bool adjacent = _ctrl_pressed;
770 
771  auto proc = [=](bool test, StationID to_join) -> bool {
772  if (test) {
773  return Command<CMD_BUILD_ROAD_WAYPOINT>::Do(CommandFlagsToDCFlags(GetCommandFlags<CMD_BUILD_ROAD_WAYPOINT>()), ta.tile, axis, ta.w, ta.h, _waypoint_gui.sel_class, _waypoint_gui.sel_type, INVALID_STATION, adjacent).Succeeded();
774  } else {
775  return Command<CMD_BUILD_ROAD_WAYPOINT>::Post(STR_ERROR_CAN_T_BUILD_ROAD_WAYPOINT, CcPlaySound_CONSTRUCTION_OTHER, ta.tile, axis, ta.w, ta.h, _waypoint_gui.sel_class, _waypoint_gui.sel_type, to_join, adjacent);
776  }
777  };
778 
780  }
781  }
782  break;
783 
784  case DDSP_BUILD_BUSSTOP:
785  case DDSP_REMOVE_BUSSTOP:
788  TileArea ta(start_tile, end_tile);
789  Command<CMD_REMOVE_ROAD_STOP>::Post(this->rti->strings.err_remove_station[ROADSTOP_BUS], CcPlaySound_CONSTRUCTION_OTHER, ta.tile, ta.w, ta.h, ROADSTOP_BUS, _ctrl_pressed);
790  } else {
791  PlaceRoadStop(start_tile, end_tile, ROADSTOP_BUS, _ctrl_pressed, _cur_roadtype, this->rti->strings.err_build_station[ROADSTOP_BUS]);
792  }
793  }
794  break;
795 
800  TileArea ta(start_tile, end_tile);
801  Command<CMD_REMOVE_ROAD_STOP>::Post(this->rti->strings.err_remove_station[ROADSTOP_TRUCK], CcPlaySound_CONSTRUCTION_OTHER, ta.tile, ta.w, ta.h, ROADSTOP_TRUCK, _ctrl_pressed);
802  } else {
803  PlaceRoadStop(start_tile, end_tile, ROADSTOP_TRUCK, _ctrl_pressed, _cur_roadtype, this->rti->strings.err_build_station[ROADSTOP_TRUCK]);
804  }
805  }
806  break;
807 
808  case DDSP_CONVERT_ROAD:
809  Command<CMD_CONVERT_ROAD>::Post(rti->strings.err_convert_road, CcPlaySound_CONSTRUCTION_OTHER, end_tile, start_tile, _cur_roadtype);
810  break;
811  }
812  }
813  }
814 
815  void OnPlacePresize([[maybe_unused]] Point pt, TileIndex tile) override
816  {
819  }
820 
822  {
823  if (RoadToolbar_CtrlChanged(this)) return ES_HANDLED;
824  return ES_NOT_HANDLED;
825  }
826 
827  void OnRealtimeTick([[maybe_unused]] uint delta_ms) override
828  {
829  if (_game_mode == GM_NORMAL && this->IsWidgetLowered(WID_ROT_BUILD_WAYPOINT)) CheckRedrawRoadWaypointCoverage(this);
830  }
831 
838  static EventState RoadTramToolbarGlobalHotkeys(int hotkey, RoadType last_build, RoadTramType rtt)
839  {
840  Window *w = nullptr;
841  switch (_game_mode) {
842  case GM_NORMAL:
843  w = ShowBuildRoadToolbar(last_build);
844  break;
845 
846  case GM_EDITOR:
847  if ((GetRoadTypes(true) & ((rtt == RTT_ROAD) ? ~_roadtypes_type : _roadtypes_type)) == ROADTYPES_NONE) return ES_NOT_HANDLED;
848  w = ShowBuildRoadScenToolbar(last_build);
849  break;
850 
851  default:
852  break;
853  }
854 
855  if (w == nullptr) return ES_NOT_HANDLED;
856  return w->OnHotkey(hotkey);
857  }
858 
859  static EventState RoadToolbarGlobalHotkeys(int hotkey)
860  {
861  extern RoadType _last_built_roadtype;
862  return RoadTramToolbarGlobalHotkeys(hotkey, _last_built_roadtype, RTT_ROAD);
863  }
864 
865  static EventState TramToolbarGlobalHotkeys(int hotkey)
866  {
867  extern RoadType _last_built_tramtype;
868  return RoadTramToolbarGlobalHotkeys(hotkey, _last_built_tramtype, RTT_TRAM);
869  }
870 
871  static inline HotkeyList road_hotkeys{"roadtoolbar", {
872  Hotkey('1', "build_x", WID_ROT_ROAD_X),
873  Hotkey('2', "build_y", WID_ROT_ROAD_Y),
874  Hotkey('3', "autoroad", WID_ROT_AUTOROAD),
875  Hotkey('4', "demolish", WID_ROT_DEMOLISH),
876  Hotkey('5', "depot", WID_ROT_DEPOT),
877  Hotkey('6', "bus_station", WID_ROT_BUS_STATION),
878  Hotkey('7', "truck_station", WID_ROT_TRUCK_STATION),
879  Hotkey('8', "oneway", WID_ROT_ONE_WAY),
880  Hotkey('9', "waypoint", WID_ROT_BUILD_WAYPOINT),
881  Hotkey('B', "bridge", WID_ROT_BUILD_BRIDGE),
882  Hotkey('T', "tunnel", WID_ROT_BUILD_TUNNEL),
883  Hotkey('R', "remove", WID_ROT_REMOVE),
884  Hotkey('C', "convert", WID_ROT_CONVERT_ROAD),
885  }, RoadToolbarGlobalHotkeys};
886 
887  static inline HotkeyList tram_hotkeys{"tramtoolbar", {
888  Hotkey('1', "build_x", WID_ROT_ROAD_X),
889  Hotkey('2', "build_y", WID_ROT_ROAD_Y),
890  Hotkey('3', "autoroad", WID_ROT_AUTOROAD),
891  Hotkey('4', "demolish", WID_ROT_DEMOLISH),
892  Hotkey('5', "depot", WID_ROT_DEPOT),
893  Hotkey('6', "bus_station", WID_ROT_BUS_STATION),
894  Hotkey('7', "truck_station", WID_ROT_TRUCK_STATION),
895  Hotkey('9', "waypoint", WID_ROT_BUILD_WAYPOINT),
896  Hotkey('B', "bridge", WID_ROT_BUILD_BRIDGE),
897  Hotkey('T', "tunnel", WID_ROT_BUILD_TUNNEL),
898  Hotkey('R', "remove", WID_ROT_REMOVE),
899  Hotkey('C', "convert", WID_ROT_CONVERT_ROAD),
900  }, TramToolbarGlobalHotkeys};
901 };
902 
903 static constexpr NWidgetPart _nested_build_road_widgets[] = {
905  NWidget(WWT_CLOSEBOX, COLOUR_DARK_GREEN),
906  NWidget(WWT_CAPTION, COLOUR_DARK_GREEN, WID_ROT_CAPTION), SetDataTip(STR_JUST_STRING2, STR_TOOLTIP_WINDOW_TITLE_DRAG_THIS), SetTextStyle(TC_WHITE),
907  NWidget(WWT_STICKYBOX, COLOUR_DARK_GREEN),
908  EndContainer(),
910  NWidget(WWT_IMGBTN, COLOUR_DARK_GREEN, WID_ROT_ROAD_X),
911  SetFill(0, 1), SetMinimalSize(22, 22), SetDataTip(SPR_IMG_ROAD_X_DIR, STR_ROAD_TOOLBAR_TOOLTIP_BUILD_ROAD_SECTION),
912  NWidget(WWT_IMGBTN, COLOUR_DARK_GREEN, WID_ROT_ROAD_Y),
913  SetFill(0, 1), SetMinimalSize(22, 22), SetDataTip(SPR_IMG_ROAD_Y_DIR, STR_ROAD_TOOLBAR_TOOLTIP_BUILD_ROAD_SECTION),
914  NWidget(WWT_IMGBTN, COLOUR_DARK_GREEN, WID_ROT_AUTOROAD),
915  SetFill(0, 1), SetMinimalSize(22, 22), SetDataTip(SPR_IMG_AUTOROAD, STR_ROAD_TOOLBAR_TOOLTIP_BUILD_AUTOROAD),
916  NWidget(WWT_IMGBTN, COLOUR_DARK_GREEN, WID_ROT_DEMOLISH),
917  SetFill(0, 1), SetMinimalSize(22, 22), SetDataTip(SPR_IMG_DYNAMITE, STR_TOOLTIP_DEMOLISH_BUILDINGS_ETC),
918  NWidget(WWT_IMGBTN, COLOUR_DARK_GREEN, WID_ROT_DEPOT),
919  SetFill(0, 1), SetMinimalSize(22, 22), SetDataTip(SPR_IMG_ROAD_DEPOT, STR_ROAD_TOOLBAR_TOOLTIP_BUILD_ROAD_VEHICLE_DEPOT),
920  NWidget(WWT_IMGBTN, COLOUR_DARK_GREEN, WID_ROT_BUILD_WAYPOINT),
921  SetFill(0, 1), SetMinimalSize(22, 22), SetDataTip(SPR_IMG_WAYPOINT, STR_ROAD_TOOLBAR_TOOLTIP_CONVERT_ROAD_TO_WAYPOINT),
922  NWidget(WWT_IMGBTN, COLOUR_DARK_GREEN, WID_ROT_BUS_STATION),
923  SetFill(0, 1), SetMinimalSize(22, 22), SetDataTip(SPR_IMG_BUS_STATION, STR_ROAD_TOOLBAR_TOOLTIP_BUILD_BUS_STATION),
924  NWidget(WWT_IMGBTN, COLOUR_DARK_GREEN, WID_ROT_TRUCK_STATION),
925  SetFill(0, 1), SetMinimalSize(22, 22), SetDataTip(SPR_IMG_TRUCK_BAY, STR_ROAD_TOOLBAR_TOOLTIP_BUILD_TRUCK_LOADING_BAY),
926  NWidget(WWT_PANEL, COLOUR_DARK_GREEN, -1), SetMinimalSize(0, 22), SetFill(1, 1), EndContainer(),
927  NWidget(WWT_IMGBTN, COLOUR_DARK_GREEN, WID_ROT_ONE_WAY),
928  SetFill(0, 1), SetMinimalSize(22, 22), SetDataTip(SPR_IMG_ROAD_ONE_WAY, STR_ROAD_TOOLBAR_TOOLTIP_TOGGLE_ONE_WAY_ROAD),
929  NWidget(WWT_IMGBTN, COLOUR_DARK_GREEN, WID_ROT_BUILD_BRIDGE),
930  SetFill(0, 1), SetMinimalSize(43, 22), SetDataTip(SPR_IMG_BRIDGE, STR_ROAD_TOOLBAR_TOOLTIP_BUILD_ROAD_BRIDGE),
931  NWidget(WWT_IMGBTN, COLOUR_DARK_GREEN, WID_ROT_BUILD_TUNNEL),
932  SetFill(0, 1), SetMinimalSize(22, 22), SetDataTip(SPR_IMG_ROAD_TUNNEL, STR_ROAD_TOOLBAR_TOOLTIP_BUILD_ROAD_TUNNEL),
933  NWidget(WWT_IMGBTN, COLOUR_DARK_GREEN, WID_ROT_REMOVE),
934  SetFill(0, 1), SetMinimalSize(22, 22), SetDataTip(SPR_IMG_REMOVE, STR_ROAD_TOOLBAR_TOOLTIP_TOGGLE_BUILD_REMOVE_FOR_ROAD),
935  NWidget(WWT_IMGBTN, COLOUR_DARK_GREEN, WID_ROT_CONVERT_ROAD),
936  SetFill(0, 1), SetMinimalSize(22, 22), SetDataTip(SPR_IMG_CONVERT_ROAD, STR_ROAD_TOOLBAR_TOOLTIP_CONVERT_ROAD),
937  EndContainer(),
938 };
939 
940 static WindowDesc _build_road_desc(
941  WDP_ALIGN_TOOLBAR, "toolbar_road", 0, 0,
944  _nested_build_road_widgets,
945  &BuildRoadToolbarWindow::road_hotkeys
946 );
947 
948 static constexpr NWidgetPart _nested_build_tramway_widgets[] = {
950  NWidget(WWT_CLOSEBOX, COLOUR_DARK_GREEN),
951  NWidget(WWT_CAPTION, COLOUR_DARK_GREEN, WID_ROT_CAPTION), SetDataTip(STR_JUST_STRING2, STR_TOOLTIP_WINDOW_TITLE_DRAG_THIS), SetTextStyle(TC_WHITE),
952  NWidget(WWT_STICKYBOX, COLOUR_DARK_GREEN),
953  EndContainer(),
955  NWidget(WWT_IMGBTN, COLOUR_DARK_GREEN, WID_ROT_ROAD_X),
956  SetFill(0, 1), SetMinimalSize(22, 22), SetDataTip(SPR_IMG_TRAMWAY_X_DIR, STR_ROAD_TOOLBAR_TOOLTIP_BUILD_TRAMWAY_SECTION),
957  NWidget(WWT_IMGBTN, COLOUR_DARK_GREEN, WID_ROT_ROAD_Y),
958  SetFill(0, 1), SetMinimalSize(22, 22), SetDataTip(SPR_IMG_TRAMWAY_Y_DIR, STR_ROAD_TOOLBAR_TOOLTIP_BUILD_TRAMWAY_SECTION),
959  NWidget(WWT_IMGBTN, COLOUR_DARK_GREEN, WID_ROT_AUTOROAD),
960  SetFill(0, 1), SetMinimalSize(22, 22), SetDataTip(SPR_IMG_AUTOTRAM, STR_ROAD_TOOLBAR_TOOLTIP_BUILD_AUTOTRAM),
961  NWidget(WWT_IMGBTN, COLOUR_DARK_GREEN, WID_ROT_DEMOLISH),
962  SetFill(0, 1), SetMinimalSize(22, 22), SetDataTip(SPR_IMG_DYNAMITE, STR_TOOLTIP_DEMOLISH_BUILDINGS_ETC),
963  NWidget(WWT_IMGBTN, COLOUR_DARK_GREEN, WID_ROT_DEPOT),
964  SetFill(0, 1), SetMinimalSize(22, 22), SetDataTip(SPR_IMG_ROAD_DEPOT, STR_ROAD_TOOLBAR_TOOLTIP_BUILD_TRAM_VEHICLE_DEPOT),
965  NWidget(WWT_IMGBTN, COLOUR_DARK_GREEN, WID_ROT_BUILD_WAYPOINT),
966  SetFill(0, 1), SetMinimalSize(22, 22), SetDataTip(SPR_IMG_WAYPOINT, STR_ROAD_TOOLBAR_TOOLTIP_CONVERT_TRAM_TO_WAYPOINT),
967  NWidget(WWT_IMGBTN, COLOUR_DARK_GREEN, WID_ROT_BUS_STATION),
968  SetFill(0, 1), SetMinimalSize(22, 22), SetDataTip(SPR_IMG_BUS_STATION, STR_ROAD_TOOLBAR_TOOLTIP_BUILD_PASSENGER_TRAM_STATION),
969  NWidget(WWT_IMGBTN, COLOUR_DARK_GREEN, WID_ROT_TRUCK_STATION),
970  SetFill(0, 1), SetMinimalSize(22, 22), SetDataTip(SPR_IMG_TRUCK_BAY, STR_ROAD_TOOLBAR_TOOLTIP_BUILD_CARGO_TRAM_STATION),
971  NWidget(WWT_PANEL, COLOUR_DARK_GREEN, -1), SetMinimalSize(0, 22), SetFill(1, 1), EndContainer(),
972  NWidget(WWT_IMGBTN, COLOUR_DARK_GREEN, WID_ROT_BUILD_BRIDGE),
973  SetFill(0, 1), SetMinimalSize(43, 22), SetDataTip(SPR_IMG_BRIDGE, STR_ROAD_TOOLBAR_TOOLTIP_BUILD_TRAMWAY_BRIDGE),
974  NWidget(WWT_IMGBTN, COLOUR_DARK_GREEN, WID_ROT_BUILD_TUNNEL),
975  SetFill(0, 1), SetMinimalSize(22, 22), SetDataTip(SPR_IMG_ROAD_TUNNEL, STR_ROAD_TOOLBAR_TOOLTIP_BUILD_TRAMWAY_TUNNEL),
976  NWidget(WWT_IMGBTN, COLOUR_DARK_GREEN, WID_ROT_REMOVE),
977  SetFill(0, 1), SetMinimalSize(22, 22), SetDataTip(SPR_IMG_REMOVE, STR_ROAD_TOOLBAR_TOOLTIP_TOGGLE_BUILD_REMOVE_FOR_TRAMWAYS),
978  NWidget(WWT_IMGBTN, COLOUR_DARK_GREEN, WID_ROT_CONVERT_ROAD),
979  SetFill(0, 1), SetMinimalSize(22, 22), SetDataTip(SPR_IMG_CONVERT_ROAD, STR_ROAD_TOOLBAR_TOOLTIP_CONVERT_TRAM),
980  EndContainer(),
981 };
982 
983 static WindowDesc _build_tramway_desc(
984  WDP_ALIGN_TOOLBAR, "toolbar_tramway", 0, 0,
987  _nested_build_tramway_widgets,
988  &BuildRoadToolbarWindow::tram_hotkeys
989 );
990 
999 {
1000  if (!Company::IsValidID(_local_company)) return nullptr;
1001  if (!ValParamRoadType(roadtype)) return nullptr;
1002 
1004  _cur_roadtype = roadtype;
1005 
1006  return AllocateWindowDescFront<BuildRoadToolbarWindow>(RoadTypeIsRoad(_cur_roadtype) ? _build_road_desc : _build_tramway_desc, TRANSPORT_ROAD);
1007 }
1008 
1009 static constexpr NWidgetPart _nested_build_road_scen_widgets[] = {
1011  NWidget(WWT_CLOSEBOX, COLOUR_DARK_GREEN),
1012  NWidget(WWT_CAPTION, COLOUR_DARK_GREEN, WID_ROT_CAPTION), SetDataTip(STR_JUST_STRING2, STR_TOOLTIP_WINDOW_TITLE_DRAG_THIS), SetTextStyle(TC_WHITE),
1013  NWidget(WWT_STICKYBOX, COLOUR_DARK_GREEN),
1014  EndContainer(),
1016  NWidget(WWT_IMGBTN, COLOUR_DARK_GREEN, WID_ROT_ROAD_X),
1017  SetFill(0, 1), SetMinimalSize(22, 22), SetDataTip(SPR_IMG_ROAD_X_DIR, STR_ROAD_TOOLBAR_TOOLTIP_BUILD_ROAD_SECTION),
1018  NWidget(WWT_IMGBTN, COLOUR_DARK_GREEN, WID_ROT_ROAD_Y),
1019  SetFill(0, 1), SetMinimalSize(22, 22), SetDataTip(SPR_IMG_ROAD_Y_DIR, STR_ROAD_TOOLBAR_TOOLTIP_BUILD_ROAD_SECTION),
1020  NWidget(WWT_IMGBTN, COLOUR_DARK_GREEN, WID_ROT_AUTOROAD),
1021  SetFill(0, 1), SetMinimalSize(22, 22), SetDataTip(SPR_IMG_AUTOROAD, STR_ROAD_TOOLBAR_TOOLTIP_BUILD_AUTOROAD),
1022  NWidget(WWT_IMGBTN, COLOUR_DARK_GREEN, WID_ROT_DEMOLISH),
1023  SetFill(0, 1), SetMinimalSize(22, 22), SetDataTip(SPR_IMG_DYNAMITE, STR_TOOLTIP_DEMOLISH_BUILDINGS_ETC),
1024  NWidget(WWT_PANEL, COLOUR_DARK_GREEN, -1), SetMinimalSize(0, 22), SetFill(1, 1), EndContainer(),
1025  NWidget(WWT_IMGBTN, COLOUR_DARK_GREEN, WID_ROT_ONE_WAY),
1026  SetFill(0, 1), SetMinimalSize(22, 22), SetDataTip(SPR_IMG_ROAD_ONE_WAY, STR_ROAD_TOOLBAR_TOOLTIP_TOGGLE_ONE_WAY_ROAD),
1027  NWidget(WWT_IMGBTN, COLOUR_DARK_GREEN, WID_ROT_BUILD_BRIDGE),
1028  SetFill(0, 1), SetMinimalSize(43, 22), SetDataTip(SPR_IMG_BRIDGE, STR_ROAD_TOOLBAR_TOOLTIP_BUILD_ROAD_BRIDGE),
1029  NWidget(WWT_IMGBTN, COLOUR_DARK_GREEN, WID_ROT_BUILD_TUNNEL),
1030  SetFill(0, 1), SetMinimalSize(22, 22), SetDataTip(SPR_IMG_ROAD_TUNNEL, STR_ROAD_TOOLBAR_TOOLTIP_BUILD_ROAD_TUNNEL),
1031  NWidget(WWT_IMGBTN, COLOUR_DARK_GREEN, WID_ROT_REMOVE),
1032  SetFill(0, 1), SetMinimalSize(22, 22), SetDataTip(SPR_IMG_REMOVE, STR_ROAD_TOOLBAR_TOOLTIP_TOGGLE_BUILD_REMOVE_FOR_ROAD),
1033  NWidget(WWT_IMGBTN, COLOUR_DARK_GREEN, WID_ROT_CONVERT_ROAD),
1034  SetFill(0, 1), SetMinimalSize(22, 22), SetDataTip(SPR_IMG_CONVERT_ROAD, STR_ROAD_TOOLBAR_TOOLTIP_CONVERT_ROAD),
1035  EndContainer(),
1036 };
1037 
1038 static WindowDesc _build_road_scen_desc(
1039  WDP_AUTO, "toolbar_road_scen", 0, 0,
1042  _nested_build_road_scen_widgets,
1043  &BuildRoadToolbarWindow::road_hotkeys
1044 );
1045 
1046 static constexpr NWidgetPart _nested_build_tramway_scen_widgets[] = {
1048  NWidget(WWT_CLOSEBOX, COLOUR_DARK_GREEN),
1049  NWidget(WWT_CAPTION, COLOUR_DARK_GREEN, WID_ROT_CAPTION), SetDataTip(STR_JUST_STRING2, STR_TOOLTIP_WINDOW_TITLE_DRAG_THIS), SetTextStyle(TC_WHITE),
1050  NWidget(WWT_STICKYBOX, COLOUR_DARK_GREEN),
1051  EndContainer(),
1053  NWidget(WWT_IMGBTN, COLOUR_DARK_GREEN, WID_ROT_ROAD_X),
1054  SetFill(0, 1), SetMinimalSize(22, 22), SetDataTip(SPR_IMG_TRAMWAY_X_DIR, STR_ROAD_TOOLBAR_TOOLTIP_BUILD_TRAMWAY_SECTION),
1055  NWidget(WWT_IMGBTN, COLOUR_DARK_GREEN, WID_ROT_ROAD_Y),
1056  SetFill(0, 1), SetMinimalSize(22, 22), SetDataTip(SPR_IMG_TRAMWAY_Y_DIR, STR_ROAD_TOOLBAR_TOOLTIP_BUILD_TRAMWAY_SECTION),
1057  NWidget(WWT_IMGBTN, COLOUR_DARK_GREEN, WID_ROT_AUTOROAD),
1058  SetFill(0, 1), SetMinimalSize(22, 22), SetDataTip(SPR_IMG_AUTOTRAM, STR_ROAD_TOOLBAR_TOOLTIP_BUILD_AUTOTRAM),
1059  NWidget(WWT_IMGBTN, COLOUR_DARK_GREEN, WID_ROT_DEMOLISH),
1060  SetFill(0, 1), SetMinimalSize(22, 22), SetDataTip(SPR_IMG_DYNAMITE, STR_TOOLTIP_DEMOLISH_BUILDINGS_ETC),
1061  NWidget(WWT_PANEL, COLOUR_DARK_GREEN, -1), SetMinimalSize(0, 22), SetFill(1, 1), EndContainer(),
1062  NWidget(WWT_IMGBTN, COLOUR_DARK_GREEN, WID_ROT_BUILD_BRIDGE),
1063  SetFill(0, 1), SetMinimalSize(43, 22), SetDataTip(SPR_IMG_BRIDGE, STR_ROAD_TOOLBAR_TOOLTIP_BUILD_TRAMWAY_BRIDGE),
1064  NWidget(WWT_IMGBTN, COLOUR_DARK_GREEN, WID_ROT_BUILD_TUNNEL),
1065  SetFill(0, 1), SetMinimalSize(22, 22), SetDataTip(SPR_IMG_ROAD_TUNNEL, STR_ROAD_TOOLBAR_TOOLTIP_BUILD_TRAMWAY_TUNNEL),
1066  NWidget(WWT_IMGBTN, COLOUR_DARK_GREEN, WID_ROT_REMOVE),
1067  SetFill(0, 1), SetMinimalSize(22, 22), SetDataTip(SPR_IMG_REMOVE, STR_ROAD_TOOLBAR_TOOLTIP_TOGGLE_BUILD_REMOVE_FOR_TRAMWAYS),
1068  NWidget(WWT_IMGBTN, COLOUR_DARK_GREEN, WID_ROT_CONVERT_ROAD),
1069  SetFill(0, 1), SetMinimalSize(22, 22), SetDataTip(SPR_IMG_CONVERT_ROAD, STR_ROAD_TOOLBAR_TOOLTIP_CONVERT_TRAM),
1070  EndContainer(),
1071 };
1072 
1073 static WindowDesc _build_tramway_scen_desc(
1074  WDP_AUTO, "toolbar_tram_scen", 0, 0,
1077  _nested_build_tramway_scen_widgets,
1078  &BuildRoadToolbarWindow::tram_hotkeys
1079 );
1080 
1086 {
1088  _cur_roadtype = roadtype;
1089 
1090  return AllocateWindowDescFront<BuildRoadToolbarWindow>(RoadTypeIsRoad(_cur_roadtype) ? _build_road_scen_desc : _build_tramway_scen_desc, TRANSPORT_ROAD);
1091 }
1092 
1095  {
1096  this->CreateNestedTree();
1097 
1098  this->LowerWidget(WID_BROD_DEPOT_NE + _road_depot_orientation);
1099  if (RoadTypeIsTram(_cur_roadtype)) {
1100  this->GetWidget<NWidgetCore>(WID_BROD_CAPTION)->widget_data = STR_BUILD_DEPOT_TRAM_ORIENTATION_CAPTION;
1101  for (WidgetID i = WID_BROD_DEPOT_NE; i <= WID_BROD_DEPOT_NW; i++) {
1102  this->GetWidget<NWidgetCore>(i)->tool_tip = STR_BUILD_DEPOT_TRAM_ORIENTATION_SELECT_TOOLTIP;
1103  }
1104  }
1105 
1107  }
1108 
1109  void UpdateWidgetSize(WidgetID widget, Dimension &size, [[maybe_unused]] const Dimension &padding, [[maybe_unused]] Dimension &fill, [[maybe_unused]] Dimension &resize) override
1110  {
1111  if (!IsInsideMM(widget, WID_BROD_DEPOT_NE, WID_BROD_DEPOT_NW + 1)) return;
1112 
1115  }
1116 
1117  void DrawWidget(const Rect &r, WidgetID widget) const override
1118  {
1119  if (!IsInsideMM(widget, WID_BROD_DEPOT_NE, WID_BROD_DEPOT_NW + 1)) return;
1120 
1121  DrawPixelInfo tmp_dpi;
1122  Rect ir = r.Shrink(WidgetDimensions::scaled.bevel);
1123  if (FillDrawPixelInfo(&tmp_dpi, ir)) {
1124  AutoRestoreBackup dpi_backup(_cur_dpi, &tmp_dpi);
1125  int x = (ir.Width() - ScaleSpriteTrad(64)) / 2 + ScaleSpriteTrad(31);
1126  int y = (ir.Height() + ScaleSpriteTrad(48)) / 2 - ScaleSpriteTrad(31);
1127  DrawRoadDepotSprite(x, y, (DiagDirection)(widget - WID_BROD_DEPOT_NE + DIAGDIR_NE), _cur_roadtype);
1128  }
1129  }
1130 
1131  void OnClick([[maybe_unused]] Point pt, WidgetID widget, [[maybe_unused]] int click_count) override
1132  {
1133  switch (widget) {
1134  case WID_BROD_DEPOT_NW:
1135  case WID_BROD_DEPOT_NE:
1136  case WID_BROD_DEPOT_SW:
1137  case WID_BROD_DEPOT_SE:
1138  this->RaiseWidget(WID_BROD_DEPOT_NE + _road_depot_orientation);
1139  _road_depot_orientation = (DiagDirection)(widget - WID_BROD_DEPOT_NE);
1140  this->LowerWidget(WID_BROD_DEPOT_NE + _road_depot_orientation);
1141  if (_settings_client.sound.click_beep) SndPlayFx(SND_15_BEEP);
1142  this->SetDirty();
1143  break;
1144 
1145  default:
1146  break;
1147  }
1148  }
1149 };
1150 
1151 static constexpr NWidgetPart _nested_build_road_depot_widgets[] = {
1153  NWidget(WWT_CLOSEBOX, COLOUR_DARK_GREEN),
1154  NWidget(WWT_CAPTION, COLOUR_DARK_GREEN, WID_BROD_CAPTION), SetDataTip(STR_BUILD_DEPOT_ROAD_ORIENTATION_CAPTION, STR_TOOLTIP_WINDOW_TITLE_DRAG_THIS),
1155  EndContainer(),
1156  NWidget(WWT_PANEL, COLOUR_DARK_GREEN),
1159  NWidget(WWT_TEXTBTN, COLOUR_GREY, WID_BROD_DEPOT_NW), SetFill(0, 0), SetDataTip(0x0, STR_BUILD_DEPOT_ROAD_ORIENTATION_SELECT_TOOLTIP),
1160  NWidget(WWT_TEXTBTN, COLOUR_GREY, WID_BROD_DEPOT_SW), SetFill(0, 0), SetDataTip(0x0, STR_BUILD_DEPOT_ROAD_ORIENTATION_SELECT_TOOLTIP),
1161  EndContainer(),
1163  NWidget(WWT_TEXTBTN, COLOUR_GREY, WID_BROD_DEPOT_NE), SetFill(0, 0), SetDataTip(0x0, STR_BUILD_DEPOT_ROAD_ORIENTATION_SELECT_TOOLTIP),
1164  NWidget(WWT_TEXTBTN, COLOUR_GREY, WID_BROD_DEPOT_SE), SetFill(0, 0), SetDataTip(0x0, STR_BUILD_DEPOT_ROAD_ORIENTATION_SELECT_TOOLTIP),
1165  EndContainer(),
1166  EndContainer(),
1167  EndContainer(),
1168 };
1169 
1170 static WindowDesc _build_road_depot_desc(
1171  WDP_AUTO, nullptr, 0, 0,
1174  _nested_build_road_depot_widgets
1175 );
1176 
1177 static void ShowRoadDepotPicker(Window *parent)
1178 {
1179  new BuildRoadDepotWindow(_build_road_depot_desc, parent);
1180 }
1181 
1182 template <RoadStopType roadstoptype>
1184 public:
1186 
1187  StringID GetClassTooltip() const override;
1188  StringID GetTypeTooltip() const override;
1189 
1190  bool IsActive() const override
1191  {
1192  for (const auto &cls : RoadStopClass::Classes()) {
1193  if (IsWaypointClass(cls)) continue;
1194  for (const auto *spec : cls.Specs()) {
1195  if (spec == nullptr) continue;
1196  if (roadstoptype == ROADSTOP_TRUCK && spec->stop_type != ROADSTOPTYPE_FREIGHT && spec->stop_type != ROADSTOPTYPE_ALL) continue;
1197  if (roadstoptype == ROADSTOP_BUS && spec->stop_type != ROADSTOPTYPE_PASSENGER && spec->stop_type != ROADSTOPTYPE_ALL) continue;
1198  return true;
1199  }
1200  }
1201  return false;
1202  }
1203 
1204  static bool IsClassChoice(const RoadStopClass &cls)
1205  {
1206  return !IsWaypointClass(cls) && GetIfClassHasNewStopsByType(&cls, roadstoptype, _cur_roadtype);
1207  }
1208 
1209  bool HasClassChoice() const override
1210  {
1211  return std::count_if(std::begin(RoadStopClass::Classes()), std::end(RoadStopClass::Classes()), IsClassChoice);
1212  }
1213 
1214  int GetSelectedClass() const override { return _roadstop_gui.sel_class; }
1215  void SetSelectedClass(int id) const override { _roadstop_gui.sel_class = this->GetClassIndex(id); }
1216 
1217  StringID GetClassName(int id) const override
1218  {
1219  const auto *rsc = this->GetClass(id);
1220  if (!IsClassChoice(*rsc)) return INVALID_STRING_ID;
1221  return rsc->name;
1222  }
1223 
1224  int GetSelectedType() const override { return _roadstop_gui.sel_type; }
1225  void SetSelectedType(int id) const override { _roadstop_gui.sel_type = id; }
1226 
1227  StringID GetTypeName(int cls_id, int id) const override
1228  {
1229  const auto *spec = this->GetSpec(cls_id, id);
1230  if (!IsRoadStopEverAvailable(spec, roadstoptype == ROADSTOP_BUS ? STATION_BUS : STATION_TRUCK)) return INVALID_STRING_ID;
1231  return (spec == nullptr) ? STR_STATION_CLASS_DFLT_ROADSTOP : spec->name;
1232  }
1233 
1234  bool IsTypeAvailable(int cls_id, int id) const override
1235  {
1236  const auto *spec = this->GetSpec(cls_id, id);
1237  return IsRoadStopAvailable(spec, roadstoptype == ROADSTOP_BUS ? STATION_BUS : STATION_TRUCK);
1238  }
1239 
1240  void DrawType(int x, int y, int cls_id, int id) const override
1241  {
1242  const auto *spec = this->GetSpec(cls_id, id);
1243  if (spec == nullptr) {
1244  StationPickerDrawSprite(x, y, roadstoptype == ROADSTOP_BUS ? STATION_BUS : STATION_TRUCK, INVALID_RAILTYPE, _cur_roadtype, _roadstop_gui.orientation);
1245  } else {
1246  DiagDirection orientation = _roadstop_gui.orientation;
1247  if (orientation < DIAGDIR_END && HasBit(spec->flags, RSF_DRIVE_THROUGH_ONLY)) orientation = DIAGDIR_END;
1248  DrawRoadStopTile(x, y, _cur_roadtype, spec, roadstoptype == ROADSTOP_BUS ? STATION_BUS : STATION_TRUCK, (uint8_t)orientation);
1249  }
1250  }
1251 
1252  void FillUsedItems(std::set<PickerItem> &items) override
1253  {
1254  for (const Station *st : Station::Iterate()) {
1255  if (st->owner != _local_company) continue;
1256  if (roadstoptype == ROADSTOP_TRUCK && !(st->facilities & FACIL_TRUCK_STOP)) continue;
1257  if (roadstoptype == ROADSTOP_BUS && !(st->facilities & FACIL_BUS_STOP)) continue;
1258  items.insert({0, 0, ROADSTOP_CLASS_DFLT, 0}); // We would need to scan the map to find out if default is used.
1259  for (const auto &sm : st->roadstop_speclist) {
1260  if (sm.spec == nullptr) continue;
1261  if (roadstoptype == ROADSTOP_TRUCK && sm.spec->stop_type != ROADSTOPTYPE_FREIGHT && sm.spec->stop_type != ROADSTOPTYPE_ALL) continue;
1262  if (roadstoptype == ROADSTOP_BUS && sm.spec->stop_type != ROADSTOPTYPE_PASSENGER && sm.spec->stop_type != ROADSTOPTYPE_ALL) continue;
1263  items.insert({sm.grfid, sm.localidx, sm.spec->class_index, sm.spec->index});
1264  }
1265  }
1266  }
1267 };
1268 
1269 template <> StringID RoadStopPickerCallbacks<ROADSTOP_BUS>::GetClassTooltip() const { return STR_PICKER_ROADSTOP_BUS_CLASS_TOOLTIP; }
1270 template <> StringID RoadStopPickerCallbacks<ROADSTOP_BUS>::GetTypeTooltip() const { return STR_PICKER_ROADSTOP_BUS_TYPE_TOOLTIP; }
1271 
1272 template <> StringID RoadStopPickerCallbacks<ROADSTOP_TRUCK>::GetClassTooltip() const { return STR_PICKER_ROADSTOP_TRUCK_CLASS_TOOLTIP; }
1273 template <> StringID RoadStopPickerCallbacks<ROADSTOP_TRUCK>::GetTypeTooltip() const { return STR_PICKER_ROADSTOP_TRUCK_TYPE_TOOLTIP; }
1274 
1275 static RoadStopPickerCallbacks<ROADSTOP_BUS> _bus_callback_instance("fav_passenger_roadstops");
1276 static RoadStopPickerCallbacks<ROADSTOP_TRUCK> _truck_callback_instance("fav_freight_roadstops");
1277 
1278 static PickerCallbacks &GetRoadStopPickerCallbacks(RoadStopType rs)
1279 {
1280  return rs == ROADSTOP_BUS ? static_cast<PickerCallbacks &>(_bus_callback_instance) : static_cast<PickerCallbacks &>(_truck_callback_instance);
1281 }
1282 
1284 private:
1286 
1287  void CheckOrientationValid()
1288  {
1289  const RoadStopSpec *spec = RoadStopClass::Get(_roadstop_gui.sel_class)->GetSpec(_roadstop_gui.sel_type);
1290 
1291  /* Raise and lower to ensure the correct widget is lowered after changing displayed orientation plane. */
1292  if (RoadTypeIsRoad(_cur_roadtype)) {
1293  this->RaiseWidget(WID_BROS_STATION_NE + _roadstop_gui.orientation);
1294  this->GetWidget<NWidgetStacked>(WID_BROS_AVAILABLE_ORIENTATIONS)->SetDisplayedPlane((spec != nullptr && HasBit(spec->flags, RSF_DRIVE_THROUGH_ONLY)) ? 1 : 0);
1295  this->LowerWidget(WID_BROS_STATION_NE + _roadstop_gui.orientation);
1296  }
1297 
1298  if (_roadstop_gui.orientation >= DIAGDIR_END) return;
1299 
1300  if (spec != nullptr && HasBit(spec->flags, RSF_DRIVE_THROUGH_ONLY)) {
1301  this->RaiseWidget(WID_BROS_STATION_NE + _roadstop_gui.orientation);
1302  _roadstop_gui.orientation = DIAGDIR_END;
1303  this->LowerWidget(WID_BROS_STATION_NE + _roadstop_gui.orientation);
1304  this->SetDirty();
1306  }
1307  }
1308 
1309 public:
1310  BuildRoadStationWindow(WindowDesc &desc, Window *parent, RoadStopType rs) : PickerWindow(desc, parent, TRANSPORT_ROAD, GetRoadStopPickerCallbacks(rs))
1311  {
1312  this->coverage_height = 2 * GetCharacterHeight(FS_NORMAL) + WidgetDimensions::scaled.vsep_normal;
1313 
1314  /* Trams don't have non-drivethrough stations */
1315  if (RoadTypeIsTram(_cur_roadtype) && _roadstop_gui.orientation < DIAGDIR_END) {
1316  _roadstop_gui.orientation = DIAGDIR_END;
1317  }
1318  this->ConstructWindow();
1319 
1320  const RoadTypeInfo *rti = GetRoadTypeInfo(_cur_roadtype);
1321  this->GetWidget<NWidgetCore>(WID_BROS_CAPTION)->widget_data = rti->strings.picker_title[rs];
1322 
1323  for (WidgetID i = RoadTypeIsTram(_cur_roadtype) ? WID_BROS_STATION_X : WID_BROS_STATION_NE; i < WID_BROS_LT_OFF; i++) {
1324  this->GetWidget<NWidgetCore>(i)->tool_tip = rti->strings.picker_tooltip[rs];
1325  }
1326 
1327  this->LowerWidget(WID_BROS_STATION_NE + _roadstop_gui.orientation);
1328  this->LowerWidget(WID_BROS_LT_OFF + _settings_client.gui.station_show_coverage);
1329 
1331  }
1332 
1333  void Close([[maybe_unused]] int data = 0) override
1334  {
1336  this->PickerWindow::Close();
1337  }
1338 
1339  void OnInvalidateData([[maybe_unused]] int data = 0, [[maybe_unused]] bool gui_scope = true) override
1340  {
1341  this->PickerWindow::OnInvalidateData(data, gui_scope);
1342 
1343  if (gui_scope) {
1344  this->CheckOrientationValid();
1345  }
1346  }
1347 
1348  void OnPaint() override
1349  {
1350  this->DrawWidgets();
1351 
1354  SetTileSelectBigSize(-rad, -rad, 2 * rad, 2 * rad);
1355  } else {
1356  SetTileSelectSize(1, 1);
1357  }
1358 
1359  if (this->IsShaded()) return;
1360 
1361  /* 'Accepts' and 'Supplies' texts. */
1363  Rect r = this->GetWidget<NWidgetBase>(WID_BROS_ACCEPTANCE)->GetCurrentRect();
1364  int top = r.top;
1365  top = DrawStationCoverageAreaText(r.left, r.right, top, sct, rad, false) + WidgetDimensions::scaled.vsep_normal;
1366  top = DrawStationCoverageAreaText(r.left, r.right, top, sct, rad, true);
1367  /* Resize background if the window is too small.
1368  * Never make the window smaller to avoid oscillating if the size change affects the acceptance.
1369  * (This is the case, if making the window bigger moves the mouse into the window.) */
1370  if (top > r.bottom) {
1371  this->coverage_height += top - r.bottom;
1372  this->ReInit();
1373  }
1374  }
1375 
1376  void UpdateWidgetSize(WidgetID widget, Dimension &size, [[maybe_unused]] const Dimension &padding, [[maybe_unused]] Dimension &fill, [[maybe_unused]] Dimension &resize) override
1377  {
1378  switch (widget) {
1379  case WID_BROS_STATION_NE:
1380  case WID_BROS_STATION_SE:
1381  case WID_BROS_STATION_SW:
1382  case WID_BROS_STATION_NW:
1383  case WID_BROS_STATION_X:
1384  case WID_BROS_STATION_Y:
1387  break;
1388 
1389  case WID_BROS_ACCEPTANCE:
1390  size.height = this->coverage_height;
1391  break;
1392 
1393  default:
1394  this->PickerWindow::UpdateWidgetSize(widget, size, padding, fill, resize);
1395  break;
1396  }
1397  }
1398 
1403  {
1404  switch (window_class) {
1405  case WC_BUS_STATION: return STATION_BUS;
1406  case WC_TRUCK_STATION: return STATION_TRUCK;
1407  default: NOT_REACHED();
1408  }
1409  }
1410 
1411  void DrawWidget(const Rect &r, WidgetID widget) const override
1412  {
1413  switch (widget) {
1414  case WID_BROS_STATION_NE:
1415  case WID_BROS_STATION_SE:
1416  case WID_BROS_STATION_SW:
1417  case WID_BROS_STATION_NW:
1418  case WID_BROS_STATION_X:
1419  case WID_BROS_STATION_Y: {
1421  const RoadStopSpec *spec = RoadStopClass::Get(_roadstop_gui.sel_class)->GetSpec(_roadstop_gui.sel_type);
1422  DrawPixelInfo tmp_dpi;
1423  Rect ir = r.Shrink(WidgetDimensions::scaled.bevel);
1424  if (FillDrawPixelInfo(&tmp_dpi, ir)) {
1425  AutoRestoreBackup dpi_backup(_cur_dpi, &tmp_dpi);
1428  if (spec == nullptr) {
1429  StationPickerDrawSprite(x, y, st, INVALID_RAILTYPE, _cur_roadtype, widget - WID_BROS_STATION_NE);
1430  } else {
1431  DrawRoadStopTile(x, y, _cur_roadtype, spec, st, widget - WID_BROS_STATION_NE);
1432  }
1433  }
1434  break;
1435  }
1436 
1437  default:
1438  this->PickerWindow::DrawWidget(r, widget);
1439  break;
1440  }
1441  }
1442 
1443  void OnClick([[maybe_unused]] Point pt, WidgetID widget, [[maybe_unused]] int click_count) override
1444  {
1445  switch (widget) {
1446  case WID_BROS_STATION_NE:
1447  case WID_BROS_STATION_SE:
1448  case WID_BROS_STATION_SW:
1449  case WID_BROS_STATION_NW:
1450  case WID_BROS_STATION_X:
1451  case WID_BROS_STATION_Y:
1452  if (widget < WID_BROS_STATION_X) {
1453  const RoadStopSpec *spec = RoadStopClass::Get(_roadstop_gui.sel_class)->GetSpec(_roadstop_gui.sel_type);
1454  if (spec != nullptr && HasBit(spec->flags, RSF_DRIVE_THROUGH_ONLY)) return;
1455  }
1456  this->RaiseWidget(WID_BROS_STATION_NE + _roadstop_gui.orientation);
1457  _roadstop_gui.orientation = (DiagDirection)(widget - WID_BROS_STATION_NE);
1458  this->LowerWidget(WID_BROS_STATION_NE + _roadstop_gui.orientation);
1459  if (_settings_client.sound.click_beep) SndPlayFx(SND_15_BEEP);
1460  this->SetDirty();
1462  break;
1463 
1464  case WID_BROS_LT_OFF:
1465  case WID_BROS_LT_ON:
1469  if (_settings_client.sound.click_beep) SndPlayFx(SND_15_BEEP);
1470  this->SetDirty();
1471  SetViewportCatchmentStation(nullptr, true);
1472  break;
1473 
1474  default:
1475  this->PickerWindow::OnClick(pt, widget, click_count);
1476  break;
1477  }
1478  }
1479 
1480  void OnRealtimeTick([[maybe_unused]] uint delta_ms) override
1481  {
1483  }
1484 
1485  static inline HotkeyList road_hotkeys{"buildroadstop", {
1486  Hotkey('F', "focus_filter_box", PCWHK_FOCUS_FILTER_BOX),
1487  }};
1488 
1489  static inline HotkeyList tram_hotkeys{"buildtramstop", {
1490  Hotkey('F', "focus_filter_box", PCWHK_FOCUS_FILTER_BOX),
1491  }};
1492 };
1493 
1497  NWidget(WWT_CLOSEBOX, COLOUR_DARK_GREEN),
1498  NWidget(WWT_CAPTION, COLOUR_DARK_GREEN, WID_BROS_CAPTION),
1499  NWidget(WWT_SHADEBOX, COLOUR_DARK_GREEN),
1500  NWidget(WWT_DEFSIZEBOX, COLOUR_DARK_GREEN),
1501  EndContainer(),
1505  NWidget(WWT_PANEL, COLOUR_DARK_GREEN),
1508  /* 6-orientation plane. */
1510  NWidget(NWID_HORIZONTAL), SetPIP(0, WidgetDimensions::unscaled.hsep_normal, 0), SetPIPRatio(1, 0, 1),
1512  NWidget(WWT_PANEL, COLOUR_GREY, WID_BROS_STATION_NW), SetFill(0, 0), EndContainer(),
1513  NWidget(WWT_PANEL, COLOUR_GREY, WID_BROS_STATION_NE), SetFill(0, 0), EndContainer(),
1514  EndContainer(),
1515  NWidget(WWT_PANEL, COLOUR_GREY, WID_BROS_STATION_X), SetFill(0, 0), EndContainer(),
1516  EndContainer(),
1517  NWidget(NWID_HORIZONTAL), SetPIP(0, WidgetDimensions::unscaled.hsep_normal, 0), SetPIPRatio(1, 0, 1),
1519  NWidget(WWT_PANEL, COLOUR_GREY, WID_BROS_STATION_SW), SetFill(0, 0), EndContainer(),
1520  NWidget(WWT_PANEL, COLOUR_GREY, WID_BROS_STATION_SE), SetFill(0, 0), EndContainer(),
1521  EndContainer(),
1522  NWidget(WWT_PANEL, COLOUR_GREY, WID_BROS_STATION_Y), SetFill(0, 0), EndContainer(),
1523  EndContainer(),
1524  EndContainer(),
1525  /* 2-orientation plane. */
1526  NWidget(NWID_VERTICAL), SetPIPRatio(0, 0, 1),
1528  NWidget(WWT_PANEL, COLOUR_GREY, WID_BROS_STATION_X), SetFill(0, 0), EndContainer(),
1529  NWidget(WWT_PANEL, COLOUR_GREY, WID_BROS_STATION_Y), SetFill(0, 0), EndContainer(),
1530  EndContainer(),
1531  EndContainer(),
1532  EndContainer(),
1533  NWidget(WWT_LABEL, COLOUR_DARK_GREEN), SetDataTip(STR_STATION_BUILD_COVERAGE_AREA_TITLE, STR_NULL), SetFill(1, 0),
1534  NWidget(NWID_HORIZONTAL), SetPIPRatio(1, 0, 1),
1535  NWidget(WWT_TEXTBTN, COLOUR_GREY, WID_BROS_LT_OFF), SetMinimalSize(60, 12),
1536  SetDataTip(STR_STATION_BUILD_COVERAGE_OFF, STR_STATION_BUILD_COVERAGE_AREA_OFF_TOOLTIP),
1537  NWidget(WWT_TEXTBTN, COLOUR_GREY, WID_BROS_LT_ON), SetMinimalSize(60, 12),
1538  SetDataTip(STR_STATION_BUILD_COVERAGE_ON, STR_STATION_BUILD_COVERAGE_AREA_ON_TOOLTIP),
1539  EndContainer(),
1540  NWidget(WWT_EMPTY, INVALID_COLOUR, WID_BROS_ACCEPTANCE), SetFill(1, 1), SetResize(1, 0), SetMinimalTextLines(2, 0),
1541  EndContainer(),
1542  EndContainer(),
1543  EndContainer(),
1545  EndContainer(),
1546 };
1547 
1548 static WindowDesc _road_station_picker_desc(
1549  WDP_AUTO, "build_station_road", 0, 0,
1553  &BuildRoadStationWindow::road_hotkeys
1554 );
1555 
1559  NWidget(WWT_CLOSEBOX, COLOUR_DARK_GREEN),
1560  NWidget(WWT_CAPTION, COLOUR_DARK_GREEN, WID_BROS_CAPTION),
1561  NWidget(WWT_SHADEBOX, COLOUR_DARK_GREEN),
1562  NWidget(WWT_DEFSIZEBOX, COLOUR_DARK_GREEN),
1563  EndContainer(),
1567  NWidget(WWT_PANEL, COLOUR_DARK_GREEN),
1570  NWidget(WWT_PANEL, COLOUR_GREY, WID_BROS_STATION_X), SetFill(0, 0), EndContainer(),
1571  NWidget(WWT_PANEL, COLOUR_GREY, WID_BROS_STATION_Y), SetFill(0, 0), EndContainer(),
1572  EndContainer(),
1573  NWidget(WWT_LABEL, COLOUR_DARK_GREEN), SetDataTip(STR_STATION_BUILD_COVERAGE_AREA_TITLE, STR_NULL), SetFill(1, 0),
1574  NWidget(NWID_HORIZONTAL), SetPIPRatio(1, 0, 1),
1575  NWidget(WWT_TEXTBTN, COLOUR_GREY, WID_BROS_LT_OFF), SetMinimalSize(60, 12),
1576  SetDataTip(STR_STATION_BUILD_COVERAGE_OFF, STR_STATION_BUILD_COVERAGE_AREA_OFF_TOOLTIP),
1577  NWidget(WWT_TEXTBTN, COLOUR_GREY, WID_BROS_LT_ON), SetMinimalSize(60, 12),
1578  SetDataTip(STR_STATION_BUILD_COVERAGE_ON, STR_STATION_BUILD_COVERAGE_AREA_ON_TOOLTIP),
1579  EndContainer(),
1580  NWidget(WWT_EMPTY, INVALID_COLOUR, WID_BROS_ACCEPTANCE), SetFill(1, 1), SetResize(1, 0), SetMinimalTextLines(2, 0),
1581  EndContainer(),
1582  EndContainer(),
1583  EndContainer(),
1585  EndContainer(),
1586 };
1587 
1588 static WindowDesc _tram_station_picker_desc(
1589  WDP_AUTO, "build_station_tram", 0, 0,
1593  &BuildRoadStationWindow::tram_hotkeys
1594 );
1595 
1596 static void ShowRVStationPicker(Window *parent, RoadStopType rs)
1597 {
1598  new BuildRoadStationWindow(RoadTypeIsRoad(_cur_roadtype) ? _road_station_picker_desc : _tram_station_picker_desc, parent, rs);
1599 }
1600 
1602 public:
1604 
1605  StringID GetClassTooltip() const override { return STR_PICKER_WAYPOINT_CLASS_TOOLTIP; }
1606  StringID GetTypeTooltip() const override { return STR_PICKER_WAYPOINT_TYPE_TOOLTIP; }
1607 
1608  bool IsActive() const override
1609  {
1610  for (const auto &cls : RoadStopClass::Classes()) {
1611  if (!IsWaypointClass(cls)) continue;
1612  for (const auto *spec : cls.Specs()) {
1613  if (spec != nullptr) return true;
1614  }
1615  }
1616  return false;
1617  }
1618 
1619  bool HasClassChoice() const override
1620  {
1621  return std::count_if(std::begin(RoadStopClass::Classes()), std::end(RoadStopClass::Classes()), IsWaypointClass) > 1;
1622  }
1623 
1624  void Close(int) override { ResetObjectToPlace(); }
1625  int GetSelectedClass() const override { return _waypoint_gui.sel_class; }
1626  void SetSelectedClass(int id) const override { _waypoint_gui.sel_class = this->GetClassIndex(id); }
1627 
1628  StringID GetClassName(int id) const override
1629  {
1630  const auto *sc = GetClass(id);
1631  if (!IsWaypointClass(*sc)) return INVALID_STRING_ID;
1632  return sc->name;
1633  }
1634 
1635  int GetSelectedType() const override { return _waypoint_gui.sel_type; }
1636  void SetSelectedType(int id) const override { _waypoint_gui.sel_type = id; }
1637 
1638  StringID GetTypeName(int cls_id, int id) const override
1639  {
1640  const auto *spec = this->GetSpec(cls_id, id);
1641  return (spec == nullptr) ? STR_STATION_CLASS_WAYP_WAYPOINT : spec->name;
1642  }
1643 
1644  bool IsTypeAvailable(int cls_id, int id) const override
1645  {
1646  return IsRoadStopAvailable(this->GetSpec(cls_id, id), STATION_ROADWAYPOINT);
1647  }
1648 
1649  void DrawType(int x, int y, int cls_id, int id) const override
1650  {
1651  const auto *spec = this->GetSpec(cls_id, id);
1652  if (spec == nullptr) {
1653  StationPickerDrawSprite(x, y, STATION_ROADWAYPOINT, INVALID_RAILTYPE, _cur_roadtype, RSV_DRIVE_THROUGH_X);
1654  } else {
1655  DrawRoadStopTile(x, y, _cur_roadtype, spec, STATION_ROADWAYPOINT, RSV_DRIVE_THROUGH_X);
1656  }
1657  }
1658 
1659  void FillUsedItems(std::set<PickerItem> &items) override
1660  {
1661  for (const Waypoint *wp : Waypoint::Iterate()) {
1662  if (wp->owner != _local_company || !HasBit(wp->waypoint_flags, WPF_ROAD)) continue;
1663  items.insert({0, 0, ROADSTOP_CLASS_WAYP, 0}); // We would need to scan the map to find out if default is used.
1664  for (const auto &sm : wp->roadstop_speclist) {
1665  if (sm.spec == nullptr) continue;
1666  items.insert({sm.grfid, sm.localidx, sm.spec->class_index, sm.spec->index});
1667  }
1668  }
1669  }
1670 
1671  static RoadWaypointPickerCallbacks instance;
1672 };
1673 /* static */ RoadWaypointPickerCallbacks RoadWaypointPickerCallbacks::instance;
1674 
1676  BuildRoadWaypointWindow(WindowDesc &desc, Window *parent) : PickerWindow(desc, parent, TRANSPORT_ROAD, RoadWaypointPickerCallbacks::instance)
1677  {
1678  this->ConstructWindow();
1679  this->InvalidateData();
1680  }
1681 
1682  static inline HotkeyList hotkeys{"buildroadwaypoint", {
1683  Hotkey('F', "focus_filter_box", PCWHK_FOCUS_FILTER_BOX),
1684  }};
1685 };
1686 
1690  NWidget(WWT_CLOSEBOX, COLOUR_DARK_GREEN),
1691  NWidget(WWT_CAPTION, COLOUR_DARK_GREEN), SetDataTip(STR_WAYPOINT_CAPTION, STR_TOOLTIP_WINDOW_TITLE_DRAG_THIS),
1692  NWidget(WWT_SHADEBOX, COLOUR_DARK_GREEN),
1693  NWidget(WWT_DEFSIZEBOX, COLOUR_DARK_GREEN),
1694  EndContainer(),
1698  EndContainer(),
1699 };
1700 
1701 static WindowDesc _build_road_waypoint_desc(
1702  WDP_AUTO, "build_road_waypoint", 0, 0,
1706  &BuildRoadWaypointWindow::hotkeys
1707 );
1708 
1709 static void ShowBuildRoadWaypointPicker(Window *parent)
1710 {
1711  if (!RoadWaypointPickerCallbacks::instance.IsActive()) return;
1712  new BuildRoadWaypointWindow(_build_road_waypoint_desc, parent);
1713 }
1714 
1715 void InitializeRoadGui()
1716 {
1717  _road_depot_orientation = DIAGDIR_NW;
1718  _roadstop_gui.orientation = DIAGDIR_NW;
1720  _waypoint_gui.sel_type = 0;
1721 }
1722 
1727 {
1729  if (w != nullptr) w->ModifyRoadType(_cur_roadtype);
1730 }
1731 
1732 DropDownList GetRoadTypeDropDownList(RoadTramTypes rtts, bool for_replacement, bool all_option)
1733 {
1734  RoadTypes used_roadtypes;
1735  RoadTypes avail_roadtypes;
1736 
1737  const Company *c = Company::Get(_local_company);
1738 
1739  /* Find the used roadtypes. */
1740  if (for_replacement) {
1741  avail_roadtypes = GetCompanyRoadTypes(c->index, false);
1742  used_roadtypes = GetRoadTypes(false);
1743  } else {
1744  avail_roadtypes = c->avail_roadtypes;
1745  used_roadtypes = GetRoadTypes(true);
1746  }
1747 
1748  /* Filter listed road types */
1749  if (!HasBit(rtts, RTT_ROAD)) used_roadtypes &= _roadtypes_type;
1750  if (!HasBit(rtts, RTT_TRAM)) used_roadtypes &= ~_roadtypes_type;
1751 
1752  DropDownList list;
1753 
1754  if (all_option) {
1755  list.push_back(MakeDropDownListStringItem(STR_REPLACE_ALL_ROADTYPE, INVALID_ROADTYPE));
1756  }
1757 
1758  Dimension d = { 0, 0 };
1759  /* Get largest icon size, to ensure text is aligned on each menu item. */
1760  if (!for_replacement) {
1761  for (const auto &rt : _sorted_roadtypes) {
1762  if (!HasBit(used_roadtypes, rt)) continue;
1763  const RoadTypeInfo *rti = GetRoadTypeInfo(rt);
1765  }
1766  }
1767 
1768  for (const auto &rt : _sorted_roadtypes) {
1769  /* If it's not used ever, don't show it to the user. */
1770  if (!HasBit(used_roadtypes, rt)) continue;
1771 
1772  const RoadTypeInfo *rti = GetRoadTypeInfo(rt);
1773 
1774  SetDParam(0, rti->strings.menu_text);
1775  SetDParam(1, rti->max_speed / 2);
1776  if (for_replacement) {
1777  list.push_back(MakeDropDownListStringItem(rti->strings.replace_text, rt, !HasBit(avail_roadtypes, rt)));
1778  } else {
1779  StringID str = rti->max_speed > 0 ? STR_TOOLBAR_RAILTYPE_VELOCITY : STR_JUST_STRING;
1780  list.push_back(MakeDropDownListIconItem(d, rti->gui_sprites.build_x_road, PAL_NONE, str, rt, !HasBit(avail_roadtypes, rt)));
1781  }
1782  }
1783 
1784  if (list.empty()) {
1785  /* Empty dropdowns are not allowed */
1786  list.push_back(MakeDropDownListStringItem(STR_NONE, INVALID_ROADTYPE, true));
1787  }
1788 
1789  return list;
1790 }
1791 
1792 DropDownList GetScenRoadTypeDropDownList(RoadTramTypes rtts)
1793 {
1794  RoadTypes avail_roadtypes = GetRoadTypes(false);
1795  avail_roadtypes = AddDateIntroducedRoadTypes(avail_roadtypes, TimerGameCalendar::date);
1796  RoadTypes used_roadtypes = GetRoadTypes(true);
1797 
1798  /* Filter listed road types */
1799  if (!HasBit(rtts, RTT_ROAD)) used_roadtypes &= _roadtypes_type;
1800  if (!HasBit(rtts, RTT_TRAM)) used_roadtypes &= ~_roadtypes_type;
1801 
1802  DropDownList list;
1803 
1804  /* If it's not used ever, don't show it to the user. */
1805  Dimension d = { 0, 0 };
1806  for (const auto &rt : _sorted_roadtypes) {
1807  if (!HasBit(used_roadtypes, rt)) continue;
1808  const RoadTypeInfo *rti = GetRoadTypeInfo(rt);
1810  }
1811  for (const auto &rt : _sorted_roadtypes) {
1812  if (!HasBit(used_roadtypes, rt)) continue;
1813 
1814  const RoadTypeInfo *rti = GetRoadTypeInfo(rt);
1815 
1816  SetDParam(0, rti->strings.menu_text);
1817  SetDParam(1, rti->max_speed / 2);
1818  StringID str = rti->max_speed > 0 ? STR_TOOLBAR_RAILTYPE_VELOCITY : STR_JUST_STRING;
1819  list.push_back(MakeDropDownListIconItem(d, rti->gui_sprites.build_x_road, PAL_NONE, str, rt, !HasBit(avail_roadtypes, rt)));
1820  }
1821 
1822  if (list.empty()) {
1823  /* Empty dropdowns are not allowed */
1824  list.push_back(MakeDropDownListStringItem(STR_NONE, -1, true));
1825  }
1826 
1827  return list;
1828 }
INVALID_RAILTYPE
@ INVALID_RAILTYPE
Flag for invalid railtype.
Definition: rail_type.h:34
ROADSTOPTYPE_FREIGHT
@ ROADSTOPTYPE_FREIGHT
This RoadStop is for freight (truck) stops.
Definition: newgrf_roadstop.h:51
ES_HANDLED
@ ES_HANDLED
The passed event is handled.
Definition: window_type.h:738
RoadStopPickerSelection::sel_type
uint16_t sel_type
Selected road stop type within the class.
Definition: road_gui.cpp:77
ROADSTOP_BUS
@ ROADSTOP_BUS
A standard stop for buses.
Definition: station_type.h:46
SetFill
constexpr NWidgetPart SetFill(uint16_t fill_x, uint16_t fill_y)
Widget part function for setting filling.
Definition: widget_type.h:1183
RoadTypeInfo::toolbar_caption
StringID toolbar_caption
Caption in the construction toolbar GUI for this rail type.
Definition: road.h:104
SetTileSelectSize
void SetTileSelectSize(int w, int h)
Highlight w by h tiles at the cursor.
Definition: viewport.cpp:2539
DDSP_DEMOLISH_AREA
@ DDSP_DEMOLISH_AREA
Clear area.
Definition: viewport_type.h:112
tunnelbridge.h
_remove_button_clicked
static bool _remove_button_clicked
Flag whether 'remove' toggle-button is currently enabled.
Definition: rail_gui.cpp:54
CA_UNMODIFIED
@ CA_UNMODIFIED
Catchment for all stations with "modified catchment" disabled.
Definition: station_type.h:84
WID_ROT_TRUCK_STATION
@ WID_ROT_TRUCK_STATION
Build truck station.
Definition: road_widget.h:24
RoadStopPickerSelection::orientation
DiagDirection orientation
Selected orientation of the road stop.
Definition: road_gui.cpp:78
PlaceRoad_Bridge
static void PlaceRoad_Bridge(TileIndex tile, Window *w)
Callback to start placing a bridge.
Definition: road_gui.cpp:123
RoadTypeInfo
Definition: road.h:78
DIAGDIR_NE
@ DIAGDIR_NE
Northeast, upper right on your monitor.
Definition: direction_type.h:75
CloseWindowByClass
void CloseWindowByClass(WindowClass cls, int data)
Close all windows of a given class.
Definition: window.cpp:1152
sound_func.h
TileHighlightData::size
Point size
Size, in tile "units", of the white/red selection area.
Definition: tilehighlight_type.h:48
RoadWaypointPickerCallbacks
Definition: road_gui.cpp:1601
_nested_build_road_waypoint_widgets
static constexpr NWidgetPart _nested_build_road_waypoint_widgets[]
Nested widget definition for the build NewGRF road waypoint window.
Definition: road_gui.cpp:1688
RoadTypeInfo::err_build_road
StringID err_build_road
Building a normal piece of road.
Definition: road.h:110
Rect::Height
int Height() const
Get height of Rect.
Definition: geometry_type.hpp:91
GUISettings::station_show_coverage
bool station_show_coverage
whether to highlight coverage area
Definition: settings_type.h:197
Pool::PoolItem<&_company_pool >::Get
static Titem * Get(size_t index)
Returns Titem with given index.
Definition: pool_type.hpp:339
WC_BUILD_TOOLBAR
@ WC_BUILD_TOOLBAR
Build toolbar; Window numbers:
Definition: window_type.h:73
DDSP_PLACE_ROAD_Y_DIR
@ DDSP_PLACE_ROAD_Y_DIR
Road placement (Y axis)
Definition: viewport_type.h:133
PickerWindow::PREVIEW_HEIGHT
static const int PREVIEW_HEIGHT
Height of each preview button.
Definition: picker_gui.h:164
BuildRoadStationWindow::OnPaint
void OnPaint() override
The window must be repainted.
Definition: road_gui.cpp:1348
WID_ROT_BUILD_BRIDGE
@ WID_ROT_BUILD_BRIDGE
Build bridge.
Definition: road_widget.h:26
RoadStopPickerCallbacks::GetClassTooltip
StringID GetClassTooltip() const override
Get the tooltip string for the class list.
GameSettings::station
StationSettings station
settings related to station management
Definition: settings_type.h:605
PickerWindow::PREVIEW_WIDTH
static const int PREVIEW_WIDTH
Width of each preview button.
Definition: picker_gui.h:163
RoadTypeInfo::menu_text
StringID menu_text
Name of this rail type in the main toolbar dropdown.
Definition: road.h:105
HotkeyList
List of hotkeys for a window.
Definition: hotkeys.h:37
RoadStopPickerCallbacks::DrawType
void DrawType(int x, int y, int cls_id, int id) const override
Draw preview image of an item.
Definition: road_gui.cpp:1240
VpSetPresizeRange
void VpSetPresizeRange(TileIndex from, TileIndex to)
Highlights all tiles between a set of two tiles.
Definition: viewport.cpp:2774
RoadTypeInfo::build_y_road
SpriteID build_y_road
button for building single rail in Y direction
Definition: road.h:86
RoadWaypointPickerCallbacks::GetSelectedType
int GetSelectedType() const override
Get the selected type.
Definition: road_gui.cpp:1635
RoadWaypointPickerCallbacks::FillUsedItems
void FillUsedItems(std::set< PickerItem > &items) override
Fill a set with all items that are used by the current player.
Definition: road_gui.cpp:1659
PickerCallbacks
Class for PickerClassWindow to collect information and retain state.
Definition: picker_gui.h:37
Dimension
Dimensions (a width and height) of a rectangle in 2D.
Definition: geometry_type.hpp:30
command_func.h
IsInsideMM
constexpr bool IsInsideMM(const T x, const size_t min, const size_t max) noexcept
Checks if a value is in an interval.
Definition: math_func.hpp:268
RoadStopSpec
Road stop specification.
Definition: newgrf_roadstop.h:135
WidgetDimensions::scaled
static WidgetDimensions scaled
Widget dimensions scaled for current zoom level.
Definition: window_gui.h:68
WID_ROT_DEMOLISH
@ WID_ROT_DEMOLISH
Demolish.
Definition: road_widget.h:20
RoadWaypointPickerCallbacks::GetClassName
StringID GetClassName(int id) const override
Get the name of a class.
Definition: road_gui.cpp:1628
WWT_STICKYBOX
@ WWT_STICKYBOX
Sticky box (at top-right of a window, after WWT_DEFSIZEBOX)
Definition: widget_type.h:68
WDF_CONSTRUCTION
@ WDF_CONSTRUCTION
This window is used for construction; close it whenever changing company.
Definition: window_gui.h:206
BuildRoadToolbarWindow::OnRealtimeTick
void OnRealtimeTick([[maybe_unused]] uint delta_ms) override
Called periodically.
Definition: road_gui.cpp:827
dropdown_func.h
PlaceRoad_TruckStation
static void PlaceRoad_TruckStation(TileIndex tile)
Callback for placing a truck station.
Definition: road_gui.cpp:295
Rect::Shrink
Rect Shrink(int s) const
Copy and shrink Rect by s pixels.
Definition: geometry_type.hpp:98
ShowSelectRoadWaypointIfNeeded
void ShowSelectRoadWaypointIfNeeded(TileArea ta, StationPickerCmdProc proc)
Show the road waypoint selection window when needed.
Definition: station_gui.cpp:2509
Company::avail_roadtypes
RoadTypes avail_roadtypes
Road types available to this company.
Definition: company_base.h:138
company_base.h
ViewportDragDropSelectionProcess
ViewportDragDropSelectionProcess
Drag and drop selection process, or, what to do with an area of land when you've selected it.
Definition: viewport_type.h:111
tunnelbridge_map.h
CommandFlagsToDCFlags
static constexpr DoCommandFlag CommandFlagsToDCFlags(CommandFlags cmd_flags)
Extracts the DC flags needed for DoCommand from the flags returned by GetCommandFlags.
Definition: command_func.h:58
timer_game_calendar.h
WWT_CAPTION
@ WWT_CAPTION
Window caption (window title between closebox and stickybox)
Definition: widget_type.h:63
CBID_STATION_AVAILABILITY
@ CBID_STATION_AVAILABILITY
Determine whether a newstation should be made available to build.
Definition: newgrf_callbacks.h:39
WC_SCEN_BUILD_TOOLBAR
@ WC_SCEN_BUILD_TOOLBAR
Scenario build toolbar; Window numbers:
Definition: window_type.h:80
Station
Station data structure.
Definition: station_base.h:439
CheckRedrawStationCoverage
void CheckRedrawStationCoverage(const Window *w)
Check whether we need to redraw the station coverage text.
Definition: station_gui.cpp:160
Window::SetWidgetDirty
void SetWidgetDirty(WidgetID widget_index) const
Invalidate a widget, i.e.
Definition: window.cpp:551
RoadStopSpec::name
StringID name
Name of this stop.
Definition: newgrf_roadstop.h:143
waypoint_cmd.h
StringID
uint32_t StringID
Numeric value that represents a string, independent of the selected language.
Definition: strings_type.h:16
WWT_IMGBTN
@ WWT_IMGBTN
(Toggle) Button with image
Definition: widget_type.h:54
DDSP_REMOVE_BUSSTOP
@ DDSP_REMOVE_BUSSTOP
Road stop removal (buses)
Definition: viewport_type.h:139
RoadStopPickerCallbacks::GetSelectedClass
int GetSelectedClass() const override
Get the index of the selected class.
Definition: road_gui.cpp:1214
WWT_LABEL
@ WWT_LABEL
Centered label.
Definition: widget_type.h:59
CloseWindowById
void CloseWindowById(WindowClass cls, WindowNumber number, bool force, int data)
Close a window by its class and window number (if it is open).
Definition: window.cpp:1140
DropDownList
std::vector< std::unique_ptr< const DropDownListItem > > DropDownList
A drop down list is a collection of drop down list items.
Definition: dropdown_type.h:50
BuildRoadWaypointWindow
Definition: road_gui.cpp:1675
SetRedErrorSquare
void SetRedErrorSquare(TileIndex tile)
Set a tile to display a red error square.
Definition: viewport.cpp:2521
WWT_DEFSIZEBOX
@ WWT_DEFSIZEBOX
Default window size box (at top-right of a window, between WWT_SHADEBOX and WWT_STICKYBOX)
Definition: widget_type.h:67
RoadStopPickerCallbacks::IsTypeAvailable
bool IsTypeAvailable(int cls_id, int id) const override
Test if an item is currently buildable.
Definition: road_gui.cpp:1234
WID_BROD_DEPOT_NW
@ WID_BROD_DEPOT_NW
Depot with NW entry.
Definition: road_widget.h:41
WDP_ALIGN_TOOLBAR
@ WDP_ALIGN_TOOLBAR
Align toward the toolbar.
Definition: window_gui.h:152
road_widget.h
Pool::PoolItem::index
Tindex index
Index of this pool item.
Definition: pool_type.hpp:238
NWID_HORIZONTAL
@ NWID_HORIZONTAL
Horizontal container.
Definition: widget_type.h:77
DiagDirToAxis
Axis DiagDirToAxis(DiagDirection d)
Convert a DiagDirection to the axis.
Definition: direction_func.h:214
DDSP_BUILD_BUSSTOP
@ DDSP_BUILD_BUSSTOP
Road stop placement (buses)
Definition: viewport_type.h:136
RoadTypeInfo::build_depot
SpriteID build_depot
button for building depots
Definition: road.h:88
maxdim
Dimension maxdim(const Dimension &d1, const Dimension &d2)
Compute bounding box of both dimensions.
Definition: geometry_func.cpp:22
Window::Close
virtual void Close(int data=0)
Hide the window and all its child windows, and mark them for a later deletion.
Definition: window.cpp:1047
FindWindowById
Window * FindWindowById(WindowClass cls, WindowNumber number)
Find a window by its class and window number.
Definition: window.cpp:1098
BuildRoadToolbarWindow::last_started_action
int last_started_action
Last started user action.
Definition: road_gui.cpp:347
NWID_HORIZONTAL_LTR
@ NWID_HORIZONTAL_LTR
Horizontal container that doesn't change the order of the widgets for RTL languages.
Definition: widget_type.h:78
INVALID_TILE
constexpr TileIndex INVALID_TILE
The very nice invalid tile marker.
Definition: tile_type.h:95
EndContainer
constexpr NWidgetPart EndContainer()
Widget part function for denoting the end of a container (horizontal, vertical, WWT_FRAME,...
Definition: widget_type.h:1193
PlaceProc_DemolishArea
void PlaceProc_DemolishArea(TileIndex tile)
Start a drag for demolishing an area.
Definition: terraform_gui.cpp:151
BuildRoadToolbarWindow::rti
const RoadTypeInfo * rti
Information about current road type.
Definition: road_gui.cpp:346
PickerWindow::PCWHK_FOCUS_FILTER_BOX
@ PCWHK_FOCUS_FILTER_BOX
Focus the edit box for editing the filter string.
Definition: picker_gui.h:185
Waypoint
Representation of a waypoint.
Definition: waypoint_base.h:23
_ctrl_pressed
bool _ctrl_pressed
Is Ctrl pressed?
Definition: gfx.cpp:38
SND_15_BEEP
@ SND_15_BEEP
19 == 0x13 GUI button click
Definition: sound_type.h:58
BuildRoadStationWindow::OnRealtimeTick
void OnRealtimeTick([[maybe_unused]] uint delta_ms) override
Called periodically.
Definition: road_gui.cpp:1480
HandlePlacePushButton
bool HandlePlacePushButton(Window *w, WidgetID widget, CursorID cursor, HighLightStyle mode)
This code is shared for the majority of the pushbuttons.
Definition: main_gui.cpp:63
RoadTypeInfo::err_remove_station
StringID err_remove_station[2]
Removing of a bus or truck station.
Definition: road.h:114
BuildRoadToolbarWindow::RoadTramToolbarGlobalHotkeys
static EventState RoadTramToolbarGlobalHotkeys(int hotkey, RoadType last_build, RoadTramType rtt)
Handler for global hotkeys of the BuildRoadToolbarWindow.
Definition: road_gui.cpp:838
VEH_ROAD
@ VEH_ROAD
Road vehicle type.
Definition: vehicle_type.h:25
zoom_func.h
Window::RaiseButtons
void RaiseButtons(bool autoraise=false)
Raise the buttons of the window.
Definition: window.cpp:525
RoadStopPickerCallbacks::SetSelectedClass
void SetSelectedClass(int id) const override
Set the selected class.
Definition: road_gui.cpp:1215
DiagDirection
DiagDirection
Enumeration for diagonal directions.
Definition: direction_type.h:73
WID_BROS_ACCEPTANCE
@ WID_BROS_ACCEPTANCE
Station acceptance info.
Definition: road_widget.h:56
BuildRoadToolbarWindow::OnCTRLStateChange
EventState OnCTRLStateChange() override
The state of the control key has changed.
Definition: road_gui.cpp:821
DrawRoadDepotSprite
void DrawRoadDepotSprite(int x, int y, DiagDirection dir, RoadType rt)
Draw the road depot sprite.
Definition: road_cmd.cpp:1875
VPM_FIX_Y
@ VPM_FIX_Y
drag only in Y axis
Definition: viewport_type.h:95
_settings_client
ClientSettings _settings_client
The current settings for this game.
Definition: settings.cpp:56
WID_BROD_DEPOT_SE
@ WID_BROD_DEPOT_SE
Depot with SE entry.
Definition: road_widget.h:39
WWT_EMPTY
@ WWT_EMPTY
Empty widget, place holder to reserve space in widget tree.
Definition: widget_type.h:50
ANIMCURSOR_DEMOLISH
static const CursorID ANIMCURSOR_DEMOLISH
704 - 707 - demolish dynamite
Definition: sprites.h:1508
GetCompanyRoadTypes
RoadTypes GetCompanyRoadTypes(CompanyID company, bool introduces)
Get the road types the given company can build.
Definition: road.cpp:199
RectPadding::Vertical
constexpr uint Vertical() const
Get total vertical padding of RectPadding.
Definition: geometry_type.hpp:69
StrongType::Typedef< uint32_t, struct TileIndexTag, StrongType::Compare, StrongType::Integer, StrongType::Compatible< int32_t >, StrongType::Compatible< int64_t > >
BuildRoadToolbarWindow::UpdateOptionWidgetStatus
void UpdateOptionWidgetStatus(RoadToolbarWidgets clicked_widget)
Update the remove button lowered state of the road toolbar.
Definition: road_gui.cpp:465
RoadStopPickerSelection::sel_class
RoadStopClassID sel_class
Selected road stop class.
Definition: road_gui.cpp:76
_waypoint_gui
static RoadWaypointPickerSelection _waypoint_gui
Settings of the road waypoint picker.
Definition: road_gui.cpp:73
RoadTypeInfo::tunnel
CursorID tunnel
Cursor for building a tunnel.
Definition: road.h:98
RoadTypeInfo::replace_text
StringID replace_text
Text used in the autoreplace GUI.
Definition: road.h:107
RoadWaypointPickerCallbacks::IsTypeAvailable
bool IsTypeAvailable(int cls_id, int id) const override
Test if an item is currently buildable.
Definition: road_gui.cpp:1644
NWidgetFunction
constexpr NWidgetPart NWidgetFunction(NWidgetFunctionType *func_ptr)
Obtain a nested widget (sub)tree from an external source.
Definition: widget_type.h:1332
ROADSTOP_CLASS_DFLT
@ ROADSTOP_CLASS_DFLT
Default road stop class.
Definition: newgrf_roadstop.h:30
ViewportPlaceMethod
ViewportPlaceMethod
Viewport place method (type of highlighted area and placed objects)
Definition: viewport_type.h:92
WID_BROS_LT_ON
@ WID_BROS_LT_ON
Turn on area highlight.
Definition: road_widget.h:55
WID_BROD_DEPOT_SW
@ WID_BROD_DEPOT_SW
Depot with SW entry.
Definition: road_widget.h:40
RoadTypeInfo::err_remove_road
StringID err_remove_road
Removing a normal piece of road.
Definition: road.h:111
Window::OnHotkey
virtual EventState OnHotkey(int hotkey)
A hotkey has been pressed.
Definition: window.cpp:565
RoadTypeInfo::depot
CursorID depot
Cursor for building a depot.
Definition: road.h:97
NWidgetPart
Partial widget specification to allow NWidgets to be written nested.
Definition: widget_type.h:1077
ROADSTOP_TRUCK
@ ROADSTOP_TRUCK
A standard stop for trucks.
Definition: station_type.h:47
WID_BROS_LT_OFF
@ WID_BROS_LT_OFF
Turn off area highlight.
Definition: road_widget.h:54
OrthogonalTileArea::h
uint16_t h
The height of the area.
Definition: tilearea_type.h:21
RoadTypeInfo::road_nwse
CursorID road_nwse
Cursor for building rail in Y direction.
Definition: road.h:95
WID_BROS_STATION_Y
@ WID_BROS_STATION_Y
Drive-through station in y-direction.
Definition: road_widget.h:53
RoadTypeInfo::road_swne
CursorID road_swne
Cursor for building rail in X direction.
Definition: road.h:94
CommandCost::Succeeded
bool Succeeded() const
Did this command succeed?
Definition: command_type.h:162
StationType
StationType
Station types.
Definition: station_type.h:31
BuildRoadToolbarWindow::OnPlaceObjectAbort
void OnPlaceObjectAbort() override
The user cancelled a tile highlight mode that has been set.
Definition: road_gui.cpp:672
SpecializedStation< Station, false >::Iterate
static Pool::IterateWrapper< Station > Iterate(size_t from=0)
Returns an iterable ensemble of all valid stations of type T.
Definition: base_station_base.h:305
TRANSPORT_ROAD
@ TRANSPORT_ROAD
Transport by road vehicle.
Definition: transport_type.h:28
DDSP_PLACE_ROAD_X_DIR
@ DDSP_PLACE_ROAD_X_DIR
Road placement (X axis)
Definition: viewport_type.h:132
ToggleRoadButton_Remove
static void ToggleRoadButton_Remove(Window *w)
Toggles state of the Remove button of Build road toolbar.
Definition: road_gui.cpp:315
DrawRoadStopTile
void DrawRoadStopTile(int x, int y, RoadType roadtype, const RoadStopSpec *spec, StationType type, int view)
Draw representation of a road stop tile for GUI purposes.
Definition: newgrf_roadstop.cpp:281
WindowDesc
High level window description.
Definition: window_gui.h:162
WidgetID
int WidgetID
Widget ID.
Definition: window_type.h:18
RectPadding::Horizontal
constexpr uint Horizontal() const
Get total horizontal padding of RectPadding.
Definition: geometry_type.hpp:63
picker_gui.h
ScaleGUITrad
int ScaleGUITrad(int value)
Scale traditional pixel dimensions to GUI zoom level.
Definition: zoom_func.h:117
window_gui.h
RoadStopPickerCallbacks
Definition: road_gui.cpp:1183
RSF_BUILD_MENU_TRAM_ONLY
@ RSF_BUILD_MENU_TRAM_ONLY
Only show in the tram build menu (not road).
Definition: newgrf_roadstop.h:75
SetPadding
constexpr NWidgetPart SetPadding(uint8_t top, uint8_t right, uint8_t bottom, uint8_t left)
Widget part function for setting additional space around a widget.
Definition: widget_type.h:1230
ROADTYPES_NONE
@ ROADTYPES_NONE
No roadtypes.
Definition: road_type.h:39
DIAGDIR_NW
@ DIAGDIR_NW
Northwest.
Definition: direction_type.h:78
WID_ROT_ROAD_Y
@ WID_ROT_ROAD_Y
Build road in y-direction.
Definition: road_widget.h:18
WID_BROS_STATION_X
@ WID_BROS_STATION_X
Drive-through station in x-direction.
Definition: road_widget.h:52
SetResize
constexpr NWidgetPart SetResize(int16_t dx, int16_t dy)
Widget part function for setting the resize step.
Definition: widget_type.h:1128
_roadtypes_type
RoadTypes _roadtypes_type
Bitmap of road/tram types.
Definition: road_cmd.cpp:62
WDP_AUTO
@ WDP_AUTO
Find a place automatically.
Definition: window_gui.h:150
SCT_PASSENGERS_ONLY
@ SCT_PASSENGERS_ONLY
Draw only passenger class cargoes.
Definition: station_gui.h:21
RoadWaypointPickerSelection::sel_class
RoadStopClassID sel_class
Selected road waypoint class.
Definition: road_gui.cpp:70
Window::resize
ResizeInfo resize
Resize information.
Definition: window_gui.h:317
CommandCost
Common return value for all commands.
Definition: command_type.h:23
PickerWindow
Definition: picker_gui.h:148
tilehighlight_func.h
ClientSettings::sound
SoundSettings sound
sound effect settings
Definition: settings_type.h:614
WindowNumber
int32_t WindowNumber
Number to differentiate different windows of the same class.
Definition: window_type.h:731
FS_NORMAL
@ FS_NORMAL
Index of the normal font in the font tables.
Definition: gfx_type.h:209
WID_ROT_BUILD_TUNNEL
@ WID_ROT_BUILD_TUNNEL
Build tunnel.
Definition: road_widget.h:27
StationCoverageType
StationCoverageType
Types of cargo to display for station coverage.
Definition: station_gui.h:20
VPM_FIX_X
@ VPM_FIX_X
drag only in X axis
Definition: viewport_type.h:94
NewGRFClass::Classes
static std::span< NewGRFClass< Tspec, Tindex, Tmax > const > Classes()
Get read-only span of all classes of this type.
Definition: newgrf_class.h:64
VpStartPlaceSizing
void VpStartPlaceSizing(TileIndex tile, ViewportPlaceMethod method, ViewportDragDropSelectionProcess process)
highlighting tiles while only going over them with the mouse
Definition: viewport.cpp:2719
RoadTypes
RoadTypes
The different roadtypes we support, but then a bitmask of them.
Definition: road_type.h:38
_nested_road_station_picker_widgets
static constexpr NWidgetPart _nested_road_station_picker_widgets[]
Widget definition of the build road station window.
Definition: road_gui.cpp:1495
DRD_NONE
@ DRD_NONE
None of the directions are disallowed.
Definition: road_type.h:74
DDSP_REMOVE_ROAD_WAYPOINT
@ DDSP_REMOVE_ROAD_WAYPOINT
Road stop removal (waypoint)
Definition: viewport_type.h:138
Window::SetDirty
void SetDirty() const
Mark entire window as dirty (in need of re-paint)
Definition: window.cpp:940
HT_DIAGONAL
@ HT_DIAGONAL
Also allow 'diagonal rectangles'. Only usable in combination with HT_RECT or HT_POINT.
Definition: tilehighlight_type.h:28
RoadTypeInfo::auto_road
SpriteID auto_road
button for the autoroad construction
Definition: road.h:87
ReverseDiagDir
DiagDirection ReverseDiagDir(DiagDirection d)
Returns the reverse direction of the given DiagDirection.
Definition: direction_func.h:118
WC_TRUCK_STATION
@ WC_TRUCK_STATION
Build truck station; Window numbers:
Definition: window_type.h:415
Window::OnPlaceMouseUp
virtual void OnPlaceMouseUp([[maybe_unused]] ViewportPlaceMethod select_method, [[maybe_unused]] ViewportDragDropSelectionProcess select_proc, [[maybe_unused]] Point pt, [[maybe_unused]] TileIndex start_tile, [[maybe_unused]] TileIndex end_tile)
The user has dragged over the map when the tile highlight mode has been set.
Definition: window_gui.h:839
station_cmd.h
RoadWaypointPickerCallbacks::DrawType
void DrawType(int x, int y, int cls_id, int id) const override
Draw preview image of an item.
Definition: road_gui.cpp:1649
ES_NOT_HANDLED
@ ES_NOT_HANDLED
The passed event is not handled.
Definition: window_type.h:739
CommandCost::Failed
bool Failed() const
Did this command fail?
Definition: command_type.h:171
station_func.h
BuildRoadToolbarWindow::ModifyRoadType
void ModifyRoadType(RoadType roadtype)
Switch to another road type.
Definition: road_gui.cpp:440
BuildRoadDepotWindow
Definition: road_gui.cpp:1093
WID_BROS_STATION_SE
@ WID_BROS_STATION_SE
Terminal station with SE entry.
Definition: road_widget.h:49
RoadStopPickerCallbacks::HasClassChoice
bool HasClassChoice() const override
Are there multiple classes to chose from?
Definition: road_gui.cpp:1209
VpSelectTilesWithMethod
void VpSelectTilesWithMethod(int x, int y, ViewportPlaceMethod method)
Selects tiles while dragging.
Definition: viewport.cpp:3213
OrthogonalTileArea
Represents the covered area of e.g.
Definition: tilearea_type.h:18
WID_ROT_REMOVE
@ WID_ROT_REMOVE
Remove road.
Definition: road_widget.h:28
BuildRoadToolbarWindow::roadtype
RoadType roadtype
Road type to build.
Definition: road_gui.cpp:345
INVALID_AXIS
@ INVALID_AXIS
Flag for an invalid Axis.
Definition: direction_type.h:120
RoadTypeInfo::gui_sprites
struct RoadTypeInfo::@27 gui_sprites
struct containing the sprites for the road GUI.
dropdown_type.h
road_gui.h
PickerWindow::PREVIEW_LEFT
static const int PREVIEW_LEFT
Offset from left edge to draw preview.
Definition: picker_gui.h:165
ShowSelectStationIfNeeded
void ShowSelectStationIfNeeded(TileArea ta, StationPickerCmdProc proc)
Show the station selection window when needed.
Definition: station_gui.cpp:2489
_settings_game
GameSettings _settings_game
Game settings of a running game or the scenario editor.
Definition: settings.cpp:57
Window::ReInit
void ReInit(int rx=0, int ry=0, bool reposition=false)
Re-initialize a window, and optionally change its size.
Definition: window.cpp:952
DDSP_REMOVE_TRUCKSTOP
@ DDSP_REMOVE_TRUCKSTOP
Road stop removal (trucks)
Definition: viewport_type.h:140
WC_BUS_STATION
@ WC_BUS_STATION
Build bus station; Window numbers:
Definition: window_type.h:409
WID_BROD_DEPOT_NE
@ WID_BROD_DEPOT_NE
Depot with NE entry.
Definition: road_widget.h:38
RoadWaypointPickerCallbacks::SetSelectedClass
void SetSelectedClass(int id) const override
Set the selected class.
Definition: road_gui.cpp:1626
IsBridgeTile
bool IsBridgeTile(Tile t)
checks if there is a bridge on this tile
Definition: bridge_map.h:35
RoadType
RoadType
The different roadtypes we support.
Definition: road_type.h:25
Window::parent
Window * parent
Parent window.
Definition: window_gui.h:331
NWidget
constexpr NWidgetPart NWidget(WidgetType tp, Colours col, WidgetID idx=-1)
Widget part function for starting a new 'real' widget.
Definition: widget_type.h:1311
_local_company
CompanyID _local_company
Company controlled by the human player at this client. Can also be COMPANY_SPECTATOR.
Definition: company_cmd.cpp:52
RoadStopPickerCallbacks::GetSelectedType
int GetSelectedType() const override
Get the selected type.
Definition: road_gui.cpp:1224
safeguards.h
Window::LowerWidget
void LowerWidget(WidgetID widget_index)
Marks a widget as lowered.
Definition: window_gui.h:469
RoadStopPickerCallbacks::IsActive
bool IsActive() const override
Should picker class/type selection be enabled?
Definition: road_gui.cpp:1190
timer.h
WID_ROT_ONE_WAY
@ WID_ROT_ONE_WAY
Build one-way road.
Definition: road_widget.h:25
WC_BUILD_BRIDGE
@ WC_BUILD_BRIDGE
Build bridge; Window numbers:
Definition: window_type.h:395
CA_BUS
@ CA_BUS
Catchment for bus stops with "modified catchment" enabled.
Definition: station_type.h:79
IsNormalRoadTile
static debug_inline bool IsNormalRoadTile(Tile t)
Return whether a tile is a normal road tile.
Definition: road_map.h:74
PlaceRoad_BusStation
static void PlaceRoad_BusStation(TileIndex tile)
Callback for placing a bus station.
Definition: road_gui.cpp:277
MakePickerTypeWidgets
std::unique_ptr< NWidgetBase > MakePickerTypeWidgets()
Create nested widgets for the type picker widgets.
Definition: picker_gui.cpp:642
WindowClass
WindowClass
Window classes.
Definition: window_type.h:44
DDSP_PLACE_AUTOROAD
@ DDSP_PLACE_AUTOROAD
Road placement (auto)
Definition: viewport_type.h:134
DDSP_BUILD_BRIDGE
@ DDSP_BUILD_BRIDGE
Bridge placement.
Definition: viewport_type.h:121
RoadStopSpec::grf_prop
GRFFilePropsBase< NUM_CARGO+3 > grf_prop
Properties related the the grf file.
Definition: newgrf_roadstop.h:142
BuildRoadToolbarWindow::OnInvalidateData
void OnInvalidateData([[maybe_unused]] int data=0, [[maybe_unused]] bool gui_scope=true) override
Some data on this window has become invalid.
Definition: road_gui.cpp:379
TileHighlightData::pos
Point pos
Location, in tile "units", of the northern tile of the selected area.
Definition: tilehighlight_type.h:47
RSF_DRIVE_THROUGH_ONLY
@ RSF_DRIVE_THROUGH_ONLY
Stop is drive-through only.
Definition: newgrf_roadstop.h:72
RoadStopPickerCallbacks::SetSelectedType
void SetSelectedType(int id) const override
Set the selected type.
Definition: road_gui.cpp:1225
INVALID_ROADTYPE
@ INVALID_ROADTYPE
flag for invalid roadtype
Definition: road_type.h:30
waypoint_func.h
FACIL_TRUCK_STOP
@ FACIL_TRUCK_STOP
Station with truck stops.
Definition: station_type.h:55
CA_TRUCK
@ CA_TRUCK
Catchment for truck stops with "modified catchment" enabled.
Definition: station_type.h:80
RSF_NO_AUTO_ROAD_CONNECTION
@ RSF_NO_AUTO_ROAD_CONNECTION
No auto road connection.
Definition: newgrf_roadstop.h:73
Point
Coordinates of a point in 2D.
Definition: geometry_type.hpp:21
PlaceRoadStop
static void PlaceRoadStop(TileIndex start_tile, TileIndex end_tile, RoadStopType stop_type, bool adjacent, RoadType rt, StringID err_msg)
Place a new road stop.
Definition: road_gui.cpp:228
ValParamRoadType
bool ValParamRoadType(RoadType roadtype)
Validate functions for rail building.
Definition: road.cpp:153
DiagDirToRoadBits
RoadBits DiagDirToRoadBits(DiagDirection d)
Create the road-part which belongs to the given DiagDirection.
Definition: road_func.h:96
Window::IsWidgetDisabled
bool IsWidgetDisabled(WidgetID widget_index) const
Gets the enabled/disabled status of a widget.
Definition: window_gui.h:419
WID_BROS_STATION_NW
@ WID_BROS_STATION_NW
Terminal station with NW entry.
Definition: road_widget.h:51
newgrf_roadstop.h
ROADSTOPTYPE_ALL
@ ROADSTOPTYPE_ALL
This RoadStop is for both types of station road stops.
Definition: newgrf_roadstop.h:52
RoadTypeInfo::build_tunnel
SpriteID build_tunnel
button for building a tunnel
Definition: road.h:89
NewGRFClass::GetSpec
const Tspec * GetSpec(uint index) const
Get a spec from the class at a given index.
Definition: newgrf_class_func.h:114
tunnelbridge_cmd.h
IsValidAxis
bool IsValidAxis(Axis d)
Checks if an integer value is a valid Axis.
Definition: direction_func.h:43
stdafx.h
RSV_DRIVE_THROUGH_X
@ RSV_DRIVE_THROUGH_X
Drive through road stop, X axis.
Definition: newgrf_roadstop.h:84
Window::window_number
WindowNumber window_number
Window number within the window class.
Definition: window_gui.h:305
GUISettings::link_terraform_toolbar
bool link_terraform_toolbar
display terraform toolbar when displaying rail, road, water and airport toolbars
Definition: settings_type.h:150
CcRoadStop
void CcRoadStop(Commands, const CommandCost &result, TileIndex tile, uint8_t width, uint8_t length, RoadStopType, bool is_drive_through, DiagDirection dir, RoadType, RoadStopClassID spec_class, uint16_t spec_index, StationID, bool)
Command callback for building road stops.
Definition: road_gui.cpp:194
WID_ROT_BUILD_WAYPOINT
@ WID_ROT_BUILD_WAYPOINT
Build waypoint.
Definition: road_widget.h:22
CanBuildVehicleInfrastructure
bool CanBuildVehicleInfrastructure(VehicleType type, uint8_t subtype)
Check whether we can build infrastructure for the given vehicle type.
Definition: vehicle.cpp:1922
Window::InvalidateData
void InvalidateData(int data=0, bool gui_scope=true)
Mark this window's data as invalid (in need of re-computing)
Definition: window.cpp:3148
viewport_func.h
BuildRoadToolbarWindow::SetupRoadToolbar
void SetupRoadToolbar()
Configures the road toolbar for roadtype given.
Definition: road_gui.cpp:424
WC_NONE
@ WC_NONE
No window, redirects to WC_MAIN_WINDOW.
Definition: window_type.h:45
Window::SetWidgetLoweredState
void SetWidgetLoweredState(WidgetID widget_index, bool lowered_stat)
Sets the lowered/raised status of a widget.
Definition: window_gui.h:450
ROADSTOPTYPE_PASSENGER
@ ROADSTOPTYPE_PASSENGER
This RoadStop is for passenger (bus) stops.
Definition: newgrf_roadstop.h:50
NWID_VERTICAL
@ NWID_VERTICAL
Vertical container.
Definition: widget_type.h:79
RoadTypeInfo::cursor
struct RoadTypeInfo::@28 cursor
Cursors associated with the road type.
FillDrawPixelInfo
bool FillDrawPixelInfo(DrawPixelInfo *n, int left, int top, int width, int height)
Set up a clipping area for only drawing into a certain area.
Definition: gfx.cpp:1548
WC_BUILD_DEPOT
@ WC_BUILD_DEPOT
Build depot; Window numbers:
Definition: window_type.h:423
AXIS_X
@ AXIS_X
The X axis.
Definition: direction_type.h:117
_nested_tram_station_picker_widgets
static constexpr NWidgetPart _nested_tram_station_picker_widgets[]
Widget definition of the build tram station window.
Definition: road_gui.cpp:1557
TileOffsByDiagDir
TileIndexDiff TileOffsByDiagDir(DiagDirection dir)
Convert a DiagDirection to a TileIndexDiff.
Definition: map_func.h:565
WidgetDimensions::unscaled
static const WidgetDimensions unscaled
Unscaled widget dimensions.
Definition: window_gui.h:67
GetRoadTypeInfo
const RoadTypeInfo * GetRoadTypeInfo(RoadType roadtype)
Returns a pointer to the Roadtype information for a given roadtype.
Definition: road.h:227
Window::SetWidgetDisabledState
void SetWidgetDisabledState(WidgetID widget_index, bool disab_stat)
Sets the enabled/disabled status of a widget.
Definition: window_gui.h:390
GetSpriteSize
Dimension GetSpriteSize(SpriteID sprid, Point *offset, ZoomLevel zoom)
Get the size of a sprite.
Definition: gfx.cpp:922
WWT_CLOSEBOX
@ WWT_CLOSEBOX
Close box (at top-left of a window)
Definition: widget_type.h:71
RoadTypeInfo::picker_tooltip
StringID picker_tooltip[2]
Tooltip for the station picker for bus or truck stations.
Definition: road.h:118
BuildRoadStationWindow::GetRoadStationTypeByWindowClass
StationType GetRoadStationTypeByWindowClass(WindowClass window_class) const
Simply to have a easier way to get the StationType for bus, truck and trams from the WindowClass.
Definition: road_gui.cpp:1402
BuildRoadStationWindow
Definition: road_gui.cpp:1283
DrawStationCoverageAreaText
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:77
IsRoadStopAvailable
static bool IsRoadStopAvailable(const RoadStopSpec *spec, StationType type)
Check whether a road stop type can be built.
Definition: road_gui.cpp:101
RoadTypeInfo::build_x_road
SpriteID build_x_road
button for building single rail in X direction
Definition: road.h:85
BuildRoadToolbarWindow::OnHotkey
EventState OnHotkey(int hotkey) override
A hotkey has been pressed.
Definition: road_gui.cpp:604
ROADTYPE_END
@ ROADTYPE_END
Used for iterations.
Definition: road_type.h:29
RoadTypeInfo::convert_road
SpriteID convert_road
button for converting road types
Definition: road.h:90
AddDateIntroducedRoadTypes
RoadTypes AddDateIntroducedRoadTypes(RoadTypes current, TimerGameCalendar::Date date)
Add the road types that are to be introduced at the given date.
Definition: road.cpp:166
PickerCallbacksNewGRFClass
Helper for PickerCallbacks when the class system is based on NewGRFClass.
Definition: picker_gui.h:100
Window::IsWidgetLowered
bool IsWidgetLowered(WidgetID widget_index) const
Gets the lowered state of a widget.
Definition: window_gui.h:500
CALLBACK_FAILED
static const uint CALLBACK_FAILED
Different values for Callback result evaluations.
Definition: newgrf_callbacks.h:420
SoundSettings::confirm
bool confirm
Play sound effect on successful constructions or other actions.
Definition: settings_type.h:248
ShowBuildBridgeWindow
void ShowBuildBridgeWindow(TileIndex start, TileIndex end, TransportType transport_type, uint8_t road_rail_type)
Prepare the data for the build a bridge window.
Definition: bridge_gui.cpp:354
vehicle_func.h
WC_SELECT_STATION
@ WC_SELECT_STATION
Select station (when joining stations); Window numbers:
Definition: window_type.h:242
station_base.h
Window::CreateNestedTree
void CreateNestedTree()
Perform the first part of the initialization of a nested widget tree.
Definition: window.cpp:1723
strings_func.h
RoadWaypointPickerCallbacks::HasClassChoice
bool HasClassChoice() const override
Are there multiple classes to chose from?
Definition: road_gui.cpp:1619
terraform_gui.h
RoadWaypointPickerCallbacks::GetTypeTooltip
StringID GetTypeTooltip() const override
Get the tooltip string for the type grid.
Definition: road_gui.cpp:1606
Window::IsShaded
bool IsShaded() const
Is window shaded currently?
Definition: window_gui.h:566
WC_BUILD_WAYPOINT
@ WC_BUILD_WAYPOINT
Build waypoint; Window numbers:
Definition: window_type.h:429
RoadStopPickerSelection
Definition: road_gui.cpp:75
VPM_Y_LIMITED
@ VPM_Y_LIMITED
Drag only in Y axis with limited size.
Definition: viewport_type.h:101
RoadTypeInfo::err_build_station
StringID err_build_station[2]
Building a bus or truck station.
Definition: road.h:113
Window::DisableWidget
void DisableWidget(WidgetID widget_index)
Sets a widget to disabled.
Definition: window_gui.h:400
SetPIP
constexpr NWidgetPart SetPIP(uint8_t pre, uint8_t inter, uint8_t post)
Widget part function for setting a pre/inter/post spaces.
Definition: widget_type.h:1262
Axis
Axis
Allow incrementing of DiagDirDiff variables.
Definition: direction_type.h:116
WC_SCEN_LAND_GEN
@ WC_SCEN_LAND_GEN
Landscape generation (in Scenario Editor); Window numbers:
Definition: window_type.h:455
SetDParam
void SetDParam(size_t n, uint64_t v)
Set a string parameter v at index n in the global string parameter array.
Definition: strings.cpp:104
WID_ROT_ROAD_X
@ WID_ROT_ROAD_X
Build road in x-direction.
Definition: road_widget.h:17
SCT_NON_PASSENGERS_ONLY
@ SCT_NON_PASSENGERS_ONLY
Draw all non-passenger class cargoes.
Definition: station_gui.h:22
BuildRoadToolbarWindow
Road toolbar window handler.
Definition: road_gui.cpp:344
geometry_func.hpp
OrthogonalTileArea::tile
TileIndex tile
The base tile of the area.
Definition: tilearea_type.h:19
IsWaypointClass
bool IsWaypointClass(const RoadStopClass &cls)
Test if a RoadStopClass is the waypoint class.
Definition: newgrf_roadstop.h:200
RoadTypeInfo::autoroad
CursorID autoroad
Cursor for autorail tool.
Definition: road.h:96
_build_tunnel_endtile
TileIndex _build_tunnel_endtile
The end of a tunnel; as hidden return from the tunnel build command for GUI purposes.
Definition: tunnelbridge_cmd.cpp:53
RoadTypeInfo::err_convert_road
StringID err_convert_road
Converting a road type.
Definition: road.h:115
WWT_PANEL
@ WWT_PANEL
Simple depressed panel.
Definition: widget_type.h:52
MarkTileDirtyByTile
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:2054
WID_BROS_STATION_SW
@ WID_BROS_STATION_SW
Terminal station with SW entry.
Definition: road_widget.h:50
WID_ROT_AUTOROAD
@ WID_ROT_AUTOROAD
Autorail.
Definition: road_widget.h:19
WidgetDimensions::vsep_normal
int vsep_normal
Normal vertical spacing.
Definition: window_gui.h:60
AutoRestoreBackup
Class to backup a specific variable and restore it upon destruction of this object to prevent stack v...
Definition: backup_type.hpp:150
ScaleSpriteTrad
int ScaleSpriteTrad(int value)
Scale traditional pixel dimensions to GUI zoom level, for drawing sprites.
Definition: zoom_func.h:107
waypoint_base.h
EventState
EventState
State of handling an event.
Definition: window_type.h:737
HT_RECT
@ HT_RECT
rectangle (stations, depots, ...)
Definition: tilehighlight_type.h:21
RoadToolbar_CtrlChanged
static bool RoadToolbar_CtrlChanged(Window *w)
Updates the Remove button because of Ctrl state change.
Definition: road_gui.cpp:328
VPM_X_AND_Y
@ VPM_X_AND_Y
area of land in X and Y directions
Definition: viewport_type.h:96
RoadStopPickerCallbacks::GetTypeTooltip
StringID GetTypeTooltip() const override
Get the tooltip string for the type grid.
Window::window_class
WindowClass window_class
Window class.
Definition: window_gui.h:304
DIAGDIR_END
@ DIAGDIR_END
Used for iterations.
Definition: direction_type.h:79
WPF_ROAD
@ WPF_ROAD
This is a road waypoint.
Definition: waypoint_base.h:19
RoadWaypointPickerCallbacks::GetSelectedClass
int GetSelectedClass() const override
Get the index of the selected class.
Definition: road_gui.cpp:1625
GetRoadBits
RoadBits GetRoadBits(Tile t, RoadTramType rtt)
Get the present road bits for a specific road type.
Definition: road_map.h:128
PackVelocity
int64_t PackVelocity(uint speed, VehicleType type)
Pack velocity and vehicle type for use with SCC_VELOCITY string parameter.
Definition: strings_func.h:74
Window::FinishInitNested
void FinishInitNested(WindowNumber window_number=0)
Perform the second part of the initialization of a nested widget tree.
Definition: window.cpp:1733
DC_AUTO
@ DC_AUTO
don't allow building on structures
Definition: command_type.h:377
NewGRFClass
Struct containing information relating to NewGRF classes for stations and airports.
Definition: newgrf_class.h:26
DDSP_CONVERT_ROAD
@ DDSP_CONVERT_ROAD
Road conversion.
Definition: viewport_type.h:141
RoadTypeInfo::strings
struct RoadTypeInfo::@29 strings
Strings associated with the rail type.
company_func.h
BuildRoadStationWindow::coverage_height
uint coverage_height
Height of the coverage texts.
Definition: road_gui.cpp:1285
PickerWindowBase
Base class for windows opened from a toolbar.
Definition: window_gui.h:989
SetViewportCatchmentStation
void SetViewportCatchmentStation(const Station *st, bool sel)
Select or deselect station for coverage area highlight.
Definition: viewport.cpp:3615
ROAD_NONE
@ ROAD_NONE
No road-part is build.
Definition: road_type.h:53
GetOtherTunnelBridgeEnd
TileIndex GetOtherTunnelBridgeEnd(Tile t)
Determines type of the wormhole and returns its other end.
Definition: tunnelbridge_map.h:78
CcBuildRoadTunnel
void CcBuildRoadTunnel(Commands, const CommandCost &result, TileIndex start_tile)
Callback executed after a build road tunnel command has been called.
Definition: road_gui.cpp:140
WidgetDimensions::fullbevel
RectPadding fullbevel
Always-scaled bevel thickness.
Definition: window_gui.h:41
WID_ROT_CAPTION
@ WID_ROT_CAPTION
Caption of the window.
Definition: road_widget.h:16
RSF_BUILD_MENU_ROAD_ONLY
@ RSF_BUILD_MENU_ROAD_ONLY
Only show in the road build menu (not tram).
Definition: newgrf_roadstop.h:74
Window::top
int top
y position of top edge of the window
Definition: window_gui.h:313
RoadWaypointPickerCallbacks::GetClassTooltip
StringID GetClassTooltip() const override
Get the tooltip string for the class list.
Definition: road_gui.cpp:1605
RoadStopPickerCallbacks::GetTypeName
StringID GetTypeName(int cls_id, int id) const override
Get the item of a type.
Definition: road_gui.cpp:1227
OrthogonalTileArea::w
uint16_t w
The width of the area.
Definition: tilearea_type.h:20
Window::RaiseWidget
void RaiseWidget(WidgetID widget_index)
Marks a widget as raised.
Definition: window_gui.h:478
BuildRoadStationWindow::OnInvalidateData
void OnInvalidateData([[maybe_unused]] int data=0, [[maybe_unused]] bool gui_scope=true) override
Some data on this window has become invalid.
Definition: road_gui.cpp:1339
PlaceRoad_Waypoint
static void PlaceRoad_Waypoint(TileIndex tile)
Place a road waypoint.
Definition: road_gui.cpp:254
CommandHelper
Definition: command_func.h:93
window_func.h
SoundSettings::click_beep
bool click_beep
Beep on a random selection of buttons.
Definition: settings_type.h:249
GetCharacterHeight
int GetCharacterHeight(FontSize size)
Get height of a character for a given font size.
Definition: fontcache.cpp:77
RoadTypeInfo::max_speed
uint16_t max_speed
Maximum speed for vehicles travelling on this road type.
Definition: road.h:142
FACIL_BUS_STOP
@ FACIL_BUS_STOP
Station with bus stops.
Definition: station_type.h:56
WID_BROS_CAPTION
@ WID_BROS_CAPTION
Caption of the window.
Definition: road_widget.h:47
VPM_X_LIMITED
@ VPM_X_LIMITED
Drag only in X axis with limited size.
Definition: viewport_type.h:100
ShowTerraformToolbar
Window * ShowTerraformToolbar(Window *link)
Show the toolbar for terraforming in the game.
Definition: terraform_gui.cpp:368
SetMinimalSize
constexpr NWidgetPart SetMinimalSize(int16_t x, int16_t y)
Widget part function for setting the minimal size.
Definition: widget_type.h:1139
SetPIPRatio
constexpr NWidgetPart SetPIPRatio(uint8_t ratio_pre, uint8_t ratio_inter, uint8_t ratio_post)
Widget part function for setting a pre/inter/post ratio.
Definition: widget_type.h:1274
PickerCallbacks::ini_group
const std::string ini_group
Ini Group for saving favourites.
Definition: picker_gui.h:91
StationSettings::station_spread
uint8_t station_spread
amount a station may spread
Definition: settings_type.h:570
CBM_ROAD_STOP_AVAIL
@ CBM_ROAD_STOP_AVAIL
Availability of road stop in construction window.
Definition: newgrf_callbacks.h:321
SND_1F_CONSTRUCTION_OTHER
@ SND_1F_CONSTRUCTION_OTHER
29 == 0x1D Construction: other (non-water, non-rail, non-bridge)
Definition: sound_type.h:68
ROADSTOP_CLASS_WAYP
@ ROADSTOP_CLASS_WAYP
Waypoint class.
Definition: newgrf_roadstop.h:31
ShowBuildRoadToolbar
Window * ShowBuildRoadToolbar(RoadType roadtype)
Open the build road toolbar window.
Definition: road_gui.cpp:998
PickerWindow::Close
void Close(int data=0) override
Hide the window and all its child windows, and mark them for a later deletion.
Definition: picker_gui.cpp:236
engine_base.h
RoadStopType
RoadStopType
Types of RoadStops.
Definition: station_type.h:45
RoadStopPickerCallbacks::GetClassName
StringID GetClassName(int id) const override
Get the name of a class.
Definition: road_gui.cpp:1217
TileVirtXY
static debug_inline TileIndex TileVirtXY(uint x, uint y)
Get a tile from the virtual XY-coordinate.
Definition: map_func.h:416
gui.h
PickerWindow::PREVIEW_BOTTOM
static const int PREVIEW_BOTTOM
Offset from bottom edge to draw preview.
Definition: picker_gui.h:166
TimerGameCalendar::date
static Date date
Current date in days (day counter).
Definition: timer_game_calendar.h:34
WID_ROT_DEPOT
@ WID_ROT_DEPOT
Build depot.
Definition: road_widget.h:21
MakePickerClassWidgets
std::unique_ptr< NWidgetBase > MakePickerClassWidgets()
Create nested widgets for the class picker widgets.
Definition: picker_gui.cpp:619
WID_BROD_CAPTION
@ WID_BROD_CAPTION
Caption of the window.
Definition: road_widget.h:37
Window
Data structure for an opened window.
Definition: window_gui.h:276
GetRoadTypes
RoadTypes GetRoadTypes(bool introduces)
Get list of road types, regardless of company availability.
Definition: road.cpp:227
Commands
Commands
List of commands.
Definition: command_type.h:187
GetAxisForNewRoadWaypoint
Axis GetAxisForNewRoadWaypoint(TileIndex tile)
Get the axis for a new road waypoint.
Definition: waypoint_cmd.cpp:123
Pool::PoolItem<&_company_pool >::IsValidID
static bool IsValidID(size_t index)
Tests whether given index can be used to get valid (non-nullptr) Titem.
Definition: pool_type.hpp:328
RoadWaypointPickerCallbacks::SetSelectedType
void SetSelectedType(int id) const override
Set the selected type.
Definition: road_gui.cpp:1636
Window::DrawWidgets
void DrawWidgets() const
Paint all widgets of a window.
Definition: widget.cpp:731
GRFFilePropsBase::grffile
const struct GRFFile * grffile
grf file that introduced this entity
Definition: newgrf_commons.h:312
RoadTypeInfo::err_depot
StringID err_depot
Building a depot.
Definition: road.h:112
SetDataTip
constexpr NWidgetPart SetDataTip(uint32_t data, StringID tip)
Widget part function for setting the data and tooltip.
Definition: widget_type.h:1204
GetIfClassHasNewStopsByType
bool GetIfClassHasNewStopsByType(const RoadStopClass *roadstopclass, RoadStopType rs, RoadType roadtype)
Checks if the given RoadStopClass has any specs assigned to it, compatible with the given RoadStopTyp...
Definition: newgrf_roadstop.cpp:500
ConnectRoadToStructure
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:162
SetMinimalTextLines
constexpr NWidgetPart SetMinimalTextLines(uint8_t lines, uint8_t spacing, FontSize size=FS_NORMAL)
Widget part function for setting the minimal text lines.
Definition: widget_type.h:1151
Rect::Width
int Width() const
Get width of Rect.
Definition: geometry_type.hpp:85
NewGRFClass::GetClassCount
static uint GetClassCount()
Get the number of allocated classes.
Definition: newgrf_class_func.h:93
VPM_X_AND_Y_LIMITED
@ VPM_X_AND_Y_LIMITED
area of land of limited size
Definition: viewport_type.h:97
NWID_SELECTION
@ NWID_SELECTION
Stacked widgets, only one visible at a time (eg in a panel with tabs).
Definition: widget_type.h:82
InitializeRoadGUI
void InitializeRoadGUI()
I really don't know why rail_gui.cpp has this too, shouldn't be included in the other one?
Definition: road_gui.cpp:1726
AXIS_Y
@ AXIS_Y
The y axis.
Definition: direction_type.h:118
NewGRFClass::Get
static NewGRFClass * Get(Tindex class_index)
Get a particular class.
Definition: newgrf_class_func.h:82
RoadWaypointPickerCallbacks::GetTypeName
StringID GetTypeName(int cls_id, int id) const override
Get the item of a type.
Definition: road_gui.cpp:1638
Rect
Specification of a rectangle with absolute coordinates of all edges.
Definition: geometry_type.hpp:75
Window::ToggleWidgetLoweredState
void ToggleWidgetLoweredState(WidgetID widget_index)
Invert the lowered/raised status of a widget.
Definition: window_gui.h:459
Company
Definition: company_base.h:133
RoadWaypointPickerCallbacks::IsActive
bool IsActive() const override
Should picker class/type selection be enabled?
Definition: road_gui.cpp:1608
Window::SetWidgetsDisabledState
void SetWidgetsDisabledState(bool disab_stat, Args... widgets)
Sets the enabled/disabled status of a list of widgets.
Definition: window_gui.h:524
VPM_X_OR_Y
@ VPM_X_OR_Y
drag in X or Y direction
Definition: viewport_type.h:93
RoadToolbarWidgets
RoadToolbarWidgets
Widgets of the BuildRoadToolbarWindow class.
Definition: road_widget.h:14
ResetObjectToPlace
void ResetObjectToPlace()
Reset the cursor and mouse mode handling back to default (normal cursor, only clicking in windows).
Definition: viewport.cpp:3495
HT_SPECIAL
@ HT_SPECIAL
special mode used for highlighting while dragging (and for tunnels/docks)
Definition: tilehighlight_type.h:23
Convert8bitBooleanCallback
bool Convert8bitBooleanCallback(const GRFFile *grffile, uint16_t cbid, uint16_t cb_res)
Converts a callback result into a boolean.
Definition: newgrf_commons.cpp:554
station_gui.h
RoadWaypointPickerSelection
Definition: road_gui.cpp:69
SetTextStyle
constexpr NWidgetPart SetTextStyle(TextColour colour, FontSize size=FS_NORMAL)
Widget part function for setting the text style.
Definition: widget_type.h:1162
RoadTypeInfo::picker_title
StringID picker_title[2]
Title for the station picker for bus or truck stations.
Definition: road.h:117
DRD_NORTHBOUND
@ DRD_NORTHBOUND
All northbound traffic is disallowed.
Definition: road_type.h:76
RoadStopPickerCallbacks::FillUsedItems
void FillUsedItems(std::set< PickerItem > &items) override
Fill a set with all items that are used by the current player.
Definition: road_gui.cpp:1252
road_cmd.h
WWT_TEXTBTN
@ WWT_TEXTBTN
(Toggle) Button with text
Definition: widget_type.h:57
INVALID_STRING_ID
static const StringID INVALID_STRING_ID
Constant representing an invalid string (16bit in case it is used in savegames)
Definition: strings_type.h:17
ClientSettings::gui
GUISettings gui
settings related to the GUI
Definition: settings_type.h:611
WID_BROS_AVAILABLE_ORIENTATIONS
@ WID_BROS_AVAILABLE_ORIENTATIONS
Selection for selecting 6 or 2 orientations.
Definition: road_widget.h:57
DDSP_BUILD_TRUCKSTOP
@ DDSP_BUILD_TRUCKSTOP
Road stop placement (trucks)
Definition: viewport_type.h:137
DrawPixelInfo
Data about how and where to blit pixels.
Definition: gfx_type.h:157
WID_ROT_CONVERT_ROAD
@ WID_ROT_CONVERT_ROAD
Convert road.
Definition: road_widget.h:29
GUISettings::persistent_buildingtools
bool persistent_buildingtools
keep the building tools active after usage
Definition: settings_type.h:198
StationSettings::modified_catchment
bool modified_catchment
different-size catchment areas
Definition: settings_type.h:565
WID_ROT_BUS_STATION
@ WID_ROT_BUS_STATION
Build bus station.
Definition: road_widget.h:23
Hotkey
All data for a single hotkey.
Definition: hotkeys.h:21
hotkeys.h
RoadStopClassID
RoadStopClassID
Definition: newgrf_roadstop.h:28
GetTunnelBridgeDirection
DiagDirection GetTunnelBridgeDirection(Tile t)
Get the direction pointing to the other end.
Definition: tunnelbridge_map.h:26
DDSP_BUILD_ROAD_WAYPOINT
@ DDSP_BUILD_ROAD_WAYPOINT
Road stop placement (waypoint)
Definition: viewport_type.h:135
ShowBuildRoadScenToolbar
Window * ShowBuildRoadScenToolbar(RoadType roadtype)
Show the road building toolbar in the scenario editor.
Definition: road_gui.cpp:1085
WWT_SHADEBOX
@ WWT_SHADEBOX
Shade box (at top-right of a window, between WWT_DEBUGBOX and WWT_DEFSIZEBOX)
Definition: widget_type.h:66
RoadWaypointPickerSelection::sel_type
uint16_t sel_type
Selected road waypoint type within the class.
Definition: road_gui.cpp:71
WID_BROS_STATION_NE
@ WID_BROS_STATION_NE
Terminal station with NE entry.
Definition: road_widget.h:48
HasBit
constexpr debug_inline bool HasBit(const T x, const uint8_t y)
Checks if a bit in a value is set.
Definition: bitmath_func.hpp:103
GUIPlaceProcDragXY
bool GUIPlaceProcDragXY(ViewportDragDropSelectionProcess proc, TileIndex start_tile, TileIndex end_tile)
A central place to handle all X_AND_Y dragged GUI functions.
Definition: terraform_gui.cpp:112