Go to the documentation of this file.
73 static void ShowBuildTrainDepotPicker(
Window *parent);
74 static void ShowBuildWaypointPicker(
Window *parent);
140 if (result.
Failed())
return;
179 if (result.
Failed())
return;
194 VpSetPlaceSizingLimit(-1);
209 auto proc = [=](
bool test, StationID to_join) ->
bool {
213 return Command<CMD_BUILD_RAIL_STATION>::Post(STR_ERROR_CAN_T_BUILD_RAILROAD_STATION, CcStation, tile, rt, params.
orientation, numtracks, platlength, params.
station_class, params.
station_type, to_join, adjacent);
249 tile, track,
_cur_signal_type,
_cur_signal_variant,
_convert_signal_button,
false,
_ctrl_pressed, cycle_start, SIGTYPE_LAST, 0, 0);
253 tile, track,
_settings_client.
gui.
default_signal_type, sigvar,
false,
false,
_ctrl_pressed, cycle_start, SIGTYPE_LAST, 0, 0);
338 VpSetPlaceSizingLimit(-1);
354 static void DoRailroadTrack(
Track track)
365 static void HandleAutodirPlacement()
374 DoRailroadTrack(trackstat);
402 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);
460 void UpdateRemoveWidgetStatus(
int clicked_widget)
462 switch (clicked_widget) {
495 SetDParam(0, STR_TOOLBAR_RAILTYPE_VELOCITY);
512 this->last_user_action = widget;
517 this->last_user_action = widget;
522 this->last_user_action = widget;
527 this->last_user_action = widget;
532 this->last_user_action = widget;
537 this->last_user_action = widget;
542 ShowBuildTrainDepotPicker(
this);
543 this->last_user_action = widget;
548 this->last_user_action = widget;
551 ShowBuildWaypointPicker(
this);
558 this->last_user_action = widget;
563 this->last_user_action = widget;
573 this->last_user_action = widget;
578 this->last_user_action = widget;
587 this->last_user_action = widget;
590 default: NOT_REACHED();
592 this->UpdateRemoveWidgetStatus(widget);
604 switch (this->last_user_action) {
657 default: NOT_REACHED();
672 switch (select_proc) {
673 default: NOT_REACHED();
680 HandleAutodirPlacement();
703 HandleStationPlacement(start_tile, end_tile);
716 auto proc = [=](
bool test, StationID to_join) ->
bool {
772 extern RailType _last_built_railtype;
780 static Hotkey railtoolbar_hotkeys[] = {
799 static const NWidgetPart _nested_build_rail_widgets[] = {
844 _nested_build_rail_widgets,
lengthof(_nested_build_rail_widgets),
845 &BuildRailToolbarWindow::hotkeys
874 uint numtracks = ta.w;
875 uint platlength = ta.h;
883 auto proc = [=](
bool test, StationID to_join) ->
bool {
887 return Command<CMD_BUILD_RAIL_STATION>::Post(STR_ERROR_CAN_T_BUILD_RAILROAD_STATION, CcStation, ta.tile, rt, params.
orientation, numtracks, platlength, params.
station_class, params.
station_type, to_join, adjacent);
928 for (
auto station_class : this->station_classes) {
932 this->vscroll->
SetCount((
int)this->station_classes.size());
973 this->vscroll =
nullptr;
992 this->station_classes.
SetListing(this->last_sorting);
993 this->station_classes.
SetFiltering(this->last_filtering);
1018 this->vscroll2 =
nullptr;
1062 this->station_classes.clear();
1064 for (uint i = 0; i < StationClass::GetClassCount(); i++) {
1076 this->station_classes.
Filter(this->string_filter);
1077 this->station_classes.shrink_to_fit();
1079 this->station_classes.
Sort();
1081 this->vscroll->
SetCount((uint)this->station_classes.size());
1097 bool available =
false;
1098 for (uint i = 0; i < StationClass::GetClassCount(); ++i) {
1120 if (!gui_scope)
return;
1168 for (uint bits = 0; bits < 7; bits++) {
1170 if (statspec ==
nullptr) {
1190 if (
top > r.bottom) {
1191 this->coverage_height +=
top - r.bottom;
1201 for (
auto station_class : this->station_classes) {
1204 size->width = std::max(size->width, d.width + padding.width);
1220 StringID str = this->GetWidget<NWidgetCore>(widget)->widget_data;
1221 for (
auto station_class : this->station_classes) {
1224 const StationSpec *statspec = stclass->GetSpec(j);
1225 SetDParam(0, (statspec !=
nullptr && statspec->
name != 0) ? statspec->
name : STR_STATION_CLASS_DFLT);
1229 size->width = std::max(size->width, d.width + padding.width);
1255 switch (
GB(widget, 0, 16)) {
1260 _cur_dpi = &tmp_dpi;
1274 _cur_dpi = &tmp_dpi;
1287 for (
auto station_class : this->station_classes) {
1288 if (this->vscroll->
IsVisible(statclass)) {
1300 byte type =
GB(widget, 16, 16);
1311 _cur_dpi = &tmp_dpi;
1326 if (this->vscroll !=
nullptr) {
1335 SetDParam(0, (statspec !=
nullptr && statspec->
name != 0) ? statspec->
name : STR_STATION_CLASS_DFLT);
1341 switch (
GB(widget, 0, 16)) {
1370 for (uint i = 0; i < 7; i++) {
1405 for (uint i = 0; i < 7; i++) {
1430 for (uint i = 0; i < 7; i++) {
1439 for (uint i = 0; i < 7; i++) {
1469 if (y >= (
int)this->station_classes.size())
return;
1490 int y =
GB(widget, 16, 16);
1531 static Hotkey buildrailstation_hotkeys[] = {
1541 &StationClassIDSorter,
1548 static const NWidgetPart _nested_station_builder_widgets[] = {
1564 SetDataTip(STR_LIST_FILTER_OSKTITLE, STR_LIST_FILTER_TOOLTIP),
1574 NWidget(
WWT_LABEL, COLOUR_DARK_GREEN),
SetMinimalSize(144, 11),
SetDataTip(STR_STATION_BUILD_ORIENTATION, STR_NULL),
SetPadding(1, 2, 0, 0),
1577 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(),
1579 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(),
1582 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),
1583 NWidget(
WWT_LABEL, COLOUR_DARK_GREEN),
SetMinimalSize(144, 11),
SetDataTip(STR_STATION_BUILD_NUMBER_OF_TRACKS, STR_NULL),
SetPadding(0, 2, 0, 2),
1595 NWidget(
WWT_LABEL, COLOUR_DARK_GREEN),
SetMinimalSize(144, 11),
SetDataTip(STR_STATION_BUILD_PLATFORM_LENGTH, STR_NULL),
SetPadding(2, 2, 0, 2),
1617 SetDataTip(STR_STATION_BUILD_COVERAGE_OFF, STR_STATION_BUILD_COVERAGE_AREA_OFF_TOOLTIP),
1619 SetDataTip(STR_STATION_BUILD_COVERAGE_ON, STR_STATION_BUILD_COVERAGE_AREA_ON_TOOLTIP),
1651 WDP_AUTO,
"build_station_rail", 350, 0,
1654 _nested_station_builder_widgets,
lengthof(_nested_station_builder_widgets),
1655 &BuildRailStationWindow::hotkeys
1682 int x =
CenterBounds(ir.left, ir.right, sprite_size.width - offset.x) - offset.x;
1724 this->sig_sprite_size.width = 0;
1725 this->sig_sprite_size.height = 0;
1726 this->sig_sprite_bottom_offset = 0;
1730 for (uint lowered = 0; lowered < 2; lowered++) {
1733 this->sig_sprite_bottom_offset = std::max<int>(this->sig_sprite_bottom_offset, sprite_size.height);
1734 this->sig_sprite_size.width = std::max<int>(this->sig_sprite_size.width, sprite_size.width - offset.x);
1735 this->sig_sprite_size.height = std::max<int>(this->sig_sprite_size.height, sprite_size.height - offset.y);
1747 size->width = std::max(size->width, this->sig_sprite_size.width + padding.width);
1748 size->height = std::max(size->height, this->sig_sprite_size.height + padding.height);
1843 if (!gui_scope)
return;
1945 _cur_dpi = &tmp_dpi;
2008 static void ShowBuildTrainDepotPicker(
Window *parent)
2039 size->width +=
resize->width * 2;
2040 size->height +=
resize->height * 2;
2055 switch (
GB(widget, 0, 16)) {
2057 byte type =
GB(widget, 16, 16);
2063 _cur_dpi = &tmp_dpi;
2079 switch (
GB(widget, 0, 16)) {
2081 byte type =
GB(widget, 16, 16);
2125 static void ShowBuildWaypointPicker(
Window *parent)
2145 extern RailType _last_built_railtype;
2159 extern RailType _last_built_railtype;
2165 memset(count, 0,
sizeof(count));
2174 if (count[rt] > 0)
break;
2181 std::vector<RailType>::const_iterator it = std::find_if(_sorted_railtypes.begin(), _sorted_railtypes.end(),
2182 [](
RailType r){ return HasRailtypeAvail(_local_company, r); });
2188 std::vector<RailType>::const_reverse_iterator it = std::find_if(_sorted_railtypes.rbegin(), _sorted_railtypes.rend(),
2189 [](
RailType r){ return HasRailtypeAvail(_local_company, r); });
2248 if (for_replacement) {
2264 if (!for_replacement) {
2265 for (
const auto &rt : _sorted_railtypes) {
2266 if (!
HasBit(used_railtypes, rt))
continue;
2272 for (
const auto &rt : _sorted_railtypes) {
2274 if (!
HasBit(used_railtypes, rt))
continue;
2280 if (for_replacement) {
2284 iconitem->SetDimension(d);
2289 list.emplace_back(item);
2292 if (list.size() == 0) {
@ ES_HANDLED
The passed event is handled.
@ 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.
void Close() override
Hide the window and all its child windows, and mark them for a later deletion.
@ 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.
static constexpr bool IsInsideMM(const T x, const size_t min, const size_t max) noexcept
Checks if a value is in an interval.
@ 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.
BuildRalStationHotkeys
Enum referring to the Hotkeys in the build rail station window.
uint16 max_speed
Maximum speed for vehicles travelling on this rail type.
static bool IsValidAxis(Axis d)
Checks if an integer value is a valid Axis.
int Height() const
Get height of Rect.
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
void SelectClassAndStation()
Checks if the previously selected current station class and station can be shown as selected to the u...
StationSettings station
settings related to station management
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.
uint GetUISpecCount() const
Get the number of potentially user-available specs within the class.
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.
void SetFocusedWindow(Window *w)
Set the window that has the focus.
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.
bool Sort(Comp compare)
Sort the list.
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.
Commands
List of commands.
Rect Shrink(int s) const
Copy and shrink Rect by s pixels.
bool IsEmpty() const
Check whether any filter words were entered.
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.
void SetFilterTerm(const char *str)
Set the term to filter on.
static constexpr DoCommandFlag CommandFlagsToDCFlags(CommandFlags cmd_flags)
Extracts the DC flags needed for DoCommand from the flags returned by GetCommandFlags.
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.
Axis
Allow incrementing of DiagDirDiff variables.
@ 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.
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.
StringID replace_text
Text used in the autoreplace GUI.
@ SIG_SEMAPHORE
Old-fashioned semaphore signal.
@ 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.
Tindex index
Index of this pool item.
@ SIGNAL_GUI_PATH
Show path signals only.
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.
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.
static constexpr TileIndex INVALID_TILE
The very nice invalid tile marker.
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.
static bool StationClassIDSorter(StationClassID const &a, StationClassID const &b)
Sort station classes by StationClassID.
byte station_type
Station type within the currently selected custom station class (if newstations is true )
bool _ctrl_pressed
Is Ctrl pressed?
@ SIGNAL_GUI_ALL
Show all signals, including block and presignals.
@ 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.
SignalType default_signal_type
The default signal type, which is set automatically by the last signal used. Not available in Setting...
@ SND_20_CONSTRUCTION_RAIL
30 == 0x1E Construction: rail infrastructure
void RaiseButtons(bool autoraise=false)
Raise the buttons of the window.
@ SIGNAL_CYCLE_ALL
Cycle through all signals visible.
static TrackBits GetTrackBits(TileIndex tile)
Gets the track bits of the given tile.
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.
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.
SignalVariant
Variant of the signal, i.e.
static const CursorID ANIMCURSOR_DEMOLISH
704 - 707 - demolish dynamite
void AddLine(const char *str)
Pass another text line from the current item to the filter.
static Filtering last_filtering
Default filtering of GUIStationClassList.
@ WC_BUILD_STATION
Build station; Window numbers:
static void ToggleRailButton_Remove(Window *w)
Toggles state of the Remove button of Build rail toolbar.
void SetSignalUIMode()
Show or hide buttons for non-path signals in the signal GUI.
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 Close() override
Hide the window and all its child windows, and mark them for a later deletion.
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.
@ INVALID_ROADTYPE
flag for invalid roadtype
@ TRACK_RIGHT
Track in the right corner of the tile (east)
EventState OnHotkey(int hotkey) override
A hotkey has been pressed.
Data stored about a string that can be modified in the GUI.
@ TRACK_BIT_UPPER
Upper track.
bool Succeeded() const
Did this command succeed?
Dimension GetStringBoundingBox(const char *str, FontSize start_fontsize)
Return the string dimension in pixels.
void SetFilterFuncs(FilterFunction *const *n_funcs)
Hand the array of filter function pointers to the sort list.
char *const buf
buffer in which text is saved
SmallMap< int, QueryString * > querystrings
QueryString associated to WWT_EDITBOX widgets.
SignalType
Type of signal, i.e.
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.
@ SIGTYPE_PBS
normal pbs signal
TrackStatus GetTileTrackStatus(TileIndex tile, TransportType mode, uint sub_mode, DiagDirection side)
Returns information about trackdirs and signal states.
@ RAILTYPE_ELECTRIC
Electric rails.
static const int MAX_CHAR_LENGTH
Max. length of UTF-8 encoded unicode character.
@ VPM_RAILDIRS
all rail directions
@ TRACK_BIT_RIGHT
Right track.
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.
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.
SignalCycleSettings cycle_signal_types
Which signal types to cycle with the build signal tool.
void EnsureSelectedStationClassIsVisible()
Scrolls WID_BRAS_NEWST_SCROLL so that the selected station class is visible.
@ TRACK_BIT_VERT
Left and right track.
void DrawSignalSprite(const Rect &r, int 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...
@ DDSP_PLACE_RAIL
Rail placement.
@ TRANSPORT_RAIL
Transport by train.
@ WDP_AUTO
Find a place automatically.
Data structure describing how to show the list (what sort direction and criteria).
static uint MapSize()
Get the size of the map.
void SetFilterState(bool state)
Enable or disable the filter.
@ WKC_GLOBAL_HOTKEY
Fake keycode bit to indicate global hotkeys.
struct RailtypeInfo::@37 gui_sprites
struct containing the sprites for the rail GUI.
RailType
Enumeration for all possible railtypes.
static bool IsBridgeTile(TileIndex t)
checks if there is a bridge on this tile
static const int DRAW_STRING_BUFFER
Size of the buffer used for drawing strings.
@ 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)
bool newstations
Are custom station definitions available?
static const uint EDITBOX_MAX_SIZE
The maximum number of characters for the filter edit box.
@ SIG_ELECTRIC
Light signal.
SoundSettings sound
sound effect settings
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.
static TrackBits TrackStatusToTrackBits(TrackStatus ts)
Returns the present-track-information of a TrackStatus.
bool SortFunction(const StationClassID &, const StationClassID &)
Signature of sort function.
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.
void SetListing(Listing l)
Import sort conditions.
@ HT_DIAGONAL
Also allow 'diagonal rectangles'. Only usable in combination with HT_RECT or HT_POINT.
uint Horizontal() const
Get total horizontal padding of RectPadding.
static EventState BuildRailStationGlobalHotkeys(int hotkey)
Handler for global hotkeys of the BuildRailStationWindow.
uint16 w
The width of the area.
static void PlaceRail_Bridge(TileIndex tile, Window *w)
Start placing a rail bridge.
@ ES_NOT_HANDLED
The passed event is not handled.
bool Failed() const
Did this command fail?
@ HT_RAIL
autorail (one piece), lower bits: direction
@ TRACK_UPPER
Track in the upper corner of the tile (north)
@ BRASHK_FOCUS_FILTER_BOX
Focus the edit box for editing the filter string.
void VpSelectTilesWithMethod(int x, int y, ViewportPlaceMethod method)
Selects tiles while dragging.
static int ScaleSpriteTrad(int value)
Scale traditional pixel dimensions to GUI zoom level, for drawing sprites.
Represents the covered area of e.g.
Struct containing information relating to NewGRF classes for stations and airports.
void ShowSelectStationIfNeeded(TileArea ta, StationPickerCmdProc proc)
Show the station selection window when needed.
GameSettings _settings_game
Game settings of a running game or the scenario editor.
void Close() override
Hide the window and all its child windows, and mark them for a later deletion.
Data structure describing what to show in the list (filter criteria).
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.
void OnEditboxChanged(int wid) override
The text in an editbox has been edited.
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.
@ WC_BUILD_BRIDGE
Build bridge; Window numbers:
void ShowSelectWaypointIfNeeded(TileArea ta, StationPickerCmdProc proc)
Show the waypoint selection window when needed.
static EventState RailToolbarGlobalHotkeys(int hotkey)
Handler for global hotkeys of the BuildRailToolbarWindow.
@ TRACK_LEFT
Track in the left corner of the tile (west)
void Close() override
Hide the window and all its child windows, and mark them for a later deletion.
@ 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.
StringFilter string_filter
Filter for available station classes.
@ CBM_STATION_AVAIL
Availability of station in construction window.
@ HT_DIR_MASK
masks the drag-direction
byte station_spread
amount a station may spread
void BuildStationClassesAvailable()
Builds the filter list of available station classes.
@ TRACK_BIT_LOWER
Lower track.
byte disallowed_platforms
Bitmask of number of platforms available for the station.
bool SetFocusedWidget(int widget_index)
Set focus within this window to the given widget.
static const uint8 PC_BLACK
Black palette colour.
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.
uint Vertical() const
Get total vertical padding of RectPadding.
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.
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.
bool NeedRebuild() const
Check if a rebuild is needed.
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.
static GUIStationClassList::SortFunction *const sorter_funcs[]
Sort functions of the GUIStationClassList.
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:
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 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.
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.
static GUIStationClassList::FilterFunction *const filter_funcs[]
Filter functions of the GUIStationClassList.
#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
@ COMPANY_SPECTATOR
The client is spectating.
@ RAILTYPE_END
Used for iterations.
bool CDECL FilterFunction(const StationClassID *, StringFilter &)
Signature of filter function.
TileIndex tile
The base tile of the area.
Year semaphore_build_before
build semaphore signals automatically before this year
void CloseWindowByClass(WindowClass cls)
Close all windows of a given class.
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 ResetState()
Reset the matching state to process a new item.
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
void SetFiltering(Filtering f)
Import filter conditions.
bool GetState() const
Get the matching state of the current item.
StringID name
Name of this class.
bool Filter(FilterFunction *decide, F filter_data)
Filter the list.
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
@ HT_DRAG_MASK
Mask for the tile drag-type modes.
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.
static Window * ShowStationBuilder(Window *parent)
Open station build window.
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.
int sig_sprite_bottom_offset
Maximum extent of signal GUI sprite from reference point towards bottom.
GUIStationClassList station_classes
Available station classes.
void ForceRebuild()
Force that a rebuild is needed.
static int CenterBounds(int min, int max, int size)
Determine where to draw a centred object inside a widget.
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.
#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
void CloseWindowById(WindowClass cls, WindowNumber number, bool force)
Close a window by its class and window number (if it is open).
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.
void InitializeRailGUI()
Resets the rail GUI - sets default railtype to build and resets the signal GUI.
static Listing last_sorting
Default sorting of GUIStationClassList.
static TileIndex GetOtherTunnelBridgeEnd(TileIndex t)
Determines type of the wormhole and returns its other end.
void ResetSignalVariant(int32 new_value)
Updates the current signal variant used in the signal GUI to the one adequate to current year.
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.
void RebuildDone()
Notify the sortlist that the rebuild is done.
byte callback_mask
Bitmask of station callbacks that have to be called.
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.
void CcBuildRailTunnel(Commands cmd, const CommandCost &result, TileIndex tile)
Command callback for building a tunnel.
byte disallowed_lengths
Bitmask of platform lengths available for the station.
struct RailtypeInfo::@39 strings
Strings associated with the rail type.
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
static void Swap(T &a, T &b)
Type safe swap operation.
int Width() const
Get width of Rect.
Track
These are used to specify a single track.
GUIList< StationClassID, StringFilter & > GUIStationClassList
Type definition for the list to hold available station classes.
@ 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.
SignalGUISettings signal_gui_mode
select which signal types are shown in the signal GUI
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.
#define lastof(x)
Get the last element of an fixed size array.
void SelectOtherClass(StationClassID station_class)
Select the specified station class.
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.
void SetWidgetLoweredState(byte widget_index, bool lowered_stat)
Sets the lowered/raised status of a widget.
static bool CDECL TagNameFilter(StationClassID const *sc, StringFilter &filter)
Filter station classes by class name.
@ SIGTYPE_NORMAL
normal signal
@ VPM_SIGNALDIRS
similar to VMP_RAILDIRS, but with different cursor
QueryString filter_editbox
Filter editbox.
List item with icon and string.
void OnInvalidateData(int data=0, bool gui_scope=true) override
Some data on this window has become invalid.
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.
void SetSortFuncs(SortFunction *const *n_funcs)
Hand the array of sort function pointers to the sort list.
Data about how and where to blit pixels.
bool persistent_buildingtools
keep the building tools active after usage
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), &BuildRailStationWindow::hotkeys)
High level window description of the station-build window (default & newGRF)
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.
virtual void Close()
Hide the window and all its child windows, and mark them for a later deletion.
@ RAILTYPE_BEGIN
Used for iterations.
static void SetDefaultRailGui()
Set the initial (default) railtype to use.