|
OpenTTD Source
14.0-beta1
|
Go to the documentation of this file.
46 #include "table/strings.h"
51 static void ShowRoadDepotPicker(
Window *parent);
54 static bool _one_way_button_clicked;
56 static Axis _place_road_dir;
57 static bool _place_road_start_half_x;
58 static bool _place_road_start_half_y;
59 static bool _place_road_end_half;
69 uint16_t roadstop_type;
70 uint16_t roadstop_count;
80 if (roadstopspec ==
nullptr)
return true;
162 if (result.
Failed())
return;
184 if (result.
Failed())
return;
189 bool connect_to_road =
true;
190 if ((uint)spec_class < RoadStopClass::GetClassCount() && spec_index <
RoadStopClass::Get(spec_class)->GetSpecCount()) {
195 if (connect_to_road) {
196 TileArea roadstop_area(tile, width, length);
197 for (
TileIndex cur_tile : roadstop_area) {
222 uint16_t spec_index = _roadstop_gui_settings.roadstop_type;
224 auto proc = [=](
bool test, StationID to_join) ->
bool {
227 ddir, rt, spec_class, spec_index, INVALID_STATION, adjacent).Succeeded();
230 ddir, rt, spec_class, spec_index, to_join, adjacent);
246 if (_roadstop_gui_settings.orientation <
DIAGDIR_END) {
264 if (_roadstop_gui_settings.orientation <
DIAGDIR_END) {
273 typedef void OnButtonClick(
Window *w);
315 this->Initialize(_cur_roadtype);
320 if (RoadTypeIsRoad(this->roadtype)) {
325 this->last_started_action = INVALID_WID_ROT;
330 void Close([[maybe_unused]]
int data = 0)
override
342 void OnInvalidateData([[maybe_unused]]
int data = 0, [[maybe_unused]]
bool gui_scope =
true)
override
344 if (!gui_scope)
return;
345 RoadTramType rtt = GetRoadTramType(this->roadtype);
358 if (_game_mode != GM_EDITOR) {
361 this->GetWidget<NWidgetCore>(
WID_ROT_DEPOT)->SetToolTip(STR_TOOLBAR_DISABLED_NO_VEHICLE_AVAILABLE);
362 this->GetWidget<NWidgetCore>(
WID_ROT_BUS_STATION)->SetToolTip(STR_TOOLBAR_DISABLED_NO_VEHICLE_AVAILABLE);
363 this->GetWidget<NWidgetCore>(
WID_ROT_TRUCK_STATION)->SetToolTip(STR_TOOLBAR_DISABLED_NO_VEHICLE_AVAILABLE);
365 this->GetWidget<NWidgetCore>(
WID_ROT_DEPOT)->SetToolTip(rtt == RTT_ROAD ? STR_ROAD_TOOLBAR_TOOLTIP_BUILD_ROAD_VEHICLE_DEPOT : STR_ROAD_TOOLBAR_TOOLTIP_BUILD_TRAM_VEHICLE_DEPOT);
366 this->GetWidget<NWidgetCore>(
WID_ROT_BUS_STATION)->SetToolTip(rtt == RTT_ROAD ? STR_ROAD_TOOLBAR_TOOLTIP_BUILD_BUS_STATION : STR_ROAD_TOOLBAR_TOOLTIP_BUILD_PASSENGER_TRAM_STATION);
367 this->GetWidget<NWidgetCore>(
WID_ROT_TRUCK_STATION)->SetToolTip(rtt == RTT_ROAD ? STR_ROAD_TOOLBAR_TOOLTIP_BUILD_TRUCK_LOADING_BAY : STR_ROAD_TOOLBAR_TOOLTIP_BUILD_CARGO_TRAM_STATION);
388 if (_game_mode != GM_EDITOR) {
406 void SetStringParameters(
WidgetID widget)
const override
410 SetDParam(0, STR_TOOLBAR_RAILTYPE_VELOCITY);
429 switch (clicked_widget) {
431 if (RoadTypeIsRoad(this->roadtype)) {
453 if (RoadTypeIsRoad(this->roadtype)) {
464 if (RoadTypeIsRoad(this->roadtype)) {
473 void OnClick([[maybe_unused]]
Point pt,
WidgetID widget, [[maybe_unused]]
int click_count)
override
476 _one_way_button_clicked =
false;
480 this->last_started_action = widget;
485 this->last_started_action = widget;
490 this->last_started_action = widget;
495 this->last_started_action = widget;
500 ShowRoadDepotPicker(
this);
501 this->last_started_action = widget;
508 this->last_started_action = widget;
515 this->last_started_action = widget;
523 SetSelectionRed(
false);
528 this->last_started_action = widget;
533 this->last_started_action = widget;
546 this->last_started_action = widget;
549 default: NOT_REACHED();
561 void OnPlaceObject([[maybe_unused]]
Point pt,
TileIndex tile)
override
565 switch (this->last_started_action) {
568 _place_road_start_half_x = _tile_fract_coords.x >= 8;
574 _place_road_start_half_y = _tile_fract_coords.y >= 8;
580 _place_road_start_half_x = _tile_fract_coords.x >= 8;
581 _place_road_start_half_y = _tile_fract_coords.y >= 8;
591 tile, _cur_roadtype, _road_depot_orientation);
615 default: NOT_REACHED();
627 if (RoadTypeIsRoad(this->roadtype)) {
645 switch (select_proc) {
647 _place_road_end_half = pt.x & 8;
651 _place_road_end_half = pt.y & 8;
658 ( (_tile_fract_coords.x < _tile_fract_coords.y && (_tile_fract_coords.x + _tile_fract_coords.y) < 16) ||
659 (_tile_fract_coords.x > _tile_fract_coords.y && (_tile_fract_coords.x + _tile_fract_coords.y) > 16) ))) {
662 _place_road_end_half = pt.x & 8;
666 _place_road_end_half = pt.y & 8;
681 switch (select_proc) {
682 default: NOT_REACHED();
695 bool start_half = _place_road_dir ==
AXIS_Y ? _place_road_start_half_y : _place_road_start_half_x;
699 end_tile, start_tile, _cur_roadtype, _place_road_dir, start_half, _place_road_end_half);
702 end_tile, start_tile, _cur_roadtype, _place_road_dir, _one_way_button_clicked ?
DRD_NORTHBOUND :
DRD_NONE, start_half, _place_road_end_half,
false);
738 void OnPlacePresize([[maybe_unused]]
Point pt,
TileIndex tile)
override
759 switch (_game_mode) {
777 static EventState RoadToolbarGlobalHotkeys(
int hotkey)
779 extern RoadType _last_built_roadtype;
783 static EventState TramToolbarGlobalHotkeys(
int hotkey)
785 extern RoadType _last_built_tramtype;
789 static inline HotkeyList road_hotkeys{
"roadtoolbar", {
802 }, RoadToolbarGlobalHotkeys};
804 static inline HotkeyList tram_hotkeys{
"tramtoolbar", {
816 }, TramToolbarGlobalHotkeys};
819 static constexpr
NWidgetPart _nested_build_road_widgets[] = {
854 static WindowDesc _build_road_desc(__FILE__, __LINE__,
858 std::begin(_nested_build_road_widgets), std::end(_nested_build_road_widgets),
859 &BuildRoadToolbarWindow::road_hotkeys
862 static constexpr
NWidgetPart _nested_build_tramway_widgets[] = {
895 static WindowDesc _build_tramway_desc(__FILE__, __LINE__,
899 std::begin(_nested_build_tramway_widgets), std::end(_nested_build_tramway_widgets),
900 &BuildRoadToolbarWindow::tram_hotkeys
916 _cur_roadtype = roadtype;
918 return AllocateWindowDescFront<BuildRoadToolbarWindow>(RoadTypeIsRoad(_cur_roadtype) ? &_build_road_desc : &_build_tramway_desc,
TRANSPORT_ROAD);
921 static constexpr
NWidgetPart _nested_build_road_scen_widgets[] = {
950 static WindowDesc _build_road_scen_desc(__FILE__, __LINE__,
951 WDP_AUTO,
"toolbar_road_scen", 0, 0,
954 std::begin(_nested_build_road_scen_widgets), std::end(_nested_build_road_scen_widgets),
955 &BuildRoadToolbarWindow::road_hotkeys
958 static constexpr
NWidgetPart _nested_build_tramway_scen_widgets[] = {
985 static WindowDesc _build_tramway_scen_desc(__FILE__, __LINE__,
986 WDP_AUTO,
"toolbar_tram_scen", 0, 0,
989 std::begin(_nested_build_tramway_scen_widgets), std::end(_nested_build_tramway_scen_widgets),
990 &BuildRoadToolbarWindow::tram_hotkeys
1000 _cur_roadtype = roadtype;
1002 return AllocateWindowDescFront<BuildRoadToolbarWindow>(RoadTypeIsRoad(_cur_roadtype) ? &_build_road_scen_desc : &_build_tramway_scen_desc,
TRANSPORT_ROAD);
1011 if (RoadTypeIsTram(_cur_roadtype)) {
1012 this->GetWidget<NWidgetCore>(
WID_BROD_CAPTION)->widget_data = STR_BUILD_DEPOT_TRAM_ORIENTATION_CAPTION;
1014 this->GetWidget<NWidgetCore>(i)->tool_tip = STR_BUILD_DEPOT_TRAM_ORIENTATION_SELECT_TOOLTIP;
1029 void DrawWidget(
const Rect &r,
WidgetID widget)
const override
1043 void OnClick([[maybe_unused]]
Point pt,
WidgetID widget, [[maybe_unused]]
int click_count)
override
1063 static constexpr
NWidgetPart _nested_build_road_depot_widgets[] = {
1082 static WindowDesc _build_road_depot_desc(__FILE__, __LINE__,
1086 std::begin(_nested_build_road_depot_widgets), std::end(_nested_build_road_depot_widgets)
1089 static void ShowRoadDepotPicker(
Window *parent)
1119 void EnsureSelectedClassIsVisible()
1122 for (
auto rs_class : this->roadstop_classes) {
1123 if (rs_class == _roadstop_gui_settings.roadstop_class)
break;
1126 this->vscrollList->
SetCount(this->roadstop_classes.size());
1130 void CheckOrientationValid()
1132 if (_roadstop_gui_settings.orientation >=
DIAGDIR_END)
return;
1147 this->vscrollList =
nullptr;
1148 this->vscrollMatrix =
nullptr;
1149 this->roadStopType = rs;
1167 this->roadstop_classes.
SetListing(this->last_sorting);
1168 this->roadstop_classes.
SetFiltering(this->last_filtering);
1169 this->roadstop_classes.
SetSortFuncs(this->sorter_funcs);
1174 BuildRoadStopClassesAvailable();
1177 if (RoadTypeIsTram(_cur_roadtype) && _roadstop_gui_settings.orientation <
DIAGDIR_END) {
1193 if (!newstops || _roadstop_gui_settings.roadstop_class >= (
int)RoadStopClass::GetClassCount()) {
1197 _roadstop_gui_settings.roadstop_type = 0;
1203 _roadstop_gui_settings.roadstop_type = 0;
1206 _roadstop_gui_settings.roadstop_type = std::min((
int)_roadstop_gui_settings.roadstop_type, _roadstop_gui_settings.roadstop_count - 1);
1213 this->SelectFirstAvailableTypeIfUnavailable();
1217 matrix->
SetCount(_roadstop_gui_settings.roadstop_count);
1218 matrix->
SetClicked(_roadstop_gui_settings.roadstop_type);
1220 this->EnsureSelectedClassIsVisible();
1221 this->CheckOrientationValid();
1225 void Close([[maybe_unused]]
int data = 0)
override
1245 inline bool ShowNewStops()
const
1247 return this->vscrollList !=
nullptr;
1250 void BuildRoadStopClassesAvailable()
1252 if (!this->roadstop_classes.
NeedRebuild())
return;
1254 this->roadstop_classes.clear();
1256 for (uint i = 0; i < RoadStopClass::GetClassCount(); i++) {
1266 if (this->ShowNewStops()) {
1267 this->roadstop_classes.
Filter(this->string_filter);
1268 this->roadstop_classes.shrink_to_fit();
1270 this->roadstop_classes.
Sort();
1272 this->vscrollList->
SetCount(this->roadstop_classes.size());
1276 void SelectFirstAvailableTypeIfUnavailable()
1281 if (
IsRoadStopAvailable(rs_class->GetSpec(_roadstop_gui_settings.roadstop_type), st))
return;
1282 for (uint i = 0; i < _roadstop_gui_settings.roadstop_count; i++) {
1284 _roadstop_gui_settings.roadstop_type = i;
1290 void OnInvalidateData([[maybe_unused]]
int data = 0, [[maybe_unused]]
bool gui_scope =
true)
override
1292 if (!gui_scope)
return;
1294 this->BuildRoadStopClassesAvailable();
1308 void OnEditboxChanged(
WidgetID widget)
override
1324 SetTileSelectBigSize(-rad, -rad, 2 * rad, 2 * rad);
1340 if (
top > r.bottom) {
1341 this->coverage_height +=
top - r.bottom;
1351 for (
auto rs_class : this->roadstop_classes) {
1354 size->width = std::max(size->width, d.width + padding.width);
1363 StringID str = this->GetWidget<NWidgetCore>(widget)->widget_data;
1364 for (
auto roadstop_class : this->roadstop_classes) {
1367 const RoadStopSpec *roadstopspec = rs_class->GetSpec(j);
1368 SetDParam(0, (roadstopspec !=
nullptr && roadstopspec->
name != 0) ? roadstopspec->
name : STR_STATION_CLASS_DFLT_ROADSTOP);
1372 size->width = std::max(size->width, d.width + padding.width);
1406 default: NOT_REACHED();
1410 void DrawWidget(
const Rect &r,
WidgetID widget)
const override
1428 if (spec ==
nullptr || disabled) {
1441 for (
auto rs_class : this->roadstop_classes) {
1442 if (this->vscrollList->
IsVisible(statclass)) {
1445 rs_class == _roadstop_gui_settings.roadstop_class ? TC_WHITE : TC_BLACK);
1454 uint16_t type = this->GetWidget<NWidgetBase>(widget)->GetParentWidget<
NWidgetMatrix>()->GetCurrentElement();
1455 assert(type < _roadstop_gui_settings.roadstop_count);
1467 if (spec ==
nullptr) {
1468 StationPickerDrawSprite(x, y, st,
INVALID_RAILTYPE, _cur_roadtype, _roadstop_gui_settings.orientation);
1470 DiagDirection orientation = _roadstop_gui_settings.orientation;
1485 if (this->vscrollList !=
nullptr) {
1490 void SetStringParameters(
WidgetID widget)
const override
1494 SetDParam(0, (roadstopspec !=
nullptr && roadstopspec->
name != 0) ? roadstopspec->
name : STR_STATION_CLASS_DFLT_ROADSTOP);
1498 void OnClick([[maybe_unused]]
Point pt,
WidgetID widget, [[maybe_unused]]
int click_count)
override
1531 if (it == this->roadstop_classes.end())
return;
1534 _roadstop_gui_settings.roadstop_class = class_id;
1536 _roadstop_gui_settings.roadstop_count = rsclass->
GetSpecCount();
1537 _roadstop_gui_settings.roadstop_type = std::min((
int)_roadstop_gui_settings.roadstop_type, std::max(0, (
int)_roadstop_gui_settings.roadstop_count - 1));
1538 this->SelectFirstAvailableTypeIfUnavailable();
1541 matrix->
SetCount(_roadstop_gui_settings.roadstop_count);
1542 matrix->
SetClicked(_roadstop_gui_settings.roadstop_type);
1543 this->CheckOrientationValid();
1552 uint16_t y = this->GetWidget<NWidgetBase>(widget)->GetParentWidget<
NWidgetMatrix>()->GetCurrentElement();
1553 if (y >= _roadstop_gui_settings.roadstop_count)
return;
1560 _roadstop_gui_settings.roadstop_type = y;
1562 this->GetWidget<NWidgetBase>(widget)->GetParentWidget<
NWidgetMatrix>()->SetClicked(_roadstop_gui_settings.roadstop_type);
1567 this->CheckOrientationValid();
1585 static inline HotkeyList hotkeys{
"buildroadstop", {
1594 &RoadStopClassIDSorter,
1620 SetDataTip(STR_LIST_FILTER_OSKTITLE, STR_LIST_FILTER_TOOLTIP),
1650 NWidget(
WWT_LABEL, COLOUR_DARK_GREEN,
WID_BROS_SHOW_NEWST_TYPE),
SetMinimalSize(144, 8),
SetDataTip(STR_JUST_STRING, STR_NULL),
SetTextStyle(TC_ORANGE),
SetFill(1, 0),
1655 SetDataTip(STR_STATION_BUILD_COVERAGE_OFF, STR_STATION_BUILD_COVERAGE_AREA_OFF_TOOLTIP),
1657 SetDataTip(STR_STATION_BUILD_COVERAGE_ON, STR_STATION_BUILD_COVERAGE_AREA_ON_TOOLTIP),
1683 static WindowDesc _road_station_picker_desc(__FILE__, __LINE__,
1684 WDP_AUTO,
"build_station_road", 0, 0,
1709 SetDataTip(STR_LIST_FILTER_OSKTITLE, STR_LIST_FILTER_TOOLTIP),
1727 NWidget(
WWT_LABEL, COLOUR_DARK_GREEN,
WID_BROS_SHOW_NEWST_TYPE),
SetMinimalSize(144, 8),
SetDataTip(STR_JUST_STRING, STR_NULL),
SetTextStyle(TC_ORANGE),
SetFill(1, 0),
1732 SetDataTip(STR_STATION_BUILD_COVERAGE_OFF, STR_STATION_BUILD_COVERAGE_AREA_OFF_TOOLTIP),
1734 SetDataTip(STR_STATION_BUILD_COVERAGE_ON, STR_STATION_BUILD_COVERAGE_AREA_ON_TOOLTIP),
1760 static WindowDesc _tram_station_picker_desc(__FILE__, __LINE__,
1761 WDP_AUTO,
"build_station_tram", 0, 0,
1769 new BuildRoadStationWindow(RoadTypeIsRoad(_cur_roadtype) ? &_road_station_picker_desc : &_tram_station_picker_desc, parent, rs);
1772 void InitializeRoadGui()
1775 _roadstop_gui_settings.orientation =
DIAGDIR_NW;
1787 DropDownList GetRoadTypeDropDownList(RoadTramTypes rtts,
bool for_replacement,
bool all_option)
1795 if (for_replacement) {
1810 list.push_back(std::make_unique<DropDownListStringItem>(STR_REPLACE_ALL_ROADTYPE,
INVALID_ROADTYPE,
false));
1815 if (!for_replacement) {
1816 for (
const auto &rt : _sorted_roadtypes) {
1817 if (!
HasBit(used_roadtypes, rt))
continue;
1823 for (
const auto &rt : _sorted_roadtypes) {
1825 if (!
HasBit(used_roadtypes, rt))
continue;
1831 if (for_replacement) {
1834 StringID str = rti->
max_speed > 0 ? STR_TOOLBAR_RAILTYPE_VELOCITY : STR_JUST_STRING;
1841 list.push_back(std::make_unique<DropDownListStringItem>(STR_NONE,
INVALID_ROADTYPE,
true));
1847 DropDownList GetScenRoadTypeDropDownList(RoadTramTypes rtts)
1861 for (
const auto &rt : _sorted_roadtypes) {
1862 if (!
HasBit(used_roadtypes, rt))
continue;
1866 for (
const auto &rt : _sorted_roadtypes) {
1867 if (!
HasBit(used_roadtypes, rt))
continue;
1873 StringID str = rti->
max_speed > 0 ? STR_TOOLBAR_RAILTYPE_VELOCITY : STR_JUST_STRING;
1879 list.push_back(std::make_unique<DropDownListStringItem>(STR_NONE, -1,
true));
@ ES_HANDLED
The passed event is handled.
StringID toolbar_caption
Caption in the construction toolbar GUI for this rail type.
void SetTileSelectSize(int w, int h)
Highlight w by h tiles at the cursor.
@ DDSP_DEMOLISH_AREA
Clear area.
static bool _remove_button_clicked
Flag whether 'remove' toggle-button is currently enabled.
@ CA_UNMODIFIED
Catchment for all stations with "modified catchment" disabled.
static void PlaceRoad_Bridge(TileIndex tile, Window *w)
Callback to start placing a bridge.
void CloseWindowByClass(WindowClass cls, int data)
Close all windows of a given class.
Point size
Size, in tile "units", of the white/red selection area.
@ ROADSTOPTYPE_ALL
This RoadStop is for both types of station road stops.
@ ROADTYPE_END
Used for iterations.
StringID err_build_road
Building a normal piece of road.
static bool RoadStopClassIDSorter(RoadStopClassID const &a, RoadStopClassID const &b)
Sort classes by RoadStopClassID.
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:
@ DDSP_PLACE_ROAD_Y_DIR
Road placement (Y axis)
void OnPaint() override
The window must be repainted.
StationSettings station
settings related to station management
StringID menu_text
Name of this rail type in the main toolbar dropdown.
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.
SpriteID build_y_road
button for building single rail in Y direction
RoadStopType
Types of RoadStops.
@ ROADSTOP_TRUCK
A standard stop for trucks.
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.
static const uint EDITBOX_MAX_SIZE
The maximum number of characters for the filter edit box.
@ WDF_CONSTRUCTION
This window is used for construction; close it whenever changing company.
static void PlaceRoad_TruckStation(TileIndex tile)
Callback for placing a truck station.
void SetFilterState(bool state)
Enable or disable the filter.
Rect Shrink(int s) const
Copy and shrink Rect by s pixels.
bool IsEmpty() const
Check whether any filter words were entered.
void OnResize() override
Called after the window got resized.
RoadTypes avail_roadtypes
Road types available to this company.
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.
Axis
Allow incrementing of DiagDirDiff variables.
@ CBID_STATION_AVAILABILITY
Determine whether a newstation should be made available to build.
@ WC_SCEN_BUILD_TOOLBAR
Scenario build toolbar; Window numbers:
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.
void SetWidgetDirty(WidgetID widget_index) const
Invalidate a widget, i.e.
static Listing last_sorting
Default sorting of GUIRoadStopClassList.
StringID name
Name of this stop.
uint32_t StringID
Numeric value that represents a string, independent of the selected language.
@ DDSP_REMOVE_BUSSTOP
Road stop removal (buses)
void CloseWindowById(WindowClass cls, WindowNumber number, bool force, int data)
Close a window by its class and window number (if it is open).
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.
@ ROADSTOPTYPE_FREIGHT
This RoadStop is for freight (truck) stops.
@ WDP_ALIGN_TOOLBAR
Align toward the toolbar.
@ DIAGDIR_END
Used for iterations.
Tindex index
Index of this pool item.
Axis DiagDirToAxis(DiagDirection d)
Convert a DiagDirection to the axis.
@ DDSP_BUILD_BUSSTOP
Road stop placement (buses)
SpriteID build_depot
button for building depots
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.
Window * FindWindowById(WindowClass cls, WindowNumber number)
Find a window by its class and window number.
constexpr TileIndex INVALID_TILE
The very nice invalid tile marker.
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
void OnRealtimeTick([[maybe_unused]] uint delta_ms) override
Called periodically.
bool HandlePlacePushButton(Window *w, WidgetID widget, CursorID cursor, HighLightStyle mode)
This code is shared for the majority of the pushbuttons.
StringID err_remove_station[2]
Removing of a bus or truck station.
void RaiseButtons(bool autoraise=false)
Raise the buttons of the window.
void DrawRoadDepotSprite(int x, int y, DiagDirection dir, RoadType rt)
Draw the road depot sprite.
@ VPM_FIX_Y
drag only in Y axis
ClientSettings _settings_client
The current settings for this game.
static const CursorID ANIMCURSOR_DEMOLISH
704 - 707 - demolish dynamite
RoadTypes GetCompanyRoadTypes(CompanyID company, bool introduces)
Get the road types the given company can build.
constexpr uint Vertical() const
Get total vertical padding of RectPadding.
bool GetIfNewStopsByType(RoadStopType rs, RoadType roadtype)
Checks if there's any new stations by a specific RoadStopType.
void AddLine(const char *str)
Pass another text line from the current item to the filter.
CursorID tunnel
Cursor for building a tunnel.
StringID replace_text
Text used in the autoreplace GUI.
@ VEH_ROAD
Road vehicle type.
ViewportPlaceMethod
Viewport place method (type of highlighted area and placed objects)
Scrollbar * vscrollMatrix
Vertical scrollbar of the station picker matrix.
StringID err_remove_road
Removing a normal piece of road.
const Scrollbar * GetScrollbar(WidgetID widnum) const
Return the Scrollbar to a widget index.
virtual EventState OnHotkey(int hotkey)
A hotkey has been pressed.
CursorID depot
Cursor for building a depot.
@ INVALID_ROADTYPE
flag for invalid roadtype
uint16_t h
The height of the area.
bool NeedRebuild() const
Check if a rebuild is needed.
CursorID road_nwse
Cursor for building rail in Y direction.
Data stored about a string that can be modified in the GUI.
CursorID road_swne
Cursor for building rail in X direction.
bool Succeeded() const
Did this command succeed?
char *const buf
buffer in which text is saved
bool GetIfClassHasNewStopsByType(RoadStopClass *roadstopclass, RoadStopType rs, RoadType roadtype)
Checks if the given RoadStopClass has any specs assigned to it, compatible with the given RoadStopTyp...
static const int MAX_CHAR_LENGTH
Max. length of UTF-8 encoded unicode character.
@ DDSP_PLACE_ROAD_X_DIR
Road placement (X axis)
static void ToggleRoadButton_Remove(Window *w)
Toggles state of the Remove button of Build road toolbar.
void DrawRoadStopTile(int x, int y, RoadType roadtype, const RoadStopSpec *spec, StationType type, int view)
Draw representation of a road stop tile for GUI purposes.
High level window description.
constexpr uint Horizontal() const
Get total horizontal padding of RectPadding.
@ BROSHK_FOCUS_FILTER_BOX
Focus the edit box for editing the filter string.
StationType
Station types.
int ScaleGUITrad(int value)
Scale traditional pixel dimensions to GUI zoom level.
@ RSF_BUILD_MENU_TRAM_ONLY
Only show in the tram build menu (not road).
@ ROADTYPES_NONE
No roadtypes.
RoadTypes _roadtypes_type
Bitmap of road/tram types.
@ WDP_AUTO
Find a place automatically.
uint line_height
Height of a single line in the newstation selection matrix.
Data structure describing how to show the list (what sort direction and criteria).
@ SCT_PASSENGERS_ONLY
Draw only passenger class cargoes.
ResizeInfo resize
Resize information.
Common return value for all commands.
SoundSettings sound
sound effect settings
int32_t WindowNumber
Number to differentiate different windows of the same class.
@ 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.
StationCoverageType
Types of cargo to display for station coverage.
@ 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
BuildRoadStopHotkeys
Enum referring to the Hotkeys in the build road stop window.
RoadTypes
The different roadtypes we support, but then a bitmask of them.
static constexpr NWidgetPart _nested_road_station_picker_widgets[]
Widget definition of the build road station window.
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.
SpriteID auto_road
button for the autoroad construction
DiagDirection ReverseDiagDir(DiagDirection d)
Returns the reverse direction of the given DiagDirection.
@ WC_TRUCK_STATION
Build truck station; Window numbers:
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?
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.
struct RoadTypeInfo::@27 gui_sprites
struct containing the sprites for the road GUI.
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).
@ DDSP_REMOVE_TRUCKSTOP
Road stop removal (trucks)
@ WC_BUS_STATION
Build bus station; Window numbers:
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.
@ WC_BUILD_BRIDGE
Build bridge; Window numbers:
@ CA_BUS
Catchment for bus stops with "modified catchment" enabled.
static debug_inline bool IsNormalRoadTile(Tile t)
Return whether a tile is a normal road tile.
static void PlaceRoad_BusStation(TileIndex tile)
Callback for placing a bus station.
WindowClass
Window classes.
@ DDSP_PLACE_AUTOROAD
Road placement (auto)
@ DDSP_BUILD_BRIDGE
Bridge placement.
GRFFilePropsBase< NUM_CARGO+3 > grf_prop
Properties related the the grf file.
Point pos
Location, in tile "units", of the northern tile of the selected area.
@ RSF_DRIVE_THROUGH_ONLY
Stop is drive-through only.
@ CA_TRUCK
Catchment for truck stops with "modified catchment" enabled.
@ RSF_NO_AUTO_ROAD_CONNECTION
No auto road connection.
Coordinates of a point in 2D.
static void PlaceRoadStop(TileIndex start_tile, TileIndex end_tile, RoadStopType stop_type, bool adjacent, RoadType rt, StringID err_msg)
Place a new road stop.
bool ValParamRoadType(RoadType roadtype)
Validate functions for rail building.
RoadBits DiagDirToRoadBits(DiagDirection d)
Create the road-part which belongs to the given DiagDirection.
DiagDirection
Enumeration for diagonal directions.
bool IsWidgetDisabled(WidgetID widget_index) const
Gets the enabled/disabled status of a widget.
GUIRoadStopClassList roadstop_classes
Available road stop classes.
SpriteID build_tunnel
button for building a tunnel
byte station_spread
amount a station may spread
WindowNumber window_number
Window number within the window class.
bool SetFocusedWidget(WidgetID widget_index)
Set focus within this window to the given widget.
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.
void CcRoadStop(Commands, const CommandCost &result, TileIndex tile, uint8_t width, uint8_t length, RoadStopType, bool is_drive_through, DiagDirection dir, RoadType, RoadStopClassID spec_class, uint16_t spec_index, StationID, bool)
Command callback for building road stops.
@ DRD_NONE
None of the directions are disallowed.
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.
static Filtering last_filtering
Default filtering of GUIRoadStopClassList.
struct RoadTypeInfo::@28 cursor
Cursors associated with the road type.
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:
static constexpr NWidgetPart _nested_tram_station_picker_widgets[]
Widget definition of the build tram station window.
TileIndexDiff TileOffsByDiagDir(DiagDirection dir)
Convert a DiagDirection to a TileIndexDiff.
QueryString filter_editbox
Filter editbox.
const RoadTypeInfo * GetRoadTypeInfo(RoadType roadtype)
Returns a pointer to the Roadtype information for a given roadtype.
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.
StringID picker_tooltip[2]
Tooltip for the station picker for bus or truck stations.
StationType GetRoadStationTypeByWindowClass(WindowClass window_class) const
Simply to have a easier way to get the StationType for bus, truck and trams from the WindowClass.
void ShowBuildBridgeWindow(TileIndex start, TileIndex end, TransportType transport_type, byte road_rail_type)
Prepare the data for the build a bridge window.
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)
SpriteID build_x_road
button for building single rail in X direction
SpriteID convert_road
button for converting road types
RoadTypes AddDateIntroducedRoadTypes(RoadTypes current, TimerGameCalendar::Date date)
Add the road types that are to be introduced at the given date.
void ForceRebuild()
Force that a rebuild is needed.
@ ROADSTOP_CLASS_WAYP
Waypoint class (unimplemented: this is reserved for future use with road waypoints).
bool IsWidgetLowered(WidgetID widget_index) const
Gets the lowered state of a widget.
static const uint CALLBACK_FAILED
Different values for Callback result evaluations.
@ ROADSTOP_BUS
A standard stop for buses.
@ ROADSTOP_CLASS_DFLT
Default road stop class.
std::map< WidgetID, QueryString * > querystrings
QueryString associated to WWT_EDITBOX widgets.
bool confirm
Play sound effect on successful constructions or other actions.
@ WC_SELECT_STATION
Select station (when joining stations); Window numbers:
void CreateNestedTree()
Perform the first part of the initialization of a nested widget tree.
bool IsShaded() const
Is window shaded currently?
@ INVALID_AXIS
Flag for an invalid Axis.
@ VPM_Y_LIMITED
Drag only in Y axis with limited size.
StringID err_build_station[2]
Building a bus or truck station.
void DisableWidget(WidgetID widget_index)
Sets a widget to disabled.
@ WC_SCEN_LAND_GEN
Landscape generation (in Scenario Editor); Window numbers:
void SetDParam(size_t n, uint64_t v)
Set a string parameter v at index n in the global string parameter array.
@ SCT_NON_PASSENGERS_ONLY
Draw all non-passenger class cargoes.
TileIndex tile
The base tile of the area.
CursorID autoroad
Cursor for autorail tool.
TileIndex _build_tunnel_endtile
The end of a tunnel; as hidden return from the tunnel build command for GUI purposes.
StringID err_convert_road
Converting a road type.
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.
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.
RoadStopType roadStopType
The RoadStopType for this Window.
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, ...)
static bool RoadToolbar_CtrlChanged(Window *w)
Updates the Remove button because of Ctrl state change.
@ VPM_X_AND_Y
area of land in X and Y directions
bool GetState() const
Get the matching state of the current item.
StringID name
Name of this class.
WindowClass window_class
Window class.
RoadType
The different roadtypes we support.
RoadBits GetRoadBits(Tile t, RoadTramType rtt)
Get the present road bits for a specific road type.
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.
@ DDSP_CONVERT_ROAD
Road conversion.
struct RoadTypeInfo::@29 strings
Strings associated with the rail type.
static bool CDECL TagNameFilter(RoadStopClassID const *sc, StringFilter &filter)
Filter classes by class name.
uint coverage_height
Height of the coverage texts.
Base class for windows opened from a toolbar.
static GUIRoadStopClassList::FilterFunction *const filter_funcs[]
Filter functions of the GUIRoadStopClassList.
void SetViewportCatchmentStation(const Station *st, bool sel)
Select or deselect station for coverage area highlight.
TileIndex GetOtherTunnelBridgeEnd(Tile t)
Determines type of the wormhole and returns its other end.
void CcBuildRoadTunnel(Commands, const CommandCost &result, TileIndex start_tile)
Callback executed after a build road tunnel command has been called.
@ RSF_BUILD_MENU_ROAD_ONLY
Only show in the road build menu (not tram).
int top
y position of top edge of the window
uint16_t w
The width of the area.
EventState OnHotkey(int hotkey) override
A hotkey has been pressed.
void RaiseWidget(WidgetID widget_index)
Marks a widget as raised.
void OnInvalidateData([[maybe_unused]] int data=0, [[maybe_unused]] bool gui_scope=true) override
Some data on this window has become invalid.
void SetFilterFuncs(FilterFunction *const *n_funcs)
Hand the array of filter function pointers to the sort list.
bool click_beep
Beep on a random selection of buttons.
int GetCharacterHeight(FontSize size)
Get height of a character for a given font size.
uint16_t max_speed
Maximum speed for vehicles travelling on this road type.
@ VPM_X_LIMITED
Drag only in X axis with limited size.
@ ROAD_NONE
No road-part is build.
static NewGRFClass * Get(Tid cls_id)
Get a particular class.
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 RoadStopClassID *, StringFilter &)
Signature of filter function.
@ CBM_ROAD_STOP_AVAIL
Availability of road stop in construction window.
@ SND_1F_CONSTRUCTION_OTHER
29 == 0x1D Construction: other (non-water, non-rail, non-bridge)
Window * ShowBuildRoadToolbar(RoadType roadtype)
Open the build road toolbar window.
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.
@ TRANSPORT_ROAD
Transport by road vehicle.
static debug_inline TileIndex TileVirtXY(uint x, uint y)
Get a tile from the virtual XY-coordinate.
static Date date
Current date in days (day counter).
Data structure for an opened window.
RoadTypes GetRoadTypes(bool introduces)
Get list of road types, regardless of company availability.
Commands
List of commands.
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.
const struct GRFFile * grffile
grf file that introduced this entity
StringID err_depot
Building a depot.
void ConnectRoadToStructure(TileIndex tile, DiagDirection direction)
If required, connects a new structure to an existing road or tram by building the missing roadbit.
int Width() const
Get width of Rect.
@ VPM_X_AND_Y_LIMITED
area of land of limited size
void InitializeRoadGUI()
I really don't know why rail_gui.cpp has this too, shouldn't be included in the other one?
@ DIAGDIR_NE
Northeast, upper right on your monitor.
Specification of a rectangle with absolute coordinates of all edges.
void ToggleWidgetLoweredState(WidgetID widget_index)
Invert the lowered/raised status of a widget.
bool Sort(Comp compare)
Sort the list.
static GUIRoadStopClassList::SortFunction *const sorter_funcs[]
Sort functions of the GUIRoadStopClassList.
void SetWidgetsDisabledState(bool disab_stat, Args... widgets)
Sets the enabled/disabled status of a list of widgets.
@ VPM_X_OR_Y
drag in X or Y direction
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 Convert8bitBooleanCallback(const GRFFile *grffile, uint16_t cbid, uint16_t cb_res)
Converts a callback result into a boolean.
void SetFiltering(Filtering f)
Import filter conditions.
StringID picker_title[2]
Title for the station picker for bus or truck stations.
StringFilter string_filter
Filter for available road stop classes.
Dimension GetStringBoundingBox(std::string_view str, FontSize start_fontsize)
Return the string dimension in pixels.
@ DRD_NORTHBOUND
All northbound traffic is disallowed.
GUISettings gui
settings related to the GUI
static bool IsRoadStopAvailable(const RoadStopSpec *roadstopspec, StationType type)
Check whether a road stop type can be built.
GUIList< RoadStopClassID, std::nullptr_t, StringFilter & > GUIRoadStopClassList
Type definition for the list to hold available road stop classes.
@ DDSP_BUILD_TRUCKSTOP
Road stop placement (trucks)
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.
DiagDirection GetTunnelBridgeDirection(Tile t)
Get the direction pointing to the other end.
@ ROADSTOPTYPE_PASSENGER
This RoadStop is for passenger (bus) stops.
@ INVALID_RAILTYPE
Flag for invalid railtype.
Scrollbar * vscrollList
Vertical scrollbar of the new station list.
Window * ShowBuildRoadScenToolbar(RoadType roadtype)
Show the road building toolbar in the scenario editor.
constexpr debug_inline bool HasBit(const T x, const uint8_t y)
Checks if a bit in a value is set.