OpenTTD Source
20240917-master-g9ab0a47812
|
Go to the documentation of this file.
49 #include "table/strings.h"
54 static void ShowRoadDepotPicker(
Window *parent);
55 static void ShowBuildRoadWaypointPicker(
Window *parent);
58 static bool _one_way_button_clicked;
60 static Axis _place_road_dir;
61 static bool _place_road_start_half_x;
62 static bool _place_road_start_half_y;
63 static bool _place_road_end_half;
84 if (spec ==
nullptr)
return true;
89 switch (spec->stop_type) {
93 default: NOT_REACHED();
103 if (spec ==
nullptr)
return true;
104 if (!IsRoadStopEverAvailable(spec, type))
return false;
175 if (result.
Failed())
return;
197 if (result.
Failed())
return;
202 bool connect_to_road =
true;
208 if (connect_to_road) {
209 TileArea roadstop_area(tile, width, length);
210 for (
TileIndex cur_tile : roadstop_area) {
235 uint16_t spec_index = _roadstop_gui.
sel_type;
237 auto proc = [=](
bool test, StationID to_join) ->
bool {
240 ddir, rt, spec_class, spec_index, INVALID_STATION, adjacent).Succeeded();
243 ddir, rt, spec_class, spec_index, to_join, adjacent);
309 typedef void OnButtonClick(
Window *w);
351 this->Initialize(_cur_roadtype);
357 if (RoadTypeIsRoad(this->roadtype)) {
362 this->last_started_action = INVALID_WID_ROT;
367 void Close([[maybe_unused]]
int data = 0)
override
379 void OnInvalidateData([[maybe_unused]]
int data = 0, [[maybe_unused]]
bool gui_scope =
true)
override
381 if (!gui_scope)
return;
382 RoadTramType rtt = GetRoadTramType(this->roadtype);
397 if (_game_mode != GM_EDITOR) {
400 this->GetWidget<NWidgetCore>(
WID_ROT_DEPOT)->SetToolTip(STR_TOOLBAR_DISABLED_NO_VEHICLE_AVAILABLE);
401 this->GetWidget<NWidgetCore>(
WID_ROT_BUILD_WAYPOINT)->SetToolTip(STR_TOOLBAR_DISABLED_NO_VEHICLE_AVAILABLE);
402 this->GetWidget<NWidgetCore>(
WID_ROT_BUS_STATION)->SetToolTip(STR_TOOLBAR_DISABLED_NO_VEHICLE_AVAILABLE);
403 this->GetWidget<NWidgetCore>(
WID_ROT_TRUCK_STATION)->SetToolTip(STR_TOOLBAR_DISABLED_NO_VEHICLE_AVAILABLE);
405 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);
406 this->GetWidget<NWidgetCore>(
WID_ROT_BUILD_WAYPOINT)->SetToolTip(rtt == RTT_ROAD ? STR_ROAD_TOOLBAR_TOOLTIP_CONVERT_ROAD_TO_WAYPOINT : STR_ROAD_TOOLBAR_TOOLTIP_CONVERT_TRAM_TO_WAYPOINT);
407 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);
408 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);
429 if (_game_mode != GM_EDITOR) {
447 void SetStringParameters(
WidgetID widget)
const override
451 SetDParam(0, STR_TOOLBAR_RAILTYPE_VELOCITY);
470 switch (clicked_widget) {
472 if (RoadTypeIsRoad(this->roadtype)) {
495 if (RoadTypeIsRoad(this->roadtype)) {
506 if (RoadTypeIsRoad(this->roadtype)) {
515 void OnClick([[maybe_unused]]
Point pt,
WidgetID widget, [[maybe_unused]]
int click_count)
override
518 _one_way_button_clicked =
false;
522 this->last_started_action = widget;
527 this->last_started_action = widget;
532 this->last_started_action = widget;
537 this->last_started_action = widget;
542 ShowRoadDepotPicker(
this);
543 this->last_started_action = widget;
548 this->last_started_action = widget;
550 ShowBuildRoadWaypointPicker(
this);
557 this->last_started_action = widget;
564 this->last_started_action = widget;
572 SetSelectionRed(
false);
577 this->last_started_action = widget;
582 this->last_started_action = widget;
595 this->last_started_action = widget;
598 default: NOT_REACHED();
610 void OnPlaceObject([[maybe_unused]]
Point pt,
TileIndex tile)
override
614 switch (this->last_started_action) {
617 _place_road_start_half_x = _tile_fract_coords.x >= 8;
623 _place_road_start_half_y = _tile_fract_coords.y >= 8;
629 _place_road_start_half_x = _tile_fract_coords.x >= 8;
630 _place_road_start_half_y = _tile_fract_coords.y >= 8;
640 tile, _cur_roadtype, _road_depot_orientation);
668 default: NOT_REACHED();
680 if (RoadTypeIsRoad(this->roadtype)) {
699 switch (select_proc) {
701 _place_road_end_half = pt.x & 8;
705 _place_road_end_half = pt.y & 8;
712 ( (_tile_fract_coords.x < _tile_fract_coords.y && (_tile_fract_coords.x + _tile_fract_coords.y) < 16) ||
713 (_tile_fract_coords.x > _tile_fract_coords.y && (_tile_fract_coords.x + _tile_fract_coords.y) > 16) ))) {
716 _place_road_end_half = pt.x & 8;
720 _place_road_end_half = pt.y & 8;
735 switch (select_proc) {
736 default: NOT_REACHED();
749 bool start_half = _place_road_dir ==
AXIS_Y ? _place_road_start_half_y : _place_road_start_half_x;
753 end_tile, start_tile, _cur_roadtype, _place_road_dir, start_half, _place_road_end_half);
756 end_tile, start_tile, _cur_roadtype, _place_road_dir, _one_way_button_clicked ?
DRD_NORTHBOUND :
DRD_NONE, start_half, _place_road_end_half,
false);
771 auto proc = [=](
bool test, StationID to_join) ->
bool {
815 void OnPlacePresize([[maybe_unused]]
Point pt,
TileIndex tile)
override
841 switch (_game_mode) {
859 static EventState RoadToolbarGlobalHotkeys(
int hotkey)
861 extern RoadType _last_built_roadtype;
865 static EventState TramToolbarGlobalHotkeys(
int hotkey)
867 extern RoadType _last_built_tramtype;
871 static inline HotkeyList road_hotkeys{
"roadtoolbar", {
885 }, RoadToolbarGlobalHotkeys};
887 static inline HotkeyList tram_hotkeys{
"tramtoolbar", {
900 }, TramToolbarGlobalHotkeys};
903 static constexpr
NWidgetPart _nested_build_road_widgets[] = {
944 _nested_build_road_widgets,
945 &BuildRoadToolbarWindow::road_hotkeys
948 static constexpr
NWidgetPart _nested_build_tramway_widgets[] = {
987 _nested_build_tramway_widgets,
988 &BuildRoadToolbarWindow::tram_hotkeys
1004 _cur_roadtype = roadtype;
1006 return AllocateWindowDescFront<BuildRoadToolbarWindow>(RoadTypeIsRoad(_cur_roadtype) ? _build_road_desc : _build_tramway_desc,
TRANSPORT_ROAD);
1009 static constexpr
NWidgetPart _nested_build_road_scen_widgets[] = {
1039 WDP_AUTO,
"toolbar_road_scen", 0, 0,
1042 _nested_build_road_scen_widgets,
1043 &BuildRoadToolbarWindow::road_hotkeys
1046 static constexpr
NWidgetPart _nested_build_tramway_scen_widgets[] = {
1074 WDP_AUTO,
"toolbar_tram_scen", 0, 0,
1077 _nested_build_tramway_scen_widgets,
1078 &BuildRoadToolbarWindow::tram_hotkeys
1088 _cur_roadtype = roadtype;
1090 return AllocateWindowDescFront<BuildRoadToolbarWindow>(RoadTypeIsRoad(_cur_roadtype) ? _build_road_scen_desc : _build_tramway_scen_desc,
TRANSPORT_ROAD);
1099 if (RoadTypeIsTram(_cur_roadtype)) {
1100 this->GetWidget<NWidgetCore>(
WID_BROD_CAPTION)->widget_data = STR_BUILD_DEPOT_TRAM_ORIENTATION_CAPTION;
1102 this->GetWidget<NWidgetCore>(i)->tool_tip = STR_BUILD_DEPOT_TRAM_ORIENTATION_SELECT_TOOLTIP;
1117 void DrawWidget(
const Rect &r,
WidgetID widget)
const override
1131 void OnClick([[maybe_unused]]
Point pt,
WidgetID widget, [[maybe_unused]]
int click_count)
override
1151 static constexpr
NWidgetPart _nested_build_road_depot_widgets[] = {
1174 _nested_build_road_depot_widgets
1177 static void ShowRoadDepotPicker(
Window *parent)
1182 template <RoadStopType roadstoptype>
1194 for (
const auto *spec : cls.Specs()) {
1195 if (spec ==
nullptr)
continue;
1219 const auto *rsc = this->GetClass(
id);
1229 const auto *spec = this->GetSpec(cls_id,
id);
1231 return (spec ==
nullptr) ? STR_STATION_CLASS_DFLT_ROADSTOP : spec->name;
1236 const auto *spec = this->GetSpec(cls_id,
id);
1240 void DrawType(
int x,
int y,
int cls_id,
int id)
const override
1242 const auto *spec = this->GetSpec(cls_id,
id);
1243 if (spec ==
nullptr) {
1259 for (
const auto &sm : st->roadstop_speclist) {
1260 if (sm.spec ==
nullptr)
continue;
1263 items.insert({sm.grfid, sm.localidx, sm.spec->class_index, sm.spec->index});
1287 void CheckOrientationValid()
1292 if (RoadTypeIsRoad(_cur_roadtype)) {
1318 this->ConstructWindow();
1333 void Close([[maybe_unused]]
int data = 0)
override
1339 void OnInvalidateData([[maybe_unused]]
int data = 0, [[maybe_unused]]
bool gui_scope =
true)
override
1341 this->PickerWindow::OnInvalidateData(data, gui_scope);
1344 this->CheckOrientationValid();
1354 SetTileSelectBigSize(-rad, -rad, 2 * rad, 2 * rad);
1370 if (
top > r.bottom) {
1371 this->coverage_height +=
top - r.bottom;
1394 this->PickerWindow::UpdateWidgetSize(widget, size, padding, fill,
resize);
1407 default: NOT_REACHED();
1411 void DrawWidget(
const Rect &r,
WidgetID widget)
const override
1428 if (spec ==
nullptr) {
1438 this->PickerWindow::DrawWidget(r, widget);
1443 void OnClick([[maybe_unused]]
Point pt,
WidgetID widget, [[maybe_unused]]
int click_count)
override
1475 this->PickerWindow::OnClick(pt, widget, click_count);
1485 static inline HotkeyList road_hotkeys{
"buildroadstop", {
1489 static inline HotkeyList tram_hotkeys{
"buildtramstop", {
1536 SetDataTip(STR_STATION_BUILD_COVERAGE_OFF, STR_STATION_BUILD_COVERAGE_AREA_OFF_TOOLTIP),
1538 SetDataTip(STR_STATION_BUILD_COVERAGE_ON, STR_STATION_BUILD_COVERAGE_AREA_ON_TOOLTIP),
1549 WDP_AUTO,
"build_station_road", 0, 0,
1553 &BuildRoadStationWindow::road_hotkeys
1576 SetDataTip(STR_STATION_BUILD_COVERAGE_OFF, STR_STATION_BUILD_COVERAGE_AREA_OFF_TOOLTIP),
1578 SetDataTip(STR_STATION_BUILD_COVERAGE_ON, STR_STATION_BUILD_COVERAGE_AREA_ON_TOOLTIP),
1589 WDP_AUTO,
"build_station_tram", 0, 0,
1593 &BuildRoadStationWindow::tram_hotkeys
1598 new BuildRoadStationWindow(RoadTypeIsRoad(_cur_roadtype) ? _road_station_picker_desc : _tram_station_picker_desc, parent, rs);
1612 for (
const auto *spec : cls.Specs()) {
1613 if (spec !=
nullptr)
return true;
1630 const auto *sc = GetClass(
id);
1640 const auto *spec = this->GetSpec(cls_id,
id);
1641 return (spec ==
nullptr) ? STR_STATION_CLASS_WAYP_WAYPOINT : spec->
name;
1649 void DrawType(
int x,
int y,
int cls_id,
int id)
const override
1651 const auto *spec = this->GetSpec(cls_id,
id);
1652 if (spec ==
nullptr) {
1664 for (
const auto &sm : wp->roadstop_speclist) {
1665 if (sm.spec ==
nullptr)
continue;
1666 items.insert({sm.grfid, sm.localidx, sm.spec->class_index, sm.spec->index});
1678 this->ConstructWindow();
1682 static inline HotkeyList hotkeys{
"buildroadwaypoint", {
1702 WDP_AUTO,
"build_road_waypoint", 0, 0,
1706 &BuildRoadWaypointWindow::hotkeys
1709 static void ShowBuildRoadWaypointPicker(
Window *parent)
1711 if (!RoadWaypointPickerCallbacks::instance.IsActive())
return;
1715 void InitializeRoadGui()
1732 DropDownList GetRoadTypeDropDownList(RoadTramTypes rtts,
bool for_replacement,
bool all_option)
1740 if (for_replacement) {
1755 list.push_back(MakeDropDownListStringItem(STR_REPLACE_ALL_ROADTYPE,
INVALID_ROADTYPE));
1760 if (!for_replacement) {
1761 for (
const auto &rt : _sorted_roadtypes) {
1762 if (!
HasBit(used_roadtypes, rt))
continue;
1768 for (
const auto &rt : _sorted_roadtypes) {
1770 if (!
HasBit(used_roadtypes, rt))
continue;
1776 if (for_replacement) {
1779 StringID str = rti->
max_speed > 0 ? STR_TOOLBAR_RAILTYPE_VELOCITY : STR_JUST_STRING;
1786 list.push_back(MakeDropDownListStringItem(STR_NONE,
INVALID_ROADTYPE,
true));
1792 DropDownList GetScenRoadTypeDropDownList(RoadTramTypes rtts)
1806 for (
const auto &rt : _sorted_roadtypes) {
1807 if (!
HasBit(used_roadtypes, rt))
continue;
1811 for (
const auto &rt : _sorted_roadtypes) {
1812 if (!
HasBit(used_roadtypes, rt))
continue;
1818 StringID str = rti->
max_speed > 0 ? STR_TOOLBAR_RAILTYPE_VELOCITY : STR_JUST_STRING;
1824 list.push_back(MakeDropDownListStringItem(STR_NONE, -1,
true));
@ INVALID_RAILTYPE
Flag for invalid railtype.
@ ROADSTOPTYPE_FREIGHT
This RoadStop is for freight (truck) stops.
@ ES_HANDLED
The passed event is handled.
uint16_t sel_type
Selected road stop type within the class.
@ ROADSTOP_BUS
A standard stop for buses.
StringID toolbar_caption
Caption in the construction toolbar GUI for this rail type.
void SetTileSelectSize(int w, int h)
Highlight w by h tiles at the cursor.
@ DDSP_DEMOLISH_AREA
Clear area.
static bool _remove_button_clicked
Flag whether 'remove' toggle-button is currently enabled.
@ CA_UNMODIFIED
Catchment for all stations with "modified catchment" disabled.
DiagDirection orientation
Selected orientation of the road stop.
static void PlaceRoad_Bridge(TileIndex tile, Window *w)
Callback to start placing a bridge.
@ DIAGDIR_NE
Northeast, upper right on your monitor.
void CloseWindowByClass(WindowClass cls, int data)
Close all windows of a given class.
Point size
Size, in tile "units", of the white/red selection area.
static constexpr NWidgetPart _nested_build_road_waypoint_widgets[]
Nested widget definition for the build NewGRF road waypoint window.
StringID err_build_road
Building a normal piece of road.
int Height() const
Get height of Rect.
bool station_show_coverage
whether to highlight coverage area
static Titem * Get(size_t index)
Returns Titem with given index.
@ WC_BUILD_TOOLBAR
Build toolbar; Window numbers:
@ DDSP_PLACE_ROAD_Y_DIR
Road placement (Y axis)
static const int PREVIEW_HEIGHT
Height of each preview button.
void OnPaint() override
The window must be repainted.
StringID GetClassTooltip() const override
Get the tooltip string for the class list.
StationSettings station
settings related to station management
static const int PREVIEW_WIDTH
Width of each preview button.
StringID menu_text
Name of this rail type in the main toolbar dropdown.
List of hotkeys for a window.
void DrawType(int x, int y, int cls_id, int id) const override
Draw preview image of an item.
void VpSetPresizeRange(TileIndex from, TileIndex to)
Highlights all tiles between a set of two tiles.
SpriteID build_y_road
button for building single rail in Y direction
int GetSelectedType() const override
Get the selected type.
void FillUsedItems(std::set< PickerItem > &items) override
Fill a set with all items that are used by the current player.
Class for PickerClassWindow to collect information and retain state.
Dimensions (a width and height) of a rectangle in 2D.
constexpr bool IsInsideMM(const T x, const size_t min, const size_t max) noexcept
Checks if a value is in an interval.
StringID GetClassName(int id) const override
Get the name of a class.
@ WDF_CONSTRUCTION
This window is used for construction; close it whenever changing company.
static void PlaceRoad_TruckStation(TileIndex tile)
Callback for placing a truck station.
Rect Shrink(int s) const
Copy and shrink Rect by s pixels.
void ShowSelectRoadWaypointIfNeeded(TileArea ta, StationPickerCmdProc proc)
Show the road waypoint selection window when needed.
RoadTypes avail_roadtypes
Road types available to this company.
ViewportDragDropSelectionProcess
Drag and drop selection process, or, what to do with an area of land when you've selected it.
static constexpr DoCommandFlag CommandFlagsToDCFlags(CommandFlags cmd_flags)
Extracts the DC flags needed for DoCommand from the flags returned by GetCommandFlags.
@ CBID_STATION_AVAILABILITY
Determine whether a newstation should be made available to build.
@ WC_SCEN_BUILD_TOOLBAR
Scenario build toolbar; Window numbers:
void CheckRedrawStationCoverage(const Window *w)
Check whether we need to redraw the station coverage text.
void SetWidgetDirty(WidgetID widget_index) const
Invalidate a widget, i.e.
StringID name
Name of this stop.
uint32_t StringID
Numeric value that represents a string, independent of the selected language.
@ DDSP_REMOVE_BUSSTOP
Road stop removal (buses)
int GetSelectedClass() const override
Get the index of the selected class.
void CloseWindowById(WindowClass cls, WindowNumber number, bool force, int data)
Close a window by its class and window number (if it is open).
std::vector< std::unique_ptr< const DropDownListItem > > DropDownList
A drop down list is a collection of drop down list items.
void SetRedErrorSquare(TileIndex tile)
Set a tile to display a red error square.
bool IsTypeAvailable(int cls_id, int id) const override
Test if an item is currently buildable.
@ WDP_ALIGN_TOOLBAR
Align toward the toolbar.
Tindex index
Index of this pool item.
Axis DiagDirToAxis(DiagDirection d)
Convert a DiagDirection to the axis.
@ DDSP_BUILD_BUSSTOP
Road stop placement (buses)
SpriteID build_depot
button for building depots
Dimension maxdim(const Dimension &d1, const Dimension &d2)
Compute bounding box of both dimensions.
virtual void Close(int data=0)
Hide the window and all its child windows, and mark them for a later deletion.
Window * FindWindowById(WindowClass cls, WindowNumber number)
Find a window by its class and window number.
constexpr TileIndex INVALID_TILE
The very nice invalid tile marker.
@ PCWHK_FOCUS_FILTER_BOX
Focus the edit box for editing the filter string.
Representation of a waypoint.
bool _ctrl_pressed
Is Ctrl pressed?
@ SND_15_BEEP
19 == 0x13 GUI button click
void OnRealtimeTick([[maybe_unused]] uint delta_ms) override
Called periodically.
bool HandlePlacePushButton(Window *w, WidgetID widget, CursorID cursor, HighLightStyle mode)
This code is shared for the majority of the pushbuttons.
StringID err_remove_station[2]
Removing of a bus or truck station.
@ VEH_ROAD
Road vehicle type.
void RaiseButtons(bool autoraise=false)
Raise the buttons of the window.
void SetSelectedClass(int id) const override
Set the selected class.
DiagDirection
Enumeration for diagonal directions.
void DrawRoadDepotSprite(int x, int y, DiagDirection dir, RoadType rt)
Draw the road depot sprite.
@ VPM_FIX_Y
drag only in Y axis
ClientSettings _settings_client
The current settings for this game.
static const CursorID ANIMCURSOR_DEMOLISH
704 - 707 - demolish dynamite
RoadTypes GetCompanyRoadTypes(CompanyID company, bool introduces)
Get the road types the given company can build.
constexpr uint Vertical() const
Get total vertical padding of RectPadding.
RoadStopClassID sel_class
Selected road stop class.
static RoadWaypointPickerSelection _waypoint_gui
Settings of the road waypoint picker.
CursorID tunnel
Cursor for building a tunnel.
StringID replace_text
Text used in the autoreplace GUI.
bool IsTypeAvailable(int cls_id, int id) const override
Test if an item is currently buildable.
@ ROADSTOP_CLASS_DFLT
Default road stop class.
ViewportPlaceMethod
Viewport place method (type of highlighted area and placed objects)
StringID err_remove_road
Removing a normal piece of road.
virtual EventState OnHotkey(int hotkey)
A hotkey has been pressed.
CursorID depot
Cursor for building a depot.
@ ROADSTOP_TRUCK
A standard stop for trucks.
uint16_t h
The height of the area.
CursorID road_nwse
Cursor for building rail in Y direction.
CursorID road_swne
Cursor for building rail in X direction.
bool Succeeded() const
Did this command succeed?
StationType
Station types.
static Pool::IterateWrapper< Station > Iterate(size_t from=0)
Returns an iterable ensemble of all valid stations of type T.
@ TRANSPORT_ROAD
Transport by road vehicle.
@ DDSP_PLACE_ROAD_X_DIR
Road placement (X axis)
static void ToggleRoadButton_Remove(Window *w)
Toggles state of the Remove button of Build road toolbar.
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.
High level window description.
constexpr uint Horizontal() const
Get total horizontal padding of RectPadding.
int ScaleGUITrad(int value)
Scale traditional pixel dimensions to GUI zoom level.
@ RSF_BUILD_MENU_TRAM_ONLY
Only show in the tram build menu (not road).
@ ROADTYPES_NONE
No roadtypes.
RoadTypes _roadtypes_type
Bitmap of road/tram types.
@ WDP_AUTO
Find a place automatically.
@ SCT_PASSENGERS_ONLY
Draw only passenger class cargoes.
RoadStopClassID sel_class
Selected road waypoint class.
ResizeInfo resize
Resize information.
Common return value for all commands.
SoundSettings sound
sound effect settings
int32_t WindowNumber
Number to differentiate different windows of the same class.
@ FS_NORMAL
Index of the normal font in the font tables.
StationCoverageType
Types of cargo to display for station coverage.
@ VPM_FIX_X
drag only in X axis
static std::span< NewGRFClass< Tspec, Tindex, Tmax > const > Classes()
Get read-only span of all classes of this type.
void VpStartPlaceSizing(TileIndex tile, ViewportPlaceMethod method, ViewportDragDropSelectionProcess process)
highlighting tiles while only going over them with the mouse
RoadTypes
The different roadtypes we support, but then a bitmask of them.
static constexpr NWidgetPart _nested_road_station_picker_widgets[]
Widget definition of the build road station window.
@ DRD_NONE
None of the directions are disallowed.
@ DDSP_REMOVE_ROAD_WAYPOINT
Road stop removal (waypoint)
void SetDirty() const
Mark entire window as dirty (in need of re-paint)
@ HT_DIAGONAL
Also allow 'diagonal rectangles'. Only usable in combination with HT_RECT or HT_POINT.
SpriteID auto_road
button for the autoroad construction
DiagDirection ReverseDiagDir(DiagDirection d)
Returns the reverse direction of the given DiagDirection.
@ WC_TRUCK_STATION
Build truck station; Window numbers:
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.
void DrawType(int x, int y, int cls_id, int id) const override
Draw preview image of an item.
@ ES_NOT_HANDLED
The passed event is not handled.
bool Failed() const
Did this command fail?
bool HasClassChoice() const override
Are there multiple classes to chose from?
void VpSelectTilesWithMethod(int x, int y, ViewportPlaceMethod method)
Selects tiles while dragging.
Represents the covered area of e.g.
@ INVALID_AXIS
Flag for an invalid Axis.
struct RoadTypeInfo::@27 gui_sprites
struct containing the sprites for the road GUI.
static const int PREVIEW_LEFT
Offset from left edge to draw preview.
void ShowSelectStationIfNeeded(TileArea ta, StationPickerCmdProc proc)
Show the station selection window when needed.
GameSettings _settings_game
Game settings of a running game or the scenario editor.
void ReInit(int rx=0, int ry=0, bool reposition=false)
Re-initialize a window, and optionally change its size.
@ DDSP_REMOVE_TRUCKSTOP
Road stop removal (trucks)
@ WC_BUS_STATION
Build bus station; Window numbers:
void SetSelectedClass(int id) const override
Set the selected class.
bool IsBridgeTile(Tile t)
checks if there is a bridge on this tile
RoadType
The different roadtypes we support.
Window * parent
Parent window.
CompanyID _local_company
Company controlled by the human player at this client. Can also be COMPANY_SPECTATOR.
int GetSelectedType() const override
Get the selected type.
void LowerWidget(WidgetID widget_index)
Marks a widget as lowered.
bool IsActive() const override
Should picker class/type selection be enabled?
@ WC_BUILD_BRIDGE
Build bridge; Window numbers:
@ CA_BUS
Catchment for bus stops with "modified catchment" enabled.
static debug_inline bool IsNormalRoadTile(Tile t)
Return whether a tile is a normal road tile.
static void PlaceRoad_BusStation(TileIndex tile)
Callback for placing a bus station.
std::unique_ptr< NWidgetBase > MakePickerTypeWidgets()
Create nested widgets for the type picker widgets.
WindowClass
Window classes.
@ DDSP_PLACE_AUTOROAD
Road placement (auto)
@ DDSP_BUILD_BRIDGE
Bridge placement.
GRFFilePropsBase< NUM_CARGO+3 > grf_prop
Properties related the the grf file.
Point pos
Location, in tile "units", of the northern tile of the selected area.
@ RSF_DRIVE_THROUGH_ONLY
Stop is drive-through only.
void SetSelectedType(int id) const override
Set the selected type.
@ INVALID_ROADTYPE
flag for invalid roadtype
@ FACIL_TRUCK_STOP
Station with truck stops.
@ CA_TRUCK
Catchment for truck stops with "modified catchment" enabled.
@ RSF_NO_AUTO_ROAD_CONNECTION
No auto road connection.
Coordinates of a point in 2D.
static void PlaceRoadStop(TileIndex start_tile, TileIndex end_tile, RoadStopType stop_type, bool adjacent, RoadType rt, StringID err_msg)
Place a new road stop.
bool ValParamRoadType(RoadType roadtype)
Validate functions for rail building.
RoadBits DiagDirToRoadBits(DiagDirection d)
Create the road-part which belongs to the given DiagDirection.
bool IsWidgetDisabled(WidgetID widget_index) const
Gets the enabled/disabled status of a widget.
@ ROADSTOPTYPE_ALL
This RoadStop is for both types of station road stops.
SpriteID build_tunnel
button for building a tunnel
const Tspec * GetSpec(uint index) const
Get a spec from the class at a given index.
bool IsValidAxis(Axis d)
Checks if an integer value is a valid Axis.
@ RSV_DRIVE_THROUGH_X
Drive through road stop, X axis.
WindowNumber window_number
Window number within the window class.
bool link_terraform_toolbar
display terraform toolbar when displaying rail, road, water and airport toolbars
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.
bool CanBuildVehicleInfrastructure(VehicleType type, uint8_t subtype)
Check whether we can build infrastructure for the given vehicle type.
void InvalidateData(int data=0, bool gui_scope=true)
Mark this window's data as invalid (in need of re-computing)
@ WC_NONE
No window, redirects to WC_MAIN_WINDOW.
void SetWidgetLoweredState(WidgetID widget_index, bool lowered_stat)
Sets the lowered/raised status of a widget.
@ ROADSTOPTYPE_PASSENGER
This RoadStop is for passenger (bus) stops.
struct RoadTypeInfo::@28 cursor
Cursors associated with the road type.
bool FillDrawPixelInfo(DrawPixelInfo *n, int left, int top, int width, int height)
Set up a clipping area for only drawing into a certain area.
@ WC_BUILD_DEPOT
Build depot; Window numbers:
static constexpr NWidgetPart _nested_tram_station_picker_widgets[]
Widget definition of the build tram station window.
TileIndexDiff TileOffsByDiagDir(DiagDirection dir)
Convert a DiagDirection to a TileIndexDiff.
const RoadTypeInfo * GetRoadTypeInfo(RoadType roadtype)
Returns a pointer to the Roadtype information for a given roadtype.
void SetWidgetDisabledState(WidgetID widget_index, bool disab_stat)
Sets the enabled/disabled status of a widget.
Dimension GetSpriteSize(SpriteID sprid, Point *offset, ZoomLevel zoom)
Get the size of a sprite.
StringID picker_tooltip[2]
Tooltip for the station picker for bus or truck stations.
StationType GetRoadStationTypeByWindowClass(WindowClass window_class) const
Simply to have a easier way to get the StationType for bus, truck and trams from the WindowClass.
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)
static bool IsRoadStopAvailable(const RoadStopSpec *spec, StationType type)
Check whether a road stop type can be built.
SpriteID build_x_road
button for building single rail in X direction
@ ROADTYPE_END
Used for iterations.
SpriteID convert_road
button for converting road types
RoadTypes AddDateIntroducedRoadTypes(RoadTypes current, TimerGameCalendar::Date date)
Add the road types that are to be introduced at the given date.
Helper for PickerCallbacks when the class system is based on NewGRFClass.
bool IsWidgetLowered(WidgetID widget_index) const
Gets the lowered state of a widget.
static const uint CALLBACK_FAILED
Different values for Callback result evaluations.
bool confirm
Play sound effect on successful constructions or other actions.
void ShowBuildBridgeWindow(TileIndex start, TileIndex end, TransportType transport_type, uint8_t road_rail_type)
Prepare the data for the build a bridge window.
@ WC_SELECT_STATION
Select station (when joining stations); Window numbers:
void CreateNestedTree()
Perform the first part of the initialization of a nested widget tree.
bool HasClassChoice() const override
Are there multiple classes to chose from?
StringID GetTypeTooltip() const override
Get the tooltip string for the type grid.
bool IsShaded() const
Is window shaded currently?
@ WC_BUILD_WAYPOINT
Build waypoint; Window numbers:
@ VPM_Y_LIMITED
Drag only in Y axis with limited size.
StringID err_build_station[2]
Building a bus or truck station.
void DisableWidget(WidgetID widget_index)
Sets a widget to disabled.
Axis
Allow incrementing of DiagDirDiff variables.
@ WC_SCEN_LAND_GEN
Landscape generation (in Scenario Editor); Window numbers:
void SetDParam(size_t n, uint64_t v)
Set a string parameter v at index n in the global string parameter array.
@ SCT_NON_PASSENGERS_ONLY
Draw all non-passenger class cargoes.
TileIndex tile
The base tile of the area.
bool IsWaypointClass(const RoadStopClass &cls)
Test if a RoadStopClass is the waypoint class.
CursorID autoroad
Cursor for autorail tool.
TileIndex _build_tunnel_endtile
The end of a tunnel; as hidden return from the tunnel build command for GUI purposes.
StringID err_convert_road
Converting a road type.
void MarkTileDirtyByTile(TileIndex tile, int bridge_level_offset, int tile_height_override)
Mark a tile given by its index dirty for repaint.
Class to backup a specific variable and restore it upon destruction of this object to prevent stack v...
int ScaleSpriteTrad(int value)
Scale traditional pixel dimensions to GUI zoom level, for drawing sprites.
EventState
State of handling an event.
@ HT_RECT
rectangle (stations, depots, ...)
static bool RoadToolbar_CtrlChanged(Window *w)
Updates the Remove button because of Ctrl state change.
@ VPM_X_AND_Y
area of land in X and Y directions
StringID GetTypeTooltip() const override
Get the tooltip string for the type grid.
WindowClass window_class
Window class.
@ DIAGDIR_END
Used for iterations.
@ WPF_ROAD
This is a road waypoint.
int GetSelectedClass() const override
Get the index of the selected class.
RoadBits GetRoadBits(Tile t, RoadTramType rtt)
Get the present road bits for a specific road type.
int64_t PackVelocity(uint speed, VehicleType type)
Pack velocity and vehicle type for use with SCC_VELOCITY string parameter.
void FinishInitNested(WindowNumber window_number=0)
Perform the second part of the initialization of a nested widget tree.
@ DC_AUTO
don't allow building on structures
Struct containing information relating to NewGRF classes for stations and airports.
@ DDSP_CONVERT_ROAD
Road conversion.
struct RoadTypeInfo::@29 strings
Strings associated with the rail type.
uint coverage_height
Height of the coverage texts.
Base class for windows opened from a toolbar.
void SetViewportCatchmentStation(const Station *st, bool sel)
Select or deselect station for coverage area highlight.
@ ROAD_NONE
No road-part is build.
TileIndex GetOtherTunnelBridgeEnd(Tile t)
Determines type of the wormhole and returns its other end.
void CcBuildRoadTunnel(Commands, const CommandCost &result, TileIndex start_tile)
Callback executed after a build road tunnel command has been called.
@ RSF_BUILD_MENU_ROAD_ONLY
Only show in the road build menu (not tram).
int top
y position of top edge of the window
StringID GetClassTooltip() const override
Get the tooltip string for the class list.
StringID GetTypeName(int cls_id, int id) const override
Get the item of a type.
uint16_t w
The width of the area.
void RaiseWidget(WidgetID widget_index)
Marks a widget as raised.
void OnInvalidateData([[maybe_unused]] int data=0, [[maybe_unused]] bool gui_scope=true) override
Some data on this window has become invalid.
static void PlaceRoad_Waypoint(TileIndex tile)
Place a road waypoint.
bool click_beep
Beep on a random selection of buttons.
int GetCharacterHeight(FontSize size)
Get height of a character for a given font size.
uint16_t max_speed
Maximum speed for vehicles travelling on this road type.
@ FACIL_BUS_STOP
Station with bus stops.
@ VPM_X_LIMITED
Drag only in X axis with limited size.
const std::string ini_group
Ini Group for saving favourites.
uint8_t station_spread
amount a station may spread
@ CBM_ROAD_STOP_AVAIL
Availability of road stop in construction window.
@ SND_1F_CONSTRUCTION_OTHER
29 == 0x1D Construction: other (non-water, non-rail, non-bridge)
@ ROADSTOP_CLASS_WAYP
Waypoint class.
Window * ShowBuildRoadToolbar(RoadType roadtype)
Open the build road toolbar window.
void Close(int data=0) override
Hide the window and all its child windows, and mark them for a later deletion.
RoadStopType
Types of RoadStops.
StringID GetClassName(int id) const override
Get the name of a class.
static debug_inline TileIndex TileVirtXY(uint x, uint y)
Get a tile from the virtual XY-coordinate.
static const int PREVIEW_BOTTOM
Offset from bottom edge to draw preview.
static Date date
Current date in days (day counter).
std::unique_ptr< NWidgetBase > MakePickerClassWidgets()
Create nested widgets for the class picker widgets.
Data structure for an opened window.
RoadTypes GetRoadTypes(bool introduces)
Get list of road types, regardless of company availability.
Commands
List of commands.
Axis GetAxisForNewRoadWaypoint(TileIndex tile)
Get the axis for a new road waypoint.
static bool IsValidID(size_t index)
Tests whether given index can be used to get valid (non-nullptr) Titem.
void SetSelectedType(int id) const override
Set the selected type.
void DrawWidgets() const
Paint all widgets of a window.
const struct GRFFile * grffile
grf file that introduced this entity
StringID err_depot
Building a depot.
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...
void ConnectRoadToStructure(TileIndex tile, DiagDirection direction)
If required, connects a new structure to an existing road or tram by building the missing roadbit.
int Width() const
Get width of Rect.
static uint GetClassCount()
Get the number of allocated classes.
@ VPM_X_AND_Y_LIMITED
area of land of limited size
void InitializeRoadGUI()
I really don't know why rail_gui.cpp has this too, shouldn't be included in the other one?
static NewGRFClass * Get(Tindex class_index)
Get a particular class.
StringID GetTypeName(int cls_id, int id) const override
Get the item of a type.
Specification of a rectangle with absolute coordinates of all edges.
void ToggleWidgetLoweredState(WidgetID widget_index)
Invert the lowered/raised status of a widget.
bool IsActive() const override
Should picker class/type selection be enabled?
void SetWidgetsDisabledState(bool disab_stat, Args... widgets)
Sets the enabled/disabled status of a list of widgets.
@ VPM_X_OR_Y
drag in X or Y direction
void ResetObjectToPlace()
Reset the cursor and mouse mode handling back to default (normal cursor, only clicking in windows).
@ HT_SPECIAL
special mode used for highlighting while dragging (and for tunnels/docks)
bool Convert8bitBooleanCallback(const GRFFile *grffile, uint16_t cbid, uint16_t cb_res)
Converts a callback result into a boolean.
StringID picker_title[2]
Title for the station picker for bus or truck stations.
@ DRD_NORTHBOUND
All northbound traffic is disallowed.
void FillUsedItems(std::set< PickerItem > &items) override
Fill a set with all items that are used by the current player.
static const StringID INVALID_STRING_ID
Constant representing an invalid string (16bit in case it is used in savegames)
GUISettings gui
settings related to the GUI
@ DDSP_BUILD_TRUCKSTOP
Road stop placement (trucks)
Data about how and where to blit pixels.
bool persistent_buildingtools
keep the building tools active after usage
bool modified_catchment
different-size catchment areas
All data for a single hotkey.
DiagDirection GetTunnelBridgeDirection(Tile t)
Get the direction pointing to the other end.
@ DDSP_BUILD_ROAD_WAYPOINT
Road stop placement (waypoint)
Window * ShowBuildRoadScenToolbar(RoadType roadtype)
Show the road building toolbar in the scenario editor.
uint16_t sel_type
Selected road waypoint type within the class.
constexpr debug_inline bool HasBit(const T x, const uint8_t y)
Checks if a bit in a value is set.