OpenTTD Source  13.2.1
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 "date_func.h"
23 #include "sound_func.h"
24 #include "company_func.h"
25 #include "widgets/dropdown_type.h"
26 #include "tunnelbridge.h"
27 #include "tilehighlight_func.h"
28 #include "spritecache.h"
29 #include "core/geometry_func.hpp"
30 #include "hotkeys.h"
31 #include "engine_base.h"
32 #include "vehicle_func.h"
33 #include "zoom_func.h"
34 #include "rail_gui.h"
35 #include "querystring_gui.h"
36 #include "sortlist_type.h"
37 #include "stringfilter_type.h"
38 #include "string_func.h"
39 #include "station_cmd.h"
40 #include "tunnelbridge_cmd.h"
41 #include "waypoint_cmd.h"
42 #include "rail_cmd.h"
43 
44 #include "station_map.h"
45 #include "tunnelbridge_map.h"
46 
47 #include "widgets/rail_widget.h"
48 
49 #include "safeguards.h"
50 
51 
55 static byte _waypoint_count = 1;
56 static byte _cur_waypoint_type;
60 
63 
64  bool newstations;
66  byte station_type;
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 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 cmd, 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 cmd, const CommandCost &result, TileIndex tile, RailType rt, 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 cmd, 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_SIGNALS>::Post(STR_ERROR_CAN_T_REMOVE_SIGNALS_FROM, CcPlaySound_CONSTRUCTION_RAIL, tile, track);
242  } else {
243  /* Which signals should we cycle through? */
245 
246  if (FindWindowById(WC_BUILD_SIGNAL, 0) != nullptr) {
247  /* signal GUI is used */
248  Command<CMD_BUILD_SIGNALS>::Post(_convert_signal_button ? STR_ERROR_SIGNAL_CAN_T_CONVERT_SIGNALS_HERE : STR_ERROR_CAN_T_BUILD_SIGNALS_HERE, CcPlaySound_CONSTRUCTION_RAIL,
249  tile, track, _cur_signal_type, _cur_signal_variant, _convert_signal_button, false, _ctrl_pressed, cycle_start, SIGTYPE_LAST, 0, 0);
250  } else {
252  Command<CMD_BUILD_SIGNALS>::Post(STR_ERROR_CAN_T_BUILD_SIGNALS_HERE, CcPlaySound_CONSTRUCTION_RAIL,
253  tile, track, _settings_client.gui.default_signal_type, sigvar, false, false, _ctrl_pressed, cycle_start, SIGTYPE_LAST, 0, 0);
254 
255  }
256  }
257 }
258 
264 static void PlaceRail_Bridge(TileIndex tile, Window *w)
265 {
266  if (IsBridgeTile(tile)) {
267  TileIndex other_tile = GetOtherTunnelBridgeEnd(tile);
268  Point pt = {0, 0};
269  w->OnPlaceMouseUp(VPM_X_OR_Y, DDSP_BUILD_BRIDGE, pt, other_tile, tile);
270  } else {
272  }
273 }
274 
276 void CcBuildRailTunnel(Commands cmd, const CommandCost &result, TileIndex tile)
277 {
278  if (result.Succeeded()) {
279  if (_settings_client.sound.confirm) SndPlayTileFx(SND_20_CONSTRUCTION_RAIL, tile);
281  } else {
283  }
284 }
285 
291 {
296  SetSelectionRed(_remove_button_clicked);
297 }
298 
305 {
306  if (w->IsWidgetDisabled(WID_RAT_REMOVE)) return false;
307 
308  /* allow ctrl to switch remove mode only for these widgets */
309  for (uint i = WID_RAT_BUILD_NS; i <= WID_RAT_BUILD_STATION; i++) {
310  if ((i <= WID_RAT_AUTORAIL || i >= WID_RAT_BUILD_WAYPOINT) && w->IsWidgetLowered(i)) {
312  return true;
313  }
314  }
315 
316  return false;
317 }
318 
319 
326 {
327  if (w->IsWidgetDisabled(WID_RAT_REMOVE)) return;
330 
331  /* handle station builder */
334  /* starting drag & drop remove */
336  SetTileSelectSize(1, 1);
337  } else {
338  VpSetPlaceSizingLimit(-1);
339  }
340  } else {
341  /* starting station build mode */
345  if (_railstation.orientation == 0) Swap(x, y);
346  SetTileSelectSize(x, y);
347  } else {
348  VpSetPlaceSizingLimit(_settings_game.station.station_spread);
349  }
350  }
351  }
352 }
353 
354 static void DoRailroadTrack(Track track)
355 {
357  Command<CMD_REMOVE_RAILROAD_TRACK>::Post(STR_ERROR_CAN_T_REMOVE_RAILROAD_TRACK, CcPlaySound_CONSTRUCTION_RAIL,
358  TileVirtXY(_thd.selend.x, _thd.selend.y), TileVirtXY(_thd.selstart.x, _thd.selstart.y), track);
359  } else {
360  Command<CMD_BUILD_RAILROAD_TRACK>::Post(STR_ERROR_CAN_T_BUILD_RAILROAD_TRACK, CcPlaySound_CONSTRUCTION_RAIL,
361  TileVirtXY(_thd.selend.x, _thd.selend.y), TileVirtXY(_thd.selstart.x, _thd.selstart.y), _cur_railtype, track, _settings_client.gui.auto_remove_signals, false);
362  }
363 }
364 
365 static void HandleAutodirPlacement()
366 {
367  Track trackstat = static_cast<Track>( _thd.drawstyle & HT_DIR_MASK); // 0..5
368 
369  if (_thd.drawstyle & HT_RAIL) { // one tile case
370  GenericPlaceRail(TileVirtXY(_thd.selend.x, _thd.selend.y), trackstat);
371  return;
372  }
373 
374  DoRailroadTrack(trackstat);
375 }
376 
384 {
385  Track track = (Track)GB(_thd.drawstyle, 0, 3); // 0..5
386 
387  if ((_thd.drawstyle & HT_DRAG_MASK) == HT_RECT) { // one tile case
388  GenericPlaceSignals(TileVirtXY(_thd.selend.x, _thd.selend.y));
389  return;
390  }
391 
392  /* _settings_client.gui.drag_signals_density is given as a parameter such that each user
393  * in a network game can specify their own signal density */
395  Command<CMD_REMOVE_SIGNAL_TRACK>::Post(STR_ERROR_CAN_T_REMOVE_SIGNALS_FROM, CcPlaySound_CONSTRUCTION_RAIL,
396  TileVirtXY(_thd.selstart.x, _thd.selstart.y), TileVirtXY(_thd.selend.x, _thd.selend.y), track, _ctrl_pressed);
397  } else {
398  bool sig_gui = FindWindowById(WC_BUILD_SIGNAL, 0) != nullptr;
401  Command<CMD_BUILD_SIGNAL_TRACK>::Post(STR_ERROR_CAN_T_BUILD_SIGNALS_HERE, CcPlaySound_CONSTRUCTION_RAIL,
403  }
404 }
405 
406 
411 
413  {
414  this->InitNested(TRANSPORT_RAIL);
415  this->SetupRailToolbar(railtype);
417  this->last_user_action = WIDGET_LIST_END;
418 
420  }
421 
422  void Close() override
423  {
427  this->Window::Close();
428  }
429 
435  {
436  this->railtype = railtype;
437  const RailtypeInfo *rti = GetRailTypeInfo(railtype);
438 
439  assert(railtype < RAILTYPE_END);
440  this->GetWidget<NWidgetCore>(WID_RAT_BUILD_NS)->widget_data = rti->gui_sprites.build_ns_rail;
441  this->GetWidget<NWidgetCore>(WID_RAT_BUILD_X)->widget_data = rti->gui_sprites.build_x_rail;
442  this->GetWidget<NWidgetCore>(WID_RAT_BUILD_EW)->widget_data = rti->gui_sprites.build_ew_rail;
443  this->GetWidget<NWidgetCore>(WID_RAT_BUILD_Y)->widget_data = rti->gui_sprites.build_y_rail;
444  this->GetWidget<NWidgetCore>(WID_RAT_AUTORAIL)->widget_data = rti->gui_sprites.auto_rail;
445  this->GetWidget<NWidgetCore>(WID_RAT_BUILD_DEPOT)->widget_data = rti->gui_sprites.build_depot;
446  this->GetWidget<NWidgetCore>(WID_RAT_CONVERT_RAIL)->widget_data = rti->gui_sprites.convert_rail;
447  this->GetWidget<NWidgetCore>(WID_RAT_BUILD_TUNNEL)->widget_data = rti->gui_sprites.build_tunnel;
448  }
449 
455  {
456  this->SetupRailToolbar(railtype);
457  this->ReInit();
458  }
459 
460  void UpdateRemoveWidgetStatus(int clicked_widget)
461  {
462  switch (clicked_widget) {
463  case WID_RAT_REMOVE:
464  /* If it is the removal button that has been clicked, do nothing,
465  * as it is up to the other buttons to drive removal status */
466  return;
467 
468  case WID_RAT_BUILD_NS:
469  case WID_RAT_BUILD_X:
470  case WID_RAT_BUILD_EW:
471  case WID_RAT_BUILD_Y:
472  case WID_RAT_AUTORAIL:
476  /* Removal button is enabled only if the rail/signal/waypoint/station
477  * button is still lowered. Once raised, it has to be disabled */
478  this->SetWidgetDisabledState(WID_RAT_REMOVE, !this->IsWidgetLowered(clicked_widget));
479  break;
480 
481  default:
482  /* When any other buttons than rail/signal/waypoint/station, raise and
483  * disable the removal button */
486  break;
487  }
488  }
489 
490  void SetStringParameters(int widget) const override
491  {
492  if (widget == WID_RAT_CAPTION) {
493  const RailtypeInfo *rti = GetRailTypeInfo(this->railtype);
494  if (rti->max_speed > 0) {
495  SetDParam(0, STR_TOOLBAR_RAILTYPE_VELOCITY);
497  SetDParam(2, rti->max_speed);
498  } else {
500  }
501  }
502  }
503 
504  void OnClick(Point pt, int widget, int click_count) override
505  {
506  if (widget < WID_RAT_BUILD_NS) return;
507 
508  _remove_button_clicked = false;
509  switch (widget) {
510  case WID_RAT_BUILD_NS:
512  this->last_user_action = widget;
513  break;
514 
515  case WID_RAT_BUILD_X:
517  this->last_user_action = widget;
518  break;
519 
520  case WID_RAT_BUILD_EW:
522  this->last_user_action = widget;
523  break;
524 
525  case WID_RAT_BUILD_Y:
527  this->last_user_action = widget;
528  break;
529 
530  case WID_RAT_AUTORAIL:
532  this->last_user_action = widget;
533  break;
534 
535  case WID_RAT_DEMOLISH:
537  this->last_user_action = widget;
538  break;
539 
540  case WID_RAT_BUILD_DEPOT:
542  ShowBuildTrainDepotPicker(this);
543  this->last_user_action = widget;
544  }
545  break;
546 
548  this->last_user_action = widget;
550  if (HandlePlacePushButton(this, WID_RAT_BUILD_WAYPOINT, SPR_CURSOR_WAYPOINT, HT_RECT) && _waypoint_count > 1) {
551  ShowBuildWaypointPicker(this);
552  }
553  break;
554 
556  if (HandlePlacePushButton(this, WID_RAT_BUILD_STATION, SPR_CURSOR_RAIL_STATION, HT_RECT)) {
557  ShowStationBuilder(this);
558  this->last_user_action = widget;
559  }
560  break;
561 
562  case WID_RAT_BUILD_SIGNALS: {
563  this->last_user_action = widget;
565  if (started != _ctrl_pressed) {
566  ShowSignalBuilder(this);
567  }
568  break;
569  }
570 
572  HandlePlacePushButton(this, WID_RAT_BUILD_BRIDGE, SPR_CURSOR_BRIDGE, HT_RECT);
573  this->last_user_action = widget;
574  break;
575 
578  this->last_user_action = widget;
579  break;
580 
581  case WID_RAT_REMOVE:
582  BuildRailClick_Remove(this);
583  break;
584 
587  this->last_user_action = widget;
588  break;
589 
590  default: NOT_REACHED();
591  }
592  this->UpdateRemoveWidgetStatus(widget);
594  }
595 
596  EventState OnHotkey(int hotkey) override
597  {
598  MarkTileDirtyByTile(TileVirtXY(_thd.pos.x, _thd.pos.y)); // redraw tile selection
599  return Window::OnHotkey(hotkey);
600  }
601 
602  void OnPlaceObject(Point pt, TileIndex tile) override
603  {
604  switch (this->last_user_action) {
605  case WID_RAT_BUILD_NS:
607  break;
608 
609  case WID_RAT_BUILD_X:
611  break;
612 
613  case WID_RAT_BUILD_EW:
615  break;
616 
617  case WID_RAT_BUILD_Y:
619  break;
620 
621  case WID_RAT_AUTORAIL:
623  break;
624 
625  case WID_RAT_DEMOLISH:
627  break;
628 
629  case WID_RAT_BUILD_DEPOT:
630  Command<CMD_BUILD_TRAIN_DEPOT>::Post(STR_ERROR_CAN_T_BUILD_TRAIN_DEPOT, CcRailDepot, tile, _cur_railtype, _build_depot_direction);
631  break;
632 
634  PlaceRail_Waypoint(tile);
635  break;
636 
638  PlaceRail_Station(tile);
639  break;
640 
643  break;
644 
646  PlaceRail_Bridge(tile, this);
647  break;
648 
650  Command<CMD_BUILD_TUNNEL>::Post(STR_ERROR_CAN_T_BUILD_TUNNEL_HERE, CcBuildRailTunnel, tile, TRANSPORT_RAIL, _cur_railtype);
651  break;
652 
655  break;
656 
657  default: NOT_REACHED();
658  }
659  }
660 
661  void OnPlaceDrag(ViewportPlaceMethod select_method, ViewportDragDropSelectionProcess select_proc, Point pt) override
662  {
663  /* no dragging if you have pressed the convert button */
665 
666  VpSelectTilesWithMethod(pt.x, pt.y, select_method);
667  }
668 
669  void OnPlaceMouseUp(ViewportPlaceMethod select_method, ViewportDragDropSelectionProcess select_proc, Point pt, TileIndex start_tile, TileIndex end_tile) override
670  {
671  if (pt.x != -1) {
672  switch (select_proc) {
673  default: NOT_REACHED();
674  case DDSP_BUILD_BRIDGE:
676  ShowBuildBridgeWindow(start_tile, end_tile, TRANSPORT_RAIL, _cur_railtype);
677  break;
678 
679  case DDSP_PLACE_RAIL:
680  HandleAutodirPlacement();
681  break;
682 
683  case DDSP_BUILD_SIGNALS:
685  break;
686 
687  case DDSP_DEMOLISH_AREA:
688  GUIPlaceProcDragXY(select_proc, start_tile, end_tile);
689  break;
690 
691  case DDSP_CONVERT_RAIL:
692  Command<CMD_CONVERT_RAIL>::Post(STR_ERROR_CAN_T_CONVERT_RAIL, CcPlaySound_CONSTRUCTION_RAIL, end_tile, start_tile, _cur_railtype, _ctrl_pressed);
693  break;
694 
695  case DDSP_REMOVE_STATION:
696  case DDSP_BUILD_STATION:
698  /* Station */
700  bool keep_rail = !_ctrl_pressed;
701  Command<CMD_REMOVE_FROM_RAIL_STATION>::Post(STR_ERROR_CAN_T_REMOVE_PART_OF_STATION, CcPlaySound_CONSTRUCTION_RAIL, end_tile, start_tile, keep_rail);
702  } else {
703  HandleStationPlacement(start_tile, end_tile);
704  }
705  } else {
706  /* Waypoint */
708  bool keep_rail = !_ctrl_pressed;
709  Command<CMD_REMOVE_FROM_RAIL_WAYPOINT>::Post(STR_ERROR_CAN_T_REMOVE_TRAIN_WAYPOINT, CcPlaySound_CONSTRUCTION_RAIL, end_tile, start_tile, keep_rail);
710  } else {
711  TileArea ta(start_tile, end_tile);
712  Axis axis = select_method == VPM_X_LIMITED ? AXIS_X : AXIS_Y;
713  bool adjacent = _ctrl_pressed;
714  byte waypoint_type = _cur_waypoint_type;
715 
716  auto proc = [=](bool test, StationID to_join) -> bool {
717  if (test) {
718  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();
719  } else {
720  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);
721  }
722  };
723 
724  ShowSelectWaypointIfNeeded(ta, proc);
725  }
726  }
727  break;
728  }
729  }
730  }
731 
732  void OnPlaceObjectAbort() override
733  {
735 
736  this->RaiseButtons();
739 
746  }
747 
748  void OnPlacePresize(Point pt, TileIndex tile) override
749  {
752  }
753 
755  {
756  /* do not toggle Remove button by Ctrl when placing station */
758  return ES_NOT_HANDLED;
759  }
760 
761  static HotkeyList hotkeys;
762 };
763 
770 {
771  if (_game_mode != GM_NORMAL) return ES_NOT_HANDLED;
772  extern RailType _last_built_railtype;
773  Window *w = ShowBuildRailToolbar(_last_built_railtype);
774  if (w == nullptr) return ES_NOT_HANDLED;
775  return w->OnHotkey(hotkey);
776 }
777 
778 const uint16 _railtoolbar_autorail_keys[] = {'5', 'A' | WKC_GLOBAL_HOTKEY, 0};
779 
780 static Hotkey railtoolbar_hotkeys[] = {
781  Hotkey('1', "build_ns", WID_RAT_BUILD_NS),
782  Hotkey('2', "build_x", WID_RAT_BUILD_X),
783  Hotkey('3', "build_ew", WID_RAT_BUILD_EW),
784  Hotkey('4', "build_y", WID_RAT_BUILD_Y),
785  Hotkey(_railtoolbar_autorail_keys, "autorail", WID_RAT_AUTORAIL),
786  Hotkey('6', "demolish", WID_RAT_DEMOLISH),
787  Hotkey('7', "depot", WID_RAT_BUILD_DEPOT),
788  Hotkey('8', "waypoint", WID_RAT_BUILD_WAYPOINT),
789  Hotkey('9', "station", WID_RAT_BUILD_STATION),
790  Hotkey('S', "signal", WID_RAT_BUILD_SIGNALS),
791  Hotkey('B', "bridge", WID_RAT_BUILD_BRIDGE),
792  Hotkey('T', "tunnel", WID_RAT_BUILD_TUNNEL),
793  Hotkey('R', "remove", WID_RAT_REMOVE),
794  Hotkey('C', "convert", WID_RAT_CONVERT_RAIL),
795  HOTKEY_LIST_END
796 };
797 HotkeyList BuildRailToolbarWindow::hotkeys("railtoolbar", railtoolbar_hotkeys, RailToolbarGlobalHotkeys);
798 
799 static const NWidgetPart _nested_build_rail_widgets[] = {
801  NWidget(WWT_CLOSEBOX, COLOUR_DARK_GREEN),
802  NWidget(WWT_CAPTION, COLOUR_DARK_GREEN, WID_RAT_CAPTION), SetDataTip(STR_WHITE_STRING, STR_TOOLTIP_WINDOW_TITLE_DRAG_THIS),
803  NWidget(WWT_STICKYBOX, COLOUR_DARK_GREEN),
804  EndContainer(),
806  NWidget(WWT_IMGBTN, COLOUR_DARK_GREEN, WID_RAT_BUILD_NS),
807  SetFill(0, 1), SetMinimalSize(22, 22), SetDataTip(SPR_IMG_RAIL_NS, STR_RAIL_TOOLBAR_TOOLTIP_BUILD_RAILROAD_TRACK),
808  NWidget(WWT_IMGBTN, COLOUR_DARK_GREEN, WID_RAT_BUILD_X),
809  SetFill(0, 1), SetMinimalSize(22, 22), SetDataTip(SPR_IMG_RAIL_NE, STR_RAIL_TOOLBAR_TOOLTIP_BUILD_RAILROAD_TRACK),
810  NWidget(WWT_IMGBTN, COLOUR_DARK_GREEN, WID_RAT_BUILD_EW),
811  SetFill(0, 1), SetMinimalSize(22, 22), SetDataTip(SPR_IMG_RAIL_EW, STR_RAIL_TOOLBAR_TOOLTIP_BUILD_RAILROAD_TRACK),
812  NWidget(WWT_IMGBTN, COLOUR_DARK_GREEN, WID_RAT_BUILD_Y),
813  SetFill(0, 1), SetMinimalSize(22, 22), SetDataTip(SPR_IMG_RAIL_NW, STR_RAIL_TOOLBAR_TOOLTIP_BUILD_RAILROAD_TRACK),
814  NWidget(WWT_IMGBTN, COLOUR_DARK_GREEN, WID_RAT_AUTORAIL),
815  SetFill(0, 1), SetMinimalSize(22, 22), SetDataTip(SPR_IMG_AUTORAIL, STR_RAIL_TOOLBAR_TOOLTIP_BUILD_AUTORAIL),
816 
817  NWidget(WWT_PANEL, COLOUR_DARK_GREEN), SetMinimalSize(4, 22), EndContainer(),
818 
819  NWidget(WWT_IMGBTN, COLOUR_DARK_GREEN, WID_RAT_DEMOLISH),
820  SetFill(0, 1), SetMinimalSize(22, 22), SetDataTip(SPR_IMG_DYNAMITE, STR_TOOLTIP_DEMOLISH_BUILDINGS_ETC),
821  NWidget(WWT_IMGBTN, COLOUR_DARK_GREEN, WID_RAT_BUILD_DEPOT),
822  SetFill(0, 1), SetMinimalSize(22, 22), SetDataTip(SPR_IMG_DEPOT_RAIL, STR_RAIL_TOOLBAR_TOOLTIP_BUILD_TRAIN_DEPOT_FOR_BUILDING),
823  NWidget(WWT_IMGBTN, COLOUR_DARK_GREEN, WID_RAT_BUILD_WAYPOINT),
824  SetFill(0, 1), SetMinimalSize(22, 22), SetDataTip(SPR_IMG_WAYPOINT, STR_RAIL_TOOLBAR_TOOLTIP_CONVERT_RAIL_TO_WAYPOINT),
825  NWidget(WWT_IMGBTN, COLOUR_DARK_GREEN, WID_RAT_BUILD_STATION),
826  SetFill(0, 1), SetMinimalSize(42, 22), SetDataTip(SPR_IMG_RAIL_STATION, STR_RAIL_TOOLBAR_TOOLTIP_BUILD_RAILROAD_STATION),
827  NWidget(WWT_IMGBTN, COLOUR_DARK_GREEN, WID_RAT_BUILD_SIGNALS),
828  SetFill(0, 1), SetMinimalSize(22, 22), SetDataTip(SPR_IMG_RAIL_SIGNALS, STR_RAIL_TOOLBAR_TOOLTIP_BUILD_RAILROAD_SIGNALS),
829  NWidget(WWT_IMGBTN, COLOUR_DARK_GREEN, WID_RAT_BUILD_BRIDGE),
830  SetFill(0, 1), SetMinimalSize(42, 22), SetDataTip(SPR_IMG_BRIDGE, STR_RAIL_TOOLBAR_TOOLTIP_BUILD_RAILROAD_BRIDGE),
831  NWidget(WWT_IMGBTN, COLOUR_DARK_GREEN, WID_RAT_BUILD_TUNNEL),
832  SetFill(0, 1), SetMinimalSize(20, 22), SetDataTip(SPR_IMG_TUNNEL_RAIL, STR_RAIL_TOOLBAR_TOOLTIP_BUILD_RAILROAD_TUNNEL),
833  NWidget(WWT_IMGBTN, COLOUR_DARK_GREEN, WID_RAT_REMOVE),
834  SetFill(0, 1), SetMinimalSize(22, 22), SetDataTip(SPR_IMG_REMOVE, STR_RAIL_TOOLBAR_TOOLTIP_TOGGLE_BUILD_REMOVE_FOR),
835  NWidget(WWT_IMGBTN, COLOUR_DARK_GREEN, WID_RAT_CONVERT_RAIL),
836  SetFill(0, 1), SetMinimalSize(22, 22), SetDataTip(SPR_IMG_CONVERT_RAIL, STR_RAIL_TOOLBAR_TOOLTIP_CONVERT_RAIL),
837  EndContainer(),
838 };
839 
840 static WindowDesc _build_rail_desc(
841  WDP_ALIGN_TOOLBAR, "toolbar_rail", 0, 0,
844  _nested_build_rail_widgets, lengthof(_nested_build_rail_widgets),
845  &BuildRailToolbarWindow::hotkeys
846 );
847 
848 
858 {
859  if (!Company::IsValidID(_local_company)) return nullptr;
860  if (!ValParamRailtype(railtype)) return nullptr;
861 
863  _cur_railtype = railtype;
864  _remove_button_clicked = false;
865  return new BuildRailToolbarWindow(&_build_rail_desc, railtype);
866 }
867 
868 /* TODO: For custom stations, respect their allowed platforms/lengths bitmasks!
869  * --pasky */
870 
871 static void HandleStationPlacement(TileIndex start, TileIndex end)
872 {
873  TileArea ta(start, end);
874  uint numtracks = ta.w;
875  uint platlength = ta.h;
876 
877  if (_railstation.orientation == AXIS_X) Swap(numtracks, platlength);
878 
880  RailType rt = _cur_railtype;
881  bool adjacent = _ctrl_pressed;
882 
883  auto proc = [=](bool test, StationID to_join) -> bool {
884  if (test) {
885  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();
886  } else {
887  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);
888  }
889  };
890 
891  ShowSelectStationIfNeeded(ta, proc);
892 }
893 
897 };
898 
900 private:
901  uint line_height;
905 
907 
908  static const uint EDITBOX_MAX_SIZE = 16;
909 
917 
926  {
927  uint pos = 0;
928  for (auto station_class : this->station_classes) {
929  if (station_class == _railstation.station_class) break;
930  pos++;
931  }
932  this->vscroll->SetCount((int)this->station_classes.size());
933  this->vscroll->ScrollTowards(pos);
934  }
935 
941  void CheckSelectedSize(const StationSpec *statspec)
942  {
943  if (statspec == nullptr || _settings_client.gui.station_dragdrop) return;
944 
945  /* If current number of tracks is not allowed, make it as big as possible */
949  if (statspec->disallowed_platforms != UINT8_MAX) {
952  }
954  }
955  }
956 
960  if (statspec->disallowed_lengths != UINT8_MAX) {
963  }
965  }
966  }
967  }
968 
969 public:
971  {
972  this->coverage_height = 2 * FONT_HEIGHT_NORMAL + 3 * WidgetDimensions::scaled.vsep_normal;
973  this->vscroll = nullptr;
974  _railstation.newstations = newstation;
975 
976  this->CreateNestedTree();
977  NWidgetStacked *newst_additions = this->GetWidget<NWidgetStacked>(WID_BRAS_SHOW_NEWST_ADDITIONS);
978  newst_additions->SetDisplayedPlane(newstation ? 0 : SZSP_NONE);
979  newst_additions = this->GetWidget<NWidgetStacked>(WID_BRAS_SHOW_NEWST_MATRIX);
980  newst_additions->SetDisplayedPlane(newstation ? 0 : SZSP_NONE);
981  newst_additions = this->GetWidget<NWidgetStacked>(WID_BRAS_SHOW_NEWST_DEFSIZE);
982  newst_additions->SetDisplayedPlane(newstation ? 0 : SZSP_NONE);
983  newst_additions = this->GetWidget<NWidgetStacked>(WID_BRAS_SHOW_NEWST_RESIZE);
984  newst_additions->SetDisplayedPlane(newstation ? 0 : SZSP_NONE);
985  /* Hide the station class filter if no stations other than the default one are available. */
986  this->GetWidget<NWidgetStacked>(WID_BRAS_FILTER_CONTAINER)->SetDisplayedPlane(newstation ? 0 : SZSP_NONE);
987  if (newstation) {
988  this->vscroll = this->GetScrollbar(WID_BRAS_NEWST_SCROLL);
989  this->vscroll2 = this->GetScrollbar(WID_BRAS_MATRIX_SCROLL);
990 
992  this->station_classes.SetListing(this->last_sorting);
993  this->station_classes.SetFiltering(this->last_filtering);
994  this->station_classes.SetSortFuncs(this->sorter_funcs);
995  this->station_classes.SetFilterFuncs(this->filter_funcs);
996  }
997 
998  this->station_classes.ForceRebuild();
999 
1002 
1004 
1005  this->LowerWidget(_railstation.orientation + WID_BRAS_PLATFORM_DIR_X);
1008  } else {
1011  }
1014 
1015  if (!newstation) {
1018  this->vscroll2 = nullptr;
1019  } else {
1022 
1023  NWidgetMatrix *matrix = this->GetWidget<NWidgetMatrix>(WID_BRAS_MATRIX);
1024  matrix->SetScrollbar(this->vscroll2);
1027 
1029  }
1030 
1031  this->InvalidateData();
1032  }
1033 
1034  void Close() override
1035  {
1037  this->PickerWindowBase::Close();
1038  }
1039 
1041  static bool StationClassIDSorter(StationClassID const &a, StationClassID const &b)
1042  {
1043  return a < b;
1044  }
1045 
1047  static bool CDECL TagNameFilter(StationClassID const * sc, StringFilter &filter)
1048  {
1049  char buffer[DRAW_STRING_BUFFER];
1050  GetString(buffer, StationClass::Get(*sc)->name, lastof(buffer));
1051 
1052  filter.ResetState();
1053  filter.AddLine(buffer);
1054  return filter.GetState();
1055  }
1056 
1059  {
1060  if (!this->station_classes.NeedRebuild()) return;
1061 
1062  this->station_classes.clear();
1063 
1064  for (uint i = 0; i < StationClass::GetClassCount(); i++) {
1065  StationClassID station_class_id = (StationClassID)i;
1066  if (station_class_id == StationClassID::STAT_CLASS_WAYP) {
1067  // Skip waypoints.
1068  continue;
1069  }
1070  StationClass *station_class = StationClass::Get(station_class_id);
1071  if (station_class->GetUISpecCount() == 0) continue;
1072  station_classes.push_back(station_class_id);
1073  }
1074 
1075  if (_railstation.newstations) {
1076  this->station_classes.Filter(this->string_filter);
1077  this->station_classes.shrink_to_fit();
1078  this->station_classes.RebuildDone();
1079  this->station_classes.Sort();
1080 
1081  this->vscroll->SetCount((uint)this->station_classes.size());
1082  }
1083  }
1084 
1090  {
1092  /* This happens during the first time the window is open during the game life cycle. */
1094  } else {
1095  /* Check if the previously selected station class is not available anymore as a
1096  * result of starting a new game without the corresponding NewGRF. */
1097  bool available = false;
1098  for (uint i = 0; i < StationClass::GetClassCount(); ++i) {
1100  available = true;
1101  break;
1102  }
1103  }
1104 
1106  }
1107  }
1108 
1113  void SelectOtherClass(StationClassID station_class)
1114  {
1115  _railstation.station_class = station_class;
1116  }
1117 
1118  void OnInvalidateData(int data = 0, bool gui_scope = true) override
1119  {
1120  if (!gui_scope) return;
1121 
1123  }
1124 
1125  EventState OnHotkey(int hotkey) override
1126  {
1127  switch (hotkey) {
1130  SetFocusedWindow(this); // The user has asked to give focus to the text box, so make sure this window is focused.
1131  break;
1132 
1133  default:
1134  return ES_NOT_HANDLED;
1135  }
1136 
1137  return ES_HANDLED;
1138  }
1139 
1140  void OnEditboxChanged(int wid) override
1141  {
1142  string_filter.SetFilterTerm(this->filter_editbox.text.buf);
1143  this->station_classes.SetFilterState(!string_filter.IsEmpty());
1144  this->station_classes.ForceRebuild();
1145  this->InvalidateData();
1146  }
1147 
1148  void OnPaint() override
1149  {
1150  bool newstations = _railstation.newstations;
1151  const StationSpec *statspec = newstations ? StationClass::Get(_railstation.station_class)->GetSpec(_railstation.station_type) : nullptr;
1152 
1154  SetTileSelectSize(1, 1);
1155  } else {
1158  if (_railstation.orientation == AXIS_X) Swap(x, y);
1159  if (!_remove_button_clicked) {
1160  SetTileSelectSize(x, y);
1161  }
1162  }
1163 
1165 
1166  if (_settings_client.gui.station_show_coverage) SetTileSelectBigSize(-rad, -rad, 2 * rad, 2 * rad);
1167 
1168  for (uint bits = 0; bits < 7; bits++) {
1169  bool disable = bits >= _settings_game.station.station_spread;
1170  if (statspec == nullptr) {
1171  this->SetWidgetDisabledState(bits + WID_BRAS_PLATFORM_NUM_1, disable);
1172  this->SetWidgetDisabledState(bits + WID_BRAS_PLATFORM_LEN_1, disable);
1173  } else {
1174  this->SetWidgetDisabledState(bits + WID_BRAS_PLATFORM_NUM_1, HasBit(statspec->disallowed_platforms, bits) || disable);
1175  this->SetWidgetDisabledState(bits + WID_BRAS_PLATFORM_LEN_1, HasBit(statspec->disallowed_lengths, bits) || disable);
1176  }
1177  }
1178 
1179  this->DrawWidgets();
1180 
1181  if (this->IsShaded()) return;
1182  /* 'Accepts' and 'Supplies' texts. */
1183  Rect r = this->GetWidget<NWidgetBase>(WID_BRAS_COVERAGE_TEXTS)->GetCurrentRect();
1187  /* Resize background if the window is too small.
1188  * Never make the window smaller to avoid oscillating if the size change affects the acceptance.
1189  * (This is the case, if making the window bigger moves the mouse into the window.) */
1190  if (top > r.bottom) {
1191  this->coverage_height += top - r.bottom;
1192  this->ReInit();
1193  }
1194  }
1195 
1196  void UpdateWidgetSize(int widget, Dimension *size, const Dimension &padding, Dimension *fill, Dimension *resize) override
1197  {
1198  switch (widget) {
1199  case WID_BRAS_NEWST_LIST: {
1200  Dimension d = {0, 0};
1201  for (auto station_class : this->station_classes) {
1202  d = maxdim(d, GetStringBoundingBox(StationClass::Get(station_class)->name));
1203  }
1204  size->width = std::max(size->width, d.width + padding.width);
1205  this->line_height = FONT_HEIGHT_NORMAL + padding.height;
1206  size->height = 5 * this->line_height;
1207  resize->height = this->line_height;
1208  break;
1209  }
1210 
1211  case WID_BRAS_SHOW_NEWST_TYPE: {
1212  if (!_railstation.newstations) {
1213  size->width = 0;
1214  size->height = 0;
1215  break;
1216  }
1217 
1218  /* If newstations exist, compute the non-zero minimal size. */
1219  Dimension d = {0, 0};
1220  StringID str = this->GetWidget<NWidgetCore>(widget)->widget_data;
1221  for (auto station_class : this->station_classes) {
1222  StationClass *stclass = StationClass::Get(station_class);
1223  for (uint j = 0; j < stclass->GetSpecCount(); j++) {
1224  const StationSpec *statspec = stclass->GetSpec(j);
1225  SetDParam(0, (statspec != nullptr && statspec->name != 0) ? statspec->name : STR_STATION_CLASS_DFLT);
1226  d = maxdim(d, GetStringBoundingBox(str));
1227  }
1228  }
1229  size->width = std::max(size->width, d.width + padding.width);
1230  break;
1231  }
1232 
1235  case WID_BRAS_IMAGE:
1238  break;
1239 
1241  size->height = this->coverage_height;
1242  break;
1243 
1244  case WID_BRAS_MATRIX:
1245  fill->height = 1;
1246  resize->height = 1;
1247  break;
1248  }
1249  }
1250 
1251  void DrawWidget(const Rect &r, int widget) const override
1252  {
1253  DrawPixelInfo tmp_dpi;
1254 
1255  switch (GB(widget, 0, 16)) {
1257  /* Set up a clipping area for the '/' station preview */
1258  if (FillDrawPixelInfo(&tmp_dpi, r.left, r.top, r.Width(), r.Height())) {
1259  DrawPixelInfo *old_dpi = _cur_dpi;
1260  _cur_dpi = &tmp_dpi;
1261  int x = (r.Width() - ScaleSpriteTrad(64)) / 2 + ScaleSpriteTrad(31);
1262  int y = (r.Height() + ScaleSpriteTrad(58)) / 2 - ScaleSpriteTrad(31);
1264  StationPickerDrawSprite(x, y, STATION_RAIL, _cur_railtype, INVALID_ROADTYPE, 2);
1265  }
1266  _cur_dpi = old_dpi;
1267  }
1268  break;
1269 
1271  /* Set up a clipping area for the '\' station preview */
1272  if (FillDrawPixelInfo(&tmp_dpi, r.left, r.top, r.Width(), r.Height())) {
1273  DrawPixelInfo *old_dpi = _cur_dpi;
1274  _cur_dpi = &tmp_dpi;
1275  int x = (r.Width() - ScaleSpriteTrad(64)) / 2 + ScaleSpriteTrad(31);
1276  int y = (r.Height() + ScaleSpriteTrad(58)) / 2 - ScaleSpriteTrad(31);
1278  StationPickerDrawSprite(x, y, STATION_RAIL, _cur_railtype, INVALID_ROADTYPE, 3);
1279  }
1280  _cur_dpi = old_dpi;
1281  }
1282  break;
1283 
1284  case WID_BRAS_NEWST_LIST: {
1285  Rect ir = r.Shrink(WidgetDimensions::scaled.matrix);
1286  uint statclass = 0;
1287  for (auto station_class : this->station_classes) {
1288  if (this->vscroll->IsVisible(statclass)) {
1289  DrawString(ir,
1290  StationClass::Get(station_class)->name,
1291  station_class == _railstation.station_class ? TC_WHITE : TC_BLACK);
1292  ir.top += this->line_height;
1293  }
1294  statclass++;
1295  }
1296  break;
1297  }
1298 
1299  case WID_BRAS_IMAGE: {
1300  byte type = GB(widget, 16, 16);
1301  assert(type < _railstation.station_count);
1302  /* Check station availability callback */
1303  const StationSpec *statspec = StationClass::Get(_railstation.station_class)->GetSpec(type);
1304  if (!IsStationAvailable(statspec)) {
1306  }
1307 
1308  /* Set up a clipping area for the station preview. */
1309  if (FillDrawPixelInfo(&tmp_dpi, r.left, r.top, r.Width(), r.Height())) {
1310  DrawPixelInfo *old_dpi = _cur_dpi;
1311  _cur_dpi = &tmp_dpi;
1312  int x = (r.Width() - ScaleSpriteTrad(64)) / 2 + ScaleSpriteTrad(31);
1313  int y = (r.Height() + ScaleSpriteTrad(58)) / 2 - ScaleSpriteTrad(31);
1315  StationPickerDrawSprite(x, y, STATION_RAIL, _cur_railtype, INVALID_ROADTYPE, 2 + _railstation.orientation);
1316  }
1317  _cur_dpi = old_dpi;
1318  }
1319  break;
1320  }
1321  }
1322  }
1323 
1324  void OnResize() override
1325  {
1326  if (this->vscroll != nullptr) { // New stations available.
1327  this->vscroll->SetCapacityFromWidget(this, WID_BRAS_NEWST_LIST);
1328  }
1329  }
1330 
1331  void SetStringParameters(int widget) const override
1332  {
1333  if (widget == WID_BRAS_SHOW_NEWST_TYPE) {
1335  SetDParam(0, (statspec != nullptr && statspec->name != 0) ? statspec->name : STR_STATION_CLASS_DFLT);
1336  }
1337  }
1338 
1339  void OnClick(Point pt, int widget, int click_count) override
1340  {
1341  switch (GB(widget, 0, 16)) {
1344  this->RaiseWidget(_railstation.orientation + WID_BRAS_PLATFORM_DIR_X);
1346  this->LowerWidget(_railstation.orientation + WID_BRAS_PLATFORM_DIR_X);
1347  if (_settings_client.sound.click_beep) SndPlayFx(SND_15_BEEP);
1348  this->SetDirty();
1350  break;
1351 
1358  case WID_BRAS_PLATFORM_NUM_7: {
1361 
1364 
1366 
1368  if (statspec != nullptr && HasBit(statspec->disallowed_lengths, _settings_client.gui.station_platlength - 1)) {
1369  /* The previously selected number of platforms in invalid */
1370  for (uint i = 0; i < 7; i++) {
1371  if (!HasBit(statspec->disallowed_lengths, i)) {
1374  break;
1375  }
1376  }
1377  }
1378 
1379  this->LowerWidget(_settings_client.gui.station_numtracks + WID_BRAS_PLATFORM_NUM_BEGIN);
1381  if (_settings_client.sound.click_beep) SndPlayFx(SND_15_BEEP);
1382  this->SetDirty();
1384  break;
1385  }
1386 
1393  case WID_BRAS_PLATFORM_LEN_7: {
1396 
1399 
1401 
1403  if (statspec != nullptr && HasBit(statspec->disallowed_platforms, _settings_client.gui.station_numtracks - 1)) {
1404  /* The previously selected number of tracks in invalid */
1405  for (uint i = 0; i < 7; i++) {
1406  if (!HasBit(statspec->disallowed_platforms, i)) {
1409  break;
1410  }
1411  }
1412  }
1413 
1415  this->LowerWidget(_settings_client.gui.station_platlength + WID_BRAS_PLATFORM_LEN_BEGIN);
1416  if (_settings_client.sound.click_beep) SndPlayFx(SND_15_BEEP);
1417  this->SetDirty();
1419  break;
1420  }
1421 
1424 
1426 
1427  /* get the first allowed length/number of platforms */
1429  if (statspec != nullptr && HasBit(statspec->disallowed_lengths, _settings_client.gui.station_platlength - 1)) {
1430  for (uint i = 0; i < 7; i++) {
1431  if (!HasBit(statspec->disallowed_lengths, i)) {
1434  break;
1435  }
1436  }
1437  }
1438  if (statspec != nullptr && HasBit(statspec->disallowed_platforms, _settings_client.gui.station_numtracks - 1)) {
1439  for (uint i = 0; i < 7; i++) {
1440  if (!HasBit(statspec->disallowed_platforms, i)) {
1443  break;
1444  }
1445  }
1446  }
1447 
1450  if (_settings_client.sound.click_beep) SndPlayFx(SND_15_BEEP);
1451  this->SetDirty();
1453  break;
1454  }
1455 
1457  case WID_BRAS_HIGHLIGHT_ON:
1459 
1462  if (_settings_client.sound.click_beep) SndPlayFx(SND_15_BEEP);
1463  this->SetDirty();
1464  SetViewportCatchmentStation(nullptr, true);
1465  break;
1466 
1467  case WID_BRAS_NEWST_LIST: {
1468  int y = this->vscroll->GetScrolledRowFromWidget(pt.y, this, WID_BRAS_NEWST_LIST);
1469  if (y >= (int)this->station_classes.size()) return;
1470  StationClassID station_class_id = this->station_classes[y];
1471  if (_railstation.station_class != station_class_id) {
1472  StationClass *station_class = StationClass::Get(station_class_id);
1473  _railstation.station_class = station_class_id;
1474  _railstation.station_count = station_class->GetSpecCount();
1476 
1477  this->CheckSelectedSize(station_class->GetSpec(_railstation.station_type));
1478 
1479  NWidgetMatrix *matrix = this->GetWidget<NWidgetMatrix>(WID_BRAS_MATRIX);
1482  }
1483  if (_settings_client.sound.click_beep) SndPlayFx(SND_15_BEEP);
1484  this->SetDirty();
1486  break;
1487  }
1488 
1489  case WID_BRAS_IMAGE: {
1490  int y = GB(widget, 16, 16);
1491  if (y >= _railstation.station_count) return;
1492 
1493  /* Check station availability callback */
1494  const StationSpec *statspec = StationClass::Get(_railstation.station_class)->GetSpec(y);
1495  if (!IsStationAvailable(statspec)) return;
1496 
1498 
1499  this->CheckSelectedSize(statspec);
1500  this->GetWidget<NWidgetMatrix>(WID_BRAS_MATRIX)->SetClicked(_railstation.station_type);
1501 
1502  if (_settings_client.sound.click_beep) SndPlayFx(SND_15_BEEP);
1503  this->SetDirty();
1505  break;
1506  }
1507  }
1508  }
1509 
1510  void OnRealtimeTick(uint delta_ms) override
1511  {
1513  }
1514 
1515  static HotkeyList hotkeys;
1516 };
1517 
1524 {
1525  if (_game_mode == GM_MENU) return ES_NOT_HANDLED;
1527  if (w == nullptr) return ES_NOT_HANDLED;
1528  return w->OnHotkey(hotkey);
1529 }
1530 
1531 static Hotkey buildrailstation_hotkeys[] = {
1532  Hotkey('F', "focus_filter_box", BRASHK_FOCUS_FILTER_BOX),
1533  HOTKEY_LIST_END
1534 };
1535 HotkeyList BuildRailStationWindow::hotkeys("buildrailstation", buildrailstation_hotkeys, BuildRailStationGlobalHotkeys);
1536 
1539 
1541  &StationClassIDSorter,
1542 };
1543 
1545  &TagNameFilter,
1546 };
1547 
1548 static const NWidgetPart _nested_station_builder_widgets[] = {
1550  NWidget(WWT_CLOSEBOX, COLOUR_DARK_GREEN),
1551  NWidget(WWT_CAPTION, COLOUR_DARK_GREEN), SetDataTip(STR_STATION_BUILD_RAIL_CAPTION, STR_TOOLTIP_WINDOW_TITLE_DRAG_THIS),
1552  NWidget(WWT_SHADEBOX, COLOUR_DARK_GREEN),
1554  NWidget(WWT_DEFSIZEBOX, COLOUR_DARK_GREEN),
1555  EndContainer(),
1556  EndContainer(),
1557  NWidget(WWT_PANEL, COLOUR_DARK_GREEN),
1558  NWidget(NWID_HORIZONTAL), SetPadding(2, 0, 0, 2),
1561  NWidget(NWID_HORIZONTAL), SetPadding(0, 5, 2, 0),
1562  NWidget(WWT_TEXT, COLOUR_DARK_GREEN), SetFill(0, 1), SetDataTip(STR_LIST_FILTER_TITLE, STR_NULL),
1563  NWidget(WWT_EDITBOX, COLOUR_GREY, WID_BRAS_FILTER_EDITBOX), SetFill(1, 0), SetResize(1, 0),
1564  SetDataTip(STR_LIST_FILTER_OSKTITLE, STR_LIST_FILTER_TOOLTIP),
1565  EndContainer(),
1566  EndContainer(),
1568  NWidget(NWID_HORIZONTAL), SetPadding(0, 5, 2, 0),
1569  NWidget(WWT_MATRIX, COLOUR_GREY, WID_BRAS_NEWST_LIST), SetMinimalSize(122, 71), SetFill(1, 0),
1570  SetMatrixDataTip(1, 0, STR_STATION_BUILD_STATION_CLASS_TOOLTIP), SetScrollbar(WID_BRAS_NEWST_SCROLL),
1572  EndContainer(),
1573  EndContainer(),
1574  NWidget(WWT_LABEL, COLOUR_DARK_GREEN), SetMinimalSize(144, 11), SetDataTip(STR_STATION_BUILD_ORIENTATION, STR_NULL), SetPadding(1, 2, 0, 0),
1576  NWidget(NWID_SPACER), SetMinimalSize(7, 0), SetFill(1, 0),
1577  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(),
1578  NWidget(NWID_SPACER), SetMinimalSize(2, 0), SetFill(1, 0),
1579  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(),
1580  NWidget(NWID_SPACER), SetMinimalSize(7, 0), SetFill(1, 0),
1581  EndContainer(),
1582  NWidget(WWT_LABEL, COLOUR_DARK_GREEN, WID_BRAS_SHOW_NEWST_TYPE), SetMinimalSize(144, 11), SetDataTip(STR_ORANGE_STRING, STR_NULL), SetPadding(1, 2, 4, 2),
1583  NWidget(WWT_LABEL, COLOUR_DARK_GREEN), SetMinimalSize(144, 11), SetDataTip(STR_STATION_BUILD_NUMBER_OF_TRACKS, STR_NULL), SetPadding(0, 2, 0, 2),
1585  NWidget(NWID_SPACER), SetFill(1, 0),
1586  NWidget(WWT_TEXTBTN, COLOUR_GREY, WID_BRAS_PLATFORM_NUM_1), SetMinimalSize(15, 12), SetDataTip(STR_BLACK_1, STR_STATION_BUILD_NUMBER_OF_TRACKS_TOOLTIP),
1587  NWidget(WWT_TEXTBTN, COLOUR_GREY, WID_BRAS_PLATFORM_NUM_2), SetMinimalSize(15, 12), SetDataTip(STR_BLACK_2, STR_STATION_BUILD_NUMBER_OF_TRACKS_TOOLTIP),
1588  NWidget(WWT_TEXTBTN, COLOUR_GREY, WID_BRAS_PLATFORM_NUM_3), SetMinimalSize(15, 12), SetDataTip(STR_BLACK_3, STR_STATION_BUILD_NUMBER_OF_TRACKS_TOOLTIP),
1589  NWidget(WWT_TEXTBTN, COLOUR_GREY, WID_BRAS_PLATFORM_NUM_4), SetMinimalSize(15, 12), SetDataTip(STR_BLACK_4, STR_STATION_BUILD_NUMBER_OF_TRACKS_TOOLTIP),
1590  NWidget(WWT_TEXTBTN, COLOUR_GREY, WID_BRAS_PLATFORM_NUM_5), SetMinimalSize(15, 12), SetDataTip(STR_BLACK_5, STR_STATION_BUILD_NUMBER_OF_TRACKS_TOOLTIP),
1591  NWidget(WWT_TEXTBTN, COLOUR_GREY, WID_BRAS_PLATFORM_NUM_6), SetMinimalSize(15, 12), SetDataTip(STR_BLACK_6, STR_STATION_BUILD_NUMBER_OF_TRACKS_TOOLTIP),
1592  NWidget(WWT_TEXTBTN, COLOUR_GREY, WID_BRAS_PLATFORM_NUM_7), SetMinimalSize(15, 12), SetDataTip(STR_BLACK_7, STR_STATION_BUILD_NUMBER_OF_TRACKS_TOOLTIP),
1593  NWidget(NWID_SPACER), SetFill(1, 0),
1594  EndContainer(),
1595  NWidget(WWT_LABEL, COLOUR_DARK_GREEN), SetMinimalSize(144, 11), SetDataTip(STR_STATION_BUILD_PLATFORM_LENGTH, STR_NULL), SetPadding(2, 2, 0, 2),
1597  NWidget(NWID_SPACER), SetFill(1, 0),
1598  NWidget(WWT_TEXTBTN, COLOUR_GREY, WID_BRAS_PLATFORM_LEN_1), SetMinimalSize(15, 12), SetDataTip(STR_BLACK_1, STR_STATION_BUILD_PLATFORM_LENGTH_TOOLTIP),
1599  NWidget(WWT_TEXTBTN, COLOUR_GREY, WID_BRAS_PLATFORM_LEN_2), SetMinimalSize(15, 12), SetDataTip(STR_BLACK_2, STR_STATION_BUILD_PLATFORM_LENGTH_TOOLTIP),
1600  NWidget(WWT_TEXTBTN, COLOUR_GREY, WID_BRAS_PLATFORM_LEN_3), SetMinimalSize(15, 12), SetDataTip(STR_BLACK_3, STR_STATION_BUILD_PLATFORM_LENGTH_TOOLTIP),
1601  NWidget(WWT_TEXTBTN, COLOUR_GREY, WID_BRAS_PLATFORM_LEN_4), SetMinimalSize(15, 12), SetDataTip(STR_BLACK_4, STR_STATION_BUILD_PLATFORM_LENGTH_TOOLTIP),
1602  NWidget(WWT_TEXTBTN, COLOUR_GREY, WID_BRAS_PLATFORM_LEN_5), SetMinimalSize(15, 12), SetDataTip(STR_BLACK_5, STR_STATION_BUILD_PLATFORM_LENGTH_TOOLTIP),
1603  NWidget(WWT_TEXTBTN, COLOUR_GREY, WID_BRAS_PLATFORM_LEN_6), SetMinimalSize(15, 12), SetDataTip(STR_BLACK_6, STR_STATION_BUILD_PLATFORM_LENGTH_TOOLTIP),
1604  NWidget(WWT_TEXTBTN, COLOUR_GREY, WID_BRAS_PLATFORM_LEN_7), SetMinimalSize(15, 12), SetDataTip(STR_BLACK_7, STR_STATION_BUILD_PLATFORM_LENGTH_TOOLTIP),
1605  NWidget(NWID_SPACER), SetFill(1, 0),
1606  EndContainer(),
1609  NWidget(NWID_SPACER), SetMinimalSize(2, 0), SetFill(1, 0),
1610  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),
1611  NWidget(NWID_SPACER), SetMinimalSize(2, 0), SetFill(1, 0),
1612  EndContainer(),
1613  NWidget(WWT_LABEL, COLOUR_DARK_GREEN), SetDataTip(STR_STATION_BUILD_COVERAGE_AREA_TITLE, STR_NULL), SetPadding(WidgetDimensions::unscaled.framerect), SetFill(1, 0),
1615  NWidget(NWID_SPACER), SetMinimalSize(2, 0), SetFill(1, 0),
1616  NWidget(WWT_TEXTBTN, COLOUR_GREY, WID_BRAS_HIGHLIGHT_OFF), SetMinimalSize(60, 12),
1617  SetDataTip(STR_STATION_BUILD_COVERAGE_OFF, STR_STATION_BUILD_COVERAGE_AREA_OFF_TOOLTIP),
1618  NWidget(WWT_TEXTBTN, COLOUR_GREY, WID_BRAS_HIGHLIGHT_ON), SetMinimalSize(60, 12),
1619  SetDataTip(STR_STATION_BUILD_COVERAGE_ON, STR_STATION_BUILD_COVERAGE_AREA_ON_TOOLTIP),
1620  NWidget(NWID_SPACER), SetMinimalSize(2, 0), SetFill(1, 0),
1621  EndContainer(),
1622  EndContainer(),
1624  /* We need an additional background for the matrix, as the matrix cannot handle the scrollbar due to not being an NWidgetCore. */
1625  NWidget(WWT_PANEL, COLOUR_DARK_GREEN), SetScrollbar(WID_BRAS_MATRIX_SCROLL),
1628  NWidget(WWT_PANEL, COLOUR_DARK_GREEN, WID_BRAS_IMAGE), SetMinimalSize(66, 60),
1629  SetFill(0, 0), SetResize(0, 0), SetDataTip(0x0, STR_STATION_BUILD_STATION_TYPE_TOOLTIP), SetScrollbar(WID_BRAS_MATRIX_SCROLL),
1630  EndContainer(),
1631  EndContainer(),
1632  NWidget(NWID_VSCROLLBAR, COLOUR_DARK_GREEN, WID_BRAS_MATRIX_SCROLL),
1633  EndContainer(),
1634  EndContainer(),
1635  EndContainer(),
1636  EndContainer(),
1641  NWidget(WWT_PANEL, COLOUR_DARK_GREEN), SetFill(0, 1), EndContainer(),
1642  NWidget(WWT_RESIZEBOX, COLOUR_DARK_GREEN),
1643  EndContainer(),
1644  EndContainer(),
1645  EndContainer(),
1646  EndContainer(),
1647 };
1648 
1651  WDP_AUTO, "build_station_rail", 350, 0,
1654  _nested_station_builder_widgets, lengthof(_nested_station_builder_widgets),
1655  &BuildRailStationWindow::hotkeys
1656 );
1657 
1660 {
1661  bool newstations = StationClass::GetClassCount() > 2 || StationClass::Get(STAT_CLASS_DFLT)->GetSpecCount() != 1;
1662  return new BuildRailStationWindow(&_station_builder_desc, parent, newstations);
1663 }
1664 
1666 private:
1669 
1677  void DrawSignalSprite(const Rect &r, int widget_index, SpriteID image) const
1678  {
1679  Point offset;
1680  Dimension sprite_size = GetSpriteSize(image, &offset);
1681  Rect ir = r.Shrink(WidgetDimensions::scaled.imgbtn);
1682  int x = CenterBounds(ir.left, ir.right, sprite_size.width - offset.x) - offset.x; // centered
1683  int y = ir.top - sig_sprite_bottom_offset +
1684  (ir.Height() + sig_sprite_size.height) / 2; // aligned to bottom
1685 
1686  DrawSprite(image, PAL_NONE,
1687  x + this->IsWidgetLowered(widget_index),
1688  y + this->IsWidgetLowered(widget_index));
1689  }
1690 
1693  {
1694  bool show_non_path_signals = (_settings_client.gui.signal_gui_mode == SIGNAL_GUI_ALL);
1695 
1696  this->GetWidget<NWidgetStacked>(WID_BS_SEMAPHORE_NORM_SEL)->SetDisplayedPlane(show_non_path_signals ? 0 : SZSP_NONE);
1697  this->GetWidget<NWidgetStacked>(WID_BS_ELECTRIC_NORM_SEL)->SetDisplayedPlane(show_non_path_signals ? 0 : SZSP_NONE);
1698  this->GetWidget<NWidgetStacked>(WID_BS_SEMAPHORE_ENTRY_SEL)->SetDisplayedPlane(show_non_path_signals ? 0 : SZSP_NONE);
1699  this->GetWidget<NWidgetStacked>(WID_BS_ELECTRIC_ENTRY_SEL)->SetDisplayedPlane(show_non_path_signals ? 0 : SZSP_NONE);
1700  this->GetWidget<NWidgetStacked>(WID_BS_SEMAPHORE_EXIT_SEL)->SetDisplayedPlane(show_non_path_signals ? 0 : SZSP_NONE);
1701  this->GetWidget<NWidgetStacked>(WID_BS_ELECTRIC_EXIT_SEL)->SetDisplayedPlane(show_non_path_signals ? 0 : SZSP_NONE);
1702  this->GetWidget<NWidgetStacked>(WID_BS_SEMAPHORE_COMBO_SEL)->SetDisplayedPlane(show_non_path_signals ? 0 : SZSP_NONE);
1703  this->GetWidget<NWidgetStacked>(WID_BS_ELECTRIC_COMBO_SEL)->SetDisplayedPlane(show_non_path_signals ? 0 : SZSP_NONE);
1704  }
1705 
1706 public:
1708  {
1709  this->CreateNestedTree();
1710  this->SetSignalUIMode();
1712  this->OnInvalidateData();
1713  }
1714 
1715  void Close() override
1716  {
1717  _convert_signal_button = false;
1718  this->PickerWindowBase::Close();
1719  }
1720 
1721  void OnInit() override
1722  {
1723  /* Calculate maximum signal sprite size. */
1724  this->sig_sprite_size.width = 0;
1725  this->sig_sprite_size.height = 0;
1726  this->sig_sprite_bottom_offset = 0;
1728  for (uint type = SIGTYPE_NORMAL; type < SIGTYPE_END; type++) {
1729  for (uint variant = SIG_ELECTRIC; variant <= SIG_SEMAPHORE; variant++) {
1730  for (uint lowered = 0; lowered < 2; lowered++) {
1731  Point offset;
1732  Dimension sprite_size = GetSpriteSize(rti->gui_sprites.signals[type][variant][lowered], &offset);
1733  this->sig_sprite_bottom_offset = std::max<int>(this->sig_sprite_bottom_offset, sprite_size.height);
1734  this->sig_sprite_size.width = std::max<int>(this->sig_sprite_size.width, sprite_size.width - offset.x);
1735  this->sig_sprite_size.height = std::max<int>(this->sig_sprite_size.height, sprite_size.height - offset.y);
1736  }
1737  }
1738  }
1739  }
1740 
1741  void UpdateWidgetSize(int widget, Dimension *size, const Dimension &padding, Dimension *fill, Dimension *resize) override
1742  {
1743  if (widget == WID_BS_DRAG_SIGNALS_DENSITY_LABEL) {
1744  /* Two digits for signals density. */
1745  size->width = std::max(size->width, 2 * GetDigitWidth() + padding.width + WidgetDimensions::scaled.framerect.Horizontal());
1746  } else if (IsInsideMM(widget, WID_BS_SEMAPHORE_NORM, WID_BS_ELECTRIC_PBS_OWAY + 1)) {
1747  size->width = std::max(size->width, this->sig_sprite_size.width + padding.width);
1748  size->height = std::max(size->height, this->sig_sprite_size.height + padding.height);
1749  } else if (widget == WID_BS_CAPTION) {
1751  }
1752  }
1753 
1754  void SetStringParameters(int widget) const override
1755  {
1756  switch (widget) {
1759  break;
1760  }
1761  }
1762 
1763  void DrawWidget(const Rect &r, int widget) const override
1764  {
1766  /* Extract signal from widget number. */
1767  int type = (widget - WID_BS_SEMAPHORE_NORM) % SIGTYPE_END;
1768  int var = SIG_SEMAPHORE - (widget - WID_BS_SEMAPHORE_NORM) / SIGTYPE_END; // SignalVariant order is reversed compared to the widgets.
1769  SpriteID sprite = GetRailTypeInfo(_cur_railtype)->gui_sprites.signals[type][var][this->IsWidgetLowered(widget)];
1770 
1771  this->DrawSignalSprite(r, widget, sprite);
1772  }
1773  }
1774 
1775  void OnClick(Point pt, int widget, int click_count) override
1776  {
1777  switch (widget) {
1778  case WID_BS_SEMAPHORE_NORM:
1780  case WID_BS_SEMAPHORE_EXIT:
1782  case WID_BS_SEMAPHORE_PBS:
1784  case WID_BS_ELECTRIC_NORM:
1785  case WID_BS_ELECTRIC_ENTRY:
1786  case WID_BS_ELECTRIC_EXIT:
1787  case WID_BS_ELECTRIC_COMBO:
1788  case WID_BS_ELECTRIC_PBS:
1791 
1792  _cur_signal_type = (SignalType)((uint)((widget - WID_BS_SEMAPHORE_NORM) % (SIGTYPE_LAST + 1)));
1794 
1795  /* Update default (last-used) signal type in config file. */
1797 
1798  /* If 'remove' button of rail build toolbar is active, disable it. */
1799  if (_remove_button_clicked) {
1801  if (w != nullptr) ToggleRailButton_Remove(w);
1802  }
1803 
1804  break;
1805 
1806  case WID_BS_CONVERT:
1808  break;
1809 
1814  }
1815  break;
1816 
1821  }
1822  break;
1823 
1824  case WID_BS_TOGGLE_SIZE:
1826  this->SetSignalUIMode();
1827  this->ReInit();
1828  break;
1829 
1830  default: break;
1831  }
1832 
1833  this->InvalidateData();
1834  }
1835 
1841  void OnInvalidateData(int data = 0, bool gui_scope = true) override
1842  {
1843  if (!gui_scope) return;
1845 
1847 
1850  }
1851 };
1852 
1856  NWidget(WWT_CLOSEBOX, COLOUR_DARK_GREEN),
1857  NWidget(WWT_CAPTION, COLOUR_DARK_GREEN, WID_BS_CAPTION), SetDataTip(STR_BUILD_SIGNAL_CAPTION, STR_TOOLTIP_WINDOW_TITLE_DRAG_THIS),
1858  NWidget(WWT_IMGBTN, COLOUR_DARK_GREEN, WID_BS_TOGGLE_SIZE), SetDataTip(SPR_LARGE_SMALL_WINDOW, STR_BUILD_SIGNAL_TOGGLE_ADVANCED_SIGNAL_TOOLTIP),
1859  EndContainer(),
1863  NWidget(WWT_PANEL, COLOUR_DARK_GREEN, WID_BS_SEMAPHORE_NORM), SetDataTip(STR_NULL, STR_BUILD_SIGNAL_SEMAPHORE_NORM_TOOLTIP), EndContainer(), SetFill(1, 1),
1864  EndContainer(),
1866  NWidget(WWT_PANEL, COLOUR_DARK_GREEN, WID_BS_SEMAPHORE_ENTRY), SetDataTip(STR_NULL, STR_BUILD_SIGNAL_SEMAPHORE_ENTRY_TOOLTIP), EndContainer(), SetFill(1, 1),
1867  EndContainer(),
1869  NWidget(WWT_PANEL, COLOUR_DARK_GREEN, WID_BS_SEMAPHORE_EXIT), SetDataTip(STR_NULL, STR_BUILD_SIGNAL_SEMAPHORE_EXIT_TOOLTIP), EndContainer(), SetFill(1, 1),
1870  EndContainer(),
1872  NWidget(WWT_PANEL, COLOUR_DARK_GREEN, WID_BS_SEMAPHORE_COMBO), SetDataTip(STR_NULL, STR_BUILD_SIGNAL_SEMAPHORE_COMBO_TOOLTIP), EndContainer(), SetFill(1, 1),
1873  EndContainer(),
1874  NWidget(WWT_PANEL, COLOUR_DARK_GREEN, WID_BS_SEMAPHORE_PBS), SetDataTip(STR_NULL, STR_BUILD_SIGNAL_SEMAPHORE_PBS_TOOLTIP), EndContainer(), SetFill(1, 1),
1875  NWidget(WWT_PANEL, COLOUR_DARK_GREEN, WID_BS_SEMAPHORE_PBS_OWAY), SetDataTip(STR_NULL, STR_BUILD_SIGNAL_SEMAPHORE_PBS_OWAY_TOOLTIP), EndContainer(), SetFill(1, 1),
1876  NWidget(WWT_IMGBTN, COLOUR_DARK_GREEN, WID_BS_CONVERT), SetDataTip(SPR_IMG_SIGNAL_CONVERT, STR_BUILD_SIGNAL_CONVERT_TOOLTIP), SetFill(1, 1),
1877  EndContainer(),
1880  NWidget(WWT_PANEL, COLOUR_DARK_GREEN, WID_BS_ELECTRIC_NORM), SetDataTip(STR_NULL, STR_BUILD_SIGNAL_ELECTRIC_NORM_TOOLTIP), EndContainer(), SetFill(1, 1),
1881  EndContainer(),
1883  NWidget(WWT_PANEL, COLOUR_DARK_GREEN, WID_BS_ELECTRIC_ENTRY), SetDataTip(STR_NULL, STR_BUILD_SIGNAL_ELECTRIC_ENTRY_TOOLTIP), EndContainer(), SetFill(1, 1),
1884  EndContainer(),
1886  NWidget(WWT_PANEL, COLOUR_DARK_GREEN, WID_BS_ELECTRIC_EXIT), SetDataTip(STR_NULL, STR_BUILD_SIGNAL_ELECTRIC_EXIT_TOOLTIP), EndContainer(), SetFill(1, 1),
1887  EndContainer(),
1889  NWidget(WWT_PANEL, COLOUR_DARK_GREEN, WID_BS_ELECTRIC_COMBO), SetDataTip(STR_NULL, STR_BUILD_SIGNAL_ELECTRIC_COMBO_TOOLTIP), EndContainer(), SetFill(1, 1),
1890  EndContainer(),
1891  NWidget(WWT_PANEL, COLOUR_DARK_GREEN, WID_BS_ELECTRIC_PBS), SetDataTip(STR_NULL, STR_BUILD_SIGNAL_ELECTRIC_PBS_TOOLTIP), EndContainer(), SetFill(1, 1),
1892  NWidget(WWT_PANEL, COLOUR_DARK_GREEN, WID_BS_ELECTRIC_PBS_OWAY), SetDataTip(STR_NULL, STR_BUILD_SIGNAL_ELECTRIC_PBS_OWAY_TOOLTIP), EndContainer(), SetFill(1, 1),
1893  NWidget(WWT_PANEL, COLOUR_DARK_GREEN), SetDataTip(STR_NULL, STR_BUILD_SIGNAL_DRAG_SIGNALS_DENSITY_TOOLTIP), SetFill(1, 1),
1894  NWidget(WWT_LABEL, COLOUR_DARK_GREEN, WID_BS_DRAG_SIGNALS_DENSITY_LABEL), SetDataTip(STR_ORANGE_INT, STR_BUILD_SIGNAL_DRAG_SIGNALS_DENSITY_TOOLTIP), SetFill(1, 1),
1895  NWidget(NWID_HORIZONTAL), SetPIP(2, 0, 2),
1896  NWidget(NWID_SPACER), SetFill(1, 0),
1897  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),
1898  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),
1899  NWidget(NWID_SPACER), SetFill(1, 0),
1900  EndContainer(),
1901  NWidget(NWID_SPACER), SetMinimalSize(0, 2), SetFill(1, 0),
1902  EndContainer(),
1903  EndContainer(),
1904  EndContainer(),
1905 };
1906 
1909  WDP_AUTO, "build_signal", 0, 0,
1913 );
1914 
1918 static void ShowSignalBuilder(Window *parent)
1919 {
1921 }
1922 
1925  {
1926  this->InitNested(TRANSPORT_RAIL);
1928  }
1929 
1930  void UpdateWidgetSize(int widget, Dimension *size, const Dimension &padding, Dimension *fill, Dimension *resize) override
1931  {
1932  if (!IsInsideMM(widget, WID_BRAD_DEPOT_NE, WID_BRAD_DEPOT_NW + 1)) return;
1933 
1936  }
1937 
1938  void DrawWidget(const Rect &r, int widget) const override
1939  {
1940  if (!IsInsideMM(widget, WID_BRAD_DEPOT_NE, WID_BRAD_DEPOT_NW + 1)) return;
1941 
1942  DrawPixelInfo tmp_dpi;
1943  if (FillDrawPixelInfo(&tmp_dpi, r.left, r.top, r.Width(), r.Height())) {
1944  DrawPixelInfo *old_dpi = _cur_dpi;
1945  _cur_dpi = &tmp_dpi;
1946  int x = (r.Width() - ScaleSpriteTrad(64)) / 2 + ScaleSpriteTrad(31);
1947  int y = (r.Height() + ScaleSpriteTrad(48)) / 2 - ScaleSpriteTrad(31);
1948  DrawTrainDepotSprite(x, y, widget - WID_BRAD_DEPOT_NE + DIAGDIR_NE, _cur_railtype);
1949  _cur_dpi = old_dpi;
1950  }
1951  }
1952 
1953  void OnClick(Point pt, int widget, int click_count) override
1954  {
1955  switch (widget) {
1956  case WID_BRAD_DEPOT_NE:
1957  case WID_BRAD_DEPOT_SE:
1958  case WID_BRAD_DEPOT_SW:
1959  case WID_BRAD_DEPOT_NW:
1963  if (_settings_client.sound.click_beep) SndPlayFx(SND_15_BEEP);
1964  this->SetDirty();
1965  break;
1966  }
1967  }
1968 };
1969 
1973  NWidget(WWT_CLOSEBOX, COLOUR_DARK_GREEN),
1974  NWidget(WWT_CAPTION, COLOUR_DARK_GREEN), SetDataTip(STR_BUILD_DEPOT_TRAIN_ORIENTATION_CAPTION, STR_TOOLTIP_WINDOW_TITLE_DRAG_THIS),
1975  EndContainer(),
1976  NWidget(WWT_PANEL, COLOUR_DARK_GREEN),
1979  NWidget(NWID_SPACER), SetMinimalSize(3, 0), SetFill(1, 0),
1981  NWidget(WWT_PANEL, COLOUR_GREY, WID_BRAD_DEPOT_NW), SetMinimalSize(66, 50), SetDataTip(0x0, STR_BUILD_DEPOT_TRAIN_ORIENTATION_TOOLTIP),
1982  EndContainer(),
1984  NWidget(WWT_PANEL, COLOUR_GREY, WID_BRAD_DEPOT_SW), SetMinimalSize(66, 50), SetDataTip(0x0, STR_BUILD_DEPOT_TRAIN_ORIENTATION_TOOLTIP),
1985  EndContainer(),
1986  EndContainer(),
1989  NWidget(WWT_PANEL, COLOUR_GREY, WID_BRAD_DEPOT_NE), SetMinimalSize(66, 50), SetDataTip(0x0, STR_BUILD_DEPOT_TRAIN_ORIENTATION_TOOLTIP),
1990  EndContainer(),
1992  NWidget(WWT_PANEL, COLOUR_GREY, WID_BRAD_DEPOT_SE), SetMinimalSize(66, 50), SetDataTip(0x0, STR_BUILD_DEPOT_TRAIN_ORIENTATION_TOOLTIP),
1993  EndContainer(),
1994  EndContainer(),
1995  NWidget(NWID_SPACER), SetMinimalSize(3, 0), SetFill(1, 0),
1996  EndContainer(),
1998  EndContainer(),
1999 };
2000 
2001 static WindowDesc _build_depot_desc(
2002  WDP_AUTO, nullptr, 0, 0,
2006 );
2007 
2008 static void ShowBuildTrainDepotPicker(Window *parent)
2009 {
2010  new BuildRailDepotWindow(&_build_depot_desc, parent);
2011 }
2012 
2015  {
2016  this->CreateNestedTree();
2017 
2018  NWidgetMatrix *matrix = this->GetWidget<NWidgetMatrix>(WID_BRW_WAYPOINT_MATRIX);
2019  matrix->SetScrollbar(this->GetScrollbar(WID_BRW_SCROLL));
2020 
2022 
2023  matrix->SetCount(_waypoint_count);
2025  matrix->SetClicked(_cur_waypoint_type);
2026  }
2027 
2028  void Close() override
2029  {
2031  this->PickerWindowBase::Close();
2032  }
2033 
2034  void UpdateWidgetSize(int widget, Dimension *size, const Dimension &padding, Dimension *fill, Dimension *resize) override
2035  {
2036  switch (widget) {
2038  /* Three blobs high and wide. */
2039  size->width += resize->width * 2;
2040  size->height += resize->height * 2;
2041 
2042  /* Resizing in X direction only at blob size, but at pixel level in Y. */
2043  resize->height = 1;
2044  break;
2045 
2046  case WID_BRW_WAYPOINT:
2049  break;
2050  }
2051  }
2052 
2053  void DrawWidget(const Rect &r, int widget) const override
2054  {
2055  switch (GB(widget, 0, 16)) {
2056  case WID_BRW_WAYPOINT: {
2057  byte type = GB(widget, 16, 16);
2058  const StationSpec *statspec = StationClass::Get(STAT_CLASS_WAYP)->GetSpec(type);
2059 
2060  DrawPixelInfo tmp_dpi;
2061  if (FillDrawPixelInfo(&tmp_dpi, r.left, r.top, r.Width(), r.Height())) {
2062  DrawPixelInfo *old_dpi = _cur_dpi;
2063  _cur_dpi = &tmp_dpi;
2064  int x = (r.Width() - ScaleSpriteTrad(64)) / 2 + ScaleSpriteTrad(31);
2065  int y = (r.Height() + ScaleSpriteTrad(58)) / 2 - ScaleSpriteTrad(31);
2066  DrawWaypointSprite(x, y, type, _cur_railtype);
2067  _cur_dpi = old_dpi;
2068  }
2069 
2070  if (!IsStationAvailable(statspec)) {
2072  }
2073  }
2074  }
2075  }
2076 
2077  void OnClick(Point pt, int widget, int click_count) override
2078  {
2079  switch (GB(widget, 0, 16)) {
2080  case WID_BRW_WAYPOINT: {
2081  byte type = GB(widget, 16, 16);
2082  this->GetWidget<NWidgetMatrix>(WID_BRW_WAYPOINT_MATRIX)->SetClicked(_cur_waypoint_type);
2083 
2084  /* Check station availability callback */
2085  const StationSpec *statspec = StationClass::Get(STAT_CLASS_WAYP)->GetSpec(type);
2086  if (!IsStationAvailable(statspec)) return;
2087 
2088  _cur_waypoint_type = type;
2089  this->GetWidget<NWidgetMatrix>(WID_BRW_WAYPOINT_MATRIX)->SetClicked(_cur_waypoint_type);
2090  if (_settings_client.sound.click_beep) SndPlayFx(SND_15_BEEP);
2091  this->SetDirty();
2092  break;
2093  }
2094  }
2095  }
2096 };
2097 
2101  NWidget(WWT_CLOSEBOX, COLOUR_DARK_GREEN),
2102  NWidget(WWT_CAPTION, COLOUR_DARK_GREEN), SetDataTip(STR_WAYPOINT_CAPTION, STR_TOOLTIP_WINDOW_TITLE_DRAG_THIS),
2103  NWidget(WWT_DEFSIZEBOX, COLOUR_DARK_GREEN),
2104  EndContainer(),
2106  NWidget(WWT_PANEL, COLOUR_DARK_GREEN),
2108  NWidget(WWT_PANEL, COLOUR_DARK_GREEN, WID_BRW_WAYPOINT), SetMinimalSize(66, 60), SetDataTip(0x0, STR_WAYPOINT_GRAPHICS_TOOLTIP), SetScrollbar(WID_BRW_SCROLL), EndContainer(),
2109  EndContainer(),
2110  EndContainer(),
2112  NWidget(NWID_VSCROLLBAR, COLOUR_DARK_GREEN, WID_BRW_SCROLL),
2113  NWidget(WWT_RESIZEBOX, COLOUR_DARK_GREEN),
2114  EndContainer(),
2115  EndContainer(),
2116 };
2117 
2118 static WindowDesc _build_waypoint_desc(
2119  WDP_AUTO, "build_waypoint", 0, 0,
2123 );
2124 
2125 static void ShowBuildWaypointPicker(Window *parent)
2126 {
2127  new BuildRailWaypointWindow(&_build_waypoint_desc, parent);
2128 }
2129 
2134 {
2137 }
2138 
2143 void ReinitGuiAfterToggleElrail(bool disable)
2144 {
2145  extern RailType _last_built_railtype;
2146  if (disable && _last_built_railtype == RAILTYPE_ELECTRIC) {
2147  _last_built_railtype = _cur_railtype = RAILTYPE_RAIL;
2149  if (w != nullptr) w->ModifyRailType(_cur_railtype);
2150  }
2152 }
2153 
2155 static void SetDefaultRailGui()
2156 {
2158 
2159  extern RailType _last_built_railtype;
2160  RailType rt;
2162  case 2: {
2163  /* Find the most used rail type */
2164  uint count[RAILTYPE_END];
2165  memset(count, 0, sizeof(count));
2166  for (TileIndex t = 0; t < MapSize(); t++) {
2169  count[GetRailType(t)]++;
2170  }
2171  }
2172 
2173  rt = static_cast<RailType>(std::max_element(count + RAILTYPE_BEGIN, count + RAILTYPE_END) - count);
2174  if (count[rt] > 0) break;
2175 
2176  /* No rail, just get the first available one */
2177  FALLTHROUGH;
2178  }
2179  case 0: {
2180  /* Use first available type */
2181  std::vector<RailType>::const_iterator it = std::find_if(_sorted_railtypes.begin(), _sorted_railtypes.end(),
2182  [](RailType r){ return HasRailtypeAvail(_local_company, r); });
2183  rt = it != _sorted_railtypes.end() ? *it : RAILTYPE_BEGIN;
2184  break;
2185  }
2186  case 1: {
2187  /* Use last available type */
2188  std::vector<RailType>::const_reverse_iterator it = std::find_if(_sorted_railtypes.rbegin(), _sorted_railtypes.rend(),
2189  [](RailType r){ return HasRailtypeAvail(_local_company, r); });
2190  rt = it != _sorted_railtypes.rend() ? *it : RAILTYPE_BEGIN;
2191  break;
2192  }
2193  default:
2194  NOT_REACHED();
2195  }
2196 
2197  _last_built_railtype = _cur_railtype = rt;
2199  if (w != nullptr) w->ModifyRailType(_cur_railtype);
2200 }
2201 
2207 void ResetSignalVariant(int32 new_value)
2208 {
2210 
2211  if (new_variant != _cur_signal_variant) {
2213  if (w != nullptr) {
2214  w->SetDirty();
2216  }
2217  _cur_signal_variant = new_variant;
2218  }
2219 }
2220 
2226 {
2228 
2229  _convert_signal_button = false;
2232 }
2233 
2240 DropDownList GetRailTypeDropDownList(bool for_replacement, bool all_option)
2241 {
2242  RailTypes used_railtypes;
2243  RailTypes avail_railtypes;
2244 
2245  const Company *c = Company::Get(_local_company);
2246 
2247  /* Find the used railtypes. */
2248  if (for_replacement) {
2249  avail_railtypes = GetCompanyRailtypes(c->index, false);
2250  used_railtypes = GetRailTypes(false);
2251  } else {
2252  avail_railtypes = c->avail_railtypes;
2253  used_railtypes = GetRailTypes(true);
2254  }
2255 
2256  DropDownList list;
2257 
2258  if (all_option) {
2259  list.emplace_back(new DropDownListStringItem(STR_REPLACE_ALL_RAILTYPE, INVALID_RAILTYPE, false));
2260  }
2261 
2262  Dimension d = { 0, 0 };
2263  /* Get largest icon size, to ensure text is aligned on each menu item. */
2264  if (!for_replacement) {
2265  for (const auto &rt : _sorted_railtypes) {
2266  if (!HasBit(used_railtypes, rt)) continue;
2267  const RailtypeInfo *rti = GetRailTypeInfo(rt);
2269  }
2270  }
2271 
2272  for (const auto &rt : _sorted_railtypes) {
2273  /* If it's not used ever, don't show it to the user. */
2274  if (!HasBit(used_railtypes, rt)) continue;
2275 
2276  const RailtypeInfo *rti = GetRailTypeInfo(rt);
2277 
2278  StringID str = for_replacement ? rti->strings.replace_text : (rti->max_speed > 0 ? STR_TOOLBAR_RAILTYPE_VELOCITY : STR_JUST_STRING);
2280  if (for_replacement) {
2281  item = new DropDownListParamStringItem(str, rt, !HasBit(avail_railtypes, rt));
2282  } else {
2283  DropDownListIconItem *iconitem = new DropDownListIconItem(rti->gui_sprites.build_x_rail, PAL_NONE, str, rt, !HasBit(avail_railtypes, rt));
2284  iconitem->SetDimension(d);
2285  item = iconitem;
2286  }
2287  item->SetParam(0, rti->strings.menu_text);
2288  item->SetParam(1, rti->max_speed);
2289  list.emplace_back(item);
2290  }
2291 
2292  if (list.size() == 0) {
2293  /* Empty dropdowns are not allowed */
2294  list.emplace_back(new DropDownListStringItem(STR_NONE, INVALID_RAILTYPE, true));
2295  }
2296 
2297  return list;
2298 }
SZSP_NONE
@ SZSP_NONE
Display plane with zero size in both directions (none filling and resizing).
Definition: widget_type.h:428
ES_HANDLED
@ ES_HANDLED
The passed event is handled.
Definition: window_type.h:720
WID_BRAS_PLATFORM_LEN_6
@ WID_BRAS_PLATFORM_LEN_6
Button to select 6 tiles length station platforms.
Definition: rail_widget.h:52
HT_DIR_HL
@ HT_DIR_HL
horizontal lower
Definition: tilehighlight_type.h:36
RailtypeInfo::rail_nwse
CursorID rail_nwse
Cursor for building rail in Y direction.
Definition: rail.h:165
BuildRailToolbarWindow::OnPlaceDrag
void OnPlaceDrag(ViewportPlaceMethod select_method, ViewportDragDropSelectionProcess select_proc, Point pt) override
The user is dragging over the map when the tile highlight mode has been set.
Definition: rail_gui.cpp:661
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:55
GUISettings::station_numtracks
byte station_numtracks
the number of platforms to default on for rail stations
Definition: settings_type.h:163
SetTileSelectSize
void SetTileSelectSize(int w, int h)
Highlight w by h tiles at the cursor.
Definition: viewport.cpp:2483
DIAGDIR_SE
@ DIAGDIR_SE
Southeast.
Definition: direction_type.h:80
PickerWindowBase::Close
void Close() override
Hide the window and all its child windows, and mark them for a later deletion.
Definition: window.cpp:3563
DDSP_DEMOLISH_AREA
@ DDSP_DEMOLISH_AREA
Clear area.
Definition: viewport_type.h:108
tunnelbridge.h
_remove_button_clicked
static bool _remove_button_clicked
Flag whether 'remove' toggle-button is currently enabled.
Definition: rail_gui.cpp:53
CA_UNMODIFIED
@ CA_UNMODIFIED
Catchment for all stations with "modified catchment" disabled.
Definition: station_type.h:83
IsInsideMM
static constexpr bool IsInsideMM(const T x, const size_t min, const size_t max) noexcept
Checks if a value is in an interval.
Definition: math_func.hpp:230
WID_RAT_DEMOLISH
@ WID_RAT_DEMOLISH
Destroy something with dynamite!
Definition: rail_widget.h:22
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:127
GUISettings::station_dragdrop
bool station_dragdrop
whether drag and drop is enabled for stations
Definition: settings_type.h:165
BuildRailStationWindow::coverage_height
uint coverage_height
Height of the coverage texts.
Definition: rail_gui.cpp:902
WID_BS_SEMAPHORE_EXIT
@ WID_BS_SEMAPHORE_EXIT
Build a semaphore exit block signal.
Definition: rail_widget.h:85
RailToolbar_CtrlChanged
static bool RailToolbar_CtrlChanged(Window *w)
Updates the Remove button because of Ctrl state change.
Definition: rail_gui.cpp:304
BuildRalStationHotkeys
BuildRalStationHotkeys
Enum referring to the Hotkeys in the build rail station window.
Definition: rail_gui.cpp:895
RailtypeInfo::max_speed
uint16 max_speed
Maximum speed for vehicles travelling on this rail type.
Definition: rail.h:228
newgrf_station.h
IsValidAxis
static bool IsValidAxis(Axis d)
Checks if an integer value is a valid Axis.
Definition: direction_func.h:43
Rect::Height
int Height() const
Get height of Rect.
Definition: geometry_type.hpp:85
GUISettings::station_show_coverage
bool station_show_coverage
whether to highlight coverage area
Definition: settings_type.h:166
Pool::PoolItem<&_company_pool >::Get
static Titem * Get(size_t index)
Returns Titem with given index.
Definition: pool_type.hpp:337
WC_BUILD_TOOLBAR
@ WC_BUILD_TOOLBAR
Build toolbar; Window numbers:
Definition: window_type.h:66
TileOffsByDiagDir
static TileIndexDiff TileOffsByDiagDir(DiagDirection dir)
Convert a DiagDirection to a TileIndexDiff.
Definition: map_func.h:341
GUISettings::drag_signals_fixed_distance
bool drag_signals_fixed_distance
keep fixed distance between signals when dragging
Definition: settings_type.h:159
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:1089
GameSettings::station
StationSettings station
settings related to station management
Definition: settings_type.h:598
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:2240
SetWindowDirty
void SetWindowDirty(WindowClass cls, WindowNumber number)
Mark window as dirty (in need of repainting)
Definition: window.cpp:3156
querystring_gui.h
DropDownListParamStringItem
String list item with parameters.
Definition: dropdown_type.h:56
SetScrollbar
static NWidgetPart SetScrollbar(int index)
Attach a scrollbar to a widget.
Definition: widget_type.h:1210
WID_BS_TOGGLE_SIZE
@ WID_BS_TOGGLE_SIZE
Toggle showing advanced signal types.
Definition: rail_widget.h:82
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:40
VpSetPresizeRange
void VpSetPresizeRange(TileIndex from, TileIndex to)
Highlights all tiles between a set of two tiles.
Definition: viewport.cpp:2720
BuildRailDepotWindow::DrawWidget
void DrawWidget(const Rect &r, int widget) const override
Draw the contents of a nested widget.
Definition: rail_gui.cpp:1938
GB
static uint GB(const T x, const uint8 s, const uint8 n)
Fetch n bits from x, started at bit s.
Definition: bitmath_func.hpp:32
WID_RAT_BUILD_SIGNALS
@ WID_RAT_BUILD_SIGNALS
Build signals.
Definition: rail_widget.h:26
WID_RAT_BUILD_Y
@ WID_RAT_BUILD_Y
Build rail along the game grid Y axis.
Definition: rail_widget.h:20
SetFocusedWindow
void SetFocusedWindow(Window *w)
Set the window that has the focus.
Definition: window.cpp:455
BuildSignalWindow::sig_sprite_size
Dimension sig_sprite_size
Maximum size of signal GUI sprites.
Definition: rail_gui.cpp:1667
Dimension
Dimensions (a width and height) of a rectangle in 2D.
Definition: geometry_type.hpp:27
command_func.h
RailtypeInfo::menu_text
StringID menu_text
Name of this rail type in the main toolbar dropdown.
Definition: rail.h:175
WWT_STICKYBOX
@ WWT_STICKYBOX
Sticky box (at top-right of a window, after WWT_DEFSIZEBOX)
Definition: widget_type.h:64
SetPadding
static NWidgetPart SetPadding(uint8 top, uint8 right, uint8 bottom, uint8 left)
Widget part function for setting additional space around a widget.
Definition: widget_type.h:1143
BuildSignalWindow
Definition: rail_gui.cpp:1665
GUIList::Sort
bool Sort(Comp compare)
Sort the list.
Definition: sortlist_type.h:247
Window::GetScrollbar
const Scrollbar * GetScrollbar(uint widnum) const
Return the Scrollbar to a widget index.
Definition: window.cpp:319
WID_RAT_CAPTION
@ WID_RAT_CAPTION
Caption of the window.
Definition: rail_widget.h:16
WDF_CONSTRUCTION
@ WDF_CONSTRUCTION
This window is used for construction; close it whenever changing company.
Definition: window_gui.h:144
WID_BRAD_DEPOT_SE
@ WID_BRAD_DEPOT_SE
Build a depot with the entrance in the south east.
Definition: rail_widget.h:113
Company::avail_railtypes
RailTypes avail_railtypes
Rail types available to this company.
Definition: company_base.h:121
Commands
Commands
List of commands.
Definition: command_type.h:176
Rect::Shrink
Rect Shrink(int s) const
Copy and shrink Rect by s pixels.
Definition: geometry_type.hpp:92
StringFilter::IsEmpty
bool IsEmpty() const
Check whether any filter words were entered.
Definition: stringfilter_type.h:59
_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_BRAS_SHOW_NEWST_MATRIX
@ WID_BRAS_SHOW_NEWST_MATRIX
Selection for newstation image matrix.
Definition: rail_widget.h:69
Window::ReInit
void ReInit(int rx=0, int ry=0)
Re-initialize a window, and optionally change its size.
Definition: window.cpp:1019
company_base.h
RailtypeInfo::build_depot
SpriteID build_depot
button for building depots
Definition: rail.h:155
WidgetDimensions::unscaled
static const WidgetDimensions unscaled
Unscaled widget dimensions.
Definition: window_gui.h:67
ViewportDragDropSelectionProcess
ViewportDragDropSelectionProcess
Drag and drop selection process, or, what to do with an area of land when you've selected it.
Definition: viewport_type.h:107
_cur_year
Year _cur_year
Current year, starting at 0.
Definition: date.cpp:26
tunnelbridge_map.h
StringFilter::SetFilterTerm
void SetFilterTerm(const char *str)
Set the term to filter on.
Definition: stringfilter.cpp:27
CommandFlagsToDCFlags
static constexpr DoCommandFlag CommandFlagsToDCFlags(CommandFlags cmd_flags)
Extracts the DC flags needed for DoCommand from the flags returned by GetCommandFlags.
Definition: command_func.h:59
_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:98
Axis
Axis
Allow incrementing of DiagDirDiff variables.
Definition: direction_type.h:125
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:780
WWT_CAPTION
@ WWT_CAPTION
Window caption (window title between closebox and stickybox)
Definition: widget_type.h:59
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:127
WID_BRAD_DEPOT_SW
@ WID_BRAD_DEPOT_SW
Build a depot with the entrance in the south west.
Definition: rail_widget.h:114
HandleAutoSignalPlacement
static void HandleAutoSignalPlacement()
Build new signals or remove signals or (if only one tile marked) edit a signal.
Definition: rail_gui.cpp:383
_cur_signal_variant
static SignalVariant _cur_signal_variant
set the signal variant (for signal GUI)
Definition: rail_gui.cpp:58
RailtypeInfo::convert
CursorID convert
Cursor for converting track.
Definition: rail.h:169
NWidgetMatrix
Matrix container with implicitly equal sized (virtual) sub-widgets.
Definition: widget_type.h:539
waypoint_cmd.h
BuildRailToolbarWindow::OnHotkey
EventState OnHotkey(int hotkey) override
A hotkey has been pressed.
Definition: rail_gui.cpp:596
WWT_IMGBTN
@ WWT_IMGBTN
(Toggle) Button with image
Definition: widget_type.h:50
GUIList< StationClassID, StringFilter & >
BuildSignalWindow::UpdateWidgetSize
void UpdateWidgetSize(int widget, Dimension *size, const Dimension &padding, Dimension *fill, Dimension *resize) override
Update size and resize step of a widget in the window.
Definition: rail_gui.cpp:1741
_railstation
static RailStationGUISettings _railstation
Settings of the station builder GUI.
Definition: rail_gui.cpp:69
TRACK_LOWER
@ TRACK_LOWER
Track in the lower corner of the tile (south)
Definition: track_type.h:24
BuildRailStationWindow::UpdateWidgetSize
void UpdateWidgetSize(int widget, Dimension *size, const Dimension &padding, Dimension *fill, Dimension *resize) override
Update size and resize step of a widget in the window.
Definition: rail_gui.cpp:1196
WID_BS_SEMAPHORE_ENTRY_SEL
@ WID_BS_SEMAPHORE_ENTRY_SEL
NWID_SELECTION for WID_BS_SEMAPHORE_ENTRY.
Definition: rail_widget.h:101
RailtypeInfo::replace_text
StringID replace_text
Text used in the autoreplace GUI.
Definition: rail.h:177
WWT_LABEL
@ WWT_LABEL
Centered label.
Definition: widget_type.h:55
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:99
SetRedErrorSquare
void SetRedErrorSquare(TileIndex tile)
Set a tile to display a red error square.
Definition: viewport.cpp:2465
WWT_DEFSIZEBOX
@ WWT_DEFSIZEBOX
Default window size box (at top-right of a window, between WWT_SHADEBOX and WWT_STICKYBOX)
Definition: widget_type.h:63
BuildSignalWindow::SetStringParameters
void SetStringParameters(int widget) const override
Initialize string parameters for a widget.
Definition: rail_gui.cpp:1754
Window::CreateNestedTree
void CreateNestedTree(bool fill_nested=true)
Perform the first part of the initialization of a nested widget tree.
Definition: window.cpp:1775
WDP_ALIGN_TOOLBAR
@ WDP_ALIGN_TOOLBAR
Align toward the toolbar.
Definition: window_gui.h:92
WID_BRAS_PLATFORM_NUM_BEGIN
@ WID_BRAS_PLATFORM_NUM_BEGIN
Helper for determining the chosen platform width.
Definition: rail_widget.h:75
Pool::PoolItem::index
Tindex index
Index of this pool item.
Definition: pool_type.hpp:235
NWID_HORIZONTAL
@ NWID_HORIZONTAL
Horizontal container.
Definition: widget_type.h:73
SIGNAL_GUI_PATH
@ SIGNAL_GUI_PATH
Show path signals only.
Definition: rail_gui.h:24
WID_BS_SEMAPHORE_PBS_OWAY
@ WID_BS_SEMAPHORE_PBS_OWAY
Build a semaphore one way path signal.
Definition: rail_widget.h:88
PlaceRail_Waypoint
static void PlaceRail_Waypoint(TileIndex tile)
Place a rail waypoint.
Definition: rail_gui.cpp:158
TRACK_X
@ TRACK_X
Track along the x-axis (north-east to south-west)
Definition: track_type.h:21
WID_BRAS_HIGHLIGHT_ON
@ WID_BRAS_HIGHLIGHT_ON
Button for turning coverage highlighting on.
Definition: rail_widget.h:58
GUISettings::default_rail_type
uint8 default_rail_type
the default rail type for the rail GUI
Definition: settings_type.h:129
maxdim
Dimension maxdim(const Dimension &d1, const Dimension &d2)
Compute bounding box of both dimensions.
Definition: geometry_func.cpp:22
WWT_MATRIX
@ WWT_MATRIX
Grid of rows and columns.
Definition: widget_type.h:57
ANIMCURSOR_BUILDSIGNALS
static const CursorID ANIMCURSOR_BUILDSIGNALS
1292 - 1293 - build signal
Definition: sprites.h:1500
FindWindowById
Window * FindWindowById(WindowClass cls, WindowNumber number)
Find a window by its class and window number.
Definition: window.cpp:1161
WID_BS_ELECTRIC_NORM
@ WID_BS_ELECTRIC_NORM
Build an electric normal block signal.
Definition: rail_widget.h:89
NWID_HORIZONTAL_LTR
@ NWID_HORIZONTAL_LTR
Horizontal container that doesn't change the order of the widgets for RTL languages.
Definition: widget_type.h:74
WID_RAT_AUTORAIL
@ WID_RAT_AUTORAIL
Autorail tool.
Definition: rail_widget.h:21
HasBit
static bool HasBit(const T x, const uint8 y)
Checks if a bit in a value is set.
Definition: bitmath_func.hpp:103
RailtypeInfo::rail_swne
CursorID rail_swne
Cursor for building rail in X direction.
Definition: rail.h:163
INVALID_TILE
static constexpr TileIndex INVALID_TILE
The very nice invalid tile marker.
Definition: tile_type.h:108
RailtypeInfo
This struct contains all the info that is needed to draw and construct tracks.
Definition: rail.h:124
PlaceProc_DemolishArea
void PlaceProc_DemolishArea(TileIndex tile)
Start a drag for demolishing an area.
Definition: terraform_gui.cpp:150
BuildRailDepotWindow::OnClick
void OnClick(Point pt, int widget, int click_count) override
A click with the left mouse button has been made on the window.
Definition: rail_gui.cpp:1953
BuildRailStationWindow::StationClassIDSorter
static bool StationClassIDSorter(StationClassID const &a, StationClassID const &b)
Sort station classes by StationClassID.
Definition: rail_gui.cpp:1041
WID_BRAD_DEPOT_NE
@ WID_BRAD_DEPOT_NE
Build a depot with the entrance in the north east.
Definition: rail_widget.h:112
RailStationGUISettings::station_type
byte station_type
Station type within the currently selected custom station class (if newstations is true )
Definition: rail_gui.cpp:66
TileIndex
The index/ID of a Tile.
Definition: tile_type.h:85
Scrollbar::SetCount
void SetCount(int num)
Sets the number of elements in the list.
Definition: widget_type.h:717
WID_BRAS_PLATFORM_LEN_1
@ WID_BRAS_PLATFORM_LEN_1
Button to select single tile length station platforms.
Definition: rail_widget.h:47
_ctrl_pressed
bool _ctrl_pressed
Is Ctrl pressed?
Definition: gfx.cpp:38
MP_RAILWAY
@ MP_RAILWAY
A railway.
Definition: tile_type.h:49
SIGNAL_GUI_ALL
@ SIGNAL_GUI_ALL
Show all signals, including block and presignals.
Definition: rail_gui.h:25
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
RailtypeInfo::build_tunnel
SpriteID build_tunnel
button for building a tunnel
Definition: rail.h:156
IsStationAvailable
static bool IsStationAvailable(const StationSpec *statspec)
Check whether a station type can be build.
Definition: rail_gui.cpp:82
RailtypeInfo::depot
CursorID depot
Cursor for building a depot.
Definition: rail.h:167
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:153
SetResize
static NWidgetPart SetResize(int16 dx, int16 dy)
Widget part function for setting the resize step.
Definition: widget_type.h:997
WID_BRAS_SHOW_NEWST_TYPE
@ WID_BRAS_SHOW_NEWST_TYPE
Display of selected station type.
Definition: rail_widget.h:71
SND_20_CONSTRUCTION_RAIL
@ SND_20_CONSTRUCTION_RAIL
30 == 0x1E Construction: rail infrastructure
Definition: sound_type.h:69
zoom_func.h
Window::RaiseButtons
void RaiseButtons(bool autoraise=false)
Raise the buttons of the window.
Definition: window.cpp:597
SIGNAL_CYCLE_ALL
@ SIGNAL_CYCLE_ALL
Cycle through all signals visible.
Definition: rail_gui.h:31
GetTrackBits
static TrackBits GetTrackBits(TileIndex tile)
Gets the track bits of the given tile.
Definition: rail_map.h:136
RailtypeInfo::auto_rail
SpriteID auto_rail
button for the autorail construction
Definition: rail.h:154
WID_BS_ELECTRIC_NORM_SEL
@ WID_BS_ELECTRIC_NORM_SEL
NWID_SELECTION for WID_BS_ELECTRIC_NORM.
Definition: rail_widget.h:100
VPM_FIX_Y
@ VPM_FIX_Y
drag only in Y axis
Definition: viewport_type.h:91
NWidgetMatrix::SetScrollbar
void SetScrollbar(Scrollbar *sb)
Assign a scrollbar to this matrix.
Definition: widget.cpp:1905
_settings_client
ClientSettings _settings_client
The current settings for this game.
Definition: settings.cpp:53
DrawString
int DrawString(int left, int right, int top, const char *str, TextColour colour, StringAlignment align, bool underline, FontSize fontsize)
Draw string, possibly truncated to make it fit in its allocated space.
Definition: gfx.cpp:644
BuildRailToolbarWindow::OnClick
void OnClick(Point pt, int widget, int click_count) override
A click with the left mouse button has been made on the window.
Definition: rail_gui.cpp:504
ShowBuildRailToolbar
Window * ShowBuildRailToolbar(RailType railtype)
Open the build rail toolbar window for a specific rail type.
Definition: rail_gui.cpp:857
SignalVariant
SignalVariant
Variant of the signal, i.e.
Definition: signal_type.h:16
WWT_EMPTY
@ WWT_EMPTY
Empty widget, place holder to reserve space in widget array.
Definition: widget_type.h:46
ANIMCURSOR_DEMOLISH
static const CursorID ANIMCURSOR_DEMOLISH
704 - 707 - demolish dynamite
Definition: sprites.h:1496
WWT_PUSHARROWBTN
@ WWT_PUSHARROWBTN
Normal push-button (no toggle button) with arrow caption.
Definition: widget_type.h:106
StringFilter::AddLine
void AddLine(const char *str)
Pass another text line from the current item to the filter.
Definition: stringfilter.cpp:104
BuildRailStationWindow::last_filtering
static Filtering last_filtering
Default filtering of GUIStationClassList.
Definition: rail_gui.cpp:911
DIAGDIR_NW
@ DIAGDIR_NW
Northwest.
Definition: direction_type.h:82
BuildRailToolbarWindow::last_user_action
int last_user_action
Last started user action.
Definition: rail_gui.cpp:410
WC_BUILD_STATION
@ WC_BUILD_STATION
Build station; Window numbers:
Definition: window_type.h:390
ToggleRailButton_Remove
static void ToggleRailButton_Remove(Window *w)
Toggles state of the Remove button of Build rail toolbar.
Definition: rail_gui.cpp:290
WID_RAT_BUILD_STATION
@ WID_RAT_BUILD_STATION
Build a station.
Definition: rail_widget.h:25
WID_BRAS_PLATFORM_LEN_4
@ WID_BRAS_PLATFORM_LEN_4
Button to select 4 tiles length station platforms.
Definition: rail_widget.h:50
BuildSignalWindow::SetSignalUIMode
void SetSignalUIMode()
Show or hide buttons for non-path signals in the signal GUI.
Definition: rail_gui.cpp:1692
ViewportPlaceMethod
ViewportPlaceMethod
Viewport place method (type of highlighted area and placed objects)
Definition: viewport_type.h:88
BuildSignalWindow::OnClick
void OnClick(Point pt, int widget, int click_count) override
A click with the left mouse button has been made on the window.
Definition: rail_gui.cpp:1775
BuildRailStationWindow::Close
void Close() override
Hide the window and all its child windows, and mark them for a later deletion.
Definition: rail_gui.cpp:1034
BuildRailWaypointWindow::UpdateWidgetSize
void UpdateWidgetSize(int widget, Dimension *size, const Dimension &padding, Dimension *fill, Dimension *resize) override
Update size and resize step of a widget in the window.
Definition: rail_gui.cpp:2034
Scrollbar::GetScrolledRowFromWidget
int GetScrolledRowFromWidget(int clickpos, const Window *const w, int widget, int padding=0) const
Compute the row of a scrolled widget that a user clicked in.
Definition: widget.cpp:2353
RailtypeInfo::build_ns_rail
SpriteID build_ns_rail
button for building single rail in N-S direction
Definition: rail.h:150
HT_DIR_Y
@ HT_DIR_Y
Y direction.
Definition: tilehighlight_type.h:34
NWID_MATRIX
@ NWID_MATRIX
Matrix container.
Definition: widget_type.h:76
Scrollbar
Scrollbar data structure.
Definition: widget_type.h:636
_cur_railtype
static RailType _cur_railtype
Rail type of the current build-rail toolbar.
Definition: rail_gui.cpp:52
GUISettings::drag_signals_density
byte drag_signals_density
many signals density
Definition: settings_type.h:158
Window::OnHotkey
virtual EventState OnHotkey(int hotkey)
A hotkey has been pressed.
Definition: window.cpp:634
SetDParam
static void SetDParam(uint n, uint64 v)
Set a string parameter v at index n in the global string parameter array.
Definition: strings_func.h:196
NWidgetPart
Partial widget specification to allow NWidgets to be written nested.
Definition: widget_type.h:975
WID_BRAS_PLATFORM_DIR_X
@ WID_BRAS_PLATFORM_DIR_X
Button to select '/' view.
Definition: rail_widget.h:36
INVALID_ROADTYPE
@ INVALID_ROADTYPE
flag for invalid roadtype
Definition: road_type.h:27
TRACK_RIGHT
@ TRACK_RIGHT
Track in the right corner of the tile (east)
Definition: track_type.h:26
SetDataTip
static NWidgetPart SetDataTip(uint32 data, StringID tip)
Widget part function for setting the data and tooltip.
Definition: widget_type.h:1111
BuildRailStationWindow::OnHotkey
EventState OnHotkey(int hotkey) override
A hotkey has been pressed.
Definition: rail_gui.cpp:1125
WID_BRAD_DEPOT_NW
@ WID_BRAD_DEPOT_NW
Build a depot with the entrance in the north west.
Definition: rail_widget.h:115
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:42
WID_BRAS_FILTER_CONTAINER
@ WID_BRAS_FILTER_CONTAINER
Container for the filter text box for the station class list.
Definition: rail_widget.h:65
CommandCost::Succeeded
bool Succeeded() const
Did this command succeed?
Definition: command_type.h:151
GetStringBoundingBox
Dimension GetStringBoundingBox(const char *str, FontSize start_fontsize)
Return the string dimension in pixels.
Definition: gfx.cpp:890
GUIList::SetFilterFuncs
void SetFilterFuncs(FilterFunction *const *n_funcs)
Hand the array of filter function pointers to the sort list.
Definition: sortlist_type.h:341
Textbuf::buf
char *const buf
buffer in which text is saved
Definition: textbuf_type.h:32
Window::querystrings
SmallMap< int, QueryString * > querystrings
QueryString associated to WWT_EDITBOX widgets.
Definition: window_gui.h:257
SignalType
SignalType
Type of signal, i.e.
Definition: signal_type.h:23
WID_BRAS_SHOW_NEWST_DEFSIZE
@ WID_BRAS_SHOW_NEWST_DEFSIZE
Selection for default-size button for newstation.
Definition: rail_widget.h:67
Window::OnPlaceMouseUp
virtual void OnPlaceMouseUp(ViewportPlaceMethod select_method, ViewportDragDropSelectionProcess select_proc, Point pt, TileIndex start_tile, TileIndex end_tile)
The user has dragged over the map when the tile highlight mode has been set.
Definition: window_gui.h:726
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:601
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
WID_BS_SEMAPHORE_EXIT_SEL
@ WID_BS_SEMAPHORE_EXIT_SEL
NWID_SELECTION for WID_BS_SEMAPHORE_EXIT.
Definition: rail_widget.h:103
VPM_RAILDIRS
@ VPM_RAILDIRS
all rail directions
Definition: viewport_type.h:98
TRACK_BIT_RIGHT
@ TRACK_BIT_RIGHT
Right track.
Definition: track_type.h:45
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:941
SpriteID
uint32 SpriteID
The number of a sprite, without mapping bits and colourtables.
Definition: gfx_type.h:17
WID_BS_DRAG_SIGNALS_DENSITY_DECREASE
@ WID_BS_DRAG_SIGNALS_DENSITY_DECREASE
Decrease the signal density.
Definition: rail_widget.h:97
NWidgetMatrix::SetCount
void SetCount(int count)
Set the number of elements in this matrix.
Definition: widget.cpp:1881
WindowDesc
High level window description.
Definition: window_gui.h:102
WID_BRAS_SHOW_NEWST_RESIZE
@ WID_BRAS_SHOW_NEWST_RESIZE
Selection for panel and resize at bottom right for newstation.
Definition: rail_widget.h:70
GetRailTypeInfo
static const RailtypeInfo * GetRailTypeInfo(RailType railtype)
Returns a pointer to the Railtype information for a given railtype.
Definition: rail.h:304
ValParamRailtype
bool ValParamRailtype(const RailType rail)
Validate functions for rail building.
Definition: rail.cpp:206
RailtypeInfo::build_x_rail
SpriteID build_x_rail
button for building single rail in X direction
Definition: rail.h:151
window_gui.h
RailtypeInfo::rail_ns
CursorID rail_ns
Cursor for building rail in N-S direction.
Definition: rail.h:162
GUISettings::cycle_signal_types
SignalCycleSettings cycle_signal_types
Which signal types to cycle with the build signal tool.
Definition: settings_type.h:152
BuildRailStationWindow::EnsureSelectedStationClassIsVisible
void EnsureSelectedStationClassIsVisible()
Scrolls WID_BRAS_NEWST_SCROLL so that the selected station class is visible.
Definition: rail_gui.cpp:925
NC_EQUALSIZE
@ NC_EQUALSIZE
Value of the NCB_EQUALSIZE flag.
Definition: widget_type.h:469
WID_RAT_BUILD_X
@ WID_RAT_BUILD_X
Build rail along the game grid X axis.
Definition: rail_widget.h:18
TRACK_BIT_VERT
@ TRACK_BIT_VERT
Left and right track.
Definition: track_type.h:48
DIAGDIR_SW
@ DIAGDIR_SW
Southwest.
Definition: direction_type.h:81
BuildSignalWindow::DrawSignalSprite
void DrawSignalSprite(const Rect &r, int widget_index, SpriteID image) const
Draw dynamic a signal-sprite in a button in the signal GUI Draw the sprite +1px to the right and down...
Definition: rail_gui.cpp:1677
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
WID_BRAS_PLATFORM_NUM_6
@ WID_BRAS_PLATFORM_NUM_6
Button to select stations with 6 platforms.
Definition: rail_widget.h:44
WDP_AUTO
@ WDP_AUTO
Find a place automatically.
Definition: window_gui.h:90
Listing
Data structure describing how to show the list (what sort direction and criteria).
Definition: sortlist_type.h:30
MapSize
static uint MapSize()
Get the size of the map.
Definition: map_func.h:92
GUIList::SetFilterState
void SetFilterState(bool state)
Enable or disable the filter.
Definition: sortlist_type.h:302
WKC_GLOBAL_HOTKEY
@ WKC_GLOBAL_HOTKEY
Fake keycode bit to indicate global hotkeys.
Definition: gfx_type.h:33
RailtypeInfo::gui_sprites
struct RailtypeInfo::@37 gui_sprites
struct containing the sprites for the rail GUI.
RailType
RailType
Enumeration for all possible railtypes.
Definition: rail_type.h:27
IsBridgeTile
static bool IsBridgeTile(TileIndex t)
checks if there is a bridge on this tile
Definition: bridge_map.h:35
DRAW_STRING_BUFFER
static const int DRAW_STRING_BUFFER
Size of the buffer used for drawing strings.
Definition: gfx_func.h:86
STAT_CLASS_WAYP
@ STAT_CLASS_WAYP
Waypoint class.
Definition: newgrf_station.h:86
Window::resize
ResizeInfo resize
Resize information.
Definition: window_gui.h:251
RailtypeInfo::tunnel
SpriteID tunnel
tunnel sprites base
Definition: rail.h:142
CommandCost
Common return value for all commands.
Definition: command_type.h:24
TRACK_Y
@ TRACK_Y
Track along the y-axis (north-west to south-east)
Definition: track_type.h:22
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:908
BuildRailToolbarWindow::Close
void Close() override
Hide the window and all its child windows, and mark them for a later deletion.
Definition: rail_gui.cpp:422
SIG_ELECTRIC
@ SIG_ELECTRIC
Light signal.
Definition: signal_type.h:17
ClientSettings::sound
SoundSettings sound
sound effect settings
Definition: settings_type.h:607
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:1804
WWT_EDITBOX
@ WWT_EDITBOX
a textbox for typing
Definition: widget_type.h:69
VPM_FIX_X
@ VPM_FIX_X
drag only in X axis
Definition: viewport_type.h:90
WID_BS_ELECTRIC_EXIT_SEL
@ WID_BS_ELECTRIC_EXIT_SEL
NWID_SELECTION for WID_BS_ELECTRIC_EXIT.
Definition: rail_widget.h:104
VpStartPlaceSizing
void VpStartPlaceSizing(TileIndex tile, ViewportPlaceMethod method, ViewportDragDropSelectionProcess process)
highlighting tiles while only going over them with the mouse
Definition: viewport.cpp:2665
GetRailTileType
static RailTileType GetRailTileType(TileIndex t)
Returns the RailTileType (normal with or without signals, waypoint or depot).
Definition: rail_map.h:36
_nested_build_depot_widgets
static const NWidgetPart _nested_build_depot_widgets[]
Nested widget definition of the build rail depot window.
Definition: rail_gui.cpp:1971
WID_RAT_BUILD_WAYPOINT
@ WID_RAT_BUILD_WAYPOINT
Build a waypoint.
Definition: rail_widget.h:24
TrackStatusToTrackBits
static TrackBits TrackStatusToTrackBits(TrackStatus ts)
Returns the present-track-information of a TrackStatus.
Definition: track_func.h:362
GUIList< StationClassID, StringFilter & >::SortFunction
bool SortFunction(const StationClassID &, const StationClassID &)
Signature of sort function.
Definition: sortlist_type.h:48
Window::SetDirty
void SetDirty() const
Mark entire window as dirty (in need of re-paint)
Definition: window.cpp:1008
Convert8bitBooleanCallback
bool Convert8bitBooleanCallback(const GRFFile *grffile, uint16 cbid, uint16 cb_res)
Converts a callback result into a boolean.
Definition: newgrf_commons.cpp:569
GUIList::SetListing
void SetListing(Listing l)
Import sort conditions.
Definition: sortlist_type.h:130
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
RectPadding::Horizontal
uint Horizontal() const
Get total horizontal padding of RectPadding.
Definition: geometry_type.hpp:59
BuildRailStationGlobalHotkeys
static EventState BuildRailStationGlobalHotkeys(int hotkey)
Handler for global hotkeys of the BuildRailStationWindow.
Definition: rail_gui.cpp:1523
OrthogonalTileArea::w
uint16 w
The width of the area.
Definition: tilearea_type.h:20
PlaceRail_Bridge
static void PlaceRail_Bridge(TileIndex tile, Window *w)
Start placing a rail bridge.
Definition: rail_gui.cpp:264
station_cmd.h
ES_NOT_HANDLED
@ ES_NOT_HANDLED
The passed event is not handled.
Definition: window_type.h:721
CommandCost::Failed
bool Failed() const
Did this command fail?
Definition: command_type.h:160
HT_RAIL
@ HT_RAIL
autorail (one piece), lower bits: direction
Definition: tilehighlight_type.h:26
BuildRailToolbarWindow::SetStringParameters
void SetStringParameters(int widget) const override
Initialize string parameters for a widget.
Definition: rail_gui.cpp:490
TRACK_UPPER
@ TRACK_UPPER
Track in the upper corner of the tile (north)
Definition: track_type.h:23
BRASHK_FOCUS_FILTER_BOX
@ BRASHK_FOCUS_FILTER_BOX
Focus the edit box for editing the filter string.
Definition: rail_gui.cpp:896
BuildRailToolbarWindow::OnPlaceMouseUp
void OnPlaceMouseUp(ViewportPlaceMethod select_method, ViewportDragDropSelectionProcess select_proc, Point pt, TileIndex start_tile, TileIndex end_tile) override
The user has dragged over the map when the tile highlight mode has been set.
Definition: rail_gui.cpp:669
VpSelectTilesWithMethod
void VpSelectTilesWithMethod(int x, int y, ViewportPlaceMethod method)
Selects tiles while dragging.
Definition: viewport.cpp:3150
ScaleSpriteTrad
static int ScaleSpriteTrad(int value)
Scale traditional pixel dimensions to GUI zoom level, for drawing sprites.
Definition: zoom_func.h:107
BuildRailToolbarWindow
Rail toolbar management class.
Definition: rail_gui.cpp:408
OrthogonalTileArea
Represents the covered area of e.g.
Definition: tilearea_type.h:18
SetMatrixDataTip
static NWidgetPart SetMatrixDataTip(uint8 cols, uint8 rows, StringID tip)
Widget part function for setting the data and tooltip of WWT_MATRIX widgets.
Definition: widget_type.h:1129
NewGRFClass
Struct containing information relating to NewGRF classes for stations and airports.
Definition: newgrf_class.h:19
WID_RAT_BUILD_BRIDGE
@ WID_RAT_BUILD_BRIDGE
Build a bridge.
Definition: rail_widget.h:27
dropdown_type.h
ShowSelectStationIfNeeded
void ShowSelectStationIfNeeded(TileArea ta, StationPickerCmdProc proc)
Show the station selection window when needed.
Definition: station_gui.cpp:2435
WID_BS_SEMAPHORE_COMBO
@ WID_BS_SEMAPHORE_COMBO
Build a semaphore combo block signal.
Definition: rail_widget.h:86
WID_BS_SEMAPHORE_COMBO_SEL
@ WID_BS_SEMAPHORE_COMBO_SEL
NWID_SELECTION for WID_BS_SEMAPHORE_COMBO.
Definition: rail_widget.h:105
_settings_game
GameSettings _settings_game
Game settings of a running game or the scenario editor.
Definition: settings.cpp:54
WID_BS_ELECTRIC_PBS
@ WID_BS_ELECTRIC_PBS
Build an electric path signal.
Definition: rail_widget.h:93
BuildRailWaypointWindow::Close
void Close() override
Hide the window and all its child windows, and mark them for a later deletion.
Definition: rail_gui.cpp:2028
Filtering
Data structure describing what to show in the list (filter criteria).
Definition: sortlist_type.h:35
RailtypeInfo::autorail
CursorID autorail
Cursor for autorail tool.
Definition: rail.h:166
ShowSignalBuilder
static void ShowSignalBuilder(Window *parent)
Open the signal selection window.
Definition: rail_gui.cpp:1918
Window::SetWidgetDisabledState
void SetWidgetDisabledState(byte widget_index, bool disab_stat)
Sets the enabled/disabled status of a widget.
Definition: window_gui.h:321
Window::parent
Window * parent
Parent window.
Definition: window_gui.h:266
_local_company
CompanyID _local_company
Company controlled by the human player at this client. Can also be COMPANY_SPECTATOR.
Definition: company_cmd.cpp:46
DropDownListStringItem
Common string list item.
Definition: dropdown_type.h:39
HasStationTileRail
static bool HasStationTileRail(TileIndex 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
DiagdirReachesTracks
static TrackBits DiagdirReachesTracks(DiagDirection diagdir)
Returns all tracks that can be reached when entering a tile from a given (diagonal) direction.
Definition: track_func.h:572
BuildRailStationWindow::OnEditboxChanged
void OnEditboxChanged(int wid) override
The text in an editbox has been edited.
Definition: rail_gui.cpp:1140
safeguards.h
WID_BRAS_PLATFORM_NUM_7
@ WID_BRAS_PLATFORM_NUM_7
Button to select stations with 7 platforms.
Definition: rail_widget.h:45
sortlist_type.h
WID_BRAS_PLATFORM_LEN_5
@ WID_BRAS_PLATFORM_LEN_5
Button to select 5 tiles length station platforms.
Definition: rail_widget.h:51
StationSpec::name
StringID name
Name of this station.
Definition: newgrf_station.h:127
HandlePlacePushButton
bool HandlePlacePushButton(Window *w, int widget, CursorID cursor, HighLightStyle mode)
This code is shared for the majority of the pushbuttons.
Definition: main_gui.cpp:62
WC_BUILD_BRIDGE
@ WC_BUILD_BRIDGE
Build bridge; Window numbers:
Definition: window_type.h:382
ShowSelectWaypointIfNeeded
void ShowSelectWaypointIfNeeded(TileArea ta, StationPickerCmdProc proc)
Show the waypoint selection window when needed.
Definition: station_gui.cpp:2445
RailToolbarGlobalHotkeys
static EventState RailToolbarGlobalHotkeys(int hotkey)
Handler for global hotkeys of the BuildRailToolbarWindow.
Definition: rail_gui.cpp:769
TRACK_LEFT
@ TRACK_LEFT
Track in the left corner of the tile (west)
Definition: track_type.h:25
BuildSignalWindow::Close
void Close() override
Hide the window and all its child windows, and mark them for a later deletion.
Definition: rail_gui.cpp:1715
WID_BS_ELECTRIC_COMBO_SEL
@ WID_BS_ELECTRIC_COMBO_SEL
NWID_SELECTION for WID_BS_ELECTRIC_COMBO.
Definition: rail_widget.h:106
WID_RAT_CONVERT_RAIL
@ WID_RAT_CONVERT_RAIL
Convert other rail to this type.
Definition: rail_widget.h:30
DDSP_BUILD_BRIDGE
@ DDSP_BUILD_BRIDGE
Bridge placement.
Definition: viewport_type.h:117
_nested_build_waypoint_widgets
static const NWidgetPart _nested_build_waypoint_widgets[]
Nested widget definition for the build NewGRF rail waypoint window.
Definition: rail_gui.cpp:2099
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:1058
MP_TUNNELBRIDGE
@ MP_TUNNELBRIDGE
Tunnel entry/exit and bridge heads.
Definition: tile_type.h:57
WID_BS_DRAG_SIGNALS_DENSITY_LABEL
@ WID_BS_DRAG_SIGNALS_DENSITY_LABEL
The current signal density.
Definition: rail_widget.h:96
WID_RAT_BUILD_TUNNEL
@ WID_RAT_BUILD_TUNNEL
Build a tunnel.
Definition: rail_widget.h:28
waypoint_func.h
Point
Coordinates of a point in 2D.
Definition: geometry_type.hpp:21
BuildRailStationWindow
Definition: rail_gui.cpp:899
DiagDirection
DiagDirection
Enumeration for diagonal directions.
Definition: direction_type.h:77
BuildRailStationWindow::string_filter
StringFilter string_filter
Filter for available station classes.
Definition: rail_gui.cpp:915
CBM_STATION_AVAIL
@ CBM_STATION_AVAIL
Availability of station in construction window.
Definition: newgrf_callbacks.h:307
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:563
tunnelbridge_cmd.h
BuildRailStationWindow::BuildStationClassesAvailable
void BuildStationClassesAvailable()
Builds the filter list of available station classes.
Definition: rail_gui.cpp:1058
date_func.h
TRACK_BIT_LOWER
@ TRACK_BIT_LOWER
Lower track.
Definition: track_type.h:43
StationSpec::disallowed_platforms
byte disallowed_platforms
Bitmask of number of platforms available for the station.
Definition: newgrf_station.h:133
Window::SetFocusedWidget
bool SetFocusedWidget(int widget_index)
Set focus within this window to the given widget.
Definition: window.cpp:519
stdafx.h
PC_BLACK
static const uint8 PC_BLACK
Black palette colour.
Definition: gfx_func.h:242
WID_BRAS_MATRIX_SCROLL
@ WID_BRAS_MATRIX_SCROLL
Scrollbar of the matrix widget.
Definition: rail_widget.h:63
BuildRailStationWindow::vscroll
Scrollbar * vscroll
Vertical scrollbar of the new station list.
Definition: rail_gui.cpp:903
GUISettings::link_terraform_toolbar
bool link_terraform_toolbar
display terraform toolbar when displaying rail, road, water and airport toolbars
Definition: settings_type.h:119
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:116
RailtypeInfo::toolbar_caption
StringID toolbar_caption
Caption in the construction toolbar GUI for this rail type.
Definition: rail.h:174
RectPadding::Vertical
uint Vertical() const
Get total vertical padding of RectPadding.
Definition: geometry_type.hpp:65
BuildRailStationWindow::vscroll2
Scrollbar * vscroll2
Vertical scrollbar of the matrix with new stations.
Definition: rail_gui.cpp:904
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:3194
NWidgetStacked::SetDisplayedPlane
void SetDisplayedPlane(int plane)
Select which plane to show (for NWID_SELECTION only).
Definition: widget.cpp:1409
viewport_func.h
NWidgetStacked
Stacked widgets, widgets all occupying the same space in the window.
Definition: widget_type.h:443
WC_NONE
@ WC_NONE
No window, redirects to WC_MAIN_WINDOW.
Definition: window_type.h:38
IsTileType
static bool IsTileType(TileIndex tile, TileType type)
Checks if a tile is a given tiletype.
Definition: tile_map.h:150
RailStationGUISettings
Definition: rail_gui.cpp:61
GetDigitWidth
byte GetDigitWidth(FontSize size)
Return the maximum width of single digit.
Definition: gfx.cpp:1478
NWID_VERTICAL
@ NWID_VERTICAL
Vertical container.
Definition: widget_type.h:75
WID_BS_SEMAPHORE_NORM
@ WID_BS_SEMAPHORE_NORM
Build a semaphore normal block signal.
Definition: rail_widget.h:83
FillDrawPixelInfo
bool FillDrawPixelInfo(DrawPixelInfo *n, int left, int top, int width, int height)
Set up a clipping area for only drawing into a certain area.
Definition: gfx.cpp:1786
WC_BUILD_DEPOT
@ WC_BUILD_DEPOT
Build depot; Window numbers:
Definition: window_type.h:410
WID_RAT_BUILD_EW
@ WID_RAT_BUILD_EW
Build rail along the game view X axis.
Definition: rail_widget.h:19
OrthogonalTileArea::h
uint16 h
The height of the area.
Definition: tilearea_type.h:21
GetSpriteSize
Dimension GetSpriteSize(SpriteID sprid, Point *offset, ZoomLevel zoom)
Get the size of a sprite.
Definition: gfx.cpp:993
WWT_CLOSEBOX
@ WWT_CLOSEBOX
Close box (at top-left of a window)
Definition: widget_type.h:67
WWT_RESIZEBOX
@ WWT_RESIZEBOX
Resize box (normally at bottom-right of a window)
Definition: widget_type.h:66
RAILTYPE_RAIL
@ RAILTYPE_RAIL
Standard non-electric rails.
Definition: rail_type.h:29
_signal_builder_desc
static WindowDesc _signal_builder_desc(WDP_AUTO, "build_signal", 0, 0, WC_BUILD_SIGNAL, WC_BUILD_TOOLBAR, WDF_CONSTRUCTION, _nested_signal_builder_widgets, lengthof(_nested_signal_builder_widgets))
Signal selection window description.
GUIList::NeedRebuild
bool NeedRebuild() const
Check if a rebuild is needed.
Definition: sortlist_type.h:362
WID_BS_ELECTRIC_PBS_OWAY
@ WID_BS_ELECTRIC_PBS_OWAY
Build an electric one way path signal.
Definition: rail_widget.h:94
ShowBuildBridgeWindow
void ShowBuildBridgeWindow(TileIndex start, TileIndex end, TransportType transport_type, byte road_rail_type)
Prepare the data for the build a bridge window.
Definition: bridge_gui.cpp:365
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:912
DrawStationCoverageAreaText
int DrawStationCoverageAreaText(int left, int right, int top, StationCoverageType sct, int rad, bool supplies)
Calculates and draws the accepted or supplied cargo around the selected tile(s)
Definition: station_gui.cpp:55
BuildRailWaypointWindow::DrawWidget
void DrawWidget(const Rect &r, int widget) const override
Draw the contents of a nested widget.
Definition: rail_gui.cpp:2053
string_func.h
spritecache.h
SCT_ALL
@ SCT_ALL
Draw all cargoes.
Definition: station_gui.h:24
CALLBACK_FAILED
static const uint CALLBACK_FAILED
Different values for Callback result evaluations.
Definition: newgrf_callbacks.h:408
TRACK_BIT_HORZ
@ TRACK_BIT_HORZ
Upper and lower track.
Definition: track_type.h:47
rail_gui.h
StringID
uint32 StringID
Numeric value that represents a string, independent of the selected language.
Definition: strings_type.h:16
SoundSettings::confirm
bool confirm
Play sound effect on successful constructions or other actions.
Definition: settings_type.h:216
WID_BRW_WAYPOINT_MATRIX
@ WID_BRW_WAYPOINT_MATRIX
Matrix with waypoints.
Definition: rail_widget.h:120
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_REMOVE
@ WID_RAT_REMOVE
Bulldozer to remove rail.
Definition: rail_widget.h:29
vehicle_func.h
WC_GAME_OPTIONS
@ WC_GAME_OPTIONS
Game options window; Window numbers:
Definition: window_type.h:606
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
EndContainer
static NWidgetPart EndContainer()
Widget part function for denoting the end of a container (horizontal, vertical, WWT_FRAME,...
Definition: widget_type.h:1096
WC_SELECT_STATION
@ WC_SELECT_STATION
Select station (when joining stations); Window numbers:
Definition: window_type.h:235
BuildRailStationWindow::DrawWidget
void DrawWidget(const Rect &r, int widget) const override
Draw the contents of a nested widget.
Definition: rail_gui.cpp:1251
GetRailTypes
RailTypes GetRailTypes(bool introduces)
Get list of rail types, regardless of company availability.
Definition: rail.cpp:282
WID_BRAS_COVERAGE_TEXTS
@ WID_BRAS_COVERAGE_TEXTS
Empty space for the coverage texts.
Definition: rail_widget.h:59
strings_func.h
_cur_waypoint_type
static byte _cur_waypoint_type
Currently selected waypoint type.
Definition: rail_gui.cpp:56
NWID_VSCROLLBAR
@ NWID_VSCROLLBAR
Vertical scrollbar.
Definition: widget_type.h:82
BuildSignalWindow::OnInit
void OnInit() override
Notification that the nested widget tree gets initialized.
Definition: rail_gui.cpp:1721
StationSpec
Station specification.
Definition: newgrf_station.h:113
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
terraform_gui.h
Window::IsShaded
bool IsShaded() const
Is window shaded currently?
Definition: window_gui.h:455
TRACK_BIT_LEFT
@ TRACK_BIT_LEFT
Left track.
Definition: track_type.h:44
WC_BUILD_WAYPOINT
@ WC_BUILD_WAYPOINT
Build waypoint; Window numbers:
Definition: window_type.h:416
WID_BRAS_PLATFORM_LEN_3
@ WID_BRAS_PLATFORM_LEN_3
Button to select 3 tiles length station platforms.
Definition: rail_widget.h:49
WIDGET_LIST_END
static const int WIDGET_LIST_END
indicate the end of widgets' list for vararg functions
Definition: widget_type.h:20
VPM_Y_LIMITED
@ VPM_Y_LIMITED
Drag only in Y axis with limited size.
Definition: viewport_type.h:97
_build_depot_direction
static DiagDirection _build_depot_direction
Currently selected depot direction.
Definition: rail_gui.cpp:54
WWT_TEXT
@ WWT_TEXT
Pure simple text.
Definition: widget_type.h:56
BuildRailStationWindow::filter_funcs
static GUIStationClassList::FilterFunction *const filter_funcs[]
Filter functions of the GUIStationClassList.
Definition: rail_gui.cpp:913
FONT_HEIGHT_NORMAL
#define FONT_HEIGHT_NORMAL
Height of characters in the normal (FS_NORMAL) font.
Definition: gfx_func.h:206
WC_SCEN_LAND_GEN
@ WC_SCEN_LAND_GEN
Landscape generation (in Scenario Editor); Window numbers:
Definition: window_type.h:442
HT_LINE
@ HT_LINE
used for autorail highlighting (longer stretches), lower bits: direction
Definition: tilehighlight_type.h:25
WID_BRW_SCROLL
@ WID_BRW_SCROLL
Scrollbar for the matrix.
Definition: rail_widget.h:122
NWidget
static NWidgetPart NWidget(WidgetType tp, Colours col, int16 idx=-1)
Widget part function for starting a new 'real' widget.
Definition: widget_type.h:1229
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
WID_BRW_WAYPOINT
@ WID_BRW_WAYPOINT
A single waypoint.
Definition: rail_widget.h:121
WidgetDimensions::fullbevel
RectPadding fullbevel
Always-scaled bevel border.
Definition: window_gui.h:46
Scrollbar::IsVisible
bool IsVisible(uint16 item) const
Checks whether given current item is visible in the list.
Definition: widget_type.h:688
geometry_func.hpp
GUIList< StationClassID, StringFilter & >::FilterFunction
bool CDECL FilterFunction(const StationClassID *, StringFilter &)
Signature of filter function.
Definition: sortlist_type.h:49
OrthogonalTileArea::tile
TileIndex tile
The base tile of the area.
Definition: tilearea_type.h:19
GUISettings::semaphore_build_before
Year semaphore_build_before
build semaphore signals automatically before this year
Definition: settings_type.h:160
WID_BRAS_FILTER_EDITBOX
@ WID_BRAS_FILTER_EDITBOX
Filter text box for the station class list.
Definition: rail_widget.h:66
CloseWindowByClass
void CloseWindowByClass(WindowClass cls)
Close all windows of a given class.
Definition: window.cpp:1203
SetMinimalSize
static NWidgetPart SetMinimalSize(int16 x, int16 y)
Widget part function for setting the minimal size.
Definition: widget_type.h:1014
WID_BRAS_NEWST_LIST
@ WID_BRAS_NEWST_LIST
List with available newstation classes.
Definition: rail_widget.h:72
_build_tunnel_endtile
TileIndex _build_tunnel_endtile
The end of a tunnel; as hidden return from the tunnel build command for GUI purposes.
Definition: tunnelbridge_cmd.cpp:52
InitializeRailGui
void InitializeRailGui()
Initialize rail building GUI settings.
Definition: rail_gui.cpp:2133
StringFilter::ResetState
void ResetState()
Reset the matching state to process a new item.
Definition: stringfilter.cpp:88
WWT_PANEL
@ WWT_PANEL
Simple depressed panel.
Definition: widget_type.h:48
MarkTileDirtyByTile
void MarkTileDirtyByTile(TileIndex tile, int bridge_level_offset, int tile_height_override)
Mark a tile given by its index dirty for repaint.
Definition: viewport.cpp:1998
WID_BS_SEMAPHORE_PBS
@ WID_BS_SEMAPHORE_PBS
Build a semaphore path signal.
Definition: rail_widget.h:87
BuildRailDepotWindow
Definition: rail_gui.cpp:1923
GetCompanyRailtypes
RailTypes GetCompanyRailtypes(CompanyID company, bool introduces)
Get the rail types the given company can build.
Definition: rail.cpp:251
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:901
GetRailType
static RailType GetRailType(TileIndex t)
Gets the rail type of the given tile.
Definition: rail_map.h:115
Window::IsWidgetLowered
bool IsWidgetLowered(byte widget_index) const
Gets the lowered state of a widget.
Definition: window_gui.h:422
PlaceRail_Station
static void PlaceRail_Station(TileIndex tile)
Place a rail station.
Definition: rail_gui.cpp:190
StationClassID
StationClassID
Definition: newgrf_station.h:83
EventState
EventState
State of handling an event.
Definition: window_type.h:719
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
WID_BRAS_HIGHLIGHT_OFF
@ WID_BRAS_HIGHLIGHT_OFF
Button for turning coverage highlighting off.
Definition: rail_widget.h:57
GUIList::SetFiltering
void SetFiltering(Filtering f)
Import filter conditions.
Definition: sortlist_type.h:181
StringFilter::GetState
bool GetState() const
Get the matching state of the current item.
Definition: stringfilter_type.h:69
WidgetDimensions::bevel
RectPadding bevel
Widths of bevel border.
Definition: window_gui.h:45
WID_BRAS_PLATFORM_NUM_5
@ WID_BRAS_PLATFORM_NUM_5
Button to select stations with 5 platforms.
Definition: rail_widget.h:43
WID_BRAS_PLATFORM_NUM_2
@ WID_BRAS_PLATFORM_NUM_2
Button to select stations with 2 platforms.
Definition: rail_widget.h:40
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:754
GUIList::Filter
bool Filter(FilterFunction *decide, F filter_data)
Filter the list.
Definition: sortlist_type.h:318
BuildRailWaypointWindow::OnClick
void OnClick(Point pt, int widget, int click_count) override
A click with the left mouse button has been made on the window.
Definition: rail_gui.cpp:2077
Window::FinishInitNested
void FinishInitNested(WindowNumber window_number=0)
Perform the second part of the initialization of a nested widget tree.
Definition: window.cpp:1791
DC_AUTO
@ DC_AUTO
don't allow building on structures
Definition: command_type.h:358
NWID_SPACER
@ NWID_SPACER
Invisible widget that takes some space.
Definition: widget_type.h:77
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:874
FindFirstTrack
static Track FindFirstTrack(TrackBits tracks)
Returns first Track from TrackBits or INVALID_TRACK.
Definition: track_func.h:176
WID_BRAS_IMAGE
@ WID_BRAS_IMAGE
Panel used at each cell of the matrix.
Definition: rail_widget.h:62
SetViewportCatchmentStation
void SetViewportCatchmentStation(const Station *st, bool sel)
Select or deselect station for coverage area highlight.
Definition: viewport.cpp:3533
IsLevelCrossingTile
static bool IsLevelCrossingTile(TileIndex t)
Return whether a tile is a level crossing tile.
Definition: road_map.h:95
ShowStationBuilder
static Window * ShowStationBuilder(Window *parent)
Open station build window.
Definition: rail_gui.cpp:1659
Window::top
int top
y position of top edge of the window
Definition: window_gui.h:247
BuildRailStationWindow::OnResize
void OnResize() override
Called after the window got resized.
Definition: rail_gui.cpp:1324
AXIS_X
@ AXIS_X
The X axis.
Definition: direction_type.h:126
WID_BS_CONVERT
@ WID_BS_CONVERT
Convert the signal.
Definition: rail_widget.h:95
WidgetDimensions::framerect
RectPadding framerect
Offsets within frame area.
Definition: window_gui.h:47
TileArea
OrthogonalTileArea TileArea
Shorthand for the much more common orthogonal tile area.
Definition: tilearea_type.h:102
rail_widget.h
RailtypeInfo::build_ew_rail
SpriteID build_ew_rail
button for building single rail in E-W direction
Definition: rail.h:152
TrackBits
TrackBits
Bitfield corresponding to Track.
Definition: track_type.h:38
BuildRailWaypointWindow
Definition: rail_gui.cpp:2013
DDSP_BUILD_SIGNALS
@ DDSP_BUILD_SIGNALS
Signal placement.
Definition: viewport_type.h:122
CommandHelper
Definition: command_func.h:94
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:1668
station_map.h
BuildRailToolbarWindow::OnPlacePresize
void OnPlacePresize(Point pt, TileIndex tile) override
The user moves over the map when a tile highlight mode has been set when the special mouse mode has b...
Definition: rail_gui.cpp:748
window_func.h
BuildRailStationWindow::station_classes
GUIStationClassList station_classes
Available station classes.
Definition: rail_gui.cpp:914
GUIList::ForceRebuild
void ForceRebuild()
Force that a rebuild is needed.
Definition: sortlist_type.h:370
CenterBounds
static int CenterBounds(int min, int max, int size)
Determine where to draw a centred object inside a widget.
Definition: gfx_func.h:178
Window::ToggleWidgetLoweredState
void ToggleWidgetLoweredState(byte widget_index)
Invert the lowered/raised status of a widget.
Definition: window_gui.h:392
SoundSettings::click_beep
bool click_beep
Beep on a random selection of buttons.
Definition: settings_type.h:217
BuildSignalWindow::OnInvalidateData
void OnInvalidateData(int data=0, bool gui_scope=true) override
Some data on this window has become invalid.
Definition: rail_gui.cpp:1841
lengthof
#define lengthof(x)
Return the length of an fixed size array.
Definition: stdafx.h:386
VPM_X_LIMITED
@ VPM_X_LIMITED
Drag only in X axis with limited size.
Definition: viewport_type.h:96
_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:125
stringfilter_type.h
NewGRFClass::Get
static NewGRFClass * Get(Tid cls_id)
Get a particular class.
Definition: newgrf_class_func.h:103
ShowTerraformToolbar
Window * ShowTerraformToolbar(Window *link)
Show the toolbar for terraforming in the game.
Definition: terraform_gui.cpp:371
Scrollbar::SetCapacityFromWidget
void SetCapacityFromWidget(Window *w, int widget, int padding=0)
Set capacity of visible elements from the size and resize properties of a widget.
Definition: widget.cpp:2427
MarkWholeScreenDirty
void MarkWholeScreenDirty()
This function mark the whole screen as dirty.
Definition: gfx.cpp:1767
WID_BS_ELECTRIC_EXIT
@ WID_BS_ELECTRIC_EXIT
Build an electric exit block signal.
Definition: rail_widget.h:91
CA_TRAIN
@ CA_TRAIN
Catchment for train stations with "modified catchment" enabled.
Definition: station_type.h:80
WID_BRAS_PLATFORM_NUM_4
@ WID_BRAS_PLATFORM_NUM_4
Button to select stations with 4 platforms.
Definition: rail_widget.h:42
GUISettings::auto_remove_signals
bool auto_remove_signals
automatically remove signals when in the way during rail construction
Definition: settings_type.h:176
SetPIP
static NWidgetPart SetPIP(uint8 pre, uint8 inter, uint8 post)
Widget part function for setting a pre/inter/post spaces.
Definition: widget_type.h:1191
CloseWindowById
void CloseWindowById(WindowClass cls, WindowNumber number, bool force)
Close a window by its class and window number (if it is open).
Definition: window.cpp:1191
GUISettings::station_platlength
byte station_platlength
the platform length, in tiles, for rail stations
Definition: settings_type.h:164
WID_BS_DRAG_SIGNALS_DENSITY_INCREASE
@ WID_BS_DRAG_SIGNALS_DENSITY_INCREASE
Increase the signal density.
Definition: rail_widget.h:98
_nested_signal_builder_widgets
static const NWidgetPart _nested_signal_builder_widgets[]
Nested widget definition of the build signal window.
Definition: rail_gui.cpp:1854
engine_base.h
WID_BS_ELECTRIC_COMBO
@ WID_BS_ELECTRIC_COMBO
Build an electric combo block signal.
Definition: rail_widget.h:92
SetFill
static NWidgetPart SetFill(uint fill_x, uint fill_y)
Widget part function for setting filling.
Definition: widget_type.h:1080
InitializeRailGUI
void InitializeRailGUI()
Resets the rail GUI - sets default railtype to build and resets the signal GUI.
Definition: rail_gui.cpp:2225
BuildRailStationWindow::last_sorting
static Listing last_sorting
Default sorting of GUIStationClassList.
Definition: rail_gui.cpp:910
GetOtherTunnelBridgeEnd
static TileIndex GetOtherTunnelBridgeEnd(TileIndex t)
Determines type of the wormhole and returns its other end.
Definition: tunnelbridge_map.h:78
ResetSignalVariant
void ResetSignalVariant(int32 new_value)
Updates the current signal variant used in the signal GUI to the one adequate to current year.
Definition: rail_gui.cpp:2207
gui.h
WID_RAT_BUILD_NS
@ WID_RAT_BUILD_NS
Build rail along the game view Y axis.
Definition: rail_widget.h:17
BuildRailToolbarWindow::OnPlaceObjectAbort
void OnPlaceObjectAbort() override
The user cancelled a tile highlight mode that has been set.
Definition: rail_gui.cpp:732
BuildRailStationWindow::OnPaint
void OnPaint() override
The window must be repainted.
Definition: rail_gui.cpp:1148
BuildRailToolbarWindow::ModifyRailType
void ModifyRailType(RailType railtype)
Switch to another rail type.
Definition: rail_gui.cpp:454
WID_RAT_BUILD_DEPOT
@ WID_RAT_BUILD_DEPOT
Build a depot.
Definition: rail_widget.h:23
WC_BUILD_SIGNAL
@ WC_BUILD_SIGNAL
Build signal toolbar; Window numbers:
Definition: window_type.h:91
WID_BS_SEMAPHORE_ENTRY
@ WID_BS_SEMAPHORE_ENTRY
Build a semaphore entry block signal.
Definition: rail_widget.h:84
BuildSignalWindow::DrawWidget
void DrawWidget(const Rect &r, int widget) const override
Draw the contents of a nested widget.
Definition: rail_gui.cpp:1763
Window
Data structure for an opened window.
Definition: window_gui.h:213
BuildRailStationWindow::OnRealtimeTick
void OnRealtimeTick(uint delta_ms) override
Called periodically.
Definition: rail_gui.cpp:1510
GUIList::RebuildDone
void RebuildDone()
Notify the sortlist that the rebuild is done.
Definition: sortlist_type.h:380
StationSpec::callback_mask
byte callback_mask
Bitmask of station callbacks that have to be called.
Definition: newgrf_station.h:158
BuildRailToolbarWindow::OnPlaceObject
void OnPlaceObject(Point pt, TileIndex tile) override
The user clicked some place on the map when a tile highlight mode has been set.
Definition: rail_gui.cpp:602
Pool::PoolItem<&_company_pool >::IsValidID
static bool IsValidID(size_t index)
Tests whether given index can be used to get valid (non-nullptr) Titem.
Definition: pool_type.hpp:326
RailtypeInfo::rail_ew
CursorID rail_ew
Cursor for building rail in E-W direction.
Definition: rail.h:164
WID_BRAS_PLATFORM_NUM_3
@ WID_BRAS_PLATFORM_NUM_3
Button to select stations with 3 platforms.
Definition: rail_widget.h:41
Window::RaiseWidget
void RaiseWidget(byte widget_index)
Marks a widget as raised.
Definition: window_gui.h:412
CcBuildRailTunnel
void CcBuildRailTunnel(Commands cmd, const CommandCost &result, TileIndex tile)
Command callback for building a tunnel.
Definition: rail_gui.cpp:276
StationSpec::disallowed_lengths
byte disallowed_lengths
Bitmask of platform lengths available for the station.
Definition: newgrf_station.h:138
RailtypeInfo::strings
struct RailtypeInfo::@39 strings
Strings associated with the rail type.
Window::DrawWidgets
void DrawWidgets() const
Paint all widgets of a window.
Definition: widget.cpp:858
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:320
WidgetDimensions::frametext
RectPadding frametext
Offsets within a text frame area.
Definition: window_gui.h:48
BuildRailToolbarWindow::SetupRailToolbar
void SetupRailToolbar(RailType railtype)
Configures the rail toolbar for railtype given.
Definition: rail_gui.cpp:434
WID_BRAS_MATRIX
@ WID_BRAS_MATRIX
Matrix widget displaying the available stations.
Definition: rail_widget.h:61
Swap
static void Swap(T &a, T &b)
Type safe swap operation.
Definition: math_func.hpp:241
Rect::Width
int Width() const
Get width of Rect.
Definition: geometry_type.hpp:79
Track
Track
These are used to specify a single track.
Definition: track_type.h:19
WidgetDimensions::scaled
static WidgetDimensions scaled
Widget dimensions scaled for current zoom level.
Definition: window_gui.h:68
BuildRailStationWindow::GUIStationClassList
GUIList< StationClassID, StringFilter & > GUIStationClassList
Type definition for the list to hold available station classes.
Definition: rail_gui.cpp:906
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:78
WID_BRAS_PLATFORM_DIR_Y
@ WID_BRAS_PLATFORM_DIR_Y
Button to select '\' view.
Definition: rail_widget.h:37
Window::IsWidgetDisabled
bool IsWidgetDisabled(byte widget_index) const
Gets the enabled/disabled status of a widget.
Definition: window_gui.h:350
RailtypeInfo::build_y_rail
SpriteID build_y_rail
button for building single rail in Y direction
Definition: rail.h:153
RailtypeInfo::signals
SpriteID signals[SIGTYPE_END][2][2]
signal GUI sprites (type, variant, state)
Definition: rail.h:158
Window::SetWidgetDirty
void SetWidgetDirty(byte widget_index) const
Invalidate a widget, i.e.
Definition: window.cpp:621
BuildRailStationWindow::SetStringParameters
void SetStringParameters(int widget) const override
Initialize string parameters for a widget.
Definition: rail_gui.cpp:1331
WID_BS_CAPTION
@ WID_BS_CAPTION
Caption for the Signal Selection window.
Definition: rail_widget.h:81
GetTunnelBridgeTransportType
static TransportType GetTunnelBridgeTransportType(TileIndex 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
DIAGDIR_NE
@ DIAGDIR_NE
Northeast, upper right on your monitor.
Definition: direction_type.h:79
BuildRailClick_Remove
static void BuildRailClick_Remove(Window *w)
The "remove"-button click proc of the build-rail toolbar.
Definition: rail_gui.cpp:325
Rect
Specification of a rectangle with absolute coordinates of all edges.
Definition: geometry_type.hpp:69
Window::LowerWidget
void LowerWidget(byte widget_index)
Marks a widget as lowered.
Definition: window_gui.h:403
Company
Definition: company_base.h:117
RailTypes
RailTypes
The different railtypes we support, but then a bitmask of them.
Definition: rail_type.h:46
WID_BS_ELECTRIC_ENTRY
@ WID_BS_ELECTRIC_ENTRY
Build an electric entry block signal.
Definition: rail_widget.h:90
GUISettings::signal_gui_mode
SignalGUISettings signal_gui_mode
select which signal types are shown in the signal GUI
Definition: settings_type.h:151
RailStationGUISettings::station_count
byte station_count
Number of custom stations (if newstations is true )
Definition: rail_gui.cpp:67
AWV_INCREASE
@ AWV_INCREASE
Arrow to the right or in case of RTL to the left.
Definition: widget_type.h:36
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:770
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
VPM_X_OR_Y
@ VPM_X_OR_Y
drag in X or Y direction
Definition: viewport_type.h:89
Window::DisableWidget
void DisableWidget(byte widget_index)
Sets a widget to disabled.
Definition: window_gui.h:331
lastof
#define lastof(x)
Get the last element of an fixed size array.
Definition: stdafx.h:402
BuildRailStationWindow::SelectOtherClass
void SelectOtherClass(StationClassID station_class)
Select the specified station class.
Definition: rail_gui.cpp:1113
BuildRailStationWindow::OnClick
void OnClick(Point pt, int widget, int click_count) override
A click with the left mouse button has been made on the window.
Definition: rail_gui.cpp:1339
WID_BS_ELECTRIC_ENTRY_SEL
@ WID_BS_ELECTRIC_ENTRY_SEL
NWID_SELECTION for WID_BS_ELECTRIC_ENTRY.
Definition: rail_widget.h:102
_waypoint_count
static byte _waypoint_count
Number of waypoint types.
Definition: rail_gui.cpp:55
WID_BRAS_NEWST_SCROLL
@ WID_BRAS_NEWST_SCROLL
Scrollbar of the WID_BRAS_NEWST_LIST.
Definition: rail_widget.h:73
ResetObjectToPlace
void ResetObjectToPlace()
Reset the cursor and mouse mode handling back to default (normal cursor, only clicking in windows).
Definition: viewport.cpp:3434
HT_SPECIAL
@ HT_SPECIAL
special mode used for highlighting while dragging (and for tunnels/docks)
Definition: tilehighlight_type.h:23
DrawWaypointSprite
void DrawWaypointSprite(int x, int y, int stat_id, RailType railtype)
Draw a waypoint.
Definition: waypoint.cpp:27
Window::SetWidgetLoweredState
void SetWidgetLoweredState(byte widget_index, bool lowered_stat)
Sets the lowered/raised status of a widget.
Definition: window_gui.h:382
station_gui.h
BuildRailStationWindow::TagNameFilter
static bool CDECL TagNameFilter(StationClassID const *sc, StringFilter &filter)
Filter station classes by class name.
Definition: rail_gui.cpp:1047
SIGTYPE_NORMAL
@ SIGTYPE_NORMAL
normal signal
Definition: signal_type.h:24
WID_BRAS_PLATFORM_LEN_BEGIN
@ WID_BRAS_PLATFORM_LEN_BEGIN
Helper for determining the chosen platform length.
Definition: rail_widget.h:76
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:916
WID_BRAS_PLATFORM_LEN_2
@ WID_BRAS_PLATFORM_LEN_2
Button to select 2 tiles length station platforms.
Definition: rail_widget.h:48
WID_BS_SEMAPHORE_NORM_SEL
@ WID_BS_SEMAPHORE_NORM_SEL
NWID_SELECTION for WID_BS_SEMAPHORE_NORM.
Definition: rail_widget.h:99
WID_BRAS_PLATFORM_NUM_1
@ WID_BRAS_PLATFORM_NUM_1
Button to select stations with a single platform.
Definition: rail_widget.h:39
StringFilter
String filter and state.
Definition: stringfilter_type.h:31
WID_BRAS_SHOW_NEWST_ADDITIONS
@ WID_BRAS_SHOW_NEWST_ADDITIONS
Selection for newstation class selection list.
Definition: rail_widget.h:68
DropDownListIconItem
List item with icon and string.
Definition: dropdown_type.h:82
BuildRailStationWindow::OnInvalidateData
void OnInvalidateData(int data=0, bool gui_scope=true) override
Some data on this window has become invalid.
Definition: rail_gui.cpp:1118
RailStationGUISettings::orientation
Axis orientation
Currently selected rail station orientation.
Definition: rail_gui.cpp:62
WWT_TEXTBTN
@ WWT_TEXTBTN
(Toggle) Button with text
Definition: widget_type.h:53
BuildRailToolbarWindow::railtype
RailType railtype
Rail type to build.
Definition: rail_gui.cpp:409
ClientSettings::gui
GUISettings gui
settings related to the GUI
Definition: settings_type.h:604
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:35
BuildRailDepotWindow::UpdateWidgetSize
void UpdateWidgetSize(int widget, Dimension *size, const Dimension &padding, Dimension *fill, Dimension *resize) override
Update size and resize step of a widget in the window.
Definition: rail_gui.cpp:1930
WID_BRAS_PLATFORM_LEN_7
@ WID_BRAS_PLATFORM_LEN_7
Button to select 7 tiles length station platforms.
Definition: rail_widget.h:53
GUIList::SetSortFuncs
void SetSortFuncs(SortFunction *const *n_funcs)
Hand the array of sort function pointers to the sort list.
Definition: sortlist_type.h:270
DrawPixelInfo
Data about how and where to blit pixels.
Definition: gfx_type.h:151
GUISettings::persistent_buildingtools
bool persistent_buildingtools
keep the building tools active after usage
Definition: settings_type.h:167
_station_builder_desc
static WindowDesc _station_builder_desc(WDP_AUTO, "build_station_rail", 350, 0, WC_BUILD_STATION, WC_BUILD_TOOLBAR, WDF_CONSTRUCTION, _nested_station_builder_widgets, lengthof(_nested_station_builder_widgets), &BuildRailStationWindow::hotkeys)
High level window description of the station-build window (default & newGRF)
StationSettings::modified_catchment
bool modified_catchment
different-size catchment areas
Definition: settings_type.h:558
TileVirtXY
static TileIndex TileVirtXY(uint x, uint y)
Get a tile from the virtual XY-coordinate.
Definition: map_func.h:194
ScaleGUITrad
static RectPadding ScaleGUITrad(const RectPadding &r)
Scale a RectPadding to GUI zoom level.
Definition: widget.cpp:168
Hotkey
All data for a single hotkey.
Definition: hotkeys.h:22
RailtypeInfo::convert_rail
SpriteID convert_rail
button for converting rail
Definition: rail.h:157
hotkeys.h
ReinitGuiAfterToggleElrail
void ReinitGuiAfterToggleElrail(bool disable)
Re-initialize rail-build toolbar after toggling support for electric trains.
Definition: rail_gui.cpp:2143
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:62
WN_GAME_OPTIONS_GAME_SETTINGS
@ WN_GAME_OPTIONS_GAME_SETTINGS
Game settings.
Definition: window_type.h:20
Window::Close
virtual void Close()
Hide the window and all its child windows, and mark them for a later deletion.
Definition: window.cpp:1107
RAILTYPE_BEGIN
@ RAILTYPE_BEGIN
Used for iterations.
Definition: rail_type.h:28
NWidgetMatrix::SetClicked
void SetClicked(int clicked)
Sets the clicked widget in the matrix.
Definition: widget.cpp:1864
SetDefaultRailGui
static void SetDefaultRailGui()
Set the initial (default) railtype to use.
Definition: rail_gui.cpp:2155
WidgetDimensions::vsep_normal
int vsep_normal
Normal vertical spacing.
Definition: window_gui.h:61
GUIPlaceProcDragXY
bool GUIPlaceProcDragXY(ViewportDragDropSelectionProcess proc, TileIndex start_tile, TileIndex end_tile)
A central place to handle all X_AND_Y dragged GUI functions.
Definition: terraform_gui.cpp:111