OpenTTD Source: src/rail_gui.cpp Source File

OpenTTD Source 15.0-RC2

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 <https://www.gnu.org/licenses/old-licenses/gpl-2.0>.
6 */
7
10#include "stdafx.h"
11#include "gui.h"
12#include "station_base.h"
13#include "waypoint_base.h"
14#include "window_gui.h"
15#include "station_gui.h"
16#include "terraform_gui.h"
17#include "viewport_func.h"
18#include "command_func.h"
19#include "waypoint_func.h"
20#include "newgrf_badge.h"
21#include "newgrf_badge_gui.h"
22#include "newgrf_station.h"
23#include "company_base.h"
24#include "strings_func.h"
25#include "window_func.h"
26#include "sound_func.h"
27#include "company_func.h"
28#include "dropdown_type.h"
29#include "dropdown_func.h"
30#include "tunnelbridge.h"
31#include "tilehighlight_func.h"
32#include "core/geometry_func.hpp"
33#include "hotkeys.h"
34#include "engine_base.h"
35#include "vehicle_func.h"
36#include "zoom_func.h"
37#include "rail_gui.h"
38#include "station_cmd.h"
39#include "tunnelbridge_cmd.h"
40#include "waypoint_cmd.h"
41#include "rail_cmd.h"
42#include "timer/timer.h"
43#include "timer/timer_game_calendar.h"
44#include "picker_gui.h"
45
46#include "station_map.h"
47#include "tunnelbridge_map.h"
48
49#include "widgets/rail_widget.h"
50
51#include "table/strings.h"
52
53#include "safeguards.h"
54
55
56 static RailType _cur_railtype;
57 static bool _remove_button_clicked;
58 static DiagDirection _build_depot_direction;
59 static bool _convert_signal_button;
60 static SignalVariant _cur_signal_variant;
61 static SignalType _cur_signal_type;
62
63 struct WaypointPickerSelection {
64 StationClassID sel_class;
65 uint16_t sel_type;
66};
67 static WaypointPickerSelection _waypoint_gui;
68
69 struct StationPickerSelection {
70 StationClassID sel_class;
71 uint16_t sel_type;
72 Axis axis;
73};
74 static StationPickerSelection _station_gui;
75
76
77static void HandleStationPlacement(TileIndex start, TileIndex end);
78static void ShowBuildTrainDepotPicker(Window *parent);
79static void ShowBuildWaypointPicker(Window *parent);
80static Window *ShowStationBuilder(Window *parent);
81static void ShowSignalBuilder(Window *parent);
82
87 static bool IsStationAvailable(const StationSpec *statspec)
88{
89 if (statspec == nullptr || !statspec->callback_mask.Test(StationCallbackMask::Avail)) return true;
90
91 uint16_t cb_res = GetStationCallback(CBID_STATION_AVAILABILITY, 0, 0, statspec, nullptr, INVALID_TILE);
92 if (cb_res == CALLBACK_FAILED) return true;
93
94 return Convert8bitBooleanCallback(statspec->grf_prop.grffile, CBID_STATION_AVAILABILITY, cb_res);
95}
96
97void CcPlaySound_CONSTRUCTION_RAIL(Commands, const CommandCost &result, TileIndex tile)
98{
99 if (result.Succeeded() && _settings_client.sound.confirm) SndPlayTileFx(SND_20_CONSTRUCTION_RAIL, tile);
100}
101
102static void GenericPlaceRail(TileIndex tile, Track track)
103{
104 if (_remove_button_clicked) {
105 Command<CMD_REMOVE_SINGLE_RAIL>::Post(STR_ERROR_CAN_T_REMOVE_RAILROAD_TRACK, CcPlaySound_CONSTRUCTION_RAIL,
106 tile, track);
107 } else {
108 Command<CMD_BUILD_SINGLE_RAIL>::Post(STR_ERROR_CAN_T_BUILD_RAILROAD_TRACK, CcPlaySound_CONSTRUCTION_RAIL,
109 tile, _cur_railtype, track, _settings_client.gui.auto_remove_signals);
110 }
111}
112
120 static void PlaceExtraDepotRail(TileIndex tile, DiagDirection dir, Track track)
121{
122 if (GetRailTileType(tile) == RailTileType::Depot) return;
123 if (GetRailTileType(tile) == RailTileType::Signals && !_settings_client.gui.auto_remove_signals) return;
124 if ((GetTrackBits(tile) & DiagdirReachesTracks(dir)) == 0) return;
125
126 Command<CMD_BUILD_SINGLE_RAIL>::Post(tile, _cur_railtype, track, _settings_client.gui.auto_remove_signals);
127}
128
130 static const Track _place_depot_extra_track[12] = {
131 TRACK_LEFT, TRACK_UPPER, TRACK_UPPER, TRACK_RIGHT, // First additional track for directions 0..3
132 TRACK_X, TRACK_Y, TRACK_X, TRACK_Y, // Second additional track
133 TRACK_LOWER, TRACK_LEFT, TRACK_RIGHT, TRACK_LOWER, // Third additional track
134};
135
137 static const DiagDirection _place_depot_extra_dir[12] = {
138 DIAGDIR_SE, DIAGDIR_SW, DIAGDIR_SE, DIAGDIR_SW,
139 DIAGDIR_SW, DIAGDIR_NW, DIAGDIR_NE, DIAGDIR_SE,
140 DIAGDIR_NW, DIAGDIR_NE, DIAGDIR_NW, DIAGDIR_NE,
141};
142
143void CcRailDepot(Commands, const CommandCost &result, TileIndex tile, RailType, DiagDirection dir)
144{
145 if (result.Failed()) return;
146
147 if (_settings_client.sound.confirm) SndPlayTileFx(SND_20_CONSTRUCTION_RAIL, tile);
148 if (!_settings_client.gui.persistent_buildingtools) ResetObjectToPlace();
149
150 tile += TileOffsByDiagDir(dir);
151
152 if (IsTileType(tile, MP_RAILWAY)) {
153 PlaceExtraDepotRail(tile, _place_depot_extra_dir[dir], _place_depot_extra_track[dir]);
154
155 /* Don't place the rail straight out of the depot of there is another depot across from it. */
156 Tile double_depot_tile = tile + TileOffsByDiagDir(dir);
157 bool is_double_depot = IsValidTile(double_depot_tile) && IsRailDepotTile(double_depot_tile);
158 if (!is_double_depot) PlaceExtraDepotRail(tile, _place_depot_extra_dir[dir + 4], _place_depot_extra_track[dir + 4]);
159
160 PlaceExtraDepotRail(tile, _place_depot_extra_dir[dir + 8], _place_depot_extra_track[dir + 8]);
161 }
162}
163
168 static void PlaceRail_Waypoint(TileIndex tile)
169{
170 if (_remove_button_clicked) {
171 VpStartPlaceSizing(tile, VPM_X_AND_Y, DDSP_REMOVE_STATION);
172 return;
173 }
174
175 Axis axis = GetAxisForNewRailWaypoint(tile);
176 if (IsValidAxis(axis)) {
177 /* Valid tile for waypoints */
178 VpStartPlaceSizing(tile, axis == AXIS_X ? VPM_X_LIMITED : VPM_Y_LIMITED, DDSP_BUILD_STATION);
179 VpSetPlaceSizingLimit(_settings_game.station.station_spread);
180 } else {
181 /* Tile where we can't build rail waypoints. This is always going to fail,
182 * but provides the user with a proper error message. */
183 Command<CMD_BUILD_RAIL_WAYPOINT>::Post(STR_ERROR_CAN_T_BUILD_RAIL_WAYPOINT , tile, AXIS_X, 1, 1, STAT_CLASS_WAYP, 0, StationID::Invalid(), false);
184 }
185}
186
187void CcStation(Commands, const CommandCost &result, TileIndex tile)
188{
189 if (result.Failed()) return;
190
191 if (_settings_client.sound.confirm) SndPlayTileFx(SND_20_CONSTRUCTION_RAIL, tile);
192 /* Only close the station builder window if the default station and non persistent building is chosen. */
193 if (_station_gui.sel_class == STAT_CLASS_DFLT && _station_gui.sel_type == 0 && !_settings_client.gui.persistent_buildingtools) ResetObjectToPlace();
194}
195
200 static void PlaceRail_Station(TileIndex tile)
201{
202 if (_remove_button_clicked) {
203 VpStartPlaceSizing(tile, VPM_X_AND_Y_LIMITED, DDSP_REMOVE_STATION);
204 VpSetPlaceSizingLimit(-1);
205 } else if (_settings_client.gui.station_dragdrop) {
206 VpStartPlaceSizing(tile, VPM_X_AND_Y_LIMITED, DDSP_BUILD_STATION);
207 VpSetPlaceSizingLimit(_settings_game.station.station_spread);
208 } else {
209 int w = _settings_client.gui.station_numtracks;
210 int h = _settings_client.gui.station_platlength;
211 if (!_station_gui.axis) std::swap(w, h);
212
213 StationPickerSelection params = _station_gui;
214 RailType rt = _cur_railtype;
215 uint8_t numtracks = _settings_client.gui.station_numtracks;
216 uint8_t platlength = _settings_client.gui.station_platlength;
217 bool adjacent = _ctrl_pressed;
218
219 auto proc = [=](bool test, StationID to_join) -> bool {
220 if (test) {
221 return Command<CMD_BUILD_RAIL_STATION>::Do(CommandFlagsToDCFlags(GetCommandFlags<CMD_BUILD_RAIL_STATION>()), tile, rt, params.axis, numtracks, platlength, params.sel_class, params.sel_type, StationID::Invalid(), adjacent).Succeeded();
222 } else {
223 return Command<CMD_BUILD_RAIL_STATION>::Post(STR_ERROR_CAN_T_BUILD_RAILROAD_STATION, CcStation, tile, rt, params.axis, numtracks, platlength, params.sel_class, params.sel_type, to_join, adjacent);
224 }
225 };
226
227 ShowSelectStationIfNeeded(TileArea(tile, w, h), proc);
228 }
229}
230
236 static void GenericPlaceSignals(TileIndex tile)
237{
238 TrackBits trackbits = TrackStatusToTrackBits(GetTileTrackStatus(tile, TRANSPORT_RAIL, 0));
239
240 if (trackbits & TRACK_BIT_VERT) { // N-S direction
241 trackbits = (_tile_fract_coords.x <= _tile_fract_coords.y) ? TRACK_BIT_RIGHT : TRACK_BIT_LEFT;
242 }
243
244 if (trackbits & TRACK_BIT_HORZ) { // E-W direction
245 trackbits = (_tile_fract_coords.x + _tile_fract_coords.y <= 15) ? TRACK_BIT_UPPER : TRACK_BIT_LOWER;
246 }
247
248 Track track = FindFirstTrack(trackbits);
249
250 if (_remove_button_clicked) {
251 Command<CMD_REMOVE_SINGLE_SIGNAL>::Post(STR_ERROR_CAN_T_REMOVE_SIGNALS_FROM, CcPlaySound_CONSTRUCTION_RAIL, tile, track);
252 } else {
253 /* Which signals should we cycle through? */
254 bool tile_has_signal = IsPlainRailTile(tile) && IsValidTrack(track) && HasSignalOnTrack(tile, track);
255 SignalType cur_signal_on_tile = tile_has_signal ? GetSignalType(tile, track) : _cur_signal_type;
256 SignalType cycle_start;
257 SignalType cycle_end;
258
259 /* Start with the least restrictive case: the player wants to cycle through all signals they can see. */
260 if (_settings_client.gui.cycle_signal_types == SIGNAL_CYCLE_ALL) {
261 cycle_start = _settings_client.gui.signal_gui_mode == SIGNAL_GUI_ALL ? SIGTYPE_BLOCK : SIGTYPE_PBS;
262 cycle_end = SIGTYPE_LAST;
263 } else {
264 /* Only cycle through signals of the same group (block or path) as the current signal on the tile. */
265 if (cur_signal_on_tile <= SIGTYPE_LAST_NOPBS) {
266 /* Block signals only. */
267 cycle_start = SIGTYPE_BLOCK;
268 cycle_end = SIGTYPE_LAST_NOPBS;
269 } else {
270 /* Path signals only. */
271 cycle_start = SIGTYPE_PBS;
272 cycle_end = SIGTYPE_LAST;
273 }
274 }
275
276 if (FindWindowById(WC_BUILD_SIGNAL, 0) != nullptr) {
277 /* signal GUI is used */
278 Command<CMD_BUILD_SINGLE_SIGNAL>::Post(_convert_signal_button ? STR_ERROR_SIGNAL_CAN_T_CONVERT_SIGNALS_HERE : STR_ERROR_CAN_T_BUILD_SIGNALS_HERE, CcPlaySound_CONSTRUCTION_RAIL,
279 tile, track, _cur_signal_type, _cur_signal_variant, _convert_signal_button, false, _ctrl_pressed, cycle_start, cycle_end, 0, 0);
280 } else {
281 SignalVariant sigvar = TimerGameCalendar::year < _settings_client.gui.semaphore_build_before ? SIG_SEMAPHORE : SIG_ELECTRIC;
282 Command<CMD_BUILD_SINGLE_SIGNAL>::Post(STR_ERROR_CAN_T_BUILD_SIGNALS_HERE, CcPlaySound_CONSTRUCTION_RAIL,
283 tile, track, _settings_client.gui.default_signal_type, sigvar, false, false, _ctrl_pressed, cycle_start, cycle_end, 0, 0);
284
285 }
286 }
287}
288
294 static void PlaceRail_Bridge(TileIndex tile, Window *w)
295{
296 if (IsBridgeTile(tile)) {
297 TileIndex other_tile = GetOtherTunnelBridgeEnd(tile);
298 Point pt = {0, 0};
299 w->OnPlaceMouseUp(VPM_X_OR_Y, DDSP_BUILD_BRIDGE, pt, other_tile, tile);
300 } else {
301 VpStartPlaceSizing(tile, VPM_X_OR_Y, DDSP_BUILD_BRIDGE);
302 }
303}
304
306 void CcBuildRailTunnel(Commands, const CommandCost &result, TileIndex tile)
307{
308 if (result.Succeeded()) {
309 if (_settings_client.sound.confirm) SndPlayTileFx(SND_20_CONSTRUCTION_RAIL, tile);
310 if (!_settings_client.gui.persistent_buildingtools) ResetObjectToPlace();
311 } else {
312 SetRedErrorSquare(_build_tunnel_endtile);
313 }
314}
315
320 static void ToggleRailButton_Remove(Window *w)
321{
322 CloseWindowById(WC_SELECT_STATION, 0);
323 w->ToggleWidgetLoweredState(WID_RAT_REMOVE);
324 w->SetWidgetDirty(WID_RAT_REMOVE);
325 _remove_button_clicked = w->IsWidgetLowered(WID_RAT_REMOVE);
326 SetSelectionRed(_remove_button_clicked);
327}
328
334 static bool RailToolbar_CtrlChanged(Window *w)
335{
336 if (w->IsWidgetDisabled(WID_RAT_REMOVE)) return false;
337
338 /* allow ctrl to switch remove mode only for these widgets */
339 for (WidgetID i = WID_RAT_BUILD_NS; i <= WID_RAT_BUILD_STATION; i++) {
340 if ((i <= WID_RAT_AUTORAIL || i >= WID_RAT_BUILD_WAYPOINT) && w->IsWidgetLowered(i)) {
341 ToggleRailButton_Remove(w);
342 return true;
343 }
344 }
345
346 return false;
347}
348
349
355 static void BuildRailClick_Remove(Window *w)
356{
357 if (w->IsWidgetDisabled(WID_RAT_REMOVE)) return;
358 ToggleRailButton_Remove(w);
359 SndClickBeep();
360
361 /* handle station builder */
362 if (w->IsWidgetLowered(WID_RAT_BUILD_STATION)) {
363 if (_remove_button_clicked) {
364 /* starting drag & drop remove */
365 if (!_settings_client.gui.station_dragdrop) {
366 SetTileSelectSize(1, 1);
367 } else {
368 VpSetPlaceSizingLimit(-1);
369 }
370 } else {
371 /* starting station build mode */
372 if (!_settings_client.gui.station_dragdrop) {
373 int x = _settings_client.gui.station_numtracks;
374 int y = _settings_client.gui.station_platlength;
375 if (_station_gui.axis == 0) std::swap(x, y);
376 SetTileSelectSize(x, y);
377 } else {
378 VpSetPlaceSizingLimit(_settings_game.station.station_spread);
379 }
380 }
381 }
382}
383
384static void DoRailroadTrack(Track track)
385{
386 if (_remove_button_clicked) {
387 Command<CMD_REMOVE_RAILROAD_TRACK>::Post(STR_ERROR_CAN_T_REMOVE_RAILROAD_TRACK, CcPlaySound_CONSTRUCTION_RAIL,
388 TileVirtXY(_thd.selend.x, _thd.selend.y), TileVirtXY(_thd.selstart.x, _thd.selstart.y), track);
389 } else {
390 Command<CMD_BUILD_RAILROAD_TRACK>::Post(STR_ERROR_CAN_T_BUILD_RAILROAD_TRACK, CcPlaySound_CONSTRUCTION_RAIL,
391 TileVirtXY(_thd.selend.x, _thd.selend.y), TileVirtXY(_thd.selstart.x, _thd.selstart.y), _cur_railtype, track, _settings_client.gui.auto_remove_signals, false);
392 }
393}
394
395static void HandleAutodirPlacement()
396{
397 Track trackstat = static_cast<Track>( _thd.drawstyle & HT_DIR_MASK); // 0..5
398
399 if (_thd.drawstyle & HT_RAIL) { // one tile case
400 GenericPlaceRail(TileVirtXY(_thd.selend.x, _thd.selend.y), trackstat);
401 return;
402 }
403
404 DoRailroadTrack(trackstat);
405}
406
413 static void HandleAutoSignalPlacement()
414{
415 Track track = (Track)GB(_thd.drawstyle, 0, 3); // 0..5
416
417 if ((_thd.drawstyle & HT_DRAG_MASK) == HT_RECT) { // one tile case
418 GenericPlaceSignals(TileVirtXY(_thd.selend.x, _thd.selend.y));
419 return;
420 }
421
422 /* _settings_client.gui.drag_signals_density is given as a parameter such that each user
423 * in a network game can specify their own signal density */
424 if (_remove_button_clicked) {
425 Command<CMD_REMOVE_SIGNAL_TRACK>::Post(STR_ERROR_CAN_T_REMOVE_SIGNALS_FROM, CcPlaySound_CONSTRUCTION_RAIL,
426 TileVirtXY(_thd.selstart.x, _thd.selstart.y), TileVirtXY(_thd.selend.x, _thd.selend.y), track, _ctrl_pressed);
427 } else {
428 bool sig_gui = FindWindowById(WC_BUILD_SIGNAL, 0) != nullptr;
429 SignalType sigtype = sig_gui ? _cur_signal_type : _settings_client.gui.default_signal_type;
430 SignalVariant sigvar = sig_gui ? _cur_signal_variant : (TimerGameCalendar::year < _settings_client.gui.semaphore_build_before ? SIG_SEMAPHORE : SIG_ELECTRIC);
431 Command<CMD_BUILD_SIGNAL_TRACK>::Post(STR_ERROR_CAN_T_BUILD_SIGNALS_HERE, CcPlaySound_CONSTRUCTION_RAIL,
432 TileVirtXY(_thd.selstart.x, _thd.selstart.y), TileVirtXY(_thd.selend.x, _thd.selend.y), track, sigtype, sigvar, false, _ctrl_pressed, !_settings_client.gui.drag_signals_fixed_distance, _settings_client.gui.drag_signals_density);
433 }
434}
435
436
438 struct BuildRailToolbarWindow : Window {
439 RailType railtype = INVALID_RAILTYPE;
440 WidgetID last_user_action = INVALID_WIDGET;
441
442 BuildRailToolbarWindow(WindowDesc &desc, RailType railtype) : Window(desc), railtype(railtype)
443 {
444 this->CreateNestedTree();
445 this->FinishInitNested(TRANSPORT_RAIL);
446 this->DisableWidget(WID_RAT_REMOVE);
447 this->OnInvalidateData();
448
449 if (_settings_client.gui.link_terraform_toolbar) ShowTerraformToolbar(this);
450 }
451
452 void Close([[maybe_unused]] int data = 0) override
453 {
454 if (this->IsWidgetLowered(WID_RAT_BUILD_STATION)) SetViewportCatchmentStation(nullptr, true);
455 if (this->IsWidgetLowered(WID_RAT_BUILD_WAYPOINT)) SetViewportCatchmentWaypoint(nullptr, true);
456 if (_settings_client.gui.link_terraform_toolbar) CloseWindowById(WC_SCEN_LAND_GEN, 0, false);
457 CloseWindowById(WC_SELECT_STATION, 0);
458 this->Window::Close();
459 }
460
462 static inline const std::initializer_list<WidgetID> can_build_widgets = {
463 WID_RAT_BUILD_NS, WID_RAT_BUILD_X, WID_RAT_BUILD_EW, WID_RAT_BUILD_Y, WID_RAT_AUTORAIL,
464 WID_RAT_BUILD_DEPOT, WID_RAT_BUILD_WAYPOINT, WID_RAT_BUILD_STATION, WID_RAT_BUILD_SIGNALS,
465 WID_RAT_BUILD_BRIDGE, WID_RAT_BUILD_TUNNEL, WID_RAT_CONVERT_RAIL,
466 };
467
468 void OnInvalidateData([[maybe_unused]] int data = 0, [[maybe_unused]] bool gui_scope = true) override
469 {
470 if (!gui_scope) return;
471
472 if (!ValParamRailType(this->railtype)) {
473 /* Close toolbar if rail type is not available. */
474 this->Close();
475 return;
476 }
477
478 bool can_build = CanBuildVehicleInfrastructure(VEH_TRAIN);
479 for (const WidgetID widget : can_build_widgets) this->SetWidgetDisabledState(widget, !can_build);
480 if (!can_build) {
481 CloseWindowById(WC_BUILD_SIGNAL, TRANSPORT_RAIL);
482 CloseWindowById(WC_BUILD_STATION, TRANSPORT_RAIL);
483 CloseWindowById(WC_BUILD_DEPOT, TRANSPORT_RAIL);
484 CloseWindowById(WC_BUILD_WAYPOINT, TRANSPORT_RAIL);
485 CloseWindowById(WC_SELECT_STATION, 0);
486 }
487 }
488
489 bool OnTooltip([[maybe_unused]] Point pt, WidgetID widget, TooltipCloseCondition close_cond) override
490 {
491 bool can_build = CanBuildVehicleInfrastructure(VEH_TRAIN);
492 if (can_build) return false;
493
494 if (std::ranges::find(can_build_widgets, widget) == std::end(can_build_widgets)) return false;
495
496 GuiShowTooltips(this, GetEncodedString(STR_TOOLBAR_DISABLED_NO_VEHICLE_AVAILABLE), close_cond);
497 return true;
498 }
499
500 void OnInit() override
501 {
502 /* Configure the rail toolbar for the railtype. */
503 const RailTypeInfo *rti = GetRailTypeInfo(this->railtype);
504 this->GetWidget<NWidgetCore>(WID_RAT_BUILD_NS)->SetSprite(rti->gui_sprites.build_ns_rail);
505 this->GetWidget<NWidgetCore>(WID_RAT_BUILD_X)->SetSprite(rti->gui_sprites.build_x_rail);
506 this->GetWidget<NWidgetCore>(WID_RAT_BUILD_EW)->SetSprite(rti->gui_sprites.build_ew_rail);
507 this->GetWidget<NWidgetCore>(WID_RAT_BUILD_Y)->SetSprite(rti->gui_sprites.build_y_rail);
508 this->GetWidget<NWidgetCore>(WID_RAT_AUTORAIL)->SetSprite(rti->gui_sprites.auto_rail);
509 this->GetWidget<NWidgetCore>(WID_RAT_BUILD_DEPOT)->SetSprite(rti->gui_sprites.build_depot);
510 this->GetWidget<NWidgetCore>(WID_RAT_CONVERT_RAIL)->SetSprite(rti->gui_sprites.convert_rail);
511 this->GetWidget<NWidgetCore>(WID_RAT_BUILD_TUNNEL)->SetSprite(rti->gui_sprites.build_tunnel);
512 }
513
518 void ModifyRailType(RailType railtype)
519 {
520 this->railtype = railtype;
521 this->ReInit();
522 }
523
524 void UpdateRemoveWidgetStatus(WidgetID clicked_widget)
525 {
526 switch (clicked_widget) {
527 case WID_RAT_REMOVE:
528 /* If it is the removal button that has been clicked, do nothing,
529 * as it is up to the other buttons to drive removal status */
530 return;
531
532 case WID_RAT_BUILD_NS:
533 case WID_RAT_BUILD_X:
534 case WID_RAT_BUILD_EW:
535 case WID_RAT_BUILD_Y:
536 case WID_RAT_AUTORAIL:
537 case WID_RAT_BUILD_WAYPOINT:
538 case WID_RAT_BUILD_STATION:
539 case WID_RAT_BUILD_SIGNALS:
540 /* Removal button is enabled only if the rail/signal/waypoint/station
541 * button is still lowered. Once raised, it has to be disabled */
542 this->SetWidgetDisabledState(WID_RAT_REMOVE, !this->IsWidgetLowered(clicked_widget));
543 break;
544
545 default:
546 /* When any other buttons than rail/signal/waypoint/station, raise and
547 * disable the removal button */
548 this->DisableWidget(WID_RAT_REMOVE);
549 this->RaiseWidget(WID_RAT_REMOVE);
550 break;
551 }
552 }
553
554 std::string GetWidgetString(WidgetID widget, StringID stringid) const override
555 {
556 if (widget == WID_RAT_CAPTION) {
557 const RailTypeInfo *rti = GetRailTypeInfo(this->railtype);
558 if (rti->max_speed > 0) {
559 return GetString(STR_TOOLBAR_RAILTYPE_VELOCITY, rti->strings.toolbar_caption, PackVelocity(rti->max_speed, VEH_TRAIN));
560 }
561 return GetString(rti->strings.toolbar_caption);
562 }
563
564 return this->Window::GetWidgetString(widget, stringid);
565 }
566
567 void OnClick([[maybe_unused]] Point pt, WidgetID widget, [[maybe_unused]] int click_count) override
568 {
569 if (widget < WID_RAT_BUILD_NS) return;
570
571 _remove_button_clicked = false;
572 switch (widget) {
573 case WID_RAT_BUILD_NS:
574 HandlePlacePushButton(this, WID_RAT_BUILD_NS, GetRailTypeInfo(_cur_railtype)->cursor.rail_ns, HT_LINE | HT_DIR_VL);
575 this->last_user_action = widget;
576 break;
577
578 case WID_RAT_BUILD_X:
579 HandlePlacePushButton(this, WID_RAT_BUILD_X, GetRailTypeInfo(_cur_railtype)->cursor.rail_swne, HT_LINE | HT_DIR_X);
580 this->last_user_action = widget;
581 break;
582
583 case WID_RAT_BUILD_EW:
584 HandlePlacePushButton(this, WID_RAT_BUILD_EW, GetRailTypeInfo(_cur_railtype)->cursor.rail_ew, HT_LINE | HT_DIR_HL);
585 this->last_user_action = widget;
586 break;
587
588 case WID_RAT_BUILD_Y:
589 HandlePlacePushButton(this, WID_RAT_BUILD_Y, GetRailTypeInfo(_cur_railtype)->cursor.rail_nwse, HT_LINE | HT_DIR_Y);
590 this->last_user_action = widget;
591 break;
592
593 case WID_RAT_AUTORAIL:
594 HandlePlacePushButton(this, WID_RAT_AUTORAIL, GetRailTypeInfo(_cur_railtype)->cursor.autorail, HT_RAIL);
595 this->last_user_action = widget;
596 break;
597
598 case WID_RAT_DEMOLISH:
599 HandlePlacePushButton(this, WID_RAT_DEMOLISH, ANIMCURSOR_DEMOLISH, HT_RECT | HT_DIAGONAL);
600 this->last_user_action = widget;
601 break;
602
603 case WID_RAT_BUILD_DEPOT:
604 if (HandlePlacePushButton(this, WID_RAT_BUILD_DEPOT, GetRailTypeInfo(_cur_railtype)->cursor.depot, HT_RECT)) {
605 ShowBuildTrainDepotPicker(this);
606 this->last_user_action = widget;
607 }
608 break;
609
610 case WID_RAT_BUILD_WAYPOINT:
611 this->last_user_action = widget;
612 if (HandlePlacePushButton(this, WID_RAT_BUILD_WAYPOINT, SPR_CURSOR_WAYPOINT, HT_RECT)) {
613 ShowBuildWaypointPicker(this);
614 }
615 break;
616
617 case WID_RAT_BUILD_STATION:
618 if (HandlePlacePushButton(this, WID_RAT_BUILD_STATION, SPR_CURSOR_RAIL_STATION, HT_RECT)) {
619 ShowStationBuilder(this);
620 this->last_user_action = widget;
621 }
622 break;
623
624 case WID_RAT_BUILD_SIGNALS: {
625 this->last_user_action = widget;
626 bool started = HandlePlacePushButton(this, WID_RAT_BUILD_SIGNALS, ANIMCURSOR_BUILDSIGNALS, HT_RECT);
627 if (started != _ctrl_pressed) {
628 ShowSignalBuilder(this);
629 }
630 break;
631 }
632
633 case WID_RAT_BUILD_BRIDGE:
634 HandlePlacePushButton(this, WID_RAT_BUILD_BRIDGE, SPR_CURSOR_BRIDGE, HT_RECT);
635 this->last_user_action = widget;
636 break;
637
638 case WID_RAT_BUILD_TUNNEL:
639 HandlePlacePushButton(this, WID_RAT_BUILD_TUNNEL, GetRailTypeInfo(_cur_railtype)->cursor.tunnel, HT_SPECIAL);
640 this->last_user_action = widget;
641 break;
642
643 case WID_RAT_REMOVE:
644 BuildRailClick_Remove(this);
645 break;
646
647 case WID_RAT_CONVERT_RAIL:
648 HandlePlacePushButton(this, WID_RAT_CONVERT_RAIL, GetRailTypeInfo(_cur_railtype)->cursor.convert, HT_RECT | HT_DIAGONAL);
649 this->last_user_action = widget;
650 break;
651
652 default: NOT_REACHED();
653 }
654 this->UpdateRemoveWidgetStatus(widget);
655 if (_ctrl_pressed) RailToolbar_CtrlChanged(this);
656 }
657
658 EventState OnHotkey(int hotkey) override
659 {
660 MarkTileDirtyByTile(TileVirtXY(_thd.pos.x, _thd.pos.y)); // redraw tile selection
661 return Window::OnHotkey(hotkey);
662 }
663
664 void OnPlaceObject([[maybe_unused]] Point pt, TileIndex tile) override
665 {
666 switch (this->last_user_action) {
667 case WID_RAT_BUILD_NS:
668 VpStartPlaceSizing(tile, VPM_FIX_VERTICAL | VPM_RAILDIRS, DDSP_PLACE_RAIL);
669 break;
670
671 case WID_RAT_BUILD_X:
672 VpStartPlaceSizing(tile, VPM_FIX_Y | VPM_RAILDIRS, DDSP_PLACE_RAIL);
673 break;
674
675 case WID_RAT_BUILD_EW:
676 VpStartPlaceSizing(tile, VPM_FIX_HORIZONTAL | VPM_RAILDIRS, DDSP_PLACE_RAIL);
677 break;
678
679 case WID_RAT_BUILD_Y:
680 VpStartPlaceSizing(tile, VPM_FIX_X | VPM_RAILDIRS, DDSP_PLACE_RAIL);
681 break;
682
683 case WID_RAT_AUTORAIL:
684 VpStartPlaceSizing(tile, VPM_RAILDIRS, DDSP_PLACE_RAIL);
685 break;
686
687 case WID_RAT_DEMOLISH:
688 PlaceProc_DemolishArea(tile);
689 break;
690
691 case WID_RAT_BUILD_DEPOT:
692 Command<CMD_BUILD_TRAIN_DEPOT>::Post(STR_ERROR_CAN_T_BUILD_TRAIN_DEPOT, CcRailDepot, tile, _cur_railtype, _build_depot_direction);
693 break;
694
695 case WID_RAT_BUILD_WAYPOINT:
696 PlaceRail_Waypoint(tile);
697 break;
698
699 case WID_RAT_BUILD_STATION:
700 PlaceRail_Station(tile);
701 break;
702
703 case WID_RAT_BUILD_SIGNALS:
704 VpStartPlaceSizing(tile, VPM_SIGNALDIRS, DDSP_BUILD_SIGNALS);
705 break;
706
707 case WID_RAT_BUILD_BRIDGE:
708 PlaceRail_Bridge(tile, this);
709 break;
710
711 case WID_RAT_BUILD_TUNNEL:
712 Command<CMD_BUILD_TUNNEL>::Post(STR_ERROR_CAN_T_BUILD_TUNNEL_HERE, CcBuildRailTunnel, tile, TRANSPORT_RAIL, _cur_railtype);
713 break;
714
715 case WID_RAT_CONVERT_RAIL:
716 VpStartPlaceSizing(tile, VPM_X_AND_Y, DDSP_CONVERT_RAIL);
717 break;
718
719 default: NOT_REACHED();
720 }
721 }
722
723 void OnPlaceDrag(ViewportPlaceMethod select_method, [[maybe_unused]] ViewportDragDropSelectionProcess select_proc, [[maybe_unused]] Point pt) override
724 {
725 /* no dragging if you have pressed the convert button */
726 if (FindWindowById(WC_BUILD_SIGNAL, 0) != nullptr && _convert_signal_button && this->IsWidgetLowered(WID_RAT_BUILD_SIGNALS)) return;
727
728 VpSelectTilesWithMethod(pt.x, pt.y, select_method);
729 }
730
731 Point OnInitialPosition(int16_t sm_width, [[maybe_unused]] int16_t sm_height, [[maybe_unused]] int window_number) override
732 {
733 return AlignInitialConstructionToolbar(sm_width);
734 }
735
736 void OnPlaceMouseUp([[maybe_unused]] ViewportPlaceMethod select_method, ViewportDragDropSelectionProcess select_proc, [[maybe_unused]] Point pt, TileIndex start_tile, TileIndex end_tile) override
737 {
738 if (pt.x != -1) {
739 switch (select_proc) {
740 default: NOT_REACHED();
741 case DDSP_BUILD_BRIDGE:
742 if (!_settings_client.gui.persistent_buildingtools) ResetObjectToPlace();
743 ShowBuildBridgeWindow(start_tile, end_tile, TRANSPORT_RAIL, _cur_railtype);
744 break;
745
746 case DDSP_PLACE_RAIL:
747 HandleAutodirPlacement();
748 break;
749
750 case DDSP_BUILD_SIGNALS:
751 HandleAutoSignalPlacement();
752 break;
753
754 case DDSP_DEMOLISH_AREA:
755 GUIPlaceProcDragXY(select_proc, start_tile, end_tile);
756 break;
757
758 case DDSP_CONVERT_RAIL:
759 Command<CMD_CONVERT_RAIL>::Post(STR_ERROR_CAN_T_CONVERT_RAIL, CcPlaySound_CONSTRUCTION_RAIL, end_tile, start_tile, _cur_railtype, _ctrl_pressed);
760 break;
761
762 case DDSP_REMOVE_STATION:
763 case DDSP_BUILD_STATION:
764 if (this->IsWidgetLowered(WID_RAT_BUILD_STATION)) {
765 /* Station */
766 if (_remove_button_clicked) {
767 bool keep_rail = !_ctrl_pressed;
768 Command<CMD_REMOVE_FROM_RAIL_STATION>::Post(STR_ERROR_CAN_T_REMOVE_PART_OF_STATION, CcPlaySound_CONSTRUCTION_RAIL, end_tile, start_tile, keep_rail);
769 } else {
770 HandleStationPlacement(start_tile, end_tile);
771 }
772 } else {
773 /* Waypoint */
774 if (_remove_button_clicked) {
775 bool keep_rail = !_ctrl_pressed;
776 Command<CMD_REMOVE_FROM_RAIL_WAYPOINT>::Post(STR_ERROR_CAN_T_REMOVE_RAIL_WAYPOINT , CcPlaySound_CONSTRUCTION_RAIL, end_tile, start_tile, keep_rail);
777 } else {
778 TileArea ta(start_tile, end_tile);
779 Axis axis = select_method == VPM_X_LIMITED ? AXIS_X : AXIS_Y;
780 bool adjacent = _ctrl_pressed;
781
782 auto proc = [=](bool test, StationID to_join) -> bool {
783 if (test) {
784 return Command<CMD_BUILD_RAIL_WAYPOINT>::Do(CommandFlagsToDCFlags(GetCommandFlags<CMD_BUILD_RAIL_WAYPOINT>()), ta.tile, axis, ta.w, ta.h, _waypoint_gui.sel_class, _waypoint_gui.sel_type, StationID::Invalid(), adjacent).Succeeded();
785 } else {
786 return Command<CMD_BUILD_RAIL_WAYPOINT>::Post(STR_ERROR_CAN_T_BUILD_RAIL_WAYPOINT , CcPlaySound_CONSTRUCTION_RAIL, ta.tile, axis, ta.w, ta.h, _waypoint_gui.sel_class, _waypoint_gui.sel_type, to_join, adjacent);
787 }
788 };
789
790 ShowSelectRailWaypointIfNeeded(ta, proc);
791 }
792 }
793 break;
794 }
795 }
796 }
797
798 void OnPlaceObjectAbort() override
799 {
800 if (this->IsWidgetLowered(WID_RAT_BUILD_STATION)) SetViewportCatchmentStation(nullptr, true);
801 if (this->IsWidgetLowered(WID_RAT_BUILD_WAYPOINT)) SetViewportCatchmentWaypoint(nullptr, true);
802
803 this->RaiseButtons();
804 this->DisableWidget(WID_RAT_REMOVE);
805 this->SetWidgetDirty(WID_RAT_REMOVE);
806
807 CloseWindowById(WC_BUILD_SIGNAL, TRANSPORT_RAIL);
808 CloseWindowById(WC_BUILD_STATION, TRANSPORT_RAIL);
809 CloseWindowById(WC_BUILD_DEPOT, TRANSPORT_RAIL);
810 CloseWindowById(WC_BUILD_WAYPOINT, TRANSPORT_RAIL);
811 CloseWindowById(WC_SELECT_STATION, 0);
812 CloseWindowByClass(WC_BUILD_BRIDGE);
813 }
814
815 void OnPlacePresize([[maybe_unused]] Point pt, TileIndex tile) override
816 {
817 Command<CMD_BUILD_TUNNEL>::Do(DoCommandFlag::Auto, tile, TRANSPORT_RAIL, _cur_railtype);
818 VpSetPresizeRange(tile, _build_tunnel_endtile == 0 ? tile : _build_tunnel_endtile);
819 }
820
821 EventState OnCTRLStateChange() override
822 {
823 /* do not toggle Remove button by Ctrl when placing station */
824 if (!this->IsWidgetLowered(WID_RAT_BUILD_STATION) && !this->IsWidgetLowered(WID_RAT_BUILD_WAYPOINT) && RailToolbar_CtrlChanged(this)) return ES_HANDLED;
825 return ES_NOT_HANDLED;
826 }
827
828 void OnRealtimeTick([[maybe_unused]] uint delta_ms) override
829 {
830 if (this->IsWidgetLowered(WID_RAT_BUILD_WAYPOINT)) CheckRedrawRailWaypointCoverage(this);
831 }
832
838 static EventState RailToolbarGlobalHotkeys(int hotkey)
839 {
840 if (_game_mode != GM_NORMAL) return ES_NOT_HANDLED;
841 extern RailType _last_built_railtype;
842 Window *w = ShowBuildRailToolbar(_last_built_railtype);
843 if (w == nullptr) return ES_NOT_HANDLED;
844 return w->OnHotkey(hotkey);
845 }
846
847 static inline HotkeyList hotkeys{"railtoolbar", {
848 Hotkey('1', "build_ns", WID_RAT_BUILD_NS),
849 Hotkey('2', "build_x", WID_RAT_BUILD_X),
850 Hotkey('3', "build_ew", WID_RAT_BUILD_EW),
851 Hotkey('4', "build_y", WID_RAT_BUILD_Y),
852 Hotkey({'5', 'A' | WKC_GLOBAL_HOTKEY}, "autorail", WID_RAT_AUTORAIL),
853 Hotkey('6', "demolish", WID_RAT_DEMOLISH),
854 Hotkey('7', "depot", WID_RAT_BUILD_DEPOT),
855 Hotkey('8', "waypoint", WID_RAT_BUILD_WAYPOINT),
856 Hotkey('9', "station", WID_RAT_BUILD_STATION),
857 Hotkey('S', "signal", WID_RAT_BUILD_SIGNALS),
858 Hotkey('B', "bridge", WID_RAT_BUILD_BRIDGE),
859 Hotkey('T', "tunnel", WID_RAT_BUILD_TUNNEL),
860 Hotkey('R', "remove", WID_RAT_REMOVE),
861 Hotkey('C', "convert", WID_RAT_CONVERT_RAIL),
862 }, RailToolbarGlobalHotkeys};
863};
864
865static constexpr std::initializer_list<NWidgetPart> _nested_build_rail_widgets = {
866 NWidget(NWID_HORIZONTAL),
867 NWidget(WWT_CLOSEBOX, COLOUR_DARK_GREEN),
868 NWidget(WWT_CAPTION, COLOUR_DARK_GREEN, WID_RAT_CAPTION), SetTextStyle(TC_WHITE),
869 NWidget(WWT_STICKYBOX, COLOUR_DARK_GREEN),
870 EndContainer(),
871 NWidget(NWID_HORIZONTAL),
872 NWidget(WWT_IMGBTN, COLOUR_DARK_GREEN, WID_RAT_BUILD_NS),
873 SetFill(0, 1), SetToolbarMinimalSize(1), SetSpriteTip(SPR_IMG_RAIL_NS, STR_RAIL_TOOLBAR_TOOLTIP_BUILD_RAILROAD_TRACK),
874 NWidget(WWT_IMGBTN, COLOUR_DARK_GREEN, WID_RAT_BUILD_X),
875 SetFill(0, 1), SetToolbarMinimalSize(1), SetSpriteTip(SPR_IMG_RAIL_NE, STR_RAIL_TOOLBAR_TOOLTIP_BUILD_RAILROAD_TRACK),
876 NWidget(WWT_IMGBTN, COLOUR_DARK_GREEN, WID_RAT_BUILD_EW),
877 SetFill(0, 1), SetToolbarMinimalSize(1), SetSpriteTip(SPR_IMG_RAIL_EW, STR_RAIL_TOOLBAR_TOOLTIP_BUILD_RAILROAD_TRACK),
878 NWidget(WWT_IMGBTN, COLOUR_DARK_GREEN, WID_RAT_BUILD_Y),
879 SetFill(0, 1), SetToolbarMinimalSize(1), SetSpriteTip(SPR_IMG_RAIL_NW, STR_RAIL_TOOLBAR_TOOLTIP_BUILD_RAILROAD_TRACK),
880 NWidget(WWT_IMGBTN, COLOUR_DARK_GREEN, WID_RAT_AUTORAIL),
881 SetFill(0, 1), SetToolbarMinimalSize(1), SetSpriteTip(SPR_IMG_AUTORAIL, STR_RAIL_TOOLBAR_TOOLTIP_BUILD_AUTORAIL),
882
883 NWidget(WWT_PANEL, COLOUR_DARK_GREEN), SetToolbarSpacerMinimalSize(), EndContainer(),
884
885 NWidget(WWT_IMGBTN, COLOUR_DARK_GREEN, WID_RAT_DEMOLISH),
886 SetFill(0, 1), SetToolbarMinimalSize(1), SetSpriteTip(SPR_IMG_DYNAMITE, STR_TOOLTIP_DEMOLISH_BUILDINGS_ETC),
887 NWidget(WWT_IMGBTN, COLOUR_DARK_GREEN, WID_RAT_BUILD_DEPOT),
888 SetFill(0, 1), SetToolbarMinimalSize(1), SetSpriteTip(SPR_IMG_DEPOT_RAIL, STR_RAIL_TOOLBAR_TOOLTIP_BUILD_TRAIN_DEPOT_FOR_BUILDING),
889 NWidget(WWT_IMGBTN, COLOUR_DARK_GREEN, WID_RAT_BUILD_WAYPOINT),
890 SetFill(0, 1), SetToolbarMinimalSize(1), SetSpriteTip(SPR_IMG_WAYPOINT, STR_RAIL_TOOLBAR_TOOLTIP_CONVERT_RAIL_TO_WAYPOINT),
891 NWidget(WWT_IMGBTN, COLOUR_DARK_GREEN, WID_RAT_BUILD_STATION),
892 SetFill(0, 1), SetToolbarMinimalSize(2), SetSpriteTip(SPR_IMG_RAIL_STATION, STR_RAIL_TOOLBAR_TOOLTIP_BUILD_RAILROAD_STATION),
893 NWidget(WWT_IMGBTN, COLOUR_DARK_GREEN, WID_RAT_BUILD_SIGNALS),
894 SetFill(0, 1), SetToolbarMinimalSize(1), SetSpriteTip(SPR_IMG_RAIL_SIGNALS, STR_RAIL_TOOLBAR_TOOLTIP_BUILD_RAILROAD_SIGNALS),
895 NWidget(WWT_IMGBTN, COLOUR_DARK_GREEN, WID_RAT_BUILD_BRIDGE),
896 SetFill(0, 1), SetToolbarMinimalSize(2), SetSpriteTip(SPR_IMG_BRIDGE, STR_RAIL_TOOLBAR_TOOLTIP_BUILD_RAILROAD_BRIDGE),
897 NWidget(WWT_IMGBTN, COLOUR_DARK_GREEN, WID_RAT_BUILD_TUNNEL),
898 SetFill(0, 1), SetToolbarMinimalSize(1), SetSpriteTip(SPR_IMG_TUNNEL_RAIL, STR_RAIL_TOOLBAR_TOOLTIP_BUILD_RAILROAD_TUNNEL),
899 NWidget(WWT_IMGBTN, COLOUR_DARK_GREEN, WID_RAT_REMOVE),
900 SetFill(0, 1), SetToolbarMinimalSize(1), SetSpriteTip(SPR_IMG_REMOVE, STR_RAIL_TOOLBAR_TOOLTIP_TOGGLE_BUILD_REMOVE_FOR),
901 NWidget(WWT_IMGBTN, COLOUR_DARK_GREEN, WID_RAT_CONVERT_RAIL),
902 SetFill(0, 1), SetToolbarMinimalSize(1), SetSpriteTip(SPR_IMG_CONVERT_RAIL, STR_RAIL_TOOLBAR_TOOLTIP_CONVERT_RAIL),
903 EndContainer(),
904};
905
906static WindowDesc _build_rail_desc(
907 WDP_MANUAL, "toolbar_rail", 0, 0,
908 WC_BUILD_TOOLBAR, WC_NONE,
909 WindowDefaultFlag::Construction,
910 _nested_build_rail_widgets,
911 &BuildRailToolbarWindow::hotkeys
912);
913
914
923 Window *ShowBuildRailToolbar(RailType railtype)
924{
925 if (!Company::IsValidID(_local_company)) return nullptr;
926 if (!ValParamRailType(railtype)) return nullptr;
927
928 CloseWindowByClass(WC_BUILD_TOOLBAR);
929 _cur_railtype = railtype;
930 _remove_button_clicked = false;
931 return new BuildRailToolbarWindow(_build_rail_desc, railtype);
932}
933
934/* TODO: For custom stations, respect their allowed platforms/lengths bitmasks!
935 * --pasky */
936
937static void HandleStationPlacement(TileIndex start, TileIndex end)
938{
939 TileArea ta(start, end);
940 uint numtracks = ta.w;
941 uint platlength = ta.h;
942
943 if (_station_gui.axis == AXIS_X) std::swap(numtracks, platlength);
944
945 StationPickerSelection params = _station_gui;
946 RailType rt = _cur_railtype;
947 bool adjacent = _ctrl_pressed;
948
949 auto proc = [=](bool test, StationID to_join) -> bool {
950 if (test) {
951 return Command<CMD_BUILD_RAIL_STATION>::Do(CommandFlagsToDCFlags(GetCommandFlags<CMD_BUILD_RAIL_STATION>()), ta.tile, rt, params.axis, numtracks, platlength, params.sel_class, params.sel_type, StationID::Invalid(), adjacent).Succeeded();
952 } else {
953 return Command<CMD_BUILD_RAIL_STATION>::Post(STR_ERROR_CAN_T_BUILD_RAILROAD_STATION, CcStation, ta.tile, rt, params.axis, numtracks, platlength, params.sel_class, params.sel_type, to_join, adjacent);
954 }
955 };
956
957 ShowSelectStationIfNeeded(ta, proc);
958}
959
965 static bool StationUsesDefaultType(const BaseStation *bst)
966{
967 for (TileIndex t : bst->train_station) {
968 if (bst->TileBelongsToRailStation(t) && HasStationRail(t) && GetCustomStationSpecIndex(t) == 0) return true;
969 }
970 return false;
971}
972
973 class StationPickerCallbacks : public PickerCallbacksNewGRFClass<StationClass> {
974public:
975 StationPickerCallbacks() : PickerCallbacksNewGRFClass<StationClass>("fav_stations") {}
976
977 GrfSpecFeature GetFeature() const override { return GSF_STATIONS; }
978
979 StringID GetClassTooltip() const override { return STR_PICKER_STATION_CLASS_TOOLTIP; }
980 StringID GetTypeTooltip() const override { return STR_PICKER_STATION_TYPE_TOOLTIP; }
981
982 bool IsActive() const override
983 {
984 for (const auto &cls : StationClass::Classes()) {
985 if (IsWaypointClass(cls)) continue;
986 for (const auto *spec : cls.Specs()) {
987 if (spec != nullptr) return true;
988 }
989 }
990 return false;
991 }
992
993 bool HasClassChoice() const override
994 {
995 return std::ranges::count_if(StationClass::Classes(), std::not_fn(IsWaypointClass)) > 1;
996 }
997
998 int GetSelectedClass() const override { return _station_gui.sel_class; }
999 void SetSelectedClass(int id) const override { _station_gui.sel_class = this->GetClassIndex(id); }
1000
1001 StringID GetClassName(int id) const override
1002 {
1003 const auto *sc = GetClass(id);
1004 if (IsWaypointClass(*sc)) return INVALID_STRING_ID;
1005 return sc->name;
1006 }
1007
1008 int GetSelectedType() const override { return _station_gui.sel_type; }
1009 void SetSelectedType(int id) const override { _station_gui.sel_type = id; }
1010
1011 StringID GetTypeName(int cls_id, int id) const override
1012 {
1013 const auto *spec = this->GetSpec(cls_id, id);
1014 return (spec == nullptr) ? STR_STATION_CLASS_DFLT_STATION : spec->name;
1015 }
1016
1017 std::span<const BadgeID> GetTypeBadges(int cls_id, int id) const override
1018 {
1019 const auto *spec = this->GetSpec(cls_id, id);
1020 if (spec == nullptr) return {};
1021 return spec->badges;
1022 }
1023
1024 bool IsTypeAvailable(int cls_id, int id) const override
1025 {
1026 return IsStationAvailable(this->GetSpec(cls_id, id));
1027 }
1028
1029 void DrawType(int x, int y, int cls_id, int id) const override
1030 {
1031 if (!DrawStationTile(x, y, _cur_railtype, _station_gui.axis, this->GetClassIndex(cls_id), id)) {
1032 StationPickerDrawSprite(x, y, StationType::Rail, _cur_railtype, INVALID_ROADTYPE, 2 + _station_gui.axis);
1033 }
1034 }
1035
1036 void FillUsedItems(std::set<PickerItem> &items) override
1037 {
1038 bool default_added = false;
1039 for (const Station *st : Station::Iterate()) {
1040 if (st->owner != _local_company) continue;
1041 if (!default_added && StationUsesDefaultType(st)) {
1042 items.insert({0, 0, STAT_CLASS_DFLT, 0});
1043 default_added = true;
1044 }
1045 for (const auto &sm : st->speclist) {
1046 if (sm.spec == nullptr) continue;
1047 items.insert({sm.grfid, sm.localidx, sm.spec->class_index, sm.spec->index});
1048 }
1049 }
1050 }
1051
1052 static StationPickerCallbacks instance;
1053};
1054/* static */ StationPickerCallbacks StationPickerCallbacks::instance;
1055
1056 struct BuildRailStationWindow : public PickerWindow {
1057private:
1058 uint coverage_height = 0;
1059
1065 void CheckSelectedSize(const StationSpec *statspec)
1066 {
1067 if (statspec == nullptr || _settings_client.gui.station_dragdrop) return;
1068
1069 /* If current number of tracks is not allowed, make it as big as possible */
1070 if (HasBit(statspec->disallowed_platforms, _settings_client.gui.station_numtracks - 1)) {
1071 this->RaiseWidget(_settings_client.gui.station_numtracks + WID_BRAS_PLATFORM_NUM_BEGIN);
1072 _settings_client.gui.station_numtracks = 1;
1073 if (statspec->disallowed_platforms != UINT8_MAX) {
1074 while (HasBit(statspec->disallowed_platforms, _settings_client.gui.station_numtracks - 1)) {
1075 _settings_client.gui.station_numtracks++;
1076 }
1077 this->LowerWidget(_settings_client.gui.station_numtracks + WID_BRAS_PLATFORM_NUM_BEGIN);
1078 }
1079 }
1080
1081 if (HasBit(statspec->disallowed_lengths, _settings_client.gui.station_platlength - 1)) {
1082 this->RaiseWidget(_settings_client.gui.station_platlength + WID_BRAS_PLATFORM_LEN_BEGIN);
1083 _settings_client.gui.station_platlength = 1;
1084 if (statspec->disallowed_lengths != UINT8_MAX) {
1085 while (HasBit(statspec->disallowed_lengths, _settings_client.gui.station_platlength - 1)) {
1086 _settings_client.gui.station_platlength++;
1087 }
1088 this->LowerWidget(_settings_client.gui.station_platlength + WID_BRAS_PLATFORM_LEN_BEGIN);
1089 }
1090 }
1091 }
1092
1093public:
1094 BuildRailStationWindow(WindowDesc &desc, Window *parent) : PickerWindow(desc, parent, TRANSPORT_RAIL, StationPickerCallbacks::instance)
1095 {
1096 this->coverage_height = 2 * GetCharacterHeight(FS_NORMAL) + WidgetDimensions::scaled.vsep_normal;
1097 this->ConstructWindow();
1098 }
1099
1100 void OnInit() override
1101 {
1102 this->LowerWidget(WID_BRAS_PLATFORM_DIR_X + _station_gui.axis);
1103 if (_settings_client.gui.station_dragdrop) {
1104 this->LowerWidget(WID_BRAS_PLATFORM_DRAG_N_DROP);
1105 } else {
1106 this->LowerWidget(WID_BRAS_PLATFORM_NUM_BEGIN + _settings_client.gui.station_numtracks);
1107 this->LowerWidget(WID_BRAS_PLATFORM_LEN_BEGIN + _settings_client.gui.station_platlength);
1108 }
1109 this->SetWidgetLoweredState(WID_BRAS_HIGHLIGHT_OFF, !_settings_client.gui.station_show_coverage);
1110 this->SetWidgetLoweredState(WID_BRAS_HIGHLIGHT_ON, _settings_client.gui.station_show_coverage);
1111
1112 this->PickerWindow::OnInit();
1113 }
1114
1115 void Close([[maybe_unused]] int data = 0) override
1116 {
1117 CloseWindowById(WC_SELECT_STATION, 0);
1118 this->PickerWindow::Close();
1119 }
1120
1121 void OnInvalidateData([[maybe_unused]] int data = 0, [[maybe_unused]] bool gui_scope = true) override
1122 {
1123 if (gui_scope) {
1124 const StationSpec *statspec = StationClass::Get(_station_gui.sel_class)->GetSpec(_station_gui.sel_type);
1125 this->CheckSelectedSize(statspec);
1126 }
1127
1128 this->PickerWindow::OnInvalidateData(data, gui_scope);
1129 }
1130
1131 void OnPaint() override
1132 {
1133 const StationSpec *statspec = StationClass::Get(_station_gui.sel_class)->GetSpec(_station_gui.sel_type);
1134
1135 if (_settings_client.gui.station_dragdrop) {
1136 SetTileSelectSize(1, 1);
1137 } else {
1138 int x = _settings_client.gui.station_numtracks;
1139 int y = _settings_client.gui.station_platlength;
1140 if (_station_gui.axis == AXIS_X) std::swap(x, y);
1141 if (!_remove_button_clicked) {
1142 SetTileSelectSize(x, y);
1143 }
1144 }
1145
1146 int rad = (_settings_game.station.modified_catchment) ? CA_TRAIN : CA_UNMODIFIED;
1147
1148 if (_settings_client.gui.station_show_coverage) SetTileSelectBigSize(-rad, -rad, 2 * rad, 2 * rad);
1149
1150 for (uint bits = 0; bits < 7; bits++) {
1151 bool disable = bits >= _settings_game.station.station_spread;
1152 if (statspec == nullptr) {
1153 this->SetWidgetDisabledState(bits + WID_BRAS_PLATFORM_NUM_1, disable);
1154 this->SetWidgetDisabledState(bits + WID_BRAS_PLATFORM_LEN_1, disable);
1155 } else {
1156 this->SetWidgetDisabledState(bits + WID_BRAS_PLATFORM_NUM_1, HasBit(statspec->disallowed_platforms, bits) || disable);
1157 this->SetWidgetDisabledState(bits + WID_BRAS_PLATFORM_LEN_1, HasBit(statspec->disallowed_lengths, bits) || disable);
1158 }
1159 }
1160
1161 this->DrawWidgets();
1162
1163 if (this->IsShaded()) return;
1164 /* 'Accepts' and 'Supplies' texts. */
1165 Rect r = this->GetWidget<NWidgetBase>(WID_BRAS_COVERAGE_TEXTS)->GetCurrentRect();
1166 const int bottom = r.bottom;
1167 r.bottom = INT_MAX; // Allow overflow as we want to know the required height.
1168 if (statspec != nullptr) r.top = DrawBadgeNameList(r, statspec->badges, GSF_STATIONS);
1169 r.top = DrawStationCoverageAreaText(r, SCT_ALL, rad, false) + WidgetDimensions::scaled.vsep_normal;
1170 r.top = DrawStationCoverageAreaText(r, SCT_ALL, rad, true);
1171 /* Resize background if the window is too small.
1172 * Never make the window smaller to avoid oscillating if the size change affects the acceptance.
1173 * (This is the case, if making the window bigger moves the mouse into the window.) */
1174 if (r.top > bottom) {
1175 this->coverage_height += r.top - bottom;
1176 this->ReInit();
1177 }
1178 }
1179
1180 void UpdateWidgetSize(WidgetID widget, Dimension &size, [[maybe_unused]] const Dimension &padding, [[maybe_unused]] Dimension &fill, [[maybe_unused]] Dimension &resize) override
1181 {
1182 switch (widget) {
1183 case WID_BRAS_PLATFORM_DIR_X:
1184 case WID_BRAS_PLATFORM_DIR_Y:
1185 size.width = ScaleGUITrad(PREVIEW_WIDTH) + WidgetDimensions::scaled.fullbevel.Horizontal();
1186 size.height = ScaleGUITrad(PREVIEW_HEIGHT) + WidgetDimensions::scaled.fullbevel.Vertical();
1187 break;
1188
1189 case WID_BRAS_COVERAGE_TEXTS:
1190 size.height = this->coverage_height;
1191 break;
1192
1193 default:
1194 this->PickerWindow::UpdateWidgetSize(widget, size, padding, fill, resize);
1195 break;
1196 }
1197 }
1198
1199 void DrawWidget(const Rect &r, WidgetID widget) const override
1200 {
1201 DrawPixelInfo tmp_dpi;
1202
1203 switch (widget) {
1204 case WID_BRAS_PLATFORM_DIR_X: {
1205 /* Set up a clipping area for the '/' station preview */
1206 Rect ir = r.Shrink(WidgetDimensions::scaled.bevel);
1207 if (FillDrawPixelInfo(&tmp_dpi, ir)) {
1208 AutoRestoreBackup dpi_backup(_cur_dpi, &tmp_dpi);
1209 int x = (ir.Width() - ScaleSpriteTrad(PREVIEW_WIDTH)) / 2 + ScaleSpriteTrad(PREVIEW_LEFT);
1210 int y = (ir.Height() + ScaleSpriteTrad(PREVIEW_HEIGHT)) / 2 - ScaleSpriteTrad(PREVIEW_BOTTOM);
1211 if (!DrawStationTile(x, y, _cur_railtype, AXIS_X, _station_gui.sel_class, _station_gui.sel_type)) {
1212 StationPickerDrawSprite(x, y, StationType::Rail, _cur_railtype, INVALID_ROADTYPE, 2);
1213 }
1214 }
1215 break;
1216 }
1217
1218 case WID_BRAS_PLATFORM_DIR_Y: {
1219 /* Set up a clipping area for the '\' station preview */
1220 Rect ir = r.Shrink(WidgetDimensions::scaled.bevel);
1221 if (FillDrawPixelInfo(&tmp_dpi, ir)) {
1222 AutoRestoreBackup dpi_backup(_cur_dpi, &tmp_dpi);
1223 int x = (ir.Width() - ScaleSpriteTrad(PREVIEW_WIDTH)) / 2 + ScaleSpriteTrad(PREVIEW_LEFT);
1224 int y = (ir.Height() + ScaleSpriteTrad(PREVIEW_HEIGHT)) / 2 - ScaleSpriteTrad(PREVIEW_BOTTOM);
1225 if (!DrawStationTile(x, y, _cur_railtype, AXIS_Y, _station_gui.sel_class, _station_gui.sel_type)) {
1226 StationPickerDrawSprite(x, y, StationType::Rail, _cur_railtype, INVALID_ROADTYPE, 3);
1227 }
1228 }
1229 break;
1230 }
1231
1232 default:
1233 this->PickerWindow::DrawWidget(r, widget);
1234 break;
1235 }
1236 }
1237
1238 void OnClick([[maybe_unused]] Point pt, WidgetID widget, [[maybe_unused]] int click_count) override
1239 {
1240 switch (widget) {
1241 case WID_BRAS_PLATFORM_DIR_X:
1242 case WID_BRAS_PLATFORM_DIR_Y:
1243 this->RaiseWidget(WID_BRAS_PLATFORM_DIR_X + _station_gui.axis);
1244 _station_gui.axis = (Axis)(widget - WID_BRAS_PLATFORM_DIR_X);
1245 this->LowerWidget(WID_BRAS_PLATFORM_DIR_X + _station_gui.axis);
1246 SndClickBeep();
1247 this->SetDirty();
1248 CloseWindowById(WC_SELECT_STATION, 0);
1249 break;
1250
1251 case WID_BRAS_PLATFORM_NUM_1:
1252 case WID_BRAS_PLATFORM_NUM_2:
1253 case WID_BRAS_PLATFORM_NUM_3:
1254 case WID_BRAS_PLATFORM_NUM_4:
1255 case WID_BRAS_PLATFORM_NUM_5:
1256 case WID_BRAS_PLATFORM_NUM_6:
1257 case WID_BRAS_PLATFORM_NUM_7: {
1258 this->RaiseWidget(WID_BRAS_PLATFORM_NUM_BEGIN + _settings_client.gui.station_numtracks);
1259 this->RaiseWidget(WID_BRAS_PLATFORM_DRAG_N_DROP);
1260
1261 _settings_client.gui.station_numtracks = widget - WID_BRAS_PLATFORM_NUM_BEGIN;
1262 _settings_client.gui.station_dragdrop = false;
1263
1264 const StationSpec *statspec = StationClass::Get(_station_gui.sel_class)->GetSpec(_station_gui.sel_type);
1265 if (statspec != nullptr && HasBit(statspec->disallowed_lengths, _settings_client.gui.station_platlength - 1)) {
1266 /* The previously selected number of platforms in invalid */
1267 for (uint i = 0; i < 7; i++) {
1268 if (!HasBit(statspec->disallowed_lengths, i)) {
1269 this->RaiseWidget(_settings_client.gui.station_platlength + WID_BRAS_PLATFORM_LEN_BEGIN);
1270 _settings_client.gui.station_platlength = i + 1;
1271 break;
1272 }
1273 }
1274 }
1275
1276 this->LowerWidget(_settings_client.gui.station_numtracks + WID_BRAS_PLATFORM_NUM_BEGIN);
1277 this->LowerWidget(_settings_client.gui.station_platlength + WID_BRAS_PLATFORM_LEN_BEGIN);
1278 SndClickBeep();
1279 this->SetDirty();
1280 CloseWindowById(WC_SELECT_STATION, 0);
1281 break;
1282 }
1283
1284 case WID_BRAS_PLATFORM_LEN_1:
1285 case WID_BRAS_PLATFORM_LEN_2:
1286 case WID_BRAS_PLATFORM_LEN_3:
1287 case WID_BRAS_PLATFORM_LEN_4:
1288 case WID_BRAS_PLATFORM_LEN_5:
1289 case WID_BRAS_PLATFORM_LEN_6:
1290 case WID_BRAS_PLATFORM_LEN_7: {
1291 this->RaiseWidget(_settings_client.gui.station_platlength + WID_BRAS_PLATFORM_LEN_BEGIN);
1292 this->RaiseWidget(WID_BRAS_PLATFORM_DRAG_N_DROP);
1293
1294 _settings_client.gui.station_platlength = widget - WID_BRAS_PLATFORM_LEN_BEGIN;
1295 _settings_client.gui.station_dragdrop = false;
1296
1297 const StationSpec *statspec = StationClass::Get(_station_gui.sel_class)->GetSpec(_station_gui.sel_type);
1298 if (statspec != nullptr && HasBit(statspec->disallowed_platforms, _settings_client.gui.station_numtracks - 1)) {
1299 /* The previously selected number of tracks in invalid */
1300 for (uint i = 0; i < 7; i++) {
1301 if (!HasBit(statspec->disallowed_platforms, i)) {
1302 this->RaiseWidget(_settings_client.gui.station_numtracks + WID_BRAS_PLATFORM_NUM_BEGIN);
1303 _settings_client.gui.station_numtracks = i + 1;
1304 break;
1305 }
1306 }
1307 }
1308
1309 this->LowerWidget(_settings_client.gui.station_numtracks + WID_BRAS_PLATFORM_NUM_BEGIN);
1310 this->LowerWidget(_settings_client.gui.station_platlength + WID_BRAS_PLATFORM_LEN_BEGIN);
1311 SndClickBeep();
1312 this->SetDirty();
1313 CloseWindowById(WC_SELECT_STATION, 0);
1314 break;
1315 }
1316
1317 case WID_BRAS_PLATFORM_DRAG_N_DROP: {
1318 _settings_client.gui.station_dragdrop ^= true;
1319
1320 this->ToggleWidgetLoweredState(WID_BRAS_PLATFORM_DRAG_N_DROP);
1321
1322 /* get the first allowed length/number of platforms */
1323 const StationSpec *statspec = StationClass::Get(_station_gui.sel_class)->GetSpec(_station_gui.sel_type);
1324 if (statspec != nullptr && HasBit(statspec->disallowed_lengths, _settings_client.gui.station_platlength - 1)) {
1325 for (uint i = 0; i < 7; i++) {
1326 if (!HasBit(statspec->disallowed_lengths, i)) {
1327 this->RaiseWidget(_settings_client.gui.station_platlength + WID_BRAS_PLATFORM_LEN_BEGIN);
1328 _settings_client.gui.station_platlength = i + 1;
1329 break;
1330 }
1331 }
1332 }
1333 if (statspec != nullptr && HasBit(statspec->disallowed_platforms, _settings_client.gui.station_numtracks - 1)) {
1334 for (uint i = 0; i < 7; i++) {
1335 if (!HasBit(statspec->disallowed_platforms, i)) {
1336 this->RaiseWidget(_settings_client.gui.station_numtracks + WID_BRAS_PLATFORM_NUM_BEGIN);
1337 _settings_client.gui.station_numtracks = i + 1;
1338 break;
1339 }
1340 }
1341 }
1342
1343 this->SetWidgetLoweredState(_settings_client.gui.station_numtracks + WID_BRAS_PLATFORM_NUM_BEGIN, !_settings_client.gui.station_dragdrop);
1344 this->SetWidgetLoweredState(_settings_client.gui.station_platlength + WID_BRAS_PLATFORM_LEN_BEGIN, !_settings_client.gui.station_dragdrop);
1345 SndClickBeep();
1346 this->SetDirty();
1347 CloseWindowById(WC_SELECT_STATION, 0);
1348 break;
1349 }
1350
1351 case WID_BRAS_HIGHLIGHT_OFF:
1352 case WID_BRAS_HIGHLIGHT_ON:
1353 _settings_client.gui.station_show_coverage = (widget != WID_BRAS_HIGHLIGHT_OFF);
1354
1355 this->SetWidgetLoweredState(WID_BRAS_HIGHLIGHT_OFF, !_settings_client.gui.station_show_coverage);
1356 this->SetWidgetLoweredState(WID_BRAS_HIGHLIGHT_ON, _settings_client.gui.station_show_coverage);
1357 SndClickBeep();
1358 this->SetDirty();
1359 SetViewportCatchmentStation(nullptr, true);
1360 break;
1361
1362 default:
1363 this->PickerWindow::OnClick(pt, widget, click_count);
1364 break;
1365 }
1366 }
1367
1368 void OnRealtimeTick([[maybe_unused]] uint delta_ms) override
1369 {
1370 CheckRedrawStationCoverage(this);
1371 }
1372
1378 static EventState BuildRailStationGlobalHotkeys(int hotkey)
1379 {
1380 if (_game_mode == GM_MENU) return ES_NOT_HANDLED;
1381 Window *w = ShowStationBuilder(FindWindowById(WC_BUILD_TOOLBAR, TRANSPORT_RAIL));
1382 if (w == nullptr) return ES_NOT_HANDLED;
1383 return w->OnHotkey(hotkey);
1384 }
1385
1386 static inline HotkeyList hotkeys{"buildrailstation", {
1387 Hotkey('F', "focus_filter_box", PCWHK_FOCUS_FILTER_BOX),
1388 }, BuildRailStationGlobalHotkeys};
1389};
1390
1391static constexpr std::initializer_list<NWidgetPart> _nested_station_builder_widgets = {
1392 NWidget(NWID_HORIZONTAL),
1393 NWidget(WWT_CLOSEBOX, COLOUR_DARK_GREEN),
1394 NWidget(WWT_CAPTION, COLOUR_DARK_GREEN), SetStringTip(STR_STATION_BUILD_RAIL_CAPTION, STR_TOOLTIP_WINDOW_TITLE_DRAG_THIS),
1395 NWidget(WWT_SHADEBOX, COLOUR_DARK_GREEN),
1396 NWidget(WWT_DEFSIZEBOX, COLOUR_DARK_GREEN),
1397 EndContainer(),
1398 NWidget(NWID_HORIZONTAL),
1399 NWidget(NWID_VERTICAL),
1400 NWidgetFunction(MakePickerClassWidgets),
1401 NWidget(WWT_PANEL, COLOUR_DARK_GREEN),
1402 NWidget(NWID_VERTICAL), SetPIP(0, WidgetDimensions::unscaled.vsep_picker, 0), SetPadding(WidgetDimensions::unscaled.picker),
1403 NWidget(WWT_LABEL, INVALID_COLOUR), SetMinimalSize(144, 11), SetFill(1, 0), SetStringTip(STR_STATION_BUILD_ORIENTATION),
1404 NWidget(NWID_HORIZONTAL), SetPIP(0, WidgetDimensions::unscaled.hsep_normal, 0), SetPIPRatio(1, 0, 1),
1405 NWidget(WWT_PANEL, COLOUR_GREY, WID_BRAS_PLATFORM_DIR_X), SetFill(0, 0), SetToolTip(STR_STATION_BUILD_RAILROAD_ORIENTATION_TOOLTIP), EndContainer(),
1406 NWidget(WWT_PANEL, COLOUR_GREY, WID_BRAS_PLATFORM_DIR_Y), SetFill(0, 0), SetToolTip(STR_STATION_BUILD_RAILROAD_ORIENTATION_TOOLTIP), EndContainer(),
1407 EndContainer(),
1408 NWidget(WWT_LABEL, INVALID_COLOUR), SetMinimalSize(144, 11), SetFill(1, 0), SetStringTip(STR_STATION_BUILD_NUMBER_OF_TRACKS),
1409 NWidget(NWID_HORIZONTAL), SetPIPRatio(1, 0, 1),
1410 NWidget(WWT_TEXTBTN, COLOUR_GREY, WID_BRAS_PLATFORM_NUM_1), SetAspect(1.25f), SetStringTip(STR_BLACK_1, STR_STATION_BUILD_NUMBER_OF_TRACKS_TOOLTIP),
1411 NWidget(WWT_TEXTBTN, COLOUR_GREY, WID_BRAS_PLATFORM_NUM_2), SetAspect(1.25f), SetStringTip(STR_BLACK_2, STR_STATION_BUILD_NUMBER_OF_TRACKS_TOOLTIP),
1412 NWidget(WWT_TEXTBTN, COLOUR_GREY, WID_BRAS_PLATFORM_NUM_3), SetAspect(1.25f), SetStringTip(STR_BLACK_3, STR_STATION_BUILD_NUMBER_OF_TRACKS_TOOLTIP),
1413 NWidget(WWT_TEXTBTN, COLOUR_GREY, WID_BRAS_PLATFORM_NUM_4), SetAspect(1.25f), SetStringTip(STR_BLACK_4, STR_STATION_BUILD_NUMBER_OF_TRACKS_TOOLTIP),
1414 NWidget(WWT_TEXTBTN, COLOUR_GREY, WID_BRAS_PLATFORM_NUM_5), SetAspect(1.25f), SetStringTip(STR_BLACK_5, STR_STATION_BUILD_NUMBER_OF_TRACKS_TOOLTIP),
1415 NWidget(WWT_TEXTBTN, COLOUR_GREY, WID_BRAS_PLATFORM_NUM_6), SetAspect(1.25f), SetStringTip(STR_BLACK_6, STR_STATION_BUILD_NUMBER_OF_TRACKS_TOOLTIP),
1416 NWidget(WWT_TEXTBTN, COLOUR_GREY, WID_BRAS_PLATFORM_NUM_7), SetAspect(1.25f), SetStringTip(STR_BLACK_7, STR_STATION_BUILD_NUMBER_OF_TRACKS_TOOLTIP),
1417 EndContainer(),
1418 NWidget(WWT_LABEL, INVALID_COLOUR), SetMinimalSize(144, 11), SetFill(1, 0), SetStringTip(STR_STATION_BUILD_PLATFORM_LENGTH),
1419 NWidget(NWID_HORIZONTAL), SetPIPRatio(1, 0, 1),
1420 NWidget(WWT_TEXTBTN, COLOUR_GREY, WID_BRAS_PLATFORM_LEN_1), SetAspect(1.25f), SetStringTip(STR_BLACK_1, STR_STATION_BUILD_PLATFORM_LENGTH_TOOLTIP),
1421 NWidget(WWT_TEXTBTN, COLOUR_GREY, WID_BRAS_PLATFORM_LEN_2), SetAspect(1.25f), SetStringTip(STR_BLACK_2, STR_STATION_BUILD_PLATFORM_LENGTH_TOOLTIP),
1422 NWidget(WWT_TEXTBTN, COLOUR_GREY, WID_BRAS_PLATFORM_LEN_3), SetAspect(1.25f), SetStringTip(STR_BLACK_3, STR_STATION_BUILD_PLATFORM_LENGTH_TOOLTIP),
1423 NWidget(WWT_TEXTBTN, COLOUR_GREY, WID_BRAS_PLATFORM_LEN_4), SetAspect(1.25f), SetStringTip(STR_BLACK_4, STR_STATION_BUILD_PLATFORM_LENGTH_TOOLTIP),
1424 NWidget(WWT_TEXTBTN, COLOUR_GREY, WID_BRAS_PLATFORM_LEN_5), SetAspect(1.25f), SetStringTip(STR_BLACK_5, STR_STATION_BUILD_PLATFORM_LENGTH_TOOLTIP),
1425 NWidget(WWT_TEXTBTN, COLOUR_GREY, WID_BRAS_PLATFORM_LEN_6), SetAspect(1.25f), SetStringTip(STR_BLACK_6, STR_STATION_BUILD_PLATFORM_LENGTH_TOOLTIP),
1426 NWidget(WWT_TEXTBTN, COLOUR_GREY, WID_BRAS_PLATFORM_LEN_7), SetAspect(1.25f), SetStringTip(STR_BLACK_7, STR_STATION_BUILD_PLATFORM_LENGTH_TOOLTIP),
1427 EndContainer(),
1428 NWidget(NWID_HORIZONTAL), SetPIPRatio(1, 0, 1),
1429 NWidget(WWT_TEXTBTN, COLOUR_GREY, WID_BRAS_PLATFORM_DRAG_N_DROP), SetMinimalSize(75, 12), SetStringTip(STR_STATION_BUILD_DRAG_DROP, STR_STATION_BUILD_DRAG_DROP_TOOLTIP),
1430 EndContainer(),
1431 NWidget(WWT_LABEL, INVALID_COLOUR), SetStringTip(STR_STATION_BUILD_COVERAGE_AREA_TITLE), SetFill(1, 0),
1432 NWidget(NWID_HORIZONTAL), SetPIPRatio(1, 0, 1),
1433 NWidget(WWT_TEXTBTN, COLOUR_GREY, WID_BRAS_HIGHLIGHT_OFF), SetMinimalSize(60, 12), SetStringTip(STR_STATION_BUILD_COVERAGE_OFF, STR_STATION_BUILD_COVERAGE_AREA_OFF_TOOLTIP),
1434 NWidget(WWT_TEXTBTN, COLOUR_GREY, WID_BRAS_HIGHLIGHT_ON), SetMinimalSize(60, 12), SetStringTip(STR_STATION_BUILD_COVERAGE_ON, STR_STATION_BUILD_COVERAGE_AREA_ON_TOOLTIP),
1435 EndContainer(),
1436 NWidget(WWT_EMPTY, INVALID_COLOUR, WID_BRAS_COVERAGE_TEXTS), SetFill(1, 1), SetResize(1, 0), SetMinimalTextLines(2, 0),
1437 EndContainer(),
1438 EndContainer(),
1439 EndContainer(),
1440 NWidgetFunction(MakePickerTypeWidgets),
1441 EndContainer(),
1442};
1443
1445 static WindowDesc _station_builder_desc(
1446 WDP_AUTO, "build_station_rail", 0, 0,
1447 WC_BUILD_STATION, WC_BUILD_TOOLBAR,
1448 WindowDefaultFlag::Construction,
1449 _nested_station_builder_widgets,
1450 &BuildRailStationWindow::hotkeys
1451);
1452
1454 static Window *ShowStationBuilder(Window *parent)
1455{
1456 return new BuildRailStationWindow(_station_builder_desc, parent);
1457}
1458
1459 struct BuildSignalWindow : public PickerWindowBase {
1460private:
1461 Dimension sig_sprite_size{};
1462 int sig_sprite_bottom_offset = 0;
1463
1468 void DrawSignalSprite(const Rect &r, SpriteID image) const
1469 {
1470 Point offset;
1471 Dimension sprite_size = GetSpriteSize(image, &offset);
1472 Rect ir = r.Shrink(WidgetDimensions::scaled.imgbtn);
1473 int x = CentreBounds(ir.left, ir.right, sprite_size.width - offset.x) - offset.x; // centered
1474 int y = ir.top - sig_sprite_bottom_offset +
1475 (ir.Height() + sig_sprite_size.height) / 2; // aligned to bottom
1476
1477 DrawSprite(image, PAL_NONE, x, y);
1478 }
1479
1481 void SetSignalUIMode()
1482 {
1483 bool show_non_path_signals = (_settings_client.gui.signal_gui_mode == SIGNAL_GUI_ALL);
1484
1485 this->GetWidget<NWidgetStacked>(WID_BS_BLOCK_SEL)->SetDisplayedPlane(show_non_path_signals ? 0 : SZSP_NONE);
1486 this->GetWidget<NWidgetStacked>(WID_BS_BLOCK_SPACER_SEL)->SetDisplayedPlane(show_non_path_signals ? 0 : SZSP_NONE);
1487 }
1488
1489public:
1490 BuildSignalWindow(WindowDesc &desc, Window *parent) : PickerWindowBase(desc, parent)
1491 {
1492 this->CreateNestedTree();
1493 this->SetSignalUIMode();
1494 this->FinishInitNested(TRANSPORT_RAIL);
1495 this->OnInvalidateData();
1496 }
1497
1498 void Close([[maybe_unused]] int data = 0) override
1499 {
1500 _convert_signal_button = false;
1501 this->PickerWindowBase::Close();
1502 }
1503
1504 void OnInit() override
1505 {
1506 /* Calculate maximum signal sprite size. */
1507 this->sig_sprite_size.width = 0;
1508 this->sig_sprite_size.height = 0;
1509 this->sig_sprite_bottom_offset = 0;
1510 const RailTypeInfo *rti = GetRailTypeInfo(_cur_railtype);
1511 for (uint type = SIGTYPE_BLOCK; type < SIGTYPE_END; type++) {
1512 for (uint variant = SIG_ELECTRIC; variant <= SIG_SEMAPHORE; variant++) {
1513 for (uint lowered = 0; lowered < 2; lowered++) {
1514 Point offset;
1515 Dimension sprite_size = GetSpriteSize(rti->gui_sprites.signals[type][variant][lowered], &offset);
1516 this->sig_sprite_bottom_offset = std::max<int>(this->sig_sprite_bottom_offset, sprite_size.height);
1517 this->sig_sprite_size.width = std::max<int>(this->sig_sprite_size.width, sprite_size.width - offset.x);
1518 this->sig_sprite_size.height = std::max<int>(this->sig_sprite_size.height, sprite_size.height - offset.y);
1519 }
1520 }
1521 }
1522 }
1523
1524 void UpdateWidgetSize(WidgetID widget, Dimension &size, [[maybe_unused]] const Dimension &padding, [[maybe_unused]] Dimension &fill, [[maybe_unused]] Dimension &resize) override
1525 {
1526 if (widget == WID_BS_DRAG_SIGNALS_DENSITY_LABEL) {
1527 /* Two digits for signals density. */
1528 size.width = std::max(size.width, 2 * GetDigitWidth() + padding.width + WidgetDimensions::scaled.framerect.Horizontal());
1529 } else if (IsInsideMM(widget, WID_BS_SEMAPHORE_NORM, WID_BS_ELECTRIC_PBS_OWAY + 1)) {
1530 size.width = std::max(size.width, this->sig_sprite_size.width + padding.width);
1531 size.height = std::max(size.height, this->sig_sprite_size.height + padding.height);
1532 }
1533 }
1534
1535 std::string GetWidgetString(WidgetID widget, StringID stringid) const override
1536 {
1537 switch (widget) {
1538 case WID_BS_DRAG_SIGNALS_DENSITY_LABEL:
1539 return GetString(STR_JUST_INT, _settings_client.gui.drag_signals_density);
1540
1541 default:
1542 return this->Window::GetWidgetString(widget, stringid);
1543 }
1544 }
1545
1546 void DrawWidget(const Rect &r, WidgetID widget) const override
1547 {
1548 if (IsInsideMM(widget, WID_BS_SEMAPHORE_NORM, WID_BS_ELECTRIC_PBS_OWAY + 1)) {
1549 /* Extract signal from widget number. */
1550 int type = (widget - WID_BS_SEMAPHORE_NORM) % SIGTYPE_END;
1551 int var = SIG_SEMAPHORE - (widget - WID_BS_SEMAPHORE_NORM) / SIGTYPE_END; // SignalVariant order is reversed compared to the widgets.
1552 SpriteID sprite = GetRailTypeInfo(_cur_railtype)->gui_sprites.signals[type][var][this->IsWidgetLowered(widget)];
1553
1554 this->DrawSignalSprite(r, sprite);
1555 }
1556 }
1557
1558 void OnClick([[maybe_unused]] Point pt, WidgetID widget, [[maybe_unused]] int click_count) override
1559 {
1560 switch (widget) {
1561 case WID_BS_SEMAPHORE_NORM:
1562 case WID_BS_SEMAPHORE_ENTRY:
1563 case WID_BS_SEMAPHORE_EXIT:
1564 case WID_BS_SEMAPHORE_COMBO:
1565 case WID_BS_SEMAPHORE_PBS:
1566 case WID_BS_SEMAPHORE_PBS_OWAY:
1567 case WID_BS_ELECTRIC_NORM:
1568 case WID_BS_ELECTRIC_ENTRY:
1569 case WID_BS_ELECTRIC_EXIT:
1570 case WID_BS_ELECTRIC_COMBO:
1571 case WID_BS_ELECTRIC_PBS:
1572 case WID_BS_ELECTRIC_PBS_OWAY:
1573 this->RaiseWidget((_cur_signal_variant == SIG_ELECTRIC ? WID_BS_ELECTRIC_NORM : WID_BS_SEMAPHORE_NORM) + _cur_signal_type);
1574
1575 _cur_signal_type = (SignalType)((uint)((widget - WID_BS_SEMAPHORE_NORM) % (SIGTYPE_LAST + 1)));
1576 _cur_signal_variant = widget >= WID_BS_ELECTRIC_NORM ? SIG_ELECTRIC : SIG_SEMAPHORE;
1577
1578 /* Update default (last-used) signal type in config file. */
1579 _settings_client.gui.default_signal_type = _cur_signal_type;
1580
1581 /* If 'remove' button of rail build toolbar is active, disable it. */
1582 if (_remove_button_clicked) {
1583 Window *w = FindWindowById(WC_BUILD_TOOLBAR, TRANSPORT_RAIL);
1584 if (w != nullptr) ToggleRailButton_Remove(w);
1585 }
1586
1587 SndClickBeep();
1588 break;
1589
1590 case WID_BS_CONVERT:
1591 _convert_signal_button = !_convert_signal_button;
1592 SndClickBeep();
1593 break;
1594
1595 case WID_BS_DRAG_SIGNALS_DENSITY_DECREASE:
1596 if (_settings_client.gui.drag_signals_density > 1) {
1597 _settings_client.gui.drag_signals_density--;
1598 SetWindowDirty(WC_GAME_OPTIONS, WN_GAME_OPTIONS_GAME_SETTINGS);
1599 }
1600 break;
1601
1602 case WID_BS_DRAG_SIGNALS_DENSITY_INCREASE:
1603 if (_settings_client.gui.drag_signals_density < 20) {
1604 _settings_client.gui.drag_signals_density++;
1605 SetWindowDirty(WC_GAME_OPTIONS, WN_GAME_OPTIONS_GAME_SETTINGS);
1606 }
1607 break;
1608
1609 default: break;
1610 }
1611
1612 this->InvalidateData();
1613 }
1614
1620 void OnInvalidateData([[maybe_unused]] int data = 0, [[maybe_unused]] bool gui_scope = true) override
1621 {
1622 if (!gui_scope) return;
1623 this->LowerWidget((_cur_signal_variant == SIG_ELECTRIC ? WID_BS_ELECTRIC_NORM : WID_BS_SEMAPHORE_NORM) + _cur_signal_type);
1624
1625 this->SetWidgetLoweredState(WID_BS_CONVERT, _convert_signal_button);
1626
1627 this->SetWidgetDisabledState(WID_BS_DRAG_SIGNALS_DENSITY_DECREASE, _settings_client.gui.drag_signals_density == 1);
1628 this->SetWidgetDisabledState(WID_BS_DRAG_SIGNALS_DENSITY_INCREASE, _settings_client.gui.drag_signals_density == 20);
1629 }
1630};
1631
1633 static constexpr std::initializer_list<NWidgetPart> _nested_signal_builder_widgets = {
1634 /* Title bar and buttons. */
1635 NWidget(NWID_HORIZONTAL),
1636 NWidget(WWT_CLOSEBOX, COLOUR_DARK_GREEN),
1637 NWidget(WWT_CAPTION, COLOUR_DARK_GREEN, WID_BS_CAPTION), SetStringTip(STR_BUILD_SIGNAL_CAPTION, STR_TOOLTIP_WINDOW_TITLE_DRAG_THIS),
1638 EndContainer(),
1639
1640 /* Container for both signal groups, spacers, and convert/autofill buttons. */
1641 NWidget(NWID_HORIZONTAL),
1642 /* Block signals (can be hidden). */
1643 NWidget(NWID_SELECTION, INVALID_COLOUR, WID_BS_BLOCK_SEL),
1644 NWidget(NWID_VERTICAL, NWidContainerFlag::EqualSize),
1645 /* Semaphore block signals. */
1646 NWidget(NWID_HORIZONTAL, NWidContainerFlag::EqualSize),
1647 NWidget(WWT_PANEL, COLOUR_DARK_GREEN, WID_BS_SEMAPHORE_NORM), SetToolTip(STR_BUILD_SIGNAL_SEMAPHORE_NORM_TOOLTIP), SetToolbarMinimalSize(1), EndContainer(),
1648 NWidget(WWT_PANEL, COLOUR_DARK_GREEN, WID_BS_SEMAPHORE_ENTRY), SetToolTip(STR_BUILD_SIGNAL_SEMAPHORE_ENTRY_TOOLTIP), SetToolbarMinimalSize(1), EndContainer(),
1649 NWidget(WWT_PANEL, COLOUR_DARK_GREEN, WID_BS_SEMAPHORE_EXIT), SetToolTip(STR_BUILD_SIGNAL_SEMAPHORE_EXIT_TOOLTIP), SetToolbarMinimalSize(1), EndContainer(),
1650 NWidget(WWT_PANEL, COLOUR_DARK_GREEN, WID_BS_SEMAPHORE_COMBO), SetToolTip(STR_BUILD_SIGNAL_SEMAPHORE_COMBO_TOOLTIP), SetToolbarMinimalSize(1), EndContainer(),
1651 EndContainer(),
1652 /* Electric block signals. */
1653 NWidget(NWID_HORIZONTAL, NWidContainerFlag::EqualSize),
1654 NWidget(WWT_PANEL, COLOUR_DARK_GREEN, WID_BS_ELECTRIC_NORM), SetToolTip(STR_BUILD_SIGNAL_ELECTRIC_NORM_TOOLTIP), SetToolbarMinimalSize(1), EndContainer(),
1655 NWidget(WWT_PANEL, COLOUR_DARK_GREEN, WID_BS_ELECTRIC_ENTRY), SetToolTip(STR_BUILD_SIGNAL_ELECTRIC_ENTRY_TOOLTIP), SetToolbarMinimalSize(1), EndContainer(),
1656 NWidget(WWT_PANEL, COLOUR_DARK_GREEN, WID_BS_ELECTRIC_EXIT), SetToolTip(STR_BUILD_SIGNAL_ELECTRIC_EXIT_TOOLTIP), SetToolbarMinimalSize(1), EndContainer(),
1657 NWidget(WWT_PANEL, COLOUR_DARK_GREEN, WID_BS_ELECTRIC_COMBO), SetToolTip(STR_BUILD_SIGNAL_ELECTRIC_COMBO_TOOLTIP), SetToolbarMinimalSize(1), EndContainer(),
1658 EndContainer(),
1659 EndContainer(),
1660 EndContainer(),
1661
1662 /* Divider (only shown if block signals visible). */
1663 NWidget(NWID_SELECTION, INVALID_COLOUR, WID_BS_BLOCK_SPACER_SEL),
1664 NWidget(WWT_PANEL, COLOUR_DARK_GREEN), SetFill(0, 0), SetToolbarSpacerMinimalSize(), EndContainer(),
1665 EndContainer(),
1666
1667 /* Path signals. */
1668 NWidget(NWID_VERTICAL, NWidContainerFlag::EqualSize),
1669 /* Semaphore path signals. */
1670 NWidget(NWID_HORIZONTAL, NWidContainerFlag::EqualSize),
1671 NWidget(WWT_PANEL, COLOUR_DARK_GREEN, WID_BS_SEMAPHORE_PBS), SetToolTip(STR_BUILD_SIGNAL_SEMAPHORE_PBS_TOOLTIP), SetToolbarMinimalSize(1), EndContainer(),
1672 NWidget(WWT_PANEL, COLOUR_DARK_GREEN, WID_BS_SEMAPHORE_PBS_OWAY), SetToolTip(STR_BUILD_SIGNAL_SEMAPHORE_PBS_OWAY_TOOLTIP), SetToolbarMinimalSize(1), EndContainer(),
1673 EndContainer(),
1674 /* Electric path signals. */
1675 NWidget(NWID_HORIZONTAL, NWidContainerFlag::EqualSize),
1676 NWidget(WWT_PANEL, COLOUR_DARK_GREEN, WID_BS_ELECTRIC_PBS), SetToolTip(STR_BUILD_SIGNAL_ELECTRIC_PBS_TOOLTIP), SetToolbarMinimalSize(1), EndContainer(),
1677 NWidget(WWT_PANEL, COLOUR_DARK_GREEN, WID_BS_ELECTRIC_PBS_OWAY), SetToolTip(STR_BUILD_SIGNAL_ELECTRIC_PBS_OWAY_TOOLTIP), SetToolbarMinimalSize(1), EndContainer(),
1678 EndContainer(),
1679 EndContainer(),
1680
1681 /* Convert/autofill buttons. */
1682 NWidget(NWID_VERTICAL, NWidContainerFlag::EqualSize),
1683 NWidget(WWT_IMGBTN, COLOUR_DARK_GREEN, WID_BS_CONVERT), SetSpriteTip(SPR_IMG_SIGNAL_CONVERT, STR_BUILD_SIGNAL_CONVERT_TOOLTIP), SetFill(0, 1),
1684 NWidget(WWT_PANEL, COLOUR_DARK_GREEN), SetToolTip(STR_BUILD_SIGNAL_DRAG_SIGNALS_DENSITY_TOOLTIP), SetFill(0, 1),
1685 NWidget(NWID_VERTICAL), SetPadding(2), SetPIPRatio(1, 0, 1),
1686 NWidget(WWT_LABEL, INVALID_COLOUR, WID_BS_DRAG_SIGNALS_DENSITY_LABEL), SetToolTip(STR_BUILD_SIGNAL_DRAG_SIGNALS_DENSITY_TOOLTIP), SetTextStyle(TC_ORANGE), SetFill(1, 1),
1687 NWidget(NWID_HORIZONTAL), SetPIPRatio(1, 0, 1),
1688 NWidget(WWT_PUSHARROWBTN, COLOUR_GREY, WID_BS_DRAG_SIGNALS_DENSITY_DECREASE), SetMinimalSize(9, 12), SetArrowWidgetTypeTip(AWV_DECREASE, STR_BUILD_SIGNAL_DRAG_SIGNALS_DENSITY_DECREASE_TOOLTIP),
1689 NWidget(WWT_PUSHARROWBTN, COLOUR_GREY, WID_BS_DRAG_SIGNALS_DENSITY_INCREASE), SetMinimalSize(9, 12), SetArrowWidgetTypeTip(AWV_INCREASE, STR_BUILD_SIGNAL_DRAG_SIGNALS_DENSITY_INCREASE_TOOLTIP),
1690 EndContainer(),
1691 EndContainer(),
1692 EndContainer(),
1693 EndContainer(),
1694 EndContainer(),
1695};
1696
1698 static WindowDesc _signal_builder_desc(
1699 WDP_AUTO, {}, 0, 0,
1700 WC_BUILD_SIGNAL, WC_BUILD_TOOLBAR,
1701 WindowDefaultFlag::Construction,
1702 _nested_signal_builder_widgets
1703);
1704
1708 static void ShowSignalBuilder(Window *parent)
1709{
1710 new BuildSignalWindow(_signal_builder_desc, parent);
1711}
1712
1713 struct BuildRailDepotWindow : public PickerWindowBase {
1714 BuildRailDepotWindow(WindowDesc &desc, Window *parent) : PickerWindowBase(desc, parent)
1715 {
1716 this->InitNested(TRANSPORT_RAIL);
1717 this->LowerWidget(WID_BRAD_DEPOT_NE + _build_depot_direction);
1718 }
1719
1720 void UpdateWidgetSize(WidgetID widget, Dimension &size, [[maybe_unused]] const Dimension &padding, [[maybe_unused]] Dimension &fill, [[maybe_unused]] Dimension &resize) override
1721 {
1722 if (!IsInsideMM(widget, WID_BRAD_DEPOT_NE, WID_BRAD_DEPOT_NW + 1)) return;
1723
1724 size.width = ScaleGUITrad(64) + WidgetDimensions::scaled.fullbevel.Horizontal();
1725 size.height = ScaleGUITrad(48) + WidgetDimensions::scaled.fullbevel.Vertical();
1726 }
1727
1728 void DrawWidget(const Rect &r, WidgetID widget) const override
1729 {
1730 if (!IsInsideMM(widget, WID_BRAD_DEPOT_NE, WID_BRAD_DEPOT_NW + 1)) return;
1731
1732 DrawPixelInfo tmp_dpi;
1733 Rect ir = r.Shrink(WidgetDimensions::scaled.bevel);
1734 if (FillDrawPixelInfo(&tmp_dpi, ir)) {
1735 AutoRestoreBackup dpi_backup(_cur_dpi, &tmp_dpi);
1736 int x = (ir.Width() - ScaleSpriteTrad(64)) / 2 + ScaleSpriteTrad(31);
1737 int y = (ir.Height() + ScaleSpriteTrad(48)) / 2 - ScaleSpriteTrad(31);
1738 DrawTrainDepotSprite(x, y, widget - WID_BRAD_DEPOT_NE + DIAGDIR_NE, _cur_railtype);
1739 }
1740 }
1741
1742 void OnClick([[maybe_unused]] Point pt, WidgetID widget, [[maybe_unused]] int click_count) override
1743 {
1744 switch (widget) {
1745 case WID_BRAD_DEPOT_NE:
1746 case WID_BRAD_DEPOT_SE:
1747 case WID_BRAD_DEPOT_SW:
1748 case WID_BRAD_DEPOT_NW:
1749 this->RaiseWidget(WID_BRAD_DEPOT_NE + _build_depot_direction);
1750 _build_depot_direction = (DiagDirection)(widget - WID_BRAD_DEPOT_NE);
1751 this->LowerWidget(WID_BRAD_DEPOT_NE + _build_depot_direction);
1752 SndClickBeep();
1753 this->SetDirty();
1754 break;
1755 }
1756 }
1757};
1758
1760 static constexpr std::initializer_list<NWidgetPart> _nested_build_depot_widgets = {
1761 NWidget(NWID_HORIZONTAL),
1762 NWidget(WWT_CLOSEBOX, COLOUR_DARK_GREEN),
1763 NWidget(WWT_CAPTION, COLOUR_DARK_GREEN), SetStringTip(STR_BUILD_DEPOT_TRAIN_ORIENTATION_CAPTION, STR_TOOLTIP_WINDOW_TITLE_DRAG_THIS),
1764 EndContainer(),
1765 NWidget(WWT_PANEL, COLOUR_DARK_GREEN),
1766 NWidget(NWID_HORIZONTAL_LTR), SetPIP(0, WidgetDimensions::unscaled.hsep_normal, 0), SetPIPRatio(1, 0, 1), SetPadding(WidgetDimensions::unscaled.picker),
1767 NWidget(NWID_VERTICAL), SetPIP(0, WidgetDimensions::unscaled.vsep_normal, 0),
1768 NWidget(WWT_TEXTBTN, COLOUR_GREY, WID_BRAD_DEPOT_NW), SetToolTip(STR_BUILD_DEPOT_TRAIN_ORIENTATION_TOOLTIP),
1769 NWidget(WWT_TEXTBTN, COLOUR_GREY, WID_BRAD_DEPOT_SW), SetToolTip(STR_BUILD_DEPOT_TRAIN_ORIENTATION_TOOLTIP),
1770 EndContainer(),
1771 NWidget(NWID_VERTICAL), SetPIP(0, WidgetDimensions::unscaled.vsep_normal, 0),
1772 NWidget(WWT_TEXTBTN, COLOUR_GREY, WID_BRAD_DEPOT_NE), SetToolTip(STR_BUILD_DEPOT_TRAIN_ORIENTATION_TOOLTIP),
1773 NWidget(WWT_TEXTBTN, COLOUR_GREY, WID_BRAD_DEPOT_SE), SetToolTip(STR_BUILD_DEPOT_TRAIN_ORIENTATION_TOOLTIP),
1774 EndContainer(),
1775 EndContainer(),
1776 EndContainer(),
1777};
1778
1779static WindowDesc _build_depot_desc(
1780 WDP_AUTO, {}, 0, 0,
1781 WC_BUILD_DEPOT, WC_BUILD_TOOLBAR,
1782 WindowDefaultFlag::Construction,
1783 _nested_build_depot_widgets
1784);
1785
1786static void ShowBuildTrainDepotPicker(Window *parent)
1787{
1788 new BuildRailDepotWindow(_build_depot_desc, parent);
1789}
1790
1791 class WaypointPickerCallbacks : public PickerCallbacksNewGRFClass<StationClass> {
1792public:
1793 WaypointPickerCallbacks() : PickerCallbacksNewGRFClass<StationClass>("fav_waypoints") {}
1794
1795 GrfSpecFeature GetFeature() const override { return GSF_STATIONS; }
1796
1797 StringID GetClassTooltip() const override { return STR_PICKER_WAYPOINT_CLASS_TOOLTIP; }
1798 StringID GetTypeTooltip() const override { return STR_PICKER_WAYPOINT_TYPE_TOOLTIP; }
1799
1800 bool IsActive() const override
1801 {
1802 for (const auto &cls : StationClass::Classes()) {
1803 if (!IsWaypointClass(cls)) continue;
1804 for (const auto *spec : cls.Specs()) {
1805 if (spec != nullptr) return true;
1806 }
1807 }
1808 return false;
1809 }
1810
1811 bool HasClassChoice() const override
1812 {
1813 return std::ranges::count_if(StationClass::Classes(), IsWaypointClass) > 1;
1814 }
1815
1816 void Close(int) override { ResetObjectToPlace(); }
1817 int GetSelectedClass() const override { return _waypoint_gui.sel_class; }
1818 void SetSelectedClass(int id) const override { _waypoint_gui.sel_class = this->GetClassIndex(id); }
1819
1820 StringID GetClassName(int id) const override
1821 {
1822 const auto *sc = GetClass(id);
1823 if (!IsWaypointClass(*sc)) return INVALID_STRING_ID;
1824 return sc->name;
1825 }
1826
1827 int GetSelectedType() const override { return _waypoint_gui.sel_type; }
1828 void SetSelectedType(int id) const override { _waypoint_gui.sel_type = id; }
1829
1830 StringID GetTypeName(int cls_id, int id) const override
1831 {
1832 const auto *spec = this->GetSpec(cls_id, id);
1833 return (spec == nullptr) ? STR_STATION_CLASS_WAYP_WAYPOINT : spec->name;
1834 }
1835
1836 std::span<const BadgeID> GetTypeBadges(int cls_id, int id) const override
1837 {
1838 const auto *spec = this->GetSpec(cls_id, id);
1839 if (spec == nullptr) return {};
1840 return spec->badges;
1841 }
1842
1843 bool IsTypeAvailable(int cls_id, int id) const override
1844 {
1845 return IsStationAvailable(this->GetSpec(cls_id, id));
1846 }
1847
1848 void DrawType(int x, int y, int cls_id, int id) const override
1849 {
1850 DrawWaypointSprite(x, y, this->GetClassIndex(cls_id), id, _cur_railtype);
1851 }
1852
1853 void FillUsedItems(std::set<PickerItem> &items) override
1854 {
1855 bool default_added = false;
1856 for (const Waypoint *wp : Waypoint::Iterate()) {
1857 if (wp->owner != _local_company || HasBit(wp->waypoint_flags, WPF_ROAD)) continue;
1858 if (!default_added && StationUsesDefaultType(wp)) {
1859 items.insert({0, 0, STAT_CLASS_WAYP, 0});
1860 default_added = true;
1861 }
1862 for (const auto &sm : wp->speclist) {
1863 if (sm.spec == nullptr) continue;
1864 items.insert({sm.grfid, sm.localidx, sm.spec->class_index, sm.spec->index});
1865 }
1866 }
1867 }
1868
1869 static WaypointPickerCallbacks instance;
1870};
1871/* static */ WaypointPickerCallbacks WaypointPickerCallbacks::instance;
1872
1873 struct BuildRailWaypointWindow : public PickerWindow {
1874 BuildRailWaypointWindow(WindowDesc &desc, Window *parent) : PickerWindow(desc, parent, TRANSPORT_RAIL, WaypointPickerCallbacks::instance)
1875 {
1876 this->ConstructWindow();
1877 }
1878
1879 static inline HotkeyList hotkeys{"buildrailwaypoint", {
1880 Hotkey('F', "focus_filter_box", PCWHK_FOCUS_FILTER_BOX),
1881 }};
1882};
1883
1885 static constexpr std::initializer_list<NWidgetPart> _nested_build_waypoint_widgets = {
1886 NWidget(NWID_HORIZONTAL),
1887 NWidget(WWT_CLOSEBOX, COLOUR_DARK_GREEN),
1888 NWidget(WWT_CAPTION, COLOUR_DARK_GREEN), SetStringTip(STR_WAYPOINT_CAPTION, STR_TOOLTIP_WINDOW_TITLE_DRAG_THIS),
1889 NWidget(WWT_SHADEBOX, COLOUR_DARK_GREEN),
1890 NWidget(WWT_DEFSIZEBOX, COLOUR_DARK_GREEN),
1891 EndContainer(),
1892 NWidget(NWID_HORIZONTAL),
1893 NWidgetFunction(MakePickerClassWidgets),
1894 NWidgetFunction(MakePickerTypeWidgets),
1895 EndContainer(),
1896};
1897
1898static WindowDesc _build_waypoint_desc(
1899 WDP_AUTO, "build_waypoint", 0, 0,
1900 WC_BUILD_WAYPOINT, WC_BUILD_TOOLBAR,
1901 WindowDefaultFlag::Construction,
1902 _nested_build_waypoint_widgets,
1903 &BuildRailWaypointWindow::hotkeys
1904);
1905
1906static void ShowBuildWaypointPicker(Window *parent)
1907{
1908 if (!WaypointPickerCallbacks::instance.IsActive()) return;
1909 new BuildRailWaypointWindow(_build_waypoint_desc, parent);
1910}
1911
1915 void InitializeRailGui()
1916{
1917 _build_depot_direction = DIAGDIR_NW;
1918 _station_gui.sel_class = StationClassID::STAT_CLASS_DFLT;
1919 _station_gui.sel_type = 0;
1920 _waypoint_gui.sel_class = StationClassID::STAT_CLASS_WAYP;
1921 _waypoint_gui.sel_type = 0;
1922}
1923
1928 void ReinitGuiAfterToggleElrail(bool disable)
1929{
1930 extern RailType _last_built_railtype;
1931 if (disable && _last_built_railtype == RAILTYPE_ELECTRIC) {
1932 _last_built_railtype = _cur_railtype = RAILTYPE_RAIL;
1933 BuildRailToolbarWindow *w = dynamic_cast<BuildRailToolbarWindow *>(FindWindowById(WC_BUILD_TOOLBAR, TRANSPORT_RAIL));
1934 if (w != nullptr) w->ModifyRailType(_cur_railtype);
1935 }
1936 MarkWholeScreenDirty();
1937}
1938
1940 static void SetDefaultRailGui()
1941{
1942 if (_local_company == COMPANY_SPECTATOR || !Company::IsValidID(_local_company)) return;
1943
1944 extern RailType _last_built_railtype;
1945 RailType rt;
1946 switch (_settings_client.gui.default_rail_type) {
1947 case 2: {
1948 /* Find the most used rail type */
1949 std::array<uint, RAILTYPE_END> count{};
1950 for (const auto t : Map::Iterate()) {
1951 if (IsTileType(t, MP_RAILWAY) || IsLevelCrossingTile(t) || HasStationTileRail(t) ||
1952 (IsTileType(t, MP_TUNNELBRIDGE) && GetTunnelBridgeTransportType(t) == TRANSPORT_RAIL)) {
1953 count[GetRailType(t)]++;
1954 }
1955 }
1956
1957 rt = static_cast<RailType>(std::distance(std::begin(count), std::ranges::max_element(count)));
1958 if (count[rt] > 0) break;
1959
1960 /* No rail, just get the first available one */
1961 [[fallthrough]];
1962 }
1963 case 0: {
1964 /* Use first available type */
1965 std::vector<RailType>::const_iterator it = std::find_if(_sorted_railtypes.begin(), _sorted_railtypes.end(),
1966 [](RailType r) { return HasRailTypeAvail(_local_company, r); });
1967 rt = it != _sorted_railtypes.end() ? *it : RAILTYPE_BEGIN;
1968 break;
1969 }
1970 case 1: {
1971 /* Use last available type */
1972 std::vector<RailType>::const_reverse_iterator it = std::find_if(_sorted_railtypes.rbegin(), _sorted_railtypes.rend(),
1973 [](RailType r){ return HasRailTypeAvail(_local_company, r); });
1974 rt = it != _sorted_railtypes.rend() ? *it : RAILTYPE_BEGIN;
1975 break;
1976 }
1977 default:
1978 NOT_REACHED();
1979 }
1980
1981 _last_built_railtype = _cur_railtype = rt;
1982 BuildRailToolbarWindow *w = dynamic_cast<BuildRailToolbarWindow *>(FindWindowById(WC_BUILD_TOOLBAR, TRANSPORT_RAIL));
1983 if (w != nullptr) w->ModifyRailType(_cur_railtype);
1984}
1985
1990 void ResetSignalVariant(int32_t)
1991{
1992 SignalVariant new_variant = (TimerGameCalendar::year < _settings_client.gui.semaphore_build_before ? SIG_SEMAPHORE : SIG_ELECTRIC);
1993
1994 if (new_variant != _cur_signal_variant) {
1995 Window *w = FindWindowById(WC_BUILD_SIGNAL, 0);
1996 if (w != nullptr) {
1997 w->SetDirty();
1998 w->RaiseWidget((_cur_signal_variant == SIG_ELECTRIC ? WID_BS_ELECTRIC_NORM : WID_BS_SEMAPHORE_NORM) + _cur_signal_type);
1999 }
2000 _cur_signal_variant = new_variant;
2001 }
2002}
2003
2004static const IntervalTimer<TimerGameCalendar> _check_reset_signal({TimerGameCalendar::YEAR, TimerGameCalendar::Priority::NONE}, [](auto)
2005{
2006 if (TimerGameCalendar::year != _settings_client.gui.semaphore_build_before) return;
2007
2008 ResetSignalVariant();
2009});
2010
2015 void InitializeRailGUI()
2016{
2017 SetDefaultRailGui();
2018
2019 _convert_signal_button = false;
2020 _cur_signal_type = _settings_client.gui.default_signal_type;
2021 ResetSignalVariant();
2022}
2023
2030 DropDownList GetRailTypeDropDownList(bool for_replacement, bool all_option)
2031{
2032 RailTypes used_railtypes;
2033 RailTypes avail_railtypes;
2034
2035 const Company *c = Company::Get(_local_company);
2036
2037 /* Find the used railtypes. */
2038 if (for_replacement) {
2039 avail_railtypes = GetCompanyRailTypes(c->index, false);
2040 used_railtypes = GetRailTypes(false);
2041 } else {
2042 avail_railtypes = c->avail_railtypes;
2043 used_railtypes = GetRailTypes(true);
2044 }
2045
2046 DropDownList list;
2047
2048 if (all_option) {
2049 list.push_back(MakeDropDownListStringItem(STR_REPLACE_ALL_RAILTYPE, INVALID_RAILTYPE));
2050 }
2051
2052 Dimension d = { 0, 0 };
2053 /* Get largest icon size, to ensure text is aligned on each menu item. */
2054 if (!for_replacement) {
2055 used_railtypes.Reset(_railtypes_hidden_mask);
2056 for (const auto &rt : _sorted_railtypes) {
2057 if (!used_railtypes.Test(rt)) continue;
2058 const RailTypeInfo *rti = GetRailTypeInfo(rt);
2059 d = maxdim(d, GetSpriteSize(rti->gui_sprites.build_x_rail));
2060 }
2061 }
2062
2063 /* Shared list so that each item can take ownership. */
2064 auto badge_class_list = std::make_shared<GUIBadgeClasses>(GSF_RAILTYPES);
2065
2066 for (const auto &rt : _sorted_railtypes) {
2067 /* If it's not used ever, don't show it to the user. */
2068 if (!used_railtypes.Test(rt)) continue;
2069
2070 const RailTypeInfo *rti = GetRailTypeInfo(rt);
2071
2072 if (for_replacement) {
2073 list.push_back(MakeDropDownListBadgeItem(badge_class_list, rti->badges, GSF_RAILTYPES, rti->introduction_date, GetString(rti->strings.replace_text), rt, !avail_railtypes.Test(rt)));
2074 } else {
2075 std::string str = rti->max_speed > 0
2076 ? GetString(STR_TOOLBAR_RAILTYPE_VELOCITY, rti->strings.menu_text, rti->max_speed)
2077 : GetString(rti->strings.menu_text);
2078 list.push_back(MakeDropDownListBadgeIconItem(badge_class_list, rti->badges, GSF_RAILTYPES, rti->introduction_date, RailBuildCost(rt), d, rti->gui_sprites.build_x_rail, PAL_NONE, std::move(str), rt, !avail_railtypes.Test(rt)));
2079 }
2080 }
2081
2082 if (list.empty()) {
2083 /* Empty dropdowns are not allowed */
2084 list.push_back(MakeDropDownListStringItem(STR_NONE, INVALID_RAILTYPE, true));
2085 }
2086
2087 return list;
2088}
GB
static constexpr uint GB(const T x, const uint8_t s, const uint8_t n)
Fetch n bits from x, started at bit s.
Definition bitmath_func.hpp:32
HasBit
constexpr bool HasBit(const T x, const uint8_t y)
Checks if a bit in a value is set.
Definition bitmath_func.hpp:103
ShowBuildBridgeWindow
void ShowBuildBridgeWindow(TileIndex start, TileIndex end, TransportType transport_type, uint8_t road_rail_type)
Prepare the data for the build a bridge window.
Definition bridge_gui.cpp:357
IsBridgeTile
bool IsBridgeTile(Tile t)
checks if there is a bridge on this tile
Definition bridge_map.h:35
BaseBitSet::Test
constexpr bool Test(Tvalue_type value) const
Test if the value-th bit is set.
Definition base_bitset_type.hpp:141
BaseBitSet::Reset
constexpr Timpl & Reset()
Reset all bits.
Definition base_bitset_type.hpp:83
CommandCost
Common return value for all commands.
Definition command_type.h:24
CommandCost::Succeeded
bool Succeeded() const
Did this command succeed?
Definition command_type.h:168
CommandCost::Failed
bool Failed() const
Did this command fail?
Definition command_type.h:177
EnumBitSet< RailType, uint64_t >
IntervalTimer
An interval timer will fire every interval, and will continue to fire until it is deleted.
Definition timer.h:76
NewGRFClass::Classes
static std::span< NewGRFClass< Tspec, Tindex, Tmax > const > Classes()
Get read-only span of all classes of this type.
Definition newgrf_class.h:64
NewGRFClass::Get
static NewGRFClass * Get(Tindex class_index)
Get a particular class.
Definition newgrf_class_func.h:82
NewGRFClass::GetSpec
const Tspec * GetSpec(uint index) const
Get a spec from the class at a given index.
Definition newgrf_class_func.h:114
PickerCallbacksNewGRFClass
Helper for PickerCallbacks when the class system is based on NewGRFClass.
Definition picker_gui.h:107
PickerWindowBase
Base class for windows opened from a toolbar.
Definition window_gui.h:992
PickerWindowBase::Close
void Close(int data=0) override
Hide the window and all its child windows, and mark them for a later deletion.
Definition window.cpp:3599
PickerWindow
Definition picker_gui.h:157
PickerWindow::PREVIEW_WIDTH
static constexpr int PREVIEW_WIDTH
Width of each preview button.
Definition picker_gui.h:176
PickerWindow::Close
void Close(int data=0) override
Hide the window and all its child windows, and mark them for a later deletion.
Definition picker_gui.cpp:260
PickerWindow::PREVIEW_HEIGHT
static constexpr int PREVIEW_HEIGHT
Height of each preview button.
Definition picker_gui.h:177
PickerWindow::DrawWidget
void DrawWidget(const Rect &r, WidgetID widget) const override
Draw the contents of a nested widget.
Definition picker_gui.cpp:308
PickerWindow::PREVIEW_LEFT
static constexpr int PREVIEW_LEFT
Offset from left edge to draw preview.
Definition picker_gui.h:178
PickerWindow::PREVIEW_BOTTOM
static constexpr int PREVIEW_BOTTOM
Offset from bottom edge to draw preview.
Definition picker_gui.h:179
PickerWindow::PCWHK_FOCUS_FILTER_BOX
@ PCWHK_FOCUS_FILTER_BOX
Focus the edit box for editing the filter string.
Definition picker_gui.h:205
PickerWindow::OnClick
void OnClick(Point pt, WidgetID widget, int click_count) override
A click with the left mouse button has been made on the window.
Definition picker_gui.cpp:373
PickerWindow::OnInvalidateData
void OnInvalidateData(int data=0, bool gui_scope=true) override
Some data on this window has become invalid.
Definition picker_gui.cpp:490
PickerWindow::OnInit
void OnInit() override
Notification that the nested widget tree gets initialized.
Definition picker_gui.cpp:251
PickerWindow::UpdateWidgetSize
void UpdateWidgetSize(WidgetID widget, Dimension &size, const Dimension &padding, Dimension &fill, Dimension &resize) override
Update size and resize step of a widget in the window.
Definition picker_gui.cpp:266
RailTypeInfo
This struct contains all the info that is needed to draw and construct tracks.
Definition rail.h:115
RailTypeInfo::max_speed
uint16_t max_speed
Maximum speed for vehicles travelling on this rail type.
Definition rail.h:220
RailTypeInfo::build_tunnel
SpriteID build_tunnel
button for building a tunnel
Definition rail.h:148
RailTypeInfo::rail_swne
CursorID rail_swne
Cursor for building rail in X direction.
Definition rail.h:155
RailTypeInfo::convert_rail
SpriteID convert_rail
button for converting rail
Definition rail.h:149
RailTypeInfo::convert
CursorID convert
Cursor for converting track.
Definition rail.h:161
RailTypeInfo::depot
CursorID depot
Cursor for building a depot.
Definition rail.h:159
RailTypeInfo::introduction_date
TimerGameCalendar::Date introduction_date
Introduction date.
Definition rail.h:244
RailTypeInfo::rail_nwse
CursorID rail_nwse
Cursor for building rail in Y direction.
Definition rail.h:157
RailTypeInfo::build_x_rail
SpriteID build_x_rail
button for building single rail in X direction
Definition rail.h:143
RailTypeInfo::rail_ew
CursorID rail_ew
Cursor for building rail in E-W direction.
Definition rail.h:156
RailTypeInfo::auto_rail
SpriteID auto_rail
button for the autorail construction
Definition rail.h:146
RailTypeInfo::autorail
CursorID autorail
Cursor for autorail tool.
Definition rail.h:158
RailTypeInfo::menu_text
StringID menu_text
Name of this rail type in the main toolbar dropdown.
Definition rail.h:167
RailTypeInfo::toolbar_caption
StringID toolbar_caption
Caption in the construction toolbar GUI for this rail type.
Definition rail.h:166
RailTypeInfo::signals
SpriteID signals[SIGTYPE_END][2][2]
signal GUI sprites (type, variant, state)
Definition rail.h:150
RailTypeInfo::build_ew_rail
SpriteID build_ew_rail
button for building single rail in E-W direction
Definition rail.h:144
RailTypeInfo::build_y_rail
SpriteID build_y_rail
button for building single rail in Y direction
Definition rail.h:145
RailTypeInfo::strings
struct RailTypeInfo::@22 strings
Strings associated with the rail type.
RailTypeInfo::replace_text
StringID replace_text
Text used in the autoreplace GUI.
Definition rail.h:169
RailTypeInfo::gui_sprites
struct RailTypeInfo::@20 gui_sprites
struct containing the sprites for the rail GUI.
RailTypeInfo::build_depot
SpriteID build_depot
button for building depots
Definition rail.h:147
RailTypeInfo::build_ns_rail
SpriteID build_ns_rail
button for building single rail in N-S direction
Definition rail.h:142
RailTypeInfo::rail_ns
CursorID rail_ns
Cursor for building rail in N-S direction.
Definition rail.h:154
RailTypeInfo::tunnel
SpriteID tunnel
tunnel sprites base
Definition rail.h:133
StationPickerCallbacks
Definition rail_gui.cpp:973
StationPickerCallbacks::IsActive
bool IsActive() const override
Should picker class/type selection be enabled?
Definition rail_gui.cpp:982
StationPickerCallbacks::HasClassChoice
bool HasClassChoice() const override
Are there multiple classes to chose from?
Definition rail_gui.cpp:993
StationPickerCallbacks::GetTypeBadges
std::span< const BadgeID > GetTypeBadges(int cls_id, int id) const override
Get the item of a type.
Definition rail_gui.cpp:1017
StationPickerCallbacks::GetTypeName
StringID GetTypeName(int cls_id, int id) const override
Get the item of a type.
Definition rail_gui.cpp:1011
StationPickerCallbacks::GetClassTooltip
StringID GetClassTooltip() const override
Get the tooltip string for the class list.
Definition rail_gui.cpp:979
StationPickerCallbacks::SetSelectedType
void SetSelectedType(int id) const override
Set the selected type.
Definition rail_gui.cpp:1009
StationPickerCallbacks::DrawType
void DrawType(int x, int y, int cls_id, int id) const override
Draw preview image of an item.
Definition rail_gui.cpp:1029
StationPickerCallbacks::GetClassName
StringID GetClassName(int id) const override
Get the name of a class.
Definition rail_gui.cpp:1001
StationPickerCallbacks::GetTypeTooltip
StringID GetTypeTooltip() const override
Get the tooltip string for the type grid.
Definition rail_gui.cpp:980
StationPickerCallbacks::GetSelectedClass
int GetSelectedClass() const override
Get the index of the selected class.
Definition rail_gui.cpp:998
StationPickerCallbacks::SetSelectedClass
void SetSelectedClass(int id) const override
Set the selected class.
Definition rail_gui.cpp:999
StationPickerCallbacks::IsTypeAvailable
bool IsTypeAvailable(int cls_id, int id) const override
Test if an item is currently buildable.
Definition rail_gui.cpp:1024
StationPickerCallbacks::GetSelectedType
int GetSelectedType() const override
Get the selected type.
Definition rail_gui.cpp:1008
StationPickerCallbacks::FillUsedItems
void FillUsedItems(std::set< PickerItem > &items) override
Fill a set with all items that are used by the current player.
Definition rail_gui.cpp:1036
Tile
Wrapper class to abstract away the way the tiles are stored.
Definition map_func.h:25
TimerGameCalendar::year
static Year year
Current year, starting at 0.
Definition timer_game_calendar.h:31
WaypointPickerCallbacks
Definition rail_gui.cpp:1791
WaypointPickerCallbacks::GetSelectedType
int GetSelectedType() const override
Get the selected type.
Definition rail_gui.cpp:1827
WaypointPickerCallbacks::SetSelectedClass
void SetSelectedClass(int id) const override
Set the selected class.
Definition rail_gui.cpp:1818
WaypointPickerCallbacks::GetTypeTooltip
StringID GetTypeTooltip() const override
Get the tooltip string for the type grid.
Definition rail_gui.cpp:1798
WaypointPickerCallbacks::DrawType
void DrawType(int x, int y, int cls_id, int id) const override
Draw preview image of an item.
Definition rail_gui.cpp:1848
WaypointPickerCallbacks::IsTypeAvailable
bool IsTypeAvailable(int cls_id, int id) const override
Test if an item is currently buildable.
Definition rail_gui.cpp:1843
WaypointPickerCallbacks::GetTypeBadges
std::span< const BadgeID > GetTypeBadges(int cls_id, int id) const override
Get the item of a type.
Definition rail_gui.cpp:1836
WaypointPickerCallbacks::GetSelectedClass
int GetSelectedClass() const override
Get the index of the selected class.
Definition rail_gui.cpp:1817
WaypointPickerCallbacks::GetTypeName
StringID GetTypeName(int cls_id, int id) const override
Get the item of a type.
Definition rail_gui.cpp:1830
WaypointPickerCallbacks::IsActive
bool IsActive() const override
Should picker class/type selection be enabled?
Definition rail_gui.cpp:1800
WaypointPickerCallbacks::SetSelectedType
void SetSelectedType(int id) const override
Set the selected type.
Definition rail_gui.cpp:1828
WaypointPickerCallbacks::GetClassName
StringID GetClassName(int id) const override
Get the name of a class.
Definition rail_gui.cpp:1820
WaypointPickerCallbacks::GetClassTooltip
StringID GetClassTooltip() const override
Get the tooltip string for the class list.
Definition rail_gui.cpp:1797
WaypointPickerCallbacks::FillUsedItems
void FillUsedItems(std::set< PickerItem > &items) override
Fill a set with all items that are used by the current player.
Definition rail_gui.cpp:1853
WaypointPickerCallbacks::HasClassChoice
bool HasClassChoice() const override
Are there multiple classes to chose from?
Definition rail_gui.cpp:1811
WidgetDimensions::framerect
RectPadding framerect
Standard padding inside many panels.
Definition window_gui.h:40
WidgetDimensions::scaled
static WidgetDimensions scaled
Widget dimensions scaled for current zoom level.
Definition window_gui.h:30
WidgetDimensions::vsep_normal
int vsep_normal
Normal vertical spacing.
Definition window_gui.h:58
WidgetDimensions::fullbevel
RectPadding fullbevel
Always-scaled bevel thickness.
Definition window_gui.h:39
WidgetDimensions::unscaled
static const WidgetDimensions unscaled
Unscaled widget dimensions.
Definition window_gui.h:93
command_func.h
Functions related to commands.
CommandFlagsToDCFlags
static constexpr DoCommandFlags CommandFlagsToDCFlags(CommandFlags cmd_flags)
Extracts the DC flags needed for DoCommand from the flags returned by GetCommandFlags.
Definition command_func.h:48
DoCommandFlag::Auto
@ Auto
don't allow building on structures
Commands
Commands
List of commands.
Definition command_type.h:196
company_base.h
Definition of stuff that is very close to a company, like the company struct itself.
_local_company
CompanyID _local_company
Company controlled by the human player at this client. Can also be COMPANY_SPECTATOR.
Definition company_cmd.cpp:55
company_func.h
Functions related to companies.
COMPANY_SPECTATOR
static constexpr CompanyID COMPANY_SPECTATOR
The client is spectating.
Definition company_type.h:21
IsValidAxis
bool IsValidAxis(Axis d)
Checks if an integer value is a valid Axis.
Definition direction_func.h:43
Axis
Axis
Allow incrementing of DiagDirDiff variables.
Definition direction_type.h:123
AXIS_X
@ AXIS_X
The X axis.
Definition direction_type.h:124
AXIS_Y
@ AXIS_Y
The y axis.
Definition direction_type.h:125
DiagDirection
DiagDirection
Enumeration for diagonal directions.
Definition direction_type.h:78
DIAGDIR_NE
@ DIAGDIR_NE
Northeast, upper right on your monitor.
Definition direction_type.h:80
DIAGDIR_NW
@ DIAGDIR_NW
Northwest.
Definition direction_type.h:83
DIAGDIR_SE
@ DIAGDIR_SE
Southeast.
Definition direction_type.h:81
DIAGDIR_SW
@ DIAGDIR_SW
Southwest.
Definition direction_type.h:82
dropdown_func.h
Functions related to the drop down widget.
dropdown_type.h
Types related to the drop down widget.
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:56
engine_base.h
Base class for engines.
GetCharacterHeight
int GetCharacterHeight(FontSize size)
Get height of a character for a given font size.
Definition fontcache.cpp:87
maxdim
Dimension maxdim(const Dimension &d1, const Dimension &d2)
Compute bounding box of both dimensions.
Definition geometry_func.cpp:22
geometry_func.hpp
Geometry functions.
CentreBounds
int CentreBounds(int min, int max, int size)
Determine where to position a centred object.
Definition geometry_type.hpp:26
GetSpriteSize
Dimension GetSpriteSize(SpriteID sprid, Point *offset, ZoomLevel zoom)
Get the size of a sprite.
Definition gfx.cpp:965
_ctrl_pressed
bool _ctrl_pressed
Is Ctrl pressed?
Definition gfx.cpp:38
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:1031
GetDigitWidth
uint8_t GetDigitWidth(FontSize size)
Return the maximum width of single digit.
Definition gfx.cpp:1283
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:1565
SpriteID
uint32_t SpriteID
The number of a sprite, without mapping bits and colourtables.
Definition gfx_type.h:17
FS_NORMAL
@ FS_NORMAL
Index of the normal font in the font tables.
Definition gfx_type.h:249
WKC_GLOBAL_HOTKEY
@ WKC_GLOBAL_HOTKEY
Fake keycode bit to indicate global hotkeys.
Definition gfx_type.h:35
NWidgetFunction
constexpr NWidgetPart NWidgetFunction(NWidgetFunctionType *func_ptr)
Obtain a nested widget (sub)tree from an external source.
Definition widget_type.h:1445
SetFill
constexpr NWidgetPart SetFill(uint16_t fill_x, uint16_t fill_y)
Widget part function for setting filling.
Definition widget_type.h:1219
SetSpriteTip
constexpr NWidgetPart SetSpriteTip(SpriteID sprite, StringID tip={})
Widget part function for setting the sprite and tooltip.
Definition widget_type.h:1251
SetToolbarMinimalSize
constexpr NWidgetPart SetToolbarMinimalSize(int width)
Widget part function to setting the minimal size for a toolbar button.
Definition widget_type.h:1175
SetPIP
constexpr NWidgetPart SetPIP(uint8_t pre, uint8_t inter, uint8_t post)
Widget part function for setting a pre/inter/post spaces.
Definition widget_type.h:1375
SetPadding
constexpr NWidgetPart SetPadding(uint8_t top, uint8_t right, uint8_t bottom, uint8_t left)
Widget part function for setting additional space around a widget.
Definition widget_type.h:1332
SetStringTip
constexpr NWidgetPart SetStringTip(StringID string, StringID tip={})
Widget part function for setting the string and tooltip.
Definition widget_type.h:1240
SetAspect
constexpr NWidgetPart SetAspect(float ratio, AspectFlags flags=AspectFlag::ResizeX)
Widget part function for setting the aspect ratio.
Definition widget_type.h:1410
SetTextStyle
constexpr NWidgetPart SetTextStyle(TextColour colour, FontSize size=FS_NORMAL)
Widget part function for setting the text style.
Definition widget_type.h:1198
SetToolbarSpacerMinimalSize
constexpr NWidgetPart SetToolbarSpacerMinimalSize()
Widget part function to setting the minimal size for a toolbar spacer.
Definition widget_type.h:1165
SetMinimalSize
constexpr NWidgetPart SetMinimalSize(int16_t x, int16_t y)
Widget part function for setting the minimal size.
Definition widget_type.h:1156
SetToolTip
constexpr NWidgetPart SetToolTip(StringID tip)
Widget part function for setting tooltip and clearing the widget data.
Definition widget_type.h:1318
EndContainer
constexpr NWidgetPart EndContainer()
Widget part function for denoting the end of a container (horizontal, vertical, WWT_FRAME,...
Definition widget_type.h:1229
SetArrowWidgetTypeTip
constexpr NWidgetPart SetArrowWidgetTypeTip(ArrowWidgetValues widget_type, StringID tip={})
Widget part function for setting the arrow widget type and tooltip.
Definition widget_type.h:1274
NWidget
constexpr NWidgetPart NWidget(WidgetType tp, Colours col, WidgetID idx=INVALID_WIDGET)
Widget part function for starting a new 'real' widget.
Definition widget_type.h:1424
SetMinimalTextLines
constexpr NWidgetPart SetMinimalTextLines(uint8_t lines, uint8_t spacing, FontSize size=FS_NORMAL)
Widget part function for setting the minimal text lines.
Definition widget_type.h:1187
SetResize
constexpr NWidgetPart SetResize(int16_t dx, int16_t dy)
Widget part function for setting the resize step.
Definition widget_type.h:1145
SetPIPRatio
constexpr NWidgetPart SetPIPRatio(uint8_t ratio_pre, uint8_t ratio_inter, uint8_t ratio_post)
Widget part function for setting a pre/inter/post ratio.
Definition widget_type.h:1387
Window::SetDirty
void SetDirty() const
Mark entire window as dirty (in need of re-paint)
Definition window.cpp:966
MarkWholeScreenDirty
void MarkWholeScreenDirty()
This function mark the whole screen as dirty.
Definition gfx.cpp:1546
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:2128
gui.h
GUI functions that shouldn't be here.
hotkeys.h
Hotkey related functions.
GetTileTrackStatus
TrackStatus GetTileTrackStatus(TileIndex tile, TransportType mode, uint sub_mode, DiagDirection side)
Returns information about trackdirs and signal states.
Definition landscape.cpp:559
HandlePlacePushButton
bool HandlePlacePushButton(Window *w, WidgetID widget, CursorID cursor, HighLightStyle mode)
This code is shared for the majority of the pushbuttons.
Definition main_gui.cpp:63
TileVirtXY
static TileIndex TileVirtXY(uint x, uint y)
Get a tile from the virtual XY-coordinate.
Definition map_func.h:416
TileOffsByDiagDir
TileIndexDiff TileOffsByDiagDir(DiagDirection dir)
Convert a DiagDirection to a TileIndexDiff.
Definition map_func.h:582
IsInsideMM
constexpr bool IsInsideMM(const size_t x, const size_t min, const size_t max) noexcept
Checks if a value is in an interval.
Definition math_func.hpp:267
GuiShowTooltips
void GuiShowTooltips(Window *parent, EncodedString &&text, TooltipCloseCondition close_tooltip)
Shows a tooltip.
Definition misc_gui.cpp:693
GrfSpecFeature
GrfSpecFeature
Definition newgrf.h:68
newgrf_badge.h
Functions related to NewGRF badges.
newgrf_badge_gui.h
GUI functions related to NewGRF badges.
StationCallbackMask::Avail
@ Avail
Availability of station in construction window.
CBID_STATION_AVAILABILITY
@ CBID_STATION_AVAILABILITY
Determine whether a newstation should be made available to build.
Definition newgrf_callbacks.h:41
CALLBACK_FAILED
static const uint CALLBACK_FAILED
Different values for Callback result evaluations.
Definition newgrf_callbacks.h:439
Convert8bitBooleanCallback
bool Convert8bitBooleanCallback(const GRFFile *grffile, uint16_t cbid, uint16_t cb_res)
Converts a callback result into a boolean.
Definition newgrf_commons.cpp:562
IsWaypointClass
bool IsWaypointClass(const RoadStopClass &cls)
Test if a RoadStopClass is the waypoint class.
Definition newgrf_roadstop.h:190
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:804
newgrf_station.h
Header file for NewGRF stations.
StationClassID
StationClassID
Definition newgrf_station.h:103
STAT_CLASS_DFLT
@ STAT_CLASS_DFLT
Default station class.
Definition newgrf_station.h:105
STAT_CLASS_WAYP
@ STAT_CLASS_WAYP
Waypoint class.
Definition newgrf_station.h:106
MakePickerClassWidgets
std::unique_ptr< NWidgetBase > MakePickerClassWidgets()
Create nested widgets for the class picker widgets.
Definition picker_gui.cpp:743
MakePickerTypeWidgets
std::unique_ptr< NWidgetBase > MakePickerTypeWidgets()
Create nested widgets for the type picker widgets.
Definition picker_gui.cpp:766
picker_gui.h
Functions/types etc.
GetCompanyRailTypes
RailTypes GetCompanyRailTypes(CompanyID company, bool introduces)
Get the rail types the given company can build.
Definition rail.cpp:135
GetRailTypes
RailTypes GetRailTypes(bool introduces)
Get list of rail types, regardless of company availability.
Definition rail.cpp:166
ValParamRailType
bool ValParamRailType(const RailType rail)
Validate functions for rail building.
Definition rail.cpp:90
RailBuildCost
Money RailBuildCost(RailType railtype)
Returns the cost of building the specified railtype.
Definition rail.h:428
_sorted_railtypes
std::vector< RailType > _sorted_railtypes
Sorted list of rail types.
Definition rail_cmd.cpp:47
GetRailTypeInfo
const RailTypeInfo * GetRailTypeInfo(RailType railtype)
Returns a pointer to the Railtype information for a given railtype.
Definition rail.h:300
rail_cmd.h
Command definitions for rail.
_nested_signal_builder_widgets
static constexpr std::initializer_list< NWidgetPart > _nested_signal_builder_widgets
Nested widget definition of the build signal window.
Definition rail_gui.cpp:1633
ShowBuildRailToolbar
Window * ShowBuildRailToolbar(RailType railtype)
Open the build rail toolbar window for a specific rail type.
Definition rail_gui.cpp:923
RailToolbar_CtrlChanged
static bool RailToolbar_CtrlChanged(Window *w)
Updates the Remove button because of Ctrl state change.
Definition rail_gui.cpp:334
ResetSignalVariant
void ResetSignalVariant(int32_t)
Updates the current signal variant used in the signal GUI to the one adequate to current year.
Definition rail_gui.cpp:1990
PlaceRail_Waypoint
static void PlaceRail_Waypoint(TileIndex tile)
Place a rail waypoint.
Definition rail_gui.cpp:168
SetDefaultRailGui
static void SetDefaultRailGui()
Set the initial (default) railtype to use.
Definition rail_gui.cpp:1940
_cur_railtype
static RailType _cur_railtype
Rail type of the current build-rail toolbar.
Definition rail_gui.cpp:56
HandleAutoSignalPlacement
static void HandleAutoSignalPlacement()
Build new signals or remove signals or (if only one tile marked) edit a signal.
Definition rail_gui.cpp:413
_cur_signal_variant
static SignalVariant _cur_signal_variant
set the signal variant (for signal GUI)
Definition rail_gui.cpp:60
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:120
PlaceRail_Bridge
static void PlaceRail_Bridge(TileIndex tile, Window *w)
Start placing a rail bridge.
Definition rail_gui.cpp:294
PlaceRail_Station
static void PlaceRail_Station(TileIndex tile)
Place a rail station.
Definition rail_gui.cpp:200
_station_gui
static StationPickerSelection _station_gui
Settings of the station picker.
Definition rail_gui.cpp:74
_cur_signal_type
static SignalType _cur_signal_type
set the signal type (for signal GUI)
Definition rail_gui.cpp:61
ToggleRailButton_Remove
static void ToggleRailButton_Remove(Window *w)
Toggles state of the Remove button of Build rail toolbar.
Definition rail_gui.cpp:320
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:2030
_station_builder_desc
static WindowDesc _station_builder_desc(WDP_AUTO, "build_station_rail", 0, 0, WC_BUILD_STATION, WC_BUILD_TOOLBAR, WindowDefaultFlag::Construction, _nested_station_builder_widgets, &BuildRailStationWindow::hotkeys)
High level window description of the station-build window (default & newGRF)
BuildRailClick_Remove
static void BuildRailClick_Remove(Window *w)
The "remove"-button click proc of the build-rail toolbar.
Definition rail_gui.cpp:355
_signal_builder_desc
static WindowDesc _signal_builder_desc(WDP_AUTO, {}, 0, 0, WC_BUILD_SIGNAL, WC_BUILD_TOOLBAR, WindowDefaultFlag::Construction, _nested_signal_builder_widgets)
Signal selection window description.
_nested_build_depot_widgets
static constexpr std::initializer_list< NWidgetPart > _nested_build_depot_widgets
Nested widget definition of the build rail depot window.
Definition rail_gui.cpp:1760
IsStationAvailable
static bool IsStationAvailable(const StationSpec *statspec)
Check whether a station type can be build.
Definition rail_gui.cpp:87
ShowStationBuilder
static Window * ShowStationBuilder(Window *parent)
Open station build window.
Definition rail_gui.cpp:1454
StationUsesDefaultType
static bool StationUsesDefaultType(const BaseStation *bst)
Test if a station/waypoint uses the default graphics.
Definition rail_gui.cpp:965
_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:130
_build_depot_direction
static DiagDirection _build_depot_direction
Currently selected depot direction.
Definition rail_gui.cpp:58
InitializeRailGui
void InitializeRailGui()
Initialize rail building GUI settings.
Definition rail_gui.cpp:1915
ShowSignalBuilder
static void ShowSignalBuilder(Window *parent)
Open the signal selection window.
Definition rail_gui.cpp:1708
_nested_build_waypoint_widgets
static constexpr std::initializer_list< NWidgetPart > _nested_build_waypoint_widgets
Nested widget definition for the build NewGRF rail waypoint window.
Definition rail_gui.cpp:1885
_remove_button_clicked
static bool _remove_button_clicked
Flag whether 'remove' toggle-button is currently enabled.
Definition rail_gui.cpp:57
ReinitGuiAfterToggleElrail
void ReinitGuiAfterToggleElrail(bool disable)
Re-initialize rail-build toolbar after toggling support for electric trains.
Definition rail_gui.cpp:1928
_place_depot_extra_dir
static const DiagDirection _place_depot_extra_dir[12]
Direction to check for existing track pieces.
Definition rail_gui.cpp:137
InitializeRailGUI
void InitializeRailGUI()
Resets the rail GUI - sets default railtype to build and resets the signal GUI.
Definition rail_gui.cpp:2015
_convert_signal_button
static bool _convert_signal_button
convert signal button in the signal GUI pressed
Definition rail_gui.cpp:59
GenericPlaceSignals
static void GenericPlaceSignals(TileIndex tile)
Build a new signal or edit/remove a present signal, use CmdBuildSingleSignal() or CmdRemoveSingleSign...
Definition rail_gui.cpp:236
_waypoint_gui
static WaypointPickerSelection _waypoint_gui
Settings of the waypoint picker.
Definition rail_gui.cpp:67
rail_gui.h
Functions/types etc.
SIGNAL_GUI_ALL
@ SIGNAL_GUI_ALL
Show all signals, including block and presignals.
Definition rail_gui.h:25
SIGNAL_CYCLE_ALL
@ SIGNAL_CYCLE_ALL
Cycle through all signals visible to the player.
Definition rail_gui.h:31
GetRailTileType
static RailTileType GetRailTileType(Tile t)
Returns the RailTileType (normal with or without signals, waypoint or depot).
Definition rail_map.h:36
GetRailType
RailType GetRailType(Tile t)
Gets the rail type of the given tile.
Definition rail_map.h:115
GetTrackBits
TrackBits GetTrackBits(Tile tile)
Gets the track bits of the given tile.
Definition rail_map.h:136
IsPlainRailTile
static bool IsPlainRailTile(Tile t)
Checks whether the tile is a rail tile or rail tile with signals.
Definition rail_map.h:60
RailTileType::Depot
@ Depot
Depot (one entrance)
RailTileType::Signals
@ Signals
Normal rail tile with signals.
HasSignalOnTrack
bool HasSignalOnTrack(Tile tile, Track track)
Checks for the presence of signals (either way) on the given track on the given rail tile.
Definition rail_map.h:412
IsRailDepotTile
static bool IsRailDepotTile(Tile t)
Is this tile rail tile and a rail depot?
Definition rail_map.h:105
RailType
RailType
Enumeration for all possible railtypes.
Definition rail_type.h:25
RAILTYPE_BEGIN
@ RAILTYPE_BEGIN
Used for iterations.
Definition rail_type.h:26
INVALID_RAILTYPE
@ INVALID_RAILTYPE
Flag for invalid railtype.
Definition rail_type.h:32
RAILTYPE_ELECTRIC
@ RAILTYPE_ELECTRIC
Electric rails.
Definition rail_type.h:28
RAILTYPE_RAIL
@ RAILTYPE_RAIL
Standard non-electric rails.
Definition rail_type.h:27
rail_widget.h
Types related to the rail widgets.
WID_RAT_BUILD_SIGNALS
@ WID_RAT_BUILD_SIGNALS
Build signals.
Definition rail_widget.h:26
WID_RAT_BUILD_NS
@ WID_RAT_BUILD_NS
Build rail along the game view Y axis.
Definition rail_widget.h:17
WID_RAT_CONVERT_RAIL
@ WID_RAT_CONVERT_RAIL
Convert other rail to this type.
Definition rail_widget.h:30
WID_RAT_BUILD_Y
@ WID_RAT_BUILD_Y
Build rail along the game grid Y axis.
Definition rail_widget.h:20
WID_RAT_BUILD_EW
@ WID_RAT_BUILD_EW
Build rail along the game view X axis.
Definition rail_widget.h:19
WID_RAT_BUILD_BRIDGE
@ WID_RAT_BUILD_BRIDGE
Build a bridge.
Definition rail_widget.h:27
WID_RAT_REMOVE
@ WID_RAT_REMOVE
Bulldozer to remove rail.
Definition rail_widget.h:29
WID_RAT_CAPTION
@ WID_RAT_CAPTION
Caption of the window.
Definition rail_widget.h:16
WID_RAT_BUILD_WAYPOINT
@ WID_RAT_BUILD_WAYPOINT
Build a waypoint.
Definition rail_widget.h:24
WID_RAT_BUILD_DEPOT
@ WID_RAT_BUILD_DEPOT
Build a depot.
Definition rail_widget.h:23
WID_RAT_DEMOLISH
@ WID_RAT_DEMOLISH
Destroy something with dynamite!
Definition rail_widget.h:22
WID_RAT_BUILD_STATION
@ WID_RAT_BUILD_STATION
Build a station.
Definition rail_widget.h:25
WID_RAT_BUILD_X
@ WID_RAT_BUILD_X
Build rail along the game grid X axis.
Definition rail_widget.h:18
WID_RAT_BUILD_TUNNEL
@ WID_RAT_BUILD_TUNNEL
Build a tunnel.
Definition rail_widget.h:28
WID_RAT_AUTORAIL
@ WID_RAT_AUTORAIL
Autorail tool.
Definition rail_widget.h:21
WID_BRAS_HIGHLIGHT_OFF
@ WID_BRAS_HIGHLIGHT_OFF
Button for turning coverage highlighting off.
Definition rail_widget.h:57
WID_BRAS_PLATFORM_NUM_4
@ WID_BRAS_PLATFORM_NUM_4
Button to select stations with 4 platforms.
Definition rail_widget.h:42
WID_BRAS_PLATFORM_NUM_7
@ WID_BRAS_PLATFORM_NUM_7
Button to select stations with 7 platforms.
Definition rail_widget.h:45
WID_BRAS_PLATFORM_DIR_X
@ WID_BRAS_PLATFORM_DIR_X
Button to select '/' view.
Definition rail_widget.h:36
WID_BRAS_PLATFORM_LEN_BEGIN
@ WID_BRAS_PLATFORM_LEN_BEGIN
Helper for determining the chosen platform length.
Definition rail_widget.h:62
WID_BRAS_PLATFORM_LEN_3
@ WID_BRAS_PLATFORM_LEN_3
Button to select 3 tiles length station platforms.
Definition rail_widget.h:49
WID_BRAS_PLATFORM_DIR_Y
@ WID_BRAS_PLATFORM_DIR_Y
Button to select '\' view.
Definition rail_widget.h:37
WID_BRAS_PLATFORM_LEN_6
@ WID_BRAS_PLATFORM_LEN_6
Button to select 6 tiles length station platforms.
Definition rail_widget.h:52
WID_BRAS_PLATFORM_NUM_1
@ WID_BRAS_PLATFORM_NUM_1
Button to select stations with a single platform.
Definition rail_widget.h:39
WID_BRAS_PLATFORM_NUM_BEGIN
@ WID_BRAS_PLATFORM_NUM_BEGIN
Helper for determining the chosen platform width.
Definition rail_widget.h:61
WID_BRAS_PLATFORM_NUM_3
@ WID_BRAS_PLATFORM_NUM_3
Button to select stations with 3 platforms.
Definition rail_widget.h:41
WID_BRAS_PLATFORM_LEN_5
@ WID_BRAS_PLATFORM_LEN_5
Button to select 5 tiles length station platforms.
Definition rail_widget.h:51
WID_BRAS_PLATFORM_NUM_5
@ WID_BRAS_PLATFORM_NUM_5
Button to select stations with 5 platforms.
Definition rail_widget.h:43
WID_BRAS_COVERAGE_TEXTS
@ WID_BRAS_COVERAGE_TEXTS
Empty space for the coverage texts.
Definition rail_widget.h:59
WID_BRAS_PLATFORM_LEN_1
@ WID_BRAS_PLATFORM_LEN_1
Button to select single tile length station platforms.
Definition rail_widget.h:47
WID_BRAS_HIGHLIGHT_ON
@ WID_BRAS_HIGHLIGHT_ON
Button for turning coverage highlighting on.
Definition rail_widget.h:58
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
WID_BRAS_PLATFORM_LEN_7
@ WID_BRAS_PLATFORM_LEN_7
Button to select 7 tiles length station platforms.
Definition rail_widget.h:53
WID_BRAS_PLATFORM_NUM_6
@ WID_BRAS_PLATFORM_NUM_6
Button to select stations with 6 platforms.
Definition rail_widget.h:44
WID_BRAS_PLATFORM_NUM_2
@ WID_BRAS_PLATFORM_NUM_2
Button to select stations with 2 platforms.
Definition rail_widget.h:40
WID_BRAS_PLATFORM_LEN_4
@ WID_BRAS_PLATFORM_LEN_4
Button to select 4 tiles length station platforms.
Definition rail_widget.h:50
WID_BRAS_PLATFORM_LEN_2
@ WID_BRAS_PLATFORM_LEN_2
Button to select 2 tiles length station platforms.
Definition rail_widget.h:48
WID_BRAD_DEPOT_SE
@ WID_BRAD_DEPOT_SE
Build a depot with the entrance in the south east.
Definition rail_widget.h:92
WID_BRAD_DEPOT_NE
@ WID_BRAD_DEPOT_NE
Build a depot with the entrance in the north east.
Definition rail_widget.h:91
WID_BRAD_DEPOT_SW
@ WID_BRAD_DEPOT_SW
Build a depot with the entrance in the south west.
Definition rail_widget.h:93
WID_BRAD_DEPOT_NW
@ WID_BRAD_DEPOT_NW
Build a depot with the entrance in the north west.
Definition rail_widget.h:94
WID_BS_DRAG_SIGNALS_DENSITY_DECREASE
@ WID_BS_DRAG_SIGNALS_DENSITY_DECREASE
Decrease the signal density.
Definition rail_widget.h:82
WID_BS_ELECTRIC_PBS
@ WID_BS_ELECTRIC_PBS
Build an electric path signal.
Definition rail_widget.h:78
WID_BS_SEMAPHORE_NORM
@ WID_BS_SEMAPHORE_NORM
Build a semaphore normal block signal.
Definition rail_widget.h:68
WID_BS_ELECTRIC_NORM
@ WID_BS_ELECTRIC_NORM
Build an electric normal block signal.
Definition rail_widget.h:74
WID_BS_ELECTRIC_EXIT
@ WID_BS_ELECTRIC_EXIT
Build an electric exit block signal.
Definition rail_widget.h:76
WID_BS_ELECTRIC_ENTRY
@ WID_BS_ELECTRIC_ENTRY
Build an electric entry block signal.
Definition rail_widget.h:75
WID_BS_SEMAPHORE_ENTRY
@ WID_BS_SEMAPHORE_ENTRY
Build a semaphore entry block signal.
Definition rail_widget.h:69
WID_BS_BLOCK_SEL
@ WID_BS_BLOCK_SEL
Container for the block signal group, which can be hidden.
Definition rail_widget.h:84
WID_BS_CAPTION
@ WID_BS_CAPTION
Caption for the Signal Selection window.
Definition rail_widget.h:67
WID_BS_SEMAPHORE_COMBO
@ WID_BS_SEMAPHORE_COMBO
Build a semaphore combo block signal.
Definition rail_widget.h:71
WID_BS_BLOCK_SPACER_SEL
@ WID_BS_BLOCK_SPACER_SEL
Container for the spacer between block and path signal groups, which can be hidden.
Definition rail_widget.h:85
WID_BS_SEMAPHORE_PBS
@ WID_BS_SEMAPHORE_PBS
Build a semaphore path signal.
Definition rail_widget.h:72
WID_BS_DRAG_SIGNALS_DENSITY_LABEL
@ WID_BS_DRAG_SIGNALS_DENSITY_LABEL
The current signal density.
Definition rail_widget.h:81
WID_BS_SEMAPHORE_EXIT
@ WID_BS_SEMAPHORE_EXIT
Build a semaphore exit block signal.
Definition rail_widget.h:70
WID_BS_SEMAPHORE_PBS_OWAY
@ WID_BS_SEMAPHORE_PBS_OWAY
Build a semaphore one way path signal.
Definition rail_widget.h:73
WID_BS_DRAG_SIGNALS_DENSITY_INCREASE
@ WID_BS_DRAG_SIGNALS_DENSITY_INCREASE
Increase the signal density.
Definition rail_widget.h:83
WID_BS_CONVERT
@ WID_BS_CONVERT
Convert the signal.
Definition rail_widget.h:80
WID_BS_ELECTRIC_COMBO
@ WID_BS_ELECTRIC_COMBO
Build an electric combo block signal.
Definition rail_widget.h:77
WID_BS_ELECTRIC_PBS_OWAY
@ WID_BS_ELECTRIC_PBS_OWAY
Build an electric one way path signal.
Definition rail_widget.h:79
IsLevelCrossingTile
bool IsLevelCrossingTile(Tile t)
Return whether a tile is a level crossing tile.
Definition road_map.h:79
INVALID_ROADTYPE
@ INVALID_ROADTYPE
flag for invalid roadtype
Definition road_type.h:28
safeguards.h
A number of safeguards to prevent using unsafe methods.
_settings_game
GameSettings _settings_game
Game settings of a running game or the scenario editor.
Definition settings.cpp:61
_settings_client
ClientSettings _settings_client
The current settings for this game.
Definition settings.cpp:60
SignalType
SignalType
Type of signal, i.e.
Definition signal_type.h:23
SIGTYPE_PBS
@ SIGTYPE_PBS
normal pbs signal
Definition signal_type.h:28
SIGTYPE_BLOCK
@ SIGTYPE_BLOCK
block signal
Definition signal_type.h:24
SignalVariant
SignalVariant
Variant of the signal, i.e.
Definition signal_type.h:16
SIG_SEMAPHORE
@ SIG_SEMAPHORE
Old-fashioned semaphore signal.
Definition signal_type.h:18
SIG_ELECTRIC
@ SIG_ELECTRIC
Light signal.
Definition signal_type.h:17
SndClickBeep
void SndClickBeep()
Play a beep sound for a click event if enabled in settings.
Definition sound.cpp:253
sound_func.h
Functions related to sound.
SND_20_CONSTRUCTION_RAIL
@ SND_20_CONSTRUCTION_RAIL
30 == 0x1E Construction: rail infrastructure
Definition sound_type.h:77
ANIMCURSOR_BUILDSIGNALS
static const CursorID ANIMCURSOR_BUILDSIGNALS
1292 - 1293 - build signal
Definition sprites.h:1526
ANIMCURSOR_DEMOLISH
static const CursorID ANIMCURSOR_DEMOLISH
704 - 707 - demolish dynamite
Definition sprites.h:1522
station_base.h
Base classes/functions for stations.
station_cmd.h
Command definitions related to stations.
ShowSelectStationIfNeeded
void ShowSelectStationIfNeeded(TileArea ta, StationPickerCmdProc proc)
Show the station selection window when needed.
Definition station_gui.cpp:2475
ShowSelectRailWaypointIfNeeded
void ShowSelectRailWaypointIfNeeded(TileArea ta, StationPickerCmdProc proc)
Show the rail waypoint selection window when needed.
Definition station_gui.cpp:2485
DrawStationCoverageAreaText
int DrawStationCoverageAreaText(const Rect &r, StationCoverageType sct, int rad, bool supplies)
Calculates and draws the accepted or supplied cargo around the selected tile(s)
Definition station_gui.cpp:77
CheckRedrawStationCoverage
void CheckRedrawStationCoverage(const Window *w)
Check whether we need to redraw the station coverage text.
Definition station_gui.cpp:159
station_gui.h
Contains enums and function declarations connected with stations GUI.
SCT_ALL
@ SCT_ALL
Draw all cargoes.
Definition station_gui.h:24
station_map.h
Maps accessors for stations.
HasStationTileRail
bool HasStationTileRail(Tile t)
Has this station tile a rail? In other words, is this station tile a rail station or rail waypoint?
Definition station_map.h:146
GetCustomStationSpecIndex
uint GetCustomStationSpecIndex(Tile t)
Get the custom station spec for this tile.
Definition station_map.h:642
HasStationRail
bool HasStationRail(Tile t)
Has this station tile a rail? In other words, is this station tile a rail station or rail waypoint?
Definition station_map.h:135
CA_TRAIN
static constexpr uint CA_TRAIN
Catchment for train stations with "modified catchment" enabled.
Definition station_type.h:117
CA_UNMODIFIED
static constexpr uint CA_UNMODIFIED
Catchment for all stations with "modified catchment" disabled.
Definition station_type.h:120
stdafx.h
Definition of base types and functions in a cross-platform compatible way.
GetEncodedString
EncodedString GetEncodedString(StringID str)
Encode a string with no parameters into an encoded string.
Definition strings.cpp:90
GetString
std::string GetString(StringID string)
Resolve the given StringID into a std::string with formatting but no parameters.
Definition strings.cpp:424
strings_func.h
Functions related to OTTD's strings.
PackVelocity
int64_t PackVelocity(uint speed, VehicleType type)
Pack velocity and vehicle type for use with SCC_VELOCITY string parameter.
Definition strings_func.h:83
StringID
uint32_t StringID
Numeric value that represents a string, independent of the selected language.
Definition strings_type.h:19
INVALID_STRING_ID
static const StringID INVALID_STRING_ID
Constant representing an invalid string (16bit in case it is used in savegames)
Definition strings_type.h:20
AutoRestoreBackup
Class to backup a specific variable and restore it upon destruction of this object to prevent stack v...
Definition backup_type.hpp:150
BaseStation
Base class for all station-ish types.
Definition base_station_base.h:58
BaseStation::train_station
TileArea train_station
Tile area the train 'station' part covers.
Definition base_station_base.h:83
BaseStation::TileBelongsToRailStation
virtual bool TileBelongsToRailStation(TileIndex tile) const =0
Check whether a specific tile belongs to this station.
BuildRailDepotWindow
Definition rail_gui.cpp:1713
BuildRailDepotWindow::UpdateWidgetSize
void UpdateWidgetSize(WidgetID 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:1720
BuildRailDepotWindow::OnClick
void OnClick(Point pt, WidgetID widget, int click_count) override
A click with the left mouse button has been made on the window.
Definition rail_gui.cpp:1742
BuildRailDepotWindow::DrawWidget
void DrawWidget(const Rect &r, WidgetID widget) const override
Draw the contents of a nested widget.
Definition rail_gui.cpp:1728
BuildRailStationWindow
Definition rail_gui.cpp:1056
BuildRailStationWindow::OnRealtimeTick
void OnRealtimeTick(uint delta_ms) override
Called periodically.
Definition rail_gui.cpp:1368
BuildRailStationWindow::OnPaint
void OnPaint() override
The window must be repainted.
Definition rail_gui.cpp:1131
BuildRailStationWindow::OnClick
void OnClick(Point pt, WidgetID widget, int click_count) override
A click with the left mouse button has been made on the window.
Definition rail_gui.cpp:1238
BuildRailStationWindow::UpdateWidgetSize
void UpdateWidgetSize(WidgetID 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:1180
BuildRailStationWindow::BuildRailStationGlobalHotkeys
static EventState BuildRailStationGlobalHotkeys(int hotkey)
Handler for global hotkeys of the BuildRailStationWindow.
Definition rail_gui.cpp:1378
BuildRailStationWindow::DrawWidget
void DrawWidget(const Rect &r, WidgetID widget) const override
Draw the contents of a nested widget.
Definition rail_gui.cpp:1199
BuildRailStationWindow::Close
void Close(int data=0) override
Hide the window and all its child windows, and mark them for a later deletion.
Definition rail_gui.cpp:1115
BuildRailStationWindow::coverage_height
uint coverage_height
Height of the coverage texts.
Definition rail_gui.cpp:1058
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:1065
BuildRailStationWindow::OnInit
void OnInit() override
Notification that the nested widget tree gets initialized.
Definition rail_gui.cpp:1100
BuildRailStationWindow::OnInvalidateData
void OnInvalidateData(int data=0, bool gui_scope=true) override
Some data on this window has become invalid.
Definition rail_gui.cpp:1121
BuildRailToolbarWindow
Rail toolbar management class.
Definition rail_gui.cpp:438
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:815
BuildRailToolbarWindow::railtype
RailType railtype
Rail type to build.
Definition rail_gui.cpp:439
BuildRailToolbarWindow::OnRealtimeTick
void OnRealtimeTick(uint delta_ms) override
Called periodically.
Definition rail_gui.cpp:828
BuildRailToolbarWindow::OnInvalidateData
void OnInvalidateData(int data=0, bool gui_scope=true) override
Some data on this window has become invalid.
Definition rail_gui.cpp:468
BuildRailToolbarWindow::last_user_action
WidgetID last_user_action
Last started user action.
Definition rail_gui.cpp:440
BuildRailToolbarWindow::ModifyRailType
void ModifyRailType(RailType railtype)
Switch to another rail type.
Definition rail_gui.cpp:518
BuildRailToolbarWindow::OnInit
void OnInit() override
Notification that the nested widget tree gets initialized.
Definition rail_gui.cpp:500
BuildRailToolbarWindow::OnTooltip
bool OnTooltip(Point pt, WidgetID widget, TooltipCloseCondition close_cond) override
Event to display a custom tooltip.
Definition rail_gui.cpp:489
BuildRailToolbarWindow::OnClick
void OnClick(Point pt, WidgetID widget, int click_count) override
A click with the left mouse button has been made on the window.
Definition rail_gui.cpp:567
BuildRailToolbarWindow::OnCTRLStateChange
EventState OnCTRLStateChange() override
The state of the control key has changed.
Definition rail_gui.cpp:821
BuildRailToolbarWindow::GetWidgetString
std::string GetWidgetString(WidgetID widget, StringID stringid) const override
Get the raw string for a widget.
Definition rail_gui.cpp:554
BuildRailToolbarWindow::OnPlaceObjectAbort
void OnPlaceObjectAbort() override
The user cancelled a tile highlight mode that has been set.
Definition rail_gui.cpp:798
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:723
BuildRailToolbarWindow::RailToolbarGlobalHotkeys
static EventState RailToolbarGlobalHotkeys(int hotkey)
Handler for global hotkeys of the BuildRailToolbarWindow.
Definition rail_gui.cpp:838
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:664
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:736
BuildRailToolbarWindow::can_build_widgets
static const std::initializer_list< WidgetID > can_build_widgets
List of widgets to be disabled if infrastructure limit prevents building.
Definition rail_gui.cpp:462
BuildRailToolbarWindow::OnInitialPosition
Point OnInitialPosition(int16_t sm_width, int16_t sm_height, int window_number) override
Compute the initial position of the window.
Definition rail_gui.cpp:731
BuildRailToolbarWindow::OnHotkey
EventState OnHotkey(int hotkey) override
A hotkey has been pressed.
Definition rail_gui.cpp:658
BuildRailToolbarWindow::Close
void Close(int data=0) override
Hide the window and all its child windows, and mark them for a later deletion.
Definition rail_gui.cpp:452
BuildRailWaypointWindow
Definition rail_gui.cpp:1873
BuildSignalWindow
Definition rail_gui.cpp:1459
BuildSignalWindow::sig_sprite_size
Dimension sig_sprite_size
Maximum size of signal GUI sprites.
Definition rail_gui.cpp:1461
BuildSignalWindow::DrawSignalSprite
void DrawSignalSprite(const Rect &r, SpriteID image) const
Draw dynamic a signal-sprite in a button in the signal GUI.
Definition rail_gui.cpp:1468
BuildSignalWindow::SetSignalUIMode
void SetSignalUIMode()
Show or hide buttons for non-path signals in the signal GUI.
Definition rail_gui.cpp:1481
BuildSignalWindow::UpdateWidgetSize
void UpdateWidgetSize(WidgetID 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:1524
BuildSignalWindow::GetWidgetString
std::string GetWidgetString(WidgetID widget, StringID stringid) const override
Get the raw string for a widget.
Definition rail_gui.cpp:1535
BuildSignalWindow::OnInit
void OnInit() override
Notification that the nested widget tree gets initialized.
Definition rail_gui.cpp:1504
BuildSignalWindow::OnInvalidateData
void OnInvalidateData(int data=0, bool gui_scope=true) override
Some data on this window has become invalid.
Definition rail_gui.cpp:1620
BuildSignalWindow::DrawWidget
void DrawWidget(const Rect &r, WidgetID widget) const override
Draw the contents of a nested widget.
Definition rail_gui.cpp:1546
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:1462
BuildSignalWindow::Close
void Close(int data=0) override
Hide the window and all its child windows, and mark them for a later deletion.
Definition rail_gui.cpp:1498
BuildSignalWindow::OnClick
void OnClick(Point pt, WidgetID widget, int click_count) override
A click with the left mouse button has been made on the window.
Definition rail_gui.cpp:1558
ClientSettings::sound
SoundSettings sound
sound effect settings
Definition settings_type.h:653
ClientSettings::gui
GUISettings gui
settings related to the GUI
Definition settings_type.h:650
CommandHelper
Definition command_func.h:83
Company
Definition company_base.h:127
Company::avail_railtypes
RailTypes avail_railtypes
Rail types available to this company.
Definition company_base.h:131
Coord2D< int >
Coord2D::y
T y
Y coordinate.
Definition geometry_type.hpp:35
Coord2D::x
T x
X coordinate.
Definition geometry_type.hpp:34
Dimension
Dimensions (a width and height) of a rectangle in 2D.
Definition geometry_type.hpp:56
DrawPixelInfo
Data about how and where to blit pixels.
Definition gfx_type.h:157
GRFFilePropsBase::grffile
const struct GRFFile * grffile
grf file that introduced this entity
Definition newgrf_commons.h:318
GUISettings::persistent_buildingtools
bool persistent_buildingtools
keep the building tools active after usage
Definition settings_type.h:225
GUISettings::cycle_signal_types
SignalCycleSettings cycle_signal_types
Which signal types to cycle with the build signal tool.
Definition settings_type.h:210
GUISettings::station_platlength
uint8_t station_platlength
the platform length, in tiles, for rail stations
Definition settings_type.h:222
GUISettings::auto_remove_signals
bool auto_remove_signals
automatically remove signals when in the way during rail construction
Definition settings_type.h:235
GUISettings::station_dragdrop
bool station_dragdrop
whether drag and drop is enabled for stations
Definition settings_type.h:223
GUISettings::station_show_coverage
bool station_show_coverage
whether to highlight coverage area
Definition settings_type.h:224
GUISettings::default_rail_type
uint8_t default_rail_type
the default rail type for the rail GUI
Definition settings_type.h:186
GUISettings::drag_signals_density
uint8_t drag_signals_density
many signals density
Definition settings_type.h:216
GUISettings::station_numtracks
uint8_t station_numtracks
the number of platforms to default on for rail stations
Definition settings_type.h:221
GUISettings::semaphore_build_before
TimerGameCalendar::Year semaphore_build_before
build semaphore signals automatically before this year
Definition settings_type.h:218
GUISettings::signal_gui_mode
SignalGUISettings signal_gui_mode
select which signal types are shown in the signal GUI
Definition settings_type.h:209
GUISettings::drag_signals_fixed_distance
bool drag_signals_fixed_distance
keep fixed distance between signals when dragging
Definition settings_type.h:217
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:211
GUISettings::link_terraform_toolbar
bool link_terraform_toolbar
display terraform toolbar when displaying rail, road, water and airport toolbars
Definition settings_type.h:176
GameSettings::station
StationSettings station
settings related to station management
Definition settings_type.h:644
HotkeyList
List of hotkeys for a window.
Definition hotkeys.h:37
Hotkey
All data for a single hotkey.
Definition hotkeys.h:21
Map::Iterate
static IterateWrapper Iterate()
Returns an iterable ensemble of all Tiles.
Definition map_func.h:375
OrthogonalTileArea
Represents the covered area of e.g.
Definition tilearea_type.h:18
OrthogonalTileArea::w
uint16_t w
The width of the area.
Definition tilearea_type.h:20
OrthogonalTileArea::tile
TileIndex tile
The base tile of the area.
Definition tilearea_type.h:19
OrthogonalTileArea::h
uint16_t h
The height of the area.
Definition tilearea_type.h:21
PoolID< uint16_t, struct StationIDTag, 64000, 0xFFFF >
Pool::PoolItem<&_company_pool >::Get
static Titem * Get(auto index)
Returns Titem with given index.
Definition pool_type.hpp:387
Pool::PoolItem::index
Tindex index
Index of this pool item.
Definition pool_type.hpp:286
Pool::PoolItem<&_company_pool >::IsValidID
static bool IsValidID(auto index)
Tests whether given index can be used to get valid (non-nullptr) Titem.
Definition pool_type.hpp:376
RectPadding::Horizontal
constexpr uint Horizontal() const
Get total horizontal padding of RectPadding.
Definition geometry_type.hpp:89
RectPadding::Vertical
constexpr uint Vertical() const
Get total vertical padding of RectPadding.
Definition geometry_type.hpp:95
Rect
Specification of a rectangle with absolute coordinates of all edges.
Definition geometry_type.hpp:101
Rect::Width
int Width() const
Get width of Rect.
Definition geometry_type.hpp:111
Rect::Shrink
Rect Shrink(int s) const
Copy and shrink Rect by s pixels.
Definition geometry_type.hpp:124
Rect::Height
int Height() const
Get height of Rect.
Definition geometry_type.hpp:117
SoundSettings::confirm
bool confirm
Play sound effect on successful constructions or other actions.
Definition settings_type.h:275
SpecializedStation< Station, false >::Iterate
static Pool::IterateWrapper< Station > Iterate(size_t from=0)
Returns an iterable ensemble of all valid stations of type T.
Definition base_station_base.h:299
StationPickerSelection
Definition rail_gui.cpp:69
StationPickerSelection::sel_class
StationClassID sel_class
Selected station class.
Definition rail_gui.cpp:70
StationPickerSelection::sel_type
uint16_t sel_type
Selected station type within the class.
Definition rail_gui.cpp:71
StationPickerSelection::axis
Axis axis
Selected orientation of the station.
Definition rail_gui.cpp:72
StationSettings::station_spread
uint8_t station_spread
amount a station may spread
Definition settings_type.h:597
StationSettings::modified_catchment
bool modified_catchment
different-size catchment areas
Definition settings_type.h:593
StationSpec
Station specification.
Definition newgrf_station.h:123
StationSpec::disallowed_lengths
uint8_t disallowed_lengths
Bitmask of platform lengths available for the station.
Definition newgrf_station.h:142
StationSpec::disallowed_platforms
uint8_t disallowed_platforms
Bitmask of number of platforms available for the station.
Definition newgrf_station.h:137
StationSpec::grf_prop
CargoGRFFileProps grf_prop
Link to NewGRF.
Definition newgrf_station.h:130
StationSpec::callback_mask
StationCallbackMasks callback_mask
Bitmask of station callbacks that have to be called.
Definition newgrf_station.h:162
Station
Station data structure.
Definition station_base.h:500
StrongType::Typedef< uint32_t, struct TileIndexTag, StrongType::Compare, StrongType::Integer, StrongType::Compatible< int32_t >, StrongType::Compatible< int64_t > >
TileHighlightData::selstart
Point selstart
The location where the dragging started.
Definition tilehighlight_type.h:60
TileHighlightData::drawstyle
HighLightStyle drawstyle
Lower bits 0-3 are reserved for detailed highlight information.
Definition tilehighlight_type.h:64
TileHighlightData::pos
Point pos
Location, in tile "units", of the northern tile of the selected area.
Definition tilehighlight_type.h:47
TileHighlightData::selend
Point selend
The location where the drag currently ends.
Definition tilehighlight_type.h:61
WaypointPickerSelection
Definition rail_gui.cpp:63
WaypointPickerSelection::sel_class
StationClassID sel_class
Selected station class.
Definition rail_gui.cpp:64
WaypointPickerSelection::sel_type
uint16_t sel_type
Selected station type within the class.
Definition rail_gui.cpp:65
Waypoint
Representation of a waypoint.
Definition waypoint_base.h:23
WindowDesc
High level window description.
Definition window_gui.h:168
Window
Data structure for an opened window.
Definition window_gui.h:274
Window::ReInit
void ReInit(int rx=0, int ry=0, bool reposition=false)
Re-initialize a window, and optionally change its size.
Definition window.cpp:978
Window::Close
virtual void Close(int data=0)
Hide the window and all its child windows, and mark them for a later deletion.
Definition window.cpp:1102
Window::FinishInitNested
void FinishInitNested(WindowNumber window_number=0)
Perform the second part of the initialization of a nested widget tree.
Definition window.cpp:1807
Window::DrawWidgets
void DrawWidgets() const
Paint all widgets of a window.
Definition widget.cpp:766
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:3234
Window::parent
Window * parent
Parent window.
Definition window_gui.h:329
Window::RaiseWidget
void RaiseWidget(WidgetID widget_index)
Marks a widget as raised.
Definition window_gui.h:470
Window::SetWidgetDirty
void SetWidgetDirty(WidgetID widget_index) const
Invalidate a widget, i.e.
Definition window.cpp:556
Window::GetWidgetString
virtual std::string GetWidgetString(WidgetID widget, StringID stringid) const
Get the raw string for a widget.
Definition window.cpp:504
Window::resize
ResizeInfo resize
Resize information.
Definition window_gui.h:315
Window::DisableWidget
void DisableWidget(WidgetID widget_index)
Sets a widget to disabled.
Definition window_gui.h:392
Window::CreateNestedTree
void CreateNestedTree()
Perform the first part of the initialization of a nested widget tree.
Definition window.cpp:1797
Window::IsWidgetLowered
bool IsWidgetLowered(WidgetID widget_index) const
Gets the lowered state of a widget.
Definition window_gui.h:492
Window::IsWidgetDisabled
bool IsWidgetDisabled(WidgetID widget_index) const
Gets the enabled/disabled status of a widget.
Definition window_gui.h:411
Window::RaiseButtons
void RaiseButtons(bool autoraise=false)
Raise the buttons of the window.
Definition window.cpp:530
Window::SetWidgetLoweredState
void SetWidgetLoweredState(WidgetID widget_index, bool lowered_stat)
Sets the lowered/raised status of a widget.
Definition window_gui.h:442
Window::IsShaded
bool IsShaded() const
Is window shaded currently?
Definition window_gui.h:560
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:843
Window::LowerWidget
void LowerWidget(WidgetID widget_index)
Marks a widget as lowered.
Definition window_gui.h:461
Window::InitNested
void InitNested(WindowNumber number=0)
Perform complete initialization of the Window with nested widgets, to allow use.
Definition window.cpp:1820
Window::OnHotkey
virtual EventState OnHotkey(int hotkey)
A hotkey has been pressed.
Definition window.cpp:570
Window::SetWidgetDisabledState
void SetWidgetDisabledState(WidgetID widget_index, bool disab_stat)
Sets the enabled/disabled status of a widget.
Definition window_gui.h:382
Window::ToggleWidgetLoweredState
void ToggleWidgetLoweredState(WidgetID widget_index)
Invert the lowered/raised status of a widget.
Definition window_gui.h:451
Window::window_number
WindowNumber window_number
Window number within the window class.
Definition window_gui.h:303
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:112
PlaceProc_DemolishArea
void PlaceProc_DemolishArea(TileIndex tile)
Start a drag for demolishing an area.
Definition terraform_gui.cpp:151
ShowTerraformToolbar
Window * ShowTerraformToolbar(Window *link)
Show the toolbar for terraforming in the game.
Definition terraform_gui.cpp:364
terraform_gui.h
GUI stuff related to terraforming.
IsTileType
static bool IsTileType(Tile tile, TileType type)
Checks if a tile is a given tiletype.
Definition tile_map.h:150
IsValidTile
bool IsValidTile(Tile tile)
Checks if a tile is valid.
Definition tile_map.h:161
INVALID_TILE
constexpr TileIndex INVALID_TILE
The very nice invalid tile marker.
Definition tile_type.h:95
MP_TUNNELBRIDGE
@ MP_TUNNELBRIDGE
Tunnel entry/exit and bridge heads.
Definition tile_type.h:57
MP_RAILWAY
@ MP_RAILWAY
A railway.
Definition tile_type.h:49
TileArea
OrthogonalTileArea TileArea
Shorthand for the much more common orthogonal tile area.
Definition tilearea_type.h:102
tilehighlight_func.h
Functions related to tile highlights.
ResetObjectToPlace
void ResetObjectToPlace()
Reset the cursor and mouse mode handling back to default (normal cursor, only clicking in windows).
Definition viewport.cpp:3573
VpSetPresizeRange
void VpSetPresizeRange(TileIndex from, TileIndex to)
Highlights all tiles between a set of two tiles.
Definition viewport.cpp:2853
VpSelectTilesWithMethod
void VpSelectTilesWithMethod(int x, int y, ViewportPlaceMethod method)
Selects tiles while dragging.
Definition viewport.cpp:3291
VpStartPlaceSizing
void VpStartPlaceSizing(TileIndex tile, ViewportPlaceMethod method, ViewportDragDropSelectionProcess process)
highlighting tiles while only going over them with the mouse
Definition viewport.cpp:2798
HT_LINE
@ HT_LINE
used for autorail highlighting (longer stretches), lower bits: direction
Definition tilehighlight_type.h:25
HT_DIR_HL
@ HT_DIR_HL
horizontal lower
Definition tilehighlight_type.h:36
HT_DIR_X
@ HT_DIR_X
X direction.
Definition tilehighlight_type.h:33
HT_DIAGONAL
@ HT_DIAGONAL
Also allow 'diagonal rectangles'. Only usable in combination with HT_RECT or HT_POINT.
Definition tilehighlight_type.h:28
HT_RECT
@ HT_RECT
rectangle (stations, depots, ...)
Definition tilehighlight_type.h:21
HT_DIR_MASK
@ HT_DIR_MASK
masks the drag-direction
Definition tilehighlight_type.h:40
HT_RAIL
@ HT_RAIL
autorail (one piece), lower bits: direction
Definition tilehighlight_type.h:26
HT_DRAG_MASK
@ HT_DRAG_MASK
Mask for the tile drag-type modes.
Definition tilehighlight_type.h:29
HT_DIR_VL
@ HT_DIR_VL
vertical left
Definition tilehighlight_type.h:37
HT_SPECIAL
@ HT_SPECIAL
special mode used for highlighting while dragging (and for tunnels/docks)
Definition tilehighlight_type.h:23
HT_DIR_Y
@ HT_DIR_Y
Y direction.
Definition tilehighlight_type.h:34
timer.h
Definition of Interval and OneShot timers.
timer_game_calendar.h
Definition of the game-calendar-timer.
IsValidTrack
bool IsValidTrack(Track track)
Checks if a Track is valid.
Definition track_func.h:28
FindFirstTrack
Track FindFirstTrack(TrackBits tracks)
Returns first Track from TrackBits or INVALID_TRACK.
Definition track_func.h:177
DiagdirReachesTracks
TrackBits DiagdirReachesTracks(DiagDirection diagdir)
Returns all tracks that can be reached when entering a tile from a given (diagonal) direction.
Definition track_func.h:573
TrackStatusToTrackBits
TrackBits TrackStatusToTrackBits(TrackStatus ts)
Returns the present-track-information of a TrackStatus.
Definition track_func.h:363
TrackBits
TrackBits
Allow incrementing of Track variables.
Definition track_type.h:35
TRACK_BIT_UPPER
@ TRACK_BIT_UPPER
Upper track.
Definition track_type.h:39
TRACK_BIT_LEFT
@ TRACK_BIT_LEFT
Left track.
Definition track_type.h:41
TRACK_BIT_HORZ
@ TRACK_BIT_HORZ
Upper and lower track.
Definition track_type.h:44
TRACK_BIT_LOWER
@ TRACK_BIT_LOWER
Lower track.
Definition track_type.h:40
TRACK_BIT_RIGHT
@ TRACK_BIT_RIGHT
Right track.
Definition track_type.h:42
TRACK_BIT_VERT
@ TRACK_BIT_VERT
Left and right track.
Definition track_type.h:45
Track
Track
These are used to specify a single track.
Definition track_type.h:19
TRACK_Y
@ TRACK_Y
Track along the y-axis (north-west to south-east)
Definition track_type.h:22
TRACK_LOWER
@ TRACK_LOWER
Track in the lower corner of the tile (south)
Definition track_type.h:24
TRACK_LEFT
@ TRACK_LEFT
Track in the left corner of the tile (west)
Definition track_type.h:25
TRACK_RIGHT
@ TRACK_RIGHT
Track in the right corner of the tile (east)
Definition track_type.h:26
TRACK_X
@ TRACK_X
Track along the x-axis (north-east to south-west)
Definition track_type.h:21
TRACK_UPPER
@ TRACK_UPPER
Track in the upper corner of the tile (north)
Definition track_type.h:23
TRANSPORT_RAIL
@ TRANSPORT_RAIL
Transport by train.
Definition transport_type.h:25
tunnelbridge.h
Header file for things common for tunnels and bridges.
_build_tunnel_endtile
TileIndex _build_tunnel_endtile
The end of a tunnel; as hidden return from the tunnel build command for GUI purposes.
Definition tunnelbridge_cmd.cpp:50
tunnelbridge_cmd.h
Command definitions related to tunnels and bridges.
tunnelbridge_map.h
Functions that have tunnels and bridges in common.
GetTunnelBridgeTransportType
TransportType GetTunnelBridgeTransportType(Tile t)
Tunnel: Get the transport type of the tunnel (road or rail) Bridge: Get the transport type of the bri...
Definition tunnelbridge_map.h:39
GetOtherTunnelBridgeEnd
TileIndex GetOtherTunnelBridgeEnd(Tile t)
Determines type of the wormhole and returns its other end.
Definition tunnelbridge_map.h:78
CanBuildVehicleInfrastructure
bool CanBuildVehicleInfrastructure(VehicleType type, uint8_t subtype)
Check whether we can build infrastructure for the given vehicle type.
Definition vehicle.cpp:1903
vehicle_func.h
Functions related to vehicles.
VEH_TRAIN
@ VEH_TRAIN
Train vehicle type.
Definition vehicle_type.h:25
SetTileSelectSize
void SetTileSelectSize(int w, int h)
Highlight w by h tiles at the cursor.
Definition viewport.cpp:2619
SetViewportCatchmentWaypoint
void SetViewportCatchmentWaypoint(const Waypoint *wp, bool sel)
Select or deselect waypoint for coverage area highlight.
Definition viewport.cpp:3759
SetRedErrorSquare
void SetRedErrorSquare(TileIndex tile)
Set a tile to display a red error square.
Definition viewport.cpp:2601
SetViewportCatchmentStation
void SetViewportCatchmentStation(const Station *st, bool sel)
Select or deselect station for coverage area highlight.
Definition viewport.cpp:3713
viewport_func.h
Functions related to (drawing on) viewports.
ViewportPlaceMethod
ViewportPlaceMethod
Viewport place method (type of highlighted area and placed objects)
Definition viewport_type.h:96
VPM_FIX_Y
@ VPM_FIX_Y
drag only in Y axis
Definition viewport_type.h:99
VPM_Y_LIMITED
@ VPM_Y_LIMITED
Drag only in Y axis with limited size.
Definition viewport_type.h:105
VPM_X_AND_Y_LIMITED
@ VPM_X_AND_Y_LIMITED
area of land of limited size
Definition viewport_type.h:101
VPM_FIX_VERTICAL
@ VPM_FIX_VERTICAL
drag only in vertical direction
Definition viewport_type.h:103
VPM_X_LIMITED
@ VPM_X_LIMITED
Drag only in X axis with limited size.
Definition viewport_type.h:104
VPM_X_AND_Y
@ VPM_X_AND_Y
area of land in X and Y directions
Definition viewport_type.h:100
VPM_FIX_HORIZONTAL
@ VPM_FIX_HORIZONTAL
drag only in horizontal direction
Definition viewport_type.h:102
VPM_FIX_X
@ VPM_FIX_X
drag only in X axis
Definition viewport_type.h:98
VPM_SIGNALDIRS
@ VPM_SIGNALDIRS
similar to VMP_RAILDIRS, but with different cursor
Definition viewport_type.h:107
VPM_X_OR_Y
@ VPM_X_OR_Y
drag in X or Y direction
Definition viewport_type.h:97
VPM_RAILDIRS
@ VPM_RAILDIRS
all rail directions
Definition viewport_type.h:106
ViewportDragDropSelectionProcess
ViewportDragDropSelectionProcess
Drag and drop selection process, or, what to do with an area of land when you've selected it.
Definition viewport_type.h:115
DDSP_CONVERT_RAIL
@ DDSP_CONVERT_RAIL
Rail conversion.
Definition viewport_type.h:133
DDSP_DEMOLISH_AREA
@ DDSP_DEMOLISH_AREA
Clear area.
Definition viewport_type.h:116
DDSP_BUILD_SIGNALS
@ DDSP_BUILD_SIGNALS
Signal placement.
Definition viewport_type.h:130
DDSP_REMOVE_STATION
@ DDSP_REMOVE_STATION
Station removal.
Definition viewport_type.h:132
DDSP_BUILD_STATION
@ DDSP_BUILD_STATION
Station placement.
Definition viewport_type.h:131
DDSP_BUILD_BRIDGE
@ DDSP_BUILD_BRIDGE
Bridge placement.
Definition viewport_type.h:125
DDSP_PLACE_RAIL
@ DDSP_PLACE_RAIL
Rail placement.
Definition viewport_type.h:129
DrawWaypointSprite
void DrawWaypointSprite(int x, int y, StationClassID station_class, uint16_t station_type, RailType railtype)
Draw a waypoint.
Definition waypoint.cpp:28
waypoint_base.h
Base of waypoints.
WPF_ROAD
@ WPF_ROAD
This is a road waypoint.
Definition waypoint_base.h:19
GetAxisForNewRailWaypoint
Axis GetAxisForNewRailWaypoint(TileIndex tile)
Get the axis for a new rail waypoint.
Definition waypoint_cmd.cpp:106
waypoint_cmd.h
Command definitions related to waypoints.
waypoint_func.h
Functions related to waypoints.
ScaleGUITrad
static RectPadding ScaleGUITrad(const RectPadding &r)
Scale a RectPadding to GUI zoom level.
Definition widget.cpp:49
WWT_IMGBTN
@ WWT_IMGBTN
(Toggle) Button with image
Definition widget_type.h:41
WWT_PUSHARROWBTN
@ WWT_PUSHARROWBTN
Normal push-button (no toggle button) with arrow caption.
Definition widget_type.h:106
WWT_LABEL
@ WWT_LABEL
Centered label.
Definition widget_type.h:48
NWID_HORIZONTAL
@ NWID_HORIZONTAL
Horizontal container.
Definition widget_type.h:66
WWT_TEXTBTN
@ WWT_TEXTBTN
(Toggle) Button with text
Definition widget_type.h:44
WWT_PANEL
@ WWT_PANEL
Simple depressed panel.
Definition widget_type.h:39
WWT_STICKYBOX
@ WWT_STICKYBOX
Sticky box (at top-right of a window, after WWT_DEFSIZEBOX)
Definition widget_type.h:57
WWT_SHADEBOX
@ WWT_SHADEBOX
Shade box (at top-right of a window, between WWT_DEBUGBOX and WWT_DEFSIZEBOX)
Definition widget_type.h:55
WWT_CAPTION
@ WWT_CAPTION
Window caption (window title between closebox and stickybox)
Definition widget_type.h:52
NWID_VERTICAL
@ NWID_VERTICAL
Vertical container.
Definition widget_type.h:68
WWT_CLOSEBOX
@ WWT_CLOSEBOX
Close box (at top-left of a window)
Definition widget_type.h:60
WWT_EMPTY
@ WWT_EMPTY
Empty widget, place holder to reserve space in widget tree.
Definition widget_type.h:37
WWT_DEFSIZEBOX
@ WWT_DEFSIZEBOX
Default window size box (at top-right of a window, between WWT_SHADEBOX and WWT_STICKYBOX)
Definition widget_type.h:56
NWID_HORIZONTAL_LTR
@ NWID_HORIZONTAL_LTR
Horizontal container that doesn't change the order of the widgets for RTL languages.
Definition widget_type.h:67
NWID_SELECTION
@ NWID_SELECTION
Stacked widgets, only one visible at a time (eg in a panel with tabs).
Definition widget_type.h:71
SZSP_NONE
@ SZSP_NONE
Display plane with zero size in both directions (none filling and resizing).
Definition widget_type.h:506
EqualSize
@ EqualSize
Containers should keep all their (resizing) children equally large.
Definition widget_type.h:541
AWV_DECREASE
@ AWV_DECREASE
Arrow to the left or in case of RTL to the right.
Definition widget_type.h:20
AWV_INCREASE
@ AWV_INCREASE
Arrow to the right or in case of RTL to the left.
Definition widget_type.h:21
CloseWindowById
void CloseWindowById(WindowClass cls, WindowNumber number, bool force, int data)
Close a window by its class and window number (if it is open).
Definition window.cpp:1193
CloseWindowByClass
void CloseWindowByClass(WindowClass cls, int data)
Close all windows of a given class.
Definition window.cpp:1205
AlignInitialConstructionToolbar
Point AlignInitialConstructionToolbar(int window_width)
Compute the position of the construction toolbars.
Definition window.cpp:1699
FindWindowById
Window * FindWindowById(WindowClass cls, WindowNumber number)
Find a window by its class and window number.
Definition window.cpp:1151
SetWindowDirty
void SetWindowDirty(WindowClass cls, WindowNumber number)
Mark window as dirty (in need of repainting)
Definition window.cpp:3176
window_func.h
Window functions not directly related to making/drawing windows.
window_gui.h
Functions, definitions and such used only by the GUI.
WindowDefaultFlag::Construction
@ Construction
This window is used for construction; close it whenever changing company.
WDP_AUTO
@ WDP_AUTO
Find a place automatically.
Definition window_gui.h:144
WDP_MANUAL
@ WDP_MANUAL
Manually align the window (so no automatic location finding)
Definition window_gui.h:143
WidgetID
int WidgetID
Widget ID.
Definition window_type.h:20
WN_GAME_OPTIONS_GAME_SETTINGS
@ WN_GAME_OPTIONS_GAME_SETTINGS
Game settings.
Definition window_type.h:32
EventState
EventState
State of handling an event.
Definition window_type.h:780
ES_HANDLED
@ ES_HANDLED
The passed event is handled.
Definition window_type.h:781
ES_NOT_HANDLED
@ ES_NOT_HANDLED
The passed event is not handled.
Definition window_type.h:782
INVALID_WIDGET
static constexpr WidgetID INVALID_WIDGET
An invalid widget index.
Definition window_type.h:23
WC_BUILD_STATION
@ WC_BUILD_STATION
Build station; Window numbers:
Definition window_type.h:408
WC_BUILD_TOOLBAR
@ WC_BUILD_TOOLBAR
Build toolbar; Window numbers:
Definition window_type.h:78
WC_NONE
@ WC_NONE
No window, redirects to WC_MAIN_WINDOW.
Definition window_type.h:50
WC_SCEN_LAND_GEN
@ WC_SCEN_LAND_GEN
Landscape generation (in Scenario Editor); Window numbers:
Definition window_type.h:460
WC_SELECT_STATION
@ WC_SELECT_STATION
Select station (when joining stations); Window numbers:
Definition window_type.h:247
WC_BUILD_SIGNAL
@ WC_BUILD_SIGNAL
Build signal toolbar; Window numbers:
Definition window_type.h:103
WC_BUILD_DEPOT
@ WC_BUILD_DEPOT
Build depot; Window numbers:
Definition window_type.h:428
WC_GAME_OPTIONS
@ WC_GAME_OPTIONS
Game options window; Window numbers:
Definition window_type.h:635
WC_BUILD_WAYPOINT
@ WC_BUILD_WAYPOINT
Build waypoint; Window numbers:
Definition window_type.h:434
WC_BUILD_BRIDGE
@ WC_BUILD_BRIDGE
Build bridge; Window numbers:
Definition window_type.h:400
zoom_func.h
Functions related to zooming.
ScaleSpriteTrad
int ScaleSpriteTrad(int value)
Scale traditional pixel dimensions to GUI zoom level, for drawing sprites.
Definition zoom_func.h:107