OpenTTD Source  13.2.1
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 "date_func.h"
34 #include "station_cmd.h"
35 #include "road_cmd.h"
36 #include "tunnelbridge_cmd.h"
37 
38 #include "widgets/road_widget.h"
39 
40 #include "table/strings.h"
41 
42 #include "safeguards.h"
43 
44 static void ShowRVStationPicker(Window *parent, RoadStopType rs);
45 static void ShowRoadDepotPicker(Window *parent);
46 
47 static bool _remove_button_clicked;
48 static bool _one_way_button_clicked;
49 
50 static Axis _place_road_dir;
51 static bool _place_road_start_half_x;
52 static bool _place_road_start_half_y;
53 static bool _place_road_end_half;
54 
55 static RoadType _cur_roadtype;
56 
57 static DiagDirection _road_depot_orientation;
58 static DiagDirection _road_station_picker_orientation;
59 
60 void CcPlaySound_CONSTRUCTION_OTHER(Commands cmd, const CommandCost &result, TileIndex tile)
61 {
62  if (result.Succeeded() && _settings_client.sound.confirm) SndPlayTileFx(SND_1F_CONSTRUCTION_OTHER, tile);
63 }
64 
70 {
71  if (IsBridgeTile(tile)) {
73  Point pt = {0, 0};
74  w->OnPlaceMouseUp(VPM_X_OR_Y, DDSP_BUILD_BRIDGE, pt, other_tile, tile);
75  } else {
77  }
78 }
79 
87 void CcBuildRoadTunnel(Commands cmd, const CommandCost &result, TileIndex start_tile)
88 {
89  if (result.Succeeded()) {
90  if (_settings_client.sound.confirm) SndPlayTileFx(SND_1F_CONSTRUCTION_OTHER, start_tile);
92 
93  DiagDirection start_direction = ReverseDiagDir(GetTunnelBridgeDirection(start_tile));
94  ConnectRoadToStructure(start_tile, start_direction);
95 
96  TileIndex end_tile = GetOtherTunnelBridgeEnd(start_tile);
97  DiagDirection end_direction = ReverseDiagDir(GetTunnelBridgeDirection(end_tile));
98  ConnectRoadToStructure(end_tile, end_direction);
99  } else {
101  }
102 }
103 
110 {
111  tile += TileOffsByDiagDir(direction);
112  /* if there is a roadpiece just outside of the station entrance, build a connecting route */
113  if (IsNormalRoadTile(tile)) {
114  if (GetRoadBits(tile, GetRoadTramType(_cur_roadtype)) != ROAD_NONE) {
116  }
117  }
118 }
119 
120 void CcRoadDepot(Commands cmd, const CommandCost &result, TileIndex tile, RoadType rt, DiagDirection dir)
121 {
122  if (result.Failed()) return;
123 
127 }
128 
140 void CcRoadStop(Commands cmd, const CommandCost &result, TileIndex tile, uint8 width, uint8 length, RoadStopType, bool is_drive_through, DiagDirection dir, RoadType, StationID, bool)
141 {
142  if (result.Failed()) return;
143 
146  TileArea roadstop_area(tile, width, length);
147  for (TileIndex cur_tile : roadstop_area) {
148  ConnectRoadToStructure(cur_tile, dir);
149  /* For a drive-through road stop build connecting road for other entrance. */
150  if (is_drive_through) ConnectRoadToStructure(cur_tile, ReverseDiagDir(dir));
151  }
152 }
153 
164 static void PlaceRoadStop(TileIndex start_tile, TileIndex end_tile, RoadStopType stop_type, bool adjacent, RoadType rt, StringID err_msg)
165 {
166  TileArea ta(start_tile, end_tile);
167  DiagDirection ddir = _road_station_picker_orientation;
168  bool drive_through = ddir >= DIAGDIR_END;
169  if (drive_through) ddir = static_cast<DiagDirection>(ddir - DIAGDIR_END); // Adjust picker result to actual direction.
170 
171  auto proc = [=](bool test, StationID to_join) -> bool {
172  if (test) {
173  return Command<CMD_BUILD_ROAD_STOP>::Do(CommandFlagsToDCFlags(GetCommandFlags<CMD_BUILD_ROAD_STOP>()), ta.tile, ta.w, ta.h, stop_type, drive_through, ddir, rt, INVALID_STATION, adjacent).Succeeded();
174  } else {
175  return Command<CMD_BUILD_ROAD_STOP>::Post(err_msg, CcRoadStop, ta.tile, ta.w, ta.h, stop_type, drive_through, ddir, rt, to_join, adjacent);
176  }
177  };
178 
179  ShowSelectStationIfNeeded(ta, proc);
180 }
181 
187 {
190  } else {
191  if (_road_station_picker_orientation < DIAGDIR_END) { // Not a drive-through stop.
192  VpStartPlaceSizing(tile, (DiagDirToAxis(_road_station_picker_orientation) == AXIS_X) ? VPM_X_LIMITED : VPM_Y_LIMITED, DDSP_BUILD_BUSSTOP);
193  } else {
195  }
196  VpSetPlaceSizingLimit(_settings_game.station.station_spread);
197  }
198 }
199 
205 {
208  } else {
209  if (_road_station_picker_orientation < DIAGDIR_END) { // Not a drive-through stop.
210  VpStartPlaceSizing(tile, (DiagDirToAxis(_road_station_picker_orientation) == AXIS_X) ? VPM_X_LIMITED : VPM_Y_LIMITED, DDSP_BUILD_TRUCKSTOP);
211  } else {
213  }
214  VpSetPlaceSizingLimit(_settings_game.station.station_spread);
215  }
216 }
217 
218 typedef void OnButtonClick(Window *w);
219 
225 {
229  SetSelectionRed(_remove_button_clicked);
230 }
231 
238 {
239  if (w->IsWidgetDisabled(WID_ROT_REMOVE)) return false;
240 
241  /* allow ctrl to switch remove mode only for these widgets */
242  for (uint i = WID_ROT_ROAD_X; i <= WID_ROT_AUTOROAD; i++) {
243  if (w->IsWidgetLowered(i)) {
245  return true;
246  }
247  }
248 
249  return false;
250 }
251 
255  const RoadTypeInfo *rti;
257 
259  {
260  this->Initialize(_cur_roadtype);
261  this->InitNested(window_number);
262  this->SetupRoadToolbar();
264 
265  if (RoadTypeIsRoad(this->roadtype)) {
267  }
268 
269  this->OnInvalidateData();
270  this->last_started_action = WIDGET_LIST_END;
271 
273  }
274 
275  void Close() override
276  {
277  if (_game_mode == GM_NORMAL && (this->IsWidgetLowered(WID_ROT_BUS_STATION) || this->IsWidgetLowered(WID_ROT_TRUCK_STATION))) SetViewportCatchmentStation(nullptr, true);
279  this->Window::Close();
280  }
281 
287  void OnInvalidateData(int data = 0, bool gui_scope = true) override
288  {
289  if (!gui_scope) return;
290  RoadTramType rtt = GetRoadTramType(this->roadtype);
291 
292  bool can_build = CanBuildVehicleInfrastructure(VEH_ROAD, rtt);
293  this->SetWidgetsDisabledState(!can_build,
298  if (!can_build) {
302  }
303 
304  if (_game_mode != GM_EDITOR) {
305  if (!can_build) {
306  /* Show in the tooltip why this button is disabled. */
307  this->GetWidget<NWidgetCore>(WID_ROT_DEPOT)->SetToolTip(STR_TOOLBAR_DISABLED_NO_VEHICLE_AVAILABLE);
308  this->GetWidget<NWidgetCore>(WID_ROT_BUS_STATION)->SetToolTip(STR_TOOLBAR_DISABLED_NO_VEHICLE_AVAILABLE);
309  this->GetWidget<NWidgetCore>(WID_ROT_TRUCK_STATION)->SetToolTip(STR_TOOLBAR_DISABLED_NO_VEHICLE_AVAILABLE);
310  } else {
311  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);
312  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);
313  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);
314  }
315  }
316  }
317 
318  void Initialize(RoadType roadtype)
319  {
320  assert(roadtype < ROADTYPE_END);
321  this->roadtype = roadtype;
322  this->rti = GetRoadTypeInfo(this->roadtype);
323  }
324 
330  {
331  this->GetWidget<NWidgetCore>(WID_ROT_ROAD_X)->widget_data = rti->gui_sprites.build_x_road;
332  this->GetWidget<NWidgetCore>(WID_ROT_ROAD_Y)->widget_data = rti->gui_sprites.build_y_road;
333  this->GetWidget<NWidgetCore>(WID_ROT_AUTOROAD)->widget_data = rti->gui_sprites.auto_road;
334  if (_game_mode != GM_EDITOR) {
335  this->GetWidget<NWidgetCore>(WID_ROT_DEPOT)->widget_data = rti->gui_sprites.build_depot;
336  }
337  this->GetWidget<NWidgetCore>(WID_ROT_CONVERT_ROAD)->widget_data = rti->gui_sprites.convert_road;
338  this->GetWidget<NWidgetCore>(WID_ROT_BUILD_TUNNEL)->widget_data = rti->gui_sprites.build_tunnel;
339  }
340 
346  {
347  this->Initialize(roadtype);
348  this->SetupRoadToolbar();
349  this->ReInit();
350  }
351 
352  void SetStringParameters(int widget) const override
353  {
354  if (widget == WID_ROT_CAPTION) {
355  if (this->rti->max_speed > 0) {
356  SetDParam(0, STR_TOOLBAR_RAILTYPE_VELOCITY);
357  SetDParam(1, this->rti->strings.toolbar_caption);
358  SetDParam(2, this->rti->max_speed / 2);
359  } else {
360  SetDParam(0, this->rti->strings.toolbar_caption);
361  }
362  }
363  }
364 
371  {
372  /* The remove and the one way button state is driven
373  * by the other buttons so they don't act on themselves.
374  * Both are only valid if they are able to apply as options. */
375  switch (clicked_widget) {
376  case WID_ROT_REMOVE:
377  if (RoadTypeIsRoad(this->roadtype)) {
380  }
381 
382  break;
383 
384  case WID_ROT_ONE_WAY:
387  break;
388 
389  case WID_ROT_BUS_STATION:
391  if (RoadTypeIsRoad(this->roadtype)) this->DisableWidget(WID_ROT_ONE_WAY);
392  this->SetWidgetDisabledState(WID_ROT_REMOVE, !this->IsWidgetLowered(clicked_widget));
393  break;
394 
395  case WID_ROT_ROAD_X:
396  case WID_ROT_ROAD_Y:
397  case WID_ROT_AUTOROAD:
398  this->SetWidgetDisabledState(WID_ROT_REMOVE, !this->IsWidgetLowered(clicked_widget));
399  if (RoadTypeIsRoad(this->roadtype)) {
400  this->SetWidgetDisabledState(WID_ROT_ONE_WAY, !this->IsWidgetLowered(clicked_widget));
401  }
402  break;
403 
404  default:
405  /* When any other buttons than road/station, raise and
406  * disable the removal button */
409 
410  if (RoadTypeIsRoad(this->roadtype)) {
413  }
414 
415  break;
416  }
417  }
418 
419  void OnClick(Point pt, int widget, int click_count) override
420  {
421  _remove_button_clicked = false;
422  _one_way_button_clicked = false;
423  switch (widget) {
424  case WID_ROT_ROAD_X:
426  this->last_started_action = widget;
427  break;
428 
429  case WID_ROT_ROAD_Y:
431  this->last_started_action = widget;
432  break;
433 
434  case WID_ROT_AUTOROAD:
436  this->last_started_action = widget;
437  break;
438 
439  case WID_ROT_DEMOLISH:
441  this->last_started_action = widget;
442  break;
443 
444  case WID_ROT_DEPOT:
445  if (HandlePlacePushButton(this, WID_ROT_DEPOT, this->rti->cursor.depot, HT_RECT)) {
446  ShowRoadDepotPicker(this);
447  this->last_started_action = widget;
448  }
449  break;
450 
451  case WID_ROT_BUS_STATION:
452  if (HandlePlacePushButton(this, WID_ROT_BUS_STATION, SPR_CURSOR_BUS_STATION, HT_RECT)) {
453  ShowRVStationPicker(this, ROADSTOP_BUS);
454  this->last_started_action = widget;
455  }
456  break;
457 
459  if (HandlePlacePushButton(this, WID_ROT_TRUCK_STATION, SPR_CURSOR_TRUCK_STATION, HT_RECT)) {
460  ShowRVStationPicker(this, ROADSTOP_TRUCK);
461  this->last_started_action = widget;
462  }
463  break;
464 
465  case WID_ROT_ONE_WAY:
466  if (this->IsWidgetDisabled(WID_ROT_ONE_WAY)) return;
467  this->SetDirty();
469  SetSelectionRed(false);
470  break;
471 
473  HandlePlacePushButton(this, WID_ROT_BUILD_BRIDGE, SPR_CURSOR_BRIDGE, HT_RECT);
474  this->last_started_action = widget;
475  break;
476 
479  this->last_started_action = widget;
480  break;
481 
482  case WID_ROT_REMOVE:
483  if (this->IsWidgetDisabled(WID_ROT_REMOVE)) return;
484 
488  break;
489 
492  this->last_started_action = widget;
493  break;
494 
495  default: NOT_REACHED();
496  }
499  }
500 
501  EventState OnHotkey(int hotkey) override
502  {
503  MarkTileDirtyByTile(TileVirtXY(_thd.pos.x, _thd.pos.y)); // redraw tile selection
504  return Window::OnHotkey(hotkey);
505  }
506 
507  void OnPlaceObject(Point pt, TileIndex tile) override
508  {
510  _one_way_button_clicked = RoadTypeIsRoad(this->roadtype) ? this->IsWidgetLowered(WID_ROT_ONE_WAY) : false;
511  switch (this->last_started_action) {
512  case WID_ROT_ROAD_X:
513  _place_road_dir = AXIS_X;
514  _place_road_start_half_x = _tile_fract_coords.x >= 8;
516  break;
517 
518  case WID_ROT_ROAD_Y:
519  _place_road_dir = AXIS_Y;
520  _place_road_start_half_y = _tile_fract_coords.y >= 8;
522  break;
523 
524  case WID_ROT_AUTOROAD:
525  _place_road_dir = INVALID_AXIS;
526  _place_road_start_half_x = _tile_fract_coords.x >= 8;
527  _place_road_start_half_y = _tile_fract_coords.y >= 8;
529  break;
530 
531  case WID_ROT_DEMOLISH:
533  break;
534 
535  case WID_ROT_DEPOT:
536  Command<CMD_BUILD_ROAD_DEPOT>::Post(this->rti->strings.err_depot, CcRoadDepot,
537  tile, _cur_roadtype, _road_depot_orientation);
538  break;
539 
540  case WID_ROT_BUS_STATION:
541  PlaceRoad_BusStation(tile);
542  break;
543 
546  break;
547 
549  PlaceRoad_Bridge(tile, this);
550  break;
551 
553  Command<CMD_BUILD_TUNNEL>::Post(STR_ERROR_CAN_T_BUILD_TUNNEL_HERE, CcBuildRoadTunnel,
554  tile, TRANSPORT_ROAD, _cur_roadtype);
555  break;
556 
559  break;
560 
561  default: NOT_REACHED();
562  }
563  }
564 
565  void OnPlaceObjectAbort() override
566  {
567  if (_game_mode != GM_EDITOR && (this->IsWidgetLowered(WID_ROT_BUS_STATION) || this->IsWidgetLowered(WID_ROT_TRUCK_STATION))) SetViewportCatchmentStation(nullptr, true);
568 
569  this->RaiseButtons();
572 
573  if (RoadTypeIsRoad(this->roadtype)) {
576  }
577 
583  }
584 
585  void OnPlaceDrag(ViewportPlaceMethod select_method, ViewportDragDropSelectionProcess select_proc, Point pt) override
586  {
587  /* Here we update the end tile flags
588  * of the road placement actions.
589  * At first we reset the end halfroad
590  * bits and if needed we set them again. */
591  switch (select_proc) {
593  _place_road_end_half = pt.x & 8;
594  break;
595 
597  _place_road_end_half = pt.y & 8;
598  break;
599 
600  case DDSP_PLACE_AUTOROAD:
601  /* For autoroad we need to update the
602  * direction of the road */
603  if (_thd.size.x > _thd.size.y || (_thd.size.x == _thd.size.y &&
604  ( (_tile_fract_coords.x < _tile_fract_coords.y && (_tile_fract_coords.x + _tile_fract_coords.y) < 16) ||
605  (_tile_fract_coords.x > _tile_fract_coords.y && (_tile_fract_coords.x + _tile_fract_coords.y) > 16) ))) {
606  /* Set dir = X */
607  _place_road_dir = AXIS_X;
608  _place_road_end_half = pt.x & 8;
609  } else {
610  /* Set dir = Y */
611  _place_road_dir = AXIS_Y;
612  _place_road_end_half = pt.y & 8;
613  }
614 
615  break;
616 
617  default:
618  break;
619  }
620 
621  VpSelectTilesWithMethod(pt.x, pt.y, select_method);
622  }
623 
624  void OnPlaceMouseUp(ViewportPlaceMethod select_method, ViewportDragDropSelectionProcess select_proc, Point pt, TileIndex start_tile, TileIndex end_tile) override
625  {
626  if (pt.x != -1) {
627  switch (select_proc) {
628  default: NOT_REACHED();
629  case DDSP_BUILD_BRIDGE:
631  ShowBuildBridgeWindow(start_tile, end_tile, TRANSPORT_ROAD, _cur_roadtype);
632  break;
633 
634  case DDSP_DEMOLISH_AREA:
635  GUIPlaceProcDragXY(select_proc, start_tile, end_tile);
636  break;
637 
640  case DDSP_PLACE_AUTOROAD: {
641  bool start_half = _place_road_dir == AXIS_Y ? _place_road_start_half_y : _place_road_start_half_x;
642 
644  Command<CMD_REMOVE_LONG_ROAD>::Post(this->rti->strings.err_remove_road, CcPlaySound_CONSTRUCTION_OTHER,
645  end_tile, start_tile, _cur_roadtype, _place_road_dir, start_half, _place_road_end_half);
646  } else {
647  Command<CMD_BUILD_LONG_ROAD>::Post(this->rti->strings.err_build_road, CcPlaySound_CONSTRUCTION_OTHER,
648  end_tile, start_tile, _cur_roadtype, _place_road_dir, _one_way_button_clicked ? DRD_NORTHBOUND : DRD_NONE, start_half, _place_road_end_half, false);
649  }
650  break;
651  }
652 
653  case DDSP_BUILD_BUSSTOP:
654  case DDSP_REMOVE_BUSSTOP:
657  TileArea ta(start_tile, end_tile);
658  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);
659  } else {
660  PlaceRoadStop(start_tile, end_tile, ROADSTOP_BUS, _ctrl_pressed, _cur_roadtype, this->rti->strings.err_build_station[ROADSTOP_BUS]);
661  }
662  }
663  break;
664 
669  TileArea ta(start_tile, end_tile);
670  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);
671  } else {
672  PlaceRoadStop(start_tile, end_tile, ROADSTOP_TRUCK, _ctrl_pressed, _cur_roadtype, this->rti->strings.err_build_station[ROADSTOP_TRUCK]);
673  }
674  }
675  break;
676 
677  case DDSP_CONVERT_ROAD:
678  Command<CMD_CONVERT_ROAD>::Post(rti->strings.err_convert_road, CcPlaySound_CONSTRUCTION_OTHER, end_tile, start_tile, _cur_roadtype);
679  break;
680  }
681  }
682  }
683 
684  void OnPlacePresize(Point pt, TileIndex tile) override
685  {
688  }
689 
691  {
692  if (RoadToolbar_CtrlChanged(this)) return ES_HANDLED;
693  return ES_NOT_HANDLED;
694  }
695 
696  static HotkeyList road_hotkeys;
697  static HotkeyList tram_hotkeys;
698 };
699 
706 static EventState RoadTramToolbarGlobalHotkeys(int hotkey, RoadType last_build, RoadTramType rtt)
707 {
708  Window* w = nullptr;
709  switch (_game_mode) {
710  case GM_NORMAL:
711  w = ShowBuildRoadToolbar(last_build);
712  break;
713 
714  case GM_EDITOR:
715  if ((GetRoadTypes(true) & ((rtt == RTT_ROAD) ? ~_roadtypes_type : _roadtypes_type)) == ROADTYPES_NONE) return ES_NOT_HANDLED;
716  w = ShowBuildRoadScenToolbar(last_build);
717  break;
718 
719  default:
720  break;
721  }
722 
723  if (w == nullptr) return ES_NOT_HANDLED;
724  return w->OnHotkey(hotkey);
725 }
726 
727 static EventState RoadToolbarGlobalHotkeys(int hotkey)
728 {
729  extern RoadType _last_built_roadtype;
730  return RoadTramToolbarGlobalHotkeys(hotkey, _last_built_roadtype, RTT_ROAD);
731 }
732 
733 static EventState TramToolbarGlobalHotkeys(int hotkey)
734 {
735  extern RoadType _last_built_tramtype;
736  return RoadTramToolbarGlobalHotkeys(hotkey, _last_built_tramtype, RTT_TRAM);
737 }
738 
739 static Hotkey roadtoolbar_hotkeys[] = {
740  Hotkey('1', "build_x", WID_ROT_ROAD_X),
741  Hotkey('2', "build_y", WID_ROT_ROAD_Y),
742  Hotkey('3', "autoroad", WID_ROT_AUTOROAD),
743  Hotkey('4', "demolish", WID_ROT_DEMOLISH),
744  Hotkey('5', "depot", WID_ROT_DEPOT),
745  Hotkey('6', "bus_station", WID_ROT_BUS_STATION),
746  Hotkey('7', "truck_station", WID_ROT_TRUCK_STATION),
747  Hotkey('8', "oneway", WID_ROT_ONE_WAY),
748  Hotkey('B', "bridge", WID_ROT_BUILD_BRIDGE),
749  Hotkey('T', "tunnel", WID_ROT_BUILD_TUNNEL),
750  Hotkey('R', "remove", WID_ROT_REMOVE),
751  Hotkey('C', "convert", WID_ROT_CONVERT_ROAD),
752  HOTKEY_LIST_END
753 };
754 HotkeyList BuildRoadToolbarWindow::road_hotkeys("roadtoolbar", roadtoolbar_hotkeys, RoadToolbarGlobalHotkeys);
755 
756 static Hotkey tramtoolbar_hotkeys[] = {
757  Hotkey('1', "build_x", WID_ROT_ROAD_X),
758  Hotkey('2', "build_y", WID_ROT_ROAD_Y),
759  Hotkey('3', "autoroad", WID_ROT_AUTOROAD),
760  Hotkey('4', "demolish", WID_ROT_DEMOLISH),
761  Hotkey('5', "depot", WID_ROT_DEPOT),
762  Hotkey('6', "bus_station", WID_ROT_BUS_STATION),
763  Hotkey('7', "truck_station", WID_ROT_TRUCK_STATION),
764  Hotkey('B', "bridge", WID_ROT_BUILD_BRIDGE),
765  Hotkey('T', "tunnel", WID_ROT_BUILD_TUNNEL),
766  Hotkey('R', "remove", WID_ROT_REMOVE),
767  Hotkey('C', "convert", WID_ROT_CONVERT_ROAD),
768  HOTKEY_LIST_END
769 };
770 HotkeyList BuildRoadToolbarWindow::tram_hotkeys("tramtoolbar", tramtoolbar_hotkeys, TramToolbarGlobalHotkeys);
771 
772 
773 static const NWidgetPart _nested_build_road_widgets[] = {
775  NWidget(WWT_CLOSEBOX, COLOUR_DARK_GREEN),
776  NWidget(WWT_CAPTION, COLOUR_DARK_GREEN, WID_ROT_CAPTION), SetDataTip(STR_WHITE_STRING, STR_TOOLTIP_WINDOW_TITLE_DRAG_THIS),
777  NWidget(WWT_STICKYBOX, COLOUR_DARK_GREEN),
778  EndContainer(),
780  NWidget(WWT_IMGBTN, COLOUR_DARK_GREEN, WID_ROT_ROAD_X),
781  SetFill(0, 1), SetMinimalSize(22, 22), SetDataTip(SPR_IMG_ROAD_X_DIR, STR_ROAD_TOOLBAR_TOOLTIP_BUILD_ROAD_SECTION),
782  NWidget(WWT_IMGBTN, COLOUR_DARK_GREEN, WID_ROT_ROAD_Y),
783  SetFill(0, 1), SetMinimalSize(22, 22), SetDataTip(SPR_IMG_ROAD_Y_DIR, STR_ROAD_TOOLBAR_TOOLTIP_BUILD_ROAD_SECTION),
784  NWidget(WWT_IMGBTN, COLOUR_DARK_GREEN, WID_ROT_AUTOROAD),
785  SetFill(0, 1), SetMinimalSize(22, 22), SetDataTip(SPR_IMG_AUTOROAD, STR_ROAD_TOOLBAR_TOOLTIP_BUILD_AUTOROAD),
786  NWidget(WWT_IMGBTN, COLOUR_DARK_GREEN, WID_ROT_DEMOLISH),
787  SetFill(0, 1), SetMinimalSize(22, 22), SetDataTip(SPR_IMG_DYNAMITE, STR_TOOLTIP_DEMOLISH_BUILDINGS_ETC),
788  NWidget(WWT_IMGBTN, COLOUR_DARK_GREEN, WID_ROT_DEPOT),
789  SetFill(0, 1), SetMinimalSize(22, 22), SetDataTip(SPR_IMG_ROAD_DEPOT, STR_ROAD_TOOLBAR_TOOLTIP_BUILD_ROAD_VEHICLE_DEPOT),
790  NWidget(WWT_IMGBTN, COLOUR_DARK_GREEN, WID_ROT_BUS_STATION),
791  SetFill(0, 1), SetMinimalSize(22, 22), SetDataTip(SPR_IMG_BUS_STATION, STR_ROAD_TOOLBAR_TOOLTIP_BUILD_BUS_STATION),
792  NWidget(WWT_IMGBTN, COLOUR_DARK_GREEN, WID_ROT_TRUCK_STATION),
793  SetFill(0, 1), SetMinimalSize(22, 22), SetDataTip(SPR_IMG_TRUCK_BAY, STR_ROAD_TOOLBAR_TOOLTIP_BUILD_TRUCK_LOADING_BAY),
794  NWidget(WWT_PANEL, COLOUR_DARK_GREEN, -1), SetMinimalSize(0, 22), SetFill(1, 1), EndContainer(),
795  NWidget(WWT_IMGBTN, COLOUR_DARK_GREEN, WID_ROT_ONE_WAY),
796  SetFill(0, 1), SetMinimalSize(22, 22), SetDataTip(SPR_IMG_ROAD_ONE_WAY, STR_ROAD_TOOLBAR_TOOLTIP_TOGGLE_ONE_WAY_ROAD),
797  NWidget(WWT_IMGBTN, COLOUR_DARK_GREEN, WID_ROT_BUILD_BRIDGE),
798  SetFill(0, 1), SetMinimalSize(43, 22), SetDataTip(SPR_IMG_BRIDGE, STR_ROAD_TOOLBAR_TOOLTIP_BUILD_ROAD_BRIDGE),
799  NWidget(WWT_IMGBTN, COLOUR_DARK_GREEN, WID_ROT_BUILD_TUNNEL),
800  SetFill(0, 1), SetMinimalSize(22, 22), SetDataTip(SPR_IMG_ROAD_TUNNEL, STR_ROAD_TOOLBAR_TOOLTIP_BUILD_ROAD_TUNNEL),
801  NWidget(WWT_IMGBTN, COLOUR_DARK_GREEN, WID_ROT_REMOVE),
802  SetFill(0, 1), SetMinimalSize(22, 22), SetDataTip(SPR_IMG_REMOVE, STR_ROAD_TOOLBAR_TOOLTIP_TOGGLE_BUILD_REMOVE_FOR_ROAD),
803  NWidget(WWT_IMGBTN, COLOUR_DARK_GREEN, WID_ROT_CONVERT_ROAD),
804  SetFill(0, 1), SetMinimalSize(22, 22), SetDataTip(SPR_IMG_CONVERT_ROAD, STR_ROAD_TOOLBAR_TOOLTIP_CONVERT_ROAD),
805  EndContainer(),
806 };
807 
808 static WindowDesc _build_road_desc(
809  WDP_ALIGN_TOOLBAR, "toolbar_road", 0, 0,
812  _nested_build_road_widgets, lengthof(_nested_build_road_widgets),
813  &BuildRoadToolbarWindow::road_hotkeys
814 );
815 
816 static const NWidgetPart _nested_build_tramway_widgets[] = {
818  NWidget(WWT_CLOSEBOX, COLOUR_DARK_GREEN),
819  NWidget(WWT_CAPTION, COLOUR_DARK_GREEN, WID_ROT_CAPTION), SetDataTip(STR_WHITE_STRING, STR_TOOLTIP_WINDOW_TITLE_DRAG_THIS),
820  NWidget(WWT_STICKYBOX, COLOUR_DARK_GREEN),
821  EndContainer(),
823  NWidget(WWT_IMGBTN, COLOUR_DARK_GREEN, WID_ROT_ROAD_X),
824  SetFill(0, 1), SetMinimalSize(22, 22), SetDataTip(SPR_IMG_TRAMWAY_X_DIR, STR_ROAD_TOOLBAR_TOOLTIP_BUILD_TRAMWAY_SECTION),
825  NWidget(WWT_IMGBTN, COLOUR_DARK_GREEN, WID_ROT_ROAD_Y),
826  SetFill(0, 1), SetMinimalSize(22, 22), SetDataTip(SPR_IMG_TRAMWAY_Y_DIR, STR_ROAD_TOOLBAR_TOOLTIP_BUILD_TRAMWAY_SECTION),
827  NWidget(WWT_IMGBTN, COLOUR_DARK_GREEN, WID_ROT_AUTOROAD),
828  SetFill(0, 1), SetMinimalSize(22, 22), SetDataTip(SPR_IMG_AUTOTRAM, STR_ROAD_TOOLBAR_TOOLTIP_BUILD_AUTOTRAM),
829  NWidget(WWT_IMGBTN, COLOUR_DARK_GREEN, WID_ROT_DEMOLISH),
830  SetFill(0, 1), SetMinimalSize(22, 22), SetDataTip(SPR_IMG_DYNAMITE, STR_TOOLTIP_DEMOLISH_BUILDINGS_ETC),
831  NWidget(WWT_IMGBTN, COLOUR_DARK_GREEN, WID_ROT_DEPOT),
832  SetFill(0, 1), SetMinimalSize(22, 22), SetDataTip(SPR_IMG_ROAD_DEPOT, STR_ROAD_TOOLBAR_TOOLTIP_BUILD_TRAM_VEHICLE_DEPOT),
833  NWidget(WWT_IMGBTN, COLOUR_DARK_GREEN, WID_ROT_BUS_STATION),
834  SetFill(0, 1), SetMinimalSize(22, 22), SetDataTip(SPR_IMG_BUS_STATION, STR_ROAD_TOOLBAR_TOOLTIP_BUILD_PASSENGER_TRAM_STATION),
835  NWidget(WWT_IMGBTN, COLOUR_DARK_GREEN, WID_ROT_TRUCK_STATION),
836  SetFill(0, 1), SetMinimalSize(22, 22), SetDataTip(SPR_IMG_TRUCK_BAY, STR_ROAD_TOOLBAR_TOOLTIP_BUILD_CARGO_TRAM_STATION),
837  NWidget(WWT_PANEL, COLOUR_DARK_GREEN, -1), SetMinimalSize(0, 22), SetFill(1, 1), EndContainer(),
838  NWidget(WWT_IMGBTN, COLOUR_DARK_GREEN, WID_ROT_BUILD_BRIDGE),
839  SetFill(0, 1), SetMinimalSize(43, 22), SetDataTip(SPR_IMG_BRIDGE, STR_ROAD_TOOLBAR_TOOLTIP_BUILD_TRAMWAY_BRIDGE),
840  NWidget(WWT_IMGBTN, COLOUR_DARK_GREEN, WID_ROT_BUILD_TUNNEL),
841  SetFill(0, 1), SetMinimalSize(22, 22), SetDataTip(SPR_IMG_ROAD_TUNNEL, STR_ROAD_TOOLBAR_TOOLTIP_BUILD_TRAMWAY_TUNNEL),
842  NWidget(WWT_IMGBTN, COLOUR_DARK_GREEN, WID_ROT_REMOVE),
843  SetFill(0, 1), SetMinimalSize(22, 22), SetDataTip(SPR_IMG_REMOVE, STR_ROAD_TOOLBAR_TOOLTIP_TOGGLE_BUILD_REMOVE_FOR_TRAMWAYS),
844  NWidget(WWT_IMGBTN, COLOUR_DARK_GREEN, WID_ROT_CONVERT_ROAD),
845  SetFill(0, 1), SetMinimalSize(22, 22), SetDataTip(SPR_IMG_CONVERT_ROAD, STR_ROAD_TOOLBAR_TOOLTIP_CONVERT_TRAM),
846  EndContainer(),
847 };
848 
849 static WindowDesc _build_tramway_desc(
850  WDP_ALIGN_TOOLBAR, "toolbar_tramway", 0, 0,
853  _nested_build_tramway_widgets, lengthof(_nested_build_tramway_widgets),
854  &BuildRoadToolbarWindow::tram_hotkeys
855 );
856 
865 {
866  if (!Company::IsValidID(_local_company)) return nullptr;
867  if (!ValParamRoadType(roadtype)) return nullptr;
868 
870  _cur_roadtype = roadtype;
871 
872  return AllocateWindowDescFront<BuildRoadToolbarWindow>(RoadTypeIsRoad(_cur_roadtype) ? &_build_road_desc : &_build_tramway_desc, TRANSPORT_ROAD);
873 }
874 
875 static const NWidgetPart _nested_build_road_scen_widgets[] = {
877  NWidget(WWT_CLOSEBOX, COLOUR_DARK_GREEN),
878  NWidget(WWT_CAPTION, COLOUR_DARK_GREEN, WID_ROT_CAPTION), SetDataTip(STR_WHITE_STRING, STR_TOOLTIP_WINDOW_TITLE_DRAG_THIS),
879  NWidget(WWT_STICKYBOX, COLOUR_DARK_GREEN),
880  EndContainer(),
882  NWidget(WWT_IMGBTN, COLOUR_DARK_GREEN, WID_ROT_ROAD_X),
883  SetFill(0, 1), SetMinimalSize(22, 22), SetDataTip(SPR_IMG_ROAD_X_DIR, STR_ROAD_TOOLBAR_TOOLTIP_BUILD_ROAD_SECTION),
884  NWidget(WWT_IMGBTN, COLOUR_DARK_GREEN, WID_ROT_ROAD_Y),
885  SetFill(0, 1), SetMinimalSize(22, 22), SetDataTip(SPR_IMG_ROAD_Y_DIR, STR_ROAD_TOOLBAR_TOOLTIP_BUILD_ROAD_SECTION),
886  NWidget(WWT_IMGBTN, COLOUR_DARK_GREEN, WID_ROT_AUTOROAD),
887  SetFill(0, 1), SetMinimalSize(22, 22), SetDataTip(SPR_IMG_AUTOROAD, STR_ROAD_TOOLBAR_TOOLTIP_BUILD_AUTOROAD),
888  NWidget(WWT_IMGBTN, COLOUR_DARK_GREEN, WID_ROT_DEMOLISH),
889  SetFill(0, 1), SetMinimalSize(22, 22), SetDataTip(SPR_IMG_DYNAMITE, STR_TOOLTIP_DEMOLISH_BUILDINGS_ETC),
890  NWidget(WWT_PANEL, COLOUR_DARK_GREEN, -1), SetMinimalSize(0, 22), SetFill(1, 1), EndContainer(),
891  NWidget(WWT_IMGBTN, COLOUR_DARK_GREEN, WID_ROT_ONE_WAY),
892  SetFill(0, 1), SetMinimalSize(22, 22), SetDataTip(SPR_IMG_ROAD_ONE_WAY, STR_ROAD_TOOLBAR_TOOLTIP_TOGGLE_ONE_WAY_ROAD),
893  NWidget(WWT_IMGBTN, COLOUR_DARK_GREEN, WID_ROT_BUILD_BRIDGE),
894  SetFill(0, 1), SetMinimalSize(43, 22), SetDataTip(SPR_IMG_BRIDGE, STR_ROAD_TOOLBAR_TOOLTIP_BUILD_ROAD_BRIDGE),
895  NWidget(WWT_IMGBTN, COLOUR_DARK_GREEN, WID_ROT_BUILD_TUNNEL),
896  SetFill(0, 1), SetMinimalSize(22, 22), SetDataTip(SPR_IMG_ROAD_TUNNEL, STR_ROAD_TOOLBAR_TOOLTIP_BUILD_ROAD_TUNNEL),
897  NWidget(WWT_IMGBTN, COLOUR_DARK_GREEN, WID_ROT_REMOVE),
898  SetFill(0, 1), SetMinimalSize(22, 22), SetDataTip(SPR_IMG_REMOVE, STR_ROAD_TOOLBAR_TOOLTIP_TOGGLE_BUILD_REMOVE_FOR_ROAD),
899  NWidget(WWT_IMGBTN, COLOUR_DARK_GREEN, WID_ROT_CONVERT_ROAD),
900  SetFill(0, 1), SetMinimalSize(22, 22), SetDataTip(SPR_IMG_CONVERT_ROAD, STR_ROAD_TOOLBAR_TOOLTIP_CONVERT_ROAD),
901  EndContainer(),
902 };
903 
904 static WindowDesc _build_road_scen_desc(
905  WDP_AUTO, "toolbar_road_scen", 0, 0,
908  _nested_build_road_scen_widgets, lengthof(_nested_build_road_scen_widgets),
909  &BuildRoadToolbarWindow::road_hotkeys
910 );
911 
912 static const NWidgetPart _nested_build_tramway_scen_widgets[] = {
914  NWidget(WWT_CLOSEBOX, COLOUR_DARK_GREEN),
915  NWidget(WWT_CAPTION, COLOUR_DARK_GREEN, WID_ROT_CAPTION), SetDataTip(STR_WHITE_STRING, STR_TOOLTIP_WINDOW_TITLE_DRAG_THIS),
916  NWidget(WWT_STICKYBOX, COLOUR_DARK_GREEN),
917  EndContainer(),
919  NWidget(WWT_IMGBTN, COLOUR_DARK_GREEN, WID_ROT_ROAD_X),
920  SetFill(0, 1), SetMinimalSize(22, 22), SetDataTip(SPR_IMG_TRAMWAY_X_DIR, STR_ROAD_TOOLBAR_TOOLTIP_BUILD_TRAMWAY_SECTION),
921  NWidget(WWT_IMGBTN, COLOUR_DARK_GREEN, WID_ROT_ROAD_Y),
922  SetFill(0, 1), SetMinimalSize(22, 22), SetDataTip(SPR_IMG_TRAMWAY_Y_DIR, STR_ROAD_TOOLBAR_TOOLTIP_BUILD_TRAMWAY_SECTION),
923  NWidget(WWT_IMGBTN, COLOUR_DARK_GREEN, WID_ROT_AUTOROAD),
924  SetFill(0, 1), SetMinimalSize(22, 22), SetDataTip(SPR_IMG_AUTOTRAM, STR_ROAD_TOOLBAR_TOOLTIP_BUILD_AUTOTRAM),
925  NWidget(WWT_IMGBTN, COLOUR_DARK_GREEN, WID_ROT_DEMOLISH),
926  SetFill(0, 1), SetMinimalSize(22, 22), SetDataTip(SPR_IMG_DYNAMITE, STR_TOOLTIP_DEMOLISH_BUILDINGS_ETC),
927  NWidget(WWT_PANEL, COLOUR_DARK_GREEN, -1), SetMinimalSize(0, 22), SetFill(1, 1), EndContainer(),
928  NWidget(WWT_IMGBTN, COLOUR_DARK_GREEN, WID_ROT_BUILD_BRIDGE),
929  SetFill(0, 1), SetMinimalSize(43, 22), SetDataTip(SPR_IMG_BRIDGE, STR_ROAD_TOOLBAR_TOOLTIP_BUILD_TRAMWAY_BRIDGE),
930  NWidget(WWT_IMGBTN, COLOUR_DARK_GREEN, WID_ROT_BUILD_TUNNEL),
931  SetFill(0, 1), SetMinimalSize(22, 22), SetDataTip(SPR_IMG_ROAD_TUNNEL, STR_ROAD_TOOLBAR_TOOLTIP_BUILD_TRAMWAY_TUNNEL),
932  NWidget(WWT_IMGBTN, COLOUR_DARK_GREEN, WID_ROT_REMOVE),
933  SetFill(0, 1), SetMinimalSize(22, 22), SetDataTip(SPR_IMG_REMOVE, STR_ROAD_TOOLBAR_TOOLTIP_TOGGLE_BUILD_REMOVE_FOR_TRAMWAYS),
934  NWidget(WWT_IMGBTN, COLOUR_DARK_GREEN, WID_ROT_CONVERT_ROAD),
935  SetFill(0, 1), SetMinimalSize(22, 22), SetDataTip(SPR_IMG_CONVERT_ROAD, STR_ROAD_TOOLBAR_TOOLTIP_CONVERT_TRAM),
936  EndContainer(),
937 };
938 
939 static WindowDesc _build_tramway_scen_desc(
940  WDP_AUTO, "toolbar_tram_scen", 0, 0,
943  _nested_build_tramway_scen_widgets, lengthof(_nested_build_tramway_scen_widgets),
944  &BuildRoadToolbarWindow::tram_hotkeys
945 );
946 
952 {
954  _cur_roadtype = roadtype;
955 
956  return AllocateWindowDescFront<BuildRoadToolbarWindow>(RoadTypeIsRoad(_cur_roadtype) ? &_build_road_scen_desc : &_build_tramway_scen_desc, TRANSPORT_ROAD);
957 }
958 
961  {
962  this->CreateNestedTree();
963 
964  this->LowerWidget(_road_depot_orientation + WID_BROD_DEPOT_NE);
965  if (RoadTypeIsTram(_cur_roadtype)) {
966  this->GetWidget<NWidgetCore>(WID_BROD_CAPTION)->widget_data = STR_BUILD_DEPOT_TRAM_ORIENTATION_CAPTION;
967  for (int i = WID_BROD_DEPOT_NE; i <= WID_BROD_DEPOT_NW; i++) this->GetWidget<NWidgetCore>(i)->tool_tip = STR_BUILD_DEPOT_TRAM_ORIENTATION_SELECT_TOOLTIP;
968  }
969 
971  }
972 
973  void UpdateWidgetSize(int widget, Dimension *size, const Dimension &padding, Dimension *fill, Dimension *resize) override
974  {
975  if (!IsInsideMM(widget, WID_BROD_DEPOT_NE, WID_BROD_DEPOT_NW + 1)) return;
976 
979  }
980 
981  void DrawWidget(const Rect &r, int widget) const override
982  {
983  if (!IsInsideMM(widget, WID_BROD_DEPOT_NE, WID_BROD_DEPOT_NW + 1)) return;
984 
985  DrawPixelInfo tmp_dpi;
986  if (FillDrawPixelInfo(&tmp_dpi, r.left, r.top, r.Width(), r.Height())) {
987  DrawPixelInfo *old_dpi = _cur_dpi;
988  _cur_dpi = &tmp_dpi;
989  int x = (r.Width() - ScaleSpriteTrad(64)) / 2 + ScaleSpriteTrad(31);
990  int y = (r.Height() + ScaleSpriteTrad(48)) / 2 - ScaleSpriteTrad(31);
991  DrawRoadDepotSprite(x, y, (DiagDirection)(widget - WID_BROD_DEPOT_NE + DIAGDIR_NE), _cur_roadtype);
992  _cur_dpi = old_dpi;
993  }
994  }
995 
996  void OnClick(Point pt, int widget, int click_count) override
997  {
998  switch (widget) {
999  case WID_BROD_DEPOT_NW:
1000  case WID_BROD_DEPOT_NE:
1001  case WID_BROD_DEPOT_SW:
1002  case WID_BROD_DEPOT_SE:
1003  this->RaiseWidget(_road_depot_orientation + WID_BROD_DEPOT_NE);
1004  _road_depot_orientation = (DiagDirection)(widget - WID_BROD_DEPOT_NE);
1005  this->LowerWidget(_road_depot_orientation + WID_BROD_DEPOT_NE);
1006  if (_settings_client.sound.click_beep) SndPlayFx(SND_15_BEEP);
1007  this->SetDirty();
1008  break;
1009 
1010  default:
1011  break;
1012  }
1013  }
1014 };
1015 
1016 static const NWidgetPart _nested_build_road_depot_widgets[] = {
1018  NWidget(WWT_CLOSEBOX, COLOUR_DARK_GREEN),
1019  NWidget(WWT_CAPTION, COLOUR_DARK_GREEN, WID_BROD_CAPTION), SetDataTip(STR_BUILD_DEPOT_ROAD_ORIENTATION_CAPTION, STR_TOOLTIP_WINDOW_TITLE_DRAG_THIS),
1020  EndContainer(),
1021  NWidget(WWT_PANEL, COLOUR_DARK_GREEN),
1023  NWidget(NWID_SPACER), SetFill(1, 0),
1024  NWidget(NWID_VERTICAL), SetPIP(0, 2, 0),
1025  NWidget(NWID_HORIZONTAL_LTR), SetPIP(0, 2, 0),
1026  NWidget(WWT_PANEL, COLOUR_GREY, WID_BROD_DEPOT_NW), SetMinimalSize(66, 50), SetFill(0, 0), SetDataTip(0x0, STR_BUILD_DEPOT_ROAD_ORIENTATION_SELECT_TOOLTIP), EndContainer(),
1027  NWidget(WWT_PANEL, COLOUR_GREY, WID_BROD_DEPOT_NE), SetMinimalSize(66, 50), SetFill(0, 0), SetDataTip(0x0, STR_BUILD_DEPOT_ROAD_ORIENTATION_SELECT_TOOLTIP), EndContainer(),
1028  EndContainer(),
1029  NWidget(NWID_HORIZONTAL_LTR), SetPIP(0, 2, 0),
1030  NWidget(WWT_PANEL, COLOUR_GREY, WID_BROD_DEPOT_SW), SetMinimalSize(66, 50), SetFill(0, 0), SetDataTip(0x0, STR_BUILD_DEPOT_ROAD_ORIENTATION_SELECT_TOOLTIP), EndContainer(),
1031  NWidget(WWT_PANEL, COLOUR_GREY, WID_BROD_DEPOT_SE), SetMinimalSize(66, 50), SetFill(0, 0), SetDataTip(0x0, STR_BUILD_DEPOT_ROAD_ORIENTATION_SELECT_TOOLTIP), EndContainer(),
1032  EndContainer(),
1033  EndContainer(),
1034  NWidget(NWID_SPACER), SetFill(1, 0),
1035  EndContainer(),
1036  EndContainer(),
1037 };
1038 
1039 static WindowDesc _build_road_depot_desc(
1040  WDP_AUTO, nullptr, 0, 0,
1043  _nested_build_road_depot_widgets, lengthof(_nested_build_road_depot_widgets)
1044 );
1045 
1046 static void ShowRoadDepotPicker(Window *parent)
1047 {
1048  new BuildRoadDepotWindow(&_build_road_depot_desc, parent);
1049 }
1050 
1053  {
1054  this->CreateNestedTree();
1055 
1056  /* Trams don't have non-drivethrough stations */
1057  if (RoadTypeIsTram(_cur_roadtype) && _road_station_picker_orientation < DIAGDIR_END) {
1058  _road_station_picker_orientation = DIAGDIR_END;
1059  }
1060  const RoadTypeInfo *rti = GetRoadTypeInfo(_cur_roadtype);
1061  this->GetWidget<NWidgetCore>(WID_BROS_CAPTION)->widget_data = rti->strings.picker_title[rs];
1062 
1063  for (uint i = RoadTypeIsTram(_cur_roadtype) ? WID_BROS_STATION_X : WID_BROS_STATION_NE; i < WID_BROS_LT_OFF; i++) {
1064  this->GetWidget<NWidgetCore>(i)->tool_tip = rti->strings.picker_tooltip[rs];
1065  }
1066 
1067  this->LowerWidget(_road_station_picker_orientation + WID_BROS_STATION_NE);
1068  this->LowerWidget(_settings_client.gui.station_show_coverage + WID_BROS_LT_OFF);
1069 
1071 
1073  }
1074 
1075  void Close() override
1076  {
1078  this->PickerWindowBase::Close();
1079  }
1080 
1081  void OnPaint() override
1082  {
1083  this->DrawWidgets();
1084 
1087  SetTileSelectBigSize(-rad, -rad, 2 * rad, 2 * rad);
1088  } else {
1089  SetTileSelectSize(1, 1);
1090  }
1091 
1092  /* 'Accepts' and 'Supplies' texts. */
1094  Rect r = this->GetWidget<NWidgetBase>(WID_BROS_ACCEPTANCE)->GetCurrentRect();
1096  top = DrawStationCoverageAreaText(r.left, r.right, top, sct, rad, false) + WidgetDimensions::scaled.vsep_normal;
1097  top = DrawStationCoverageAreaText(r.left, r.right, top, sct, rad, true) + WidgetDimensions::scaled.vsep_normal;
1098  /* Resize background if the window is too small.
1099  * Never make the window smaller to avoid oscillating if the size change affects the acceptance.
1100  * (This is the case, if making the window bigger moves the mouse into the window.) */
1101  if (top > r.bottom) {
1102  ResizeWindow(this, 0, top - r.bottom, false);
1103  }
1104  }
1105 
1106  void UpdateWidgetSize(int widget, Dimension *size, const Dimension &padding, Dimension *fill, Dimension *resize) override
1107  {
1108  if (!IsInsideMM(widget, WID_BROS_STATION_NE, WID_BROS_STATION_Y + 1)) return;
1109 
1112  }
1113 
1114  void DrawWidget(const Rect &r, int widget) const override
1115  {
1116  if (!IsInsideMM(widget, WID_BROS_STATION_NE, WID_BROS_STATION_Y + 1)) return;
1117 
1118  StationType st = (this->window_class == WC_BUS_STATION) ? STATION_BUS : STATION_TRUCK;
1119 
1120  DrawPixelInfo tmp_dpi;
1121  if (FillDrawPixelInfo(&tmp_dpi, r.left, r.top, r.Width(), r.Height())) {
1122  DrawPixelInfo *old_dpi = _cur_dpi;
1123  _cur_dpi = &tmp_dpi;
1124  int x = (r.Width() - ScaleSpriteTrad(64)) / 2 + ScaleSpriteTrad(31);
1125  int y = (r.Height() + ScaleSpriteTrad(48)) / 2 - ScaleSpriteTrad(31);
1126  StationPickerDrawSprite(x, y, st, INVALID_RAILTYPE, _cur_roadtype, widget - WID_BROS_STATION_NE);
1127  _cur_dpi = old_dpi;
1128  }
1129  }
1130 
1131  void OnClick(Point pt, int widget, int click_count) override
1132  {
1133  switch (widget) {
1134  case WID_BROS_STATION_NE:
1135  case WID_BROS_STATION_SE:
1136  case WID_BROS_STATION_SW:
1137  case WID_BROS_STATION_NW:
1138  case WID_BROS_STATION_X:
1139  case WID_BROS_STATION_Y:
1140  this->RaiseWidget(_road_station_picker_orientation + WID_BROS_STATION_NE);
1141  _road_station_picker_orientation = (DiagDirection)(widget - WID_BROS_STATION_NE);
1142  this->LowerWidget(_road_station_picker_orientation + WID_BROS_STATION_NE);
1143  if (_settings_client.sound.click_beep) SndPlayFx(SND_15_BEEP);
1144  this->SetDirty();
1146  break;
1147 
1148  case WID_BROS_LT_OFF:
1149  case WID_BROS_LT_ON:
1153  if (_settings_client.sound.click_beep) SndPlayFx(SND_15_BEEP);
1154  this->SetDirty();
1155  SetViewportCatchmentStation(nullptr, true);
1156  break;
1157 
1158  default:
1159  break;
1160  }
1161  }
1162 
1163  void OnRealtimeTick(uint delta_ms) override
1164  {
1166  }
1167 };
1168 
1172  NWidget(WWT_CLOSEBOX, COLOUR_DARK_GREEN),
1173  NWidget(WWT_CAPTION, COLOUR_DARK_GREEN, WID_BROS_CAPTION),
1174  EndContainer(),
1175  NWidget(WWT_PANEL, COLOUR_DARK_GREEN, WID_BROS_BACKGROUND),
1177  NWidget(NWID_SPACER), SetFill(1, 0),
1178  NWidget(NWID_VERTICAL), SetPIP(0, 2, 0),
1179  NWidget(NWID_HORIZONTAL), SetPIP(0, 2, 0),
1180  NWidget(WWT_PANEL, COLOUR_GREY, WID_BROS_STATION_NW), SetMinimalSize(66, 50), SetFill(0, 0), EndContainer(),
1181  NWidget(WWT_PANEL, COLOUR_GREY, WID_BROS_STATION_NE), SetMinimalSize(66, 50), SetFill(0, 0), EndContainer(),
1182  NWidget(WWT_PANEL, COLOUR_GREY, WID_BROS_STATION_X), SetMinimalSize(66, 50), SetFill(0, 0), EndContainer(),
1183  EndContainer(),
1184  NWidget(NWID_HORIZONTAL), SetPIP(0, 2, 0),
1185  NWidget(WWT_PANEL, COLOUR_GREY, WID_BROS_STATION_SW), SetMinimalSize(66, 50), SetFill(0, 0), EndContainer(),
1186  NWidget(WWT_PANEL, COLOUR_GREY, WID_BROS_STATION_SE), SetMinimalSize(66, 50), SetFill(0, 0), EndContainer(),
1187  NWidget(WWT_PANEL, COLOUR_GREY, WID_BROS_STATION_Y), SetMinimalSize(66, 50), SetFill(0, 0), EndContainer(),
1188  EndContainer(),
1189  EndContainer(),
1190  NWidget(NWID_SPACER), SetFill(1, 0),
1191  EndContainer(),
1192  NWidget(WWT_LABEL, COLOUR_DARK_GREEN, WID_BROS_INFO), SetPadding(WidgetDimensions::unscaled.framerect), SetDataTip(STR_STATION_BUILD_COVERAGE_AREA_TITLE, STR_NULL), SetFill(1, 0),
1194  NWidget(NWID_SPACER), SetFill(1, 0),
1195  NWidget(WWT_TEXTBTN, COLOUR_GREY, WID_BROS_LT_OFF), SetMinimalSize(60, 12),
1196  SetDataTip(STR_STATION_BUILD_COVERAGE_OFF, STR_STATION_BUILD_COVERAGE_AREA_OFF_TOOLTIP),
1197  NWidget(WWT_TEXTBTN, COLOUR_GREY, WID_BROS_LT_ON), SetMinimalSize(60, 12),
1198  SetDataTip(STR_STATION_BUILD_COVERAGE_ON, STR_STATION_BUILD_COVERAGE_AREA_ON_TOOLTIP),
1199  NWidget(NWID_SPACER), SetFill(1, 0),
1200  EndContainer(),
1201  NWidget(WWT_EMPTY, COLOUR_DARK_GREEN, WID_BROS_ACCEPTANCE), SetPadding(WidgetDimensions::unscaled.framerect), SetResize(0, 1),
1202  EndContainer(),
1203 };
1204 
1205 static WindowDesc _road_station_picker_desc(
1206  WDP_AUTO, nullptr, 0, 0,
1210 );
1211 
1215  NWidget(WWT_CLOSEBOX, COLOUR_DARK_GREEN),
1216  NWidget(WWT_CAPTION, COLOUR_DARK_GREEN, WID_BROS_CAPTION),
1217  EndContainer(),
1218  NWidget(WWT_PANEL, COLOUR_DARK_GREEN, WID_BROS_BACKGROUND),
1220  NWidget(NWID_SPACER), SetFill(1, 0),
1221  NWidget(NWID_VERTICAL), SetPIP(0, 2, 0),
1222  NWidget(NWID_HORIZONTAL), SetPIP(0, 2, 0),
1223  NWidget(WWT_PANEL, COLOUR_GREY, WID_BROS_STATION_X), SetMinimalSize(66, 50), SetFill(0, 0), EndContainer(),
1224  NWidget(WWT_PANEL, COLOUR_GREY, WID_BROS_STATION_Y), SetMinimalSize(66, 50), SetFill(0, 0), EndContainer(),
1225  EndContainer(),
1226  EndContainer(),
1227  NWidget(NWID_SPACER), SetFill(1, 0),
1228  EndContainer(),
1229  NWidget(WWT_LABEL, COLOUR_DARK_GREEN, WID_BROS_INFO), SetPadding(WidgetDimensions::unscaled.framerect), SetMinimalSize(140, 14), SetDataTip(STR_STATION_BUILD_COVERAGE_AREA_TITLE, STR_NULL), SetFill(1, 0),
1231  NWidget(NWID_SPACER), SetFill(1, 0),
1232  NWidget(WWT_TEXTBTN, COLOUR_GREY, WID_BROS_LT_OFF), SetMinimalSize(60, 12),
1233  SetDataTip(STR_STATION_BUILD_COVERAGE_OFF, STR_STATION_BUILD_COVERAGE_AREA_OFF_TOOLTIP),
1234  NWidget(WWT_TEXTBTN, COLOUR_GREY, WID_BROS_LT_ON), SetMinimalSize(60, 12),
1235  SetDataTip(STR_STATION_BUILD_COVERAGE_ON, STR_STATION_BUILD_COVERAGE_AREA_ON_TOOLTIP),
1236  NWidget(NWID_SPACER), SetFill(1, 0),
1237  EndContainer(),
1238  NWidget(WWT_EMPTY, COLOUR_DARK_GREEN, WID_BROS_ACCEPTANCE), SetPadding(WidgetDimensions::unscaled.framerect), SetResize(0, 1),
1239  EndContainer(),
1240 };
1241 
1242 static WindowDesc _tram_station_picker_desc(
1243  WDP_AUTO, nullptr, 0, 0,
1247 );
1248 
1249 static void ShowRVStationPicker(Window *parent, RoadStopType rs)
1250 {
1251  new BuildRoadStationWindow(RoadTypeIsRoad(_cur_roadtype) ? &_road_station_picker_desc : &_tram_station_picker_desc, parent, rs);
1252 }
1253 
1254 void InitializeRoadGui()
1255 {
1256  _road_depot_orientation = DIAGDIR_NW;
1257  _road_station_picker_orientation = DIAGDIR_NW;
1258 }
1259 
1264 {
1266  if (w != nullptr) w->ModifyRoadType(_cur_roadtype);
1267 }
1268 
1269 DropDownList GetRoadTypeDropDownList(RoadTramTypes rtts, bool for_replacement, bool all_option)
1270 {
1271  RoadTypes used_roadtypes;
1272  RoadTypes avail_roadtypes;
1273 
1274  const Company *c = Company::Get(_local_company);
1275 
1276  /* Find the used roadtypes. */
1277  if (for_replacement) {
1278  avail_roadtypes = GetCompanyRoadTypes(c->index, false);
1279  used_roadtypes = GetRoadTypes(false);
1280  } else {
1281  avail_roadtypes = c->avail_roadtypes;
1282  used_roadtypes = GetRoadTypes(true);
1283  }
1284 
1285  /* Filter listed road types */
1286  if (!HasBit(rtts, RTT_ROAD)) used_roadtypes &= _roadtypes_type;
1287  if (!HasBit(rtts, RTT_TRAM)) used_roadtypes &= ~_roadtypes_type;
1288 
1289  DropDownList list;
1290 
1291  if (all_option) {
1292  list.emplace_back(new DropDownListStringItem(STR_REPLACE_ALL_ROADTYPE, INVALID_ROADTYPE, false));
1293  }
1294 
1295  Dimension d = { 0, 0 };
1296  /* Get largest icon size, to ensure text is aligned on each menu item. */
1297  if (!for_replacement) {
1298  for (const auto &rt : _sorted_roadtypes) {
1299  if (!HasBit(used_roadtypes, rt)) continue;
1300  const RoadTypeInfo *rti = GetRoadTypeInfo(rt);
1302  }
1303  }
1304 
1305  for (const auto &rt : _sorted_roadtypes) {
1306  /* If it's not used ever, don't show it to the user. */
1307  if (!HasBit(used_roadtypes, rt)) continue;
1308 
1309  const RoadTypeInfo *rti = GetRoadTypeInfo(rt);
1310 
1312  if (for_replacement) {
1313  item = new DropDownListParamStringItem(rti->strings.replace_text, rt, !HasBit(avail_roadtypes, rt));
1314  } else {
1315  StringID str = rti->max_speed > 0 ? STR_TOOLBAR_RAILTYPE_VELOCITY : STR_JUST_STRING;
1316  DropDownListIconItem *iconitem = new DropDownListIconItem(rti->gui_sprites.build_x_road, PAL_NONE, str, rt, !HasBit(avail_roadtypes, rt));
1317  iconitem->SetDimension(d);
1318  item = iconitem;
1319  }
1320  item->SetParam(0, rti->strings.menu_text);
1321  item->SetParam(1, rti->max_speed / 2);
1322  list.emplace_back(item);
1323  }
1324 
1325  if (list.size() == 0) {
1326  /* Empty dropdowns are not allowed */
1327  list.emplace_back(new DropDownListStringItem(STR_NONE, INVALID_ROADTYPE, true));
1328  }
1329 
1330  return list;
1331 }
1332 
1333 DropDownList GetScenRoadTypeDropDownList(RoadTramTypes rtts)
1334 {
1335  RoadTypes avail_roadtypes = GetRoadTypes(false);
1336  avail_roadtypes = AddDateIntroducedRoadTypes(avail_roadtypes, _date);
1337  RoadTypes used_roadtypes = GetRoadTypes(true);
1338 
1339  /* Filter listed road types */
1340  if (!HasBit(rtts, RTT_ROAD)) used_roadtypes &= _roadtypes_type;
1341  if (!HasBit(rtts, RTT_TRAM)) used_roadtypes &= ~_roadtypes_type;
1342 
1343  DropDownList list;
1344 
1345  /* If it's not used ever, don't show it to the user. */
1346  Dimension d = { 0, 0 };
1347  for (const auto &rt : _sorted_roadtypes) {
1348  if (!HasBit(used_roadtypes, rt)) continue;
1349  const RoadTypeInfo *rti = GetRoadTypeInfo(rt);
1351  }
1352  for (const auto &rt : _sorted_roadtypes) {
1353  if (!HasBit(used_roadtypes, rt)) continue;
1354 
1355  const RoadTypeInfo *rti = GetRoadTypeInfo(rt);
1356 
1357  StringID str = rti->max_speed > 0 ? STR_TOOLBAR_RAILTYPE_VELOCITY : STR_JUST_STRING;
1358  DropDownListIconItem *item = new DropDownListIconItem(rti->gui_sprites.build_x_road, PAL_NONE, str, rt, !HasBit(avail_roadtypes, rt));
1359  item->SetDimension(d);
1360  item->SetParam(0, rti->strings.menu_text);
1361  item->SetParam(1, rti->max_speed / 2);
1362  list.emplace_back(item);
1363  }
1364 
1365  if (list.size() == 0) {
1366  /* Empty dropdowns are not allowed */
1367  list.emplace_back(new DropDownListStringItem(STR_NONE, -1, true));
1368  }
1369 
1370  return list;
1371 }
_nested_tram_station_picker_widgets
static const NWidgetPart _nested_tram_station_picker_widgets[]
Widget definition of the build tram station window.
Definition: road_gui.cpp:1213
ES_HANDLED
@ ES_HANDLED
The passed event is handled.
Definition: window_type.h:720
RoadTypeInfo::toolbar_caption
StringID toolbar_caption
Caption in the construction toolbar GUI for this rail type.
Definition: road.h:102
SetTileSelectSize
void SetTileSelectSize(int w, int h)
Highlight w by h tiles at the cursor.
Definition: viewport.cpp:2483
PickerWindowBase::Close
void Close() override
Hide the window and all its child windows, and mark them for a later deletion.
Definition: window.cpp:3563
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:53
CA_UNMODIFIED
@ CA_UNMODIFIED
Catchment for all stations with "modified catchment" disabled.
Definition: station_type.h:83
WID_ROT_REMOVE
@ WID_ROT_REMOVE
Remove road.
Definition: road_widget.h:27
PlaceRoad_Bridge
static void PlaceRoad_Bridge(TileIndex tile, Window *w)
Callback to start placing a bridge.
Definition: road_gui.cpp:69
RoadTypeInfo
Definition: road.h:76
IsInsideMM
static 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:230
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:127
ROADTYPE_END
@ ROADTYPE_END
Used for iterations.
Definition: road_type.h:26
RoadTypeInfo::err_build_road
StringID err_build_road
Building a normal piece of road.
Definition: road.h:108
Rect::Height
int Height() const
Get height of Rect.
Definition: geometry_type.hpp:85
GUISettings::station_show_coverage
bool station_show_coverage
whether to highlight coverage area
Definition: settings_type.h:166
Pool::PoolItem<&_company_pool >::Get
static Titem * Get(size_t index)
Returns Titem with given index.
Definition: pool_type.hpp:337
WC_BUILD_TOOLBAR
@ WC_BUILD_TOOLBAR
Build toolbar; Window numbers:
Definition: window_type.h:66
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:1081
TileOffsByDiagDir
static TileIndexDiff TileOffsByDiagDir(DiagDirection dir)
Convert a DiagDirection to a TileIndexDiff.
Definition: map_func.h:341
GameSettings::station
StationSettings station
settings related to station management
Definition: settings_type.h:598
DropDownListParamStringItem
String list item with parameters.
Definition: dropdown_type.h:56
RoadTypeInfo::menu_text
StringID menu_text
Name of this rail type in the main toolbar dropdown.
Definition: road.h:103
HotkeyList
List of hotkeys for a window.
Definition: hotkeys.h:40
VpSetPresizeRange
void VpSetPresizeRange(TileIndex from, TileIndex to)
Highlights all tiles between a set of two tiles.
Definition: viewport.cpp:2720
CcRoadStop
void CcRoadStop(Commands cmd, const CommandCost &result, TileIndex tile, uint8 width, uint8 length, RoadStopType, bool is_drive_through, DiagDirection dir, RoadType, StationID, bool)
Command callback for building road stops.
Definition: road_gui.cpp:140
BuildRoadStationWindow::UpdateWidgetSize
void UpdateWidgetSize(int widget, Dimension *size, const Dimension &padding, Dimension *fill, Dimension *resize) override
Update size and resize step of a widget in the window.
Definition: road_gui.cpp:1106
RoadTypeInfo::build_y_road
SpriteID build_y_road
button for building single rail in Y direction
Definition: road.h:84
RoadStopType
RoadStopType
Types of RoadStops.
Definition: station_type.h:44
ROADSTOP_TRUCK
@ ROADSTOP_TRUCK
A standard stop for trucks.
Definition: station_type.h:46
Dimension
Dimensions (a width and height) of a rectangle in 2D.
Definition: geometry_type.hpp:27
command_func.h
WWT_STICKYBOX
@ WWT_STICKYBOX
Sticky box (at top-right of a window, after WWT_DEFSIZEBOX)
Definition: widget_type.h:64
SetPadding
static NWidgetPart SetPadding(uint8 top, uint8 right, uint8 bottom, uint8 left)
Widget part function for setting additional space around a widget.
Definition: widget_type.h:1143
WDF_CONSTRUCTION
@ WDF_CONSTRUCTION
This window is used for construction; close it whenever changing company.
Definition: window_gui.h:144
PlaceRoad_TruckStation
static void PlaceRoad_TruckStation(TileIndex tile)
Callback for placing a truck station.
Definition: road_gui.cpp:204
Commands
Commands
List of commands.
Definition: command_type.h:176
WID_BROS_INFO
@ WID_BROS_INFO
Station acceptance toggle.
Definition: road_widget.h:54
Company::avail_roadtypes
RoadTypes avail_roadtypes
Road types available to this company.
Definition: company_base.h:122
Window::ReInit
void ReInit(int rx=0, int ry=0)
Re-initialize a window, and optionally change its size.
Definition: window.cpp:1019
company_base.h
WidgetDimensions::unscaled
static const WidgetDimensions unscaled
Unscaled widget dimensions.
Definition: window_gui.h:67
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
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:59
Axis
Axis
Allow incrementing of DiagDirDiff variables.
Definition: direction_type.h:125
WWT_CAPTION
@ WWT_CAPTION
Window caption (window title between closebox and stickybox)
Definition: widget_type.h:59
WC_SCEN_BUILD_TOOLBAR
@ WC_SCEN_BUILD_TOOLBAR
Scenario build toolbar; Window numbers:
Definition: window_type.h:73
CheckRedrawStationCoverage
void CheckRedrawStationCoverage(const Window *w)
Check whether we need to redraw the station coverage text.
Definition: station_gui.cpp:127
WWT_IMGBTN
@ WWT_IMGBTN
(Toggle) Button with image
Definition: widget_type.h:50
DDSP_REMOVE_BUSSTOP
@ DDSP_REMOVE_BUSSTOP
Road stop removal (buses)
Definition: viewport_type.h:133
DiagDirToAxis
static Axis DiagDirToAxis(DiagDirection d)
Convert a DiagDirection to the axis.
Definition: direction_func.h:214
WWT_LABEL
@ WWT_LABEL
Centered label.
Definition: widget_type.h:55
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:99
BuildRoadToolbarWindow::OnClick
void OnClick(Point pt, int widget, int click_count) override
A click with the left mouse button has been made on the window.
Definition: road_gui.cpp:419
SetRedErrorSquare
void SetRedErrorSquare(TileIndex tile)
Set a tile to display a red error square.
Definition: viewport.cpp:2465
Window::CreateNestedTree
void CreateNestedTree(bool fill_nested=true)
Perform the first part of the initialization of a nested widget tree.
Definition: window.cpp:1775
WDP_ALIGN_TOOLBAR
@ WDP_ALIGN_TOOLBAR
Align toward the toolbar.
Definition: window_gui.h:92
WID_ROT_BUILD_TUNNEL
@ WID_ROT_BUILD_TUNNEL
Build tunnel.
Definition: road_widget.h:26
DIAGDIR_END
@ DIAGDIR_END
Used for iterations.
Definition: direction_type.h:83
WID_BROD_CAPTION
@ WID_BROD_CAPTION
Caption of the window.
Definition: road_widget.h:34
road_widget.h
Pool::PoolItem::index
Tindex index
Index of this pool item.
Definition: pool_type.hpp:235
NWID_HORIZONTAL
@ NWID_HORIZONTAL
Horizontal container.
Definition: widget_type.h:73
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:86
maxdim
Dimension maxdim(const Dimension &d1, const Dimension &d2)
Compute bounding box of both dimensions.
Definition: geometry_func.cpp:22
BuildRoadStationWindow::Close
void Close() override
Hide the window and all its child windows, and mark them for a later deletion.
Definition: road_gui.cpp:1075
FindWindowById
Window * FindWindowById(WindowClass cls, WindowNumber number)
Find a window by its class and window number.
Definition: window.cpp:1161
BuildRoadToolbarWindow::last_started_action
int last_started_action
Last started user action.
Definition: road_gui.cpp:256
NWID_HORIZONTAL_LTR
@ NWID_HORIZONTAL_LTR
Horizontal container that doesn't change the order of the widgets for RTL languages.
Definition: widget_type.h:74
HasBit
static bool HasBit(const T x, const uint8 y)
Checks if a bit in a value is set.
Definition: bitmath_func.hpp:103
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:255
TileIndex
The index/ID of a Tile.
Definition: tile_type.h:85
_ctrl_pressed
bool _ctrl_pressed
Is Ctrl pressed?
Definition: gfx.cpp:38
SND_15_BEEP
@ SND_15_BEEP
19 == 0x13 GUI button click
Definition: sound_type.h:58
RoadTypeInfo::err_remove_station
StringID err_remove_station[2]
Removing of a bus or truck station.
Definition: road.h:112
SetResize
static NWidgetPart SetResize(int16 dx, int16 dy)
Widget part function for setting the resize step.
Definition: widget_type.h:997
zoom_func.h
Window::RaiseButtons
void RaiseButtons(bool autoraise=false)
Raise the buttons of the window.
Definition: window.cpp:597
BuildRoadToolbarWindow::OnCTRLStateChange
EventState OnCTRLStateChange() override
The state of the control key has changed.
Definition: road_gui.cpp:690
DrawRoadDepotSprite
void DrawRoadDepotSprite(int x, int y, DiagDirection dir, RoadType rt)
Draw the road depot sprite.
Definition: road_cmd.cpp:1830
VPM_FIX_Y
@ VPM_FIX_Y
drag only in Y axis
Definition: viewport_type.h:91
_settings_client
ClientSettings _settings_client
The current settings for this game.
Definition: settings.cpp:53
AddDateIntroducedRoadTypes
RoadTypes AddDateIntroducedRoadTypes(RoadTypes current, Date date)
Add the road types that are to be introduced at the given date.
Definition: road.cpp:155
WID_BROS_STATION_Y
@ WID_BROS_STATION_Y
Drive-through station in y-direction.
Definition: road_widget.h:51
WWT_EMPTY
@ WWT_EMPTY
Empty widget, place holder to reserve space in widget array.
Definition: widget_type.h:46
ANIMCURSOR_DEMOLISH
static const CursorID ANIMCURSOR_DEMOLISH
704 - 707 - demolish dynamite
Definition: sprites.h:1496
GetCompanyRoadTypes
RoadTypes GetCompanyRoadTypes(CompanyID company, bool introduces)
Get the road types the given company can build.
Definition: road.cpp:188
DIAGDIR_NW
@ DIAGDIR_NW
Northwest.
Definition: direction_type.h:82
WindowNumber
int32 WindowNumber
Number to differentiate different windows of the same class.
Definition: window_type.h:713
BuildRoadToolbarWindow::UpdateOptionWidgetStatus
void UpdateOptionWidgetStatus(RoadToolbarWidgets clicked_widget)
Update the remove button lowered state of the road toolbar.
Definition: road_gui.cpp:370
RoadTypeInfo::tunnel
CursorID tunnel
Cursor for building a tunnel.
Definition: road.h:96
RoadTypeInfo::replace_text
StringID replace_text
Text used in the autoreplace GUI.
Definition: road.h:105
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
WID_BROS_LT_ON
@ WID_BROS_LT_ON
Turn on area highlight.
Definition: road_widget.h:53
BuildRoadToolbarWindow::OnPlacePresize
void OnPlacePresize(Point pt, TileIndex tile) override
The user moves over the map when a tile highlight mode has been set when the special mouse mode has b...
Definition: road_gui.cpp:684
RoadTypeInfo::err_remove_road
StringID err_remove_road
Removing a normal piece of road.
Definition: road.h:109
Window::OnHotkey
virtual EventState OnHotkey(int hotkey)
A hotkey has been pressed.
Definition: window.cpp:634
BuildRoadStationWindow::OnClick
void OnClick(Point pt, int widget, int click_count) override
A click with the left mouse button has been made on the window.
Definition: road_gui.cpp:1131
RoadTypeInfo::depot
CursorID depot
Cursor for building a depot.
Definition: road.h:95
SetDParam
static void SetDParam(uint n, uint64 v)
Set a string parameter v at index n in the global string parameter array.
Definition: strings_func.h:196
NWidgetPart
Partial widget specification to allow NWidgets to be written nested.
Definition: widget_type.h:975
INVALID_ROADTYPE
@ INVALID_ROADTYPE
flag for invalid roadtype
Definition: road_type.h:27
SetDataTip
static NWidgetPart SetDataTip(uint32 data, StringID tip)
Widget part function for setting the data and tooltip.
Definition: widget_type.h:1111
RoadTypeInfo::road_nwse
CursorID road_nwse
Cursor for building rail in Y direction.
Definition: road.h:93
RoadTypeInfo::road_swne
CursorID road_swne
Cursor for building rail in X direction.
Definition: road.h:92
CommandCost::Succeeded
bool Succeeded() const
Did this command succeed?
Definition: command_type.h:151
BuildRoadToolbarWindow::OnPlaceObjectAbort
void OnPlaceObjectAbort() override
The user cancelled a tile highlight mode that has been set.
Definition: road_gui.cpp:565
DiagDirToRoadBits
static RoadBits DiagDirToRoadBits(DiagDirection d)
Create the road-part which belongs to the given DiagDirection.
Definition: road_func.h:96
Window::OnPlaceMouseUp
virtual void OnPlaceMouseUp(ViewportPlaceMethod select_method, ViewportDragDropSelectionProcess select_proc, Point pt, TileIndex start_tile, TileIndex end_tile)
The user has dragged over the map when the tile highlight mode has been set.
Definition: window_gui.h:726
DDSP_PLACE_ROAD_X_DIR
@ DDSP_PLACE_ROAD_X_DIR
Road placement (X axis)
Definition: viewport_type.h:128
BuildRoadToolbarWindow::SetStringParameters
void SetStringParameters(int widget) const override
Initialize string parameters for a widget.
Definition: road_gui.cpp:352
ToggleRoadButton_Remove
static void ToggleRoadButton_Remove(Window *w)
Toggles state of the Remove button of Build road toolbar.
Definition: road_gui.cpp:224
WindowDesc
High level window description.
Definition: window_gui.h:102
StationType
StationType
Station types.
Definition: station_type.h:32
window_gui.h
BuildRoadToolbarWindow::OnPlaceDrag
void OnPlaceDrag(ViewportPlaceMethod select_method, ViewportDragDropSelectionProcess select_proc, Point pt) override
The user is dragging over the map when the tile highlight mode has been set.
Definition: road_gui.cpp:585
GetRoadBits
static RoadBits GetRoadBits(TileIndex t, RoadTramType rtt)
Get the present road bits for a specific road type.
Definition: road_map.h:128
BuildRoadDepotWindow::UpdateWidgetSize
void UpdateWidgetSize(int widget, Dimension *size, const Dimension &padding, Dimension *fill, Dimension *resize) override
Update size and resize step of a widget in the window.
Definition: road_gui.cpp:973
BuildRoadToolbarWindow::OnInvalidateData
void OnInvalidateData(int data=0, bool gui_scope=true) override
Some data on this window has become invalid.
Definition: road_gui.cpp:287
_roadtypes_type
RoadTypes _roadtypes_type
Bitmap of road/tram types.
Definition: road_cmd.cpp:60
WDP_AUTO
@ WDP_AUTO
Find a place automatically.
Definition: window_gui.h:90
SCT_PASSENGERS_ONLY
@ SCT_PASSENGERS_ONLY
Draw only passenger class cargoes.
Definition: station_gui.h:22
IsBridgeTile
static bool IsBridgeTile(TileIndex t)
checks if there is a bridge on this tile
Definition: bridge_map.h:35
Window::resize
ResizeInfo resize
Resize information.
Definition: window_gui.h:251
CommandCost
Common return value for all commands.
Definition: command_type.h:24
_date
Date _date
Current date in days (day counter)
Definition: date.cpp:28
tilehighlight_func.h
ClientSettings::sound
SoundSettings sound
sound effect settings
Definition: settings_type.h:607
BuildRoadDepotWindow::OnClick
void OnClick(Point pt, int widget, int click_count) override
A click with the left mouse button has been made on the window.
Definition: road_gui.cpp:996
Window::InitNested
void InitNested(WindowNumber number=0)
Perform complete initialization of the Window with nested widgets, to allow use.
Definition: window.cpp:1804
StationCoverageType
StationCoverageType
Types of cargo to display for station coverage.
Definition: station_gui.h:21
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:2665
BuildRoadStationWindow::DrawWidget
void DrawWidget(const Rect &r, int widget) const override
Draw the contents of a nested widget.
Definition: road_gui.cpp:1114
WID_BROS_BACKGROUND
@ WID_BROS_BACKGROUND
Background of the window.
Definition: road_widget.h:45
Window::SetDirty
void SetDirty() const
Mark entire window as dirty (in need of re-paint)
Definition: window.cpp:1008
HT_DIAGONAL
@ HT_DIAGONAL
Also allow 'diagonal rectangles'. Only usable in combination with HT_RECT or HT_POINT.
Definition: tilehighlight_type.h:28
RectPadding::Horizontal
uint Horizontal() const
Get total horizontal padding of RectPadding.
Definition: geometry_type.hpp:59
OrthogonalTileArea::w
uint16 w
The width of the area.
Definition: tilearea_type.h:20
RoadTypeInfo::auto_road
SpriteID auto_road
button for the autoroad construction
Definition: road.h:85
WC_TRUCK_STATION
@ WC_TRUCK_STATION
Build truck station; Window numbers:
Definition: window_type.h:402
station_cmd.h
ES_NOT_HANDLED
@ ES_NOT_HANDLED
The passed event is not handled.
Definition: window_type.h:721
CommandCost::Failed
bool Failed() const
Did this command fail?
Definition: command_type.h:160
station_func.h
BuildRoadToolbarWindow::ModifyRoadType
void ModifyRoadType(RoadType roadtype)
Switch to another road type.
Definition: road_gui.cpp:345
BuildRoadDepotWindow
Definition: road_gui.cpp:959
BuildRoadDepotWindow::DrawWidget
void DrawWidget(const Rect &r, int widget) const override
Draw the contents of a nested widget.
Definition: road_gui.cpp:981
VpSelectTilesWithMethod
void VpSelectTilesWithMethod(int x, int y, ViewportPlaceMethod method)
Selects tiles while dragging.
Definition: viewport.cpp:3150
ScaleSpriteTrad
static int ScaleSpriteTrad(int value)
Scale traditional pixel dimensions to GUI zoom level, for drawing sprites.
Definition: zoom_func.h:107
OrthogonalTileArea
Represents the covered area of e.g.
Definition: tilearea_type.h:18
WID_BROS_STATION_X
@ WID_BROS_STATION_X
Drive-through station in x-direction.
Definition: road_widget.h:50
BuildRoadToolbarWindow::roadtype
RoadType roadtype
Road type to build.
Definition: road_gui.cpp:254
RoadTypes
RoadTypes
The different roadtypes we support, but then a bitmask of them.
Definition: road_type.h:36
road_gui.h
ShowSelectStationIfNeeded
void ShowSelectStationIfNeeded(TileArea ta, StationPickerCmdProc proc)
Show the station selection window when needed.
Definition: station_gui.cpp:2435
_settings_game
GameSettings _settings_game
Game settings of a running game or the scenario editor.
Definition: settings.cpp:54
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:396
BuildRoadToolbarWindow::OnPlaceObject
void OnPlaceObject(Point pt, TileIndex tile) override
The user clicked some place on the map when a tile highlight mode has been set.
Definition: road_gui.cpp:507
Window::SetWidgetDisabledState
void SetWidgetDisabledState(byte widget_index, bool disab_stat)
Sets the enabled/disabled status of a widget.
Definition: window_gui.h:321
Window::parent
Window * parent
Parent window.
Definition: window_gui.h:266
_local_company
CompanyID _local_company
Company controlled by the human player at this client. Can also be COMPANY_SPECTATOR.
Definition: company_cmd.cpp:46
DropDownListStringItem
Common string list item.
Definition: dropdown_type.h:39
safeguards.h
HandlePlacePushButton
bool HandlePlacePushButton(Window *w, int widget, CursorID cursor, HighLightStyle mode)
This code is shared for the majority of the pushbuttons.
Definition: main_gui.cpp:62
WC_BUILD_BRIDGE
@ WC_BUILD_BRIDGE
Build bridge; Window numbers:
Definition: window_type.h:382
CA_BUS
@ CA_BUS
Catchment for bus stops with "modified catchment" enabled.
Definition: station_type.h:78
ReverseDiagDir
static DiagDirection ReverseDiagDir(DiagDirection d)
Returns the reverse direction of the given DiagDirection.
Definition: direction_func.h:118
PlaceRoad_BusStation
static void PlaceRoad_BusStation(TileIndex tile)
Callback for placing a bus station.
Definition: road_gui.cpp:186
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
TileHighlightData::pos
Point pos
Location, in tile "units", of the northern tile of the selected area.
Definition: tilehighlight_type.h:47
BuildRoadToolbarWindow::OnPlaceMouseUp
void OnPlaceMouseUp(ViewportPlaceMethod select_method, ViewportDragDropSelectionProcess select_proc, Point pt, TileIndex start_tile, TileIndex end_tile) override
The user has dragged over the map when the tile highlight mode has been set.
Definition: road_gui.cpp:624
CA_TRUCK
@ CA_TRUCK
Catchment for truck stops with "modified catchment" enabled.
Definition: station_type.h:79
WID_ROT_CAPTION
@ WID_ROT_CAPTION
Caption of the window.
Definition: road_widget.h:16
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:164
ValParamRoadType
bool ValParamRoadType(RoadType roadtype)
Validate functions for rail building.
Definition: road.cpp:142
DiagDirection
DiagDirection
Enumeration for diagonal directions.
Definition: direction_type.h:77
WID_ROT_ROAD_Y
@ WID_ROT_ROAD_Y
Build road in y-direction.
Definition: road_widget.h:18
RoadTypeInfo::build_tunnel
SpriteID build_tunnel
button for building a tunnel
Definition: road.h:87
StationSettings::station_spread
byte station_spread
amount a station may spread
Definition: settings_type.h:563
WID_ROT_BUILD_BRIDGE
@ WID_ROT_BUILD_BRIDGE
Build bridge.
Definition: road_widget.h:25
tunnelbridge_cmd.h
date_func.h
stdafx.h
Window::window_number
WindowNumber window_number
Window number within the window class.
Definition: window_gui.h:241
GUISettings::link_terraform_toolbar
bool link_terraform_toolbar
display terraform toolbar when displaying rail, road, water and airport toolbars
Definition: settings_type.h:119
DRD_NONE
@ DRD_NONE
None of the directions are disallowed.
Definition: road_type.h:73
RectPadding::Vertical
uint Vertical() const
Get total vertical padding of RectPadding.
Definition: geometry_type.hpp:65
viewport_func.h
BuildRoadToolbarWindow::SetupRoadToolbar
void SetupRoadToolbar()
Configures the road toolbar for roadtype given.
Definition: road_gui.cpp:329
WC_NONE
@ WC_NONE
No window, redirects to WC_MAIN_WINDOW.
Definition: window_type.h:38
CanBuildVehicleInfrastructure
bool CanBuildVehicleInfrastructure(VehicleType type, byte subtype)
Check whether we can build infrastructure for the given vehicle type.
Definition: vehicle.cpp:1835
NWID_VERTICAL
@ NWID_VERTICAL
Vertical container.
Definition: widget_type.h:75
GetTunnelBridgeDirection
static DiagDirection GetTunnelBridgeDirection(TileIndex t)
Get the direction pointing to the other end.
Definition: tunnelbridge_map.h:26
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:1786
WC_BUILD_DEPOT
@ WC_BUILD_DEPOT
Build depot; Window numbers:
Definition: window_type.h:410
WID_ROT_TRUCK_STATION
@ WID_ROT_TRUCK_STATION
Build truck station.
Definition: road_widget.h:23
WID_BROD_DEPOT_SW
@ WID_BROD_DEPOT_SW
Depot with SW entry.
Definition: road_widget.h:37
_nested_road_station_picker_widgets
static const NWidgetPart _nested_road_station_picker_widgets[]
Widget definition of the build road station window.
Definition: road_gui.cpp:1170
OrthogonalTileArea::h
uint16 h
The height of the area.
Definition: tilearea_type.h:21
GetSpriteSize
Dimension GetSpriteSize(SpriteID sprid, Point *offset, ZoomLevel zoom)
Get the size of a sprite.
Definition: gfx.cpp:993
WWT_CLOSEBOX
@ WWT_CLOSEBOX
Close box (at top-left of a window)
Definition: widget_type.h:67
RoadTypeInfo::picker_tooltip
StringID picker_tooltip[2]
Tooltip for the station picker for bus or truck stations.
Definition: road.h:116
BuildRoadStationWindow
Definition: road_gui.cpp:1051
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:365
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:55
WID_BROS_STATION_SE
@ WID_BROS_STATION_SE
Terminal station with SE entry.
Definition: road_widget.h:47
RoadTypeInfo::build_x_road
SpriteID build_x_road
button for building single rail in X direction
Definition: road.h:83
BuildRoadToolbarWindow::OnHotkey
EventState OnHotkey(int hotkey) override
A hotkey has been pressed.
Definition: road_gui.cpp:501
RoadTypeInfo::convert_road
SpriteID convert_road
button for converting road types
Definition: road.h:88
WID_ROT_ONE_WAY
@ WID_ROT_ONE_WAY
Build one-way road.
Definition: road_widget.h:24
ROADSTOP_BUS
@ ROADSTOP_BUS
A standard stop for buses.
Definition: station_type.h:45
StringID
uint32 StringID
Numeric value that represents a string, independent of the selected language.
Definition: strings_type.h:16
SoundSettings::confirm
bool confirm
Play sound effect on successful constructions or other actions.
Definition: settings_type.h:216
vehicle_func.h
EndContainer
static NWidgetPart EndContainer()
Widget part function for denoting the end of a container (horizontal, vertical, WWT_FRAME,...
Definition: widget_type.h:1096
WC_SELECT_STATION
@ WC_SELECT_STATION
Select station (when joining stations); Window numbers:
Definition: window_type.h:235
strings_func.h
terraform_gui.h
RoadTypeInfo::gui_sprites
struct RoadTypeInfo::@40 gui_sprites
struct containing the sprites for the road GUI.
WID_BROD_DEPOT_NW
@ WID_BROD_DEPOT_NW
Depot with NW entry.
Definition: road_widget.h:38
INVALID_AXIS
@ INVALID_AXIS
Flag for an invalid Axis.
Definition: direction_type.h:129
WIDGET_LIST_END
static const int WIDGET_LIST_END
indicate the end of widgets' list for vararg functions
Definition: widget_type.h:20
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:111
RoadTramToolbarGlobalHotkeys
static EventState RoadTramToolbarGlobalHotkeys(int hotkey, RoadType last_build, RoadTramType rtt)
Handler for global hotkeys of the BuildRoadToolbarWindow.
Definition: road_gui.cpp:706
RoadTypeInfo::cursor
struct RoadTypeInfo::@41 cursor
Cursors associated with the road type.
WID_BROS_STATION_SW
@ WID_BROS_STATION_SW
Terminal station with SW entry.
Definition: road_widget.h:48
WC_SCEN_LAND_GEN
@ WC_SCEN_LAND_GEN
Landscape generation (in Scenario Editor); Window numbers:
Definition: window_type.h:442
NWidget
static NWidgetPart NWidget(WidgetType tp, Colours col, int16 idx=-1)
Widget part function for starting a new 'real' widget.
Definition: widget_type.h:1229
SCT_NON_PASSENGERS_ONLY
@ SCT_NON_PASSENGERS_ONLY
Draw all non-passenger class cargoes.
Definition: station_gui.h:23
WidgetDimensions::fullbevel
RectPadding fullbevel
Always-scaled bevel border.
Definition: window_gui.h:46
BuildRoadToolbarWindow
Road toolbar window handler.
Definition: road_gui.cpp:253
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:94
CloseWindowByClass
void CloseWindowByClass(WindowClass cls)
Close all windows of a given class.
Definition: window.cpp:1203
SetMinimalSize
static NWidgetPart SetMinimalSize(int16 x, int16 y)
Widget part function for setting the minimal size.
Definition: widget_type.h:1014
_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:52
RoadTypeInfo::err_convert_road
StringID err_convert_road
Converting a road type.
Definition: road.h:113
WWT_PANEL
@ WWT_PANEL
Simple depressed panel.
Definition: widget_type.h:48
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:1998
Window::SetWidgetsDisabledState
void CDECL SetWidgetsDisabledState(bool disab_stat, int widgets,...)
Sets the enabled/disabled status of a list of widgets.
Definition: window.cpp:560
WID_ROT_CONVERT_ROAD
@ WID_ROT_CONVERT_ROAD
Convert road.
Definition: road_widget.h:28
Window::IsWidgetLowered
bool IsWidgetLowered(byte widget_index) const
Gets the lowered state of a widget.
Definition: window_gui.h:422
EventState
EventState
State of handling an event.
Definition: window_type.h:719
HT_RECT
@ HT_RECT
rectangle (stations, depots, ...)
Definition: tilehighlight_type.h:21
WID_ROT_ROAD_X
@ WID_ROT_ROAD_X
Build road in x-direction.
Definition: road_widget.h:17
RoadToolbar_CtrlChanged
static bool RoadToolbar_CtrlChanged(Window *w)
Updates the Remove button because of Ctrl state change.
Definition: road_gui.cpp:237
WID_BROS_STATION_NE
@ WID_BROS_STATION_NE
Terminal station with NE entry.
Definition: road_widget.h:46
VPM_X_AND_Y
@ VPM_X_AND_Y
area of land in X and Y directions
Definition: viewport_type.h:92
RoadToolbarWidgets
RoadToolbarWidgets
Widgets of the BuildRoadToolbarWindow class.
Definition: road_widget.h:14
GetRoadTypeInfo
static const RoadTypeInfo * GetRoadTypeInfo(RoadType roadtype)
Returns a pointer to the Roadtype information for a given roadtype.
Definition: road.h:225
Window::window_class
WindowClass window_class
Window class.
Definition: window_gui.h:240
RoadType
RoadType
The different roadtypes we support.
Definition: road_type.h:22
WID_ROT_DEPOT
@ WID_ROT_DEPOT
Build depot.
Definition: road_widget.h:21
WID_BROD_DEPOT_SE
@ WID_BROD_DEPOT_SE
Depot with SE entry.
Definition: road_widget.h:36
Window::FinishInitNested
void FinishInitNested(WindowNumber window_number=0)
Perform the second part of the initialization of a nested widget tree.
Definition: window.cpp:1791
DC_AUTO
@ DC_AUTO
don't allow building on structures
Definition: command_type.h:358
WID_BROS_CAPTION
@ WID_BROS_CAPTION
Caption of the window.
Definition: road_widget.h:44
NWID_SPACER
@ NWID_SPACER
Invisible widget that takes some space.
Definition: widget_type.h:77
DDSP_CONVERT_ROAD
@ DDSP_CONVERT_ROAD
Road conversion.
Definition: viewport_type.h:135
company_func.h
PickerWindowBase
Base class for windows opened from a toolbar.
Definition: window_gui.h:874
SetViewportCatchmentStation
void SetViewportCatchmentStation(const Station *st, bool sel)
Select or deselect station for coverage area highlight.
Definition: viewport.cpp:3533
CcBuildRoadTunnel
void CcBuildRoadTunnel(Commands cmd, const CommandCost &result, TileIndex start_tile)
Callback executed after a build road tunnel command has been called.
Definition: road_gui.cpp:87
Window::top
int top
y position of top edge of the window
Definition: window_gui.h:247
AXIS_X
@ AXIS_X
The X axis.
Definition: direction_type.h:126
CommandHelper
Definition: command_func.h:94
window_func.h
Window::ToggleWidgetLoweredState
void ToggleWidgetLoweredState(byte widget_index)
Invert the lowered/raised status of a widget.
Definition: window_gui.h:392
SoundSettings::click_beep
bool click_beep
Beep on a random selection of buttons.
Definition: settings_type.h:217
WID_ROT_BUS_STATION
@ WID_ROT_BUS_STATION
Build bus station.
Definition: road_widget.h:22
lengthof
#define lengthof(x)
Return the length of an fixed size array.
Definition: stdafx.h:386
VPM_X_LIMITED
@ VPM_X_LIMITED
Drag only in X axis with limited size.
Definition: viewport_type.h:96
ROAD_NONE
@ ROAD_NONE
No road-part is build.
Definition: road_type.h:51
ShowTerraformToolbar
Window * ShowTerraformToolbar(Window *link)
Show the toolbar for terraforming in the game.
Definition: terraform_gui.cpp:371
RoadTypeInfo::max_speed
uint16 max_speed
Maximum speed for vehicles travelling on this road type.
Definition: road.h:140
SetPIP
static NWidgetPart SetPIP(uint8 pre, uint8 inter, uint8 post)
Widget part function for setting a pre/inter/post spaces.
Definition: widget_type.h:1191
SND_1F_CONSTRUCTION_OTHER
@ SND_1F_CONSTRUCTION_OTHER
29 == 0x1D Construction: other (non-water, non-rail, non-bridge)
Definition: sound_type.h:68
CloseWindowById
void CloseWindowById(WindowClass cls, WindowNumber number, bool force)
Close a window by its class and window number (if it is open).
Definition: window.cpp:1191
ShowBuildRoadToolbar
Window * ShowBuildRoadToolbar(RoadType roadtype)
Open the build road toolbar window.
Definition: road_gui.cpp:864
IsNormalRoadTile
static bool IsNormalRoadTile(TileIndex t)
Return whether a tile is a normal road tile.
Definition: road_map.h:74
engine_base.h
TRANSPORT_ROAD
@ TRANSPORT_ROAD
Transport by road vehicle.
Definition: transport_type.h:28
SetFill
static NWidgetPart SetFill(uint fill_x, uint fill_y)
Widget part function for setting filling.
Definition: widget_type.h:1080
GetOtherTunnelBridgeEnd
static TileIndex GetOtherTunnelBridgeEnd(TileIndex t)
Determines type of the wormhole and returns its other end.
Definition: tunnelbridge_map.h:78
gui.h
BuildRoadToolbarWindow::Close
void Close() override
Hide the window and all its child windows, and mark them for a later deletion.
Definition: road_gui.cpp:275
TileInfo::tile
TileIndex tile
Tile index.
Definition: tile_cmd.h:46
Window
Data structure for an opened window.
Definition: window_gui.h:213
GetRoadTypes
RoadTypes GetRoadTypes(bool introduces)
Get list of road types, regardless of company availability.
Definition: road.cpp:216
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:326
Window::RaiseWidget
void RaiseWidget(byte widget_index)
Marks a widget as raised.
Definition: window_gui.h:412
BuildRoadStationWindow::OnRealtimeTick
void OnRealtimeTick(uint delta_ms) override
Called periodically.
Definition: road_gui.cpp:1163
Window::DrawWidgets
void DrawWidgets() const
Paint all widgets of a window.
Definition: widget.cpp:858
RoadTypeInfo::err_depot
StringID err_depot
Building a depot.
Definition: road.h:110
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:109
Rect::Width
int Width() const
Get width of Rect.
Definition: geometry_type.hpp:79
WidgetDimensions::scaled
static WidgetDimensions scaled
Widget dimensions scaled for current zoom level.
Definition: window_gui.h:68
VPM_X_AND_Y_LIMITED
@ VPM_X_AND_Y_LIMITED
area of land of limited size
Definition: viewport_type.h:93
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:1263
Window::IsWidgetDisabled
bool IsWidgetDisabled(byte widget_index) const
Gets the enabled/disabled status of a widget.
Definition: window_gui.h:350
Window::SetWidgetDirty
void SetWidgetDirty(byte widget_index) const
Invalidate a widget, i.e.
Definition: window.cpp:621
WID_ROT_AUTOROAD
@ WID_ROT_AUTOROAD
Autorail.
Definition: road_widget.h:19
DIAGDIR_NE
@ DIAGDIR_NE
Northeast, upper right on your monitor.
Definition: direction_type.h:79
ROADTYPES_NONE
@ ROADTYPES_NONE
No roadtypes.
Definition: road_type.h:37
Rect
Specification of a rectangle with absolute coordinates of all edges.
Definition: geometry_type.hpp:69
Window::LowerWidget
void LowerWidget(byte widget_index)
Marks a widget as lowered.
Definition: window_gui.h:403
Company
Definition: company_base.h:117
VPM_X_OR_Y
@ VPM_X_OR_Y
drag in X or Y direction
Definition: viewport_type.h:89
Window::DisableWidget
void DisableWidget(byte widget_index)
Sets a widget to disabled.
Definition: window_gui.h:331
ResetObjectToPlace
void ResetObjectToPlace()
Reset the cursor and mouse mode handling back to default (normal cursor, only clicking in windows).
Definition: viewport.cpp:3434
HT_SPECIAL
@ HT_SPECIAL
special mode used for highlighting while dragging (and for tunnels/docks)
Definition: tilehighlight_type.h:23
WID_ROT_DEMOLISH
@ WID_ROT_DEMOLISH
Demolish.
Definition: road_widget.h:20
Window::SetWidgetLoweredState
void SetWidgetLoweredState(byte widget_index, bool lowered_stat)
Sets the lowered/raised status of a widget.
Definition: window_gui.h:382
station_gui.h
WID_BROS_LT_OFF
@ WID_BROS_LT_OFF
Turn off area highlight.
Definition: road_widget.h:52
RoadTypeInfo::picker_title
StringID picker_title[2]
Title for the station picker for bus or truck stations.
Definition: road.h:115
DropDownListIconItem
List item with icon and string.
Definition: dropdown_type.h:82
DRD_NORTHBOUND
@ DRD_NORTHBOUND
All northbound traffic is disallowed.
Definition: road_type.h:75
road_cmd.h
WWT_TEXTBTN
@ WWT_TEXTBTN
(Toggle) Button with text
Definition: widget_type.h:53
ClientSettings::gui
GUISettings gui
settings related to the GUI
Definition: settings_type.h:604
WID_BROS_STATION_NW
@ WID_BROS_STATION_NW
Terminal station with NW entry.
Definition: road_widget.h:49
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
GUISettings::persistent_buildingtools
bool persistent_buildingtools
keep the building tools active after usage
Definition: settings_type.h:167
StationSettings::modified_catchment
bool modified_catchment
different-size catchment areas
Definition: settings_type.h:558
TileVirtXY
static TileIndex TileVirtXY(uint x, uint y)
Get a tile from the virtual XY-coordinate.
Definition: map_func.h:194
ScaleGUITrad
static RectPadding ScaleGUITrad(const RectPadding &r)
Scale a RectPadding to GUI zoom level.
Definition: widget.cpp:168
Hotkey
All data for a single hotkey.
Definition: hotkeys.h:22
RoadTypeInfo::strings
struct RoadTypeInfo::@42 strings
Strings associated with the rail type.
hotkeys.h
ResizeWindow
void ResizeWindow(Window *w, int delta_x, int delta_y, bool clamp_to_screen)
Resize the window.
Definition: window.cpp:2088
WID_BROS_ACCEPTANCE
@ WID_BROS_ACCEPTANCE
Station acceptance.
Definition: road_widget.h:55
WID_BROD_DEPOT_NE
@ WID_BROD_DEPOT_NE
Depot with NE entry.
Definition: road_widget.h:35
INVALID_RAILTYPE
@ INVALID_RAILTYPE
Flag for invalid railtype.
Definition: rail_type.h:34
ShowBuildRoadScenToolbar
Window * ShowBuildRoadScenToolbar(RoadType roadtype)
Show the road building toolbar in the scenario editor.
Definition: road_gui.cpp:951
Window::Close
virtual void Close()
Hide the window and all its child windows, and mark them for a later deletion.
Definition: window.cpp:1107
WidgetDimensions::vsep_normal
int vsep_normal
Normal vertical spacing.
Definition: window_gui.h:61
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