OpenTTD Source: src/rail_gui.cpp Source File

OpenTTD Source 1.11.0-RC1

rail_gui.cpp
Go to the documentation of this file.
1 /*
2 * This file is part of OpenTTD.
3 * OpenTTD is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, version 2.
4 * OpenTTD is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
5 * See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with OpenTTD. If not, see <http://www.gnu.org/licenses/>.
6 */
7
10 #include "stdafx.h"
11 #include "gui.h"
12 #include "window_gui.h"
13 #include "station_gui.h"
14 #include "terraform_gui.h"
15 #include "viewport_func.h"
16 #include "command_func.h"
17 #include "waypoint_func.h"
18 #include "newgrf_station.h"
19 #include "company_base.h"
20 #include "strings_func.h"
21 #include "window_func.h"
22 #include "date_func.h"
23 #include "sound_func.h"
24 #include "company_func.h"
25 #include "widgets/dropdown_type.h"
26 #include "tunnelbridge.h"
27 #include "tilehighlight_func.h"
28 #include "spritecache.h"
29 #include "core/geometry_func.hpp"
30 #include "hotkeys.h"
31 #include "engine_base.h"
32 #include "vehicle_func.h"
33 #include "zoom_func.h"
34 #include "rail_gui.h"
35 #include "querystring_gui.h"
36 #include "sortlist_type.h"
37 #include "stringfilter_type.h"
38 #include "string_func.h"
39
40 #include "station_map.h"
41 #include "tunnelbridge_map.h"
42
43 #include "widgets/rail_widget.h"
44
45 #include "safeguards.h"
46
47
48 static RailType _cur_railtype;
49 static bool _remove_button_clicked;
50 static DiagDirection _build_depot_direction;
51 static byte _waypoint_count = 1;
52 static byte _cur_waypoint_type;
53 static bool _convert_signal_button;
54 static SignalVariant _cur_signal_variant;
55 static SignalType _cur_signal_type;
56
57 /* Map the setting: default_signal_type to the corresponding signal type */
58 static const SignalType _default_signal_type[] = {SIGTYPE_NORMAL, SIGTYPE_PBS, SIGTYPE_PBS_ONEWAY};
59
60 struct RailStationGUISettings {
61 Axis orientation;
62
63 bool newstations;
64 StationClassID station_class;
65 byte station_type;
66 byte station_count;
67 };
68 static RailStationGUISettings _railstation;
69
70
71 static void HandleStationPlacement(TileIndex start, TileIndex end);
72 static void ShowBuildTrainDepotPicker(Window *parent);
73 static void ShowBuildWaypointPicker(Window *parent);
74 static void ShowStationBuilder(Window *parent);
75 static void ShowSignalBuilder(Window *parent);
76
81 static bool IsStationAvailable(const StationSpec *statspec)
82 {
83 if (statspec == nullptr || !HasBit(statspec->callback_mask, CBM_STATION_AVAIL)) return true;
84
85 uint16 cb_res = GetStationCallback(CBID_STATION_AVAILABILITY, 0, 0, statspec, nullptr, INVALID_TILE);
86 if (cb_res == CALLBACK_FAILED) return true;
87
88 return Convert8bitBooleanCallback(statspec->grf_prop.grffile, CBID_STATION_AVAILABILITY, cb_res);
89 }
90
91 void CcPlaySound_CONSTRUCTION_RAIL(const CommandCost &result, TileIndex tile, uint32 p1, uint32 p2, uint32 cmd)
92 {
93 if (result.Succeeded() && _settings_client.sound.confirm) SndPlayTileFx(SND_20_CONSTRUCTION_RAIL, tile);
94 }
95
96 static void GenericPlaceRail(TileIndex tile, int cmd)
97 {
98 DoCommandP(tile, _cur_railtype, cmd | (_settings_client.gui.auto_remove_signals << 3),
99 _remove_button_clicked ?
100 CMD_REMOVE_SINGLE_RAIL | CMD_MSG(STR_ERROR_CAN_T_REMOVE_RAILROAD_TRACK) :
101 CMD_BUILD_SINGLE_RAIL | CMD_MSG(STR_ERROR_CAN_T_BUILD_RAILROAD_TRACK),
102 CcPlaySound_CONSTRUCTION_RAIL);
103 }
104
112 static void PlaceExtraDepotRail(TileIndex tile, DiagDirection dir, Track track)
113 {
114 if (GetRailTileType(tile) == RAIL_TILE_DEPOT) return;
115 if (GetRailTileType(tile) == RAIL_TILE_SIGNALS && !_settings_client.gui.auto_remove_signals) return;
116 if ((GetTrackBits(tile) & DiagdirReachesTracks(dir)) == 0) return;
117
118 DoCommandP(tile, _cur_railtype, track | (_settings_client.gui.auto_remove_signals << 3), CMD_BUILD_SINGLE_RAIL);
119 }
120
122 static const Track _place_depot_extra_track[12] = {
123 TRACK_LEFT, TRACK_UPPER, TRACK_UPPER, TRACK_RIGHT, // First additional track for directions 0..3
124 TRACK_X, TRACK_Y, TRACK_X, TRACK_Y, // Second additional track
125 TRACK_LOWER, TRACK_LEFT, TRACK_RIGHT, TRACK_LOWER, // Third additional track
126 };
127
129 static const DiagDirection _place_depot_extra_dir[12] = {
130 DIAGDIR_SE, DIAGDIR_SW, DIAGDIR_SE, DIAGDIR_SW,
131 DIAGDIR_SW, DIAGDIR_NW, DIAGDIR_NE, DIAGDIR_SE,
132 DIAGDIR_NW, DIAGDIR_NE, DIAGDIR_NW, DIAGDIR_NE,
133 };
134
135 void CcRailDepot(const CommandCost &result, TileIndex tile, uint32 p1, uint32 p2, uint32 cmd)
136 {
137 if (result.Failed()) return;
138
139 DiagDirection dir = (DiagDirection)p2;
140
141 if (_settings_client.sound.confirm) SndPlayTileFx(SND_20_CONSTRUCTION_RAIL, tile);
142 if (!_settings_client.gui.persistent_buildingtools) ResetObjectToPlace();
143
144 tile += TileOffsByDiagDir(dir);
145
146 if (IsTileType(tile, MP_RAILWAY)) {
147 PlaceExtraDepotRail(tile, _place_depot_extra_dir[dir], _place_depot_extra_track[dir]);
148 PlaceExtraDepotRail(tile, _place_depot_extra_dir[dir + 4], _place_depot_extra_track[dir + 4]);
149 PlaceExtraDepotRail(tile, _place_depot_extra_dir[dir + 8], _place_depot_extra_track[dir + 8]);
150 }
151 }
152
157 static void PlaceRail_Waypoint(TileIndex tile)
158 {
159 if (_remove_button_clicked) {
160 VpStartPlaceSizing(tile, VPM_X_AND_Y, DDSP_REMOVE_STATION);
161 return;
162 }
163
164 Axis axis = GetAxisForNewWaypoint(tile);
165 if (IsValidAxis(axis)) {
166 /* Valid tile for waypoints */
167 VpStartPlaceSizing(tile, axis == AXIS_X ? VPM_X_LIMITED : VPM_Y_LIMITED, DDSP_BUILD_STATION);
168 VpSetPlaceSizingLimit(_settings_game.station.station_spread);
169 } else {
170 /* Tile where we can't build rail waypoints. This is always going to fail,
171 * but provides the user with a proper error message. */
172 DoCommandP(tile, 1 << 8 | 1 << 16, STAT_CLASS_WAYP | INVALID_STATION << 16, CMD_BUILD_RAIL_WAYPOINT | CMD_MSG(STR_ERROR_CAN_T_BUILD_TRAIN_WAYPOINT));
173 }
174 }
175
176 void CcStation(const CommandCost &result, TileIndex tile, uint32 p1, uint32 p2, uint32 cmd)
177 {
178 if (result.Failed()) return;
179
180 if (_settings_client.sound.confirm) SndPlayTileFx(SND_20_CONSTRUCTION_RAIL, tile);
181 /* Only close the station builder window if the default station and non persistent building is chosen. */
182 if (_railstation.station_class == STAT_CLASS_DFLT && _railstation.station_type == 0 && !_settings_client.gui.persistent_buildingtools) ResetObjectToPlace();
183 }
184
189 static void PlaceRail_Station(TileIndex tile)
190 {
191 if (_remove_button_clicked) {
192 VpStartPlaceSizing(tile, VPM_X_AND_Y_LIMITED, DDSP_REMOVE_STATION);
193 VpSetPlaceSizingLimit(-1);
194 } else if (_settings_client.gui.station_dragdrop) {
195 VpStartPlaceSizing(tile, VPM_X_AND_Y_LIMITED, DDSP_BUILD_STATION);
196 VpSetPlaceSizingLimit(_settings_game.station.station_spread);
197 } else {
198 uint32 p1 = _cur_railtype | _railstation.orientation << 6 | _settings_client.gui.station_numtracks << 8 | _settings_client.gui.station_platlength << 16 | _ctrl_pressed << 24;
199 uint32 p2 = _railstation.station_class | _railstation.station_type << 8 | INVALID_STATION << 16;
200
201 int w = _settings_client.gui.station_numtracks;
202 int h = _settings_client.gui.station_platlength;
203 if (!_railstation.orientation) Swap(w, h);
204
205 CommandContainer cmdcont = { tile, p1, p2, CMD_BUILD_RAIL_STATION | CMD_MSG(STR_ERROR_CAN_T_BUILD_RAILROAD_STATION), CcStation, "" };
206 ShowSelectStationIfNeeded(cmdcont, TileArea(tile, w, h));
207 }
208 }
209
215 static void GenericPlaceSignals(TileIndex tile)
216 {
217 TrackBits trackbits = TrackStatusToTrackBits(GetTileTrackStatus(tile, TRANSPORT_RAIL, 0));
218
219 if (trackbits & TRACK_BIT_VERT) { // N-S direction
220 trackbits = (_tile_fract_coords.x <= _tile_fract_coords.y) ? TRACK_BIT_RIGHT : TRACK_BIT_LEFT;
221 }
222
223 if (trackbits & TRACK_BIT_HORZ) { // E-W direction
224 trackbits = (_tile_fract_coords.x + _tile_fract_coords.y <= 15) ? TRACK_BIT_UPPER : TRACK_BIT_LOWER;
225 }
226
227 Track track = FindFirstTrack(trackbits);
228
229 if (_remove_button_clicked) {
230 DoCommandP(tile, track, 0, CMD_REMOVE_SIGNALS | CMD_MSG(STR_ERROR_CAN_T_REMOVE_SIGNALS_FROM), CcPlaySound_CONSTRUCTION_RAIL);
231 } else {
232 const Window *w = FindWindowById(WC_BUILD_SIGNAL, 0);
233
234 /* Map the setting cycle_signal_types to the lower and upper allowed signal type. */
235 static const uint cycle_bounds[] = {SIGTYPE_NORMAL | (SIGTYPE_LAST_NOPBS << 3), SIGTYPE_PBS | (SIGTYPE_LAST << 3), SIGTYPE_NORMAL | (SIGTYPE_LAST << 3)};
236
237 /* various bitstuffed elements for CmdBuildSingleSignal() */
238 uint32 p1 = track;
239
240 if (w != nullptr) {
241 /* signal GUI is used */
242 SB(p1, 3, 1, _ctrl_pressed);
243 SB(p1, 4, 1, _cur_signal_variant);
244 SB(p1, 5, 3, _cur_signal_type);
245 SB(p1, 8, 1, _convert_signal_button);
246 SB(p1, 9, 6, cycle_bounds[_settings_client.gui.cycle_signal_types]);
247 } else {
248 SB(p1, 3, 1, _ctrl_pressed);
249 SB(p1, 4, 1, (_cur_year < _settings_client.gui.semaphore_build_before ? SIG_SEMAPHORE : SIG_ELECTRIC));
250 SB(p1, 5, 3, _default_signal_type[_settings_client.gui.default_signal_type]);
251 SB(p1, 8, 1, 0);
252 SB(p1, 9, 6, cycle_bounds[_settings_client.gui.cycle_signal_types]);
253 }
254
255 DoCommandP(tile, p1, 0, CMD_BUILD_SIGNALS |
256 CMD_MSG((w != nullptr && _convert_signal_button) ? STR_ERROR_SIGNAL_CAN_T_CONVERT_SIGNALS_HERE : STR_ERROR_CAN_T_BUILD_SIGNALS_HERE),
257 CcPlaySound_CONSTRUCTION_RAIL);
258 }
259 }
260
266 static void PlaceRail_Bridge(TileIndex tile, Window *w)
267 {
268 if (IsBridgeTile(tile)) {
269 TileIndex other_tile = GetOtherTunnelBridgeEnd(tile);
270 Point pt = {0, 0};
271 w->OnPlaceMouseUp(VPM_X_OR_Y, DDSP_BUILD_BRIDGE, pt, other_tile, tile);
272 } else {
273 VpStartPlaceSizing(tile, VPM_X_OR_Y, DDSP_BUILD_BRIDGE);
274 }
275 }
276
278 void CcBuildRailTunnel(const CommandCost &result, TileIndex tile, uint32 p1, uint32 p2, uint32 cmd)
279 {
280 if (result.Succeeded()) {
281 if (_settings_client.sound.confirm) SndPlayTileFx(SND_20_CONSTRUCTION_RAIL, tile);
282 if (!_settings_client.gui.persistent_buildingtools) ResetObjectToPlace();
283 } else {
284 SetRedErrorSquare(_build_tunnel_endtile);
285 }
286 }
287
292 static void ToggleRailButton_Remove(Window *w)
293 {
294 DeleteWindowById(WC_SELECT_STATION, 0);
295 w->ToggleWidgetLoweredState(WID_RAT_REMOVE);
296 w->SetWidgetDirty(WID_RAT_REMOVE);
297 _remove_button_clicked = w->IsWidgetLowered(WID_RAT_REMOVE);
298 SetSelectionRed(_remove_button_clicked);
299 }
300
306 static bool RailToolbar_CtrlChanged(Window *w)
307 {
308 if (w->IsWidgetDisabled(WID_RAT_REMOVE)) return false;
309
310 /* allow ctrl to switch remove mode only for these widgets */
311 for (uint i = WID_RAT_BUILD_NS; i <= WID_RAT_BUILD_STATION; i++) {
312 if ((i <= WID_RAT_AUTORAIL || i >= WID_RAT_BUILD_WAYPOINT) && w->IsWidgetLowered(i)) {
313 ToggleRailButton_Remove(w);
314 return true;
315 }
316 }
317
318 return false;
319 }
320
321
327 static void BuildRailClick_Remove(Window *w)
328 {
329 if (w->IsWidgetDisabled(WID_RAT_REMOVE)) return;
330 ToggleRailButton_Remove(w);
331 if (_settings_client.sound.click_beep) SndPlayFx(SND_15_BEEP);
332
333 /* handle station builder */
334 if (w->IsWidgetLowered(WID_RAT_BUILD_STATION)) {
335 if (_remove_button_clicked) {
336 /* starting drag & drop remove */
337 if (!_settings_client.gui.station_dragdrop) {
338 SetTileSelectSize(1, 1);
339 } else {
340 VpSetPlaceSizingLimit(-1);
341 }
342 } else {
343 /* starting station build mode */
344 if (!_settings_client.gui.station_dragdrop) {
345 int x = _settings_client.gui.station_numtracks;
346 int y = _settings_client.gui.station_platlength;
347 if (_railstation.orientation == 0) Swap(x, y);
348 SetTileSelectSize(x, y);
349 } else {
350 VpSetPlaceSizingLimit(_settings_game.station.station_spread);
351 }
352 }
353 }
354 }
355
356 static void DoRailroadTrack(int mode)
357 {
358 uint32 p2 = _cur_railtype | (mode << 6) | (_settings_client.gui.auto_remove_signals << 11);
359 DoCommandP(TileVirtXY(_thd.selstart.x, _thd.selstart.y), TileVirtXY(_thd.selend.x, _thd.selend.y), p2,
360 _remove_button_clicked ?
361 CMD_REMOVE_RAILROAD_TRACK | CMD_MSG(STR_ERROR_CAN_T_REMOVE_RAILROAD_TRACK) :
362 CMD_BUILD_RAILROAD_TRACK | CMD_MSG(STR_ERROR_CAN_T_BUILD_RAILROAD_TRACK),
363 CcPlaySound_CONSTRUCTION_RAIL);
364 }
365
366 static void HandleAutodirPlacement()
367 {
368 int trackstat = _thd.drawstyle & HT_DIR_MASK; // 0..5
369
370 if (_thd.drawstyle & HT_RAIL) { // one tile case
371 GenericPlaceRail(TileVirtXY(_thd.selend.x, _thd.selend.y), trackstat);
372 return;
373 }
374
375 DoRailroadTrack(trackstat);
376 }
377
384 static void HandleAutoSignalPlacement()
385 {
386 uint32 p2 = GB(_thd.drawstyle, 0, 3); // 0..5
387
388 if ((_thd.drawstyle & HT_DRAG_MASK) == HT_RECT) { // one tile case
389 GenericPlaceSignals(TileVirtXY(_thd.selend.x, _thd.selend.y));
390 return;
391 }
392
393 const Window *w = FindWindowById(WC_BUILD_SIGNAL, 0);
394
395 if (w != nullptr) {
396 /* signal GUI is used */
397 SB(p2, 3, 1, 0);
398 SB(p2, 4, 1, _cur_signal_variant);
399 SB(p2, 6, 1, _ctrl_pressed);
400 SB(p2, 7, 3, _cur_signal_type);
401 SB(p2, 24, 8, _settings_client.gui.drag_signals_density);
402 SB(p2, 10, 1, !_settings_client.gui.drag_signals_fixed_distance);
403 } else {
404 SB(p2, 3, 1, 0);
405 SB(p2, 4, 1, (_cur_year < _settings_client.gui.semaphore_build_before ? SIG_SEMAPHORE : SIG_ELECTRIC));
406 SB(p2, 6, 1, _ctrl_pressed);
407 SB(p2, 7, 3, _default_signal_type[_settings_client.gui.default_signal_type]);
408 SB(p2, 24, 8, _settings_client.gui.drag_signals_density);
409 SB(p2, 10, 1, !_settings_client.gui.drag_signals_fixed_distance);
410 }
411
412 /* _settings_client.gui.drag_signals_density is given as a parameter such that each user
413 * in a network game can specify his/her own signal density */
414 DoCommandP(TileVirtXY(_thd.selstart.x, _thd.selstart.y), TileVirtXY(_thd.selend.x, _thd.selend.y), p2,
415 _remove_button_clicked ?
416 CMD_REMOVE_SIGNAL_TRACK | CMD_MSG(STR_ERROR_CAN_T_REMOVE_SIGNALS_FROM) :
417 CMD_BUILD_SIGNAL_TRACK | CMD_MSG(STR_ERROR_CAN_T_BUILD_SIGNALS_HERE),
418 CcPlaySound_CONSTRUCTION_RAIL);
419 }
420
421
423 struct BuildRailToolbarWindow : Window {
424 RailType railtype;
425 int last_user_action;
426
427 BuildRailToolbarWindow(WindowDesc *desc, RailType railtype) : Window(desc)
428 {
429 this->InitNested(TRANSPORT_RAIL);
430 this->SetupRailToolbar(railtype);
431 this->DisableWidget(WID_RAT_REMOVE);
432 this->last_user_action = WIDGET_LIST_END;
433
434 if (_settings_client.gui.link_terraform_toolbar) ShowTerraformToolbar(this);
435 }
436
437 ~BuildRailToolbarWindow()
438 {
439 if (this->IsWidgetLowered(WID_RAT_BUILD_STATION)) SetViewportCatchmentStation(nullptr, true);
440 if (_settings_client.gui.link_terraform_toolbar) DeleteWindowById(WC_SCEN_LAND_GEN, 0, false);
441 }
442
447 void SetupRailToolbar(RailType railtype)
448 {
449 this->railtype = railtype;
450 const RailtypeInfo *rti = GetRailTypeInfo(railtype);
451
452 assert(railtype < RAILTYPE_END);
453 this->GetWidget<NWidgetCore>(WID_RAT_BUILD_NS)->widget_data = rti->gui_sprites.build_ns_rail;
454 this->GetWidget<NWidgetCore>(WID_RAT_BUILD_X)->widget_data = rti->gui_sprites.build_x_rail;
455 this->GetWidget<NWidgetCore>(WID_RAT_BUILD_EW)->widget_data = rti->gui_sprites.build_ew_rail;
456 this->GetWidget<NWidgetCore>(WID_RAT_BUILD_Y)->widget_data = rti->gui_sprites.build_y_rail;
457 this->GetWidget<NWidgetCore>(WID_RAT_AUTORAIL)->widget_data = rti->gui_sprites.auto_rail;
458 this->GetWidget<NWidgetCore>(WID_RAT_BUILD_DEPOT)->widget_data = rti->gui_sprites.build_depot;
459 this->GetWidget<NWidgetCore>(WID_RAT_CONVERT_RAIL)->widget_data = rti->gui_sprites.convert_rail;
460 this->GetWidget<NWidgetCore>(WID_RAT_BUILD_TUNNEL)->widget_data = rti->gui_sprites.build_tunnel;
461 }
462
467 void ModifyRailType(RailType railtype)
468 {
469 this->SetupRailToolbar(railtype);
470 this->ReInit();
471 }
472
473 void UpdateRemoveWidgetStatus(int clicked_widget)
474 {
475 switch (clicked_widget) {
476 case WID_RAT_REMOVE:
477 /* If it is the removal button that has been clicked, do nothing,
478 * as it is up to the other buttons to drive removal status */
479 return;
480
481 case WID_RAT_BUILD_NS:
482 case WID_RAT_BUILD_X:
483 case WID_RAT_BUILD_EW:
484 case WID_RAT_BUILD_Y:
485 case WID_RAT_AUTORAIL:
486 case WID_RAT_BUILD_WAYPOINT:
487 case WID_RAT_BUILD_STATION:
488 case WID_RAT_BUILD_SIGNALS:
489 /* Removal button is enabled only if the rail/signal/waypoint/station
490 * button is still lowered. Once raised, it has to be disabled */
491 this->SetWidgetDisabledState(WID_RAT_REMOVE, !this->IsWidgetLowered(clicked_widget));
492 break;
493
494 default:
495 /* When any other buttons than rail/signal/waypoint/station, raise and
496 * disable the removal button */
497 this->DisableWidget(WID_RAT_REMOVE);
498 this->RaiseWidget(WID_RAT_REMOVE);
499 break;
500 }
501 }
502
503 void SetStringParameters(int widget) const override
504 {
505 if (widget == WID_RAT_CAPTION) {
506 const RailtypeInfo *rti = GetRailTypeInfo(this->railtype);
507 if (rti->max_speed > 0) {
508 SetDParam(0, STR_TOOLBAR_RAILTYPE_VELOCITY);
509 SetDParam(1, rti->strings.toolbar_caption);
510 SetDParam(2, rti->max_speed);
511 } else {
512 SetDParam(0, rti->strings.toolbar_caption);
513 }
514 }
515 }
516
517 void OnClick(Point pt, int widget, int click_count) override
518 {
519 if (widget < WID_RAT_BUILD_NS) return;
520
521 _remove_button_clicked = false;
522 switch (widget) {
523 case WID_RAT_BUILD_NS:
524 HandlePlacePushButton(this, WID_RAT_BUILD_NS, GetRailTypeInfo(_cur_railtype)->cursor.rail_ns, HT_LINE | HT_DIR_VL);
525 this->last_user_action = widget;
526 break;
527
528 case WID_RAT_BUILD_X:
529 HandlePlacePushButton(this, WID_RAT_BUILD_X, GetRailTypeInfo(_cur_railtype)->cursor.rail_swne, HT_LINE | HT_DIR_X);
530 this->last_user_action = widget;
531 break;
532
533 case WID_RAT_BUILD_EW:
534 HandlePlacePushButton(this, WID_RAT_BUILD_EW, GetRailTypeInfo(_cur_railtype)->cursor.rail_ew, HT_LINE | HT_DIR_HL);
535 this->last_user_action = widget;
536 break;
537
538 case WID_RAT_BUILD_Y:
539 HandlePlacePushButton(this, WID_RAT_BUILD_Y, GetRailTypeInfo(_cur_railtype)->cursor.rail_nwse, HT_LINE | HT_DIR_Y);
540 this->last_user_action = widget;
541 break;
542
543 case WID_RAT_AUTORAIL:
544 HandlePlacePushButton(this, WID_RAT_AUTORAIL, GetRailTypeInfo(_cur_railtype)->cursor.autorail, HT_RAIL);
545 this->last_user_action = widget;
546 break;
547
548 case WID_RAT_DEMOLISH:
549 HandlePlacePushButton(this, WID_RAT_DEMOLISH, ANIMCURSOR_DEMOLISH, HT_RECT | HT_DIAGONAL);
550 this->last_user_action = widget;
551 break;
552
553 case WID_RAT_BUILD_DEPOT:
554 if (HandlePlacePushButton(this, WID_RAT_BUILD_DEPOT, GetRailTypeInfo(_cur_railtype)->cursor.depot, HT_RECT)) {
555 ShowBuildTrainDepotPicker(this);
556 this->last_user_action = widget;
557 }
558 break;
559
560 case WID_RAT_BUILD_WAYPOINT:
561 this->last_user_action = widget;
562 _waypoint_count = StationClass::Get(STAT_CLASS_WAYP)->GetSpecCount();
563 if (HandlePlacePushButton(this, WID_RAT_BUILD_WAYPOINT, SPR_CURSOR_WAYPOINT, HT_RECT) && _waypoint_count > 1) {
564 ShowBuildWaypointPicker(this);
565 }
566 break;
567
568 case WID_RAT_BUILD_STATION:
569 if (HandlePlacePushButton(this, WID_RAT_BUILD_STATION, SPR_CURSOR_RAIL_STATION, HT_RECT)) {
570 ShowStationBuilder(this);
571 this->last_user_action = widget;
572 }
573 break;
574
575 case WID_RAT_BUILD_SIGNALS: {
576 this->last_user_action = widget;
577 bool started = HandlePlacePushButton(this, WID_RAT_BUILD_SIGNALS, ANIMCURSOR_BUILDSIGNALS, HT_RECT);
578 if (started && _settings_client.gui.enable_signal_gui != _ctrl_pressed) {
579 ShowSignalBuilder(this);
580 }
581 break;
582 }
583
584 case WID_RAT_BUILD_BRIDGE:
585 HandlePlacePushButton(this, WID_RAT_BUILD_BRIDGE, SPR_CURSOR_BRIDGE, HT_RECT);
586 this->last_user_action = widget;
587 break;
588
589 case WID_RAT_BUILD_TUNNEL:
590 HandlePlacePushButton(this, WID_RAT_BUILD_TUNNEL, GetRailTypeInfo(_cur_railtype)->cursor.tunnel, HT_SPECIAL);
591 this->last_user_action = widget;
592 break;
593
594 case WID_RAT_REMOVE:
595 BuildRailClick_Remove(this);
596 break;
597
598 case WID_RAT_CONVERT_RAIL:
599 HandlePlacePushButton(this, WID_RAT_CONVERT_RAIL, GetRailTypeInfo(_cur_railtype)->cursor.convert, HT_RECT | HT_DIAGONAL);
600 this->last_user_action = widget;
601 break;
602
603 default: NOT_REACHED();
604 }
605 this->UpdateRemoveWidgetStatus(widget);
606 if (_ctrl_pressed) RailToolbar_CtrlChanged(this);
607 }
608
609 EventState OnHotkey(int hotkey) override
610 {
611 MarkTileDirtyByTile(TileVirtXY(_thd.pos.x, _thd.pos.y)); // redraw tile selection
612 return Window::OnHotkey(hotkey);
613 }
614
615 void OnPlaceObject(Point pt, TileIndex tile) override
616 {
617 switch (this->last_user_action) {
618 case WID_RAT_BUILD_NS:
619 VpStartPlaceSizing(tile, VPM_FIX_VERTICAL | VPM_RAILDIRS, DDSP_PLACE_RAIL);
620 break;
621
622 case WID_RAT_BUILD_X:
623 VpStartPlaceSizing(tile, VPM_FIX_Y | VPM_RAILDIRS, DDSP_PLACE_RAIL);
624 break;
625
626 case WID_RAT_BUILD_EW:
627 VpStartPlaceSizing(tile, VPM_FIX_HORIZONTAL | VPM_RAILDIRS, DDSP_PLACE_RAIL);
628 break;
629
630 case WID_RAT_BUILD_Y:
631 VpStartPlaceSizing(tile, VPM_FIX_X | VPM_RAILDIRS, DDSP_PLACE_RAIL);
632 break;
633
634 case WID_RAT_AUTORAIL:
635 VpStartPlaceSizing(tile, VPM_RAILDIRS, DDSP_PLACE_RAIL);
636 break;
637
638 case WID_RAT_DEMOLISH:
639 PlaceProc_DemolishArea(tile);
640 break;
641
642 case WID_RAT_BUILD_DEPOT:
643 DoCommandP(tile, _cur_railtype, _build_depot_direction,
644 CMD_BUILD_TRAIN_DEPOT | CMD_MSG(STR_ERROR_CAN_T_BUILD_TRAIN_DEPOT),
645 CcRailDepot);
646 break;
647
648 case WID_RAT_BUILD_WAYPOINT:
649 PlaceRail_Waypoint(tile);
650 break;
651
652 case WID_RAT_BUILD_STATION:
653 PlaceRail_Station(tile);
654 break;
655
656 case WID_RAT_BUILD_SIGNALS:
657 VpStartPlaceSizing(tile, VPM_SIGNALDIRS, DDSP_BUILD_SIGNALS);
658 break;
659
660 case WID_RAT_BUILD_BRIDGE:
661 PlaceRail_Bridge(tile, this);
662 break;
663
664 case WID_RAT_BUILD_TUNNEL:
665 DoCommandP(tile, _cur_railtype | (TRANSPORT_RAIL << 8), 0, CMD_BUILD_TUNNEL | CMD_MSG(STR_ERROR_CAN_T_BUILD_TUNNEL_HERE), CcBuildRailTunnel);
666 break;
667
668 case WID_RAT_CONVERT_RAIL:
669 VpStartPlaceSizing(tile, VPM_X_AND_Y, DDSP_CONVERT_RAIL);
670 break;
671
672 default: NOT_REACHED();
673 }
674 }
675
676 void OnPlaceDrag(ViewportPlaceMethod select_method, ViewportDragDropSelectionProcess select_proc, Point pt) override
677 {
678 /* no dragging if you have pressed the convert button */
679 if (FindWindowById(WC_BUILD_SIGNAL, 0) != nullptr && _convert_signal_button && this->IsWidgetLowered(WID_RAT_BUILD_SIGNALS)) return;
680
681 VpSelectTilesWithMethod(pt.x, pt.y, select_method);
682 }
683
684 void OnPlaceMouseUp(ViewportPlaceMethod select_method, ViewportDragDropSelectionProcess select_proc, Point pt, TileIndex start_tile, TileIndex end_tile) override
685 {
686 if (pt.x != -1) {
687 switch (select_proc) {
688 default: NOT_REACHED();
689 case DDSP_BUILD_BRIDGE:
690 if (!_settings_client.gui.persistent_buildingtools) ResetObjectToPlace();
691 ShowBuildBridgeWindow(start_tile, end_tile, TRANSPORT_RAIL, _cur_railtype);
692 break;
693
694 case DDSP_PLACE_RAIL:
695 HandleAutodirPlacement();
696 break;
697
698 case DDSP_BUILD_SIGNALS:
699 HandleAutoSignalPlacement();
700 break;
701
702 case DDSP_DEMOLISH_AREA:
703 GUIPlaceProcDragXY(select_proc, start_tile, end_tile);
704 break;
705
706 case DDSP_CONVERT_RAIL:
707 DoCommandP(end_tile, start_tile, _cur_railtype | (_ctrl_pressed ? 1 << 6 : 0), CMD_CONVERT_RAIL | CMD_MSG(STR_ERROR_CAN_T_CONVERT_RAIL), CcPlaySound_CONSTRUCTION_RAIL);
708 break;
709
710 case DDSP_REMOVE_STATION:
711 case DDSP_BUILD_STATION:
712 if (this->IsWidgetLowered(WID_RAT_BUILD_STATION)) {
713 /* Station */
714 if (_remove_button_clicked) {
715 DoCommandP(end_tile, start_tile, _ctrl_pressed ? 0 : 1, CMD_REMOVE_FROM_RAIL_STATION | CMD_MSG(STR_ERROR_CAN_T_REMOVE_PART_OF_STATION), CcPlaySound_CONSTRUCTION_RAIL);
716 } else {
717 HandleStationPlacement(start_tile, end_tile);
718 }
719 } else {
720 /* Waypoint */
721 if (_remove_button_clicked) {
722 DoCommandP(end_tile, start_tile, _ctrl_pressed ? 0 : 1, CMD_REMOVE_FROM_RAIL_WAYPOINT | CMD_MSG(STR_ERROR_CAN_T_REMOVE_TRAIN_WAYPOINT), CcPlaySound_CONSTRUCTION_RAIL);
723 } else {
724 TileArea ta(start_tile, end_tile);
725 uint32 p1 = _cur_railtype | (select_method == VPM_X_LIMITED ? AXIS_X : AXIS_Y) << 6 | ta.w << 8 | ta.h << 16 | _ctrl_pressed << 24;
726 uint32 p2 = STAT_CLASS_WAYP | _cur_waypoint_type << 8 | INVALID_STATION << 16;
727
728 CommandContainer cmdcont = { ta.tile, p1, p2, CMD_BUILD_RAIL_WAYPOINT | CMD_MSG(STR_ERROR_CAN_T_BUILD_TRAIN_WAYPOINT), CcPlaySound_CONSTRUCTION_RAIL, "" };
729 ShowSelectWaypointIfNeeded(cmdcont, ta);
730 }
731 }
732 break;
733 }
734 }
735 }
736
737 void OnPlaceObjectAbort() override
738 {
739 if (this->IsWidgetLowered(WID_RAT_BUILD_STATION)) SetViewportCatchmentStation(nullptr, true);
740
741 this->RaiseButtons();
742 this->DisableWidget(WID_RAT_REMOVE);
743 this->SetWidgetDirty(WID_RAT_REMOVE);
744
745 DeleteWindowById(WC_BUILD_SIGNAL, TRANSPORT_RAIL);
746 DeleteWindowById(WC_BUILD_STATION, TRANSPORT_RAIL);
747 DeleteWindowById(WC_BUILD_DEPOT, TRANSPORT_RAIL);
748 DeleteWindowById(WC_BUILD_WAYPOINT, TRANSPORT_RAIL);
749 DeleteWindowById(WC_SELECT_STATION, 0);
750 DeleteWindowByClass(WC_BUILD_BRIDGE);
751 }
752
753 void OnPlacePresize(Point pt, TileIndex tile) override
754 {
755 DoCommand(tile, _cur_railtype | (TRANSPORT_RAIL << 8), 0, DC_AUTO, CMD_BUILD_TUNNEL);
756 VpSetPresizeRange(tile, _build_tunnel_endtile == 0 ? tile : _build_tunnel_endtile);
757 }
758
759 EventState OnCTRLStateChange() override
760 {
761 /* do not toggle Remove button by Ctrl when placing station */
762 if (!this->IsWidgetLowered(WID_RAT_BUILD_STATION) && !this->IsWidgetLowered(WID_RAT_BUILD_WAYPOINT) && RailToolbar_CtrlChanged(this)) return ES_HANDLED;
763 return ES_NOT_HANDLED;
764 }
765
766 static HotkeyList hotkeys;
767 };
768
774 static EventState RailToolbarGlobalHotkeys(int hotkey)
775 {
776 if (_game_mode != GM_NORMAL) return ES_NOT_HANDLED;
777 extern RailType _last_built_railtype;
778 Window *w = ShowBuildRailToolbar(_last_built_railtype);
779 if (w == nullptr) return ES_NOT_HANDLED;
780 return w->OnHotkey(hotkey);
781 }
782
783 const uint16 _railtoolbar_autorail_keys[] = {'5', 'A' | WKC_GLOBAL_HOTKEY, 0};
784
785 static Hotkey railtoolbar_hotkeys[] = {
786 Hotkey('1', "build_ns", WID_RAT_BUILD_NS),
787 Hotkey('2', "build_x", WID_RAT_BUILD_X),
788 Hotkey('3', "build_ew", WID_RAT_BUILD_EW),
789 Hotkey('4', "build_y", WID_RAT_BUILD_Y),
790 Hotkey(_railtoolbar_autorail_keys, "autorail", WID_RAT_AUTORAIL),
791 Hotkey('6', "demolish", WID_RAT_DEMOLISH),
792 Hotkey('7', "depot", WID_RAT_BUILD_DEPOT),
793 Hotkey('8', "waypoint", WID_RAT_BUILD_WAYPOINT),
794 Hotkey('9', "station", WID_RAT_BUILD_STATION),
795 Hotkey('S', "signal", WID_RAT_BUILD_SIGNALS),
796 Hotkey('B', "bridge", WID_RAT_BUILD_BRIDGE),
797 Hotkey('T', "tunnel", WID_RAT_BUILD_TUNNEL),
798 Hotkey('R', "remove", WID_RAT_REMOVE),
799 Hotkey('C', "convert", WID_RAT_CONVERT_RAIL),
800 HOTKEY_LIST_END
801 };
802 HotkeyList BuildRailToolbarWindow::hotkeys("railtoolbar", railtoolbar_hotkeys, RailToolbarGlobalHotkeys);
803
804 static const NWidgetPart _nested_build_rail_widgets[] = {
805 NWidget(NWID_HORIZONTAL),
806 NWidget(WWT_CLOSEBOX, COLOUR_DARK_GREEN),
807 NWidget(WWT_CAPTION, COLOUR_DARK_GREEN, WID_RAT_CAPTION), SetDataTip(STR_WHITE_STRING, STR_TOOLTIP_WINDOW_TITLE_DRAG_THIS),
808 NWidget(WWT_STICKYBOX, COLOUR_DARK_GREEN),
809 EndContainer(),
810 NWidget(NWID_HORIZONTAL),
811 NWidget(WWT_IMGBTN, COLOUR_DARK_GREEN, WID_RAT_BUILD_NS),
812 SetFill(0, 1), SetMinimalSize(22, 22), SetDataTip(SPR_IMG_RAIL_NS, STR_RAIL_TOOLBAR_TOOLTIP_BUILD_RAILROAD_TRACK),
813 NWidget(WWT_IMGBTN, COLOUR_DARK_GREEN, WID_RAT_BUILD_X),
814 SetFill(0, 1), SetMinimalSize(22, 22), SetDataTip(SPR_IMG_RAIL_NE, STR_RAIL_TOOLBAR_TOOLTIP_BUILD_RAILROAD_TRACK),
815 NWidget(WWT_IMGBTN, COLOUR_DARK_GREEN, WID_RAT_BUILD_EW),
816 SetFill(0, 1), SetMinimalSize(22, 22), SetDataTip(SPR_IMG_RAIL_EW, STR_RAIL_TOOLBAR_TOOLTIP_BUILD_RAILROAD_TRACK),
817 NWidget(WWT_IMGBTN, COLOUR_DARK_GREEN, WID_RAT_BUILD_Y),
818 SetFill(0, 1), SetMinimalSize(22, 22), SetDataTip(SPR_IMG_RAIL_NW, STR_RAIL_TOOLBAR_TOOLTIP_BUILD_RAILROAD_TRACK),
819 NWidget(WWT_IMGBTN, COLOUR_DARK_GREEN, WID_RAT_AUTORAIL),
820 SetFill(0, 1), SetMinimalSize(22, 22), SetDataTip(SPR_IMG_AUTORAIL, STR_RAIL_TOOLBAR_TOOLTIP_BUILD_AUTORAIL),
821
822 NWidget(WWT_PANEL, COLOUR_DARK_GREEN), SetMinimalSize(4, 22), SetDataTip(0x0, STR_NULL), EndContainer(),
823
824 NWidget(WWT_IMGBTN, COLOUR_DARK_GREEN, WID_RAT_DEMOLISH),
825 SetFill(0, 1), SetMinimalSize(22, 22), SetDataTip(SPR_IMG_DYNAMITE, STR_TOOLTIP_DEMOLISH_BUILDINGS_ETC),
826 NWidget(WWT_IMGBTN, COLOUR_DARK_GREEN, WID_RAT_BUILD_DEPOT),
827 SetFill(0, 1), SetMinimalSize(22, 22), SetDataTip(SPR_IMG_DEPOT_RAIL, STR_RAIL_TOOLBAR_TOOLTIP_BUILD_TRAIN_DEPOT_FOR_BUILDING),
828 NWidget(WWT_IMGBTN, COLOUR_DARK_GREEN, WID_RAT_BUILD_WAYPOINT),
829 SetFill(0, 1), SetMinimalSize(22, 22), SetDataTip(SPR_IMG_WAYPOINT, STR_RAIL_TOOLBAR_TOOLTIP_CONVERT_RAIL_TO_WAYPOINT),
830 NWidget(WWT_IMGBTN, COLOUR_DARK_GREEN, WID_RAT_BUILD_STATION),
831 SetFill(0, 1), SetMinimalSize(42, 22), SetDataTip(SPR_IMG_RAIL_STATION, STR_RAIL_TOOLBAR_TOOLTIP_BUILD_RAILROAD_STATION),
832 NWidget(WWT_IMGBTN, COLOUR_DARK_GREEN, WID_RAT_BUILD_SIGNALS),
833 SetFill(0, 1), SetMinimalSize(22, 22), SetDataTip(SPR_IMG_RAIL_SIGNALS, STR_RAIL_TOOLBAR_TOOLTIP_BUILD_RAILROAD_SIGNALS),
834 NWidget(WWT_IMGBTN, COLOUR_DARK_GREEN, WID_RAT_BUILD_BRIDGE),
835 SetFill(0, 1), SetMinimalSize(42, 22), SetDataTip(SPR_IMG_BRIDGE, STR_RAIL_TOOLBAR_TOOLTIP_BUILD_RAILROAD_BRIDGE),
836 NWidget(WWT_IMGBTN, COLOUR_DARK_GREEN, WID_RAT_BUILD_TUNNEL),
837 SetFill(0, 1), SetMinimalSize(20, 22), SetDataTip(SPR_IMG_TUNNEL_RAIL, STR_RAIL_TOOLBAR_TOOLTIP_BUILD_RAILROAD_TUNNEL),
838 NWidget(WWT_IMGBTN, COLOUR_DARK_GREEN, WID_RAT_REMOVE),
839 SetFill(0, 1), SetMinimalSize(22, 22), SetDataTip(SPR_IMG_REMOVE, STR_RAIL_TOOLBAR_TOOLTIP_TOGGLE_BUILD_REMOVE_FOR),
840 NWidget(WWT_IMGBTN, COLOUR_DARK_GREEN, WID_RAT_CONVERT_RAIL),
841 SetFill(0, 1), SetMinimalSize(22, 22), SetDataTip(SPR_IMG_CONVERT_RAIL, STR_RAIL_TOOLBAR_TOOLTIP_CONVERT_RAIL),
842 EndContainer(),
843 };
844
845 static WindowDesc _build_rail_desc(
846 WDP_ALIGN_TOOLBAR, "toolbar_rail", 0, 0,
847 WC_BUILD_TOOLBAR, WC_NONE,
848 WDF_CONSTRUCTION,
849 _nested_build_rail_widgets, lengthof(_nested_build_rail_widgets),
850 &BuildRailToolbarWindow::hotkeys
851 );
852
853
862 Window *ShowBuildRailToolbar(RailType railtype)
863 {
864 if (!Company::IsValidID(_local_company)) return nullptr;
865 if (!ValParamRailtype(railtype)) return nullptr;
866
867 DeleteWindowByClass(WC_BUILD_TOOLBAR);
868 _cur_railtype = railtype;
869 _remove_button_clicked = false;
870 return new BuildRailToolbarWindow(&_build_rail_desc, railtype);
871 }
872
873 /* TODO: For custom stations, respect their allowed platforms/lengths bitmasks!
874 * --pasky */
875
876 static void HandleStationPlacement(TileIndex start, TileIndex end)
877 {
878 TileArea ta(start, end);
879 uint numtracks = ta.w;
880 uint platlength = ta.h;
881
882 if (_railstation.orientation == AXIS_X) Swap(numtracks, platlength);
883
884 uint32 p1 = _cur_railtype | _railstation.orientation << 6 | numtracks << 8 | platlength << 16 | _ctrl_pressed << 24;
885 uint32 p2 = _railstation.station_class | _railstation.station_type << 8 | INVALID_STATION << 16;
886
887 CommandContainer cmdcont = { ta.tile, p1, p2, CMD_BUILD_RAIL_STATION | CMD_MSG(STR_ERROR_CAN_T_BUILD_RAILROAD_STATION), CcStation, "" };
888 ShowSelectStationIfNeeded(cmdcont, ta);
889 }
890
891 struct BuildRailStationWindow : public PickerWindowBase {
892 private:
893 uint line_height;
894 uint coverage_height;
895 Scrollbar *vscroll;
896 Scrollbar *vscroll2;
897
898 typedef GUIList<StationClassID, StringFilter &> GUIStationClassList;
899
900 static const uint EDITBOX_MAX_SIZE = 16;
901
902 static Listing last_sorting;
903 static Filtering last_filtering;
904 static GUIStationClassList::SortFunction * const sorter_funcs[];
905 static GUIStationClassList::FilterFunction * const filter_funcs[];
906 GUIStationClassList station_classes;
907 StringFilter string_filter;
908 QueryString filter_editbox;
909
917 void EnsureSelectedStationClassIsVisible()
918 {
919 uint pos = 0;
920 for (auto station_class : this->station_classes) {
921 if (station_class == _railstation.station_class) break;
922 pos++;
923 }
924 this->vscroll->SetCount((int)this->station_classes.size());
925 this->vscroll->ScrollTowards(pos);
926 }
927
933 void CheckSelectedSize(const StationSpec *statspec)
934 {
935 if (statspec == nullptr || _settings_client.gui.station_dragdrop) return;
936
937 /* If current number of tracks is not allowed, make it as big as possible */
938 if (HasBit(statspec->disallowed_platforms, _settings_client.gui.station_numtracks - 1)) {
939 this->RaiseWidget(_settings_client.gui.station_numtracks + WID_BRAS_PLATFORM_NUM_BEGIN);
940 _settings_client.gui.station_numtracks = 1;
941 if (statspec->disallowed_platforms != UINT8_MAX) {
942 while (HasBit(statspec->disallowed_platforms, _settings_client.gui.station_numtracks - 1)) {
943 _settings_client.gui.station_numtracks++;
944 }
945 this->LowerWidget(_settings_client.gui.station_numtracks + WID_BRAS_PLATFORM_NUM_BEGIN);
946 }
947 }
948
949 if (HasBit(statspec->disallowed_lengths, _settings_client.gui.station_platlength - 1)) {
950 this->RaiseWidget(_settings_client.gui.station_platlength + WID_BRAS_PLATFORM_LEN_BEGIN);
951 _settings_client.gui.station_platlength = 1;
952 if (statspec->disallowed_lengths != UINT8_MAX) {
953 while (HasBit(statspec->disallowed_lengths, _settings_client.gui.station_platlength - 1)) {
954 _settings_client.gui.station_platlength++;
955 }
956 this->LowerWidget(_settings_client.gui.station_platlength + WID_BRAS_PLATFORM_LEN_BEGIN);
957 }
958 }
959 }
960
961 public:
962 BuildRailStationWindow(WindowDesc *desc, Window *parent, bool newstation) : PickerWindowBase(desc, parent), filter_editbox(EDITBOX_MAX_SIZE)
963 {
964 this->coverage_height = 2 * FONT_HEIGHT_NORMAL + 3 * WD_PAR_VSEP_NORMAL;
965 this->vscroll = nullptr;
966 _railstation.newstations = newstation;
967
968 this->CreateNestedTree();
969 NWidgetStacked *newst_additions = this->GetWidget<NWidgetStacked>(WID_BRAS_SHOW_NEWST_ADDITIONS);
970 newst_additions->SetDisplayedPlane(newstation ? 0 : SZSP_NONE);
971 newst_additions = this->GetWidget<NWidgetStacked>(WID_BRAS_SHOW_NEWST_MATRIX);
972 newst_additions->SetDisplayedPlane(newstation ? 0 : SZSP_NONE);
973 newst_additions = this->GetWidget<NWidgetStacked>(WID_BRAS_SHOW_NEWST_DEFSIZE);
974 newst_additions->SetDisplayedPlane(newstation ? 0 : SZSP_NONE);
975 newst_additions = this->GetWidget<NWidgetStacked>(WID_BRAS_SHOW_NEWST_RESIZE);
976 newst_additions->SetDisplayedPlane(newstation ? 0 : SZSP_NONE);
977 /* Hide the station class filter if no stations other than the default one are available. */
978 this->GetWidget<NWidgetStacked>(WID_BRAS_FILTER_CONTAINER)->SetDisplayedPlane(newstation ? 0 : SZSP_NONE);
979 if (newstation) {
980 this->vscroll = this->GetScrollbar(WID_BRAS_NEWST_SCROLL);
981 this->vscroll2 = this->GetScrollbar(WID_BRAS_MATRIX_SCROLL);
982
983 this->querystrings[WID_BRAS_FILTER_EDITBOX] = &this->filter_editbox;
984 this->station_classes.SetListing(this->last_sorting);
985 this->station_classes.SetFiltering(this->last_filtering);
986 this->station_classes.SetSortFuncs(this->sorter_funcs);
987 this->station_classes.SetFilterFuncs(this->filter_funcs);
988 }
989
990 this->station_classes.ForceRebuild();
991
992 BuildStationClassesAvailable();
993 SelectClassAndStation();
994
995 this->FinishInitNested(TRANSPORT_RAIL);
996
997 this->LowerWidget(_railstation.orientation + WID_BRAS_PLATFORM_DIR_X);
998 if (_settings_client.gui.station_dragdrop) {
999 this->LowerWidget(WID_BRAS_PLATFORM_DRAG_N_DROP);
1000 } else {
1001 this->LowerWidget(_settings_client.gui.station_numtracks + WID_BRAS_PLATFORM_NUM_BEGIN);
1002 this->LowerWidget(_settings_client.gui.station_platlength + WID_BRAS_PLATFORM_LEN_BEGIN);
1003 }
1004 this->SetWidgetLoweredState(WID_BRAS_HIGHLIGHT_OFF, !_settings_client.gui.station_show_coverage);
1005 this->SetWidgetLoweredState(WID_BRAS_HIGHLIGHT_ON, _settings_client.gui.station_show_coverage);
1006
1007 if (!newstation) {
1008 _railstation.station_class = StationClassID::STAT_CLASS_DFLT;
1009 _railstation.station_type = 0;
1010 this->vscroll2 = nullptr;
1011 } else {
1012 _railstation.station_count = StationClass::Get(_railstation.station_class)->GetSpecCount();
1013 _railstation.station_type = std::min<int>(_railstation.station_type, _railstation.station_count - 1);
1014
1015 NWidgetMatrix *matrix = this->GetWidget<NWidgetMatrix>(WID_BRAS_MATRIX);
1016 matrix->SetScrollbar(this->vscroll2);
1017 matrix->SetCount(_railstation.station_count);
1018 matrix->SetClicked(_railstation.station_type);
1019
1020 EnsureSelectedStationClassIsVisible();
1021
1022 this->SetFocusedWidget(WID_BRAS_FILTER_EDITBOX);
1023 }
1024
1025 this->InvalidateData();
1026 }
1027
1028 virtual ~BuildRailStationWindow()
1029 {
1030 DeleteWindowById(WC_SELECT_STATION, 0);
1031 }
1032
1034 static bool StationClassIDSorter(StationClassID const &a, StationClassID const &b)
1035 {
1036 return a < b;
1037 }
1038
1040 static bool CDECL TagNameFilter(StationClassID const * sc, StringFilter &filter)
1041 {
1042 char buffer[DRAW_STRING_BUFFER];
1043 GetString(buffer, StationClass::Get(*sc)->name, lastof(buffer));
1044
1045 filter.ResetState();
1046 filter.AddLine(buffer);
1047 return filter.GetState();
1048 }
1049
1051 void BuildStationClassesAvailable()
1052 {
1053 if (!this->station_classes.NeedRebuild()) return;
1054
1055 this->station_classes.clear();
1056
1057 for (uint i = 0; i < StationClass::GetClassCount(); i++) {
1058 StationClassID station_class_id = (StationClassID)i;
1059 if (station_class_id == StationClassID::STAT_CLASS_WAYP) {
1060 // Skip waypoints.
1061 continue;
1062 }
1063 StationClass *station_class = StationClass::Get(station_class_id);
1064 if (station_class->GetUISpecCount() == 0) continue;
1065 station_classes.push_back(station_class_id);
1066 }
1067
1068 if (_railstation.newstations) {
1069 this->station_classes.Filter(this->string_filter);
1070 this->station_classes.shrink_to_fit();
1071 this->station_classes.RebuildDone();
1072 this->station_classes.Sort();
1073
1074 this->vscroll->SetCount((uint)this->station_classes.size());
1075 }
1076 }
1077
1082 void SelectClassAndStation()
1083 {
1084 if (_railstation.station_class == StationClassID::STAT_CLASS_DFLT) {
1085 /* This happens during the first time the window is open during the game life cycle. */
1086 this->SelectOtherClass(StationClassID::STAT_CLASS_DFLT);
1087 } else {
1088 /* Check if the previously selected station class is not available anymore as a
1089 * result of starting a new game without the corresponding NewGRF. */
1090 bool available = false;
1091 for (uint i = 0; i < StationClass::GetClassCount(); ++i) {
1092 if ((StationClassID)i == _railstation.station_class) {
1093 available = true;
1094 break;
1095 }
1096 }
1097
1098 this->SelectOtherClass(available ? _railstation.station_class : StationClassID::STAT_CLASS_DFLT);
1099 }
1100 }
1101
1106 void SelectOtherClass(StationClassID station_class)
1107 {
1108 _railstation.station_class = station_class;
1109 }
1110
1111 void OnInvalidateData(int data = 0, bool gui_scope = true) override
1112 {
1113 if (!gui_scope) return;
1114
1115 this->BuildStationClassesAvailable();
1116 }
1117
1118 void OnEditboxChanged(int wid) override
1119 {
1120 string_filter.SetFilterTerm(this->filter_editbox.text.buf);
1121 this->station_classes.SetFilterState(!string_filter.IsEmpty());
1122 this->station_classes.ForceRebuild();
1123 this->InvalidateData();
1124 }
1125
1126 void OnPaint() override
1127 {
1128 bool newstations = _railstation.newstations;
1129 const StationSpec *statspec = newstations ? StationClass::Get(_railstation.station_class)->GetSpec(_railstation.station_type) : nullptr;
1130
1131 if (_settings_client.gui.station_dragdrop) {
1132 SetTileSelectSize(1, 1);
1133 } else {
1134 int x = _settings_client.gui.station_numtracks;
1135 int y = _settings_client.gui.station_platlength;
1136 if (_railstation.orientation == AXIS_X) Swap(x, y);
1137 if (!_remove_button_clicked) {
1138 SetTileSelectSize(x, y);
1139 }
1140 }
1141
1142 int rad = (_settings_game.station.modified_catchment) ? CA_TRAIN : CA_UNMODIFIED;
1143
1144 if (_settings_client.gui.station_show_coverage) SetTileSelectBigSize(-rad, -rad, 2 * rad, 2 * rad);
1145
1146 for (uint bits = 0; bits < 7; bits++) {
1147 bool disable = bits >= _settings_game.station.station_spread;
1148 if (statspec == nullptr) {
1149 this->SetWidgetDisabledState(bits + WID_BRAS_PLATFORM_NUM_1, disable);
1150 this->SetWidgetDisabledState(bits + WID_BRAS_PLATFORM_LEN_1, disable);
1151 } else {
1152 this->SetWidgetDisabledState(bits + WID_BRAS_PLATFORM_NUM_1, HasBit(statspec->disallowed_platforms, bits) || disable);
1153 this->SetWidgetDisabledState(bits + WID_BRAS_PLATFORM_LEN_1, HasBit(statspec->disallowed_lengths, bits) || disable);
1154 }
1155 }
1156
1157 this->DrawWidgets();
1158
1159 if (this->IsShaded()) return;
1160 /* 'Accepts' and 'Supplies' texts. */
1161 NWidgetBase *cov = this->GetWidget<NWidgetBase>(WID_BRAS_COVERAGE_TEXTS);
1162 int top = cov->pos_y + WD_PAR_VSEP_NORMAL;
1163 int left = cov->pos_x + WD_FRAMERECT_LEFT;
1164 int right = cov->pos_x + cov->current_x - WD_FRAMERECT_RIGHT;
1165 int bottom = cov->pos_y + cov->current_y;
1166 top = DrawStationCoverageAreaText(left, right, top, SCT_ALL, rad, false) + WD_PAR_VSEP_NORMAL;
1167 top = DrawStationCoverageAreaText(left, right, top, SCT_ALL, rad, true) + WD_PAR_VSEP_NORMAL;
1168 /* Resize background if the window is too small.
1169 * Never make the window smaller to avoid oscillating if the size change affects the acceptance.
1170 * (This is the case, if making the window bigger moves the mouse into the window.) */
1171 if (top > bottom) {
1172 this->coverage_height += top - bottom;
1173 this->ReInit();
1174 }
1175 }
1176
1177 void UpdateWidgetSize(int widget, Dimension *size, const Dimension &padding, Dimension *fill, Dimension *resize) override
1178 {
1179 switch (widget) {
1180 case WID_BRAS_NEWST_LIST: {
1181 Dimension d = {0, 0};
1182 for (auto station_class : this->station_classes) {
1183 d = maxdim(d, GetStringBoundingBox(StationClass::Get(station_class)->name));
1184 }
1185 size->width = std::max(size->width, d.width + padding.width);
1186 this->line_height = FONT_HEIGHT_NORMAL + WD_MATRIX_TOP + WD_MATRIX_BOTTOM;
1187 size->height = 5 * this->line_height;
1188 resize->height = this->line_height;
1189 break;
1190 }
1191
1192 case WID_BRAS_SHOW_NEWST_TYPE: {
1193 if (!_railstation.newstations) {
1194 size->width = 0;
1195 size->height = 0;
1196 break;
1197 }
1198
1199 /* If newstations exist, compute the non-zero minimal size. */
1200 Dimension d = {0, 0};
1201 StringID str = this->GetWidget<NWidgetCore>(widget)->widget_data;
1202 for (auto station_class : this->station_classes) {
1203 StationClass *stclass = StationClass::Get(station_class);
1204 for (uint16 j = 0; j < stclass->GetSpecCount(); j++) {
1205 const StationSpec *statspec = stclass->GetSpec(j);
1206 SetDParam(0, (statspec != nullptr && statspec->name != 0) ? statspec->name : STR_STATION_CLASS_DFLT);
1207 d = maxdim(d, GetStringBoundingBox(str));
1208 }
1209 }
1210 size->width = std::max(size->width, d.width + padding.width);
1211 break;
1212 }
1213
1214 case WID_BRAS_PLATFORM_DIR_X:
1215 case WID_BRAS_PLATFORM_DIR_Y:
1216 case WID_BRAS_IMAGE:
1217 size->width = ScaleGUITrad(64) + 2;
1218 size->height = ScaleGUITrad(58) + 2;
1219 break;
1220
1221 case WID_BRAS_COVERAGE_TEXTS:
1222 size->height = this->coverage_height;
1223 break;
1224
1225 case WID_BRAS_MATRIX:
1226 fill->height = 1;
1227 resize->height = 1;
1228 break;
1229 }
1230 }
1231
1232 void DrawWidget(const Rect &r, int widget) const override
1233 {
1234 DrawPixelInfo tmp_dpi;
1235
1236 switch (GB(widget, 0, 16)) {
1237 case WID_BRAS_PLATFORM_DIR_X:
1238 /* Set up a clipping area for the '/' station preview */
1239 if (FillDrawPixelInfo(&tmp_dpi, r.left, r.top, r.right - r.left + 1, r.bottom - r.top + 1)) {
1240 DrawPixelInfo *old_dpi = _cur_dpi;
1241 _cur_dpi = &tmp_dpi;
1242 int x = ScaleGUITrad(31) + 1;
1243 int y = r.bottom - r.top - ScaleGUITrad(31);
1244 if (!DrawStationTile(x, y, _cur_railtype, AXIS_X, _railstation.station_class, _railstation.station_type)) {
1245 StationPickerDrawSprite(x, y, STATION_RAIL, _cur_railtype, INVALID_ROADTYPE, 2);
1246 }
1247 _cur_dpi = old_dpi;
1248 }
1249 break;
1250
1251 case WID_BRAS_PLATFORM_DIR_Y:
1252 /* Set up a clipping area for the '\' station preview */
1253 if (FillDrawPixelInfo(&tmp_dpi, r.left, r.top, r.right - r.left + 1, r.bottom - r.top + 1)) {
1254 DrawPixelInfo *old_dpi = _cur_dpi;
1255 _cur_dpi = &tmp_dpi;
1256 int x = ScaleGUITrad(31) + 1;
1257 int y = r.bottom - r.top - ScaleGUITrad(31);
1258 if (!DrawStationTile(x, y, _cur_railtype, AXIS_Y, _railstation.station_class, _railstation.station_type)) {
1259 StationPickerDrawSprite(x, y, STATION_RAIL, _cur_railtype, INVALID_ROADTYPE, 3);
1260 }
1261 _cur_dpi = old_dpi;
1262 }
1263 break;
1264
1265 case WID_BRAS_NEWST_LIST: {
1266 uint statclass = 0;
1267 uint row = 0;
1268 for (auto station_class : this->station_classes) {
1269 if (this->vscroll->IsVisible(statclass)) {
1270 DrawString(r.left + WD_MATRIX_LEFT, r.right - WD_MATRIX_RIGHT, row * this->line_height + r.top + WD_MATRIX_TOP,
1271 StationClass::Get(station_class)->name,
1272 station_class == _railstation.station_class ? TC_WHITE : TC_BLACK);
1273 row++;
1274 }
1275 statclass++;
1276 }
1277 break;
1278 }
1279
1280 case WID_BRAS_IMAGE: {
1281 byte type = GB(widget, 16, 16);
1282 assert(type < _railstation.station_count);
1283 /* Check station availability callback */
1284 const StationSpec *statspec = StationClass::Get(_railstation.station_class)->GetSpec(type);
1285 if (!IsStationAvailable(statspec)) {
1286 GfxFillRect(r.left + 1, r.top + 1, r.right - 1, r.bottom - 1, PC_BLACK, FILLRECT_CHECKER);
1287 }
1288
1289 /* Set up a clipping area for the station preview. */
1290 if (FillDrawPixelInfo(&tmp_dpi, r.left, r.top, r.right - r.left + 1, r.bottom - r.top + 1)) {
1291 DrawPixelInfo *old_dpi = _cur_dpi;
1292 _cur_dpi = &tmp_dpi;
1293 int x = ScaleGUITrad(31) + 1;
1294 int y = r.bottom - r.top - ScaleGUITrad(31);
1295 if (!DrawStationTile(x, y, _cur_railtype, _railstation.orientation, _railstation.station_class, type)) {
1296 StationPickerDrawSprite(x, y, STATION_RAIL, _cur_railtype, INVALID_ROADTYPE, 2 + _railstation.orientation);
1297 }
1298 _cur_dpi = old_dpi;
1299 }
1300 break;
1301 }
1302 }
1303 }
1304
1305 void OnResize() override
1306 {
1307 if (this->vscroll != nullptr) { // New stations available.
1308 this->vscroll->SetCapacityFromWidget(this, WID_BRAS_NEWST_LIST);
1309 }
1310 }
1311
1312 void SetStringParameters(int widget) const override
1313 {
1314 if (widget == WID_BRAS_SHOW_NEWST_TYPE) {
1315 const StationSpec *statspec = StationClass::Get(_railstation.station_class)->GetSpec(_railstation.station_type);
1316 SetDParam(0, (statspec != nullptr && statspec->name != 0) ? statspec->name : STR_STATION_CLASS_DFLT);
1317 }
1318 }
1319
1320 void OnClick(Point pt, int widget, int click_count) override
1321 {
1322 switch (GB(widget, 0, 16)) {
1323 case WID_BRAS_PLATFORM_DIR_X:
1324 case WID_BRAS_PLATFORM_DIR_Y:
1325 this->RaiseWidget(_railstation.orientation + WID_BRAS_PLATFORM_DIR_X);
1326 _railstation.orientation = (Axis)(widget - WID_BRAS_PLATFORM_DIR_X);
1327 this->LowerWidget(_railstation.orientation + WID_BRAS_PLATFORM_DIR_X);
1328 if (_settings_client.sound.click_beep) SndPlayFx(SND_15_BEEP);
1329 this->SetDirty();
1330 DeleteWindowById(WC_SELECT_STATION, 0);
1331 break;
1332
1333 case WID_BRAS_PLATFORM_NUM_1:
1334 case WID_BRAS_PLATFORM_NUM_2:
1335 case WID_BRAS_PLATFORM_NUM_3:
1336 case WID_BRAS_PLATFORM_NUM_4:
1337 case WID_BRAS_PLATFORM_NUM_5:
1338 case WID_BRAS_PLATFORM_NUM_6:
1339 case WID_BRAS_PLATFORM_NUM_7: {
1340 this->RaiseWidget(_settings_client.gui.station_numtracks + WID_BRAS_PLATFORM_NUM_BEGIN);
1341 this->RaiseWidget(WID_BRAS_PLATFORM_DRAG_N_DROP);
1342
1343 _settings_client.gui.station_numtracks = widget - WID_BRAS_PLATFORM_NUM_BEGIN;
1344 _settings_client.gui.station_dragdrop = false;
1345
1346 _settings_client.gui.station_dragdrop = false;
1347
1348 const StationSpec *statspec = _railstation.newstations ? StationClass::Get(_railstation.station_class)->GetSpec(_railstation.station_type) : nullptr;
1349 if (statspec != nullptr && HasBit(statspec->disallowed_lengths, _settings_client.gui.station_platlength - 1)) {
1350 /* The previously selected number of platforms in invalid */
1351 for (uint i = 0; i < 7; i++) {
1352 if (!HasBit(statspec->disallowed_lengths, i)) {
1353 this->RaiseWidget(_settings_client.gui.station_platlength + WID_BRAS_PLATFORM_LEN_BEGIN);
1354 _settings_client.gui.station_platlength = i + 1;
1355 break;
1356 }
1357 }
1358 }
1359
1360 this->LowerWidget(_settings_client.gui.station_numtracks + WID_BRAS_PLATFORM_NUM_BEGIN);
1361 this->LowerWidget(_settings_client.gui.station_platlength + WID_BRAS_PLATFORM_LEN_BEGIN);
1362 if (_settings_client.sound.click_beep) SndPlayFx(SND_15_BEEP);
1363 this->SetDirty();
1364 DeleteWindowById(WC_SELECT_STATION, 0);
1365 break;
1366 }
1367
1368 case WID_BRAS_PLATFORM_LEN_1:
1369 case WID_BRAS_PLATFORM_LEN_2:
1370 case WID_BRAS_PLATFORM_LEN_3:
1371 case WID_BRAS_PLATFORM_LEN_4:
1372 case WID_BRAS_PLATFORM_LEN_5:
1373 case WID_BRAS_PLATFORM_LEN_6:
1374 case WID_BRAS_PLATFORM_LEN_7: {
1375 this->RaiseWidget(_settings_client.gui.station_platlength + WID_BRAS_PLATFORM_LEN_BEGIN);
1376 this->RaiseWidget(WID_BRAS_PLATFORM_DRAG_N_DROP);
1377
1378 _settings_client.gui.station_platlength = widget - WID_BRAS_PLATFORM_LEN_BEGIN;
1379 _settings_client.gui.station_dragdrop = false;
1380
1381 _settings_client.gui.station_dragdrop = false;
1382
1383 const StationSpec *statspec = _railstation.newstations ? StationClass::Get(_railstation.station_class)->GetSpec(_railstation.station_type) : nullptr;
1384 if (statspec != nullptr && HasBit(statspec->disallowed_platforms, _settings_client.gui.station_numtracks - 1)) {
1385 /* The previously selected number of tracks in invalid */
1386 for (uint i = 0; i < 7; i++) {
1387 if (!HasBit(statspec->disallowed_platforms, i)) {
1388 this->RaiseWidget(_settings_client.gui.station_numtracks + WID_BRAS_PLATFORM_NUM_BEGIN);
1389 _settings_client.gui.station_numtracks = i + 1;
1390 break;
1391 }
1392 }
1393 }
1394
1395 this->LowerWidget(_settings_client.gui.station_numtracks + WID_BRAS_PLATFORM_NUM_BEGIN);
1396 this->LowerWidget(_settings_client.gui.station_platlength + WID_BRAS_PLATFORM_LEN_BEGIN);
1397 if (_settings_client.sound.click_beep) SndPlayFx(SND_15_BEEP);
1398 this->SetDirty();
1399 DeleteWindowById(WC_SELECT_STATION, 0);
1400 break;
1401 }
1402
1403 case WID_BRAS_PLATFORM_DRAG_N_DROP: {
1404 _settings_client.gui.station_dragdrop ^= true;
1405
1406 this->ToggleWidgetLoweredState(WID_BRAS_PLATFORM_DRAG_N_DROP);
1407
1408 /* get the first allowed length/number of platforms */
1409 const StationSpec *statspec = _railstation.newstations ? StationClass::Get(_railstation.station_class)->GetSpec(_railstation.station_type) : nullptr;
1410 if (statspec != nullptr && HasBit(statspec->disallowed_lengths, _settings_client.gui.station_platlength - 1)) {
1411 for (uint i = 0; i < 7; i++) {
1412 if (!HasBit(statspec->disallowed_lengths, i)) {
1413 this->RaiseWidget(_settings_client.gui.station_platlength + WID_BRAS_PLATFORM_LEN_BEGIN);
1414 _settings_client.gui.station_platlength = i + 1;
1415 break;
1416 }
1417 }
1418 }
1419 if (statspec != nullptr && HasBit(statspec->disallowed_platforms, _settings_client.gui.station_numtracks - 1)) {
1420 for (uint i = 0; i < 7; i++) {
1421 if (!HasBit(statspec->disallowed_platforms, i)) {
1422 this->RaiseWidget(_settings_client.gui.station_numtracks + WID_BRAS_PLATFORM_NUM_BEGIN);
1423 _settings_client.gui.station_numtracks = i + 1;
1424 break;
1425 }
1426 }
1427 }
1428
1429 this->SetWidgetLoweredState(_settings_client.gui.station_numtracks + WID_BRAS_PLATFORM_NUM_BEGIN, !_settings_client.gui.station_dragdrop);
1430 this->SetWidgetLoweredState(_settings_client.gui.station_platlength + WID_BRAS_PLATFORM_LEN_BEGIN, !_settings_client.gui.station_dragdrop);
1431 if (_settings_client.sound.click_beep) SndPlayFx(SND_15_BEEP);
1432 this->SetDirty();
1433 DeleteWindowById(WC_SELECT_STATION, 0);
1434 break;
1435 }
1436
1437 case WID_BRAS_HIGHLIGHT_OFF:
1438 case WID_BRAS_HIGHLIGHT_ON:
1439 _settings_client.gui.station_show_coverage = (widget != WID_BRAS_HIGHLIGHT_OFF);
1440
1441 this->SetWidgetLoweredState(WID_BRAS_HIGHLIGHT_OFF, !_settings_client.gui.station_show_coverage);
1442 this->SetWidgetLoweredState(WID_BRAS_HIGHLIGHT_ON, _settings_client.gui.station_show_coverage);
1443 if (_settings_client.sound.click_beep) SndPlayFx(SND_15_BEEP);
1444 this->SetDirty();
1445 SetViewportCatchmentStation(nullptr, true);
1446 break;
1447
1448 case WID_BRAS_NEWST_LIST: {
1449 int y = this->vscroll->GetScrolledRowFromWidget(pt.y, this, WID_BRAS_NEWST_LIST, 0, this->line_height);
1450 if (y >= (int)this->station_classes.size()) return;
1451 StationClassID station_class_id = this->station_classes[y];
1452 if (_railstation.station_class != station_class_id) {
1453 StationClass *station_class = StationClass::Get(station_class_id);
1454 _railstation.station_class = station_class_id;
1455 _railstation.station_count = station_class->GetSpecCount();
1456 _railstation.station_type = 0;
1457
1458 this->CheckSelectedSize(station_class->GetSpec(_railstation.station_type));
1459
1460 NWidgetMatrix *matrix = this->GetWidget<NWidgetMatrix>(WID_BRAS_MATRIX);
1461 matrix->SetCount(_railstation.station_count);
1462 matrix->SetClicked(_railstation.station_type);
1463 }
1464 if (_settings_client.sound.click_beep) SndPlayFx(SND_15_BEEP);
1465 this->SetDirty();
1466 DeleteWindowById(WC_SELECT_STATION, 0);
1467 break;
1468 }
1469
1470 case WID_BRAS_IMAGE: {
1471 int y = GB(widget, 16, 16);
1472 if (y >= _railstation.station_count) return;
1473
1474 /* Check station availability callback */
1475 const StationSpec *statspec = StationClass::Get(_railstation.station_class)->GetSpec(y);
1476 if (!IsStationAvailable(statspec)) return;
1477
1478 _railstation.station_type = y;
1479
1480 this->CheckSelectedSize(statspec);
1481 this->GetWidget<NWidgetMatrix>(WID_BRAS_MATRIX)->SetClicked(_railstation.station_type);
1482
1483 if (_settings_client.sound.click_beep) SndPlayFx(SND_15_BEEP);
1484 this->SetDirty();
1485 DeleteWindowById(WC_SELECT_STATION, 0);
1486 break;
1487 }
1488 }
1489 }
1490
1491 void OnRealtimeTick(uint delta_ms) override
1492 {
1493 CheckRedrawStationCoverage(this);
1494 }
1495 };
1496
1497 Listing BuildRailStationWindow::last_sorting = { false, 0 };
1498 Filtering BuildRailStationWindow::last_filtering = { false, 0 };
1499
1500 BuildRailStationWindow::GUIStationClassList::SortFunction * const BuildRailStationWindow::sorter_funcs[] = {
1501 &StationClassIDSorter,
1502 };
1503
1504 BuildRailStationWindow::GUIStationClassList::FilterFunction * const BuildRailStationWindow::filter_funcs[] = {
1505 &TagNameFilter,
1506 };
1507
1508 static const NWidgetPart _nested_station_builder_widgets[] = {
1509 NWidget(NWID_HORIZONTAL),
1510 NWidget(WWT_CLOSEBOX, COLOUR_DARK_GREEN),
1511 NWidget(WWT_CAPTION, COLOUR_DARK_GREEN), SetDataTip(STR_STATION_BUILD_RAIL_CAPTION, STR_TOOLTIP_WINDOW_TITLE_DRAG_THIS),
1512 NWidget(WWT_SHADEBOX, COLOUR_DARK_GREEN),
1513 NWidget(NWID_SELECTION, INVALID_COLOUR, WID_BRAS_SHOW_NEWST_DEFSIZE),
1514 NWidget(WWT_DEFSIZEBOX, COLOUR_DARK_GREEN),
1515 EndContainer(),
1516 EndContainer(),
1517 NWidget(WWT_PANEL, COLOUR_DARK_GREEN),
1518 NWidget(NWID_HORIZONTAL),
1519 NWidget(NWID_VERTICAL),
1520 NWidget(NWID_SELECTION, INVALID_COLOUR, WID_BRAS_FILTER_CONTAINER),
1521 NWidget(NWID_HORIZONTAL), SetPadding(2, 2, 0, 5),
1522 NWidget(WWT_TEXT, COLOUR_DARK_GREEN), SetFill(0, 1), SetDataTip(STR_LIST_FILTER_TITLE, STR_NULL),
1523 NWidget(WWT_EDITBOX, COLOUR_GREY, WID_BRAS_FILTER_EDITBOX), SetFill(1, 0), SetResize(1, 0),
1524 SetDataTip(STR_LIST_FILTER_OSKTITLE, STR_LIST_FILTER_TOOLTIP),
1525 EndContainer(),
1526 EndContainer(),
1527 NWidget(NWID_SELECTION, INVALID_COLOUR, WID_BRAS_SHOW_NEWST_ADDITIONS),
1528 NWidget(NWID_HORIZONTAL), SetPIP(7, 0, 7), SetPadding(2, 0, 1, 0),
1529 NWidget(WWT_MATRIX, COLOUR_GREY, WID_BRAS_NEWST_LIST), SetMinimalSize(122, 71), SetFill(1, 0),
1530 SetMatrixDataTip(1, 0, STR_STATION_BUILD_STATION_CLASS_TOOLTIP), SetScrollbar(WID_BRAS_NEWST_SCROLL),
1531 NWidget(NWID_VSCROLLBAR, COLOUR_GREY, WID_BRAS_NEWST_SCROLL),
1532 EndContainer(),
1533 EndContainer(),
1534 NWidget(WWT_LABEL, COLOUR_DARK_GREEN), SetMinimalSize(144, 11), SetDataTip(STR_STATION_BUILD_ORIENTATION, STR_NULL), SetPadding(1, 2, 0, 2),
1535 NWidget(NWID_HORIZONTAL),
1536 NWidget(NWID_SPACER), SetMinimalSize(7, 0), SetFill(1, 0),
1537 NWidget(WWT_PANEL, COLOUR_GREY, WID_BRAS_PLATFORM_DIR_X), SetMinimalSize(66, 60), SetFill(0, 0), SetDataTip(0x0, STR_STATION_BUILD_RAILROAD_ORIENTATION_TOOLTIP), EndContainer(),
1538 NWidget(NWID_SPACER), SetMinimalSize(2, 0), SetFill(1, 0),
1539 NWidget(WWT_PANEL, COLOUR_GREY, WID_BRAS_PLATFORM_DIR_Y), SetMinimalSize(66, 60), SetFill(0, 0), SetDataTip(0x0, STR_STATION_BUILD_RAILROAD_ORIENTATION_TOOLTIP), EndContainer(),
1540 NWidget(NWID_SPACER), SetMinimalSize(7, 0), SetFill(1, 0),
1541 EndContainer(),
1542 NWidget(WWT_LABEL, COLOUR_DARK_GREEN, WID_BRAS_SHOW_NEWST_TYPE), SetMinimalSize(144, 11), SetDataTip(STR_ORANGE_STRING, STR_NULL), SetPadding(1, 2, 4, 2),
1543 NWidget(WWT_LABEL, COLOUR_DARK_GREEN), SetMinimalSize(144, 11), SetDataTip(STR_STATION_BUILD_NUMBER_OF_TRACKS, STR_NULL), SetPadding(0, 2, 0, 2),
1544 NWidget(NWID_HORIZONTAL),
1545 NWidget(NWID_SPACER), SetFill(1, 0),
1546 NWidget(WWT_TEXTBTN, COLOUR_GREY, WID_BRAS_PLATFORM_NUM_1), SetMinimalSize(15, 12), SetDataTip(STR_BLACK_1, STR_STATION_BUILD_NUMBER_OF_TRACKS_TOOLTIP),
1547 NWidget(WWT_TEXTBTN, COLOUR_GREY, WID_BRAS_PLATFORM_NUM_2), SetMinimalSize(15, 12), SetDataTip(STR_BLACK_2, STR_STATION_BUILD_NUMBER_OF_TRACKS_TOOLTIP),
1548 NWidget(WWT_TEXTBTN, COLOUR_GREY, WID_BRAS_PLATFORM_NUM_3), SetMinimalSize(15, 12), SetDataTip(STR_BLACK_3, STR_STATION_BUILD_NUMBER_OF_TRACKS_TOOLTIP),
1549 NWidget(WWT_TEXTBTN, COLOUR_GREY, WID_BRAS_PLATFORM_NUM_4), SetMinimalSize(15, 12), SetDataTip(STR_BLACK_4, STR_STATION_BUILD_NUMBER_OF_TRACKS_TOOLTIP),
1550 NWidget(WWT_TEXTBTN, COLOUR_GREY, WID_BRAS_PLATFORM_NUM_5), SetMinimalSize(15, 12), SetDataTip(STR_BLACK_5, STR_STATION_BUILD_NUMBER_OF_TRACKS_TOOLTIP),
1551 NWidget(WWT_TEXTBTN, COLOUR_GREY, WID_BRAS_PLATFORM_NUM_6), SetMinimalSize(15, 12), SetDataTip(STR_BLACK_6, STR_STATION_BUILD_NUMBER_OF_TRACKS_TOOLTIP),
1552 NWidget(WWT_TEXTBTN, COLOUR_GREY, WID_BRAS_PLATFORM_NUM_7), SetMinimalSize(15, 12), SetDataTip(STR_BLACK_7, STR_STATION_BUILD_NUMBER_OF_TRACKS_TOOLTIP),
1553 NWidget(NWID_SPACER), SetFill(1, 0),
1554 EndContainer(),
1555 NWidget(WWT_LABEL, COLOUR_DARK_GREEN), SetMinimalSize(144, 11), SetDataTip(STR_STATION_BUILD_PLATFORM_LENGTH, STR_NULL), SetPadding(2, 2, 0, 2),
1556 NWidget(NWID_HORIZONTAL),
1557 NWidget(NWID_SPACER), SetFill(1, 0),
1558 NWidget(WWT_TEXTBTN, COLOUR_GREY, WID_BRAS_PLATFORM_LEN_1), SetMinimalSize(15, 12), SetDataTip(STR_BLACK_1, STR_STATION_BUILD_PLATFORM_LENGTH_TOOLTIP),
1559 NWidget(WWT_TEXTBTN, COLOUR_GREY, WID_BRAS_PLATFORM_LEN_2), SetMinimalSize(15, 12), SetDataTip(STR_BLACK_2, STR_STATION_BUILD_PLATFORM_LENGTH_TOOLTIP),
1560 NWidget(WWT_TEXTBTN, COLOUR_GREY, WID_BRAS_PLATFORM_LEN_3), SetMinimalSize(15, 12), SetDataTip(STR_BLACK_3, STR_STATION_BUILD_PLATFORM_LENGTH_TOOLTIP),
1561 NWidget(WWT_TEXTBTN, COLOUR_GREY, WID_BRAS_PLATFORM_LEN_4), SetMinimalSize(15, 12), SetDataTip(STR_BLACK_4, STR_STATION_BUILD_PLATFORM_LENGTH_TOOLTIP),
1562 NWidget(WWT_TEXTBTN, COLOUR_GREY, WID_BRAS_PLATFORM_LEN_5), SetMinimalSize(15, 12), SetDataTip(STR_BLACK_5, STR_STATION_BUILD_PLATFORM_LENGTH_TOOLTIP),
1563 NWidget(WWT_TEXTBTN, COLOUR_GREY, WID_BRAS_PLATFORM_LEN_6), SetMinimalSize(15, 12), SetDataTip(STR_BLACK_6, STR_STATION_BUILD_PLATFORM_LENGTH_TOOLTIP),
1564 NWidget(WWT_TEXTBTN, COLOUR_GREY, WID_BRAS_PLATFORM_LEN_7), SetMinimalSize(15, 12), SetDataTip(STR_BLACK_7, STR_STATION_BUILD_PLATFORM_LENGTH_TOOLTIP),
1565 NWidget(NWID_SPACER), SetFill(1, 0),
1566 EndContainer(),
1567 NWidget(NWID_SPACER), SetMinimalSize(0, 2),
1568 NWidget(NWID_HORIZONTAL),
1569 NWidget(NWID_SPACER), SetMinimalSize(2, 0), SetFill(1, 0),
1570 NWidget(WWT_TEXTBTN, COLOUR_GREY, WID_BRAS_PLATFORM_DRAG_N_DROP), SetMinimalSize(75, 12), SetDataTip(STR_STATION_BUILD_DRAG_DROP, STR_STATION_BUILD_DRAG_DROP_TOOLTIP),
1571 NWidget(NWID_SPACER), SetMinimalSize(2, 0), SetFill(1, 0),
1572 EndContainer(),
1573 NWidget(WWT_LABEL, COLOUR_DARK_GREEN), SetMinimalSize(144, 11), SetDataTip(STR_STATION_BUILD_COVERAGE_AREA_TITLE, STR_NULL), SetPadding(3, 2, 0, 2),
1574 NWidget(NWID_HORIZONTAL),
1575 NWidget(NWID_SPACER), SetMinimalSize(2, 0), SetFill(1, 0),
1576 NWidget(WWT_TEXTBTN, COLOUR_GREY, WID_BRAS_HIGHLIGHT_OFF), SetMinimalSize(60, 12),
1577 SetDataTip(STR_STATION_BUILD_COVERAGE_OFF, STR_STATION_BUILD_COVERAGE_AREA_OFF_TOOLTIP),
1578 NWidget(WWT_TEXTBTN, COLOUR_GREY, WID_BRAS_HIGHLIGHT_ON), SetMinimalSize(60, 12),
1579 SetDataTip(STR_STATION_BUILD_COVERAGE_ON, STR_STATION_BUILD_COVERAGE_AREA_ON_TOOLTIP),
1580 NWidget(NWID_SPACER), SetMinimalSize(2, 0), SetFill(1, 0),
1581 EndContainer(),
1582 EndContainer(),
1583 NWidget(NWID_SELECTION, INVALID_COLOUR, WID_BRAS_SHOW_NEWST_MATRIX),
1584 /* We need an additional background for the matrix, as the matrix cannot handle the scrollbar due to not being an NWidgetCore. */
1585 NWidget(WWT_PANEL, COLOUR_DARK_GREEN), SetScrollbar(WID_BRAS_MATRIX_SCROLL),
1586 NWidget(NWID_HORIZONTAL),
1587 NWidget(NWID_MATRIX, COLOUR_DARK_GREEN, WID_BRAS_MATRIX), SetScrollbar(WID_BRAS_MATRIX_SCROLL), SetPIP(0, 2, 0), SetPadding(2, 0, 0, 0),
1588 NWidget(WWT_PANEL, COLOUR_DARK_GREEN, WID_BRAS_IMAGE), SetMinimalSize(66, 60),
1589 SetFill(0, 0), SetResize(0, 0), SetDataTip(0x0, STR_STATION_BUILD_STATION_TYPE_TOOLTIP), SetScrollbar(WID_BRAS_MATRIX_SCROLL),
1590 EndContainer(),
1591 EndContainer(),
1592 NWidget(NWID_VSCROLLBAR, COLOUR_DARK_GREEN, WID_BRAS_MATRIX_SCROLL),
1593 EndContainer(),
1594 EndContainer(),
1595 EndContainer(),
1596 EndContainer(),
1597 NWidget(NWID_HORIZONTAL),
1598 NWidget(WWT_EMPTY, INVALID_COLOUR, WID_BRAS_COVERAGE_TEXTS), SetFill(1, 1), SetResize(1, 0),
1599 NWidget(NWID_SELECTION, INVALID_COLOUR, WID_BRAS_SHOW_NEWST_RESIZE),
1600 NWidget(NWID_VERTICAL),
1601 NWidget(WWT_PANEL, COLOUR_DARK_GREEN), SetFill(0, 1), EndContainer(),
1602 NWidget(WWT_RESIZEBOX, COLOUR_DARK_GREEN),
1603 EndContainer(),
1604 EndContainer(),
1605 EndContainer(),
1606 EndContainer(),
1607 };
1608
1610 static WindowDesc _station_builder_desc(
1611 WDP_AUTO, "build_station_rail", 350, 0,
1612 WC_BUILD_STATION, WC_BUILD_TOOLBAR,
1613 WDF_CONSTRUCTION,
1614 _nested_station_builder_widgets, lengthof(_nested_station_builder_widgets)
1615 );
1616
1618 static void ShowStationBuilder(Window *parent)
1619 {
1620 bool newstations = StationClass::GetClassCount() > 2 || StationClass::Get(STAT_CLASS_DFLT)->GetSpecCount() != 1;
1621 new BuildRailStationWindow(&_station_builder_desc, parent, newstations);
1622 }
1623
1624 struct BuildSignalWindow : public PickerWindowBase {
1625 private:
1626 Dimension sig_sprite_size;
1627 int sig_sprite_bottom_offset;
1628
1636 void DrawSignalSprite(byte widget_index, SpriteID image) const
1637 {
1638 Point offset;
1639 Dimension sprite_size = GetSpriteSize(image, &offset);
1640 const NWidgetBase *widget = this->GetWidget<NWidgetBase>(widget_index);
1641 int x = widget->pos_x - offset.x +
1642 (widget->current_x - sprite_size.width + offset.x) / 2; // centered
1643 int y = widget->pos_y - sig_sprite_bottom_offset + WD_IMGBTN_TOP +
1644 (widget->current_y - WD_IMGBTN_TOP - WD_IMGBTN_BOTTOM + sig_sprite_size.height) / 2; // aligned to bottom
1645
1646 DrawSprite(image, PAL_NONE,
1647 x + this->IsWidgetLowered(widget_index),
1648 y + this->IsWidgetLowered(widget_index));
1649 }
1650
1651 public:
1652 BuildSignalWindow(WindowDesc *desc, Window *parent) : PickerWindowBase(desc, parent)
1653 {
1654 this->InitNested(TRANSPORT_RAIL);
1655 this->OnInvalidateData();
1656 }
1657
1658 ~BuildSignalWindow()
1659 {
1660 _convert_signal_button = false;
1661 }
1662
1663 void OnInit() override
1664 {
1665 /* Calculate maximum signal sprite size. */
1666 this->sig_sprite_size.width = 0;
1667 this->sig_sprite_size.height = 0;
1668 this->sig_sprite_bottom_offset = 0;
1669 const RailtypeInfo *rti = GetRailTypeInfo(_cur_railtype);
1670 for (uint type = SIGTYPE_NORMAL; type < SIGTYPE_END; type++) {
1671 for (uint variant = SIG_ELECTRIC; variant <= SIG_SEMAPHORE; variant++) {
1672 for (uint lowered = 0; lowered < 2; lowered++) {
1673 Point offset;
1674 Dimension sprite_size = GetSpriteSize(rti->gui_sprites.signals[type][variant][lowered], &offset);
1675 this->sig_sprite_bottom_offset = std::max<int>(this->sig_sprite_bottom_offset, sprite_size.height);
1676 this->sig_sprite_size.width = std::max<int>(this->sig_sprite_size.width, sprite_size.width - offset.x);
1677 this->sig_sprite_size.height = std::max<int>(this->sig_sprite_size.height, sprite_size.height - offset.y);
1678 }
1679 }
1680 }
1681 }
1682
1683 void UpdateWidgetSize(int widget, Dimension *size, const Dimension &padding, Dimension *fill, Dimension *resize) override
1684 {
1685 if (widget == WID_BS_DRAG_SIGNALS_DENSITY_LABEL) {
1686 /* Two digits for signals density. */
1687 size->width = std::max(size->width, 2 * GetDigitWidth() + padding.width + WD_FRAMERECT_LEFT + WD_FRAMERECT_RIGHT);
1688 } else if (IsInsideMM(widget, WID_BS_SEMAPHORE_NORM, WID_BS_ELECTRIC_PBS_OWAY + 1)) {
1689 size->width = std::max(size->width, this->sig_sprite_size.width + WD_IMGBTN_LEFT + WD_IMGBTN_RIGHT);
1690 size->height = std::max(size->height, this->sig_sprite_size.height + WD_IMGBTN_TOP + WD_IMGBTN_BOTTOM);
1691 }
1692 }
1693
1694 void SetStringParameters(int widget) const override
1695 {
1696 switch (widget) {
1697 case WID_BS_DRAG_SIGNALS_DENSITY_LABEL:
1698 SetDParam(0, _settings_client.gui.drag_signals_density);
1699 break;
1700 }
1701 }
1702
1703 void DrawWidget(const Rect &r, int widget) const override
1704 {
1705 if (IsInsideMM(widget, WID_BS_SEMAPHORE_NORM, WID_BS_ELECTRIC_PBS_OWAY + 1)) {
1706 /* Extract signal from widget number. */
1707 int type = (widget - WID_BS_SEMAPHORE_NORM) % SIGTYPE_END;
1708 int var = SIG_SEMAPHORE - (widget - WID_BS_SEMAPHORE_NORM) / SIGTYPE_END; // SignalVariant order is reversed compared to the widgets.
1709 SpriteID sprite = GetRailTypeInfo(_cur_railtype)->gui_sprites.signals[type][var][this->IsWidgetLowered(widget)];
1710
1711 this->DrawSignalSprite(widget, sprite);
1712 }
1713 }
1714
1715 void OnClick(Point pt, int widget, int click_count) override
1716 {
1717 switch (widget) {
1718 case WID_BS_SEMAPHORE_NORM:
1719 case WID_BS_SEMAPHORE_ENTRY:
1720 case WID_BS_SEMAPHORE_EXIT:
1721 case WID_BS_SEMAPHORE_COMBO:
1722 case WID_BS_SEMAPHORE_PBS:
1723 case WID_BS_SEMAPHORE_PBS_OWAY:
1724 case WID_BS_ELECTRIC_NORM:
1725 case WID_BS_ELECTRIC_ENTRY:
1726 case WID_BS_ELECTRIC_EXIT:
1727 case WID_BS_ELECTRIC_COMBO:
1728 case WID_BS_ELECTRIC_PBS:
1729 case WID_BS_ELECTRIC_PBS_OWAY:
1730 this->RaiseWidget((_cur_signal_variant == SIG_ELECTRIC ? WID_BS_ELECTRIC_NORM : WID_BS_SEMAPHORE_NORM) + _cur_signal_type);
1731
1732 _cur_signal_type = (SignalType)((uint)((widget - WID_BS_SEMAPHORE_NORM) % (SIGTYPE_LAST + 1)));
1733 _cur_signal_variant = widget >= WID_BS_ELECTRIC_NORM ? SIG_ELECTRIC : SIG_SEMAPHORE;
1734
1735 /* If 'remove' button of rail build toolbar is active, disable it. */
1736 if (_remove_button_clicked) {
1737 Window *w = FindWindowById(WC_BUILD_TOOLBAR, TRANSPORT_RAIL);
1738 if (w != nullptr) ToggleRailButton_Remove(w);
1739 }
1740
1741 break;
1742
1743 case WID_BS_CONVERT:
1744 _convert_signal_button = !_convert_signal_button;
1745 break;
1746
1747 case WID_BS_DRAG_SIGNALS_DENSITY_DECREASE:
1748 if (_settings_client.gui.drag_signals_density > 1) {
1749 _settings_client.gui.drag_signals_density--;
1750 SetWindowDirty(WC_GAME_OPTIONS, WN_GAME_OPTIONS_GAME_SETTINGS);
1751 }
1752 break;
1753
1754 case WID_BS_DRAG_SIGNALS_DENSITY_INCREASE:
1755 if (_settings_client.gui.drag_signals_density < 20) {
1756 _settings_client.gui.drag_signals_density++;
1757 SetWindowDirty(WC_GAME_OPTIONS, WN_GAME_OPTIONS_GAME_SETTINGS);
1758 }
1759 break;
1760
1761 default: break;
1762 }
1763
1764 this->InvalidateData();
1765 }
1766
1772 void OnInvalidateData(int data = 0, bool gui_scope = true) override
1773 {
1774 if (!gui_scope) return;
1775 this->LowerWidget((_cur_signal_variant == SIG_ELECTRIC ? WID_BS_ELECTRIC_NORM : WID_BS_SEMAPHORE_NORM) + _cur_signal_type);
1776
1777 this->SetWidgetLoweredState(WID_BS_CONVERT, _convert_signal_button);
1778
1779 this->SetWidgetDisabledState(WID_BS_DRAG_SIGNALS_DENSITY_DECREASE, _settings_client.gui.drag_signals_density == 1);
1780 this->SetWidgetDisabledState(WID_BS_DRAG_SIGNALS_DENSITY_INCREASE, _settings_client.gui.drag_signals_density == 20);
1781 }
1782 };
1783
1785 static const NWidgetPart _nested_signal_builder_widgets[] = {
1786 NWidget(NWID_HORIZONTAL),
1787 NWidget(WWT_CLOSEBOX, COLOUR_DARK_GREEN),
1788 NWidget(WWT_CAPTION, COLOUR_DARK_GREEN), SetDataTip(STR_BUILD_SIGNAL_CAPTION, STR_TOOLTIP_WINDOW_TITLE_DRAG_THIS),
1789 EndContainer(),
1790 NWidget(NWID_VERTICAL, NC_EQUALSIZE),
1791 NWidget(NWID_HORIZONTAL, NC_EQUALSIZE),
1792 NWidget(WWT_PANEL, COLOUR_DARK_GREEN, WID_BS_SEMAPHORE_NORM), SetDataTip(STR_NULL, STR_BUILD_SIGNAL_SEMAPHORE_NORM_TOOLTIP), EndContainer(), SetFill(1, 1),
1793 NWidget(WWT_PANEL, COLOUR_DARK_GREEN, WID_BS_SEMAPHORE_ENTRY), SetDataTip(STR_NULL, STR_BUILD_SIGNAL_SEMAPHORE_ENTRY_TOOLTIP), EndContainer(), SetFill(1, 1),
1794 NWidget(WWT_PANEL, COLOUR_DARK_GREEN, WID_BS_SEMAPHORE_EXIT), SetDataTip(STR_NULL, STR_BUILD_SIGNAL_SEMAPHORE_EXIT_TOOLTIP), EndContainer(), SetFill(1, 1),
1795 NWidget(WWT_PANEL, COLOUR_DARK_GREEN, WID_BS_SEMAPHORE_COMBO), SetDataTip(STR_NULL, STR_BUILD_SIGNAL_SEMAPHORE_COMBO_TOOLTIP), EndContainer(), SetFill(1, 1),
1796 NWidget(WWT_PANEL, COLOUR_DARK_GREEN, WID_BS_SEMAPHORE_PBS), SetDataTip(STR_NULL, STR_BUILD_SIGNAL_SEMAPHORE_PBS_TOOLTIP), EndContainer(), SetFill(1, 1),
1797 NWidget(WWT_PANEL, COLOUR_DARK_GREEN, WID_BS_SEMAPHORE_PBS_OWAY), SetDataTip(STR_NULL, STR_BUILD_SIGNAL_SEMAPHORE_PBS_OWAY_TOOLTIP), EndContainer(), SetFill(1, 1),
1798 NWidget(WWT_IMGBTN, COLOUR_DARK_GREEN, WID_BS_CONVERT), SetDataTip(SPR_IMG_SIGNAL_CONVERT, STR_BUILD_SIGNAL_CONVERT_TOOLTIP), SetFill(1, 1),
1799 EndContainer(),
1800 NWidget(NWID_HORIZONTAL, NC_EQUALSIZE),
1801 NWidget(WWT_PANEL, COLOUR_DARK_GREEN, WID_BS_ELECTRIC_NORM), SetDataTip(STR_NULL, STR_BUILD_SIGNAL_ELECTRIC_NORM_TOOLTIP), EndContainer(), SetFill(1, 1),
1802 NWidget(WWT_PANEL, COLOUR_DARK_GREEN, WID_BS_ELECTRIC_ENTRY), SetDataTip(STR_NULL, STR_BUILD_SIGNAL_ELECTRIC_ENTRY_TOOLTIP), EndContainer(), SetFill(1, 1),
1803 NWidget(WWT_PANEL, COLOUR_DARK_GREEN, WID_BS_ELECTRIC_EXIT), SetDataTip(STR_NULL, STR_BUILD_SIGNAL_ELECTRIC_EXIT_TOOLTIP), EndContainer(), SetFill(1, 1),
1804 NWidget(WWT_PANEL, COLOUR_DARK_GREEN, WID_BS_ELECTRIC_COMBO), SetDataTip(STR_NULL, STR_BUILD_SIGNAL_ELECTRIC_COMBO_TOOLTIP), EndContainer(), SetFill(1, 1),
1805 NWidget(WWT_PANEL, COLOUR_DARK_GREEN, WID_BS_ELECTRIC_PBS), SetDataTip(STR_NULL, STR_BUILD_SIGNAL_ELECTRIC_PBS_TOOLTIP), EndContainer(), SetFill(1, 1),
1806 NWidget(WWT_PANEL, COLOUR_DARK_GREEN, WID_BS_ELECTRIC_PBS_OWAY), SetDataTip(STR_NULL, STR_BUILD_SIGNAL_ELECTRIC_PBS_OWAY_TOOLTIP), EndContainer(), SetFill(1, 1),
1807 NWidget(WWT_PANEL, COLOUR_DARK_GREEN), SetDataTip(STR_NULL, STR_BUILD_SIGNAL_DRAG_SIGNALS_DENSITY_TOOLTIP), SetFill(1, 1),
1808 NWidget(WWT_LABEL, COLOUR_DARK_GREEN, WID_BS_DRAG_SIGNALS_DENSITY_LABEL), SetDataTip(STR_ORANGE_INT, STR_BUILD_SIGNAL_DRAG_SIGNALS_DENSITY_TOOLTIP), SetFill(1, 1),
1809 NWidget(NWID_HORIZONTAL), SetPIP(2, 0, 2),
1810 NWidget(NWID_SPACER), SetFill(1, 0),
1811 NWidget(WWT_PUSHARROWBTN, COLOUR_GREY, WID_BS_DRAG_SIGNALS_DENSITY_DECREASE), SetMinimalSize(9, 12), SetDataTip(AWV_DECREASE, STR_BUILD_SIGNAL_DRAG_SIGNALS_DENSITY_DECREASE_TOOLTIP),
1812 NWidget(WWT_PUSHARROWBTN, COLOUR_GREY, WID_BS_DRAG_SIGNALS_DENSITY_INCREASE), SetMinimalSize(9, 12), SetDataTip(AWV_INCREASE, STR_BUILD_SIGNAL_DRAG_SIGNALS_DENSITY_INCREASE_TOOLTIP),
1813 NWidget(NWID_SPACER), SetFill(1, 0),
1814 EndContainer(),
1815 NWidget(NWID_SPACER), SetMinimalSize(0, 2), SetFill(1, 0),
1816 EndContainer(),
1817 EndContainer(),
1818 EndContainer(),
1819 };
1820
1822 static WindowDesc _signal_builder_desc(
1823 WDP_AUTO, "build_signal", 0, 0,
1824 WC_BUILD_SIGNAL, WC_BUILD_TOOLBAR,
1825 WDF_CONSTRUCTION,
1826 _nested_signal_builder_widgets, lengthof(_nested_signal_builder_widgets)
1827 );
1828
1832 static void ShowSignalBuilder(Window *parent)
1833 {
1834 new BuildSignalWindow(&_signal_builder_desc, parent);
1835 }
1836
1837 struct BuildRailDepotWindow : public PickerWindowBase {
1838 BuildRailDepotWindow(WindowDesc *desc, Window *parent) : PickerWindowBase(desc, parent)
1839 {
1840 this->InitNested(TRANSPORT_RAIL);
1841 this->LowerWidget(_build_depot_direction + WID_BRAD_DEPOT_NE);
1842 }
1843
1844 void UpdateWidgetSize(int widget, Dimension *size, const Dimension &padding, Dimension *fill, Dimension *resize) override
1845 {
1846 if (!IsInsideMM(widget, WID_BRAD_DEPOT_NE, WID_BRAD_DEPOT_NW + 1)) return;
1847
1848 size->width = ScaleGUITrad(64) + 2;
1849 size->height = ScaleGUITrad(48) + 2;
1850 }
1851
1852 void DrawWidget(const Rect &r, int widget) const override
1853 {
1854 if (!IsInsideMM(widget, WID_BRAD_DEPOT_NE, WID_BRAD_DEPOT_NW + 1)) return;
1855
1856 DrawTrainDepotSprite(r.left + 1 + ScaleGUITrad(31), r.bottom - ScaleGUITrad(31), widget - WID_BRAD_DEPOT_NE + DIAGDIR_NE, _cur_railtype);
1857 }
1858
1859 void OnClick(Point pt, int widget, int click_count) override
1860 {
1861 switch (widget) {
1862 case WID_BRAD_DEPOT_NE:
1863 case WID_BRAD_DEPOT_SE:
1864 case WID_BRAD_DEPOT_SW:
1865 case WID_BRAD_DEPOT_NW:
1866 this->RaiseWidget(_build_depot_direction + WID_BRAD_DEPOT_NE);
1867 _build_depot_direction = (DiagDirection)(widget - WID_BRAD_DEPOT_NE);
1868 this->LowerWidget(_build_depot_direction + WID_BRAD_DEPOT_NE);
1869 if (_settings_client.sound.click_beep) SndPlayFx(SND_15_BEEP);
1870 this->SetDirty();
1871 break;
1872 }
1873 }
1874 };
1875
1877 static const NWidgetPart _nested_build_depot_widgets[] = {
1878 NWidget(NWID_HORIZONTAL),
1879 NWidget(WWT_CLOSEBOX, COLOUR_DARK_GREEN),
1880 NWidget(WWT_CAPTION, COLOUR_DARK_GREEN), SetDataTip(STR_BUILD_DEPOT_TRAIN_ORIENTATION_CAPTION, STR_TOOLTIP_WINDOW_TITLE_DRAG_THIS),
1881 EndContainer(),
1882 NWidget(WWT_PANEL, COLOUR_DARK_GREEN),
1883 NWidget(NWID_SPACER), SetMinimalSize(0, 3),
1884 NWidget(NWID_HORIZONTAL_LTR),
1885 NWidget(NWID_SPACER), SetMinimalSize(3, 0), SetFill(1, 0),
1886 NWidget(NWID_VERTICAL),
1887 NWidget(WWT_PANEL, COLOUR_GREY, WID_BRAD_DEPOT_NW), SetMinimalSize(66, 50), SetDataTip(0x0, STR_BUILD_DEPOT_TRAIN_ORIENTATION_TOOLTIP),
1888 EndContainer(),
1889 NWidget(NWID_SPACER), SetMinimalSize(0, 2),
1890 NWidget(WWT_PANEL, COLOUR_GREY, WID_BRAD_DEPOT_SW), SetMinimalSize(66, 50), SetDataTip(0x0, STR_BUILD_DEPOT_TRAIN_ORIENTATION_TOOLTIP),
1891 EndContainer(),
1892 EndContainer(),
1893 NWidget(NWID_SPACER), SetMinimalSize(2, 0),
1894 NWidget(NWID_VERTICAL),
1895 NWidget(WWT_PANEL, COLOUR_GREY, WID_BRAD_DEPOT_NE), SetMinimalSize(66, 50), SetDataTip(0x0, STR_BUILD_DEPOT_TRAIN_ORIENTATION_TOOLTIP),
1896 EndContainer(),
1897 NWidget(NWID_SPACER), SetMinimalSize(0, 2),
1898 NWidget(WWT_PANEL, COLOUR_GREY, WID_BRAD_DEPOT_SE), SetMinimalSize(66, 50), SetDataTip(0x0, STR_BUILD_DEPOT_TRAIN_ORIENTATION_TOOLTIP),
1899 EndContainer(),
1900 EndContainer(),
1901 NWidget(NWID_SPACER), SetMinimalSize(3, 0), SetFill(1, 0),
1902 EndContainer(),
1903 NWidget(NWID_SPACER), SetMinimalSize(0, 3),
1904 EndContainer(),
1905 };
1906
1907 static WindowDesc _build_depot_desc(
1908 WDP_AUTO, nullptr, 0, 0,
1909 WC_BUILD_DEPOT, WC_BUILD_TOOLBAR,
1910 WDF_CONSTRUCTION,
1911 _nested_build_depot_widgets, lengthof(_nested_build_depot_widgets)
1912 );
1913
1914 static void ShowBuildTrainDepotPicker(Window *parent)
1915 {
1916 new BuildRailDepotWindow(&_build_depot_desc, parent);
1917 }
1918
1919 struct BuildRailWaypointWindow : PickerWindowBase {
1920 BuildRailWaypointWindow(WindowDesc *desc, Window *parent) : PickerWindowBase(desc, parent)
1921 {
1922 this->CreateNestedTree();
1923
1924 NWidgetMatrix *matrix = this->GetWidget<NWidgetMatrix>(WID_BRW_WAYPOINT_MATRIX);
1925 matrix->SetScrollbar(this->GetScrollbar(WID_BRW_SCROLL));
1926
1927 this->FinishInitNested(TRANSPORT_RAIL);
1928
1929 matrix->SetCount(_waypoint_count);
1930 matrix->SetClicked(_cur_waypoint_type);
1931 }
1932
1933 void UpdateWidgetSize(int widget, Dimension *size, const Dimension &padding, Dimension *fill, Dimension *resize) override
1934 {
1935 switch (widget) {
1936 case WID_BRW_WAYPOINT_MATRIX:
1937 /* Three blobs high and wide. */
1938 size->width += resize->width * 2;
1939 size->height += resize->height * 2;
1940
1941 /* Resizing in X direction only at blob size, but at pixel level in Y. */
1942 resize->height = 1;
1943 break;
1944
1945 case WID_BRW_WAYPOINT:
1946 size->width = ScaleGUITrad(64) + 2;
1947 size->height = ScaleGUITrad(58) + 2;
1948 break;
1949 }
1950 }
1951
1952 void DrawWidget(const Rect &r, int widget) const override
1953 {
1954 switch (GB(widget, 0, 16)) {
1955 case WID_BRW_WAYPOINT: {
1956 byte type = GB(widget, 16, 16);
1957 const StationSpec *statspec = StationClass::Get(STAT_CLASS_WAYP)->GetSpec(type);
1958 DrawWaypointSprite(r.left + 1 + ScaleGUITrad(31), r.bottom - ScaleGUITrad(31), type, _cur_railtype);
1959
1960 if (!IsStationAvailable(statspec)) {
1961 GfxFillRect(r.left + 1, r.top + 1, r.right - 1, r.bottom - 1, PC_BLACK, FILLRECT_CHECKER);
1962 }
1963 }
1964 }
1965 }
1966
1967 void OnClick(Point pt, int widget, int click_count) override
1968 {
1969 switch (GB(widget, 0, 16)) {
1970 case WID_BRW_WAYPOINT: {
1971 byte type = GB(widget, 16, 16);
1972 this->GetWidget<NWidgetMatrix>(WID_BRW_WAYPOINT_MATRIX)->SetClicked(_cur_waypoint_type);
1973
1974 /* Check station availability callback */
1975 const StationSpec *statspec = StationClass::Get(STAT_CLASS_WAYP)->GetSpec(type);
1976 if (!IsStationAvailable(statspec)) return;
1977
1978 _cur_waypoint_type = type;
1979 this->GetWidget<NWidgetMatrix>(WID_BRW_WAYPOINT_MATRIX)->SetClicked(_cur_waypoint_type);
1980 if (_settings_client.sound.click_beep) SndPlayFx(SND_15_BEEP);
1981 this->SetDirty();
1982 break;
1983 }
1984 }
1985 }
1986 };
1987
1989 static const NWidgetPart _nested_build_waypoint_widgets[] = {
1990 NWidget(NWID_HORIZONTAL),
1991 NWidget(WWT_CLOSEBOX, COLOUR_DARK_GREEN),
1992 NWidget(WWT_CAPTION, COLOUR_DARK_GREEN), SetDataTip(STR_WAYPOINT_CAPTION, STR_TOOLTIP_WINDOW_TITLE_DRAG_THIS),
1993 NWidget(WWT_DEFSIZEBOX, COLOUR_DARK_GREEN),
1994 EndContainer(),
1995 NWidget(NWID_HORIZONTAL),
1996 NWidget(NWID_MATRIX, COLOUR_DARK_GREEN, WID_BRW_WAYPOINT_MATRIX), SetPIP(3, 2, 3), SetScrollbar(WID_BRW_SCROLL),
1997 NWidget(WWT_PANEL, COLOUR_DARK_GREEN, WID_BRW_WAYPOINT), SetMinimalSize(66, 60), SetDataTip(0x0, STR_WAYPOINT_GRAPHICS_TOOLTIP), SetScrollbar(WID_BRW_SCROLL), EndContainer(),
1998 EndContainer(),
1999 NWidget(NWID_VERTICAL),
2000 NWidget(NWID_VSCROLLBAR, COLOUR_DARK_GREEN, WID_BRW_SCROLL),
2001 NWidget(WWT_RESIZEBOX, COLOUR_DARK_GREEN),
2002 EndContainer(),
2003 EndContainer(),
2004 };
2005
2006 static WindowDesc _build_waypoint_desc(
2007 WDP_AUTO, "build_waypoint", 0, 0,
2008 WC_BUILD_WAYPOINT, WC_BUILD_TOOLBAR,
2009 WDF_CONSTRUCTION,
2010 _nested_build_waypoint_widgets, lengthof(_nested_build_waypoint_widgets)
2011 );
2012
2013 static void ShowBuildWaypointPicker(Window *parent)
2014 {
2015 new BuildRailWaypointWindow(&_build_waypoint_desc, parent);
2016 }
2017
2021 void InitializeRailGui()
2022 {
2023 _build_depot_direction = DIAGDIR_NW;
2024 _railstation.station_class = StationClassID::STAT_CLASS_DFLT;
2025 }
2026
2031 void ReinitGuiAfterToggleElrail(bool disable)
2032 {
2033 extern RailType _last_built_railtype;
2034 if (disable && _last_built_railtype == RAILTYPE_ELECTRIC) {
2035 _last_built_railtype = _cur_railtype = RAILTYPE_RAIL;
2036 BuildRailToolbarWindow *w = dynamic_cast<BuildRailToolbarWindow *>(FindWindowById(WC_BUILD_TOOLBAR, TRANSPORT_RAIL));
2037 if (w != nullptr) w->ModifyRailType(_cur_railtype);
2038 }
2039 MarkWholeScreenDirty();
2040 }
2041
2043 static void SetDefaultRailGui()
2044 {
2045 if (_local_company == COMPANY_SPECTATOR || !Company::IsValidID(_local_company)) return;
2046
2047 extern RailType _last_built_railtype;
2048 RailType rt;
2049 switch (_settings_client.gui.default_rail_type) {
2050 case 2: {
2051 /* Find the most used rail type */
2052 uint count[RAILTYPE_END];
2053 memset(count, 0, sizeof(count));
2054 for (TileIndex t = 0; t < MapSize(); t++) {
2055 if (IsTileType(t, MP_RAILWAY) || IsLevelCrossingTile(t) || HasStationTileRail(t) ||
2056 (IsTileType(t, MP_TUNNELBRIDGE) && GetTunnelBridgeTransportType(t) == TRANSPORT_RAIL)) {
2057 count[GetRailType(t)]++;
2058 }
2059 }
2060
2061 rt = static_cast<RailType>(std::max_element(count + RAILTYPE_BEGIN, count + RAILTYPE_END) - count);
2062 if (count[rt] > 0) break;
2063
2064 /* No rail, just get the first available one */
2065 FALLTHROUGH;
2066 }
2067 case 0: {
2068 /* Use first available type */
2069 std::vector<RailType>::const_iterator it = std::find_if(_sorted_railtypes.begin(), _sorted_railtypes.end(),
2070 [](RailType r){ return HasRailtypeAvail(_local_company, r); });
2071 rt = it != _sorted_railtypes.end() ? *it : RAILTYPE_BEGIN;
2072 break;
2073 }
2074 case 1: {
2075 /* Use last available type */
2076 std::vector<RailType>::const_reverse_iterator it = std::find_if(_sorted_railtypes.rbegin(), _sorted_railtypes.rend(),
2077 [](RailType r){ return HasRailtypeAvail(_local_company, r); });
2078 rt = it != _sorted_railtypes.rend() ? *it : RAILTYPE_BEGIN;
2079 break;
2080 }
2081 default:
2082 NOT_REACHED();
2083 }
2084
2085 _last_built_railtype = _cur_railtype = rt;
2086 BuildRailToolbarWindow *w = dynamic_cast<BuildRailToolbarWindow *>(FindWindowById(WC_BUILD_TOOLBAR, TRANSPORT_RAIL));
2087 if (w != nullptr) w->ModifyRailType(_cur_railtype);
2088 }
2089
2096 bool ResetSignalVariant(int32 p)
2097 {
2098 SignalVariant new_variant = (_cur_year < _settings_client.gui.semaphore_build_before ? SIG_SEMAPHORE : SIG_ELECTRIC);
2099
2100 if (new_variant != _cur_signal_variant) {
2101 Window *w = FindWindowById(WC_BUILD_SIGNAL, 0);
2102 if (w != nullptr) {
2103 w->SetDirty();
2104 w->RaiseWidget((_cur_signal_variant == SIG_ELECTRIC ? WID_BS_ELECTRIC_NORM : WID_BS_SEMAPHORE_NORM) + _cur_signal_type);
2105 }
2106 _cur_signal_variant = new_variant;
2107 }
2108
2109 return true;
2110 }
2111
2116 void InitializeRailGUI()
2117 {
2118 SetDefaultRailGui();
2119
2120 _convert_signal_button = false;
2121 _cur_signal_type = _default_signal_type[_settings_client.gui.default_signal_type];
2122 ResetSignalVariant();
2123 }
2124
2131 DropDownList GetRailTypeDropDownList(bool for_replacement, bool all_option)
2132 {
2133 RailTypes used_railtypes;
2134 RailTypes avail_railtypes;
2135
2136 const Company *c = Company::Get(_local_company);
2137
2138 /* Find the used railtypes. */
2139 if (for_replacement) {
2140 avail_railtypes = GetCompanyRailtypes(c->index, false);
2141 used_railtypes = GetRailTypes(false);
2142 } else {
2143 avail_railtypes = c->avail_railtypes;
2144 used_railtypes = GetRailTypes(true);
2145 }
2146
2147 DropDownList list;
2148
2149 if (all_option) {
2150 list.emplace_back(new DropDownListStringItem(STR_REPLACE_ALL_RAILTYPE, INVALID_RAILTYPE, false));
2151 }
2152
2153 Dimension d = { 0, 0 };
2154 RailType rt;
2155 /* Get largest icon size, to ensure text is aligned on each menu item. */
2156 if (!for_replacement) {
2157 FOR_ALL_SORTED_RAILTYPES(rt) {
2158 if (!HasBit(used_railtypes, rt)) continue;
2159 const RailtypeInfo *rti = GetRailTypeInfo(rt);
2160 d = maxdim(d, GetSpriteSize(rti->gui_sprites.build_x_rail));
2161 }
2162 }
2163
2164 FOR_ALL_SORTED_RAILTYPES(rt) {
2165 /* If it's not used ever, don't show it to the user. */
2166 if (!HasBit(used_railtypes, rt)) continue;
2167
2168 const RailtypeInfo *rti = GetRailTypeInfo(rt);
2169
2170 StringID str = for_replacement ? rti->strings.replace_text : (rti->max_speed > 0 ? STR_TOOLBAR_RAILTYPE_VELOCITY : STR_JUST_STRING);
2171 DropDownListParamStringItem *item;
2172 if (for_replacement) {
2173 item = new DropDownListParamStringItem(str, rt, !HasBit(avail_railtypes, rt));
2174 } else {
2175 DropDownListIconItem *iconitem = new DropDownListIconItem(rti->gui_sprites.build_x_rail, PAL_NONE, str, rt, !HasBit(avail_railtypes, rt));
2176 iconitem->SetDimension(d);
2177 item = iconitem;
2178 }
2179 item->SetParam(0, rti->strings.menu_text);
2180 item->SetParam(1, rti->max_speed);
2181 list.emplace_back(item);
2182 }
2183
2184 if (list.size() == 0) {
2185 /* Empty dropdowns are not allowed */
2186 list.emplace_back(new DropDownListStringItem(STR_NONE, INVALID_RAILTYPE, true));
2187 }
2188
2189 return list;
2190 }
SZSP_NONE
@ SZSP_NONE
Display plane with zero size in both directions (none filling and resizing).
Definition: widget_type.h:389
ES_HANDLED
@ ES_HANDLED
The passed event is handled.
Definition: window_type.h:718
WID_BRAS_PLATFORM_LEN_6
@ WID_BRAS_PLATFORM_LEN_6
Button to select 6 tiles length station platforms.
Definition: rail_widget.h:52
RailtypeInfo::gui_sprites
struct RailtypeInfo::@39 gui_sprites
struct containing the sprites for the rail GUI.
HT_DIR_HL
@ HT_DIR_HL
horizontal lower
Definition: tilehighlight_type.h:36
RailtypeInfo::rail_nwse
CursorID rail_nwse
Cursor for building rail in Y direction.
Definition: rail.h:165
BuildRailToolbarWindow::OnPlaceDrag
void OnPlaceDrag(ViewportPlaceMethod select_method, ViewportDragDropSelectionProcess select_proc, Point pt) override
The user is dragging over the map when the tile highlight mode has been set.
Definition: rail_gui.cpp:676
WID_BRAS_PLATFORM_DRAG_N_DROP
@ WID_BRAS_PLATFORM_DRAG_N_DROP
Button to enable drag and drop type station placement.
Definition: rail_widget.h:55
GUISettings::station_numtracks
byte station_numtracks
the number of platforms to default on for rail stations
Definition: settings_type.h:147
SetTileSelectSize
void SetTileSelectSize(int w, int h)
Highlight w by h tiles at the cursor.
Definition: viewport.cpp:2470
DIAGDIR_SE
@ DIAGDIR_SE
Southeast.
Definition: direction_type.h:80
DDSP_DEMOLISH_AREA
@ DDSP_DEMOLISH_AREA
Clear area.
Definition: viewport_type.h:116
tunnelbridge.h
_remove_button_clicked
static bool _remove_button_clicked
Flag whether 'remove' toggle-button is currently enabled.
Definition: rail_gui.cpp:49
CA_UNMODIFIED
@ CA_UNMODIFIED
Catchment for all stations with "modified catchment" disabled.
Definition: station_type.h:82
CMD_MSG
#define CMD_MSG(x)
Used to combine a StringID with the command.
Definition: command_type.h:372
TileIndex
uint32 TileIndex
The index/ID of a Tile.
Definition: tile_type.h:78
WID_RAT_DEMOLISH
@ WID_RAT_DEMOLISH
Destroy something with dynamite!
Definition: rail_widget.h:22
sound_func.h
DDSP_CONVERT_RAIL
@ DDSP_CONVERT_RAIL
Rail conversion.
Definition: viewport_type.h:132
GUISettings::station_dragdrop
bool station_dragdrop
whether drag and drop is enabled for stations
Definition: settings_type.h:149
BuildRailStationWindow::coverage_height
uint coverage_height
Height of the coverage texts.
Definition: rail_gui.cpp:894
WID_BS_SEMAPHORE_EXIT
@ WID_BS_SEMAPHORE_EXIT
Build a semaphore exit block signal.
Definition: rail_widget.h:83
RailToolbar_CtrlChanged
static bool RailToolbar_CtrlChanged(Window *w)
Updates the Remove button because of Ctrl state change.
Definition: rail_gui.cpp:306
RailtypeInfo::max_speed
uint16 max_speed
Maximum speed for vehicles travelling on this rail type.
Definition: rail.h:228
newgrf_station.h
DoCommand
CommandCost DoCommand(const CommandContainer *container, DoCommandFlag flags)
Shorthand for calling the long DoCommand with a container.
Definition: command.cpp:450
IsValidAxis
static bool IsValidAxis(Axis d)
Checks if an integer value is a valid Axis.
Definition: direction_func.h:43
GUISettings::station_show_coverage
bool station_show_coverage
whether to highlight coverage area
Definition: settings_type.h:150
Pool::PoolItem<&_company_pool >::Get
static Titem * Get(size_t index)
Returns Titem with given index.
Definition: pool_type.hpp:329
WC_BUILD_TOOLBAR
@ WC_BUILD_TOOLBAR
Build toolbar; Window numbers:
Definition: window_type.h:66
TileOffsByDiagDir
static TileIndexDiff TileOffsByDiagDir(DiagDirection dir)
Convert a DiagDirection to a TileIndexDiff.
Definition: map_func.h:341
GUISettings::drag_signals_fixed_distance
bool drag_signals_fixed_distance
keep fixed distance between signals when dragging
Definition: settings_type.h:141
VPM_FIX_VERTICAL
@ VPM_FIX_VERTICAL
drag only in vertical direction
Definition: viewport_type.h:103
BuildRailStationWindow::SelectClassAndStation
void SelectClassAndStation()
Checks if the previously selected current station class and station can be shown as selected to the u...
Definition: rail_gui.cpp:1082
GameSettings::station
StationSettings station
settings related to station management
Definition: settings_type.h:571
WD_MATRIX_RIGHT
@ WD_MATRIX_RIGHT
Offset at right of a matrix cell.
Definition: window_gui.h:77
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:2131
SetWindowDirty
void SetWindowDirty(WindowClass cls, WindowNumber number)
Mark window as dirty (in need of repainting)
Definition: window.cpp:3220
querystring_gui.h
DropDownListParamStringItem
String list item with parameters.
Definition: dropdown_type.h:56
SetScrollbar
static NWidgetPart SetScrollbar(int index)
Attach a scrollbar to a widget.
Definition: widget_type.h:1094
NewGRFClass::GetUISpecCount
uint GetUISpecCount() const
Get the number of potentially user-available specs within the class.
Definition: newgrf_class.h:46
HotkeyList
List of hotkeys for a window.
Definition: hotkeys.h:40
VpSetPresizeRange
void VpSetPresizeRange(TileIndex from, TileIndex to)
Highlights all tiles between a set of two tiles.
Definition: viewport.cpp:2707
BuildRailDepotWindow::DrawWidget
void DrawWidget(const Rect &r, int widget) const override
Draw the contents of a nested widget.
Definition: rail_gui.cpp:1852
GB
static uint GB(const T x, const uint8 s, const uint8 n)
Fetch n bits from x, started at bit s.
Definition: bitmath_func.hpp:32
WID_RAT_BUILD_SIGNALS
@ WID_RAT_BUILD_SIGNALS
Build signals.
Definition: rail_widget.h:26
WID_RAT_BUILD_Y
@ WID_RAT_BUILD_Y
Build rail along the game grid Y axis.
Definition: rail_widget.h:20
BuildSignalWindow::sig_sprite_size
Dimension sig_sprite_size
Maximum size of signal GUI sprites.
Definition: rail_gui.cpp:1626
Dimension
Dimensions (a width and height) of a rectangle in 2D.
Definition: geometry_type.hpp:27
command_func.h
RailtypeInfo::menu_text
StringID menu_text
Name of this rail type in the main toolbar dropdown.
Definition: rail.h:175
WWT_STICKYBOX
@ WWT_STICKYBOX
Sticky box (at top-right of a window, after WWT_DEFSIZEBOX)
Definition: widget_type.h:64
SetPadding
static NWidgetPart SetPadding(uint8 top, uint8 right, uint8 bottom, uint8 left)
Widget part function for setting additional space around a widget.
Definition: widget_type.h:1045
BuildSignalWindow
Definition: rail_gui.cpp:1624
GUIList::Sort
bool Sort(Comp compare)
Sort the list.
Definition: sortlist_type.h:247
Window::GetScrollbar
const Scrollbar * GetScrollbar(uint widnum) const
Return the Scrollbar to a widget index.
Definition: window.cpp:309
WID_RAT_CAPTION
@ WID_RAT_CAPTION
Caption of the window.
Definition: rail_widget.h:16
WDF_CONSTRUCTION
@ WDF_CONSTRUCTION
This window is used for construction; close it whenever changing company.
Definition: window_gui.h:208
WID_BRAD_DEPOT_SE
@ WID_BRAD_DEPOT_SE
Build a depot with the entrance in the south east.
Definition: rail_widget.h:103
Company::avail_railtypes
RailTypes avail_railtypes
Rail types available to this company.
Definition: company_base.h:115
StringFilter::IsEmpty
bool IsEmpty() const
Check whether any filter words were entered.
Definition: stringfilter_type.h:59
_cur_signal_type
static SignalType _cur_signal_type
set the signal type (for signal GUI)
Definition: rail_gui.cpp:55
DDSP_BUILD_STATION
@ DDSP_BUILD_STATION
Station placement.
Definition: viewport_type.h:130
WID_BRAS_SHOW_NEWST_MATRIX
@ WID_BRAS_SHOW_NEWST_MATRIX
Selection for newstation image matrix.
Definition: rail_widget.h:69
Window::ReInit
void ReInit(int rx=0, int ry=0)
Re-initialize a window, and optionally change its size.
Definition: window.cpp:995
company_base.h
RailtypeInfo::build_depot
SpriteID build_depot
button for building depots
Definition: rail.h:155
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
_cur_year
Year _cur_year
Current year, starting at 0.
Definition: date.cpp:26
TRANSPORT_RAIL
@ TRANSPORT_RAIL
Transport by train.
Definition: transport_type.h:27
tunnelbridge_map.h
StringFilter::SetFilterTerm
void SetFilterTerm(const char *str)
Set the term to filter on.
Definition: stringfilter.cpp:27
WD_MATRIX_TOP
@ WD_MATRIX_TOP
Offset at top of a matrix cell.
Definition: window_gui.h:78
_place_depot_extra_dir
static const DiagDirection _place_depot_extra_dir[12]
Direction to check for existing track pieces.
Definition: rail_gui.cpp:129
GetAxisForNewWaypoint
Axis GetAxisForNewWaypoint(TileIndex tile)
Get the axis for a new waypoint.
Definition: waypoint_cmd.cpp:97
Scrollbar::ScrollTowards
void ScrollTowards(int position)
Scroll towards the given position; if the item is visible nothing happens, otherwise it will be shown...
Definition: widget_type.h:730
WWT_CAPTION
@ WWT_CAPTION
Window caption (window title between closebox and stickybox)
Definition: widget_type.h:59
CBID_STATION_AVAILABILITY
@ CBID_STATION_AVAILABILITY
Determine whether a newstation should be made available to build.
Definition: newgrf_callbacks.h:39
NewGRFClass::GetSpecCount
uint GetSpecCount() const
Get the number of allocated specs within the class.
Definition: newgrf_class.h:44
CheckRedrawStationCoverage
void CheckRedrawStationCoverage(const Window *w)
Check whether we need to redraw the station coverage text.
Definition: station_gui.cpp:126
WID_BRAD_DEPOT_SW
@ WID_BRAD_DEPOT_SW
Build a depot with the entrance in the south west.
Definition: rail_widget.h:104
HandleAutoSignalPlacement
static void HandleAutoSignalPlacement()
Build new signals or remove signals or (if only one tile marked) edit a signal.
Definition: rail_gui.cpp:384
_cur_signal_variant
static SignalVariant _cur_signal_variant
set the signal variant (for signal GUI)
Definition: rail_gui.cpp:54
RailtypeInfo::convert
CursorID convert
Cursor for converting track.
Definition: rail.h:169
NWidgetMatrix
Matrix container with implicitly equal sized (virtual) sub-widgets.
Definition: widget_type.h:492
Scrollbar::GetScrolledRowFromWidget
int GetScrolledRowFromWidget(int clickpos, const Window *const w, int widget, int padding=0, int line_height=-1) const
Compute the row of a scrolled widget that a user clicked in.
Definition: widget.cpp:1966
BuildRailToolbarWindow::OnHotkey
EventState OnHotkey(int hotkey) override
A hotkey has been pressed.
Definition: rail_gui.cpp:609
WWT_IMGBTN
@ WWT_IMGBTN
(Toggle) Button with image
Definition: widget_type.h:50
GUIList< StationClassID, StringFilter & >
INVALID_ROADTYPE
@ INVALID_ROADTYPE
flag for invalid roadtype
Definition: road_type.h:27
BuildSignalWindow::UpdateWidgetSize
void UpdateWidgetSize(int widget, Dimension *size, const Dimension &padding, Dimension *fill, Dimension *resize) override
Update size and resize step of a widget in the window.
Definition: rail_gui.cpp:1683
_railstation
static RailStationGUISettings _railstation
Settings of the station builder GUI.
Definition: rail_gui.cpp:68
TRACK_LOWER
@ TRACK_LOWER
Track in the lower corner of the tile (south)
Definition: track_type.h:24
BuildRailStationWindow::UpdateWidgetSize
void UpdateWidgetSize(int widget, Dimension *size, const Dimension &padding, Dimension *fill, Dimension *resize) override
Update size and resize step of a widget in the window.
Definition: rail_gui.cpp:1177
CMD_REMOVE_SIGNALS
@ CMD_REMOVE_SIGNALS
remove a signal
Definition: command_type.h:185
RailtypeInfo::replace_text
StringID replace_text
Text used in the autoreplace GUI.
Definition: rail.h:177
WWT_LABEL
@ WWT_LABEL
Centered label.
Definition: widget_type.h:55
RAIL_TILE_SIGNALS
@ RAIL_TILE_SIGNALS
Normal rail tile with signals.
Definition: rail_map.h:25
DropDownList
std::vector< std::unique_ptr< const DropDownListItem > > DropDownList
A drop down list is a collection of drop down list items.
Definition: dropdown_type.h:100
SetRedErrorSquare
void SetRedErrorSquare(TileIndex tile)
Set a tile to display a red error square.
Definition: viewport.cpp:2452
WWT_DEFSIZEBOX
@ WWT_DEFSIZEBOX
Default window size box (at top-right of a window, between WWT_SHADEBOX and WWT_STICKYBOX)
Definition: widget_type.h:63
BuildSignalWindow::SetStringParameters
void SetStringParameters(int widget) const override
Initialize string parameters for a widget.
Definition: rail_gui.cpp:1694
Window::CreateNestedTree
void CreateNestedTree(bool fill_nested=true)
Perform the first part of the initialization of a nested widget tree.
Definition: window.cpp:1832
WDP_ALIGN_TOOLBAR
@ WDP_ALIGN_TOOLBAR
Align toward the toolbar.
Definition: window_gui.h:156
CMD_REMOVE_RAILROAD_TRACK
@ CMD_REMOVE_RAILROAD_TRACK
remove a rail track
Definition: command_type.h:177
WID_BRAS_PLATFORM_NUM_BEGIN
@ WID_BRAS_PLATFORM_NUM_BEGIN
Helper for determining the chosen platform width.
Definition: rail_widget.h:75
Pool::PoolItem::index
Tindex index
Index of this pool item.
Definition: pool_type.hpp:227
NWID_HORIZONTAL
@ NWID_HORIZONTAL
Horizontal container.
Definition: widget_type.h:73
WID_BS_SEMAPHORE_PBS_OWAY
@ WID_BS_SEMAPHORE_PBS_OWAY
Build a semaphore one way path signal.
Definition: rail_widget.h:86
PlaceRail_Waypoint
static void PlaceRail_Waypoint(TileIndex tile)
Place a rail waypoint.
Definition: rail_gui.cpp:157
TRACK_X
@ TRACK_X
Track along the x-axis (north-east to south-west)
Definition: track_type.h:21
WID_BRAS_HIGHLIGHT_ON
@ WID_BRAS_HIGHLIGHT_ON
Button for turning coverage highlighting on.
Definition: rail_widget.h:58
GUISettings::default_rail_type
uint8 default_rail_type
the default rail type for the rail GUI
Definition: settings_type.h:113
maxdim
Dimension maxdim(const Dimension &d1, const Dimension &d2)
Compute bounding box of both dimensions.
Definition: geometry_func.cpp:22
WWT_MATRIX
@ WWT_MATRIX
Grid of rows and columns.
Definition: widget_type.h:57
ANIMCURSOR_BUILDSIGNALS
static const CursorID ANIMCURSOR_BUILDSIGNALS
1292 - 1293 - build signal
Definition: sprites.h:1496
FindWindowById
Window * FindWindowById(WindowClass cls, WindowNumber number)
Find a window by its class and window number.
Definition: window.cpp:1133
WID_BS_ELECTRIC_NORM
@ WID_BS_ELECTRIC_NORM
Build an electric normal block signal.
Definition: rail_widget.h:87
CMD_BUILD_SINGLE_RAIL
@ CMD_BUILD_SINGLE_RAIL
build a single rail track
Definition: command_type.h:178
NWID_HORIZONTAL_LTR
@ NWID_HORIZONTAL_LTR
Horizontal container that doesn't change the order of the widgets for RTL languages.
Definition: widget_type.h:74
WID_RAT_AUTORAIL
@ WID_RAT_AUTORAIL
Autorail tool.
Definition: rail_widget.h:21
HasBit
static bool HasBit(const T x, const uint8 y)
Checks if a bit in a value is set.
Definition: bitmath_func.hpp:103
RailtypeInfo::rail_swne
CursorID rail_swne
Cursor for building rail in X direction.
Definition: rail.h:163
RailtypeInfo
This struct contains all the info that is needed to draw and construct tracks.
Definition: rail.h:124
PlaceProc_DemolishArea
void PlaceProc_DemolishArea(TileIndex tile)
Start a drag for demolishing an area.
Definition: terraform_gui.cpp:145
BuildRailDepotWindow::OnClick
void OnClick(Point pt, int widget, int click_count) override
A click with the left mouse button has been made on the window.
Definition: rail_gui.cpp:1859
BuildRailStationWindow::StationClassIDSorter
static bool StationClassIDSorter(StationClassID const &a, StationClassID const &b)
Sort station classes by StationClassID.
Definition: rail_gui.cpp:1034
WID_BRAD_DEPOT_NE
@ WID_BRAD_DEPOT_NE
Build a depot with the entrance in the north east.
Definition: rail_widget.h:102
RailStationGUISettings::station_type
byte station_type
Station type within the currently selected custom station class (if newstations is true )
Definition: rail_gui.cpp:65
Scrollbar::SetCount
void SetCount(int num)
Sets the number of elements in the list.
Definition: widget_type.h:669
WID_BRAS_PLATFORM_LEN_1
@ WID_BRAS_PLATFORM_LEN_1
Button to select single tile length station platforms.
Definition: rail_widget.h:47
_ctrl_pressed
bool _ctrl_pressed
Is Ctrl pressed?
Definition: gfx.cpp:35
MP_RAILWAY
@ MP_RAILWAY
A railway.
Definition: tile_type.h:42
FILLRECT_CHECKER
@ FILLRECT_CHECKER
Draw only every second pixel, used for greying-out.
Definition: gfx_type.h:288
SND_15_BEEP
@ SND_15_BEEP
19 == 0x13 GUI button click
Definition: sound_type.h:58
RailtypeInfo::build_tunnel
SpriteID build_tunnel
button for building a tunnel
Definition: rail.h:156
IsStationAvailable
static bool IsStationAvailable(const StationSpec *statspec)
Check whether a station type can be build.
Definition: rail_gui.cpp:81
RailtypeInfo::depot
CursorID depot
Cursor for building a depot.
Definition: rail.h:167
SetResize
static NWidgetPart SetResize(int16 dx, int16 dy)
Widget part function for setting the resize step.
Definition: widget_type.h:929
WID_BRAS_SHOW_NEWST_TYPE
@ WID_BRAS_SHOW_NEWST_TYPE
Display of selected station type.
Definition: rail_widget.h:71
SND_20_CONSTRUCTION_RAIL
@ SND_20_CONSTRUCTION_RAIL
30 == 0x1E Construction: rail infrastructure
Definition: sound_type.h:69
zoom_func.h
GetTrackBits
static TrackBits GetTrackBits(TileIndex tile)
Gets the track bits of the given tile.
Definition: rail_map.h:136
CommandContainer
Structure for buffering the build command when selecting a station to join.
Definition: command_type.h:479
RailtypeInfo::auto_rail
SpriteID auto_rail
button for the autorail construction
Definition: rail.h:154
VPM_FIX_Y
@ VPM_FIX_Y
drag only in Y axis
Definition: viewport_type.h:99
NWidgetMatrix::SetScrollbar
void SetScrollbar(Scrollbar *sb)
Assign a scrollbar to this matrix.
Definition: widget.cpp:1535
_settings_client
ClientSettings _settings_client
The current settings for this game.
Definition: settings.cpp:79
CMD_BUILD_SIGNALS
@ CMD_BUILD_SIGNALS
build a signal
Definition: command_type.h:184
DrawString
int DrawString(int left, int right, int top, const char *str, TextColour colour, StringAlignment align, bool underline, FontSize fontsize)
Draw string, possibly truncated to make it fit in its allocated space.
Definition: gfx.cpp:640
BuildRailToolbarWindow::OnClick
void OnClick(Point pt, int widget, int click_count) override
A click with the left mouse button has been made on the window.
Definition: rail_gui.cpp:517
ShowBuildRailToolbar
Window * ShowBuildRailToolbar(RailType railtype)
Open the build rail toolbar window for a specific rail type.
Definition: rail_gui.cpp:862
WWT_EMPTY
@ WWT_EMPTY
Empty widget, place holder to reserve space in widget array.
Definition: widget_type.h:46
ANIMCURSOR_DEMOLISH
static const CursorID ANIMCURSOR_DEMOLISH
704 - 707 - demolish dynamite
Definition: sprites.h:1492
DeleteWindowByClass
void DeleteWindowByClass(WindowClass cls)
Delete all windows of a given class.
Definition: window.cpp:1178
WWT_PUSHARROWBTN
@ WWT_PUSHARROWBTN
Normal push-button (no toggle button) with arrow caption.
Definition: widget_type.h:104
StringFilter::AddLine
void AddLine(const char *str)
Pass another text line from the current item to the filter.
Definition: stringfilter.cpp:104
BuildRailStationWindow::last_filtering
static Filtering last_filtering
Default filtering of GUIStationClassList.
Definition: rail_gui.cpp:903
DIAGDIR_NW
@ DIAGDIR_NW
Northwest.
Definition: direction_type.h:82
BuildRailToolbarWindow::last_user_action
int last_user_action
Last started user action.
Definition: rail_gui.cpp:425
CMD_REMOVE_FROM_RAIL_WAYPOINT
@ CMD_REMOVE_FROM_RAIL_WAYPOINT
remove a (rectangle of) tiles from a rail waypoint
Definition: command_type.h:195
WC_BUILD_STATION
@ WC_BUILD_STATION
Build station; Window numbers:
Definition: window_type.h:390
ToggleRailButton_Remove
static void ToggleRailButton_Remove(Window *w)
Toggles state of the Remove button of Build rail toolbar.
Definition: rail_gui.cpp:292
WID_RAT_BUILD_STATION
@ WID_RAT_BUILD_STATION
Build a station.
Definition: rail_widget.h:25
WID_BRAS_PLATFORM_LEN_4
@ WID_BRAS_PLATFORM_LEN_4
Button to select 4 tiles length station platforms.
Definition: rail_widget.h:50
ViewportPlaceMethod
ViewportPlaceMethod
Viewport place method (type of highlighted area and placed objects)
Definition: viewport_type.h:96
BuildSignalWindow::OnClick
void OnClick(Point pt, int widget, int click_count) override
A click with the left mouse button has been made on the window.
Definition: rail_gui.cpp:1715
BuildRailWaypointWindow::UpdateWidgetSize
void UpdateWidgetSize(int widget, Dimension *size, const Dimension &padding, Dimension *fill, Dimension *resize) override
Update size and resize step of a widget in the window.
Definition: rail_gui.cpp:1933
RailtypeInfo::build_ns_rail
SpriteID build_ns_rail
button for building single rail in N-S direction
Definition: rail.h:150
HT_DIR_Y
@ HT_DIR_Y
Y direction.
Definition: tilehighlight_type.h:34
NWID_MATRIX
@ NWID_MATRIX
Matrix container.
Definition: widget_type.h:76
Scrollbar
Scrollbar data structure.
Definition: widget_type.h:588
_cur_railtype
static RailType _cur_railtype
Rail type of the current build-rail toolbar.
Definition: rail_gui.cpp:48
GUISettings::drag_signals_density
byte drag_signals_density
many signals density
Definition: settings_type.h:140
Window::OnHotkey
virtual EventState OnHotkey(int hotkey)
A hotkey has been pressed.
Definition: window.cpp:610
SetDParam
static void SetDParam(uint n, uint64 v)
Set a string parameter v at index n in the global string parameter array.
Definition: strings_func.h:199
NWidgetPart
Partial widget specification to allow NWidgets to be written nested.
Definition: widget_type.h:909
WID_BRAS_PLATFORM_DIR_X
@ WID_BRAS_PLATFORM_DIR_X
Button to select '/' view.
Definition: rail_widget.h:36
TRACK_RIGHT
@ TRACK_RIGHT
Track in the right corner of the tile (east)
Definition: track_type.h:26
CMD_REMOVE_SIGNAL_TRACK
@ CMD_REMOVE_SIGNAL_TRACK
remove signals along a track (by dragging)
Definition: command_type.h:306
SetDataTip
static NWidgetPart SetDataTip(uint32 data, StringID tip)
Widget part function for setting the data and tooltip.
Definition: widget_type.h:1013
CMD_BUILD_RAILROAD_TRACK
@ CMD_BUILD_RAILROAD_TRACK
build a rail track
Definition: command_type.h:176
WID_BRAD_DEPOT_NW
@ WID_BRAD_DEPOT_NW
Build a depot with the entrance in the north west.
Definition: rail_widget.h:105
QueryString
Data stored about a string that can be modified in the GUI.
Definition: querystring_gui.h:20
CMD_BUILD_TUNNEL
@ CMD_BUILD_TUNNEL
build a tunnel
Definition: command_type.h:188
TRACK_BIT_UPPER
@ TRACK_BIT_UPPER
Upper track.
Definition: track_type.h:42
WID_BRAS_FILTER_CONTAINER
@ WID_BRAS_FILTER_CONTAINER
Container for the filter text box for the station class list.
Definition: rail_widget.h:65
WD_IMGBTN_BOTTOM
@ WD_IMGBTN_BOTTOM
Bottom offset of image in the button.
Definition: window_gui.h:41
CommandCost::Succeeded
bool Succeeded() const
Did this command succeed?
Definition: command_type.h:150
GetStringBoundingBox
Dimension GetStringBoundingBox(const char *str, FontSize start_fontsize)
Return the string dimension in pixels.
Definition: gfx.cpp:842
GUIList::SetFilterFuncs
void SetFilterFuncs(FilterFunction *const *n_funcs)
Hand the array of filter function pointers to the sort list.
Definition: sortlist_type.h:341
Textbuf::buf
char *const buf
buffer in which text is saved
Definition: textbuf_type.h:32
Window::querystrings
SmallMap< int, QueryString * > querystrings
QueryString associated to WWT_EDITBOX widgets.
Definition: window_gui.h:328
WID_BRAS_SHOW_NEWST_DEFSIZE
@ WID_BRAS_SHOW_NEWST_DEFSIZE
Selection for default-size button for newstation.
Definition: rail_widget.h:67
Window::OnPlaceMouseUp
virtual void OnPlaceMouseUp(ViewportPlaceMethod select_method, ViewportDragDropSelectionProcess select_proc, Point pt, TileIndex start_tile, TileIndex end_tile)
The user has dragged over the map when the tile highlight mode has been set.
Definition: window_gui.h:786
GetTileTrackStatus
TrackStatus GetTileTrackStatus(TileIndex tile, TransportType mode, uint sub_mode, DiagDirection side)
Returns information about trackdirs and signal states.
Definition: landscape.cpp:589
RAILTYPE_ELECTRIC
@ RAILTYPE_ELECTRIC
Electric rails.
Definition: rail_type.h:30
SignalType
SignalType
Type of signal, i.e.
Definition: signal_type.h:23
VPM_RAILDIRS
@ VPM_RAILDIRS
all rail directions
Definition: viewport_type.h:106
TRACK_BIT_RIGHT
@ TRACK_BIT_RIGHT
Right track.
Definition: track_type.h:45
IsInsideMM
static bool IsInsideMM(const T x, const size_t min, const size_t max)
Checks if a value is in an interval.
Definition: math_func.hpp:204
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:933
SpriteID
uint32 SpriteID
The number of a sprite, without mapping bits and colourtables.
Definition: gfx_type.h:17
WID_BS_DRAG_SIGNALS_DENSITY_DECREASE
@ WID_BS_DRAG_SIGNALS_DENSITY_DECREASE
Decrease the signal density.
Definition: rail_widget.h:95
NWidgetMatrix::SetCount
void SetCount(int count)
Set the number of elements in this matrix.
Definition: widget.cpp:1511
WindowDesc
High level window description.
Definition: window_gui.h:166
WID_BRAS_SHOW_NEWST_RESIZE
@ WID_BRAS_SHOW_NEWST_RESIZE
Selection for panel and resize at bottom right for newstation.
Definition: rail_widget.h:70
SIG_ELECTRIC
@ SIG_ELECTRIC
Light signal.
Definition: signal_type.h:17
GetRailTypeInfo
static const RailtypeInfo * GetRailTypeInfo(RailType railtype)
Returns a pointer to the Railtype information for a given railtype.
Definition: rail.h:304
ValParamRailtype
bool ValParamRailtype(const RailType rail)
Validate functions for rail building.
Definition: rail.cpp:206
RailtypeInfo::build_x_rail
SpriteID build_x_rail
button for building single rail in X direction
Definition: rail.h:151
window_gui.h
RailtypeInfo::rail_ns
CursorID rail_ns
Cursor for building rail in N-S direction.
Definition: rail.h:162
BuildRailStationWindow::EnsureSelectedStationClassIsVisible
void EnsureSelectedStationClassIsVisible()
Scrolls WID_BRAS_NEWST_SCROLL so that the selected station class is visible.
Definition: rail_gui.cpp:917
NC_EQUALSIZE
@ NC_EQUALSIZE
Value of the NCB_EQUALSIZE flag.
Definition: widget_type.h:428
WID_RAT_BUILD_X
@ WID_RAT_BUILD_X
Build rail along the game grid X axis.
Definition: rail_widget.h:18
TRACK_BIT_VERT
@ TRACK_BIT_VERT
Left and right track.
Definition: track_type.h:48
DIAGDIR_SW
@ DIAGDIR_SW
Southwest.
Definition: direction_type.h:81
SIGTYPE_PBS
@ SIGTYPE_PBS
normal pbs signal
Definition: signal_type.h:28
DDSP_PLACE_RAIL
@ DDSP_PLACE_RAIL
Rail placement.
Definition: viewport_type.h:128
AXIS_Y
@ AXIS_Y
The y axis.
Definition: direction_type.h:125
WID_BRAS_PLATFORM_NUM_6
@ WID_BRAS_PLATFORM_NUM_6
Button to select stations with 6 platforms.
Definition: rail_widget.h:44
WDP_AUTO
@ WDP_AUTO
Find a place automatically.
Definition: window_gui.h:154
Listing
Data structure describing how to show the list (what sort direction and criteria).
Definition: sortlist_type.h:30
MapSize
static uint MapSize()
Get the size of the map.
Definition: map_func.h:92
GUIList::SetFilterState
void SetFilterState(bool state)
Enable or disable the filter.
Definition: sortlist_type.h:302
WKC_GLOBAL_HOTKEY
@ WKC_GLOBAL_HOTKEY
Fake keycode bit to indicate global hotkeys.
Definition: gfx_type.h:33
RailType
RailType
Enumeration for all possible railtypes.
Definition: rail_type.h:27
IsBridgeTile
static bool IsBridgeTile(TileIndex t)
checks if there is a bridge on this tile
Definition: bridge_map.h:35
DRAW_STRING_BUFFER
static const int DRAW_STRING_BUFFER
Size of the buffer used for drawing strings.
Definition: gfx_func.h:85
STAT_CLASS_WAYP
@ STAT_CLASS_WAYP
Waypoint class.
Definition: newgrf_station.h:86
Window::resize
ResizeInfo resize
Resize information.
Definition: window_gui.h:322
RailtypeInfo::tunnel
SpriteID tunnel
tunnel sprites base
Definition: rail.h:142
CommandCost
Common return value for all commands.
Definition: command_type.h:23
TRACK_Y
@ TRACK_Y
Track along the y-axis (north-west to south-east)
Definition: track_type.h:22
SIGTYPE_NORMAL
@ SIGTYPE_NORMAL
normal signal
Definition: signal_type.h:24
RailStationGUISettings::newstations
bool newstations
Are custom station definitions available?
Definition: rail_gui.cpp:63
tilehighlight_func.h
BuildRailStationWindow::EDITBOX_MAX_SIZE
static const uint EDITBOX_MAX_SIZE
The maximum number of characters for the filter edit box.
Definition: rail_gui.cpp:900
ClientSettings::sound
SoundSettings sound
sound effect settings
Definition: settings_type.h:580
DoCommandP
bool DoCommandP(const CommandContainer *container, bool my_cmd)
Shortcut for the long DoCommandP when having a container with the data.
Definition: command.cpp:541
HT_DIR_VL
@ HT_DIR_VL
vertical left
Definition: tilehighlight_type.h:37
Window::InitNested
void InitNested(WindowNumber number=0)
Perform complete initialization of the Window with nested widgets, to allow use.
Definition: window.cpp:1861
WWT_EDITBOX
@ WWT_EDITBOX
a textbox for typing
Definition: widget_type.h:69
VPM_FIX_X
@ VPM_FIX_X
drag only in X axis
Definition: viewport_type.h:98
VpStartPlaceSizing
void VpStartPlaceSizing(TileIndex tile, ViewportPlaceMethod method, ViewportDragDropSelectionProcess process)
highlighting tiles while only going over them with the mouse
Definition: viewport.cpp:2652
GetRailTileType
static RailTileType GetRailTileType(TileIndex t)
Returns the RailTileType (normal with or without signals, waypoint or depot).
Definition: rail_map.h:36
_nested_build_depot_widgets
static const NWidgetPart _nested_build_depot_widgets[]
Nested widget definition of the build rail depot window.
Definition: rail_gui.cpp:1877
WID_RAT_BUILD_WAYPOINT
@ WID_RAT_BUILD_WAYPOINT
Build a waypoint.
Definition: rail_widget.h:24
GUISettings::cycle_signal_types
uint8 cycle_signal_types
what signal types to cycle with the build signal tool.
Definition: settings_type.h:146
TrackStatusToTrackBits
static TrackBits TrackStatusToTrackBits(TrackStatus ts)
Returns the present-track-information of a TrackStatus.
Definition: track_func.h:371
GUIList< StationClassID, StringFilter & >::SortFunction
bool SortFunction(const StationClassID &, const StationClassID &)
Signature of sort function.
Definition: sortlist_type.h:48
Window::SetDirty
void SetDirty() const
Mark entire window as dirty (in need of re-paint)
Definition: window.cpp:984
Convert8bitBooleanCallback
bool Convert8bitBooleanCallback(const GRFFile *grffile, uint16 cbid, uint16 cb_res)
Converts a callback result into a boolean.
Definition: newgrf_commons.cpp:569
GUIList::SetListing
void SetListing(Listing l)
Import sort conditions.
Definition: sortlist_type.h:130
WD_FRAMERECT_LEFT
@ WD_FRAMERECT_LEFT
Offset at left to draw the frame rectangular area.
Definition: window_gui.h:60
ShowStationBuilder
static void ShowStationBuilder(Window *parent)
Open station build window.
Definition: rail_gui.cpp:1618
HT_DIAGONAL
@ HT_DIAGONAL
Also allow 'diagonal rectangles'. Only usable in combination with HT_RECT or HT_POINT.
Definition: tilehighlight_type.h:28
SB
static T SB(T &x, const uint8 s, const uint8 n, const U d)
Set n bits in x starting at bit s to d.
Definition: bitmath_func.hpp:58
OrthogonalTileArea::w
uint16 w
The width of the area.
Definition: tilearea_type.h:18
PlaceRail_Bridge
static void PlaceRail_Bridge(TileIndex tile, Window *w)
Start placing a rail bridge.
Definition: rail_gui.cpp:266
WD_PAR_VSEP_NORMAL
@ WD_PAR_VSEP_NORMAL
Normal amount of vertical space between two paragraphs of text.
Definition: window_gui.h:137
CMD_BUILD_RAIL_WAYPOINT
@ CMD_BUILD_RAIL_WAYPOINT
build a waypoint
Definition: command_type.h:193
WD_FRAMERECT_RIGHT
@ WD_FRAMERECT_RIGHT
Offset at right to draw the frame rectangular area.
Definition: window_gui.h:61
ES_NOT_HANDLED
@ ES_NOT_HANDLED
The passed event is not handled.
Definition: window_type.h:719
CommandCost::Failed
bool Failed() const
Did this command fail?
Definition: command_type.h:159
HT_RAIL
@ HT_RAIL
autorail (one piece), lower bits: direction
Definition: tilehighlight_type.h:26
NWidgetBase
Baseclass for nested widgets.
Definition: widget_type.h:124
BuildRailToolbarWindow::SetStringParameters
void SetStringParameters(int widget) const override
Initialize string parameters for a widget.
Definition: rail_gui.cpp:503
GUISettings::enable_signal_gui
bool enable_signal_gui
show the signal GUI when the signal button is pressed
Definition: settings_type.h:135
TRACK_UPPER
@ TRACK_UPPER
Track in the upper corner of the tile (north)
Definition: track_type.h:23
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:684
VpSelectTilesWithMethod
void VpSelectTilesWithMethod(int x, int y, ViewportPlaceMethod method)
Selects tiles while dragging.
Definition: viewport.cpp:3137
BuildRailToolbarWindow
Rail toolbar management class.
Definition: rail_gui.cpp:423
OrthogonalTileArea
Represents the covered area of e.g.
Definition: tilearea_type.h:16
SetMatrixDataTip
static NWidgetPart SetMatrixDataTip(uint8 cols, uint8 rows, StringID tip)
Widget part function for setting the data and tooltip of WWT_MATRIX widgets.
Definition: widget_type.h:1031
NewGRFClass
Struct containing information relating to NewGRF classes for stations and airports.
Definition: newgrf_class.h:19
WID_RAT_BUILD_BRIDGE
@ WID_RAT_BUILD_BRIDGE
Build a bridge.
Definition: rail_widget.h:27
dropdown_type.h
WID_BS_SEMAPHORE_COMBO
@ WID_BS_SEMAPHORE_COMBO
Build a semaphore combo block signal.
Definition: rail_widget.h:84
_settings_game
GameSettings _settings_game
Game settings of a running game or the scenario editor.
Definition: settings.cpp:80
WID_BS_ELECTRIC_PBS
@ WID_BS_ELECTRIC_PBS
Build an electric path signal.
Definition: rail_widget.h:91
Filtering
Data structure describing what to show in the list (filter criteria).
Definition: sortlist_type.h:35
RailtypeInfo::autorail
CursorID autorail
Cursor for autorail tool.
Definition: rail.h:166
ShowSignalBuilder
static void ShowSignalBuilder(Window *parent)
Open the signal selection window.
Definition: rail_gui.cpp:1832
Window::SetWidgetDisabledState
void SetWidgetDisabledState(byte widget_index, bool disab_stat)
Sets the enabled/disabled status of a widget.
Definition: window_gui.h:392
Window::parent
Window * parent
Parent window.
Definition: window_gui.h:337
_local_company
CompanyID _local_company
Company controlled by the human player at this client. Can also be COMPANY_SPECTATOR.
Definition: company_cmd.cpp:46
DropDownListStringItem
Common string list item.
Definition: dropdown_type.h:39
HasStationTileRail
static bool HasStationTileRail(TileIndex t)
Has this station tile a rail? In other words, is this station tile a rail station or rail waypoint?
Definition: station_map.h:146
DiagdirReachesTracks
static TrackBits DiagdirReachesTracks(DiagDirection diagdir)
Returns all tracks that can be reached when entering a tile from a given (diagonal) direction.
Definition: track_func.h:581
BuildRailStationWindow::OnEditboxChanged
void OnEditboxChanged(int wid) override
The text in an editbox has been edited.
Definition: rail_gui.cpp:1118
safeguards.h
WID_BRAS_PLATFORM_NUM_7
@ WID_BRAS_PLATFORM_NUM_7
Button to select stations with 7 platforms.
Definition: rail_widget.h:45
sortlist_type.h
WID_BRAS_PLATFORM_LEN_5
@ WID_BRAS_PLATFORM_LEN_5
Button to select 5 tiles length station platforms.
Definition: rail_widget.h:51
StationSpec::name
StringID name
Name of this station.
Definition: newgrf_station.h:126
HandlePlacePushButton
bool HandlePlacePushButton(Window *w, int widget, CursorID cursor, HighLightStyle mode)
This code is shared for the majority of the pushbuttons.
Definition: main_gui.cpp:61
Window::left
int left
x position of left edge of the window
Definition: window_gui.h:317
WC_BUILD_BRIDGE
@ WC_BUILD_BRIDGE
Build bridge; Window numbers:
Definition: window_type.h:382
RailToolbarGlobalHotkeys
static EventState RailToolbarGlobalHotkeys(int hotkey)
Handler for global hotkeys of the BuildRailToolbarWindow.
Definition: rail_gui.cpp:774
TRACK_LEFT
@ TRACK_LEFT
Track in the left corner of the tile (west)
Definition: track_type.h:25
CMD_REMOVE_SINGLE_RAIL
@ CMD_REMOVE_SINGLE_RAIL
remove a single rail track
Definition: command_type.h:179
WID_RAT_CONVERT_RAIL
@ WID_RAT_CONVERT_RAIL
Convert other rail to this type.
Definition: rail_widget.h:30
DDSP_BUILD_BRIDGE
@ DDSP_BUILD_BRIDGE
Bridge placement.
Definition: viewport_type.h:125
_nested_build_waypoint_widgets
static const NWidgetPart _nested_build_waypoint_widgets[]
Nested widget definition for the build NewGRF rail waypoint window.
Definition: rail_gui.cpp:1989
TileHighlightData::pos
Point pos
Location, in tile "units", of the northern tile of the selected area.
Definition: tilehighlight_type.h:47
DrawSprite
void DrawSprite(SpriteID img, PaletteID pal, int x, int y, const SubSprite *sub, ZoomLevel zoom)
Draw a sprite, not in a viewport.
Definition: gfx.cpp:978
MP_TUNNELBRIDGE
@ MP_TUNNELBRIDGE
Tunnel entry/exit and bridge heads.
Definition: tile_type.h:50
WID_BS_DRAG_SIGNALS_DENSITY_LABEL
@ WID_BS_DRAG_SIGNALS_DENSITY_LABEL
The current signal density.
Definition: rail_widget.h:94
WID_RAT_BUILD_TUNNEL
@ WID_RAT_BUILD_TUNNEL
Build a tunnel.
Definition: rail_widget.h:28
waypoint_func.h
Point
Coordinates of a point in 2D.
Definition: geometry_type.hpp:21
BuildRailStationWindow
Definition: rail_gui.cpp:891
DiagDirection
DiagDirection
Enumeration for diagonal directions.
Definition: direction_type.h:77
BuildRailStationWindow::string_filter
StringFilter string_filter
Filter for available station classes.
Definition: rail_gui.cpp:907
CBM_STATION_AVAIL
@ CBM_STATION_AVAIL
Availability of station in construction window.
Definition: newgrf_callbacks.h:303
HT_DIR_MASK
@ HT_DIR_MASK
masks the drag-direction
Definition: tilehighlight_type.h:40
StationSettings::station_spread
byte station_spread
amount a station may spread
Definition: settings_type.h:536
BuildRailStationWindow::BuildStationClassesAvailable
void BuildStationClassesAvailable()
Builds the filter list of available station classes.
Definition: rail_gui.cpp:1051
date_func.h
TRACK_BIT_LOWER
@ TRACK_BIT_LOWER
Lower track.
Definition: track_type.h:43
StationSpec::disallowed_platforms
byte disallowed_platforms
Bitmask of number of platforms available for the station.
Definition: newgrf_station.h:132
Window::SetFocusedWidget
bool SetFocusedWidget(int widget_index)
Set focus within this window to the given widget.
Definition: window.cpp:495
stdafx.h
PC_BLACK
static const uint8 PC_BLACK
Black palette colour.
Definition: gfx_func.h:206
WID_BRAS_MATRIX_SCROLL
@ WID_BRAS_MATRIX_SCROLL
Scrollbar of the matrix widget.
Definition: rail_widget.h:63
CMD_BUILD_TRAIN_DEPOT
@ CMD_BUILD_TRAIN_DEPOT
build a train depot
Definition: command_type.h:183
BuildRailStationWindow::vscroll
Scrollbar * vscroll
Vertical scrollbar of the new station list.
Definition: rail_gui.cpp:895
GUISettings::link_terraform_toolbar
bool link_terraform_toolbar
display terraform toolbar when displaying rail, road, water and airport toolbars
Definition: settings_type.h:104
GfxFillRect
void GfxFillRect(int left, int top, int right, int bottom, int colour, FillRectMode mode)
Applies a certain FillRectMode-operation to a rectangle [left, right] x [top, bottom] on the screen.
Definition: gfx.cpp:114
RailtypeInfo::toolbar_caption
StringID toolbar_caption
Caption in the construction toolbar GUI for this rail type.
Definition: rail.h:174
CMD_REMOVE_FROM_RAIL_STATION
@ CMD_REMOVE_FROM_RAIL_STATION
remove a (rectangle of) tiles from a rail station
Definition: command_type.h:190
BuildRailStationWindow::vscroll2
Scrollbar * vscroll2
Vertical scrollbar of the matrix with new stations.
Definition: rail_gui.cpp:896
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:3261
NWidgetStacked::SetDisplayedPlane
void SetDisplayedPlane(int plane)
Select which plane to show (for NWID_SELECTION only).
Definition: widget.cpp:1091
viewport_func.h
NWidgetBase::current_y
uint current_y
Current vertical size (after resizing).
Definition: widget_type.h:173
NWidgetStacked
Stacked widgets, widgets all occupying the same space in the window.
Definition: widget_type.h:404
WC_NONE
@ WC_NONE
No window, redirects to WC_MAIN_WINDOW.
Definition: window_type.h:38
IsTileType
static bool IsTileType(TileIndex tile, TileType type)
Checks if a tile is a given tiletype.
Definition: tile_map.h:150
RailStationGUISettings
Definition: rail_gui.cpp:60
GetDigitWidth
byte GetDigitWidth(FontSize size)
Return the maximum width of single digit.
Definition: gfx.cpp:1308
ShowSelectStationIfNeeded
void ShowSelectStationIfNeeded(const CommandContainer &cmd, TileArea ta)
Show the station selection window when needed.
Definition: station_gui.cpp:2459
NWID_VERTICAL
@ NWID_VERTICAL
Vertical container.
Definition: widget_type.h:75
WID_BS_SEMAPHORE_NORM
@ WID_BS_SEMAPHORE_NORM
Build a semaphore normal block signal.
Definition: rail_widget.h:81
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:1616
WC_BUILD_DEPOT
@ WC_BUILD_DEPOT
Build depot; Window numbers:
Definition: window_type.h:410
WID_RAT_BUILD_EW
@ WID_RAT_BUILD_EW
Build rail along the game view X axis.
Definition: rail_widget.h:19
OrthogonalTileArea::h
uint16 h
The height of the area.
Definition: tilearea_type.h:19
GetSpriteSize
Dimension GetSpriteSize(SpriteID sprid, Point *offset, ZoomLevel zoom)
Get the size of a sprite.
Definition: gfx.cpp:913
WWT_CLOSEBOX
@ WWT_CLOSEBOX
Close box (at top-left of a window)
Definition: widget_type.h:67
WWT_RESIZEBOX
@ WWT_RESIZEBOX
Resize box (normally at bottom-right of a window)
Definition: widget_type.h:66
RAILTYPE_RAIL
@ RAILTYPE_RAIL
Standard non-electric rails.
Definition: rail_type.h:29
_signal_builder_desc
static WindowDesc _signal_builder_desc(WDP_AUTO, "build_signal", 0, 0, WC_BUILD_SIGNAL, WC_BUILD_TOOLBAR, WDF_CONSTRUCTION, _nested_signal_builder_widgets, lengthof(_nested_signal_builder_widgets))
Signal selection window description.
GUIList::NeedRebuild
bool NeedRebuild() const
Check if a rebuild is needed.
Definition: sortlist_type.h:362
WID_BS_ELECTRIC_PBS_OWAY
@ WID_BS_ELECTRIC_PBS_OWAY
Build an electric one way path signal.
Definition: rail_widget.h:92
ShowBuildBridgeWindow
void ShowBuildBridgeWindow(TileIndex start, TileIndex end, TransportType transport_type, byte road_rail_type)
Prepare the data for the build a bridge window.
Definition: bridge_gui.cpp:361
TileHighlightData::drawstyle
HighLightStyle drawstyle
Lower bits 0-3 are reserved for detailed highlight information.
Definition: tilehighlight_type.h:64
BuildRailStationWindow::sorter_funcs
static GUIStationClassList::SortFunction *const sorter_funcs[]
Sort functions of the GUIStationClassList.
Definition: rail_gui.cpp:904
DrawStationCoverageAreaText
int DrawStationCoverageAreaText(int left, int right, int top, StationCoverageType sct, int rad, bool supplies)
Calculates and draws the accepted or supplied cargo around the selected tile(s)
Definition: station_gui.cpp:54
BuildRailWaypointWindow::DrawWidget
void DrawWidget(const Rect &r, int widget) const override
Draw the contents of a nested widget.
Definition: rail_gui.cpp:1952
string_func.h
spritecache.h
SCT_ALL
@ SCT_ALL
Draw all cargoes.
Definition: station_gui.h:22
CALLBACK_FAILED
static const uint CALLBACK_FAILED
Different values for Callback result evaluations.
Definition: newgrf_callbacks.h:404
TRACK_BIT_HORZ
@ TRACK_BIT_HORZ
Upper and lower track.
Definition: track_type.h:47
rail_gui.h
StringID
uint32 StringID
Numeric value that represents a string, independent of the selected language.
Definition: strings_type.h:16
SoundSettings::confirm
bool confirm
Play sound effect on successful constructions or other actions.
Definition: settings_type.h:197
WID_BRW_WAYPOINT_MATRIX
@ WID_BRW_WAYPOINT_MATRIX
Matrix with waypoints.
Definition: rail_widget.h:110
RailStationGUISettings::station_class
StationClassID station_class
Currently selected custom station class (if newstations is true )
Definition: rail_gui.cpp:64
TileHighlightData::selstart
Point selstart
The location where the dragging started.
Definition: tilehighlight_type.h:60
WID_RAT_REMOVE
@ WID_RAT_REMOVE
Bulldozer to remove rail.
Definition: rail_widget.h:29
vehicle_func.h
WC_GAME_OPTIONS
@ WC_GAME_OPTIONS
Game options window; Window numbers:
Definition: window_type.h:606
GenericPlaceSignals
static void GenericPlaceSignals(TileIndex tile)
Build a new signal or edit/remove a present signal, use CmdBuildSingleSignal() or CmdRemoveSingleSign...
Definition: rail_gui.cpp:215
_convert_signal_button
static bool _convert_signal_button
convert signal button in the signal GUI pressed
Definition: rail_gui.cpp:53
EndContainer
static NWidgetPart EndContainer()
Widget part function for denoting the end of a container (horizontal, vertical, WWT_FRAME,...
Definition: widget_type.h:998
WC_SELECT_STATION
@ WC_SELECT_STATION
Select station (when joining stations); Window numbers:
Definition: window_type.h:235
SignalVariant
SignalVariant
Variant of the signal, i.e.
Definition: signal_type.h:16
BuildRailStationWindow::DrawWidget
void DrawWidget(const Rect &r, int widget) const override
Draw the contents of a nested widget.
Definition: rail_gui.cpp:1232
GetRailTypes
RailTypes GetRailTypes(bool introduces)
Get list of rail types, regardless of company availability.
Definition: rail.cpp:282
WID_BRAS_COVERAGE_TEXTS
@ WID_BRAS_COVERAGE_TEXTS
Empty space for the coverage texts.
Definition: rail_widget.h:59
SIGTYPE_PBS_ONEWAY
@ SIGTYPE_PBS_ONEWAY
no-entry signal
Definition: signal_type.h:29
strings_func.h
_cur_waypoint_type
static byte _cur_waypoint_type
Currently selected waypoint type.
Definition: rail_gui.cpp:52
NWID_VSCROLLBAR
@ NWID_VSCROLLBAR
Vertical scrollbar.
Definition: widget_type.h:82
BuildSignalWindow::OnInit
void OnInit() override
Notification that the nested widget tree gets initialized.
Definition: rail_gui.cpp:1663
StationSpec
Station specification.
Definition: newgrf_station.h:117
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:112
terraform_gui.h
DeleteWindowById
void DeleteWindowById(WindowClass cls, WindowNumber number, bool force)
Delete a window by its class and window number (if it is open).
Definition: window.cpp:1165
Window::IsShaded
bool IsShaded() const
Is window shaded currently?
Definition: window_gui.h:524
TRACK_BIT_LEFT
@ TRACK_BIT_LEFT
Left track.
Definition: track_type.h:44
NWidgetBase::pos_x
int pos_x
Horizontal position of top-left corner of the widget in the window.
Definition: widget_type.h:175
WC_BUILD_WAYPOINT
@ WC_BUILD_WAYPOINT
Build waypoint; Window numbers:
Definition: window_type.h:416
WID_BRAS_PLATFORM_LEN_3
@ WID_BRAS_PLATFORM_LEN_3
Button to select 3 tiles length station platforms.
Definition: rail_widget.h:49
WIDGET_LIST_END
static const int WIDGET_LIST_END
indicate the end of widgets' list for vararg functions
Definition: widget_type.h:20
VPM_Y_LIMITED
@ VPM_Y_LIMITED
Drag only in Y axis with limited size.
Definition: viewport_type.h:105
_build_depot_direction
static DiagDirection _build_depot_direction
Currently selected depot direction.
Definition: rail_gui.cpp:50
WWT_TEXT
@ WWT_TEXT
Pure simple text.
Definition: widget_type.h:56
BuildSignalWindow::DrawSignalSprite
void DrawSignalSprite(byte widget_index, SpriteID image) const
Draw dynamic a signal-sprite in a button in the signal GUI Draw the sprite +1px to the right and down...
Definition: rail_gui.cpp:1636
BuildRailStationWindow::filter_funcs
static GUIStationClassList::FilterFunction *const filter_funcs[]
Filter functions of the GUIStationClassList.
Definition: rail_gui.cpp:905
FONT_HEIGHT_NORMAL
#define FONT_HEIGHT_NORMAL
Height of characters in the normal (FS_NORMAL) font.
Definition: gfx_func.h:179
WC_SCEN_LAND_GEN
@ WC_SCEN_LAND_GEN
Landscape generation (in Scenario Editor); Window numbers:
Definition: window_type.h:442
HT_LINE
@ HT_LINE
used for autorail highlighting (longer stretches), lower bits: direction
Definition: tilehighlight_type.h:25
WID_BRW_SCROLL
@ WID_BRW_SCROLL
Scrollbar for the matrix.
Definition: rail_widget.h:112
ScaleGUITrad
static int ScaleGUITrad(int value)
Scale traditional pixel dimensions to GUI zoom level.
Definition: zoom_func.h:76
NWidget
static NWidgetPart NWidget(WidgetType tp, Colours col, int16 idx=-1)
Widget part function for starting a new 'real' widget.
Definition: widget_type.h:1113
COMPANY_SPECTATOR
@ COMPANY_SPECTATOR
The client is spectating.
Definition: company_type.h:35
RAILTYPE_END
@ RAILTYPE_END
Used for iterations.
Definition: rail_type.h:33
WID_BRW_WAYPOINT
@ WID_BRW_WAYPOINT
A single waypoint.
Definition: rail_widget.h:111
Scrollbar::IsVisible
bool IsVisible(uint16 item) const
Checks whether given current item is visible in the list.
Definition: widget_type.h:640
geometry_func.hpp
GUIList< StationClassID, StringFilter & >::FilterFunction
bool CDECL FilterFunction(const StationClassID *, StringFilter &)
Signature of filter function.
Definition: sortlist_type.h:49
OrthogonalTileArea::tile
TileIndex tile
The base tile of the area.
Definition: tilearea_type.h:17
GUISettings::semaphore_build_before
Year semaphore_build_before
build semaphore signals automatically before this year
Definition: settings_type.h:142
WID_BRAS_FILTER_EDITBOX
@ WID_BRAS_FILTER_EDITBOX
Filter text box for the station class list.
Definition: rail_widget.h:66
ResetSignalVariant
bool ResetSignalVariant(int32 p)
Updates the current signal variant used in the signal GUI to the one adequate to current year.
Definition: rail_gui.cpp:2096
SetMinimalSize
static NWidgetPart SetMinimalSize(int16 x, int16 y)
Widget part function for setting the minimal size.
Definition: widget_type.h:946
WID_BRAS_NEWST_LIST
@ WID_BRAS_NEWST_LIST
List with available newstation classes.
Definition: rail_widget.h:72
_build_tunnel_endtile
TileIndex _build_tunnel_endtile
The end of a tunnel; as hidden return from the tunnel build command for GUI purposes.
Definition: tunnelbridge_cmd.cpp:50
InitializeRailGui
void InitializeRailGui()
Initialize rail building GUI settings.
Definition: rail_gui.cpp:2021
StringFilter::ResetState
void ResetState()
Reset the matching state to process a new item.
Definition: stringfilter.cpp:88
WWT_PANEL
@ WWT_PANEL
Simple depressed panel.
Definition: widget_type.h:48
MarkTileDirtyByTile
void MarkTileDirtyByTile(TileIndex tile, int bridge_level_offset, int tile_height_override)
Mark a tile given by its index dirty for repaint.
Definition: viewport.cpp:1985
WID_BS_SEMAPHORE_PBS
@ WID_BS_SEMAPHORE_PBS
Build a semaphore path signal.
Definition: rail_widget.h:85
BuildRailDepotWindow
Definition: rail_gui.cpp:1837
GetCompanyRailtypes
RailTypes GetCompanyRailtypes(CompanyID company, bool introduces)
Get the rail types the given company can build.
Definition: rail.cpp:251
BuildRailStationWindow::line_height
uint line_height
Height of a single line in the newstation selection matrix (WID_BRAS_NEWST_LIST widget).
Definition: rail_gui.cpp:893
GetRailType
static RailType GetRailType(TileIndex t)
Gets the rail type of the given tile.
Definition: rail_map.h:115
Window::IsWidgetLowered
bool IsWidgetLowered(byte widget_index) const
Gets the lowered state of a widget.
Definition: window_gui.h:493
PlaceRail_Station
static void PlaceRail_Station(TileIndex tile)
Place a rail station.
Definition: rail_gui.cpp:189
StationClassID
StationClassID
Definition: newgrf_station.h:83
EventState
EventState
State of handling an event.
Definition: window_type.h:717
HT_RECT
@ HT_RECT
rectangle (stations, depots, ...)
Definition: tilehighlight_type.h:21
VPM_FIX_HORIZONTAL
@ VPM_FIX_HORIZONTAL
drag only in horizontal direction
Definition: viewport_type.h:102
VPM_X_AND_Y
@ VPM_X_AND_Y
area of land in X and Y directions
Definition: viewport_type.h:100
WID_BRAS_HIGHLIGHT_OFF
@ WID_BRAS_HIGHLIGHT_OFF
Button for turning coverage highlighting off.
Definition: rail_widget.h:57
FOR_ALL_SORTED_RAILTYPES
#define FOR_ALL_SORTED_RAILTYPES(var)
Loop header for iterating over railtypes, sorted by sortorder.
Definition: rail.h:471
GUIList::SetFiltering
void SetFiltering(Filtering f)
Import filter conditions.
Definition: sortlist_type.h:181
StringFilter::GetState
bool GetState() const
Get the matching state of the current item.
Definition: stringfilter_type.h:69
WD_IMGBTN_TOP
@ WD_IMGBTN_TOP
Top offset of image in the button.
Definition: window_gui.h:40
WID_BRAS_PLATFORM_NUM_5
@ WID_BRAS_PLATFORM_NUM_5
Button to select stations with 5 platforms.
Definition: rail_widget.h:43
WID_BRAS_PLATFORM_NUM_2
@ WID_BRAS_PLATFORM_NUM_2
Button to select stations with 2 platforms.
Definition: rail_widget.h:40
NewGRFClass::name
StringID name
Name of this class.
Definition: newgrf_class.h:39
BuildRailToolbarWindow::OnCTRLStateChange
EventState OnCTRLStateChange() override
The state of the control key has changed.
Definition: rail_gui.cpp:759
GUIList::Filter
bool Filter(FilterFunction *decide, F filter_data)
Filter the list.
Definition: sortlist_type.h:318
BuildRailWaypointWindow::OnClick
void OnClick(Point pt, int widget, int click_count) override
A click with the left mouse button has been made on the window.
Definition: rail_gui.cpp:1967
Window::FinishInitNested
void FinishInitNested(WindowNumber window_number=0)
Perform the second part of the initialization of a nested widget tree.
Definition: window.cpp:1848
DC_AUTO
@ DC_AUTO
don't allow building on structures
Definition: command_type.h:349
NWID_SPACER
@ NWID_SPACER
Invisible widget that takes some space.
Definition: widget_type.h:77
CcBuildRailTunnel
void CcBuildRailTunnel(const CommandCost &result, TileIndex tile, uint32 p1, uint32 p2, uint32 cmd)
Command callback for building a tunnel.
Definition: rail_gui.cpp:278
HT_DRAG_MASK
@ HT_DRAG_MASK
Mask for the tile drag-type modes.
Definition: tilehighlight_type.h:29
RailtypeInfo::strings
struct RailtypeInfo::@41 strings
Strings associated with the rail type.
company_func.h
PickerWindowBase
Base class for windows opened from a toolbar.
Definition: window_gui.h:853
FindFirstTrack
static Track FindFirstTrack(TrackBits tracks)
Returns first Track from TrackBits or INVALID_TRACK.
Definition: track_func.h:185
WID_BRAS_IMAGE
@ WID_BRAS_IMAGE
Panel used at each cell of the matrix.
Definition: rail_widget.h:62
SetViewportCatchmentStation
void SetViewportCatchmentStation(const Station *st, bool sel)
Select or deselect station for coverage area highlight.
Definition: viewport.cpp:3522
IsLevelCrossingTile
static bool IsLevelCrossingTile(TileIndex t)
Return whether a tile is a level crossing tile.
Definition: road_map.h:94
Window::top
int top
y position of top edge of the window
Definition: window_gui.h:318
BuildRailStationWindow::OnResize
void OnResize() override
Called after the window got resized.
Definition: rail_gui.cpp:1305
WID_BS_CONVERT
@ WID_BS_CONVERT
Convert the signal.
Definition: rail_widget.h:93
TileArea
OrthogonalTileArea TileArea
Shorthand for the much more common orthogonal tile area.
Definition: tilearea_type.h:96
rail_widget.h
RailtypeInfo::build_ew_rail
SpriteID build_ew_rail
button for building single rail in E-W direction
Definition: rail.h:152
TrackBits
TrackBits
Bitfield corresponding to Track.
Definition: track_type.h:38
BuildRailWaypointWindow
Definition: rail_gui.cpp:1919
DDSP_BUILD_SIGNALS
@ DDSP_BUILD_SIGNALS
Signal placement.
Definition: viewport_type.h:129
WD_MATRIX_BOTTOM
@ WD_MATRIX_BOTTOM
Offset at bottom of a matrix cell.
Definition: window_gui.h:79
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:1627
station_map.h
BuildRailToolbarWindow::OnPlacePresize
void OnPlacePresize(Point pt, TileIndex tile) override
The user moves over the map when a tile highlight mode has been set when the special mouse mode has b...
Definition: rail_gui.cpp:753
window_func.h
BuildRailStationWindow::station_classes
GUIStationClassList station_classes
Available station classes.
Definition: rail_gui.cpp:906
GUIList::ForceRebuild
void ForceRebuild()
Force that a rebuild is needed.
Definition: sortlist_type.h:370
Window::ToggleWidgetLoweredState
void ToggleWidgetLoweredState(byte widget_index)
Invert the lowered/raised status of a widget.
Definition: window_gui.h:463
SoundSettings::click_beep
bool click_beep
Beep on a random selection of buttons.
Definition: settings_type.h:198
BuildSignalWindow::OnInvalidateData
void OnInvalidateData(int data=0, bool gui_scope=true) override
Some data on this window has become invalid.
Definition: rail_gui.cpp:1772
CMD_CONVERT_RAIL
@ CMD_CONVERT_RAIL
convert a rail type
Definition: command_type.h:191
lengthof
#define lengthof(x)
Return the length of an fixed size array.
Definition: stdafx.h:367
VPM_X_LIMITED
@ VPM_X_LIMITED
Drag only in X axis with limited size.
Definition: viewport_type.h:104
_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:122
StationSpec::grf_prop
GRFFilePropsBase< NUM_CARGO+3 > grf_prop
Properties related the the grf file.
Definition: newgrf_station.h:124
stringfilter_type.h
NewGRFClass::Get
static NewGRFClass * Get(Tid cls_id)
Get a particular class.
Definition: newgrf_class_func.h:103
ShowTerraformToolbar
Window * ShowTerraformToolbar(Window *link)
Show the toolbar for terraforming in the game.
Definition: terraform_gui.cpp:356
Scrollbar::SetCapacityFromWidget
void SetCapacityFromWidget(Window *w, int widget, int padding=0)
Set capacity of visible elements from the size and resize properties of a widget.
Definition: widget.cpp:1980
MarkWholeScreenDirty
void MarkWholeScreenDirty()
This function mark the whole screen as dirty.
Definition: gfx.cpp:1597
WID_BS_ELECTRIC_EXIT
@ WID_BS_ELECTRIC_EXIT
Build an electric exit block signal.
Definition: rail_widget.h:89
CA_TRAIN
@ CA_TRAIN
Catchment for train stations with "modified catchment" enabled.
Definition: station_type.h:79
WID_BRAS_PLATFORM_NUM_4
@ WID_BRAS_PLATFORM_NUM_4
Button to select stations with 4 platforms.
Definition: rail_widget.h:42
GUISettings::auto_remove_signals
bool auto_remove_signals
automatically remove signals when in the way during rail construction
Definition: settings_type.h:159
SetPIP
static NWidgetPart SetPIP(uint8 pre, uint8 inter, uint8 post)
Widget part function for setting a pre/inter/post spaces.
Definition: widget_type.h:1075
NWidgetBase::pos_y
int pos_y
Vertical position of top-left corner of the widget in the window.
Definition: widget_type.h:176
INVALID_TILE
static const TileIndex INVALID_TILE
The very nice invalid tile marker.
Definition: tile_type.h:83
GUISettings::station_platlength
byte station_platlength
the platform length, in tiles, for rail stations
Definition: settings_type.h:148
WID_BS_DRAG_SIGNALS_DENSITY_INCREASE
@ WID_BS_DRAG_SIGNALS_DENSITY_INCREASE
Increase the signal density.
Definition: rail_widget.h:96
_nested_signal_builder_widgets
static const NWidgetPart _nested_signal_builder_widgets[]
Nested widget definition of the build signal window.
Definition: rail_gui.cpp:1785
Axis
Axis
Allow incrementing of DiagDirDiff variables.
Definition: direction_type.h:123
engine_base.h
WID_BS_ELECTRIC_COMBO
@ WID_BS_ELECTRIC_COMBO
Build an electric combo block signal.
Definition: rail_widget.h:90
SetFill
static NWidgetPart SetFill(uint fill_x, uint fill_y)
Widget part function for setting filling.
Definition: widget_type.h:982
InitializeRailGUI
void InitializeRailGUI()
Resets the rail GUI - sets default railtype to build and resets the signal GUI.
Definition: rail_gui.cpp:2116
BuildRailStationWindow::last_sorting
static Listing last_sorting
Default sorting of GUIStationClassList.
Definition: rail_gui.cpp:902
GetOtherTunnelBridgeEnd
static TileIndex GetOtherTunnelBridgeEnd(TileIndex t)
Determines type of the wormhole and returns its other end.
Definition: tunnelbridge_map.h:78
gui.h
WID_RAT_BUILD_NS
@ WID_RAT_BUILD_NS
Build rail along the game view Y axis.
Definition: rail_widget.h:17
BuildRailToolbarWindow::OnPlaceObjectAbort
void OnPlaceObjectAbort() override
The user cancelled a tile highlight mode that has been set.
Definition: rail_gui.cpp:737
BuildRailStationWindow::OnPaint
void OnPaint() override
The window must be repainted.
Definition: rail_gui.cpp:1126
BuildRailToolbarWindow::ModifyRailType
void ModifyRailType(RailType railtype)
Switch to another rail type.
Definition: rail_gui.cpp:467
WID_RAT_BUILD_DEPOT
@ WID_RAT_BUILD_DEPOT
Build a depot.
Definition: rail_widget.h:23
WC_BUILD_SIGNAL
@ WC_BUILD_SIGNAL
Build signal toolbar; Window numbers:
Definition: window_type.h:91
WID_BS_SEMAPHORE_ENTRY
@ WID_BS_SEMAPHORE_ENTRY
Build a semaphore entry block signal.
Definition: rail_widget.h:82
BuildSignalWindow::DrawWidget
void DrawWidget(const Rect &r, int widget) const override
Draw the contents of a nested widget.
Definition: rail_gui.cpp:1703
Window
Data structure for an opened window.
Definition: window_gui.h:276
BuildRailStationWindow::OnRealtimeTick
void OnRealtimeTick(uint delta_ms) override
Called periodically.
Definition: rail_gui.cpp:1491
GUIList::RebuildDone
void RebuildDone()
Notify the sortlist that the rebuild is done.
Definition: sortlist_type.h:380
StationSpec::callback_mask
byte callback_mask
Bitmask of station callbacks that have to be called.
Definition: newgrf_station.h:158
ShowSelectWaypointIfNeeded
void ShowSelectWaypointIfNeeded(const CommandContainer &cmd, TileArea ta)
Show the waypoint selection window when needed.
Definition: station_gui.cpp:2469
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:615
Pool::PoolItem<&_company_pool >::IsValidID
static bool IsValidID(size_t index)
Tests whether given index can be used to get valid (non-nullptr) Titem.
Definition: pool_type.hpp:318
RailtypeInfo::rail_ew
CursorID rail_ew
Cursor for building rail in E-W direction.
Definition: rail.h:164
WID_BRAS_PLATFORM_NUM_3
@ WID_BRAS_PLATFORM_NUM_3
Button to select stations with 3 platforms.
Definition: rail_widget.h:41
Window::RaiseWidget
void RaiseWidget(byte widget_index)
Marks a widget as raised.
Definition: window_gui.h:483
WD_MATRIX_LEFT
@ WD_MATRIX_LEFT
Offset at left of a matrix cell.
Definition: window_gui.h:76
StationSpec::disallowed_lengths
byte disallowed_lengths
Bitmask of platform lengths available for the station.
Definition: newgrf_station.h:137
Window::DrawWidgets
void DrawWidgets() const
Paint all widgets of a window.
Definition: widget.cpp:602
RAIL_TILE_DEPOT
@ RAIL_TILE_DEPOT
Depot (one entrance)
Definition: rail_map.h:26
GRFFilePropsBase::grffile
const struct GRFFile * grffile
grf file that introduced this entity
Definition: newgrf_commons.h:320
CommandContainer::tile
TileIndex tile
tile command being executed on.
Definition: command_type.h:480
BuildRailToolbarWindow::SetupRailToolbar
void SetupRailToolbar(RailType railtype)
Configures the rail toolbar for railtype given.
Definition: rail_gui.cpp:447
WID_BRAS_MATRIX
@ WID_BRAS_MATRIX
Matrix widget displaying the available stations.
Definition: rail_widget.h:61
Swap
static void Swap(T &a, T &b)
Type safe swap operation.
Definition: math_func.hpp:215
WD_IMGBTN_LEFT
@ WD_IMGBTN_LEFT
Left offset of the image in the button.
Definition: window_gui.h:38
Track
Track
These are used to specify a single track.
Definition: track_type.h:19
BuildRailStationWindow::GUIStationClassList
GUIList< StationClassID, StringFilter & > GUIStationClassList
Type definition for the list to hold available station classes.
Definition: rail_gui.cpp:898
VPM_X_AND_Y_LIMITED
@ VPM_X_AND_Y_LIMITED
area of land of limited size
Definition: viewport_type.h:101
NWID_SELECTION
@ NWID_SELECTION
Stacked widgets, only one visible at a time (eg in a panel with tabs).
Definition: widget_type.h:78
WID_BRAS_PLATFORM_DIR_Y
@ WID_BRAS_PLATFORM_DIR_Y
Button to select '\' view.
Definition: rail_widget.h:37
Window::IsWidgetDisabled
bool IsWidgetDisabled(byte widget_index) const
Gets the enabled/disabled status of a widget.
Definition: window_gui.h:421
RailtypeInfo::build_y_rail
SpriteID build_y_rail
button for building single rail in Y direction
Definition: rail.h:153
RailtypeInfo::signals
SpriteID signals[SIGTYPE_END][2][2]
signal GUI sprites (type, variant, state)
Definition: rail.h:158
Window::SetWidgetDirty
void SetWidgetDirty(byte widget_index) const
Invalidate a widget, i.e.
Definition: window.cpp:597
BuildRailStationWindow::SetStringParameters
void SetStringParameters(int widget) const override
Initialize string parameters for a widget.
Definition: rail_gui.cpp:1312
GetTunnelBridgeTransportType
static TransportType GetTunnelBridgeTransportType(TileIndex t)
Tunnel: Get the transport type of the tunnel (road or rail) Bridge: Get the transport type of the bri...
Definition: tunnelbridge_map.h:39
DIAGDIR_NE
@ DIAGDIR_NE
Northeast, upper right on your monitor.
Definition: direction_type.h:79
BuildRailClick_Remove
static void BuildRailClick_Remove(Window *w)
The "remove"-button click proc of the build-rail toolbar.
Definition: rail_gui.cpp:327
Rect
Specification of a rectangle with absolute coordinates of all edges.
Definition: geometry_type.hpp:47
Window::LowerWidget
void LowerWidget(byte widget_index)
Marks a widget as lowered.
Definition: window_gui.h:474
Company
Definition: company_base.h:110
RailTypes
RailTypes
The different railtypes we support, but then a bitmask of them.
Definition: rail_type.h:46
WID_BS_ELECTRIC_ENTRY
@ WID_BS_ELECTRIC_ENTRY
Build an electric entry block signal.
Definition: rail_widget.h:88
RailStationGUISettings::station_count
byte station_count
Number of custom stations (if newstations is true )
Definition: rail_gui.cpp:66
AWV_INCREASE
@ AWV_INCREASE
Arrow to the right or in case of RTL to the left.
Definition: widget_type.h:36
DrawStationTile
bool DrawStationTile(int x, int y, RailType railtype, Axis axis, StationClassID sclass, uint station)
Draw representation of a station tile for GUI purposes.
Definition: newgrf_station.cpp:781
STAT_CLASS_DFLT
@ STAT_CLASS_DFLT
Default station class.
Definition: newgrf_station.h:85
DDSP_REMOVE_STATION
@ DDSP_REMOVE_STATION
Station removal.
Definition: viewport_type.h:131
VPM_X_OR_Y
@ VPM_X_OR_Y
drag in X or Y direction
Definition: viewport_type.h:97
Window::DisableWidget
void DisableWidget(byte widget_index)
Sets a widget to disabled.
Definition: window_gui.h:402
NWidgetBase::current_x
uint current_x
Current horizontal size (after resizing).
Definition: widget_type.h:172
lastof
#define lastof(x)
Get the last element of an fixed size array.
Definition: stdafx.h:383
BuildRailStationWindow::SelectOtherClass
void SelectOtherClass(StationClassID station_class)
Select the specified station class.
Definition: rail_gui.cpp:1106
BuildRailStationWindow::OnClick
void OnClick(Point pt, int widget, int click_count) override
A click with the left mouse button has been made on the window.
Definition: rail_gui.cpp:1320
_waypoint_count
static byte _waypoint_count
Number of waypoint types.
Definition: rail_gui.cpp:51
WID_BRAS_NEWST_SCROLL
@ WID_BRAS_NEWST_SCROLL
Scrollbar of the WID_BRAS_NEWST_LIST.
Definition: rail_widget.h:73
ResetObjectToPlace
void ResetObjectToPlace()
Reset the cursor and mouse mode handling back to default (normal cursor, only clicking in windows).
Definition: viewport.cpp:3421
HT_SPECIAL
@ HT_SPECIAL
special mode used for highlighting while dragging (and for tunnels/docks)
Definition: tilehighlight_type.h:23
DrawWaypointSprite
void DrawWaypointSprite(int x, int y, int stat_id, RailType railtype)
Draw a waypoint.
Definition: waypoint.cpp:27
WD_IMGBTN_RIGHT
@ WD_IMGBTN_RIGHT
Right offset of the image in the button.
Definition: window_gui.h:39
Window::SetWidgetLoweredState
void SetWidgetLoweredState(byte widget_index, bool lowered_stat)
Sets the lowered/raised status of a widget.
Definition: window_gui.h:453
station_gui.h
CMD_BUILD_RAIL_STATION
@ CMD_BUILD_RAIL_STATION
build a rail station
Definition: command_type.h:182
BuildRailStationWindow::TagNameFilter
static bool CDECL TagNameFilter(StationClassID const *sc, StringFilter &filter)
Filter station classes by class name.
Definition: rail_gui.cpp:1040
_station_builder_desc
static WindowDesc _station_builder_desc(WDP_AUTO, "build_station_rail", 350, 0, WC_BUILD_STATION, WC_BUILD_TOOLBAR, WDF_CONSTRUCTION, _nested_station_builder_widgets, lengthof(_nested_station_builder_widgets))
High level window description of the station-build window (default & newGRF)
SIG_SEMAPHORE
@ SIG_SEMAPHORE
Old-fashioned semaphore signal.
Definition: signal_type.h:18
WID_BRAS_PLATFORM_LEN_BEGIN
@ WID_BRAS_PLATFORM_LEN_BEGIN
Helper for determining the chosen platform length.
Definition: rail_widget.h:76
CMD_BUILD_SIGNAL_TRACK
@ CMD_BUILD_SIGNAL_TRACK
add signals along a track (by dragging)
Definition: command_type.h:305
VPM_SIGNALDIRS
@ VPM_SIGNALDIRS
similar to VMP_RAILDIRS, but with different cursor
Definition: viewport_type.h:107
GUISettings::default_signal_type
uint8 default_signal_type
the signal type to build by default.
Definition: settings_type.h:145
BuildRailStationWindow::filter_editbox
QueryString filter_editbox
Filter editbox.
Definition: rail_gui.cpp:908
WID_BRAS_PLATFORM_LEN_2
@ WID_BRAS_PLATFORM_LEN_2
Button to select 2 tiles length station platforms.
Definition: rail_widget.h:48
WID_BRAS_PLATFORM_NUM_1
@ WID_BRAS_PLATFORM_NUM_1
Button to select stations with a single platform.
Definition: rail_widget.h:39
StringFilter
String filter and state.
Definition: stringfilter_type.h:31
WID_BRAS_SHOW_NEWST_ADDITIONS
@ WID_BRAS_SHOW_NEWST_ADDITIONS
Selection for newstation class selection list.
Definition: rail_widget.h:68
DropDownListIconItem
List item with icon and string.
Definition: dropdown_type.h:82
BuildRailStationWindow::OnInvalidateData
void OnInvalidateData(int data=0, bool gui_scope=true) override
Some data on this window has become invalid.
Definition: rail_gui.cpp:1111
RailStationGUISettings::orientation
Axis orientation
Currently selected rail station orientation.
Definition: rail_gui.cpp:61
WWT_TEXTBTN
@ WWT_TEXTBTN
(Toggle) Button with text
Definition: widget_type.h:53
BuildRailToolbarWindow::railtype
RailType railtype
Rail type to build.
Definition: rail_gui.cpp:424
ClientSettings::gui
GUISettings gui
settings related to the GUI
Definition: settings_type.h:577
TileHighlightData::selend
Point selend
The location where the drag currently ends.
Definition: tilehighlight_type.h:61
HT_DIR_X
@ HT_DIR_X
X direction.
Definition: tilehighlight_type.h:33
AWV_DECREASE
@ AWV_DECREASE
Arrow to the left or in case of RTL to the right.
Definition: widget_type.h:35
BuildRailDepotWindow::UpdateWidgetSize
void UpdateWidgetSize(int widget, Dimension *size, const Dimension &padding, Dimension *fill, Dimension *resize) override
Update size and resize step of a widget in the window.
Definition: rail_gui.cpp:1844
WID_BRAS_PLATFORM_LEN_7
@ WID_BRAS_PLATFORM_LEN_7
Button to select 7 tiles length station platforms.
Definition: rail_widget.h:53
GUIList::SetSortFuncs
void SetSortFuncs(SortFunction *const *n_funcs)
Hand the array of sort function pointers to the sort list.
Definition: sortlist_type.h:270
DrawPixelInfo
Data about how and where to blit pixels.
Definition: gfx_type.h:155
GUISettings::persistent_buildingtools
bool persistent_buildingtools
keep the building tools active after usage
Definition: settings_type.h:151
StationSettings::modified_catchment
bool modified_catchment
different-size catchment areas
Definition: settings_type.h:531
TileVirtXY
static TileIndex TileVirtXY(uint x, uint y)
Get a tile from the virtual XY-coordinate.
Definition: map_func.h:194
Hotkey
All data for a single hotkey.
Definition: hotkeys.h:22
RailtypeInfo::convert_rail
SpriteID convert_rail
button for converting rail
Definition: rail.h:157
hotkeys.h
ReinitGuiAfterToggleElrail
void ReinitGuiAfterToggleElrail(bool disable)
Re-initialize rail-build toolbar after toggling support for electric trains.
Definition: rail_gui.cpp:2031
INVALID_RAILTYPE
@ INVALID_RAILTYPE
Flag for invalid railtype.
Definition: rail_type.h:34
WWT_SHADEBOX
@ WWT_SHADEBOX
Shade box (at top-right of a window, between WWT_DEBUGBOX and WWT_DEFSIZEBOX)
Definition: widget_type.h:62
WN_GAME_OPTIONS_GAME_SETTINGS
@ WN_GAME_OPTIONS_GAME_SETTINGS
Game settings.
Definition: window_type.h:19
RAILTYPE_BEGIN
@ RAILTYPE_BEGIN
Used for iterations.
Definition: rail_type.h:28
NWidgetMatrix::SetClicked
void SetClicked(int clicked)
Sets the clicked widget in the matrix.
Definition: widget.cpp:1494
AXIS_X
@ AXIS_X
The X axis.
Definition: direction_type.h:124
SetDefaultRailGui
static void SetDefaultRailGui()
Set the initial (default) railtype to use.
Definition: rail_gui.cpp:2043
GUIPlaceProcDragXY
bool GUIPlaceProcDragXY(ViewportDragDropSelectionProcess proc, TileIndex start_tile, TileIndex end_tile)
A central place to handle all X_AND_Y dragged GUI functions.
Definition: terraform_gui.cpp:106