68 static void ShowBuildTrainDepotPicker(
Window *parent);
69 static void ShowBuildWaypointPicker(
Window *parent);
87 void CcPlaySound_SPLAT_RAIL(
const CommandCost &result,
TileIndex tile, uint32 p1, uint32 p2, uint32 cmd)
92 static void GenericPlaceRail(
TileIndex tile,
int cmd)
98 CcPlaySound_SPLAT_RAIL);
132 if (result.
Failed())
return;
173 if (result.
Failed())
return;
188 VpSetPlaceSizingLimit(-1);
252 CcPlaySound_SPLAT_RAIL);
335 VpSetPlaceSizingLimit(-1);
351 static void DoRailroadTrack(
int mode)
357 CcPlaySound_SPLAT_RAIL);
360 static void HandleAutodirPlacement()
369 DoRailroadTrack(trackstat);
412 CcPlaySound_SPLAT_RAIL);
424 this->SetupRailToolbar(railtype);
444 if (!gui_scope)
return;
455 this->railtype = railtype;
475 this->SetupRailToolbar(railtype);
479 void UpdateRemoveWidgetStatus(
int clicked_widget)
481 switch (clicked_widget) {
497 this->SetWidgetDisabledState(
WID_RAT_REMOVE, !this->IsWidgetLowered(clicked_widget));
514 SetDParam(0, STR_TOOLBAR_RAILTYPE_VELOCITY);
531 this->last_user_action = widget;
536 this->last_user_action = widget;
541 this->last_user_action = widget;
546 this->last_user_action = widget;
551 this->last_user_action = widget;
556 this->last_user_action = widget;
561 ShowBuildTrainDepotPicker(
this);
562 this->last_user_action = widget;
567 this->last_user_action = widget;
570 ShowBuildWaypointPicker(
this);
577 this->last_user_action = widget;
582 this->last_user_action = widget;
592 this->last_user_action = widget;
597 this->last_user_action = widget;
606 this->last_user_action = widget;
609 default: NOT_REACHED();
611 this->UpdateRemoveWidgetStatus(widget);
623 switch (this->last_user_action) {
678 default: NOT_REACHED();
693 switch (select_proc) {
694 default: NOT_REACHED();
701 HandleAutodirPlacement();
723 HandleStationPlacement(start_tile, end_tile);
747 this->RaiseButtons();
783 extern RailType _last_built_railtype;
791 static Hotkey railtoolbar_hotkeys[] = {
810 static const NWidgetPart _nested_build_rail_widgets[] = {
855 _nested_build_rail_widgets,
lengthof(_nested_build_rail_widgets),
856 &BuildRailToolbarWindow::hotkeys
885 uint numtracks = ta.
w;
886 uint platlength = ta.
h;
941 this->vscroll =
nullptr;
944 this->CreateNestedTree();
969 if (!newstation || _railstation.
station_class >= (
int)StationClass::GetClassCount()) {
974 this->vscroll2 =
nullptr;
981 for (uint i = 0; i < StationClass::GetClassCount(); i++) {
1020 for (uint bits = 0; bits < 7; bits++) {
1022 if (statspec ==
nullptr) {
1031 this->DrawWidgets();
1033 if (this->IsShaded())
return;
1046 this->coverage_height += top - bottom;
1056 for (uint i = 0; i < StationClass::GetClassCount(); i++) {
1060 size->width =
max(size->width, d.width + padding.width);
1062 size->height = 5 * this->line_height;
1063 resize->height = this->line_height;
1076 StringID str = this->GetWidget<NWidgetCore>(widget)->widget_data;
1081 const StationSpec *statspec = stclass->GetSpec(j);
1082 SetDParam(0, (statspec !=
nullptr && statspec->
name != 0) ? statspec->
name : STR_STATION_CLASS_DFLT);
1086 size->width =
max(size->width, d.width + padding.width);
1098 size->height = this->coverage_height;
1112 switch (
GB(widget, 0, 16)) {
1115 if (
FillDrawPixelInfo(&tmp_dpi, r.left, r.top, r.right - r.left + 1, r.bottom - r.top + 1)) {
1117 _cur_dpi = &tmp_dpi;
1129 if (
FillDrawPixelInfo(&tmp_dpi, r.left, r.top, r.right - r.left + 1, r.bottom - r.top + 1)) {
1131 _cur_dpi = &tmp_dpi;
1144 for (uint i = 0; i < StationClass::GetClassCount(); i++) {
1146 if (this->vscroll->
IsVisible(statclass)) {
1158 byte type =
GB(widget, 16, 16);
1167 if (
FillDrawPixelInfo(&tmp_dpi, r.left, r.top, r.right - r.left + 1, r.bottom - r.top + 1)) {
1169 _cur_dpi = &tmp_dpi;
1184 if (this->vscroll !=
nullptr) {
1193 SetDParam(0, (statspec !=
nullptr && statspec->
name != 0) ? statspec->
name : STR_STATION_CLASS_DFLT);
1199 switch (
GB(widget, 0, 16)) {
1228 for (uint i = 0; i < 7; i++) {
1263 for (uint i = 0; i < 7; i++) {
1288 for (uint i = 0; i < 7; i++) {
1297 for (uint i = 0; i < 7; i++) {
1326 if (y >= (
int)StationClass::GetClassCount())
return;
1327 for (uint i = 0; i < StationClass::GetClassCount(); i++) {
1336 this->CheckSelectedSize(stclass->GetSpec(_railstation.
station_type));
1353 int y =
GB(widget, 16, 16);
1362 this->CheckSelectedSize(statspec);
1379 static const NWidgetPart _nested_station_builder_widgets[] = {
1398 NWidget(
WWT_LABEL, COLOUR_DARK_GREEN),
SetMinimalSize(144, 11),
SetDataTip(STR_STATION_BUILD_ORIENTATION, STR_NULL),
SetPadding(1, 2, 0, 2),
1401 NWidget(
WWT_PANEL, COLOUR_GREY,
WID_BRAS_PLATFORM_DIR_X),
SetMinimalSize(66, 60),
SetFill(0, 0),
SetDataTip(0x0, STR_STATION_BUILD_RAILROAD_ORIENTATION_TOOLTIP),
EndContainer(),
1403 NWidget(
WWT_PANEL, COLOUR_GREY,
WID_BRAS_PLATFORM_DIR_Y),
SetMinimalSize(66, 60),
SetFill(0, 0),
SetDataTip(0x0, STR_STATION_BUILD_RAILROAD_ORIENTATION_TOOLTIP),
EndContainer(),
1406 NWidget(
WWT_LABEL, COLOUR_DARK_GREEN,
WID_BRAS_SHOW_NEWST_TYPE),
SetMinimalSize(144, 11),
SetDataTip(STR_ORANGE_STRING, STR_NULL),
SetPadding(1, 2, 4, 2),
1407 NWidget(
WWT_LABEL, COLOUR_DARK_GREEN),
SetMinimalSize(144, 11),
SetDataTip(STR_STATION_BUILD_NUMBER_OF_TRACKS, STR_NULL),
SetPadding(0, 2, 0, 2),
1419 NWidget(
WWT_LABEL, COLOUR_DARK_GREEN),
SetMinimalSize(144, 11),
SetDataTip(STR_STATION_BUILD_PLATFORM_LENGTH, STR_NULL),
SetPadding(2, 2, 0, 2),
1437 NWidget(
WWT_LABEL, COLOUR_DARK_GREEN),
SetMinimalSize(144, 11),
SetDataTip(STR_STATION_BUILD_COVERAGE_AREA_TITLE, STR_NULL),
SetPadding(3, 2, 0, 2),
1441 SetDataTip(STR_STATION_BUILD_COVERAGE_OFF, STR_STATION_BUILD_COVERAGE_AREA_OFF_TOOLTIP),
1443 SetDataTip(STR_STATION_BUILD_COVERAGE_ON, STR_STATION_BUILD_COVERAGE_AREA_ON_TOOLTIP),
1451 NWidget(
NWID_MATRIX, COLOUR_DARK_GREEN,
WID_BRAS_MATRIX),
SetScrollbar(
WID_BRAS_MATRIX_SCROLL),
SetPIP(0, 2, 0),
SetPadding(2, 0, 0, 0),
1475 WDP_AUTO,
"build_station_rail", 350, 0,
1478 _nested_station_builder_widgets,
lengthof(_nested_station_builder_widgets)
1504 const NWidgetBase *widget = this->GetWidget<NWidgetBase>(widget_index);
1505 int x = widget->
pos_x - offset.x +
1506 (widget->
current_x - sprite_size.width + offset.x) / 2;
1511 x + this->IsWidgetLowered(widget_index),
1512 y + this->IsWidgetLowered(widget_index));
1519 this->OnInvalidateData();
1530 this->sig_sprite_size.width = 0;
1531 this->sig_sprite_size.height = 0;
1532 this->sig_sprite_bottom_offset = 0;
1536 for (uint lowered = 0; lowered < 2; lowered++) {
1539 this->sig_sprite_bottom_offset = max<int>(this->sig_sprite_bottom_offset, sprite_size.height);
1540 this->sig_sprite_size.width = max<int>(this->sig_sprite_size.width, sprite_size.width - offset.x);
1541 this->sig_sprite_size.height = max<int>(this->sig_sprite_size.height, sprite_size.height - offset.y);
1575 this->DrawSignalSprite(widget, sprite);
1628 this->InvalidateData();
1638 if (!gui_scope)
return;
1690 _nested_signal_builder_widgets,
lengthof(_nested_signal_builder_widgets)
1775 _nested_build_depot_widgets,
lengthof(_nested_build_depot_widgets)
1778 static void ShowBuildTrainDepotPicker(
Window *parent)
1786 this->CreateNestedTree();
1802 size->width += resize->width * 2;
1803 size->height += resize->height * 2;
1818 switch (
GB(widget, 0, 16)) {
1820 byte type =
GB(widget, 16, 16);
1833 switch (
GB(widget, 0, 16)) {
1835 byte type =
GB(widget, 16, 16);
1874 _nested_build_waypoint_widgets,
lengthof(_nested_build_waypoint_widgets)
1877 static void ShowBuildWaypointPicker(
Window *parent)
1896 extern RailType _last_built_railtype;
1910 extern RailType _last_built_railtype;
1916 memset(count, 0,
sizeof(count));
1925 if (count[rt] > 0)
break;
1932 std::vector<RailType>::const_iterator it = std::find_if(_sorted_railtypes.begin(), _sorted_railtypes.end(),
1939 std::vector<RailType>::const_reverse_iterator it = std::find_if(_sorted_railtypes.rbegin(), _sorted_railtypes.rend(),
2002 if (for_replacement) {
2019 if (!for_replacement) {
2021 if (!
HasBit(used_railtypes, rt))
continue;
2029 if (!
HasBit(used_railtypes, rt))
continue;
2035 if (for_replacement) {
2039 iconitem->SetDimension(d);
2044 list.emplace_back(item);
2047 if (list.size() == 0) {
EventState
State of handling an event.
Functions related to OTTD's strings.
Window * ShowBuildRailToolbar(RailType railtype)
Open the build rail toolbar window for a specific rail type.
ViewportDragDropSelectionProcess
Drag and drop selection process, or, what to do with an area of land when you've selected it...
static void ShowSignalBuilder(Window *parent)
Open the signal selection window.
don't allow building on structures
void UpdateWidgetSize(int widget, Dimension *size, const Dimension &padding, Dimension *fill, Dimension *resize) override
Update size and resize step of a widget in the window.
static void Swap(T &a, T &b)
Type safe swap operation.
GameSettings _settings_game
Game settings of a running game or the scenario editor.
Definition of stuff that is very close to a company, like the company struct itself.
#define FOR_ALL_SORTED_RAILTYPES(var)
Loop header for iterating over railtypes, sorted by sortorder.
static const NWidgetPart _nested_signal_builder_widgets[]
Nested widget definition of the build signal window.
void UpdateWidgetSize(int widget, Dimension *size, const Dimension &padding, Dimension *fill, Dimension *resize) override
Update size and resize step of a widget in the window.
static const RailtypeInfo * GetRailTypeInfo(RailType railtype)
Returns a pointer to the Railtype information for a given railtype.
Select station (when joining stations); Window numbers:
static const uint CALLBACK_FAILED
Different values for Callback result evaluations.
static TransportType GetTunnelBridgeTransportType(TileIndex t)
Tunnel: Get the transport type of the tunnel (road or rail) Bridge: Get the transport type of the bri...
Data about how and where to blit pixels.
void DrawSignalSprite(byte widget_index, SpriteID image) const
Draw dynamic a signal-sprite in a button in the signal GUI Draw the sprite +1px to the right and down...
bool link_terraform_toolbar
display terraform toolbar when displaying rail, road, water and airport toolbars
virtual EventState OnHotkey(int hotkey)
A hotkey has been pressed.
void GfxFillRect(int left, int top, int right, int bottom, int colour, FillRectMode mode)
Applies a certain FillRectMode-operation to a rectangle [left, right] x [top, bottom] on the screen...
void CheckRedrawStationCoverage(const Window *w)
Check whether we need to redraw the station coverage text.
Point pos
Location, in tile "units", of the northern tile of the selected area.
Offset at right of a matrix cell.
static void GenericPlaceSignals(TileIndex tile)
Build a new signal or edit/remove a present signal, use CmdBuildSingleSignal() or CmdRemoveSingleSign...
void SetWindowDirty(WindowClass cls, WindowNumber number)
Mark window as dirty (in need of repainting)
SignalType
Type of signal, i.e.
SpriteID auto_rail
button for the autorail construction
bool enable_signal_gui
show the signal GUI when the signal button is pressed
area of land of limited size
Maps accessors for stations.
Track along the x-axis (north-east to south-west)
All data for a single hotkey.
High level window description.
StringID toolbar_caption
Caption in the construction toolbar GUI for this rail type.
static const CursorID ANIMCURSOR_DEMOLISH
704 - 707 - demolish dynamite
Track in the lower corner of the tile (south)
Landscape generation (in Scenario Editor); Window numbers:
static void PlaceRail_Bridge(TileIndex tile, Window *w)
Start placing a rail bridge.
bool DrawStationTile(int x, int y, RailType railtype, Axis axis, StationClassID sclass, uint station)
Draw representation of a station tile for GUI purposes.
bool station_show_coverage
whether to highlight coverage area
static Titem * Get(size_t index)
Returns Titem with given index.
static bool IsBridgeTile(TileIndex t)
checks if there is a bridge on this tile
Hotkey related functions.
void OnRealtimeTick(uint delta_ms) override
Called periodically.
Functions related to dates.
SpriteID build_y_rail
button for building single rail in Y direction
uint GetSpecCount() const
Get the number of allocated specs within the class.
int sig_sprite_bottom_offset
Maximum extent of signal GUI sprite from reference point towards bottom.
void ShowSelectStationIfNeeded(const CommandContainer &cmd, TileArea ta)
Show the station selection window when needed.
Contains enums and function declarations connected with stations GUI.
uint8 default_rail_type
the default rail type for the rail GUI
void SetWidgetDirty(byte widget_index) const
Invalidate a widget, i.e.
Normal amount of vertical space between two paragraphs of text.
remove signals along a track (by dragging)
Window * FindWindowById(WindowClass cls, WindowNumber number)
Find a window by its class and window number.
byte station_type
Station type within the currently selected custom station class (if newstations is true ) ...
The passed event is not handled.
void DrawWidget(const Rect &r, int widget) const override
Draw the contents of a nested widget.
void SetTileSelectSize(int w, int h)
Highlight w by h tiles at the cursor.
void CheckSelectedSize(const StationSpec *statspec)
Verify whether the currently selected station size is allowed after selecting a new station class/typ...
static const CursorID ANIMCURSOR_BUILDSIGNALS
1292 - 1293 - build signal
static int ScaleGUITrad(int value)
Scale traditional pixel dimensions to GUI zoom level.
Drag only in X axis with limited size.
Flag for invalid railtype.
void DrawWidget(const Rect &r, int widget) const override
Draw the contents of a nested widget.
similar to VMP_RAILDIRS, but with different cursor
void SetStringParameters(int widget) const override
Initialize string parameters for a widget.
void OnInvalidateData(int data=0, bool gui_scope=true) override
Some data on this window has become invalid.
bool ValParamRailtype(const RailType rail)
Validate functions for rail building.
byte drag_signals_density
many signals density
Drag only in Y axis with limited size.
Functions related to vehicles.
byte station_spread
amount a station may spread
Build depot; Window numbers:
void ToggleWidgetLoweredState(byte widget_index)
Invert the lowered/raised status of a widget.
add signals along a track (by dragging)
Tindex index
Index of this pool item.
static bool IsStationAvailable(const StationSpec *statspec)
Check whether a station type can be build.
flag for invalid roadtype
static void ShowStationBuilder(Window *parent)
Open station build window.
Offset at top of a matrix cell.
void VpSetPresizeRange(TileIndex from, TileIndex to)
Highlights all tiles between a set of two tiles.
void ShowSelectWaypointIfNeeded(const CommandContainer &cmd, TileArea ta)
Show the waypoint selection window when needed.
static bool RailToolbar_CtrlChanged(Window *w)
Updates the Remove button because of Ctrl state change.
byte GetDigitWidth(FontSize size)
Return the maximum width of single digit.
bool persistent_buildingtools
keep the building tools active after usage
Common return value for all commands.
DropDownList GetRailTypeDropDownList(bool for_replacement, bool all_option)
Create a drop down list for all the rail types of the local company.
CursorID autorail
Cursor for autorail tool.
static T max(const T a, const T b)
Returns the maximum of two values.
void RaiseWidget(byte widget_index)
Marks a widget as raised.
Year _cur_year
Current year, starting at 0.
struct RailtypeInfo::@39 strings
Strings associated with the rail type.
void OnClick(Point pt, int widget, int click_count) override
A click with the left mouse button has been made on the window.
uint16 w
The width of the area.
Dimension sig_sprite_size
Maximum size of signal GUI sprites.
Determine whether a newstation should be made available to build.
StringID menu_text
Name of this rail type in the main toolbar dropdown.
StationSettings station
settings related to station management
static T SB(T &x, const uint8 s, const uint8 n, const U d)
Set n bits in x starting at bit s to d.
CursorID rail_ew
Cursor for building rail in E-W direction.
Functions, definitions and such used only by the GUI.
bool FillDrawPixelInfo(DrawPixelInfo *n, int left, int top, int width, int height)
Set up a clipping area for only drawing into a certain area.
This struct contains all the info that is needed to draw and construct tracks.
bool newstations
Are custom station definitions available?
Functions related to (drawing on) viewports.
static SignalType _cur_signal_type
set the signal type (for signal GUI)
static void BuildRailClick_Remove(Window *w)
The "remove"-button click proc of the build-rail toolbar.
SpriteID signals[SIGTYPE_END][2][2]
signal GUI sprites (type, variant, state)
Data structure for an opened window.
bool _ctrl_pressed
Is Ctrl pressed?
Track in the right corner of the tile (east)
build a single rail track
static bool IsInsideMM(const T x, const size_t min, const size_t max)
Checks if a value is in an interval.
Bottom offset of image in the button.
Point selstart
The location where the dragging started.
std::vector< std::unique_ptr< const DropDownListItem > > DropDownList
A drop down list is a collection of drop down list items.
Struct containing information relating to NewGRF classes for stations and airports.
Point selend
The location where the drag currently ends.
static TileIndexDiff TileOffsByDiagDir(DiagDirection dir)
Convert a DiagDirection to a TileIndexDiff.
OrthogonalTileArea TileArea
Shorthand for the much more common orthogonal tile area.
Axis GetAxisForNewWaypoint(TileIndex tile)
Get the axis for a new waypoint.
static bool IsTileType(TileIndex tile, TileType type)
Checks if a tile is a given tiletype.
static const NWidgetPart _nested_build_depot_widgets[]
Nested widget definition of the build rail depot window.
Offset at bottom of a matrix cell.
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)
CommandCost DoCommand(const CommandContainer *container, DoCommandFlag flags)
Shorthand for calling the long DoCommand with a container.
void DrawWidget(const Rect &r, int widget) const override
Draw the contents of a nested widget.
This window is used for construction; close it whenever changing company.
The client is spectating.
bool IsWidgetLowered(byte widget_index) const
Gets the lowered state of a widget.
List item with icon and string.
SoundSettings sound
sound effect settings
Header file for things common for tunnels and bridges.
static WindowDesc _station_builder_desc(WDP_AUTO, "build_station_rail", 350, 0, WC_BUILD_STATION, WC_BUILD_TOOLBAR, WDF_CONSTRUCTION, _nested_station_builder_widgets, lengthof(_nested_station_builder_widgets))
High level window description of the station-build window (default & newGRF)
void SetRedErrorSquare(TileIndex tile)
Set a tile to display a red error square.
void ReinitGuiAfterToggleElrail(bool disable)
Re-initialize rail-build toolbar after toggling support for electric trains.
ViewportPlaceMethod
Viewport place method (type of highlighted area and placed objects)
Structure for buffering the build command when selecting a station to join.
#define FONT_HEIGHT_NORMAL
Height of characters in the normal (FS_NORMAL) font.
GRFFilePropsBase< NUM_CARGO+3 > grf_prop
Properties related the the grf file.
ClientSettings _settings_client
The current settings for this game.
Standard non-electric rails.
bool Succeeded() const
Did this command succeed?
static bool HasStationTileRail(TileIndex t)
Has this station tile a rail? In other words, is this station tile a rail station or rail waypoint...
Definition of base types and functions in a cross-platform compatible way.
Build waypoint; Window numbers:
A number of safeguards to prevent using unsafe methods.
SpriteID build_ns_rail
button for building single rail in N-S direction
uint8 default_signal_type
the signal type to build by default.
List of hotkeys for a window.
uint line_height
Height of a single line in the newstation selection matrix (WID_BRAS_NEWST_LIST widget).
static void ToggleRailButton_Remove(Window *w)
Toggles state of the Remove button of Build rail toolbar.
RailTypes GetRailTypes(bool introduces)
Get list of rail types, regardless of company availability.
rectangle (stations, depots, ...)
bool ResetSignalVariant(int32 p)
Updates the current signal variant used in the signal GUI to the one adequate to current year...
Year semaphore_build_before
build semaphore signals automatically before this year
static EventState RailToolbarGlobalHotkeys(int hotkey)
Handler for global hotkeys of the BuildRailToolbarWindow.
bool IsWidgetDisabled(byte widget_index) const
Gets the enabled/disabled status of a widget.
static void PlaceRail_Station(TileIndex tile)
Place a rail station.
Represents the covered area of e.g.
static const NWidgetPart _nested_build_waypoint_widgets[]
Nested widget definition for the build NewGRF rail waypoint window.
Offset at left of a matrix cell.
HighLightStyle drawstyle
Lower bits 0-3 are reserved for detailed highlight information.
TrackBits
Bitfield corresponding to Track.
void SetViewportCatchmentStation(const Station *st, bool sel)
Select or deselect station for coverage area highlight.
uint16 max_speed
Maximum speed for vehicles travelling on this rail type.
CursorID rail_nwse
Cursor for building rail in Y direction.
void MarkTileDirtyByTile(TileIndex tile, int bridge_level_offset, int tile_height_override)
Mark a tile given by its index dirty for repaint.
TileIndex _build_tunnel_endtile
The end of a tunnel; as hidden return from the tunnel build command for GUI purposes.
int DrawString(int left, int right, int top, const char *str, TextColour colour, StringAlignment align, bool underline, FontSize fontsize)
Draw string, possibly truncated to make it fit in its allocated space.
byte station_numtracks
the number of platforms to default on for rail stations
Build station; Window numbers:
SpriteID convert_rail
button for converting rail
bool DoCommandP(const CommandContainer *container, bool my_cmd)
Shortcut for the long DoCommandP when having a container with the data.
autorail (one piece), lower bits: direction
void CcBuildRailTunnel(const CommandCost &result, TileIndex tile, uint32 p1, uint32 p2, uint32 cmd)
Command callback for building a tunnel.
void VpStartPlaceSizing(TileIndex tile, ViewportPlaceMethod method, ViewportDragDropSelectionProcess process)
highlighting tiles while only going over them with the mouse
Catchment for all stations with "modified catchment" disabled.
#define lengthof(x)
Return the length of an fixed size array.
void ShowBuildBridgeWindow(TileIndex start, TileIndex end, TransportType transport_type, byte road_rail_type)
Prepare the data for the build a bridge window.
Build bridge; Window numbers:
static T min(const T a, const T b)
Returns the minimum of two values.
Right offset of the image in the button.
RailTypes
The different railtypes we support, but then a bitmask of them.
static WindowDesc _signal_builder_desc(WDP_AUTO, "build_signal", 0, 0, WC_BUILD_SIGNAL, WC_BUILD_TOOLBAR, WDF_CONSTRUCTION, _nested_signal_builder_widgets, lengthof(_nested_signal_builder_widgets))
Signal selection window description.
Types related to the drop down widget.
Also allow 'diagonal rectangles'. Only usable in combination with HT_RECT or HT_POINT.
Functions related to sound.
bool Convert8bitBooleanCallback(const GRFFile *grffile, uint16 cbid, uint16 cb_res)
Converts a callback result into a boolean.
Functions to cache sprites in memory.
uint32 StringID
Numeric value that represents a string, independent of the selected language.
static SignalVariant _cur_signal_variant
set the signal variant (for signal GUI)
void DeleteWindowByClass(WindowClass cls)
Delete all windows of a given class.
bool Failed() const
Did this command fail?
drag only in horizontal direction
static const uint8 PC_BLACK
Black palette colour.
static void PlaceRail_Waypoint(TileIndex tile)
Place a rail waypoint.
void OnPaint() override
The window must be repainted.
void VpSelectTilesWithMethod(int x, int y, ViewportPlaceMethod method)
Selects tiles while dragging.
static bool _convert_signal_button
convert signal button in the signal GUI pressed
bool CanBuildVehicleInfrastructure(VehicleType type, byte subtype)
Check whether we can build infrastructure for the given vehicle type.
static void PlaceExtraDepotRail(TileIndex tile, DiagDirection dir, Track track)
Try to add an additional rail-track at the entrance of a depot.
TrackStatus GetTileTrackStatus(TileIndex tile, TransportType mode, uint sub_mode, DiagDirection side)
Returns information about trackdirs and signal states.
byte station_platlength
the platform length, in tiles, for rail stations
static T Clamp(const T a, const T min, const T max)
Clamp a value between an interval.
bool drag_signals_fixed_distance
keep fixed distance between signals when dragging
StringID replace_text
Text used in the autoreplace GUI.
void SetDirty() const
Mark entire window as dirty (in need of re-paint)
Build toolbar; Window numbers:
SpriteID build_depot
button for building depots
static TrackBits DiagdirReachesTracks(DiagDirection diagdir)
Returns all tracks that can be reached when entering a tile from a given (diagonal) direction...
CursorID depot
Cursor for building a depot.
Dimension GetStringBoundingBox(const char *str, FontSize start_fontsize)
Return the string dimension in pixels.
Build signal toolbar; Window numbers:
static byte _cur_waypoint_type
Currently selected waypoint type.
void UpdateWidgetSize(int widget, Dimension *size, const Dimension &padding, Dimension *fill, Dimension *resize) override
Update size and resize step of a widget in the window.
static RailTileType GetRailTileType(TileIndex t)
Returns the RailTileType (normal with or without signals, waypoint or depot).
TileIndex tile
The base tile of the area.
Mask for the tile drag-type modes.
static TrackBits GetTrackBits(TileIndex tile)
Gets the track bits of the given tile.
static DiagDirection _build_depot_direction
Currently selected depot direction.
Dimension maxdim(const Dimension &d1, const Dimension &d2)
Compute bounding box of both dimensions.
Draw only every second pixel, used for greying-out.
No window, redirects to WC_MAIN_WINDOW.
void DeleteWindowById(WindowClass cls, WindowNumber number, bool force)
Delete a window by its class and window number (if it is open).
CursorID convert
Cursor for converting track.
static TileIndex GetOtherTunnelBridgeEnd(TileIndex t)
Determines type of the wormhole and returns its other end.
void DrawWidget(const Rect &r, int widget) const override
Draw the contents of a nested widget.
Functions related to companies.
static TileIndex TileVirtXY(uint x, uint y)
Get a tile from the virtual XY-coordinate.
static bool _remove_button_clicked
Flag whether 'remove' toggle-button is currently enabled.
static uint MapSize()
Get the size of the map.
area of land in X and Y directions
Header file for NewGRF stations.
Track along the y-axis (north-west to south-east)
RailType
Enumeration for all possible railtypes.
GUISettings gui
settings related to the GUI
Tunnel entry/exit and bridge heads.
void OnClick(Point pt, int widget, int click_count) override
A click with the left mouse button has been made on the window.
Align toward the toolbar.
uint32 SpriteID
The number of a sprite, without mapping bits and colourtables.
CursorID rail_swne
Cursor for building rail in X direction.
static void HandleAutoSignalPlacement()
Build new signals or remove signals or (if only one tile marked) edit a signal.
uint32 TileIndex
The index/ID of a Tile.
bool HandlePlacePushButton(Window *w, int widget, CursorID cursor, HighLightStyle mode)
This code is shared for the majority of the pushbuttons.
bool HasRailtypeAvail(const CompanyID company, const RailType railtype)
Finds out if a company has a certain buildable railtype available.
bool modified_catchment
different-size catchment areas
static bool IsLevelCrossingTile(TileIndex t)
Return whether a tile is a level crossing tile.
Track
These are used to specify a single track.
Top offset of image in the button.
Catchment for train stations with "modified catchment" enabled.
static bool IsValidAxis(Axis d)
Checks if an integer value is a valid Axis.
Old-fashioned semaphore signal.
Availability of station in construction window.
static uint GB(const T x, const uint8 s, const uint8 n)
Fetch n bits from x, started at bit s.
Functions related to zooming.
void OnClick(Point pt, int widget, int click_count) override
A click with the left mouse button has been made on the window.
SpriteID build_tunnel
button for building a tunnel
bool station_dragdrop
whether drag and drop is enabled for stations
uint8 cycle_signal_types
what signal types to cycle with the build signal tool.
Normal rail tile without signals.
static Track FindFirstTrack(TrackBits tracks)
Returns first Track from TrackBits or INVALID_TRACK.
static TrackBits TrackStatusToTrackBits(TrackStatus ts)
Returns the present-track-information of a TrackStatus.
StationClassID station_class
Currently selected custom station class (if newstations is true )
static NewGRFClass * Get(Tid cls_id)
Get a particular class.
uint coverage_height
Height of the coverage texts.
bool confirm
Play sound effect on successful constructions or other actions.
Axis orientation
Currently selected rail station orientation.
Functions related to commands.
void OnInit() override
Notification that the nested widget tree gets initialized.
static RailType _cur_railtype
Rail type of the current build-rail toolbar.
Coordinates of a point in 2D.
remove a single rail track
struct RailtypeInfo::@37 gui_sprites
struct containing the sprites for the rail GUI.
used for autorail highlighting (longer stretches), lower bits: direction
Dimension GetSpriteSize(SpriteID sprid, Point *offset, ZoomLevel zoom)
Get the size of a sprite.
void InitializeRailGUI()
Resets the rail GUI - sets default railtype to build and resets the signal GUI.
static bool IsValidID(size_t index)
Tests whether given index can be used to get valid (non-nullptr) Titem.
Scrollbar * vscroll2
Vertical scrollbar of the matrix with new stations.
special mode used for highlighting while dragging (and for tunnels/docks)
Scrollbar * vscroll
Vertical scrollbar of the new station list.
static const Track _place_depot_extra_track[12]
Additional pieces of track to add at the entrance of a depot.
Functions that have tunnels and bridges in common.
Functions related to waypoints.
void SetStringParameters(int widget) const override
Initialize string parameters for a widget.
drag only in vertical direction
Offset at right to draw the frame rectangular area.
const struct GRFFile * grffile
grf file that introduced this entity
SpriteID tunnel
tunnel sprites base
CursorID rail_ns
Cursor for building rail in N-S direction.
remove a (rectangle of) tiles from a rail station
RailTypes avail_railtypes
Rail types available to this company.
static bool HasBit(const T x, const uint8 y)
Checks if a bit in a value is set.
DiagDirection
Enumeration for diagonal directions.
byte callback_mask
Bitmask of station callbacks that have to be called.
static const TileIndex INVALID_TILE
The very nice invalid tile marker.
byte disallowed_lengths
Bitmask of platform lengths available for the station.
Northeast, upper right on your monitor.
#define CMD_MSG(x)
Used to combine a StringID with the command.
void ResetObjectToPlace()
Reset the cursor and mouse mode handling back to default (normal cursor, only clicking in windows)...
Specification of a rectangle with absolute coordinates of all edges.
The passed event is handled.
RailTypes GetCompanyRailtypes(CompanyID company, bool introduces)
Get the rail types the given company can build.
Functions related to tile highlights.
Window functions not directly related to making/drawing windows.
StringID name
Name of this station.
Find a place automatically.
SpriteID build_x_rail
button for building single rail in X direction
String list item with parameters.
static RailStationGUISettings _railstation
Settings of the station builder GUI.
void OnClick(Point pt, int widget, int click_count) override
A click with the left mouse button has been made on the window.
void InitializeRailGui()
Initialize rail building GUI settings.
Track in the left corner of the tile (west)
byte disallowed_platforms
Bitmask of number of platforms available for the station.
GUI functions that shouldn't be here.
static const DiagDirection _place_depot_extra_dir[12]
Direction to check for existing track pieces.
SignalVariant
Variant of the signal, i.e.
void DrawWaypointSprite(int x, int y, int stat_id, RailType railtype)
Draw a waypoint.
uint16 h
The height of the area.
static byte _waypoint_count
Number of waypoint types.
SpriteID build_ew_rail
button for building single rail in E-W direction
Left offset of the image in the button.
byte station_count
Number of custom stations (if newstations is true )
Fake keycode bit to indicate global hotkeys.
void OnResize() override
Called after the window got resized.
CompanyID _local_company
Company controlled by the human player at this client. Can also be COMPANY_SPECTATOR.
remove a (rectangle of) tiles from a rail waypoint
void UpdateWidgetSize(int widget, Dimension *size, const Dimension &padding, Dimension *fill, Dimension *resize) override
Update size and resize step of a widget in the window.
Dimensions (a width and height) of a rectangle in 2D.
bool click_beep
Beep on a random selection of buttons.
Offset at left to draw the frame rectangular area.
Axis
Allow incrementing of DiagDirDiff variables.
Game options window; Window numbers:
void DrawSprite(SpriteID img, PaletteID pal, int x, int y, const SubSprite *sub, ZoomLevel zoom)
Draw a sprite, not in a viewport.
static RailType GetRailType(TileIndex t)
Gets the rail type of the given tile.
Base class for windows opened from a toolbar.
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.
Track in the upper corner of the tile (north)
void MarkWholeScreenDirty()
This function mark the whole screen as dirty.
static void SetDefaultRailGui()
Set the initial (default) railtype to use.
static void SetDParam(uint n, uint64 v)
Set a string parameter v at index n in the global string parameter array.
StringID name
Name of this class.