|
OpenTTD Source
14.0-beta3
|
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);
252 cycle_end = SIGTYPE_LAST;
255 if (cur_signal_on_tile <= SIGTYPE_LAST_NOPBS) {
258 cycle_end = SIGTYPE_LAST_NOPBS;
262 cycle_end = SIGTYPE_LAST;
269 tile, track,
_cur_signal_type,
_cur_signal_variant,
_convert_signal_button,
false,
_ctrl_pressed, cycle_start, cycle_end, 0, 0);
273 tile, track,
_settings_client.
gui.
default_signal_type, sigvar,
false,
false,
_ctrl_pressed, cycle_start, cycle_end, 0, 0);
358 VpSetPlaceSizingLimit(-1);
374 static void DoRailroadTrack(
Track track)
385 static void HandleAutodirPlacement()
394 DoRailroadTrack(trackstat);
422 TileVirtXY(_thd.
selstart.x, _thd.
selstart.y),
TileVirtXY(_thd.
selend.x, _thd.
selend.y), track, sigtype, sigvar,
false,
true, !
_settings_client.
gui.
drag_signals_fixed_distance,
_settings_client.
gui.
drag_signals_density);
438 this->last_user_action = INVALID_WID_RAT;
443 void Close([[maybe_unused]]
int data = 0)
override
459 void OnInvalidateData([[maybe_unused]]
int data = 0, [[maybe_unused]]
bool gui_scope =
true)
override
461 if (!gui_scope)
return;
474 bool OnTooltip([[maybe_unused]]
Point pt,
WidgetID widget, TooltipCloseCondition close_cond)
override
477 if (can_build)
return false;
481 GuiShowTooltips(
this, STR_TOOLBAR_DISABLED_NO_VEHICLE_AVAILABLE, close_cond);
515 void UpdateRemoveWidgetStatus(
WidgetID clicked_widget)
517 switch (clicked_widget) {
545 void SetStringParameters(
WidgetID widget)
const override
550 SetDParam(0, STR_TOOLBAR_RAILTYPE_VELOCITY);
559 void OnClick([[maybe_unused]]
Point pt,
WidgetID widget, [[maybe_unused]]
int click_count)
override
567 this->last_user_action = widget;
572 this->last_user_action = widget;
577 this->last_user_action = widget;
582 this->last_user_action = widget;
587 this->last_user_action = widget;
592 this->last_user_action = widget;
597 ShowBuildTrainDepotPicker(
this);
598 this->last_user_action = widget;
603 this->last_user_action = widget;
605 ShowBuildWaypointPicker(
this);
612 this->last_user_action = widget;
617 this->last_user_action = widget;
627 this->last_user_action = widget;
632 this->last_user_action = widget;
641 this->last_user_action = widget;
644 default: NOT_REACHED();
646 this->UpdateRemoveWidgetStatus(widget);
656 void OnPlaceObject([[maybe_unused]]
Point pt,
TileIndex tile)
override
658 switch (this->last_user_action) {
711 default: NOT_REACHED();
726 switch (select_proc) {
727 default: NOT_REACHED();
734 HandleAutodirPlacement();
757 HandleStationPlacement(start_tile, end_tile);
770 auto proc = [=](
bool test, StationID to_join) ->
bool {
803 void OnPlacePresize([[maybe_unused]]
Point pt,
TileIndex tile)
override
829 extern RailType _last_built_railtype;
835 static inline HotkeyList hotkeys{
"railtoolbar", {
853 static constexpr
NWidgetPart _nested_build_rail_widgets[] = {
894 static WindowDesc _build_rail_desc(__FILE__, __LINE__,
898 std::begin(_nested_build_rail_widgets), std::end(_nested_build_rail_widgets),
899 &BuildRailToolbarWindow::hotkeys
928 uint numtracks = ta.w;
929 uint platlength = ta.h;
937 auto proc = [=](
bool test, StationID to_join) ->
bool {
941 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);
982 for (
auto station_class : this->station_classes) {
986 this->vscroll->
SetCount(this->station_classes.size());
1027 this->vscroll =
nullptr;
1042 this->station_classes.
SetListing(this->last_sorting);
1043 this->station_classes.
SetFiltering(this->last_filtering);
1044 this->station_classes.
SetSortFuncs(this->sorter_funcs);
1068 this->vscroll2 =
nullptr;
1084 void Close([[maybe_unused]]
int data = 0)
override
1109 this->station_classes.clear();
1111 for (uint i = 0; i < StationClass::GetClassCount(); i++) {
1123 this->station_classes.
Filter(this->string_filter);
1124 this->station_classes.shrink_to_fit();
1126 this->station_classes.
Sort();
1128 this->vscroll->
SetCount(this->station_classes.size());
1158 void OnInvalidateData([[maybe_unused]]
int data = 0, [[maybe_unused]]
bool gui_scope =
true)
override
1160 if (!gui_scope)
return;
1180 void OnEditboxChanged(
WidgetID widget)
override
1210 for (uint bits = 0; bits < 7; bits++) {
1212 if (statspec ==
nullptr) {
1232 if (
top > r.bottom) {
1233 this->coverage_height +=
top - r.bottom;
1243 for (
auto station_class : this->station_classes) {
1246 size->width = std::max(size->width, d.width + padding.width);
1262 StringID str = this->GetWidget<NWidgetCore>(widget)->widget_data;
1263 for (
auto station_class : this->station_classes) {
1266 const StationSpec *statspec = stclass->GetSpec(j);
1267 SetDParam(0, (statspec !=
nullptr && statspec->
name != 0) ? statspec->
name : STR_STATION_CLASS_DFLT_STATION);
1271 size->width = std::max(size->width, d.width + padding.width);
1293 void DrawWidget(
const Rect &r,
WidgetID widget)
const override
1329 for (
auto station_class : this->station_classes) {
1330 if (this->vscroll->
IsVisible(statclass)) {
1342 uint16_t type = this->GetWidget<NWidgetBase>(widget)->GetParentWidget<
NWidgetMatrix>()->GetCurrentElement();
1367 if (this->vscroll !=
nullptr) {
1372 void SetStringParameters(
WidgetID widget)
const override
1376 SetDParam(0, (statspec !=
nullptr && statspec->
name != 0) ? statspec->
name : STR_STATION_CLASS_DFLT_STATION);
1380 void OnClick([[maybe_unused]]
Point pt,
WidgetID widget, [[maybe_unused]]
int click_count)
override
1409 for (uint i = 0; i < 7; i++) {
1442 for (uint i = 0; i < 7; i++) {
1467 for (uint i = 0; i < 7; i++) {
1476 for (uint i = 0; i < 7; i++) {
1506 if (it == this->station_classes.end())
return;
1527 uint16_t y = this->GetWidget<NWidgetBase>(widget)->GetParentWidget<
NWidgetMatrix>()->GetCurrentElement();
1569 static inline HotkeyList hotkeys{
"buildrailstation", {
1578 &StationClassIDSorter,
1585 static constexpr
NWidgetPart _nested_station_builder_widgets[] = {
1603 SetDataTip(STR_LIST_FILTER_OSKTITLE, STR_LIST_FILTER_TOOLTIP),
1615 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(),
1616 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(),
1645 SetDataTip(STR_STATION_BUILD_COVERAGE_OFF, STR_STATION_BUILD_COVERAGE_AREA_OFF_TOOLTIP),
1647 SetDataTip(STR_STATION_BUILD_COVERAGE_ON, STR_STATION_BUILD_COVERAGE_AREA_ON_TOOLTIP),
1675 WDP_AUTO,
"build_station_rail", 350, 0,
1678 std::begin(_nested_station_builder_widgets), std::end(_nested_station_builder_widgets),
1679 &BuildRailStationWindow::hotkeys
1703 int x =
CenterBounds(ir.left, ir.right, sprite_size.width - offset.x) - offset.x;
1728 void Close([[maybe_unused]]
int data = 0)
override
1737 this->sig_sprite_size.width = 0;
1738 this->sig_sprite_size.height = 0;
1739 this->sig_sprite_bottom_offset = 0;
1741 for (uint type =
SIGTYPE_BLOCK; type < SIGTYPE_END; type++) {
1743 for (uint lowered = 0; lowered < 2; lowered++) {
1746 this->sig_sprite_bottom_offset = std::max<int>(this->sig_sprite_bottom_offset, sprite_size.height);
1747 this->sig_sprite_size.width = std::max<int>(this->sig_sprite_size.width, sprite_size.width - offset.x);
1748 this->sig_sprite_size.height = std::max<int>(this->sig_sprite_size.height, sprite_size.height - offset.y);
1760 size->width = std::max(size->width, this->sig_sprite_size.width + padding.width);
1761 size->height = std::max(size->height, this->sig_sprite_size.height + padding.height);
1767 void SetStringParameters(
WidgetID widget)
const override
1776 void DrawWidget(
const Rect &r,
WidgetID widget)
const override
1788 void OnClick([[maybe_unused]]
Point pt,
WidgetID widget, [[maybe_unused]]
int click_count)
override
1854 void OnInvalidateData([[maybe_unused]]
int data = 0, [[maybe_unused]]
bool gui_scope =
true)
override
1856 if (!gui_scope)
return;
1964 void DrawWidget(
const Rect &r,
WidgetID widget)
const override
1978 void OnClick([[maybe_unused]]
Point pt,
WidgetID widget, [[maybe_unused]]
int click_count)
override
2015 static WindowDesc _build_depot_desc(__FILE__, __LINE__,
2022 static void ShowBuildTrainDepotPicker(
Window *parent)
2029 static const uint FILTER_LENGTH = 20;
2052 this->BuildPickerList();
2055 void Close([[maybe_unused]]
int data = 0)
override
2063 if (this->string_filter.
IsEmpty())
return true;
2065 if (statspec ==
nullptr) {
2074 return this->string_filter.
GetState();
2077 void BuildPickerList()
2083 for (uint i = 0; i < this->waypoints->
GetSpecCount(); i++) {
2084 const StationSpec *statspec = this->waypoints->GetSpec(i);
2085 if (!FilterByText(statspec))
continue;
2087 this->list.push_back(i);
2092 matrix->
SetCount((
int)this->list.size());
2096 uint UpdateSelection(uint type)
2098 auto found = std::find(std::begin(this->list), std::end(this->list), type);
2099 if (found != std::end(this->list))
return found - std::begin(this->list);
2102 if (this->list.empty()) {
2116 size->width +=
resize->width * 2;
2117 size->height +=
resize->height * 1;
2130 void SetStringParameters(
WidgetID widget)
const override
2135 if (statspec ==
nullptr) {
2136 SetDParam(0, STR_STATION_CLASS_WAYP_WAYPOINT);
2148 this->BuildPickerList();
2152 void DrawWidget(
const Rect &r,
WidgetID widget)
const override
2156 uint16_t type = this->list.at(this->GetWidget<NWidgetBase>(widget)->GetParentWidget<NWidgetMatrix>()->GetCurrentElement());
2157 const StationSpec *statspec = this->waypoints->GetSpec(type);
2175 void OnClick([[maybe_unused]]
Point pt,
WidgetID widget, [[maybe_unused]]
int click_count)
override
2179 uint16_t sel = this->GetWidget<NWidgetBase>(widget)->GetParentWidget<
NWidgetMatrix>()->GetCurrentElement();
2180 assert(sel < this->list.size());
2181 uint16_t type = this->list.at(sel);
2184 const StationSpec *statspec = this->waypoints->GetSpec(type);
2188 this->GetWidget<NWidgetBase>(widget)->GetParentWidget<
NWidgetMatrix>()->SetClicked(sel);
2196 void OnInvalidateData([[maybe_unused]]
int data = 0, [[maybe_unused]]
bool gui_scope =
true)
override
2198 if (!gui_scope)
return;
2202 void OnEditboxChanged(
WidgetID wid)
override
2212 CheckRedrawWaypointCoverage(
this);
2226 NWidget(
WWT_EDITBOX, COLOUR_DARK_GREEN,
WID_BRW_FILTER),
SetPadding(2),
SetResize(1, 0),
SetFill(1, 0),
SetDataTip(STR_LIST_FILTER_OSKTITLE, STR_LIST_FILTER_TOOLTIP),
2238 NWidget(
WWT_TEXT, COLOUR_DARK_GREEN,
WID_BRW_NAME),
SetPadding(2),
SetResize(1, 0),
SetFill(1, 0),
SetDataTip(STR_JUST_STRING, STR_NULL),
SetTextStyle(TC_ORANGE),
SetAlignment(
SA_CENTER),
2244 static WindowDesc _build_waypoint_desc(__FILE__, __LINE__,
2251 static void ShowBuildWaypointPicker(
Window *parent)
2271 extern RailType _last_built_railtype;
2285 extern RailType _last_built_railtype;
2291 memset(count, 0,
sizeof(count));
2300 if (count[rt] > 0)
break;
2307 std::vector<RailType>::const_iterator it = std::find_if(_sorted_railtypes.begin(), _sorted_railtypes.end(),
2308 [](
RailType r){ return HasRailTypeAvail(_local_company, r); });
2314 std::vector<RailType>::const_reverse_iterator it = std::find_if(_sorted_railtypes.rbegin(), _sorted_railtypes.rend(),
2315 [](
RailType r){ return HasRailTypeAvail(_local_company, r); });
2380 if (for_replacement) {
2391 list.push_back(std::make_unique<DropDownListStringItem>(STR_REPLACE_ALL_RAILTYPE,
INVALID_RAILTYPE,
false));
2396 if (!for_replacement) {
2397 for (
const auto &rt : _sorted_railtypes) {
2398 if (!
HasBit(used_railtypes, rt))
continue;
2404 for (
const auto &rt : _sorted_railtypes) {
2406 if (!
HasBit(used_railtypes, rt))
continue;
2412 if (for_replacement) {
2415 StringID str = rti->
max_speed > 0 ? STR_TOOLBAR_RAILTYPE_VELOCITY : STR_JUST_STRING;
2422 list.push_back(std::make_unique<DropDownListStringItem>(STR_NONE,
INVALID_RAILTYPE,
true));
CursorID convert
Cursor for converting track.
@ 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.
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.
void OnPaint() override
The window must be repainted.
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
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.
BuildRalStationHotkeys
Enum referring to the Hotkeys in the build rail station window.
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:
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)
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 SetFocusedWindow(Window *w)
Set the window that has the focus.
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.
void SetFilterState(bool state)
Enable or disable the filter.
RailTypes avail_railtypes
Rail types available to this company.
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.
SpriteID tunnel
tunnel sprites base
ViewportDragDropSelectionProcess
Drag and drop selection process, or, what to do with an area of land when you've selected it.
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.
void SetWidgetDirty(WidgetID widget_index) const
Invalidate a widget, i.e.
static SignalVariant _cur_signal_variant
set the signal variant (for signal GUI)
uint32_t StringID
Numeric value that represents a string, independent of the selected language.
static RailStationGUISettings _railstation
Settings of the station builder GUI.
@ TRACK_LOWER
Track in the lower corner of the tile (south)
void CloseWindowById(WindowClass cls, WindowNumber number, bool force, int data)
Close a window by its class and window number (if it is open).
@ 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.
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.
Tindex index
Index of this pool item.
static QueryString editbox
Filter editbox.
static void PlaceRail_Waypoint(TileIndex tile)
Place a rail waypoint.
SpriteID signals[SIGTYPE_END][2][2]
signal GUI sprites (type, variant, state)
@ TRACK_X
Track along the x-axis (north-east to south-west)
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.
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.
constexpr TileIndex INVALID_TILE
The very nice invalid tile marker.
static bool StationClassIDSorter(StationClassID const &a, StationClassID const &b)
Sort station classes by StationClassID.
This struct contains all the info that is needed to draw and construct tracks.
CursorID autorail
Cursor for autorail tool.
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
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...
@ SND_20_CONSTRUCTION_RAIL
30 == 0x1E Construction: rail infrastructure
void RaiseButtons(bool autoraise=false)
Raise the buttons of the window.
bool IsLevelCrossingTile(Tile t)
Return whether a tile is a level crossing tile.
@ VPM_FIX_Y
drag only in Y axis
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.
SignalVariant
Variant of the signal, i.e.
static EventState BuildRailStationGlobalHotkeys(int hotkey)
Handler for global hotkeys of the BuildRailStationWindow.
static const CursorID ANIMCURSOR_DEMOLISH
704 - 707 - demolish dynamite
GRFConfig * GetGRFConfig(uint32_t grfid, uint32_t mask)
Retrieve a NewGRF from the current config by its grfid.
constexpr uint Vertical() const
Get total vertical padding of RectPadding.
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)
RailType GetRailType(Tile t)
Gets the rail type of the given tile.
struct RailTypeInfo::@26 strings
Strings associated with the rail type.
const Scrollbar * GetScrollbar(WidgetID widnum) const
Return the Scrollbar to a widget index.
static RailType _cur_railtype
Rail type of the current build-rail toolbar.
byte drag_signals_density
many signals density
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.
@ INVALID_ROADTYPE
flag for invalid roadtype
@ TRACK_RIGHT
Track in the right corner of the tile (east)
bool NeedRebuild() const
Check if a rebuild is needed.
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?
char *const buf
buffer in which text is saved
SignalType
Type of signal, i.e.
@ 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...
SpriteID build_depot
button for building depots
High level window description.
constexpr uint Horizontal() const
Get total horizontal padding of RectPadding.
int ScaleGUITrad(int value)
Scale traditional pixel dimensions to GUI zoom level.
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.
constexpr bool IsInsideBS(const T x, const size_t base, const size_t size)
Checks if a value is between a window started at some base point.
@ 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).
uint8_t default_rail_type
the default rail type for the rail GUI
@ WKC_GLOBAL_HOTKEY
Fake keycode bit to indicate global hotkeys.
static WindowDesc _signal_builder_desc(__FILE__, __LINE__, WDP_AUTO, nullptr, 0, 0, WC_BUILD_SIGNAL, WC_BUILD_TOOLBAR, WDF_CONSTRUCTION, std::begin(_nested_signal_builder_widgets), std::end(_nested_signal_builder_widgets))
Signal selection window description.
RailType
Enumeration for all possible railtypes.
@ STAT_CLASS_WAYP
Waypoint class.
ResizeInfo resize
Resize information.
Common return value for all commands.
@ TRACK_Y
Track along the y-axis (north-west to south-east)
CursorID rail_ns
Cursor for building rail in N-S direction.
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
Information about GRF, used in the game and (part of it) in savegames.
@ FS_NORMAL
Index of the normal font in the font tables.
void InitNested(WindowNumber number=0)
Perform complete initialization of the Window with nested widgets, to allow use.
bool Filter(FilterFunction *decide, F filter_data)
Filter the list.
@ 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
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)
std::conditional_t< std::is_same_v< P, std::nullptr_t >, bool(const T &, const T &), bool(const T &, const T &, const P)> SortFunction
Signature of sort function.
@ 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
@ TRACK_UPPER
Track in the upper corner of the tile (north)
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
@ BRASHK_FOCUS_FILTER_BOX
Focus the edit box for editing the filter string.
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.
Struct containing information relating to NewGRF classes for stations and airports.
bool HasStationTileRail(Tile t)
Has this station tile a rail? In other words, is this station tile a rail station or rail waypoint?
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 ReInit(int rx=0, int ry=0, bool reposition=false)
Re-initialize a window, and optionally change its size.
Data structure describing what to show in the list (filter criteria).
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 name
Name of this station.
@ WC_BUILD_BRIDGE
Build bridge; Window numbers:
void ShowSelectWaypointIfNeeded(TileArea ta, StationPickerCmdProc proc)
Show the waypoint selection window when needed.
@ TRACK_LEFT
Track in the left corner of the tile (west)
@ 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.
Coordinates of a point in 2D.
DiagDirection
Enumeration for diagonal directions.
bool IsWidgetDisabled(WidgetID widget_index) const
Gets the enabled/disabled status of a widget.
StringFilter string_filter
Filter for available station classes.
static debug_inline RailTileType GetRailTileType(Tile t)
Returns the RailTileType (normal with or without signals, waypoint or depot).
int CenterBounds(int min, int max, int size)
Determine where to draw a centred object inside a widget.
@ CBM_STATION_AVAIL
Availability of station in construction window.
@ HT_DIR_MASK
masks the drag-direction
byte station_spread
amount a station may spread
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.
void BuildStationClassesAvailable()
Builds the filter list of available station classes.
@ TRACK_BIT_LOWER
Lower track.
bool IsValidAxis(Axis d)
Checks if an integer value is a valid Axis.
byte disallowed_platforms
Bitmask of number of platforms available for the station.
CursorID rail_ew
Cursor for building rail in E-W direction.
bool SetFocusedWidget(WidgetID widget_index)
Set focus within this window to the given widget.
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.
uint32_t SpriteID
The number of a sprite, without mapping bits and colourtables.
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.
bool CanBuildVehicleInfrastructure(VehicleType type, byte subtype)
Check whether we can build infrastructure for the given vehicle type.
void SetWidgetLoweredState(WidgetID widget_index, bool lowered_stat)
Sets the lowered/raised status of a widget.
byte GetDigitWidth(FontSize size)
Return the maximum width of single digit.
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:
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.
@ SIGTYPE_BLOCK
block signal
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.
@ RAILTYPE_RAIL
Standard non-electric rails.
void OnRealtimeTick([[maybe_unused]] uint delta_ms) override
Called periodically.
StringID menu_text
Name of this rail type in the main toolbar dropdown.
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 ForceRebuild()
Force that a rebuild is needed.
@ 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.
@ TRACK_BIT_HORZ
Upper and lower track.
std::map< WidgetID, QueryString * > querystrings
QueryString associated to WWT_EDITBOX widgets.
bool confirm
Play sound effect on successful constructions or other actions.
int cancel_button
Widget button of parent window to simulate when pressing CANCEL in OSK.
StationClassID station_class
Currently selected custom station class (if newstations is true )
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
@ 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.
StringFilter string_filter
Filter for waypoint name.
bool IsShaded() const
Is window shaded currently?
@ TRACK_BIT_LEFT
Left track.
GUIList< StationClassID, std::nullptr_t, StringFilter & > GUIStationClassList
Type definition for the list to hold available station classes.
@ WC_BUILD_WAYPOINT
Build waypoint; Window numbers:
CursorID depot
Cursor for building a depot.
RailTypes GetCompanyRailTypes(CompanyID company, bool introduces)
Get the rail types the given company can build.
@ 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.
static debug_inline uint Size()
Get the size of the map.
static GUIStationClassList::FilterFunction *const filter_funcs[]
Filter functions of the GUIStationClassList.
@ 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.
@ COMPANY_SPECTATOR
The client is spectating.
@ RAILTYPE_END
Used for iterations.
SpriteID build_tunnel
button for building a tunnel
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 ResetState()
Reset the matching state to process a new item.
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.
SpriteID build_x_rail
button for building single rail in X direction
uint line_height
Height of a single line in the newstation selection matrix (WID_BRAS_NEWST_LIST widget).
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.
std::string GetString(StringID string)
Resolve the given StringID into a std::string with all the associated DParam lookups and formatting.
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.
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.
bool GetState() const
Get the matching state of the current item.
StringID name
Name of this class.
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 const uint8_t PC_BLACK
Black palette colour.
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 windows opened from a toolbar.
void SetViewportCatchmentStation(const Station *st, bool sel)
Select or deselect station for coverage area highlight.
static uint16_t _cur_waypoint_type
Currently selected waypoint type.
TileIndex GetOtherTunnelBridgeEnd(Tile t)
Determines type of the wormhole and returns its other end.
static const int ACTION_CLEAR
Clear editbox.
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.
CursorID rail_nwse
Cursor for building rail in Y direction.
void RaiseWidget(WidgetID widget_index)
Marks a widget as raised.
TrackBits
Allow incrementing of Track variables.
@ DDSP_BUILD_SIGNALS
Signal placement.
void SetFilterFuncs(FilterFunction *const *n_funcs)
Hand the array of filter function pointers to the sort list.
int sig_sprite_bottom_offset
Maximum extent of signal GUI sprite from reference point towards bottom.
GUIStationClassList station_classes
Available station classes.
@ SA_CENTER
Center both horizontally and vertically.
bool click_beep
Beep on a random selection of buttons.
int GetCharacterHeight(FontSize size)
Get height of a character for a given font size.
@ 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.
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.
void SetSortFuncs(SortFunction *const *n_funcs)
Hand the array of sort function pointers to the sort list.
void RebuildDone()
Notify the sortlist that the rebuild is done.
bool CDECL FilterFunction(const StationClassID *, StringFilter &)
Signature of filter function.
bool auto_remove_signals
automatically remove signals when in the way during rail construction
int DrawString(int left, int right, int top, std::string_view str, TextColour colour, StringAlignment align, bool underline, FontSize fontsize)
Draw string, possibly truncated to make it fit in its allocated space.
byte station_platlength
the platform length, in tiles, for rail stations
void OnInvalidateData([[maybe_unused]] int data=0, [[maybe_unused]] bool gui_scope=true) override
Some data on this window has become invalid.
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 Listing last_sorting
Default sorting of GUIStationClassList.
void OnPaint() override
The window must be repainted.
@ WC_BUILD_SIGNAL
Build signal toolbar; Window numbers:
Data structure for an opened window.
Commands
List of commands.
byte callback_mask
Bitmask of station callbacks that have to be called.
static debug_inline bool IsTileType(Tile tile, TileType type)
Checks if a tile is a given tiletype.
@ VEH_TRAIN
Train vehicle type.
static bool IsValidID(size_t index)
Tests whether given index can be used to get valid (non-nullptr) Titem.
byte disallowed_lengths
Bitmask of platform lengths available for the station.
void DrawWidgets() const
Paint all widgets of a window.
uint16_t station_count
Number of custom stations (if newstations is true )
@ RAIL_TILE_DEPOT
Depot (one entrance)
const struct GRFFile * grffile
grf file that introduced this entity
int Width() const
Get width of Rect.
Track
These are used to specify a single track.
@ VPM_X_AND_Y_LIMITED
area of land of limited size
@ DIAGDIR_NE
Northeast, upper right on your monitor.
static WindowDesc _station_builder_desc(__FILE__, __LINE__, WDP_AUTO, "build_station_rail", 350, 0, WC_BUILD_STATION, WC_BUILD_TOOLBAR, WDF_CONSTRUCTION, std::begin(_nested_station_builder_widgets), std::end(_nested_station_builder_widgets), &BuildRailStationWindow::hotkeys)
High level window description of the station-build window (default & newGRF)
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 Sort(Comp compare)
Sort the list.
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.
StringID replace_text
Text used in the autoreplace GUI.
@ VPM_X_OR_Y
drag in X or Y direction
void OnInvalidateData([[maybe_unused]] int data=0, [[maybe_unused]] bool gui_scope=true) override
Some data on this window has become invalid.
void SelectOtherClass(StationClassID station_class)
Select the specified station class.
void DrawSignalSprite(const Rect &r, SpriteID image) const
Draw dynamic a signal-sprite in a button in the signal GUI.
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.
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
uint16_t station_type
Station type within the currently selected custom station class (if newstations is true )
static bool CDECL TagNameFilter(StationClassID const *sc, StringFilter &filter)
Filter station classes by class name.
void SetFiltering(Filtering f)
Import filter conditions.
@ VPM_SIGNALDIRS
similar to VMP_RAILDIRS, but with different cursor
QueryString filter_editbox
Filter editbox.
Dimension GetStringBoundingBox(std::string_view str, FontSize start_fontsize)
Return the string dimension in pixels.
Axis orientation
Currently selected rail station orientation.
GUISettings gui
settings related to the GUI
Point selend
The location where the drag currently ends.
const char * GetName() const
Get the name of this grf.
Data about how and where to blit pixels.
bool persistent_buildingtools
keep the building tools active after usage
void SetListing(Listing l)
Import sort conditions.
bool modified_catchment
different-size catchment areas
All data for a single hotkey.
void ReinitGuiAfterToggleElrail(bool disable)
Re-initialize rail-build toolbar after toggling support for electric trains.
static Year year
Current year, starting at 0.
@ 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.
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.