OpenTTD Source  14.0-beta1
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 "window_func.h"
20 #include "vehicle_func.h"
21 #include "sound_func.h"
22 #include "company_func.h"
23 #include "tunnelbridge.h"
24 #include "tunnelbridge_map.h"
25 #include "tilehighlight_func.h"
26 #include "company_base.h"
27 #include "hotkeys.h"
28 #include "road_gui.h"
29 #include "zoom_func.h"
30 #include "engine_base.h"
31 #include "strings_func.h"
32 #include "core/geometry_func.hpp"
33 #include "station_cmd.h"
34 #include "road_cmd.h"
35 #include "tunnelbridge_cmd.h"
36 #include "newgrf_roadstop.h"
37 #include "querystring_gui.h"
38 #include "sortlist_type.h"
39 #include "stringfilter_type.h"
40 #include "string_func.h"
41 #include "timer/timer.h"
43 
44 #include "widgets/road_widget.h"
45 
46 #include "table/strings.h"
47 
48 #include "safeguards.h"
49 
50 static void ShowRVStationPicker(Window *parent, RoadStopType rs);
51 static void ShowRoadDepotPicker(Window *parent);
52 
53 static bool _remove_button_clicked;
54 static bool _one_way_button_clicked;
55 
56 static Axis _place_road_dir;
57 static bool _place_road_start_half_x;
58 static bool _place_road_start_half_y;
59 static bool _place_road_end_half;
60 
61 static RoadType _cur_roadtype;
62 
63 static DiagDirection _road_depot_orientation;
64 
66  DiagDirection orientation;
67 
68  RoadStopClassID roadstop_class;
69  uint16_t roadstop_type;
70  uint16_t roadstop_count;
71 };
72 static RoadStopGUISettings _roadstop_gui_settings;
73 
78 static bool IsRoadStopAvailable(const RoadStopSpec *roadstopspec, StationType type)
79 {
80  if (roadstopspec == nullptr) return true;
81 
82  if (HasBit(roadstopspec->flags, RSF_BUILD_MENU_ROAD_ONLY) && !RoadTypeIsRoad(_cur_roadtype)) return false;
83  if (HasBit(roadstopspec->flags, RSF_BUILD_MENU_TRAM_ONLY) && !RoadTypeIsTram(_cur_roadtype)) return false;
84 
85  if (roadstopspec->stop_type != ROADSTOPTYPE_ALL) {
86  switch (type) {
87  case STATION_BUS: if (roadstopspec->stop_type != ROADSTOPTYPE_PASSENGER) return false; break;
88  case STATION_TRUCK: if (roadstopspec->stop_type != ROADSTOPTYPE_FREIGHT) return false; break;
89  default: break;
90  }
91  }
92 
93  if (!HasBit(roadstopspec->callback_mask, CBM_ROAD_STOP_AVAIL)) return true;
94 
95  uint16_t cb_res = GetRoadStopCallback(CBID_STATION_AVAILABILITY, 0, 0, roadstopspec, nullptr, INVALID_TILE, _cur_roadtype, type, 0);
96  if (cb_res == CALLBACK_FAILED) return true;
97 
99 }
100 
101 void CcPlaySound_CONSTRUCTION_OTHER(Commands, const CommandCost &result, TileIndex tile)
102 {
103  if (result.Succeeded() && _settings_client.sound.confirm) SndPlayTileFx(SND_1F_CONSTRUCTION_OTHER, tile);
104 }
105 
110 static void PlaceRoad_Bridge(TileIndex tile, Window *w)
111 {
112  if (IsBridgeTile(tile)) {
113  TileIndex other_tile = GetOtherTunnelBridgeEnd(tile);
114  Point pt = {0, 0};
115  w->OnPlaceMouseUp(VPM_X_OR_Y, DDSP_BUILD_BRIDGE, pt, other_tile, tile);
116  } else {
118  }
119 }
120 
127 void CcBuildRoadTunnel(Commands, const CommandCost &result, TileIndex start_tile)
128 {
129  if (result.Succeeded()) {
130  if (_settings_client.sound.confirm) SndPlayTileFx(SND_1F_CONSTRUCTION_OTHER, start_tile);
132 
133  DiagDirection start_direction = ReverseDiagDir(GetTunnelBridgeDirection(start_tile));
134  ConnectRoadToStructure(start_tile, start_direction);
135 
136  TileIndex end_tile = GetOtherTunnelBridgeEnd(start_tile);
137  DiagDirection end_direction = ReverseDiagDir(GetTunnelBridgeDirection(end_tile));
138  ConnectRoadToStructure(end_tile, end_direction);
139  } else {
141  }
142 }
143 
150 {
151  tile += TileOffsByDiagDir(direction);
152  /* if there is a roadpiece just outside of the station entrance, build a connecting route */
153  if (IsNormalRoadTile(tile)) {
154  if (GetRoadBits(tile, GetRoadTramType(_cur_roadtype)) != ROAD_NONE) {
155  Command<CMD_BUILD_ROAD>::Post(tile, DiagDirToRoadBits(ReverseDiagDir(direction)), _cur_roadtype, DRD_NONE, 0);
156  }
157  }
158 }
159 
160 void CcRoadDepot(Commands, const CommandCost &result, TileIndex tile, RoadType, DiagDirection dir)
161 {
162  if (result.Failed()) return;
163 
164  if (_settings_client.sound.confirm) SndPlayTileFx(SND_1F_CONSTRUCTION_OTHER, tile);
166  ConnectRoadToStructure(tile, dir);
167 }
168 
181 void CcRoadStop(Commands, const CommandCost &result, TileIndex tile, uint8_t width, uint8_t length, RoadStopType, bool is_drive_through,
182  DiagDirection dir, RoadType, RoadStopClassID spec_class, uint16_t spec_index, StationID, bool)
183 {
184  if (result.Failed()) return;
185 
186  if (_settings_client.sound.confirm) SndPlayTileFx(SND_1F_CONSTRUCTION_OTHER, tile);
188 
189  bool connect_to_road = true;
190  if ((uint)spec_class < RoadStopClass::GetClassCount() && spec_index < RoadStopClass::Get(spec_class)->GetSpecCount()) {
191  const RoadStopSpec *roadstopspec = RoadStopClass::Get(spec_class)->GetSpec(spec_index);
192  if (roadstopspec != nullptr && HasBit(roadstopspec->flags, RSF_NO_AUTO_ROAD_CONNECTION)) connect_to_road = false;
193  }
194 
195  if (connect_to_road) {
196  TileArea roadstop_area(tile, width, length);
197  for (TileIndex cur_tile : roadstop_area) {
198  ConnectRoadToStructure(cur_tile, dir);
199  /* For a drive-through road stop build connecting road for other entrance. */
200  if (is_drive_through) ConnectRoadToStructure(cur_tile, ReverseDiagDir(dir));
201  }
202  }
203 }
204 
215 static void PlaceRoadStop(TileIndex start_tile, TileIndex end_tile, RoadStopType stop_type, bool adjacent, RoadType rt, StringID err_msg)
216 {
217  TileArea ta(start_tile, end_tile);
218  DiagDirection ddir = _roadstop_gui_settings.orientation;
219  bool drive_through = ddir >= DIAGDIR_END;
220  if (drive_through) ddir = static_cast<DiagDirection>(ddir - DIAGDIR_END); // Adjust picker result to actual direction.
221  RoadStopClassID spec_class = _roadstop_gui_settings.roadstop_class;
222  uint16_t spec_index = _roadstop_gui_settings.roadstop_type;
223 
224  auto proc = [=](bool test, StationID to_join) -> bool {
225  if (test) {
226  return Command<CMD_BUILD_ROAD_STOP>::Do(CommandFlagsToDCFlags(GetCommandFlags<CMD_BUILD_ROAD_STOP>()), ta.tile, ta.w, ta.h, stop_type, drive_through,
227  ddir, rt, spec_class, spec_index, INVALID_STATION, adjacent).Succeeded();
228  } else {
229  return Command<CMD_BUILD_ROAD_STOP>::Post(err_msg, CcRoadStop, ta.tile, ta.w, ta.h, stop_type, drive_through,
230  ddir, rt, spec_class, spec_index, to_join, adjacent);
231  }
232  };
233 
234  ShowSelectStationIfNeeded(ta, proc);
235 }
236 
242 {
245  } else {
246  if (_roadstop_gui_settings.orientation < DIAGDIR_END) { // Not a drive-through stop.
247  VpStartPlaceSizing(tile, (DiagDirToAxis(_roadstop_gui_settings.orientation) == AXIS_X) ? VPM_X_LIMITED : VPM_Y_LIMITED, DDSP_BUILD_BUSSTOP);
248  } else {
250  }
251  VpSetPlaceSizingLimit(_settings_game.station.station_spread);
252  }
253 }
254 
260 {
263  } else {
264  if (_roadstop_gui_settings.orientation < DIAGDIR_END) { // Not a drive-through stop.
265  VpStartPlaceSizing(tile, (DiagDirToAxis(_roadstop_gui_settings.orientation) == AXIS_X) ? VPM_X_LIMITED : VPM_Y_LIMITED, DDSP_BUILD_TRUCKSTOP);
266  } else {
268  }
269  VpSetPlaceSizingLimit(_settings_game.station.station_spread);
270  }
271 }
272 
273 typedef void OnButtonClick(Window *w);
274 
280 {
284  SetSelectionRed(_remove_button_clicked);
285 }
286 
293 {
294  if (w->IsWidgetDisabled(WID_ROT_REMOVE)) return false;
295 
296  /* allow ctrl to switch remove mode only for these widgets */
297  for (WidgetID i = WID_ROT_ROAD_X; i <= WID_ROT_AUTOROAD; i++) {
298  if (w->IsWidgetLowered(i)) {
300  return true;
301  }
302  }
303 
304  return false;
305 }
306 
310  const RoadTypeInfo *rti;
312 
314  {
315  this->Initialize(_cur_roadtype);
316  this->InitNested(window_number);
317  this->SetupRoadToolbar();
319 
320  if (RoadTypeIsRoad(this->roadtype)) {
322  }
323 
324  this->OnInvalidateData();
325  this->last_started_action = INVALID_WID_ROT;
326 
328  }
329 
330  void Close([[maybe_unused]] int data = 0) override
331  {
332  if (_game_mode == GM_NORMAL && (this->IsWidgetLowered(WID_ROT_BUS_STATION) || this->IsWidgetLowered(WID_ROT_TRUCK_STATION))) SetViewportCatchmentStation(nullptr, true);
334  this->Window::Close();
335  }
336 
342  void OnInvalidateData([[maybe_unused]] int data = 0, [[maybe_unused]] bool gui_scope = true) override
343  {
344  if (!gui_scope) return;
345  RoadTramType rtt = GetRoadTramType(this->roadtype);
346 
347  bool can_build = CanBuildVehicleInfrastructure(VEH_ROAD, rtt);
348  this->SetWidgetsDisabledState(!can_build,
352  if (!can_build) {
356  }
357 
358  if (_game_mode != GM_EDITOR) {
359  if (!can_build) {
360  /* Show in the tooltip why this button is disabled. */
361  this->GetWidget<NWidgetCore>(WID_ROT_DEPOT)->SetToolTip(STR_TOOLBAR_DISABLED_NO_VEHICLE_AVAILABLE);
362  this->GetWidget<NWidgetCore>(WID_ROT_BUS_STATION)->SetToolTip(STR_TOOLBAR_DISABLED_NO_VEHICLE_AVAILABLE);
363  this->GetWidget<NWidgetCore>(WID_ROT_TRUCK_STATION)->SetToolTip(STR_TOOLBAR_DISABLED_NO_VEHICLE_AVAILABLE);
364  } else {
365  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);
366  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);
367  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);
368  }
369  }
370  }
371 
372  void Initialize(RoadType roadtype)
373  {
374  assert(roadtype < ROADTYPE_END);
375  this->roadtype = roadtype;
376  this->rti = GetRoadTypeInfo(this->roadtype);
377  }
378 
384  {
385  this->GetWidget<NWidgetCore>(WID_ROT_ROAD_X)->widget_data = rti->gui_sprites.build_x_road;
386  this->GetWidget<NWidgetCore>(WID_ROT_ROAD_Y)->widget_data = rti->gui_sprites.build_y_road;
387  this->GetWidget<NWidgetCore>(WID_ROT_AUTOROAD)->widget_data = rti->gui_sprites.auto_road;
388  if (_game_mode != GM_EDITOR) {
389  this->GetWidget<NWidgetCore>(WID_ROT_DEPOT)->widget_data = rti->gui_sprites.build_depot;
390  }
391  this->GetWidget<NWidgetCore>(WID_ROT_CONVERT_ROAD)->widget_data = rti->gui_sprites.convert_road;
392  this->GetWidget<NWidgetCore>(WID_ROT_BUILD_TUNNEL)->widget_data = rti->gui_sprites.build_tunnel;
393  }
394 
400  {
401  this->Initialize(roadtype);
402  this->SetupRoadToolbar();
403  this->ReInit();
404  }
405 
406  void SetStringParameters(WidgetID widget) const override
407  {
408  if (widget == WID_ROT_CAPTION) {
409  if (this->rti->max_speed > 0) {
410  SetDParam(0, STR_TOOLBAR_RAILTYPE_VELOCITY);
411  SetDParam(1, this->rti->strings.toolbar_caption);
412  SetDParam(2, PackVelocity(this->rti->max_speed / 2, VEH_ROAD));
413  } else {
414  SetDParam(0, this->rti->strings.toolbar_caption);
415  }
416  }
417  }
418 
425  {
426  /* The remove and the one way button state is driven
427  * by the other buttons so they don't act on themselves.
428  * Both are only valid if they are able to apply as options. */
429  switch (clicked_widget) {
430  case WID_ROT_REMOVE:
431  if (RoadTypeIsRoad(this->roadtype)) {
434  }
435 
436  break;
437 
438  case WID_ROT_ONE_WAY:
441  break;
442 
443  case WID_ROT_BUS_STATION:
445  if (RoadTypeIsRoad(this->roadtype)) this->DisableWidget(WID_ROT_ONE_WAY);
446  this->SetWidgetDisabledState(WID_ROT_REMOVE, !this->IsWidgetLowered(clicked_widget));
447  break;
448 
449  case WID_ROT_ROAD_X:
450  case WID_ROT_ROAD_Y:
451  case WID_ROT_AUTOROAD:
452  this->SetWidgetDisabledState(WID_ROT_REMOVE, !this->IsWidgetLowered(clicked_widget));
453  if (RoadTypeIsRoad(this->roadtype)) {
454  this->SetWidgetDisabledState(WID_ROT_ONE_WAY, !this->IsWidgetLowered(clicked_widget));
455  }
456  break;
457 
458  default:
459  /* When any other buttons than road/station, raise and
460  * disable the removal button */
463 
464  if (RoadTypeIsRoad(this->roadtype)) {
467  }
468 
469  break;
470  }
471  }
472 
473  void OnClick([[maybe_unused]] Point pt, WidgetID widget, [[maybe_unused]] int click_count) override
474  {
475  _remove_button_clicked = false;
476  _one_way_button_clicked = false;
477  switch (widget) {
478  case WID_ROT_ROAD_X:
480  this->last_started_action = widget;
481  break;
482 
483  case WID_ROT_ROAD_Y:
485  this->last_started_action = widget;
486  break;
487 
488  case WID_ROT_AUTOROAD:
490  this->last_started_action = widget;
491  break;
492 
493  case WID_ROT_DEMOLISH:
495  this->last_started_action = widget;
496  break;
497 
498  case WID_ROT_DEPOT:
499  if (HandlePlacePushButton(this, WID_ROT_DEPOT, this->rti->cursor.depot, HT_RECT)) {
500  ShowRoadDepotPicker(this);
501  this->last_started_action = widget;
502  }
503  break;
504 
505  case WID_ROT_BUS_STATION:
506  if (HandlePlacePushButton(this, WID_ROT_BUS_STATION, SPR_CURSOR_BUS_STATION, HT_RECT)) {
507  ShowRVStationPicker(this, ROADSTOP_BUS);
508  this->last_started_action = widget;
509  }
510  break;
511 
513  if (HandlePlacePushButton(this, WID_ROT_TRUCK_STATION, SPR_CURSOR_TRUCK_STATION, HT_RECT)) {
514  ShowRVStationPicker(this, ROADSTOP_TRUCK);
515  this->last_started_action = widget;
516  }
517  break;
518 
519  case WID_ROT_ONE_WAY:
520  if (this->IsWidgetDisabled(WID_ROT_ONE_WAY)) return;
521  this->SetDirty();
523  SetSelectionRed(false);
524  break;
525 
527  HandlePlacePushButton(this, WID_ROT_BUILD_BRIDGE, SPR_CURSOR_BRIDGE, HT_RECT);
528  this->last_started_action = widget;
529  break;
530 
533  this->last_started_action = widget;
534  break;
535 
536  case WID_ROT_REMOVE:
537  if (this->IsWidgetDisabled(WID_ROT_REMOVE)) return;
538 
542  break;
543 
546  this->last_started_action = widget;
547  break;
548 
549  default: NOT_REACHED();
550  }
553  }
554 
555  EventState OnHotkey(int hotkey) override
556  {
557  MarkTileDirtyByTile(TileVirtXY(_thd.pos.x, _thd.pos.y)); // redraw tile selection
558  return Window::OnHotkey(hotkey);
559  }
560 
561  void OnPlaceObject([[maybe_unused]] Point pt, TileIndex tile) override
562  {
564  _one_way_button_clicked = RoadTypeIsRoad(this->roadtype) ? this->IsWidgetLowered(WID_ROT_ONE_WAY) : false;
565  switch (this->last_started_action) {
566  case WID_ROT_ROAD_X:
567  _place_road_dir = AXIS_X;
568  _place_road_start_half_x = _tile_fract_coords.x >= 8;
570  break;
571 
572  case WID_ROT_ROAD_Y:
573  _place_road_dir = AXIS_Y;
574  _place_road_start_half_y = _tile_fract_coords.y >= 8;
576  break;
577 
578  case WID_ROT_AUTOROAD:
579  _place_road_dir = INVALID_AXIS;
580  _place_road_start_half_x = _tile_fract_coords.x >= 8;
581  _place_road_start_half_y = _tile_fract_coords.y >= 8;
583  break;
584 
585  case WID_ROT_DEMOLISH:
587  break;
588 
589  case WID_ROT_DEPOT:
590  Command<CMD_BUILD_ROAD_DEPOT>::Post(this->rti->strings.err_depot, CcRoadDepot,
591  tile, _cur_roadtype, _road_depot_orientation);
592  break;
593 
594  case WID_ROT_BUS_STATION:
595  PlaceRoad_BusStation(tile);
596  break;
597 
600  break;
601 
603  PlaceRoad_Bridge(tile, this);
604  break;
605 
607  Command<CMD_BUILD_TUNNEL>::Post(STR_ERROR_CAN_T_BUILD_TUNNEL_HERE, CcBuildRoadTunnel,
608  tile, TRANSPORT_ROAD, _cur_roadtype);
609  break;
610 
613  break;
614 
615  default: NOT_REACHED();
616  }
617  }
618 
619  void OnPlaceObjectAbort() override
620  {
621  if (_game_mode != GM_EDITOR && (this->IsWidgetLowered(WID_ROT_BUS_STATION) || this->IsWidgetLowered(WID_ROT_TRUCK_STATION))) SetViewportCatchmentStation(nullptr, true);
622 
623  this->RaiseButtons();
626 
627  if (RoadTypeIsRoad(this->roadtype)) {
630  }
631 
637  }
638 
639  void OnPlaceDrag(ViewportPlaceMethod select_method, [[maybe_unused]] ViewportDragDropSelectionProcess select_proc, [[maybe_unused]] Point pt) override
640  {
641  /* Here we update the end tile flags
642  * of the road placement actions.
643  * At first we reset the end halfroad
644  * bits and if needed we set them again. */
645  switch (select_proc) {
647  _place_road_end_half = pt.x & 8;
648  break;
649 
651  _place_road_end_half = pt.y & 8;
652  break;
653 
654  case DDSP_PLACE_AUTOROAD:
655  /* For autoroad we need to update the
656  * direction of the road */
657  if (_thd.size.x > _thd.size.y || (_thd.size.x == _thd.size.y &&
658  ( (_tile_fract_coords.x < _tile_fract_coords.y && (_tile_fract_coords.x + _tile_fract_coords.y) < 16) ||
659  (_tile_fract_coords.x > _tile_fract_coords.y && (_tile_fract_coords.x + _tile_fract_coords.y) > 16) ))) {
660  /* Set dir = X */
661  _place_road_dir = AXIS_X;
662  _place_road_end_half = pt.x & 8;
663  } else {
664  /* Set dir = Y */
665  _place_road_dir = AXIS_Y;
666  _place_road_end_half = pt.y & 8;
667  }
668 
669  break;
670 
671  default:
672  break;
673  }
674 
675  VpSelectTilesWithMethod(pt.x, pt.y, select_method);
676  }
677 
678  void OnPlaceMouseUp([[maybe_unused]] ViewportPlaceMethod select_method, ViewportDragDropSelectionProcess select_proc, [[maybe_unused]] Point pt, TileIndex start_tile, TileIndex end_tile) override
679  {
680  if (pt.x != -1) {
681  switch (select_proc) {
682  default: NOT_REACHED();
683  case DDSP_BUILD_BRIDGE:
685  ShowBuildBridgeWindow(start_tile, end_tile, TRANSPORT_ROAD, _cur_roadtype);
686  break;
687 
688  case DDSP_DEMOLISH_AREA:
689  GUIPlaceProcDragXY(select_proc, start_tile, end_tile);
690  break;
691 
694  case DDSP_PLACE_AUTOROAD: {
695  bool start_half = _place_road_dir == AXIS_Y ? _place_road_start_half_y : _place_road_start_half_x;
696 
698  Command<CMD_REMOVE_LONG_ROAD>::Post(this->rti->strings.err_remove_road, CcPlaySound_CONSTRUCTION_OTHER,
699  end_tile, start_tile, _cur_roadtype, _place_road_dir, start_half, _place_road_end_half);
700  } else {
701  Command<CMD_BUILD_LONG_ROAD>::Post(this->rti->strings.err_build_road, CcPlaySound_CONSTRUCTION_OTHER,
702  end_tile, start_tile, _cur_roadtype, _place_road_dir, _one_way_button_clicked ? DRD_NORTHBOUND : DRD_NONE, start_half, _place_road_end_half, false);
703  }
704  break;
705  }
706 
707  case DDSP_BUILD_BUSSTOP:
708  case DDSP_REMOVE_BUSSTOP:
709  if (this->IsWidgetLowered(WID_ROT_BUS_STATION) && GetIfClassHasNewStopsByType(RoadStopClass::Get(_roadstop_gui_settings.roadstop_class), ROADSTOP_BUS, _cur_roadtype)) {
711  TileArea ta(start_tile, end_tile);
712  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);
713  } else {
714  PlaceRoadStop(start_tile, end_tile, ROADSTOP_BUS, _ctrl_pressed, _cur_roadtype, this->rti->strings.err_build_station[ROADSTOP_BUS]);
715  }
716  }
717  break;
718 
721  if (this->IsWidgetLowered(WID_ROT_TRUCK_STATION) && GetIfClassHasNewStopsByType(RoadStopClass::Get(_roadstop_gui_settings.roadstop_class), ROADSTOP_TRUCK, _cur_roadtype)) {
723  TileArea ta(start_tile, end_tile);
724  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);
725  } else {
726  PlaceRoadStop(start_tile, end_tile, ROADSTOP_TRUCK, _ctrl_pressed, _cur_roadtype, this->rti->strings.err_build_station[ROADSTOP_TRUCK]);
727  }
728  }
729  break;
730 
731  case DDSP_CONVERT_ROAD:
732  Command<CMD_CONVERT_ROAD>::Post(rti->strings.err_convert_road, CcPlaySound_CONSTRUCTION_OTHER, end_tile, start_tile, _cur_roadtype);
733  break;
734  }
735  }
736  }
737 
738  void OnPlacePresize([[maybe_unused]] Point pt, TileIndex tile) override
739  {
742  }
743 
745  {
746  if (RoadToolbar_CtrlChanged(this)) return ES_HANDLED;
747  return ES_NOT_HANDLED;
748  }
749 
756  static EventState RoadTramToolbarGlobalHotkeys(int hotkey, RoadType last_build, RoadTramType rtt)
757  {
758  Window *w = nullptr;
759  switch (_game_mode) {
760  case GM_NORMAL:
761  w = ShowBuildRoadToolbar(last_build);
762  break;
763 
764  case GM_EDITOR:
765  if ((GetRoadTypes(true) & ((rtt == RTT_ROAD) ? ~_roadtypes_type : _roadtypes_type)) == ROADTYPES_NONE) return ES_NOT_HANDLED;
766  w = ShowBuildRoadScenToolbar(last_build);
767  break;
768 
769  default:
770  break;
771  }
772 
773  if (w == nullptr) return ES_NOT_HANDLED;
774  return w->OnHotkey(hotkey);
775  }
776 
777  static EventState RoadToolbarGlobalHotkeys(int hotkey)
778  {
779  extern RoadType _last_built_roadtype;
780  return RoadTramToolbarGlobalHotkeys(hotkey, _last_built_roadtype, RTT_ROAD);
781  }
782 
783  static EventState TramToolbarGlobalHotkeys(int hotkey)
784  {
785  extern RoadType _last_built_tramtype;
786  return RoadTramToolbarGlobalHotkeys(hotkey, _last_built_tramtype, RTT_TRAM);
787  }
788 
789  static inline HotkeyList road_hotkeys{"roadtoolbar", {
790  Hotkey('1', "build_x", WID_ROT_ROAD_X),
791  Hotkey('2', "build_y", WID_ROT_ROAD_Y),
792  Hotkey('3', "autoroad", WID_ROT_AUTOROAD),
793  Hotkey('4', "demolish", WID_ROT_DEMOLISH),
794  Hotkey('5', "depot", WID_ROT_DEPOT),
795  Hotkey('6', "bus_station", WID_ROT_BUS_STATION),
796  Hotkey('7', "truck_station", WID_ROT_TRUCK_STATION),
797  Hotkey('8', "oneway", WID_ROT_ONE_WAY),
798  Hotkey('B', "bridge", WID_ROT_BUILD_BRIDGE),
799  Hotkey('T', "tunnel", WID_ROT_BUILD_TUNNEL),
800  Hotkey('R', "remove", WID_ROT_REMOVE),
801  Hotkey('C', "convert", WID_ROT_CONVERT_ROAD),
802  }, RoadToolbarGlobalHotkeys};
803 
804  static inline HotkeyList tram_hotkeys{"tramtoolbar", {
805  Hotkey('1', "build_x", WID_ROT_ROAD_X),
806  Hotkey('2', "build_y", WID_ROT_ROAD_Y),
807  Hotkey('3', "autoroad", WID_ROT_AUTOROAD),
808  Hotkey('4', "demolish", WID_ROT_DEMOLISH),
809  Hotkey('5', "depot", WID_ROT_DEPOT),
810  Hotkey('6', "bus_station", WID_ROT_BUS_STATION),
811  Hotkey('7', "truck_station", WID_ROT_TRUCK_STATION),
812  Hotkey('B', "bridge", WID_ROT_BUILD_BRIDGE),
813  Hotkey('T', "tunnel", WID_ROT_BUILD_TUNNEL),
814  Hotkey('R', "remove", WID_ROT_REMOVE),
815  Hotkey('C', "convert", WID_ROT_CONVERT_ROAD),
816  }, TramToolbarGlobalHotkeys};
817 };
818 
819 static constexpr NWidgetPart _nested_build_road_widgets[] = {
821  NWidget(WWT_CLOSEBOX, COLOUR_DARK_GREEN),
822  NWidget(WWT_CAPTION, COLOUR_DARK_GREEN, WID_ROT_CAPTION), SetDataTip(STR_JUST_STRING2, STR_TOOLTIP_WINDOW_TITLE_DRAG_THIS), SetTextStyle(TC_WHITE),
823  NWidget(WWT_STICKYBOX, COLOUR_DARK_GREEN),
824  EndContainer(),
826  NWidget(WWT_IMGBTN, COLOUR_DARK_GREEN, WID_ROT_ROAD_X),
827  SetFill(0, 1), SetMinimalSize(22, 22), SetDataTip(SPR_IMG_ROAD_X_DIR, STR_ROAD_TOOLBAR_TOOLTIP_BUILD_ROAD_SECTION),
828  NWidget(WWT_IMGBTN, COLOUR_DARK_GREEN, WID_ROT_ROAD_Y),
829  SetFill(0, 1), SetMinimalSize(22, 22), SetDataTip(SPR_IMG_ROAD_Y_DIR, STR_ROAD_TOOLBAR_TOOLTIP_BUILD_ROAD_SECTION),
830  NWidget(WWT_IMGBTN, COLOUR_DARK_GREEN, WID_ROT_AUTOROAD),
831  SetFill(0, 1), SetMinimalSize(22, 22), SetDataTip(SPR_IMG_AUTOROAD, STR_ROAD_TOOLBAR_TOOLTIP_BUILD_AUTOROAD),
832  NWidget(WWT_IMGBTN, COLOUR_DARK_GREEN, WID_ROT_DEMOLISH),
833  SetFill(0, 1), SetMinimalSize(22, 22), SetDataTip(SPR_IMG_DYNAMITE, STR_TOOLTIP_DEMOLISH_BUILDINGS_ETC),
834  NWidget(WWT_IMGBTN, COLOUR_DARK_GREEN, WID_ROT_DEPOT),
835  SetFill(0, 1), SetMinimalSize(22, 22), SetDataTip(SPR_IMG_ROAD_DEPOT, STR_ROAD_TOOLBAR_TOOLTIP_BUILD_ROAD_VEHICLE_DEPOT),
836  NWidget(WWT_IMGBTN, COLOUR_DARK_GREEN, WID_ROT_BUS_STATION),
837  SetFill(0, 1), SetMinimalSize(22, 22), SetDataTip(SPR_IMG_BUS_STATION, STR_ROAD_TOOLBAR_TOOLTIP_BUILD_BUS_STATION),
838  NWidget(WWT_IMGBTN, COLOUR_DARK_GREEN, WID_ROT_TRUCK_STATION),
839  SetFill(0, 1), SetMinimalSize(22, 22), SetDataTip(SPR_IMG_TRUCK_BAY, STR_ROAD_TOOLBAR_TOOLTIP_BUILD_TRUCK_LOADING_BAY),
840  NWidget(WWT_PANEL, COLOUR_DARK_GREEN, -1), SetMinimalSize(0, 22), SetFill(1, 1), EndContainer(),
841  NWidget(WWT_IMGBTN, COLOUR_DARK_GREEN, WID_ROT_ONE_WAY),
842  SetFill(0, 1), SetMinimalSize(22, 22), SetDataTip(SPR_IMG_ROAD_ONE_WAY, STR_ROAD_TOOLBAR_TOOLTIP_TOGGLE_ONE_WAY_ROAD),
843  NWidget(WWT_IMGBTN, COLOUR_DARK_GREEN, WID_ROT_BUILD_BRIDGE),
844  SetFill(0, 1), SetMinimalSize(43, 22), SetDataTip(SPR_IMG_BRIDGE, STR_ROAD_TOOLBAR_TOOLTIP_BUILD_ROAD_BRIDGE),
845  NWidget(WWT_IMGBTN, COLOUR_DARK_GREEN, WID_ROT_BUILD_TUNNEL),
846  SetFill(0, 1), SetMinimalSize(22, 22), SetDataTip(SPR_IMG_ROAD_TUNNEL, STR_ROAD_TOOLBAR_TOOLTIP_BUILD_ROAD_TUNNEL),
847  NWidget(WWT_IMGBTN, COLOUR_DARK_GREEN, WID_ROT_REMOVE),
848  SetFill(0, 1), SetMinimalSize(22, 22), SetDataTip(SPR_IMG_REMOVE, STR_ROAD_TOOLBAR_TOOLTIP_TOGGLE_BUILD_REMOVE_FOR_ROAD),
849  NWidget(WWT_IMGBTN, COLOUR_DARK_GREEN, WID_ROT_CONVERT_ROAD),
850  SetFill(0, 1), SetMinimalSize(22, 22), SetDataTip(SPR_IMG_CONVERT_ROAD, STR_ROAD_TOOLBAR_TOOLTIP_CONVERT_ROAD),
851  EndContainer(),
852 };
853 
854 static WindowDesc _build_road_desc(__FILE__, __LINE__,
855  WDP_ALIGN_TOOLBAR, "toolbar_road", 0, 0,
858  std::begin(_nested_build_road_widgets), std::end(_nested_build_road_widgets),
859  &BuildRoadToolbarWindow::road_hotkeys
860 );
861 
862 static constexpr NWidgetPart _nested_build_tramway_widgets[] = {
864  NWidget(WWT_CLOSEBOX, COLOUR_DARK_GREEN),
865  NWidget(WWT_CAPTION, COLOUR_DARK_GREEN, WID_ROT_CAPTION), SetDataTip(STR_JUST_STRING2, STR_TOOLTIP_WINDOW_TITLE_DRAG_THIS), SetTextStyle(TC_WHITE),
866  NWidget(WWT_STICKYBOX, COLOUR_DARK_GREEN),
867  EndContainer(),
869  NWidget(WWT_IMGBTN, COLOUR_DARK_GREEN, WID_ROT_ROAD_X),
870  SetFill(0, 1), SetMinimalSize(22, 22), SetDataTip(SPR_IMG_TRAMWAY_X_DIR, STR_ROAD_TOOLBAR_TOOLTIP_BUILD_TRAMWAY_SECTION),
871  NWidget(WWT_IMGBTN, COLOUR_DARK_GREEN, WID_ROT_ROAD_Y),
872  SetFill(0, 1), SetMinimalSize(22, 22), SetDataTip(SPR_IMG_TRAMWAY_Y_DIR, STR_ROAD_TOOLBAR_TOOLTIP_BUILD_TRAMWAY_SECTION),
873  NWidget(WWT_IMGBTN, COLOUR_DARK_GREEN, WID_ROT_AUTOROAD),
874  SetFill(0, 1), SetMinimalSize(22, 22), SetDataTip(SPR_IMG_AUTOTRAM, STR_ROAD_TOOLBAR_TOOLTIP_BUILD_AUTOTRAM),
875  NWidget(WWT_IMGBTN, COLOUR_DARK_GREEN, WID_ROT_DEMOLISH),
876  SetFill(0, 1), SetMinimalSize(22, 22), SetDataTip(SPR_IMG_DYNAMITE, STR_TOOLTIP_DEMOLISH_BUILDINGS_ETC),
877  NWidget(WWT_IMGBTN, COLOUR_DARK_GREEN, WID_ROT_DEPOT),
878  SetFill(0, 1), SetMinimalSize(22, 22), SetDataTip(SPR_IMG_ROAD_DEPOT, STR_ROAD_TOOLBAR_TOOLTIP_BUILD_TRAM_VEHICLE_DEPOT),
879  NWidget(WWT_IMGBTN, COLOUR_DARK_GREEN, WID_ROT_BUS_STATION),
880  SetFill(0, 1), SetMinimalSize(22, 22), SetDataTip(SPR_IMG_BUS_STATION, STR_ROAD_TOOLBAR_TOOLTIP_BUILD_PASSENGER_TRAM_STATION),
881  NWidget(WWT_IMGBTN, COLOUR_DARK_GREEN, WID_ROT_TRUCK_STATION),
882  SetFill(0, 1), SetMinimalSize(22, 22), SetDataTip(SPR_IMG_TRUCK_BAY, STR_ROAD_TOOLBAR_TOOLTIP_BUILD_CARGO_TRAM_STATION),
883  NWidget(WWT_PANEL, COLOUR_DARK_GREEN, -1), SetMinimalSize(0, 22), SetFill(1, 1), EndContainer(),
884  NWidget(WWT_IMGBTN, COLOUR_DARK_GREEN, WID_ROT_BUILD_BRIDGE),
885  SetFill(0, 1), SetMinimalSize(43, 22), SetDataTip(SPR_IMG_BRIDGE, STR_ROAD_TOOLBAR_TOOLTIP_BUILD_TRAMWAY_BRIDGE),
886  NWidget(WWT_IMGBTN, COLOUR_DARK_GREEN, WID_ROT_BUILD_TUNNEL),
887  SetFill(0, 1), SetMinimalSize(22, 22), SetDataTip(SPR_IMG_ROAD_TUNNEL, STR_ROAD_TOOLBAR_TOOLTIP_BUILD_TRAMWAY_TUNNEL),
888  NWidget(WWT_IMGBTN, COLOUR_DARK_GREEN, WID_ROT_REMOVE),
889  SetFill(0, 1), SetMinimalSize(22, 22), SetDataTip(SPR_IMG_REMOVE, STR_ROAD_TOOLBAR_TOOLTIP_TOGGLE_BUILD_REMOVE_FOR_TRAMWAYS),
890  NWidget(WWT_IMGBTN, COLOUR_DARK_GREEN, WID_ROT_CONVERT_ROAD),
891  SetFill(0, 1), SetMinimalSize(22, 22), SetDataTip(SPR_IMG_CONVERT_ROAD, STR_ROAD_TOOLBAR_TOOLTIP_CONVERT_TRAM),
892  EndContainer(),
893 };
894 
895 static WindowDesc _build_tramway_desc(__FILE__, __LINE__,
896  WDP_ALIGN_TOOLBAR, "toolbar_tramway", 0, 0,
899  std::begin(_nested_build_tramway_widgets), std::end(_nested_build_tramway_widgets),
900  &BuildRoadToolbarWindow::tram_hotkeys
901 );
902 
911 {
912  if (!Company::IsValidID(_local_company)) return nullptr;
913  if (!ValParamRoadType(roadtype)) return nullptr;
914 
916  _cur_roadtype = roadtype;
917 
918  return AllocateWindowDescFront<BuildRoadToolbarWindow>(RoadTypeIsRoad(_cur_roadtype) ? &_build_road_desc : &_build_tramway_desc, TRANSPORT_ROAD);
919 }
920 
921 static constexpr NWidgetPart _nested_build_road_scen_widgets[] = {
923  NWidget(WWT_CLOSEBOX, COLOUR_DARK_GREEN),
924  NWidget(WWT_CAPTION, COLOUR_DARK_GREEN, WID_ROT_CAPTION), SetDataTip(STR_JUST_STRING2, STR_TOOLTIP_WINDOW_TITLE_DRAG_THIS), SetTextStyle(TC_WHITE),
925  NWidget(WWT_STICKYBOX, COLOUR_DARK_GREEN),
926  EndContainer(),
928  NWidget(WWT_IMGBTN, COLOUR_DARK_GREEN, WID_ROT_ROAD_X),
929  SetFill(0, 1), SetMinimalSize(22, 22), SetDataTip(SPR_IMG_ROAD_X_DIR, STR_ROAD_TOOLBAR_TOOLTIP_BUILD_ROAD_SECTION),
930  NWidget(WWT_IMGBTN, COLOUR_DARK_GREEN, WID_ROT_ROAD_Y),
931  SetFill(0, 1), SetMinimalSize(22, 22), SetDataTip(SPR_IMG_ROAD_Y_DIR, STR_ROAD_TOOLBAR_TOOLTIP_BUILD_ROAD_SECTION),
932  NWidget(WWT_IMGBTN, COLOUR_DARK_GREEN, WID_ROT_AUTOROAD),
933  SetFill(0, 1), SetMinimalSize(22, 22), SetDataTip(SPR_IMG_AUTOROAD, STR_ROAD_TOOLBAR_TOOLTIP_BUILD_AUTOROAD),
934  NWidget(WWT_IMGBTN, COLOUR_DARK_GREEN, WID_ROT_DEMOLISH),
935  SetFill(0, 1), SetMinimalSize(22, 22), SetDataTip(SPR_IMG_DYNAMITE, STR_TOOLTIP_DEMOLISH_BUILDINGS_ETC),
936  NWidget(WWT_PANEL, COLOUR_DARK_GREEN, -1), SetMinimalSize(0, 22), SetFill(1, 1), EndContainer(),
937  NWidget(WWT_IMGBTN, COLOUR_DARK_GREEN, WID_ROT_ONE_WAY),
938  SetFill(0, 1), SetMinimalSize(22, 22), SetDataTip(SPR_IMG_ROAD_ONE_WAY, STR_ROAD_TOOLBAR_TOOLTIP_TOGGLE_ONE_WAY_ROAD),
939  NWidget(WWT_IMGBTN, COLOUR_DARK_GREEN, WID_ROT_BUILD_BRIDGE),
940  SetFill(0, 1), SetMinimalSize(43, 22), SetDataTip(SPR_IMG_BRIDGE, STR_ROAD_TOOLBAR_TOOLTIP_BUILD_ROAD_BRIDGE),
941  NWidget(WWT_IMGBTN, COLOUR_DARK_GREEN, WID_ROT_BUILD_TUNNEL),
942  SetFill(0, 1), SetMinimalSize(22, 22), SetDataTip(SPR_IMG_ROAD_TUNNEL, STR_ROAD_TOOLBAR_TOOLTIP_BUILD_ROAD_TUNNEL),
943  NWidget(WWT_IMGBTN, COLOUR_DARK_GREEN, WID_ROT_REMOVE),
944  SetFill(0, 1), SetMinimalSize(22, 22), SetDataTip(SPR_IMG_REMOVE, STR_ROAD_TOOLBAR_TOOLTIP_TOGGLE_BUILD_REMOVE_FOR_ROAD),
945  NWidget(WWT_IMGBTN, COLOUR_DARK_GREEN, WID_ROT_CONVERT_ROAD),
946  SetFill(0, 1), SetMinimalSize(22, 22), SetDataTip(SPR_IMG_CONVERT_ROAD, STR_ROAD_TOOLBAR_TOOLTIP_CONVERT_ROAD),
947  EndContainer(),
948 };
949 
950 static WindowDesc _build_road_scen_desc(__FILE__, __LINE__,
951  WDP_AUTO, "toolbar_road_scen", 0, 0,
954  std::begin(_nested_build_road_scen_widgets), std::end(_nested_build_road_scen_widgets),
955  &BuildRoadToolbarWindow::road_hotkeys
956 );
957 
958 static constexpr NWidgetPart _nested_build_tramway_scen_widgets[] = {
960  NWidget(WWT_CLOSEBOX, COLOUR_DARK_GREEN),
961  NWidget(WWT_CAPTION, COLOUR_DARK_GREEN, WID_ROT_CAPTION), SetDataTip(STR_JUST_STRING2, STR_TOOLTIP_WINDOW_TITLE_DRAG_THIS), SetTextStyle(TC_WHITE),
962  NWidget(WWT_STICKYBOX, COLOUR_DARK_GREEN),
963  EndContainer(),
965  NWidget(WWT_IMGBTN, COLOUR_DARK_GREEN, WID_ROT_ROAD_X),
966  SetFill(0, 1), SetMinimalSize(22, 22), SetDataTip(SPR_IMG_TRAMWAY_X_DIR, STR_ROAD_TOOLBAR_TOOLTIP_BUILD_TRAMWAY_SECTION),
967  NWidget(WWT_IMGBTN, COLOUR_DARK_GREEN, WID_ROT_ROAD_Y),
968  SetFill(0, 1), SetMinimalSize(22, 22), SetDataTip(SPR_IMG_TRAMWAY_Y_DIR, STR_ROAD_TOOLBAR_TOOLTIP_BUILD_TRAMWAY_SECTION),
969  NWidget(WWT_IMGBTN, COLOUR_DARK_GREEN, WID_ROT_AUTOROAD),
970  SetFill(0, 1), SetMinimalSize(22, 22), SetDataTip(SPR_IMG_AUTOTRAM, STR_ROAD_TOOLBAR_TOOLTIP_BUILD_AUTOTRAM),
971  NWidget(WWT_IMGBTN, COLOUR_DARK_GREEN, WID_ROT_DEMOLISH),
972  SetFill(0, 1), SetMinimalSize(22, 22), SetDataTip(SPR_IMG_DYNAMITE, STR_TOOLTIP_DEMOLISH_BUILDINGS_ETC),
973  NWidget(WWT_PANEL, COLOUR_DARK_GREEN, -1), SetMinimalSize(0, 22), SetFill(1, 1), EndContainer(),
974  NWidget(WWT_IMGBTN, COLOUR_DARK_GREEN, WID_ROT_BUILD_BRIDGE),
975  SetFill(0, 1), SetMinimalSize(43, 22), SetDataTip(SPR_IMG_BRIDGE, STR_ROAD_TOOLBAR_TOOLTIP_BUILD_TRAMWAY_BRIDGE),
976  NWidget(WWT_IMGBTN, COLOUR_DARK_GREEN, WID_ROT_BUILD_TUNNEL),
977  SetFill(0, 1), SetMinimalSize(22, 22), SetDataTip(SPR_IMG_ROAD_TUNNEL, STR_ROAD_TOOLBAR_TOOLTIP_BUILD_TRAMWAY_TUNNEL),
978  NWidget(WWT_IMGBTN, COLOUR_DARK_GREEN, WID_ROT_REMOVE),
979  SetFill(0, 1), SetMinimalSize(22, 22), SetDataTip(SPR_IMG_REMOVE, STR_ROAD_TOOLBAR_TOOLTIP_TOGGLE_BUILD_REMOVE_FOR_TRAMWAYS),
980  NWidget(WWT_IMGBTN, COLOUR_DARK_GREEN, WID_ROT_CONVERT_ROAD),
981  SetFill(0, 1), SetMinimalSize(22, 22), SetDataTip(SPR_IMG_CONVERT_ROAD, STR_ROAD_TOOLBAR_TOOLTIP_CONVERT_TRAM),
982  EndContainer(),
983 };
984 
985 static WindowDesc _build_tramway_scen_desc(__FILE__, __LINE__,
986  WDP_AUTO, "toolbar_tram_scen", 0, 0,
989  std::begin(_nested_build_tramway_scen_widgets), std::end(_nested_build_tramway_scen_widgets),
990  &BuildRoadToolbarWindow::tram_hotkeys
991 );
992 
998 {
1000  _cur_roadtype = roadtype;
1001 
1002  return AllocateWindowDescFront<BuildRoadToolbarWindow>(RoadTypeIsRoad(_cur_roadtype) ? &_build_road_scen_desc : &_build_tramway_scen_desc, TRANSPORT_ROAD);
1003 }
1004 
1007  {
1008  this->CreateNestedTree();
1009 
1010  this->LowerWidget(WID_BROD_DEPOT_NE + _road_depot_orientation);
1011  if (RoadTypeIsTram(_cur_roadtype)) {
1012  this->GetWidget<NWidgetCore>(WID_BROD_CAPTION)->widget_data = STR_BUILD_DEPOT_TRAM_ORIENTATION_CAPTION;
1013  for (WidgetID i = WID_BROD_DEPOT_NE; i <= WID_BROD_DEPOT_NW; i++) {
1014  this->GetWidget<NWidgetCore>(i)->tool_tip = STR_BUILD_DEPOT_TRAM_ORIENTATION_SELECT_TOOLTIP;
1015  }
1016  }
1017 
1019  }
1020 
1021  void UpdateWidgetSize(WidgetID widget, Dimension *size, [[maybe_unused]] const Dimension &padding, [[maybe_unused]] Dimension *fill, [[maybe_unused]] Dimension *resize) override
1022  {
1023  if (!IsInsideMM(widget, WID_BROD_DEPOT_NE, WID_BROD_DEPOT_NW + 1)) return;
1024 
1027  }
1028 
1029  void DrawWidget(const Rect &r, WidgetID widget) const override
1030  {
1031  if (!IsInsideMM(widget, WID_BROD_DEPOT_NE, WID_BROD_DEPOT_NW + 1)) return;
1032 
1033  DrawPixelInfo tmp_dpi;
1034  Rect ir = r.Shrink(WidgetDimensions::scaled.bevel);
1035  if (FillDrawPixelInfo(&tmp_dpi, ir)) {
1036  AutoRestoreBackup dpi_backup(_cur_dpi, &tmp_dpi);
1037  int x = (ir.Width() - ScaleSpriteTrad(64)) / 2 + ScaleSpriteTrad(31);
1038  int y = (ir.Height() + ScaleSpriteTrad(48)) / 2 - ScaleSpriteTrad(31);
1039  DrawRoadDepotSprite(x, y, (DiagDirection)(widget - WID_BROD_DEPOT_NE + DIAGDIR_NE), _cur_roadtype);
1040  }
1041  }
1042 
1043  void OnClick([[maybe_unused]] Point pt, WidgetID widget, [[maybe_unused]] int click_count) override
1044  {
1045  switch (widget) {
1046  case WID_BROD_DEPOT_NW:
1047  case WID_BROD_DEPOT_NE:
1048  case WID_BROD_DEPOT_SW:
1049  case WID_BROD_DEPOT_SE:
1050  this->RaiseWidget(WID_BROD_DEPOT_NE + _road_depot_orientation);
1051  _road_depot_orientation = (DiagDirection)(widget - WID_BROD_DEPOT_NE);
1052  this->LowerWidget(WID_BROD_DEPOT_NE + _road_depot_orientation);
1053  if (_settings_client.sound.click_beep) SndPlayFx(SND_15_BEEP);
1054  this->SetDirty();
1055  break;
1056 
1057  default:
1058  break;
1059  }
1060  }
1061 };
1062 
1063 static constexpr NWidgetPart _nested_build_road_depot_widgets[] = {
1065  NWidget(WWT_CLOSEBOX, COLOUR_DARK_GREEN),
1066  NWidget(WWT_CAPTION, COLOUR_DARK_GREEN, WID_BROD_CAPTION), SetDataTip(STR_BUILD_DEPOT_ROAD_ORIENTATION_CAPTION, STR_TOOLTIP_WINDOW_TITLE_DRAG_THIS),
1067  EndContainer(),
1068  NWidget(WWT_PANEL, COLOUR_DARK_GREEN),
1071  NWidget(WWT_TEXTBTN, COLOUR_GREY, WID_BROD_DEPOT_NW), SetMinimalSize(66, 50), SetFill(0, 0), SetDataTip(0x0, STR_BUILD_DEPOT_ROAD_ORIENTATION_SELECT_TOOLTIP),
1072  NWidget(WWT_TEXTBTN, COLOUR_GREY, WID_BROD_DEPOT_SW), SetMinimalSize(66, 50), SetFill(0, 0), SetDataTip(0x0, STR_BUILD_DEPOT_ROAD_ORIENTATION_SELECT_TOOLTIP),
1073  EndContainer(),
1075  NWidget(WWT_TEXTBTN, COLOUR_GREY, WID_BROD_DEPOT_NE), SetMinimalSize(66, 50), SetFill(0, 0), SetDataTip(0x0, STR_BUILD_DEPOT_ROAD_ORIENTATION_SELECT_TOOLTIP),
1076  NWidget(WWT_TEXTBTN, COLOUR_GREY, WID_BROD_DEPOT_SE), SetMinimalSize(66, 50), SetFill(0, 0), SetDataTip(0x0, STR_BUILD_DEPOT_ROAD_ORIENTATION_SELECT_TOOLTIP),
1077  EndContainer(),
1078  EndContainer(),
1079  EndContainer(),
1080 };
1081 
1082 static WindowDesc _build_road_depot_desc(__FILE__, __LINE__,
1083  WDP_AUTO, nullptr, 0, 0,
1086  std::begin(_nested_build_road_depot_widgets), std::end(_nested_build_road_depot_widgets)
1087 );
1088 
1089 static void ShowRoadDepotPicker(Window *parent)
1090 {
1091  new BuildRoadDepotWindow(&_build_road_depot_desc, parent);
1092 }
1093 
1097 };
1098 
1100 private:
1106 
1108 
1109  static const uint EDITBOX_MAX_SIZE = 16;
1110 
1118 
1119  void EnsureSelectedClassIsVisible()
1120  {
1121  uint pos = 0;
1122  for (auto rs_class : this->roadstop_classes) {
1123  if (rs_class == _roadstop_gui_settings.roadstop_class) break;
1124  pos++;
1125  }
1126  this->vscrollList->SetCount(this->roadstop_classes.size());
1127  this->vscrollList->ScrollTowards(pos);
1128  }
1129 
1130  void CheckOrientationValid()
1131  {
1132  if (_roadstop_gui_settings.orientation >= DIAGDIR_END) return;
1133  const RoadStopSpec *spec = RoadStopClass::Get(_roadstop_gui_settings.roadstop_class)->GetSpec(_roadstop_gui_settings.roadstop_type);
1134  if (spec != nullptr && HasBit(spec->flags, RSF_DRIVE_THROUGH_ONLY)) {
1135  this->RaiseWidget(WID_BROS_STATION_NE + _roadstop_gui_settings.orientation);
1136  _roadstop_gui_settings.orientation = DIAGDIR_END;
1137  this->LowerWidget(WID_BROS_STATION_NE + _roadstop_gui_settings.orientation);
1138  this->SetDirty();
1140  }
1141  }
1142 
1143 public:
1145  {
1146  this->coverage_height = 2 * GetCharacterHeight(FS_NORMAL) + WidgetDimensions::scaled.vsep_normal;
1147  this->vscrollList = nullptr;
1148  this->vscrollMatrix = nullptr;
1149  this->roadStopType = rs;
1150  bool newstops = GetIfNewStopsByType(rs, _cur_roadtype);
1151 
1152  this->CreateNestedTree();
1153 
1154  /* Hide the station class filter if no stations other than the default one are available. */
1155  this->GetWidget<NWidgetStacked>(WID_BROS_SHOW_NEWST_DEFSIZE)->SetDisplayedPlane(newstops ? 0 : SZSP_NONE);
1156  this->GetWidget<NWidgetStacked>(WID_BROS_FILTER_CONTAINER)->SetDisplayedPlane(newstops ? 0 : SZSP_HORIZONTAL);
1157  this->GetWidget<NWidgetStacked>(WID_BROS_SHOW_NEWST_ADDITIONS)->SetDisplayedPlane(newstops ? 0 : SZSP_HORIZONTAL);
1158  this->GetWidget<NWidgetStacked>(WID_BROS_SHOW_NEWST_ORIENTATION)->SetDisplayedPlane(newstops ? 0 : SZSP_HORIZONTAL);
1159  this->GetWidget<NWidgetStacked>(WID_BROS_SHOW_NEWST_TYPE_SEL)->SetDisplayedPlane(newstops ? 0 : SZSP_HORIZONTAL);
1160  this->GetWidget<NWidgetStacked>(WID_BROS_SHOW_NEWST_MATRIX)->SetDisplayedPlane(newstops ? 0 : SZSP_NONE);
1161  this->GetWidget<NWidgetStacked>(WID_BROS_SHOW_NEWST_RESIZE)->SetDisplayedPlane(newstops ? 0 : SZSP_NONE);
1162  if (newstops) {
1163  this->vscrollList = this->GetScrollbar(WID_BROS_NEWST_SCROLL);
1164  this->vscrollMatrix = this->GetScrollbar(WID_BROS_MATRIX_SCROLL);
1165 
1167  this->roadstop_classes.SetListing(this->last_sorting);
1168  this->roadstop_classes.SetFiltering(this->last_filtering);
1169  this->roadstop_classes.SetSortFuncs(this->sorter_funcs);
1170  this->roadstop_classes.SetFilterFuncs(this->filter_funcs);
1171  }
1172 
1173  this->roadstop_classes.ForceRebuild();
1174  BuildRoadStopClassesAvailable();
1175 
1176  /* Trams don't have non-drivethrough stations */
1177  if (RoadTypeIsTram(_cur_roadtype) && _roadstop_gui_settings.orientation < DIAGDIR_END) {
1178  _roadstop_gui_settings.orientation = DIAGDIR_END;
1179  }
1180  const RoadTypeInfo *rti = GetRoadTypeInfo(_cur_roadtype);
1181  this->GetWidget<NWidgetCore>(WID_BROS_CAPTION)->widget_data = rti->strings.picker_title[rs];
1182 
1183  for (WidgetID i = RoadTypeIsTram(_cur_roadtype) ? WID_BROS_STATION_X : WID_BROS_STATION_NE; i < WID_BROS_LT_OFF; i++) {
1184  this->GetWidget<NWidgetCore>(i)->tool_tip = rti->strings.picker_tooltip[rs];
1185  }
1186 
1187  this->LowerWidget(WID_BROS_STATION_NE + _roadstop_gui_settings.orientation);
1188  this->LowerWidget(WID_BROS_LT_OFF + _settings_client.gui.station_show_coverage);
1189 
1191 
1193  if (!newstops || _roadstop_gui_settings.roadstop_class >= (int)RoadStopClass::GetClassCount()) {
1194  /* There's no new stops available or the list has reduced in size.
1195  * Now, set the default road stops as selected. */
1196  _roadstop_gui_settings.roadstop_class = ROADSTOP_CLASS_DFLT;
1197  _roadstop_gui_settings.roadstop_type = 0;
1198  }
1199  if (newstops) {
1200  /* The currently selected class doesn't have any stops for this RoadStopType, reset the selection. */
1201  if (!GetIfClassHasNewStopsByType(RoadStopClass::Get(_roadstop_gui_settings.roadstop_class), rs, _cur_roadtype)) {
1202  _roadstop_gui_settings.roadstop_class = ROADSTOP_CLASS_DFLT;
1203  _roadstop_gui_settings.roadstop_type = 0;
1204  }
1205  _roadstop_gui_settings.roadstop_count = RoadStopClass::Get(_roadstop_gui_settings.roadstop_class)->GetSpecCount();
1206  _roadstop_gui_settings.roadstop_type = std::min((int)_roadstop_gui_settings.roadstop_type, _roadstop_gui_settings.roadstop_count - 1);
1207 
1208  /* Reset back to default class if the previously selected class is not available for this road stop type. */
1209  if (!GetIfClassHasNewStopsByType(RoadStopClass::Get(_roadstop_gui_settings.roadstop_class), roadStopType, _cur_roadtype)) {
1210  _roadstop_gui_settings.roadstop_class = ROADSTOP_CLASS_DFLT;
1211  }
1212 
1213  this->SelectFirstAvailableTypeIfUnavailable();
1214 
1215  NWidgetMatrix *matrix = this->GetWidget<NWidgetMatrix>(WID_BROS_MATRIX);
1216  matrix->SetScrollbar(this->vscrollMatrix);
1217  matrix->SetCount(_roadstop_gui_settings.roadstop_count);
1218  matrix->SetClicked(_roadstop_gui_settings.roadstop_type);
1219 
1220  this->EnsureSelectedClassIsVisible();
1221  this->CheckOrientationValid();
1222  }
1223  }
1224 
1225  void Close([[maybe_unused]] int data = 0) override
1226  {
1228  this->PickerWindowBase::Close();
1229  }
1230 
1233  {
1234  return a < b;
1235  }
1236 
1238  static bool CDECL TagNameFilter(RoadStopClassID const *sc, StringFilter &filter)
1239  {
1240  filter.ResetState();
1241  filter.AddLine(GetString(RoadStopClass::Get(*sc)->name));
1242  return filter.GetState();
1243  }
1244 
1245  inline bool ShowNewStops() const
1246  {
1247  return this->vscrollList != nullptr;
1248  }
1249 
1250  void BuildRoadStopClassesAvailable()
1251  {
1252  if (!this->roadstop_classes.NeedRebuild()) return;
1253 
1254  this->roadstop_classes.clear();
1255 
1256  for (uint i = 0; i < RoadStopClass::GetClassCount(); i++) {
1257  RoadStopClassID rs_id = (RoadStopClassID)i;
1258  if (rs_id == ROADSTOP_CLASS_WAYP) {
1259  // Skip waypoints.
1260  continue;
1261  }
1262  RoadStopClass *rs_class = RoadStopClass::Get(rs_id);
1263  if (GetIfClassHasNewStopsByType(rs_class, this->roadStopType, _cur_roadtype)) this->roadstop_classes.push_back(rs_id);
1264  }
1265 
1266  if (this->ShowNewStops()) {
1267  this->roadstop_classes.Filter(this->string_filter);
1268  this->roadstop_classes.shrink_to_fit();
1269  this->roadstop_classes.RebuildDone();
1270  this->roadstop_classes.Sort();
1271 
1272  this->vscrollList->SetCount(this->roadstop_classes.size());
1273  }
1274  }
1275 
1276  void SelectFirstAvailableTypeIfUnavailable()
1277  {
1278  const RoadStopClass *rs_class = RoadStopClass::Get(_roadstop_gui_settings.roadstop_class);
1280 
1281  if (IsRoadStopAvailable(rs_class->GetSpec(_roadstop_gui_settings.roadstop_type), st)) return;
1282  for (uint i = 0; i < _roadstop_gui_settings.roadstop_count; i++) {
1283  if (IsRoadStopAvailable(rs_class->GetSpec(i), st)) {
1284  _roadstop_gui_settings.roadstop_type = i;
1285  break;
1286  }
1287  }
1288  }
1289 
1290  void OnInvalidateData([[maybe_unused]] int data = 0, [[maybe_unused]] bool gui_scope = true) override
1291  {
1292  if (!gui_scope) return;
1293 
1294  this->BuildRoadStopClassesAvailable();
1295  }
1296 
1297  EventState OnHotkey(int hotkey) override
1298  {
1299  if (hotkey == BROSHK_FOCUS_FILTER_BOX) {
1301  SetFocusedWindow(this); // The user has asked to give focus to the text box, so make sure this window is focused.
1302  return ES_HANDLED;
1303  }
1304 
1305  return ES_NOT_HANDLED;
1306  }
1307 
1308  void OnEditboxChanged(WidgetID widget) override
1309  {
1310  if (widget == WID_BROS_FILTER_EDITBOX) {
1311  string_filter.SetFilterTerm(this->filter_editbox.text.buf);
1312  this->roadstop_classes.SetFilterState(!string_filter.IsEmpty());
1313  this->roadstop_classes.ForceRebuild();
1314  this->InvalidateData();
1315  }
1316  }
1317 
1318  void OnPaint() override
1319  {
1320  this->DrawWidgets();
1321 
1324  SetTileSelectBigSize(-rad, -rad, 2 * rad, 2 * rad);
1325  } else {
1326  SetTileSelectSize(1, 1);
1327  }
1328 
1329  if (this->IsShaded()) return;
1330 
1331  /* 'Accepts' and 'Supplies' texts. */
1333  Rect r = this->GetWidget<NWidgetBase>(WID_BROS_ACCEPTANCE)->GetCurrentRect();
1334  int top = r.top;
1335  top = DrawStationCoverageAreaText(r.left, r.right, top, sct, rad, false) + WidgetDimensions::scaled.vsep_normal;
1336  top = DrawStationCoverageAreaText(r.left, r.right, top, sct, rad, true);
1337  /* Resize background if the window is too small.
1338  * Never make the window smaller to avoid oscillating if the size change affects the acceptance.
1339  * (This is the case, if making the window bigger moves the mouse into the window.) */
1340  if (top > r.bottom) {
1341  this->coverage_height += top - r.bottom;
1342  this->ReInit();
1343  }
1344  }
1345 
1346  void UpdateWidgetSize(WidgetID widget, Dimension *size, [[maybe_unused]] const Dimension &padding, [[maybe_unused]] Dimension *fill, [[maybe_unused]] Dimension *resize) override
1347  {
1348  switch (widget) {
1349  case WID_BROS_NEWST_LIST: {
1350  Dimension d = { 0, 0 };
1351  for (auto rs_class : this->roadstop_classes) {
1352  d = maxdim(d, GetStringBoundingBox(RoadStopClass::Get(rs_class)->name));
1353  }
1354  size->width = std::max(size->width, d.width + padding.width);
1356  size->height = 5 * this->line_height;
1357  resize->height = this->line_height;
1358  break;
1359  }
1360 
1361  case WID_BROS_SHOW_NEWST_TYPE: {
1362  Dimension d = {0, 0};
1363  StringID str = this->GetWidget<NWidgetCore>(widget)->widget_data;
1364  for (auto roadstop_class : this->roadstop_classes) {
1365  RoadStopClass *rs_class = RoadStopClass::Get(roadstop_class);
1366  for (uint j = 0; j < rs_class->GetSpecCount(); j++) {
1367  const RoadStopSpec *roadstopspec = rs_class->GetSpec(j);
1368  SetDParam(0, (roadstopspec != nullptr && roadstopspec->name != 0) ? roadstopspec->name : STR_STATION_CLASS_DFLT_ROADSTOP);
1369  d = maxdim(d, GetStringBoundingBox(str));
1370  }
1371  }
1372  size->width = std::max(size->width, d.width + padding.width);
1373  break;
1374  }
1375 
1376  case WID_BROS_STATION_NE:
1377  case WID_BROS_STATION_SE:
1378  case WID_BROS_STATION_SW:
1379  case WID_BROS_STATION_NW:
1380  case WID_BROS_STATION_X:
1381  case WID_BROS_STATION_Y:
1382  case WID_BROS_IMAGE:
1385  break;
1386 
1387  case WID_BROS_MATRIX:
1388  fill->height = 1;
1389  resize->height = 1;
1390  break;
1391 
1392  case WID_BROS_ACCEPTANCE:
1393  size->height = this->coverage_height;
1394  break;
1395  }
1396  }
1397 
1402  {
1403  switch (window_class) {
1404  case WC_BUS_STATION: return STATION_BUS;
1405  case WC_TRUCK_STATION: return STATION_TRUCK;
1406  default: NOT_REACHED();
1407  }
1408  }
1409 
1410  void DrawWidget(const Rect &r, WidgetID widget) const override
1411  {
1412  switch (widget) {
1413  case WID_BROS_STATION_NE:
1414  case WID_BROS_STATION_SE:
1415  case WID_BROS_STATION_SW:
1416  case WID_BROS_STATION_NW:
1417  case WID_BROS_STATION_X:
1418  case WID_BROS_STATION_Y: {
1420  const RoadStopSpec *spec = RoadStopClass::Get(_roadstop_gui_settings.roadstop_class)->GetSpec(_roadstop_gui_settings.roadstop_type);
1421  bool disabled = (spec != nullptr && widget < WID_BROS_STATION_X && HasBit(spec->flags, RSF_DRIVE_THROUGH_ONLY));
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);
1426  int x = (ir.Width() - ScaleSpriteTrad(64)) / 2 + ScaleSpriteTrad(31);
1427  int y = (ir.Height() + ScaleSpriteTrad(48)) / 2 - ScaleSpriteTrad(31);
1428  if (spec == nullptr || disabled) {
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  if (disabled) GfxFillRect(ir, PC_BLACK, FILLRECT_CHECKER);
1435  break;
1436  }
1437 
1438  case WID_BROS_NEWST_LIST: {
1439  uint statclass = 0;
1440  uint row = 0;
1441  for (auto rs_class : this->roadstop_classes) {
1442  if (this->vscrollList->IsVisible(statclass)) {
1443  DrawString(r.left + WidgetDimensions::scaled.matrix.left, r.right, row * this->line_height + r.top + WidgetDimensions::scaled.matrix.top,
1444  RoadStopClass::Get(rs_class)->name,
1445  rs_class == _roadstop_gui_settings.roadstop_class ? TC_WHITE : TC_BLACK);
1446  row++;
1447  }
1448  statclass++;
1449  }
1450  break;
1451  }
1452 
1453  case WID_BROS_IMAGE: {
1454  uint16_t type = this->GetWidget<NWidgetBase>(widget)->GetParentWidget<NWidgetMatrix>()->GetCurrentElement();
1455  assert(type < _roadstop_gui_settings.roadstop_count);
1456 
1457  const RoadStopSpec *spec = RoadStopClass::Get(_roadstop_gui_settings.roadstop_class)->GetSpec(type);
1459 
1460  /* Set up a clipping area for the sprite preview. */
1461  DrawPixelInfo tmp_dpi;
1462  Rect ir = r.Shrink(WidgetDimensions::scaled.bevel);
1463  if (FillDrawPixelInfo(&tmp_dpi, ir)) {
1464  AutoRestoreBackup dpi_backup(_cur_dpi, &tmp_dpi);
1465  int x = (ir.Width() - ScaleSpriteTrad(64)) / 2 + ScaleSpriteTrad(31);
1466  int y = (ir.Height() + ScaleSpriteTrad(48)) / 2 - ScaleSpriteTrad(31);
1467  if (spec == nullptr) {
1468  StationPickerDrawSprite(x, y, st, INVALID_RAILTYPE, _cur_roadtype, _roadstop_gui_settings.orientation);
1469  } else {
1470  DiagDirection orientation = _roadstop_gui_settings.orientation;
1471  if (orientation < DIAGDIR_END && HasBit(spec->flags, RSF_DRIVE_THROUGH_ONLY)) orientation = DIAGDIR_END;
1472  DrawRoadStopTile(x, y, _cur_roadtype, spec, st, (uint8_t)orientation);
1473  }
1474  }
1475  if (!IsRoadStopAvailable(spec, st)) {
1477  }
1478  break;
1479  }
1480  }
1481  }
1482 
1483  void OnResize() override
1484  {
1485  if (this->vscrollList != nullptr) {
1486  this->vscrollList->SetCapacityFromWidget(this, WID_BROS_NEWST_LIST);
1487  }
1488  }
1489 
1490  void SetStringParameters(WidgetID widget) const override
1491  {
1492  if (widget == WID_BROS_SHOW_NEWST_TYPE) {
1493  const RoadStopSpec *roadstopspec = RoadStopClass::Get(_roadstop_gui_settings.roadstop_class)->GetSpec(_roadstop_gui_settings.roadstop_type);
1494  SetDParam(0, (roadstopspec != nullptr && roadstopspec->name != 0) ? roadstopspec->name : STR_STATION_CLASS_DFLT_ROADSTOP);
1495  }
1496  }
1497 
1498  void OnClick([[maybe_unused]] Point pt, WidgetID widget, [[maybe_unused]] int click_count) override
1499  {
1500  switch (widget) {
1501  case WID_BROS_STATION_NE:
1502  case WID_BROS_STATION_SE:
1503  case WID_BROS_STATION_SW:
1504  case WID_BROS_STATION_NW:
1505  case WID_BROS_STATION_X:
1506  case WID_BROS_STATION_Y:
1507  if (widget < WID_BROS_STATION_X) {
1508  const RoadStopSpec *spec = RoadStopClass::Get(_roadstop_gui_settings.roadstop_class)->GetSpec(_roadstop_gui_settings.roadstop_type);
1509  if (spec != nullptr && HasBit(spec->flags, RSF_DRIVE_THROUGH_ONLY)) return;
1510  }
1511  this->RaiseWidget(WID_BROS_STATION_NE + _roadstop_gui_settings.orientation);
1512  _roadstop_gui_settings.orientation = (DiagDirection)(widget - WID_BROS_STATION_NE);
1513  this->LowerWidget(WID_BROS_STATION_NE + _roadstop_gui_settings.orientation);
1514  if (_settings_client.sound.click_beep) SndPlayFx(SND_15_BEEP);
1515  this->SetDirty();
1517  break;
1518 
1519  case WID_BROS_LT_OFF:
1520  case WID_BROS_LT_ON:
1521  this->RaiseWidget(_settings_client.gui.station_show_coverage + WID_BROS_LT_OFF);
1523  this->LowerWidget(_settings_client.gui.station_show_coverage + WID_BROS_LT_OFF);
1524  if (_settings_client.sound.click_beep) SndPlayFx(SND_15_BEEP);
1525  this->SetDirty();
1526  SetViewportCatchmentStation(nullptr, true);
1527  break;
1528 
1529  case WID_BROS_NEWST_LIST: {
1530  auto it = this->vscrollList->GetScrolledItemFromWidget(this->roadstop_classes, pt.y, this, WID_BROS_NEWST_LIST);
1531  if (it == this->roadstop_classes.end()) return;
1532  RoadStopClassID class_id = *it;
1533  if (_roadstop_gui_settings.roadstop_class != class_id && GetIfClassHasNewStopsByType(RoadStopClass::Get(class_id), roadStopType, _cur_roadtype)) {
1534  _roadstop_gui_settings.roadstop_class = class_id;
1535  RoadStopClass *rsclass = RoadStopClass::Get(_roadstop_gui_settings.roadstop_class);
1536  _roadstop_gui_settings.roadstop_count = rsclass->GetSpecCount();
1537  _roadstop_gui_settings.roadstop_type = std::min((int)_roadstop_gui_settings.roadstop_type, std::max(0, (int)_roadstop_gui_settings.roadstop_count - 1));
1538  this->SelectFirstAvailableTypeIfUnavailable();
1539 
1540  NWidgetMatrix *matrix = this->GetWidget<NWidgetMatrix>(WID_BROS_MATRIX);
1541  matrix->SetCount(_roadstop_gui_settings.roadstop_count);
1542  matrix->SetClicked(_roadstop_gui_settings.roadstop_type);
1543  this->CheckOrientationValid();
1544  }
1545  if (_settings_client.sound.click_beep) SndPlayFx(SND_15_BEEP);
1546  this->SetDirty();
1548  break;
1549  }
1550 
1551  case WID_BROS_IMAGE: {
1552  uint16_t y = this->GetWidget<NWidgetBase>(widget)->GetParentWidget<NWidgetMatrix>()->GetCurrentElement();
1553  if (y >= _roadstop_gui_settings.roadstop_count) return;
1554 
1555  const RoadStopSpec *spec = RoadStopClass::Get(_roadstop_gui_settings.roadstop_class)->GetSpec(y);
1557 
1558  if (!IsRoadStopAvailable(spec, st)) return;
1559 
1560  _roadstop_gui_settings.roadstop_type = y;
1561 
1562  this->GetWidget<NWidgetBase>(widget)->GetParentWidget<NWidgetMatrix>()->SetClicked(_roadstop_gui_settings.roadstop_type);
1563 
1564  if (_settings_client.sound.click_beep) SndPlayFx(SND_15_BEEP);
1565  this->SetDirty();
1567  this->CheckOrientationValid();
1568  break;
1569  }
1570 
1571  default:
1572  break;
1573  }
1574  }
1575 
1576  void OnRealtimeTick([[maybe_unused]] uint delta_ms) override
1577  {
1579  }
1580 
1581  IntervalTimer<TimerGameCalendar> yearly_interval = {{TimerGameCalendar::YEAR, TimerGameCalendar::Priority::NONE}, [this](auto) {
1582  this->InvalidateData();
1583  }};
1584 
1585  static inline HotkeyList hotkeys{"buildroadstop", {
1586  Hotkey('F', "focus_filter_box", BROSHK_FOCUS_FILTER_BOX),
1587  }};
1588 };
1589 
1592 
1594  &RoadStopClassIDSorter,
1595 };
1596 
1598  &TagNameFilter,
1599 };
1600 
1604  NWidget(WWT_CLOSEBOX, COLOUR_DARK_GREEN),
1605  NWidget(WWT_CAPTION, COLOUR_DARK_GREEN, WID_BROS_CAPTION),
1606  NWidget(WWT_SHADEBOX, COLOUR_DARK_GREEN),
1608  NWidget(WWT_DEFSIZEBOX, COLOUR_DARK_GREEN),
1609  EndContainer(),
1610  EndContainer(),
1612  NWidget(WWT_PANEL, COLOUR_DARK_GREEN),
1614  NWidget(NWID_HORIZONTAL), SetPIP(0, WidgetDimensions::unscaled.hsep_normal, 0), SetPIPRatio(1, 0, 1),
1618  NWidget(WWT_TEXT, COLOUR_DARK_GREEN), SetFill(0, 1), SetDataTip(STR_LIST_FILTER_TITLE, STR_NULL),
1619  NWidget(WWT_EDITBOX, COLOUR_GREY, WID_BROS_FILTER_EDITBOX), SetFill(1, 0), SetResize(1, 0),
1620  SetDataTip(STR_LIST_FILTER_OSKTITLE, STR_LIST_FILTER_TOOLTIP),
1621  EndContainer(),
1622  EndContainer(),
1625  NWidget(WWT_MATRIX, COLOUR_GREY, WID_BROS_NEWST_LIST), SetMinimalSize(122, 71), SetFill(1, 0),
1626  SetMatrixDataTip(1, 0, STR_STATION_BUILD_STATION_CLASS_TOOLTIP), SetScrollbar(WID_BROS_NEWST_SCROLL),
1628  EndContainer(),
1629  EndContainer(),
1631  NWidget(WWT_LABEL, COLOUR_DARK_GREEN), SetMinimalSize(144, 11), SetDataTip(STR_STATION_BUILD_ORIENTATION, STR_NULL), SetFill(1, 0),
1632  EndContainer(),
1634  NWidget(NWID_HORIZONTAL), SetPIP(0, WidgetDimensions::unscaled.hsep_normal, 0), SetPIPRatio(1, 0, 1),
1636  NWidget(WWT_PANEL, COLOUR_GREY, WID_BROS_STATION_NW), SetMinimalSize(66, 50), SetFill(0, 0), EndContainer(),
1637  NWidget(WWT_PANEL, COLOUR_GREY, WID_BROS_STATION_NE), SetMinimalSize(66, 50), SetFill(0, 0), EndContainer(),
1638  EndContainer(),
1639  NWidget(WWT_PANEL, COLOUR_GREY, WID_BROS_STATION_X), SetMinimalSize(66, 50), SetFill(0, 0), EndContainer(),
1640  EndContainer(),
1641  NWidget(NWID_HORIZONTAL), SetPIP(0, WidgetDimensions::unscaled.hsep_normal, 0), SetPIPRatio(1, 0, 1),
1643  NWidget(WWT_PANEL, COLOUR_GREY, WID_BROS_STATION_SW), SetMinimalSize(66, 50), SetFill(0, 0), EndContainer(),
1644  NWidget(WWT_PANEL, COLOUR_GREY, WID_BROS_STATION_SE), SetMinimalSize(66, 50), SetFill(0, 0), EndContainer(),
1645  EndContainer(),
1646  NWidget(WWT_PANEL, COLOUR_GREY, WID_BROS_STATION_Y), SetMinimalSize(66, 50), SetFill(0, 0), EndContainer(),
1647  EndContainer(),
1648  EndContainer(),
1650  NWidget(WWT_LABEL, COLOUR_DARK_GREEN, WID_BROS_SHOW_NEWST_TYPE), SetMinimalSize(144, 8), SetDataTip(STR_JUST_STRING, STR_NULL), SetTextStyle(TC_ORANGE), SetFill(1, 0),
1651  EndContainer(),
1652  NWidget(WWT_LABEL, COLOUR_DARK_GREEN), SetDataTip(STR_STATION_BUILD_COVERAGE_AREA_TITLE, STR_NULL), SetFill(1, 0),
1653  NWidget(NWID_HORIZONTAL), SetPIPRatio(1, 0, 1),
1654  NWidget(WWT_TEXTBTN, COLOUR_GREY, WID_BROS_LT_OFF), SetMinimalSize(60, 12),
1655  SetDataTip(STR_STATION_BUILD_COVERAGE_OFF, STR_STATION_BUILD_COVERAGE_AREA_OFF_TOOLTIP),
1656  NWidget(WWT_TEXTBTN, COLOUR_GREY, WID_BROS_LT_ON), SetMinimalSize(60, 12),
1657  SetDataTip(STR_STATION_BUILD_COVERAGE_ON, STR_STATION_BUILD_COVERAGE_AREA_ON_TOOLTIP),
1658  EndContainer(),
1659  EndContainer(),
1661  /* Hidden panel as NWID_MATRIX does not support SetScrollbar() */
1662  NWidget(WWT_PANEL, COLOUR_DARK_GREEN), SetScrollbar(WID_BROS_MATRIX_SCROLL),
1663  NWidget(NWID_MATRIX, COLOUR_DARK_GREEN, WID_BROS_MATRIX), SetPIP(0, 2, 0),
1664  NWidget(WWT_PANEL, COLOUR_DARK_GREEN, WID_BROS_IMAGE), SetMinimalSize(66, 60),
1665  SetFill(0, 0), SetResize(0, 0), SetDataTip(0x0, STR_STATION_BUILD_STATION_TYPE_TOOLTIP), SetScrollbar(WID_BROS_MATRIX_SCROLL),
1666  EndContainer(),
1667  EndContainer(),
1668  EndContainer(),
1669  EndContainer(),
1670  EndContainer(),
1671  NWidget(WWT_EMPTY, INVALID_COLOUR, WID_BROS_ACCEPTANCE), SetFill(1, 1), SetResize(1, 0), SetMinimalTextLines(2, WidgetDimensions::unscaled.vsep_normal),
1672  EndContainer(),
1673  EndContainer(),
1676  NWidget(NWID_VSCROLLBAR, COLOUR_DARK_GREEN, WID_BROS_MATRIX_SCROLL),
1677  NWidget(WWT_RESIZEBOX, COLOUR_DARK_GREEN),
1678  EndContainer(),
1679  EndContainer(),
1680  EndContainer(),
1681 };
1682 
1683 static WindowDesc _road_station_picker_desc(__FILE__, __LINE__,
1684  WDP_AUTO, "build_station_road", 0, 0,
1688 );
1689 
1693  NWidget(WWT_CLOSEBOX, COLOUR_DARK_GREEN),
1694  NWidget(WWT_CAPTION, COLOUR_DARK_GREEN, WID_BROS_CAPTION),
1695  NWidget(WWT_SHADEBOX, COLOUR_DARK_GREEN),
1697  NWidget(WWT_DEFSIZEBOX, COLOUR_DARK_GREEN),
1698  EndContainer(),
1699  EndContainer(),
1701  NWidget(WWT_PANEL, COLOUR_DARK_GREEN),
1703  NWidget(NWID_HORIZONTAL), SetPIP(0, WidgetDimensions::unscaled.hsep_normal, 0), SetPIPRatio(1, 0, 1),
1707  NWidget(WWT_TEXT, COLOUR_DARK_GREEN), SetFill(0, 1), SetDataTip(STR_LIST_FILTER_TITLE, STR_NULL),
1708  NWidget(WWT_EDITBOX, COLOUR_GREY, WID_BROS_FILTER_EDITBOX), SetFill(1, 0), SetResize(1, 0),
1709  SetDataTip(STR_LIST_FILTER_OSKTITLE, STR_LIST_FILTER_TOOLTIP),
1710  EndContainer(),
1711  EndContainer(),
1714  NWidget(WWT_MATRIX, COLOUR_GREY, WID_BROS_NEWST_LIST), SetMinimalSize(122, 71), SetFill(1, 0),
1715  SetMatrixDataTip(1, 0, STR_STATION_BUILD_STATION_CLASS_TOOLTIP), SetScrollbar(WID_BROS_NEWST_SCROLL),
1717  EndContainer(),
1718  EndContainer(),
1720  NWidget(WWT_LABEL, COLOUR_DARK_GREEN), SetMinimalSize(144, 11), SetDataTip(STR_STATION_BUILD_ORIENTATION, STR_NULL), SetFill(1, 0),
1721  EndContainer(),
1723  NWidget(WWT_PANEL, COLOUR_GREY, WID_BROS_STATION_X), SetMinimalSize(66, 50), SetFill(0, 0), EndContainer(),
1724  NWidget(WWT_PANEL, COLOUR_GREY, WID_BROS_STATION_Y), SetMinimalSize(66, 50), SetFill(0, 0), EndContainer(),
1725  EndContainer(),
1727  NWidget(WWT_LABEL, COLOUR_DARK_GREEN, WID_BROS_SHOW_NEWST_TYPE), SetMinimalSize(144, 8), SetDataTip(STR_JUST_STRING, STR_NULL), SetTextStyle(TC_ORANGE), SetFill(1, 0),
1728  EndContainer(),
1729  NWidget(WWT_LABEL, COLOUR_DARK_GREEN), SetDataTip(STR_STATION_BUILD_COVERAGE_AREA_TITLE, STR_NULL), SetFill(1, 0),
1730  NWidget(NWID_HORIZONTAL), SetPIPRatio(1, 0, 1),
1731  NWidget(WWT_TEXTBTN, COLOUR_GREY, WID_BROS_LT_OFF), SetMinimalSize(60, 12),
1732  SetDataTip(STR_STATION_BUILD_COVERAGE_OFF, STR_STATION_BUILD_COVERAGE_AREA_OFF_TOOLTIP),
1733  NWidget(WWT_TEXTBTN, COLOUR_GREY, WID_BROS_LT_ON), SetMinimalSize(60, 12),
1734  SetDataTip(STR_STATION_BUILD_COVERAGE_ON, STR_STATION_BUILD_COVERAGE_AREA_ON_TOOLTIP),
1735  EndContainer(),
1736  EndContainer(),
1738  /* Hidden panel as NWID_MATRIX does not support SetScrollbar() */
1739  NWidget(WWT_PANEL, COLOUR_DARK_GREEN), SetScrollbar(WID_BROS_MATRIX_SCROLL),
1740  NWidget(NWID_MATRIX, COLOUR_DARK_GREEN, WID_BROS_MATRIX), SetPIP(0, 2, 0),
1741  NWidget(WWT_PANEL, COLOUR_DARK_GREEN, WID_BROS_IMAGE), SetMinimalSize(66, 60),
1742  SetFill(0, 0), SetResize(0, 0), SetDataTip(0x0, STR_STATION_BUILD_STATION_TYPE_TOOLTIP), SetScrollbar(WID_BROS_MATRIX_SCROLL),
1743  EndContainer(),
1744  EndContainer(),
1745  EndContainer(),
1746  EndContainer(),
1747  EndContainer(),
1748  NWidget(WWT_EMPTY, INVALID_COLOUR, WID_BROS_ACCEPTANCE), SetFill(1, 1), SetResize(1, 0), SetMinimalTextLines(2, WidgetDimensions::unscaled.vsep_normal),
1749  EndContainer(),
1750  EndContainer(),
1753  NWidget(NWID_VSCROLLBAR, COLOUR_DARK_GREEN, WID_BROS_MATRIX_SCROLL),
1754  NWidget(WWT_RESIZEBOX, COLOUR_DARK_GREEN),
1755  EndContainer(),
1756  EndContainer(),
1757  EndContainer(),
1758 };
1759 
1760 static WindowDesc _tram_station_picker_desc(__FILE__, __LINE__,
1761  WDP_AUTO, "build_station_tram", 0, 0,
1765 );
1766 
1767 static void ShowRVStationPicker(Window *parent, RoadStopType rs)
1768 {
1769  new BuildRoadStationWindow(RoadTypeIsRoad(_cur_roadtype) ? &_road_station_picker_desc : &_tram_station_picker_desc, parent, rs);
1770 }
1771 
1772 void InitializeRoadGui()
1773 {
1774  _road_depot_orientation = DIAGDIR_NW;
1775  _roadstop_gui_settings.orientation = DIAGDIR_NW;
1776 }
1777 
1782 {
1784  if (w != nullptr) w->ModifyRoadType(_cur_roadtype);
1785 }
1786 
1787 DropDownList GetRoadTypeDropDownList(RoadTramTypes rtts, bool for_replacement, bool all_option)
1788 {
1789  RoadTypes used_roadtypes;
1790  RoadTypes avail_roadtypes;
1791 
1792  const Company *c = Company::Get(_local_company);
1793 
1794  /* Find the used roadtypes. */
1795  if (for_replacement) {
1796  avail_roadtypes = GetCompanyRoadTypes(c->index, false);
1797  used_roadtypes = GetRoadTypes(false);
1798  } else {
1799  avail_roadtypes = c->avail_roadtypes;
1800  used_roadtypes = GetRoadTypes(true);
1801  }
1802 
1803  /* Filter listed road types */
1804  if (!HasBit(rtts, RTT_ROAD)) used_roadtypes &= _roadtypes_type;
1805  if (!HasBit(rtts, RTT_TRAM)) used_roadtypes &= ~_roadtypes_type;
1806 
1807  DropDownList list;
1808 
1809  if (all_option) {
1810  list.push_back(std::make_unique<DropDownListStringItem>(STR_REPLACE_ALL_ROADTYPE, INVALID_ROADTYPE, false));
1811  }
1812 
1813  Dimension d = { 0, 0 };
1814  /* Get largest icon size, to ensure text is aligned on each menu item. */
1815  if (!for_replacement) {
1816  for (const auto &rt : _sorted_roadtypes) {
1817  if (!HasBit(used_roadtypes, rt)) continue;
1818  const RoadTypeInfo *rti = GetRoadTypeInfo(rt);
1820  }
1821  }
1822 
1823  for (const auto &rt : _sorted_roadtypes) {
1824  /* If it's not used ever, don't show it to the user. */
1825  if (!HasBit(used_roadtypes, rt)) continue;
1826 
1827  const RoadTypeInfo *rti = GetRoadTypeInfo(rt);
1828 
1829  SetDParam(0, rti->strings.menu_text);
1830  SetDParam(1, rti->max_speed / 2);
1831  if (for_replacement) {
1832  list.push_back(std::make_unique<DropDownListStringItem>(rti->strings.replace_text, rt, !HasBit(avail_roadtypes, rt)));
1833  } else {
1834  StringID str = rti->max_speed > 0 ? STR_TOOLBAR_RAILTYPE_VELOCITY : STR_JUST_STRING;
1835  list.push_back(std::make_unique<DropDownListIconItem>(d, rti->gui_sprites.build_x_road, PAL_NONE, str, rt, !HasBit(avail_roadtypes, rt)));
1836  }
1837  }
1838 
1839  if (list.empty()) {
1840  /* Empty dropdowns are not allowed */
1841  list.push_back(std::make_unique<DropDownListStringItem>(STR_NONE, INVALID_ROADTYPE, true));
1842  }
1843 
1844  return list;
1845 }
1846 
1847 DropDownList GetScenRoadTypeDropDownList(RoadTramTypes rtts)
1848 {
1849  RoadTypes avail_roadtypes = GetRoadTypes(false);
1850  avail_roadtypes = AddDateIntroducedRoadTypes(avail_roadtypes, TimerGameCalendar::date);
1851  RoadTypes used_roadtypes = GetRoadTypes(true);
1852 
1853  /* Filter listed road types */
1854  if (!HasBit(rtts, RTT_ROAD)) used_roadtypes &= _roadtypes_type;
1855  if (!HasBit(rtts, RTT_TRAM)) used_roadtypes &= ~_roadtypes_type;
1856 
1857  DropDownList list;
1858 
1859  /* If it's not used ever, don't show it to the user. */
1860  Dimension d = { 0, 0 };
1861  for (const auto &rt : _sorted_roadtypes) {
1862  if (!HasBit(used_roadtypes, rt)) continue;
1863  const RoadTypeInfo *rti = GetRoadTypeInfo(rt);
1865  }
1866  for (const auto &rt : _sorted_roadtypes) {
1867  if (!HasBit(used_roadtypes, rt)) continue;
1868 
1869  const RoadTypeInfo *rti = GetRoadTypeInfo(rt);
1870 
1871  SetDParam(0, rti->strings.menu_text);
1872  SetDParam(1, rti->max_speed / 2);
1873  StringID str = rti->max_speed > 0 ? STR_TOOLBAR_RAILTYPE_VELOCITY : STR_JUST_STRING;
1874  list.push_back(std::make_unique<DropDownListIconItem>(d, rti->gui_sprites.build_x_road, PAL_NONE, str, rt, !HasBit(avail_roadtypes, rt)));
1875  }
1876 
1877  if (list.empty()) {
1878  /* Empty dropdowns are not allowed */
1879  list.push_back(std::make_unique<DropDownListStringItem>(STR_NONE, -1, true));
1880  }
1881 
1882  return list;
1883 }
SZSP_NONE
@ SZSP_NONE
Display plane with zero size in both directions (none filling and resizing).
Definition: widget_type.h:469
ES_HANDLED
@ ES_HANDLED
The passed event is handled.
Definition: window_type.h:739
SetFill
constexpr NWidgetPart SetFill(uint16_t fill_x, uint16_t fill_y)
Widget part function for setting filling.
Definition: widget_type.h:1141
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:2536
DDSP_DEMOLISH_AREA
@ DDSP_DEMOLISH_AREA
Clear area.
Definition: viewport_type.h:108
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:82
WID_ROT_TRUCK_STATION
@ WID_ROT_TRUCK_STATION
Build truck station.
Definition: road_widget.h:23
PlaceRoad_Bridge
static void PlaceRoad_Bridge(TileIndex tile, Window *w)
Callback to start placing a bridge.
Definition: road_gui.cpp:110
RoadTypeInfo
Definition: road.h:78
CloseWindowByClass
void CloseWindowByClass(WindowClass cls, int data)
Close all windows of a given class.
Definition: window.cpp:1153
sound_func.h
TileHighlightData::size
Point size
Size, in tile "units", of the white/red selection area.
Definition: tilehighlight_type.h:48
AXIS_Y
@ AXIS_Y
The y axis.
Definition: direction_type.h:118
WID_BROS_SHOW_NEWST_TYPE_SEL
@ WID_BROS_SHOW_NEWST_TYPE_SEL
Selection for the type name.
Definition: road_widget.h:66
ROADSTOPTYPE_ALL
@ ROADSTOPTYPE_ALL
This RoadStop is for both types of station road stops.
Definition: newgrf_roadstop.h:49
ROADTYPE_END
@ ROADTYPE_END
Used for iterations.
Definition: road_type.h:29
RoadTypeInfo::err_build_road
StringID err_build_road
Building a normal piece of road.
Definition: road.h:110
BuildRoadStationWindow::RoadStopClassIDSorter
static bool RoadStopClassIDSorter(RoadStopClassID const &a, RoadStopClassID const &b)
Sort classes by RoadStopClassID.
Definition: road_gui.cpp:1232
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:189
Pool::PoolItem<&_company_pool >::Get
static Titem * Get(size_t index)
Returns Titem with given index.
Definition: pool_type.hpp:335
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:129
BuildRoadStationWindow::OnPaint
void OnPaint() override
The window must be repainted.
Definition: road_gui.cpp:1318
WID_ROT_BUILD_BRIDGE
@ WID_ROT_BUILD_BRIDGE
Build bridge.
Definition: road_widget.h:25
WID_BROS_NEWST_SCROLL
@ WID_BROS_NEWST_SCROLL
Scrollbar of the WID_BROS_NEWST_LIST.
Definition: road_widget.h:69
GameSettings::station
StationSettings station
settings related to station management
Definition: settings_type.h:630
querystring_gui.h
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
VpSetPresizeRange
void VpSetPresizeRange(TileIndex from, TileIndex to)
Highlights all tiles between a set of two tiles.
Definition: viewport.cpp:2771
SetFocusedWindow
void SetFocusedWindow(Window *w)
Set the window that has the focus.
Definition: window.cpp:423
RoadTypeInfo::build_y_road
SpriteID build_y_road
button for building single rail in Y direction
Definition: road.h:86
RoadStopType
RoadStopType
Types of RoadStops.
Definition: station_type.h:43
ROADSTOP_TRUCK
@ ROADSTOP_TRUCK
A standard stop for trucks.
Definition: station_type.h:45
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:122
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
WWT_STICKYBOX
@ WWT_STICKYBOX
Sticky box (at top-right of a window, after WWT_DEFSIZEBOX)
Definition: widget_type.h:68
BuildRoadStationWindow::EDITBOX_MAX_SIZE
static const uint EDITBOX_MAX_SIZE
The maximum number of characters for the filter edit box.
Definition: road_gui.cpp:1109
WDF_CONSTRUCTION
@ WDF_CONSTRUCTION
This window is used for construction; close it whenever changing company.
Definition: window_gui.h:197
PlaceRoad_TruckStation
static void PlaceRoad_TruckStation(TileIndex tile)
Callback for placing a truck station.
Definition: road_gui.cpp:259
GUIList::SetFilterState
void SetFilterState(bool state)
Enable or disable the filter.
Definition: sortlist_type.h:327
Rect::Shrink
Rect Shrink(int s) const
Copy and shrink Rect by s pixels.
Definition: geometry_type.hpp:98
RoadStopGUISettings
Definition: road_gui.cpp:65
StringFilter::IsEmpty
bool IsEmpty() const
Check whether any filter words were entered.
Definition: stringfilter_type.h:60
BuildRoadStationWindow::OnResize
void OnResize() override
Called after the window got resized.
Definition: road_gui.cpp:1483
WID_BROS_MATRIX_SCROLL
@ WID_BROS_MATRIX_SCROLL
Scrollbar of the WID_BROS_SHOW_NEWST_ADDITIONS.
Definition: road_widget.h:58
Company::avail_roadtypes
RoadTypes avail_roadtypes
Road types available to this company.
Definition: company_base.h:121
WID_BROS_IMAGE
@ WID_BROS_IMAGE
Panel used for each image of the matrix.
Definition: road_widget.h:57
WID_BROS_SHOW_NEWST_DEFSIZE
@ WID_BROS_SHOW_NEWST_DEFSIZE
Selection for default-size button for new road stops.
Definition: road_widget.h:61
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:107
tunnelbridge_map.h
StringFilter::SetFilterTerm
void SetFilterTerm(const char *str)
Set the term to filter on.
Definition: stringfilter.cpp:28
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
Axis
Axis
Allow incrementing of DiagDirDiff variables.
Definition: direction_type.h:116
Scrollbar::ScrollTowards
void ScrollTowards(int position)
Scroll towards the given position; if the item is visible nothing happens, otherwise it will be shown...
Definition: widget_type.h:821
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
NewGRFClass::GetSpecCount
uint GetSpecCount() const
Get the number of allocated specs within the class.
Definition: newgrf_class.h:44
CheckRedrawStationCoverage
void CheckRedrawStationCoverage(const Window *w)
Check whether we need to redraw the station coverage text.
Definition: station_gui.cpp:126
Window::SetWidgetDirty
void SetWidgetDirty(WidgetID widget_index) const
Invalidate a widget, i.e.
Definition: window.cpp:552
BuildRoadStationWindow::last_sorting
static Listing last_sorting
Default sorting of GUIRoadStopClassList.
Definition: road_gui.cpp:1111
NWidgetMatrix
Matrix container with implicitly equal sized (virtual) sub-widgets.
Definition: widget_type.h:581
RoadStopSpec::name
StringID name
Name of this stop.
Definition: newgrf_roadstop.h:132
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:133
GUIList< RoadStopClassID, std::nullptr_t, StringFilter & >
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:1141
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:210
SetRedErrorSquare
void SetRedErrorSquare(TileIndex tile)
Set a tile to display a red error square.
Definition: viewport.cpp:2518
ROADSTOPTYPE_FREIGHT
@ ROADSTOPTYPE_FREIGHT
This RoadStop is for freight (truck) stops.
Definition: newgrf_roadstop.h:48
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
IntervalTimer< TimerGameCalendar >
WID_BROD_DEPOT_NW
@ WID_BROD_DEPOT_NW
Depot with NW entry.
Definition: road_widget.h:40
WDP_ALIGN_TOOLBAR
@ WDP_ALIGN_TOOLBAR
Align toward the toolbar.
Definition: window_gui.h:143
DIAGDIR_END
@ DIAGDIR_END
Used for iterations.
Definition: direction_type.h:79
road_widget.h
Pool::PoolItem::index
Tindex index
Index of this pool item.
Definition: pool_type.hpp:234
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:131
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:1048
WWT_MATRIX
@ WWT_MATRIX
Grid of rows and columns.
Definition: widget_type.h:61
FindWindowById
Window * FindWindowById(WindowClass cls, WindowNumber number)
Find a window by its class and window number.
Definition: window.cpp:1099
BuildRoadToolbarWindow::last_started_action
int last_started_action
Last started user action.
Definition: road_gui.cpp:311
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:1151
PlaceProc_DemolishArea
void PlaceProc_DemolishArea(TileIndex tile)
Start a drag for demolishing an area.
Definition: terraform_gui.cpp:150
BuildRoadToolbarWindow::rti
const RoadTypeInfo * rti
Information about current road type.
Definition: road_gui.cpp:310
SetMatrixDataTip
constexpr NWidgetPart SetMatrixDataTip(uint8_t cols, uint8_t rows, StringID tip)
Widget part function for setting the data and tooltip of WWT_MATRIX widgets.
Definition: widget_type.h:1174
_ctrl_pressed
bool _ctrl_pressed
Is Ctrl pressed?
Definition: gfx.cpp:37
FILLRECT_CHECKER
@ FILLRECT_CHECKER
Draw only every second pixel, used for greying-out.
Definition: gfx_type.h:294
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:1576
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:756
zoom_func.h
Scrollbar::SetCapacityFromWidget
void SetCapacityFromWidget(Window *w, WidgetID widget, int padding=0)
Set capacity of visible elements from the size and resize properties of a widget.
Definition: widget.cpp:2334
Window::RaiseButtons
void RaiseButtons(bool autoraise=false)
Raise the buttons of the window.
Definition: window.cpp:526
WID_BROS_FILTER_EDITBOX
@ WID_BROS_FILTER_EDITBOX
Filter text box for the road stop class list.
Definition: road_widget.h:60
WID_BROS_ACCEPTANCE
@ WID_BROS_ACCEPTANCE
Station acceptance info.
Definition: road_widget.h:55
BuildRoadToolbarWindow::OnCTRLStateChange
EventState OnCTRLStateChange() override
The state of the control key has changed.
Definition: road_gui.cpp:744
DrawRoadDepotSprite
void DrawRoadDepotSprite(int x, int y, DiagDirection dir, RoadType rt)
Draw the road depot sprite.
Definition: road_cmd.cpp:1866
VPM_FIX_Y
@ VPM_FIX_Y
drag only in Y axis
Definition: viewport_type.h:91
NWidgetMatrix::SetScrollbar
void SetScrollbar(Scrollbar *sb)
Assign a scrollbar to this matrix.
Definition: widget.cpp:1804
_settings_client
ClientSettings _settings_client
The current settings for this game.
Definition: settings.cpp:54
SZSP_HORIZONTAL
@ SZSP_HORIZONTAL
Display plane with zero size vertically, and filling and resizing horizontally.
Definition: widget_type.h:468
WID_BROD_DEPOT_SE
@ WID_BROD_DEPOT_SE
Depot with SE entry.
Definition: road_widget.h:38
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:1500
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 > >
GetIfNewStopsByType
bool GetIfNewStopsByType(RoadStopType rs, RoadType roadtype)
Checks if there's any new stations by a specific RoadStopType.
Definition: newgrf_roadstop.cpp:465
StringFilter::AddLine
void AddLine(const char *str)
Pass another text line from the current item to the filter.
Definition: stringfilter.cpp:114
DIAGDIR_NW
@ DIAGDIR_NW
Northwest.
Definition: direction_type.h:78
WID_BROS_SHOW_NEWST_MATRIX
@ WID_BROS_SHOW_NEWST_MATRIX
Selection for new stop image matrix.
Definition: road_widget.h:63
BuildRoadToolbarWindow::UpdateOptionWidgetStatus
void UpdateOptionWidgetStatus(RoadToolbarWidgets clicked_widget)
Update the remove button lowered state of the road toolbar.
Definition: road_gui.cpp:424
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
VEH_ROAD
@ VEH_ROAD
Road vehicle type.
Definition: vehicle_type.h:25
ViewportPlaceMethod
ViewportPlaceMethod
Viewport place method (type of highlighted area and placed objects)
Definition: viewport_type.h:88
BuildRoadStationWindow::vscrollMatrix
Scrollbar * vscrollMatrix
Vertical scrollbar of the station picker matrix.
Definition: road_gui.cpp:1105
WID_BROS_LT_ON
@ WID_BROS_LT_ON
Turn on area highlight.
Definition: road_widget.h:54
WID_BROD_DEPOT_SW
@ WID_BROD_DEPOT_SW
Depot with SW entry.
Definition: road_widget.h:39
RoadTypeInfo::err_remove_road
StringID err_remove_road
Removing a normal piece of road.
Definition: road.h:111
NWID_MATRIX
@ NWID_MATRIX
Matrix container.
Definition: widget_type.h:80
Scrollbar
Scrollbar data structure.
Definition: widget_type.h:678
Window::GetScrollbar
const Scrollbar * GetScrollbar(WidgetID widnum) const
Return the Scrollbar to a widget index.
Definition: window.cpp:315
Window::OnHotkey
virtual EventState OnHotkey(int hotkey)
A hotkey has been pressed.
Definition: window.cpp:566
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:1038
WID_BROS_LT_OFF
@ WID_BROS_LT_OFF
Turn off area highlight.
Definition: road_widget.h:53
INVALID_ROADTYPE
@ INVALID_ROADTYPE
flag for invalid roadtype
Definition: road_type.h:30
OrthogonalTileArea::h
uint16_t h
The height of the area.
Definition: tilearea_type.h:21
GUIList::NeedRebuild
bool NeedRebuild() const
Check if a rebuild is needed.
Definition: sortlist_type.h:387
RoadTypeInfo::road_nwse
CursorID road_nwse
Cursor for building rail in Y direction.
Definition: road.h:95
QueryString
Data stored about a string that can be modified in the GUI.
Definition: querystring_gui.h:20
WID_BROS_STATION_Y
@ WID_BROS_STATION_Y
Drive-through station in y-direction.
Definition: road_widget.h:52
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
BuildRoadToolbarWindow::OnPlaceObjectAbort
void OnPlaceObjectAbort() override
The user cancelled a tile highlight mode that has been set.
Definition: road_gui.cpp:619
Textbuf::buf
char *const buf
buffer in which text is saved
Definition: textbuf_type.h:32
GetIfClassHasNewStopsByType
bool GetIfClassHasNewStopsByType(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:484
MAX_CHAR_LENGTH
static const int MAX_CHAR_LENGTH
Max. length of UTF-8 encoded unicode character.
Definition: strings_type.h:18
DDSP_PLACE_ROAD_X_DIR
@ DDSP_PLACE_ROAD_X_DIR
Road placement (X axis)
Definition: viewport_type.h:128
ToggleRoadButton_Remove
static void ToggleRoadButton_Remove(Window *w)
Toggles state of the Remove button of Build road toolbar.
Definition: road_gui.cpp:279
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:277
NWidgetMatrix::SetCount
void SetCount(int count)
Set the number of elements in this matrix.
Definition: widget.cpp:1780
WindowDesc
High level window description.
Definition: window_gui.h:153
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
BROSHK_FOCUS_FILTER_BOX
@ BROSHK_FOCUS_FILTER_BOX
Focus the edit box for editing the filter string.
Definition: road_gui.cpp:1096
StationType
StationType
Station types.
Definition: station_type.h:31
ScaleGUITrad
int ScaleGUITrad(int value)
Scale traditional pixel dimensions to GUI zoom level.
Definition: zoom_func.h:117
window_gui.h
RSF_BUILD_MENU_TRAM_ONLY
@ RSF_BUILD_MENU_TRAM_ONLY
Only show in the tram build menu (not road).
Definition: newgrf_roadstop.h:71
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:1188
ROADTYPES_NONE
@ ROADTYPES_NONE
No roadtypes.
Definition: road_type.h:39
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:51
SetResize
constexpr NWidgetPart SetResize(int16_t dx, int16_t dy)
Widget part function for setting the resize step.
Definition: widget_type.h:1086
_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:141
BuildRoadStationWindow::line_height
uint line_height
Height of a single line in the newstation selection matrix.
Definition: road_gui.cpp:1102
Listing
Data structure describing how to show the list (what sort direction and criteria).
Definition: sortlist_type.h:30
SCT_PASSENGERS_ONLY
@ SCT_PASSENGERS_ONLY
Draw only passenger class cargoes.
Definition: station_gui.h:21
Window::resize
ResizeInfo resize
Resize information.
Definition: window_gui.h:308
CommandCost
Common return value for all commands.
Definition: command_type.h:23
WidgetDimensions::matrix
RectPadding matrix
Padding of WWT_MATRIX items.
Definition: window_gui.h:44
tilehighlight_func.h
ClientSettings::sound
SoundSettings sound
sound effect settings
Definition: settings_type.h:639
WindowNumber
int32_t WindowNumber
Number to differentiate different windows of the same class.
Definition: window_type.h:732
FS_NORMAL
@ FS_NORMAL
Index of the normal font in the font tables.
Definition: gfx_type.h:203
Window::InitNested
void InitNested(WindowNumber number=0)
Perform complete initialization of the Window with nested widgets, to allow use.
Definition: window.cpp:1747
SetScrollbar
constexpr NWidgetPart SetScrollbar(WidgetID index)
Attach a scrollbar to a widget.
Definition: widget_type.h:1244
WID_ROT_BUILD_TUNNEL
@ WID_ROT_BUILD_TUNNEL
Build tunnel.
Definition: road_widget.h:26
GUIList::Filter
bool Filter(FilterFunction *decide, F filter_data)
Filter the list.
Definition: sortlist_type.h:343
WWT_EDITBOX
@ WWT_EDITBOX
a textbox for typing
Definition: widget_type.h:73
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:90
VpStartPlaceSizing
void VpStartPlaceSizing(TileIndex tile, ViewportPlaceMethod method, ViewportDragDropSelectionProcess process)
highlighting tiles while only going over them with the mouse
Definition: viewport.cpp:2716
BuildRoadStopHotkeys
BuildRoadStopHotkeys
Enum referring to the Hotkeys in the build road stop window.
Definition: road_gui.cpp:1095
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:1602
Window::SetDirty
void SetDirty() const
Mark entire window as dirty (in need of re-paint)
Definition: window.cpp:941
GUIList::SortFunction
std::conditional_t< std::is_same_v< P, std::nullptr_t >, bool(const T &, const T &), bool(const T &, const T &, const P)> SortFunction
Signature of sort function.
Definition: sortlist_type.h:49
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:409
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:829
station_cmd.h
ES_NOT_HANDLED
@ ES_NOT_HANDLED
The passed event is not handled.
Definition: window_type.h:740
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:399
BuildRoadDepotWindow
Definition: road_gui.cpp:1005
WID_BROS_STATION_SE
@ WID_BROS_STATION_SE
Terminal station with SE entry.
Definition: road_widget.h:48
PickerWindowBase::Close
void Close([[maybe_unused]] int data=0) override
Hide the window and all its child windows, and mark them for a later deletion.
Definition: window.cpp:3500
VpSelectTilesWithMethod
void VpSelectTilesWithMethod(int x, int y, ViewportPlaceMethod method)
Selects tiles while dragging.
Definition: viewport.cpp:3201
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:27
NewGRFClass
Struct containing information relating to NewGRF classes for stations and airports.
Definition: newgrf_class.h:20
BuildRoadToolbarWindow::roadtype
RoadType roadtype
Road type to build.
Definition: road_gui.cpp:309
RoadTypeInfo::gui_sprites
struct RoadTypeInfo::@27 gui_sprites
struct containing the sprites for the road GUI.
road_gui.h
ShowSelectStationIfNeeded
void ShowSelectStationIfNeeded(TileArea ta, StationPickerCmdProc proc)
Show the station selection window when needed.
Definition: station_gui.cpp:2460
_settings_game
GameSettings _settings_game
Game settings of a running game or the scenario editor.
Definition: settings.cpp:55
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:953
Filtering
Data structure describing what to show in the list (filter criteria).
Definition: sortlist_type.h:35
DDSP_REMOVE_TRUCKSTOP
@ DDSP_REMOVE_TRUCKSTOP
Road stop removal (trucks)
Definition: viewport_type.h:134
WC_BUS_STATION
@ WC_BUS_STATION
Build bus station; Window numbers:
Definition: window_type.h:403
WID_BROD_DEPOT_NE
@ WID_BROD_DEPOT_NE
Depot with NE entry.
Definition: road_widget.h:37
IsBridgeTile
bool IsBridgeTile(Tile t)
checks if there is a bridge on this tile
Definition: bridge_map.h:35
Window::parent
Window * parent
Parent window.
Definition: window_gui.h:322
NWidget
constexpr NWidgetPart NWidget(WidgetType tp, Colours col, WidgetID idx=-1)
Widget part function for starting a new 'real' widget.
Definition: widget_type.h:1258
_local_company
CompanyID _local_company
Company controlled by the human player at this client. Can also be COMPANY_SPECTATOR.
Definition: company_cmd.cpp:49
safeguards.h
sortlist_type.h
Window::LowerWidget
void LowerWidget(WidgetID widget_index)
Marks a widget as lowered.
Definition: window_gui.h:460
timer.h
WID_ROT_ONE_WAY
@ WID_ROT_ONE_WAY
Build one-way road.
Definition: road_widget.h:24
WC_BUILD_BRIDGE
@ WC_BUILD_BRIDGE
Build bridge; Window numbers:
Definition: window_type.h:389
CA_BUS
@ CA_BUS
Catchment for bus stops with "modified catchment" enabled.
Definition: station_type.h:77
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:241
WindowClass
WindowClass
Window classes.
Definition: window_type.h:44
DDSP_PLACE_AUTOROAD
@ DDSP_PLACE_AUTOROAD
Road placement (auto)
Definition: viewport_type.h:130
DDSP_BUILD_BRIDGE
@ DDSP_BUILD_BRIDGE
Bridge placement.
Definition: viewport_type.h:117
RoadStopSpec::grf_prop
GRFFilePropsBase< NUM_CARGO+3 > grf_prop
Properties related the the grf file.
Definition: newgrf_roadstop.h:129
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:342
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:68
CA_TRUCK
@ CA_TRUCK
Catchment for truck stops with "modified catchment" enabled.
Definition: station_type.h:78
RSF_NO_AUTO_ROAD_CONNECTION
@ RSF_NO_AUTO_ROAD_CONNECTION
No auto road connection.
Definition: newgrf_roadstop.h:69
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:215
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
DiagDirection
DiagDirection
Enumeration for diagonal directions.
Definition: direction_type.h:73
Window::IsWidgetDisabled
bool IsWidgetDisabled(WidgetID widget_index) const
Gets the enabled/disabled status of a widget.
Definition: window_gui.h:410
WID_BROS_STATION_NW
@ WID_BROS_STATION_NW
Terminal station with NW entry.
Definition: road_widget.h:50
BuildRoadStationWindow::roadstop_classes
GUIRoadStopClassList roadstop_classes
Available road stop classes.
Definition: road_gui.cpp:1115
newgrf_roadstop.h
Scrollbar::GetScrolledItemFromWidget
Tcontainer::iterator GetScrolledItemFromWidget(Tcontainer &container, int clickpos, const Window *const w, WidgetID widget, int padding=0, int line_height=-1) const
Return an iterator pointing to the element of a scrolled widget that a user clicked in.
Definition: widget_type.h:845
RoadTypeInfo::build_tunnel
SpriteID build_tunnel
button for building a tunnel
Definition: road.h:89
StationSettings::station_spread
byte station_spread
amount a station may spread
Definition: settings_type.h:595
tunnelbridge_cmd.h
stdafx.h
Window::window_number
WindowNumber window_number
Window number within the window class.
Definition: window_gui.h:296
Window::SetFocusedWidget
bool SetFocusedWidget(WidgetID widget_index)
Set focus within this window to the given widget.
Definition: window.cpp:487
GUISettings::link_terraform_toolbar
bool link_terraform_toolbar
display terraform toolbar when displaying rail, road, water and airport toolbars
Definition: settings_type.h:142
GfxFillRect
void GfxFillRect(int left, int top, int right, int bottom, int colour, FillRectMode mode)
Applies a certain FillRectMode-operation to a rectangle [left, right] x [top, bottom] on the screen.
Definition: gfx.cpp:113
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:181
DRD_NONE
@ DRD_NONE
None of the directions are disallowed.
Definition: road_type.h:74
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:3140
viewport_func.h
BuildRoadToolbarWindow::SetupRoadToolbar
void SetupRoadToolbar()
Configures the road toolbar for roadtype given.
Definition: road_gui.cpp:383
WC_NONE
@ WC_NONE
No window, redirects to WC_MAIN_WINDOW.
Definition: window_type.h:45
CanBuildVehicleInfrastructure
bool CanBuildVehicleInfrastructure(VehicleType type, byte subtype)
Check whether we can build infrastructure for the given vehicle type.
Definition: vehicle.cpp:1893
Window::SetWidgetLoweredState
void SetWidgetLoweredState(WidgetID widget_index, bool lowered_stat)
Sets the lowered/raised status of a widget.
Definition: window_gui.h:441
BuildRoadStationWindow::last_filtering
static Filtering last_filtering
Default filtering of GUIRoadStopClassList.
Definition: road_gui.cpp:1112
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:1571
WC_BUILD_DEPOT
@ WC_BUILD_DEPOT
Build depot; Window numbers:
Definition: window_type.h:417
_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:1691
TileOffsByDiagDir
TileIndexDiff TileOffsByDiagDir(DiagDirection dir)
Convert a DiagDirection to a TileIndexDiff.
Definition: map_func.h:563
BuildRoadStationWindow::filter_editbox
QueryString filter_editbox
Filter editbox.
Definition: road_gui.cpp:1117
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:381
WID_BROS_MATRIX
@ WID_BROS_MATRIX
Matrix widget displaying all available road stops.
Definition: road_widget.h:56
GetSpriteSize
Dimension GetSpriteSize(SpriteID sprid, Point *offset, ZoomLevel zoom)
Get the size of a sprite.
Definition: gfx.cpp:941
WWT_CLOSEBOX
@ WWT_CLOSEBOX
Close box (at top-left of a window)
Definition: widget_type.h:71
WWT_RESIZEBOX
@ WWT_RESIZEBOX
Resize box (normally at bottom-right of a window)
Definition: widget_type.h:70
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:1401
BuildRoadStationWindow
Definition: road_gui.cpp:1099
ShowBuildBridgeWindow
void ShowBuildBridgeWindow(TileIndex start, TileIndex end, TransportType transport_type, byte road_rail_type)
Prepare the data for the build a bridge window.
Definition: bridge_gui.cpp:361
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:52
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:555
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
GUIList::ForceRebuild
void ForceRebuild()
Force that a rebuild is needed.
Definition: sortlist_type.h:395
string_func.h
ROADSTOP_CLASS_WAYP
@ ROADSTOP_CLASS_WAYP
Waypoint class (unimplemented: this is reserved for future use with road waypoints).
Definition: newgrf_roadstop.h:28
Window::IsWidgetLowered
bool IsWidgetLowered(WidgetID widget_index) const
Gets the lowered state of a widget.
Definition: window_gui.h:491
CALLBACK_FAILED
static const uint CALLBACK_FAILED
Different values for Callback result evaluations.
Definition: newgrf_callbacks.h:420
ROADSTOP_BUS
@ ROADSTOP_BUS
A standard stop for buses.
Definition: station_type.h:44
ROADSTOP_CLASS_DFLT
@ ROADSTOP_CLASS_DFLT
Default road stop class.
Definition: newgrf_roadstop.h:27
Window::querystrings
std::map< WidgetID, QueryString * > querystrings
QueryString associated to WWT_EDITBOX widgets.
Definition: window_gui.h:314
SoundSettings::confirm
bool confirm
Play sound effect on successful constructions or other actions.
Definition: settings_type.h:240
vehicle_func.h
WC_SELECT_STATION
@ WC_SELECT_STATION
Select station (when joining stations); Window numbers:
Definition: window_type.h:242
Window::CreateNestedTree
void CreateNestedTree()
Perform the first part of the initialization of a nested widget tree.
Definition: window.cpp:1724
strings_func.h
NWID_VSCROLLBAR
@ NWID_VSCROLLBAR
Vertical scrollbar.
Definition: widget_type.h:86
terraform_gui.h
Window::IsShaded
bool IsShaded() const
Is window shaded currently?
Definition: window_gui.h:556
INVALID_AXIS
@ INVALID_AXIS
Flag for an invalid Axis.
Definition: direction_type.h:120
Scrollbar::IsVisible
bool IsVisible(uint16_t item) const
Checks whether given current item is visible in the list.
Definition: widget_type.h:730
VPM_Y_LIMITED
@ VPM_Y_LIMITED
Drag only in Y axis with limited size.
Definition: viewport_type.h:97
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:391
WWT_TEXT
@ WWT_TEXT
Pure simple text.
Definition: widget_type.h:60
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:1220
WC_SCEN_LAND_GEN
@ WC_SCEN_LAND_GEN
Landscape generation (in Scenario Editor); Window numbers:
Definition: window_type.h:449
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:308
geometry_func.hpp
OrthogonalTileArea::tile
TileIndex tile
The base tile of the area.
Definition: tilearea_type.h:19
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
WID_BROS_FILTER_CONTAINER
@ WID_BROS_FILTER_CONTAINER
Container for the filter text box for the road stop class list.
Definition: road_widget.h:59
StringFilter::ResetState
void ResetState()
Reset the matching state to process a new item.
Definition: stringfilter.cpp:98
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:2051
WID_BROS_STATION_SW
@ WID_BROS_STATION_SW
Terminal station with SW entry.
Definition: road_widget.h:49
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:153
ScaleSpriteTrad
int ScaleSpriteTrad(int value)
Scale traditional pixel dimensions to GUI zoom level, for drawing sprites.
Definition: zoom_func.h:107
BuildRoadStationWindow::roadStopType
RoadStopType roadStopType
The RoadStopType for this Window.
Definition: road_gui.cpp:1101
Scrollbar::SetCount
void SetCount(size_t num)
Sets the number of elements in the list.
Definition: widget_type.h:760
GetString
std::string GetString(StringID string)
Resolve the given StringID into a std::string with all the associated DParam lookups and formatting.
Definition: strings.cpp:327
EventState
EventState
State of handling an event.
Definition: window_type.h:738
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:292
VPM_X_AND_Y
@ VPM_X_AND_Y
area of land in X and Y directions
Definition: viewport_type.h:92
StringFilter::GetState
bool GetState() const
Get the matching state of the current item.
Definition: stringfilter_type.h:71
NewGRFClass::name
StringID name
Name of this class.
Definition: newgrf_class.h:39
Window::window_class
WindowClass window_class
Window class.
Definition: window_gui.h:295
RoadType
RoadType
The different roadtypes we support.
Definition: road_type.h:25
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:1734
DC_AUTO
@ DC_AUTO
don't allow building on structures
Definition: command_type.h:372
PC_BLACK
static const uint8_t PC_BLACK
Black palette colour.
Definition: palette_func.h:55
DDSP_CONVERT_ROAD
@ DDSP_CONVERT_ROAD
Road conversion.
Definition: viewport_type.h:135
RoadTypeInfo::strings
struct RoadTypeInfo::@29 strings
Strings associated with the rail type.
company_func.h
BuildRoadStationWindow::TagNameFilter
static bool CDECL TagNameFilter(RoadStopClassID const *sc, StringFilter &filter)
Filter classes by class name.
Definition: road_gui.cpp:1238
BuildRoadStationWindow::coverage_height
uint coverage_height
Height of the coverage texts.
Definition: road_gui.cpp:1103
PickerWindowBase
Base class for windows opened from a toolbar.
Definition: window_gui.h:979
BuildRoadStationWindow::filter_funcs
static GUIRoadStopClassList::FilterFunction *const filter_funcs[]
Filter functions of the GUIRoadStopClassList.
Definition: road_gui.cpp:1114
SetViewportCatchmentStation
void SetViewportCatchmentStation(const Station *st, bool sel)
Select or deselect station for coverage area highlight.
Definition: viewport.cpp:3603
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:127
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:70
Window::top
int top
y position of top edge of the window
Definition: window_gui.h:304
AXIS_X
@ AXIS_X
The X axis.
Definition: direction_type.h:117
OrthogonalTileArea::w
uint16_t w
The width of the area.
Definition: tilearea_type.h:20
BuildRoadStationWindow::OnHotkey
EventState OnHotkey(int hotkey) override
A hotkey has been pressed.
Definition: road_gui.cpp:1297
Window::RaiseWidget
void RaiseWidget(WidgetID widget_index)
Marks a widget as raised.
Definition: window_gui.h:469
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:1290
CommandHelper
Definition: command_func.h:93
GUIList::SetFilterFuncs
void SetFilterFuncs(FilterFunction *const *n_funcs)
Hand the array of filter function pointers to the sort list.
Definition: sortlist_type.h:366
window_func.h
SoundSettings::click_beep
bool click_beep
Beep on a random selection of buttons.
Definition: settings_type.h:241
GetCharacterHeight
int GetCharacterHeight(FontSize size)
Get height of a character for a given font size.
Definition: fontcache.cpp:78
RoadTypeInfo::max_speed
uint16_t max_speed
Maximum speed for vehicles travelling on this road type.
Definition: road.h:142
WID_BROS_CAPTION
@ WID_BROS_CAPTION
Caption of the window.
Definition: road_widget.h:46
VPM_X_LIMITED
@ VPM_X_LIMITED
Drag only in X axis with limited size.
Definition: viewport_type.h:96
stringfilter_type.h
ROAD_NONE
@ ROAD_NONE
No road-part is build.
Definition: road_type.h:53
NewGRFClass::Get
static NewGRFClass * Get(Tid cls_id)
Get a particular class.
Definition: newgrf_class_func.h:98
ShowTerraformToolbar
Window * ShowTerraformToolbar(Window *link)
Show the toolbar for terraforming in the game.
Definition: terraform_gui.cpp:367
SetMinimalSize
constexpr NWidgetPart SetMinimalSize(int16_t x, int16_t y)
Widget part function for setting the minimal size.
Definition: widget_type.h:1097
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:1232
GUIList::SetSortFuncs
void SetSortFuncs(SortFunction *const *n_funcs)
Hand the array of sort function pointers to the sort list.
Definition: sortlist_type.h:295
GUIList::RebuildDone
void RebuildDone()
Notify the sortlist that the rebuild is done.
Definition: sortlist_type.h:405
GUIList< RoadStopClassID, std::nullptr_t, StringFilter & >::FilterFunction
bool CDECL FilterFunction(const RoadStopClassID *, StringFilter &)
Signature of filter function.
Definition: sortlist_type.h:50
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
ShowBuildRoadToolbar
Window * ShowBuildRoadToolbar(RoadType roadtype)
Open the build road toolbar window.
Definition: road_gui.cpp:910
DrawString
int DrawString(int left, int right, int top, std::string_view str, TextColour colour, StringAlignment align, bool underline, FontSize fontsize)
Draw string, possibly truncated to make it fit in its allocated space.
Definition: gfx.cpp:658
engine_base.h
TRANSPORT_ROAD
@ TRANSPORT_ROAD
Transport by road vehicle.
Definition: transport_type.h:28
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
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
WID_BROS_SHOW_NEWST_ORIENTATION
@ WID_BROS_SHOW_NEWST_ORIENTATION
Selection for the orientation string for new stops.
Definition: road_widget.h:65
WID_BROD_CAPTION
@ WID_BROD_CAPTION
Caption of the window.
Definition: road_widget.h:36
Window
Data structure for an opened window.
Definition: window_gui.h:267
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
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:324
WID_BROS_SHOW_NEWST_RESIZE
@ WID_BROS_SHOW_NEWST_RESIZE
Selection for panel and resize at bottom right for new stops.
Definition: road_widget.h:64
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:319
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:1162
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:149
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:1109
Rect::Width
int Width() const
Get width of Rect.
Definition: geometry_type.hpp:85
VPM_X_AND_Y_LIMITED
@ VPM_X_AND_Y_LIMITED
area of land of limited size
Definition: viewport_type.h:93
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:1781
DIAGDIR_NE
@ DIAGDIR_NE
Northeast, upper right on your monitor.
Definition: direction_type.h:75
RoadStopClassID
RoadStopClassID
Definition: newgrf_roadstop.h:25
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:450
Company
Definition: company_base.h:116
GUIList::Sort
bool Sort(Comp compare)
Sort the list.
Definition: sortlist_type.h:268
BuildRoadStationWindow::sorter_funcs
static GUIRoadStopClassList::SortFunction *const sorter_funcs[]
Sort functions of the GUIRoadStopClassList.
Definition: road_gui.cpp:1113
Window::SetWidgetsDisabledState
void SetWidgetsDisabledState(bool disab_stat, Args... widgets)
Sets the enabled/disabled status of a list of widgets.
Definition: window_gui.h:515
VPM_X_OR_Y
@ VPM_X_OR_Y
drag in X or Y direction
Definition: viewport_type.h:89
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:3483
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:548
station_gui.h
GUIList::SetFiltering
void SetFiltering(Filtering f)
Import filter conditions.
Definition: sortlist_type.h:202
SetTextStyle
constexpr NWidgetPart SetTextStyle(TextColour colour, FontSize size=FS_NORMAL)
Widget part function for setting the text style.
Definition: widget_type.h:1120
RoadTypeInfo::picker_title
StringID picker_title[2]
Title for the station picker for bus or truck stations.
Definition: road.h:117
WID_BROS_SHOW_NEWST_TYPE
@ WID_BROS_SHOW_NEWST_TYPE
Display of selected stop type.
Definition: road_widget.h:67
BuildRoadStationWindow::string_filter
StringFilter string_filter
Filter for available road stop classes.
Definition: road_gui.cpp:1116
GetStringBoundingBox
Dimension GetStringBoundingBox(std::string_view str, FontSize start_fontsize)
Return the string dimension in pixels.
Definition: gfx.cpp:852
StringFilter
String filter and state.
Definition: stringfilter_type.h:30
DRD_NORTHBOUND
@ DRD_NORTHBOUND
All northbound traffic is disallowed.
Definition: road_type.h:76
road_cmd.h
WWT_TEXTBTN
@ WWT_TEXTBTN
(Toggle) Button with text
Definition: widget_type.h:57
WID_BROS_SHOW_NEWST_ADDITIONS
@ WID_BROS_SHOW_NEWST_ADDITIONS
Selection for new class selection list.
Definition: road_widget.h:62
ClientSettings::gui
GUISettings gui
settings related to the GUI
Definition: settings_type.h:636
WID_BROS_NEWST_LIST
@ WID_BROS_NEWST_LIST
List with new road stops.
Definition: road_widget.h:68
IsRoadStopAvailable
static bool IsRoadStopAvailable(const RoadStopSpec *roadstopspec, StationType type)
Check whether a road stop type can be built.
Definition: road_gui.cpp:78
BuildRoadStationWindow::GUIRoadStopClassList
GUIList< RoadStopClassID, std::nullptr_t, StringFilter & > GUIRoadStopClassList
Type definition for the list to hold available road stop classes.
Definition: road_gui.cpp:1107
DDSP_BUILD_TRUCKSTOP
@ DDSP_BUILD_TRUCKSTOP
Road stop placement (trucks)
Definition: viewport_type.h:132
DrawPixelInfo
Data about how and where to blit pixels.
Definition: gfx_type.h:151
WID_ROT_CONVERT_ROAD
@ WID_ROT_CONVERT_ROAD
Convert road.
Definition: road_widget.h:28
GUISettings::persistent_buildingtools
bool persistent_buildingtools
keep the building tools active after usage
Definition: settings_type.h:190
GUIList::SetListing
void SetListing(Listing l)
Import sort conditions.
Definition: sortlist_type.h:151
StationSettings::modified_catchment
bool modified_catchment
different-size catchment areas
Definition: settings_type.h:590
WID_ROT_BUS_STATION
@ WID_ROT_BUS_STATION
Build bus station.
Definition: road_widget.h:22
Hotkey
All data for a single hotkey.
Definition: hotkeys.h:21
hotkeys.h
GetTunnelBridgeDirection
DiagDirection GetTunnelBridgeDirection(Tile t)
Get the direction pointing to the other end.
Definition: tunnelbridge_map.h:26
ROADSTOPTYPE_PASSENGER
@ ROADSTOPTYPE_PASSENGER
This RoadStop is for passenger (bus) stops.
Definition: newgrf_roadstop.h:47
INVALID_RAILTYPE
@ INVALID_RAILTYPE
Flag for invalid railtype.
Definition: rail_type.h:34
BuildRoadStationWindow::vscrollList
Scrollbar * vscrollList
Vertical scrollbar of the new station list.
Definition: road_gui.cpp:1104
ShowBuildRoadScenToolbar
Window * ShowBuildRoadScenToolbar(RoadType roadtype)
Show the road building toolbar in the scenario editor.
Definition: road_gui.cpp:997
WWT_SHADEBOX
@ WWT_SHADEBOX
Shade box (at top-right of a window, between WWT_DEBUGBOX and WWT_DEFSIZEBOX)
Definition: widget_type.h:66
WID_BROS_STATION_NE
@ WID_BROS_STATION_NE
Terminal station with NE entry.
Definition: road_widget.h:47
NWidgetMatrix::SetClicked
void SetClicked(int clicked)
Sets the clicked element in the matrix.
Definition: widget.cpp:1763
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:111