51#include "table/strings.h"
56static void ShowRoadDepotPicker(
Window *parent);
57static void ShowBuildRoadWaypointPicker(
Window *parent);
60static bool _one_way_button_clicked;
62static Axis _place_road_dir;
63static bool _place_road_start_half_x;
64static bool _place_road_start_half_y;
65static bool _place_road_end_half;
86 if (spec ==
nullptr)
return true;
91 switch (spec->stop_type) {
95 default: NOT_REACHED();
107 if (spec ==
nullptr)
return true;
108 if (!IsRoadStopEverAvailable(spec, type))
return false;
180 if (result.
Failed())
return;
202 if (result.
Failed())
return;
207 bool connect_to_road =
true;
213 if (connect_to_road) {
214 TileArea roadstop_area(tile, width, length);
215 for (
TileIndex cur_tile : roadstop_area) {
240 uint16_t spec_index = _roadstop_gui.sel_type;
242 auto proc = [=](
bool test, StationID to_join) ->
bool {
245 ddir, rt, spec_class, spec_index, StationID::Invalid(), adjacent).Succeeded();
247 return Command<Commands::BuildRoadStop>::Post(err_msg,
CcRoadStop, ta.
tile, ta.
w, ta.
h, stop_type, drive_through,
248 ddir, rt, spec_class, spec_index, to_join, adjacent);
274 Command<Commands::BuildRoadWaypoint>::Post(STR_ERROR_CAN_T_BUILD_ROAD_WAYPOINT, tile,
AXIS_X, 1, 1,
ROADSTOP_CLASS_WAYP, 0, StationID::Invalid(),
false);
314typedef void OnButtonClick(
Window *w);
359 if (RoadTypeIsRoad(this->roadtype)) {
368 void Close([[maybe_unused]]
int data = 0)
override
380 void OnInvalidateData([[maybe_unused]]
int data = 0, [[maybe_unused]]
bool gui_scope =
true)
override
382 if (!gui_scope)
return;
405 if (_game_mode != GM_EDITOR) {
428 if (_game_mode != GM_EDITOR) {
469 switch (clicked_widget) {
471 if (RoadTypeIsRoad(this->roadtype)) {
494 if (RoadTypeIsRoad(this->roadtype)) {
505 if (RoadTypeIsRoad(this->roadtype)) {
533 default: NOT_REACHED();
556 default: NOT_REACHED();
563 _remove_button_clicked =
false;
564 _one_way_button_clicked =
false;
568 this->last_started_action = widget;
574 ShowRoadDepotPicker(
this);
580 ShowBuildRoadWaypointPicker(
this);
600 SetSelectionRed(
false);
629 if (RoadTypeIsRoad(_cur_roadtype)) {
653 switch (this->last_started_action) {
656 _place_road_start_half_x = _tile_fract_coords.x >= 8;
662 _place_road_start_half_y = _tile_fract_coords.y >= 8;
668 _place_road_start_half_x = _tile_fract_coords.x >= 8;
669 _place_road_start_half_y = _tile_fract_coords.y >= 8;
679 tile, _cur_roadtype, _road_depot_orientation);
699 Command<Commands::BuildTunnel>::Post(STR_ERROR_CAN_T_BUILD_TUNNEL_HERE,
CcBuildRoadTunnel,
707 default: NOT_REACHED();
719 if (RoadTypeIsRoad(this->roadtype)) {
738 switch (select_proc) {
740 _place_road_end_half = pt.x & 8;
744 _place_road_end_half = pt.y & 8;
750 if (_thd.size.x > _thd.size.y || (_thd.size.x == _thd.size.y &&
751 ( (_tile_fract_coords.x < _tile_fract_coords.y && (_tile_fract_coords.x + _tile_fract_coords.y) < 16) ||
752 (_tile_fract_coords.x > _tile_fract_coords.y && (_tile_fract_coords.x + _tile_fract_coords.y) > 16) ))) {
755 _place_road_end_half = pt.x & 8;
759 _place_road_end_half = pt.y & 8;
779 switch (select_proc) {
780 default: NOT_REACHED();
793 bool start_half = _place_road_dir ==
AXIS_Y ? _place_road_start_half_y : _place_road_start_half_x;
795 if (_remove_button_clicked) {
797 end_tile, start_tile, _cur_roadtype, _place_road_dir, start_half, _place_road_end_half);
800 end_tile, start_tile, _cur_roadtype, _place_road_dir, _one_way_button_clicked ?
DRD_NORTHBOUND :
DRD_NONE, start_half, _place_road_end_half,
false);
808 if (_remove_button_clicked) {
809 Command<Commands::RemoveFromRoadWaypoint>::Post(STR_ERROR_CAN_T_REMOVE_ROAD_WAYPOINT, CcPlaySound_CONSTRUCTION_OTHER, end_tile, start_tile);
815 auto proc = [=](
bool test, StationID to_join) ->
bool {
819 return Command<Commands::BuildRoadWaypoint>::Post(STR_ERROR_CAN_T_BUILD_ROAD_WAYPOINT, CcPlaySound_CONSTRUCTION_OTHER, ta.
tile, axis, ta.
w, ta.
h,
_waypoint_gui.sel_class,
_waypoint_gui.sel_type, to_join, adjacent);
831 if (_remove_button_clicked) {
845 if (_remove_button_clicked) {
890 switch (_game_mode) {
908 static EventState RoadToolbarGlobalHotkeys(
int hotkey)
913 static EventState TramToolbarGlobalHotkeys(
int hotkey)
918 static inline HotkeyList road_hotkeys{
"roadtoolbar", {
936 }, RoadToolbarGlobalHotkeys};
938 static inline HotkeyList tram_hotkeys{
"tramtoolbar", {
955 }, TramToolbarGlobalHotkeys};
958static constexpr std::initializer_list<NWidgetPart> _nested_build_road_widgets = {
1001 _nested_build_road_widgets,
1002 &BuildRoadToolbarWindow::road_hotkeys
1005static constexpr std::initializer_list<NWidgetPart> _nested_build_tramway_widgets = {
1046 _nested_build_tramway_widgets,
1047 &BuildRoadToolbarWindow::tram_hotkeys
1064 _cur_roadtype = roadtype;
1069static constexpr std::initializer_list<NWidgetPart> _nested_build_road_scen_widgets = {
1101 WDP_AUTO,
"toolbar_road_scen", 0, 0,
1104 _nested_build_road_scen_widgets,
1105 &BuildRoadToolbarWindow::road_hotkeys
1108static constexpr std::initializer_list<NWidgetPart> _nested_build_tramway_scen_widgets = {
1138 WDP_AUTO,
"toolbar_tram_scen", 0, 0,
1141 _nested_build_tramway_scen_widgets,
1142 &BuildRoadToolbarWindow::tram_hotkeys
1153 _cur_roadtype = roadtype;
1158struct BuildRoadDepotWindow :
public PickerWindowBase {
1164 if (RoadTypeIsTram(_cur_roadtype)) {
1216static constexpr std::initializer_list<NWidgetPart> _nested_build_road_depot_widgets = {
1239 _nested_build_road_depot_widgets
1242static void ShowRoadDepotPicker(
Window *parent)
1247template <RoadStopType roadstoptype>
1248class RoadStopPickerCallbacks :
public PickerCallbacksNewGRFClass<RoadStopClass> {
1250 RoadStopPickerCallbacks(
const std::string &
ini_group) : PickerCallbacksNewGRFClass<RoadStopClass>(
ini_group) {}
1262 for (
const auto *spec : cls.Specs()) {
1263 if (spec ==
nullptr)
continue;
1272 static bool IsClassChoice(
const RoadStopClass &cls)
1283 void SetSelectedClass(
int id)
const override { _roadstop_gui.sel_class = this->GetClassIndex(
id); }
1287 const auto *rsc = this->GetClass(
id);
1297 const auto *spec = this->GetSpec(cls_id,
id);
1299 return (spec ==
nullptr) ? STR_STATION_CLASS_DFLT_ROADSTOP : spec->name;
1304 const auto *spec = this->GetSpec(cls_id,
id);
1306 if (spec ==
nullptr)
return {};
1307 return spec->badges;
1312 const auto *spec = this->GetSpec(cls_id,
id);
1316 void DrawType(
int x,
int y,
int cls_id,
int id)
const override
1318 const auto *spec = this->GetSpec(cls_id,
id);
1319 if (spec ==
nullptr) {
1335 for (
const auto &sm : st->roadstop_speclist) {
1336 if (sm.spec ==
nullptr)
continue;
1339 items.insert({sm.grfid, sm.localidx, sm.spec->class_index.base(), sm.spec->index});
1361struct BuildRoadStationWindow :
public PickerWindow {
1365 void CheckOrientationValid()
1370 if (RoadTypeIsRoad(_cur_roadtype)) {
1376 if (_roadstop_gui.orientation >=
DIAGDIR_END)
return;
1393 if (RoadTypeIsTram(_cur_roadtype) && _roadstop_gui.orientation <
DIAGDIR_END) {
1396 this->ConstructWindow();
1411 void Close([[maybe_unused]]
int data = 0)
override
1417 void OnInvalidateData([[maybe_unused]]
int data = 0, [[maybe_unused]]
bool gui_scope =
true)
override
1422 this->CheckOrientationValid();
1434 SetTileSelectBigSize(-rad, -rad, 2 * rad, 2 * rad);
1444 const int bottom = r.bottom;
1452 if (r.top > bottom) {
1453 this->coverage_height += r.top - bottom;
1472 size.height = this->coverage_height;
1491 default: NOT_REACHED();
1512 if (spec ==
nullptr) {
1569 static inline HotkeyList road_hotkeys{
"buildroadstop", {
1573 static inline HotkeyList tram_hotkeys{
"buildtramstop", {
1620 SetStringTip(STR_STATION_BUILD_COVERAGE_OFF, STR_STATION_BUILD_COVERAGE_AREA_OFF_TOOLTIP),
1622 SetStringTip(STR_STATION_BUILD_COVERAGE_ON, STR_STATION_BUILD_COVERAGE_AREA_ON_TOOLTIP),
1633 WDP_AUTO,
"build_station_road", 0, 0,
1637 &BuildRoadStationWindow::road_hotkeys
1660 SetStringTip(STR_STATION_BUILD_COVERAGE_OFF, STR_STATION_BUILD_COVERAGE_AREA_OFF_TOOLTIP),
1662 SetStringTip(STR_STATION_BUILD_COVERAGE_ON, STR_STATION_BUILD_COVERAGE_AREA_ON_TOOLTIP),
1673 WDP_AUTO,
"build_station_tram", 0, 0,
1677 &BuildRoadStationWindow::tram_hotkeys
1682 new BuildRoadStationWindow(RoadTypeIsRoad(_cur_roadtype) ? _road_station_picker_desc : _tram_station_picker_desc, parent, rs);
1685class RoadWaypointPickerCallbacks :
public PickerCallbacksNewGRFClass<RoadStopClass> {
1687 RoadWaypointPickerCallbacks() : PickerCallbacksNewGRFClass<RoadStopClass>(
"fav_road_waypoints") {}
1699 for (
const auto *spec : cls.Specs()) {
1700 if (spec !=
nullptr)
return true;
1717 const auto *sc = GetClass(
id);
1727 const auto *spec = this->GetSpec(cls_id,
id);
1728 return (spec ==
nullptr) ? STR_STATION_CLASS_WAYP_WAYPOINT : spec->name;
1733 const auto *spec = this->GetSpec(cls_id,
id);
1734 if (spec ==
nullptr)
return {};
1735 return spec->badges;
1743 void DrawType(
int x,
int y,
int cls_id,
int id)
const override
1745 const auto *spec = this->GetSpec(cls_id,
id);
1746 if (spec ==
nullptr) {
1758 for (
const auto &sm : wp->roadstop_speclist) {
1759 if (sm.spec ==
nullptr)
continue;
1760 items.insert({sm.grfid, sm.localidx, sm.spec->class_index.base(), sm.spec->index});
1769struct BuildRoadWaypointWindow :
public PickerWindow {
1772 this->ConstructWindow();
1775 static inline HotkeyList hotkeys{
"buildroadwaypoint", {
1795 WDP_AUTO,
"build_road_waypoint", 0, 0,
1799 &BuildRoadWaypointWindow::hotkeys
1802static void ShowBuildRoadWaypointPicker(
Window *parent)
1804 if (!RoadWaypointPickerCallbacks::instance.IsActive())
return;
1808void InitializeRoadGui()
1827 RoadTypes used_roadtypes;
1828 RoadTypes avail_roadtypes;
1833 if (for_replacement) {
1853 if (!for_replacement) {
1856 if (!used_roadtypes.
Test(rt))
continue;
1863 auto badge_class_list = std::make_shared<GUIBadgeClasses>(GSF_ROADTYPES);
1867 if (!used_roadtypes.
Test(rt))
continue;
1871 if (for_replacement) {
1877 list.push_back(MakeDropDownListBadgeIconItem(badge_class_list, rti->badges, GSF_ROADTYPES, rti->
introduction_date,
RoadBuildCost(rt), d, rti->
gui_sprites.
build_x_road, PAL_NONE, std::move(str), rt, !avail_roadtypes.
Test(rt)));
1905 if (!used_roadtypes.
Test(rt))
continue;
1911 auto badge_class_list = std::make_shared<GUIBadgeClasses>(GSF_ROADTYPES);
1914 if (!used_roadtypes.
Test(rt))
continue;
1921 list.push_back(MakeDropDownListBadgeIconItem(badge_class_list, rti->badges, GSF_ROADTYPES, rti->
introduction_date,
RoadBuildCost(rt), d, rti->
gui_sprites.
build_x_road, PAL_NONE, std::move(str), rt, !avail_roadtypes.
Test(rt)));
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.
constexpr Timpl & Reset()
Reset all bits.
Common return value for all commands.
bool Succeeded() const
Did this command succeed?
bool Failed() const
Did this command fail?
const Tspec * GetSpec(uint index) const
Get a spec from the class at a given index.
static std::span< NewGRFClass< RoadStopSpec, RoadStopClassID > const > Classes()
static NewGRFClass * Get(RoadStopClassID class_index)
static uint GetClassCount()
Class for PickerClassWindow to collect information and retain state.
const std::string ini_group
Ini Group for saving favourites.
static constexpr int PREVIEW_WIDTH
Width of each preview button.
void Close(int data=0) override
Hide the window and all its child windows, and mark them for a later deletion.
static constexpr int PREVIEW_HEIGHT
Height of each preview button.
void DrawWidget(const Rect &r, WidgetID widget) const override
Draw the contents of a nested widget.
static constexpr int PREVIEW_LEFT
Offset from left edge to draw preview.
static constexpr int PREVIEW_BOTTOM
Offset from bottom edge to draw preview.
@ 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.
void OnInvalidateData(int data=0, bool gui_scope=true) override
Some data on this window has become invalid.
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 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's badges of a type.
StringID GetTypeName(int cls_id, int id) const override
Get the item name of a type.
bool IsActive() const override
Should picker class/type selection be enabled?
GrfSpecFeature GetFeature() const override
NewGRF feature this picker is for.
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 GetCollectionTooltip() const override
Get the tooltip string for the collection list.
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.
struct RoadTypeInfo::@040007041145073342004320043002073006000034160103 gui_sprites
struct containing the sprites for the road GUI.
StringID picker_title[2]
Title for the station picker for bus or truck stations.
struct RoadTypeInfo::@262365004142063215107272155332373126354130071373 cursor
Cursors associated with the road type.
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.
struct RoadTypeInfo::@070000167274302256150317022075324310363002361255 strings
Strings associated with the rail 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
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.
std::span< const BadgeID > GetTypeBadges(int cls_id, int id) const override
Get the item's badges 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 Close(int) override
Hide the window and all its child windows, and mark them for a later deletion.
StringID GetCollectionTooltip() const override
Get the tooltip string for the collection list.
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 name 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.
GrfSpecFeature GetFeature() const override
NewGRF feature this picker is for.
bool HasClassChoice() const override
Are there multiple classes to chose from?
static Date date
Current date in days (day counter).
CommandFlags GetCommandFlags(Commands cmd)
Get the command flags associated with the given command.
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.
std::unique_ptr< DropDownListItem > MakeDropDownListStringItem(StringID str, int value, bool masked, bool shaded)
Creates new DropDownListStringItem.
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?
void SetCursor(CursorID icon, PaletteID pal)
Assign an animation or a non-animated sprite to the cursor.
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.
uint32_t CursorID
The number of the cursor (sprite).
@ WKC_R_BRACKET
] Right square bracket
@ WKC_L_BRACKET
[ Left square bracket
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.
std::tuple< size_t, size_t > GetListIndexStep(SpecialListHotkeys hotkey, const ListType &list, const ItemType ¤t_item)
Gets the first index in the list for given hotkey and the step to look for another if first is invali...
SpecialListHotkeys
Indexes for special hotkeys to navigate in lists.
@ NextItem
Hotkey to select next item in the list.
@ FirstItem
Hotkey to select first item in the list.
@ LastItem
Hotkey to select last item in the list.
@ PreviousItem
Hotkey to select previous item in the list.
bool IsSpecialHotkey(const int &hotkey)
Checks if hotkey index is special or not.
#define Point
Macro that prevents name conflicts between included headers.
bool HandlePlacePushButton(Window *w, WidgetID widget, CursorID cursor, HighLightStyle mode)
This code is shared for the majority of the pushbuttons.
static TileIndex TileVirtXY(uint x, uint y)
Get a tile from the virtual XY-coordinate.
TileIndexDiff TileOffsByDiagDir(DiagDirection dir)
Convert a DiagDirection to a TileIndexDiff.
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.
GUI 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.
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.
NewGRF definitions and structures for road stops.
bool IsWaypointClass(const RoadStopClass &cls)
Test if a RoadStopClass is the waypoint class.
PoolID< uint16_t, struct RoadStopClassIDTag, UINT16_MAX, UINT16_MAX > RoadStopClassID
Class IDs for stations.
static constexpr RoadStopClassID ROADSTOP_CLASS_DFLT
Default road stop class.
static constexpr RoadStopClassID 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.
static bool _remove_button_clicked
Flag whether 'remove' toggle-button is currently enabled.
static WaypointPickerSelection _waypoint_gui
Settings of the waypoint picker.
@ 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.
bool HasRoadTypeAvail(const CompanyID company, RoadType roadtype)
Finds out, whether given company has a given RoadType available for construction.
RoadTypes _roadtypes_hidden_mask
Bitset of hidden roadtypes.
RoadTypes GetMaskForRoadTramType(RoadTramType rtt)
Get the mask for road types of the given RoadTramType.
const RoadTypeInfo * GetRoadTypeInfo(RoadType roadtype)
Returns a pointer to the Roadtype information for a given roadtype.
std::vector< RoadType > _sorted_roadtypes
Sorted list of road types.
Money RoadBuildCost(RoadType roadtype)
Returns the cost of building the specified roadtype.
void DrawRoadDepotSprite(int x, int y, DiagDirection dir, RoadType rt)
Draw the road depot sprite.
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.
RoadBits DiagDirToRoadBits(DiagDirection d)
Create the road-part which belongs to the given DiagDirection.
void InitializeRoadGUI()
I really don't know why rail_gui.cpp has this too, shouldn't be included in the other one?
static constexpr std::initializer_list< 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 void PlaceRoad_TruckStation(TileIndex tile)
Callback for placing a truck station.
static constexpr std::initializer_list< NWidgetPart > _nested_tram_station_picker_widgets
Widget definition of the build tram station window.
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 constexpr std::initializer_list< NWidgetPart > _nested_road_station_picker_widgets
Widget definition of the build road station window.
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 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.
RoadBits GetRoadBits(Tile t, RoadTramType rtt)
Get the present road bits for a specific road type.
static bool IsNormalRoadTile(Tile t)
Return whether a tile is a normal road tile.
@ ROAD_NONE
No road-part is build.
RoadTramType
The different types of road type.
@ RTT_ROAD
Road road type.
@ RTT_TRAM
Tram road type.
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.
void SndClickBeep()
Play a beep sound for a click event if enabled in settings.
Functions related to sound.
@ 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.
@ Bus
Road stop for busses.
@ Truck
Road stop for trucks.
@ RoadWaypoint
Waypoint for trucks and busses.
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.
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 station_show_coverage
whether to highlight coverage area
List of hotkeys for a window.
All data for a single hotkey.
uint16_t w
The width of the area.
TileIndex tile
The base tile of the area.
uint16_t h
The height of the area.
static Company * Get(auto index)
static bool IsValidID(auto index)
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.
CargoGRFFileProps grf_prop
Link to NewGRF.
RoadStopClassID sel_class
Selected road waypoint class.
uint16_t sel_type
Selected road waypoint type within the class.
static Pool::IterateWrapper< Station > Iterate(size_t from=0)
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.
Window(WindowDesc &desc)
Empty constructor, initialization has been moved to InitNested() called from the constructor of the d...
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.
StrongType::Typedef< uint32_t, struct TileIndexTag, StrongType::Compare, StrongType::Integer, StrongType::Compatible< int32_t >, StrongType::Compatible< int64_t > > TileIndex
The index/ID of a Tile.
constexpr TileIndex INVALID_TILE
The very nice invalid tile marker.
OrthogonalTileArea TileArea
Shorthand for the much more common orthogonal tile area.
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
HighLightStyle
Highlighting draw styles.
@ 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.
Point AlignInitialConstructionToolbar(int window_width)
Compute the position of the construction toolbars.
Window * FindWindowById(WindowClass cls, WindowNumber number)
Find a window by its class and window number.
void SetWindowDirty(WindowClass cls, WindowNumber number)
Mark window as dirty (in need of repainting).
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.
Twindow * AllocateWindowDescFront(WindowDesc &desc, WindowNumber window_number, Targs... extra_arguments)
Open a new window.
@ WDP_AUTO
Find a place automatically.
@ WDP_MANUAL
Manually align the window (so no automatic location finding).
EventState
State of handling an event.
@ ES_HANDLED
The passed event is handled.
@ ES_NOT_HANDLED
The passed event is not handled.
static constexpr WidgetID INVALID_WIDGET
An invalid widget index.
@ 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.