OpenTTD Source
20240906-master-gd5ff6b4156
|
Go to the documentation of this file.
75 static void ShowBuildTrainDepotPicker(
Window *parent);
76 static void ShowBuildWaypointPicker(
Window *parent);
142 if (result.
Failed())
return;
186 if (result.
Failed())
return;
201 VpSetPlaceSizingLimit(-1);
216 auto proc = [=](
bool test, StationID to_join) ->
bool {
220 return Command<CMD_BUILD_RAIL_STATION>::Post(STR_ERROR_CAN_T_BUILD_RAILROAD_STATION, CcStation, tile, rt, params.
axis, numtracks, platlength, params.
sel_class, params.
sel_type, to_join, adjacent);
259 cycle_end = SIGTYPE_LAST;
262 if (cur_signal_on_tile <= SIGTYPE_LAST_NOPBS) {
265 cycle_end = SIGTYPE_LAST_NOPBS;
269 cycle_end = SIGTYPE_LAST;
276 tile, track,
_cur_signal_type,
_cur_signal_variant,
_convert_signal_button,
false,
_ctrl_pressed, cycle_start, cycle_end, 0, 0);
280 tile, track,
_settings_client.
gui.
default_signal_type, sigvar,
false,
false,
_ctrl_pressed, cycle_start, cycle_end, 0, 0);
365 VpSetPlaceSizingLimit(-1);
381 static void DoRailroadTrack(
Track track)
392 static void HandleAutodirPlacement()
401 DoRailroadTrack(trackstat);
429 TileVirtXY(_thd.
selstart.x, _thd.
selstart.y),
TileVirtXY(_thd.
selend.x, _thd.
selend.y), track, sigtype, sigvar,
false,
_ctrl_pressed, !
_settings_client.
gui.
drag_signals_fixed_distance,
_settings_client.
gui.
drag_signals_density);
446 this->last_user_action = INVALID_WID_RAT;
451 void Close([[maybe_unused]]
int data = 0)
override
467 void OnInvalidateData([[maybe_unused]]
int data = 0, [[maybe_unused]]
bool gui_scope =
true)
override
469 if (!gui_scope)
return;
482 bool OnTooltip([[maybe_unused]]
Point pt,
WidgetID widget, TooltipCloseCondition close_cond)
override
485 if (can_build)
return false;
489 GuiShowTooltips(
this, STR_TOOLBAR_DISABLED_NO_VEHICLE_AVAILABLE, close_cond);
523 void UpdateRemoveWidgetStatus(
WidgetID clicked_widget)
525 switch (clicked_widget) {
553 void SetStringParameters(
WidgetID widget)
const override
558 SetDParam(0, STR_TOOLBAR_RAILTYPE_VELOCITY);
567 void OnClick([[maybe_unused]]
Point pt,
WidgetID widget, [[maybe_unused]]
int click_count)
override
575 this->last_user_action = widget;
580 this->last_user_action = widget;
585 this->last_user_action = widget;
590 this->last_user_action = widget;
595 this->last_user_action = widget;
600 this->last_user_action = widget;
605 ShowBuildTrainDepotPicker(
this);
606 this->last_user_action = widget;
611 this->last_user_action = widget;
613 ShowBuildWaypointPicker(
this);
620 this->last_user_action = widget;
625 this->last_user_action = widget;
635 this->last_user_action = widget;
640 this->last_user_action = widget;
649 this->last_user_action = widget;
652 default: NOT_REACHED();
654 this->UpdateRemoveWidgetStatus(widget);
664 void OnPlaceObject([[maybe_unused]]
Point pt,
TileIndex tile)
override
666 switch (this->last_user_action) {
719 default: NOT_REACHED();
734 switch (select_proc) {
735 default: NOT_REACHED();
742 HandleAutodirPlacement();
765 HandleStationPlacement(start_tile, end_tile);
777 auto proc = [=](
bool test, StationID to_join) ->
bool {
810 void OnPlacePresize([[maybe_unused]]
Point pt,
TileIndex tile)
override
836 extern RailType _last_built_railtype;
842 static inline HotkeyList hotkeys{
"railtoolbar", {
860 static constexpr
NWidgetPart _nested_build_rail_widgets[] = {
905 _nested_build_rail_widgets,
906 &BuildRailToolbarWindow::hotkeys
935 uint numtracks = ta.w;
936 uint platlength = ta.h;
944 auto proc = [=](
bool test, StationID to_join) ->
bool {
948 return Command<CMD_BUILD_RAIL_STATION>::Post(STR_ERROR_CAN_T_BUILD_RAILROAD_STATION, CcStation, ta.tile, rt, params.
axis, numtracks, platlength, params.
sel_class, params.
sel_type, to_join, adjacent);
979 for (
const auto *spec : cls.Specs()) {
980 if (spec !=
nullptr)
return true;
996 const auto *sc = GetClass(
id);
1006 const auto *spec = this->GetSpec(cls_id,
id);
1007 return (spec ==
nullptr) ? STR_STATION_CLASS_DFLT_STATION : spec->name;
1015 void DrawType(
int x,
int y,
int cls_id,
int id)
const override
1024 bool default_added =
false;
1029 default_added =
true;
1031 for (
const auto &sm : st->speclist) {
1032 if (sm.spec ==
nullptr)
continue;
1033 items.insert({sm.grfid, sm.localidx, sm.spec->class_index, sm.spec->index});
1083 this->ConstructWindow();
1102 void Close([[maybe_unused]]
int data = 0)
override
1108 void OnInvalidateData([[maybe_unused]]
int data = 0, [[maybe_unused]]
bool gui_scope =
true)
override
1115 this->PickerWindow::OnInvalidateData(data, gui_scope);
1137 for (uint bits = 0; bits < 7; bits++) {
1139 if (statspec ==
nullptr) {
1159 if (
top > r.bottom) {
1160 this->coverage_height +=
top - r.bottom;
1179 this->PickerWindow::UpdateWidgetSize(widget, size, padding, fill,
resize);
1184 void DrawWidget(
const Rect &r,
WidgetID widget)
const override
1218 this->PickerWindow::DrawWidget(r, widget);
1223 void OnClick([[maybe_unused]]
Point pt,
WidgetID widget, [[maybe_unused]]
int click_count)
override
1252 for (uint i = 0; i < 7; i++) {
1285 for (uint i = 0; i < 7; i++) {
1310 for (uint i = 0; i < 7; i++) {
1319 for (uint i = 0; i < 7; i++) {
1348 this->PickerWindow::OnClick(pt, widget, click_count);
1371 static inline HotkeyList hotkeys{
"buildrailstation", {
1376 static constexpr
NWidgetPart _nested_station_builder_widgets[] = {
1431 WDP_AUTO,
"build_station_rail", 0, 0,
1434 _nested_station_builder_widgets,
1435 &BuildRailStationWindow::hotkeys
1458 int x =
CenterBounds(ir.left, ir.right, sprite_size.width - offset.x) - offset.x;
1483 void Close([[maybe_unused]]
int data = 0)
override
1492 this->sig_sprite_size.width = 0;
1493 this->sig_sprite_size.height = 0;
1494 this->sig_sprite_bottom_offset = 0;
1496 for (uint type =
SIGTYPE_BLOCK; type < SIGTYPE_END; type++) {
1498 for (uint lowered = 0; lowered < 2; lowered++) {
1501 this->sig_sprite_bottom_offset = std::max<int>(this->sig_sprite_bottom_offset, sprite_size.height);
1502 this->sig_sprite_size.width = std::max<int>(this->sig_sprite_size.width, sprite_size.width - offset.x);
1503 this->sig_sprite_size.height = std::max<int>(this->sig_sprite_size.height, sprite_size.height - offset.y);
1515 size.width = std::max(size.width, this->sig_sprite_size.width + padding.width);
1516 size.height = std::max(size.height, this->sig_sprite_size.height + padding.height);
1520 void SetStringParameters(
WidgetID widget)
const override
1529 void DrawWidget(
const Rect &r,
WidgetID widget)
const override
1541 void OnClick([[maybe_unused]]
Point pt,
WidgetID widget, [[maybe_unused]]
int click_count)
override
1607 void OnInvalidateData([[maybe_unused]]
int data = 0, [[maybe_unused]]
bool gui_scope =
true)
override
1609 if (!gui_scope)
return;
1716 void DrawWidget(
const Rect &r,
WidgetID widget)
const override
1730 void OnClick([[maybe_unused]]
Point pt,
WidgetID widget, [[maybe_unused]]
int click_count)
override
1774 static void ShowBuildTrainDepotPicker(
Window *parent)
1790 for (
const auto *spec : cls.Specs()) {
1791 if (spec !=
nullptr)
return true;
1808 const auto *sc = GetClass(
id);
1818 const auto *spec = this->GetSpec(cls_id,
id);
1819 return (spec ==
nullptr) ? STR_STATION_CLASS_WAYP_WAYPOINT : spec->name;
1827 void DrawType(
int x,
int y,
int cls_id,
int id)
const override
1834 bool default_added =
false;
1839 default_added =
true;
1841 for (
const auto &sm : wp->speclist) {
1842 if (sm.spec ==
nullptr)
continue;
1843 items.insert({0, 0, sm.spec->class_index, sm.spec->index});
1855 this->ConstructWindow();
1859 static inline HotkeyList hotkeys{
"buildrailwaypoint", {
1883 &BuildRailWaypointWindow::hotkeys
1886 static void ShowBuildWaypointPicker(
Window *parent)
1888 if (!WaypointPickerCallbacks::instance.IsActive())
return;
1910 extern RailType _last_built_railtype;
1924 extern RailType _last_built_railtype;
1930 memset(count, 0,
sizeof(count));
1939 if (count[rt] > 0)
break;
1946 std::vector<RailType>::const_iterator it = std::find_if(_sorted_railtypes.begin(), _sorted_railtypes.end(),
1947 [](
RailType r) { return HasRailTypeAvail(_local_company, r); });
1953 std::vector<RailType>::const_reverse_iterator it = std::find_if(_sorted_railtypes.rbegin(), _sorted_railtypes.rend(),
1954 [](
RailType r){ return HasRailTypeAvail(_local_company, r); });
2019 if (for_replacement) {
2030 list.push_back(MakeDropDownListStringItem(STR_REPLACE_ALL_RAILTYPE,
INVALID_RAILTYPE));
2035 if (!for_replacement) {
2036 for (
const auto &rt : _sorted_railtypes) {
2037 if (!
HasBit(used_railtypes, rt))
continue;
2043 for (
const auto &rt : _sorted_railtypes) {
2045 if (!
HasBit(used_railtypes, rt))
continue;
2051 if (for_replacement) {
2054 StringID str = rti->
max_speed > 0 ? STR_TOOLBAR_RAILTYPE_VELOCITY : STR_JUST_STRING;
2061 list.push_back(MakeDropDownListStringItem(STR_NONE,
INVALID_RAILTYPE,
true));
CursorID convert
Cursor for converting track.
@ INVALID_RAILTYPE
Flag for invalid railtype.
bool HasClassChoice() const override
Are there multiple classes to chose from?
@ ES_HANDLED
The passed event is handled.
@ HT_DIR_HL
horizontal lower
TrackBits DiagdirReachesTracks(DiagDirection diagdir)
Returns all tracks that can be reached when entering a tile from a given (diagonal) direction.
void SetTileSelectSize(int w, int h)
Highlight w by h tiles at the cursor.
@ DDSP_DEMOLISH_AREA
Clear area.
@ SIGTYPE_PBS
normal pbs signal
static bool _remove_button_clicked
Flag whether 'remove' toggle-button is currently enabled.
@ CA_UNMODIFIED
Catchment for all stations with "modified catchment" disabled.
SpriteID build_ew_rail
button for building single rail in E-W direction
@ DIAGDIR_NE
Northeast, upper right on your monitor.
void CloseWindowByClass(WindowClass cls, int data)
Close all windows of a given class.
@ DDSP_CONVERT_RAIL
Rail conversion.
bool station_dragdrop
whether drag and drop is enabled for stations
Track FindFirstTrack(TrackBits tracks)
Returns first Track from TrackBits or INVALID_TRACK.
uint coverage_height
Height of the coverage texts.
static bool RailToolbar_CtrlChanged(Window *w)
Updates the Remove button because of Ctrl state change.
@ SIG_SEMAPHORE
Old-fashioned semaphore signal.
void CcBuildRailTunnel(Commands, const CommandCost &result, TileIndex tile)
Command callback for building a tunnel.
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 const int PREVIEW_HEIGHT
Height of each preview button.
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
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)
static const int PREVIEW_WIDTH
Width of each preview button.
void SetSelectedType(int id) const override
Set the selected type.
List of hotkeys for a window.
void VpSetPresizeRange(TileIndex from, TileIndex to)
Highlights all tiles between a set of two tiles.
@ SIGTYPE_BLOCK
block signal
Dimension sig_sprite_size
Maximum size of signal GUI sprites.
bool ValParamRailType(const RailType rail)
Validate functions for rail building.
Dimensions (a width and height) of a rectangle in 2D.
constexpr bool IsInsideMM(const T x, const size_t min, const size_t max) noexcept
Checks if a value is in an interval.
constexpr void Swap(T &a, T &b)
Type safe swap operation.
SpriteID build_y_rail
button for building single rail in Y direction
@ WDF_CONSTRUCTION
This window is used for construction; close it whenever changing company.
const RailTypeInfo * GetRailTypeInfo(RailType railtype)
Returns a pointer to the Railtype information for a given railtype.
RailTypes avail_railtypes
Rail types available to this company.
Rect Shrink(int s) const
Copy and shrink Rect by s pixels.
bool IsRailStation(Tile t)
Is this station tile a rail station?
static SignalType _cur_signal_type
set the signal type (for signal GUI)
@ DDSP_BUILD_STATION
Station placement.
@ RAILTYPE_RAIL
Standard non-electric rails.
SpriteID tunnel
tunnel sprites base
uint16_t sel_type
Selected station type within the class.
@ RAILTYPE_ELECTRIC
Electric rails.
ViewportDragDropSelectionProcess
Drag and drop selection process, or, what to do with an area of land when you've selected it.
static constexpr DoCommandFlag CommandFlagsToDCFlags(CommandFlags cmd_flags)
Extracts the DC flags needed for DoCommand from the flags returned by GetCommandFlags.
int GetSelectedType() const override
Get the selected type.
static const DiagDirection _place_depot_extra_dir[12]
Direction to check for existing track pieces.
@ CBID_STATION_AVAILABILITY
Determine whether a newstation should be made available to build.
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.
void SetWidgetDirty(WidgetID widget_index) const
Invalidate a widget, i.e.
static SignalVariant _cur_signal_variant
set the signal variant (for signal GUI)
uint8_t callback_mask
Bitmask of station callbacks that have to be called.
uint32_t StringID
Numeric value that represents a string, independent of the selected language.
void CloseWindowById(WindowClass cls, WindowNumber number, bool force, int data)
Close a window by its class and window number (if it is open).
@ 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 SetSelectedClass(int id) const override
Set the selected class.
constexpr static debug_inline uint GB(const T x, const uint8_t s, const uint8_t n)
Fetch n bits from x, started at bit s.
@ WDP_ALIGN_TOOLBAR
Align toward the toolbar.
@ SIG_ELECTRIC
Light signal.
RailType
Enumeration for all possible railtypes.
@ TRACK_BIT_HORZ
Upper and lower track.
Tindex index
Index of this pool item.
@ VEH_TRAIN
Train vehicle type.
static WindowDesc _station_builder_desc(WDP_AUTO, "build_station_rail", 0, 0, WC_BUILD_STATION, WC_BUILD_TOOLBAR, WDF_CONSTRUCTION, _nested_station_builder_widgets, &BuildRailStationWindow::hotkeys)
High level window description of the station-build window (default & newGRF)
static void PlaceRail_Waypoint(TileIndex tile)
Place a rail waypoint.
SpriteID signals[SIGTYPE_END][2][2]
signal GUI sprites (type, variant, state)
Dimension maxdim(const Dimension &d1, const Dimension &d2)
Compute bounding box of both dimensions.
virtual void Close(int data=0)
Hide the window and all its child windows, and mark them for a later deletion.
@ STAT_CLASS_WAYP
Waypoint class.
static const CursorID ANIMCURSOR_BUILDSIGNALS
1292 - 1293 - build signal
Window * FindWindowById(WindowClass cls, WindowNumber number)
Find a window by its class and window number.
@ SIGNAL_GUI_PATH
Show path signals only.
Axis axis
Selected orientation of the station.
constexpr TileIndex INVALID_TILE
The very nice invalid tile marker.
This struct contains all the info that is needed to draw and construct tracks.
CursorID autorail
Cursor for autorail tool.
@ PCWHK_FOCUS_FILTER_BOX
Focus the edit box for editing the filter string.
Representation of a waypoint.
bool _ctrl_pressed
Is Ctrl pressed?
@ SND_15_BEEP
19 == 0x13 GUI button click
static bool IsStationAvailable(const StationSpec *statspec)
Check whether a station type can be build.
bool HandlePlacePushButton(Window *w, WidgetID widget, CursorID cursor, HighLightStyle mode)
This code is shared for the majority of the pushbuttons.
SignalType default_signal_type
The default signal type, which is set automatically by the last signal used. Not available in Setting...
StringID GetClassTooltip() const override
Get the tooltip string for the class list.
@ TRACK_BIT_VERT
Left and right track.
@ SND_20_CONSTRUCTION_RAIL
30 == 0x1E Construction: rail infrastructure
void RaiseButtons(bool autoraise=false)
Raise the buttons of the window.
DiagDirection
Enumeration for diagonal directions.
Wrapper class to abstract away the way the tiles are stored.
bool IsActive() const override
Should picker class/type selection be enabled?
bool IsLevelCrossingTile(Tile t)
Return whether a tile is a level crossing tile.
@ VPM_FIX_Y
drag only in Y axis
@ RAILTYPE_END
Used for iterations.
ClientSettings _settings_client
The current settings for this game.
CursorID rail_swne
Cursor for building rail in X direction.
bool IsValidTrack(Track track)
Checks if a Track is valid.
Window * ShowBuildRailToolbar(RailType railtype)
Open the build rail toolbar window for a specific rail type.
static EventState BuildRailStationGlobalHotkeys(int hotkey)
Handler for global hotkeys of the BuildRailStationWindow.
static const CursorID ANIMCURSOR_DEMOLISH
704 - 707 - demolish dynamite
constexpr uint Vertical() const
Get total vertical padding of RectPadding.
void DrawType(int x, int y, int cls_id, int id) const override
Draw preview image of an item.
@ WC_BUILD_STATION
Build station; Window numbers:
static void ToggleRailButton_Remove(Window *w)
Toggles state of the Remove button of Build rail toolbar.
void DrawWaypointSprite(int x, int y, StationClassID station_class, uint16_t station_type, RailType railtype)
Draw a waypoint.
StringID GetTypeName(int cls_id, int id) const override
Get the item of a type.
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)
RailType GetRailType(Tile t)
Gets the rail type of the given tile.
struct RailTypeInfo::@26 strings
Strings associated with the rail type.
static RailType _cur_railtype
Rail type of the current build-rail toolbar.
void OnInit() override
Notification that the nested widget tree gets initialized.
RailTypes
Allow incrementing of Track variables.
virtual EventState OnHotkey(int hotkey)
A hotkey has been pressed.
static constexpr NWidgetPart _nested_build_depot_widgets[]
Nested widget definition of the build rail depot window.
void SetSelectedType(int id) const override
Set the selected type.
bool Succeeded() const
Did this command succeed?
virtual bool TileBelongsToRailStation(TileIndex tile) const =0
Check whether a specific tile belongs to this station.
TrackStatus GetTileTrackStatus(TileIndex tile, TransportType mode, uint sub_mode, DiagDirection side)
Returns information about trackdirs and signal states.
static Pool::IterateWrapper< Station > Iterate(size_t from=0)
Returns an iterable ensemble of all valid stations of type T.
@ VPM_RAILDIRS
all rail directions
void CheckSelectedSize(const StationSpec *statspec)
Verify whether the currently selected station size is allowed after selecting a new station class/typ...
SpriteID build_depot
button for building depots
High level window description.
constexpr uint Horizontal() const
Get total horizontal padding of RectPadding.
int GetSelectedClass() const override
Get the index of the selected class.
int ScaleGUITrad(int value)
Scale traditional pixel dimensions to GUI zoom level.
SignalVariant
Variant of the signal, i.e.
SignalCycleSettings cycle_signal_types
Which signal types to cycle with the build signal tool.
uint8_t GetDigitWidth(FontSize size)
Return the maximum width of single digit.
uint8_t drag_signals_density
many signals density
@ DDSP_PLACE_RAIL
Rail placement.
@ WDP_AUTO
Find a place automatically.
static WaypointPickerSelection _waypoint_gui
Settings of the waypoint picker.
uint8_t default_rail_type
the default rail type for the rail GUI
@ WKC_GLOBAL_HOTKEY
Fake keycode bit to indicate global hotkeys.
ResizeInfo resize
Resize information.
Common return value for all commands.
CursorID rail_ns
Cursor for building rail in N-S direction.
SoundSettings sound
sound effect settings
@ FS_NORMAL
Index of the normal font in the font tables.
TileArea train_station
Tile area the train 'station' part covers.
void InitNested(WindowNumber number=0)
Perform complete initialization of the Window with nested widgets, to allow use.
TrackBits
Allow incrementing of Track variables.
@ VPM_FIX_X
drag only in X axis
static std::span< NewGRFClass< Tspec, Tindex, Tmax > const > Classes()
Get read-only span of all classes of this type.
@ RAILTYPE_BEGIN
Used for iterations.
void VpStartPlaceSizing(TileIndex tile, ViewportPlaceMethod method, ViewportDragDropSelectionProcess process)
highlighting tiles while only going over them with the mouse
StringID GetClassName(int id) const override
Get the name of a class.
SpriteID auto_rail
button for the autorail construction
TimerGameCalendar::Year semaphore_build_before
build semaphore signals automatically before this year
void SetDirty() const
Mark entire window as dirty (in need of re-paint)
StringID GetTypeTooltip() const override
Get the tooltip string for the type grid.
@ HT_DIAGONAL
Also allow 'diagonal rectangles'. Only usable in combination with HT_RECT or HT_POINT.
bool HasSignalOnTrack(Tile tile, Track track)
Checks for the presence of signals (either way) on the given track on the given rail tile.
static void PlaceRail_Bridge(TileIndex tile, Window *w)
Start placing a rail bridge.
virtual void OnPlaceMouseUp([[maybe_unused]] ViewportPlaceMethod select_method, [[maybe_unused]] ViewportDragDropSelectionProcess select_proc, [[maybe_unused]] Point pt, [[maybe_unused]] TileIndex start_tile, [[maybe_unused]] TileIndex end_tile)
The user has dragged over the map when the tile highlight mode has been set.
@ ES_NOT_HANDLED
The passed event is not handled.
bool Failed() const
Did this command fail?
@ HT_RAIL
autorail (one piece), lower bits: direction
StringID toolbar_caption
Caption in the construction toolbar GUI for this rail type.
SpriteID build_ns_rail
button for building single rail in N-S direction
@ TRACK_BIT_LEFT
Left track.
void Close([[maybe_unused]] int data=0) override
Hide the window and all its child windows, and mark them for a later deletion.
void VpSelectTilesWithMethod(int x, int y, ViewportPlaceMethod method)
Selects tiles while dragging.
Represents the covered area of e.g.
bool HasStationTileRail(Tile t)
Has this station tile a rail? In other words, is this station tile a rail station or rail waypoint?
void FillUsedItems(std::set< PickerItem > &items) override
Fill a set with all items that are used by the current player.
static const int PREVIEW_LEFT
Offset from left edge to draw preview.
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 ShowSelectRailWaypointIfNeeded(TileArea ta, StationPickerCmdProc proc)
Show the rail waypoint selection window when needed.
void ReInit(int rx=0, int ry=0, bool reposition=false)
Re-initialize a window, and optionally change its size.
static void ShowSignalBuilder(Window *parent)
Open the signal selection window.
bool IsBridgeTile(Tile t)
checks if there is a bridge on this tile
Window * parent
Parent window.
CompanyID _local_company
Company controlled by the human player at this client. Can also be COMPANY_SPECTATOR.
void LowerWidget(WidgetID widget_index)
Marks a widget as lowered.
StringID GetTypeName(int cls_id, int id) const override
Get the item of a type.
@ WC_BUILD_BRIDGE
Build bridge; Window numbers:
std::unique_ptr< NWidgetBase > MakePickerTypeWidgets()
Create nested widgets for the type picker widgets.
@ DDSP_BUILD_BRIDGE
Bridge placement.
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.
@ INVALID_ROADTYPE
flag for invalid roadtype
Coordinates of a point in 2D.
void FillUsedItems(std::set< PickerItem > &items) override
Fill a set with all items that are used by the current player.
bool IsWidgetDisabled(WidgetID widget_index) const
Gets the enabled/disabled status of a widget.
static debug_inline RailTileType GetRailTileType(Tile t)
Returns the RailTileType (normal with or without signals, waypoint or depot).
virtual void OnInit()
Notification that the nested widget tree gets initialized.
int CenterBounds(int min, int max, int size)
Determine where to draw a centred object inside a widget.
StringID GetClassTooltip() const override
Get the tooltip string for the class list.
@ CBM_STATION_AVAIL
Availability of station in construction window.
@ HT_DIR_MASK
masks the drag-direction
const Tspec * GetSpec(uint index) const
Get a spec from the class at a given index.
struct RailTypeInfo::@24 gui_sprites
struct containing the sprites for the rail GUI.
TrackBits TrackStatusToTrackBits(TrackStatus ts)
Returns the present-track-information of a TrackStatus.
bool IsValidAxis(Axis d)
Checks if an integer value is a valid Axis.
CursorID rail_ew
Cursor for building rail in E-W direction.
bool link_terraform_toolbar
display terraform toolbar when displaying rail, road, water and airport toolbars
uint32_t SpriteID
The number of a sprite, without mapping bits and colourtables.
bool CanBuildVehicleInfrastructure(VehicleType type, uint8_t subtype)
Check whether we can build infrastructure for the given vehicle type.
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.
void SetWidgetLoweredState(WidgetID widget_index, bool lowered_stat)
Sets the lowered/raised status of a widget.
static debug_inline bool IsPlainRailTile(Tile t)
Checks whether the tile is a rail tile or rail tile with signals.
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:
uint8_t disallowed_lengths
Bitmask of platform lengths available for the station.
bool IsValidTile(Tile tile)
Checks if a tile is valid.
TrackBits GetTrackBits(Tile tile)
Gets the track bits of the given tile.
uint16_t max_speed
Maximum speed for vehicles travelling on this rail type.
TileIndexDiff TileOffsByDiagDir(DiagDirection dir)
Convert a DiagDirection to a TileIndexDiff.
void SetWidgetDisabledState(WidgetID widget_index, bool disab_stat)
Sets the enabled/disabled status of a widget.
Dimension GetSpriteSize(SpriteID sprid, Point *offset, ZoomLevel zoom)
Get the size of a sprite.
@ TRACK_BIT_UPPER
Upper track.
StringID menu_text
Name of this rail type in the main toolbar dropdown.
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)
uint8_t station_numtracks
the number of platforms to default on for rail stations
Helper for PickerCallbacks when the class system is based on NewGRFClass.
StationClassID sel_class
Selected station class.
@ SCT_ALL
Draw all cargoes.
bool IsWidgetLowered(WidgetID widget_index) const
Gets the lowered state of a widget.
static const uint CALLBACK_FAILED
Different values for Callback result evaluations.
bool confirm
Play sound effect on successful constructions or other actions.
void ShowBuildBridgeWindow(TileIndex start, TileIndex end, TransportType transport_type, uint8_t road_rail_type)
Prepare the data for the build a bridge window.
Point selstart
The location where the dragging started.
void GuiShowTooltips(Window *parent, StringID str, TooltipCloseCondition close_tooltip, uint paramcount)
Shows a tooltip.
@ 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
Track
These are used to specify a single track.
@ WC_SELECT_STATION
Select station (when joining stations); Window numbers:
RailTypes GetRailTypes(bool introduces)
Get list of rail types, regardless of company availability.
void CreateNestedTree()
Perform the first part of the initialization of a nested widget tree.
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.
static StationPickerSelection _station_gui
Settings of the station picker.
int GetSelectedClass() const override
Get the index of the selected class.
@ TRACK_BIT_RIGHT
Right track.
bool IsShaded() const
Is window shaded currently?
@ WC_BUILD_WAYPOINT
Build waypoint; Window numbers:
@ STAT_CLASS_DFLT
Default station class.
CursorID depot
Cursor for building a depot.
RailTypes GetCompanyRailTypes(CompanyID company, bool introduces)
Get the rail types the given company can build.
static debug_inline bool IsRailDepotTile(Tile t)
Is this tile rail tile and a rail depot?
@ VPM_Y_LIMITED
Drag only in Y axis with limited size.
void DisableWidget(WidgetID widget_index)
Sets a widget to disabled.
static DiagDirection _build_depot_direction
Currently selected depot direction.
Axis
Allow incrementing of DiagDirDiff variables.
@ TRANSPORT_RAIL
Transport by train.
static debug_inline uint Size()
Get the size of the map.
@ WC_SCEN_LAND_GEN
Landscape generation (in Scenario Editor); Window numbers:
@ HT_LINE
used for autorail highlighting (longer stretches), lower bits: direction
void SetDParam(size_t n, uint64_t v)
Set a string parameter v at index n in the global string parameter array.
SpriteID build_tunnel
button for building a tunnel
bool IsWaypointClass(const RoadStopClass &cls)
Test if a RoadStopClass is the waypoint class.
TileIndex _build_tunnel_endtile
The end of a tunnel; as hidden return from the tunnel build command for GUI purposes.
@ SIGNAL_CYCLE_ALL
Cycle through all signals visible to the player.
void InitializeRailGui()
Initialize rail building GUI settings.
void OnInvalidateData([[maybe_unused]] int data=0, [[maybe_unused]] bool gui_scope=true) override
Some data on this window has become invalid.
void MarkTileDirtyByTile(TileIndex tile, int bridge_level_offset, int tile_height_override)
Mark a tile given by its index dirty for repaint.
uint8_t station_platlength
the platform length, in tiles, for rail stations
SpriteID build_x_rail
button for building single rail in X direction
@ TRACK_LEFT
Track in the left corner of the tile (west)
Class to backup a specific variable and restore it upon destruction of this object to prevent stack v...
int ScaleSpriteTrad(int value)
Scale traditional pixel dimensions to GUI zoom level, for drawing sprites.
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 ResetSignalVariant(int32_t)
Updates the current signal variant used in the signal GUI to the one adequate to current year.
uint8_t disallowed_platforms
Bitmask of number of platforms available for the station.
TransportType GetTunnelBridgeTransportType(Tile t)
Tunnel: Get the transport type of the tunnel (road or rail) Bridge: Get the transport type of the bri...
void OnRealtimeTick([[maybe_unused]] uint delta_ms) override
Called periodically.
@ WPF_ROAD
This is a road waypoint.
@ TRACK_UPPER
Track in the upper corner of the tile (north)
void SetViewportCatchmentWaypoint(const Waypoint *wp, bool sel)
Select or deselect waypoint for coverage area highlight.
int64_t PackVelocity(uint speed, VehicleType type)
Pack velocity and vehicle type for use with SCC_VELOCITY string parameter.
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
static constexpr NWidgetPart _nested_signal_builder_widgets[]
Nested widget definition of the build signal window.
@ HT_DRAG_MASK
Mask for the tile drag-type modes.
Base class for all station-ish types.
Base class for windows opened from a toolbar.
void SetViewportCatchmentStation(const Station *st, bool sel)
Select or deselect station for coverage area highlight.
@ TRACK_LOWER
Track in the lower corner of the tile (south)
TileIndex GetOtherTunnelBridgeEnd(Tile t)
Determines type of the wormhole and returns its other end.
static Window * ShowStationBuilder(Window *parent)
Open station build window.
int top
y position of top edge of the window
OrthogonalTileArea TileArea
Shorthand for the much more common orthogonal tile area.
CursorID rail_nwse
Cursor for building rail in Y direction.
void RaiseWidget(WidgetID widget_index)
Marks a widget as raised.
@ DDSP_BUILD_SIGNALS
Signal placement.
int sig_sprite_bottom_offset
Maximum extent of signal GUI sprite from reference point towards bottom.
bool click_beep
Beep on a random selection of buttons.
int GetCharacterHeight(FontSize size)
Get height of a character for a given font size.
StringID GetTypeTooltip() const override
Get the tooltip string for the type grid.
@ SIGNAL_GUI_ALL
Show all signals, including block and presignals.
@ 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.
void MarkWholeScreenDirty()
This function mark the whole screen as dirty.
@ CA_TRAIN
Catchment for train stations with "modified catchment" enabled.
uint8_t station_spread
amount a station may spread
@ COMPANY_SPECTATOR
The client is spectating.
bool auto_remove_signals
automatically remove signals when in the way during rail construction
uint16_t sel_type
Selected station type within the class.
int GetSelectedType() const override
Get the selected type.
void Close(int data=0) override
Hide the window and all its child windows, and mark them for a later deletion.
void OnInvalidateData([[maybe_unused]] int data=0, [[maybe_unused]] bool gui_scope=true) override
Some data on this window has become invalid.
@ TRACK_BIT_LOWER
Lower track.
static debug_inline TileIndex TileVirtXY(uint x, uint y)
Get a tile from the virtual XY-coordinate.
void InitializeRailGUI()
Resets the rail GUI - sets default railtype to build and resets the signal GUI.
static const int PREVIEW_BOTTOM
Offset from bottom edge to draw preview.
void DrawType(int x, int y, int cls_id, int id) const override
Draw preview image of an item.
StringID GetClassName(int id) const override
Get the name of a class.
void OnPaint() override
The window must be repainted.
@ WC_BUILD_SIGNAL
Build signal toolbar; Window numbers:
std::unique_ptr< NWidgetBase > MakePickerClassWidgets()
Create nested widgets for the class picker widgets.
Data structure for an opened window.
Commands
List of commands.
SignalType
Type of signal, i.e.
static debug_inline bool IsTileType(Tile tile, TileType type)
Checks if a tile is a given tiletype.
static WindowDesc _signal_builder_desc(WDP_AUTO, nullptr, 0, 0, WC_BUILD_SIGNAL, WC_BUILD_TOOLBAR, WDF_CONSTRUCTION, _nested_signal_builder_widgets)
Signal selection window description.
static bool IsValidID(size_t index)
Tests whether given index can be used to get valid (non-nullptr) Titem.
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
@ TRACK_Y
Track along the y-axis (north-west to south-east)
static bool StationUsesDefaultType(const BaseStation *bst)
Test if a station/waypoint uses the default graphics.
int Width() const
Get width of Rect.
@ VPM_X_AND_Y_LIMITED
area of land of limited size
static NewGRFClass * Get(Tindex class_index)
Get a particular class.
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 ToggleWidgetLoweredState(WidgetID widget_index)
Invert the lowered/raised status of a widget.
SignalGUISettings signal_gui_mode
select which signal types are shown in the signal GUI
bool DrawStationTile(int x, int y, RailType railtype, Axis axis, StationClassID sclass, uint station)
Draw representation of a station tile for GUI purposes.
@ DDSP_REMOVE_STATION
Station removal.
StringID replace_text
Text used in the autoreplace GUI.
@ VPM_X_OR_Y
drag in X or Y direction
bool IsActive() const override
Should picker class/type selection be enabled?
void DrawSignalSprite(const Rect &r, SpriteID image) const
Draw dynamic a signal-sprite in a button in the signal GUI.
@ TRACK_X
Track along the x-axis (north-east to south-west)
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)
bool HasClassChoice() const override
Are there multiple classes to chose from?
bool Convert8bitBooleanCallback(const GRFFile *grffile, uint16_t cbid, uint16_t cb_res)
Converts a callback result into a boolean.
SpriteID convert_rail
button for converting rail
@ VPM_SIGNALDIRS
similar to VMP_RAILDIRS, but with different cursor
Axis GetAxisForNewRailWaypoint(TileIndex tile)
Get the axis for a new rail waypoint.
bool IsTypeAvailable(int cls_id, int id) const override
Test if an item is currently buildable.
static const StringID INVALID_STRING_ID
Constant representing an invalid string (16bit in case it is used in savegames)
GUISettings gui
settings related to the GUI
bool IsTypeAvailable(int cls_id, int id) const override
Test if an item is currently buildable.
Point selend
The location where the drag currently ends.
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
All data for a single hotkey.
StationClassID sel_class
Selected station class.
void ReinitGuiAfterToggleElrail(bool disable)
Re-initialize rail-build toolbar after toggling support for electric trains.
static Year year
Current year, starting at 0.
@ WN_GAME_OPTIONS_GAME_SETTINGS
Game settings.
uint GetCustomStationSpecIndex(Tile t)
Get the custom station spec for this tile.
@ TRACK_RIGHT
Track in the right corner of the tile (east)
void SetSelectedClass(int id) const override
Set the selected class.
static void SetDefaultRailGui()
Set the initial (default) railtype to use.
static constexpr NWidgetPart _nested_build_waypoint_widgets[]
Nested widget definition for the build NewGRF rail waypoint window.
constexpr debug_inline bool HasBit(const T x, const uint8_t y)
Checks if a bit in a value is set.