OpenTTD Source  14.0-beta3
rail_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 "waypoint_func.h"
18 #include "newgrf_station.h"
19 #include "company_base.h"
20 #include "strings_func.h"
21 #include "window_func.h"
22 #include "sound_func.h"
23 #include "company_func.h"
24 #include "widgets/dropdown_type.h"
25 #include "tunnelbridge.h"
26 #include "tilehighlight_func.h"
27 #include "spritecache.h"
28 #include "core/geometry_func.hpp"
29 #include "hotkeys.h"
30 #include "engine_base.h"
31 #include "vehicle_func.h"
32 #include "zoom_func.h"
33 #include "rail_gui.h"
34 #include "querystring_gui.h"
35 #include "sortlist_type.h"
36 #include "stringfilter_type.h"
37 #include "string_func.h"
38 #include "station_cmd.h"
39 #include "tunnelbridge_cmd.h"
40 #include "waypoint_cmd.h"
41 #include "rail_cmd.h"
42 #include "timer/timer.h"
44 
45 #include "station_map.h"
46 #include "tunnelbridge_map.h"
47 
48 #include "widgets/rail_widget.h"
49 
50 #include "safeguards.h"
51 
52 
56 static uint16_t _cur_waypoint_type;
60 
63 
64  bool newstations;
66  uint16_t station_type;
67  uint16_t station_count;
68 };
70 
71 
72 static void HandleStationPlacement(TileIndex start, TileIndex end);
73 static void ShowBuildTrainDepotPicker(Window *parent);
74 static void ShowBuildWaypointPicker(Window *parent);
75 static Window *ShowStationBuilder(Window *parent);
76 static void ShowSignalBuilder(Window *parent);
77 
82 static bool IsStationAvailable(const StationSpec *statspec)
83 {
84  if (statspec == nullptr || !HasBit(statspec->callback_mask, CBM_STATION_AVAIL)) return true;
85 
86  uint16_t cb_res = GetStationCallback(CBID_STATION_AVAILABILITY, 0, 0, statspec, nullptr, INVALID_TILE);
87  if (cb_res == CALLBACK_FAILED) return true;
88 
90 }
91 
92 void CcPlaySound_CONSTRUCTION_RAIL(Commands, const CommandCost &result, TileIndex tile)
93 {
94  if (result.Succeeded() && _settings_client.sound.confirm) SndPlayTileFx(SND_20_CONSTRUCTION_RAIL, tile);
95 }
96 
97 static void GenericPlaceRail(TileIndex tile, Track track)
98 {
100  Command<CMD_REMOVE_SINGLE_RAIL>::Post(STR_ERROR_CAN_T_REMOVE_RAILROAD_TRACK, CcPlaySound_CONSTRUCTION_RAIL,
101  tile, track);
102  } else {
103  Command<CMD_BUILD_SINGLE_RAIL>::Post(STR_ERROR_CAN_T_BUILD_RAILROAD_TRACK, CcPlaySound_CONSTRUCTION_RAIL,
105  }
106 }
107 
115 static void PlaceExtraDepotRail(TileIndex tile, DiagDirection dir, Track track)
116 {
117  if (GetRailTileType(tile) == RAIL_TILE_DEPOT) return;
119  if ((GetTrackBits(tile) & DiagdirReachesTracks(dir)) == 0) return;
120 
122 }
123 
125 static const Track _place_depot_extra_track[12] = {
126  TRACK_LEFT, TRACK_UPPER, TRACK_UPPER, TRACK_RIGHT, // First additional track for directions 0..3
127  TRACK_X, TRACK_Y, TRACK_X, TRACK_Y, // Second additional track
128  TRACK_LOWER, TRACK_LEFT, TRACK_RIGHT, TRACK_LOWER, // Third additional track
129 };
130 
136 };
137 
138 void CcRailDepot(Commands, const CommandCost &result, TileIndex tile, RailType, DiagDirection dir)
139 {
140  if (result.Failed()) return;
141 
142  if (_settings_client.sound.confirm) SndPlayTileFx(SND_20_CONSTRUCTION_RAIL, tile);
144 
145  tile += TileOffsByDiagDir(dir);
146 
147  if (IsTileType(tile, MP_RAILWAY)) {
151  }
152 }
153 
158 static void PlaceRail_Waypoint(TileIndex tile)
159 {
162  return;
163  }
164 
165  Axis axis = GetAxisForNewWaypoint(tile);
166  if (IsValidAxis(axis)) {
167  /* Valid tile for waypoints */
169  VpSetPlaceSizingLimit(_settings_game.station.station_spread);
170  } else {
171  /* Tile where we can't build rail waypoints. This is always going to fail,
172  * but provides the user with a proper error message. */
173  Command<CMD_BUILD_RAIL_WAYPOINT>::Post(STR_ERROR_CAN_T_BUILD_TRAIN_WAYPOINT, tile, AXIS_X, 1, 1, STAT_CLASS_WAYP, 0, INVALID_STATION, false);
174  }
175 }
176 
177 void CcStation(Commands, const CommandCost &result, TileIndex tile)
178 {
179  if (result.Failed()) return;
180 
181  if (_settings_client.sound.confirm) SndPlayTileFx(SND_20_CONSTRUCTION_RAIL, tile);
182  /* Only close the station builder window if the default station and non persistent building is chosen. */
184 }
185 
190 static void PlaceRail_Station(TileIndex tile)
191 {
194  VpSetPlaceSizingLimit(-1);
197  VpSetPlaceSizingLimit(_settings_game.station.station_spread);
198  } else {
201  if (!_railstation.orientation) Swap(w, h);
202 
204  RailType rt = _cur_railtype;
205  byte numtracks = _settings_client.gui.station_numtracks;
206  byte platlength = _settings_client.gui.station_platlength;
207  bool adjacent = _ctrl_pressed;
208 
209  auto proc = [=](bool test, StationID to_join) -> bool {
210  if (test) {
211  return Command<CMD_BUILD_RAIL_STATION>::Do(CommandFlagsToDCFlags(GetCommandFlags<CMD_BUILD_RAIL_STATION>()), tile, rt, params.orientation, numtracks, platlength, params.station_class, params.station_type, INVALID_STATION, adjacent).Succeeded();
212  } else {
213  return Command<CMD_BUILD_RAIL_STATION>::Post(STR_ERROR_CAN_T_BUILD_RAILROAD_STATION, CcStation, tile, rt, params.orientation, numtracks, platlength, params.station_class, params.station_type, to_join, adjacent);
214  }
215  };
216 
217  ShowSelectStationIfNeeded(TileArea(tile, w, h), proc);
218  }
219 }
220 
227 {
229 
230  if (trackbits & TRACK_BIT_VERT) { // N-S direction
231  trackbits = (_tile_fract_coords.x <= _tile_fract_coords.y) ? TRACK_BIT_RIGHT : TRACK_BIT_LEFT;
232  }
233 
234  if (trackbits & TRACK_BIT_HORZ) { // E-W direction
235  trackbits = (_tile_fract_coords.x + _tile_fract_coords.y <= 15) ? TRACK_BIT_UPPER : TRACK_BIT_LOWER;
236  }
237 
238  Track track = FindFirstTrack(trackbits);
239 
241  Command<CMD_REMOVE_SINGLE_SIGNAL>::Post(STR_ERROR_CAN_T_REMOVE_SIGNALS_FROM, CcPlaySound_CONSTRUCTION_RAIL, tile, track);
242  } else {
243  /* Which signals should we cycle through? */
244  bool tile_has_signal = IsPlainRailTile(tile) && IsValidTrack(track) && HasSignalOnTrack(tile, track);
245  SignalType cur_signal_on_tile = tile_has_signal ? GetSignalType(tile, track) : _cur_signal_type;
246  SignalType cycle_start;
247  SignalType cycle_end;
248 
249  /* Start with the least restrictive case: the player wants to cycle through all signals they can see. */
252  cycle_end = SIGTYPE_LAST;
253  } else {
254  /* Only cycle through signals of the same group (block or path) as the current signal on the tile. */
255  if (cur_signal_on_tile <= SIGTYPE_LAST_NOPBS) {
256  /* Block signals only. */
257  cycle_start = SIGTYPE_BLOCK;
258  cycle_end = SIGTYPE_LAST_NOPBS;
259  } else {
260  /* Path signals only. */
261  cycle_start = SIGTYPE_PBS;
262  cycle_end = SIGTYPE_LAST;
263  }
264  }
265 
266  if (FindWindowById(WC_BUILD_SIGNAL, 0) != nullptr) {
267  /* signal GUI is used */
268  Command<CMD_BUILD_SINGLE_SIGNAL>::Post(_convert_signal_button ? STR_ERROR_SIGNAL_CAN_T_CONVERT_SIGNALS_HERE : STR_ERROR_CAN_T_BUILD_SIGNALS_HERE, CcPlaySound_CONSTRUCTION_RAIL,
269  tile, track, _cur_signal_type, _cur_signal_variant, _convert_signal_button, false, _ctrl_pressed, cycle_start, cycle_end, 0, 0);
270  } else {
272  Command<CMD_BUILD_SINGLE_SIGNAL>::Post(STR_ERROR_CAN_T_BUILD_SIGNALS_HERE, CcPlaySound_CONSTRUCTION_RAIL,
273  tile, track, _settings_client.gui.default_signal_type, sigvar, false, false, _ctrl_pressed, cycle_start, cycle_end, 0, 0);
274 
275  }
276  }
277 }
278 
284 static void PlaceRail_Bridge(TileIndex tile, Window *w)
285 {
286  if (IsBridgeTile(tile)) {
287  TileIndex other_tile = GetOtherTunnelBridgeEnd(tile);
288  Point pt = {0, 0};
289  w->OnPlaceMouseUp(VPM_X_OR_Y, DDSP_BUILD_BRIDGE, pt, other_tile, tile);
290  } else {
292  }
293 }
294 
297 {
298  if (result.Succeeded()) {
299  if (_settings_client.sound.confirm) SndPlayTileFx(SND_20_CONSTRUCTION_RAIL, tile);
301  } else {
303  }
304 }
305 
311 {
316  SetSelectionRed(_remove_button_clicked);
317 }
318 
325 {
326  if (w->IsWidgetDisabled(WID_RAT_REMOVE)) return false;
327 
328  /* allow ctrl to switch remove mode only for these widgets */
329  for (WidgetID i = WID_RAT_BUILD_NS; i <= WID_RAT_BUILD_STATION; i++) {
330  if ((i <= WID_RAT_AUTORAIL || i >= WID_RAT_BUILD_WAYPOINT) && w->IsWidgetLowered(i)) {
332  return true;
333  }
334  }
335 
336  return false;
337 }
338 
339 
346 {
347  if (w->IsWidgetDisabled(WID_RAT_REMOVE)) return;
350 
351  /* handle station builder */
354  /* starting drag & drop remove */
356  SetTileSelectSize(1, 1);
357  } else {
358  VpSetPlaceSizingLimit(-1);
359  }
360  } else {
361  /* starting station build mode */
365  if (_railstation.orientation == 0) Swap(x, y);
366  SetTileSelectSize(x, y);
367  } else {
368  VpSetPlaceSizingLimit(_settings_game.station.station_spread);
369  }
370  }
371  }
372 }
373 
374 static void DoRailroadTrack(Track track)
375 {
377  Command<CMD_REMOVE_RAILROAD_TRACK>::Post(STR_ERROR_CAN_T_REMOVE_RAILROAD_TRACK, CcPlaySound_CONSTRUCTION_RAIL,
378  TileVirtXY(_thd.selend.x, _thd.selend.y), TileVirtXY(_thd.selstart.x, _thd.selstart.y), track);
379  } else {
380  Command<CMD_BUILD_RAILROAD_TRACK>::Post(STR_ERROR_CAN_T_BUILD_RAILROAD_TRACK, CcPlaySound_CONSTRUCTION_RAIL,
381  TileVirtXY(_thd.selend.x, _thd.selend.y), TileVirtXY(_thd.selstart.x, _thd.selstart.y), _cur_railtype, track, _settings_client.gui.auto_remove_signals, false);
382  }
383 }
384 
385 static void HandleAutodirPlacement()
386 {
387  Track trackstat = static_cast<Track>( _thd.drawstyle & HT_DIR_MASK); // 0..5
388 
389  if (_thd.drawstyle & HT_RAIL) { // one tile case
390  GenericPlaceRail(TileVirtXY(_thd.selend.x, _thd.selend.y), trackstat);
391  return;
392  }
393 
394  DoRailroadTrack(trackstat);
395 }
396 
404 {
405  Track track = (Track)GB(_thd.drawstyle, 0, 3); // 0..5
406 
407  if ((_thd.drawstyle & HT_DRAG_MASK) == HT_RECT) { // one tile case
408  GenericPlaceSignals(TileVirtXY(_thd.selend.x, _thd.selend.y));
409  return;
410  }
411 
412  /* _settings_client.gui.drag_signals_density is given as a parameter such that each user
413  * in a network game can specify their own signal density */
415  Command<CMD_REMOVE_SIGNAL_TRACK>::Post(STR_ERROR_CAN_T_REMOVE_SIGNALS_FROM, CcPlaySound_CONSTRUCTION_RAIL,
416  TileVirtXY(_thd.selstart.x, _thd.selstart.y), TileVirtXY(_thd.selend.x, _thd.selend.y), track, true);
417  } else {
418  bool sig_gui = FindWindowById(WC_BUILD_SIGNAL, 0) != nullptr;
421  Command<CMD_BUILD_SIGNAL_TRACK>::Post(STR_ERROR_CAN_T_BUILD_SIGNALS_HERE, CcPlaySound_CONSTRUCTION_RAIL,
422  TileVirtXY(_thd.selstart.x, _thd.selstart.y), TileVirtXY(_thd.selend.x, _thd.selend.y), track, sigtype, sigvar, false, true, !_settings_client.gui.drag_signals_fixed_distance, _settings_client.gui.drag_signals_density);
423  }
424 }
425 
426 
431 
433  {
434  this->InitNested(TRANSPORT_RAIL);
435  this->SetupRailToolbar(railtype);
437  this->OnInvalidateData();
438  this->last_user_action = INVALID_WID_RAT;
439 
441  }
442 
443  void Close([[maybe_unused]] int data = 0) override
444  {
449  this->Window::Close();
450  }
451 
453  static inline const std::initializer_list<WidgetID> can_build_widgets = {
457  };
458 
459  void OnInvalidateData([[maybe_unused]] int data = 0, [[maybe_unused]] bool gui_scope = true) override
460  {
461  if (!gui_scope) return;
462 
463  bool can_build = CanBuildVehicleInfrastructure(VEH_TRAIN);
464  for (const WidgetID widget : can_build_widgets) this->SetWidgetDisabledState(widget, !can_build);
465  if (!can_build) {
471  }
472  }
473 
474  bool OnTooltip([[maybe_unused]] Point pt, WidgetID widget, TooltipCloseCondition close_cond) override
475  {
476  bool can_build = CanBuildVehicleInfrastructure(VEH_TRAIN);
477  if (can_build) return false;
478 
479  if (std::find(std::begin(can_build_widgets), std::end(can_build_widgets), widget) == std::end(can_build_widgets)) return false;
480 
481  GuiShowTooltips(this, STR_TOOLBAR_DISABLED_NO_VEHICLE_AVAILABLE, close_cond);
482  return true;
483  }
484 
490  {
491  this->railtype = railtype;
492  const RailTypeInfo *rti = GetRailTypeInfo(railtype);
493 
494  assert(railtype < RAILTYPE_END);
495  this->GetWidget<NWidgetCore>(WID_RAT_BUILD_NS)->widget_data = rti->gui_sprites.build_ns_rail;
496  this->GetWidget<NWidgetCore>(WID_RAT_BUILD_X)->widget_data = rti->gui_sprites.build_x_rail;
497  this->GetWidget<NWidgetCore>(WID_RAT_BUILD_EW)->widget_data = rti->gui_sprites.build_ew_rail;
498  this->GetWidget<NWidgetCore>(WID_RAT_BUILD_Y)->widget_data = rti->gui_sprites.build_y_rail;
499  this->GetWidget<NWidgetCore>(WID_RAT_AUTORAIL)->widget_data = rti->gui_sprites.auto_rail;
500  this->GetWidget<NWidgetCore>(WID_RAT_BUILD_DEPOT)->widget_data = rti->gui_sprites.build_depot;
501  this->GetWidget<NWidgetCore>(WID_RAT_CONVERT_RAIL)->widget_data = rti->gui_sprites.convert_rail;
502  this->GetWidget<NWidgetCore>(WID_RAT_BUILD_TUNNEL)->widget_data = rti->gui_sprites.build_tunnel;
503  }
504 
510  {
511  this->SetupRailToolbar(railtype);
512  this->ReInit();
513  }
514 
515  void UpdateRemoveWidgetStatus(WidgetID clicked_widget)
516  {
517  switch (clicked_widget) {
518  case WID_RAT_REMOVE:
519  /* If it is the removal button that has been clicked, do nothing,
520  * as it is up to the other buttons to drive removal status */
521  return;
522 
523  case WID_RAT_BUILD_NS:
524  case WID_RAT_BUILD_X:
525  case WID_RAT_BUILD_EW:
526  case WID_RAT_BUILD_Y:
527  case WID_RAT_AUTORAIL:
531  /* Removal button is enabled only if the rail/signal/waypoint/station
532  * button is still lowered. Once raised, it has to be disabled */
533  this->SetWidgetDisabledState(WID_RAT_REMOVE, !this->IsWidgetLowered(clicked_widget));
534  break;
535 
536  default:
537  /* When any other buttons than rail/signal/waypoint/station, raise and
538  * disable the removal button */
541  break;
542  }
543  }
544 
545  void SetStringParameters(WidgetID widget) const override
546  {
547  if (widget == WID_RAT_CAPTION) {
548  const RailTypeInfo *rti = GetRailTypeInfo(this->railtype);
549  if (rti->max_speed > 0) {
550  SetDParam(0, STR_TOOLBAR_RAILTYPE_VELOCITY);
553  } else {
555  }
556  }
557  }
558 
559  void OnClick([[maybe_unused]] Point pt, WidgetID widget, [[maybe_unused]] int click_count) override
560  {
561  if (widget < WID_RAT_BUILD_NS) return;
562 
563  _remove_button_clicked = false;
564  switch (widget) {
565  case WID_RAT_BUILD_NS:
567  this->last_user_action = widget;
568  break;
569 
570  case WID_RAT_BUILD_X:
572  this->last_user_action = widget;
573  break;
574 
575  case WID_RAT_BUILD_EW:
577  this->last_user_action = widget;
578  break;
579 
580  case WID_RAT_BUILD_Y:
582  this->last_user_action = widget;
583  break;
584 
585  case WID_RAT_AUTORAIL:
587  this->last_user_action = widget;
588  break;
589 
590  case WID_RAT_DEMOLISH:
592  this->last_user_action = widget;
593  break;
594 
595  case WID_RAT_BUILD_DEPOT:
597  ShowBuildTrainDepotPicker(this);
598  this->last_user_action = widget;
599  }
600  break;
601 
603  this->last_user_action = widget;
604  if (HandlePlacePushButton(this, WID_RAT_BUILD_WAYPOINT, SPR_CURSOR_WAYPOINT, HT_RECT) && StationClass::Get(STAT_CLASS_WAYP)->GetSpecCount() > 1) {
605  ShowBuildWaypointPicker(this);
606  }
607  break;
608 
610  if (HandlePlacePushButton(this, WID_RAT_BUILD_STATION, SPR_CURSOR_RAIL_STATION, HT_RECT)) {
611  ShowStationBuilder(this);
612  this->last_user_action = widget;
613  }
614  break;
615 
616  case WID_RAT_BUILD_SIGNALS: {
617  this->last_user_action = widget;
619  if (started != _ctrl_pressed) {
620  ShowSignalBuilder(this);
621  }
622  break;
623  }
624 
626  HandlePlacePushButton(this, WID_RAT_BUILD_BRIDGE, SPR_CURSOR_BRIDGE, HT_RECT);
627  this->last_user_action = widget;
628  break;
629 
632  this->last_user_action = widget;
633  break;
634 
635  case WID_RAT_REMOVE:
636  BuildRailClick_Remove(this);
637  break;
638 
641  this->last_user_action = widget;
642  break;
643 
644  default: NOT_REACHED();
645  }
646  this->UpdateRemoveWidgetStatus(widget);
648  }
649 
650  EventState OnHotkey(int hotkey) override
651  {
652  MarkTileDirtyByTile(TileVirtXY(_thd.pos.x, _thd.pos.y)); // redraw tile selection
653  return Window::OnHotkey(hotkey);
654  }
655 
656  void OnPlaceObject([[maybe_unused]] Point pt, TileIndex tile) override
657  {
658  switch (this->last_user_action) {
659  case WID_RAT_BUILD_NS:
661  break;
662 
663  case WID_RAT_BUILD_X:
665  break;
666 
667  case WID_RAT_BUILD_EW:
669  break;
670 
671  case WID_RAT_BUILD_Y:
673  break;
674 
675  case WID_RAT_AUTORAIL:
677  break;
678 
679  case WID_RAT_DEMOLISH:
681  break;
682 
683  case WID_RAT_BUILD_DEPOT:
684  Command<CMD_BUILD_TRAIN_DEPOT>::Post(STR_ERROR_CAN_T_BUILD_TRAIN_DEPOT, CcRailDepot, tile, _cur_railtype, _build_depot_direction);
685  break;
686 
688  PlaceRail_Waypoint(tile);
689  break;
690 
692  PlaceRail_Station(tile);
693  break;
694 
697  break;
698 
700  PlaceRail_Bridge(tile, this);
701  break;
702 
704  Command<CMD_BUILD_TUNNEL>::Post(STR_ERROR_CAN_T_BUILD_TUNNEL_HERE, CcBuildRailTunnel, tile, TRANSPORT_RAIL, _cur_railtype);
705  break;
706 
709  break;
710 
711  default: NOT_REACHED();
712  }
713  }
714 
715  void OnPlaceDrag(ViewportPlaceMethod select_method, [[maybe_unused]] ViewportDragDropSelectionProcess select_proc, [[maybe_unused]] Point pt) override
716  {
717  /* no dragging if you have pressed the convert button */
719 
720  VpSelectTilesWithMethod(pt.x, pt.y, select_method);
721  }
722 
723  void OnPlaceMouseUp([[maybe_unused]] ViewportPlaceMethod select_method, ViewportDragDropSelectionProcess select_proc, [[maybe_unused]] Point pt, TileIndex start_tile, TileIndex end_tile) override
724  {
725  if (pt.x != -1) {
726  switch (select_proc) {
727  default: NOT_REACHED();
728  case DDSP_BUILD_BRIDGE:
730  ShowBuildBridgeWindow(start_tile, end_tile, TRANSPORT_RAIL, _cur_railtype);
731  break;
732 
733  case DDSP_PLACE_RAIL:
734  HandleAutodirPlacement();
735  break;
736 
737  case DDSP_BUILD_SIGNALS:
739  break;
740 
741  case DDSP_DEMOLISH_AREA:
742  GUIPlaceProcDragXY(select_proc, start_tile, end_tile);
743  break;
744 
745  case DDSP_CONVERT_RAIL:
746  Command<CMD_CONVERT_RAIL>::Post(STR_ERROR_CAN_T_CONVERT_RAIL, CcPlaySound_CONSTRUCTION_RAIL, end_tile, start_tile, _cur_railtype, _ctrl_pressed);
747  break;
748 
749  case DDSP_REMOVE_STATION:
750  case DDSP_BUILD_STATION:
752  /* Station */
754  bool keep_rail = !_ctrl_pressed;
755  Command<CMD_REMOVE_FROM_RAIL_STATION>::Post(STR_ERROR_CAN_T_REMOVE_PART_OF_STATION, CcPlaySound_CONSTRUCTION_RAIL, end_tile, start_tile, keep_rail);
756  } else {
757  HandleStationPlacement(start_tile, end_tile);
758  }
759  } else {
760  /* Waypoint */
762  bool keep_rail = !_ctrl_pressed;
763  Command<CMD_REMOVE_FROM_RAIL_WAYPOINT>::Post(STR_ERROR_CAN_T_REMOVE_TRAIN_WAYPOINT, CcPlaySound_CONSTRUCTION_RAIL, end_tile, start_tile, keep_rail);
764  } else {
765  TileArea ta(start_tile, end_tile);
766  Axis axis = select_method == VPM_X_LIMITED ? AXIS_X : AXIS_Y;
767  bool adjacent = _ctrl_pressed;
768  uint16_t waypoint_type = _cur_waypoint_type;
769 
770  auto proc = [=](bool test, StationID to_join) -> bool {
771  if (test) {
772  return Command<CMD_BUILD_RAIL_WAYPOINT>::Do(CommandFlagsToDCFlags(GetCommandFlags<CMD_BUILD_RAIL_WAYPOINT>()), ta.tile, axis, ta.w, ta.h, STAT_CLASS_WAYP, waypoint_type, INVALID_STATION, adjacent).Succeeded();
773  } else {
774  return Command<CMD_BUILD_RAIL_WAYPOINT>::Post(STR_ERROR_CAN_T_BUILD_TRAIN_WAYPOINT, CcPlaySound_CONSTRUCTION_RAIL, ta.tile, axis, ta.w, ta.h, STAT_CLASS_WAYP, waypoint_type, to_join, adjacent);
775  }
776  };
777 
778  ShowSelectWaypointIfNeeded(ta, proc);
779  }
780  }
781  break;
782  }
783  }
784  }
785 
786  void OnPlaceObjectAbort() override
787  {
790 
791  this->RaiseButtons();
794 
801  }
802 
803  void OnPlacePresize([[maybe_unused]] Point pt, TileIndex tile) override
804  {
807  }
808 
810  {
811  /* do not toggle Remove button by Ctrl when placing station */
813  return ES_NOT_HANDLED;
814  }
815 
816  void OnRealtimeTick([[maybe_unused]] uint delta_ms) override
817  {
818  if (this->IsWidgetLowered(WID_RAT_BUILD_WAYPOINT)) CheckRedrawWaypointCoverage(this);
819  }
820 
827  {
828  if (_game_mode != GM_NORMAL) return ES_NOT_HANDLED;
829  extern RailType _last_built_railtype;
830  Window *w = ShowBuildRailToolbar(_last_built_railtype);
831  if (w == nullptr) return ES_NOT_HANDLED;
832  return w->OnHotkey(hotkey);
833  }
834 
835  static inline HotkeyList hotkeys{"railtoolbar", {
836  Hotkey('1', "build_ns", WID_RAT_BUILD_NS),
837  Hotkey('2', "build_x", WID_RAT_BUILD_X),
838  Hotkey('3', "build_ew", WID_RAT_BUILD_EW),
839  Hotkey('4', "build_y", WID_RAT_BUILD_Y),
840  Hotkey({'5', 'A' | WKC_GLOBAL_HOTKEY}, "autorail", WID_RAT_AUTORAIL),
841  Hotkey('6', "demolish", WID_RAT_DEMOLISH),
842  Hotkey('7', "depot", WID_RAT_BUILD_DEPOT),
843  Hotkey('8', "waypoint", WID_RAT_BUILD_WAYPOINT),
844  Hotkey('9', "station", WID_RAT_BUILD_STATION),
845  Hotkey('S', "signal", WID_RAT_BUILD_SIGNALS),
846  Hotkey('B', "bridge", WID_RAT_BUILD_BRIDGE),
847  Hotkey('T', "tunnel", WID_RAT_BUILD_TUNNEL),
848  Hotkey('R', "remove", WID_RAT_REMOVE),
849  Hotkey('C', "convert", WID_RAT_CONVERT_RAIL),
851 };
852 
853 static constexpr NWidgetPart _nested_build_rail_widgets[] = {
855  NWidget(WWT_CLOSEBOX, COLOUR_DARK_GREEN),
856  NWidget(WWT_CAPTION, COLOUR_DARK_GREEN, WID_RAT_CAPTION), SetDataTip(STR_JUST_STRING2, STR_TOOLTIP_WINDOW_TITLE_DRAG_THIS), SetTextStyle(TC_WHITE),
857  NWidget(WWT_STICKYBOX, COLOUR_DARK_GREEN),
858  EndContainer(),
860  NWidget(WWT_IMGBTN, COLOUR_DARK_GREEN, WID_RAT_BUILD_NS),
861  SetFill(0, 1), SetMinimalSize(22, 22), SetDataTip(SPR_IMG_RAIL_NS, STR_RAIL_TOOLBAR_TOOLTIP_BUILD_RAILROAD_TRACK),
862  NWidget(WWT_IMGBTN, COLOUR_DARK_GREEN, WID_RAT_BUILD_X),
863  SetFill(0, 1), SetMinimalSize(22, 22), SetDataTip(SPR_IMG_RAIL_NE, STR_RAIL_TOOLBAR_TOOLTIP_BUILD_RAILROAD_TRACK),
864  NWidget(WWT_IMGBTN, COLOUR_DARK_GREEN, WID_RAT_BUILD_EW),
865  SetFill(0, 1), SetMinimalSize(22, 22), SetDataTip(SPR_IMG_RAIL_EW, STR_RAIL_TOOLBAR_TOOLTIP_BUILD_RAILROAD_TRACK),
866  NWidget(WWT_IMGBTN, COLOUR_DARK_GREEN, WID_RAT_BUILD_Y),
867  SetFill(0, 1), SetMinimalSize(22, 22), SetDataTip(SPR_IMG_RAIL_NW, STR_RAIL_TOOLBAR_TOOLTIP_BUILD_RAILROAD_TRACK),
868  NWidget(WWT_IMGBTN, COLOUR_DARK_GREEN, WID_RAT_AUTORAIL),
869  SetFill(0, 1), SetMinimalSize(22, 22), SetDataTip(SPR_IMG_AUTORAIL, STR_RAIL_TOOLBAR_TOOLTIP_BUILD_AUTORAIL),
870 
871  NWidget(WWT_PANEL, COLOUR_DARK_GREEN), SetMinimalSize(4, 22), EndContainer(),
872 
873  NWidget(WWT_IMGBTN, COLOUR_DARK_GREEN, WID_RAT_DEMOLISH),
874  SetFill(0, 1), SetMinimalSize(22, 22), SetDataTip(SPR_IMG_DYNAMITE, STR_TOOLTIP_DEMOLISH_BUILDINGS_ETC),
875  NWidget(WWT_IMGBTN, COLOUR_DARK_GREEN, WID_RAT_BUILD_DEPOT),
876  SetFill(0, 1), SetMinimalSize(22, 22), SetDataTip(SPR_IMG_DEPOT_RAIL, STR_RAIL_TOOLBAR_TOOLTIP_BUILD_TRAIN_DEPOT_FOR_BUILDING),
877  NWidget(WWT_IMGBTN, COLOUR_DARK_GREEN, WID_RAT_BUILD_WAYPOINT),
878  SetFill(0, 1), SetMinimalSize(22, 22), SetDataTip(SPR_IMG_WAYPOINT, STR_RAIL_TOOLBAR_TOOLTIP_CONVERT_RAIL_TO_WAYPOINT),
879  NWidget(WWT_IMGBTN, COLOUR_DARK_GREEN, WID_RAT_BUILD_STATION),
880  SetFill(0, 1), SetMinimalSize(42, 22), SetDataTip(SPR_IMG_RAIL_STATION, STR_RAIL_TOOLBAR_TOOLTIP_BUILD_RAILROAD_STATION),
881  NWidget(WWT_IMGBTN, COLOUR_DARK_GREEN, WID_RAT_BUILD_SIGNALS),
882  SetFill(0, 1), SetMinimalSize(22, 22), SetDataTip(SPR_IMG_RAIL_SIGNALS, STR_RAIL_TOOLBAR_TOOLTIP_BUILD_RAILROAD_SIGNALS),
883  NWidget(WWT_IMGBTN, COLOUR_DARK_GREEN, WID_RAT_BUILD_BRIDGE),
884  SetFill(0, 1), SetMinimalSize(42, 22), SetDataTip(SPR_IMG_BRIDGE, STR_RAIL_TOOLBAR_TOOLTIP_BUILD_RAILROAD_BRIDGE),
885  NWidget(WWT_IMGBTN, COLOUR_DARK_GREEN, WID_RAT_BUILD_TUNNEL),
886  SetFill(0, 1), SetMinimalSize(20, 22), SetDataTip(SPR_IMG_TUNNEL_RAIL, STR_RAIL_TOOLBAR_TOOLTIP_BUILD_RAILROAD_TUNNEL),
887  NWidget(WWT_IMGBTN, COLOUR_DARK_GREEN, WID_RAT_REMOVE),
888  SetFill(0, 1), SetMinimalSize(22, 22), SetDataTip(SPR_IMG_REMOVE, STR_RAIL_TOOLBAR_TOOLTIP_TOGGLE_BUILD_REMOVE_FOR),
889  NWidget(WWT_IMGBTN, COLOUR_DARK_GREEN, WID_RAT_CONVERT_RAIL),
890  SetFill(0, 1), SetMinimalSize(22, 22), SetDataTip(SPR_IMG_CONVERT_RAIL, STR_RAIL_TOOLBAR_TOOLTIP_CONVERT_RAIL),
891  EndContainer(),
892 };
893 
894 static WindowDesc _build_rail_desc(__FILE__, __LINE__,
895  WDP_ALIGN_TOOLBAR, "toolbar_rail", 0, 0,
898  std::begin(_nested_build_rail_widgets), std::end(_nested_build_rail_widgets),
899  &BuildRailToolbarWindow::hotkeys
900 );
901 
902 
912 {
913  if (!Company::IsValidID(_local_company)) return nullptr;
914  if (!ValParamRailType(railtype)) return nullptr;
915 
917  _cur_railtype = railtype;
918  _remove_button_clicked = false;
919  return new BuildRailToolbarWindow(&_build_rail_desc, railtype);
920 }
921 
922 /* TODO: For custom stations, respect their allowed platforms/lengths bitmasks!
923  * --pasky */
924 
925 static void HandleStationPlacement(TileIndex start, TileIndex end)
926 {
927  TileArea ta(start, end);
928  uint numtracks = ta.w;
929  uint platlength = ta.h;
930 
931  if (_railstation.orientation == AXIS_X) Swap(numtracks, platlength);
932 
934  RailType rt = _cur_railtype;
935  bool adjacent = _ctrl_pressed;
936 
937  auto proc = [=](bool test, StationID to_join) -> bool {
938  if (test) {
939  return Command<CMD_BUILD_RAIL_STATION>::Do(CommandFlagsToDCFlags(GetCommandFlags<CMD_BUILD_RAIL_STATION>()), ta.tile, rt, params.orientation, numtracks, platlength, params.station_class, params.station_type, INVALID_STATION, adjacent).Succeeded();
940  } else {
941  return Command<CMD_BUILD_RAIL_STATION>::Post(STR_ERROR_CAN_T_BUILD_RAILROAD_STATION, CcStation, ta.tile, rt, params.orientation, numtracks, platlength, params.station_class, params.station_type, to_join, adjacent);
942  }
943  };
944 
945  ShowSelectStationIfNeeded(ta, proc);
946 }
947 
951 };
952 
954 private:
955  uint line_height;
959 
961 
962  static const uint EDITBOX_MAX_SIZE = 16;
963 
971 
980  {
981  uint pos = 0;
982  for (auto station_class : this->station_classes) {
983  if (station_class == _railstation.station_class) break;
984  pos++;
985  }
986  this->vscroll->SetCount(this->station_classes.size());
987  this->vscroll->ScrollTowards(pos);
988  }
989 
995  void CheckSelectedSize(const StationSpec *statspec)
996  {
997  if (statspec == nullptr || _settings_client.gui.station_dragdrop) return;
998 
999  /* If current number of tracks is not allowed, make it as big as possible */
1003  if (statspec->disallowed_platforms != UINT8_MAX) {
1006  }
1008  }
1009  }
1010 
1014  if (statspec->disallowed_lengths != UINT8_MAX) {
1017  }
1019  }
1020  }
1021  }
1022 
1023 public:
1025  {
1026  this->coverage_height = 2 * GetCharacterHeight(FS_NORMAL) + WidgetDimensions::scaled.vsep_normal;
1027  this->vscroll = nullptr;
1028  _railstation.newstations = newstation;
1029 
1030  this->CreateNestedTree();
1031  this->GetWidget<NWidgetStacked>(WID_BRAS_SHOW_NEWST_ADDITIONS)->SetDisplayedPlane(newstation ? 0 : SZSP_NONE);
1032  this->GetWidget<NWidgetStacked>(WID_BRAS_SHOW_NEWST_MATRIX)->SetDisplayedPlane(newstation ? 0 : SZSP_NONE);
1033  this->GetWidget<NWidgetStacked>(WID_BRAS_SHOW_NEWST_DEFSIZE)->SetDisplayedPlane(newstation ? 0 : SZSP_NONE);
1034  this->GetWidget<NWidgetStacked>(WID_BRAS_SHOW_NEWST_RESIZE)->SetDisplayedPlane(newstation ? 0 : SZSP_NONE);
1035  /* Hide the station class filter if no stations other than the default one are available. */
1036  this->GetWidget<NWidgetStacked>(WID_BRAS_FILTER_CONTAINER)->SetDisplayedPlane(newstation ? 0 : SZSP_NONE);
1037  if (newstation) {
1038  this->vscroll = this->GetScrollbar(WID_BRAS_NEWST_SCROLL);
1039  this->vscroll2 = this->GetScrollbar(WID_BRAS_MATRIX_SCROLL);
1040 
1042  this->station_classes.SetListing(this->last_sorting);
1043  this->station_classes.SetFiltering(this->last_filtering);
1044  this->station_classes.SetSortFuncs(this->sorter_funcs);
1045  this->station_classes.SetFilterFuncs(this->filter_funcs);
1046  }
1047 
1048  this->station_classes.ForceRebuild();
1049 
1052 
1054 
1055  this->LowerWidget(WID_BRAS_PLATFORM_DIR_X + _railstation.orientation);
1058  } else {
1061  }
1064 
1065  if (!newstation) {
1068  this->vscroll2 = nullptr;
1069  } else {
1072 
1073  NWidgetMatrix *matrix = this->GetWidget<NWidgetMatrix>(WID_BRAS_MATRIX);
1074  matrix->SetScrollbar(this->vscroll2);
1077 
1079  }
1080 
1081  this->InvalidateData();
1082  }
1083 
1084  void Close([[maybe_unused]] int data = 0) override
1085  {
1087  this->PickerWindowBase::Close();
1088  }
1089 
1091  static bool StationClassIDSorter(StationClassID const &a, StationClassID const &b)
1092  {
1093  return a < b;
1094  }
1095 
1097  static bool CDECL TagNameFilter(StationClassID const * sc, StringFilter &filter)
1098  {
1099  filter.ResetState();
1100  filter.AddLine(GetString(StationClass::Get(*sc)->name));
1101  return filter.GetState();
1102  }
1103 
1106  {
1107  if (!this->station_classes.NeedRebuild()) return;
1108 
1109  this->station_classes.clear();
1110 
1111  for (uint i = 0; i < StationClass::GetClassCount(); i++) {
1112  StationClassID station_class_id = (StationClassID)i;
1113  if (station_class_id == StationClassID::STAT_CLASS_WAYP) {
1114  // Skip waypoints.
1115  continue;
1116  }
1117  StationClass *station_class = StationClass::Get(station_class_id);
1118  if (station_class->GetUISpecCount() == 0) continue;
1119  station_classes.push_back(station_class_id);
1120  }
1121 
1122  if (_railstation.newstations) {
1123  this->station_classes.Filter(this->string_filter);
1124  this->station_classes.shrink_to_fit();
1125  this->station_classes.RebuildDone();
1126  this->station_classes.Sort();
1127 
1128  this->vscroll->SetCount(this->station_classes.size());
1129  }
1130  }
1131 
1137  {
1139  /* This happens during the first time the window is open during the game life cycle. */
1141  } else {
1142  /* Check if the previously selected station class is not available anymore as a
1143  * result of starting a new game without the corresponding NewGRF. */
1144  bool available = _railstation.station_class < StationClass::GetClassCount();
1146  }
1147  }
1148 
1153  void SelectOtherClass(StationClassID station_class)
1154  {
1155  _railstation.station_class = station_class;
1156  }
1157 
1158  void OnInvalidateData([[maybe_unused]] int data = 0, [[maybe_unused]] bool gui_scope = true) override
1159  {
1160  if (!gui_scope) return;
1161 
1163  }
1164 
1165  EventState OnHotkey(int hotkey) override
1166  {
1167  switch (hotkey) {
1170  SetFocusedWindow(this); // The user has asked to give focus to the text box, so make sure this window is focused.
1171  break;
1172 
1173  default:
1174  return ES_NOT_HANDLED;
1175  }
1176 
1177  return ES_HANDLED;
1178  }
1179 
1180  void OnEditboxChanged(WidgetID widget) override
1181  {
1182  if (widget == WID_BRAS_FILTER_EDITBOX) {
1183  string_filter.SetFilterTerm(this->filter_editbox.text.buf);
1184  this->station_classes.SetFilterState(!string_filter.IsEmpty());
1185  this->station_classes.ForceRebuild();
1186  this->InvalidateData();
1187  }
1188  }
1189 
1190  void OnPaint() override
1191  {
1192  bool newstations = _railstation.newstations;
1193  const StationSpec *statspec = newstations ? StationClass::Get(_railstation.station_class)->GetSpec(_railstation.station_type) : nullptr;
1194 
1196  SetTileSelectSize(1, 1);
1197  } else {
1200  if (_railstation.orientation == AXIS_X) Swap(x, y);
1201  if (!_remove_button_clicked) {
1202  SetTileSelectSize(x, y);
1203  }
1204  }
1205 
1207 
1208  if (_settings_client.gui.station_show_coverage) SetTileSelectBigSize(-rad, -rad, 2 * rad, 2 * rad);
1209 
1210  for (uint bits = 0; bits < 7; bits++) {
1211  bool disable = bits >= _settings_game.station.station_spread;
1212  if (statspec == nullptr) {
1213  this->SetWidgetDisabledState(bits + WID_BRAS_PLATFORM_NUM_1, disable);
1214  this->SetWidgetDisabledState(bits + WID_BRAS_PLATFORM_LEN_1, disable);
1215  } else {
1216  this->SetWidgetDisabledState(bits + WID_BRAS_PLATFORM_NUM_1, HasBit(statspec->disallowed_platforms, bits) || disable);
1217  this->SetWidgetDisabledState(bits + WID_BRAS_PLATFORM_LEN_1, HasBit(statspec->disallowed_lengths, bits) || disable);
1218  }
1219  }
1220 
1221  this->DrawWidgets();
1222 
1223  if (this->IsShaded()) return;
1224  /* 'Accepts' and 'Supplies' texts. */
1225  Rect r = this->GetWidget<NWidgetBase>(WID_BRAS_COVERAGE_TEXTS)->GetCurrentRect();
1226  int top = r.top;
1228  top = DrawStationCoverageAreaText(r.left, r.right, top, SCT_ALL, rad, true);
1229  /* Resize background if the window is too small.
1230  * Never make the window smaller to avoid oscillating if the size change affects the acceptance.
1231  * (This is the case, if making the window bigger moves the mouse into the window.) */
1232  if (top > r.bottom) {
1233  this->coverage_height += top - r.bottom;
1234  this->ReInit();
1235  }
1236  }
1237 
1238  void UpdateWidgetSize(WidgetID widget, Dimension *size, [[maybe_unused]] const Dimension &padding, [[maybe_unused]] Dimension *fill, [[maybe_unused]] Dimension *resize) override
1239  {
1240  switch (widget) {
1241  case WID_BRAS_NEWST_LIST: {
1242  Dimension d = {0, 0};
1243  for (auto station_class : this->station_classes) {
1244  d = maxdim(d, GetStringBoundingBox(StationClass::Get(station_class)->name));
1245  }
1246  size->width = std::max(size->width, d.width + padding.width);
1247  this->line_height = GetCharacterHeight(FS_NORMAL) + padding.height;
1248  size->height = 5 * this->line_height;
1249  resize->height = this->line_height;
1250  break;
1251  }
1252 
1253  case WID_BRAS_SHOW_NEWST_TYPE: {
1254  if (!_railstation.newstations) {
1255  size->width = 0;
1256  size->height = 0;
1257  break;
1258  }
1259 
1260  /* If newstations exist, compute the non-zero minimal size. */
1261  Dimension d = {0, 0};
1262  StringID str = this->GetWidget<NWidgetCore>(widget)->widget_data;
1263  for (auto station_class : this->station_classes) {
1264  StationClass *stclass = StationClass::Get(station_class);
1265  for (uint j = 0; j < stclass->GetSpecCount(); j++) {
1266  const StationSpec *statspec = stclass->GetSpec(j);
1267  SetDParam(0, (statspec != nullptr && statspec->name != 0) ? statspec->name : STR_STATION_CLASS_DFLT_STATION);
1268  d = maxdim(d, GetStringBoundingBox(str));
1269  }
1270  }
1271  size->width = std::max(size->width, d.width + padding.width);
1272  break;
1273  }
1274 
1277  case WID_BRAS_IMAGE:
1280  break;
1281 
1283  size->height = this->coverage_height;
1284  break;
1285 
1286  case WID_BRAS_MATRIX:
1287  fill->height = 1;
1288  resize->height = 1;
1289  break;
1290  }
1291  }
1292 
1293  void DrawWidget(const Rect &r, WidgetID widget) const override
1294  {
1295  DrawPixelInfo tmp_dpi;
1296 
1297  switch (widget) {
1298  case WID_BRAS_PLATFORM_DIR_X: {
1299  /* Set up a clipping area for the '/' station preview */
1300  Rect ir = r.Shrink(WidgetDimensions::scaled.bevel);
1301  if (FillDrawPixelInfo(&tmp_dpi, ir)) {
1302  AutoRestoreBackup dpi_backup(_cur_dpi, &tmp_dpi);
1303  int x = (ir.Width() - ScaleSpriteTrad(64)) / 2 + ScaleSpriteTrad(31);
1304  int y = (ir.Height() + ScaleSpriteTrad(58)) / 2 - ScaleSpriteTrad(31);
1306  StationPickerDrawSprite(x, y, STATION_RAIL, _cur_railtype, INVALID_ROADTYPE, 2);
1307  }
1308  }
1309  break;
1310  }
1311 
1312  case WID_BRAS_PLATFORM_DIR_Y: {
1313  /* Set up a clipping area for the '\' station preview */
1314  Rect ir = r.Shrink(WidgetDimensions::scaled.bevel);
1315  if (FillDrawPixelInfo(&tmp_dpi, ir)) {
1316  AutoRestoreBackup dpi_backup(_cur_dpi, &tmp_dpi);
1317  int x = (ir.Width() - ScaleSpriteTrad(64)) / 2 + ScaleSpriteTrad(31);
1318  int y = (ir.Height() + ScaleSpriteTrad(58)) / 2 - ScaleSpriteTrad(31);
1320  StationPickerDrawSprite(x, y, STATION_RAIL, _cur_railtype, INVALID_ROADTYPE, 3);
1321  }
1322  }
1323  break;
1324  }
1325 
1326  case WID_BRAS_NEWST_LIST: {
1327  Rect ir = r.Shrink(WidgetDimensions::scaled.matrix);
1328  uint statclass = 0;
1329  for (auto station_class : this->station_classes) {
1330  if (this->vscroll->IsVisible(statclass)) {
1331  DrawString(ir,
1332  StationClass::Get(station_class)->name,
1333  station_class == _railstation.station_class ? TC_WHITE : TC_BLACK);
1334  ir.top += this->line_height;
1335  }
1336  statclass++;
1337  }
1338  break;
1339  }
1340 
1341  case WID_BRAS_IMAGE: {
1342  uint16_t type = this->GetWidget<NWidgetBase>(widget)->GetParentWidget<NWidgetMatrix>()->GetCurrentElement();
1343  assert(type < _railstation.station_count);
1344  /* Check station availability callback */
1345  const StationSpec *statspec = StationClass::Get(_railstation.station_class)->GetSpec(type);
1346 
1347  /* Set up a clipping area for the station preview. */
1348  Rect ir = r.Shrink(WidgetDimensions::scaled.bevel);
1349  if (FillDrawPixelInfo(&tmp_dpi, ir)) {
1350  AutoRestoreBackup dpi_backup(_cur_dpi, &tmp_dpi);
1351  int x = (ir.Width() - ScaleSpriteTrad(64)) / 2 + ScaleSpriteTrad(31);
1352  int y = (ir.Height() + ScaleSpriteTrad(58)) / 2 - ScaleSpriteTrad(31);
1354  StationPickerDrawSprite(x, y, STATION_RAIL, _cur_railtype, INVALID_ROADTYPE, 2 + _railstation.orientation);
1355  }
1356  }
1357  if (!IsStationAvailable(statspec)) {
1359  }
1360  break;
1361  }
1362  }
1363  }
1364 
1365  void OnResize() override
1366  {
1367  if (this->vscroll != nullptr) { // New stations available.
1368  this->vscroll->SetCapacityFromWidget(this, WID_BRAS_NEWST_LIST);
1369  }
1370  }
1371 
1372  void SetStringParameters(WidgetID widget) const override
1373  {
1374  if (widget == WID_BRAS_SHOW_NEWST_TYPE) {
1376  SetDParam(0, (statspec != nullptr && statspec->name != 0) ? statspec->name : STR_STATION_CLASS_DFLT_STATION);
1377  }
1378  }
1379 
1380  void OnClick([[maybe_unused]] Point pt, WidgetID widget, [[maybe_unused]] int click_count) override
1381  {
1382  switch (widget) {
1385  this->RaiseWidget(WID_BRAS_PLATFORM_DIR_X + _railstation.orientation);
1387  this->LowerWidget(WID_BRAS_PLATFORM_DIR_X + _railstation.orientation);
1388  if (_settings_client.sound.click_beep) SndPlayFx(SND_15_BEEP);
1389  this->SetDirty();
1391  break;
1392 
1399  case WID_BRAS_PLATFORM_NUM_7: {
1402 
1405 
1407  if (statspec != nullptr && HasBit(statspec->disallowed_lengths, _settings_client.gui.station_platlength - 1)) {
1408  /* The previously selected number of platforms in invalid */
1409  for (uint i = 0; i < 7; i++) {
1410  if (!HasBit(statspec->disallowed_lengths, i)) {
1413  break;
1414  }
1415  }
1416  }
1417 
1418  this->LowerWidget(_settings_client.gui.station_numtracks + WID_BRAS_PLATFORM_NUM_BEGIN);
1420  if (_settings_client.sound.click_beep) SndPlayFx(SND_15_BEEP);
1421  this->SetDirty();
1423  break;
1424  }
1425 
1432  case WID_BRAS_PLATFORM_LEN_7: {
1435 
1438 
1440  if (statspec != nullptr && HasBit(statspec->disallowed_platforms, _settings_client.gui.station_numtracks - 1)) {
1441  /* The previously selected number of tracks in invalid */
1442  for (uint i = 0; i < 7; i++) {
1443  if (!HasBit(statspec->disallowed_platforms, i)) {
1444  this->RaiseWidget(_settings_client.gui.station_numtracks + WID_BRAS_PLATFORM_NUM_BEGIN);
1446  break;
1447  }
1448  }
1449  }
1450 
1451  this->LowerWidget(_settings_client.gui.station_numtracks + WID_BRAS_PLATFORM_NUM_BEGIN);
1452  this->LowerWidget(_settings_client.gui.station_platlength + WID_BRAS_PLATFORM_LEN_BEGIN);
1453  if (_settings_client.sound.click_beep) SndPlayFx(SND_15_BEEP);
1454  this->SetDirty();
1456  break;
1457  }
1458 
1461 
1463 
1464  /* get the first allowed length/number of platforms */
1466  if (statspec != nullptr && HasBit(statspec->disallowed_lengths, _settings_client.gui.station_platlength - 1)) {
1467  for (uint i = 0; i < 7; i++) {
1468  if (!HasBit(statspec->disallowed_lengths, i)) {
1469  this->RaiseWidget(_settings_client.gui.station_platlength + WID_BRAS_PLATFORM_LEN_BEGIN);
1471  break;
1472  }
1473  }
1474  }
1475  if (statspec != nullptr && HasBit(statspec->disallowed_platforms, _settings_client.gui.station_numtracks - 1)) {
1476  for (uint i = 0; i < 7; i++) {
1477  if (!HasBit(statspec->disallowed_platforms, i)) {
1478  this->RaiseWidget(_settings_client.gui.station_numtracks + WID_BRAS_PLATFORM_NUM_BEGIN);
1480  break;
1481  }
1482  }
1483  }
1484 
1487  if (_settings_client.sound.click_beep) SndPlayFx(SND_15_BEEP);
1488  this->SetDirty();
1490  break;
1491  }
1492 
1494  case WID_BRAS_HIGHLIGHT_ON:
1496 
1499  if (_settings_client.sound.click_beep) SndPlayFx(SND_15_BEEP);
1500  this->SetDirty();
1501  SetViewportCatchmentStation(nullptr, true);
1502  break;
1503 
1504  case WID_BRAS_NEWST_LIST: {
1505  auto it = this->vscroll->GetScrolledItemFromWidget(this->station_classes, pt.y, this, WID_BRAS_NEWST_LIST);
1506  if (it == this->station_classes.end()) return;
1507  StationClassID station_class_id = *it;
1508  if (_railstation.station_class != station_class_id) {
1509  StationClass *station_class = StationClass::Get(station_class_id);
1510  _railstation.station_class = station_class_id;
1511  _railstation.station_count = station_class->GetSpecCount();
1513 
1514  this->CheckSelectedSize(station_class->GetSpec(_railstation.station_type));
1515 
1516  NWidgetMatrix *matrix = this->GetWidget<NWidgetMatrix>(WID_BRAS_MATRIX);
1519  }
1520  if (_settings_client.sound.click_beep) SndPlayFx(SND_15_BEEP);
1521  this->SetDirty();
1523  break;
1524  }
1525 
1526  case WID_BRAS_IMAGE: {
1527  uint16_t y = this->GetWidget<NWidgetBase>(widget)->GetParentWidget<NWidgetMatrix>()->GetCurrentElement();
1528  if (y >= _railstation.station_count) return;
1529 
1530  /* Check station availability callback */
1531  const StationSpec *statspec = StationClass::Get(_railstation.station_class)->GetSpec(y);
1532  if (!IsStationAvailable(statspec)) return;
1533 
1535 
1536  this->CheckSelectedSize(statspec);
1537  this->GetWidget<NWidgetBase>(widget)->GetParentWidget<NWidgetMatrix>()->SetClicked(_railstation.station_type);
1538 
1539  if (_settings_client.sound.click_beep) SndPlayFx(SND_15_BEEP);
1540  this->SetDirty();
1542  break;
1543  }
1544  }
1545  }
1546 
1547  void OnRealtimeTick([[maybe_unused]] uint delta_ms) override
1548  {
1550  }
1551 
1552  IntervalTimer<TimerGameCalendar> yearly_interval = {{TimerGameCalendar::YEAR, TimerGameCalendar::Priority::NONE}, [this](auto) {
1553  this->SetDirty();
1554  }};
1555 
1562  {
1563  if (_game_mode == GM_MENU) return ES_NOT_HANDLED;
1565  if (w == nullptr) return ES_NOT_HANDLED;
1566  return w->OnHotkey(hotkey);
1567  }
1568 
1569  static inline HotkeyList hotkeys{"buildrailstation", {
1570  Hotkey('F', "focus_filter_box", BRASHK_FOCUS_FILTER_BOX),
1572 };
1573 
1576 
1578  &StationClassIDSorter,
1579 };
1580 
1582  &TagNameFilter,
1583 };
1584 
1585 static constexpr NWidgetPart _nested_station_builder_widgets[] = {
1587  NWidget(WWT_CLOSEBOX, COLOUR_DARK_GREEN),
1588  NWidget(WWT_CAPTION, COLOUR_DARK_GREEN), SetDataTip(STR_STATION_BUILD_RAIL_CAPTION, STR_TOOLTIP_WINDOW_TITLE_DRAG_THIS),
1589  NWidget(WWT_SHADEBOX, COLOUR_DARK_GREEN),
1591  NWidget(WWT_DEFSIZEBOX, COLOUR_DARK_GREEN),
1592  EndContainer(),
1593  EndContainer(),
1595  NWidget(WWT_PANEL, COLOUR_DARK_GREEN),
1597  NWidget(NWID_HORIZONTAL), SetPIP(0, WidgetDimensions::unscaled.hsep_normal, 0), SetPIPRatio(1, 0, 1),
1601  NWidget(WWT_TEXT, COLOUR_DARK_GREEN), SetFill(0, 1), SetDataTip(STR_LIST_FILTER_TITLE, STR_NULL),
1602  NWidget(WWT_EDITBOX, COLOUR_GREY, WID_BRAS_FILTER_EDITBOX), SetFill(1, 0), SetResize(1, 0),
1603  SetDataTip(STR_LIST_FILTER_OSKTITLE, STR_LIST_FILTER_TOOLTIP),
1604  EndContainer(),
1605  EndContainer(),
1608  NWidget(WWT_MATRIX, COLOUR_GREY, WID_BRAS_NEWST_LIST), SetMinimalSize(122, 71), SetFill(1, 0),
1609  SetMatrixDataTip(1, 0, STR_STATION_BUILD_STATION_CLASS_TOOLTIP), SetScrollbar(WID_BRAS_NEWST_SCROLL),
1611  EndContainer(),
1612  EndContainer(),
1613  NWidget(WWT_LABEL, COLOUR_DARK_GREEN), SetMinimalSize(144, 11), SetDataTip(STR_STATION_BUILD_ORIENTATION, STR_NULL),
1614  NWidget(NWID_HORIZONTAL), SetPIP(0, WidgetDimensions::unscaled.hsep_normal, 0), SetPIPRatio(1, 0, 1),
1615  NWidget(WWT_PANEL, COLOUR_GREY, WID_BRAS_PLATFORM_DIR_X), SetMinimalSize(66, 60), SetFill(0, 0), SetDataTip(0x0, STR_STATION_BUILD_RAILROAD_ORIENTATION_TOOLTIP), EndContainer(),
1616  NWidget(WWT_PANEL, COLOUR_GREY, WID_BRAS_PLATFORM_DIR_Y), SetMinimalSize(66, 60), SetFill(0, 0), SetDataTip(0x0, STR_STATION_BUILD_RAILROAD_ORIENTATION_TOOLTIP), EndContainer(),
1617  EndContainer(),
1618  NWidget(WWT_LABEL, COLOUR_DARK_GREEN, WID_BRAS_SHOW_NEWST_TYPE), SetMinimalSize(144, 11), SetDataTip(STR_JUST_STRING, STR_NULL), SetTextStyle(TC_ORANGE),
1619  NWidget(WWT_LABEL, COLOUR_DARK_GREEN), SetMinimalSize(144, 11), SetDataTip(STR_STATION_BUILD_NUMBER_OF_TRACKS, STR_NULL),
1620  NWidget(NWID_HORIZONTAL), SetPIPRatio(1, 0, 1),
1621  NWidget(WWT_TEXTBTN, COLOUR_GREY, WID_BRAS_PLATFORM_NUM_1), SetMinimalSize(15, 12), SetDataTip(STR_BLACK_1, STR_STATION_BUILD_NUMBER_OF_TRACKS_TOOLTIP),
1622  NWidget(WWT_TEXTBTN, COLOUR_GREY, WID_BRAS_PLATFORM_NUM_2), SetMinimalSize(15, 12), SetDataTip(STR_BLACK_2, STR_STATION_BUILD_NUMBER_OF_TRACKS_TOOLTIP),
1623  NWidget(WWT_TEXTBTN, COLOUR_GREY, WID_BRAS_PLATFORM_NUM_3), SetMinimalSize(15, 12), SetDataTip(STR_BLACK_3, STR_STATION_BUILD_NUMBER_OF_TRACKS_TOOLTIP),
1624  NWidget(WWT_TEXTBTN, COLOUR_GREY, WID_BRAS_PLATFORM_NUM_4), SetMinimalSize(15, 12), SetDataTip(STR_BLACK_4, STR_STATION_BUILD_NUMBER_OF_TRACKS_TOOLTIP),
1625  NWidget(WWT_TEXTBTN, COLOUR_GREY, WID_BRAS_PLATFORM_NUM_5), SetMinimalSize(15, 12), SetDataTip(STR_BLACK_5, STR_STATION_BUILD_NUMBER_OF_TRACKS_TOOLTIP),
1626  NWidget(WWT_TEXTBTN, COLOUR_GREY, WID_BRAS_PLATFORM_NUM_6), SetMinimalSize(15, 12), SetDataTip(STR_BLACK_6, STR_STATION_BUILD_NUMBER_OF_TRACKS_TOOLTIP),
1627  NWidget(WWT_TEXTBTN, COLOUR_GREY, WID_BRAS_PLATFORM_NUM_7), SetMinimalSize(15, 12), SetDataTip(STR_BLACK_7, STR_STATION_BUILD_NUMBER_OF_TRACKS_TOOLTIP),
1628  EndContainer(),
1629  NWidget(WWT_LABEL, COLOUR_DARK_GREEN), SetMinimalSize(144, 11), SetDataTip(STR_STATION_BUILD_PLATFORM_LENGTH, STR_NULL),
1630  NWidget(NWID_HORIZONTAL), SetPIPRatio(1, 0, 1),
1631  NWidget(WWT_TEXTBTN, COLOUR_GREY, WID_BRAS_PLATFORM_LEN_1), SetMinimalSize(15, 12), SetDataTip(STR_BLACK_1, STR_STATION_BUILD_PLATFORM_LENGTH_TOOLTIP),
1632  NWidget(WWT_TEXTBTN, COLOUR_GREY, WID_BRAS_PLATFORM_LEN_2), SetMinimalSize(15, 12), SetDataTip(STR_BLACK_2, STR_STATION_BUILD_PLATFORM_LENGTH_TOOLTIP),
1633  NWidget(WWT_TEXTBTN, COLOUR_GREY, WID_BRAS_PLATFORM_LEN_3), SetMinimalSize(15, 12), SetDataTip(STR_BLACK_3, STR_STATION_BUILD_PLATFORM_LENGTH_TOOLTIP),
1634  NWidget(WWT_TEXTBTN, COLOUR_GREY, WID_BRAS_PLATFORM_LEN_4), SetMinimalSize(15, 12), SetDataTip(STR_BLACK_4, STR_STATION_BUILD_PLATFORM_LENGTH_TOOLTIP),
1635  NWidget(WWT_TEXTBTN, COLOUR_GREY, WID_BRAS_PLATFORM_LEN_5), SetMinimalSize(15, 12), SetDataTip(STR_BLACK_5, STR_STATION_BUILD_PLATFORM_LENGTH_TOOLTIP),
1636  NWidget(WWT_TEXTBTN, COLOUR_GREY, WID_BRAS_PLATFORM_LEN_6), SetMinimalSize(15, 12), SetDataTip(STR_BLACK_6, STR_STATION_BUILD_PLATFORM_LENGTH_TOOLTIP),
1637  NWidget(WWT_TEXTBTN, COLOUR_GREY, WID_BRAS_PLATFORM_LEN_7), SetMinimalSize(15, 12), SetDataTip(STR_BLACK_7, STR_STATION_BUILD_PLATFORM_LENGTH_TOOLTIP),
1638  EndContainer(),
1639  NWidget(NWID_HORIZONTAL), SetPIPRatio(1, 0, 1),
1640  NWidget(WWT_TEXTBTN, COLOUR_GREY, WID_BRAS_PLATFORM_DRAG_N_DROP), SetMinimalSize(75, 12), SetDataTip(STR_STATION_BUILD_DRAG_DROP, STR_STATION_BUILD_DRAG_DROP_TOOLTIP),
1641  EndContainer(),
1642  NWidget(WWT_LABEL, COLOUR_DARK_GREEN), SetDataTip(STR_STATION_BUILD_COVERAGE_AREA_TITLE, STR_NULL), SetFill(1, 0),
1643  NWidget(NWID_HORIZONTAL), SetPIPRatio(1, 0, 1),
1644  NWidget(WWT_TEXTBTN, COLOUR_GREY, WID_BRAS_HIGHLIGHT_OFF), SetMinimalSize(60, 12),
1645  SetDataTip(STR_STATION_BUILD_COVERAGE_OFF, STR_STATION_BUILD_COVERAGE_AREA_OFF_TOOLTIP),
1646  NWidget(WWT_TEXTBTN, COLOUR_GREY, WID_BRAS_HIGHLIGHT_ON), SetMinimalSize(60, 12),
1647  SetDataTip(STR_STATION_BUILD_COVERAGE_ON, STR_STATION_BUILD_COVERAGE_AREA_ON_TOOLTIP),
1648  EndContainer(),
1649  EndContainer(),
1651  /* We need an additional background for the matrix, as the matrix cannot handle the scrollbar due to not being an NWidgetCore. */
1652  NWidget(WWT_PANEL, COLOUR_DARK_GREEN), SetScrollbar(WID_BRAS_MATRIX_SCROLL),
1653  NWidget(NWID_MATRIX, COLOUR_DARK_GREEN, WID_BRAS_MATRIX), SetPIP(0, 2, 0),
1654  NWidget(WWT_PANEL, COLOUR_DARK_GREEN, WID_BRAS_IMAGE), SetMinimalSize(66, 60),
1655  SetFill(0, 0), SetResize(0, 0), SetDataTip(0x0, STR_STATION_BUILD_STATION_TYPE_TOOLTIP), SetScrollbar(WID_BRAS_MATRIX_SCROLL),
1656  EndContainer(),
1657  EndContainer(),
1658  EndContainer(),
1659  EndContainer(),
1660  EndContainer(),
1662  EndContainer(),
1663  EndContainer(),
1666  NWidget(NWID_VSCROLLBAR, COLOUR_DARK_GREEN, WID_BRAS_MATRIX_SCROLL),
1667  NWidget(WWT_RESIZEBOX, COLOUR_DARK_GREEN),
1668  EndContainer(),
1669  EndContainer(),
1670  EndContainer(),
1671 };
1672 
1674 static WindowDesc _station_builder_desc(__FILE__, __LINE__,
1675  WDP_AUTO, "build_station_rail", 350, 0,
1678  std::begin(_nested_station_builder_widgets), std::end(_nested_station_builder_widgets),
1679  &BuildRailStationWindow::hotkeys
1680 );
1681 
1684 {
1685  bool newstations = StationClass::GetClassCount() > 2 || StationClass::Get(STAT_CLASS_DFLT)->GetSpecCount() != 1;
1686  return new BuildRailStationWindow(&_station_builder_desc, parent, newstations);
1687 }
1688 
1690 private:
1693 
1698  void DrawSignalSprite(const Rect &r, SpriteID image) const
1699  {
1700  Point offset;
1701  Dimension sprite_size = GetSpriteSize(image, &offset);
1702  Rect ir = r.Shrink(WidgetDimensions::scaled.imgbtn);
1703  int x = CenterBounds(ir.left, ir.right, sprite_size.width - offset.x) - offset.x; // centered
1704  int y = ir.top - sig_sprite_bottom_offset +
1705  (ir.Height() + sig_sprite_size.height) / 2; // aligned to bottom
1706 
1707  DrawSprite(image, PAL_NONE, x, y);
1708  }
1709 
1712  {
1713  bool show_non_path_signals = (_settings_client.gui.signal_gui_mode == SIGNAL_GUI_ALL);
1714 
1715  this->GetWidget<NWidgetStacked>(WID_BS_BLOCK_SEL)->SetDisplayedPlane(show_non_path_signals ? 0 : SZSP_NONE);
1716  this->GetWidget<NWidgetStacked>(WID_BS_BLOCK_SPACER_SEL)->SetDisplayedPlane(show_non_path_signals ? 0 : SZSP_NONE);
1717  }
1718 
1719 public:
1721  {
1722  this->CreateNestedTree();
1723  this->SetSignalUIMode();
1725  this->OnInvalidateData();
1726  }
1727 
1728  void Close([[maybe_unused]] int data = 0) override
1729  {
1730  _convert_signal_button = false;
1731  this->PickerWindowBase::Close();
1732  }
1733 
1734  void OnInit() override
1735  {
1736  /* Calculate maximum signal sprite size. */
1737  this->sig_sprite_size.width = 0;
1738  this->sig_sprite_size.height = 0;
1739  this->sig_sprite_bottom_offset = 0;
1741  for (uint type = SIGTYPE_BLOCK; type < SIGTYPE_END; type++) {
1742  for (uint variant = SIG_ELECTRIC; variant <= SIG_SEMAPHORE; variant++) {
1743  for (uint lowered = 0; lowered < 2; lowered++) {
1744  Point offset;
1745  Dimension sprite_size = GetSpriteSize(rti->gui_sprites.signals[type][variant][lowered], &offset);
1746  this->sig_sprite_bottom_offset = std::max<int>(this->sig_sprite_bottom_offset, sprite_size.height);
1747  this->sig_sprite_size.width = std::max<int>(this->sig_sprite_size.width, sprite_size.width - offset.x);
1748  this->sig_sprite_size.height = std::max<int>(this->sig_sprite_size.height, sprite_size.height - offset.y);
1749  }
1750  }
1751  }
1752  }
1753 
1754  void UpdateWidgetSize(WidgetID widget, Dimension *size, [[maybe_unused]] const Dimension &padding, [[maybe_unused]] Dimension *fill, [[maybe_unused]] Dimension *resize) override
1755  {
1756  if (widget == WID_BS_DRAG_SIGNALS_DENSITY_LABEL) {
1757  /* Two digits for signals density. */
1758  size->width = std::max(size->width, 2 * GetDigitWidth() + padding.width + WidgetDimensions::scaled.framerect.Horizontal());
1759  } else if (IsInsideMM(widget, WID_BS_SEMAPHORE_NORM, WID_BS_ELECTRIC_PBS_OWAY + 1)) {
1760  size->width = std::max(size->width, this->sig_sprite_size.width + padding.width);
1761  size->height = std::max(size->height, this->sig_sprite_size.height + padding.height);
1762  } else if (widget == WID_BS_CAPTION) {
1764  }
1765  }
1766 
1767  void SetStringParameters(WidgetID widget) const override
1768  {
1769  switch (widget) {
1772  break;
1773  }
1774  }
1775 
1776  void DrawWidget(const Rect &r, WidgetID widget) const override
1777  {
1779  /* Extract signal from widget number. */
1780  int type = (widget - WID_BS_SEMAPHORE_NORM) % SIGTYPE_END;
1781  int var = SIG_SEMAPHORE - (widget - WID_BS_SEMAPHORE_NORM) / SIGTYPE_END; // SignalVariant order is reversed compared to the widgets.
1782  SpriteID sprite = GetRailTypeInfo(_cur_railtype)->gui_sprites.signals[type][var][this->IsWidgetLowered(widget)];
1783 
1784  this->DrawSignalSprite(r, sprite);
1785  }
1786  }
1787 
1788  void OnClick([[maybe_unused]] Point pt, WidgetID widget, [[maybe_unused]] int click_count) override
1789  {
1790  switch (widget) {
1791  case WID_BS_SEMAPHORE_NORM:
1793  case WID_BS_SEMAPHORE_EXIT:
1795  case WID_BS_SEMAPHORE_PBS:
1797  case WID_BS_ELECTRIC_NORM:
1798  case WID_BS_ELECTRIC_ENTRY:
1799  case WID_BS_ELECTRIC_EXIT:
1800  case WID_BS_ELECTRIC_COMBO:
1801  case WID_BS_ELECTRIC_PBS:
1804 
1805  _cur_signal_type = (SignalType)((uint)((widget - WID_BS_SEMAPHORE_NORM) % (SIGTYPE_LAST + 1)));
1807 
1808  /* Update default (last-used) signal type in config file. */
1810 
1811  /* If 'remove' button of rail build toolbar is active, disable it. */
1812  if (_remove_button_clicked) {
1814  if (w != nullptr) ToggleRailButton_Remove(w);
1815  }
1816 
1817  break;
1818 
1819  case WID_BS_CONVERT:
1821  break;
1822 
1827  }
1828  break;
1829 
1834  }
1835  break;
1836 
1837  case WID_BS_TOGGLE_SIZE:
1839  this->SetSignalUIMode();
1840  this->ReInit();
1841  break;
1842 
1843  default: break;
1844  }
1845 
1846  this->InvalidateData();
1847  }
1848 
1854  void OnInvalidateData([[maybe_unused]] int data = 0, [[maybe_unused]] bool gui_scope = true) override
1855  {
1856  if (!gui_scope) return;
1858 
1860 
1863  }
1864 };
1865 
1868  /* Title bar and buttons. */
1870  NWidget(WWT_CLOSEBOX, COLOUR_DARK_GREEN),
1871  NWidget(WWT_CAPTION, COLOUR_DARK_GREEN, WID_BS_CAPTION), SetDataTip(STR_BUILD_SIGNAL_CAPTION, STR_TOOLTIP_WINDOW_TITLE_DRAG_THIS),
1872  NWidget(WWT_IMGBTN, COLOUR_DARK_GREEN, WID_BS_TOGGLE_SIZE), SetDataTip(SPR_LARGE_SMALL_WINDOW, STR_BUILD_SIGNAL_TOGGLE_ADVANCED_SIGNAL_TOOLTIP),
1873  EndContainer(),
1874 
1875  /* Container for both signal groups, spacers, and convert/autofill buttons. */
1877  /* Block signals (can be hidden). */
1878  NWidget(NWID_SELECTION, INVALID_COLOUR, WID_BS_BLOCK_SEL),
1880  /* Semaphore block signals. */
1882  NWidget(WWT_PANEL, COLOUR_DARK_GREEN, WID_BS_SEMAPHORE_NORM), SetDataTip(STR_NULL, STR_BUILD_SIGNAL_SEMAPHORE_NORM_TOOLTIP), EndContainer(),
1883  NWidget(WWT_PANEL, COLOUR_DARK_GREEN, WID_BS_SEMAPHORE_ENTRY), SetDataTip(STR_NULL, STR_BUILD_SIGNAL_SEMAPHORE_ENTRY_TOOLTIP), EndContainer(),
1884  NWidget(WWT_PANEL, COLOUR_DARK_GREEN, WID_BS_SEMAPHORE_EXIT), SetDataTip(STR_NULL, STR_BUILD_SIGNAL_SEMAPHORE_EXIT_TOOLTIP), EndContainer(),
1885  NWidget(WWT_PANEL, COLOUR_DARK_GREEN, WID_BS_SEMAPHORE_COMBO), SetDataTip(STR_NULL, STR_BUILD_SIGNAL_SEMAPHORE_COMBO_TOOLTIP), EndContainer(),
1886  EndContainer(),
1887  /* Electric block signals. */
1889  NWidget(WWT_PANEL, COLOUR_DARK_GREEN, WID_BS_ELECTRIC_NORM), SetDataTip(STR_NULL, STR_BUILD_SIGNAL_ELECTRIC_NORM_TOOLTIP), EndContainer(),
1890  NWidget(WWT_PANEL, COLOUR_DARK_GREEN, WID_BS_ELECTRIC_ENTRY), SetDataTip(STR_NULL, STR_BUILD_SIGNAL_ELECTRIC_ENTRY_TOOLTIP), EndContainer(),
1891  NWidget(WWT_PANEL, COLOUR_DARK_GREEN, WID_BS_ELECTRIC_EXIT), SetDataTip(STR_NULL, STR_BUILD_SIGNAL_ELECTRIC_EXIT_TOOLTIP), EndContainer(),
1892  NWidget(WWT_PANEL, COLOUR_DARK_GREEN, WID_BS_ELECTRIC_COMBO), SetDataTip(STR_NULL, STR_BUILD_SIGNAL_ELECTRIC_COMBO_TOOLTIP), EndContainer(),
1893  EndContainer(),
1894  EndContainer(),
1895  EndContainer(),
1896 
1897  /* Divider (only shown if block signals visible). */
1899  NWidget(WWT_PANEL, COLOUR_DARK_GREEN), SetMinimalSize(4, 0), EndContainer(),
1900  EndContainer(),
1901 
1902  /* Path signals. */
1904  /* Semaphore path signals. */
1906  NWidget(WWT_PANEL, COLOUR_DARK_GREEN, WID_BS_SEMAPHORE_PBS), SetDataTip(STR_NULL, STR_BUILD_SIGNAL_SEMAPHORE_PBS_TOOLTIP), EndContainer(),
1907  NWidget(WWT_PANEL, COLOUR_DARK_GREEN, WID_BS_SEMAPHORE_PBS_OWAY), SetDataTip(STR_NULL, STR_BUILD_SIGNAL_SEMAPHORE_PBS_OWAY_TOOLTIP), EndContainer(),
1908  EndContainer(),
1909  /* Electric path signals. */
1911  NWidget(WWT_PANEL, COLOUR_DARK_GREEN, WID_BS_ELECTRIC_PBS), SetDataTip(STR_NULL, STR_BUILD_SIGNAL_ELECTRIC_PBS_TOOLTIP), EndContainer(),
1912  NWidget(WWT_PANEL, COLOUR_DARK_GREEN, WID_BS_ELECTRIC_PBS_OWAY), SetDataTip(STR_NULL, STR_BUILD_SIGNAL_ELECTRIC_PBS_OWAY_TOOLTIP), EndContainer(),
1913  EndContainer(),
1914  EndContainer(),
1915 
1916  /* Convert/autofill buttons. */
1918  NWidget(WWT_IMGBTN, COLOUR_DARK_GREEN, WID_BS_CONVERT), SetDataTip(SPR_IMG_SIGNAL_CONVERT, STR_BUILD_SIGNAL_CONVERT_TOOLTIP), SetFill(1, 1),
1919  NWidget(WWT_PANEL, COLOUR_DARK_GREEN), SetDataTip(STR_NULL, STR_BUILD_SIGNAL_DRAG_SIGNALS_DENSITY_TOOLTIP), SetFill(1, 1),
1920  NWidget(WWT_LABEL, COLOUR_DARK_GREEN, WID_BS_DRAG_SIGNALS_DENSITY_LABEL), SetDataTip(STR_JUST_INT, STR_BUILD_SIGNAL_DRAG_SIGNALS_DENSITY_TOOLTIP), SetTextStyle(TC_ORANGE), SetFill(1, 1),
1921  NWidget(NWID_HORIZONTAL), SetPIP(2, 0, 2),
1922  NWidget(NWID_SPACER), SetFill(1, 0),
1923  NWidget(WWT_PUSHARROWBTN, COLOUR_GREY, WID_BS_DRAG_SIGNALS_DENSITY_DECREASE), SetMinimalSize(9, 12), SetDataTip(AWV_DECREASE, STR_BUILD_SIGNAL_DRAG_SIGNALS_DENSITY_DECREASE_TOOLTIP),
1924  NWidget(WWT_PUSHARROWBTN, COLOUR_GREY, WID_BS_DRAG_SIGNALS_DENSITY_INCREASE), SetMinimalSize(9, 12), SetDataTip(AWV_INCREASE, STR_BUILD_SIGNAL_DRAG_SIGNALS_DENSITY_INCREASE_TOOLTIP),
1925  NWidget(NWID_SPACER), SetFill(1, 0),
1926  EndContainer(),
1927  NWidget(NWID_SPACER), SetMinimalSize(0, 2), SetFill(1, 0),
1928  EndContainer(),
1929  EndContainer(),
1930  EndContainer(),
1931 };
1932 
1934 static WindowDesc _signal_builder_desc(__FILE__, __LINE__,
1935  WDP_AUTO, nullptr, 0, 0,
1939 );
1940 
1944 static void ShowSignalBuilder(Window *parent)
1945 {
1947 }
1948 
1951  {
1952  this->InitNested(TRANSPORT_RAIL);
1954  }
1955 
1956  void UpdateWidgetSize(WidgetID widget, Dimension *size, [[maybe_unused]] const Dimension &padding, [[maybe_unused]] Dimension *fill, [[maybe_unused]] Dimension *resize) override
1957  {
1958  if (!IsInsideMM(widget, WID_BRAD_DEPOT_NE, WID_BRAD_DEPOT_NW + 1)) return;
1959 
1962  }
1963 
1964  void DrawWidget(const Rect &r, WidgetID widget) const override
1965  {
1966  if (!IsInsideMM(widget, WID_BRAD_DEPOT_NE, WID_BRAD_DEPOT_NW + 1)) return;
1967 
1968  DrawPixelInfo tmp_dpi;
1969  Rect ir = r.Shrink(WidgetDimensions::scaled.bevel);
1970  if (FillDrawPixelInfo(&tmp_dpi, ir)) {
1971  AutoRestoreBackup dpi_backup(_cur_dpi, &tmp_dpi);
1972  int x = (ir.Width() - ScaleSpriteTrad(64)) / 2 + ScaleSpriteTrad(31);
1973  int y = (ir.Height() + ScaleSpriteTrad(48)) / 2 - ScaleSpriteTrad(31);
1974  DrawTrainDepotSprite(x, y, widget - WID_BRAD_DEPOT_NE + DIAGDIR_NE, _cur_railtype);
1975  }
1976  }
1977 
1978  void OnClick([[maybe_unused]] Point pt, WidgetID widget, [[maybe_unused]] int click_count) override
1979  {
1980  switch (widget) {
1981  case WID_BRAD_DEPOT_NE:
1982  case WID_BRAD_DEPOT_SE:
1983  case WID_BRAD_DEPOT_SW:
1984  case WID_BRAD_DEPOT_NW:
1988  if (_settings_client.sound.click_beep) SndPlayFx(SND_15_BEEP);
1989  this->SetDirty();
1990  break;
1991  }
1992  }
1993 };
1994 
1998  NWidget(WWT_CLOSEBOX, COLOUR_DARK_GREEN),
1999  NWidget(WWT_CAPTION, COLOUR_DARK_GREEN), SetDataTip(STR_BUILD_DEPOT_TRAIN_ORIENTATION_CAPTION, STR_TOOLTIP_WINDOW_TITLE_DRAG_THIS),
2000  EndContainer(),
2001  NWidget(WWT_PANEL, COLOUR_DARK_GREEN),
2004  NWidget(WWT_TEXTBTN, COLOUR_GREY, WID_BRAD_DEPOT_NW), SetMinimalSize(66, 50), SetDataTip(0x0, STR_BUILD_DEPOT_TRAIN_ORIENTATION_TOOLTIP),
2005  NWidget(WWT_TEXTBTN, COLOUR_GREY, WID_BRAD_DEPOT_SW), SetMinimalSize(66, 50), SetDataTip(0x0, STR_BUILD_DEPOT_TRAIN_ORIENTATION_TOOLTIP),
2006  EndContainer(),
2008  NWidget(WWT_TEXTBTN, COLOUR_GREY, WID_BRAD_DEPOT_NE), SetMinimalSize(66, 50), SetDataTip(0x0, STR_BUILD_DEPOT_TRAIN_ORIENTATION_TOOLTIP),
2009  NWidget(WWT_TEXTBTN, COLOUR_GREY, WID_BRAD_DEPOT_SE), SetMinimalSize(66, 50), SetDataTip(0x0, STR_BUILD_DEPOT_TRAIN_ORIENTATION_TOOLTIP),
2010  EndContainer(),
2011  EndContainer(),
2012  EndContainer(),
2013 };
2014 
2015 static WindowDesc _build_depot_desc(__FILE__, __LINE__,
2016  WDP_AUTO, nullptr, 0, 0,
2020 );
2021 
2022 static void ShowBuildTrainDepotPicker(Window *parent)
2023 {
2024  new BuildRailDepotWindow(&_build_depot_desc, parent);
2025 }
2026 
2028  using WaypointList = GUIList<uint>;
2029  static const uint FILTER_LENGTH = 20;
2030 
2031  const StationClass *waypoints;
2032  WaypointList list;
2035 
2037  {
2038  this->waypoints = StationClass::Get(STAT_CLASS_WAYP);
2039 
2040  this->CreateNestedTree();
2041 
2042  NWidgetMatrix *matrix = this->GetWidget<NWidgetMatrix>(WID_BRW_WAYPOINT_MATRIX);
2043  matrix->SetScrollbar(this->GetScrollbar(WID_BRW_SCROLL));
2044 
2046 
2047  this->querystrings[WID_BRW_FILTER] = &this->editbox;
2048  this->editbox.cancel_button = QueryString::ACTION_CLEAR;
2049  this->string_filter.SetFilterTerm(this->editbox.text.buf);
2050 
2051  this->list.ForceRebuild();
2052  this->BuildPickerList();
2053  }
2054 
2055  void Close([[maybe_unused]] int data = 0) override
2056  {
2058  this->PickerWindowBase::Close();
2059  }
2060 
2061  bool FilterByText(const StationSpec *statspec)
2062  {
2063  if (this->string_filter.IsEmpty()) return true;
2064  this->string_filter.ResetState();
2065  if (statspec == nullptr) {
2066  this->string_filter.AddLine(GetString(STR_STATION_CLASS_WAYP_WAYPOINT));
2067  } else {
2068  this->string_filter.AddLine(GetString(statspec->name));
2069  if (statspec->grf_prop.grffile != nullptr) {
2070  const GRFConfig *gc = GetGRFConfig(statspec->grf_prop.grffile->grfid);
2071  this->string_filter.AddLine(gc->GetName());
2072  }
2073  }
2074  return this->string_filter.GetState();
2075  }
2076 
2077  void BuildPickerList()
2078  {
2079  if (!this->list.NeedRebuild()) return;
2080 
2081  this->list.clear();
2082  this->list.reserve(this->waypoints->GetSpecCount());
2083  for (uint i = 0; i < this->waypoints->GetSpecCount(); i++) {
2084  const StationSpec *statspec = this->waypoints->GetSpec(i);
2085  if (!FilterByText(statspec)) continue;
2086 
2087  this->list.push_back(i);
2088  }
2089  this->list.RebuildDone();
2090 
2091  NWidgetMatrix *matrix = this->GetWidget<NWidgetMatrix>(WID_BRW_WAYPOINT_MATRIX);
2092  matrix->SetCount((int)this->list.size());
2093  matrix->SetClicked(this->UpdateSelection(_cur_waypoint_type));
2094  }
2095 
2096  uint UpdateSelection(uint type)
2097  {
2098  auto found = std::find(std::begin(this->list), std::end(this->list), type);
2099  if (found != std::end(this->list)) return found - std::begin(this->list);
2100 
2101  /* Selection isn't in the list, default to first */
2102  if (this->list.empty()) {
2103  _cur_waypoint_type = 0;
2104  return -1;
2105  } else {
2106  _cur_waypoint_type = this->list.front();
2107  return 0;
2108  }
2109  }
2110 
2111  void UpdateWidgetSize(WidgetID widget, Dimension *size, [[maybe_unused]] const Dimension &padding, [[maybe_unused]] Dimension *fill, [[maybe_unused]] Dimension *resize) override
2112  {
2113  switch (widget) {
2115  /* Two blobs high and three wide. */
2116  size->width += resize->width * 2;
2117  size->height += resize->height * 1;
2118 
2119  /* Resizing in X direction only at blob size, but at pixel level in Y. */
2120  resize->height = 1;
2121  break;
2122 
2123  case WID_BRW_WAYPOINT:
2126  break;
2127  }
2128  }
2129 
2130  void SetStringParameters(WidgetID widget) const override
2131  {
2132  if (widget == WID_BRW_NAME) {
2133  if (!this->list.empty() && IsInsideBS(_cur_waypoint_type, 0, this->waypoints->GetSpecCount())) {
2134  const StationSpec *statspec = this->waypoints->GetSpec(_cur_waypoint_type);
2135  if (statspec == nullptr) {
2136  SetDParam(0, STR_STATION_CLASS_WAYP_WAYPOINT);
2137  } else {
2138  SetDParam(0, statspec->name);
2139  }
2140  } else {
2141  SetDParam(0, STR_EMPTY);
2142  }
2143  }
2144  }
2145 
2146  void OnPaint() override
2147  {
2148  this->BuildPickerList();
2149  this->DrawWidgets();
2150  }
2151 
2152  void DrawWidget(const Rect &r, WidgetID widget) const override
2153  {
2154  switch (widget) {
2155  case WID_BRW_WAYPOINT: {
2156  uint16_t type = this->list.at(this->GetWidget<NWidgetBase>(widget)->GetParentWidget<NWidgetMatrix>()->GetCurrentElement());
2157  const StationSpec *statspec = this->waypoints->GetSpec(type);
2158 
2159  DrawPixelInfo tmp_dpi;
2160  Rect ir = r.Shrink(WidgetDimensions::scaled.bevel);
2161  if (FillDrawPixelInfo(&tmp_dpi, ir)) {
2162  AutoRestoreBackup dpi_backup(_cur_dpi, &tmp_dpi);
2163  int x = (ir.Width() - ScaleSpriteTrad(64)) / 2 + ScaleSpriteTrad(31);
2164  int y = (ir.Height() + ScaleSpriteTrad(58)) / 2 - ScaleSpriteTrad(31);
2165  DrawWaypointSprite(x, y, type, _cur_railtype);
2166  }
2167 
2168  if (!IsStationAvailable(statspec)) {
2170  }
2171  }
2172  }
2173  }
2174 
2175  void OnClick([[maybe_unused]] Point pt, WidgetID widget, [[maybe_unused]] int click_count) override
2176  {
2177  switch (widget) {
2178  case WID_BRW_WAYPOINT: {
2179  uint16_t sel = this->GetWidget<NWidgetBase>(widget)->GetParentWidget<NWidgetMatrix>()->GetCurrentElement();
2180  assert(sel < this->list.size());
2181  uint16_t type = this->list.at(sel);
2182 
2183  /* Check station availability callback */
2184  const StationSpec *statspec = this->waypoints->GetSpec(type);
2185  if (!IsStationAvailable(statspec)) return;
2186 
2187  _cur_waypoint_type = type;
2188  this->GetWidget<NWidgetBase>(widget)->GetParentWidget<NWidgetMatrix>()->SetClicked(sel);
2189  if (_settings_client.sound.click_beep) SndPlayFx(SND_15_BEEP);
2190  this->SetDirty();
2191  break;
2192  }
2193  }
2194  }
2195 
2196  void OnInvalidateData([[maybe_unused]] int data = 0, [[maybe_unused]] bool gui_scope = true) override
2197  {
2198  if (!gui_scope) return;
2199  this->list.ForceRebuild();
2200  }
2201 
2202  void OnEditboxChanged(WidgetID wid) override
2203  {
2204  if (wid == WID_BRW_FILTER) {
2205  this->string_filter.SetFilterTerm(this->editbox.text.buf);
2206  this->InvalidateData();
2207  }
2208  }
2209 
2210  void OnRealtimeTick([[maybe_unused]] uint delta_ms) override
2211  {
2212  CheckRedrawWaypointCoverage(this);
2213  }
2214 };
2215 
2216 /* static */ QueryString BuildRailWaypointWindow::editbox(BuildRailWaypointWindow::FILTER_LENGTH * MAX_CHAR_LENGTH, BuildRailWaypointWindow::FILTER_LENGTH);
2217 
2221  NWidget(WWT_CLOSEBOX, COLOUR_DARK_GREEN),
2222  NWidget(WWT_CAPTION, COLOUR_DARK_GREEN), SetDataTip(STR_WAYPOINT_CAPTION, STR_TOOLTIP_WINDOW_TITLE_DRAG_THIS),
2223  NWidget(WWT_DEFSIZEBOX, COLOUR_DARK_GREEN),
2224  EndContainer(),
2225  NWidget(WWT_PANEL, COLOUR_DARK_GREEN),
2226  NWidget(WWT_EDITBOX, COLOUR_DARK_GREEN, WID_BRW_FILTER), SetPadding(2), SetResize(1, 0), SetFill(1, 0), SetDataTip(STR_LIST_FILTER_OSKTITLE, STR_LIST_FILTER_TOOLTIP),
2227  EndContainer(),
2229  NWidget(WWT_PANEL, COLOUR_DARK_GREEN), SetScrollbar(WID_BRW_SCROLL),
2231  NWidget(WWT_PANEL, COLOUR_GREY, WID_BRW_WAYPOINT), SetDataTip(0x0, STR_WAYPOINT_GRAPHICS_TOOLTIP), SetScrollbar(WID_BRW_SCROLL), EndContainer(),
2232  EndContainer(),
2233  EndContainer(),
2234  NWidget(NWID_VSCROLLBAR, COLOUR_DARK_GREEN, WID_BRW_SCROLL),
2235  EndContainer(),
2237  NWidget(WWT_PANEL, COLOUR_DARK_GREEN),
2238  NWidget(WWT_TEXT, COLOUR_DARK_GREEN, WID_BRW_NAME), SetPadding(2), SetResize(1, 0), SetFill(1, 0), SetDataTip(STR_JUST_STRING, STR_NULL), SetTextStyle(TC_ORANGE), SetAlignment(SA_CENTER),
2239  EndContainer(),
2240  NWidget(WWT_RESIZEBOX, COLOUR_DARK_GREEN),
2241  EndContainer(),
2242 };
2243 
2244 static WindowDesc _build_waypoint_desc(__FILE__, __LINE__,
2245  WDP_AUTO, "build_waypoint", 0, 0,
2249 );
2250 
2251 static void ShowBuildWaypointPicker(Window *parent)
2252 {
2253  new BuildRailWaypointWindow(&_build_waypoint_desc, parent);
2254 }
2255 
2260 {
2263 }
2264 
2269 void ReinitGuiAfterToggleElrail(bool disable)
2270 {
2271  extern RailType _last_built_railtype;
2272  if (disable && _last_built_railtype == RAILTYPE_ELECTRIC) {
2273  _last_built_railtype = _cur_railtype = RAILTYPE_RAIL;
2275  if (w != nullptr) w->ModifyRailType(_cur_railtype);
2276  }
2278 }
2279 
2281 static void SetDefaultRailGui()
2282 {
2284 
2285  extern RailType _last_built_railtype;
2286  RailType rt;
2288  case 2: {
2289  /* Find the most used rail type */
2290  uint count[RAILTYPE_END];
2291  memset(count, 0, sizeof(count));
2292  for (TileIndex t = 0; t < Map::Size(); t++) {
2295  count[GetRailType(t)]++;
2296  }
2297  }
2298 
2299  rt = static_cast<RailType>(std::max_element(count + RAILTYPE_BEGIN, count + RAILTYPE_END) - count);
2300  if (count[rt] > 0) break;
2301 
2302  /* No rail, just get the first available one */
2303  [[fallthrough]];
2304  }
2305  case 0: {
2306  /* Use first available type */
2307  std::vector<RailType>::const_iterator it = std::find_if(_sorted_railtypes.begin(), _sorted_railtypes.end(),
2308  [](RailType r){ return HasRailTypeAvail(_local_company, r); });
2309  rt = it != _sorted_railtypes.end() ? *it : RAILTYPE_BEGIN;
2310  break;
2311  }
2312  case 1: {
2313  /* Use last available type */
2314  std::vector<RailType>::const_reverse_iterator it = std::find_if(_sorted_railtypes.rbegin(), _sorted_railtypes.rend(),
2315  [](RailType r){ return HasRailTypeAvail(_local_company, r); });
2316  rt = it != _sorted_railtypes.rend() ? *it : RAILTYPE_BEGIN;
2317  break;
2318  }
2319  default:
2320  NOT_REACHED();
2321  }
2322 
2323  _last_built_railtype = _cur_railtype = rt;
2325  if (w != nullptr) w->ModifyRailType(_cur_railtype);
2326 }
2327 
2332 void ResetSignalVariant(int32_t)
2333 {
2335 
2336  if (new_variant != _cur_signal_variant) {
2338  if (w != nullptr) {
2339  w->SetDirty();
2341  }
2342  _cur_signal_variant = new_variant;
2343  }
2344 }
2345 
2346 static IntervalTimer<TimerGameCalendar> _check_reset_signal({TimerGameCalendar::YEAR, TimerGameCalendar::Priority::NONE}, [](auto)
2347 {
2349 
2351 });
2352 
2358 {
2360 
2361  _convert_signal_button = false;
2364 }
2365 
2372 DropDownList GetRailTypeDropDownList(bool for_replacement, bool all_option)
2373 {
2374  RailTypes used_railtypes;
2375  RailTypes avail_railtypes;
2376 
2377  const Company *c = Company::Get(_local_company);
2378 
2379  /* Find the used railtypes. */
2380  if (for_replacement) {
2381  avail_railtypes = GetCompanyRailTypes(c->index, false);
2382  used_railtypes = GetRailTypes(false);
2383  } else {
2384  avail_railtypes = c->avail_railtypes;
2385  used_railtypes = GetRailTypes(true);
2386  }
2387 
2388  DropDownList list;
2389 
2390  if (all_option) {
2391  list.push_back(std::make_unique<DropDownListStringItem>(STR_REPLACE_ALL_RAILTYPE, INVALID_RAILTYPE, false));
2392  }
2393 
2394  Dimension d = { 0, 0 };
2395  /* Get largest icon size, to ensure text is aligned on each menu item. */
2396  if (!for_replacement) {
2397  for (const auto &rt : _sorted_railtypes) {
2398  if (!HasBit(used_railtypes, rt)) continue;
2399  const RailTypeInfo *rti = GetRailTypeInfo(rt);
2401  }
2402  }
2403 
2404  for (const auto &rt : _sorted_railtypes) {
2405  /* If it's not used ever, don't show it to the user. */
2406  if (!HasBit(used_railtypes, rt)) continue;
2407 
2408  const RailTypeInfo *rti = GetRailTypeInfo(rt);
2409 
2410  SetDParam(0, rti->strings.menu_text);
2411  SetDParam(1, rti->max_speed);
2412  if (for_replacement) {
2413  list.push_back(std::make_unique<DropDownListStringItem>(rti->strings.replace_text, rt, !HasBit(avail_railtypes, rt)));
2414  } else {
2415  StringID str = rti->max_speed > 0 ? STR_TOOLBAR_RAILTYPE_VELOCITY : STR_JUST_STRING;
2416  list.push_back(std::make_unique<DropDownListIconItem>(d, rti->gui_sprites.build_x_rail, PAL_NONE, str, rt, !HasBit(avail_railtypes, rt)));
2417  }
2418  }
2419 
2420  if (list.empty()) {
2421  /* Empty dropdowns are not allowed */
2422  list.push_back(std::make_unique<DropDownListStringItem>(STR_NONE, INVALID_RAILTYPE, true));
2423  }
2424 
2425  return list;
2426 }
SZSP_NONE
@ SZSP_NONE
Display plane with zero size in both directions (none filling and resizing).
Definition: widget_type.h:469
RailTypeInfo::convert
CursorID convert
Cursor for converting track.
Definition: rail.h:172
WID_BRAS_PLATFORM_LEN_2
@ WID_BRAS_PLATFORM_LEN_2
Button to select 2 tiles length station platforms.
Definition: rail_widget.h:50
WID_BRAS_HIGHLIGHT_OFF
@ WID_BRAS_HIGHLIGHT_OFF
Button for turning coverage highlighting off.
Definition: rail_widget.h:59
WID_BRAS_IMAGE
@ WID_BRAS_IMAGE
Panel used at each cell of the matrix.
Definition: rail_widget.h:64
ES_HANDLED
@ ES_HANDLED
The passed event is handled.
Definition: window_type.h:739
HT_DIR_HL
@ HT_DIR_HL
horizontal lower
Definition: tilehighlight_type.h:36
DiagdirReachesTracks
TrackBits DiagdirReachesTracks(DiagDirection diagdir)
Returns all tracks that can be reached when entering a tile from a given (diagonal) direction.
Definition: track_func.h:573
SetFill
constexpr NWidgetPart SetFill(uint16_t fill_x, uint16_t fill_y)
Widget part function for setting filling.
Definition: widget_type.h:1141
GUISettings::station_numtracks
byte station_numtracks
the number of platforms to default on for rail stations
Definition: settings_type.h:186
SetTileSelectSize
void SetTileSelectSize(int w, int h)
Highlight w by h tiles at the cursor.
Definition: viewport.cpp:2536
DIAGDIR_SE
@ DIAGDIR_SE
Southeast.
Definition: direction_type.h:76
DDSP_DEMOLISH_AREA
@ DDSP_DEMOLISH_AREA
Clear area.
Definition: viewport_type.h:108
WID_BRAS_PLATFORM_DIR_X
@ WID_BRAS_PLATFORM_DIR_X
Button to select '/' view.
Definition: rail_widget.h:38
BuildRailWaypointWindow::OnPaint
void OnPaint() override
The window must be repainted.
Definition: rail_gui.cpp:2146
tunnelbridge.h
_remove_button_clicked
static bool _remove_button_clicked
Flag whether 'remove' toggle-button is currently enabled.
Definition: rail_gui.cpp:54
CA_UNMODIFIED
@ CA_UNMODIFIED
Catchment for all stations with "modified catchment" disabled.
Definition: station_type.h:82
RailTypeInfo::build_ew_rail
SpriteID build_ew_rail
button for building single rail in E-W direction
Definition: rail.h:155
CloseWindowByClass
void CloseWindowByClass(WindowClass cls, int data)
Close all windows of a given class.
Definition: window.cpp:1153
sound_func.h
DDSP_CONVERT_RAIL
@ DDSP_CONVERT_RAIL
Rail conversion.
Definition: viewport_type.h:125
AXIS_Y
@ AXIS_Y
The y axis.
Definition: direction_type.h:118
GUISettings::station_dragdrop
bool station_dragdrop
whether drag and drop is enabled for stations
Definition: settings_type.h:188
FindFirstTrack
Track FindFirstTrack(TrackBits tracks)
Returns first Track from TrackBits or INVALID_TRACK.
Definition: track_func.h:177
BuildRailStationWindow::coverage_height
uint coverage_height
Height of the coverage texts.
Definition: rail_gui.cpp:956
WID_BRAD_DEPOT_SW
@ WID_BRAD_DEPOT_SW
Build a depot with the entrance in the south west.
Definition: rail_widget.h:110
RailToolbar_CtrlChanged
static bool RailToolbar_CtrlChanged(Window *w)
Updates the Remove button because of Ctrl state change.
Definition: rail_gui.cpp:324
BuildRalStationHotkeys
BuildRalStationHotkeys
Enum referring to the Hotkeys in the build rail station window.
Definition: rail_gui.cpp:949
newgrf_station.h
CcBuildRailTunnel
void CcBuildRailTunnel(Commands, const CommandCost &result, TileIndex tile)
Command callback for building a tunnel.
Definition: rail_gui.cpp:296
Rect::Height
int Height() const
Get height of Rect.
Definition: geometry_type.hpp:91
GUISettings::station_show_coverage
bool station_show_coverage
whether to highlight coverage area
Definition: settings_type.h:189
Pool::PoolItem<&_company_pool >::Get
static Titem * Get(size_t index)
Returns Titem with given index.
Definition: pool_type.hpp:335
WC_BUILD_TOOLBAR
@ WC_BUILD_TOOLBAR
Build toolbar; Window numbers:
Definition: window_type.h:73
GUISettings::drag_signals_fixed_distance
bool drag_signals_fixed_distance
keep fixed distance between signals when dragging
Definition: settings_type.h:182
VPM_FIX_VERTICAL
@ VPM_FIX_VERTICAL
drag only in vertical direction
Definition: viewport_type.h:95
BuildRailStationWindow::SelectClassAndStation
void SelectClassAndStation()
Checks if the previously selected current station class and station can be shown as selected to the u...
Definition: rail_gui.cpp:1136
GameSettings::station
StationSettings station
settings related to station management
Definition: settings_type.h:630
WID_RAT_BUILD_STATION
@ WID_RAT_BUILD_STATION
Build a station.
Definition: rail_widget.h:25
GetRailTypeDropDownList
DropDownList GetRailTypeDropDownList(bool for_replacement, bool all_option)
Create a drop down list for all the rail types of the local company.
Definition: rail_gui.cpp:2372
WID_BS_TOGGLE_SIZE
@ WID_BS_TOGGLE_SIZE
Toggle showing advanced signal types.
Definition: rail_widget.h:84
SetWindowDirty
void SetWindowDirty(WindowClass cls, WindowNumber number)
Mark window as dirty (in need of repainting)
Definition: window.cpp:3082
querystring_gui.h
NewGRFClass::GetUISpecCount
uint GetUISpecCount() const
Get the number of potentially user-available specs within the class.
Definition: newgrf_class.h:46
HotkeyList
List of hotkeys for a window.
Definition: hotkeys.h:37
VpSetPresizeRange
void VpSetPresizeRange(TileIndex from, TileIndex to)
Highlights all tiles between a set of two tiles.
Definition: viewport.cpp:2771
WID_BRAS_PLATFORM_LEN_6
@ WID_BRAS_PLATFORM_LEN_6
Button to select 6 tiles length station platforms.
Definition: rail_widget.h:54
SetFocusedWindow
void SetFocusedWindow(Window *w)
Set the window that has the focus.
Definition: window.cpp:423
WID_BRAS_PLATFORM_LEN_1
@ WID_BRAS_PLATFORM_LEN_1
Button to select single tile length station platforms.
Definition: rail_widget.h:49
BuildSignalWindow::sig_sprite_size
Dimension sig_sprite_size
Maximum size of signal GUI sprites.
Definition: rail_gui.cpp:1691
ValParamRailType
bool ValParamRailType(const RailType rail)
Validate functions for rail building.
Definition: rail.cpp:206
Dimension
Dimensions (a width and height) of a rectangle in 2D.
Definition: geometry_type.hpp:30
command_func.h
IsInsideMM
constexpr bool IsInsideMM(const T x, const size_t min, const size_t max) noexcept
Checks if a value is in an interval.
Definition: math_func.hpp:268
WidgetDimensions::scaled
static WidgetDimensions scaled
Widget dimensions scaled for current zoom level.
Definition: window_gui.h:68
WID_BRAS_SHOW_NEWST_ADDITIONS
@ WID_BRAS_SHOW_NEWST_ADDITIONS
Selection for newstation class selection list.
Definition: rail_widget.h:70
WWT_STICKYBOX
@ WWT_STICKYBOX
Sticky box (at top-right of a window, after WWT_DEFSIZEBOX)
Definition: widget_type.h:68
Swap
constexpr void Swap(T &a, T &b)
Type safe swap operation.
Definition: math_func.hpp:283
BuildSignalWindow
Definition: rail_gui.cpp:1689
RailTypeInfo::build_y_rail
SpriteID build_y_rail
button for building single rail in Y direction
Definition: rail.h:156
WDF_CONSTRUCTION
@ WDF_CONSTRUCTION
This window is used for construction; close it whenever changing company.
Definition: window_gui.h:197
GetRailTypeInfo
const RailTypeInfo * GetRailTypeInfo(RailType railtype)
Returns a pointer to the Railtype information for a given railtype.
Definition: rail.h:307
GUIList::SetFilterState
void SetFilterState(bool state)
Enable or disable the filter.
Definition: sortlist_type.h:327
Company::avail_railtypes
RailTypes avail_railtypes
Rail types available to this company.
Definition: company_base.h:120
WID_BS_SEMAPHORE_ENTRY
@ WID_BS_SEMAPHORE_ENTRY
Build a semaphore entry block signal.
Definition: rail_widget.h:86
Rect::Shrink
Rect Shrink(int s) const
Copy and shrink Rect by s pixels.
Definition: geometry_type.hpp:98
StringFilter::IsEmpty
bool IsEmpty() const
Check whether any filter words were entered.
Definition: stringfilter_type.h:60
_cur_signal_type
static SignalType _cur_signal_type
set the signal type (for signal GUI)
Definition: rail_gui.cpp:59
DDSP_BUILD_STATION
@ DDSP_BUILD_STATION
Station placement.
Definition: viewport_type.h:123
WID_RAT_BUILD_NS
@ WID_RAT_BUILD_NS
Build rail along the game view Y axis.
Definition: rail_widget.h:17
WID_BRW_WAYPOINT
@ WID_BRW_WAYPOINT
A single waypoint.
Definition: rail_widget.h:118
RailTypeInfo::tunnel
SpriteID tunnel
tunnel sprites base
Definition: rail.h:145
company_base.h
ViewportDragDropSelectionProcess
ViewportDragDropSelectionProcess
Drag and drop selection process, or, what to do with an area of land when you've selected it.
Definition: viewport_type.h:107
tunnelbridge_map.h
StringFilter::SetFilterTerm
void SetFilterTerm(const char *str)
Set the term to filter on.
Definition: stringfilter.cpp:28
CommandFlagsToDCFlags
static constexpr DoCommandFlag CommandFlagsToDCFlags(CommandFlags cmd_flags)
Extracts the DC flags needed for DoCommand from the flags returned by GetCommandFlags.
Definition: command_func.h:58
timer_game_calendar.h
_place_depot_extra_dir
static const DiagDirection _place_depot_extra_dir[12]
Direction to check for existing track pieces.
Definition: rail_gui.cpp:132
GetAxisForNewWaypoint
Axis GetAxisForNewWaypoint(TileIndex tile)
Get the axis for a new waypoint.
Definition: waypoint_cmd.cpp:99
Axis
Axis
Allow incrementing of DiagDirDiff variables.
Definition: direction_type.h:116
Scrollbar::ScrollTowards
void ScrollTowards(int position)
Scroll towards the given position; if the item is visible nothing happens, otherwise it will be shown...
Definition: widget_type.h:821
WWT_CAPTION
@ WWT_CAPTION
Window caption (window title between closebox and stickybox)
Definition: widget_type.h:63
CBID_STATION_AVAILABILITY
@ CBID_STATION_AVAILABILITY
Determine whether a newstation should be made available to build.
Definition: newgrf_callbacks.h:39
NewGRFClass::GetSpecCount
uint GetSpecCount() const
Get the number of allocated specs within the class.
Definition: newgrf_class.h:44
CheckRedrawStationCoverage
void CheckRedrawStationCoverage(const Window *w)
Check whether we need to redraw the station coverage text.
Definition: station_gui.cpp:126
HandleAutoSignalPlacement
static void HandleAutoSignalPlacement()
Build new signals or remove signals or (if only one tile marked) edit a signal.
Definition: rail_gui.cpp:403
Window::SetWidgetDirty
void SetWidgetDirty(WidgetID widget_index) const
Invalidate a widget, i.e.
Definition: window.cpp:552
WID_BRAS_NEWST_SCROLL
@ WID_BRAS_NEWST_SCROLL
Scrollbar of the WID_BRAS_NEWST_LIST.
Definition: rail_widget.h:75
_cur_signal_variant
static SignalVariant _cur_signal_variant
set the signal variant (for signal GUI)
Definition: rail_gui.cpp:58
NWidgetMatrix
Matrix container with implicitly equal sized (virtual) sub-widgets.
Definition: widget_type.h:581
waypoint_cmd.h
SetAlignment
constexpr NWidgetPart SetAlignment(StringAlignment align)
Widget part function for setting the alignment of text/images.
Definition: widget_type.h:1130
BuildRailToolbarWindow::OnHotkey
EventState OnHotkey(int hotkey) override
A hotkey has been pressed.
Definition: rail_gui.cpp:650
StringID
uint32_t StringID
Numeric value that represents a string, independent of the selected language.
Definition: strings_type.h:16
WWT_IMGBTN
@ WWT_IMGBTN
(Toggle) Button with image
Definition: widget_type.h:54
WID_BRAS_COVERAGE_TEXTS
@ WID_BRAS_COVERAGE_TEXTS
Empty space for the coverage texts.
Definition: rail_widget.h:61
GUIList< StationClassID, std::nullptr_t, StringFilter & >
_railstation
static RailStationGUISettings _railstation
Settings of the station builder GUI.
Definition: rail_gui.cpp:69
WID_RAT_BUILD_TUNNEL
@ WID_RAT_BUILD_TUNNEL
Build a tunnel.
Definition: rail_widget.h:28
TRACK_LOWER
@ TRACK_LOWER
Track in the lower corner of the tile (south)
Definition: track_type.h:24
WWT_LABEL
@ WWT_LABEL
Centered label.
Definition: widget_type.h:59
CloseWindowById
void CloseWindowById(WindowClass cls, WindowNumber number, bool force, int data)
Close a window by its class and window number (if it is open).
Definition: window.cpp:1141
SIG_SEMAPHORE
@ SIG_SEMAPHORE
Old-fashioned semaphore signal.
Definition: signal_type.h:18
RAIL_TILE_SIGNALS
@ RAIL_TILE_SIGNALS
Normal rail tile with signals.
Definition: rail_map.h:25
DropDownList
std::vector< std::unique_ptr< const DropDownListItem > > DropDownList
A drop down list is a collection of drop down list items.
Definition: dropdown_type.h:210
WID_BRAS_PLATFORM_NUM_6
@ WID_BRAS_PLATFORM_NUM_6
Button to select stations with 6 platforms.
Definition: rail_widget.h:46
SetRedErrorSquare
void SetRedErrorSquare(TileIndex tile)
Set a tile to display a red error square.
Definition: viewport.cpp:2518
WWT_DEFSIZEBOX
@ WWT_DEFSIZEBOX
Default window size box (at top-right of a window, between WWT_SHADEBOX and WWT_STICKYBOX)
Definition: widget_type.h:67
IntervalTimer< TimerGameCalendar >
GB
constexpr static debug_inline uint GB(const T x, const uint8_t s, const uint8_t n)
Fetch n bits from x, started at bit s.
Definition: bitmath_func.hpp:32
WDP_ALIGN_TOOLBAR
@ WDP_ALIGN_TOOLBAR
Align toward the toolbar.
Definition: window_gui.h:143
WID_BRAS_PLATFORM_DRAG_N_DROP
@ WID_BRAS_PLATFORM_DRAG_N_DROP
Button to enable drag and drop type station placement.
Definition: rail_widget.h:57
Pool::PoolItem::index
Tindex index
Index of this pool item.
Definition: pool_type.hpp:234
NWID_HORIZONTAL
@ NWID_HORIZONTAL
Horizontal container.
Definition: widget_type.h:77
WID_BRAS_PLATFORM_LEN_7
@ WID_BRAS_PLATFORM_LEN_7
Button to select 7 tiles length station platforms.
Definition: rail_widget.h:55
BuildRailWaypointWindow::editbox
static QueryString editbox
Filter editbox.
Definition: rail_gui.cpp:2034
PlaceRail_Waypoint
static void PlaceRail_Waypoint(TileIndex tile)
Place a rail waypoint.
Definition: rail_gui.cpp:158
RailTypeInfo::signals
SpriteID signals[SIGTYPE_END][2][2]
signal GUI sprites (type, variant, state)
Definition: rail.h:161
TRACK_X
@ TRACK_X
Track along the x-axis (north-east to south-west)
Definition: track_type.h:21
WID_BRAS_PLATFORM_NUM_BEGIN
@ WID_BRAS_PLATFORM_NUM_BEGIN
Helper for determining the chosen platform width.
Definition: rail_widget.h:77
maxdim
Dimension maxdim(const Dimension &d1, const Dimension &d2)
Compute bounding box of both dimensions.
Definition: geometry_func.cpp:22
Window::Close
virtual void Close(int data=0)
Hide the window and all its child windows, and mark them for a later deletion.
Definition: window.cpp:1048
WWT_MATRIX
@ WWT_MATRIX
Grid of rows and columns.
Definition: widget_type.h:61
ANIMCURSOR_BUILDSIGNALS
static const CursorID ANIMCURSOR_BUILDSIGNALS
1292 - 1293 - build signal
Definition: sprites.h:1504
FindWindowById
Window * FindWindowById(WindowClass cls, WindowNumber number)
Find a window by its class and window number.
Definition: window.cpp:1099
SIGNAL_GUI_PATH
@ SIGNAL_GUI_PATH
Show path signals only.
Definition: rail_gui.h:24
NWID_HORIZONTAL_LTR
@ NWID_HORIZONTAL_LTR
Horizontal container that doesn't change the order of the widgets for RTL languages.
Definition: widget_type.h:78
INVALID_TILE
constexpr TileIndex INVALID_TILE
The very nice invalid tile marker.
Definition: tile_type.h:95
EndContainer
constexpr NWidgetPart EndContainer()
Widget part function for denoting the end of a container (horizontal, vertical, WWT_FRAME,...
Definition: widget_type.h:1151
PlaceProc_DemolishArea
void PlaceProc_DemolishArea(TileIndex tile)
Start a drag for demolishing an area.
Definition: terraform_gui.cpp:150
WID_BRAS_PLATFORM_NUM_1
@ WID_BRAS_PLATFORM_NUM_1
Button to select stations with a single platform.
Definition: rail_widget.h:41
BuildRailStationWindow::StationClassIDSorter
static bool StationClassIDSorter(StationClassID const &a, StationClassID const &b)
Sort station classes by StationClassID.
Definition: rail_gui.cpp:1091
RailTypeInfo
This struct contains all the info that is needed to draw and construct tracks.
Definition: rail.h:127
WID_RAT_BUILD_X
@ WID_RAT_BUILD_X
Build rail along the game grid X axis.
Definition: rail_widget.h:18
SetMatrixDataTip
constexpr NWidgetPart SetMatrixDataTip(uint8_t cols, uint8_t rows, StringID tip)
Widget part function for setting the data and tooltip of WWT_MATRIX widgets.
Definition: widget_type.h:1174
RailTypeInfo::autorail
CursorID autorail
Cursor for autorail tool.
Definition: rail.h:169
_ctrl_pressed
bool _ctrl_pressed
Is Ctrl pressed?
Definition: gfx.cpp:37
MP_RAILWAY
@ MP_RAILWAY
A railway.
Definition: tile_type.h:49
FILLRECT_CHECKER
@ FILLRECT_CHECKER
Draw only every second pixel, used for greying-out.
Definition: gfx_type.h:294
SND_15_BEEP
@ SND_15_BEEP
19 == 0x13 GUI button click
Definition: sound_type.h:58
IsStationAvailable
static bool IsStationAvailable(const StationSpec *statspec)
Check whether a station type can be build.
Definition: rail_gui.cpp:82
HandlePlacePushButton
bool HandlePlacePushButton(Window *w, WidgetID widget, CursorID cursor, HighLightStyle mode)
This code is shared for the majority of the pushbuttons.
Definition: main_gui.cpp:63
WID_BS_ELECTRIC_COMBO
@ WID_BS_ELECTRIC_COMBO
Build an electric combo block signal.
Definition: rail_widget.h:94
GUISettings::default_signal_type
SignalType default_signal_type
The default signal type, which is set automatically by the last signal used. Not available in Setting...
Definition: settings_type.h:176
SND_20_CONSTRUCTION_RAIL
@ SND_20_CONSTRUCTION_RAIL
30 == 0x1E Construction: rail infrastructure
Definition: sound_type.h:69
zoom_func.h
Scrollbar::SetCapacityFromWidget
void SetCapacityFromWidget(Window *w, WidgetID widget, int padding=0)
Set capacity of visible elements from the size and resize properties of a widget.
Definition: widget.cpp:2334
Window::RaiseButtons
void RaiseButtons(bool autoraise=false)
Raise the buttons of the window.
Definition: window.cpp:526
WID_RAT_BUILD_BRIDGE
@ WID_RAT_BUILD_BRIDGE
Build a bridge.
Definition: rail_widget.h:27
IsLevelCrossingTile
bool IsLevelCrossingTile(Tile t)
Return whether a tile is a level crossing tile.
Definition: road_map.h:95
VPM_FIX_Y
@ VPM_FIX_Y
drag only in Y axis
Definition: viewport_type.h:91
WID_BRAS_HIGHLIGHT_ON
@ WID_BRAS_HIGHLIGHT_ON
Button for turning coverage highlighting on.
Definition: rail_widget.h:60
NWidgetMatrix::SetScrollbar
void SetScrollbar(Scrollbar *sb)
Assign a scrollbar to this matrix.
Definition: widget.cpp:1804
_settings_client
ClientSettings _settings_client
The current settings for this game.
Definition: settings.cpp:54
RailTypeInfo::rail_swne
CursorID rail_swne
Cursor for building rail in X direction.
Definition: rail.h:166
IsValidTrack
bool IsValidTrack(Track track)
Checks if a Track is valid.
Definition: track_func.h:28
ShowBuildRailToolbar
Window * ShowBuildRailToolbar(RailType railtype)
Open the build rail toolbar window for a specific rail type.
Definition: rail_gui.cpp:911
SignalVariant
SignalVariant
Variant of the signal, i.e.
Definition: signal_type.h:16
BuildRailStationWindow::BuildRailStationGlobalHotkeys
static EventState BuildRailStationGlobalHotkeys(int hotkey)
Handler for global hotkeys of the BuildRailStationWindow.
Definition: rail_gui.cpp:1561
WWT_EMPTY
@ WWT_EMPTY
Empty widget, place holder to reserve space in widget tree.
Definition: widget_type.h:50
ANIMCURSOR_DEMOLISH
static const CursorID ANIMCURSOR_DEMOLISH
704 - 707 - demolish dynamite
Definition: sprites.h:1500
GetGRFConfig
GRFConfig * GetGRFConfig(uint32_t grfid, uint32_t mask)
Retrieve a NewGRF from the current config by its grfid.
Definition: newgrf_config.cpp:716
RectPadding::Vertical
constexpr uint Vertical() const
Get total vertical padding of RectPadding.
Definition: geometry_type.hpp:69
WWT_PUSHARROWBTN
@ WWT_PUSHARROWBTN
Normal push-button (no toggle button) with arrow caption.
Definition: widget_type.h:112
StrongType::Typedef< uint32_t, struct TileIndexTag, StrongType::Compare, StrongType::Integer, StrongType::Compatible< int32_t >, StrongType::Compatible< int64_t > >
StringFilter::AddLine
void AddLine(const char *str)
Pass another text line from the current item to the filter.
Definition: stringfilter.cpp:114
BuildRailStationWindow::last_filtering
static Filtering last_filtering
Default filtering of GUIStationClassList.
Definition: rail_gui.cpp:965
DIAGDIR_NW
@ DIAGDIR_NW
Northwest.
Definition: direction_type.h:78
BuildRailToolbarWindow::last_user_action
int last_user_action
Last started user action.
Definition: rail_gui.cpp:430
WC_BUILD_STATION
@ WC_BUILD_STATION
Build station; Window numbers:
Definition: window_type.h:397
ToggleRailButton_Remove
static void ToggleRailButton_Remove(Window *w)
Toggles state of the Remove button of Build rail toolbar.
Definition: rail_gui.cpp:310
WID_BS_ELECTRIC_PBS_OWAY
@ WID_BS_ELECTRIC_PBS_OWAY
Build an electric one way path signal.
Definition: rail_widget.h:96
BuildSignalWindow::SetSignalUIMode
void SetSignalUIMode()
Show or hide buttons for non-path signals in the signal GUI.
Definition: rail_gui.cpp:1711
ViewportPlaceMethod
ViewportPlaceMethod
Viewport place method (type of highlighted area and placed objects)
Definition: viewport_type.h:88
GetRailType
RailType GetRailType(Tile t)
Gets the rail type of the given tile.
Definition: rail_map.h:115
RailTypeInfo::strings
struct RailTypeInfo::@26 strings
Strings associated with the rail type.
WID_BRAS_PLATFORM_NUM_2
@ WID_BRAS_PLATFORM_NUM_2
Button to select stations with 2 platforms.
Definition: rail_widget.h:42
HT_DIR_Y
@ HT_DIR_Y
Y direction.
Definition: tilehighlight_type.h:34
NWID_MATRIX
@ NWID_MATRIX
Matrix container.
Definition: widget_type.h:80
WID_BRAS_SHOW_NEWST_RESIZE
@ WID_BRAS_SHOW_NEWST_RESIZE
Selection for panel and resize at bottom right for newstation.
Definition: rail_widget.h:72
Scrollbar
Scrollbar data structure.
Definition: widget_type.h:678
Window::GetScrollbar
const Scrollbar * GetScrollbar(WidgetID widnum) const
Return the Scrollbar to a widget index.
Definition: window.cpp:315
_cur_railtype
static RailType _cur_railtype
Rail type of the current build-rail toolbar.
Definition: rail_gui.cpp:53
GUISettings::drag_signals_density
byte drag_signals_density
many signals density
Definition: settings_type.h:181
RailTypes
RailTypes
Allow incrementing of Track variables.
Definition: rail_type.h:44
Window::OnHotkey
virtual EventState OnHotkey(int hotkey)
A hotkey has been pressed.
Definition: window.cpp:566
WID_BS_SEMAPHORE_NORM
@ WID_BS_SEMAPHORE_NORM
Build a semaphore normal block signal.
Definition: rail_widget.h:85
_nested_build_depot_widgets
static constexpr NWidgetPart _nested_build_depot_widgets[]
Nested widget definition of the build rail depot window.
Definition: rail_gui.cpp:1996
NWidgetPart
Partial widget specification to allow NWidgets to be written nested.
Definition: widget_type.h:1038
INVALID_ROADTYPE
@ INVALID_ROADTYPE
flag for invalid roadtype
Definition: road_type.h:30
TRACK_RIGHT
@ TRACK_RIGHT
Track in the right corner of the tile (east)
Definition: track_type.h:26
GUIList::NeedRebuild
bool NeedRebuild() const
Check if a rebuild is needed.
Definition: sortlist_type.h:387
BuildRailStationWindow::OnHotkey
EventState OnHotkey(int hotkey) override
A hotkey has been pressed.
Definition: rail_gui.cpp:1165
QueryString
Data stored about a string that can be modified in the GUI.
Definition: querystring_gui.h:20
TRACK_BIT_UPPER
@ TRACK_BIT_UPPER
Upper track.
Definition: track_type.h:39
CommandCost::Succeeded
bool Succeeded() const
Did this command succeed?
Definition: command_type.h:162
Textbuf::buf
char *const buf
buffer in which text is saved
Definition: textbuf_type.h:32
SignalType
SignalType
Type of signal, i.e.
Definition: signal_type.h:23
SIGTYPE_PBS
@ SIGTYPE_PBS
normal pbs signal
Definition: signal_type.h:28
GetTileTrackStatus
TrackStatus GetTileTrackStatus(TileIndex tile, TransportType mode, uint sub_mode, DiagDirection side)
Returns information about trackdirs and signal states.
Definition: landscape.cpp:556
RAILTYPE_ELECTRIC
@ RAILTYPE_ELECTRIC
Electric rails.
Definition: rail_type.h:30
MAX_CHAR_LENGTH
static const int MAX_CHAR_LENGTH
Max. length of UTF-8 encoded unicode character.
Definition: strings_type.h:18
VPM_RAILDIRS
@ VPM_RAILDIRS
all rail directions
Definition: viewport_type.h:98
TRACK_BIT_RIGHT
@ TRACK_BIT_RIGHT
Right track.
Definition: track_type.h:42
WID_BS_ELECTRIC_NORM
@ WID_BS_ELECTRIC_NORM
Build an electric normal block signal.
Definition: rail_widget.h:91
BuildRailStationWindow::CheckSelectedSize
void CheckSelectedSize(const StationSpec *statspec)
Verify whether the currently selected station size is allowed after selecting a new station class/typ...
Definition: rail_gui.cpp:995
RailTypeInfo::build_depot
SpriteID build_depot
button for building depots
Definition: rail.h:158
NWidgetMatrix::SetCount
void SetCount(int count)
Set the number of elements in this matrix.
Definition: widget.cpp:1780
WID_BS_DRAG_SIGNALS_DENSITY_LABEL
@ WID_BS_DRAG_SIGNALS_DENSITY_LABEL
The current signal density.
Definition: rail_widget.h:98
WindowDesc
High level window description.
Definition: window_gui.h:153
WidgetID
int WidgetID
Widget ID.
Definition: window_type.h:18
RectPadding::Horizontal
constexpr uint Horizontal() const
Get total horizontal padding of RectPadding.
Definition: geometry_type.hpp:63
ScaleGUITrad
int ScaleGUITrad(int value)
Scale traditional pixel dimensions to GUI zoom level.
Definition: zoom_func.h:117
window_gui.h
GUISettings::cycle_signal_types
SignalCycleSettings cycle_signal_types
Which signal types to cycle with the build signal tool.
Definition: settings_type.h:175
BuildRailStationWindow::EnsureSelectedStationClassIsVisible
void EnsureSelectedStationClassIsVisible()
Scrolls WID_BRAS_NEWST_SCROLL so that the selected station class is visible.
Definition: rail_gui.cpp:979
NC_EQUALSIZE
@ NC_EQUALSIZE
Value of the NCB_EQUALSIZE flag.
Definition: widget_type.h:508
SetPadding
constexpr NWidgetPart SetPadding(uint8_t top, uint8_t right, uint8_t bottom, uint8_t left)
Widget part function for setting additional space around a widget.
Definition: widget_type.h:1188
TRACK_BIT_VERT
@ TRACK_BIT_VERT
Left and right track.
Definition: track_type.h:45
DIAGDIR_SW
@ DIAGDIR_SW
Southwest.
Definition: direction_type.h:77
IsInsideBS
constexpr bool IsInsideBS(const T x, const size_t base, const size_t size)
Checks if a value is between a window started at some base point.
Definition: math_func.hpp:252
DDSP_PLACE_RAIL
@ DDSP_PLACE_RAIL
Rail placement.
Definition: viewport_type.h:121
TRANSPORT_RAIL
@ TRANSPORT_RAIL
Transport by train.
Definition: transport_type.h:27
SetResize
constexpr NWidgetPart SetResize(int16_t dx, int16_t dy)
Widget part function for setting the resize step.
Definition: widget_type.h:1086
WDP_AUTO
@ WDP_AUTO
Find a place automatically.
Definition: window_gui.h:141
Listing
Data structure describing how to show the list (what sort direction and criteria).
Definition: sortlist_type.h:30
WID_BRAS_SHOW_NEWST_MATRIX
@ WID_BRAS_SHOW_NEWST_MATRIX
Selection for newstation image matrix.
Definition: rail_widget.h:71
GUISettings::default_rail_type
uint8_t default_rail_type
the default rail type for the rail GUI
Definition: settings_type.h:152
WKC_GLOBAL_HOTKEY
@ WKC_GLOBAL_HOTKEY
Fake keycode bit to indicate global hotkeys.
Definition: gfx_type.h:33
_signal_builder_desc
static WindowDesc _signal_builder_desc(__FILE__, __LINE__, WDP_AUTO, nullptr, 0, 0, WC_BUILD_SIGNAL, WC_BUILD_TOOLBAR, WDF_CONSTRUCTION, std::begin(_nested_signal_builder_widgets), std::end(_nested_signal_builder_widgets))
Signal selection window description.
RailType
RailType
Enumeration for all possible railtypes.
Definition: rail_type.h:27
STAT_CLASS_WAYP
@ STAT_CLASS_WAYP
Waypoint class.
Definition: newgrf_station.h:86
Window::resize
ResizeInfo resize
Resize information.
Definition: window_gui.h:308
CommandCost
Common return value for all commands.
Definition: command_type.h:23
TRACK_Y
@ TRACK_Y
Track along the y-axis (north-west to south-east)
Definition: track_type.h:22
RailTypeInfo::rail_ns
CursorID rail_ns
Cursor for building rail in N-S direction.
Definition: rail.h:165
RailStationGUISettings::newstations
bool newstations
Are custom station definitions available?
Definition: rail_gui.cpp:64
tilehighlight_func.h
BuildRailStationWindow::EDITBOX_MAX_SIZE
static const uint EDITBOX_MAX_SIZE
The maximum number of characters for the filter edit box.
Definition: rail_gui.cpp:962
SIG_ELECTRIC
@ SIG_ELECTRIC
Light signal.
Definition: signal_type.h:17
ClientSettings::sound
SoundSettings sound
sound effect settings
Definition: settings_type.h:639
GRFConfig
Information about GRF, used in the game and (part of it) in savegames.
Definition: newgrf_config.h:147
FS_NORMAL
@ FS_NORMAL
Index of the normal font in the font tables.
Definition: gfx_type.h:203
HT_DIR_VL
@ HT_DIR_VL
vertical left
Definition: tilehighlight_type.h:37
Window::InitNested
void InitNested(WindowNumber number=0)
Perform complete initialization of the Window with nested widgets, to allow use.
Definition: window.cpp:1747
WID_BS_SEMAPHORE_PBS
@ WID_BS_SEMAPHORE_PBS
Build a semaphore path signal.
Definition: rail_widget.h:89
SetScrollbar
constexpr NWidgetPart SetScrollbar(WidgetID index)
Attach a scrollbar to a widget.
Definition: widget_type.h:1244
GUIList::Filter
bool Filter(FilterFunction *decide, F filter_data)
Filter the list.
Definition: sortlist_type.h:343
WID_BRAS_PLATFORM_LEN_4
@ WID_BRAS_PLATFORM_LEN_4
Button to select 4 tiles length station platforms.
Definition: rail_widget.h:52
WWT_EDITBOX
@ WWT_EDITBOX
a textbox for typing
Definition: widget_type.h:73
VPM_FIX_X
@ VPM_FIX_X
drag only in X axis
Definition: viewport_type.h:90
VpStartPlaceSizing
void VpStartPlaceSizing(TileIndex tile, ViewportPlaceMethod method, ViewportDragDropSelectionProcess process)
highlighting tiles while only going over them with the mouse
Definition: viewport.cpp:2716
WID_RAT_REMOVE
@ WID_RAT_REMOVE
Bulldozer to remove rail.
Definition: rail_widget.h:29
RailTypeInfo::auto_rail
SpriteID auto_rail
button for the autorail construction
Definition: rail.h:157
GUISettings::semaphore_build_before
TimerGameCalendar::Year semaphore_build_before
build semaphore signals automatically before this year
Definition: settings_type.h:183
Window::SetDirty
void SetDirty() const
Mark entire window as dirty (in need of re-paint)
Definition: window.cpp:941
WID_BRAS_SHOW_NEWST_TYPE
@ WID_BRAS_SHOW_NEWST_TYPE
Display of selected station type.
Definition: rail_widget.h:73
BuildRailToolbarWindow::can_build_widgets
static const std::initializer_list< WidgetID > can_build_widgets
List of widgets to be disabled if infrastructure limit prevents building.
Definition: rail_gui.cpp:453
GUIList::SortFunction
std::conditional_t< std::is_same_v< P, std::nullptr_t >, bool(const T &, const T &), bool(const T &, const T &, const P)> SortFunction
Signature of sort function.
Definition: sortlist_type.h:49
rail_cmd.h
HT_DIAGONAL
@ HT_DIAGONAL
Also allow 'diagonal rectangles'. Only usable in combination with HT_RECT or HT_POINT.
Definition: tilehighlight_type.h:28
HasSignalOnTrack
bool HasSignalOnTrack(Tile tile, Track track)
Checks for the presence of signals (either way) on the given track on the given rail tile.
Definition: rail_map.h:413
PlaceRail_Bridge
static void PlaceRail_Bridge(TileIndex tile, Window *w)
Start placing a rail bridge.
Definition: rail_gui.cpp:284
Window::OnPlaceMouseUp
virtual void OnPlaceMouseUp([[maybe_unused]] ViewportPlaceMethod select_method, [[maybe_unused]] ViewportDragDropSelectionProcess select_proc, [[maybe_unused]] Point pt, [[maybe_unused]] TileIndex start_tile, [[maybe_unused]] TileIndex end_tile)
The user has dragged over the map when the tile highlight mode has been set.
Definition: window_gui.h:829
station_cmd.h
ES_NOT_HANDLED
@ ES_NOT_HANDLED
The passed event is not handled.
Definition: window_type.h:740
CommandCost::Failed
bool Failed() const
Did this command fail?
Definition: command_type.h:171
HT_RAIL
@ HT_RAIL
autorail (one piece), lower bits: direction
Definition: tilehighlight_type.h:26
TRACK_UPPER
@ TRACK_UPPER
Track in the upper corner of the tile (north)
Definition: track_type.h:23
RailTypeInfo::toolbar_caption
StringID toolbar_caption
Caption in the construction toolbar GUI for this rail type.
Definition: rail.h:177
RailTypeInfo::build_ns_rail
SpriteID build_ns_rail
button for building single rail in N-S direction
Definition: rail.h:153
BRASHK_FOCUS_FILTER_BOX
@ BRASHK_FOCUS_FILTER_BOX
Focus the edit box for editing the filter string.
Definition: rail_gui.cpp:950
PickerWindowBase::Close
void Close([[maybe_unused]] int data=0) override
Hide the window and all its child windows, and mark them for a later deletion.
Definition: window.cpp:3500
VpSelectTilesWithMethod
void VpSelectTilesWithMethod(int x, int y, ViewportPlaceMethod method)
Selects tiles while dragging.
Definition: viewport.cpp:3201
BuildRailToolbarWindow
Rail toolbar management class.
Definition: rail_gui.cpp:428
OrthogonalTileArea
Represents the covered area of e.g.
Definition: tilearea_type.h:18
NewGRFClass
Struct containing information relating to NewGRF classes for stations and airports.
Definition: newgrf_class.h:20
WID_BS_SEMAPHORE_EXIT
@ WID_BS_SEMAPHORE_EXIT
Build a semaphore exit block signal.
Definition: rail_widget.h:87
HasStationTileRail
bool HasStationTileRail(Tile t)
Has this station tile a rail? In other words, is this station tile a rail station or rail waypoint?
Definition: station_map.h:146
dropdown_type.h
ShowSelectStationIfNeeded
void ShowSelectStationIfNeeded(TileArea ta, StationPickerCmdProc proc)
Show the station selection window when needed.
Definition: station_gui.cpp:2460
WID_BRAD_DEPOT_SE
@ WID_BRAD_DEPOT_SE
Build a depot with the entrance in the south east.
Definition: rail_widget.h:109
_settings_game
GameSettings _settings_game
Game settings of a running game or the scenario editor.
Definition: settings.cpp:55
Window::ReInit
void ReInit(int rx=0, int ry=0, bool reposition=false)
Re-initialize a window, and optionally change its size.
Definition: window.cpp:953
Filtering
Data structure describing what to show in the list (filter criteria).
Definition: sortlist_type.h:35
ShowSignalBuilder
static void ShowSignalBuilder(Window *parent)
Open the signal selection window.
Definition: rail_gui.cpp:1944
IsBridgeTile
bool IsBridgeTile(Tile t)
checks if there is a bridge on this tile
Definition: bridge_map.h:35
WID_BRAS_PLATFORM_NUM_5
@ WID_BRAS_PLATFORM_NUM_5
Button to select stations with 5 platforms.
Definition: rail_widget.h:45
WID_BS_ELECTRIC_ENTRY
@ WID_BS_ELECTRIC_ENTRY
Build an electric entry block signal.
Definition: rail_widget.h:92
Window::parent
Window * parent
Parent window.
Definition: window_gui.h:322
NWidget
constexpr NWidgetPart NWidget(WidgetType tp, Colours col, WidgetID idx=-1)
Widget part function for starting a new 'real' widget.
Definition: widget_type.h:1258
_local_company
CompanyID _local_company
Company controlled by the human player at this client. Can also be COMPANY_SPECTATOR.
Definition: company_cmd.cpp:49
safeguards.h
sortlist_type.h
Window::LowerWidget
void LowerWidget(WidgetID widget_index)
Marks a widget as lowered.
Definition: window_gui.h:460
StationSpec::name
StringID name
Name of this station.
Definition: newgrf_station.h:126
timer.h
WC_BUILD_BRIDGE
@ WC_BUILD_BRIDGE
Build bridge; Window numbers:
Definition: window_type.h:389
ShowSelectWaypointIfNeeded
void ShowSelectWaypointIfNeeded(TileArea ta, StationPickerCmdProc proc)
Show the waypoint selection window when needed.
Definition: station_gui.cpp:2470
WID_RAT_BUILD_WAYPOINT
@ WID_RAT_BUILD_WAYPOINT
Build a waypoint.
Definition: rail_widget.h:24
TRACK_LEFT
@ TRACK_LEFT
Track in the left corner of the tile (west)
Definition: track_type.h:25
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
DrawSprite
void DrawSprite(SpriteID img, PaletteID pal, int x, int y, const SubSprite *sub, ZoomLevel zoom)
Draw a sprite, not in a viewport.
Definition: gfx.cpp:1007
MP_TUNNELBRIDGE
@ MP_TUNNELBRIDGE
Tunnel entry/exit and bridge heads.
Definition: tile_type.h:57
WID_BRAS_PLATFORM_NUM_7
@ WID_BRAS_PLATFORM_NUM_7
Button to select stations with 7 platforms.
Definition: rail_widget.h:47
waypoint_func.h
WID_BRAS_NEWST_LIST
@ WID_BRAS_NEWST_LIST
List with available newstation classes.
Definition: rail_widget.h:74
Point
Coordinates of a point in 2D.
Definition: geometry_type.hpp:21
BuildRailToolbarWindow::OnInvalidateData
void OnInvalidateData([[maybe_unused]] int data=0, [[maybe_unused]] bool gui_scope=true) override
Some data on this window has become invalid.
Definition: rail_gui.cpp:459
BuildRailStationWindow
Definition: rail_gui.cpp:953
DiagDirection
DiagDirection
Enumeration for diagonal directions.
Definition: direction_type.h:73
Window::IsWidgetDisabled
bool IsWidgetDisabled(WidgetID widget_index) const
Gets the enabled/disabled status of a widget.
Definition: window_gui.h:410
BuildRailStationWindow::string_filter
StringFilter string_filter
Filter for available station classes.
Definition: rail_gui.cpp:969
GetRailTileType
static debug_inline RailTileType GetRailTileType(Tile t)
Returns the RailTileType (normal with or without signals, waypoint or depot).
Definition: rail_map.h:36
CenterBounds
int CenterBounds(int min, int max, int size)
Determine where to draw a centred object inside a widget.
Definition: gfx_func.h:166
Scrollbar::GetScrolledItemFromWidget
Tcontainer::iterator GetScrolledItemFromWidget(Tcontainer &container, int clickpos, const Window *const w, WidgetID widget, int padding=0, int line_height=-1) const
Return an iterator pointing to the element of a scrolled widget that a user clicked in.
Definition: widget_type.h:845
CBM_STATION_AVAIL
@ CBM_STATION_AVAIL
Availability of station in construction window.
Definition: newgrf_callbacks.h:310
HT_DIR_MASK
@ HT_DIR_MASK
masks the drag-direction
Definition: tilehighlight_type.h:40
StationSettings::station_spread
byte station_spread
amount a station may spread
Definition: settings_type.h:595
RailTypeInfo::gui_sprites
struct RailTypeInfo::@24 gui_sprites
struct containing the sprites for the rail GUI.
tunnelbridge_cmd.h
TrackStatusToTrackBits
TrackBits TrackStatusToTrackBits(TrackStatus ts)
Returns the present-track-information of a TrackStatus.
Definition: track_func.h:363
BuildRailStationWindow::BuildStationClassesAvailable
void BuildStationClassesAvailable()
Builds the filter list of available station classes.
Definition: rail_gui.cpp:1105
WID_RAT_CAPTION
@ WID_RAT_CAPTION
Caption of the window.
Definition: rail_widget.h:16
TRACK_BIT_LOWER
@ TRACK_BIT_LOWER
Lower track.
Definition: track_type.h:40
IsValidAxis
bool IsValidAxis(Axis d)
Checks if an integer value is a valid Axis.
Definition: direction_func.h:43
StationSpec::disallowed_platforms
byte disallowed_platforms
Bitmask of number of platforms available for the station.
Definition: newgrf_station.h:132
stdafx.h
RailTypeInfo::rail_ew
CursorID rail_ew
Cursor for building rail in E-W direction.
Definition: rail.h:167
Window::SetFocusedWidget
bool SetFocusedWidget(WidgetID widget_index)
Set focus within this window to the given widget.
Definition: window.cpp:487
BuildRailStationWindow::vscroll
Scrollbar * vscroll
Vertical scrollbar of the new station list.
Definition: rail_gui.cpp:957
GUISettings::link_terraform_toolbar
bool link_terraform_toolbar
display terraform toolbar when displaying rail, road, water and airport toolbars
Definition: settings_type.h:142
GfxFillRect
void GfxFillRect(int left, int top, int right, int bottom, int colour, FillRectMode mode)
Applies a certain FillRectMode-operation to a rectangle [left, right] x [top, bottom] on the screen.
Definition: gfx.cpp:113
WID_BRW_SCROLL
@ WID_BRW_SCROLL
Scrollbar for the matrix.
Definition: rail_widget.h:119
SpriteID
uint32_t SpriteID
The number of a sprite, without mapping bits and colourtables.
Definition: gfx_type.h:17
WID_BS_SEMAPHORE_COMBO
@ WID_BS_SEMAPHORE_COMBO
Build a semaphore combo block signal.
Definition: rail_widget.h:88
BuildRailStationWindow::vscroll2
Scrollbar * vscroll2
Vertical scrollbar of the matrix with new stations.
Definition: rail_gui.cpp:958
Window::InvalidateData
void InvalidateData(int data=0, bool gui_scope=true)
Mark this window's data as invalid (in need of re-computing)
Definition: window.cpp:3140
viewport_func.h
WID_RAT_CONVERT_RAIL
@ WID_RAT_CONVERT_RAIL
Convert other rail to this type.
Definition: rail_widget.h:30
WC_NONE
@ WC_NONE
No window, redirects to WC_MAIN_WINDOW.
Definition: window_type.h:45
CanBuildVehicleInfrastructure
bool CanBuildVehicleInfrastructure(VehicleType type, byte subtype)
Check whether we can build infrastructure for the given vehicle type.
Definition: vehicle.cpp:1893
Window::SetWidgetLoweredState
void SetWidgetLoweredState(WidgetID widget_index, bool lowered_stat)
Sets the lowered/raised status of a widget.
Definition: window_gui.h:441
RailStationGUISettings
Definition: rail_gui.cpp:61
GetDigitWidth
byte GetDigitWidth(FontSize size)
Return the maximum width of single digit.
Definition: gfx.cpp:1263
NWID_VERTICAL
@ NWID_VERTICAL
Vertical container.
Definition: widget_type.h:79
IsPlainRailTile
static debug_inline bool IsPlainRailTile(Tile t)
Checks whether the tile is a rail tile or rail tile with signals.
Definition: rail_map.h:60
FillDrawPixelInfo
bool FillDrawPixelInfo(DrawPixelInfo *n, int left, int top, int width, int height)
Set up a clipping area for only drawing into a certain area.
Definition: gfx.cpp:1571
WC_BUILD_DEPOT
@ WC_BUILD_DEPOT
Build depot; Window numbers:
Definition: window_type.h:417
GetTrackBits
TrackBits GetTrackBits(Tile tile)
Gets the track bits of the given tile.
Definition: rail_map.h:136
RailTypeInfo::max_speed
uint16_t max_speed
Maximum speed for vehicles travelling on this rail type.
Definition: rail.h:231
TileOffsByDiagDir
TileIndexDiff TileOffsByDiagDir(DiagDirection dir)
Convert a DiagDirection to a TileIndexDiff.
Definition: map_func.h:563
SIGTYPE_BLOCK
@ SIGTYPE_BLOCK
block signal
Definition: signal_type.h:24
WidgetDimensions::unscaled
static const WidgetDimensions unscaled
Unscaled widget dimensions.
Definition: window_gui.h:67
Window::SetWidgetDisabledState
void SetWidgetDisabledState(WidgetID widget_index, bool disab_stat)
Sets the enabled/disabled status of a widget.
Definition: window_gui.h:381
WID_BS_DRAG_SIGNALS_DENSITY_INCREASE
@ WID_BS_DRAG_SIGNALS_DENSITY_INCREASE
Increase the signal density.
Definition: rail_widget.h:100
GetSpriteSize
Dimension GetSpriteSize(SpriteID sprid, Point *offset, ZoomLevel zoom)
Get the size of a sprite.
Definition: gfx.cpp:941
WWT_CLOSEBOX
@ WWT_CLOSEBOX
Close box (at top-left of a window)
Definition: widget_type.h:71
WWT_RESIZEBOX
@ WWT_RESIZEBOX
Resize box (normally at bottom-right of a window)
Definition: widget_type.h:70
RAILTYPE_RAIL
@ RAILTYPE_RAIL
Standard non-electric rails.
Definition: rail_type.h:29
BuildRailWaypointWindow::OnRealtimeTick
void OnRealtimeTick([[maybe_unused]] uint delta_ms) override
Called periodically.
Definition: rail_gui.cpp:2210
RailTypeInfo::menu_text
StringID menu_text
Name of this rail type in the main toolbar dropdown.
Definition: rail.h:178
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
TileHighlightData::drawstyle
HighLightStyle drawstyle
Lower bits 0-3 are reserved for detailed highlight information.
Definition: tilehighlight_type.h:64
BuildRailStationWindow::sorter_funcs
static GUIStationClassList::SortFunction *const sorter_funcs[]
Sort functions of the GUIStationClassList.
Definition: rail_gui.cpp:966
DrawStationCoverageAreaText
int DrawStationCoverageAreaText(int left, int right, int top, StationCoverageType sct, int rad, bool supplies)
Calculates and draws the accepted or supplied cargo around the selected tile(s)
Definition: station_gui.cpp:52
GUIList::ForceRebuild
void ForceRebuild()
Force that a rebuild is needed.
Definition: sortlist_type.h:395
string_func.h
spritecache.h
SCT_ALL
@ SCT_ALL
Draw all cargoes.
Definition: station_gui.h:23
Window::IsWidgetLowered
bool IsWidgetLowered(WidgetID widget_index) const
Gets the lowered state of a widget.
Definition: window_gui.h:491
CALLBACK_FAILED
static const uint CALLBACK_FAILED
Different values for Callback result evaluations.
Definition: newgrf_callbacks.h:420
WID_BS_DRAG_SIGNALS_DENSITY_DECREASE
@ WID_BS_DRAG_SIGNALS_DENSITY_DECREASE
Decrease the signal density.
Definition: rail_widget.h:99
TRACK_BIT_HORZ
@ TRACK_BIT_HORZ
Upper and lower track.
Definition: track_type.h:44
rail_gui.h
Window::querystrings
std::map< WidgetID, QueryString * > querystrings
QueryString associated to WWT_EDITBOX widgets.
Definition: window_gui.h:314
SoundSettings::confirm
bool confirm
Play sound effect on successful constructions or other actions.
Definition: settings_type.h:240
QueryString::cancel_button
int cancel_button
Widget button of parent window to simulate when pressing CANCEL in OSK.
Definition: querystring_gui.h:28
RailStationGUISettings::station_class
StationClassID station_class
Currently selected custom station class (if newstations is true )
Definition: rail_gui.cpp:65
TileHighlightData::selstart
Point selstart
The location where the dragging started.
Definition: tilehighlight_type.h:60
WID_RAT_DEMOLISH
@ WID_RAT_DEMOLISH
Destroy something with dynamite!
Definition: rail_widget.h:22
GuiShowTooltips
void GuiShowTooltips(Window *parent, StringID str, TooltipCloseCondition close_tooltip, uint paramcount)
Shows a tooltip.
Definition: misc_gui.cpp:757
vehicle_func.h
WC_GAME_OPTIONS
@ WC_GAME_OPTIONS
Game options window; Window numbers:
Definition: window_type.h:619
GenericPlaceSignals
static void GenericPlaceSignals(TileIndex tile)
Build a new signal or edit/remove a present signal, use CmdBuildSingleSignal() or CmdRemoveSingleSign...
Definition: rail_gui.cpp:226
_convert_signal_button
static bool _convert_signal_button
convert signal button in the signal GUI pressed
Definition: rail_gui.cpp:57
WID_BRAD_DEPOT_NW
@ WID_BRAD_DEPOT_NW
Build a depot with the entrance in the north west.
Definition: rail_widget.h:111
WC_SELECT_STATION
@ WC_SELECT_STATION
Select station (when joining stations); Window numbers:
Definition: window_type.h:242
WID_BS_BLOCK_SEL
@ WID_BS_BLOCK_SEL
Container for the block signal group, which can be hidden.
Definition: rail_widget.h:101
GetRailTypes
RailTypes GetRailTypes(bool introduces)
Get list of rail types, regardless of company availability.
Definition: rail.cpp:282
Window::CreateNestedTree
void CreateNestedTree()
Perform the first part of the initialization of a nested widget tree.
Definition: window.cpp:1724
strings_func.h
NWID_VSCROLLBAR
@ NWID_VSCROLLBAR
Vertical scrollbar.
Definition: widget_type.h:86
BuildSignalWindow::OnInit
void OnInit() override
Notification that the nested widget tree gets initialized.
Definition: rail_gui.cpp:1734
BuildRailToolbarWindow::OnRealtimeTick
void OnRealtimeTick([[maybe_unused]] uint delta_ms) override
Called periodically.
Definition: rail_gui.cpp:816
StationSpec
Station specification.
Definition: newgrf_station.h:112
PlaceExtraDepotRail
static void PlaceExtraDepotRail(TileIndex tile, DiagDirection dir, Track track)
Try to add an additional rail-track at the entrance of a depot.
Definition: rail_gui.cpp:115
WID_BS_BLOCK_SPACER_SEL
@ WID_BS_BLOCK_SPACER_SEL
Container for the spacer between block and path signal groups, which can be hidden.
Definition: rail_widget.h:102
BuildRailWaypointWindow::string_filter
StringFilter string_filter
Filter for waypoint name.
Definition: rail_gui.cpp:2033
terraform_gui.h
WID_RAT_BUILD_Y
@ WID_RAT_BUILD_Y
Build rail along the game grid Y axis.
Definition: rail_widget.h:20
Window::IsShaded
bool IsShaded() const
Is window shaded currently?
Definition: window_gui.h:556
TRACK_BIT_LEFT
@ TRACK_BIT_LEFT
Left track.
Definition: track_type.h:41
WID_BRAS_FILTER_EDITBOX
@ WID_BRAS_FILTER_EDITBOX
Filter text box for the station class list.
Definition: rail_widget.h:68
BuildRailStationWindow::GUIStationClassList
GUIList< StationClassID, std::nullptr_t, StringFilter & > GUIStationClassList
Type definition for the list to hold available station classes.
Definition: rail_gui.cpp:960
WC_BUILD_WAYPOINT
@ WC_BUILD_WAYPOINT
Build waypoint; Window numbers:
Definition: window_type.h:423
RailTypeInfo::depot
CursorID depot
Cursor for building a depot.
Definition: rail.h:170
GetCompanyRailTypes
RailTypes GetCompanyRailTypes(CompanyID company, bool introduces)
Get the rail types the given company can build.
Definition: rail.cpp:251
Scrollbar::IsVisible
bool IsVisible(uint16_t item) const
Checks whether given current item is visible in the list.
Definition: widget_type.h:730
VPM_Y_LIMITED
@ VPM_Y_LIMITED
Drag only in Y axis with limited size.
Definition: viewport_type.h:97
Window::DisableWidget
void DisableWidget(WidgetID widget_index)
Sets a widget to disabled.
Definition: window_gui.h:391
_build_depot_direction
static DiagDirection _build_depot_direction
Currently selected depot direction.
Definition: rail_gui.cpp:55
WWT_TEXT
@ WWT_TEXT
Pure simple text.
Definition: widget_type.h:60
SetPIP
constexpr NWidgetPart SetPIP(uint8_t pre, uint8_t inter, uint8_t post)
Widget part function for setting a pre/inter/post spaces.
Definition: widget_type.h:1220
WID_BS_SEMAPHORE_PBS_OWAY
@ WID_BS_SEMAPHORE_PBS_OWAY
Build a semaphore one way path signal.
Definition: rail_widget.h:90
Map::Size
static debug_inline uint Size()
Get the size of the map.
Definition: map_func.h:288
BuildRailStationWindow::filter_funcs
static GUIStationClassList::FilterFunction *const filter_funcs[]
Filter functions of the GUIStationClassList.
Definition: rail_gui.cpp:967
WC_SCEN_LAND_GEN
@ WC_SCEN_LAND_GEN
Landscape generation (in Scenario Editor); Window numbers:
Definition: window_type.h:449
HT_LINE
@ HT_LINE
used for autorail highlighting (longer stretches), lower bits: direction
Definition: tilehighlight_type.h:25
SetDParam
void SetDParam(size_t n, uint64_t v)
Set a string parameter v at index n in the global string parameter array.
Definition: strings.cpp:104
COMPANY_SPECTATOR
@ COMPANY_SPECTATOR
The client is spectating.
Definition: company_type.h:35
RAILTYPE_END
@ RAILTYPE_END
Used for iterations.
Definition: rail_type.h:33
geometry_func.hpp
RailTypeInfo::build_tunnel
SpriteID build_tunnel
button for building a tunnel
Definition: rail.h:159
WID_BRAS_PLATFORM_NUM_3
@ WID_BRAS_PLATFORM_NUM_3
Button to select stations with 3 platforms.
Definition: rail_widget.h:43
_build_tunnel_endtile
TileIndex _build_tunnel_endtile
The end of a tunnel; as hidden return from the tunnel build command for GUI purposes.
Definition: tunnelbridge_cmd.cpp:53
SIGNAL_CYCLE_ALL
@ SIGNAL_CYCLE_ALL
Cycle through all signals visible to the player.
Definition: rail_gui.h:31
InitializeRailGui
void InitializeRailGui()
Initialize rail building GUI settings.
Definition: rail_gui.cpp:2259
StringFilter::ResetState
void ResetState()
Reset the matching state to process a new item.
Definition: stringfilter.cpp:98
BuildRailStationWindow::OnInvalidateData
void OnInvalidateData([[maybe_unused]] int data=0, [[maybe_unused]] bool gui_scope=true) override
Some data on this window has become invalid.
Definition: rail_gui.cpp:1158
WWT_PANEL
@ WWT_PANEL
Simple depressed panel.
Definition: widget_type.h:52
MarkTileDirtyByTile
void MarkTileDirtyByTile(TileIndex tile, int bridge_level_offset, int tile_height_override)
Mark a tile given by its index dirty for repaint.
Definition: viewport.cpp:2051
BuildRailDepotWindow
Definition: rail_gui.cpp:1949
WidgetDimensions::vsep_normal
int vsep_normal
Normal vertical spacing.
Definition: window_gui.h:60
RailTypeInfo::build_x_rail
SpriteID build_x_rail
button for building single rail in X direction
Definition: rail.h:154
BuildRailStationWindow::line_height
uint line_height
Height of a single line in the newstation selection matrix (WID_BRAS_NEWST_LIST widget).
Definition: rail_gui.cpp:955
AutoRestoreBackup
Class to backup a specific variable and restore it upon destruction of this object to prevent stack v...
Definition: backup_type.hpp:153
WID_BRAS_PLATFORM_LEN_5
@ WID_BRAS_PLATFORM_LEN_5
Button to select 5 tiles length station platforms.
Definition: rail_widget.h:53
ScaleSpriteTrad
int ScaleSpriteTrad(int value)
Scale traditional pixel dimensions to GUI zoom level, for drawing sprites.
Definition: zoom_func.h:107
PlaceRail_Station
static void PlaceRail_Station(TileIndex tile)
Place a rail station.
Definition: rail_gui.cpp:190
Scrollbar::SetCount
void SetCount(size_t num)
Sets the number of elements in the list.
Definition: widget_type.h:760
GetString
std::string GetString(StringID string)
Resolve the given StringID into a std::string with all the associated DParam lookups and formatting.
Definition: strings.cpp:327
StationClassID
StationClassID
Definition: newgrf_station.h:83
EventState
EventState
State of handling an event.
Definition: window_type.h:738
HT_RECT
@ HT_RECT
rectangle (stations, depots, ...)
Definition: tilehighlight_type.h:21
VPM_FIX_HORIZONTAL
@ VPM_FIX_HORIZONTAL
drag only in horizontal direction
Definition: viewport_type.h:94
VPM_X_AND_Y
@ VPM_X_AND_Y
area of land in X and Y directions
Definition: viewport_type.h:92
ResetSignalVariant
void ResetSignalVariant(int32_t)
Updates the current signal variant used in the signal GUI to the one adequate to current year.
Definition: rail_gui.cpp:2332
WID_BRW_NAME
@ WID_BRW_NAME
Name of selected waypoint.
Definition: rail_widget.h:120
GetTunnelBridgeTransportType
TransportType GetTunnelBridgeTransportType(Tile t)
Tunnel: Get the transport type of the tunnel (road or rail) Bridge: Get the transport type of the bri...
Definition: tunnelbridge_map.h:39
BuildRailStationWindow::OnRealtimeTick
void OnRealtimeTick([[maybe_unused]] uint delta_ms) override
Called periodically.
Definition: rail_gui.cpp:1547
StringFilter::GetState
bool GetState() const
Get the matching state of the current item.
Definition: stringfilter_type.h:71
NewGRFClass::name
StringID name
Name of this class.
Definition: newgrf_class.h:39
BuildRailToolbarWindow::OnCTRLStateChange
EventState OnCTRLStateChange() override
The state of the control key has changed.
Definition: rail_gui.cpp:809
SetViewportCatchmentWaypoint
void SetViewportCatchmentWaypoint(const Waypoint *wp, bool sel)
Select or deselect waypoint for coverage area highlight.
Definition: viewport.cpp:3623
PackVelocity
int64_t PackVelocity(uint speed, VehicleType type)
Pack velocity and vehicle type for use with SCC_VELOCITY string parameter.
Definition: strings_func.h:74
Window::FinishInitNested
void FinishInitNested(WindowNumber window_number=0)
Perform the second part of the initialization of a nested widget tree.
Definition: window.cpp:1734
DC_AUTO
@ DC_AUTO
don't allow building on structures
Definition: command_type.h:372
PC_BLACK
static const uint8_t PC_BLACK
Black palette colour.
Definition: palette_func.h:55
_nested_signal_builder_widgets
static constexpr NWidgetPart _nested_signal_builder_widgets[]
Nested widget definition of the build signal window.
Definition: rail_gui.cpp:1867
NWID_SPACER
@ NWID_SPACER
Invisible widget that takes some space.
Definition: widget_type.h:81
HT_DRAG_MASK
@ HT_DRAG_MASK
Mask for the tile drag-type modes.
Definition: tilehighlight_type.h:29
company_func.h
PickerWindowBase
Base class for windows opened from a toolbar.
Definition: window_gui.h:979
WID_BRAS_PLATFORM_NUM_4
@ WID_BRAS_PLATFORM_NUM_4
Button to select stations with 4 platforms.
Definition: rail_widget.h:44
SetViewportCatchmentStation
void SetViewportCatchmentStation(const Station *st, bool sel)
Select or deselect station for coverage area highlight.
Definition: viewport.cpp:3603
_cur_waypoint_type
static uint16_t _cur_waypoint_type
Currently selected waypoint type.
Definition: rail_gui.cpp:56
GetOtherTunnelBridgeEnd
TileIndex GetOtherTunnelBridgeEnd(Tile t)
Determines type of the wormhole and returns its other end.
Definition: tunnelbridge_map.h:78
WidgetDimensions::fullbevel
RectPadding fullbevel
Always-scaled bevel thickness.
Definition: window_gui.h:41
QueryString::ACTION_CLEAR
static const int ACTION_CLEAR
Clear editbox.
Definition: querystring_gui.h:24
ShowStationBuilder
static Window * ShowStationBuilder(Window *parent)
Open station build window.
Definition: rail_gui.cpp:1683
Window::top
int top
y position of top edge of the window
Definition: window_gui.h:304
BuildRailStationWindow::OnResize
void OnResize() override
Called after the window got resized.
Definition: rail_gui.cpp:1365
AXIS_X
@ AXIS_X
The X axis.
Definition: direction_type.h:117
TileArea
OrthogonalTileArea TileArea
Shorthand for the much more common orthogonal tile area.
Definition: tilearea_type.h:102
RailTypeInfo::rail_nwse
CursorID rail_nwse
Cursor for building rail in Y direction.
Definition: rail.h:168
Window::RaiseWidget
void RaiseWidget(WidgetID widget_index)
Marks a widget as raised.
Definition: window_gui.h:469
rail_widget.h
WID_BRAS_MATRIX_SCROLL
@ WID_BRAS_MATRIX_SCROLL
Scrollbar of the matrix widget.
Definition: rail_widget.h:65
TrackBits
TrackBits
Allow incrementing of Track variables.
Definition: track_type.h:35
BuildRailWaypointWindow
Definition: rail_gui.cpp:2027
DDSP_BUILD_SIGNALS
@ DDSP_BUILD_SIGNALS
Signal placement.
Definition: viewport_type.h:122
CommandHelper
Definition: command_func.h:93
GUIList::SetFilterFuncs
void SetFilterFuncs(FilterFunction *const *n_funcs)
Hand the array of filter function pointers to the sort list.
Definition: sortlist_type.h:366
BuildSignalWindow::sig_sprite_bottom_offset
int sig_sprite_bottom_offset
Maximum extent of signal GUI sprite from reference point towards bottom.
Definition: rail_gui.cpp:1692
station_map.h
window_func.h
BuildRailStationWindow::station_classes
GUIStationClassList station_classes
Available station classes.
Definition: rail_gui.cpp:968
SA_CENTER
@ SA_CENTER
Center both horizontally and vertically.
Definition: gfx_type.h:348
SoundSettings::click_beep
bool click_beep
Beep on a random selection of buttons.
Definition: settings_type.h:241
WID_BRAS_PLATFORM_DIR_Y
@ WID_BRAS_PLATFORM_DIR_Y
Button to select '\' view.
Definition: rail_widget.h:39
GetCharacterHeight
int GetCharacterHeight(FontSize size)
Get height of a character for a given font size.
Definition: fontcache.cpp:78
SIGNAL_GUI_ALL
@ SIGNAL_GUI_ALL
Show all signals, including block and presignals.
Definition: rail_gui.h:25
VPM_X_LIMITED
@ VPM_X_LIMITED
Drag only in X axis with limited size.
Definition: viewport_type.h:96
_place_depot_extra_track
static const Track _place_depot_extra_track[12]
Additional pieces of track to add at the entrance of a depot.
Definition: rail_gui.cpp:125
StationSpec::grf_prop
GRFFilePropsBase< NUM_CARGO+3 > grf_prop
Properties related the the grf file.
Definition: newgrf_station.h:124
stringfilter_type.h
NewGRFClass::Get
static NewGRFClass * Get(Tid cls_id)
Get a particular class.
Definition: newgrf_class_func.h:98
ShowTerraformToolbar
Window * ShowTerraformToolbar(Window *link)
Show the toolbar for terraforming in the game.
Definition: terraform_gui.cpp:367
SetMinimalSize
constexpr NWidgetPart SetMinimalSize(int16_t x, int16_t y)
Widget part function for setting the minimal size.
Definition: widget_type.h:1097
MarkWholeScreenDirty
void MarkWholeScreenDirty()
This function mark the whole screen as dirty.
Definition: gfx.cpp:1552
SetPIPRatio
constexpr NWidgetPart SetPIPRatio(uint8_t ratio_pre, uint8_t ratio_inter, uint8_t ratio_post)
Widget part function for setting a pre/inter/post ratio.
Definition: widget_type.h:1232
CA_TRAIN
@ CA_TRAIN
Catchment for train stations with "modified catchment" enabled.
Definition: station_type.h:79
WID_RAT_BUILD_DEPOT
@ WID_RAT_BUILD_DEPOT
Build a depot.
Definition: rail_widget.h:23
GUIList::SetSortFuncs
void SetSortFuncs(SortFunction *const *n_funcs)
Hand the array of sort function pointers to the sort list.
Definition: sortlist_type.h:295
GUIList::RebuildDone
void RebuildDone()
Notify the sortlist that the rebuild is done.
Definition: sortlist_type.h:405
GUIList< StationClassID, std::nullptr_t, StringFilter & >::FilterFunction
bool CDECL FilterFunction(const StationClassID *, StringFilter &)
Signature of filter function.
Definition: sortlist_type.h:50
GUISettings::auto_remove_signals
bool auto_remove_signals
automatically remove signals when in the way during rail construction
Definition: settings_type.h:200
WID_BRW_FILTER
@ WID_BRW_FILTER
Text filter.
Definition: rail_widget.h:116
DrawString
int DrawString(int left, int right, int top, std::string_view str, TextColour colour, StringAlignment align, bool underline, FontSize fontsize)
Draw string, possibly truncated to make it fit in its allocated space.
Definition: gfx.cpp:658
WID_BRAD_DEPOT_NE
@ WID_BRAD_DEPOT_NE
Build a depot with the entrance in the north east.
Definition: rail_widget.h:108
GUISettings::station_platlength
byte station_platlength
the platform length, in tiles, for rail stations
Definition: settings_type.h:187
WID_BRAS_SHOW_NEWST_DEFSIZE
@ WID_BRAS_SHOW_NEWST_DEFSIZE
Selection for default-size button for newstation.
Definition: rail_widget.h:69
engine_base.h
BuildSignalWindow::OnInvalidateData
void OnInvalidateData([[maybe_unused]] int data=0, [[maybe_unused]] bool gui_scope=true) override
Some data on this window has become invalid.
Definition: rail_gui.cpp:1854
WID_BRW_WAYPOINT_MATRIX
@ WID_BRW_WAYPOINT_MATRIX
Matrix with waypoints.
Definition: rail_widget.h:117
TileVirtXY
static debug_inline TileIndex TileVirtXY(uint x, uint y)
Get a tile from the virtual XY-coordinate.
Definition: map_func.h:416
InitializeRailGUI
void InitializeRailGUI()
Resets the rail GUI - sets default railtype to build and resets the signal GUI.
Definition: rail_gui.cpp:2357
BuildRailStationWindow::last_sorting
static Listing last_sorting
Default sorting of GUIStationClassList.
Definition: rail_gui.cpp:964
gui.h
WID_BRAS_PLATFORM_LEN_3
@ WID_BRAS_PLATFORM_LEN_3
Button to select 3 tiles length station platforms.
Definition: rail_widget.h:51
WidgetDimensions::frametext
RectPadding frametext
Padding inside frame with text.
Definition: window_gui.h:43
WID_BS_ELECTRIC_PBS
@ WID_BS_ELECTRIC_PBS
Build an electric path signal.
Definition: rail_widget.h:95
BuildRailToolbarWindow::OnPlaceObjectAbort
void OnPlaceObjectAbort() override
The user cancelled a tile highlight mode that has been set.
Definition: rail_gui.cpp:786
BuildRailStationWindow::OnPaint
void OnPaint() override
The window must be repainted.
Definition: rail_gui.cpp:1190
BuildRailToolbarWindow::ModifyRailType
void ModifyRailType(RailType railtype)
Switch to another rail type.
Definition: rail_gui.cpp:509
WC_BUILD_SIGNAL
@ WC_BUILD_SIGNAL
Build signal toolbar; Window numbers:
Definition: window_type.h:98
Window
Data structure for an opened window.
Definition: window_gui.h:267
Commands
Commands
List of commands.
Definition: command_type.h:187
StationSpec::callback_mask
byte callback_mask
Bitmask of station callbacks that have to be called.
Definition: newgrf_station.h:157
WID_BS_CAPTION
@ WID_BS_CAPTION
Caption for the Signal Selection window.
Definition: rail_widget.h:83
IsTileType
static debug_inline bool IsTileType(Tile tile, TileType type)
Checks if a tile is a given tiletype.
Definition: tile_map.h:150
VEH_TRAIN
@ VEH_TRAIN
Train vehicle type.
Definition: vehicle_type.h:24
Pool::PoolItem<&_company_pool >::IsValidID
static bool IsValidID(size_t index)
Tests whether given index can be used to get valid (non-nullptr) Titem.
Definition: pool_type.hpp:324
StationSpec::disallowed_lengths
byte disallowed_lengths
Bitmask of platform lengths available for the station.
Definition: newgrf_station.h:137
Window::DrawWidgets
void DrawWidgets() const
Paint all widgets of a window.
Definition: widget.cpp:731
RailStationGUISettings::station_count
uint16_t station_count
Number of custom stations (if newstations is true )
Definition: rail_gui.cpp:67
RAIL_TILE_DEPOT
@ RAIL_TILE_DEPOT
Depot (one entrance)
Definition: rail_map.h:26
GRFFilePropsBase::grffile
const struct GRFFile * grffile
grf file that introduced this entity
Definition: newgrf_commons.h:319
BuildRailToolbarWindow::RailToolbarGlobalHotkeys
static EventState RailToolbarGlobalHotkeys(int hotkey)
Handler for global hotkeys of the BuildRailToolbarWindow.
Definition: rail_gui.cpp:826
WID_BS_CONVERT
@ WID_BS_CONVERT
Convert the signal.
Definition: rail_widget.h:97
WID_BS_ELECTRIC_EXIT
@ WID_BS_ELECTRIC_EXIT
Build an electric exit block signal.
Definition: rail_widget.h:93
BuildRailToolbarWindow::SetupRailToolbar
void SetupRailToolbar(RailType railtype)
Configures the rail toolbar for railtype given.
Definition: rail_gui.cpp:489
SetDataTip
constexpr NWidgetPart SetDataTip(uint32_t data, StringID tip)
Widget part function for setting the data and tooltip.
Definition: widget_type.h:1162
SetMinimalTextLines
constexpr NWidgetPart SetMinimalTextLines(uint8_t lines, uint8_t spacing, FontSize size=FS_NORMAL)
Widget part function for setting the minimal text lines.
Definition: widget_type.h:1109
Rect::Width
int Width() const
Get width of Rect.
Definition: geometry_type.hpp:85
Track
Track
These are used to specify a single track.
Definition: track_type.h:19
VPM_X_AND_Y_LIMITED
@ VPM_X_AND_Y_LIMITED
area of land of limited size
Definition: viewport_type.h:93
NWID_SELECTION
@ NWID_SELECTION
Stacked widgets, only one visible at a time (eg in a panel with tabs).
Definition: widget_type.h:82
WID_BRAS_FILTER_CONTAINER
@ WID_BRAS_FILTER_CONTAINER
Container for the filter text box for the station class list.
Definition: rail_widget.h:67
DIAGDIR_NE
@ DIAGDIR_NE
Northeast, upper right on your monitor.
Definition: direction_type.h:75
_station_builder_desc
static WindowDesc _station_builder_desc(__FILE__, __LINE__, WDP_AUTO, "build_station_rail", 350, 0, WC_BUILD_STATION, WC_BUILD_TOOLBAR, WDF_CONSTRUCTION, std::begin(_nested_station_builder_widgets), std::end(_nested_station_builder_widgets), &BuildRailStationWindow::hotkeys)
High level window description of the station-build window (default & newGRF)
BuildRailClick_Remove
static void BuildRailClick_Remove(Window *w)
The "remove"-button click proc of the build-rail toolbar.
Definition: rail_gui.cpp:345
WID_BRAS_MATRIX
@ WID_BRAS_MATRIX
Matrix widget displaying the available stations.
Definition: rail_widget.h:63
Rect
Specification of a rectangle with absolute coordinates of all edges.
Definition: geometry_type.hpp:75
Window::ToggleWidgetLoweredState
void ToggleWidgetLoweredState(WidgetID widget_index)
Invert the lowered/raised status of a widget.
Definition: window_gui.h:450
Company
Definition: company_base.h:116
GUISettings::signal_gui_mode
SignalGUISettings signal_gui_mode
select which signal types are shown in the signal GUI
Definition: settings_type.h:174
GUIList::Sort
bool Sort(Comp compare)
Sort the list.
Definition: sortlist_type.h:268
AWV_INCREASE
@ AWV_INCREASE
Arrow to the right or in case of RTL to the left.
Definition: widget_type.h:34
DrawStationTile
bool DrawStationTile(int x, int y, RailType railtype, Axis axis, StationClassID sclass, uint station)
Draw representation of a station tile for GUI purposes.
Definition: newgrf_station.cpp:779
STAT_CLASS_DFLT
@ STAT_CLASS_DFLT
Default station class.
Definition: newgrf_station.h:85
DDSP_REMOVE_STATION
@ DDSP_REMOVE_STATION
Station removal.
Definition: viewport_type.h:124
RailTypeInfo::replace_text
StringID replace_text
Text used in the autoreplace GUI.
Definition: rail.h:180
VPM_X_OR_Y
@ VPM_X_OR_Y
drag in X or Y direction
Definition: viewport_type.h:89
BuildRailWaypointWindow::OnInvalidateData
void OnInvalidateData([[maybe_unused]] int data=0, [[maybe_unused]] bool gui_scope=true) override
Some data on this window has become invalid.
Definition: rail_gui.cpp:2196
WidgetDimensions::framerect
RectPadding framerect
Standard padding inside many panels.
Definition: window_gui.h:42
BuildRailStationWindow::SelectOtherClass
void SelectOtherClass(StationClassID station_class)
Select the specified station class.
Definition: rail_gui.cpp:1153
BuildSignalWindow::DrawSignalSprite
void DrawSignalSprite(const Rect &r, SpriteID image) const
Draw dynamic a signal-sprite in a button in the signal GUI.
Definition: rail_gui.cpp:1698
ResetObjectToPlace
void ResetObjectToPlace()
Reset the cursor and mouse mode handling back to default (normal cursor, only clicking in windows).
Definition: viewport.cpp:3483
HT_SPECIAL
@ HT_SPECIAL
special mode used for highlighting while dragging (and for tunnels/docks)
Definition: tilehighlight_type.h:23
DrawWaypointSprite
void DrawWaypointSprite(int x, int y, int stat_id, RailType railtype)
Draw a waypoint.
Definition: waypoint.cpp:27
WID_RAT_BUILD_SIGNALS
@ WID_RAT_BUILD_SIGNALS
Build signals.
Definition: rail_widget.h:26
Convert8bitBooleanCallback
bool Convert8bitBooleanCallback(const GRFFile *grffile, uint16_t cbid, uint16_t cb_res)
Converts a callback result into a boolean.
Definition: newgrf_commons.cpp:548
RailTypeInfo::convert_rail
SpriteID convert_rail
button for converting rail
Definition: rail.h:160
RailStationGUISettings::station_type
uint16_t station_type
Station type within the currently selected custom station class (if newstations is true )
Definition: rail_gui.cpp:66
station_gui.h
BuildRailStationWindow::TagNameFilter
static bool CDECL TagNameFilter(StationClassID const *sc, StringFilter &filter)
Filter station classes by class name.
Definition: rail_gui.cpp:1097
GUIList::SetFiltering
void SetFiltering(Filtering f)
Import filter conditions.
Definition: sortlist_type.h:202
SetTextStyle
constexpr NWidgetPart SetTextStyle(TextColour colour, FontSize size=FS_NORMAL)
Widget part function for setting the text style.
Definition: widget_type.h:1120
VPM_SIGNALDIRS
@ VPM_SIGNALDIRS
similar to VMP_RAILDIRS, but with different cursor
Definition: viewport_type.h:99
BuildRailStationWindow::filter_editbox
QueryString filter_editbox
Filter editbox.
Definition: rail_gui.cpp:970
GetStringBoundingBox
Dimension GetStringBoundingBox(std::string_view str, FontSize start_fontsize)
Return the string dimension in pixels.
Definition: gfx.cpp:852
StringFilter
String filter and state.
Definition: stringfilter_type.h:30
WID_RAT_AUTORAIL
@ WID_RAT_AUTORAIL
Autorail tool.
Definition: rail_widget.h:21
RailStationGUISettings::orientation
Axis orientation
Currently selected rail station orientation.
Definition: rail_gui.cpp:62
WID_RAT_BUILD_EW
@ WID_RAT_BUILD_EW
Build rail along the game view X axis.
Definition: rail_widget.h:19
WWT_TEXTBTN
@ WWT_TEXTBTN
(Toggle) Button with text
Definition: widget_type.h:57
BuildRailToolbarWindow::railtype
RailType railtype
Rail type to build.
Definition: rail_gui.cpp:429
ClientSettings::gui
GUISettings gui
settings related to the GUI
Definition: settings_type.h:636
TileHighlightData::selend
Point selend
The location where the drag currently ends.
Definition: tilehighlight_type.h:61
HT_DIR_X
@ HT_DIR_X
X direction.
Definition: tilehighlight_type.h:33
AWV_DECREASE
@ AWV_DECREASE
Arrow to the left or in case of RTL to the right.
Definition: widget_type.h:33
WID_BRAS_PLATFORM_LEN_BEGIN
@ WID_BRAS_PLATFORM_LEN_BEGIN
Helper for determining the chosen platform length.
Definition: rail_widget.h:78
GRFConfig::GetName
const char * GetName() const
Get the name of this grf.
Definition: newgrf_config.cpp:98
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:190
GUIList::SetListing
void SetListing(Listing l)
Import sort conditions.
Definition: sortlist_type.h:151
StationSettings::modified_catchment
bool modified_catchment
different-size catchment areas
Definition: settings_type.h:590
Hotkey
All data for a single hotkey.
Definition: hotkeys.h:21
hotkeys.h
ReinitGuiAfterToggleElrail
void ReinitGuiAfterToggleElrail(bool disable)
Re-initialize rail-build toolbar after toggling support for electric trains.
Definition: rail_gui.cpp:2269
TimerGameCalendar::year
static Year year
Current year, starting at 0.
Definition: timer_game_calendar.h:32
INVALID_RAILTYPE
@ INVALID_RAILTYPE
Flag for invalid railtype.
Definition: rail_type.h:34
WWT_SHADEBOX
@ WWT_SHADEBOX
Shade box (at top-right of a window, between WWT_DEBUGBOX and WWT_DEFSIZEBOX)
Definition: widget_type.h:66
WN_GAME_OPTIONS_GAME_SETTINGS
@ WN_GAME_OPTIONS_GAME_SETTINGS
Game settings.
Definition: window_type.h:27
RAILTYPE_BEGIN
@ RAILTYPE_BEGIN
Used for iterations.
Definition: rail_type.h:28
NWidgetMatrix::SetClicked
void SetClicked(int clicked)
Sets the clicked element in the matrix.
Definition: widget.cpp:1763
SetDefaultRailGui
static void SetDefaultRailGui()
Set the initial (default) railtype to use.
Definition: rail_gui.cpp:2281
_nested_build_waypoint_widgets
static constexpr NWidgetPart _nested_build_waypoint_widgets[]
Nested widget definition for the build NewGRF rail waypoint window.
Definition: rail_gui.cpp:2219
HasBit
constexpr debug_inline bool HasBit(const T x, const uint8_t y)
Checks if a bit in a value is set.
Definition: bitmath_func.hpp:103
GUIPlaceProcDragXY
bool GUIPlaceProcDragXY(ViewportDragDropSelectionProcess proc, TileIndex start_tile, TileIndex end_tile)
A central place to handle all X_AND_Y dragged GUI functions.
Definition: terraform_gui.cpp:111