OpenTTD Source
1.11.0-beta2
|
Go to the documentation of this file.
68 static void ShowBuildTrainDepotPicker(
Window *parent);
69 static void ShowBuildWaypointPicker(
Window *parent);
87 void CcPlaySound_CONSTRUCTION_RAIL(
const CommandCost &result,
TileIndex tile, uint32 p1, uint32 p2, uint32 cmd)
92 static void GenericPlaceRail(
TileIndex tile,
int cmd)
98 CcPlaySound_CONSTRUCTION_RAIL);
133 if (result.
Failed())
return;
174 if (result.
Failed())
return;
189 VpSetPlaceSizingLimit(-1);
253 CcPlaySound_CONSTRUCTION_RAIL);
336 VpSetPlaceSizingLimit(-1);
352 static void DoRailroadTrack(
int mode)
359 CcPlaySound_CONSTRUCTION_RAIL);
362 static void HandleAutodirPlacement()
371 DoRailroadTrack(trackstat);
414 CcPlaySound_CONSTRUCTION_RAIL);
469 void UpdateRemoveWidgetStatus(
int clicked_widget)
471 switch (clicked_widget) {
504 SetDParam(0, STR_TOOLBAR_RAILTYPE_VELOCITY);
521 this->last_user_action = widget;
526 this->last_user_action = widget;
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 ShowBuildTrainDepotPicker(
this);
552 this->last_user_action = widget;
557 this->last_user_action = widget;
560 ShowBuildWaypointPicker(
this);
567 this->last_user_action = widget;
572 this->last_user_action = widget;
582 this->last_user_action = widget;
587 this->last_user_action = widget;
596 this->last_user_action = widget;
599 default: NOT_REACHED();
601 this->UpdateRemoveWidgetStatus(widget);
613 switch (this->last_user_action) {
668 default: NOT_REACHED();
683 switch (select_proc) {
684 default: NOT_REACHED();
691 HandleAutodirPlacement();
713 HandleStationPlacement(start_tile, end_tile);
737 this->RaiseButtons();
773 extern RailType _last_built_railtype;
781 static Hotkey railtoolbar_hotkeys[] = {
800 static const NWidgetPart _nested_build_rail_widgets[] = {
845 _nested_build_rail_widgets,
lengthof(_nested_build_rail_widgets),
846 &BuildRailToolbarWindow::hotkeys
875 uint numtracks = ta.w;
876 uint platlength = ta.h;
931 this->vscroll =
nullptr;
964 this->vscroll2 =
nullptr;
971 for (uint i = 0; i < StationClass::GetClassCount(); i++) {
1010 for (uint bits = 0; bits < 7; bits++) {
1012 if (statspec ==
nullptr) {
1036 this->coverage_height +=
top - bottom;
1046 for (uint i = 0; i < StationClass::GetClassCount(); i++) {
1050 size->width = std::max(size->width, d.width + padding.width);
1066 StringID str = this->GetWidget<NWidgetCore>(widget)->widget_data;
1071 const StationSpec *statspec = stclass->GetSpec(j);
1072 SetDParam(0, (statspec !=
nullptr && statspec->
name != 0) ? statspec->
name : STR_STATION_CLASS_DFLT);
1076 size->width = std::max(size->width, d.width + padding.width);
1102 switch (
GB(widget, 0, 16)) {
1105 if (
FillDrawPixelInfo(&tmp_dpi, r.left, r.top, r.right - r.left + 1, r.bottom - r.top + 1)) {
1107 _cur_dpi = &tmp_dpi;
1119 if (
FillDrawPixelInfo(&tmp_dpi, r.left, r.top, r.right - r.left + 1, r.bottom - r.top + 1)) {
1121 _cur_dpi = &tmp_dpi;
1134 for (uint i = 0; i < StationClass::GetClassCount(); i++) {
1136 if (this->vscroll->
IsVisible(statclass)) {
1148 byte type =
GB(widget, 16, 16);
1157 if (
FillDrawPixelInfo(&tmp_dpi, r.left, r.top, r.right - r.left + 1, r.bottom - r.top + 1)) {
1159 _cur_dpi = &tmp_dpi;
1174 if (this->vscroll !=
nullptr) {
1183 SetDParam(0, (statspec !=
nullptr && statspec->
name != 0) ? statspec->
name : STR_STATION_CLASS_DFLT);
1189 switch (
GB(widget, 0, 16)) {
1218 for (uint i = 0; i < 7; i++) {
1253 for (uint i = 0; i < 7; i++) {
1278 for (uint i = 0; i < 7; i++) {
1287 for (uint i = 0; i < 7; i++) {
1317 if (y >= (
int)StationClass::GetClassCount())
return;
1318 for (uint i = 0; i < StationClass::GetClassCount(); i++) {
1344 int y =
GB(widget, 16, 16);
1370 static const NWidgetPart _nested_station_builder_widgets[] = {
1389 NWidget(
WWT_LABEL, COLOUR_DARK_GREEN),
SetMinimalSize(144, 11),
SetDataTip(STR_STATION_BUILD_ORIENTATION, STR_NULL),
SetPadding(1, 2, 0, 2),
1392 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(),
1394 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(),
1397 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),
1398 NWidget(
WWT_LABEL, COLOUR_DARK_GREEN),
SetMinimalSize(144, 11),
SetDataTip(STR_STATION_BUILD_NUMBER_OF_TRACKS, STR_NULL),
SetPadding(0, 2, 0, 2),
1410 NWidget(
WWT_LABEL, COLOUR_DARK_GREEN),
SetMinimalSize(144, 11),
SetDataTip(STR_STATION_BUILD_PLATFORM_LENGTH, STR_NULL),
SetPadding(2, 2, 0, 2),
1428 NWidget(
WWT_LABEL, COLOUR_DARK_GREEN),
SetMinimalSize(144, 11),
SetDataTip(STR_STATION_BUILD_COVERAGE_AREA_TITLE, STR_NULL),
SetPadding(3, 2, 0, 2),
1432 SetDataTip(STR_STATION_BUILD_COVERAGE_OFF, STR_STATION_BUILD_COVERAGE_AREA_OFF_TOOLTIP),
1434 SetDataTip(STR_STATION_BUILD_COVERAGE_ON, STR_STATION_BUILD_COVERAGE_AREA_ON_TOOLTIP),
1442 NWidget(
NWID_MATRIX, COLOUR_DARK_GREEN,
WID_BRAS_MATRIX),
SetScrollbar(
WID_BRAS_MATRIX_SCROLL),
SetPIP(0, 2, 0),
SetPadding(2, 0, 0, 0),
1466 WDP_AUTO,
"build_station_rail", 350, 0,
1469 _nested_station_builder_widgets,
lengthof(_nested_station_builder_widgets)
1495 const NWidgetBase *widget = this->GetWidget<NWidgetBase>(widget_index);
1496 int x = widget->
pos_x - offset.x +
1497 (widget->
current_x - sprite_size.width + offset.x) / 2;
1521 this->sig_sprite_size.width = 0;
1522 this->sig_sprite_size.height = 0;
1523 this->sig_sprite_bottom_offset = 0;
1527 for (uint lowered = 0; lowered < 2; lowered++) {
1530 this->sig_sprite_bottom_offset = std::max<int>(this->sig_sprite_bottom_offset, sprite_size.height);
1531 this->sig_sprite_size.width = std::max<int>(this->sig_sprite_size.width, sprite_size.width - offset.x);
1532 this->sig_sprite_size.height = std::max<int>(this->sig_sprite_size.height, sprite_size.height - offset.y);
1629 if (!gui_scope)
return;
1769 static void ShowBuildTrainDepotPicker(
Window *parent)
1793 size->width +=
resize->width * 2;
1794 size->height +=
resize->height * 2;
1809 switch (
GB(widget, 0, 16)) {
1811 byte type =
GB(widget, 16, 16);
1824 switch (
GB(widget, 0, 16)) {
1826 byte type =
GB(widget, 16, 16);
1868 static void ShowBuildWaypointPicker(
Window *parent)
1887 extern RailType _last_built_railtype;
1901 extern RailType _last_built_railtype;
1907 memset(count, 0,
sizeof(count));
1916 if (count[rt] > 0)
break;
1923 std::vector<RailType>::const_iterator it = std::find_if(_sorted_railtypes.begin(), _sorted_railtypes.end(),
1924 [](
RailType r){ return HasRailtypeAvail(_local_company, r); });
1930 std::vector<RailType>::const_reverse_iterator it = std::find_if(_sorted_railtypes.rbegin(), _sorted_railtypes.rend(),
1931 [](
RailType r){ return HasRailtypeAvail(_local_company, r); });
1993 if (for_replacement) {
2010 if (!for_replacement) {
2012 if (!
HasBit(used_railtypes, rt))
continue;
2020 if (!
HasBit(used_railtypes, rt))
continue;
2026 if (for_replacement) {
2030 iconitem->SetDimension(d);
2035 list.emplace_back(item);
2038 if (list.size() == 0) {
@ ES_HANDLED
The passed event is handled.
struct RailtypeInfo::@39 gui_sprites
struct containing the sprites for the rail GUI.
@ HT_DIR_HL
horizontal lower
CursorID rail_nwse
Cursor for building rail in Y direction.
byte station_numtracks
the number of platforms to default on for rail stations
void SetTileSelectSize(int w, int h)
Highlight w by h tiles at the cursor.
@ DDSP_DEMOLISH_AREA
Clear area.
static bool _remove_button_clicked
Flag whether 'remove' toggle-button is currently enabled.
@ CA_UNMODIFIED
Catchment for all stations with "modified catchment" disabled.
#define CMD_MSG(x)
Used to combine a StringID with the command.
uint32 TileIndex
The index/ID of a Tile.
@ DDSP_CONVERT_RAIL
Rail conversion.
bool station_dragdrop
whether drag and drop is enabled for stations
uint coverage_height
Height of the coverage texts.
static bool RailToolbar_CtrlChanged(Window *w)
Updates the Remove button because of Ctrl state change.
uint16 max_speed
Maximum speed for vehicles travelling on this rail type.
CommandCost DoCommand(const CommandContainer *container, DoCommandFlag flags)
Shorthand for calling the long DoCommand with a container.
static bool IsValidAxis(Axis d)
Checks if an integer value is a valid Axis.
bool station_show_coverage
whether to highlight coverage area
static Titem * Get(size_t index)
Returns Titem with given index.
@ WC_BUILD_TOOLBAR
Build toolbar; Window numbers:
static TileIndexDiff TileOffsByDiagDir(DiagDirection dir)
Convert a DiagDirection to a TileIndexDiff.
bool drag_signals_fixed_distance
keep fixed distance between signals when dragging
@ VPM_FIX_VERTICAL
drag only in vertical direction
StationSettings station
settings related to station management
@ WD_MATRIX_RIGHT
Offset at right of a matrix cell.
DropDownList GetRailTypeDropDownList(bool for_replacement, bool all_option)
Create a drop down list for all the rail types of the local company.
void SetWindowDirty(WindowClass cls, WindowNumber number)
Mark window as dirty (in need of repainting)
String list item with parameters.
List of hotkeys for a window.
void VpSetPresizeRange(TileIndex from, TileIndex to)
Highlights all tiles between a set of two tiles.
void DrawWidget(const Rect &r, int widget) const override
Draw the contents of a nested widget.
static uint GB(const T x, const uint8 s, const uint8 n)
Fetch n bits from x, started at bit s.
Dimension sig_sprite_size
Maximum size of signal GUI sprites.
Dimensions (a width and height) of a rectangle in 2D.
StringID menu_text
Name of this rail type in the main toolbar dropdown.
const Scrollbar * GetScrollbar(uint widnum) const
Return the Scrollbar to a widget index.
@ WDF_CONSTRUCTION
This window is used for construction; close it whenever changing company.
RailTypes avail_railtypes
Rail types available to this company.
static SignalType _cur_signal_type
set the signal type (for signal GUI)
@ DDSP_BUILD_STATION
Station placement.
void ReInit(int rx=0, int ry=0)
Re-initialize a window, and optionally change its size.
SpriteID build_depot
button for building depots
ViewportDragDropSelectionProcess
Drag and drop selection process, or, what to do with an area of land when you've selected it.
Year _cur_year
Current year, starting at 0.
@ TRANSPORT_RAIL
Transport by train.
@ WD_MATRIX_TOP
Offset at top of a matrix cell.
static const DiagDirection _place_depot_extra_dir[12]
Direction to check for existing track pieces.
Axis GetAxisForNewWaypoint(TileIndex tile)
Get the axis for a new waypoint.
@ CBID_STATION_AVAILABILITY
Determine whether a newstation should be made available to build.
uint GetSpecCount() const
Get the number of allocated specs within the class.
void CheckRedrawStationCoverage(const Window *w)
Check whether we need to redraw the station coverage text.
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)
CursorID convert
Cursor for converting track.
@ INVALID_ROADTYPE
flag for invalid roadtype
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 RailStationGUISettings _railstation
Settings of the station builder GUI.
@ TRACK_LOWER
Track in the lower corner of the tile (south)
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.
@ CMD_REMOVE_SIGNALS
remove a signal
StringID replace_text
Text used in the autoreplace GUI.
@ RAIL_TILE_SIGNALS
Normal rail tile with signals.
std::vector< std::unique_ptr< const DropDownListItem > > DropDownList
A drop down list is a collection of drop down list items.
void SetRedErrorSquare(TileIndex tile)
Set a tile to display a red error square.
void SetStringParameters(int widget) const override
Initialize string parameters for a widget.
void CreateNestedTree(bool fill_nested=true)
Perform the first part of the initialization of a nested widget tree.
@ WDP_ALIGN_TOOLBAR
Align toward the toolbar.
@ CMD_REMOVE_RAILROAD_TRACK
remove a rail track
Tindex index
Index of this pool item.
static void PlaceRail_Waypoint(TileIndex tile)
Place a rail waypoint.
@ TRACK_X
Track along the x-axis (north-east to south-west)
uint8 default_rail_type
the default rail type for the rail GUI
Dimension maxdim(const Dimension &d1, const Dimension &d2)
Compute bounding box of both dimensions.
static const CursorID ANIMCURSOR_BUILDSIGNALS
1292 - 1293 - build signal
Window * FindWindowById(WindowClass cls, WindowNumber number)
Find a window by its class and window number.
@ CMD_BUILD_SINGLE_RAIL
build a single rail track
static bool HasBit(const T x, const uint8 y)
Checks if a bit in a value is set.
CursorID rail_swne
Cursor for building rail in X direction.
This struct contains all the info that is needed to draw and construct tracks.
void OnClick(Point pt, int widget, int click_count) override
A click with the left mouse button has been made on the window.
byte station_type
Station type within the currently selected custom station class (if newstations is true )
bool _ctrl_pressed
Is Ctrl pressed?
@ FILLRECT_CHECKER
Draw only every second pixel, used for greying-out.
@ SND_15_BEEP
19 == 0x13 GUI button click
SpriteID build_tunnel
button for building a tunnel
static bool IsStationAvailable(const StationSpec *statspec)
Check whether a station type can be build.
CursorID depot
Cursor for building a depot.
@ SND_20_CONSTRUCTION_RAIL
30 == 0x1E Construction: rail infrastructure
static TrackBits GetTrackBits(TileIndex tile)
Gets the track bits of the given tile.
Structure for buffering the build command when selecting a station to join.
SpriteID auto_rail
button for the autorail construction
@ VPM_FIX_Y
drag only in Y axis
ClientSettings _settings_client
The current settings for this game.
@ CMD_BUILD_SIGNALS
build a signal
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.
Window * ShowBuildRailToolbar(RailType railtype)
Open the build rail toolbar window for a specific rail type.
static const CursorID ANIMCURSOR_DEMOLISH
704 - 707 - demolish dynamite
void DeleteWindowByClass(WindowClass cls)
Delete all windows of a given class.
@ CMD_REMOVE_FROM_RAIL_WAYPOINT
remove a (rectangle of) tiles from a rail waypoint
@ WC_BUILD_STATION
Build station; Window numbers:
static void ToggleRailButton_Remove(Window *w)
Toggles state of the Remove button of Build rail toolbar.
@ STAT_CLASS_BEGIN
the lowest valid value
ViewportPlaceMethod
Viewport place method (type of highlighted area and placed objects)
void OnClick(Point pt, int widget, int click_count) override
A click with the left mouse button has been made on the 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.
SpriteID build_ns_rail
button for building single rail in N-S direction
static RailType _cur_railtype
Rail type of the current build-rail toolbar.
byte drag_signals_density
many signals density
virtual EventState OnHotkey(int hotkey)
A hotkey has been pressed.
static void SetDParam(uint n, uint64 v)
Set a string parameter v at index n in the global string parameter array.
@ TRACK_RIGHT
Track in the right corner of the tile (east)
@ CMD_REMOVE_SIGNAL_TRACK
remove signals along a track (by dragging)
@ CMD_BUILD_RAILROAD_TRACK
build a rail track
@ CMD_BUILD_TUNNEL
build a tunnel
@ TRACK_BIT_UPPER
Upper track.
@ WD_IMGBTN_BOTTOM
Bottom offset of image in the button.
bool Succeeded() const
Did this command succeed?
Dimension GetStringBoundingBox(const char *str, FontSize start_fontsize)
Return the string dimension in pixels.
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.
TrackStatus GetTileTrackStatus(TileIndex tile, TransportType mode, uint sub_mode, DiagDirection side)
Returns information about trackdirs and signal states.
@ RAILTYPE_ELECTRIC
Electric rails.
SignalType
Type of signal, i.e.
@ VPM_RAILDIRS
all rail directions
@ TRACK_BIT_RIGHT
Right track.
static bool IsInsideMM(const T x, const size_t min, const size_t max)
Checks if a value is in an interval.
void CheckSelectedSize(const StationSpec *statspec)
Verify whether the currently selected station size is allowed after selecting a new station class/typ...
uint32 SpriteID
The number of a sprite, without mapping bits and colourtables.
High level window description.
@ SIG_ELECTRIC
Light signal.
static const RailtypeInfo * GetRailTypeInfo(RailType railtype)
Returns a pointer to the Railtype information for a given railtype.
bool ValParamRailtype(const RailType rail)
Validate functions for rail building.
SpriteID build_x_rail
button for building single rail in X direction
CursorID rail_ns
Cursor for building rail in N-S direction.
@ TRACK_BIT_VERT
Left and right track.
@ SIGTYPE_PBS
normal pbs signal
@ DDSP_PLACE_RAIL
Rail placement.
@ WDP_AUTO
Find a place automatically.
static uint MapSize()
Get the size of the map.
@ WKC_GLOBAL_HOTKEY
Fake keycode bit to indicate global hotkeys.
RailType
Enumeration for all possible railtypes.
static bool IsBridgeTile(TileIndex t)
checks if there is a bridge on this tile
@ STAT_CLASS_WAYP
Waypoint class.
ResizeInfo resize
Resize information.
SpriteID tunnel
tunnel sprites base
Common return value for all commands.
@ TRACK_Y
Track along the y-axis (north-west to south-east)
@ SIGTYPE_NORMAL
normal signal
bool newstations
Are custom station definitions available?
SoundSettings sound
sound effect settings
bool DoCommandP(const CommandContainer *container, bool my_cmd)
Shortcut for the long DoCommandP when having a container with the data.
void InitNested(WindowNumber number=0)
Perform complete initialization of the Window with nested widgets, to allow use.
@ VPM_FIX_X
drag only in X axis
void VpStartPlaceSizing(TileIndex tile, ViewportPlaceMethod method, ViewportDragDropSelectionProcess process)
highlighting tiles while only going over them with the mouse
static RailTileType GetRailTileType(TileIndex t)
Returns the RailTileType (normal with or without signals, waypoint or depot).
static const NWidgetPart _nested_build_depot_widgets[]
Nested widget definition of the build rail depot window.
uint8 cycle_signal_types
what signal types to cycle with the build signal tool.
static TrackBits TrackStatusToTrackBits(TrackStatus ts)
Returns the present-track-information of a TrackStatus.
void SetDirty() const
Mark entire window as dirty (in need of re-paint)
bool Convert8bitBooleanCallback(const GRFFile *grffile, uint16 cbid, uint16 cb_res)
Converts a callback result into a boolean.
@ WD_FRAMERECT_LEFT
Offset at left to draw the frame rectangular area.
static void ShowStationBuilder(Window *parent)
Open station build window.
@ HT_DIAGONAL
Also allow 'diagonal rectangles'. Only usable in combination with HT_RECT or HT_POINT.
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.
uint16 w
The width of the area.
static void PlaceRail_Bridge(TileIndex tile, Window *w)
Start placing a rail bridge.
@ WD_PAR_VSEP_NORMAL
Normal amount of vertical space between two paragraphs of text.
@ CMD_BUILD_RAIL_WAYPOINT
build a waypoint
@ WD_FRAMERECT_RIGHT
Offset at right to draw the frame rectangular area.
@ ES_NOT_HANDLED
The passed event is not handled.
bool Failed() const
Did this command fail?
@ HT_RAIL
autorail (one piece), lower bits: direction
bool enable_signal_gui
show the signal GUI when the signal button is pressed
@ TRACK_UPPER
Track in the upper corner of the tile (north)
void VpSelectTilesWithMethod(int x, int y, ViewportPlaceMethod method)
Selects tiles while dragging.
Represents the covered area of e.g.
Struct containing information relating to NewGRF classes for stations and airports.
GameSettings _settings_game
Game settings of a running game or the scenario editor.
CursorID autorail
Cursor for autorail tool.
static void ShowSignalBuilder(Window *parent)
Open the signal selection window.
void SetWidgetDisabledState(byte widget_index, bool disab_stat)
Sets the enabled/disabled status of a widget.
Window * parent
Parent window.
CompanyID _local_company
Company controlled by the human player at this client. Can also be COMPANY_SPECTATOR.
static bool HasStationTileRail(TileIndex t)
Has this station tile a rail? In other words, is this station tile a rail station or rail waypoint?
static TrackBits DiagdirReachesTracks(DiagDirection diagdir)
Returns all tracks that can be reached when entering a tile from a given (diagonal) direction.
StringID name
Name of this station.
bool HandlePlacePushButton(Window *w, int widget, CursorID cursor, HighLightStyle mode)
This code is shared for the majority of the pushbuttons.
int left
x position of left edge of the window
@ WC_BUILD_BRIDGE
Build bridge; Window numbers:
static EventState RailToolbarGlobalHotkeys(int hotkey)
Handler for global hotkeys of the BuildRailToolbarWindow.
@ TRACK_LEFT
Track in the left corner of the tile (west)
@ CMD_REMOVE_SINGLE_RAIL
remove a single rail track
@ DDSP_BUILD_BRIDGE
Bridge placement.
static const NWidgetPart _nested_build_waypoint_widgets[]
Nested widget definition for the build NewGRF rail waypoint window.
Point pos
Location, in tile "units", of the northern tile of the selected area.
void DrawSprite(SpriteID img, PaletteID pal, int x, int y, const SubSprite *sub, ZoomLevel zoom)
Draw a sprite, not in a viewport.
@ MP_TUNNELBRIDGE
Tunnel entry/exit and bridge heads.
Coordinates of a point in 2D.
DiagDirection
Enumeration for diagonal directions.
@ CBM_STATION_AVAIL
Availability of station in construction window.
@ HT_DIR_MASK
masks the drag-direction
byte station_spread
amount a station may spread
@ TRACK_BIT_LOWER
Lower track.
byte disallowed_platforms
Bitmask of number of platforms available for the station.
static const uint8 PC_BLACK
Black palette colour.
@ CMD_BUILD_TRAIN_DEPOT
build a train depot
Scrollbar * vscroll
Vertical scrollbar of the new station list.
bool link_terraform_toolbar
display terraform toolbar when displaying rail, road, water and airport toolbars
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.
StringID toolbar_caption
Caption in the construction toolbar GUI for this rail type.
@ CMD_REMOVE_FROM_RAIL_STATION
remove a (rectangle of) tiles from a rail station
Scrollbar * vscroll2
Vertical scrollbar of the matrix with new stations.
void InvalidateData(int data=0, bool gui_scope=true)
Mark this window's data as invalid (in need of re-computing)
@ WC_NONE
No window, redirects to WC_MAIN_WINDOW.
static bool IsTileType(TileIndex tile, TileType type)
Checks if a tile is a given tiletype.
byte GetDigitWidth(FontSize size)
Return the maximum width of single digit.
void ShowSelectStationIfNeeded(const CommandContainer &cmd, TileArea ta)
Show the station selection window when needed.
bool FillDrawPixelInfo(DrawPixelInfo *n, int left, int top, int width, int height)
Set up a clipping area for only drawing into a certain area.
@ WC_BUILD_DEPOT
Build depot; Window numbers:
uint16 h
The height of the area.
Dimension GetSpriteSize(SpriteID sprid, Point *offset, ZoomLevel zoom)
Get the size of a sprite.
@ RAILTYPE_RAIL
Standard non-electric rails.
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.
void ShowBuildBridgeWindow(TileIndex start, TileIndex end, TransportType transport_type, byte road_rail_type)
Prepare the data for the build a bridge window.
HighLightStyle drawstyle
Lower bits 0-3 are reserved for detailed highlight information.
int DrawStationCoverageAreaText(int left, int right, int top, StationCoverageType sct, int rad, bool supplies)
Calculates and draws the accepted or supplied cargo around the selected tile(s)
void DrawWidget(const Rect &r, int widget) const override
Draw the contents of a nested widget.
@ SCT_ALL
Draw all cargoes.
static const uint CALLBACK_FAILED
Different values for Callback result evaluations.
@ TRACK_BIT_HORZ
Upper and lower track.
uint32 StringID
Numeric value that represents a string, independent of the selected language.
bool confirm
Play sound effect on successful constructions or other actions.
StationClassID station_class
Currently selected custom station class (if newstations is true )
Point selstart
The location where the dragging started.
@ WC_GAME_OPTIONS
Game options window; Window numbers:
static void GenericPlaceSignals(TileIndex tile)
Build a new signal or edit/remove a present signal, use CmdBuildSingleSignal() or CmdRemoveSingleSign...
static bool _convert_signal_button
convert signal button in the signal GUI pressed
@ WC_SELECT_STATION
Select station (when joining stations); Window numbers:
SignalVariant
Variant of the signal, i.e.
void DrawWidget(const Rect &r, int widget) const override
Draw the contents of a nested widget.
RailTypes GetRailTypes(bool introduces)
Get list of rail types, regardless of company availability.
static T Clamp(const T a, const T min, const T max)
Clamp a value between an interval.
@ SIGTYPE_PBS_ONEWAY
no-entry signal
static byte _cur_waypoint_type
Currently selected waypoint type.
void OnInit() override
Notification that the nested widget tree gets initialized.
static void PlaceExtraDepotRail(TileIndex tile, DiagDirection dir, Track track)
Try to add an additional rail-track at the entrance of a depot.
void DeleteWindowById(WindowClass cls, WindowNumber number, bool force)
Delete a window by its class and window number (if it is open).
bool IsShaded() const
Is window shaded currently?
@ TRACK_BIT_LEFT
Left track.
@ WC_BUILD_WAYPOINT
Build waypoint; Window numbers:
@ VPM_Y_LIMITED
Drag only in Y axis with limited size.
static DiagDirection _build_depot_direction
Currently selected depot direction.
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...
#define FONT_HEIGHT_NORMAL
Height of characters in the normal (FS_NORMAL) font.
@ WC_SCEN_LAND_GEN
Landscape generation (in Scenario Editor); Window numbers:
@ HT_LINE
used for autorail highlighting (longer stretches), lower bits: direction
static int ScaleGUITrad(int value)
Scale traditional pixel dimensions to GUI zoom level.
@ COMPANY_SPECTATOR
The client is spectating.
@ RAILTYPE_END
Used for iterations.
TileIndex tile
The base tile of the area.
Year semaphore_build_before
build semaphore signals automatically before this year
bool ResetSignalVariant(int32 p)
Updates the current signal variant used in the signal GUI to the one adequate to current year.
TileIndex _build_tunnel_endtile
The end of a tunnel; as hidden return from the tunnel build command for GUI purposes.
void InitializeRailGui()
Initialize rail building GUI settings.
void MarkTileDirtyByTile(TileIndex tile, int bridge_level_offset, int tile_height_override)
Mark a tile given by its index dirty for repaint.
RailTypes GetCompanyRailtypes(CompanyID company, bool introduces)
Get the rail types the given company can build.
uint line_height
Height of a single line in the newstation selection matrix (WID_BRAS_NEWST_LIST widget).
static RailType GetRailType(TileIndex t)
Gets the rail type of the given tile.
bool IsWidgetLowered(byte widget_index) const
Gets the lowered state of a widget.
static void PlaceRail_Station(TileIndex tile)
Place a rail station.
EventState
State of handling an event.
@ HT_RECT
rectangle (stations, depots, ...)
@ VPM_FIX_HORIZONTAL
drag only in horizontal direction
@ VPM_X_AND_Y
area of land in X and Y directions
#define FOR_ALL_SORTED_RAILTYPES(var)
Loop header for iterating over railtypes, sorted by sortorder.
@ WD_IMGBTN_TOP
Top offset of image in the button.
StringID name
Name of this class.
void OnClick(Point pt, int widget, int click_count) override
A click with the left mouse button has been made on the window.
void FinishInitNested(WindowNumber window_number=0)
Perform the second part of the initialization of a nested widget tree.
@ DC_AUTO
don't allow building on structures
void CcBuildRailTunnel(const CommandCost &result, TileIndex tile, uint32 p1, uint32 p2, uint32 cmd)
Command callback for building a tunnel.
@ HT_DRAG_MASK
Mask for the tile drag-type modes.
struct RailtypeInfo::@41 strings
Strings associated with the rail type.
Base class for windows opened from a toolbar.
static Track FindFirstTrack(TrackBits tracks)
Returns first Track from TrackBits or INVALID_TRACK.
void SetViewportCatchmentStation(const Station *st, bool sel)
Select or deselect station for coverage area highlight.
static bool IsLevelCrossingTile(TileIndex t)
Return whether a tile is a level crossing tile.
int top
y position of top edge of the window
void OnResize() override
Called after the window got resized.
OrthogonalTileArea TileArea
Shorthand for the much more common orthogonal tile area.
SpriteID build_ew_rail
button for building single rail in E-W direction
TrackBits
Bitfield corresponding to Track.
@ DDSP_BUILD_SIGNALS
Signal placement.
@ WD_MATRIX_BOTTOM
Offset at bottom of a matrix cell.
int sig_sprite_bottom_offset
Maximum extent of signal GUI sprite from reference point towards bottom.
void ToggleWidgetLoweredState(byte widget_index)
Invert the lowered/raised status of a widget.
bool click_beep
Beep on a random selection of buttons.
void OnInvalidateData(int data=0, bool gui_scope=true) override
Some data on this window has become invalid.
@ CMD_CONVERT_RAIL
convert a rail type
#define lengthof(x)
Return the length of an fixed size array.
@ VPM_X_LIMITED
Drag only in X axis with limited size.
static const Track _place_depot_extra_track[12]
Additional pieces of track to add at the entrance of a depot.
GRFFilePropsBase< NUM_CARGO+3 > grf_prop
Properties related the the grf file.
static NewGRFClass * Get(Tid cls_id)
Get a particular class.
void MarkWholeScreenDirty()
This function mark the whole screen as dirty.
@ CA_TRAIN
Catchment for train stations with "modified catchment" enabled.
bool auto_remove_signals
automatically remove signals when in the way during rail construction
static const TileIndex INVALID_TILE
The very nice invalid tile marker.
byte station_platlength
the platform length, in tiles, for rail stations
static const NWidgetPart _nested_signal_builder_widgets[]
Nested widget definition of the build signal window.
Axis
Allow incrementing of DiagDirDiff variables.
void InitializeRailGUI()
Resets the rail GUI - sets default railtype to build and resets the signal GUI.
static TileIndex GetOtherTunnelBridgeEnd(TileIndex t)
Determines type of the wormhole and returns its other end.
void OnPaint() override
The window must be repainted.
@ WC_BUILD_SIGNAL
Build signal toolbar; Window numbers:
void DrawWidget(const Rect &r, int widget) const override
Draw the contents of a nested widget.
Data structure for an opened window.
void OnRealtimeTick(uint delta_ms) override
Called periodically.
byte callback_mask
Bitmask of station callbacks that have to be called.
void ShowSelectWaypointIfNeeded(const CommandContainer &cmd, TileArea ta)
Show the waypoint selection window when needed.
static bool IsValidID(size_t index)
Tests whether given index can be used to get valid (non-nullptr) Titem.
CursorID rail_ew
Cursor for building rail in E-W direction.
void RaiseWidget(byte widget_index)
Marks a widget as raised.
@ WD_MATRIX_LEFT
Offset at left of a matrix cell.
byte disallowed_lengths
Bitmask of platform lengths available for the station.
void DrawWidgets() const
Paint all widgets of a window.
@ RAIL_TILE_DEPOT
Depot (one entrance)
const struct GRFFile * grffile
grf file that introduced this entity
TileIndex tile
tile command being executed on.
static void Swap(T &a, T &b)
Type safe swap operation.
@ WD_IMGBTN_LEFT
Left offset of the image in the button.
Track
These are used to specify a single track.
@ VPM_X_AND_Y_LIMITED
area of land of limited size
bool IsWidgetDisabled(byte widget_index) const
Gets the enabled/disabled status of a widget.
SpriteID build_y_rail
button for building single rail in Y direction
SpriteID signals[SIGTYPE_END][2][2]
signal GUI sprites (type, variant, state)
void SetWidgetDirty(byte widget_index) const
Invalidate a widget, i.e.
void SetStringParameters(int widget) const override
Initialize string parameters for a widget.
static TransportType GetTunnelBridgeTransportType(TileIndex t)
Tunnel: Get the transport type of the tunnel (road or rail) Bridge: Get the transport type of the bri...
@ DIAGDIR_NE
Northeast, upper right on your monitor.
static void BuildRailClick_Remove(Window *w)
The "remove"-button click proc of the build-rail toolbar.
Specification of a rectangle with absolute coordinates of all edges.
void LowerWidget(byte widget_index)
Marks a widget as lowered.
RailTypes
The different railtypes we support, but then a bitmask of them.
byte station_count
Number of custom stations (if newstations is true )
bool DrawStationTile(int x, int y, RailType railtype, Axis axis, StationClassID sclass, uint station)
Draw representation of a station tile for GUI purposes.
@ STAT_CLASS_DFLT
Default station class.
@ DDSP_REMOVE_STATION
Station removal.
@ VPM_X_OR_Y
drag in X or Y direction
void DisableWidget(byte widget_index)
Sets a widget to disabled.
void OnClick(Point pt, int widget, int click_count) override
A click with the left mouse button has been made on the window.
static byte _waypoint_count
Number of waypoint types.
void ResetObjectToPlace()
Reset the cursor and mouse mode handling back to default (normal cursor, only clicking in windows).
@ HT_SPECIAL
special mode used for highlighting while dragging (and for tunnels/docks)
void DrawWaypointSprite(int x, int y, int stat_id, RailType railtype)
Draw a waypoint.
@ WD_IMGBTN_RIGHT
Right offset of the image in the button.
void SetWidgetLoweredState(byte widget_index, bool lowered_stat)
Sets the lowered/raised status of a widget.
@ CMD_BUILD_RAIL_STATION
build a rail station
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)
@ SIG_SEMAPHORE
Old-fashioned semaphore signal.
@ CMD_BUILD_SIGNAL_TRACK
add signals along a track (by dragging)
@ VPM_SIGNALDIRS
similar to VMP_RAILDIRS, but with different cursor
uint8 default_signal_type
the signal type to build by default.
List item with icon and string.
Axis orientation
Currently selected rail station orientation.
GUISettings gui
settings related to the GUI
Point selend
The location where the drag currently ends.
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.
Data about how and where to blit pixels.
bool persistent_buildingtools
keep the building tools active after usage
bool modified_catchment
different-size catchment areas
static TileIndex TileVirtXY(uint x, uint y)
Get a tile from the virtual XY-coordinate.
All data for a single hotkey.
SpriteID convert_rail
button for converting rail
void ReinitGuiAfterToggleElrail(bool disable)
Re-initialize rail-build toolbar after toggling support for electric trains.
@ INVALID_RAILTYPE
Flag for invalid railtype.
@ WN_GAME_OPTIONS_GAME_SETTINGS
Game settings.
@ RAILTYPE_BEGIN
Used for iterations.
static void SetDefaultRailGui()
Set the initial (default) railtype to use.