75static void ShowBuildTrainDepotPicker(
Window *parent);
76static void ShowBuildWaypointPicker(
Window *parent);
142 if (result.
Failed())
return;
186 if (result.
Failed())
return;
201 VpSetPlaceSizingLimit(-1);
216 auto proc = [=](
bool test, StationID to_join) ->
bool {
220 return Command<CMD_BUILD_RAIL_STATION>::Post(STR_ERROR_CAN_T_BUILD_RAILROAD_STATION, CcStation, tile, rt, params.
axis, numtracks, platlength, params.
sel_class, params.
sel_type, to_join, adjacent);
259 cycle_end = SIGTYPE_LAST;
262 if (cur_signal_on_tile <= SIGTYPE_LAST_NOPBS) {
265 cycle_end = SIGTYPE_LAST_NOPBS;
269 cycle_end = SIGTYPE_LAST;
276 tile, track,
_cur_signal_type,
_cur_signal_variant,
_convert_signal_button,
false,
_ctrl_pressed, cycle_start, cycle_end, 0, 0);
280 tile, track,
_settings_client.
gui.
default_signal_type, sigvar,
false,
false,
_ctrl_pressed, cycle_start, cycle_end, 0, 0);
365 VpSetPlaceSizingLimit(-1);
381static void DoRailroadTrack(
Track track)
392static void HandleAutodirPlacement()
401 DoRailroadTrack(trackstat);
429 TileVirtXY(_thd.
selstart.x, _thd.
selstart.y),
TileVirtXY(_thd.
selend.x, _thd.
selend.y), track, sigtype, sigvar,
false,
_ctrl_pressed, !
_settings_client.
gui.
drag_signals_fixed_distance,
_settings_client.
gui.
drag_signals_density);
446 this->last_user_action = INVALID_WID_RAT;
523 void UpdateRemoveWidgetStatus(
WidgetID clicked_widget)
525 switch (clicked_widget) {
575 this->last_user_action = widget;
580 this->last_user_action = widget;
585 this->last_user_action = widget;
590 this->last_user_action = widget;
595 this->last_user_action = widget;
600 this->last_user_action = widget;
605 ShowBuildTrainDepotPicker(
this);
606 this->last_user_action = widget;
611 this->last_user_action = widget;
613 ShowBuildWaypointPicker(
this);
620 this->last_user_action = widget;
625 this->last_user_action = widget;
635 this->last_user_action = widget;
640 this->last_user_action = widget;
649 this->last_user_action = widget;
652 default: NOT_REACHED();
654 this->UpdateRemoveWidgetStatus(widget);
666 switch (this->last_user_action) {
719 default: NOT_REACHED();
734 switch (select_proc) {
735 default: NOT_REACHED();
742 HandleAutodirPlacement();
765 HandleStationPlacement(start_tile, end_tile);
777 auto proc = [=](
bool test, StationID
to_join) ->
bool {
836 extern RailType _last_built_railtype;
842 static inline HotkeyList hotkeys{
"railtoolbar", {
860static constexpr NWidgetPart _nested_build_rail_widgets[] = {
905 _nested_build_rail_widgets,
906 &BuildRailToolbarWindow::hotkeys
935 uint numtracks = ta.w;
936 uint platlength = ta.h;
944 auto proc = [=](
bool test, StationID to_join) ->
bool {
948 return Command<CMD_BUILD_RAIL_STATION>::Post(STR_ERROR_CAN_T_BUILD_RAILROAD_STATION, CcStation, ta.tile, rt, params.
axis, numtracks, platlength, params.
sel_class, params.
sel_type, to_join, adjacent);
979 for (
const auto *spec : cls.Specs()) {
980 if (spec !=
nullptr)
return true;
996 const auto *sc = GetClass(
id);
1006 const auto *spec = this->GetSpec(cls_id,
id);
1007 return (spec ==
nullptr) ? STR_STATION_CLASS_DFLT_STATION : spec->name;
1015 void DrawType(
int x,
int y,
int cls_id,
int id)
const override
1024 bool default_added =
false;
1029 default_added =
true;
1031 for (
const auto &sm : st->speclist) {
1032 if (sm.spec ==
nullptr)
continue;
1033 items.insert({sm.grfid, sm.localidx, sm.spec->class_index, sm.spec->index});
1083 this->ConstructWindow();
1139 if (statspec ==
nullptr) {
1159 if (
top > r.bottom) {
1160 this->coverage_height +=
top - r.bottom;
1252 for (uint i = 0; i < 7; i++) {
1285 for (uint i = 0; i < 7; i++) {
1310 for (uint i = 0; i < 7; i++) {
1319 for (uint i = 0; i < 7; i++) {
1371 static inline HotkeyList hotkeys{
"buildrailstation", {
1376static constexpr NWidgetPart _nested_station_builder_widgets[] = {
1431 WDP_AUTO,
"build_station_rail", 0, 0,
1434 _nested_station_builder_widgets,
1435 &BuildRailStationWindow::hotkeys
1492 this->sig_sprite_size.width = 0;
1493 this->sig_sprite_size.height = 0;
1494 this->sig_sprite_bottom_offset = 0;
1496 for (uint type =
SIGTYPE_BLOCK; type < SIGTYPE_END; type++) {
1501 this->sig_sprite_bottom_offset = std::max<int>(this->sig_sprite_bottom_offset,
sprite_size.height);
1502 this->sig_sprite_size.width = std::max<int>(this->sig_sprite_size.width,
sprite_size.width - offset.x);
1503 this->sig_sprite_size.height = std::max<int>(this->sig_sprite_size.height,
sprite_size.height - offset.y);
1515 size.width = std::max(size.width,
this->sig_sprite_size.width + padding.width);
1516 size.height = std::max(size.height,
this->sig_sprite_size.height + padding.height);
1774static void ShowBuildTrainDepotPicker(
Window *parent)
1790 for (
const auto *spec : cls.Specs()) {
1791 if (spec !=
nullptr)
return true;
1808 const auto *sc = GetClass(
id);
1818 const auto *spec = this->GetSpec(cls_id,
id);
1819 return (spec ==
nullptr) ? STR_STATION_CLASS_WAYP_WAYPOINT : spec->name;
1827 void DrawType(
int x,
int y,
int cls_id,
int id)
const override
1834 bool default_added =
false;
1839 default_added =
true;
1841 for (
const auto &sm : wp->speclist) {
1842 if (sm.spec ==
nullptr)
continue;
1843 items.insert({sm.grfid, sm.localidx, sm.spec->class_index, sm.spec->index});
1855 this->ConstructWindow();
1859 static inline HotkeyList hotkeys{
"buildrailwaypoint", {
1883 &BuildRailWaypointWindow::hotkeys
1886static void ShowBuildWaypointPicker(
Window *parent)
1888 if (!WaypointPickerCallbacks::instance.IsActive())
return;
1910 extern RailType _last_built_railtype;
1924 extern RailType _last_built_railtype;
1930 memset(count, 0,
sizeof(count));
1939 if (count[rt] > 0)
break;
1946 std::vector<RailType>::const_iterator it = std::find_if(_sorted_railtypes.begin(), _sorted_railtypes.end(),
1947 [](
RailType r) { return HasRailTypeAvail(_local_company, r); });
1953 std::vector<RailType>::const_reverse_iterator it = std::find_if(_sorted_railtypes.rbegin(), _sorted_railtypes.rend(),
1954 [](
RailType r){ return HasRailTypeAvail(_local_company, r); });
2019 if (for_replacement) {
2030 list.push_back(MakeDropDownListStringItem(STR_REPLACE_ALL_RAILTYPE,
INVALID_RAILTYPE));
2035 if (!for_replacement) {
2036 for (
const auto &rt : _sorted_railtypes) {
2037 if (!
HasBit(used_railtypes, rt))
continue;
2043 for (
const auto &rt : _sorted_railtypes) {
2045 if (!
HasBit(used_railtypes, rt))
continue;
2051 if (for_replacement) {
2054 StringID str = rti->
max_speed > 0 ? STR_TOOLBAR_RAILTYPE_VELOCITY : STR_JUST_STRING;
2061 list.push_back(MakeDropDownListStringItem(STR_NONE,
INVALID_RAILTYPE,
true));
debug_inline constexpr bool HasBit(const T x, const uint8_t y)
Checks if a bit in a value is set.
debug_inline static constexpr uint GB(const T x, const uint8_t s, const uint8_t n)
Fetch n bits from x, started at bit s.
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?
An interval timer will fire every interval, and will continue to fire until it is deleted.
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.
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.
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.
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.
This struct contains all the info that is needed to draw and construct tracks.
uint16_t max_speed
Maximum speed for vehicles travelling on this rail type.
SpriteID build_tunnel
button for building a tunnel
CursorID rail_swne
Cursor for building rail in X direction.
SpriteID convert_rail
button for converting rail
CursorID convert
Cursor for converting track.
CursorID depot
Cursor for building a depot.
struct RailTypeInfo::@26 strings
Strings associated with the rail type.
CursorID rail_nwse
Cursor for building rail in Y direction.
SpriteID build_x_rail
button for building single rail in X direction
CursorID rail_ew
Cursor for building rail in E-W direction.
SpriteID auto_rail
button for the autorail construction
CursorID autorail
Cursor for autorail tool.
StringID menu_text
Name of this rail type in the main toolbar dropdown.
StringID toolbar_caption
Caption in the construction toolbar GUI for this rail type.
SpriteID signals[SIGTYPE_END][2][2]
signal GUI sprites (type, variant, state)
SpriteID build_ew_rail
button for building single rail in E-W direction
SpriteID build_y_rail
button for building single rail in Y direction
StringID replace_text
Text used in the autoreplace GUI.
SpriteID build_depot
button for building depots
struct RailTypeInfo::@24 gui_sprites
struct containing the sprites for the rail GUI.
SpriteID build_ns_rail
button for building single rail in N-S direction
CursorID rail_ns
Cursor for building rail in N-S direction.
SpriteID tunnel
tunnel sprites base
bool IsActive() const override
Should picker class/type selection be enabled?
bool HasClassChoice() const override
Are there multiple classes to chose from?
StringID GetTypeName(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 SetSelectedType(int id) const override
Set the selected type.
void DrawType(int x, int y, int cls_id, int id) const override
Draw preview image of an item.
StringID GetClassName(int id) const override
Get the name of a class.
StringID GetTypeTooltip() const override
Get the tooltip string for the type grid.
int GetSelectedClass() const override
Get the index of the selected class.
void SetSelectedClass(int id) const override
Set the selected class.
bool IsTypeAvailable(int cls_id, int id) const override
Test if an item is currently buildable.
int GetSelectedType() const override
Get the selected type.
void FillUsedItems(std::set< PickerItem > &items) override
Fill a set with all items that are used by the current player.
Wrapper class to abstract away the way the tiles are stored.
static Year year
Current year, starting at 0.
int GetSelectedType() const override
Get the selected type.
void SetSelectedClass(int id) const override
Set the selected class.
StringID GetTypeTooltip() const override
Get the tooltip string for the type grid.
void DrawType(int x, int y, int cls_id, int id) const override
Draw preview image of an item.
bool IsTypeAvailable(int cls_id, int id) const override
Test if an item is currently buildable.
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?
void SetSelectedType(int id) const override
Set the selected type.
StringID GetClassName(int id) const override
Get the name of a class.
StringID GetClassTooltip() const override
Get the tooltip string for the class list.
void FillUsedItems(std::set< PickerItem > &items) override
Fill a set with all items that are used by the current player.
bool HasClassChoice() const override
Are there multiple classes to chose from?
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.
@ COMPANY_SPECTATOR
The client is spectating.
bool IsValidAxis(Axis d)
Checks if an integer value is a valid Axis.
Axis
Allow incrementing of DiagDirDiff variables.
DiagDirection
Enumeration for diagonal directions.
@ DIAGDIR_NE
Northeast, upper right on your monitor.
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?
void DrawSprite(SpriteID img, PaletteID pal, int x, int y, const SubSprite *sub, ZoomLevel zoom)
Draw a sprite, not in a viewport.
uint8_t GetDigitWidth(FontSize size)
Return the maximum width of single digit.
bool FillDrawPixelInfo(DrawPixelInfo *n, int left, int top, int width, int height)
Set up a clipping area for only drawing into a certain area.
int CenterBounds(int min, int max, int size)
Determine where to draw a centred object inside a widget.
uint32_t SpriteID
The number of a sprite, without mapping bits and colourtables.
@ FS_NORMAL
Index of the normal font in the font tables.
@ WKC_GLOBAL_HOTKEY
Fake keycode bit to indicate global hotkeys.
void SetDirty() const
Mark entire window as dirty (in need of re-paint)
void MarkWholeScreenDirty()
This function mark the whole screen as dirty.
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.
TrackStatus GetTileTrackStatus(TileIndex tile, TransportType mode, uint sub_mode, DiagDirection side)
Returns information about trackdirs and signal states.
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.
constexpr void Swap(T &a, T &b)
Type safe swap operation.
void GuiShowTooltips(Window *parent, StringID str, TooltipCloseCondition close_tooltip, uint paramcount)
Shows a tooltip.
@ CBM_STATION_AVAIL
Availability of station in construction window.
@ CBID_STATION_AVAILABILITY
Determine whether a newstation should be made available to build.
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.
bool IsWaypointClass(const RoadStopClass &cls)
Test if a RoadStopClass is the waypoint class.
bool DrawStationTile(int x, int y, RailType railtype, Axis axis, StationClassID sclass, uint station)
Draw representation of a station tile for GUI purposes.
Header file for NewGRF stations.
@ STAT_CLASS_DFLT
Default station class.
@ STAT_CLASS_WAYP
Waypoint class.
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.
RailTypes GetCompanyRailTypes(CompanyID company, bool introduces)
Get the rail types the given company can build.
RailTypes GetRailTypes(bool introduces)
Get list of rail types, regardless of company availability.
bool ValParamRailType(const RailType rail)
Validate functions for rail building.
const RailTypeInfo * GetRailTypeInfo(RailType railtype)
Returns a pointer to the Railtype information for a given railtype.
Command definitions for rail.
Window * ShowBuildRailToolbar(RailType railtype)
Open the build rail toolbar window for a specific rail type.
static constexpr NWidgetPart _nested_signal_builder_widgets[]
Nested widget definition of the build signal window.
static bool RailToolbar_CtrlChanged(Window *w)
Updates the Remove button because of Ctrl state change.
void ResetSignalVariant(int32_t)
Updates the current signal variant used in the signal GUI to the one adequate to current year.
static void PlaceRail_Waypoint(TileIndex tile)
Place a rail waypoint.
static void SetDefaultRailGui()
Set the initial (default) railtype to use.
static RailType _cur_railtype
Rail type of the current build-rail toolbar.
static constexpr NWidgetPart _nested_build_waypoint_widgets[]
Nested widget definition for the build NewGRF rail waypoint window.
static constexpr NWidgetPart _nested_build_depot_widgets[]
Nested widget definition of the build rail depot window.
static void HandleAutoSignalPlacement()
Build new signals or remove signals or (if only one tile marked) edit a signal.
static SignalVariant _cur_signal_variant
set the signal variant (for signal GUI)
static void PlaceExtraDepotRail(TileIndex tile, DiagDirection dir, Track track)
Try to add an additional rail-track at the entrance of a depot.
static void PlaceRail_Bridge(TileIndex tile, Window *w)
Start placing a rail bridge.
static void PlaceRail_Station(TileIndex tile)
Place a rail station.
static StationPickerSelection _station_gui
Settings of the station picker.
static SignalType _cur_signal_type
set the signal type (for signal GUI)
static void ToggleRailButton_Remove(Window *w)
Toggles state of the Remove button of Build rail toolbar.
DropDownList GetRailTypeDropDownList(bool for_replacement, bool all_option)
Create a drop down list for all the rail types of the local company.
static void BuildRailClick_Remove(Window *w)
The "remove"-button click proc of the build-rail toolbar.
static bool IsStationAvailable(const StationSpec *statspec)
Check whether a station type can be build.
static Window * ShowStationBuilder(Window *parent)
Open station build window.
static bool StationUsesDefaultType(const BaseStation *bst)
Test if a station/waypoint uses the default graphics.
static WindowDesc _station_builder_desc(WDP_AUTO, "build_station_rail", 0, 0, WC_BUILD_STATION, WC_BUILD_TOOLBAR, WDF_CONSTRUCTION, _nested_station_builder_widgets, &BuildRailStationWindow::hotkeys)
High level window description of the station-build window (default & newGRF)
static const Track _place_depot_extra_track[12]
Additional pieces of track to add at the entrance of a depot.
static WindowDesc _signal_builder_desc(WDP_AUTO, nullptr, 0, 0, WC_BUILD_SIGNAL, WC_BUILD_TOOLBAR, WDF_CONSTRUCTION, _nested_signal_builder_widgets)
Signal selection window description.
static DiagDirection _build_depot_direction
Currently selected depot direction.
void InitializeRailGui()
Initialize rail building GUI settings.
static void ShowSignalBuilder(Window *parent)
Open the signal selection window.
static bool _remove_button_clicked
Flag whether 'remove' toggle-button is currently enabled.
void ReinitGuiAfterToggleElrail(bool disable)
Re-initialize rail-build toolbar after toggling support for electric trains.
static const DiagDirection _place_depot_extra_dir[12]
Direction to check for existing track pieces.
void InitializeRailGUI()
Resets the rail GUI - sets default railtype to build and resets the signal GUI.
static bool _convert_signal_button
convert signal button in the signal GUI pressed
static void GenericPlaceSignals(TileIndex tile)
Build a new signal or edit/remove a present signal, use CmdBuildSingleSignal() or CmdRemoveSingleSign...
static WaypointPickerSelection _waypoint_gui
Settings of the waypoint picker.
@ SIGNAL_GUI_ALL
Show all signals, including block and presignals.
@ SIGNAL_GUI_PATH
Show path signals only.
@ SIGNAL_CYCLE_ALL
Cycle through all signals visible to the player.
RailType GetRailType(Tile t)
Gets the rail type of the given tile.
static debug_inline RailTileType GetRailTileType(Tile t)
Returns the RailTileType (normal with or without signals, waypoint or depot).
TrackBits GetTrackBits(Tile tile)
Gets the track bits of the given tile.
static debug_inline bool IsRailDepotTile(Tile t)
Is this tile rail tile and a rail depot?
bool HasSignalOnTrack(Tile tile, Track track)
Checks for the presence of signals (either way) on the given track on the given rail tile.
@ RAIL_TILE_DEPOT
Depot (one entrance)
@ RAIL_TILE_SIGNALS
Normal rail tile with signals.
static debug_inline bool IsPlainRailTile(Tile t)
Checks whether the tile is a rail tile or rail tile with signals.
RailTypes
Allow incrementing of Track variables.
RailType
Enumeration for all possible railtypes.
@ RAILTYPE_BEGIN
Used for iterations.
@ RAILTYPE_END
Used for iterations.
@ INVALID_RAILTYPE
Flag for invalid railtype.
@ RAILTYPE_ELECTRIC
Electric rails.
@ RAILTYPE_RAIL
Standard non-electric rails.
bool IsLevelCrossingTile(Tile t)
Return whether a tile is a level crossing tile.
@ INVALID_ROADTYPE
flag for invalid roadtype
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.
SignalType
Type of signal, i.e.
@ SIGTYPE_PBS
normal pbs signal
@ SIGTYPE_BLOCK
block signal
SignalVariant
Variant of the signal, i.e.
@ SIG_SEMAPHORE
Old-fashioned semaphore signal.
@ SIG_ELECTRIC
Light signal.
Functions related to sound.
@ SND_15_BEEP
19 == 0x13 GUI button click
@ SND_20_CONSTRUCTION_RAIL
30 == 0x1E Construction: rail infrastructure
Functions to cache sprites in memory.
static const CursorID ANIMCURSOR_BUILDSIGNALS
1292 - 1293 - build signal
static const CursorID ANIMCURSOR_DEMOLISH
704 - 707 - demolish dynamite
Base classes/functions for stations.
Command definitions related to stations.
void ShowSelectStationIfNeeded(TileArea ta, StationPickerCmdProc proc)
Show the station selection window when needed.
void ShowSelectRailWaypointIfNeeded(TileArea ta, StationPickerCmdProc proc)
Show the rail waypoint 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)
Contains enums and function declarations connected with stations GUI.
@ SCT_ALL
Draw all cargoes.
Maps accessors for stations.
bool HasStationTileRail(Tile t)
Has this station tile a rail? In other words, is this station tile a rail station or rail waypoint?
uint GetCustomStationSpecIndex(Tile t)
Get the custom station spec for this tile.
bool HasStationRail(Tile t)
Has this station tile a rail? In other words, is this station tile a rail station or rail waypoint?
static constexpr uint CA_TRAIN
Catchment for train stations with "modified catchment" enabled.
static constexpr uint CA_UNMODIFIED
Catchment for all stations with "modified catchment" disabled.
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...
Base class for all station-ish types.
TileArea train_station
Tile area the train 'station' part covers.
virtual bool TileBelongsToRailStation(TileIndex tile) const =0
Check whether a specific tile belongs to this station.
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 OnClick(Point pt, WidgetID widget, int click_count) override
A click with the left mouse button has been made on the window.
void DrawWidget(const Rect &r, WidgetID widget) const override
Draw the contents of a nested widget.
void OnRealtimeTick(uint delta_ms) override
Called periodically.
void OnPaint() override
The window must be repainted.
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.
static EventState BuildRailStationGlobalHotkeys(int hotkey)
Handler for global hotkeys of the BuildRailStationWindow.
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.
uint coverage_height
Height of the coverage texts.
void CheckSelectedSize(const StationSpec *statspec)
Verify whether the currently selected station size is allowed after selecting a new station class/typ...
void OnInit() override
Notification that the nested widget tree gets initialized.
void OnInvalidateData(int data=0, bool gui_scope=true) override
Some data on this window has become invalid.
Dimension sig_sprite_size
Maximum size of signal GUI sprites.
void DrawSignalSprite(const Rect &r, SpriteID image) const
Draw dynamic a signal-sprite in a button in the signal GUI.
void SetSignalUIMode()
Show or hide buttons for non-path signals in the signal GUI.
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 OnInit() override
Notification that the nested widget tree gets initialized.
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.
int sig_sprite_bottom_offset
Maximum extent of signal GUI sprite from reference point towards bottom.
void Close(int data=0) override
Hide the window and all its child windows, and mark them for a later deletion.
void SetStringParameters(WidgetID widget) const override
Initialize string parameters for a widget.
void OnClick(Point pt, WidgetID widget, int click_count) override
A click with the left mouse button has been made on the window.
SoundSettings sound
sound effect settings
GUISettings gui
settings related to the GUI
RailTypes avail_railtypes
Rail 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
SignalCycleSettings cycle_signal_types
Which signal types to cycle with the build signal tool.
uint8_t station_platlength
the platform length, in tiles, for rail stations
bool auto_remove_signals
automatically remove signals when in the way during rail construction
bool station_dragdrop
whether drag and drop is enabled for stations
bool station_show_coverage
whether to highlight coverage area
uint8_t default_rail_type
the default rail type for the rail GUI
uint8_t drag_signals_density
many signals density
uint8_t station_numtracks
the number of platforms to default on for rail stations
TimerGameCalendar::Year semaphore_build_before
build semaphore signals automatically before this year
SignalGUISettings signal_gui_mode
select which signal types are shown in the signal GUI
bool drag_signals_fixed_distance
keep fixed distance between signals when dragging
SignalType default_signal_type
The default signal type, which is set automatically by the last signal used. Not available in Setting...
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.
static IterateWrapper Iterate()
Returns an iterable ensemble of all Tiles.
Represents the covered area of e.g.
Coordinates of a point in 2D.
Tindex index
Index of this pool item.
static bool IsValidID(size_t index)
Tests whether given index can be used to get valid (non-nullptr) Titem.
static Titem * Get(size_t index)
Returns Titem with given index.
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.
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.
StationClassID sel_class
Selected station class.
uint16_t sel_type
Selected station type within the class.
Axis axis
Selected orientation of the station.
uint8_t station_spread
amount a station may spread
bool modified_catchment
different-size catchment areas
uint8_t callback_mask
Bitmask of station callbacks that have to be called.
uint8_t disallowed_lengths
Bitmask of platform lengths available for the station.
uint8_t disallowed_platforms
Bitmask of number of platforms available for the station.
GRFFilePropsBase< NUM_CARGO+3 > grf_prop
Properties related the the grf file.
Point selstart
The location where the dragging started.
HighLightStyle drawstyle
Lower bits 0-3 are reserved for detailed highlight information.
Point pos
Location, in tile "units", of the northern tile of the selected area.
Point selend
The location where the drag currently ends.
StationClassID sel_class
Selected station class.
uint16_t sel_type
Selected station type within the class.
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 CreateNestedTree()
Perform the first part of the initialization of a nested widget tree.
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?
int top
y position of top edge of the window
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.
void InitNested(WindowNumber number=0)
Perform complete initialization of the Window with nested widgets, to allow use.
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.
virtual void OnInit()
Notification that the nested widget tree gets initialized.
void ToggleWidgetLoweredState(WidgetID widget_index)
Invert the lowered/raised status of a widget.
bool IsValidTile(Tile tile)
Checks if a tile is valid.
static debug_inline bool IsTileType(Tile tile, TileType type)
Checks if a tile is a given tiletype.
constexpr TileIndex INVALID_TILE
The very nice invalid tile marker.
@ MP_TUNNELBRIDGE
Tunnel entry/exit and bridge heads.
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
@ HT_LINE
used for autorail highlighting (longer stretches), lower bits: direction
@ HT_DIR_HL
horizontal lower
@ HT_DIAGONAL
Also allow 'diagonal rectangles'. Only usable in combination with HT_RECT or HT_POINT.
@ HT_RECT
rectangle (stations, depots, ...)
@ HT_DIR_MASK
masks the drag-direction
@ HT_RAIL
autorail (one piece), lower bits: direction
@ HT_DRAG_MASK
Mask for the tile drag-type modes.
@ 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.
bool IsValidTrack(Track track)
Checks if a Track is valid.
Track FindFirstTrack(TrackBits tracks)
Returns first Track from TrackBits or INVALID_TRACK.
TrackBits DiagdirReachesTracks(DiagDirection diagdir)
Returns all tracks that can be reached when entering a tile from a given (diagonal) direction.
TrackBits TrackStatusToTrackBits(TrackStatus ts)
Returns the present-track-information of a TrackStatus.
TrackBits
Allow incrementing of Track variables.
@ TRACK_BIT_UPPER
Upper track.
@ TRACK_BIT_LEFT
Left track.
@ TRACK_BIT_HORZ
Upper and lower track.
@ TRACK_BIT_LOWER
Lower track.
@ TRACK_BIT_RIGHT
Right track.
@ TRACK_BIT_VERT
Left and right track.
Track
These are used to specify a single track.
@ TRACK_Y
Track along the y-axis (north-west to south-east)
@ TRACK_LOWER
Track in the lower corner of the tile (south)
@ TRACK_LEFT
Track in the left corner of the tile (west)
@ TRACK_RIGHT
Track in the right corner of the tile (east)
@ TRACK_X
Track along the x-axis (north-east to south-west)
@ TRACK_UPPER
Track in the upper corner of the tile (north)
@ TRANSPORT_RAIL
Transport by train.
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.
TransportType GetTunnelBridgeTransportType(Tile t)
Tunnel: Get the transport type of the tunnel (road or rail) Bridge: Get the transport type of the bri...
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_TRAIN
Train vehicle type.
void SetTileSelectSize(int w, int h)
Highlight w by h tiles at the cursor.
void SetViewportCatchmentWaypoint(const Waypoint *wp, bool sel)
Select or deselect waypoint for coverage area highlight.
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_CONVERT_RAIL
Rail conversion.
@ DDSP_DEMOLISH_AREA
Clear area.
@ DDSP_BUILD_SIGNALS
Signal placement.
@ DDSP_REMOVE_STATION
Station removal.
@ DDSP_BUILD_STATION
Station placement.
@ DDSP_BUILD_BRIDGE
Bridge placement.
@ DDSP_PLACE_RAIL
Rail placement.
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_FIX_VERTICAL
drag only in vertical direction
@ 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_HORIZONTAL
drag only in horizontal direction
@ VPM_FIX_X
drag only in X axis
@ VPM_SIGNALDIRS
similar to VMP_RAILDIRS, but with different cursor
@ VPM_X_OR_Y
drag in X or Y direction
@ VPM_RAILDIRS
all rail directions
void DrawWaypointSprite(int x, int y, StationClassID station_class, uint16_t station_type, RailType railtype)
Draw a waypoint.
@ WPF_ROAD
This is a road waypoint.
Axis GetAxisForNewRailWaypoint(TileIndex tile)
Get the axis for a new rail 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.
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.
@ 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.
@ WN_GAME_OPTIONS_GAME_SETTINGS
Game settings.
EventState
State of handling an event.
@ ES_HANDLED
The passed event is handled.
@ ES_NOT_HANDLED
The passed event is not handled.
@ WC_BUILD_STATION
Build station; 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_SIGNAL
Build signal toolbar; Window numbers:
@ WC_BUILD_DEPOT
Build depot; Window numbers:
@ WC_GAME_OPTIONS
Game options window; 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.