OpenTTD Source  1.11.0-beta2
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 
35 #include "widgets/road_widget.h"
36 
37 #include "table/strings.h"
38 
39 #include "safeguards.h"
40 
41 static void ShowRVStationPicker(Window *parent, RoadStopType rs);
42 static void ShowRoadDepotPicker(Window *parent);
43 
44 static bool _remove_button_clicked;
45 static bool _one_way_button_clicked;
46 
51 enum RoadFlags {
52  RF_NONE = 0x00,
53  RF_START_HALFROAD_Y = 0x01, // The start tile in Y-dir should have only a half road
54  RF_END_HALFROAD_Y = 0x02, // The end tile in Y-dir should have only a half road
55  RF_DIR_Y = 0x04, // The direction is Y-dir
56  RF_DIR_X = RF_NONE, // Dummy; Dir X is set when RF_DIR_Y is not set
57  RF_START_HALFROAD_X = 0x08, // The start tile in X-dir should have only a half road
58  RF_END_HALFROAD_X = 0x10, // The end tile in X-dir should have only a half road
59 };
61 
62 static RoadFlags _place_road_flag;
63 
64 static RoadType _cur_roadtype;
65 
66 static DiagDirection _road_depot_orientation;
67 static DiagDirection _road_station_picker_orientation;
68 
69 void CcPlaySound_CONSTRUCTION_OTHER(const CommandCost &result, TileIndex tile, uint32 p1, uint32 p2, uint32 cmd)
70 {
71  if (result.Succeeded() && _settings_client.sound.confirm) SndPlayTileFx(SND_1F_CONSTRUCTION_OTHER, tile);
72 }
73 
79 {
80  if (IsBridgeTile(tile)) {
82  Point pt = {0, 0};
83  w->OnPlaceMouseUp(VPM_X_OR_Y, DDSP_BUILD_BRIDGE, pt, other_tile, tile);
84  } else {
86  }
87 }
88 
99 void CcBuildRoadTunnel(const CommandCost &result, TileIndex start_tile, uint32 p1, uint32 p2, uint32 cmd)
100 {
101  if (result.Succeeded()) {
102  if (_settings_client.sound.confirm) SndPlayTileFx(SND_1F_CONSTRUCTION_OTHER, start_tile);
104 
105  DiagDirection start_direction = ReverseDiagDir(GetTunnelBridgeDirection(start_tile));
106  ConnectRoadToStructure(start_tile, start_direction);
107 
108  TileIndex end_tile = GetOtherTunnelBridgeEnd(start_tile);
109  DiagDirection end_direction = ReverseDiagDir(GetTunnelBridgeDirection(end_tile));
110  ConnectRoadToStructure(end_tile, end_direction);
111  } else {
113  }
114 }
115 
122 {
123  tile += TileOffsByDiagDir(direction);
124  /* if there is a roadpiece just outside of the station entrance, build a connecting route */
125  if (IsNormalRoadTile(tile)) {
126  if (GetRoadBits(tile, GetRoadTramType(_cur_roadtype)) != ROAD_NONE) {
127  DoCommandP(tile, _cur_roadtype << 4 | DiagDirToRoadBits(ReverseDiagDir(direction)), 0, CMD_BUILD_ROAD);
128  }
129  }
130 }
131 
132 void CcRoadDepot(const CommandCost &result, TileIndex tile, uint32 p1, uint32 p2, uint32 cmd)
133 {
134  if (result.Failed()) return;
135 
136  DiagDirection dir = (DiagDirection)GB(p1, 0, 2);
140 }
141 
158 void CcRoadStop(const CommandCost &result, TileIndex tile, uint32 p1, uint32 p2, uint32 cmd)
159 {
160  if (result.Failed()) return;
161 
162  DiagDirection dir = (DiagDirection)GB(p2, 3, 2);
165  TileArea roadstop_area(tile, GB(p1, 0, 8), GB(p1, 8, 8));
166  TILE_AREA_LOOP(cur_tile, roadstop_area) {
167  ConnectRoadToStructure(cur_tile, dir);
168  /* For a drive-through road stop build connecting road for other entrance. */
169  if (HasBit(p2, 1)) ConnectRoadToStructure(cur_tile, ReverseDiagDir(dir));
170  }
171 }
172 
183 static void PlaceRoadStop(TileIndex start_tile, TileIndex end_tile, uint32 p2, uint32 cmd)
184 {
185  uint8 ddir = _road_station_picker_orientation;
186  SB(p2, 16, 16, INVALID_STATION); // no station to join
187 
188  if (ddir >= DIAGDIR_END) {
189  SetBit(p2, 1); // It's a drive-through stop.
190  ddir -= DIAGDIR_END; // Adjust picker result to actual direction.
191  }
192  p2 |= ddir << 3; // Set the DiagDirecion into p2 bits 3 and 4.
193 
194  TileArea ta(start_tile, end_tile);
195  CommandContainer cmdcont = { ta.tile, (uint32)(ta.w | ta.h << 8), p2, cmd, CcRoadStop, "" };
196  ShowSelectStationIfNeeded(cmdcont, ta);
197 }
198 
204 {
207  } else {
208  if (_road_station_picker_orientation < DIAGDIR_END) { // Not a drive-through stop.
209  VpStartPlaceSizing(tile, (DiagDirToAxis(_road_station_picker_orientation) == AXIS_X) ? VPM_X_LIMITED : VPM_Y_LIMITED, DDSP_BUILD_BUSSTOP);
210  } else {
212  }
213  VpSetPlaceSizingLimit(_settings_game.station.station_spread);
214  }
215 }
216 
222 {
225  } else {
226  if (_road_station_picker_orientation < DIAGDIR_END) { // Not a drive-through stop.
227  VpStartPlaceSizing(tile, (DiagDirToAxis(_road_station_picker_orientation) == AXIS_X) ? VPM_X_LIMITED : VPM_Y_LIMITED, DDSP_BUILD_TRUCKSTOP);
228  } else {
230  }
231  VpSetPlaceSizingLimit(_settings_game.station.station_spread);
232  }
233 }
234 
235 typedef void OnButtonClick(Window *w);
236 
242 {
246  SetSelectionRed(_remove_button_clicked);
247 }
248 
255 {
256  if (w->IsWidgetDisabled(WID_ROT_REMOVE)) return false;
257 
258  /* allow ctrl to switch remove mode only for these widgets */
259  for (uint i = WID_ROT_ROAD_X; i <= WID_ROT_AUTOROAD; i++) {
260  if (w->IsWidgetLowered(i)) {
262  return true;
263  }
264  }
265 
266  return false;
267 }
268 
272  const RoadTypeInfo *rti;
274 
276  {
277  this->Initialize(_cur_roadtype);
278  this->InitNested(window_number);
279  this->SetupRoadToolbar();
281 
282  if (RoadTypeIsRoad(this->roadtype)) {
284  }
285 
286  this->OnInvalidateData();
287  this->last_started_action = WIDGET_LIST_END;
288 
290  }
291 
293  {
294  if (_game_mode == GM_NORMAL && (this->IsWidgetLowered(WID_ROT_BUS_STATION) || this->IsWidgetLowered(WID_ROT_TRUCK_STATION))) SetViewportCatchmentStation(nullptr, true);
296  }
297 
303  void OnInvalidateData(int data = 0, bool gui_scope = true) override
304  {
305  if (!gui_scope) return;
306  RoadTramType rtt = GetRoadTramType(this->roadtype);
307 
308  bool can_build = CanBuildVehicleInfrastructure(VEH_ROAD, rtt);
309  this->SetWidgetsDisabledState(!can_build,
314  if (!can_build) {
318  }
319 
320  if (_game_mode != GM_EDITOR) {
321  if (!can_build) {
322  /* Show in the tooltip why this button is disabled. */
323  this->GetWidget<NWidgetCore>(WID_ROT_DEPOT)->SetToolTip(STR_TOOLBAR_DISABLED_NO_VEHICLE_AVAILABLE);
324  this->GetWidget<NWidgetCore>(WID_ROT_BUS_STATION)->SetToolTip(STR_TOOLBAR_DISABLED_NO_VEHICLE_AVAILABLE);
325  this->GetWidget<NWidgetCore>(WID_ROT_TRUCK_STATION)->SetToolTip(STR_TOOLBAR_DISABLED_NO_VEHICLE_AVAILABLE);
326  } else {
327  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);
328  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);
329  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);
330  }
331  }
332  }
333 
334  void Initialize(RoadType roadtype)
335  {
336  assert(roadtype < ROADTYPE_END);
337  this->roadtype = roadtype;
338  this->rti = GetRoadTypeInfo(this->roadtype);
339  }
340 
346  {
347  this->GetWidget<NWidgetCore>(WID_ROT_ROAD_X)->widget_data = rti->gui_sprites.build_x_road;
348  this->GetWidget<NWidgetCore>(WID_ROT_ROAD_Y)->widget_data = rti->gui_sprites.build_y_road;
349  this->GetWidget<NWidgetCore>(WID_ROT_AUTOROAD)->widget_data = rti->gui_sprites.auto_road;
350  if (_game_mode != GM_EDITOR) {
351  this->GetWidget<NWidgetCore>(WID_ROT_DEPOT)->widget_data = rti->gui_sprites.build_depot;
352  }
353  this->GetWidget<NWidgetCore>(WID_ROT_CONVERT_ROAD)->widget_data = rti->gui_sprites.convert_road;
354  this->GetWidget<NWidgetCore>(WID_ROT_BUILD_TUNNEL)->widget_data = rti->gui_sprites.build_tunnel;
355  }
356 
362  {
363  this->Initialize(roadtype);
364  this->SetupRoadToolbar();
365  this->ReInit();
366  }
367 
368  void SetStringParameters(int widget) const override
369  {
370  if (widget == WID_ROT_CAPTION) {
371  if (this->rti->max_speed > 0) {
372  SetDParam(0, STR_TOOLBAR_RAILTYPE_VELOCITY);
373  SetDParam(1, this->rti->strings.toolbar_caption);
374  SetDParam(2, this->rti->max_speed / 2);
375  } else {
376  SetDParam(0, this->rti->strings.toolbar_caption);
377  }
378  }
379  }
380 
387  {
388  /* The remove and the one way button state is driven
389  * by the other buttons so they don't act on themselves.
390  * Both are only valid if they are able to apply as options. */
391  switch (clicked_widget) {
392  case WID_ROT_REMOVE:
393  if (RoadTypeIsRoad(this->roadtype)) {
396  }
397 
398  break;
399 
400  case WID_ROT_ONE_WAY:
403  break;
404 
405  case WID_ROT_BUS_STATION:
407  if (RoadTypeIsRoad(this->roadtype)) this->DisableWidget(WID_ROT_ONE_WAY);
408  this->SetWidgetDisabledState(WID_ROT_REMOVE, !this->IsWidgetLowered(clicked_widget));
409  break;
410 
411  case WID_ROT_ROAD_X:
412  case WID_ROT_ROAD_Y:
413  case WID_ROT_AUTOROAD:
414  this->SetWidgetDisabledState(WID_ROT_REMOVE, !this->IsWidgetLowered(clicked_widget));
415  if (RoadTypeIsRoad(this->roadtype)) {
416  this->SetWidgetDisabledState(WID_ROT_ONE_WAY, !this->IsWidgetLowered(clicked_widget));
417  }
418  break;
419 
420  default:
421  /* When any other buttons than road/station, raise and
422  * disable the removal button */
425 
426  if (RoadTypeIsRoad(this->roadtype)) {
429  }
430 
431  break;
432  }
433  }
434 
435  void OnClick(Point pt, int widget, int click_count) override
436  {
437  _remove_button_clicked = false;
438  _one_way_button_clicked = false;
439  switch (widget) {
440  case WID_ROT_ROAD_X:
442  this->last_started_action = widget;
443  break;
444 
445  case WID_ROT_ROAD_Y:
447  this->last_started_action = widget;
448  break;
449 
450  case WID_ROT_AUTOROAD:
452  this->last_started_action = widget;
453  break;
454 
455  case WID_ROT_DEMOLISH:
457  this->last_started_action = widget;
458  break;
459 
460  case WID_ROT_DEPOT:
461  if (HandlePlacePushButton(this, WID_ROT_DEPOT, this->rti->cursor.depot, HT_RECT)) {
462  ShowRoadDepotPicker(this);
463  this->last_started_action = widget;
464  }
465  break;
466 
467  case WID_ROT_BUS_STATION:
468  if (HandlePlacePushButton(this, WID_ROT_BUS_STATION, SPR_CURSOR_BUS_STATION, HT_RECT)) {
469  ShowRVStationPicker(this, ROADSTOP_BUS);
470  this->last_started_action = widget;
471  }
472  break;
473 
475  if (HandlePlacePushButton(this, WID_ROT_TRUCK_STATION, SPR_CURSOR_TRUCK_STATION, HT_RECT)) {
476  ShowRVStationPicker(this, ROADSTOP_TRUCK);
477  this->last_started_action = widget;
478  }
479  break;
480 
481  case WID_ROT_ONE_WAY:
482  if (this->IsWidgetDisabled(WID_ROT_ONE_WAY)) return;
483  this->SetDirty();
485  SetSelectionRed(false);
486  break;
487 
489  HandlePlacePushButton(this, WID_ROT_BUILD_BRIDGE, SPR_CURSOR_BRIDGE, HT_RECT);
490  this->last_started_action = widget;
491  break;
492 
495  this->last_started_action = widget;
496  break;
497 
498  case WID_ROT_REMOVE:
499  if (this->IsWidgetDisabled(WID_ROT_REMOVE)) return;
500 
504  break;
505 
508  this->last_started_action = widget;
509  break;
510 
511  default: NOT_REACHED();
512  }
515  }
516 
517  EventState OnHotkey(int hotkey) override
518  {
519  MarkTileDirtyByTile(TileVirtXY(_thd.pos.x, _thd.pos.y)); // redraw tile selection
520  return Window::OnHotkey(hotkey);
521  }
522 
523  void OnPlaceObject(Point pt, TileIndex tile) override
524  {
526  _one_way_button_clicked = RoadTypeIsRoad(this->roadtype) ? this->IsWidgetLowered(WID_ROT_ONE_WAY) : false;
527  switch (this->last_started_action) {
528  case WID_ROT_ROAD_X:
529  _place_road_flag = RF_DIR_X;
530  if (_tile_fract_coords.x >= 8) _place_road_flag |= RF_START_HALFROAD_X;
532  break;
533 
534  case WID_ROT_ROAD_Y:
535  _place_road_flag = RF_DIR_Y;
536  if (_tile_fract_coords.y >= 8) _place_road_flag |= RF_START_HALFROAD_Y;
538  break;
539 
540  case WID_ROT_AUTOROAD:
541  _place_road_flag = RF_NONE;
542  if (_tile_fract_coords.x >= 8) _place_road_flag |= RF_START_HALFROAD_X;
543  if (_tile_fract_coords.y >= 8) _place_road_flag |= RF_START_HALFROAD_Y;
545  break;
546 
547  case WID_ROT_DEMOLISH:
549  break;
550 
551  case WID_ROT_DEPOT:
552  DoCommandP(tile, _cur_roadtype << 2 | _road_depot_orientation, 0,
553  CMD_BUILD_ROAD_DEPOT | CMD_MSG(this->rti->strings.err_depot), CcRoadDepot);
554  break;
555 
556  case WID_ROT_BUS_STATION:
557  PlaceRoad_BusStation(tile);
558  break;
559 
562  break;
563 
565  PlaceRoad_Bridge(tile, this);
566  break;
567 
569  DoCommandP(tile, _cur_roadtype | (TRANSPORT_ROAD << 8), 0,
570  CMD_BUILD_TUNNEL | CMD_MSG(STR_ERROR_CAN_T_BUILD_TUNNEL_HERE), CcBuildRoadTunnel);
571  break;
572 
575  break;
576 
577  default: NOT_REACHED();
578  }
579  }
580 
581  void OnPlaceObjectAbort() override
582  {
583  if (_game_mode != GM_EDITOR && (this->IsWidgetLowered(WID_ROT_BUS_STATION) || this->IsWidgetLowered(WID_ROT_TRUCK_STATION))) SetViewportCatchmentStation(nullptr, true);
584 
585  this->RaiseButtons();
588 
589  if (RoadTypeIsRoad(this->roadtype)) {
592  }
593 
599  }
600 
601  void OnPlaceDrag(ViewportPlaceMethod select_method, ViewportDragDropSelectionProcess select_proc, Point pt) override
602  {
603  /* Here we update the end tile flags
604  * of the road placement actions.
605  * At first we reset the end halfroad
606  * bits and if needed we set them again. */
607  switch (select_proc) {
609  _place_road_flag &= ~RF_END_HALFROAD_X;
610  if (pt.x & 8) _place_road_flag |= RF_END_HALFROAD_X;
611  break;
612 
614  _place_road_flag &= ~RF_END_HALFROAD_Y;
615  if (pt.y & 8) _place_road_flag |= RF_END_HALFROAD_Y;
616  break;
617 
618  case DDSP_PLACE_AUTOROAD:
619  _place_road_flag &= ~(RF_END_HALFROAD_Y | RF_END_HALFROAD_X);
620  if (pt.y & 8) _place_road_flag |= RF_END_HALFROAD_Y;
621  if (pt.x & 8) _place_road_flag |= RF_END_HALFROAD_X;
622 
623  /* For autoroad we need to update the
624  * direction of the road */
625  if (_thd.size.x > _thd.size.y || (_thd.size.x == _thd.size.y &&
626  ( (_tile_fract_coords.x < _tile_fract_coords.y && (_tile_fract_coords.x + _tile_fract_coords.y) < 16) ||
627  (_tile_fract_coords.x > _tile_fract_coords.y && (_tile_fract_coords.x + _tile_fract_coords.y) > 16) ))) {
628  /* Set dir = X */
629  _place_road_flag &= ~RF_DIR_Y;
630  } else {
631  /* Set dir = Y */
632  _place_road_flag |= RF_DIR_Y;
633  }
634 
635  break;
636 
637  default:
638  break;
639  }
640 
641  VpSelectTilesWithMethod(pt.x, pt.y, select_method);
642  }
643 
644  void OnPlaceMouseUp(ViewportPlaceMethod select_method, ViewportDragDropSelectionProcess select_proc, Point pt, TileIndex start_tile, TileIndex end_tile) override
645  {
646  if (pt.x != -1) {
647  switch (select_proc) {
648  default: NOT_REACHED();
649  case DDSP_BUILD_BRIDGE:
651  ShowBuildBridgeWindow(start_tile, end_tile, TRANSPORT_ROAD, _cur_roadtype);
652  break;
653 
654  case DDSP_DEMOLISH_AREA:
655  GUIPlaceProcDragXY(select_proc, start_tile, end_tile);
656  break;
657 
660  case DDSP_PLACE_AUTOROAD:
661  /* Flag description:
662  * Use the first three bits (0x07) if dir == Y
663  * else use the last 2 bits (X dir has
664  * not the 3rd bit set) */
665 
666  /* Even if _cur_roadtype_id is a uint8 we only use 5 bits so
667  * we could ignore the last 3 bits and reuse them for other
668  * flags */
669  _place_road_flag = (RoadFlags)((_place_road_flag & RF_DIR_Y) ? (_place_road_flag & 0x07) : (_place_road_flag >> 3));
670 
671  DoCommandP(start_tile, end_tile, _place_road_flag | (_cur_roadtype << 3) | (_one_way_button_clicked << 10),
674  CMD_BUILD_LONG_ROAD | CMD_MSG(this->rti->strings.err_build_road), CcPlaySound_CONSTRUCTION_OTHER);
675  break;
676 
677  case DDSP_BUILD_BUSSTOP:
678  case DDSP_REMOVE_BUSSTOP:
681  TileArea ta(start_tile, end_tile);
682  DoCommandP(ta.tile, ta.w | ta.h << 8, (_ctrl_pressed << 1) | ROADSTOP_BUS, CMD_REMOVE_ROAD_STOP | CMD_MSG(this->rti->strings.err_remove_station[ROADSTOP_BUS]), CcPlaySound_CONSTRUCTION_OTHER);
683  } else {
684  PlaceRoadStop(start_tile, end_tile, _cur_roadtype << 5 | (_ctrl_pressed << 2) | ROADSTOP_BUS, CMD_BUILD_ROAD_STOP | CMD_MSG(this->rti->strings.err_build_station[ROADSTOP_BUS]));
685  }
686  }
687  break;
688 
693  TileArea ta(start_tile, end_tile);
694  DoCommandP(ta.tile, ta.w | ta.h << 8, (_ctrl_pressed << 1) | ROADSTOP_TRUCK, CMD_REMOVE_ROAD_STOP | CMD_MSG(this->rti->strings.err_remove_station[ROADSTOP_TRUCK]), CcPlaySound_CONSTRUCTION_OTHER);
695  } else {
696  PlaceRoadStop(start_tile, end_tile, _cur_roadtype << 5 | (_ctrl_pressed << 2) | ROADSTOP_TRUCK, CMD_BUILD_ROAD_STOP | CMD_MSG(this->rti->strings.err_build_station[ROADSTOP_TRUCK]));
697  }
698  }
699  break;
700 
701  case DDSP_CONVERT_ROAD:
702  DoCommandP(end_tile, start_tile, _cur_roadtype, CMD_CONVERT_ROAD | CMD_MSG(rti->strings.err_convert_road), CcPlaySound_CONSTRUCTION_OTHER);
703  break;
704  }
705  }
706  }
707 
708  void OnPlacePresize(Point pt, TileIndex tile) override
709  {
710  DoCommand(tile, _cur_roadtype | (TRANSPORT_ROAD << 8), 0, DC_AUTO, CMD_BUILD_TUNNEL);
712  }
713 
715  {
716  if (RoadToolbar_CtrlChanged(this)) return ES_HANDLED;
717  return ES_NOT_HANDLED;
718  }
719 
720  static HotkeyList road_hotkeys;
721  static HotkeyList tram_hotkeys;
722 };
723 
730 static EventState RoadTramToolbarGlobalHotkeys(int hotkey, RoadType last_build, RoadTramType rtt)
731 {
732  Window* w = nullptr;
733  switch (_game_mode) {
734  case GM_NORMAL:
735  w = ShowBuildRoadToolbar(last_build);
736  break;
737 
738  case GM_EDITOR:
739  if ((GetRoadTypes(true) & ((rtt == RTT_ROAD) ? ~_roadtypes_type : _roadtypes_type)) == ROADTYPES_NONE) return ES_NOT_HANDLED;
740  w = ShowBuildRoadScenToolbar(last_build);
741  break;
742 
743  default:
744  break;
745  }
746 
747  if (w == nullptr) return ES_NOT_HANDLED;
748  return w->OnHotkey(hotkey);
749 }
750 
751 static EventState RoadToolbarGlobalHotkeys(int hotkey)
752 {
753  extern RoadType _last_built_roadtype;
754  return RoadTramToolbarGlobalHotkeys(hotkey, _last_built_roadtype, RTT_ROAD);
755 }
756 
757 static EventState TramToolbarGlobalHotkeys(int hotkey)
758 {
759  extern RoadType _last_built_tramtype;
760  return RoadTramToolbarGlobalHotkeys(hotkey, _last_built_tramtype, RTT_TRAM);
761 }
762 
763 static Hotkey roadtoolbar_hotkeys[] = {
764  Hotkey('1', "build_x", WID_ROT_ROAD_X),
765  Hotkey('2', "build_y", WID_ROT_ROAD_Y),
766  Hotkey('3', "autoroad", WID_ROT_AUTOROAD),
767  Hotkey('4', "demolish", WID_ROT_DEMOLISH),
768  Hotkey('5', "depot", WID_ROT_DEPOT),
769  Hotkey('6', "bus_station", WID_ROT_BUS_STATION),
770  Hotkey('7', "truck_station", WID_ROT_TRUCK_STATION),
771  Hotkey('8', "oneway", WID_ROT_ONE_WAY),
772  Hotkey('B', "bridge", WID_ROT_BUILD_BRIDGE),
773  Hotkey('T', "tunnel", WID_ROT_BUILD_TUNNEL),
774  Hotkey('R', "remove", WID_ROT_REMOVE),
775  Hotkey('C', "convert", WID_ROT_CONVERT_ROAD),
776  HOTKEY_LIST_END
777 };
778 HotkeyList BuildRoadToolbarWindow::road_hotkeys("roadtoolbar", roadtoolbar_hotkeys, RoadToolbarGlobalHotkeys);
779 
780 static Hotkey tramtoolbar_hotkeys[] = {
781  Hotkey('1', "build_x", WID_ROT_ROAD_X),
782  Hotkey('2', "build_y", WID_ROT_ROAD_Y),
783  Hotkey('3', "autoroad", WID_ROT_AUTOROAD),
784  Hotkey('4', "demolish", WID_ROT_DEMOLISH),
785  Hotkey('5', "depot", WID_ROT_DEPOT),
786  Hotkey('6', "bus_station", WID_ROT_BUS_STATION),
787  Hotkey('7', "truck_station", WID_ROT_TRUCK_STATION),
788  Hotkey('B', "bridge", WID_ROT_BUILD_BRIDGE),
789  Hotkey('T', "tunnel", WID_ROT_BUILD_TUNNEL),
790  Hotkey('R', "remove", WID_ROT_REMOVE),
791  Hotkey('C', "convert", WID_ROT_CONVERT_ROAD),
792  HOTKEY_LIST_END
793 };
794 HotkeyList BuildRoadToolbarWindow::tram_hotkeys("tramtoolbar", tramtoolbar_hotkeys, TramToolbarGlobalHotkeys);
795 
796 
797 static const NWidgetPart _nested_build_road_widgets[] = {
799  NWidget(WWT_CLOSEBOX, COLOUR_DARK_GREEN),
800  NWidget(WWT_CAPTION, COLOUR_DARK_GREEN, WID_ROT_CAPTION), SetDataTip(STR_WHITE_STRING, STR_TOOLTIP_WINDOW_TITLE_DRAG_THIS),
801  NWidget(WWT_STICKYBOX, COLOUR_DARK_GREEN),
802  EndContainer(),
804  NWidget(WWT_IMGBTN, COLOUR_DARK_GREEN, WID_ROT_ROAD_X),
805  SetFill(0, 1), SetMinimalSize(22, 22), SetDataTip(SPR_IMG_ROAD_X_DIR, STR_ROAD_TOOLBAR_TOOLTIP_BUILD_ROAD_SECTION),
806  NWidget(WWT_IMGBTN, COLOUR_DARK_GREEN, WID_ROT_ROAD_Y),
807  SetFill(0, 1), SetMinimalSize(22, 22), SetDataTip(SPR_IMG_ROAD_Y_DIR, STR_ROAD_TOOLBAR_TOOLTIP_BUILD_ROAD_SECTION),
808  NWidget(WWT_IMGBTN, COLOUR_DARK_GREEN, WID_ROT_AUTOROAD),
809  SetFill(0, 1), SetMinimalSize(22, 22), SetDataTip(SPR_IMG_AUTOROAD, STR_ROAD_TOOLBAR_TOOLTIP_BUILD_AUTOROAD),
810  NWidget(WWT_IMGBTN, COLOUR_DARK_GREEN, WID_ROT_DEMOLISH),
811  SetFill(0, 1), SetMinimalSize(22, 22), SetDataTip(SPR_IMG_DYNAMITE, STR_TOOLTIP_DEMOLISH_BUILDINGS_ETC),
812  NWidget(WWT_IMGBTN, COLOUR_DARK_GREEN, WID_ROT_DEPOT),
813  SetFill(0, 1), SetMinimalSize(22, 22), SetDataTip(SPR_IMG_ROAD_DEPOT, STR_ROAD_TOOLBAR_TOOLTIP_BUILD_ROAD_VEHICLE_DEPOT),
814  NWidget(WWT_IMGBTN, COLOUR_DARK_GREEN, WID_ROT_BUS_STATION),
815  SetFill(0, 1), SetMinimalSize(22, 22), SetDataTip(SPR_IMG_BUS_STATION, STR_ROAD_TOOLBAR_TOOLTIP_BUILD_BUS_STATION),
816  NWidget(WWT_IMGBTN, COLOUR_DARK_GREEN, WID_ROT_TRUCK_STATION),
817  SetFill(0, 1), SetMinimalSize(22, 22), SetDataTip(SPR_IMG_TRUCK_BAY, STR_ROAD_TOOLBAR_TOOLTIP_BUILD_TRUCK_LOADING_BAY),
818  NWidget(WWT_PANEL, COLOUR_DARK_GREEN, -1), SetMinimalSize(0, 22), SetFill(1, 1), EndContainer(),
819  NWidget(WWT_IMGBTN, COLOUR_DARK_GREEN, WID_ROT_ONE_WAY),
820  SetFill(0, 1), SetMinimalSize(22, 22), SetDataTip(SPR_IMG_ROAD_ONE_WAY, STR_ROAD_TOOLBAR_TOOLTIP_TOGGLE_ONE_WAY_ROAD),
821  NWidget(WWT_IMGBTN, COLOUR_DARK_GREEN, WID_ROT_BUILD_BRIDGE),
822  SetFill(0, 1), SetMinimalSize(43, 22), SetDataTip(SPR_IMG_BRIDGE, STR_ROAD_TOOLBAR_TOOLTIP_BUILD_ROAD_BRIDGE),
823  NWidget(WWT_IMGBTN, COLOUR_DARK_GREEN, WID_ROT_BUILD_TUNNEL),
824  SetFill(0, 1), SetMinimalSize(22, 22), SetDataTip(SPR_IMG_ROAD_TUNNEL, STR_ROAD_TOOLBAR_TOOLTIP_BUILD_ROAD_TUNNEL),
825  NWidget(WWT_IMGBTN, COLOUR_DARK_GREEN, WID_ROT_REMOVE),
826  SetFill(0, 1), SetMinimalSize(22, 22), SetDataTip(SPR_IMG_REMOVE, STR_ROAD_TOOLBAR_TOOLTIP_TOGGLE_BUILD_REMOVE_FOR_ROAD),
827  NWidget(WWT_IMGBTN, COLOUR_DARK_GREEN, WID_ROT_CONVERT_ROAD),
828  SetFill(0, 1), SetMinimalSize(22, 22), SetDataTip(SPR_IMG_CONVERT_ROAD, STR_ROAD_TOOLBAR_TOOLTIP_CONVERT_ROAD),
829  EndContainer(),
830 };
831 
832 static WindowDesc _build_road_desc(
833  WDP_ALIGN_TOOLBAR, "toolbar_road", 0, 0,
836  _nested_build_road_widgets, lengthof(_nested_build_road_widgets),
837  &BuildRoadToolbarWindow::road_hotkeys
838 );
839 
840 static const NWidgetPart _nested_build_tramway_widgets[] = {
842  NWidget(WWT_CLOSEBOX, COLOUR_DARK_GREEN),
843  NWidget(WWT_CAPTION, COLOUR_DARK_GREEN, WID_ROT_CAPTION), SetDataTip(STR_WHITE_STRING, STR_TOOLTIP_WINDOW_TITLE_DRAG_THIS),
844  NWidget(WWT_STICKYBOX, COLOUR_DARK_GREEN),
845  EndContainer(),
847  NWidget(WWT_IMGBTN, COLOUR_DARK_GREEN, WID_ROT_ROAD_X),
848  SetFill(0, 1), SetMinimalSize(22, 22), SetDataTip(SPR_IMG_TRAMWAY_X_DIR, STR_ROAD_TOOLBAR_TOOLTIP_BUILD_TRAMWAY_SECTION),
849  NWidget(WWT_IMGBTN, COLOUR_DARK_GREEN, WID_ROT_ROAD_Y),
850  SetFill(0, 1), SetMinimalSize(22, 22), SetDataTip(SPR_IMG_TRAMWAY_Y_DIR, STR_ROAD_TOOLBAR_TOOLTIP_BUILD_TRAMWAY_SECTION),
851  NWidget(WWT_IMGBTN, COLOUR_DARK_GREEN, WID_ROT_AUTOROAD),
852  SetFill(0, 1), SetMinimalSize(22, 22), SetDataTip(SPR_IMG_AUTOTRAM, STR_ROAD_TOOLBAR_TOOLTIP_BUILD_AUTOTRAM),
853  NWidget(WWT_IMGBTN, COLOUR_DARK_GREEN, WID_ROT_DEMOLISH),
854  SetFill(0, 1), SetMinimalSize(22, 22), SetDataTip(SPR_IMG_DYNAMITE, STR_TOOLTIP_DEMOLISH_BUILDINGS_ETC),
855  NWidget(WWT_IMGBTN, COLOUR_DARK_GREEN, WID_ROT_DEPOT),
856  SetFill(0, 1), SetMinimalSize(22, 22), SetDataTip(SPR_IMG_ROAD_DEPOT, STR_ROAD_TOOLBAR_TOOLTIP_BUILD_TRAM_VEHICLE_DEPOT),
857  NWidget(WWT_IMGBTN, COLOUR_DARK_GREEN, WID_ROT_BUS_STATION),
858  SetFill(0, 1), SetMinimalSize(22, 22), SetDataTip(SPR_IMG_BUS_STATION, STR_ROAD_TOOLBAR_TOOLTIP_BUILD_PASSENGER_TRAM_STATION),
859  NWidget(WWT_IMGBTN, COLOUR_DARK_GREEN, WID_ROT_TRUCK_STATION),
860  SetFill(0, 1), SetMinimalSize(22, 22), SetDataTip(SPR_IMG_TRUCK_BAY, STR_ROAD_TOOLBAR_TOOLTIP_BUILD_CARGO_TRAM_STATION),
861  NWidget(WWT_PANEL, COLOUR_DARK_GREEN, -1), SetMinimalSize(0, 22), SetFill(1, 1), EndContainer(),
862  NWidget(WWT_IMGBTN, COLOUR_DARK_GREEN, WID_ROT_BUILD_BRIDGE),
863  SetFill(0, 1), SetMinimalSize(43, 22), SetDataTip(SPR_IMG_BRIDGE, STR_ROAD_TOOLBAR_TOOLTIP_BUILD_TRAMWAY_BRIDGE),
864  NWidget(WWT_IMGBTN, COLOUR_DARK_GREEN, WID_ROT_BUILD_TUNNEL),
865  SetFill(0, 1), SetMinimalSize(22, 22), SetDataTip(SPR_IMG_ROAD_TUNNEL, STR_ROAD_TOOLBAR_TOOLTIP_BUILD_TRAMWAY_TUNNEL),
866  NWidget(WWT_IMGBTN, COLOUR_DARK_GREEN, WID_ROT_REMOVE),
867  SetFill(0, 1), SetMinimalSize(22, 22), SetDataTip(SPR_IMG_REMOVE, STR_ROAD_TOOLBAR_TOOLTIP_TOGGLE_BUILD_REMOVE_FOR_TRAMWAYS),
868  NWidget(WWT_IMGBTN, COLOUR_DARK_GREEN, WID_ROT_CONVERT_ROAD),
869  SetFill(0, 1), SetMinimalSize(22, 22), SetDataTip(SPR_IMG_CONVERT_ROAD, STR_ROAD_TOOLBAR_TOOLTIP_CONVERT_TRAM),
870  EndContainer(),
871 };
872 
873 static WindowDesc _build_tramway_desc(
874  WDP_ALIGN_TOOLBAR, "toolbar_tramway", 0, 0,
877  _nested_build_tramway_widgets, lengthof(_nested_build_tramway_widgets),
878  &BuildRoadToolbarWindow::tram_hotkeys
879 );
880 
889 {
890  if (!Company::IsValidID(_local_company)) return nullptr;
891  if (!ValParamRoadType(roadtype)) return nullptr;
892 
894  _cur_roadtype = roadtype;
895 
896  return AllocateWindowDescFront<BuildRoadToolbarWindow>(RoadTypeIsRoad(_cur_roadtype) ? &_build_road_desc : &_build_tramway_desc, TRANSPORT_ROAD);
897 }
898 
899 static const NWidgetPart _nested_build_road_scen_widgets[] = {
901  NWidget(WWT_CLOSEBOX, COLOUR_DARK_GREEN),
902  NWidget(WWT_CAPTION, COLOUR_DARK_GREEN, WID_ROT_CAPTION), SetDataTip(STR_WHITE_STRING, STR_TOOLTIP_WINDOW_TITLE_DRAG_THIS),
903  NWidget(WWT_STICKYBOX, COLOUR_DARK_GREEN),
904  EndContainer(),
906  NWidget(WWT_IMGBTN, COLOUR_DARK_GREEN, WID_ROT_ROAD_X),
907  SetFill(0, 1), SetMinimalSize(22, 22), SetDataTip(SPR_IMG_ROAD_X_DIR, STR_ROAD_TOOLBAR_TOOLTIP_BUILD_ROAD_SECTION),
908  NWidget(WWT_IMGBTN, COLOUR_DARK_GREEN, WID_ROT_ROAD_Y),
909  SetFill(0, 1), SetMinimalSize(22, 22), SetDataTip(SPR_IMG_ROAD_Y_DIR, STR_ROAD_TOOLBAR_TOOLTIP_BUILD_ROAD_SECTION),
910  NWidget(WWT_IMGBTN, COLOUR_DARK_GREEN, WID_ROT_AUTOROAD),
911  SetFill(0, 1), SetMinimalSize(22, 22), SetDataTip(SPR_IMG_AUTOROAD, STR_ROAD_TOOLBAR_TOOLTIP_BUILD_AUTOROAD),
912  NWidget(WWT_IMGBTN, COLOUR_DARK_GREEN, WID_ROT_DEMOLISH),
913  SetFill(0, 1), SetMinimalSize(22, 22), SetDataTip(SPR_IMG_DYNAMITE, STR_TOOLTIP_DEMOLISH_BUILDINGS_ETC),
914  NWidget(WWT_PANEL, COLOUR_DARK_GREEN, -1), SetMinimalSize(0, 22), SetFill(1, 1), EndContainer(),
915  NWidget(WWT_IMGBTN, COLOUR_DARK_GREEN, WID_ROT_ONE_WAY),
916  SetFill(0, 1), SetMinimalSize(22, 22), SetDataTip(SPR_IMG_ROAD_ONE_WAY, STR_ROAD_TOOLBAR_TOOLTIP_TOGGLE_ONE_WAY_ROAD),
917  NWidget(WWT_IMGBTN, COLOUR_DARK_GREEN, WID_ROT_BUILD_BRIDGE),
918  SetFill(0, 1), SetMinimalSize(43, 22), SetDataTip(SPR_IMG_BRIDGE, STR_ROAD_TOOLBAR_TOOLTIP_BUILD_ROAD_BRIDGE),
919  NWidget(WWT_IMGBTN, COLOUR_DARK_GREEN, WID_ROT_BUILD_TUNNEL),
920  SetFill(0, 1), SetMinimalSize(22, 22), SetDataTip(SPR_IMG_ROAD_TUNNEL, STR_ROAD_TOOLBAR_TOOLTIP_BUILD_ROAD_TUNNEL),
921  NWidget(WWT_IMGBTN, COLOUR_DARK_GREEN, WID_ROT_REMOVE),
922  SetFill(0, 1), SetMinimalSize(22, 22), SetDataTip(SPR_IMG_REMOVE, STR_ROAD_TOOLBAR_TOOLTIP_TOGGLE_BUILD_REMOVE_FOR_ROAD),
923  NWidget(WWT_IMGBTN, COLOUR_DARK_GREEN, WID_ROT_CONVERT_ROAD),
924  SetFill(0, 1), SetMinimalSize(22, 22), SetDataTip(SPR_IMG_CONVERT_ROAD, STR_ROAD_TOOLBAR_TOOLTIP_CONVERT_ROAD),
925  EndContainer(),
926 };
927 
928 static WindowDesc _build_road_scen_desc(
929  WDP_AUTO, "toolbar_road_scen", 0, 0,
932  _nested_build_road_scen_widgets, lengthof(_nested_build_road_scen_widgets),
933  &BuildRoadToolbarWindow::road_hotkeys
934 );
935 
936 static const NWidgetPart _nested_build_tramway_scen_widgets[] = {
938  NWidget(WWT_CLOSEBOX, COLOUR_DARK_GREEN),
939  NWidget(WWT_CAPTION, COLOUR_DARK_GREEN, WID_ROT_CAPTION), SetDataTip(STR_WHITE_STRING, STR_TOOLTIP_WINDOW_TITLE_DRAG_THIS),
940  NWidget(WWT_STICKYBOX, COLOUR_DARK_GREEN),
941  EndContainer(),
943  NWidget(WWT_IMGBTN, COLOUR_DARK_GREEN, WID_ROT_ROAD_X),
944  SetFill(0, 1), SetMinimalSize(22, 22), SetDataTip(SPR_IMG_TRAMWAY_X_DIR, STR_ROAD_TOOLBAR_TOOLTIP_BUILD_TRAMWAY_SECTION),
945  NWidget(WWT_IMGBTN, COLOUR_DARK_GREEN, WID_ROT_ROAD_Y),
946  SetFill(0, 1), SetMinimalSize(22, 22), SetDataTip(SPR_IMG_TRAMWAY_Y_DIR, STR_ROAD_TOOLBAR_TOOLTIP_BUILD_TRAMWAY_SECTION),
947  NWidget(WWT_IMGBTN, COLOUR_DARK_GREEN, WID_ROT_AUTOROAD),
948  SetFill(0, 1), SetMinimalSize(22, 22), SetDataTip(SPR_IMG_AUTOTRAM, STR_ROAD_TOOLBAR_TOOLTIP_BUILD_AUTOTRAM),
949  NWidget(WWT_IMGBTN, COLOUR_DARK_GREEN, WID_ROT_DEMOLISH),
950  SetFill(0, 1), SetMinimalSize(22, 22), SetDataTip(SPR_IMG_DYNAMITE, STR_TOOLTIP_DEMOLISH_BUILDINGS_ETC),
951  NWidget(WWT_PANEL, COLOUR_DARK_GREEN, -1), SetMinimalSize(0, 22), SetFill(1, 1), EndContainer(),
952  NWidget(WWT_IMGBTN, COLOUR_DARK_GREEN, WID_ROT_BUILD_BRIDGE),
953  SetFill(0, 1), SetMinimalSize(43, 22), SetDataTip(SPR_IMG_BRIDGE, STR_ROAD_TOOLBAR_TOOLTIP_BUILD_TRAMWAY_BRIDGE),
954  NWidget(WWT_IMGBTN, COLOUR_DARK_GREEN, WID_ROT_BUILD_TUNNEL),
955  SetFill(0, 1), SetMinimalSize(22, 22), SetDataTip(SPR_IMG_ROAD_TUNNEL, STR_ROAD_TOOLBAR_TOOLTIP_BUILD_TRAMWAY_TUNNEL),
956  NWidget(WWT_IMGBTN, COLOUR_DARK_GREEN, WID_ROT_REMOVE),
957  SetFill(0, 1), SetMinimalSize(22, 22), SetDataTip(SPR_IMG_REMOVE, STR_ROAD_TOOLBAR_TOOLTIP_TOGGLE_BUILD_REMOVE_FOR_TRAMWAYS),
958  NWidget(WWT_IMGBTN, COLOUR_DARK_GREEN, WID_ROT_CONVERT_ROAD),
959  SetFill(0, 1), SetMinimalSize(22, 22), SetDataTip(SPR_IMG_CONVERT_ROAD, STR_ROAD_TOOLBAR_TOOLTIP_CONVERT_TRAM),
960  EndContainer(),
961 };
962 
963 static WindowDesc _build_tramway_scen_desc(
964  WDP_AUTO, "toolbar_tram_scen", 0, 0,
967  _nested_build_tramway_scen_widgets, lengthof(_nested_build_tramway_scen_widgets),
968  &BuildRoadToolbarWindow::tram_hotkeys
969 );
970 
976 {
978  _cur_roadtype = roadtype;
979 
980  return AllocateWindowDescFront<BuildRoadToolbarWindow>(RoadTypeIsRoad(_cur_roadtype) ? &_build_road_scen_desc : &_build_tramway_scen_desc, TRANSPORT_ROAD);
981 }
982 
985  {
986  this->CreateNestedTree();
987 
988  this->LowerWidget(_road_depot_orientation + WID_BROD_DEPOT_NE);
989  if (RoadTypeIsTram(_cur_roadtype)) {
990  this->GetWidget<NWidgetCore>(WID_BROD_CAPTION)->widget_data = STR_BUILD_DEPOT_TRAM_ORIENTATION_CAPTION;
991  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;
992  }
993 
995  }
996 
997  void UpdateWidgetSize(int widget, Dimension *size, const Dimension &padding, Dimension *fill, Dimension *resize) override
998  {
999  if (!IsInsideMM(widget, WID_BROD_DEPOT_NE, WID_BROD_DEPOT_NW + 1)) return;
1000 
1001  size->width = ScaleGUITrad(64) + 2;
1002  size->height = ScaleGUITrad(48) + 2;
1003  }
1004 
1005  void DrawWidget(const Rect &r, int widget) const override
1006  {
1007  if (!IsInsideMM(widget, WID_BROD_DEPOT_NE, WID_BROD_DEPOT_NW + 1)) return;
1008 
1009  DrawRoadDepotSprite(r.left + 1 + ScaleGUITrad(31), r.bottom - ScaleGUITrad(31), (DiagDirection)(widget - WID_BROD_DEPOT_NE + DIAGDIR_NE), _cur_roadtype);
1010  }
1011 
1012  void OnClick(Point pt, int widget, int click_count) override
1013  {
1014  switch (widget) {
1015  case WID_BROD_DEPOT_NW:
1016  case WID_BROD_DEPOT_NE:
1017  case WID_BROD_DEPOT_SW:
1018  case WID_BROD_DEPOT_SE:
1019  this->RaiseWidget(_road_depot_orientation + WID_BROD_DEPOT_NE);
1020  _road_depot_orientation = (DiagDirection)(widget - WID_BROD_DEPOT_NE);
1021  this->LowerWidget(_road_depot_orientation + WID_BROD_DEPOT_NE);
1022  if (_settings_client.sound.click_beep) SndPlayFx(SND_15_BEEP);
1023  this->SetDirty();
1024  break;
1025 
1026  default:
1027  break;
1028  }
1029  }
1030 };
1031 
1032 static const NWidgetPart _nested_build_road_depot_widgets[] = {
1034  NWidget(WWT_CLOSEBOX, COLOUR_DARK_GREEN),
1035  NWidget(WWT_CAPTION, COLOUR_DARK_GREEN, WID_BROD_CAPTION), SetDataTip(STR_BUILD_DEPOT_ROAD_ORIENTATION_CAPTION, STR_TOOLTIP_WINDOW_TITLE_DRAG_THIS),
1036  EndContainer(),
1037  NWidget(WWT_PANEL, COLOUR_DARK_GREEN),
1040  NWidget(NWID_SPACER), SetMinimalSize(3, 0), SetFill(1, 0),
1042  NWidget(WWT_PANEL, COLOUR_GREY, WID_BROD_DEPOT_NW), SetMinimalSize(66, 50), SetDataTip(0x0, STR_BUILD_DEPOT_ROAD_ORIENTATION_SELECT_TOOLTIP),
1043  EndContainer(),
1045  NWidget(WWT_PANEL, COLOUR_GREY, WID_BROD_DEPOT_SW), SetMinimalSize(66, 50), SetDataTip(0x0, STR_BUILD_DEPOT_ROAD_ORIENTATION_SELECT_TOOLTIP),
1046  EndContainer(),
1047  EndContainer(),
1050  NWidget(WWT_PANEL, COLOUR_GREY, WID_BROD_DEPOT_NE), SetMinimalSize(66, 50), SetDataTip(0x0, STR_BUILD_DEPOT_ROAD_ORIENTATION_SELECT_TOOLTIP),
1051  EndContainer(),
1053  NWidget(WWT_PANEL, COLOUR_GREY, WID_BROD_DEPOT_SE), SetMinimalSize(66, 50), SetDataTip(0x0, STR_BUILD_DEPOT_ROAD_ORIENTATION_SELECT_TOOLTIP),
1054  EndContainer(),
1055  EndContainer(),
1056  NWidget(NWID_SPACER), SetMinimalSize(3, 0), SetFill(1, 0),
1057  EndContainer(),
1059  EndContainer(),
1060 };
1061 
1062 static WindowDesc _build_road_depot_desc(
1063  WDP_AUTO, nullptr, 0, 0,
1066  _nested_build_road_depot_widgets, lengthof(_nested_build_road_depot_widgets)
1067 );
1068 
1069 static void ShowRoadDepotPicker(Window *parent)
1070 {
1071  new BuildRoadDepotWindow(&_build_road_depot_desc, parent);
1072 }
1073 
1076  {
1077  this->CreateNestedTree();
1078 
1079  /* Trams don't have non-drivethrough stations */
1080  if (RoadTypeIsTram(_cur_roadtype) && _road_station_picker_orientation < DIAGDIR_END) {
1081  _road_station_picker_orientation = DIAGDIR_END;
1082  }
1083  const RoadTypeInfo *rti = GetRoadTypeInfo(_cur_roadtype);
1084  this->GetWidget<NWidgetCore>(WID_BROS_CAPTION)->widget_data = rti->strings.picker_title[rs];
1085 
1086  for (uint i = RoadTypeIsTram(_cur_roadtype) ? WID_BROS_STATION_X : WID_BROS_STATION_NE; i < WID_BROS_LT_OFF; i++) {
1087  this->GetWidget<NWidgetCore>(i)->tool_tip = rti->strings.picker_tooltip[rs];
1088  }
1089 
1090  this->LowerWidget(_road_station_picker_orientation + WID_BROS_STATION_NE);
1091  this->LowerWidget(_settings_client.gui.station_show_coverage + WID_BROS_LT_OFF);
1092 
1094 
1096  }
1097 
1098  virtual ~BuildRoadStationWindow()
1099  {
1101  }
1102 
1103  void OnPaint() override
1104  {
1105  this->DrawWidgets();
1106 
1109  SetTileSelectBigSize(-rad, -rad, 2 * rad, 2 * rad);
1110  } else {
1111  SetTileSelectSize(1, 1);
1112  }
1113 
1114  /* 'Accepts' and 'Supplies' texts. */
1116  int top = this->GetWidget<NWidgetBase>(WID_BROS_LT_ON)->pos_y + this->GetWidget<NWidgetBase>(WID_BROS_LT_ON)->current_y + WD_PAR_VSEP_NORMAL;
1117  NWidgetBase *back_nwi = this->GetWidget<NWidgetBase>(WID_BROS_BACKGROUND);
1118  int right = back_nwi->pos_x + back_nwi->current_x;
1119  int bottom = back_nwi->pos_y + back_nwi->current_y;
1122  /* Resize background if the window is too small.
1123  * Never make the window smaller to avoid oscillating if the size change affects the acceptance.
1124  * (This is the case, if making the window bigger moves the mouse into the window.) */
1125  if (top > bottom) {
1126  ResizeWindow(this, 0, top - bottom, false);
1127  }
1128  }
1129 
1130  void UpdateWidgetSize(int widget, Dimension *size, const Dimension &padding, Dimension *fill, Dimension *resize) override
1131  {
1132  if (!IsInsideMM(widget, WID_BROS_STATION_NE, WID_BROS_STATION_Y + 1)) return;
1133 
1134  size->width = ScaleGUITrad(64) + 2;
1135  size->height = ScaleGUITrad(48) + 2;
1136  }
1137 
1138  void DrawWidget(const Rect &r, int widget) const override
1139  {
1140  if (!IsInsideMM(widget, WID_BROS_STATION_NE, WID_BROS_STATION_Y + 1)) return;
1141 
1142  StationType st = (this->window_class == WC_BUS_STATION) ? STATION_BUS : STATION_TRUCK;
1143  StationPickerDrawSprite(r.left + 1 + ScaleGUITrad(31), r.bottom - ScaleGUITrad(31), st, INVALID_RAILTYPE, _cur_roadtype, widget - WID_BROS_STATION_NE);
1144  }
1145 
1146  void OnClick(Point pt, int widget, int click_count) override
1147  {
1148  switch (widget) {
1149  case WID_BROS_STATION_NE:
1150  case WID_BROS_STATION_SE:
1151  case WID_BROS_STATION_SW:
1152  case WID_BROS_STATION_NW:
1153  case WID_BROS_STATION_X:
1154  case WID_BROS_STATION_Y:
1155  this->RaiseWidget(_road_station_picker_orientation + WID_BROS_STATION_NE);
1156  _road_station_picker_orientation = (DiagDirection)(widget - WID_BROS_STATION_NE);
1157  this->LowerWidget(_road_station_picker_orientation + WID_BROS_STATION_NE);
1158  if (_settings_client.sound.click_beep) SndPlayFx(SND_15_BEEP);
1159  this->SetDirty();
1161  break;
1162 
1163  case WID_BROS_LT_OFF:
1164  case WID_BROS_LT_ON:
1168  if (_settings_client.sound.click_beep) SndPlayFx(SND_15_BEEP);
1169  this->SetDirty();
1170  SetViewportCatchmentStation(nullptr, true);
1171  break;
1172 
1173  default:
1174  break;
1175  }
1176  }
1177 
1178  void OnRealtimeTick(uint delta_ms) override
1179  {
1181  }
1182 };
1183 
1187  NWidget(WWT_CLOSEBOX, COLOUR_DARK_GREEN),
1188  NWidget(WWT_CAPTION, COLOUR_DARK_GREEN, WID_BROS_CAPTION),
1189  EndContainer(),
1190  NWidget(WWT_PANEL, COLOUR_DARK_GREEN, WID_BROS_BACKGROUND),
1192  NWidget(NWID_HORIZONTAL), SetPIP(0, 2, 0),
1193  NWidget(NWID_SPACER), SetFill(1, 0),
1194  NWidget(WWT_PANEL, COLOUR_GREY, WID_BROS_STATION_NW), SetMinimalSize(66, 50), SetFill(0, 0), EndContainer(),
1195  NWidget(WWT_PANEL, COLOUR_GREY, WID_BROS_STATION_NE), SetMinimalSize(66, 50), SetFill(0, 0), EndContainer(),
1196  NWidget(WWT_PANEL, COLOUR_GREY, WID_BROS_STATION_X), SetMinimalSize(66, 50), SetFill(0, 0), EndContainer(),
1197  NWidget(NWID_SPACER), SetFill(1, 0),
1198  EndContainer(),
1200  NWidget(NWID_HORIZONTAL), SetPIP(0, 2, 0),
1201  NWidget(NWID_SPACER), SetFill(1, 0),
1202  NWidget(WWT_PANEL, COLOUR_GREY, WID_BROS_STATION_SW), SetMinimalSize(66, 50), SetFill(0, 0), EndContainer(),
1203  NWidget(WWT_PANEL, COLOUR_GREY, WID_BROS_STATION_SE), SetMinimalSize(66, 50), SetFill(0, 0), EndContainer(),
1204  NWidget(WWT_PANEL, COLOUR_GREY, WID_BROS_STATION_Y), SetMinimalSize(66, 50), SetFill(0, 0), EndContainer(),
1205  NWidget(NWID_SPACER), SetFill(1, 0),
1206  EndContainer(),
1208  NWidget(NWID_HORIZONTAL), SetPIP(2, 0, 2),
1209  NWidget(WWT_LABEL, COLOUR_DARK_GREEN, WID_BROS_INFO), SetMinimalSize(140, 14), SetDataTip(STR_STATION_BUILD_COVERAGE_AREA_TITLE, STR_NULL),
1210  NWidget(NWID_SPACER), SetFill(1, 0),
1211  EndContainer(),
1212  NWidget(NWID_HORIZONTAL), SetPIP(2, 0, 2),
1213  NWidget(NWID_SPACER), SetFill(1, 0),
1214  NWidget(WWT_TEXTBTN, COLOUR_GREY, WID_BROS_LT_OFF), SetMinimalSize(60, 12),
1215  SetDataTip(STR_STATION_BUILD_COVERAGE_OFF, STR_STATION_BUILD_COVERAGE_AREA_OFF_TOOLTIP),
1216  NWidget(WWT_TEXTBTN, COLOUR_GREY, WID_BROS_LT_ON), SetMinimalSize(60, 12),
1217  SetDataTip(STR_STATION_BUILD_COVERAGE_ON, STR_STATION_BUILD_COVERAGE_AREA_ON_TOOLTIP),
1218  NWidget(NWID_SPACER), SetFill(1, 0),
1219  EndContainer(),
1220  NWidget(NWID_SPACER), SetMinimalSize(0, 10), SetResize(0, 1),
1221  EndContainer(),
1222 };
1223 
1224 static WindowDesc _road_station_picker_desc(
1225  WDP_AUTO, nullptr, 0, 0,
1229 );
1230 
1234  NWidget(WWT_CLOSEBOX, COLOUR_DARK_GREEN),
1235  NWidget(WWT_CAPTION, COLOUR_DARK_GREEN, WID_BROS_CAPTION),
1236  EndContainer(),
1237  NWidget(WWT_PANEL, COLOUR_DARK_GREEN, WID_BROS_BACKGROUND),
1239  NWidget(NWID_HORIZONTAL), SetPIP(0, 2, 0),
1240  NWidget(NWID_SPACER), SetFill(1, 0),
1241  NWidget(WWT_PANEL, COLOUR_GREY, WID_BROS_STATION_X), SetMinimalSize(66, 50), SetFill(0, 0), EndContainer(),
1242  NWidget(WWT_PANEL, COLOUR_GREY, WID_BROS_STATION_Y), SetMinimalSize(66, 50), SetFill(0, 0), EndContainer(),
1243  NWidget(NWID_SPACER), SetFill(1, 0),
1244  EndContainer(),
1246  NWidget(NWID_HORIZONTAL), SetPIP(2, 0, 2),
1247  NWidget(WWT_LABEL, COLOUR_DARK_GREEN, WID_BROS_INFO), SetMinimalSize(140, 14), SetDataTip(STR_STATION_BUILD_COVERAGE_AREA_TITLE, STR_NULL),
1248  NWidget(NWID_SPACER), SetFill(1, 0),
1249  EndContainer(),
1250  NWidget(NWID_HORIZONTAL), SetPIP(2, 0, 2),
1251  NWidget(NWID_SPACER), SetFill(1, 0),
1252  NWidget(WWT_TEXTBTN, COLOUR_GREY, WID_BROS_LT_OFF), SetMinimalSize(60, 12),
1253  SetDataTip(STR_STATION_BUILD_COVERAGE_OFF, STR_STATION_BUILD_COVERAGE_AREA_OFF_TOOLTIP),
1254  NWidget(WWT_TEXTBTN, COLOUR_GREY, WID_BROS_LT_ON), SetMinimalSize(60, 12),
1255  SetDataTip(STR_STATION_BUILD_COVERAGE_ON, STR_STATION_BUILD_COVERAGE_AREA_ON_TOOLTIP),
1256  NWidget(NWID_SPACER), SetFill(1, 0),
1257  EndContainer(),
1258  NWidget(NWID_SPACER), SetMinimalSize(0, 10), SetResize(0, 1),
1259  EndContainer(),
1260 };
1261 
1262 static WindowDesc _tram_station_picker_desc(
1263  WDP_AUTO, nullptr, 0, 0,
1267 );
1268 
1269 static void ShowRVStationPicker(Window *parent, RoadStopType rs)
1270 {
1271  new BuildRoadStationWindow(RoadTypeIsRoad(_cur_roadtype) ? &_road_station_picker_desc : &_tram_station_picker_desc, parent, rs);
1272 }
1273 
1274 void InitializeRoadGui()
1275 {
1276  _road_depot_orientation = DIAGDIR_NW;
1277  _road_station_picker_orientation = DIAGDIR_NW;
1278 }
1279 
1284 {
1286  if (w != nullptr) w->ModifyRoadType(_cur_roadtype);
1287 }
1288 
1289 DropDownList GetRoadTypeDropDownList(RoadTramTypes rtts, bool for_replacement, bool all_option)
1290 {
1291  RoadTypes used_roadtypes;
1292  RoadTypes avail_roadtypes;
1293 
1294  const Company *c = Company::Get(_local_company);
1295 
1296  /* Find the used roadtypes. */
1297  if (for_replacement) {
1298  avail_roadtypes = GetCompanyRoadTypes(c->index, false);
1299  used_roadtypes = GetRoadTypes(false);
1300  } else {
1301  avail_roadtypes = c->avail_roadtypes;
1302  used_roadtypes = GetRoadTypes(true);
1303  }
1304 
1305  /* Filter listed road types */
1306  if (!HasBit(rtts, RTT_ROAD)) used_roadtypes &= _roadtypes_type;
1307  if (!HasBit(rtts, RTT_TRAM)) used_roadtypes &= ~_roadtypes_type;
1308 
1309  DropDownList list;
1310 
1311  if (all_option) {
1312  list.emplace_back(new DropDownListStringItem(STR_REPLACE_ALL_ROADTYPE, INVALID_ROADTYPE, false));
1313  }
1314 
1315  Dimension d = { 0, 0 };
1316  RoadType rt;
1317  /* Get largest icon size, to ensure text is aligned on each menu item. */
1318  if (!for_replacement) {
1320  if (!HasBit(used_roadtypes, rt)) continue;
1321  const RoadTypeInfo *rti = GetRoadTypeInfo(rt);
1323  }
1324  }
1325 
1327  /* If it's not used ever, don't show it to the user. */
1328  if (!HasBit(used_roadtypes, rt)) continue;
1329 
1330  const RoadTypeInfo *rti = GetRoadTypeInfo(rt);
1331 
1333  if (for_replacement) {
1334  item = new DropDownListParamStringItem(rti->strings.replace_text, rt, !HasBit(avail_roadtypes, rt));
1335  } else {
1336  StringID str = rti->max_speed > 0 ? STR_TOOLBAR_RAILTYPE_VELOCITY : STR_JUST_STRING;
1337  DropDownListIconItem *iconitem = new DropDownListIconItem(rti->gui_sprites.build_x_road, PAL_NONE, str, rt, !HasBit(avail_roadtypes, rt));
1338  iconitem->SetDimension(d);
1339  item = iconitem;
1340  }
1341  item->SetParam(0, rti->strings.menu_text);
1342  item->SetParam(1, rti->max_speed / 2);
1343  list.emplace_back(item);
1344  }
1345 
1346  if (list.size() == 0) {
1347  /* Empty dropdowns are not allowed */
1348  list.emplace_back(new DropDownListStringItem(STR_NONE, INVALID_ROADTYPE, true));
1349  }
1350 
1351  return list;
1352 }
1353 
1354 DropDownList GetScenRoadTypeDropDownList(RoadTramTypes rtts)
1355 {
1356  RoadTypes avail_roadtypes = GetRoadTypes(false);
1357  avail_roadtypes = AddDateIntroducedRoadTypes(avail_roadtypes, _date);
1358  RoadTypes used_roadtypes = GetRoadTypes(true);
1359 
1360  /* Filter listed road types */
1361  if (!HasBit(rtts, RTT_ROAD)) used_roadtypes &= _roadtypes_type;
1362  if (!HasBit(rtts, RTT_TRAM)) used_roadtypes &= ~_roadtypes_type;
1363 
1364  DropDownList list;
1365 
1366  /* If it's not used ever, don't show it to the user. */
1367  Dimension d = { 0, 0 };
1368  RoadType rt;
1370  if (!HasBit(used_roadtypes, rt)) continue;
1371  const RoadTypeInfo *rti = GetRoadTypeInfo(rt);
1373  }
1375  if (!HasBit(used_roadtypes, rt)) continue;
1376 
1377  const RoadTypeInfo *rti = GetRoadTypeInfo(rt);
1378 
1379  StringID str = rti->max_speed > 0 ? STR_TOOLBAR_RAILTYPE_VELOCITY : STR_JUST_STRING;
1380  DropDownListIconItem *item = new DropDownListIconItem(rti->gui_sprites.build_x_road, PAL_NONE, str, rt, !HasBit(avail_roadtypes, rt));
1381  item->SetDimension(d);
1382  item->SetParam(0, rti->strings.menu_text);
1383  item->SetParam(1, rti->max_speed / 2);
1384  list.emplace_back(item);
1385  }
1386 
1387  if (list.size() == 0) {
1388  /* Empty dropdowns are not allowed */
1389  list.emplace_back(new DropDownListStringItem(STR_NONE, -1, true));
1390  }
1391 
1392  return list;
1393 }
_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:1232
ES_HANDLED
@ ES_HANDLED
The passed event is handled.
Definition: window_type.h:718
RoadTypeInfo::toolbar_caption
StringID toolbar_caption
Caption in the construction toolbar GUI for this rail type.
Definition: road.h:101
SetTileSelectSize
void SetTileSelectSize(int w, int h)
Highlight w by h tiles at the cursor.
Definition: viewport.cpp:2470
DDSP_DEMOLISH_AREA
@ DDSP_DEMOLISH_AREA
Clear area.
Definition: viewport_type.h:116
tunnelbridge.h
_remove_button_clicked
static bool _remove_button_clicked
Flag whether 'remove' toggle-button is currently enabled.
Definition: rail_gui.cpp:45
CA_UNMODIFIED
@ CA_UNMODIFIED
Catchment for all stations with "modified catchment" disabled.
Definition: station_type.h:82
WID_ROT_REMOVE
@ WID_ROT_REMOVE
Remove road.
Definition: road_widget.h:27
CMD_MSG
#define CMD_MSG(x)
Used to combine a StringID with the command.
Definition: command_type.h:372
TileIndex
uint32 TileIndex
The index/ID of a Tile.
Definition: tile_type.h:78
PlaceRoad_Bridge
static void PlaceRoad_Bridge(TileIndex tile, Window *w)
Callback to start placing a bridge.
Definition: road_gui.cpp:78
RoadTypeInfo
Definition: road.h:75
RoadTypeInfo::gui_sprites
struct RoadTypeInfo::@42 gui_sprites
struct containing the sprites for the road GUI.
sound_func.h
TileHighlightData::size
Point size
Size, in tile "units", of the white/red selection area.
Definition: tilehighlight_type.h:48
RoadTypeInfo::err_build_road
StringID err_build_road
Building a normal piece of road.
Definition: road.h:107
DoCommand
CommandCost DoCommand(const CommandContainer *container, DoCommandFlag flags)
Shorthand for calling the long DoCommand with a container.
Definition: command.cpp:450
GUISettings::station_show_coverage
bool station_show_coverage
whether to highlight coverage area
Definition: settings_type.h:140
Pool::PoolItem<&_company_pool >::Get
static Titem * Get(size_t index)
Returns Titem with given index.
Definition: pool_type.hpp:329
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:136
BuildRoadStationWindow::OnPaint
void OnPaint() override
The window must be repainted.
Definition: road_gui.cpp:1103
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:561
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:102
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:2707
GB
static uint GB(const T x, const uint8 s, const uint8 n)
Fetch n bits from x, started at bit s.
Definition: bitmath_func.hpp:32
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:1130
RoadTypeInfo::build_y_road
SpriteID build_y_road
button for building single rail in Y direction
Definition: road.h:83
Dimension
Dimensions (a width and height) of a rectangle in 2D.
Definition: geometry_type.hpp:27
command_func.h
RoadTypeInfo::strings
struct RoadTypeInfo::@44 strings
Strings associated with the rail type.
WWT_STICKYBOX
@ WWT_STICKYBOX
Sticky box (at top-right of a window, after WWT_DEFSIZEBOX)
Definition: widget_type.h:64
WDF_CONSTRUCTION
@ WDF_CONSTRUCTION
This window is used for construction; close it whenever changing company.
Definition: window_gui.h:208
PlaceRoad_TruckStation
static void PlaceRoad_TruckStation(TileIndex tile)
Callback for placing a truck station.
Definition: road_gui.cpp:221
WID_BROS_INFO
@ WID_BROS_INFO
Station acceptance info.
Definition: road_widget.h:54
Company::avail_roadtypes
RoadTypes avail_roadtypes
Road types available to this company.
Definition: company_base.h:116
Window::ReInit
void ReInit(int rx=0, int ry=0)
Re-initialize a window, and optionally change its size.
Definition: window.cpp:995
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:115
tunnelbridge_map.h
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:126
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:140
INVALID_ROADTYPE
@ INVALID_ROADTYPE
flag for invalid roadtype
Definition: road_type.h:27
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:435
SetRedErrorSquare
void SetRedErrorSquare(TileIndex tile)
Set a tile to display a red error square.
Definition: viewport.cpp:2452
Window::CreateNestedTree
void CreateNestedTree(bool fill_nested=true)
Perform the first part of the initialization of a nested widget tree.
Definition: window.cpp:1832
WDP_ALIGN_TOOLBAR
@ WDP_ALIGN_TOOLBAR
Align toward the toolbar.
Definition: window_gui.h:156
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
CcRoadStop
void CcRoadStop(const CommandCost &result, TileIndex tile, uint32 p1, uint32 p2, uint32 cmd)
Command callback for building road stops.
Definition: road_gui.cpp:158
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:227
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:138
RoadTypeInfo::build_depot
SpriteID build_depot
button for building depots
Definition: road.h:85
maxdim
Dimension maxdim(const Dimension &d1, const Dimension &d2)
Compute bounding box of both dimensions.
Definition: geometry_func.cpp:22
FindWindowById
Window * FindWindowById(WindowClass cls, WindowNumber number)
Find a window by its class and window number.
Definition: window.cpp:1133
BuildRoadToolbarWindow::last_started_action
int last_started_action
Last started user action.
Definition: road_gui.cpp:273
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:145
BuildRoadToolbarWindow::rti
const RoadTypeInfo * rti
Information about current road type.
Definition: road_gui.cpp:272
_ctrl_pressed
bool _ctrl_pressed
Is Ctrl pressed?
Definition: gfx.cpp:35
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:111
SetResize
static NWidgetPart SetResize(int16 dx, int16 dy)
Widget part function for setting the resize step.
Definition: widget_type.h:929
zoom_func.h
ROADTYPE_END
@ ROADTYPE_END
Used for iterations.
Definition: road_type.h:26
Window::RaiseButtons
void RaiseButtons(bool autoraise=false)
Raise the buttons of the window.
Definition: window.cpp:573
CommandContainer
Structure for buffering the build command when selecting a station to join.
Definition: command_type.h:479
BuildRoadToolbarWindow::OnCTRLStateChange
EventState OnCTRLStateChange() override
The state of the control key has changed.
Definition: road_gui.cpp:714
DrawRoadDepotSprite
void DrawRoadDepotSprite(int x, int y, DiagDirection dir, RoadType rt)
Draw the road depot sprite.
Definition: road_cmd.cpp:1785
VPM_FIX_Y
@ VPM_FIX_Y
drag only in Y axis
Definition: viewport_type.h:99
_settings_client
ClientSettings _settings_client
The current settings for this game.
Definition: settings.cpp:79
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
ANIMCURSOR_DEMOLISH
static const CursorID ANIMCURSOR_DEMOLISH
704 - 707 - demolish dynamite
Definition: sprites.h:1492
GetCompanyRoadTypes
RoadTypes GetCompanyRoadTypes(CompanyID company, bool introduces)
Get the road types the given company can build.
Definition: road.cpp:188
DeleteWindowByClass
void DeleteWindowByClass(WindowClass cls)
Delete all windows of a given class.
Definition: window.cpp:1178
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:711
BuildRoadToolbarWindow::UpdateOptionWidgetStatus
void UpdateOptionWidgetStatus(RoadToolbarWidgets clicked_widget)
Update the remove button lowered state of the road toolbar.
Definition: road_gui.cpp:386
RoadTypeInfo::tunnel
CursorID tunnel
Cursor for building a tunnel.
Definition: road.h:95
RoadTypeInfo::replace_text
StringID replace_text
Text used in the autoreplace GUI.
Definition: road.h:104
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:96
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:708
RoadTypeInfo::err_remove_road
StringID err_remove_road
Removing a normal piece of road.
Definition: road.h:108
Window::OnHotkey
virtual EventState OnHotkey(int hotkey)
A hotkey has been pressed.
Definition: window.cpp:610
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:1146
RoadTypeInfo::depot
CursorID depot
Cursor for building a depot.
Definition: road.h:94
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:199
NWidgetPart
Partial widget specification to allow NWidgets to be written nested.
Definition: widget_type.h:909
SetDataTip
static NWidgetPart SetDataTip(uint32 data, StringID tip)
Widget part function for setting the data and tooltip.
Definition: widget_type.h:1013
RoadTypeInfo::road_nwse
CursorID road_nwse
Cursor for building rail in Y direction.
Definition: road.h:92
CMD_BUILD_TUNNEL
@ CMD_BUILD_TUNNEL
build a tunnel
Definition: command_type.h:188
RoadFlags
RoadFlags
Define the values of the RoadFlags.
Definition: road_gui.cpp:51
RoadTypeInfo::road_swne
CursorID road_swne
Cursor for building rail in X direction.
Definition: road.h:91
CommandCost::Succeeded
bool Succeeded() const
Did this command succeed?
Definition: command_type.h:150
BuildRoadToolbarWindow::OnPlaceObjectAbort
void OnPlaceObjectAbort() override
The user cancelled a tile highlight mode that has been set.
Definition: road_gui.cpp:581
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:786
ROADSTOP_BUS
@ ROADSTOP_BUS
A standard stop for buses.
Definition: station_type.h:45
IsInsideMM
static bool IsInsideMM(const T x, const size_t min, const size_t max)
Checks if a value is in an interval.
Definition: math_func.hpp:204
DDSP_PLACE_ROAD_X_DIR
@ DDSP_PLACE_ROAD_X_DIR
Road placement (X axis)
Definition: viewport_type.h:135
BuildRoadToolbarWindow::SetStringParameters
void SetStringParameters(int widget) const override
Initialize string parameters for a widget.
Definition: road_gui.cpp:368
ToggleRoadButton_Remove
static void ToggleRoadButton_Remove(Window *w)
Toggles state of the Remove button of Build road toolbar.
Definition: road_gui.cpp:241
WindowDesc
High level window description.
Definition: window_gui.h:166
StationType
StationType
Station types.
Definition: station_type.h:32
TRANSPORT_ROAD
@ TRANSPORT_ROAD
Transport by road vehicle.
Definition: transport_type.h:28
ROAD_NONE
@ ROAD_NONE
No road-part is build.
Definition: road_type.h:51
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:601
GetRoadBits
static RoadBits GetRoadBits(TileIndex t, RoadTramType rtt)
Get the present road bits for a specific road type.
Definition: road_map.h:127
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:997
BuildRoadToolbarWindow::OnInvalidateData
void OnInvalidateData(int data=0, bool gui_scope=true) override
Some data on this window has become invalid.
Definition: road_gui.cpp:303
_roadtypes_type
RoadTypes _roadtypes_type
Bitmap of road/tram types.
Definition: road_cmd.cpp:57
WDP_AUTO
@ WDP_AUTO
Find a place automatically.
Definition: window_gui.h:154
SCT_PASSENGERS_ONLY
@ SCT_PASSENGERS_ONLY
Draw only passenger class cargoes.
Definition: station_gui.h:20
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:322
CommandCost
Common return value for all commands.
Definition: command_type.h:23
_date
Date _date
Current date in days (day counter)
Definition: date.cpp:28
TILE_AREA_LOOP
#define TILE_AREA_LOOP(var, ta)
A loop which iterates over the tiles of a TileArea.
Definition: tilearea_type.h:232
tilehighlight_func.h
ClientSettings::sound
SoundSettings sound
sound effect settings
Definition: settings_type.h:570
CMD_BUILD_ROAD
@ CMD_BUILD_ROAD
build a "half" road
Definition: command_type.h:201
DoCommandP
bool DoCommandP(const CommandContainer *container, bool my_cmd)
Shortcut for the long DoCommandP when having a container with the data.
Definition: command.cpp:541
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:1012
Window::InitNested
void InitNested(WindowNumber number=0)
Perform complete initialization of the Window with nested widgets, to allow use.
Definition: window.cpp:1861
StationCoverageType
StationCoverageType
Types of cargo to display for station coverage.
Definition: station_gui.h:19
VPM_FIX_X
@ VPM_FIX_X
drag only in X axis
Definition: viewport_type.h:98
VpStartPlaceSizing
void VpStartPlaceSizing(TileIndex tile, ViewportPlaceMethod method, ViewportDragDropSelectionProcess process)
highlighting tiles while only going over them with the mouse
Definition: viewport.cpp:2652
BuildRoadStationWindow::DrawWidget
void DrawWidget(const Rect &r, int widget) const override
Draw the contents of a nested widget.
Definition: road_gui.cpp:1138
WID_BROS_BACKGROUND
@ WID_BROS_BACKGROUND
Background of the window.
Definition: road_widget.h:45
CMD_REMOVE_LONG_ROAD
@ CMD_REMOVE_LONG_ROAD
remove a complete road (not a "half" one)
Definition: command_type.h:200
Window::SetDirty
void SetDirty() const
Mark entire window as dirty (in need of re-paint)
Definition: window.cpp:984
CMD_BUILD_ROAD_STOP
@ CMD_BUILD_ROAD_STOP
build a road stop
Definition: command_type.h:197
WD_FRAMERECT_LEFT
@ WD_FRAMERECT_LEFT
Offset at left to draw the frame rectangular area.
Definition: window_gui.h:60
HT_DIAGONAL
@ HT_DIAGONAL
Also allow 'diagonal rectangles'. Only usable in combination with HT_RECT or HT_POINT.
Definition: tilehighlight_type.h:28
SB
static T SB(T &x, const uint8 s, const uint8 n, const U d)
Set n bits in x starting at bit s to d.
Definition: bitmath_func.hpp:58
CMD_BUILD_ROAD_DEPOT
@ CMD_BUILD_ROAD_DEPOT
build a road depot
Definition: command_type.h:202
OrthogonalTileArea::w
uint16 w
The width of the area.
Definition: tilearea_type.h:18
RoadTypeInfo::auto_road
SpriteID auto_road
button for the autoroad construction
Definition: road.h:84
WC_TRUCK_STATION
@ WC_TRUCK_STATION
Build truck station; Window numbers:
Definition: window_type.h:402
WD_PAR_VSEP_NORMAL
@ WD_PAR_VSEP_NORMAL
Normal amount of vertical space between two paragraphs of text.
Definition: window_gui.h:137
WD_FRAMERECT_RIGHT
@ WD_FRAMERECT_RIGHT
Offset at right to draw the frame rectangular area.
Definition: window_gui.h:61
ES_NOT_HANDLED
@ ES_NOT_HANDLED
The passed event is not handled.
Definition: window_type.h:719
CommandCost::Failed
bool Failed() const
Did this command fail?
Definition: command_type.h:159
NWidgetBase
Baseclass for nested widgets.
Definition: widget_type.h:124
station_func.h
RoadTypeInfo::cursor
struct RoadTypeInfo::@43 cursor
Cursors associated with the road type.
BuildRoadToolbarWindow::ModifyRoadType
void ModifyRoadType(RoadType roadtype)
Switch to another road type.
Definition: road_gui.cpp:361
BuildRoadDepotWindow
Definition: road_gui.cpp:983
BuildRoadDepotWindow::DrawWidget
void DrawWidget(const Rect &r, int widget) const override
Draw the contents of a nested widget.
Definition: road_gui.cpp:1005
VpSelectTilesWithMethod
void VpSelectTilesWithMethod(int x, int y, ViewportPlaceMethod method)
Selects tiles while dragging.
Definition: viewport.cpp:3137
OrthogonalTileArea
Represents the covered area of e.g.
Definition: tilearea_type.h:16
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:271
RoadTypes
RoadTypes
The different roadtypes we support, but then a bitmask of them.
Definition: road_type.h:36
road_gui.h
_settings_game
GameSettings _settings_game
Game settings of a running game or the scenario editor.
Definition: settings.cpp:80
DDSP_REMOVE_TRUCKSTOP
@ DDSP_REMOVE_TRUCKSTOP
Road stop removal (trucks)
Definition: viewport_type.h:141
WC_BUS_STATION
@ WC_BUS_STATION
Build bus station; Window numbers:
Definition: window_type.h:396
CMD_BUILD_LONG_ROAD
@ CMD_BUILD_LONG_ROAD
build a complete road (not a "half" one)
Definition: command_type.h:199
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:523
Window::SetWidgetDisabledState
void SetWidgetDisabledState(byte widget_index, bool disab_stat)
Sets the enabled/disabled status of a widget.
Definition: window_gui.h:392
Window::parent
Window * parent
Parent window.
Definition: window_gui.h:337
_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:61
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:77
ReverseDiagDir
static DiagDirection ReverseDiagDir(DiagDirection d)
Returns the reverse direction of the given DiagDirection.
Definition: direction_func.h:118
ROADSTOP_TRUCK
@ ROADSTOP_TRUCK
A standard stop for trucks.
Definition: station_type.h:46
PlaceRoad_BusStation
static void PlaceRoad_BusStation(TileIndex tile)
Callback for placing a bus station.
Definition: road_gui.cpp:203
FOR_ALL_SORTED_ROADTYPES
#define FOR_ALL_SORTED_ROADTYPES(var)
Loop header for iterating over roadtypes, sorted by sortorder.
Definition: road.h:312
DDSP_PLACE_AUTOROAD
@ DDSP_PLACE_AUTOROAD
Road placement (auto)
Definition: viewport_type.h:137
DDSP_BUILD_BRIDGE
@ DDSP_BUILD_BRIDGE
Bridge placement.
Definition: viewport_type.h:125
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:644
CA_TRUCK
@ CA_TRUCK
Catchment for truck stops with "modified catchment" enabled.
Definition: station_type.h:78
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
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:86
StationSettings::station_spread
byte station_spread
amount a station may spread
Definition: settings_type.h:526
WID_ROT_BUILD_BRIDGE
@ WID_ROT_BUILD_BRIDGE
Build bridge.
Definition: road_widget.h:25
date_func.h
stdafx.h
Window::window_number
WindowNumber window_number
Window number within the window class.
Definition: window_gui.h:312
RoadType
RoadType
The different roadtypes we support.
Definition: road_type.h:22
GUISettings::link_terraform_toolbar
bool link_terraform_toolbar
display terraform toolbar when displaying rail, road, water and airport toolbars
Definition: settings_type.h:95
CMD_CONVERT_ROAD
@ CMD_CONVERT_ROAD
convert a road type
Definition: command_type.h:203
viewport_func.h
BuildRoadToolbarWindow::SetupRoadToolbar
void SetupRoadToolbar()
Configures the road toolbar for roadtype given.
Definition: road_gui.cpp:345
NWidgetBase::current_y
uint current_y
Current vertical size (after resizing).
Definition: widget_type.h:173
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:1814
ShowSelectStationIfNeeded
void ShowSelectStationIfNeeded(const CommandContainer &cmd, TileArea ta)
Show the station selection window when needed.
Definition: station_gui.cpp:2459
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
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:1185
OrthogonalTileArea::h
uint16 h
The height of the area.
Definition: tilearea_type.h:19
GetSpriteSize
Dimension GetSpriteSize(SpriteID sprid, Point *offset, ZoomLevel zoom)
Get the size of a sprite.
Definition: gfx.cpp:913
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:115
BuildRoadStationWindow
Definition: road_gui.cpp:1074
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:54
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:82
BuildRoadToolbarWindow::OnHotkey
EventState OnHotkey(int hotkey) override
A hotkey has been pressed.
Definition: road_gui.cpp:517
RoadTypeInfo::convert_road
SpriteID convert_road
button for converting road types
Definition: road.h:87
WID_ROT_ONE_WAY
@ WID_ROT_ONE_WAY
Build one-way road.
Definition: road_widget.h:24
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:187
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:998
WC_SELECT_STATION
@ WC_SELECT_STATION
Select station (when joining stations); Window numbers:
Definition: window_type.h:235
strings_func.h
terraform_gui.h
DeleteWindowById
void DeleteWindowById(WindowClass cls, WindowNumber number, bool force)
Delete a window by its class and window number (if it is open).
Definition: window.cpp:1165
WID_BROD_DEPOT_NW
@ WID_BROD_DEPOT_NW
Depot with NW entry.
Definition: road_widget.h:38
NWidgetBase::pos_x
int pos_x
Horizontal position of top-left corner of the widget in the window.
Definition: widget_type.h:175
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:105
RoadTypeInfo::err_build_station
StringID err_build_station[2]
Building a bus or truck station.
Definition: road.h:110
RoadTramToolbarGlobalHotkeys
static EventState RoadTramToolbarGlobalHotkeys(int hotkey, RoadType last_build, RoadTramType rtt)
Handler for global hotkeys of the BuildRoadToolbarWindow.
Definition: road_gui.cpp:730
WID_BROS_STATION_SW
@ WID_BROS_STATION_SW
Terminal station with SW entry.
Definition: road_widget.h:48
RoadStopType
RoadStopType
Types of RoadStops.
Definition: station_type.h:44
WC_SCEN_LAND_GEN
@ WC_SCEN_LAND_GEN
Landscape generation (in Scenario Editor); Window numbers:
Definition: window_type.h:442
ScaleGUITrad
static int ScaleGUITrad(int value)
Scale traditional pixel dimensions to GUI zoom level.
Definition: zoom_func.h:76
NWidget
static NWidgetPart NWidget(WidgetType tp, Colours col, int16 idx=-1)
Widget part function for starting a new 'real' widget.
Definition: widget_type.h:1113
SCT_NON_PASSENGERS_ONLY
@ SCT_NON_PASSENGERS_ONLY
Draw all non-passenger class cargoes.
Definition: station_gui.h:21
BuildRoadToolbarWindow
Road toolbar window handler.
Definition: road_gui.cpp:270
geometry_func.hpp
OrthogonalTileArea::tile
TileIndex tile
The base tile of the area.
Definition: tilearea_type.h:17
RoadTypeInfo::autoroad
CursorID autoroad
Cursor for autorail tool.
Definition: road.h:93
SetMinimalSize
static NWidgetPart SetMinimalSize(int16 x, int16 y)
Widget part function for setting the minimal size.
Definition: widget_type.h:946
_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:50
RoadTypeInfo::err_convert_road
StringID err_convert_road
Converting a road type.
Definition: road.h:112
CMD_REMOVE_ROAD_STOP
@ CMD_REMOVE_ROAD_STOP
remove a road stop
Definition: command_type.h:198
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:1985
Window::SetWidgetsDisabledState
void CDECL SetWidgetsDisabledState(bool disab_stat, int widgets,...)
Sets the enabled/disabled status of a list of widgets.
Definition: window.cpp:536
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:493
EventState
EventState
State of handling an event.
Definition: window_type.h:717
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:254
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:100
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:224
Window::window_class
WindowClass window_class
Window class.
Definition: window_gui.h:311
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:1848
DC_AUTO
@ DC_AUTO
don't allow building on structures
Definition: command_type.h:349
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:142
company_func.h
PickerWindowBase
Base class for windows opened from a toolbar.
Definition: window_gui.h:853
SetViewportCatchmentStation
void SetViewportCatchmentStation(const Station *st, bool sel)
Select or deselect station for coverage area highlight.
Definition: viewport.cpp:3522
Window::top
int top
y position of top edge of the window
Definition: window_gui.h:318
DECLARE_ENUM_AS_BIT_SET
DECLARE_ENUM_AS_BIT_SET(GenderEthnicity) enum CompanyManagerFaceVariable
Bitgroups of the CompanyManagerFace variable.
Definition: company_manager_face.h:29
window_func.h
Window::ToggleWidgetLoweredState
void ToggleWidgetLoweredState(byte widget_index)
Invert the lowered/raised status of a widget.
Definition: window_gui.h:463
SoundSettings::click_beep
bool click_beep
Beep on a random selection of buttons.
Definition: settings_type.h:188
WID_ROT_BUS_STATION
@ WID_ROT_BUS_STATION
Build bus station.
Definition: road_widget.h:22
SetBit
static T SetBit(T &x, const uint8 y)
Set a bit in a variable.
Definition: bitmath_func.hpp:121
lengthof
#define lengthof(x)
Return the length of an fixed size array.
Definition: stdafx.h:367
VPM_X_LIMITED
@ VPM_X_LIMITED
Drag only in X axis with limited size.
Definition: viewport_type.h:104
ShowTerraformToolbar
Window * ShowTerraformToolbar(Window *link)
Show the toolbar for terraforming in the game.
Definition: terraform_gui.cpp:356
RoadTypeInfo::max_speed
uint16 max_speed
Maximum speed for vehicles travelling on this road type.
Definition: road.h:139
SetPIP
static NWidgetPart SetPIP(uint8 pre, uint8 inter, uint8 post)
Widget part function for setting a pre/inter/post spaces.
Definition: widget_type.h:1075
SND_1F_CONSTRUCTION_OTHER
@ SND_1F_CONSTRUCTION_OTHER
29 == 0x1D Construction: other (non-water, non-rail, non-bridge)
Definition: sound_type.h:68
NWidgetBase::pos_y
int pos_y
Vertical position of top-left corner of the widget in the window.
Definition: widget_type.h:176
ShowBuildRoadToolbar
Window * ShowBuildRoadToolbar(RoadType roadtype)
Open the build road toolbar window.
Definition: road_gui.cpp:888
IsNormalRoadTile
static bool IsNormalRoadTile(TileIndex t)
Return whether a tile is a normal road tile.
Definition: road_map.h:73
engine_base.h
SetFill
static NWidgetPart SetFill(uint fill_x, uint fill_y)
Widget part function for setting filling.
Definition: widget_type.h:982
GetOtherTunnelBridgeEnd
static TileIndex GetOtherTunnelBridgeEnd(TileIndex t)
Determines type of the wormhole and returns its other end.
Definition: tunnelbridge_map.h:78
gui.h
TileInfo::tile
TileIndex tile
Tile index.
Definition: tile_cmd.h:46
Window
Data structure for an opened window.
Definition: window_gui.h:276
GetRoadTypes
RoadTypes GetRoadTypes(bool introduces)
Get list of road types, regardless of company availability.
Definition: road.cpp: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:318
Window::RaiseWidget
void RaiseWidget(byte widget_index)
Marks a widget as raised.
Definition: window_gui.h:483
BuildRoadStationWindow::OnRealtimeTick
void OnRealtimeTick(uint delta_ms) override
Called periodically.
Definition: road_gui.cpp:1178
PlaceRoadStop
static void PlaceRoadStop(TileIndex start_tile, TileIndex end_tile, uint32 p2, uint32 cmd)
Place a new road stop.
Definition: road_gui.cpp:183
Window::DrawWidgets
void DrawWidgets() const
Paint all widgets of a window.
Definition: widget.cpp:602
RoadTypeInfo::err_depot
StringID err_depot
Building a depot.
Definition: road.h:109
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:121
VPM_X_AND_Y_LIMITED
@ VPM_X_AND_Y_LIMITED
area of land of limited size
Definition: viewport_type.h:101
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:1283
Window::IsWidgetDisabled
bool IsWidgetDisabled(byte widget_index) const
Gets the enabled/disabled status of a widget.
Definition: window_gui.h:421
Window::SetWidgetDirty
void SetWidgetDirty(byte widget_index) const
Invalidate a widget, i.e.
Definition: window.cpp:597
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:47
Window::LowerWidget
void LowerWidget(byte widget_index)
Marks a widget as lowered.
Definition: window_gui.h:474
Company
Definition: company_base.h:110
VPM_X_OR_Y
@ VPM_X_OR_Y
drag in X or Y direction
Definition: viewport_type.h:97
Window::DisableWidget
void DisableWidget(byte widget_index)
Sets a widget to disabled.
Definition: window_gui.h:402
NWidgetBase::current_x
uint current_x
Current horizontal size (after resizing).
Definition: widget_type.h:172
ResetObjectToPlace
void ResetObjectToPlace()
Reset the cursor and mouse mode handling back to default (normal cursor, only clicking in windows).
Definition: viewport.cpp:3421
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:453
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:114
DropDownListIconItem
List item with icon and string.
Definition: dropdown_type.h:81
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:567
CcBuildRoadTunnel
void CcBuildRoadTunnel(const CommandCost &result, TileIndex start_tile, uint32 p1, uint32 p2, uint32 cmd)
Callback executed after a build road tunnel command has been called.
Definition: road_gui.cpp:99
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:139
GUISettings::persistent_buildingtools
bool persistent_buildingtools
keep the building tools active after usage
Definition: settings_type.h:141
StationSettings::modified_catchment
bool modified_catchment
different-size catchment areas
Definition: settings_type.h:521
TileVirtXY
static TileIndex TileVirtXY(uint x, uint y)
Get a tile from the virtual XY-coordinate.
Definition: map_func.h:194
Hotkey
All data for a single hotkey.
Definition: hotkeys.h:22
hotkeys.h
ResizeWindow
void ResizeWindow(Window *w, int delta_x, int delta_y, bool clamp_to_screen)
Resize the window.
Definition: window.cpp:2153
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:975
AXIS_X
@ AXIS_X
The X axis.
Definition: direction_type.h:124
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:106