50#include "table/strings.h"
55static void ShowRoadDepotPicker(
Window *parent);
56static void ShowBuildRoadWaypointPicker(
Window *parent);
58static bool _remove_button_clicked;
59static bool _one_way_button_clicked;
61static Axis _place_road_dir;
62static bool _place_road_start_half_x;
63static bool _place_road_start_half_y;
64static bool _place_road_end_half;
85 if (spec ==
nullptr)
return true;
90 switch (spec->stop_type) {
94 default: NOT_REACHED();
104 if (spec ==
nullptr)
return true;
105 if (!IsRoadStopEverAvailable(spec, type))
return false;
176 if (result.
Failed())
return;
198 if (result.
Failed())
return;
203 bool connect_to_road =
true;
209 if (connect_to_road) {
210 TileArea roadstop_area(tile, width, length);
211 for (
TileIndex cur_tile : roadstop_area) {
236 uint16_t spec_index = _roadstop_gui.
sel_type;
238 auto proc = [=](
bool test,
StationID to_join) ->
bool {
241 ddir, rt, spec_class, spec_index, StationID::Invalid(), adjacent).Succeeded();
244 ddir, rt, spec_class, spec_index, to_join, adjacent);
257 if (_remove_button_clicked) {
280 if (_remove_button_clicked) {
298 if (_remove_button_clicked) {
310typedef void OnButtonClick(
Window *w);
321 SetSelectionRed(_remove_button_clicked);
355 if (RoadTypeIsRoad(this->roadtype)) {
386 RoadTramType
rtt = GetRoadTramType(this->roadtype);
401 if (_game_mode != GM_EDITOR) {
424 if (_game_mode != GM_EDITOR) {
467 if (RoadTypeIsRoad(this->roadtype)) {
490 if (RoadTypeIsRoad(this->roadtype)) {
501 if (RoadTypeIsRoad(this->roadtype)) {
512 _remove_button_clicked =
false;
513 _one_way_button_clicked =
false;
517 this->last_started_action = widget;
522 this->last_started_action = widget;
527 this->last_started_action = widget;
532 this->last_started_action = widget;
537 ShowRoadDepotPicker(
this);
538 this->last_started_action = widget;
543 this->last_started_action = widget;
545 ShowBuildRoadWaypointPicker(
this);
552 this->last_started_action = widget;
559 this->last_started_action = widget;
567 SetSelectionRed(
false);
572 this->last_started_action = widget;
577 this->last_started_action = widget;
590 this->last_started_action = widget;
593 default: NOT_REACHED();
609 switch (this->last_started_action) {
612 _place_road_start_half_x = _tile_fract_coords.x >= 8;
618 _place_road_start_half_y = _tile_fract_coords.y >= 8;
624 _place_road_start_half_x = _tile_fract_coords.x >= 8;
625 _place_road_start_half_y = _tile_fract_coords.y >= 8;
635 tile, _cur_roadtype, _road_depot_orientation);
663 default: NOT_REACHED();
675 if (RoadTypeIsRoad(this->roadtype)) {
694 switch (select_proc) {
696 _place_road_end_half =
pt.x & 8;
700 _place_road_end_half =
pt.y & 8;
707 ( (_tile_fract_coords.x < _tile_fract_coords.y && (_tile_fract_coords.x + _tile_fract_coords.y) < 16) ||
708 (_tile_fract_coords.x > _tile_fract_coords.y && (_tile_fract_coords.x + _tile_fract_coords.y) > 16) ))) {
711 _place_road_end_half =
pt.x & 8;
715 _place_road_end_half =
pt.y & 8;
730 switch (select_proc) {
731 default: NOT_REACHED();
744 bool start_half = _place_road_dir ==
AXIS_Y ? _place_road_start_half_y : _place_road_start_half_x;
746 if (_remove_button_clicked) {
748 end_tile, start_tile, _cur_roadtype, _place_road_dir,
start_half, _place_road_end_half);
759 if (_remove_button_clicked) {
782 if (_remove_button_clicked) {
796 if (_remove_button_clicked) {
840 switch (_game_mode) {
860 extern RoadType _last_built_roadtype;
866 extern RoadType _last_built_tramtype;
870 static inline HotkeyList road_hotkeys{
"roadtoolbar", {
884 }, RoadToolbarGlobalHotkeys};
886 static inline HotkeyList tram_hotkeys{
"tramtoolbar", {
899 }, TramToolbarGlobalHotkeys};
902static constexpr NWidgetPart _nested_build_road_widgets[] = {
943 _nested_build_road_widgets,
944 &BuildRoadToolbarWindow::road_hotkeys
947static constexpr NWidgetPart _nested_build_tramway_widgets[] = {
986 _nested_build_tramway_widgets,
987 &BuildRoadToolbarWindow::tram_hotkeys
1003 _cur_roadtype = roadtype;
1005 return AllocateWindowDescFront<BuildRoadToolbarWindow>(RoadTypeIsRoad(_cur_roadtype) ? _build_road_desc : _build_tramway_desc,
TRANSPORT_ROAD);
1008static constexpr NWidgetPart _nested_build_road_scen_widgets[] = {
1038 WDP_AUTO,
"toolbar_road_scen", 0, 0,
1041 _nested_build_road_scen_widgets,
1042 &BuildRoadToolbarWindow::road_hotkeys
1045static constexpr NWidgetPart _nested_build_tramway_scen_widgets[] = {
1073 WDP_AUTO,
"toolbar_tram_scen", 0, 0,
1076 _nested_build_tramway_scen_widgets,
1077 &BuildRoadToolbarWindow::tram_hotkeys
1087 _cur_roadtype = roadtype;
1089 return AllocateWindowDescFront<BuildRoadToolbarWindow>(RoadTypeIsRoad(_cur_roadtype) ? _build_road_scen_desc : _build_tramway_scen_desc,
TRANSPORT_ROAD);
1098 if (RoadTypeIsTram(_cur_roadtype)) {
1150static constexpr NWidgetPart _nested_build_road_depot_widgets[] = {
1173 _nested_build_road_depot_widgets
1176static void ShowRoadDepotPicker(
Window *parent)
1181template <RoadStopType roadstoptype>
1186 GrfSpecFeature GetFeature()
const override {
return GSF_ROADSTOPS; }
1195 for (
const auto *spec : cls.Specs()) {
1196 if (spec ==
nullptr)
continue;
1207 return !
IsWaypointClass(cls) && GetIfClassHasNewStopsByType(&cls, roadstoptype, _cur_roadtype);
1220 const auto *rsc = this->GetClass(
id);
1230 const auto *spec = this->GetSpec(cls_id,
id);
1232 return (spec ==
nullptr) ? STR_STATION_CLASS_DFLT_ROADSTOP : spec->name;
1237 const auto *spec = this->GetSpec(cls_id,
id);
1238 if (!IsRoadStopEverAvailable(spec, roadstoptype ==
RoadStopType::Bus ? StationType::Bus : StationType::Truck))
return {};
1239 if (spec ==
nullptr)
return {};
1240 return spec->badges;
1245 const auto *spec = this->GetSpec(cls_id,
id);
1249 void DrawType(
int x,
int y,
int cls_id,
int id)
const override
1251 const auto *spec = this->GetSpec(cls_id,
id);
1252 if (spec ==
nullptr) {
1257 DrawRoadStopTile(x, y, _cur_roadtype, spec, roadstoptype ==
RoadStopType::Bus ? StationType::Bus : StationType::Truck, (uint8_t)orientation);
1268 for (
const auto &sm : st->roadstop_speclist) {
1269 if (sm.spec ==
nullptr)
continue;
1272 items.insert({sm.grfid, sm.localidx, sm.spec->class_index, sm.spec->index});
1296 void CheckOrientationValid()
1301 if (RoadTypeIsRoad(_cur_roadtype)) {
1327 this->ConstructWindow();
1353 this->CheckOrientationValid();
1375 const int bottom = r.bottom;
1383 if (r.top > bottom) {
1384 this->coverage_height += r.top - bottom;
1420 default: NOT_REACHED();
1441 if (spec ==
nullptr) {
1498 static inline HotkeyList road_hotkeys{
"buildroadstop", {
1502 static inline HotkeyList tram_hotkeys{
"buildtramstop", {
1549 SetStringTip(STR_STATION_BUILD_COVERAGE_OFF, STR_STATION_BUILD_COVERAGE_AREA_OFF_TOOLTIP),
1551 SetStringTip(STR_STATION_BUILD_COVERAGE_ON, STR_STATION_BUILD_COVERAGE_AREA_ON_TOOLTIP),
1562 WDP_AUTO,
"build_station_road", 0, 0,
1566 &BuildRoadStationWindow::road_hotkeys
1589 SetStringTip(STR_STATION_BUILD_COVERAGE_OFF, STR_STATION_BUILD_COVERAGE_AREA_OFF_TOOLTIP),
1591 SetStringTip(STR_STATION_BUILD_COVERAGE_ON, STR_STATION_BUILD_COVERAGE_AREA_ON_TOOLTIP),
1602 WDP_AUTO,
"build_station_tram", 0, 0,
1606 &BuildRoadStationWindow::tram_hotkeys
1611 new BuildRoadStationWindow(RoadTypeIsRoad(_cur_roadtype) ? _road_station_picker_desc : _tram_station_picker_desc, parent, rs);
1618 GrfSpecFeature GetFeature()
const override {
return GSF_ROADSTOPS; }
1627 for (
const auto *spec : cls.Specs()) {
1628 if (spec !=
nullptr)
return true;
1645 const auto *sc = GetClass(
id);
1655 const auto *spec = this->GetSpec(cls_id,
id);
1656 return (spec ==
nullptr) ? STR_STATION_CLASS_WAYP_WAYPOINT : spec->name;
1661 const auto *spec = this->GetSpec(cls_id,
id);
1662 if (spec ==
nullptr)
return {};
1663 return spec->badges;
1671 void DrawType(
int x,
int y,
int cls_id,
int id)
const override
1673 const auto *spec = this->GetSpec(cls_id,
id);
1674 if (spec ==
nullptr) {
1677 DrawRoadStopTile(x, y, _cur_roadtype, spec, StationType::RoadWaypoint,
RSV_DRIVE_THROUGH_X);
1686 for (
const auto &sm : wp->roadstop_speclist) {
1687 if (sm.spec ==
nullptr)
continue;
1688 items.insert({sm.grfid, sm.localidx, sm.spec->class_index, sm.spec->index});
1700 this->ConstructWindow();
1703 static inline HotkeyList hotkeys{
"buildroadwaypoint", {
1723 WDP_AUTO,
"build_road_waypoint", 0, 0,
1727 &BuildRoadWaypointWindow::hotkeys
1730static void ShowBuildRoadWaypointPicker(
Window *parent)
1732 if (!RoadWaypointPickerCallbacks::instance.IsActive())
return;
1736void InitializeRoadGui()
1753DropDownList GetRoadTypeDropDownList(RoadTramTypes rtts,
bool for_replacement,
bool all_option)
1761 if (for_replacement) {
1771 if (!
HasBit(rtts, RTT_TRAM)) used_roadtypes &= ~_roadtypes_type;
1776 list.push_back(MakeDropDownListStringItem(STR_REPLACE_ALL_ROADTYPE,
INVALID_ROADTYPE));
1781 if (!for_replacement) {
1782 for (
const auto &rt : _sorted_roadtypes) {
1783 if (!
HasBit(used_roadtypes, rt))
continue;
1790 auto badge_class_list = std::make_shared<GUIBadgeClasses>(GSF_ROADTYPES);
1792 for (
const auto &rt : _sorted_roadtypes) {
1794 if (!
HasBit(used_roadtypes, rt))
continue;
1798 if (for_replacement) {
1804 list.push_back(MakeDropDownListBadgeIconItem(badge_class_list, rti->badges, GSF_ROADTYPES, rti->
introduction_date, d, rti->
gui_sprites.
build_x_road, PAL_NONE, std::move(str), rt, !
HasBit(avail_roadtypes, rt)));
1810 list.push_back(MakeDropDownListStringItem(STR_NONE,
INVALID_ROADTYPE,
true));
1816DropDownList GetScenRoadTypeDropDownList(RoadTramTypes rtts)
1824 if (!
HasBit(rtts, RTT_TRAM)) used_roadtypes &= ~_roadtypes_type;
1830 for (
const auto &rt : _sorted_roadtypes) {
1831 if (!
HasBit(used_roadtypes, rt))
continue;
1837 auto badge_class_list = std::make_shared<GUIBadgeClasses>(GSF_ROADTYPES);
1839 for (
const auto &rt : _sorted_roadtypes) {
1840 if (!
HasBit(used_roadtypes, rt))
continue;
1847 list.push_back(MakeDropDownListBadgeIconItem(badge_class_list, rti->badges, GSF_ROADTYPES, rti->
introduction_date, d, rti->
gui_sprites.
build_x_road, PAL_NONE, std::move(str), rt, !
HasBit(avail_roadtypes, rt)));
1852 list.push_back(MakeDropDownListStringItem(STR_NONE, -1,
true));
debug_inline constexpr 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
constexpr bool Test(Tvalue_type value) const
Test if the value-th bit is set.
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.
void DrawWidget(const Rect &r, WidgetID widget) const override
Draw the contents of a nested widget.
@ PCWHK_FOCUS_FILTER_BOX
Focus the edit box for editing the filter string.
void OnClick(Point pt, WidgetID widget, int click_count) override
A click with the left mouse button has been made on the window.
static const int PREVIEW_WIDTH
Width of each preview button.
void OnInvalidateData(int data=0, bool gui_scope=true) override
Some data on this window has become invalid.
static const int PREVIEW_BOTTOM
Offset from bottom edge to draw preview.
void UpdateWidgetSize(WidgetID widget, Dimension &size, const Dimension &padding, Dimension &fill, Dimension &resize) override
Update size and resize step of a widget in the window.
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.
std::span< const BadgeID > GetTypeBadges(int cls_id, int id) const override
Get the item of a type.
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.
TimerGameCalendar::Date introduction_date
Introduction date.
StringID picker_tooltip[2]
Tooltip for the station picker for bus or truck stations.
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
struct RoadTypeInfo::@27 strings
Strings associated with the rail type.
CursorID tunnel
Cursor for building a tunnel.
SpriteID auto_road
button for the autoroad construction
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.
struct RoadTypeInfo::@25 gui_sprites
struct containing the sprites for the road GUI.
StringID GetTypeTooltip() const override
Get the tooltip string for the type grid.
int GetSelectedType() const override
Get the selected type.
std::span< const BadgeID > GetTypeBadges(int cls_id, int id) const override
Get the item of a 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 DoCommandFlags CommandFlagsToDCFlags(CommandFlags cmd_flags)
Extracts the DC flags needed for DoCommand from the flags returned by GetCommandFlags.
@ 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.
constexpr std::underlying_type_t< enum_type > to_underlying(enum_type e)
Implementation of std::to_underlying (from C++23)
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 size_t x, const size_t min, const size_t max) noexcept
Checks if a value is in an interval.
int DrawBadgeNameList(Rect r, std::span< const BadgeID > badges, GrfSpecFeature)
Draw names for a list of badge labels.
Functions related to NewGRF badges.
@ CBID_STATION_AVAILABILITY
Determine whether a newstation should be made available to build.
static const uint CALLBACK_FAILED
Different values for Callback result evaluations.
@ Avail
Availability of road stop in construction window.
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.
@ 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.
@ RSV_DRIVE_THROUGH_X
Drive through road stop, X axis.
@ NoAutoRoadConnection
No auto road connection.
@ RoadOnly
Only show in the road build menu (not tram).
@ TramOnly
Only show in the tram build menu (not road).
@ DriveThroughOnly
Stop is drive-through only.
std::unique_ptr< NWidgetBase > MakePickerClassWidgets()
Create nested widgets for the class picker widgets.
std::unique_ptr< NWidgetBase > MakePickerTypeWidgets()
Create nested widgets for the type picker widgets.
@ 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.
RoadTypes _roadtypes_type
Bitmap of road/tram types.
const RoadTypeInfo * GetRoadTypeInfo(RoadType roadtype)
Returns a pointer to the Roadtype information for a given roadtype.
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 * ShowBuildRoadScenToolbar(RoadType roadtype)
Show the road building toolbar in the scenario editor.
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.
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.
Window * ShowBuildRoadToolbar(RoadType roadtype)
Open the build road toolbar window.
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.
int DrawStationCoverageAreaText(const Rect &r, StationCoverageType sct, int rad, bool supplies)
Calculates and draws the accepted or supplied cargo around the selected tile(s)
void CheckRedrawStationCoverage(const Window *w)
Check whether we need to redraw the station coverage text.
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.
@ Bus
A standard stop for buses.
@ Truck
A standard stop for trucks.
@ TruckStop
Station with truck stops.
@ BusStop
Station with bus 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.
std::string GetString(StringID string)
Resolve the given StringID into a std::string with formatting but no parameters.
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...
void UpdateWidgetSize(WidgetID widget, Dimension &size, const Dimension &padding, Dimension &fill, Dimension &resize) override
Update size and resize step of a widget in the window.
void DrawWidget(const Rect &r, WidgetID widget) const override
Draw the contents of a nested widget.
void OnClick(Point pt, WidgetID widget, int click_count) override
A click with the left mouse button has been made on the window.
uint coverage_height
Height of the coverage texts.
void OnInvalidateData(int data=0, bool gui_scope=true) override
Some data on this window has become invalid.
void DrawWidget(const Rect &r, WidgetID widget) const override
Draw the contents of a nested widget.
void Close(int data=0) override
Hide the window and all its child windows, and mark them for a later deletion.
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 OnClick(Point pt, WidgetID widget, int click_count) override
A click with the left mouse button has been made on the window.
void UpdateWidgetSize(WidgetID widget, Dimension &size, const Dimension &padding, Dimension &fill, Dimension &resize) override
Update size and resize step of a widget in the window.
void OnPaint() override
The window must be repainted.
void OnRealtimeTick(uint delta_ms) override
Called periodically.
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.
static Titem * Get(auto index)
Returns Titem with given index.
Tindex index
Index of this pool item.
static bool IsValidID(auto 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.
Rect Shrink(int s) const
Copy and shrink Rect by s pixels.
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.
VariableGRFFileProps 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.
Number to differentiate different windows of the same class.
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.
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.
virtual std::string GetWidgetString(WidgetID widget, StringID stringid) const
Get the raw string for a widget.
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.
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?
virtual void OnPlaceMouseUp(ViewportPlaceMethod select_method, ViewportDragDropSelectionProcess select_proc, Point pt, TileIndex start_tile, TileIndex end_tile)
The user has dragged over the map when the tile highlight mode has been set.
const NWID * GetWidget(WidgetID widnum) const
Get the nested widget with number widnum from the nested widget tree.
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.
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
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.
@ 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).
void CloseWindowByClass(WindowClass cls, int data)
Close all windows of a given class.
Window * FindWindowById(WindowClass cls, WindowNumber number)
Find a window by its class and window number.
Window functions not directly related to making/drawing windows.
Functions, definitions and such used only by the GUI.
@ 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.
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.