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);
350 this->roadtype = _cur_roadtype;
355 if (RoadTypeIsRoad(this->roadtype)) {
360 this->last_started_action = INVALID_WID_ROT;
365 void Close([[maybe_unused]]
int data = 0)
override
377 void OnInvalidateData([[maybe_unused]]
int data = 0, [[maybe_unused]]
bool gui_scope =
true)
override
379 if (!gui_scope)
return;
387 RoadTramType rtt = GetRoadTramType(this->roadtype);
402 if (_game_mode != GM_EDITOR) {
405 this->GetWidget<NWidgetCore>(
WID_ROT_DEPOT)->SetToolTip(STR_TOOLBAR_DISABLED_NO_VEHICLE_AVAILABLE);
406 this->GetWidget<NWidgetCore>(
WID_ROT_BUILD_WAYPOINT)->SetToolTip(STR_TOOLBAR_DISABLED_NO_VEHICLE_AVAILABLE);
407 this->GetWidget<NWidgetCore>(
WID_ROT_BUS_STATION)->SetToolTip(STR_TOOLBAR_DISABLED_NO_VEHICLE_AVAILABLE);
408 this->GetWidget<NWidgetCore>(
WID_ROT_TRUCK_STATION)->SetToolTip(STR_TOOLBAR_DISABLED_NO_VEHICLE_AVAILABLE);
410 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);
411 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);
412 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);
413 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);
425 if (_game_mode != GM_EDITOR) {
442 void SetStringParameters(
WidgetID widget)
const override
447 SetDParam(0, STR_TOOLBAR_RAILTYPE_VELOCITY);
466 switch (clicked_widget) {
468 if (RoadTypeIsRoad(this->roadtype)) {
491 if (RoadTypeIsRoad(this->roadtype)) {
502 if (RoadTypeIsRoad(this->roadtype)) {
511 void OnClick([[maybe_unused]]
Point pt,
WidgetID widget, [[maybe_unused]]
int click_count)
override
514 _one_way_button_clicked =
false;
518 this->last_started_action = widget;
523 this->last_started_action = widget;
528 this->last_started_action = widget;
533 this->last_started_action = widget;
538 ShowRoadDepotPicker(
this);
539 this->last_started_action = widget;
544 this->last_started_action = widget;
546 ShowBuildRoadWaypointPicker(
this);
553 this->last_started_action = widget;
560 this->last_started_action = widget;
568 SetSelectionRed(
false);
573 this->last_started_action = widget;
578 this->last_started_action = widget;
591 this->last_started_action = widget;
594 default: NOT_REACHED();
606 void OnPlaceObject([[maybe_unused]]
Point pt,
TileIndex tile)
override
610 switch (this->last_started_action) {
613 _place_road_start_half_x = _tile_fract_coords.x >= 8;
619 _place_road_start_half_y = _tile_fract_coords.y >= 8;
625 _place_road_start_half_x = _tile_fract_coords.x >= 8;
626 _place_road_start_half_y = _tile_fract_coords.y >= 8;
636 tile, _cur_roadtype, _road_depot_orientation);
664 default: NOT_REACHED();
676 if (RoadTypeIsRoad(this->roadtype)) {
695 switch (select_proc) {
697 _place_road_end_half = pt.x & 8;
701 _place_road_end_half = pt.y & 8;
708 ( (_tile_fract_coords.x < _tile_fract_coords.y && (_tile_fract_coords.x + _tile_fract_coords.y) < 16) ||
709 (_tile_fract_coords.x > _tile_fract_coords.y && (_tile_fract_coords.x + _tile_fract_coords.y) > 16) ))) {
712 _place_road_end_half = pt.x & 8;
716 _place_road_end_half = pt.y & 8;
731 switch (select_proc) {
732 default: NOT_REACHED();
745 bool start_half = _place_road_dir ==
AXIS_Y ? _place_road_start_half_y : _place_road_start_half_x;
749 end_tile, start_tile, _cur_roadtype, _place_road_dir, start_half, _place_road_end_half);
752 end_tile, start_tile, _cur_roadtype, _place_road_dir, _one_way_button_clicked ?
DRD_NORTHBOUND :
DRD_NONE, start_half, _place_road_end_half,
false);
767 auto proc = [=](
bool test, StationID to_join) ->
bool {
811 void OnPlacePresize([[maybe_unused]]
Point pt,
TileIndex tile)
override
837 switch (_game_mode) {
855 static EventState RoadToolbarGlobalHotkeys(
int hotkey)
857 extern RoadType _last_built_roadtype;
861 static EventState TramToolbarGlobalHotkeys(
int hotkey)
863 extern RoadType _last_built_tramtype;
867 static inline HotkeyList road_hotkeys{
"roadtoolbar", {
881 }, RoadToolbarGlobalHotkeys};
883 static inline HotkeyList tram_hotkeys{
"tramtoolbar", {
896 }, TramToolbarGlobalHotkeys};
899 static constexpr
NWidgetPart _nested_build_road_widgets[] = {
940 _nested_build_road_widgets,
941 &BuildRoadToolbarWindow::road_hotkeys
944 static constexpr
NWidgetPart _nested_build_tramway_widgets[] = {
983 _nested_build_tramway_widgets,
984 &BuildRoadToolbarWindow::tram_hotkeys
1000 _cur_roadtype = roadtype;
1002 return AllocateWindowDescFront<BuildRoadToolbarWindow>(RoadTypeIsRoad(_cur_roadtype) ? _build_road_desc : _build_tramway_desc,
TRANSPORT_ROAD);
1005 static constexpr
NWidgetPart _nested_build_road_scen_widgets[] = {
1035 WDP_AUTO,
"toolbar_road_scen", 0, 0,
1038 _nested_build_road_scen_widgets,
1039 &BuildRoadToolbarWindow::road_hotkeys
1042 static constexpr
NWidgetPart _nested_build_tramway_scen_widgets[] = {
1070 WDP_AUTO,
"toolbar_tram_scen", 0, 0,
1073 _nested_build_tramway_scen_widgets,
1074 &BuildRoadToolbarWindow::tram_hotkeys
1084 _cur_roadtype = roadtype;
1086 return AllocateWindowDescFront<BuildRoadToolbarWindow>(RoadTypeIsRoad(_cur_roadtype) ? _build_road_scen_desc : _build_tramway_scen_desc,
TRANSPORT_ROAD);
1095 if (RoadTypeIsTram(_cur_roadtype)) {
1096 this->GetWidget<NWidgetCore>(
WID_BROD_CAPTION)->widget_data = STR_BUILD_DEPOT_TRAM_ORIENTATION_CAPTION;
1098 this->GetWidget<NWidgetCore>(i)->tool_tip = STR_BUILD_DEPOT_TRAM_ORIENTATION_SELECT_TOOLTIP;
1113 void DrawWidget(
const Rect &r,
WidgetID widget)
const override
1127 void OnClick([[maybe_unused]]
Point pt,
WidgetID widget, [[maybe_unused]]
int click_count)
override
1147 static constexpr
NWidgetPart _nested_build_road_depot_widgets[] = {
1170 _nested_build_road_depot_widgets
1173 static void ShowRoadDepotPicker(
Window *parent)
1178 template <RoadStopType roadstoptype>
1190 for (
const auto *spec : cls.Specs()) {
1191 if (spec ==
nullptr)
continue;
1215 const auto *rsc = this->GetClass(
id);
1225 const auto *spec = this->GetSpec(cls_id,
id);
1227 return (spec ==
nullptr) ? STR_STATION_CLASS_DFLT_ROADSTOP : spec->name;
1232 const auto *spec = this->GetSpec(cls_id,
id);
1236 void DrawType(
int x,
int y,
int cls_id,
int id)
const override
1238 const auto *spec = this->GetSpec(cls_id,
id);
1239 if (spec ==
nullptr) {
1255 for (
const auto &sm : st->roadstop_speclist) {
1256 if (sm.spec ==
nullptr)
continue;
1259 items.insert({sm.grfid, sm.localidx, sm.spec->class_index, sm.spec->index});
1283 void CheckOrientationValid()
1288 if (RoadTypeIsRoad(_cur_roadtype)) {
1314 this->ConstructWindow();
1329 void Close([[maybe_unused]]
int data = 0)
override
1335 void OnInvalidateData([[maybe_unused]]
int data = 0, [[maybe_unused]]
bool gui_scope =
true)
override
1337 this->PickerWindow::OnInvalidateData(data, gui_scope);
1340 this->CheckOrientationValid();
1350 SetTileSelectBigSize(-rad, -rad, 2 * rad, 2 * rad);
1366 if (
top > r.bottom) {
1367 this->coverage_height +=
top - r.bottom;
1390 this->PickerWindow::UpdateWidgetSize(widget, size, padding, fill,
resize);
1403 default: NOT_REACHED();
1407 void DrawWidget(
const Rect &r,
WidgetID widget)
const override
1424 if (spec ==
nullptr) {
1434 this->PickerWindow::DrawWidget(r, widget);
1439 void OnClick([[maybe_unused]]
Point pt,
WidgetID widget, [[maybe_unused]]
int click_count)
override
1471 this->PickerWindow::OnClick(pt, widget, click_count);
1481 static inline HotkeyList road_hotkeys{
"buildroadstop", {
1485 static inline HotkeyList tram_hotkeys{
"buildtramstop", {
1532 SetDataTip(STR_STATION_BUILD_COVERAGE_OFF, STR_STATION_BUILD_COVERAGE_AREA_OFF_TOOLTIP),
1534 SetDataTip(STR_STATION_BUILD_COVERAGE_ON, STR_STATION_BUILD_COVERAGE_AREA_ON_TOOLTIP),
1545 WDP_AUTO,
"build_station_road", 0, 0,
1549 &BuildRoadStationWindow::road_hotkeys
1572 SetDataTip(STR_STATION_BUILD_COVERAGE_OFF, STR_STATION_BUILD_COVERAGE_AREA_OFF_TOOLTIP),
1574 SetDataTip(STR_STATION_BUILD_COVERAGE_ON, STR_STATION_BUILD_COVERAGE_AREA_ON_TOOLTIP),
1585 WDP_AUTO,
"build_station_tram", 0, 0,
1589 &BuildRoadStationWindow::tram_hotkeys
1594 new BuildRoadStationWindow(RoadTypeIsRoad(_cur_roadtype) ? _road_station_picker_desc : _tram_station_picker_desc, parent, rs);
1608 for (
const auto *spec : cls.Specs()) {
1609 if (spec !=
nullptr)
return true;
1626 const auto *sc = GetClass(
id);
1636 const auto *spec = this->GetSpec(cls_id,
id);
1637 return (spec ==
nullptr) ? STR_STATION_CLASS_WAYP_WAYPOINT : spec->
name;
1645 void DrawType(
int x,
int y,
int cls_id,
int id)
const override
1647 const auto *spec = this->GetSpec(cls_id,
id);
1648 if (spec ==
nullptr) {
1660 for (
const auto &sm : wp->roadstop_speclist) {
1661 if (sm.spec ==
nullptr)
continue;
1662 items.insert({sm.grfid, sm.localidx, sm.spec->class_index, sm.spec->index});
1674 this->ConstructWindow();
1678 static inline HotkeyList hotkeys{
"buildroadwaypoint", {
1698 WDP_AUTO,
"build_road_waypoint", 0, 0,
1702 &BuildRoadWaypointWindow::hotkeys
1705 static void ShowBuildRoadWaypointPicker(
Window *parent)
1707 if (!RoadWaypointPickerCallbacks::instance.IsActive())
return;
1711 void InitializeRoadGui()
1728 DropDownList GetRoadTypeDropDownList(RoadTramTypes rtts,
bool for_replacement,
bool all_option)
1736 if (for_replacement) {
1751 list.push_back(MakeDropDownListStringItem(STR_REPLACE_ALL_ROADTYPE,
INVALID_ROADTYPE));
1756 if (!for_replacement) {
1757 for (
const auto &rt : _sorted_roadtypes) {
1758 if (!
HasBit(used_roadtypes, rt))
continue;
1764 for (
const auto &rt : _sorted_roadtypes) {
1766 if (!
HasBit(used_roadtypes, rt))
continue;
1772 if (for_replacement) {
1775 StringID str = rti->
max_speed > 0 ? STR_TOOLBAR_RAILTYPE_VELOCITY : STR_JUST_STRING;
1782 list.push_back(MakeDropDownListStringItem(STR_NONE,
INVALID_ROADTYPE,
true));
1788 DropDownList GetScenRoadTypeDropDownList(RoadTramTypes rtts)
1802 for (
const auto &rt : _sorted_roadtypes) {
1803 if (!
HasBit(used_roadtypes, rt))
continue;
1807 for (
const auto &rt : _sorted_roadtypes) {
1808 if (!
HasBit(used_roadtypes, rt))
continue;
1814 StringID str = rti->
max_speed > 0 ? STR_TOOLBAR_RAILTYPE_VELOCITY : STR_JUST_STRING;
1820 list.push_back(MakeDropDownListStringItem(STR_NONE, -1,
true));
constexpr debug_inline bool HasBit(const T x, const uint8_t y)
Checks if a bit in a value is set.
void ShowBuildBridgeWindow(TileIndex start, TileIndex end, TransportType transport_type, uint8_t road_rail_type)
Prepare the data for the build a bridge window.
bool IsBridgeTile(Tile t)
checks if there is a bridge on this tile
Common return value for all commands.
bool Succeeded() const
Did this command succeed?
bool Failed() const
Did this command fail?
Struct containing information relating to NewGRF classes for stations and airports.
static std::span< NewGRFClass< Tspec, Tindex, Tmax > const > Classes()
Get read-only span of all classes of this type.
static NewGRFClass * Get(Tindex class_index)
Get a particular class.
static uint GetClassCount()
Get the number of allocated classes.
const Tspec * GetSpec(uint index) const
Get a spec from the class at a given index.
Helper for PickerCallbacks when the class system is based on NewGRFClass.
Class for PickerClassWindow to collect information and retain state.
const std::string ini_group
Ini Group for saving favourites.
Base class for windows opened from a toolbar.
void Close(int data=0) override
Hide the window and all its child windows, and mark them for a later deletion.
static const int PREVIEW_LEFT
Offset from left edge to draw preview.
@ PCWHK_FOCUS_FILTER_BOX
Focus the edit box for editing the filter string.
static const int PREVIEW_WIDTH
Width of each preview button.
static const int PREVIEW_BOTTOM
Offset from bottom edge to draw preview.
static const int PREVIEW_HEIGHT
Height of each preview button.
void SetSelectedType(int id) const override
Set the selected type.
bool HasClassChoice() const override
Are there multiple classes to chose from?
StringID GetClassTooltip() const override
Get the tooltip string for the class list.
StringID GetClassName(int id) const override
Get the name of a class.
void FillUsedItems(std::set< PickerItem > &items) override
Fill a set with all items that are used by the current player.
void SetSelectedClass(int id) const override
Set the selected class.
void DrawType(int x, int y, int cls_id, int id) const override
Draw preview image of an item.
int GetSelectedClass() const override
Get the index of the selected class.
StringID GetTypeName(int cls_id, int id) const override
Get the item of a type.
bool IsActive() const override
Should picker class/type selection be enabled?
int GetSelectedType() const override
Get the selected type.
bool IsTypeAvailable(int cls_id, int id) const override
Test if an item is currently buildable.
StringID GetTypeTooltip() const override
Get the tooltip string for the type grid.
StringID menu_text
Name of this rail type in the main toolbar dropdown.
StringID replace_text
Text used in the autoreplace GUI.
StringID picker_title[2]
Title for the station picker for bus or truck stations.
CursorID autoroad
Cursor for autorail tool.
StringID picker_tooltip[2]
Tooltip for the station picker for bus or truck stations.
struct RoadTypeInfo::@29 strings
Strings associated with the rail type.
StringID err_build_road
Building a normal piece of road.
StringID err_remove_road
Removing a normal piece of road.
CursorID depot
Cursor for building a depot.
CursorID road_nwse
Cursor for building rail in Y direction.
uint16_t max_speed
Maximum speed for vehicles travelling on this road type.
StringID toolbar_caption
Caption in the construction toolbar GUI for this rail type.
SpriteID build_y_road
button for building single rail in Y direction
CursorID tunnel
Cursor for building a tunnel.
SpriteID auto_road
button for the autoroad construction
struct RoadTypeInfo::@27 gui_sprites
struct containing the sprites for the road GUI.
SpriteID convert_road
button for converting road types
CursorID road_swne
Cursor for building rail in X direction.
StringID err_convert_road
Converting a road type.
StringID err_depot
Building a depot.
SpriteID build_x_road
button for building single rail in X direction
SpriteID build_depot
button for building depots
SpriteID build_tunnel
button for building a tunnel
StringID err_build_station[2]
Building a bus or truck station.
StringID err_remove_station[2]
Removing of a bus or truck station.
StringID GetTypeTooltip() const override
Get the tooltip string for the type grid.
int GetSelectedType() const override
Get the selected type.
StringID GetClassTooltip() const override
Get the tooltip string for the class list.
void DrawType(int x, int y, int cls_id, int id) const override
Draw preview image of an item.
bool IsActive() const override
Should picker class/type selection be enabled?
bool IsTypeAvailable(int cls_id, int id) const override
Test if an item is currently buildable.
void SetSelectedType(int id) const override
Set the selected type.
void FillUsedItems(std::set< PickerItem > &items) override
Fill a set with all items that are used by the current player.
StringID GetTypeName(int cls_id, int id) const override
Get the item of a type.
StringID GetClassName(int id) const override
Get the name of a class.
void SetSelectedClass(int id) const override
Set the selected class.
int GetSelectedClass() const override
Get the index of the selected class.
bool HasClassChoice() const override
Are there multiple classes to chose from?
static Date date
Current date in days (day counter).
Functions related to commands.
static constexpr DoCommandFlag CommandFlagsToDCFlags(CommandFlags cmd_flags)
Extracts the DC flags needed for DoCommand from the flags returned by GetCommandFlags.
@ DC_AUTO
don't allow building on structures
Commands
List of commands.
Definition of stuff that is very close to a company, like the company struct itself.
CompanyID _local_company
Company controlled by the human player at this client. Can also be COMPANY_SPECTATOR.
Functions related to companies.
bool IsValidAxis(Axis d)
Checks if an integer value is a valid Axis.
DiagDirection ReverseDiagDir(DiagDirection d)
Returns the reverse direction of the given DiagDirection.
Axis DiagDirToAxis(DiagDirection d)
Convert a DiagDirection to the axis.
Axis
Allow incrementing of DiagDirDiff variables.
@ INVALID_AXIS
Flag for an invalid Axis.
DiagDirection
Enumeration for diagonal directions.
@ DIAGDIR_NE
Northeast, upper right on your monitor.
@ DIAGDIR_END
Used for iterations.
Functions related to the drop down widget.
Types related to the drop down widget.
std::vector< std::unique_ptr< const DropDownListItem > > DropDownList
A drop down list is a collection of drop down list items.
int GetCharacterHeight(FontSize size)
Get height of a character for a given font size.
Dimension maxdim(const Dimension &d1, const Dimension &d2)
Compute bounding box of both dimensions.
Dimension GetSpriteSize(SpriteID sprid, Point *offset, ZoomLevel zoom)
Get the size of a sprite.
bool _ctrl_pressed
Is Ctrl pressed?
bool FillDrawPixelInfo(DrawPixelInfo *n, int left, int top, int width, int height)
Set up a clipping area for only drawing into a certain area.
@ FS_NORMAL
Index of the normal font in the font tables.
void SetDirty() const
Mark entire window as dirty (in need of re-paint)
void MarkTileDirtyByTile(TileIndex tile, int bridge_level_offset, int tile_height_override)
Mark a tile given by its index dirty for repaint.
GUI functions that shouldn't be here.
Hotkey related functions.
bool HandlePlacePushButton(Window *w, WidgetID widget, CursorID cursor, HighLightStyle mode)
This code is shared for the majority of the pushbuttons.
TileIndexDiff TileOffsByDiagDir(DiagDirection dir)
Convert a DiagDirection to a TileIndexDiff.
static debug_inline TileIndex TileVirtXY(uint x, uint y)
Get a tile from the virtual XY-coordinate.
constexpr bool IsInsideMM(const T x, const size_t min, const size_t max) noexcept
Checks if a value is in an interval.
@ CBID_STATION_AVAILABILITY
Determine whether a newstation should be made available to build.
@ CBM_ROAD_STOP_AVAIL
Availability of road stop in construction window.
static const uint CALLBACK_FAILED
Different values for Callback result evaluations.
bool Convert8bitBooleanCallback(const GRFFile *grffile, uint16_t cbid, uint16_t cb_res)
Converts a callback result into a boolean.
NewGRF definitions and structures for road stops.
bool IsWaypointClass(const RoadStopClass &cls)
Test if a RoadStopClass is the waypoint class.
@ RSV_DRIVE_THROUGH_X
Drive through road stop, X axis.
@ ROADSTOP_CLASS_DFLT
Default road stop class.
@ ROADSTOP_CLASS_WAYP
Waypoint class.
@ ROADSTOPTYPE_FREIGHT
This RoadStop is for freight (truck) stops.
@ ROADSTOPTYPE_ALL
This RoadStop is for both types of station road stops.
@ ROADSTOPTYPE_PASSENGER
This RoadStop is for passenger (bus) stops.
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 DrawRoadStopTile(int x, int y, RoadType roadtype, const RoadStopSpec *spec, StationType type, int view)
Draw representation of a road stop tile for GUI purposes.
@ RSF_NO_AUTO_ROAD_CONNECTION
No auto road connection.
@ RSF_DRIVE_THROUGH_ONLY
Stop is drive-through only.
@ RSF_BUILD_MENU_ROAD_ONLY
Only show in the road build menu (not tram).
@ RSF_BUILD_MENU_TRAM_ONLY
Only show in the tram build menu (not road).
std::unique_ptr< NWidgetBase > MakePickerTypeWidgets()
Create nested widgets for the type picker widgets.
std::unique_ptr< NWidgetBase > MakePickerClassWidgets()
Create nested widgets for the class picker widgets.
static bool _remove_button_clicked
Flag whether 'remove' toggle-button is currently enabled.
@ INVALID_RAILTYPE
Flag for invalid railtype.
RoadTypes GetCompanyRoadTypes(CompanyID company, bool introduces)
Get the road types the given company can build.
RoadTypes GetRoadTypes(bool introduces)
Get list of road types, regardless of company availability.
bool ValParamRoadType(RoadType roadtype)
Validate functions for rail building.
RoadTypes AddDateIntroducedRoadTypes(RoadTypes current, TimerGameCalendar::Date date)
Add the road types that are to be introduced at the given date.
const RoadTypeInfo * GetRoadTypeInfo(RoadType roadtype)
Returns a pointer to the Roadtype information for a given roadtype.
RoadTypes _roadtypes_type
Bitmap of road/tram types.
void DrawRoadDepotSprite(int x, int y, DiagDirection dir, RoadType rt)
Draw the road depot sprite.
RoadBits DiagDirToRoadBits(DiagDirection d)
Create the road-part which belongs to the given DiagDirection.
static constexpr NWidgetPart _nested_road_station_picker_widgets[]
Widget definition of the build road station window.
void InitializeRoadGUI()
I really don't know why rail_gui.cpp has this too, shouldn't be included in the other one?
static constexpr NWidgetPart _nested_build_road_waypoint_widgets[]
Nested widget definition for the build NewGRF road waypoint window.
Window * ShowBuildRoadToolbar(RoadType roadtype)
Open the build road toolbar window.
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.
static void PlaceRoadStop(TileIndex start_tile, TileIndex end_tile, RoadStopType stop_type, bool adjacent, RoadType rt, StringID err_msg)
Place a new road stop.
static constexpr NWidgetPart _nested_tram_station_picker_widgets[]
Widget definition of the build tram station window.
static void PlaceRoad_TruckStation(TileIndex tile)
Callback for placing a truck station.
static bool IsRoadStopAvailable(const RoadStopSpec *spec, StationType type)
Check whether a road stop type can be built.
Window * ShowBuildRoadScenToolbar(RoadType roadtype)
Show the road building toolbar in the scenario editor.
static void PlaceRoad_Bridge(TileIndex tile, Window *w)
Callback to start placing a bridge.
static void PlaceRoad_BusStation(TileIndex tile)
Callback for placing a bus station.
static void PlaceRoad_Waypoint(TileIndex tile)
Place a road waypoint.
static void ToggleRoadButton_Remove(Window *w)
Toggles state of the Remove button of Build road toolbar.
static RoadWaypointPickerSelection _waypoint_gui
Settings of the road waypoint picker.
static bool RoadToolbar_CtrlChanged(Window *w)
Updates the Remove button because of Ctrl state change.
void CcBuildRoadTunnel(Commands, const CommandCost &result, TileIndex start_tile)
Callback executed after a build road tunnel command has been called.
void ConnectRoadToStructure(TileIndex tile, DiagDirection direction)
If required, connects a new structure to an existing road or tram by building the missing roadbit.
Functions/types related to the road GUIs.
static debug_inline bool IsNormalRoadTile(Tile t)
Return whether a tile is a normal road tile.
RoadBits GetRoadBits(Tile t, RoadTramType rtt)
Get the present road bits for a specific road type.
@ ROAD_NONE
No road-part is build.
RoadTypes
The different roadtypes we support, but then a bitmask of them.
@ ROADTYPES_NONE
No roadtypes.
RoadType
The different roadtypes we support.
@ INVALID_ROADTYPE
flag for invalid roadtype
@ DRD_NORTHBOUND
All northbound traffic is disallowed.
@ DRD_NONE
None of the directions are disallowed.
A number of safeguards to prevent using unsafe methods.
GameSettings _settings_game
Game settings of a running game or the scenario editor.
ClientSettings _settings_client
The current settings for this game.
Functions related to sound.
@ SND_15_BEEP
19 == 0x13 GUI button click
@ SND_1F_CONSTRUCTION_OTHER
29 == 0x1D Construction: other (non-water, non-rail, non-bridge)
static const CursorID ANIMCURSOR_DEMOLISH
704 - 707 - demolish dynamite
Base classes/functions for stations.
Command definitions related to stations.
Functions related to stations.
void ShowSelectStationIfNeeded(TileArea ta, StationPickerCmdProc proc)
Show the station selection window when needed.
void CheckRedrawStationCoverage(const Window *w)
Check whether we need to redraw the station coverage text.
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)
void ShowSelectRoadWaypointIfNeeded(TileArea ta, StationPickerCmdProc proc)
Show the road waypoint selection window when needed.
Contains enums and function declarations connected with stations GUI.
StationCoverageType
Types of cargo to display for station coverage.
@ SCT_NON_PASSENGERS_ONLY
Draw all non-passenger class cargoes.
@ SCT_PASSENGERS_ONLY
Draw only passenger class cargoes.
RoadStopType
Types of RoadStops.
@ ROADSTOP_BUS
A standard stop for buses.
@ ROADSTOP_TRUCK
A standard stop for trucks.
@ FACIL_BUS_STOP
Station with bus stops.
@ FACIL_TRUCK_STOP
Station with truck stops.
StationType
Station types.
static constexpr uint CA_BUS
Catchment for bus stops with "modified catchment" enabled.
static constexpr uint CA_UNMODIFIED
Catchment for all stations with "modified catchment" disabled.
static constexpr uint CA_TRUCK
Catchment for truck stops with "modified catchment" enabled.
Definition of base types and functions in a cross-platform compatible way.
void SetDParam(size_t n, uint64_t v)
Set a string parameter v at index n in the global string parameter array.
Functions related to OTTD's strings.
int64_t PackVelocity(uint speed, VehicleType type)
Pack velocity and vehicle type for use with SCC_VELOCITY string parameter.
uint32_t StringID
Numeric value that represents a string, independent of the selected language.
static const StringID INVALID_STRING_ID
Constant representing an invalid string (16bit in case it is used in savegames)
Class to backup a specific variable and restore it upon destruction of this object to prevent stack v...
uint coverage_height
Height of the coverage texts.
void OnInvalidateData([[maybe_unused]] int data=0, [[maybe_unused]] bool gui_scope=true) override
Some data on this window has become invalid.
void OnRealtimeTick([[maybe_unused]] uint delta_ms) override
Called periodically.
StationType GetRoadStationTypeByWindowClass(WindowClass window_class) const
Simply to have a easier way to get the StationType for bus, truck and trams from the WindowClass.
void OnPaint() override
The window must be repainted.
SoundSettings sound
sound effect settings
GUISettings gui
settings related to the GUI
RoadTypes avail_roadtypes
Road types available to this company.
Dimensions (a width and height) of a rectangle in 2D.
Data about how and where to blit pixels.
const struct GRFFile * grffile
grf file that introduced this entity
bool persistent_buildingtools
keep the building tools active after usage
bool station_show_coverage
whether to highlight coverage area
bool link_terraform_toolbar
display terraform toolbar when displaying rail, road, water and airport toolbars
StationSettings station
settings related to station management
List of hotkeys for a window.
All data for a single hotkey.
Represents the covered area of e.g.
uint16_t w
The width of the area.
TileIndex tile
The base tile of the area.
uint16_t h
The height of the area.
Coordinates of a point in 2D.
Tindex index
Index of this pool item.
static Titem * Get(size_t index)
Returns Titem with given index.
static bool IsValidID(size_t index)
Tests whether given index can be used to get valid (non-nullptr) Titem.
constexpr uint Horizontal() const
Get total horizontal padding of RectPadding.
constexpr uint Vertical() const
Get total vertical padding of RectPadding.
Specification of a rectangle with absolute coordinates of all edges.
int Width() const
Get width of Rect.
Rect Shrink(int s) const
Copy and shrink Rect by s pixels.
int Height() const
Get height of Rect.
RoadStopClassID sel_class
Selected road stop class.
DiagDirection orientation
Selected orientation of the road stop.
uint16_t sel_type
Selected road stop type within the class.
StringID name
Name of this stop.
GRFFilePropsBase< NUM_CARGO+3 > grf_prop
Properties related the the grf file.
RoadStopClassID sel_class
Selected road waypoint class.
uint16_t sel_type
Selected road waypoint type within the class.
bool click_beep
Beep on a random selection of buttons.
bool confirm
Play sound effect on successful constructions or other actions.
static Pool::IterateWrapper< Station > Iterate(size_t from=0)
Returns an iterable ensemble of all valid stations of type T.
uint8_t station_spread
amount a station may spread
bool modified_catchment
different-size catchment areas
Point size
Size, in tile "units", of the white/red selection area.
Point pos
Location, in tile "units", of the northern tile of the selected area.
Representation of a waypoint.
High level window description.
Data structure for an opened window.
void ReInit(int rx=0, int ry=0, bool reposition=false)
Re-initialize a window, and optionally change its size.
virtual void Close(int data=0)
Hide the window and all its child windows, and mark them for a later deletion.
void FinishInitNested(WindowNumber window_number=0)
Perform the second part of the initialization of a nested widget tree.
void DrawWidgets() const
Paint all widgets of a window.
void InvalidateData(int data=0, bool gui_scope=true)
Mark this window's data as invalid (in need of re-computing)
Window * parent
Parent window.
void RaiseWidget(WidgetID widget_index)
Marks a widget as raised.
void SetWidgetDirty(WidgetID widget_index) const
Invalidate a widget, i.e.
ResizeInfo resize
Resize information.
void DisableWidget(WidgetID widget_index)
Sets a widget to disabled.
void SetWidgetsDisabledState(bool disab_stat, Args... widgets)
Sets the enabled/disabled status of a list of widgets.
void CreateNestedTree()
Perform the first part of the initialization of a nested widget tree.
WindowClass window_class
Window class.
bool IsWidgetLowered(WidgetID widget_index) const
Gets the lowered state of a widget.
bool IsWidgetDisabled(WidgetID widget_index) const
Gets the enabled/disabled status of a widget.
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 RaiseButtons(bool autoraise=false)
Raise the buttons of the window.
void SetWidgetLoweredState(WidgetID widget_index, bool lowered_stat)
Sets the lowered/raised status of a widget.
bool IsShaded() const
Is window shaded currently?
int top
y position of top edge of the window
void LowerWidget(WidgetID widget_index)
Marks a widget as lowered.
virtual EventState OnHotkey(int hotkey)
A hotkey has been pressed.
void SetWidgetDisabledState(WidgetID widget_index, bool disab_stat)
Sets the enabled/disabled status of a widget.
void ToggleWidgetLoweredState(WidgetID widget_index)
Invert the lowered/raised status of a widget.
WindowNumber window_number
Window number within the window class.
constexpr TileIndex INVALID_TILE
The very nice invalid tile marker.
Functions related to tile highlights.
void ResetObjectToPlace()
Reset the cursor and mouse mode handling back to default (normal cursor, only clicking in windows).
void VpSetPresizeRange(TileIndex from, TileIndex to)
Highlights all tiles between a set of two tiles.
void VpSelectTilesWithMethod(int x, int y, ViewportPlaceMethod method)
Selects tiles while dragging.
void VpStartPlaceSizing(TileIndex tile, ViewportPlaceMethod method, ViewportDragDropSelectionProcess process)
highlighting tiles while only going over them with the mouse
@ HT_DIAGONAL
Also allow 'diagonal rectangles'. Only usable in combination with HT_RECT or HT_POINT.
@ HT_RECT
rectangle (stations, depots, ...)
@ HT_SPECIAL
special mode used for highlighting while dragging (and for tunnels/docks)
Definition of Interval and OneShot timers.
Definition of the game-calendar-timer.
@ TRANSPORT_ROAD
Transport by road vehicle.
Header file for things common for tunnels and bridges.
TileIndex _build_tunnel_endtile
The end of a tunnel; as hidden return from the tunnel build command for GUI purposes.
Command definitions related to tunnels and bridges.
Functions that have tunnels and bridges in common.
DiagDirection GetTunnelBridgeDirection(Tile t)
Get the direction pointing to the other end.
TileIndex GetOtherTunnelBridgeEnd(Tile t)
Determines type of the wormhole and returns its other end.
bool CanBuildVehicleInfrastructure(VehicleType type, uint8_t subtype)
Check whether we can build infrastructure for the given vehicle type.
Functions related to vehicles.
@ VEH_ROAD
Road vehicle type.
void SetTileSelectSize(int w, int h)
Highlight w by h tiles at the cursor.
void SetRedErrorSquare(TileIndex tile)
Set a tile to display a red error square.
void SetViewportCatchmentStation(const Station *st, bool sel)
Select or deselect station for coverage area highlight.
Functions related to (drawing on) viewports.
ViewportDragDropSelectionProcess
Drag and drop selection process, or, what to do with an area of land when you've selected it.
@ DDSP_PLACE_ROAD_Y_DIR
Road placement (Y axis)
@ DDSP_BUILD_BUSSTOP
Road stop placement (buses)
@ DDSP_REMOVE_BUSSTOP
Road stop removal (buses)
@ DDSP_REMOVE_ROAD_WAYPOINT
Road stop removal (waypoint)
@ DDSP_DEMOLISH_AREA
Clear area.
@ DDSP_BUILD_TRUCKSTOP
Road stop placement (trucks)
@ DDSP_REMOVE_TRUCKSTOP
Road stop removal (trucks)
@ DDSP_PLACE_AUTOROAD
Road placement (auto)
@ DDSP_BUILD_ROAD_WAYPOINT
Road stop placement (waypoint)
@ DDSP_PLACE_ROAD_X_DIR
Road placement (X axis)
@ DDSP_BUILD_BRIDGE
Bridge placement.
@ DDSP_CONVERT_ROAD
Road conversion.
ViewportPlaceMethod
Viewport place method (type of highlighted area and placed objects)
@ VPM_FIX_Y
drag only in Y axis
@ VPM_Y_LIMITED
Drag only in Y axis with limited size.
@ VPM_X_AND_Y_LIMITED
area of land of limited size
@ VPM_X_LIMITED
Drag only in X axis with limited size.
@ VPM_X_AND_Y
area of land in X and Y directions
@ VPM_FIX_X
drag only in X axis
@ VPM_X_OR_Y
drag in X or Y direction
@ WPF_ROAD
This is a road waypoint.
Axis GetAxisForNewRoadWaypoint(TileIndex tile)
Get the axis for a new road waypoint.
Command definitions related to waypoints.
Functions related to waypoints.
void CloseWindowById(WindowClass cls, WindowNumber number, bool force, int data)
Close a window by its class and window number (if it is open).
Window * FindWindowById(WindowClass cls, WindowNumber number)
Find a window by its class and window number.
void CloseWindowByClass(WindowClass cls, int data)
Close all windows of a given class.
Window functions not directly related to making/drawing windows.
Functions, definitions and such used only by the GUI.
@ WDF_CONSTRUCTION
This window is used for construction; close it whenever changing company.
@ WDP_AUTO
Find a place automatically.
@ WDP_ALIGN_TOOLBAR
Align toward the toolbar.
int32_t WindowNumber
Number to differentiate different windows of the same class.
EventState
State of handling an event.
@ ES_HANDLED
The passed event is handled.
@ ES_NOT_HANDLED
The passed event is not handled.
WindowClass
Window classes.
@ WC_SCEN_BUILD_TOOLBAR
Scenario build toolbar; Window numbers:
@ WC_BUILD_TOOLBAR
Build toolbar; Window numbers:
@ WC_NONE
No window, redirects to WC_MAIN_WINDOW.
@ WC_SCEN_LAND_GEN
Landscape generation (in Scenario Editor); Window numbers:
@ WC_SELECT_STATION
Select station (when joining stations); Window numbers:
@ WC_BUILD_DEPOT
Build depot; Window numbers:
@ WC_TRUCK_STATION
Build truck station; Window numbers:
@ WC_BUS_STATION
Build bus station; Window numbers:
@ WC_BUILD_WAYPOINT
Build waypoint; Window numbers:
@ WC_BUILD_BRIDGE
Build bridge; Window numbers:
Functions related to zooming.
int ScaleSpriteTrad(int value)
Scale traditional pixel dimensions to GUI zoom level, for drawing sprites.
int ScaleGUITrad(int value)
Scale traditional pixel dimensions to GUI zoom level.