OpenTTD Source: src/road_gui.cpp Source File

OpenTTD Source 14.1

road_gui.cpp
Go to the documentation of this file.
1 /*
2 * This file is part of OpenTTD.
3 * OpenTTD is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, version 2.
4 * OpenTTD is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
5 * See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with OpenTTD. If not, see <http://www.gnu.org/licenses/>.
6 */
7
10 #include "stdafx.h"
11 #include "gui.h"
12 #include "window_gui.h"
13 #include "station_gui.h"
14 #include "terraform_gui.h"
15 #include "viewport_func.h"
16 #include "command_func.h"
17 #include "road_cmd.h"
18 #include "station_func.h"
19 #include "window_func.h"
20 #include "vehicle_func.h"
21 #include "sound_func.h"
22 #include "company_func.h"
23 #include "tunnelbridge.h"
24 #include "tunnelbridge_map.h"
25 #include "tilehighlight_func.h"
26 #include "company_base.h"
27 #include "hotkeys.h"
28 #include "road_gui.h"
29 #include "zoom_func.h"
30 #include "engine_base.h"
31 #include "strings_func.h"
32 #include "core/geometry_func.hpp"
33 #include "station_cmd.h"
34 #include "road_cmd.h"
35 #include "tunnelbridge_cmd.h"
36 #include "newgrf_roadstop.h"
37 #include "querystring_gui.h"
38 #include "sortlist_type.h"
39 #include "stringfilter_type.h"
40 #include "string_func.h"
41 #include "timer/timer.h"
42 #include "timer/timer_game_calendar.h"
43
44 #include "widgets/road_widget.h"
45
46 #include "table/strings.h"
47
48 #include "safeguards.h"
49
50 static void ShowRVStationPicker(Window *parent, RoadStopType rs);
51 static void ShowRoadDepotPicker(Window *parent);
52
53 static bool _remove_button_clicked;
54 static bool _one_way_button_clicked;
55
56 static Axis _place_road_dir;
57 static bool _place_road_start_half_x;
58 static bool _place_road_start_half_y;
59 static bool _place_road_end_half;
60
61 static RoadType _cur_roadtype;
62
63 static DiagDirection _road_depot_orientation;
64
65 struct RoadStopGUISettings {
66 DiagDirection orientation;
67
68 RoadStopClassID roadstop_class;
69 uint16_t roadstop_type;
70 uint16_t roadstop_count;
71 };
72 static RoadStopGUISettings _roadstop_gui_settings;
73
78 static bool IsRoadStopAvailable(const RoadStopSpec *roadstopspec, StationType type)
79 {
80 if (roadstopspec == nullptr) return true;
81
82 if (HasBit(roadstopspec->flags, RSF_BUILD_MENU_ROAD_ONLY) && !RoadTypeIsRoad(_cur_roadtype)) return false;
83 if (HasBit(roadstopspec->flags, RSF_BUILD_MENU_TRAM_ONLY) && !RoadTypeIsTram(_cur_roadtype)) return false;
84
85 if (roadstopspec->stop_type != ROADSTOPTYPE_ALL) {
86 switch (type) {
87 case STATION_BUS: if (roadstopspec->stop_type != ROADSTOPTYPE_PASSENGER) return false; break;
88 case STATION_TRUCK: if (roadstopspec->stop_type != ROADSTOPTYPE_FREIGHT) return false; break;
89 default: break;
90 }
91 }
92
93 if (!HasBit(roadstopspec->callback_mask, CBM_ROAD_STOP_AVAIL)) return true;
94
95 uint16_t cb_res = GetRoadStopCallback(CBID_STATION_AVAILABILITY, 0, 0, roadstopspec, nullptr, INVALID_TILE, _cur_roadtype, type, 0);
96 if (cb_res == CALLBACK_FAILED) return true;
97
98 return Convert8bitBooleanCallback(roadstopspec->grf_prop.grffile, CBID_STATION_AVAILABILITY, cb_res);
99 }
100
101 void CcPlaySound_CONSTRUCTION_OTHER(Commands, const CommandCost &result, TileIndex tile)
102 {
103 if (result.Succeeded() && _settings_client.sound.confirm) SndPlayTileFx(SND_1F_CONSTRUCTION_OTHER, tile);
104 }
105
110 static void PlaceRoad_Bridge(TileIndex tile, Window *w)
111 {
112 if (IsBridgeTile(tile)) {
113 TileIndex other_tile = GetOtherTunnelBridgeEnd(tile);
114 Point pt = {0, 0};
115 w->OnPlaceMouseUp(VPM_X_OR_Y, DDSP_BUILD_BRIDGE, pt, other_tile, tile);
116 } else {
117 VpStartPlaceSizing(tile, VPM_X_OR_Y, DDSP_BUILD_BRIDGE);
118 }
119 }
120
127 void CcBuildRoadTunnel(Commands, const CommandCost &result, TileIndex start_tile)
128 {
129 if (result.Succeeded()) {
130 if (_settings_client.sound.confirm) SndPlayTileFx(SND_1F_CONSTRUCTION_OTHER, start_tile);
131 if (!_settings_client.gui.persistent_buildingtools) ResetObjectToPlace();
132
133 DiagDirection start_direction = ReverseDiagDir(GetTunnelBridgeDirection(start_tile));
134 ConnectRoadToStructure(start_tile, start_direction);
135
136 TileIndex end_tile = GetOtherTunnelBridgeEnd(start_tile);
137 DiagDirection end_direction = ReverseDiagDir(GetTunnelBridgeDirection(end_tile));
138 ConnectRoadToStructure(end_tile, end_direction);
139 } else {
140 SetRedErrorSquare(_build_tunnel_endtile);
141 }
142 }
143
149 void ConnectRoadToStructure(TileIndex tile, DiagDirection direction)
150 {
151 tile += TileOffsByDiagDir(direction);
152 /* if there is a roadpiece just outside of the station entrance, build a connecting route */
153 if (IsNormalRoadTile(tile)) {
154 if (GetRoadBits(tile, GetRoadTramType(_cur_roadtype)) != ROAD_NONE) {
155 Command<CMD_BUILD_ROAD>::Post(tile, DiagDirToRoadBits(ReverseDiagDir(direction)), _cur_roadtype, DRD_NONE, 0);
156 }
157 }
158 }
159
160 void CcRoadDepot(Commands, const CommandCost &result, TileIndex tile, RoadType, DiagDirection dir)
161 {
162 if (result.Failed()) return;
163
164 if (_settings_client.sound.confirm) SndPlayTileFx(SND_1F_CONSTRUCTION_OTHER, tile);
165 if (!_settings_client.gui.persistent_buildingtools) ResetObjectToPlace();
166 ConnectRoadToStructure(tile, dir);
167 }
168
181 void CcRoadStop(Commands, const CommandCost &result, TileIndex tile, uint8_t width, uint8_t length, RoadStopType, bool is_drive_through,
182 DiagDirection dir, RoadType, RoadStopClassID spec_class, uint16_t spec_index, StationID, bool)
183 {
184 if (result.Failed()) return;
185
186 if (_settings_client.sound.confirm) SndPlayTileFx(SND_1F_CONSTRUCTION_OTHER, tile);
187 if (!_settings_client.gui.persistent_buildingtools) ResetObjectToPlace();
188
189 bool connect_to_road = true;
190 if ((uint)spec_class < RoadStopClass::GetClassCount() && spec_index < RoadStopClass::Get(spec_class)->GetSpecCount()) {
191 const RoadStopSpec *roadstopspec = RoadStopClass::Get(spec_class)->GetSpec(spec_index);
192 if (roadstopspec != nullptr && HasBit(roadstopspec->flags, RSF_NO_AUTO_ROAD_CONNECTION)) connect_to_road = false;
193 }
194
195 if (connect_to_road) {
196 TileArea roadstop_area(tile, width, length);
197 for (TileIndex cur_tile : roadstop_area) {
198 ConnectRoadToStructure(cur_tile, dir);
199 /* For a drive-through road stop build connecting road for other entrance. */
200 if (is_drive_through) ConnectRoadToStructure(cur_tile, ReverseDiagDir(dir));
201 }
202 }
203 }
204
215 static void PlaceRoadStop(TileIndex start_tile, TileIndex end_tile, RoadStopType stop_type, bool adjacent, RoadType rt, StringID err_msg)
216 {
217 TileArea ta(start_tile, end_tile);
218 DiagDirection ddir = _roadstop_gui_settings.orientation;
219 bool drive_through = ddir >= DIAGDIR_END;
220 if (drive_through) ddir = static_cast<DiagDirection>(ddir - DIAGDIR_END); // Adjust picker result to actual direction.
221 RoadStopClassID spec_class = _roadstop_gui_settings.roadstop_class;
222 uint16_t spec_index = _roadstop_gui_settings.roadstop_type;
223
224 auto proc = [=](bool test, StationID to_join) -> bool {
225 if (test) {
226 return Command<CMD_BUILD_ROAD_STOP>::Do(CommandFlagsToDCFlags(GetCommandFlags<CMD_BUILD_ROAD_STOP>()), ta.tile, ta.w, ta.h, stop_type, drive_through,
227 ddir, rt, spec_class, spec_index, INVALID_STATION, adjacent).Succeeded();
228 } else {
229 return Command<CMD_BUILD_ROAD_STOP>::Post(err_msg, CcRoadStop, ta.tile, ta.w, ta.h, stop_type, drive_through,
230 ddir, rt, spec_class, spec_index, to_join, adjacent);
231 }
232 };
233
234 ShowSelectStationIfNeeded(ta, proc);
235 }
236
241 static void PlaceRoad_BusStation(TileIndex tile)
242 {
243 if (_remove_button_clicked) {
244 VpStartPlaceSizing(tile, VPM_X_AND_Y, DDSP_REMOVE_BUSSTOP);
245 } else {
246 if (_roadstop_gui_settings.orientation < DIAGDIR_END) { // Not a drive-through stop.
247 VpStartPlaceSizing(tile, (DiagDirToAxis(_roadstop_gui_settings.orientation) == AXIS_X) ? VPM_X_LIMITED : VPM_Y_LIMITED, DDSP_BUILD_BUSSTOP);
248 } else {
249 VpStartPlaceSizing(tile, VPM_X_AND_Y_LIMITED, DDSP_BUILD_BUSSTOP);
250 }
251 VpSetPlaceSizingLimit(_settings_game.station.station_spread);
252 }
253 }
254
259 static void PlaceRoad_TruckStation(TileIndex tile)
260 {
261 if (_remove_button_clicked) {
262 VpStartPlaceSizing(tile, VPM_X_AND_Y, DDSP_REMOVE_TRUCKSTOP);
263 } else {
264 if (_roadstop_gui_settings.orientation < DIAGDIR_END) { // Not a drive-through stop.
265 VpStartPlaceSizing(tile, (DiagDirToAxis(_roadstop_gui_settings.orientation) == AXIS_X) ? VPM_X_LIMITED : VPM_Y_LIMITED, DDSP_BUILD_TRUCKSTOP);
266 } else {
267 VpStartPlaceSizing(tile, VPM_X_AND_Y_LIMITED, DDSP_BUILD_TRUCKSTOP);
268 }
269 VpSetPlaceSizingLimit(_settings_game.station.station_spread);
270 }
271 }
272
273 typedef void OnButtonClick(Window *w);
274
279 static void ToggleRoadButton_Remove(Window *w)
280 {
281 w->ToggleWidgetLoweredState(WID_ROT_REMOVE);
282 w->SetWidgetDirty(WID_ROT_REMOVE);
283 _remove_button_clicked = w->IsWidgetLowered(WID_ROT_REMOVE);
284 SetSelectionRed(_remove_button_clicked);
285 }
286
292 static bool RoadToolbar_CtrlChanged(Window *w)
293 {
294 if (w->IsWidgetDisabled(WID_ROT_REMOVE)) return false;
295
296 /* allow ctrl to switch remove mode only for these widgets */
297 for (WidgetID i = WID_ROT_ROAD_X; i <= WID_ROT_AUTOROAD; i++) {
298 if (w->IsWidgetLowered(i)) {
299 ToggleRoadButton_Remove(w);
300 return true;
301 }
302 }
303
304 return false;
305 }
306
308 struct BuildRoadToolbarWindow : Window {
309 RoadType roadtype;
310 const RoadTypeInfo *rti;
311 int last_started_action;
312
313 BuildRoadToolbarWindow(WindowDesc *desc, WindowNumber window_number) : Window(desc)
314 {
315 this->Initialize(_cur_roadtype);
316 this->InitNested(window_number);
317 this->SetupRoadToolbar();
318 this->SetWidgetDisabledState(WID_ROT_REMOVE, true);
319
320 if (RoadTypeIsRoad(this->roadtype)) {
321 this->SetWidgetDisabledState(WID_ROT_ONE_WAY, true);
322 }
323
324 this->OnInvalidateData();
325 this->last_started_action = INVALID_WID_ROT;
326
327 if (_settings_client.gui.link_terraform_toolbar) ShowTerraformToolbar(this);
328 }
329
330 void Close([[maybe_unused]] int data = 0) override
331 {
332 if (_game_mode == GM_NORMAL && (this->IsWidgetLowered(WID_ROT_BUS_STATION) || this->IsWidgetLowered(WID_ROT_TRUCK_STATION))) SetViewportCatchmentStation(nullptr, true);
333 if (_settings_client.gui.link_terraform_toolbar) CloseWindowById(WC_SCEN_LAND_GEN, 0, false);
334 this->Window::Close();
335 }
336
342 void OnInvalidateData([[maybe_unused]] int data = 0, [[maybe_unused]] bool gui_scope = true) override
343 {
344 if (!gui_scope) return;
345 RoadTramType rtt = GetRoadTramType(this->roadtype);
346
347 bool can_build = CanBuildVehicleInfrastructure(VEH_ROAD, rtt);
348 this->SetWidgetsDisabledState(!can_build,
349 WID_ROT_DEPOT,
350 WID_ROT_BUS_STATION,
351 WID_ROT_TRUCK_STATION);
352 if (!can_build) {
353 CloseWindowById(WC_BUS_STATION, TRANSPORT_ROAD);
354 CloseWindowById(WC_TRUCK_STATION, TRANSPORT_ROAD);
355 CloseWindowById(WC_BUILD_DEPOT, TRANSPORT_ROAD);
356 }
357
358 if (_game_mode != GM_EDITOR) {
359 if (!can_build) {
360 /* Show in the tooltip why this button is disabled. */
361 this->GetWidget<NWidgetCore>(WID_ROT_DEPOT)->SetToolTip(STR_TOOLBAR_DISABLED_NO_VEHICLE_AVAILABLE);
362 this->GetWidget<NWidgetCore>(WID_ROT_BUS_STATION)->SetToolTip(STR_TOOLBAR_DISABLED_NO_VEHICLE_AVAILABLE);
363 this->GetWidget<NWidgetCore>(WID_ROT_TRUCK_STATION)->SetToolTip(STR_TOOLBAR_DISABLED_NO_VEHICLE_AVAILABLE);
364 } else {
365 this->GetWidget<NWidgetCore>(WID_ROT_DEPOT)->SetToolTip(rtt == RTT_ROAD ? STR_ROAD_TOOLBAR_TOOLTIP_BUILD_ROAD_VEHICLE_DEPOT : STR_ROAD_TOOLBAR_TOOLTIP_BUILD_TRAM_VEHICLE_DEPOT);
366 this->GetWidget<NWidgetCore>(WID_ROT_BUS_STATION)->SetToolTip(rtt == RTT_ROAD ? STR_ROAD_TOOLBAR_TOOLTIP_BUILD_BUS_STATION : STR_ROAD_TOOLBAR_TOOLTIP_BUILD_PASSENGER_TRAM_STATION);
367 this->GetWidget<NWidgetCore>(WID_ROT_TRUCK_STATION)->SetToolTip(rtt == RTT_ROAD ? STR_ROAD_TOOLBAR_TOOLTIP_BUILD_TRUCK_LOADING_BAY : STR_ROAD_TOOLBAR_TOOLTIP_BUILD_CARGO_TRAM_STATION);
368 }
369 }
370 }
371
372 void Initialize(RoadType roadtype)
373 {
374 assert(roadtype < ROADTYPE_END);
375 this->roadtype = roadtype;
376 this->rti = GetRoadTypeInfo(this->roadtype);
377 }
378
383 void SetupRoadToolbar()
384 {
385 this->GetWidget<NWidgetCore>(WID_ROT_ROAD_X)->widget_data = rti->gui_sprites.build_x_road;
386 this->GetWidget<NWidgetCore>(WID_ROT_ROAD_Y)->widget_data = rti->gui_sprites.build_y_road;
387 this->GetWidget<NWidgetCore>(WID_ROT_AUTOROAD)->widget_data = rti->gui_sprites.auto_road;
388 if (_game_mode != GM_EDITOR) {
389 this->GetWidget<NWidgetCore>(WID_ROT_DEPOT)->widget_data = rti->gui_sprites.build_depot;
390 }
391 this->GetWidget<NWidgetCore>(WID_ROT_CONVERT_ROAD)->widget_data = rti->gui_sprites.convert_road;
392 this->GetWidget<NWidgetCore>(WID_ROT_BUILD_TUNNEL)->widget_data = rti->gui_sprites.build_tunnel;
393 }
394
399 void ModifyRoadType(RoadType roadtype)
400 {
401 this->Initialize(roadtype);
402 this->SetupRoadToolbar();
403 this->ReInit();
404 }
405
406 void SetStringParameters(WidgetID widget) const override
407 {
408 if (widget == WID_ROT_CAPTION) {
409 if (this->rti->max_speed > 0) {
410 SetDParam(0, STR_TOOLBAR_RAILTYPE_VELOCITY);
411 SetDParam(1, this->rti->strings.toolbar_caption);
412 SetDParam(2, PackVelocity(this->rti->max_speed / 2, VEH_ROAD));
413 } else {
414 SetDParam(0, this->rti->strings.toolbar_caption);
415 }
416 }
417 }
418
424 void UpdateOptionWidgetStatus(RoadToolbarWidgets clicked_widget)
425 {
426 /* The remove and the one way button state is driven
427 * by the other buttons so they don't act on themselves.
428 * Both are only valid if they are able to apply as options. */
429 switch (clicked_widget) {
430 case WID_ROT_REMOVE:
431 if (RoadTypeIsRoad(this->roadtype)) {
432 this->RaiseWidget(WID_ROT_ONE_WAY);
433 this->SetWidgetDirty(WID_ROT_ONE_WAY);
434 }
435
436 break;
437
438 case WID_ROT_ONE_WAY:
439 this->RaiseWidget(WID_ROT_REMOVE);
440 this->SetWidgetDirty(WID_ROT_REMOVE);
441 break;
442
443 case WID_ROT_BUS_STATION:
444 case WID_ROT_TRUCK_STATION:
445 if (RoadTypeIsRoad(this->roadtype)) this->DisableWidget(WID_ROT_ONE_WAY);
446 this->SetWidgetDisabledState(WID_ROT_REMOVE, !this->IsWidgetLowered(clicked_widget));
447 break;
448
449 case WID_ROT_ROAD_X:
450 case WID_ROT_ROAD_Y:
451 case WID_ROT_AUTOROAD:
452 this->SetWidgetDisabledState(WID_ROT_REMOVE, !this->IsWidgetLowered(clicked_widget));
453 if (RoadTypeIsRoad(this->roadtype)) {
454 this->SetWidgetDisabledState(WID_ROT_ONE_WAY, !this->IsWidgetLowered(clicked_widget));
455 }
456 break;
457
458 default:
459 /* When any other buttons than road/station, raise and
460 * disable the removal button */
461 this->SetWidgetDisabledState(WID_ROT_REMOVE, true);
462 this->SetWidgetLoweredState(WID_ROT_REMOVE, false);
463
464 if (RoadTypeIsRoad(this->roadtype)) {
465 this->SetWidgetDisabledState(WID_ROT_ONE_WAY, true);
466 this->SetWidgetLoweredState(WID_ROT_ONE_WAY, false);
467 }
468
469 break;
470 }
471 }
472
473 void OnClick([[maybe_unused]] Point pt, WidgetID widget, [[maybe_unused]] int click_count) override
474 {
475 _remove_button_clicked = false;
476 _one_way_button_clicked = false;
477 switch (widget) {
478 case WID_ROT_ROAD_X:
479 HandlePlacePushButton(this, WID_ROT_ROAD_X, this->rti->cursor.road_nwse, HT_RECT);
480 this->last_started_action = widget;
481 break;
482
483 case WID_ROT_ROAD_Y:
484 HandlePlacePushButton(this, WID_ROT_ROAD_Y, this->rti->cursor.road_swne, HT_RECT);
485 this->last_started_action = widget;
486 break;
487
488 case WID_ROT_AUTOROAD:
489 HandlePlacePushButton(this, WID_ROT_AUTOROAD, this->rti->cursor.autoroad, HT_RECT);
490 this->last_started_action = widget;
491 break;
492
493 case WID_ROT_DEMOLISH:
494 HandlePlacePushButton(this, WID_ROT_DEMOLISH, ANIMCURSOR_DEMOLISH, HT_RECT | HT_DIAGONAL);
495 this->last_started_action = widget;
496 break;
497
498 case WID_ROT_DEPOT:
499 if (HandlePlacePushButton(this, WID_ROT_DEPOT, this->rti->cursor.depot, HT_RECT)) {
500 ShowRoadDepotPicker(this);
501 this->last_started_action = widget;
502 }
503 break;
504
505 case WID_ROT_BUS_STATION:
506 if (HandlePlacePushButton(this, WID_ROT_BUS_STATION, SPR_CURSOR_BUS_STATION, HT_RECT)) {
507 ShowRVStationPicker(this, ROADSTOP_BUS);
508 this->last_started_action = widget;
509 }
510 break;
511
512 case WID_ROT_TRUCK_STATION:
513 if (HandlePlacePushButton(this, WID_ROT_TRUCK_STATION, SPR_CURSOR_TRUCK_STATION, HT_RECT)) {
514 ShowRVStationPicker(this, ROADSTOP_TRUCK);
515 this->last_started_action = widget;
516 }
517 break;
518
519 case WID_ROT_ONE_WAY:
520 if (this->IsWidgetDisabled(WID_ROT_ONE_WAY)) return;
521 this->SetDirty();
522 this->ToggleWidgetLoweredState(WID_ROT_ONE_WAY);
523 SetSelectionRed(false);
524 break;
525
526 case WID_ROT_BUILD_BRIDGE:
527 HandlePlacePushButton(this, WID_ROT_BUILD_BRIDGE, SPR_CURSOR_BRIDGE, HT_RECT);
528 this->last_started_action = widget;
529 break;
530
531 case WID_ROT_BUILD_TUNNEL:
532 HandlePlacePushButton(this, WID_ROT_BUILD_TUNNEL, this->rti->cursor.tunnel, HT_SPECIAL);
533 this->last_started_action = widget;
534 break;
535
536 case WID_ROT_REMOVE:
537 if (this->IsWidgetDisabled(WID_ROT_REMOVE)) return;
538
539 CloseWindowById(WC_SELECT_STATION, 0);
540 ToggleRoadButton_Remove(this);
541 if (_settings_client.sound.click_beep) SndPlayFx(SND_15_BEEP);
542 break;
543
544 case WID_ROT_CONVERT_ROAD:
545 HandlePlacePushButton(this, WID_ROT_CONVERT_ROAD, this->rti->cursor.convert_road, HT_RECT);
546 this->last_started_action = widget;
547 break;
548
549 default: NOT_REACHED();
550 }
551 this->UpdateOptionWidgetStatus((RoadToolbarWidgets)widget);
552 if (_ctrl_pressed) RoadToolbar_CtrlChanged(this);
553 }
554
555 EventState OnHotkey(int hotkey) override
556 {
557 MarkTileDirtyByTile(TileVirtXY(_thd.pos.x, _thd.pos.y)); // redraw tile selection
558 return Window::OnHotkey(hotkey);
559 }
560
561 void OnPlaceObject([[maybe_unused]] Point pt, TileIndex tile) override
562 {
563 _remove_button_clicked = this->IsWidgetLowered(WID_ROT_REMOVE);
564 _one_way_button_clicked = RoadTypeIsRoad(this->roadtype) ? this->IsWidgetLowered(WID_ROT_ONE_WAY) : false;
565 switch (this->last_started_action) {
566 case WID_ROT_ROAD_X:
567 _place_road_dir = AXIS_X;
568 _place_road_start_half_x = _tile_fract_coords.x >= 8;
569 VpStartPlaceSizing(tile, VPM_FIX_Y, DDSP_PLACE_ROAD_X_DIR);
570 break;
571
572 case WID_ROT_ROAD_Y:
573 _place_road_dir = AXIS_Y;
574 _place_road_start_half_y = _tile_fract_coords.y >= 8;
575 VpStartPlaceSizing(tile, VPM_FIX_X, DDSP_PLACE_ROAD_Y_DIR);
576 break;
577
578 case WID_ROT_AUTOROAD:
579 _place_road_dir = INVALID_AXIS;
580 _place_road_start_half_x = _tile_fract_coords.x >= 8;
581 _place_road_start_half_y = _tile_fract_coords.y >= 8;
582 VpStartPlaceSizing(tile, VPM_X_OR_Y, DDSP_PLACE_AUTOROAD);
583 break;
584
585 case WID_ROT_DEMOLISH:
586 PlaceProc_DemolishArea(tile);
587 break;
588
589 case WID_ROT_DEPOT:
590 Command<CMD_BUILD_ROAD_DEPOT>::Post(this->rti->strings.err_depot, CcRoadDepot,
591 tile, _cur_roadtype, _road_depot_orientation);
592 break;
593
594 case WID_ROT_BUS_STATION:
595 PlaceRoad_BusStation(tile);
596 break;
597
598 case WID_ROT_TRUCK_STATION:
599 PlaceRoad_TruckStation(tile);
600 break;
601
602 case WID_ROT_BUILD_BRIDGE:
603 PlaceRoad_Bridge(tile, this);
604 break;
605
606 case WID_ROT_BUILD_TUNNEL:
607 Command<CMD_BUILD_TUNNEL>::Post(STR_ERROR_CAN_T_BUILD_TUNNEL_HERE, CcBuildRoadTunnel,
608 tile, TRANSPORT_ROAD, _cur_roadtype);
609 break;
610
611 case WID_ROT_CONVERT_ROAD:
612 VpStartPlaceSizing(tile, VPM_X_AND_Y, DDSP_CONVERT_ROAD);
613 break;
614
615 default: NOT_REACHED();
616 }
617 }
618
619 void OnPlaceObjectAbort() override
620 {
621 if (_game_mode != GM_EDITOR && (this->IsWidgetLowered(WID_ROT_BUS_STATION) || this->IsWidgetLowered(WID_ROT_TRUCK_STATION))) SetViewportCatchmentStation(nullptr, true);
622
623 this->RaiseButtons();
624 this->SetWidgetDisabledState(WID_ROT_REMOVE, true);
625 this->SetWidgetDirty(WID_ROT_REMOVE);
626
627 if (RoadTypeIsRoad(this->roadtype)) {
628 this->SetWidgetDisabledState(WID_ROT_ONE_WAY, true);
629 this->SetWidgetDirty(WID_ROT_ONE_WAY);
630 }
631
632 CloseWindowById(WC_BUS_STATION, TRANSPORT_ROAD);
633 CloseWindowById(WC_TRUCK_STATION, TRANSPORT_ROAD);
634 CloseWindowById(WC_BUILD_DEPOT, TRANSPORT_ROAD);
635 CloseWindowById(WC_SELECT_STATION, 0);
636 CloseWindowByClass(WC_BUILD_BRIDGE);
637 }
638
639 void OnPlaceDrag(ViewportPlaceMethod select_method, [[maybe_unused]] ViewportDragDropSelectionProcess select_proc, [[maybe_unused]] Point pt) override
640 {
641 /* Here we update the end tile flags
642 * of the road placement actions.
643 * At first we reset the end halfroad
644 * bits and if needed we set them again. */
645 switch (select_proc) {
646 case DDSP_PLACE_ROAD_X_DIR:
647 _place_road_end_half = pt.x & 8;
648 break;
649
650 case DDSP_PLACE_ROAD_Y_DIR:
651 _place_road_end_half = pt.y & 8;
652 break;
653
654 case DDSP_PLACE_AUTOROAD:
655 /* For autoroad we need to update the
656 * direction of the road */
657 if (_thd.size.x > _thd.size.y || (_thd.size.x == _thd.size.y &&
658 ( (_tile_fract_coords.x < _tile_fract_coords.y && (_tile_fract_coords.x + _tile_fract_coords.y) < 16) ||
659 (_tile_fract_coords.x > _tile_fract_coords.y && (_tile_fract_coords.x + _tile_fract_coords.y) > 16) ))) {
660 /* Set dir = X */
661 _place_road_dir = AXIS_X;
662 _place_road_end_half = pt.x & 8;
663 } else {
664 /* Set dir = Y */
665 _place_road_dir = AXIS_Y;
666 _place_road_end_half = pt.y & 8;
667 }
668
669 break;
670
671 default:
672 break;
673 }
674
675 VpSelectTilesWithMethod(pt.x, pt.y, select_method);
676 }
677
678 void OnPlaceMouseUp([[maybe_unused]] ViewportPlaceMethod select_method, ViewportDragDropSelectionProcess select_proc, [[maybe_unused]] Point pt, TileIndex start_tile, TileIndex end_tile) override
679 {
680 if (pt.x != -1) {
681 switch (select_proc) {
682 default: NOT_REACHED();
683 case DDSP_BUILD_BRIDGE:
684 if (!_settings_client.gui.persistent_buildingtools) ResetObjectToPlace();
685 ShowBuildBridgeWindow(start_tile, end_tile, TRANSPORT_ROAD, _cur_roadtype);
686 break;
687
688 case DDSP_DEMOLISH_AREA:
689 GUIPlaceProcDragXY(select_proc, start_tile, end_tile);
690 break;
691
692 case DDSP_PLACE_ROAD_X_DIR:
693 case DDSP_PLACE_ROAD_Y_DIR:
694 case DDSP_PLACE_AUTOROAD: {
695 bool start_half = _place_road_dir == AXIS_Y ? _place_road_start_half_y : _place_road_start_half_x;
696
697 if (_remove_button_clicked) {
698 Command<CMD_REMOVE_LONG_ROAD>::Post(this->rti->strings.err_remove_road, CcPlaySound_CONSTRUCTION_OTHER,
699 end_tile, start_tile, _cur_roadtype, _place_road_dir, start_half, _place_road_end_half);
700 } else {
701 Command<CMD_BUILD_LONG_ROAD>::Post(this->rti->strings.err_build_road, CcPlaySound_CONSTRUCTION_OTHER,
702 end_tile, start_tile, _cur_roadtype, _place_road_dir, _one_way_button_clicked ? DRD_NORTHBOUND : DRD_NONE, start_half, _place_road_end_half, false);
703 }
704 break;
705 }
706
707 case DDSP_BUILD_BUSSTOP:
708 case DDSP_REMOVE_BUSSTOP:
709 if (this->IsWidgetLowered(WID_ROT_BUS_STATION) && GetIfClassHasNewStopsByType(RoadStopClass::Get(_roadstop_gui_settings.roadstop_class), ROADSTOP_BUS, _cur_roadtype)) {
710 if (_remove_button_clicked) {
711 TileArea ta(start_tile, end_tile);
712 Command<CMD_REMOVE_ROAD_STOP>::Post(this->rti->strings.err_remove_station[ROADSTOP_BUS], CcPlaySound_CONSTRUCTION_OTHER, ta.tile, ta.w, ta.h, ROADSTOP_BUS, _ctrl_pressed);
713 } else {
714 PlaceRoadStop(start_tile, end_tile, ROADSTOP_BUS, _ctrl_pressed, _cur_roadtype, this->rti->strings.err_build_station[ROADSTOP_BUS]);
715 }
716 }
717 break;
718
719 case DDSP_BUILD_TRUCKSTOP:
720 case DDSP_REMOVE_TRUCKSTOP:
721 if (this->IsWidgetLowered(WID_ROT_TRUCK_STATION) && GetIfClassHasNewStopsByType(RoadStopClass::Get(_roadstop_gui_settings.roadstop_class), ROADSTOP_TRUCK, _cur_roadtype)) {
722 if (_remove_button_clicked) {
723 TileArea ta(start_tile, end_tile);
724 Command<CMD_REMOVE_ROAD_STOP>::Post(this->rti->strings.err_remove_station[ROADSTOP_TRUCK], CcPlaySound_CONSTRUCTION_OTHER, ta.tile, ta.w, ta.h, ROADSTOP_TRUCK, _ctrl_pressed);
725 } else {
726 PlaceRoadStop(start_tile, end_tile, ROADSTOP_TRUCK, _ctrl_pressed, _cur_roadtype, this->rti->strings.err_build_station[ROADSTOP_TRUCK]);
727 }
728 }
729 break;
730
731 case DDSP_CONVERT_ROAD:
732 Command<CMD_CONVERT_ROAD>::Post(rti->strings.err_convert_road, CcPlaySound_CONSTRUCTION_OTHER, end_tile, start_tile, _cur_roadtype);
733 break;
734 }
735 }
736 }
737
738 void OnPlacePresize([[maybe_unused]] Point pt, TileIndex tile) override
739 {
740 Command<CMD_BUILD_TUNNEL>::Do(DC_AUTO, tile, TRANSPORT_ROAD, _cur_roadtype);
741 VpSetPresizeRange(tile, _build_tunnel_endtile == 0 ? tile : _build_tunnel_endtile);
742 }
743
744 EventState OnCTRLStateChange() override
745 {
746 if (RoadToolbar_CtrlChanged(this)) return ES_HANDLED;
747 return ES_NOT_HANDLED;
748 }
749
756 static EventState RoadTramToolbarGlobalHotkeys(int hotkey, RoadType last_build, RoadTramType rtt)
757 {
758 Window *w = nullptr;
759 switch (_game_mode) {
760 case GM_NORMAL:
761 w = ShowBuildRoadToolbar(last_build);
762 break;
763
764 case GM_EDITOR:
765 if ((GetRoadTypes(true) & ((rtt == RTT_ROAD) ? ~_roadtypes_type : _roadtypes_type)) == ROADTYPES_NONE) return ES_NOT_HANDLED;
766 w = ShowBuildRoadScenToolbar(last_build);
767 break;
768
769 default:
770 break;
771 }
772
773 if (w == nullptr) return ES_NOT_HANDLED;
774 return w->OnHotkey(hotkey);
775 }
776
777 static EventState RoadToolbarGlobalHotkeys(int hotkey)
778 {
779 extern RoadType _last_built_roadtype;
780 return RoadTramToolbarGlobalHotkeys(hotkey, _last_built_roadtype, RTT_ROAD);
781 }
782
783 static EventState TramToolbarGlobalHotkeys(int hotkey)
784 {
785 extern RoadType _last_built_tramtype;
786 return RoadTramToolbarGlobalHotkeys(hotkey, _last_built_tramtype, RTT_TRAM);
787 }
788
789 static inline HotkeyList road_hotkeys{"roadtoolbar", {
790 Hotkey('1', "build_x", WID_ROT_ROAD_X),
791 Hotkey('2', "build_y", WID_ROT_ROAD_Y),
792 Hotkey('3', "autoroad", WID_ROT_AUTOROAD),
793 Hotkey('4', "demolish", WID_ROT_DEMOLISH),
794 Hotkey('5', "depot", WID_ROT_DEPOT),
795 Hotkey('6', "bus_station", WID_ROT_BUS_STATION),
796 Hotkey('7', "truck_station", WID_ROT_TRUCK_STATION),
797 Hotkey('8', "oneway", WID_ROT_ONE_WAY),
798 Hotkey('B', "bridge", WID_ROT_BUILD_BRIDGE),
799 Hotkey('T', "tunnel", WID_ROT_BUILD_TUNNEL),
800 Hotkey('R', "remove", WID_ROT_REMOVE),
801 Hotkey('C', "convert", WID_ROT_CONVERT_ROAD),
802 }, RoadToolbarGlobalHotkeys};
803
804 static inline HotkeyList tram_hotkeys{"tramtoolbar", {
805 Hotkey('1', "build_x", WID_ROT_ROAD_X),
806 Hotkey('2', "build_y", WID_ROT_ROAD_Y),
807 Hotkey('3', "autoroad", WID_ROT_AUTOROAD),
808 Hotkey('4', "demolish", WID_ROT_DEMOLISH),
809 Hotkey('5', "depot", WID_ROT_DEPOT),
810 Hotkey('6', "bus_station", WID_ROT_BUS_STATION),
811 Hotkey('7', "truck_station", WID_ROT_TRUCK_STATION),
812 Hotkey('B', "bridge", WID_ROT_BUILD_BRIDGE),
813 Hotkey('T', "tunnel", WID_ROT_BUILD_TUNNEL),
814 Hotkey('R', "remove", WID_ROT_REMOVE),
815 Hotkey('C', "convert", WID_ROT_CONVERT_ROAD),
816 }, TramToolbarGlobalHotkeys};
817 };
818
819 static constexpr NWidgetPart _nested_build_road_widgets[] = {
820 NWidget(NWID_HORIZONTAL),
821 NWidget(WWT_CLOSEBOX, COLOUR_DARK_GREEN),
822 NWidget(WWT_CAPTION, COLOUR_DARK_GREEN, WID_ROT_CAPTION), SetDataTip(STR_JUST_STRING2, STR_TOOLTIP_WINDOW_TITLE_DRAG_THIS), SetTextStyle(TC_WHITE),
823 NWidget(WWT_STICKYBOX, COLOUR_DARK_GREEN),
824 EndContainer(),
825 NWidget(NWID_HORIZONTAL),
826 NWidget(WWT_IMGBTN, COLOUR_DARK_GREEN, WID_ROT_ROAD_X),
827 SetFill(0, 1), SetMinimalSize(22, 22), SetDataTip(SPR_IMG_ROAD_X_DIR, STR_ROAD_TOOLBAR_TOOLTIP_BUILD_ROAD_SECTION),
828 NWidget(WWT_IMGBTN, COLOUR_DARK_GREEN, WID_ROT_ROAD_Y),
829 SetFill(0, 1), SetMinimalSize(22, 22), SetDataTip(SPR_IMG_ROAD_Y_DIR, STR_ROAD_TOOLBAR_TOOLTIP_BUILD_ROAD_SECTION),
830 NWidget(WWT_IMGBTN, COLOUR_DARK_GREEN, WID_ROT_AUTOROAD),
831 SetFill(0, 1), SetMinimalSize(22, 22), SetDataTip(SPR_IMG_AUTOROAD, STR_ROAD_TOOLBAR_TOOLTIP_BUILD_AUTOROAD),
832 NWidget(WWT_IMGBTN, COLOUR_DARK_GREEN, WID_ROT_DEMOLISH),
833 SetFill(0, 1), SetMinimalSize(22, 22), SetDataTip(SPR_IMG_DYNAMITE, STR_TOOLTIP_DEMOLISH_BUILDINGS_ETC),
834 NWidget(WWT_IMGBTN, COLOUR_DARK_GREEN, WID_ROT_DEPOT),
835 SetFill(0, 1), SetMinimalSize(22, 22), SetDataTip(SPR_IMG_ROAD_DEPOT, STR_ROAD_TOOLBAR_TOOLTIP_BUILD_ROAD_VEHICLE_DEPOT),
836 NWidget(WWT_IMGBTN, COLOUR_DARK_GREEN, WID_ROT_BUS_STATION),
837 SetFill(0, 1), SetMinimalSize(22, 22), SetDataTip(SPR_IMG_BUS_STATION, STR_ROAD_TOOLBAR_TOOLTIP_BUILD_BUS_STATION),
838 NWidget(WWT_IMGBTN, COLOUR_DARK_GREEN, WID_ROT_TRUCK_STATION),
839 SetFill(0, 1), SetMinimalSize(22, 22), SetDataTip(SPR_IMG_TRUCK_BAY, STR_ROAD_TOOLBAR_TOOLTIP_BUILD_TRUCK_LOADING_BAY),
840 NWidget(WWT_PANEL, COLOUR_DARK_GREEN, -1), SetMinimalSize(0, 22), SetFill(1, 1), EndContainer(),
841 NWidget(WWT_IMGBTN, COLOUR_DARK_GREEN, WID_ROT_ONE_WAY),
842 SetFill(0, 1), SetMinimalSize(22, 22), SetDataTip(SPR_IMG_ROAD_ONE_WAY, STR_ROAD_TOOLBAR_TOOLTIP_TOGGLE_ONE_WAY_ROAD),
843 NWidget(WWT_IMGBTN, COLOUR_DARK_GREEN, WID_ROT_BUILD_BRIDGE),
844 SetFill(0, 1), SetMinimalSize(43, 22), SetDataTip(SPR_IMG_BRIDGE, STR_ROAD_TOOLBAR_TOOLTIP_BUILD_ROAD_BRIDGE),
845 NWidget(WWT_IMGBTN, COLOUR_DARK_GREEN, WID_ROT_BUILD_TUNNEL),
846 SetFill(0, 1), SetMinimalSize(22, 22), SetDataTip(SPR_IMG_ROAD_TUNNEL, STR_ROAD_TOOLBAR_TOOLTIP_BUILD_ROAD_TUNNEL),
847 NWidget(WWT_IMGBTN, COLOUR_DARK_GREEN, WID_ROT_REMOVE),
848 SetFill(0, 1), SetMinimalSize(22, 22), SetDataTip(SPR_IMG_REMOVE, STR_ROAD_TOOLBAR_TOOLTIP_TOGGLE_BUILD_REMOVE_FOR_ROAD),
849 NWidget(WWT_IMGBTN, COLOUR_DARK_GREEN, WID_ROT_CONVERT_ROAD),
850 SetFill(0, 1), SetMinimalSize(22, 22), SetDataTip(SPR_IMG_CONVERT_ROAD, STR_ROAD_TOOLBAR_TOOLTIP_CONVERT_ROAD),
851 EndContainer(),
852 };
853
854 static WindowDesc _build_road_desc(__FILE__, __LINE__,
855 WDP_ALIGN_TOOLBAR, "toolbar_road", 0, 0,
856 WC_BUILD_TOOLBAR, WC_NONE,
857 WDF_CONSTRUCTION,
858 std::begin(_nested_build_road_widgets), std::end(_nested_build_road_widgets),
859 &BuildRoadToolbarWindow::road_hotkeys
860 );
861
862 static constexpr NWidgetPart _nested_build_tramway_widgets[] = {
863 NWidget(NWID_HORIZONTAL),
864 NWidget(WWT_CLOSEBOX, COLOUR_DARK_GREEN),
865 NWidget(WWT_CAPTION, COLOUR_DARK_GREEN, WID_ROT_CAPTION), SetDataTip(STR_JUST_STRING2, STR_TOOLTIP_WINDOW_TITLE_DRAG_THIS), SetTextStyle(TC_WHITE),
866 NWidget(WWT_STICKYBOX, COLOUR_DARK_GREEN),
867 EndContainer(),
868 NWidget(NWID_HORIZONTAL),
869 NWidget(WWT_IMGBTN, COLOUR_DARK_GREEN, WID_ROT_ROAD_X),
870 SetFill(0, 1), SetMinimalSize(22, 22), SetDataTip(SPR_IMG_TRAMWAY_X_DIR, STR_ROAD_TOOLBAR_TOOLTIP_BUILD_TRAMWAY_SECTION),
871 NWidget(WWT_IMGBTN, COLOUR_DARK_GREEN, WID_ROT_ROAD_Y),
872 SetFill(0, 1), SetMinimalSize(22, 22), SetDataTip(SPR_IMG_TRAMWAY_Y_DIR, STR_ROAD_TOOLBAR_TOOLTIP_BUILD_TRAMWAY_SECTION),
873 NWidget(WWT_IMGBTN, COLOUR_DARK_GREEN, WID_ROT_AUTOROAD),
874 SetFill(0, 1), SetMinimalSize(22, 22), SetDataTip(SPR_IMG_AUTOTRAM, STR_ROAD_TOOLBAR_TOOLTIP_BUILD_AUTOTRAM),
875 NWidget(WWT_IMGBTN, COLOUR_DARK_GREEN, WID_ROT_DEMOLISH),
876 SetFill(0, 1), SetMinimalSize(22, 22), SetDataTip(SPR_IMG_DYNAMITE, STR_TOOLTIP_DEMOLISH_BUILDINGS_ETC),
877 NWidget(WWT_IMGBTN, COLOUR_DARK_GREEN, WID_ROT_DEPOT),
878 SetFill(0, 1), SetMinimalSize(22, 22), SetDataTip(SPR_IMG_ROAD_DEPOT, STR_ROAD_TOOLBAR_TOOLTIP_BUILD_TRAM_VEHICLE_DEPOT),
879 NWidget(WWT_IMGBTN, COLOUR_DARK_GREEN, WID_ROT_BUS_STATION),
880 SetFill(0, 1), SetMinimalSize(22, 22), SetDataTip(SPR_IMG_BUS_STATION, STR_ROAD_TOOLBAR_TOOLTIP_BUILD_PASSENGER_TRAM_STATION),
881 NWidget(WWT_IMGBTN, COLOUR_DARK_GREEN, WID_ROT_TRUCK_STATION),
882 SetFill(0, 1), SetMinimalSize(22, 22), SetDataTip(SPR_IMG_TRUCK_BAY, STR_ROAD_TOOLBAR_TOOLTIP_BUILD_CARGO_TRAM_STATION),
883 NWidget(WWT_PANEL, COLOUR_DARK_GREEN, -1), SetMinimalSize(0, 22), SetFill(1, 1), EndContainer(),
884 NWidget(WWT_IMGBTN, COLOUR_DARK_GREEN, WID_ROT_BUILD_BRIDGE),
885 SetFill(0, 1), SetMinimalSize(43, 22), SetDataTip(SPR_IMG_BRIDGE, STR_ROAD_TOOLBAR_TOOLTIP_BUILD_TRAMWAY_BRIDGE),
886 NWidget(WWT_IMGBTN, COLOUR_DARK_GREEN, WID_ROT_BUILD_TUNNEL),
887 SetFill(0, 1), SetMinimalSize(22, 22), SetDataTip(SPR_IMG_ROAD_TUNNEL, STR_ROAD_TOOLBAR_TOOLTIP_BUILD_TRAMWAY_TUNNEL),
888 NWidget(WWT_IMGBTN, COLOUR_DARK_GREEN, WID_ROT_REMOVE),
889 SetFill(0, 1), SetMinimalSize(22, 22), SetDataTip(SPR_IMG_REMOVE, STR_ROAD_TOOLBAR_TOOLTIP_TOGGLE_BUILD_REMOVE_FOR_TRAMWAYS),
890 NWidget(WWT_IMGBTN, COLOUR_DARK_GREEN, WID_ROT_CONVERT_ROAD),
891 SetFill(0, 1), SetMinimalSize(22, 22), SetDataTip(SPR_IMG_CONVERT_ROAD, STR_ROAD_TOOLBAR_TOOLTIP_CONVERT_TRAM),
892 EndContainer(),
893 };
894
895 static WindowDesc _build_tramway_desc(__FILE__, __LINE__,
896 WDP_ALIGN_TOOLBAR, "toolbar_tramway", 0, 0,
897 WC_BUILD_TOOLBAR, WC_NONE,
898 WDF_CONSTRUCTION,
899 std::begin(_nested_build_tramway_widgets), std::end(_nested_build_tramway_widgets),
900 &BuildRoadToolbarWindow::tram_hotkeys
901 );
902
910 Window *ShowBuildRoadToolbar(RoadType roadtype)
911 {
912 if (!Company::IsValidID(_local_company)) return nullptr;
913 if (!ValParamRoadType(roadtype)) return nullptr;
914
915 CloseWindowByClass(WC_BUILD_TOOLBAR);
916 _cur_roadtype = roadtype;
917
918 return AllocateWindowDescFront<BuildRoadToolbarWindow>(RoadTypeIsRoad(_cur_roadtype) ? &_build_road_desc : &_build_tramway_desc, TRANSPORT_ROAD);
919 }
920
921 static constexpr NWidgetPart _nested_build_road_scen_widgets[] = {
922 NWidget(NWID_HORIZONTAL),
923 NWidget(WWT_CLOSEBOX, COLOUR_DARK_GREEN),
924 NWidget(WWT_CAPTION, COLOUR_DARK_GREEN, WID_ROT_CAPTION), SetDataTip(STR_JUST_STRING2, STR_TOOLTIP_WINDOW_TITLE_DRAG_THIS), SetTextStyle(TC_WHITE),
925 NWidget(WWT_STICKYBOX, COLOUR_DARK_GREEN),
926 EndContainer(),
927 NWidget(NWID_HORIZONTAL),
928 NWidget(WWT_IMGBTN, COLOUR_DARK_GREEN, WID_ROT_ROAD_X),
929 SetFill(0, 1), SetMinimalSize(22, 22), SetDataTip(SPR_IMG_ROAD_X_DIR, STR_ROAD_TOOLBAR_TOOLTIP_BUILD_ROAD_SECTION),
930 NWidget(WWT_IMGBTN, COLOUR_DARK_GREEN, WID_ROT_ROAD_Y),
931 SetFill(0, 1), SetMinimalSize(22, 22), SetDataTip(SPR_IMG_ROAD_Y_DIR, STR_ROAD_TOOLBAR_TOOLTIP_BUILD_ROAD_SECTION),
932 NWidget(WWT_IMGBTN, COLOUR_DARK_GREEN, WID_ROT_AUTOROAD),
933 SetFill(0, 1), SetMinimalSize(22, 22), SetDataTip(SPR_IMG_AUTOROAD, STR_ROAD_TOOLBAR_TOOLTIP_BUILD_AUTOROAD),
934 NWidget(WWT_IMGBTN, COLOUR_DARK_GREEN, WID_ROT_DEMOLISH),
935 SetFill(0, 1), SetMinimalSize(22, 22), SetDataTip(SPR_IMG_DYNAMITE, STR_TOOLTIP_DEMOLISH_BUILDINGS_ETC),
936 NWidget(WWT_PANEL, COLOUR_DARK_GREEN, -1), SetMinimalSize(0, 22), SetFill(1, 1), EndContainer(),
937 NWidget(WWT_IMGBTN, COLOUR_DARK_GREEN, WID_ROT_ONE_WAY),
938 SetFill(0, 1), SetMinimalSize(22, 22), SetDataTip(SPR_IMG_ROAD_ONE_WAY, STR_ROAD_TOOLBAR_TOOLTIP_TOGGLE_ONE_WAY_ROAD),
939 NWidget(WWT_IMGBTN, COLOUR_DARK_GREEN, WID_ROT_BUILD_BRIDGE),
940 SetFill(0, 1), SetMinimalSize(43, 22), SetDataTip(SPR_IMG_BRIDGE, STR_ROAD_TOOLBAR_TOOLTIP_BUILD_ROAD_BRIDGE),
941 NWidget(WWT_IMGBTN, COLOUR_DARK_GREEN, WID_ROT_BUILD_TUNNEL),
942 SetFill(0, 1), SetMinimalSize(22, 22), SetDataTip(SPR_IMG_ROAD_TUNNEL, STR_ROAD_TOOLBAR_TOOLTIP_BUILD_ROAD_TUNNEL),
943 NWidget(WWT_IMGBTN, COLOUR_DARK_GREEN, WID_ROT_REMOVE),
944 SetFill(0, 1), SetMinimalSize(22, 22), SetDataTip(SPR_IMG_REMOVE, STR_ROAD_TOOLBAR_TOOLTIP_TOGGLE_BUILD_REMOVE_FOR_ROAD),
945 NWidget(WWT_IMGBTN, COLOUR_DARK_GREEN, WID_ROT_CONVERT_ROAD),
946 SetFill(0, 1), SetMinimalSize(22, 22), SetDataTip(SPR_IMG_CONVERT_ROAD, STR_ROAD_TOOLBAR_TOOLTIP_CONVERT_ROAD),
947 EndContainer(),
948 };
949
950 static WindowDesc _build_road_scen_desc(__FILE__, __LINE__,
951 WDP_AUTO, "toolbar_road_scen", 0, 0,
952 WC_SCEN_BUILD_TOOLBAR, WC_NONE,
953 WDF_CONSTRUCTION,
954 std::begin(_nested_build_road_scen_widgets), std::end(_nested_build_road_scen_widgets),
955 &BuildRoadToolbarWindow::road_hotkeys
956 );
957
958 static constexpr NWidgetPart _nested_build_tramway_scen_widgets[] = {
959 NWidget(NWID_HORIZONTAL),
960 NWidget(WWT_CLOSEBOX, COLOUR_DARK_GREEN),
961 NWidget(WWT_CAPTION, COLOUR_DARK_GREEN, WID_ROT_CAPTION), SetDataTip(STR_JUST_STRING2, STR_TOOLTIP_WINDOW_TITLE_DRAG_THIS), SetTextStyle(TC_WHITE),
962 NWidget(WWT_STICKYBOX, COLOUR_DARK_GREEN),
963 EndContainer(),
964 NWidget(NWID_HORIZONTAL),
965 NWidget(WWT_IMGBTN, COLOUR_DARK_GREEN, WID_ROT_ROAD_X),
966 SetFill(0, 1), SetMinimalSize(22, 22), SetDataTip(SPR_IMG_TRAMWAY_X_DIR, STR_ROAD_TOOLBAR_TOOLTIP_BUILD_TRAMWAY_SECTION),
967 NWidget(WWT_IMGBTN, COLOUR_DARK_GREEN, WID_ROT_ROAD_Y),
968 SetFill(0, 1), SetMinimalSize(22, 22), SetDataTip(SPR_IMG_TRAMWAY_Y_DIR, STR_ROAD_TOOLBAR_TOOLTIP_BUILD_TRAMWAY_SECTION),
969 NWidget(WWT_IMGBTN, COLOUR_DARK_GREEN, WID_ROT_AUTOROAD),
970 SetFill(0, 1), SetMinimalSize(22, 22), SetDataTip(SPR_IMG_AUTOTRAM, STR_ROAD_TOOLBAR_TOOLTIP_BUILD_AUTOTRAM),
971 NWidget(WWT_IMGBTN, COLOUR_DARK_GREEN, WID_ROT_DEMOLISH),
972 SetFill(0, 1), SetMinimalSize(22, 22), SetDataTip(SPR_IMG_DYNAMITE, STR_TOOLTIP_DEMOLISH_BUILDINGS_ETC),
973 NWidget(WWT_PANEL, COLOUR_DARK_GREEN, -1), SetMinimalSize(0, 22), SetFill(1, 1), EndContainer(),
974 NWidget(WWT_IMGBTN, COLOUR_DARK_GREEN, WID_ROT_BUILD_BRIDGE),
975 SetFill(0, 1), SetMinimalSize(43, 22), SetDataTip(SPR_IMG_BRIDGE, STR_ROAD_TOOLBAR_TOOLTIP_BUILD_TRAMWAY_BRIDGE),
976 NWidget(WWT_IMGBTN, COLOUR_DARK_GREEN, WID_ROT_BUILD_TUNNEL),
977 SetFill(0, 1), SetMinimalSize(22, 22), SetDataTip(SPR_IMG_ROAD_TUNNEL, STR_ROAD_TOOLBAR_TOOLTIP_BUILD_TRAMWAY_TUNNEL),
978 NWidget(WWT_IMGBTN, COLOUR_DARK_GREEN, WID_ROT_REMOVE),
979 SetFill(0, 1), SetMinimalSize(22, 22), SetDataTip(SPR_IMG_REMOVE, STR_ROAD_TOOLBAR_TOOLTIP_TOGGLE_BUILD_REMOVE_FOR_TRAMWAYS),
980 NWidget(WWT_IMGBTN, COLOUR_DARK_GREEN, WID_ROT_CONVERT_ROAD),
981 SetFill(0, 1), SetMinimalSize(22, 22), SetDataTip(SPR_IMG_CONVERT_ROAD, STR_ROAD_TOOLBAR_TOOLTIP_CONVERT_TRAM),
982 EndContainer(),
983 };
984
985 static WindowDesc _build_tramway_scen_desc(__FILE__, __LINE__,
986 WDP_AUTO, "toolbar_tram_scen", 0, 0,
987 WC_SCEN_BUILD_TOOLBAR, WC_NONE,
988 WDF_CONSTRUCTION,
989 std::begin(_nested_build_tramway_scen_widgets), std::end(_nested_build_tramway_scen_widgets),
990 &BuildRoadToolbarWindow::tram_hotkeys
991 );
992
997 Window *ShowBuildRoadScenToolbar(RoadType roadtype)
998 {
999 CloseWindowById(WC_SCEN_BUILD_TOOLBAR, TRANSPORT_ROAD);
1000 _cur_roadtype = roadtype;
1001
1002 return AllocateWindowDescFront<BuildRoadToolbarWindow>(RoadTypeIsRoad(_cur_roadtype) ? &_build_road_scen_desc : &_build_tramway_scen_desc, TRANSPORT_ROAD);
1003 }
1004
1005 struct BuildRoadDepotWindow : public PickerWindowBase {
1006 BuildRoadDepotWindow(WindowDesc *desc, Window *parent) : PickerWindowBase(desc, parent)
1007 {
1008 this->CreateNestedTree();
1009
1010 this->LowerWidget(WID_BROD_DEPOT_NE + _road_depot_orientation);
1011 if (RoadTypeIsTram(_cur_roadtype)) {
1012 this->GetWidget<NWidgetCore>(WID_BROD_CAPTION)->widget_data = STR_BUILD_DEPOT_TRAM_ORIENTATION_CAPTION;
1013 for (WidgetID i = WID_BROD_DEPOT_NE; i <= WID_BROD_DEPOT_NW; i++) {
1014 this->GetWidget<NWidgetCore>(i)->tool_tip = STR_BUILD_DEPOT_TRAM_ORIENTATION_SELECT_TOOLTIP;
1015 }
1016 }
1017
1018 this->FinishInitNested(TRANSPORT_ROAD);
1019 }
1020
1021 void UpdateWidgetSize(WidgetID widget, Dimension *size, [[maybe_unused]] const Dimension &padding, [[maybe_unused]] Dimension *fill, [[maybe_unused]] Dimension *resize) override
1022 {
1023 if (!IsInsideMM(widget, WID_BROD_DEPOT_NE, WID_BROD_DEPOT_NW + 1)) return;
1024
1025 size->width = ScaleGUITrad(64) + WidgetDimensions::scaled.fullbevel.Horizontal();
1026 size->height = ScaleGUITrad(48) + WidgetDimensions::scaled.fullbevel.Vertical();
1027 }
1028
1029 void DrawWidget(const Rect &r, WidgetID widget) const override
1030 {
1031 if (!IsInsideMM(widget, WID_BROD_DEPOT_NE, WID_BROD_DEPOT_NW + 1)) return;
1032
1033 DrawPixelInfo tmp_dpi;
1034 Rect ir = r.Shrink(WidgetDimensions::scaled.bevel);
1035 if (FillDrawPixelInfo(&tmp_dpi, ir)) {
1036 AutoRestoreBackup dpi_backup(_cur_dpi, &tmp_dpi);
1037 int x = (ir.Width() - ScaleSpriteTrad(64)) / 2 + ScaleSpriteTrad(31);
1038 int y = (ir.Height() + ScaleSpriteTrad(48)) / 2 - ScaleSpriteTrad(31);
1039 DrawRoadDepotSprite(x, y, (DiagDirection)(widget - WID_BROD_DEPOT_NE + DIAGDIR_NE), _cur_roadtype);
1040 }
1041 }
1042
1043 void OnClick([[maybe_unused]] Point pt, WidgetID widget, [[maybe_unused]] int click_count) override
1044 {
1045 switch (widget) {
1046 case WID_BROD_DEPOT_NW:
1047 case WID_BROD_DEPOT_NE:
1048 case WID_BROD_DEPOT_SW:
1049 case WID_BROD_DEPOT_SE:
1050 this->RaiseWidget(WID_BROD_DEPOT_NE + _road_depot_orientation);
1051 _road_depot_orientation = (DiagDirection)(widget - WID_BROD_DEPOT_NE);
1052 this->LowerWidget(WID_BROD_DEPOT_NE + _road_depot_orientation);
1053 if (_settings_client.sound.click_beep) SndPlayFx(SND_15_BEEP);
1054 this->SetDirty();
1055 break;
1056
1057 default:
1058 break;
1059 }
1060 }
1061 };
1062
1063 static constexpr NWidgetPart _nested_build_road_depot_widgets[] = {
1064 NWidget(NWID_HORIZONTAL),
1065 NWidget(WWT_CLOSEBOX, COLOUR_DARK_GREEN),
1066 NWidget(WWT_CAPTION, COLOUR_DARK_GREEN, WID_BROD_CAPTION), SetDataTip(STR_BUILD_DEPOT_ROAD_ORIENTATION_CAPTION, STR_TOOLTIP_WINDOW_TITLE_DRAG_THIS),
1067 EndContainer(),
1068 NWidget(WWT_PANEL, COLOUR_DARK_GREEN),
1069 NWidget(NWID_HORIZONTAL_LTR), SetPIP(0, WidgetDimensions::unscaled.hsep_normal, 0), SetPIPRatio(1, 0, 1), SetPadding(WidgetDimensions::unscaled.picker),
1070 NWidget(NWID_VERTICAL), SetPIP(0, WidgetDimensions::unscaled.vsep_normal, 0),
1071 NWidget(WWT_TEXTBTN, COLOUR_GREY, WID_BROD_DEPOT_NW), SetMinimalSize(66, 50), SetFill(0, 0), SetDataTip(0x0, STR_BUILD_DEPOT_ROAD_ORIENTATION_SELECT_TOOLTIP),
1072 NWidget(WWT_TEXTBTN, COLOUR_GREY, WID_BROD_DEPOT_SW), SetMinimalSize(66, 50), SetFill(0, 0), SetDataTip(0x0, STR_BUILD_DEPOT_ROAD_ORIENTATION_SELECT_TOOLTIP),
1073 EndContainer(),
1074 NWidget(NWID_VERTICAL), SetPIP(0, WidgetDimensions::unscaled.vsep_normal, 0),
1075 NWidget(WWT_TEXTBTN, COLOUR_GREY, WID_BROD_DEPOT_NE), SetMinimalSize(66, 50), SetFill(0, 0), SetDataTip(0x0, STR_BUILD_DEPOT_ROAD_ORIENTATION_SELECT_TOOLTIP),
1076 NWidget(WWT_TEXTBTN, COLOUR_GREY, WID_BROD_DEPOT_SE), SetMinimalSize(66, 50), SetFill(0, 0), SetDataTip(0x0, STR_BUILD_DEPOT_ROAD_ORIENTATION_SELECT_TOOLTIP),
1077 EndContainer(),
1078 EndContainer(),
1079 EndContainer(),
1080 };
1081
1082 static WindowDesc _build_road_depot_desc(__FILE__, __LINE__,
1083 WDP_AUTO, nullptr, 0, 0,
1084 WC_BUILD_DEPOT, WC_BUILD_TOOLBAR,
1085 WDF_CONSTRUCTION,
1086 std::begin(_nested_build_road_depot_widgets), std::end(_nested_build_road_depot_widgets)
1087 );
1088
1089 static void ShowRoadDepotPicker(Window *parent)
1090 {
1091 new BuildRoadDepotWindow(&_build_road_depot_desc, parent);
1092 }
1093
1095 enum BuildRoadStopHotkeys {
1096 BROSHK_FOCUS_FILTER_BOX,
1097 };
1098
1099 struct BuildRoadStationWindow : public PickerWindowBase {
1100 private:
1101 RoadStopType roadStopType;
1102 uint line_height;
1103 uint coverage_height;
1104 Scrollbar *vscrollList;
1105 Scrollbar *vscrollMatrix;
1106
1107 typedef GUIList<RoadStopClassID, std::nullptr_t, StringFilter &> GUIRoadStopClassList;
1108
1109 static const uint EDITBOX_MAX_SIZE = 16;
1110
1111 static Listing last_sorting;
1112 static Filtering last_filtering;
1113 static GUIRoadStopClassList::SortFunction * const sorter_funcs[];
1114 static GUIRoadStopClassList::FilterFunction * const filter_funcs[];
1115 GUIRoadStopClassList roadstop_classes;
1116 StringFilter string_filter;
1117 QueryString filter_editbox;
1118
1119 void EnsureSelectedClassIsVisible()
1120 {
1121 uint pos = 0;
1122 for (auto rs_class : this->roadstop_classes) {
1123 if (rs_class == _roadstop_gui_settings.roadstop_class) break;
1124 pos++;
1125 }
1126 this->vscrollList->SetCount(this->roadstop_classes.size());
1127 this->vscrollList->ScrollTowards(pos);
1128 }
1129
1130 void CheckOrientationValid()
1131 {
1132 const RoadStopSpec *spec = RoadStopClass::Get(_roadstop_gui_settings.roadstop_class)->GetSpec(_roadstop_gui_settings.roadstop_type);
1133
1134 /* Raise and lower to ensure the correct widget is lowered after changing displayed orientation plane. */
1135 if (RoadTypeIsRoad(_cur_roadtype)) {
1136 this->RaiseWidget(WID_BROS_STATION_NE + _roadstop_gui_settings.orientation);
1137 this->GetWidget<NWidgetStacked>(WID_BROS_AVAILABLE_ORIENTATIONS)->SetDisplayedPlane((spec != nullptr && HasBit(spec->flags, RSF_DRIVE_THROUGH_ONLY)) ? 1 : 0);
1138 this->LowerWidget(WID_BROS_STATION_NE + _roadstop_gui_settings.orientation);
1139 }
1140
1141 if (_roadstop_gui_settings.orientation >= DIAGDIR_END) return;
1142
1143 if (spec != nullptr && HasBit(spec->flags, RSF_DRIVE_THROUGH_ONLY)) {
1144 this->RaiseWidget(WID_BROS_STATION_NE + _roadstop_gui_settings.orientation);
1145 _roadstop_gui_settings.orientation = DIAGDIR_END;
1146 this->LowerWidget(WID_BROS_STATION_NE + _roadstop_gui_settings.orientation);
1147 this->SetDirty();
1148 CloseWindowById(WC_SELECT_STATION, 0);
1149 }
1150 }
1151
1152 public:
1153 BuildRoadStationWindow(WindowDesc *desc, Window *parent, RoadStopType rs) : PickerWindowBase(desc, parent), filter_editbox(EDITBOX_MAX_SIZE * MAX_CHAR_LENGTH, EDITBOX_MAX_SIZE)
1154 {
1155 this->coverage_height = 2 * GetCharacterHeight(FS_NORMAL) + WidgetDimensions::scaled.vsep_normal;
1156 this->vscrollList = nullptr;
1157 this->vscrollMatrix = nullptr;
1158 this->roadStopType = rs;
1159 bool newstops = GetIfNewStopsByType(rs, _cur_roadtype);
1160
1161 this->CreateNestedTree();
1162
1163 /* Hide the station class filter if no stations other than the default one are available. */
1164 this->GetWidget<NWidgetStacked>(WID_BROS_SHOW_NEWST_DEFSIZE)->SetDisplayedPlane(newstops ? 0 : SZSP_NONE);
1165 this->GetWidget<NWidgetStacked>(WID_BROS_FILTER_CONTAINER)->SetDisplayedPlane(newstops ? 0 : SZSP_HORIZONTAL);
1166 this->GetWidget<NWidgetStacked>(WID_BROS_SHOW_NEWST_ADDITIONS)->SetDisplayedPlane(newstops ? 0 : SZSP_HORIZONTAL);
1167 this->GetWidget<NWidgetStacked>(WID_BROS_SHOW_NEWST_ORIENTATION)->SetDisplayedPlane(newstops ? 0 : SZSP_HORIZONTAL);
1168 this->GetWidget<NWidgetStacked>(WID_BROS_SHOW_NEWST_TYPE_SEL)->SetDisplayedPlane(newstops ? 0 : SZSP_HORIZONTAL);
1169 this->GetWidget<NWidgetStacked>(WID_BROS_SHOW_NEWST_MATRIX)->SetDisplayedPlane(newstops ? 0 : SZSP_NONE);
1170 this->GetWidget<NWidgetStacked>(WID_BROS_SHOW_NEWST_RESIZE)->SetDisplayedPlane(newstops ? 0 : SZSP_NONE);
1171 if (newstops) {
1172 this->vscrollList = this->GetScrollbar(WID_BROS_NEWST_SCROLL);
1173 this->vscrollMatrix = this->GetScrollbar(WID_BROS_MATRIX_SCROLL);
1174
1175 this->querystrings[WID_BROS_FILTER_EDITBOX] = &this->filter_editbox;
1176 this->roadstop_classes.SetListing(this->last_sorting);
1177 this->roadstop_classes.SetFiltering(this->last_filtering);
1178 this->roadstop_classes.SetSortFuncs(this->sorter_funcs);
1179 this->roadstop_classes.SetFilterFuncs(this->filter_funcs);
1180 }
1181
1182 this->roadstop_classes.ForceRebuild();
1183 BuildRoadStopClassesAvailable();
1184
1185 /* Trams don't have non-drivethrough stations */
1186 if (RoadTypeIsTram(_cur_roadtype) && _roadstop_gui_settings.orientation < DIAGDIR_END) {
1187 _roadstop_gui_settings.orientation = DIAGDIR_END;
1188 }
1189 const RoadTypeInfo *rti = GetRoadTypeInfo(_cur_roadtype);
1190 this->GetWidget<NWidgetCore>(WID_BROS_CAPTION)->widget_data = rti->strings.picker_title[rs];
1191
1192 for (WidgetID i = RoadTypeIsTram(_cur_roadtype) ? WID_BROS_STATION_X : WID_BROS_STATION_NE; i < WID_BROS_LT_OFF; i++) {
1193 this->GetWidget<NWidgetCore>(i)->tool_tip = rti->strings.picker_tooltip[rs];
1194 }
1195
1196 this->LowerWidget(WID_BROS_STATION_NE + _roadstop_gui_settings.orientation);
1197 this->LowerWidget(WID_BROS_LT_OFF + _settings_client.gui.station_show_coverage);
1198
1199 this->FinishInitNested(TRANSPORT_ROAD);
1200
1201 this->window_class = (rs == ROADSTOP_BUS) ? WC_BUS_STATION : WC_TRUCK_STATION;
1202 if (!newstops || _roadstop_gui_settings.roadstop_class >= (int)RoadStopClass::GetClassCount()) {
1203 /* There's no new stops available or the list has reduced in size.
1204 * Now, set the default road stops as selected. */
1205 _roadstop_gui_settings.roadstop_class = ROADSTOP_CLASS_DFLT;
1206 _roadstop_gui_settings.roadstop_type = 0;
1207 }
1208 if (newstops) {
1209 /* The currently selected class doesn't have any stops for this RoadStopType, reset the selection. */
1210 if (!GetIfClassHasNewStopsByType(RoadStopClass::Get(_roadstop_gui_settings.roadstop_class), rs, _cur_roadtype)) {
1211 _roadstop_gui_settings.roadstop_class = ROADSTOP_CLASS_DFLT;
1212 _roadstop_gui_settings.roadstop_type = 0;
1213 }
1214 _roadstop_gui_settings.roadstop_count = RoadStopClass::Get(_roadstop_gui_settings.roadstop_class)->GetSpecCount();
1215 _roadstop_gui_settings.roadstop_type = std::min((int)_roadstop_gui_settings.roadstop_type, _roadstop_gui_settings.roadstop_count - 1);
1216
1217 /* Reset back to default class if the previously selected class is not available for this road stop type. */
1218 if (!GetIfClassHasNewStopsByType(RoadStopClass::Get(_roadstop_gui_settings.roadstop_class), roadStopType, _cur_roadtype)) {
1219 _roadstop_gui_settings.roadstop_class = ROADSTOP_CLASS_DFLT;
1220 }
1221
1222 this->SelectFirstAvailableTypeIfUnavailable();
1223
1224 NWidgetMatrix *matrix = this->GetWidget<NWidgetMatrix>(WID_BROS_MATRIX);
1225 matrix->SetScrollbar(this->vscrollMatrix);
1226 matrix->SetCount(_roadstop_gui_settings.roadstop_count);
1227 matrix->SetClicked(_roadstop_gui_settings.roadstop_type);
1228
1229 this->EnsureSelectedClassIsVisible();
1230 this->CheckOrientationValid();
1231 }
1232 }
1233
1234 void Close([[maybe_unused]] int data = 0) override
1235 {
1236 CloseWindowById(WC_SELECT_STATION, 0);
1237 this->PickerWindowBase::Close();
1238 }
1239
1241 static bool RoadStopClassIDSorter(RoadStopClassID const &a, RoadStopClassID const &b)
1242 {
1243 return a < b;
1244 }
1245
1247 static bool CDECL TagNameFilter(RoadStopClassID const *sc, StringFilter &filter)
1248 {
1249 filter.ResetState();
1250 filter.AddLine(GetString(RoadStopClass::Get(*sc)->name));
1251 return filter.GetState();
1252 }
1253
1254 inline bool ShowNewStops() const
1255 {
1256 return this->vscrollList != nullptr;
1257 }
1258
1259 void BuildRoadStopClassesAvailable()
1260 {
1261 if (!this->roadstop_classes.NeedRebuild()) return;
1262
1263 this->roadstop_classes.clear();
1264
1265 for (uint i = 0; i < RoadStopClass::GetClassCount(); i++) {
1266 RoadStopClassID rs_id = (RoadStopClassID)i;
1267 if (rs_id == ROADSTOP_CLASS_WAYP) {
1268 // Skip waypoints.
1269 continue;
1270 }
1271 RoadStopClass *rs_class = RoadStopClass::Get(rs_id);
1272 if (GetIfClassHasNewStopsByType(rs_class, this->roadStopType, _cur_roadtype)) this->roadstop_classes.push_back(rs_id);
1273 }
1274
1275 if (this->ShowNewStops()) {
1276 this->roadstop_classes.Filter(this->string_filter);
1277 this->roadstop_classes.shrink_to_fit();
1278 this->roadstop_classes.RebuildDone();
1279 this->roadstop_classes.Sort();
1280
1281 this->vscrollList->SetCount(this->roadstop_classes.size());
1282 }
1283 }
1284
1285 void SelectFirstAvailableTypeIfUnavailable()
1286 {
1287 const RoadStopClass *rs_class = RoadStopClass::Get(_roadstop_gui_settings.roadstop_class);
1288 StationType st = GetRoadStationTypeByWindowClass(this->window_class);
1289
1290 if (IsRoadStopAvailable(rs_class->GetSpec(_roadstop_gui_settings.roadstop_type), st)) return;
1291 for (uint i = 0; i < _roadstop_gui_settings.roadstop_count; i++) {
1292 if (IsRoadStopAvailable(rs_class->GetSpec(i), st)) {
1293 _roadstop_gui_settings.roadstop_type = i;
1294 break;
1295 }
1296 }
1297 }
1298
1299 void OnInvalidateData([[maybe_unused]] int data = 0, [[maybe_unused]] bool gui_scope = true) override
1300 {
1301 if (!gui_scope) return;
1302
1303 this->BuildRoadStopClassesAvailable();
1304 }
1305
1306 EventState OnHotkey(int hotkey) override
1307 {
1308 if (hotkey == BROSHK_FOCUS_FILTER_BOX) {
1309 this->SetFocusedWidget(WID_BROS_FILTER_EDITBOX);
1310 SetFocusedWindow(this); // The user has asked to give focus to the text box, so make sure this window is focused.
1311 return ES_HANDLED;
1312 }
1313
1314 return ES_NOT_HANDLED;
1315 }
1316
1317 void OnEditboxChanged(WidgetID widget) override
1318 {
1319 if (widget == WID_BROS_FILTER_EDITBOX) {
1320 string_filter.SetFilterTerm(this->filter_editbox.text.buf);
1321 this->roadstop_classes.SetFilterState(!string_filter.IsEmpty());
1322 this->roadstop_classes.ForceRebuild();
1323 this->InvalidateData();
1324 }
1325 }
1326
1327 void OnPaint() override
1328 {
1329 this->DrawWidgets();
1330
1331 int rad = _settings_game.station.modified_catchment ? ((this->window_class == WC_BUS_STATION) ? CA_BUS : CA_TRUCK) : CA_UNMODIFIED;
1332 if (_settings_client.gui.station_show_coverage) {
1333 SetTileSelectBigSize(-rad, -rad, 2 * rad, 2 * rad);
1334 } else {
1335 SetTileSelectSize(1, 1);
1336 }
1337
1338 if (this->IsShaded()) return;
1339
1340 /* 'Accepts' and 'Supplies' texts. */
1341 StationCoverageType sct = (this->window_class == WC_BUS_STATION) ? SCT_PASSENGERS_ONLY : SCT_NON_PASSENGERS_ONLY;
1342 Rect r = this->GetWidget<NWidgetBase>(WID_BROS_ACCEPTANCE)->GetCurrentRect();
1343 int top = r.top;
1344 top = DrawStationCoverageAreaText(r.left, r.right, top, sct, rad, false) + WidgetDimensions::scaled.vsep_normal;
1345 top = DrawStationCoverageAreaText(r.left, r.right, top, sct, rad, true);
1346 /* Resize background if the window is too small.
1347 * Never make the window smaller to avoid oscillating if the size change affects the acceptance.
1348 * (This is the case, if making the window bigger moves the mouse into the window.) */
1349 if (top > r.bottom) {
1350 this->coverage_height += top - r.bottom;
1351 this->ReInit();
1352 }
1353 }
1354
1355 void UpdateWidgetSize(WidgetID widget, Dimension *size, [[maybe_unused]] const Dimension &padding, [[maybe_unused]] Dimension *fill, [[maybe_unused]] Dimension *resize) override
1356 {
1357 switch (widget) {
1358 case WID_BROS_NEWST_LIST: {
1359 Dimension d = { 0, 0 };
1360 for (auto rs_class : this->roadstop_classes) {
1361 d = maxdim(d, GetStringBoundingBox(RoadStopClass::Get(rs_class)->name));
1362 }
1363 size->width = std::max(size->width, d.width + padding.width);
1364 this->line_height = GetCharacterHeight(FS_NORMAL) + WidgetDimensions::scaled.matrix.Vertical();
1365 size->height = 5 * this->line_height;
1366 resize->height = this->line_height;
1367 break;
1368 }
1369
1370 case WID_BROS_SHOW_NEWST_TYPE: {
1371 Dimension d = {0, 0};
1372 StringID str = this->GetWidget<NWidgetCore>(widget)->widget_data;
1373 for (auto roadstop_class : this->roadstop_classes) {
1374 RoadStopClass *rs_class = RoadStopClass::Get(roadstop_class);
1375 for (uint j = 0; j < rs_class->GetSpecCount(); j++) {
1376 const RoadStopSpec *roadstopspec = rs_class->GetSpec(j);
1377 SetDParam(0, (roadstopspec != nullptr && roadstopspec->name != 0) ? roadstopspec->name : STR_STATION_CLASS_DFLT_ROADSTOP);
1378 d = maxdim(d, GetStringBoundingBox(str));
1379 }
1380 }
1381 size->width = std::max(size->width, d.width + padding.width);
1382 break;
1383 }
1384
1385 case WID_BROS_STATION_NE:
1386 case WID_BROS_STATION_SE:
1387 case WID_BROS_STATION_SW:
1388 case WID_BROS_STATION_NW:
1389 case WID_BROS_STATION_X:
1390 case WID_BROS_STATION_Y:
1391 case WID_BROS_IMAGE:
1392 size->width = ScaleGUITrad(64) + WidgetDimensions::scaled.fullbevel.Horizontal();
1393 size->height = ScaleGUITrad(48) + WidgetDimensions::scaled.fullbevel.Vertical();
1394 break;
1395
1396 case WID_BROS_MATRIX:
1397 fill->height = 1;
1398 resize->height = 1;
1399 break;
1400
1401 case WID_BROS_ACCEPTANCE:
1402 size->height = this->coverage_height;
1403 break;
1404 }
1405 }
1406
1410 StationType GetRoadStationTypeByWindowClass(WindowClass window_class) const
1411 {
1412 switch (window_class) {
1413 case WC_BUS_STATION: return STATION_BUS;
1414 case WC_TRUCK_STATION: return STATION_TRUCK;
1415 default: NOT_REACHED();
1416 }
1417 }
1418
1419 void DrawWidget(const Rect &r, WidgetID widget) const override
1420 {
1421 switch (widget) {
1422 case WID_BROS_STATION_NE:
1423 case WID_BROS_STATION_SE:
1424 case WID_BROS_STATION_SW:
1425 case WID_BROS_STATION_NW:
1426 case WID_BROS_STATION_X:
1427 case WID_BROS_STATION_Y: {
1428 StationType st = GetRoadStationTypeByWindowClass(this->window_class);
1429 const RoadStopSpec *spec = RoadStopClass::Get(_roadstop_gui_settings.roadstop_class)->GetSpec(_roadstop_gui_settings.roadstop_type);
1430 DrawPixelInfo tmp_dpi;
1431 Rect ir = r.Shrink(WidgetDimensions::scaled.bevel);
1432 if (FillDrawPixelInfo(&tmp_dpi, ir)) {
1433 AutoRestoreBackup dpi_backup(_cur_dpi, &tmp_dpi);
1434 int x = (ir.Width() - ScaleSpriteTrad(64)) / 2 + ScaleSpriteTrad(31);
1435 int y = (ir.Height() + ScaleSpriteTrad(48)) / 2 - ScaleSpriteTrad(31);
1436 if (spec == nullptr) {
1437 StationPickerDrawSprite(x, y, st, INVALID_RAILTYPE, _cur_roadtype, widget - WID_BROS_STATION_NE);
1438 } else {
1439 DrawRoadStopTile(x, y, _cur_roadtype, spec, st, widget - WID_BROS_STATION_NE);
1440 }
1441 }
1442 break;
1443 }
1444
1445 case WID_BROS_NEWST_LIST: {
1446 uint statclass = 0;
1447 uint row = 0;
1448 for (auto rs_class : this->roadstop_classes) {
1449 if (this->vscrollList->IsVisible(statclass)) {
1450 DrawString(r.left + WidgetDimensions::scaled.matrix.left, r.right, row * this->line_height + r.top + WidgetDimensions::scaled.matrix.top,
1451 RoadStopClass::Get(rs_class)->name,
1452 rs_class == _roadstop_gui_settings.roadstop_class ? TC_WHITE : TC_BLACK);
1453 row++;
1454 }
1455 statclass++;
1456 }
1457 break;
1458 }
1459
1460 case WID_BROS_IMAGE: {
1461 uint16_t type = this->GetWidget<NWidgetBase>(widget)->GetParentWidget<NWidgetMatrix>()->GetCurrentElement();
1462 assert(type < _roadstop_gui_settings.roadstop_count);
1463
1464 const RoadStopSpec *spec = RoadStopClass::Get(_roadstop_gui_settings.roadstop_class)->GetSpec(type);
1465 StationType st = GetRoadStationTypeByWindowClass(this->window_class);
1466
1467 /* Set up a clipping area for the sprite preview. */
1468 DrawPixelInfo tmp_dpi;
1469 Rect ir = r.Shrink(WidgetDimensions::scaled.bevel);
1470 if (FillDrawPixelInfo(&tmp_dpi, ir)) {
1471 AutoRestoreBackup dpi_backup(_cur_dpi, &tmp_dpi);
1472 int x = (ir.Width() - ScaleSpriteTrad(64)) / 2 + ScaleSpriteTrad(31);
1473 int y = (ir.Height() + ScaleSpriteTrad(48)) / 2 - ScaleSpriteTrad(31);
1474 if (spec == nullptr) {
1475 StationPickerDrawSprite(x, y, st, INVALID_RAILTYPE, _cur_roadtype, _roadstop_gui_settings.orientation);
1476 } else {
1477 DiagDirection orientation = _roadstop_gui_settings.orientation;
1478 if (orientation < DIAGDIR_END && HasBit(spec->flags, RSF_DRIVE_THROUGH_ONLY)) orientation = DIAGDIR_END;
1479 DrawRoadStopTile(x, y, _cur_roadtype, spec, st, (uint8_t)orientation);
1480 }
1481 }
1482 if (!IsRoadStopAvailable(spec, st)) {
1483 GfxFillRect(ir, PC_BLACK, FILLRECT_CHECKER);
1484 }
1485 break;
1486 }
1487 }
1488 }
1489
1490 void OnResize() override
1491 {
1492 if (this->vscrollList != nullptr) {
1493 this->vscrollList->SetCapacityFromWidget(this, WID_BROS_NEWST_LIST);
1494 }
1495 }
1496
1497 void SetStringParameters(WidgetID widget) const override
1498 {
1499 if (widget == WID_BROS_SHOW_NEWST_TYPE) {
1500 const RoadStopSpec *roadstopspec = RoadStopClass::Get(_roadstop_gui_settings.roadstop_class)->GetSpec(_roadstop_gui_settings.roadstop_type);
1501 SetDParam(0, (roadstopspec != nullptr && roadstopspec->name != 0) ? roadstopspec->name : STR_STATION_CLASS_DFLT_ROADSTOP);
1502 }
1503 }
1504
1505 void OnClick([[maybe_unused]] Point pt, WidgetID widget, [[maybe_unused]] int click_count) override
1506 {
1507 switch (widget) {
1508 case WID_BROS_STATION_NE:
1509 case WID_BROS_STATION_SE:
1510 case WID_BROS_STATION_SW:
1511 case WID_BROS_STATION_NW:
1512 case WID_BROS_STATION_X:
1513 case WID_BROS_STATION_Y:
1514 if (widget < WID_BROS_STATION_X) {
1515 const RoadStopSpec *spec = RoadStopClass::Get(_roadstop_gui_settings.roadstop_class)->GetSpec(_roadstop_gui_settings.roadstop_type);
1516 if (spec != nullptr && HasBit(spec->flags, RSF_DRIVE_THROUGH_ONLY)) return;
1517 }
1518 this->RaiseWidget(WID_BROS_STATION_NE + _roadstop_gui_settings.orientation);
1519 _roadstop_gui_settings.orientation = (DiagDirection)(widget - WID_BROS_STATION_NE);
1520 this->LowerWidget(WID_BROS_STATION_NE + _roadstop_gui_settings.orientation);
1521 if (_settings_client.sound.click_beep) SndPlayFx(SND_15_BEEP);
1522 this->SetDirty();
1523 CloseWindowById(WC_SELECT_STATION, 0);
1524 break;
1525
1526 case WID_BROS_LT_OFF:
1527 case WID_BROS_LT_ON:
1528 this->RaiseWidget(_settings_client.gui.station_show_coverage + WID_BROS_LT_OFF);
1529 _settings_client.gui.station_show_coverage = (widget != WID_BROS_LT_OFF);
1530 this->LowerWidget(_settings_client.gui.station_show_coverage + WID_BROS_LT_OFF);
1531 if (_settings_client.sound.click_beep) SndPlayFx(SND_15_BEEP);
1532 this->SetDirty();
1533 SetViewportCatchmentStation(nullptr, true);
1534 break;
1535
1536 case WID_BROS_NEWST_LIST: {
1537 auto it = this->vscrollList->GetScrolledItemFromWidget(this->roadstop_classes, pt.y, this, WID_BROS_NEWST_LIST);
1538 if (it == this->roadstop_classes.end()) return;
1539 RoadStopClassID class_id = *it;
1540 if (_roadstop_gui_settings.roadstop_class != class_id && GetIfClassHasNewStopsByType(RoadStopClass::Get(class_id), roadStopType, _cur_roadtype)) {
1541 _roadstop_gui_settings.roadstop_class = class_id;
1542 RoadStopClass *rsclass = RoadStopClass::Get(_roadstop_gui_settings.roadstop_class);
1543 _roadstop_gui_settings.roadstop_count = rsclass->GetSpecCount();
1544 _roadstop_gui_settings.roadstop_type = std::min((int)_roadstop_gui_settings.roadstop_type, std::max(0, (int)_roadstop_gui_settings.roadstop_count - 1));
1545 this->SelectFirstAvailableTypeIfUnavailable();
1546
1547 NWidgetMatrix *matrix = this->GetWidget<NWidgetMatrix>(WID_BROS_MATRIX);
1548 matrix->SetCount(_roadstop_gui_settings.roadstop_count);
1549 matrix->SetClicked(_roadstop_gui_settings.roadstop_type);
1550 }
1551 if (_settings_client.sound.click_beep) SndPlayFx(SND_15_BEEP);
1552 this->SetDirty();
1553 CloseWindowById(WC_SELECT_STATION, 0);
1554 this->CheckOrientationValid();
1555 break;
1556 }
1557
1558 case WID_BROS_IMAGE: {
1559 uint16_t y = this->GetWidget<NWidgetBase>(widget)->GetParentWidget<NWidgetMatrix>()->GetCurrentElement();
1560 if (y >= _roadstop_gui_settings.roadstop_count) return;
1561
1562 const RoadStopSpec *spec = RoadStopClass::Get(_roadstop_gui_settings.roadstop_class)->GetSpec(y);
1563 StationType st = GetRoadStationTypeByWindowClass(this->window_class);
1564
1565 if (!IsRoadStopAvailable(spec, st)) return;
1566
1567 _roadstop_gui_settings.roadstop_type = y;
1568
1569 this->GetWidget<NWidgetBase>(widget)->GetParentWidget<NWidgetMatrix>()->SetClicked(_roadstop_gui_settings.roadstop_type);
1570
1571 if (_settings_client.sound.click_beep) SndPlayFx(SND_15_BEEP);
1572 this->SetDirty();
1573 CloseWindowById(WC_SELECT_STATION, 0);
1574 this->CheckOrientationValid();
1575 break;
1576 }
1577
1578 default:
1579 break;
1580 }
1581 }
1582
1583 void OnRealtimeTick([[maybe_unused]] uint delta_ms) override
1584 {
1585 CheckRedrawStationCoverage(this);
1586 }
1587
1588 IntervalTimer<TimerGameCalendar> yearly_interval = {{TimerGameCalendar::YEAR, TimerGameCalendar::Priority::NONE}, [this](auto) {
1589 this->InvalidateData();
1590 }};
1591
1592 static inline HotkeyList road_hotkeys{"buildroadstop", {
1593 Hotkey('F', "focus_filter_box", BROSHK_FOCUS_FILTER_BOX),
1594 }};
1595
1596 static inline HotkeyList tram_hotkeys{"buildtramstop", {
1597 Hotkey('F', "focus_filter_box", BROSHK_FOCUS_FILTER_BOX),
1598 }};
1599 };
1600
1601 Listing BuildRoadStationWindow::last_sorting = { false, 0 };
1602 Filtering BuildRoadStationWindow::last_filtering = { false, 0 };
1603
1604 BuildRoadStationWindow::GUIRoadStopClassList::SortFunction * const BuildRoadStationWindow::sorter_funcs[] = {
1605 &RoadStopClassIDSorter,
1606 };
1607
1608 BuildRoadStationWindow::GUIRoadStopClassList::FilterFunction * const BuildRoadStationWindow::filter_funcs[] = {
1609 &TagNameFilter,
1610 };
1611
1613 static constexpr NWidgetPart _nested_road_station_picker_widgets[] = {
1614 NWidget(NWID_HORIZONTAL),
1615 NWidget(WWT_CLOSEBOX, COLOUR_DARK_GREEN),
1616 NWidget(WWT_CAPTION, COLOUR_DARK_GREEN, WID_BROS_CAPTION),
1617 NWidget(WWT_SHADEBOX, COLOUR_DARK_GREEN),
1618 NWidget(NWID_SELECTION, INVALID_COLOUR, WID_BROS_SHOW_NEWST_DEFSIZE),
1619 NWidget(WWT_DEFSIZEBOX, COLOUR_DARK_GREEN),
1620 EndContainer(),
1621 EndContainer(),
1622 NWidget(NWID_HORIZONTAL),
1623 NWidget(WWT_PANEL, COLOUR_DARK_GREEN),
1624 NWidget(NWID_VERTICAL), SetPIP(0, WidgetDimensions::unscaled.vsep_normal, 0), SetPadding(WidgetDimensions::unscaled.picker),
1625 NWidget(NWID_HORIZONTAL), SetPIP(0, WidgetDimensions::unscaled.hsep_normal, 0), SetPIPRatio(1, 0, 1),
1626 NWidget(NWID_VERTICAL), SetPIP(0, WidgetDimensions::unscaled.vsep_picker, 0),
1627 NWidget(NWID_SELECTION, INVALID_COLOUR, WID_BROS_FILTER_CONTAINER),
1628 NWidget(NWID_HORIZONTAL), SetPIP(0, WidgetDimensions::unscaled.hsep_normal, 0),
1629 NWidget(WWT_TEXT, COLOUR_DARK_GREEN), SetFill(0, 1), SetDataTip(STR_LIST_FILTER_TITLE, STR_NULL),
1630 NWidget(WWT_EDITBOX, COLOUR_GREY, WID_BROS_FILTER_EDITBOX), SetFill(1, 0), SetResize(1, 0),
1631 SetDataTip(STR_LIST_FILTER_OSKTITLE, STR_LIST_FILTER_TOOLTIP),
1632 EndContainer(),
1633 EndContainer(),
1634 NWidget(NWID_SELECTION, INVALID_COLOUR, WID_BROS_SHOW_NEWST_ADDITIONS),
1635 NWidget(NWID_HORIZONTAL),
1636 NWidget(WWT_MATRIX, COLOUR_GREY, WID_BROS_NEWST_LIST), SetMinimalSize(122, 71), SetFill(1, 0),
1637 SetMatrixDataTip(1, 0, STR_STATION_BUILD_STATION_CLASS_TOOLTIP), SetScrollbar(WID_BROS_NEWST_SCROLL),
1638 NWidget(NWID_VSCROLLBAR, COLOUR_GREY, WID_BROS_NEWST_SCROLL),
1639 EndContainer(),
1640 EndContainer(),
1641 NWidget(NWID_SELECTION, INVALID_COLOUR, WID_BROS_SHOW_NEWST_ORIENTATION),
1642 NWidget(WWT_LABEL, COLOUR_DARK_GREEN), SetMinimalSize(144, 11), SetDataTip(STR_STATION_BUILD_ORIENTATION, STR_NULL), SetFill(1, 0),
1643 EndContainer(),
1644 NWidget(NWID_SELECTION, INVALID_COLOUR, WID_BROS_AVAILABLE_ORIENTATIONS),
1645 /* 6-orientation plane. */
1646 NWidget(NWID_VERTICAL), SetPIP(0, WidgetDimensions::unscaled.vsep_normal, 0),
1647 NWidget(NWID_HORIZONTAL), SetPIP(0, WidgetDimensions::unscaled.hsep_normal, 0), SetPIPRatio(1, 0, 1),
1648 NWidget(NWID_HORIZONTAL_LTR), SetPIP(0, WidgetDimensions::unscaled.hsep_normal, 0),
1649 NWidget(WWT_PANEL, COLOUR_GREY, WID_BROS_STATION_NW), SetMinimalSize(66, 50), SetFill(0, 0), EndContainer(),
1650 NWidget(WWT_PANEL, COLOUR_GREY, WID_BROS_STATION_NE), SetMinimalSize(66, 50), SetFill(0, 0), EndContainer(),
1651 EndContainer(),
1652 NWidget(WWT_PANEL, COLOUR_GREY, WID_BROS_STATION_X), SetMinimalSize(66, 50), SetFill(0, 0), EndContainer(),
1653 EndContainer(),
1654 NWidget(NWID_HORIZONTAL), SetPIP(0, WidgetDimensions::unscaled.hsep_normal, 0), SetPIPRatio(1, 0, 1),
1655 NWidget(NWID_HORIZONTAL_LTR), SetPIP(0, WidgetDimensions::unscaled.hsep_normal, 0),
1656 NWidget(WWT_PANEL, COLOUR_GREY, WID_BROS_STATION_SW), SetMinimalSize(66, 50), SetFill(0, 0), EndContainer(),
1657 NWidget(WWT_PANEL, COLOUR_GREY, WID_BROS_STATION_SE), SetMinimalSize(66, 50), SetFill(0, 0), EndContainer(),
1658 EndContainer(),
1659 NWidget(WWT_PANEL, COLOUR_GREY, WID_BROS_STATION_Y), SetMinimalSize(66, 50), SetFill(0, 0), EndContainer(),
1660 EndContainer(),
1661 EndContainer(),
1662 /* 2-orientation plane. */
1663 NWidget(NWID_VERTICAL), SetPIPRatio(0, 0, 1),
1664 NWidget(NWID_HORIZONTAL_LTR), SetPIP(0, WidgetDimensions::unscaled.hsep_normal, 0), SetPIPRatio(1, 0, 1),
1665 NWidget(WWT_PANEL, COLOUR_GREY, WID_BROS_STATION_X), SetMinimalSize(66, 50), SetFill(0, 0), EndContainer(),
1666 NWidget(WWT_PANEL, COLOUR_GREY, WID_BROS_STATION_Y), SetMinimalSize(66, 50), SetFill(0, 0), EndContainer(),
1667 EndContainer(),
1668 EndContainer(),
1669 EndContainer(),
1670 NWidget(NWID_SELECTION, INVALID_COLOUR, WID_BROS_SHOW_NEWST_TYPE_SEL),
1671 NWidget(WWT_LABEL, COLOUR_DARK_GREEN, WID_BROS_SHOW_NEWST_TYPE), SetMinimalSize(144, 8), SetDataTip(STR_JUST_STRING, STR_NULL), SetTextStyle(TC_ORANGE), SetFill(1, 0),
1672 EndContainer(),
1673 NWidget(WWT_LABEL, COLOUR_DARK_GREEN), SetDataTip(STR_STATION_BUILD_COVERAGE_AREA_TITLE, STR_NULL), SetFill(1, 0),
1674 NWidget(NWID_HORIZONTAL), SetPIPRatio(1, 0, 1),
1675 NWidget(WWT_TEXTBTN, COLOUR_GREY, WID_BROS_LT_OFF), SetMinimalSize(60, 12),
1676 SetDataTip(STR_STATION_BUILD_COVERAGE_OFF, STR_STATION_BUILD_COVERAGE_AREA_OFF_TOOLTIP),
1677 NWidget(WWT_TEXTBTN, COLOUR_GREY, WID_BROS_LT_ON), SetMinimalSize(60, 12),
1678 SetDataTip(STR_STATION_BUILD_COVERAGE_ON, STR_STATION_BUILD_COVERAGE_AREA_ON_TOOLTIP),
1679 EndContainer(),
1680 EndContainer(),
1681 NWidget(NWID_SELECTION, INVALID_COLOUR, WID_BROS_SHOW_NEWST_MATRIX),
1682 /* Hidden panel as NWID_MATRIX does not support SetScrollbar() */
1683 NWidget(WWT_PANEL, COLOUR_DARK_GREEN), SetScrollbar(WID_BROS_MATRIX_SCROLL),
1684 NWidget(NWID_MATRIX, COLOUR_DARK_GREEN, WID_BROS_MATRIX), SetPIP(0, 2, 0),
1685 NWidget(WWT_PANEL, COLOUR_DARK_GREEN, WID_BROS_IMAGE), SetMinimalSize(66, 60),
1686 SetFill(0, 0), SetResize(0, 0), SetDataTip(0x0, STR_STATION_BUILD_STATION_TYPE_TOOLTIP), SetScrollbar(WID_BROS_MATRIX_SCROLL),
1687 EndContainer(),
1688 EndContainer(),
1689 EndContainer(),
1690 EndContainer(),
1691 EndContainer(),
1692 NWidget(WWT_EMPTY, INVALID_COLOUR, WID_BROS_ACCEPTANCE), SetFill(1, 1), SetResize(1, 0), SetMinimalTextLines(2, WidgetDimensions::unscaled.vsep_normal),
1693 EndContainer(),
1694 EndContainer(),
1695 NWidget(NWID_SELECTION, INVALID_COLOUR, WID_BROS_SHOW_NEWST_RESIZE),
1696 NWidget(NWID_VERTICAL),
1697 NWidget(NWID_VSCROLLBAR, COLOUR_DARK_GREEN, WID_BROS_MATRIX_SCROLL),
1698 NWidget(WWT_RESIZEBOX, COLOUR_DARK_GREEN),
1699 EndContainer(),
1700 EndContainer(),
1701 EndContainer(),
1702 };
1703
1704 static WindowDesc _road_station_picker_desc(__FILE__, __LINE__,
1705 WDP_AUTO, "build_station_road", 0, 0,
1706 WC_BUS_STATION, WC_BUILD_TOOLBAR,
1707 WDF_CONSTRUCTION,
1708 std::begin(_nested_road_station_picker_widgets), std::end(_nested_road_station_picker_widgets),
1709 &BuildRoadStationWindow::road_hotkeys
1710 );
1711
1713 static constexpr NWidgetPart _nested_tram_station_picker_widgets[] = {
1714 NWidget(NWID_HORIZONTAL),
1715 NWidget(WWT_CLOSEBOX, COLOUR_DARK_GREEN),
1716 NWidget(WWT_CAPTION, COLOUR_DARK_GREEN, WID_BROS_CAPTION),
1717 NWidget(WWT_SHADEBOX, COLOUR_DARK_GREEN),
1718 NWidget(NWID_SELECTION, INVALID_COLOUR, WID_BROS_SHOW_NEWST_DEFSIZE),
1719 NWidget(WWT_DEFSIZEBOX, COLOUR_DARK_GREEN),
1720 EndContainer(),
1721 EndContainer(),
1722 NWidget(NWID_HORIZONTAL),
1723 NWidget(WWT_PANEL, COLOUR_DARK_GREEN),
1724 NWidget(NWID_VERTICAL), SetPIP(0, WidgetDimensions::unscaled.vsep_normal, 0), SetPadding(WidgetDimensions::unscaled.picker),
1725 NWidget(NWID_HORIZONTAL), SetPIP(0, WidgetDimensions::unscaled.hsep_normal, 0), SetPIPRatio(1, 0, 1),
1726 NWidget(NWID_VERTICAL), SetPIP(0, WidgetDimensions::unscaled.vsep_picker, 0),
1727 NWidget(NWID_SELECTION, INVALID_COLOUR, WID_BROS_FILTER_CONTAINER),
1728 NWidget(NWID_HORIZONTAL), SetPIP(0, WidgetDimensions::unscaled.hsep_normal, 0),
1729 NWidget(WWT_TEXT, COLOUR_DARK_GREEN), SetFill(0, 1), SetDataTip(STR_LIST_FILTER_TITLE, STR_NULL),
1730 NWidget(WWT_EDITBOX, COLOUR_GREY, WID_BROS_FILTER_EDITBOX), SetFill(1, 0), SetResize(1, 0),
1731 SetDataTip(STR_LIST_FILTER_OSKTITLE, STR_LIST_FILTER_TOOLTIP),
1732 EndContainer(),
1733 EndContainer(),
1734 NWidget(NWID_SELECTION, INVALID_COLOUR, WID_BROS_SHOW_NEWST_ADDITIONS),
1735 NWidget(NWID_HORIZONTAL),
1736 NWidget(WWT_MATRIX, COLOUR_GREY, WID_BROS_NEWST_LIST), SetMinimalSize(122, 71), SetFill(1, 0),
1737 SetMatrixDataTip(1, 0, STR_STATION_BUILD_STATION_CLASS_TOOLTIP), SetScrollbar(WID_BROS_NEWST_SCROLL),
1738 NWidget(NWID_VSCROLLBAR, COLOUR_GREY, WID_BROS_NEWST_SCROLL),
1739 EndContainer(),
1740 EndContainer(),
1741 NWidget(NWID_SELECTION, INVALID_COLOUR, WID_BROS_SHOW_NEWST_ORIENTATION),
1742 NWidget(WWT_LABEL, COLOUR_DARK_GREEN), SetMinimalSize(144, 11), SetDataTip(STR_STATION_BUILD_ORIENTATION, STR_NULL), SetFill(1, 0),
1743 EndContainer(),
1744 NWidget(NWID_HORIZONTAL_LTR), SetPIP(0, WidgetDimensions::unscaled.hsep_normal, 0), SetPIPRatio(1, 0, 1),
1745 NWidget(WWT_PANEL, COLOUR_GREY, WID_BROS_STATION_X), SetMinimalSize(66, 50), SetFill(0, 0), EndContainer(),
1746 NWidget(WWT_PANEL, COLOUR_GREY, WID_BROS_STATION_Y), SetMinimalSize(66, 50), SetFill(0, 0), EndContainer(),
1747 EndContainer(),
1748 NWidget(NWID_SELECTION, INVALID_COLOUR, WID_BROS_SHOW_NEWST_TYPE_SEL),
1749 NWidget(WWT_LABEL, COLOUR_DARK_GREEN, WID_BROS_SHOW_NEWST_TYPE), SetMinimalSize(144, 8), SetDataTip(STR_JUST_STRING, STR_NULL), SetTextStyle(TC_ORANGE), SetFill(1, 0),
1750 EndContainer(),
1751 NWidget(WWT_LABEL, COLOUR_DARK_GREEN), SetDataTip(STR_STATION_BUILD_COVERAGE_AREA_TITLE, STR_NULL), SetFill(1, 0),
1752 NWidget(NWID_HORIZONTAL), SetPIPRatio(1, 0, 1),
1753 NWidget(WWT_TEXTBTN, COLOUR_GREY, WID_BROS_LT_OFF), SetMinimalSize(60, 12),
1754 SetDataTip(STR_STATION_BUILD_COVERAGE_OFF, STR_STATION_BUILD_COVERAGE_AREA_OFF_TOOLTIP),
1755 NWidget(WWT_TEXTBTN, COLOUR_GREY, WID_BROS_LT_ON), SetMinimalSize(60, 12),
1756 SetDataTip(STR_STATION_BUILD_COVERAGE_ON, STR_STATION_BUILD_COVERAGE_AREA_ON_TOOLTIP),
1757 EndContainer(),
1758 EndContainer(),
1759 NWidget(NWID_SELECTION, INVALID_COLOUR, WID_BROS_SHOW_NEWST_MATRIX),
1760 /* Hidden panel as NWID_MATRIX does not support SetScrollbar() */
1761 NWidget(WWT_PANEL, COLOUR_DARK_GREEN), SetScrollbar(WID_BROS_MATRIX_SCROLL),
1762 NWidget(NWID_MATRIX, COLOUR_DARK_GREEN, WID_BROS_MATRIX), SetPIP(0, 2, 0),
1763 NWidget(WWT_PANEL, COLOUR_DARK_GREEN, WID_BROS_IMAGE), SetMinimalSize(66, 60),
1764 SetFill(0, 0), SetResize(0, 0), SetDataTip(0x0, STR_STATION_BUILD_STATION_TYPE_TOOLTIP), SetScrollbar(WID_BROS_MATRIX_SCROLL),
1765 EndContainer(),
1766 EndContainer(),
1767 EndContainer(),
1768 EndContainer(),
1769 EndContainer(),
1770 NWidget(WWT_EMPTY, INVALID_COLOUR, WID_BROS_ACCEPTANCE), SetFill(1, 1), SetResize(1, 0), SetMinimalTextLines(2, WidgetDimensions::unscaled.vsep_normal),
1771 EndContainer(),
1772 EndContainer(),
1773 NWidget(NWID_SELECTION, INVALID_COLOUR, WID_BROS_SHOW_NEWST_RESIZE),
1774 NWidget(NWID_VERTICAL),
1775 NWidget(NWID_VSCROLLBAR, COLOUR_DARK_GREEN, WID_BROS_MATRIX_SCROLL),
1776 NWidget(WWT_RESIZEBOX, COLOUR_DARK_GREEN),
1777 EndContainer(),
1778 EndContainer(),
1779 EndContainer(),
1780 };
1781
1782 static WindowDesc _tram_station_picker_desc(__FILE__, __LINE__,
1783 WDP_AUTO, "build_station_tram", 0, 0,
1784 WC_BUS_STATION, WC_BUILD_TOOLBAR,
1785 WDF_CONSTRUCTION,
1786 std::begin(_nested_tram_station_picker_widgets), std::end(_nested_tram_station_picker_widgets),
1787 &BuildRoadStationWindow::tram_hotkeys
1788 );
1789
1790 static void ShowRVStationPicker(Window *parent, RoadStopType rs)
1791 {
1792 new BuildRoadStationWindow(RoadTypeIsRoad(_cur_roadtype) ? &_road_station_picker_desc : &_tram_station_picker_desc, parent, rs);
1793 }
1794
1795 void InitializeRoadGui()
1796 {
1797 _road_depot_orientation = DIAGDIR_NW;
1798 _roadstop_gui_settings.orientation = DIAGDIR_NW;
1799 }
1800
1804 void InitializeRoadGUI()
1805 {
1806 BuildRoadToolbarWindow *w = dynamic_cast<BuildRoadToolbarWindow *>(FindWindowById(WC_BUILD_TOOLBAR, TRANSPORT_ROAD));
1807 if (w != nullptr) w->ModifyRoadType(_cur_roadtype);
1808 }
1809
1810 DropDownList GetRoadTypeDropDownList(RoadTramTypes rtts, bool for_replacement, bool all_option)
1811 {
1812 RoadTypes used_roadtypes;
1813 RoadTypes avail_roadtypes;
1814
1815 const Company *c = Company::Get(_local_company);
1816
1817 /* Find the used roadtypes. */
1818 if (for_replacement) {
1819 avail_roadtypes = GetCompanyRoadTypes(c->index, false);
1820 used_roadtypes = GetRoadTypes(false);
1821 } else {
1822 avail_roadtypes = c->avail_roadtypes;
1823 used_roadtypes = GetRoadTypes(true);
1824 }
1825
1826 /* Filter listed road types */
1827 if (!HasBit(rtts, RTT_ROAD)) used_roadtypes &= _roadtypes_type;
1828 if (!HasBit(rtts, RTT_TRAM)) used_roadtypes &= ~_roadtypes_type;
1829
1830 DropDownList list;
1831
1832 if (all_option) {
1833 list.push_back(std::make_unique<DropDownListStringItem>(STR_REPLACE_ALL_ROADTYPE, INVALID_ROADTYPE, false));
1834 }
1835
1836 Dimension d = { 0, 0 };
1837 /* Get largest icon size, to ensure text is aligned on each menu item. */
1838 if (!for_replacement) {
1839 for (const auto &rt : _sorted_roadtypes) {
1840 if (!HasBit(used_roadtypes, rt)) continue;
1841 const RoadTypeInfo *rti = GetRoadTypeInfo(rt);
1842 d = maxdim(d, GetSpriteSize(rti->gui_sprites.build_x_road));
1843 }
1844 }
1845
1846 for (const auto &rt : _sorted_roadtypes) {
1847 /* If it's not used ever, don't show it to the user. */
1848 if (!HasBit(used_roadtypes, rt)) continue;
1849
1850 const RoadTypeInfo *rti = GetRoadTypeInfo(rt);
1851
1852 SetDParam(0, rti->strings.menu_text);
1853 SetDParam(1, rti->max_speed / 2);
1854 if (for_replacement) {
1855 list.push_back(std::make_unique<DropDownListStringItem>(rti->strings.replace_text, rt, !HasBit(avail_roadtypes, rt)));
1856 } else {
1857 StringID str = rti->max_speed > 0 ? STR_TOOLBAR_RAILTYPE_VELOCITY : STR_JUST_STRING;
1858 list.push_back(std::make_unique<DropDownListIconItem>(d, rti->gui_sprites.build_x_road, PAL_NONE, str, rt, !HasBit(avail_roadtypes, rt)));
1859 }
1860 }
1861
1862 if (list.empty()) {
1863 /* Empty dropdowns are not allowed */
1864 list.push_back(std::make_unique<DropDownListStringItem>(STR_NONE, INVALID_ROADTYPE, true));
1865 }
1866
1867 return list;
1868 }
1869
1870 DropDownList GetScenRoadTypeDropDownList(RoadTramTypes rtts)
1871 {
1872 RoadTypes avail_roadtypes = GetRoadTypes(false);
1873 avail_roadtypes = AddDateIntroducedRoadTypes(avail_roadtypes, TimerGameCalendar::date);
1874 RoadTypes used_roadtypes = GetRoadTypes(true);
1875
1876 /* Filter listed road types */
1877 if (!HasBit(rtts, RTT_ROAD)) used_roadtypes &= _roadtypes_type;
1878 if (!HasBit(rtts, RTT_TRAM)) used_roadtypes &= ~_roadtypes_type;
1879
1880 DropDownList list;
1881
1882 /* If it's not used ever, don't show it to the user. */
1883 Dimension d = { 0, 0 };
1884 for (const auto &rt : _sorted_roadtypes) {
1885 if (!HasBit(used_roadtypes, rt)) continue;
1886 const RoadTypeInfo *rti = GetRoadTypeInfo(rt);
1887 d = maxdim(d, GetSpriteSize(rti->gui_sprites.build_x_road));
1888 }
1889 for (const auto &rt : _sorted_roadtypes) {
1890 if (!HasBit(used_roadtypes, rt)) continue;
1891
1892 const RoadTypeInfo *rti = GetRoadTypeInfo(rt);
1893
1894 SetDParam(0, rti->strings.menu_text);
1895 SetDParam(1, rti->max_speed / 2);
1896 StringID str = rti->max_speed > 0 ? STR_TOOLBAR_RAILTYPE_VELOCITY : STR_JUST_STRING;
1897 list.push_back(std::make_unique<DropDownListIconItem>(d, rti->gui_sprites.build_x_road, PAL_NONE, str, rt, !HasBit(avail_roadtypes, rt)));
1898 }
1899
1900 if (list.empty()) {
1901 /* Empty dropdowns are not allowed */
1902 list.push_back(std::make_unique<DropDownListStringItem>(STR_NONE, -1, true));
1903 }
1904
1905 return list;
1906 }
SZSP_NONE
@ SZSP_NONE
Display plane with zero size in both directions (none filling and resizing).
Definition: widget_type.h:469
ES_HANDLED
@ ES_HANDLED
The passed event is handled.
Definition: window_type.h:739
SetFill
constexpr NWidgetPart SetFill(uint16_t fill_x, uint16_t fill_y)
Widget part function for setting filling.
Definition: widget_type.h:1143
RoadTypeInfo::toolbar_caption
StringID toolbar_caption
Caption in the construction toolbar GUI for this rail type.
Definition: road.h:104
SetTileSelectSize
void SetTileSelectSize(int w, int h)
Highlight w by h tiles at the cursor.
Definition: viewport.cpp:2536
DDSP_DEMOLISH_AREA
@ DDSP_DEMOLISH_AREA
Clear area.
Definition: viewport_type.h:108
tunnelbridge.h
_remove_button_clicked
static bool _remove_button_clicked
Flag whether 'remove' toggle-button is currently enabled.
Definition: rail_gui.cpp:54
CA_UNMODIFIED
@ CA_UNMODIFIED
Catchment for all stations with "modified catchment" disabled.
Definition: station_type.h:82
WID_ROT_TRUCK_STATION
@ WID_ROT_TRUCK_STATION
Build truck station.
Definition: road_widget.h:23
PlaceRoad_Bridge
static void PlaceRoad_Bridge(TileIndex tile, Window *w)
Callback to start placing a bridge.
Definition: road_gui.cpp:110
RoadTypeInfo
Definition: road.h:78
CloseWindowByClass
void CloseWindowByClass(WindowClass cls, int data)
Close all windows of a given class.
Definition: window.cpp:1153
sound_func.h
TileHighlightData::size
Point size
Size, in tile "units", of the white/red selection area.
Definition: tilehighlight_type.h:48
AXIS_Y
@ AXIS_Y
The y axis.
Definition: direction_type.h:118
WID_BROS_SHOW_NEWST_TYPE_SEL
@ WID_BROS_SHOW_NEWST_TYPE_SEL
Selection for the type name.
Definition: road_widget.h:67
ROADSTOPTYPE_ALL
@ ROADSTOPTYPE_ALL
This RoadStop is for both types of station road stops.
Definition: newgrf_roadstop.h:49
ROADTYPE_END
@ ROADTYPE_END
Used for iterations.
Definition: road_type.h:29
RoadTypeInfo::err_build_road
StringID err_build_road
Building a normal piece of road.
Definition: road.h:110
BuildRoadStationWindow::RoadStopClassIDSorter
static bool RoadStopClassIDSorter(RoadStopClassID const &a, RoadStopClassID const &b)
Sort classes by RoadStopClassID.
Definition: road_gui.cpp:1241
Rect::Height
int Height() const
Get height of Rect.
Definition: geometry_type.hpp:91
GUISettings::station_show_coverage
bool station_show_coverage
whether to highlight coverage area
Definition: settings_type.h:189
Pool::PoolItem<&_company_pool >::Get
static Titem * Get(size_t index)
Returns Titem with given index.
Definition: pool_type.hpp:339
WC_BUILD_TOOLBAR
@ WC_BUILD_TOOLBAR
Build toolbar; Window numbers:
Definition: window_type.h:73
DDSP_PLACE_ROAD_Y_DIR
@ DDSP_PLACE_ROAD_Y_DIR
Road placement (Y axis)
Definition: viewport_type.h:129
BuildRoadStationWindow::OnPaint
void OnPaint() override
The window must be repainted.
Definition: road_gui.cpp:1327
WID_ROT_BUILD_BRIDGE
@ WID_ROT_BUILD_BRIDGE
Build bridge.
Definition: road_widget.h:25
WID_BROS_NEWST_SCROLL
@ WID_BROS_NEWST_SCROLL
Scrollbar of the WID_BROS_NEWST_LIST.
Definition: road_widget.h:70
GameSettings::station
StationSettings station
settings related to station management
Definition: settings_type.h:629
querystring_gui.h
RoadTypeInfo::menu_text
StringID menu_text
Name of this rail type in the main toolbar dropdown.
Definition: road.h:105
HotkeyList
List of hotkeys for a window.
Definition: hotkeys.h:37
VpSetPresizeRange
void VpSetPresizeRange(TileIndex from, TileIndex to)
Highlights all tiles between a set of two tiles.
Definition: viewport.cpp:2771
SetFocusedWindow
void SetFocusedWindow(Window *w)
Set the window that has the focus.
Definition: window.cpp:423
RoadTypeInfo::build_y_road
SpriteID build_y_road
button for building single rail in Y direction
Definition: road.h:86
RoadStopType
RoadStopType
Types of RoadStops.
Definition: station_type.h:43
ROADSTOP_TRUCK
@ ROADSTOP_TRUCK
A standard stop for trucks.
Definition: station_type.h:45
Dimension
Dimensions (a width and height) of a rectangle in 2D.
Definition: geometry_type.hpp:30
command_func.h
IsInsideMM
constexpr bool IsInsideMM(const T x, const size_t min, const size_t max) noexcept
Checks if a value is in an interval.
Definition: math_func.hpp:268
RoadStopSpec
Road stop specification.
Definition: newgrf_roadstop.h:122
WidgetDimensions::scaled
static WidgetDimensions scaled
Widget dimensions scaled for current zoom level.
Definition: window_gui.h:68
WID_ROT_DEMOLISH
@ WID_ROT_DEMOLISH
Demolish.
Definition: road_widget.h:20
WWT_STICKYBOX
@ WWT_STICKYBOX
Sticky box (at top-right of a window, after WWT_DEFSIZEBOX)
Definition: widget_type.h:68
BuildRoadStationWindow::EDITBOX_MAX_SIZE
static const uint EDITBOX_MAX_SIZE
The maximum number of characters for the filter edit box.
Definition: road_gui.cpp:1109
WDF_CONSTRUCTION
@ WDF_CONSTRUCTION
This window is used for construction; close it whenever changing company.
Definition: window_gui.h:197
PlaceRoad_TruckStation
static void PlaceRoad_TruckStation(TileIndex tile)
Callback for placing a truck station.
Definition: road_gui.cpp:259
GUIList::SetFilterState
void SetFilterState(bool state)
Enable or disable the filter.
Definition: sortlist_type.h:327
Rect::Shrink
Rect Shrink(int s) const
Copy and shrink Rect by s pixels.
Definition: geometry_type.hpp:98
RoadStopGUISettings
Definition: road_gui.cpp:65
StringFilter::IsEmpty
bool IsEmpty() const
Check whether any filter words were entered.
Definition: stringfilter_type.h:60
BuildRoadStationWindow::OnResize
void OnResize() override
Called after the window got resized.
Definition: road_gui.cpp:1490
WID_BROS_MATRIX_SCROLL
@ WID_BROS_MATRIX_SCROLL
Scrollbar of the WID_BROS_SHOW_NEWST_ADDITIONS.
Definition: road_widget.h:58
Company::avail_roadtypes
RoadTypes avail_roadtypes
Road types available to this company.
Definition: company_base.h:134
WID_BROS_IMAGE
@ WID_BROS_IMAGE
Panel used for each image of the matrix.
Definition: road_widget.h:57
WID_BROS_SHOW_NEWST_DEFSIZE
@ WID_BROS_SHOW_NEWST_DEFSIZE
Selection for default-size button for new road stops.
Definition: road_widget.h:62
company_base.h
ViewportDragDropSelectionProcess
ViewportDragDropSelectionProcess
Drag and drop selection process, or, what to do with an area of land when you've selected it.
Definition: viewport_type.h:107
tunnelbridge_map.h
StringFilter::SetFilterTerm
void SetFilterTerm(const char *str)
Set the term to filter on.
Definition: stringfilter.cpp:28
CommandFlagsToDCFlags
static constexpr DoCommandFlag CommandFlagsToDCFlags(CommandFlags cmd_flags)
Extracts the DC flags needed for DoCommand from the flags returned by GetCommandFlags.
Definition: command_func.h:58
timer_game_calendar.h
Axis
Axis
Allow incrementing of DiagDirDiff variables.
Definition: direction_type.h:116
Scrollbar::ScrollTowards
void ScrollTowards(int position)
Scroll towards the given position; if the item is visible nothing happens, otherwise it will be shown...
Definition: widget_type.h:823
WWT_CAPTION
@ WWT_CAPTION
Window caption (window title between closebox and stickybox)
Definition: widget_type.h:63
CBID_STATION_AVAILABILITY
@ CBID_STATION_AVAILABILITY
Determine whether a newstation should be made available to build.
Definition: newgrf_callbacks.h:39
WC_SCEN_BUILD_TOOLBAR
@ WC_SCEN_BUILD_TOOLBAR
Scenario build toolbar; Window numbers:
Definition: window_type.h:80
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
Window::SetWidgetDirty
void SetWidgetDirty(WidgetID widget_index) const
Invalidate a widget, i.e.
Definition: window.cpp:552
BuildRoadStationWindow::last_sorting
static Listing last_sorting
Default sorting of GUIRoadStopClassList.
Definition: road_gui.cpp:1111
NWidgetMatrix
Matrix container with implicitly equal sized (virtual) sub-widgets.
Definition: widget_type.h:583
RoadStopSpec::name
StringID name
Name of this stop.
Definition: newgrf_roadstop.h:132
StringID
uint32_t StringID
Numeric value that represents a string, independent of the selected language.
Definition: strings_type.h:16
WWT_IMGBTN
@ WWT_IMGBTN
(Toggle) Button with image
Definition: widget_type.h:54
DDSP_REMOVE_BUSSTOP
@ DDSP_REMOVE_BUSSTOP
Road stop removal (buses)
Definition: viewport_type.h:133
GUIList< RoadStopClassID, std::nullptr_t, StringFilter & >
WWT_LABEL
@ WWT_LABEL
Centered label.
Definition: widget_type.h:59
CloseWindowById
void CloseWindowById(WindowClass cls, WindowNumber number, bool force, int data)
Close a window by its class and window number (if it is open).
Definition: window.cpp:1141
DropDownList
std::vector< std::unique_ptr< const DropDownListItem > > DropDownList
A drop down list is a collection of drop down list items.
Definition: dropdown_type.h:210
SetRedErrorSquare
void SetRedErrorSquare(TileIndex tile)
Set a tile to display a red error square.
Definition: viewport.cpp:2518
ROADSTOPTYPE_FREIGHT
@ ROADSTOPTYPE_FREIGHT
This RoadStop is for freight (truck) stops.
Definition: newgrf_roadstop.h:48
WWT_DEFSIZEBOX
@ WWT_DEFSIZEBOX
Default window size box (at top-right of a window, between WWT_SHADEBOX and WWT_STICKYBOX)
Definition: widget_type.h:67
IntervalTimer< TimerGameCalendar >
WID_BROD_DEPOT_NW
@ WID_BROD_DEPOT_NW
Depot with NW entry.
Definition: road_widget.h:40
WDP_ALIGN_TOOLBAR
@ WDP_ALIGN_TOOLBAR
Align toward the toolbar.
Definition: window_gui.h:143
DIAGDIR_END
@ DIAGDIR_END
Used for iterations.
Definition: direction_type.h:79
road_widget.h
Pool::PoolItem::index
Tindex index
Index of this pool item.
Definition: pool_type.hpp:238
NWID_HORIZONTAL
@ NWID_HORIZONTAL
Horizontal container.
Definition: widget_type.h:77
DiagDirToAxis
Axis DiagDirToAxis(DiagDirection d)
Convert a DiagDirection to the axis.
Definition: direction_func.h:214
DDSP_BUILD_BUSSTOP
@ DDSP_BUILD_BUSSTOP
Road stop placement (buses)
Definition: viewport_type.h:131
RoadTypeInfo::build_depot
SpriteID build_depot
button for building depots
Definition: road.h:88
maxdim
Dimension maxdim(const Dimension &d1, const Dimension &d2)
Compute bounding box of both dimensions.
Definition: geometry_func.cpp:22
Window::Close
virtual void Close(int data=0)
Hide the window and all its child windows, and mark them for a later deletion.
Definition: window.cpp:1048
WWT_MATRIX
@ WWT_MATRIX
Grid of rows and columns.
Definition: widget_type.h:61
FindWindowById
Window * FindWindowById(WindowClass cls, WindowNumber number)
Find a window by its class and window number.
Definition: window.cpp:1099
BuildRoadToolbarWindow::last_started_action
int last_started_action
Last started user action.
Definition: road_gui.cpp:311
NWID_HORIZONTAL_LTR
@ NWID_HORIZONTAL_LTR
Horizontal container that doesn't change the order of the widgets for RTL languages.
Definition: widget_type.h:78
INVALID_TILE
constexpr TileIndex INVALID_TILE
The very nice invalid tile marker.
Definition: tile_type.h:95
EndContainer
constexpr NWidgetPart EndContainer()
Widget part function for denoting the end of a container (horizontal, vertical, WWT_FRAME,...
Definition: widget_type.h:1153
PlaceProc_DemolishArea
void PlaceProc_DemolishArea(TileIndex tile)
Start a drag for demolishing an area.
Definition: terraform_gui.cpp:150
BuildRoadToolbarWindow::rti
const RoadTypeInfo * rti
Information about current road type.
Definition: road_gui.cpp:310
SetMatrixDataTip
constexpr NWidgetPart SetMatrixDataTip(uint8_t cols, uint8_t rows, StringID tip)
Widget part function for setting the data and tooltip of WWT_MATRIX widgets.
Definition: widget_type.h:1176
_ctrl_pressed
bool _ctrl_pressed
Is Ctrl pressed?
Definition: gfx.cpp:37
FILLRECT_CHECKER
@ FILLRECT_CHECKER
Draw only every second pixel, used for greying-out.
Definition: gfx_type.h:294
SND_15_BEEP
@ SND_15_BEEP
19 == 0x13 GUI button click
Definition: sound_type.h:58
BuildRoadStationWindow::OnRealtimeTick
void OnRealtimeTick([[maybe_unused]] uint delta_ms) override
Called periodically.
Definition: road_gui.cpp:1583
HandlePlacePushButton
bool HandlePlacePushButton(Window *w, WidgetID widget, CursorID cursor, HighLightStyle mode)
This code is shared for the majority of the pushbuttons.
Definition: main_gui.cpp:63
RoadTypeInfo::err_remove_station
StringID err_remove_station[2]
Removing of a bus or truck station.
Definition: road.h:114
BuildRoadToolbarWindow::RoadTramToolbarGlobalHotkeys
static EventState RoadTramToolbarGlobalHotkeys(int hotkey, RoadType last_build, RoadTramType rtt)
Handler for global hotkeys of the BuildRoadToolbarWindow.
Definition: road_gui.cpp:756
zoom_func.h
Scrollbar::SetCapacityFromWidget
void SetCapacityFromWidget(Window *w, WidgetID widget, int padding=0)
Set capacity of visible elements from the size and resize properties of a widget.
Definition: widget.cpp:2341
Window::RaiseButtons
void RaiseButtons(bool autoraise=false)
Raise the buttons of the window.
Definition: window.cpp:526
WID_BROS_FILTER_EDITBOX
@ WID_BROS_FILTER_EDITBOX
Filter text box for the road stop class list.
Definition: road_widget.h:60
WID_BROS_ACCEPTANCE
@ WID_BROS_ACCEPTANCE
Station acceptance info.
Definition: road_widget.h:55
BuildRoadToolbarWindow::OnCTRLStateChange
EventState OnCTRLStateChange() override
The state of the control key has changed.
Definition: road_gui.cpp:744
DrawRoadDepotSprite
void DrawRoadDepotSprite(int x, int y, DiagDirection dir, RoadType rt)
Draw the road depot sprite.
Definition: road_cmd.cpp:1860
VPM_FIX_Y
@ VPM_FIX_Y
drag only in Y axis
Definition: viewport_type.h:91
NWidgetMatrix::SetScrollbar
void SetScrollbar(Scrollbar *sb)
Assign a scrollbar to this matrix.
Definition: widget.cpp:1811
_settings_client
ClientSettings _settings_client
The current settings for this game.
Definition: settings.cpp:54
SZSP_HORIZONTAL
@ SZSP_HORIZONTAL
Display plane with zero size vertically, and filling and resizing horizontally.
Definition: widget_type.h:468
WID_BROD_DEPOT_SE
@ WID_BROD_DEPOT_SE
Depot with SE entry.
Definition: road_widget.h:38
WWT_EMPTY
@ WWT_EMPTY
Empty widget, place holder to reserve space in widget tree.
Definition: widget_type.h:50
ANIMCURSOR_DEMOLISH
static const CursorID ANIMCURSOR_DEMOLISH
704 - 707 - demolish dynamite
Definition: sprites.h:1500
GetCompanyRoadTypes
RoadTypes GetCompanyRoadTypes(CompanyID company, bool introduces)
Get the road types the given company can build.
Definition: road.cpp:199
RectPadding::Vertical
constexpr uint Vertical() const
Get total vertical padding of RectPadding.
Definition: geometry_type.hpp:69
StrongType::Typedef< uint32_t, struct TileIndexTag, StrongType::Compare, StrongType::Integer, StrongType::Compatible< int32_t >, StrongType::Compatible< int64_t > >
GetIfNewStopsByType
bool GetIfNewStopsByType(RoadStopType rs, RoadType roadtype)
Checks if there's any new stations by a specific RoadStopType.
Definition: newgrf_roadstop.cpp:465
StringFilter::AddLine
void AddLine(const char *str)
Pass another text line from the current item to the filter.
Definition: stringfilter.cpp:114
DIAGDIR_NW
@ DIAGDIR_NW
Northwest.
Definition: direction_type.h:78
WID_BROS_SHOW_NEWST_MATRIX
@ WID_BROS_SHOW_NEWST_MATRIX
Selection for new stop image matrix.
Definition: road_widget.h:64
BuildRoadToolbarWindow::UpdateOptionWidgetStatus
void UpdateOptionWidgetStatus(RoadToolbarWidgets clicked_widget)
Update the remove button lowered state of the road toolbar.
Definition: road_gui.cpp:424
RoadTypeInfo::tunnel
CursorID tunnel
Cursor for building a tunnel.
Definition: road.h:98
RoadTypeInfo::replace_text
StringID replace_text
Text used in the autoreplace GUI.
Definition: road.h:107
VEH_ROAD
@ VEH_ROAD
Road vehicle type.
Definition: vehicle_type.h:25
ViewportPlaceMethod
ViewportPlaceMethod
Viewport place method (type of highlighted area and placed objects)
Definition: viewport_type.h:88
BuildRoadStationWindow::vscrollMatrix
Scrollbar * vscrollMatrix
Vertical scrollbar of the station picker matrix.
Definition: road_gui.cpp:1105
WID_BROS_LT_ON
@ WID_BROS_LT_ON
Turn on area highlight.
Definition: road_widget.h:54
WID_BROD_DEPOT_SW
@ WID_BROD_DEPOT_SW
Depot with SW entry.
Definition: road_widget.h:39
RoadTypeInfo::err_remove_road
StringID err_remove_road
Removing a normal piece of road.
Definition: road.h:111
NWID_MATRIX
@ NWID_MATRIX
Matrix container.
Definition: widget_type.h:80
Scrollbar
Scrollbar data structure.
Definition: widget_type.h:680
Window::GetScrollbar
const Scrollbar * GetScrollbar(WidgetID widnum) const
Return the Scrollbar to a widget index.
Definition: window.cpp:315
Window::OnHotkey
virtual EventState OnHotkey(int hotkey)
A hotkey has been pressed.
Definition: window.cpp:566
RoadTypeInfo::depot
CursorID depot
Cursor for building a depot.
Definition: road.h:97
NWidgetPart
Partial widget specification to allow NWidgets to be written nested.
Definition: widget_type.h:1040
WID_BROS_LT_OFF
@ WID_BROS_LT_OFF
Turn off area highlight.
Definition: road_widget.h:53
INVALID_ROADTYPE
@ INVALID_ROADTYPE
flag for invalid roadtype
Definition: road_type.h:30
OrthogonalTileArea::h
uint16_t h
The height of the area.
Definition: tilearea_type.h:21
GUIList::NeedRebuild
bool NeedRebuild() const
Check if a rebuild is needed.
Definition: sortlist_type.h:387
RoadTypeInfo::road_nwse
CursorID road_nwse
Cursor for building rail in Y direction.
Definition: road.h:95
QueryString
Data stored about a string that can be modified in the GUI.
Definition: querystring_gui.h:20
WID_BROS_STATION_Y
@ WID_BROS_STATION_Y
Drive-through station in y-direction.
Definition: road_widget.h:52
RoadTypeInfo::road_swne
CursorID road_swne
Cursor for building rail in X direction.
Definition: road.h:94
CommandCost::Succeeded
bool Succeeded() const
Did this command succeed?
Definition: command_type.h:162
BuildRoadToolbarWindow::OnPlaceObjectAbort
void OnPlaceObjectAbort() override
The user cancelled a tile highlight mode that has been set.
Definition: road_gui.cpp:619
Textbuf::buf
char *const buf
buffer in which text is saved
Definition: textbuf_type.h:32
MAX_CHAR_LENGTH
static const int MAX_CHAR_LENGTH
Max. length of UTF-8 encoded unicode character.
Definition: strings_type.h:18
DDSP_PLACE_ROAD_X_DIR
@ DDSP_PLACE_ROAD_X_DIR
Road placement (X axis)
Definition: viewport_type.h:128
ToggleRoadButton_Remove
static void ToggleRoadButton_Remove(Window *w)
Toggles state of the Remove button of Build road toolbar.
Definition: road_gui.cpp:279
DrawRoadStopTile
void DrawRoadStopTile(int x, int y, RoadType roadtype, const RoadStopSpec *spec, StationType type, int view)
Draw representation of a road stop tile for GUI purposes.
Definition: newgrf_roadstop.cpp:277
NWidgetMatrix::SetCount
void SetCount(int count)
Set the number of elements in this matrix.
Definition: widget.cpp:1787
WindowDesc
High level window description.
Definition: window_gui.h:153
WidgetID
int WidgetID
Widget ID.
Definition: window_type.h:18
RectPadding::Horizontal
constexpr uint Horizontal() const
Get total horizontal padding of RectPadding.
Definition: geometry_type.hpp:63
BROSHK_FOCUS_FILTER_BOX
@ BROSHK_FOCUS_FILTER_BOX
Focus the edit box for editing the filter string.
Definition: road_gui.cpp:1096
StationType
StationType
Station types.
Definition: station_type.h:31
ScaleGUITrad
int ScaleGUITrad(int value)
Scale traditional pixel dimensions to GUI zoom level.
Definition: zoom_func.h:117
window_gui.h
RSF_BUILD_MENU_TRAM_ONLY
@ RSF_BUILD_MENU_TRAM_ONLY
Only show in the tram build menu (not road).
Definition: newgrf_roadstop.h:71
SetPadding
constexpr NWidgetPart SetPadding(uint8_t top, uint8_t right, uint8_t bottom, uint8_t left)
Widget part function for setting additional space around a widget.
Definition: widget_type.h:1190
ROADTYPES_NONE
@ ROADTYPES_NONE
No roadtypes.
Definition: road_type.h:39
WID_ROT_ROAD_Y
@ WID_ROT_ROAD_Y
Build road in y-direction.
Definition: road_widget.h:18
WID_BROS_STATION_X
@ WID_BROS_STATION_X
Drive-through station in x-direction.
Definition: road_widget.h:51
SetResize
constexpr NWidgetPart SetResize(int16_t dx, int16_t dy)
Widget part function for setting the resize step.
Definition: widget_type.h:1088
_roadtypes_type
RoadTypes _roadtypes_type
Bitmap of road/tram types.
Definition: road_cmd.cpp:62
WDP_AUTO
@ WDP_AUTO
Find a place automatically.
Definition: window_gui.h:141
BuildRoadStationWindow::line_height
uint line_height
Height of a single line in the newstation selection matrix.
Definition: road_gui.cpp:1102
Listing
Data structure describing how to show the list (what sort direction and criteria).
Definition: sortlist_type.h:30
SCT_PASSENGERS_ONLY
@ SCT_PASSENGERS_ONLY
Draw only passenger class cargoes.
Definition: station_gui.h:21
Window::resize
ResizeInfo resize
Resize information.
Definition: window_gui.h:308
CommandCost
Common return value for all commands.
Definition: command_type.h:23
WidgetDimensions::matrix
RectPadding matrix
Padding of WWT_MATRIX items.
Definition: window_gui.h:44
tilehighlight_func.h
ClientSettings::sound
SoundSettings sound
sound effect settings
Definition: settings_type.h:638
WindowNumber
int32_t WindowNumber
Number to differentiate different windows of the same class.
Definition: window_type.h:732
FS_NORMAL
@ FS_NORMAL
Index of the normal font in the font tables.
Definition: gfx_type.h:203
Window::InitNested
void InitNested(WindowNumber number=0)
Perform complete initialization of the Window with nested widgets, to allow use.
Definition: window.cpp:1747
SetScrollbar
constexpr NWidgetPart SetScrollbar(WidgetID index)
Attach a scrollbar to a widget.
Definition: widget_type.h:1246
WID_ROT_BUILD_TUNNEL
@ WID_ROT_BUILD_TUNNEL
Build tunnel.
Definition: road_widget.h:26
GUIList::Filter
bool Filter(FilterFunction *decide, F filter_data)
Filter the list.
Definition: sortlist_type.h:343
WWT_EDITBOX
@ WWT_EDITBOX
a textbox for typing
Definition: widget_type.h:73
StationCoverageType
StationCoverageType
Types of cargo to display for station coverage.
Definition: station_gui.h:20
VPM_FIX_X
@ VPM_FIX_X
drag only in X axis
Definition: viewport_type.h:90
VpStartPlaceSizing
void VpStartPlaceSizing(TileIndex tile, ViewportPlaceMethod method, ViewportDragDropSelectionProcess process)
highlighting tiles while only going over them with the mouse
Definition: viewport.cpp:2716
BuildRoadStopHotkeys
BuildRoadStopHotkeys
Enum referring to the Hotkeys in the build road stop window.
Definition: road_gui.cpp:1095
RoadTypes
RoadTypes
The different roadtypes we support, but then a bitmask of them.
Definition: road_type.h:38
_nested_road_station_picker_widgets
static constexpr NWidgetPart _nested_road_station_picker_widgets[]
Widget definition of the build road station window.
Definition: road_gui.cpp:1613
Window::SetDirty
void SetDirty() const
Mark entire window as dirty (in need of re-paint)
Definition: window.cpp:941
GUIList::SortFunction
std::conditional_t< std::is_same_v< P, std::nullptr_t >, bool(const T &, const T &), bool(const T &, const T &, const P)> SortFunction
Signature of sort function.
Definition: sortlist_type.h:49
HT_DIAGONAL
@ HT_DIAGONAL
Also allow 'diagonal rectangles'. Only usable in combination with HT_RECT or HT_POINT.
Definition: tilehighlight_type.h:28
RoadTypeInfo::auto_road
SpriteID auto_road
button for the autoroad construction
Definition: road.h:87
ReverseDiagDir
DiagDirection ReverseDiagDir(DiagDirection d)
Returns the reverse direction of the given DiagDirection.
Definition: direction_func.h:118
WC_TRUCK_STATION
@ WC_TRUCK_STATION
Build truck station; Window numbers:
Definition: window_type.h:409
Window::OnPlaceMouseUp
virtual void OnPlaceMouseUp([[maybe_unused]] ViewportPlaceMethod select_method, [[maybe_unused]] ViewportDragDropSelectionProcess select_proc, [[maybe_unused]] Point pt, [[maybe_unused]] TileIndex start_tile, [[maybe_unused]] TileIndex end_tile)
The user has dragged over the map when the tile highlight mode has been set.
Definition: window_gui.h:830
station_cmd.h
ES_NOT_HANDLED
@ ES_NOT_HANDLED
The passed event is not handled.
Definition: window_type.h:740
CommandCost::Failed
bool Failed() const
Did this command fail?
Definition: command_type.h:171
station_func.h
BuildRoadToolbarWindow::ModifyRoadType
void ModifyRoadType(RoadType roadtype)
Switch to another road type.
Definition: road_gui.cpp:399
BuildRoadDepotWindow
Definition: road_gui.cpp:1005
WID_BROS_STATION_SE
@ WID_BROS_STATION_SE
Terminal station with SE entry.
Definition: road_widget.h:48
PickerWindowBase::Close
void Close([[maybe_unused]] int data=0) override
Hide the window and all its child windows, and mark them for a later deletion.
Definition: window.cpp:3504
VpSelectTilesWithMethod
void VpSelectTilesWithMethod(int x, int y, ViewportPlaceMethod method)
Selects tiles while dragging.
Definition: viewport.cpp:3201
OrthogonalTileArea
Represents the covered area of e.g.
Definition: tilearea_type.h:18
WID_ROT_REMOVE
@ WID_ROT_REMOVE
Remove road.
Definition: road_widget.h:27
NewGRFClass
Struct containing information relating to NewGRF classes for stations and airports.
Definition: newgrf_class.h:20
BuildRoadToolbarWindow::roadtype
RoadType roadtype
Road type to build.
Definition: road_gui.cpp:309
RoadTypeInfo::gui_sprites
struct RoadTypeInfo::@27 gui_sprites
struct containing the sprites for the road GUI.
road_gui.h
ShowSelectStationIfNeeded
void ShowSelectStationIfNeeded(TileArea ta, StationPickerCmdProc proc)
Show the station selection window when needed.
Definition: station_gui.cpp:2455
_settings_game
GameSettings _settings_game
Game settings of a running game or the scenario editor.
Definition: settings.cpp:55
Window::ReInit
void ReInit(int rx=0, int ry=0, bool reposition=false)
Re-initialize a window, and optionally change its size.
Definition: window.cpp:953
Filtering
Data structure describing what to show in the list (filter criteria).
Definition: sortlist_type.h:35
DDSP_REMOVE_TRUCKSTOP
@ DDSP_REMOVE_TRUCKSTOP
Road stop removal (trucks)
Definition: viewport_type.h:134
WC_BUS_STATION
@ WC_BUS_STATION
Build bus station; Window numbers:
Definition: window_type.h:403
WID_BROD_DEPOT_NE
@ WID_BROD_DEPOT_NE
Depot with NE entry.
Definition: road_widget.h:37
IsBridgeTile
bool IsBridgeTile(Tile t)
checks if there is a bridge on this tile
Definition: bridge_map.h:35
Window::parent
Window * parent
Parent window.
Definition: window_gui.h:322
NWidget
constexpr NWidgetPart NWidget(WidgetType tp, Colours col, WidgetID idx=-1)
Widget part function for starting a new 'real' widget.
Definition: widget_type.h:1260
_local_company
CompanyID _local_company
Company controlled by the human player at this client. Can also be COMPANY_SPECTATOR.
Definition: company_cmd.cpp:50
safeguards.h
sortlist_type.h
Window::LowerWidget
void LowerWidget(WidgetID widget_index)
Marks a widget as lowered.
Definition: window_gui.h:460
timer.h
WID_ROT_ONE_WAY
@ WID_ROT_ONE_WAY
Build one-way road.
Definition: road_widget.h:24
WC_BUILD_BRIDGE
@ WC_BUILD_BRIDGE
Build bridge; Window numbers:
Definition: window_type.h:389
CA_BUS
@ CA_BUS
Catchment for bus stops with "modified catchment" enabled.
Definition: station_type.h:77
IsNormalRoadTile
static debug_inline bool IsNormalRoadTile(Tile t)
Return whether a tile is a normal road tile.
Definition: road_map.h:74
PlaceRoad_BusStation
static void PlaceRoad_BusStation(TileIndex tile)
Callback for placing a bus station.
Definition: road_gui.cpp:241
WindowClass
WindowClass
Window classes.
Definition: window_type.h:44
DDSP_PLACE_AUTOROAD
@ DDSP_PLACE_AUTOROAD
Road placement (auto)
Definition: viewport_type.h:130
DDSP_BUILD_BRIDGE
@ DDSP_BUILD_BRIDGE
Bridge placement.
Definition: viewport_type.h:117
RoadStopSpec::grf_prop
GRFFilePropsBase< NUM_CARGO+3 > grf_prop
Properties related the the grf file.
Definition: newgrf_roadstop.h:129
BuildRoadToolbarWindow::OnInvalidateData
void OnInvalidateData([[maybe_unused]] int data=0, [[maybe_unused]] bool gui_scope=true) override
Some data on this window has become invalid.
Definition: road_gui.cpp:342
TileHighlightData::pos
Point pos
Location, in tile "units", of the northern tile of the selected area.
Definition: tilehighlight_type.h:47
RSF_DRIVE_THROUGH_ONLY
@ RSF_DRIVE_THROUGH_ONLY
Stop is drive-through only.
Definition: newgrf_roadstop.h:68
CA_TRUCK
@ CA_TRUCK
Catchment for truck stops with "modified catchment" enabled.
Definition: station_type.h:78
RSF_NO_AUTO_ROAD_CONNECTION
@ RSF_NO_AUTO_ROAD_CONNECTION
No auto road connection.
Definition: newgrf_roadstop.h:69
Point
Coordinates of a point in 2D.
Definition: geometry_type.hpp:21
PlaceRoadStop
static void PlaceRoadStop(TileIndex start_tile, TileIndex end_tile, RoadStopType stop_type, bool adjacent, RoadType rt, StringID err_msg)
Place a new road stop.
Definition: road_gui.cpp:215
ValParamRoadType
bool ValParamRoadType(RoadType roadtype)
Validate functions for rail building.
Definition: road.cpp:153
DiagDirToRoadBits
RoadBits DiagDirToRoadBits(DiagDirection d)
Create the road-part which belongs to the given DiagDirection.
Definition: road_func.h:96
DiagDirection
DiagDirection
Enumeration for diagonal directions.
Definition: direction_type.h:73
Window::IsWidgetDisabled
bool IsWidgetDisabled(WidgetID widget_index) const
Gets the enabled/disabled status of a widget.
Definition: window_gui.h:410
WID_BROS_STATION_NW
@ WID_BROS_STATION_NW
Terminal station with NW entry.
Definition: road_widget.h:50
BuildRoadStationWindow::roadstop_classes
GUIRoadStopClassList roadstop_classes
Available road stop classes.
Definition: road_gui.cpp:1115
newgrf_roadstop.h
Scrollbar::GetScrolledItemFromWidget
Tcontainer::iterator GetScrolledItemFromWidget(Tcontainer &container, int clickpos, const Window *const w, WidgetID widget, int padding=0, int line_height=-1) const
Return an iterator pointing to the element of a scrolled widget that a user clicked in.
Definition: widget_type.h:847
RoadTypeInfo::build_tunnel
SpriteID build_tunnel
button for building a tunnel
Definition: road.h:89
StationSettings::station_spread
byte station_spread
amount a station may spread
Definition: settings_type.h:594
tunnelbridge_cmd.h
stdafx.h
Window::window_number
WindowNumber window_number
Window number within the window class.
Definition: window_gui.h:296
Window::SetFocusedWidget
bool SetFocusedWidget(WidgetID widget_index)
Set focus within this window to the given widget.
Definition: window.cpp:487
GUISettings::link_terraform_toolbar
bool link_terraform_toolbar
display terraform toolbar when displaying rail, road, water and airport toolbars
Definition: settings_type.h:142
GfxFillRect
void GfxFillRect(int left, int top, int right, int bottom, int colour, FillRectMode mode)
Applies a certain FillRectMode-operation to a rectangle [left, right] x [top, bottom] on the screen.
Definition: gfx.cpp:113
CcRoadStop
void CcRoadStop(Commands, const CommandCost &result, TileIndex tile, uint8_t width, uint8_t length, RoadStopType, bool is_drive_through, DiagDirection dir, RoadType, RoadStopClassID spec_class, uint16_t spec_index, StationID, bool)
Command callback for building road stops.
Definition: road_gui.cpp:181
DRD_NONE
@ DRD_NONE
None of the directions are disallowed.
Definition: road_type.h:74
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:3144
viewport_func.h
BuildRoadToolbarWindow::SetupRoadToolbar
void SetupRoadToolbar()
Configures the road toolbar for roadtype given.
Definition: road_gui.cpp:383
WC_NONE
@ WC_NONE
No window, redirects to WC_MAIN_WINDOW.
Definition: window_type.h:45
CanBuildVehicleInfrastructure
bool CanBuildVehicleInfrastructure(VehicleType type, byte subtype)
Check whether we can build infrastructure for the given vehicle type.
Definition: vehicle.cpp:1915
Window::SetWidgetLoweredState
void SetWidgetLoweredState(WidgetID widget_index, bool lowered_stat)
Sets the lowered/raised status of a widget.
Definition: window_gui.h:441
BuildRoadStationWindow::last_filtering
static Filtering last_filtering
Default filtering of GUIRoadStopClassList.
Definition: road_gui.cpp:1112
NWID_VERTICAL
@ NWID_VERTICAL
Vertical container.
Definition: widget_type.h:79
RoadTypeInfo::cursor
struct RoadTypeInfo::@28 cursor
Cursors associated with the road type.
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:1567
WC_BUILD_DEPOT
@ WC_BUILD_DEPOT
Build depot; Window numbers:
Definition: window_type.h:417
_nested_tram_station_picker_widgets
static constexpr NWidgetPart _nested_tram_station_picker_widgets[]
Widget definition of the build tram station window.
Definition: road_gui.cpp:1713
TileOffsByDiagDir
TileIndexDiff TileOffsByDiagDir(DiagDirection dir)
Convert a DiagDirection to a TileIndexDiff.
Definition: map_func.h:563
BuildRoadStationWindow::filter_editbox
QueryString filter_editbox
Filter editbox.
Definition: road_gui.cpp:1117
WidgetDimensions::unscaled
static const WidgetDimensions unscaled
Unscaled widget dimensions.
Definition: window_gui.h:67
GetRoadTypeInfo
const RoadTypeInfo * GetRoadTypeInfo(RoadType roadtype)
Returns a pointer to the Roadtype information for a given roadtype.
Definition: road.h:227
Window::SetWidgetDisabledState
void SetWidgetDisabledState(WidgetID widget_index, bool disab_stat)
Sets the enabled/disabled status of a widget.
Definition: window_gui.h:381
WID_BROS_MATRIX
@ WID_BROS_MATRIX
Matrix widget displaying all available road stops.
Definition: road_widget.h:56
GetSpriteSize
Dimension GetSpriteSize(SpriteID sprid, Point *offset, ZoomLevel zoom)
Get the size of a sprite.
Definition: gfx.cpp:937
WWT_CLOSEBOX
@ WWT_CLOSEBOX
Close box (at top-left of a window)
Definition: widget_type.h:71
WWT_RESIZEBOX
@ WWT_RESIZEBOX
Resize box (normally at bottom-right of a window)
Definition: widget_type.h:70
RoadTypeInfo::picker_tooltip
StringID picker_tooltip[2]
Tooltip for the station picker for bus or truck stations.
Definition: road.h:118
BuildRoadStationWindow::GetRoadStationTypeByWindowClass
StationType GetRoadStationTypeByWindowClass(WindowClass window_class) const
Simply to have a easier way to get the StationType for bus, truck and trams from the WindowClass.
Definition: road_gui.cpp:1410
BuildRoadStationWindow
Definition: road_gui.cpp:1099
ShowBuildBridgeWindow
void ShowBuildBridgeWindow(TileIndex start, TileIndex end, TransportType transport_type, byte road_rail_type)
Prepare the data for the build a bridge window.
Definition: bridge_gui.cpp:361
DrawStationCoverageAreaText
int DrawStationCoverageAreaText(int left, int right, int top, StationCoverageType sct, int rad, bool supplies)
Calculates and draws the accepted or supplied cargo around the selected tile(s)
Definition: station_gui.cpp:52
RoadTypeInfo::build_x_road
SpriteID build_x_road
button for building single rail in X direction
Definition: road.h:85
BuildRoadToolbarWindow::OnHotkey
EventState OnHotkey(int hotkey) override
A hotkey has been pressed.
Definition: road_gui.cpp:555
RoadTypeInfo::convert_road
SpriteID convert_road
button for converting road types
Definition: road.h:90
AddDateIntroducedRoadTypes
RoadTypes AddDateIntroducedRoadTypes(RoadTypes current, TimerGameCalendar::Date date)
Add the road types that are to be introduced at the given date.
Definition: road.cpp:166
GUIList::ForceRebuild
void ForceRebuild()
Force that a rebuild is needed.
Definition: sortlist_type.h:395
string_func.h
ROADSTOP_CLASS_WAYP
@ ROADSTOP_CLASS_WAYP
Waypoint class (unimplemented: this is reserved for future use with road waypoints).
Definition: newgrf_roadstop.h:28
Window::IsWidgetLowered
bool IsWidgetLowered(WidgetID widget_index) const
Gets the lowered state of a widget.
Definition: window_gui.h:491
CALLBACK_FAILED
static const uint CALLBACK_FAILED
Different values for Callback result evaluations.
Definition: newgrf_callbacks.h:420
ROADSTOP_BUS
@ ROADSTOP_BUS
A standard stop for buses.
Definition: station_type.h:44
ROADSTOP_CLASS_DFLT
@ ROADSTOP_CLASS_DFLT
Default road stop class.
Definition: newgrf_roadstop.h:27
Window::querystrings
std::map< WidgetID, QueryString * > querystrings
QueryString associated to WWT_EDITBOX widgets.
Definition: window_gui.h:314
SoundSettings::confirm
bool confirm
Play sound effect on successful constructions or other actions.
Definition: settings_type.h:240
vehicle_func.h
WC_SELECT_STATION
@ WC_SELECT_STATION
Select station (when joining stations); Window numbers:
Definition: window_type.h:242
Window::CreateNestedTree
void CreateNestedTree()
Perform the first part of the initialization of a nested widget tree.
Definition: window.cpp:1724
strings_func.h
NWID_VSCROLLBAR
@ NWID_VSCROLLBAR
Vertical scrollbar.
Definition: widget_type.h:86
terraform_gui.h
Window::IsShaded
bool IsShaded() const
Is window shaded currently?
Definition: window_gui.h:557
INVALID_AXIS
@ INVALID_AXIS
Flag for an invalid Axis.
Definition: direction_type.h:120
Scrollbar::IsVisible
bool IsVisible(uint16_t item) const
Checks whether given current item is visible in the list.
Definition: widget_type.h:732
VPM_Y_LIMITED
@ VPM_Y_LIMITED
Drag only in Y axis with limited size.
Definition: viewport_type.h:97
RoadTypeInfo::err_build_station
StringID err_build_station[2]
Building a bus or truck station.
Definition: road.h:113
Window::DisableWidget
void DisableWidget(WidgetID widget_index)
Sets a widget to disabled.
Definition: window_gui.h:391
WWT_TEXT
@ WWT_TEXT
Pure simple text.
Definition: widget_type.h:60
SetPIP
constexpr NWidgetPart SetPIP(uint8_t pre, uint8_t inter, uint8_t post)
Widget part function for setting a pre/inter/post spaces.
Definition: widget_type.h:1222
WC_SCEN_LAND_GEN
@ WC_SCEN_LAND_GEN
Landscape generation (in Scenario Editor); Window numbers:
Definition: window_type.h:449
SetDParam
void SetDParam(size_t n, uint64_t v)
Set a string parameter v at index n in the global string parameter array.
Definition: strings.cpp:104
WID_ROT_ROAD_X
@ WID_ROT_ROAD_X
Build road in x-direction.
Definition: road_widget.h:17
SCT_NON_PASSENGERS_ONLY
@ SCT_NON_PASSENGERS_ONLY
Draw all non-passenger class cargoes.
Definition: station_gui.h:22
BuildRoadToolbarWindow
Road toolbar window handler.
Definition: road_gui.cpp:308
geometry_func.hpp
OrthogonalTileArea::tile
TileIndex tile
The base tile of the area.
Definition: tilearea_type.h:19
RoadTypeInfo::autoroad
CursorID autoroad
Cursor for autorail tool.
Definition: road.h:96
_build_tunnel_endtile
TileIndex _build_tunnel_endtile
The end of a tunnel; as hidden return from the tunnel build command for GUI purposes.
Definition: tunnelbridge_cmd.cpp:53
RoadTypeInfo::err_convert_road
StringID err_convert_road
Converting a road type.
Definition: road.h:115
WID_BROS_FILTER_CONTAINER
@ WID_BROS_FILTER_CONTAINER
Container for the filter text box for the road stop class list.
Definition: road_widget.h:59
StringFilter::ResetState
void ResetState()
Reset the matching state to process a new item.
Definition: stringfilter.cpp:98
WWT_PANEL
@ WWT_PANEL
Simple depressed panel.
Definition: widget_type.h:52
MarkTileDirtyByTile
void MarkTileDirtyByTile(TileIndex tile, int bridge_level_offset, int tile_height_override)
Mark a tile given by its index dirty for repaint.
Definition: viewport.cpp:2051
WID_BROS_STATION_SW
@ WID_BROS_STATION_SW
Terminal station with SW entry.
Definition: road_widget.h:49
WID_ROT_AUTOROAD
@ WID_ROT_AUTOROAD
Autorail.
Definition: road_widget.h:19
WidgetDimensions::vsep_normal
int vsep_normal
Normal vertical spacing.
Definition: window_gui.h:60
AutoRestoreBackup
Class to backup a specific variable and restore it upon destruction of this object to prevent stack v...
Definition: backup_type.hpp:153
ScaleSpriteTrad
int ScaleSpriteTrad(int value)
Scale traditional pixel dimensions to GUI zoom level, for drawing sprites.
Definition: zoom_func.h:107
BuildRoadStationWindow::roadStopType
RoadStopType roadStopType
The RoadStopType for this Window.
Definition: road_gui.cpp:1101
Scrollbar::SetCount
void SetCount(size_t num)
Sets the number of elements in the list.
Definition: widget_type.h:762
GetString
std::string GetString(StringID string)
Resolve the given StringID into a std::string with all the associated DParam lookups and formatting.
Definition: strings.cpp:327
EventState
EventState
State of handling an event.
Definition: window_type.h:738
HT_RECT
@ HT_RECT
rectangle (stations, depots, ...)
Definition: tilehighlight_type.h:21
RoadToolbar_CtrlChanged
static bool RoadToolbar_CtrlChanged(Window *w)
Updates the Remove button because of Ctrl state change.
Definition: road_gui.cpp:292
VPM_X_AND_Y
@ VPM_X_AND_Y
area of land in X and Y directions
Definition: viewport_type.h:92
StringFilter::GetState
bool GetState() const
Get the matching state of the current item.
Definition: stringfilter_type.h:71
NewGRFClass::name
StringID name
Name of this class.
Definition: newgrf_class.h:39
Window::window_class
WindowClass window_class
Window class.
Definition: window_gui.h:295
RoadType
RoadType
The different roadtypes we support.
Definition: road_type.h:25
GetRoadBits
RoadBits GetRoadBits(Tile t, RoadTramType rtt)
Get the present road bits for a specific road type.
Definition: road_map.h:128
PackVelocity
int64_t PackVelocity(uint speed, VehicleType type)
Pack velocity and vehicle type for use with SCC_VELOCITY string parameter.
Definition: strings_func.h:74
Window::FinishInitNested
void FinishInitNested(WindowNumber window_number=0)
Perform the second part of the initialization of a nested widget tree.
Definition: window.cpp:1734
DC_AUTO
@ DC_AUTO
don't allow building on structures
Definition: command_type.h:372
PC_BLACK
static const uint8_t PC_BLACK
Black palette colour.
Definition: palette_func.h:55
DDSP_CONVERT_ROAD
@ DDSP_CONVERT_ROAD
Road conversion.
Definition: viewport_type.h:135
RoadTypeInfo::strings
struct RoadTypeInfo::@29 strings
Strings associated with the rail type.
company_func.h
BuildRoadStationWindow::TagNameFilter
static bool CDECL TagNameFilter(RoadStopClassID const *sc, StringFilter &filter)
Filter classes by class name.
Definition: road_gui.cpp:1247
BuildRoadStationWindow::coverage_height
uint coverage_height
Height of the coverage texts.
Definition: road_gui.cpp:1103
PickerWindowBase
Base class for windows opened from a toolbar.
Definition: window_gui.h:980
BuildRoadStationWindow::filter_funcs
static GUIRoadStopClassList::FilterFunction *const filter_funcs[]
Filter functions of the GUIRoadStopClassList.
Definition: road_gui.cpp:1114
SetViewportCatchmentStation
void SetViewportCatchmentStation(const Station *st, bool sel)
Select or deselect station for coverage area highlight.
Definition: viewport.cpp:3603
GetOtherTunnelBridgeEnd
TileIndex GetOtherTunnelBridgeEnd(Tile t)
Determines type of the wormhole and returns its other end.
Definition: tunnelbridge_map.h:78
CcBuildRoadTunnel
void CcBuildRoadTunnel(Commands, const CommandCost &result, TileIndex start_tile)
Callback executed after a build road tunnel command has been called.
Definition: road_gui.cpp:127
WidgetDimensions::fullbevel
RectPadding fullbevel
Always-scaled bevel thickness.
Definition: window_gui.h:41
WID_ROT_CAPTION
@ WID_ROT_CAPTION
Caption of the window.
Definition: road_widget.h:16
RSF_BUILD_MENU_ROAD_ONLY
@ RSF_BUILD_MENU_ROAD_ONLY
Only show in the road build menu (not tram).
Definition: newgrf_roadstop.h:70
Window::top
int top
y position of top edge of the window
Definition: window_gui.h:304
AXIS_X
@ AXIS_X
The X axis.
Definition: direction_type.h:117
OrthogonalTileArea::w
uint16_t w
The width of the area.
Definition: tilearea_type.h:20
BuildRoadStationWindow::OnHotkey
EventState OnHotkey(int hotkey) override
A hotkey has been pressed.
Definition: road_gui.cpp:1306
Window::RaiseWidget
void RaiseWidget(WidgetID widget_index)
Marks a widget as raised.
Definition: window_gui.h:469
BuildRoadStationWindow::OnInvalidateData
void OnInvalidateData([[maybe_unused]] int data=0, [[maybe_unused]] bool gui_scope=true) override
Some data on this window has become invalid.
Definition: road_gui.cpp:1299
CommandHelper
Definition: command_func.h:93
GUIList::SetFilterFuncs
void SetFilterFuncs(FilterFunction *const *n_funcs)
Hand the array of filter function pointers to the sort list.
Definition: sortlist_type.h:366
window_func.h
SoundSettings::click_beep
bool click_beep
Beep on a random selection of buttons.
Definition: settings_type.h:241
GetCharacterHeight
int GetCharacterHeight(FontSize size)
Get height of a character for a given font size.
Definition: fontcache.cpp:78
RoadTypeInfo::max_speed
uint16_t max_speed
Maximum speed for vehicles travelling on this road type.
Definition: road.h:142
WID_BROS_CAPTION
@ WID_BROS_CAPTION
Caption of the window.
Definition: road_widget.h:46
VPM_X_LIMITED
@ VPM_X_LIMITED
Drag only in X axis with limited size.
Definition: viewport_type.h:96
stringfilter_type.h
ROAD_NONE
@ ROAD_NONE
No road-part is build.
Definition: road_type.h:53
NewGRFClass::Get
static NewGRFClass * Get(Tid cls_id)
Get a particular class.
Definition: newgrf_class_func.h:98
ShowTerraformToolbar
Window * ShowTerraformToolbar(Window *link)
Show the toolbar for terraforming in the game.
Definition: terraform_gui.cpp:367
SetMinimalSize
constexpr NWidgetPart SetMinimalSize(int16_t x, int16_t y)
Widget part function for setting the minimal size.
Definition: widget_type.h:1099
SetPIPRatio
constexpr NWidgetPart SetPIPRatio(uint8_t ratio_pre, uint8_t ratio_inter, uint8_t ratio_post)
Widget part function for setting a pre/inter/post ratio.
Definition: widget_type.h:1234
GUIList::SetSortFuncs
void SetSortFuncs(SortFunction *const *n_funcs)
Hand the array of sort function pointers to the sort list.
Definition: sortlist_type.h:295
GUIList::RebuildDone
void RebuildDone()
Notify the sortlist that the rebuild is done.
Definition: sortlist_type.h:405
GUIList< RoadStopClassID, std::nullptr_t, StringFilter & >::FilterFunction
bool CDECL FilterFunction(const RoadStopClassID *, StringFilter &)
Signature of filter function.
Definition: sortlist_type.h:50
CBM_ROAD_STOP_AVAIL
@ CBM_ROAD_STOP_AVAIL
Availability of road stop in construction window.
Definition: newgrf_callbacks.h:321
SND_1F_CONSTRUCTION_OTHER
@ SND_1F_CONSTRUCTION_OTHER
29 == 0x1D Construction: other (non-water, non-rail, non-bridge)
Definition: sound_type.h:68
ShowBuildRoadToolbar
Window * ShowBuildRoadToolbar(RoadType roadtype)
Open the build road toolbar window.
Definition: road_gui.cpp:910
DrawString
int DrawString(int left, int right, int top, std::string_view str, TextColour colour, StringAlignment align, bool underline, FontSize fontsize)
Draw string, possibly truncated to make it fit in its allocated space.
Definition: gfx.cpp:654
engine_base.h
TRANSPORT_ROAD
@ TRANSPORT_ROAD
Transport by road vehicle.
Definition: transport_type.h:28
TileVirtXY
static debug_inline TileIndex TileVirtXY(uint x, uint y)
Get a tile from the virtual XY-coordinate.
Definition: map_func.h:416
gui.h
TimerGameCalendar::date
static Date date
Current date in days (day counter).
Definition: timer_game_calendar.h:34
WID_ROT_DEPOT
@ WID_ROT_DEPOT
Build depot.
Definition: road_widget.h:21
WID_BROS_SHOW_NEWST_ORIENTATION
@ WID_BROS_SHOW_NEWST_ORIENTATION
Selection for the orientation string for new stops.
Definition: road_widget.h:66
WID_BROD_CAPTION
@ WID_BROD_CAPTION
Caption of the window.
Definition: road_widget.h:36
Window
Data structure for an opened window.
Definition: window_gui.h:267
GetRoadTypes
RoadTypes GetRoadTypes(bool introduces)
Get list of road types, regardless of company availability.
Definition: road.cpp:227
Commands
Commands
List of commands.
Definition: command_type.h:187
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:328
WID_BROS_SHOW_NEWST_RESIZE
@ WID_BROS_SHOW_NEWST_RESIZE
Selection for panel and resize at bottom right for new stops.
Definition: road_widget.h:65
Window::DrawWidgets
void DrawWidgets() const
Paint all widgets of a window.
Definition: widget.cpp:731
GRFFilePropsBase::grffile
const struct GRFFile * grffile
grf file that introduced this entity
Definition: newgrf_commons.h:319
RoadTypeInfo::err_depot
StringID err_depot
Building a depot.
Definition: road.h:112
SetDataTip
constexpr NWidgetPart SetDataTip(uint32_t data, StringID tip)
Widget part function for setting the data and tooltip.
Definition: widget_type.h:1164
GetIfClassHasNewStopsByType
bool GetIfClassHasNewStopsByType(const RoadStopClass *roadstopclass, RoadStopType rs, RoadType roadtype)
Checks if the given RoadStopClass has any specs assigned to it, compatible with the given RoadStopTyp...
Definition: newgrf_roadstop.cpp:485
ConnectRoadToStructure
void ConnectRoadToStructure(TileIndex tile, DiagDirection direction)
If required, connects a new structure to an existing road or tram by building the missing roadbit.
Definition: road_gui.cpp:149
SetMinimalTextLines
constexpr NWidgetPart SetMinimalTextLines(uint8_t lines, uint8_t spacing, FontSize size=FS_NORMAL)
Widget part function for setting the minimal text lines.
Definition: widget_type.h:1111
Rect::Width
int Width() const
Get width of Rect.
Definition: geometry_type.hpp:85
VPM_X_AND_Y_LIMITED
@ VPM_X_AND_Y_LIMITED
area of land of limited size
Definition: viewport_type.h:93
NWID_SELECTION
@ NWID_SELECTION
Stacked widgets, only one visible at a time (eg in a panel with tabs).
Definition: widget_type.h:82
InitializeRoadGUI
void InitializeRoadGUI()
I really don't know why rail_gui.cpp has this too, shouldn't be included in the other one?
Definition: road_gui.cpp:1804
DIAGDIR_NE
@ DIAGDIR_NE
Northeast, upper right on your monitor.
Definition: direction_type.h:75
RoadStopClassID
RoadStopClassID
Definition: newgrf_roadstop.h:25
Rect
Specification of a rectangle with absolute coordinates of all edges.
Definition: geometry_type.hpp:75
Window::ToggleWidgetLoweredState
void ToggleWidgetLoweredState(WidgetID widget_index)
Invert the lowered/raised status of a widget.
Definition: window_gui.h:450
Company
Definition: company_base.h:129
GUIList::Sort
bool Sort(Comp compare)
Sort the list.
Definition: sortlist_type.h:268
BuildRoadStationWindow::sorter_funcs
static GUIRoadStopClassList::SortFunction *const sorter_funcs[]
Sort functions of the GUIRoadStopClassList.
Definition: road_gui.cpp:1113
Window::SetWidgetsDisabledState
void SetWidgetsDisabledState(bool disab_stat, Args... widgets)
Sets the enabled/disabled status of a list of widgets.
Definition: window_gui.h:515
VPM_X_OR_Y
@ VPM_X_OR_Y
drag in X or Y direction
Definition: viewport_type.h:89
RoadToolbarWidgets
RoadToolbarWidgets
Widgets of the BuildRoadToolbarWindow class.
Definition: road_widget.h:14
ResetObjectToPlace
void ResetObjectToPlace()
Reset the cursor and mouse mode handling back to default (normal cursor, only clicking in windows).
Definition: viewport.cpp:3483
HT_SPECIAL
@ HT_SPECIAL
special mode used for highlighting while dragging (and for tunnels/docks)
Definition: tilehighlight_type.h:23
Convert8bitBooleanCallback
bool Convert8bitBooleanCallback(const GRFFile *grffile, uint16_t cbid, uint16_t cb_res)
Converts a callback result into a boolean.
Definition: newgrf_commons.cpp:548
station_gui.h
GUIList::SetFiltering
void SetFiltering(Filtering f)
Import filter conditions.
Definition: sortlist_type.h:202
SetTextStyle
constexpr NWidgetPart SetTextStyle(TextColour colour, FontSize size=FS_NORMAL)
Widget part function for setting the text style.
Definition: widget_type.h:1122
RoadTypeInfo::picker_title
StringID picker_title[2]
Title for the station picker for bus or truck stations.
Definition: road.h:117
WID_BROS_SHOW_NEWST_TYPE
@ WID_BROS_SHOW_NEWST_TYPE
Display of selected stop type.
Definition: road_widget.h:68
BuildRoadStationWindow::string_filter
StringFilter string_filter
Filter for available road stop classes.
Definition: road_gui.cpp:1116
GetStringBoundingBox
Dimension GetStringBoundingBox(std::string_view str, FontSize start_fontsize)
Return the string dimension in pixels.
Definition: gfx.cpp:848
StringFilter
String filter and state.
Definition: stringfilter_type.h:30
DRD_NORTHBOUND
@ DRD_NORTHBOUND
All northbound traffic is disallowed.
Definition: road_type.h:76
road_cmd.h
WWT_TEXTBTN
@ WWT_TEXTBTN
(Toggle) Button with text
Definition: widget_type.h:57
WID_BROS_SHOW_NEWST_ADDITIONS
@ WID_BROS_SHOW_NEWST_ADDITIONS
Selection for new class selection list.
Definition: road_widget.h:63
ClientSettings::gui
GUISettings gui
settings related to the GUI
Definition: settings_type.h:635
WID_BROS_NEWST_LIST
@ WID_BROS_NEWST_LIST
List with new road stops.
Definition: road_widget.h:69
IsRoadStopAvailable
static bool IsRoadStopAvailable(const RoadStopSpec *roadstopspec, StationType type)
Check whether a road stop type can be built.
Definition: road_gui.cpp:78
WID_BROS_AVAILABLE_ORIENTATIONS
@ WID_BROS_AVAILABLE_ORIENTATIONS
Selection for selecting 6 or 2 orientations.
Definition: road_widget.h:61
BuildRoadStationWindow::GUIRoadStopClassList
GUIList< RoadStopClassID, std::nullptr_t, StringFilter & > GUIRoadStopClassList
Type definition for the list to hold available road stop classes.
Definition: road_gui.cpp:1107
DDSP_BUILD_TRUCKSTOP
@ DDSP_BUILD_TRUCKSTOP
Road stop placement (trucks)
Definition: viewport_type.h:132
DrawPixelInfo
Data about how and where to blit pixels.
Definition: gfx_type.h:151
WID_ROT_CONVERT_ROAD
@ WID_ROT_CONVERT_ROAD
Convert road.
Definition: road_widget.h:28
GUISettings::persistent_buildingtools
bool persistent_buildingtools
keep the building tools active after usage
Definition: settings_type.h:190
GUIList::SetListing
void SetListing(Listing l)
Import sort conditions.
Definition: sortlist_type.h:151
StationSettings::modified_catchment
bool modified_catchment
different-size catchment areas
Definition: settings_type.h:589
WID_ROT_BUS_STATION
@ WID_ROT_BUS_STATION
Build bus station.
Definition: road_widget.h:22
Hotkey
All data for a single hotkey.
Definition: hotkeys.h:21
hotkeys.h
GetTunnelBridgeDirection
DiagDirection GetTunnelBridgeDirection(Tile t)
Get the direction pointing to the other end.
Definition: tunnelbridge_map.h:26
ROADSTOPTYPE_PASSENGER
@ ROADSTOPTYPE_PASSENGER
This RoadStop is for passenger (bus) stops.
Definition: newgrf_roadstop.h:47
INVALID_RAILTYPE
@ INVALID_RAILTYPE
Flag for invalid railtype.
Definition: rail_type.h:34
BuildRoadStationWindow::vscrollList
Scrollbar * vscrollList
Vertical scrollbar of the new station list.
Definition: road_gui.cpp:1104
ShowBuildRoadScenToolbar
Window * ShowBuildRoadScenToolbar(RoadType roadtype)
Show the road building toolbar in the scenario editor.
Definition: road_gui.cpp:997
WWT_SHADEBOX
@ WWT_SHADEBOX
Shade box (at top-right of a window, between WWT_DEBUGBOX and WWT_DEFSIZEBOX)
Definition: widget_type.h:66
WID_BROS_STATION_NE
@ WID_BROS_STATION_NE
Terminal station with NE entry.
Definition: road_widget.h:47
NWidgetMatrix::SetClicked
void SetClicked(int clicked)
Sets the clicked element in the matrix.
Definition: widget.cpp:1770
HasBit
constexpr debug_inline bool HasBit(const T x, const uint8_t y)
Checks if a bit in a value is set.
Definition: bitmath_func.hpp:103
GUIPlaceProcDragXY
bool GUIPlaceProcDragXY(ViewportDragDropSelectionProcess proc, TileIndex start_tile, TileIndex end_tile)
A central place to handle all X_AND_Y dragged GUI functions.
Definition: terraform_gui.cpp:111