Go to the documentation of this file.
38 #include "table/strings.h"
55 CargoTypes cargo_mask = 0;
70 default: NOT_REACHED();
72 if (cargoes[i] >= (supplies ? 1U : 8U))
SetBit(cargo_mask, i);
76 return DrawStringMultiLine(left, right, top, INT32_MAX, supplies ? STR_STATION_BUILD_SUPPLIES_CARGO : STR_STATION_BUILD_ACCEPTS_CARGO);
88 SetViewportCatchmentSpecializedStation<T>(
nullptr,
true);
103 T *adjacent =
nullptr;
108 T *st = T::GetByTile(tile);
109 if (st ==
nullptr)
continue;
110 if (adjacent !=
nullptr && st != adjacent) {
118 SetViewportCatchmentSpecializedStation<T>(adjacent,
true);
129 static bool _last_ctrl_pressed;
135 if (_thd.
dirty & 1) {
140 FindStationsAroundSelection<Station>();
145 void CheckRedrawWaypointCoverage(
const Window *)
148 static bool _last_ctrl_pressed;
154 if (_thd.
dirty & 1) {
158 FindStationsAroundSelection<Waypoint>();
177 static const uint units_full = 576;
178 static const uint rating_full = 224;
184 int width = right - left;
185 int colour = cs->rating_colour;
187 uint w = std::min(amount + 5, units_full) * width / units_full;
193 GfxFillRect(left, y, left + w - 1, y + height, colour);
199 GfxFillRect(left, y + height - rest, left + padding - 1, y + height, colour);
206 y += height + padding + 1;
208 w = std::min<uint>(rating, rating_full) * (width - padding - padding) / rating_full;
236 static const StringID sorter_names[];
243 bool filter_expanded;
256 Debug(misc, 3,
"Building station list for company {}",
owner);
258 this->stations.clear();
259 this->stations_per_cargo_type.fill(0);
260 this->stations_per_cargo_type_no_rating = 0;
264 if (this->filter.facilities & st->facilities) {
265 bool has_rating =
false;
268 if (st->goods[j].HasRating()) this->stations_per_cargo_type[j]++;
271 if (st->goods[j].HasRating()) {
273 if (
HasBit(this->filter.cargoes, j)) {
274 this->stations.push_back(st);
281 if (this->filter.include_no_rating) this->stations.push_back(st);
282 this->stations_per_cargo_type_no_rating++;
288 this->stations.shrink_to_fit();
291 this->vscroll->
SetCount(this->stations.size());
343 return maxr1 < maxr2;
357 return minr1 > minr2;
363 if (!this->stations.
Sort())
return;
373 this->filter = CompanyStationsWindow::initial_state;
376 this->stations.
SetListing(this->filter.last_sorting);
377 this->stations.
SetSortFuncs(CompanyStationsWindow::sorter_funcs);
387 if (this->filter.cargoes == ALL_CARGOTYPES) this->filter.cargoes =
_cargo_mask;
389 for (uint i = 0; i < 5; i++) {
399 this->filter.last_sorting = this->stations.
GetListing();
400 CompanyStationsWindow::initial_state = this->filter;
409 d.height += padding.height;
416 for (
int i = 0; CompanyStationsWindow::sorter_names[i] !=
INVALID_STRING_ID; i++) {
419 d.width += padding.width;
420 d.height += padding.height;
427 size->height = padding.height + 5 *
resize->height;
430 this->rating_width = 0;
435 this->rating_width = this->rating_width * 16 / 10;
448 void DrawWidget(
const Rect &r,
WidgetID widget)
const override
458 size_t max = std::min<size_t>(this->vscroll->
GetPosition() + this->vscroll->GetCapacity(), this->stations.size());
460 uint line_height = this->GetWidget<NWidgetBase>(widget)->resize_y;
466 for (
size_t i = this->vscroll->
GetPosition(); i < max; ++i) {
467 const Station *st = this->stations[i];
477 x += rtl ? -text_spacing : text_spacing;
488 x -= rating_width + rating_spacing;
489 if (x < tr.left)
break;
493 x += rating_width + rating_spacing;
494 if (x > tr.right)
break;
498 tr.top += line_height;
501 if (this->vscroll->
GetCount() == 0) {
510 void SetStringParameters(
WidgetID widget)
const override
518 if (this->filter.cargoes == 0) {
519 SetDParam(0, this->filter.include_no_rating ? STR_STATION_LIST_CARGO_FILTER_ONLY_NO_RATING : STR_STATION_LIST_CARGO_FILTER_NO_CARGO_TYPES);
521 SetDParam(0, this->filter.include_no_rating ? STR_STATION_LIST_CARGO_FILTER_ALL_AND_NO_RATING : STR_CARGO_TYPE_FILTER_ALL);
522 }
else if (
CountBits(this->filter.cargoes) == 1 && !this->filter.include_no_rating) {
525 SetDParam(0, STR_STATION_LIST_CARGO_FILTER_MULTIPLE);
530 DropDownList BuildCargoDropDownList(
bool expanded)
const
537 list.push_back(std::make_unique<DropDownListDividerItem>(-1));
539 bool any_hidden =
false;
542 if (count == 0 && !expanded) {
550 count = this->stations_per_cargo_type[cs->Index()];
551 if (count == 0 && !expanded) {
554 list.push_back(std::make_unique<DropDownListCargoItem>(
HasBit(this->filter.cargoes, cs->Index()), fmt::format(
"{}", count), d, cs->GetCargoIcon(), PAL_NONE, cs->name, cs->Index(),
false, count == 0));
558 if (!expanded && any_hidden) {
559 if (list.size() > 2) list.push_back(std::make_unique<DropDownListDividerItem>(-1));
566 void OnClick([[maybe_unused]]
Point pt,
WidgetID widget, [[maybe_unused]]
int click_count)
override
571 if (it == this->stations.end())
return;
624 this->filter_expanded =
false;
625 ShowDropDownList(
this, this->BuildCargoDropDownList(this->filter_expanded), -1, widget, 0,
false,
true);
630 void OnDropdownSelect(
int widget,
int index)
override
633 if (this->stations.
SortType() != index) {
644 FilterState oldstate = this->filter;
650 this->filter.cargoes = 1ULL << index;
651 this->filter.include_no_rating =
false;
655 this->filter.include_no_rating = !this->filter.include_no_rating;
657 this->filter.include_no_rating =
true;
658 this->filter.cargoes = 0;
662 this->filter.include_no_rating =
true;
664 this->filter_expanded =
true;
665 ReplaceDropDownList(
this, this->BuildCargoDropDownList(this->filter_expanded));
669 if (oldstate.cargoes != this->filter.cargoes || oldstate.include_no_rating != this->filter.include_no_rating) {
674 if (
_ctrl_pressed) ReplaceDropDownList(
this, this->BuildCargoDropDownList(this->filter_expanded));
685 Debug(misc, 3,
"Periodic rebuild station list company {}", this->window_number);
700 void OnInvalidateData([[maybe_unused]]
int data = 0, [[maybe_unused]]
bool gui_scope =
true)
override
715 &StationWaitingTotalSorter,
716 &StationWaitingAvailableSorter,
717 &StationRatingMaxSorter,
718 &StationRatingMinSorter
722 const StringID CompanyStationsWindow::sorter_names[] = {
724 STR_SORT_BY_FACILITY,
725 STR_SORT_BY_WAITING_TOTAL,
726 STR_SORT_BY_WAITING_AVAILABLE,
727 STR_SORT_BY_RATING_MAX,
728 STR_SORT_BY_RATING_MIN,
732 static constexpr
NWidgetPart _nested_company_stations_widgets[] = {
746 NWidget(
WWT_PUSHTXTBTN, COLOUR_GREY,
WID_STL_FACILALL),
SetMinimalSize(14, 0),
SetDataTip(STR_ABBREV_ALL, STR_STATION_LIST_SELECT_ALL_FACILITIES),
SetTextStyle(TC_BLACK,
FS_SMALL),
SetFill(0, 1),
757 NWidget(
WWT_PANEL, COLOUR_GREY,
WID_STL_LIST),
SetMinimalSize(346, 125),
SetResize(1, 10),
SetDataTip(0x0, STR_STATION_LIST_TOOLTIP),
SetScrollbar(
WID_STL_SCROLLBAR),
EndContainer(),
765 static WindowDesc _company_stations_desc(__FILE__, __LINE__,
766 WDP_AUTO,
"list_stations", 358, 162,
769 std::begin(_nested_company_stations_widgets), std::end(_nested_company_stations_widgets)
781 AllocateWindowDescFront<CompanyStationsWindow>(&_company_stations_desc, company);
784 static constexpr
NWidgetPart _nested_station_view_widgets[] = {
796 NWidget(
WWT_DROPDOWN, COLOUR_GREY,
WID_SV_GROUP_BY),
SetMinimalSize(168, 12),
SetResize(1, 0),
SetFill(0, 1),
SetDataTip(0x0, STR_TOOLTIP_GROUP_ORDER),
800 NWidget(
WWT_DROPDOWN, COLOUR_GREY,
WID_SV_SORT_BY),
SetMinimalSize(168, 12),
SetResize(1, 0),
SetFill(0, 1),
SetDataTip(0x0, STR_TOOLTIP_SORT_CRITERIA),
809 SetDataTip(STR_STATION_VIEW_RATINGS_BUTTON, STR_STATION_VIEW_RATINGS_TOOLTIP),
811 SetDataTip(STR_STATION_VIEW_CLOSE_AIRPORT, STR_STATION_VIEW_CLOSE_AIRPORT_TOOLTIP),
812 NWidget(
WWT_TEXTBTN, COLOUR_GREY,
WID_SV_CATCHMENT),
SetMinimalSize(45, 12),
SetResize(1, 0),
SetFill(1, 1),
SetDataTip(STR_BUTTON_CATCHMENT, STR_TOOLTIP_CATCHMENT),
833 uint num = std::min<uint>((waiting + (width / 2)) / width, (right - left) / width);
834 if (num == 0)
return;
871 bool SortId(Tid st1, Tid st2)
const;
873 bool SortStation (StationID st1, StationID st2)
const;
876 typedef std::set<CargoDataEntry *, CargoSorter> CargoDataSet;
895 return this->InsertOrRetrieve<StationID>(
station);
905 return this->InsertOrRetrieve<CargoID>(
cargo);
987 CargoDataSet::iterator
End()
const {
return this->
children->end(); }
1028 CargoDataEntry::CargoDataEntry() :
1030 station(INVALID_STATION),
1041 children(new CargoDataSet)
1044 CargoDataEntry::CargoDataEntry(StationID station, uint count,
CargoDataEntry *parent) :
1049 children(new CargoDataSet)
1052 CargoDataEntry::CargoDataEntry(StationID station) :
1060 CargoDataEntry::CargoDataEntry(
CargoID cargo) :
1068 CargoDataEntry::~CargoDataEntry()
1084 this->children->clear();
1099 CargoDataSet::iterator i = this->
children->find(child);
1116 CargoDataSet::iterator i = this->
children->find(&tmp);
1134 this->count +=
count;
1147 void CargoDataEntry::Resort(
CargoSortType type, SortOrder order)
1149 CargoDataSet *new_subs =
new CargoDataSet(this->
children->begin(), this->children->end(),
CargoSorter(type, order));
1166 switch (this->type) {
1172 return this->SortCount(cd1, cd2);
1181 bool CargoSorter::SortId(Tid st1, Tid st2)
const
1183 return (this->order == SO_ASCENDING) ? st1 < st2 : st2 < st1;
1192 }
else if (this->order == SO_ASCENDING) {
1199 bool CargoSorter::SortStation(StationID st1, StationID st2)
const
1202 return Station::IsValidID(st2) ? this->order == SO_ASCENDING : this->SortId(st1, st2);
1204 return order == SO_DESCENDING;
1209 return this->SortId(st1, st2);
1211 return (this->order == SO_ASCENDING) ? res < 0 : res > 0;
1243 typedef std::vector<RowDisplay> CargoDataVector;
1322 this->sort_orders[0] = SO_ASCENDING;
1327 void Close([[maybe_unused]]
int data = 0)
override
1350 if (count == 0)
return;
1353 for (
int i = 0; i <
NUM_COLUMNS && expand !=
nullptr; ++i) {
1362 if (auto_distributed || source != this->window_number) {
1368 if (auto_distributed) {
1374 if (auto_distributed) {
1389 size->height = 4 *
resize->height + padding.height;
1434 const Rect r = wid->GetCurrentRect();
1435 if (this->GetWidget<NWidgetCore>(
WID_SV_ACCEPTS_RATINGS)->widget_data == STR_STATION_VIEW_RATINGS_BUTTON) {
1437 if (lines > this->accepts_lines) {
1438 this->accepts_lines = lines;
1444 if (lines > this->rating_lines) {
1445 this->rating_lines = lines;
1463 this->
DrawEntries(&cargo, waiting_rect, pos, maxrows, 0);
1468 void SetStringParameters(
WidgetID widget)
const override
1486 cargo_entry->
Clear();
1489 StationID from = it.first;
1491 uint32_t prev_count = 0;
1492 for (
const auto &flow_it : *it.second.GetShares()) {
1493 StationID via = flow_it.second;
1495 if (via == this->window_number) {
1500 prev_count = flow_it.first;
1519 FlowStatMap::const_iterator map_it = flowmap.find(source);
1520 if (map_it != flowmap.end()) {
1521 const FlowStat::SharesMap *shares = map_it->second.GetShares();
1522 uint32_t prev_count = 0;
1523 for (FlowStat::SharesMap::const_iterator i = shares->begin(); i != shares->end(); ++i) {
1525 prev_count = i->first;
1532 uint sum_estimated = 0;
1533 while (sum_estimated < count) {
1534 for (CargoDataSet::iterator i = tmp.
Begin(); i != tmp.
End() && sum_estimated < count; ++i) {
1537 if (estimate == 0) estimate = 1;
1539 sum_estimated += estimate;
1540 if (sum_estimated > count) {
1541 estimate -= sum_estimated - count;
1542 sum_estimated = count;
1570 for (FlowStatMap::const_iterator it = flows.begin(); it != flows.end(); ++it) {
1571 StationID from = it->first;
1573 const FlowStat::SharesMap *shares = it->second.GetShares();
1574 for (FlowStat::SharesMap::const_iterator flow_it = shares->begin(); flow_it != shares->end(); ++flow_it) {
1576 for (CargoDataSet::iterator dest_it = via_entry->
Begin(); dest_it != via_entry->
End(); ++dest_it) {
1595 StationID next = it.GetKey();
1598 if (source_entry ==
nullptr) {
1604 if (via_entry ==
nullptr) {
1609 uint remaining = cp->
Count();
1610 for (CargoDataSet::iterator dest_it = via_entry->
Begin(); dest_it != via_entry->
End();) {
1617 if (dest_it == via_entry->
End()) {
1641 if (this->cached_destinations.
Retrieve(i) ==
nullptr) {
1659 std::list<StationID> stations;
1661 if (
parent->GetParent() ==
nullptr) {
1667 while (
parent->GetParent()->GetParent() !=
nullptr) {
1668 stations.push_back(
parent->GetStation());
1674 while (!stations.empty()) {
1675 filter = filter->
Retrieve(stations.back());
1676 stations.pop_back();
1679 this->displayed_rows.push_back(
RowDisplay(filter, next));
1692 if (station == this->window_number) {
1694 }
else if (station == INVALID_STATION) {
1696 }
else if (station == NEW_STATION) {
1697 return STR_STATION_VIEW_RESERVED;
1700 return other_station;
1714 for (
int i = column - 1; i > 0; --i) {
1716 if (
parent->GetStation() == station) {
1717 return STR_STATION_VIEW_NONSTOP;
1719 return STR_STATION_VIEW_VIA;
1726 CargoDataSet::iterator begin = cd->
Begin();
1727 CargoDataSet::iterator end = cd->
End();
1728 if (begin != end && ++(cd->
Begin()) == end && (*(begin))->GetStation() == station) {
1729 return STR_STATION_VIEW_NONSTOP;
1731 return STR_STATION_VIEW_VIA;
1735 return STR_STATION_VIEW_VIA;
1751 if (this->groupings[column] !=
GR_CARGO) {
1757 for (CargoDataSet::iterator i = entry->
Begin(); i != entry->
End(); ++i) {
1760 Grouping grouping = this->groupings[column];
1764 if (pos > -maxrows && pos <= 0) {
1770 if (this->groupings[column] ==
GR_CARGO) {
1771 str = STR_STATION_VIEW_WAITING_CARGO;
1774 if (!auto_distributed) grouping =
GR_SOURCE;
1779 str = this->
GetEntryString(station, STR_STATION_VIEW_FROM_HERE, STR_STATION_VIEW_FROM, STR_STATION_VIEW_FROM_ANY);
1782 str = this->
GetEntryString(station, STR_STATION_VIEW_VIA_HERE, STR_STATION_VIEW_VIA, STR_STATION_VIEW_VIA_ANY);
1783 if (str == STR_STATION_VIEW_VIA) str = this->
SearchNonStop(cd, station, column);
1786 str = this->
GetEntryString(station, STR_STATION_VIEW_TO_HERE, STR_STATION_VIEW_TO, STR_STATION_VIEW_TO_ANY);
1803 const char *sym =
nullptr;
1806 }
else if (auto_distributed && str != STR_STATION_VIEW_RESERVED) {
1815 if (sym !=
nullptr)
DrawString(shrink.left, shrink.right, y, sym, TC_YELLOW);
1820 if (auto_distributed || column == 0) {
1821 pos = this->
DrawEntries(cd, r, pos, maxrows, column + 1, cargo);
1838 int bottom =
DrawStringMultiLine(tr.left, tr.right, tr.top, INT32_MAX, STR_STATION_VIEW_ACCEPTS_CARGO);
1885 if (filter->
Retrieve(next) !=
nullptr) {
1898 if (row < 0 || (uint)row >= this->displayed_rows.size())
return;
1900 this->scroll_to_row = row;
1902 RowDisplay &display = this->displayed_rows[row];
1903 if (display.
filter == &this->expanded_rows) {
1904 this->HandleCargoWaitingClick<CargoID>(display.
filter, display.
next_cargo);
1912 void OnClick([[maybe_unused]]
Point pt,
WidgetID widget, [[maybe_unused]]
int click_count)
override
1935 if (this->GetWidget<NWidgetCore>(
WID_SV_ACCEPTS_RATINGS)->widget_data == STR_STATION_VIEW_RATINGS_BUTTON) {
1936 nwi->
SetDataTip(STR_STATION_VIEW_ACCEPTS_BUTTON, STR_STATION_VIEW_ACCEPTS_TOOLTIP);
1939 nwi->
SetDataTip(STR_STATION_VIEW_RATINGS_BUTTON, STR_STATION_VIEW_RATINGS_TOOLTIP);
1940 height_change = this->accepts_lines - this->
rating_lines;
1982 this->
SelectSortOrder(this->sort_orders[1] == SO_ASCENDING ? SO_DESCENDING : SO_ASCENDING);
1996 this->sort_orders[1] = this->sort_orders[2] = this->sort_orders[3] = order;
2009 case STR_STATION_VIEW_WAITING_STATION:
2013 case STR_STATION_VIEW_WAITING_AMOUNT:
2017 case STR_STATION_VIEW_PLANNED_STATION:
2021 case STR_STATION_VIEW_PLANNED_AMOUNT:
2039 this->grouping_index = index;
2043 case STR_STATION_VIEW_GROUP_S_V_D:
2048 case STR_STATION_VIEW_GROUP_S_D_V:
2053 case STR_STATION_VIEW_GROUP_V_S_D:
2058 case STR_STATION_VIEW_GROUP_V_D_S:
2063 case STR_STATION_VIEW_GROUP_D_S_V:
2068 case STR_STATION_VIEW_GROUP_D_V_S:
2077 void OnDropdownSelect(
WidgetID widget,
int index)
override
2086 void OnQueryTextFinished(
char *str)
override
2088 if (str ==
nullptr)
return;
2103 void OnInvalidateData([[maybe_unused]]
int data = 0, [[maybe_unused]]
bool gui_scope =
true)
override
2116 STR_STATION_VIEW_WAITING_STATION,
2117 STR_STATION_VIEW_WAITING_AMOUNT,
2118 STR_STATION_VIEW_PLANNED_STATION,
2119 STR_STATION_VIEW_PLANNED_AMOUNT,
2124 STR_STATION_VIEW_GROUP_S_V_D,
2125 STR_STATION_VIEW_GROUP_S_D_V,
2126 STR_STATION_VIEW_GROUP_V_S_D,
2127 STR_STATION_VIEW_GROUP_V_D_S,
2128 STR_STATION_VIEW_GROUP_D_S_V,
2129 STR_STATION_VIEW_GROUP_D_V_S,
2133 static WindowDesc _station_view_desc(__FILE__, __LINE__,
2134 WDP_AUTO,
"view_station", 249, 117,
2137 std::begin(_nested_station_view_widgets), std::end(_nested_station_view_widgets)
2147 AllocateWindowDescFront<StationViewWindow>(&_station_view_desc, station);
2156 static std::vector<TileAndStation> _deleted_stations_nearby;
2157 static std::vector<StationID> _stations_nearby_list;
2172 for (
auto it = _deleted_stations_nearby.begin(); it != _deleted_stations_nearby.end(); ) {
2173 if (it->tile == tile) {
2174 _stations_nearby_list.push_back(it->station);
2175 it = _deleted_stations_nearby.erase(it);
2187 if (!T::IsValidID(sid))
return false;
2189 T *st = T::Get(sid);
2190 if (st->owner !=
_local_company || std::find(_stations_nearby_list.begin(), _stations_nearby_list.end(), sid) != _stations_nearby_list.end())
return false;
2192 if (st->rect.BeforeAddRect(ctx->
tile, ctx->
w, ctx->
h, StationRect::ADD_TEST).Succeeded()) {
2193 _stations_nearby_list.push_back(sid);
2213 _stations_nearby_list.clear();
2214 _stations_nearby_list.push_back(NEW_STATION);
2215 _deleted_stations_nearby.clear();
2227 _deleted_stations_nearby.push_back({st->
xy, st->
index});
2232 AddNearbyStation<T>(st->
xy, &ctx);
2250 static constexpr
NWidgetPart _nested_select_station_widgets[] = {
2271 StationPickerCmdProc select_station_proc;
2277 select_station_proc(std::move(proc)),
2282 this->GetWidget<NWidgetCore>(WID_JS_CAPTION)->widget_data = T::EXPECTED_FACIL ==
FACIL_WAYPOINT ? STR_JOIN_WAYPOINT_CAPTION : STR_JOIN_STATION_CAPTION;
2289 void Close([[maybe_unused]]
int data = 0)
override
2291 SetViewportCatchmentSpecializedStation<T>(
nullptr,
true);
2299 if (widget != WID_JS_PANEL)
return;
2303 for (
const auto &station : _stations_nearby_list) {
2304 if (station == NEW_STATION)
continue;
2305 const T *st = T::Get(station);
2311 resize->height = d.height;
2313 d.width += padding.width;
2314 d.height += padding.height;
2318 void DrawWidget(
const Rect &r,
WidgetID widget)
const override
2320 if (widget != WID_JS_PANEL)
return;
2323 for (uint i = this->vscroll->
GetPosition(); i < _stations_nearby_list.size(); ++i, tr.top += this->resize.step_height) {
2324 if (_stations_nearby_list[i] == NEW_STATION) {
2325 DrawString(tr, T::EXPECTED_FACIL ==
FACIL_WAYPOINT ? STR_JOIN_WAYPOINT_CREATE_SPLITTED_WAYPOINT : STR_JOIN_STATION_CREATE_SPLITTED_STATION);
2327 const T *st = T::Get(_stations_nearby_list[i]);
2336 void OnClick([[maybe_unused]]
Point pt,
WidgetID widget, [[maybe_unused]]
int click_count)
override
2338 if (widget != WID_JS_PANEL)
return;
2341 if (it == _stations_nearby_list.end())
return;
2344 this->select_station_proc(
false, *it);
2352 if (_thd.
dirty & 2) {
2368 void OnInvalidateData([[maybe_unused]]
int data = 0, [[maybe_unused]]
bool gui_scope =
true)
override
2370 if (!gui_scope)
return;
2371 FindStationsNearby<T>(this->area,
true);
2372 this->vscroll->
SetCount(_stations_nearby_list.size());
2376 void OnMouseOver([[maybe_unused]]
Point pt,
WidgetID widget)
override
2378 if (widget != WID_JS_PANEL) {
2379 SetViewportCatchmentSpecializedStation<T>(
nullptr,
true);
2385 const T *st = it == _stations_nearby_list.end() || *it == NEW_STATION ? nullptr : T::Get(*it);
2386 SetViewportCatchmentSpecializedStation<T>(st,
true);
2390 static WindowDesc _select_station_desc(__FILE__, __LINE__,
2391 WDP_AUTO,
"build_station_join", 200, 180,
2394 std::begin(_nested_select_station_widgets), std::end(_nested_select_station_widgets)
2414 if (selection_window !=
nullptr) {
2416 selection_window->
Close();
2424 if (!proc(
true, INVALID_STATION))
return false;
2429 const T *st = FindStationsNearby<T>(ta,
false);
2430 return st ==
nullptr && (
_settings_game.
station.
adjacent_stations || std::any_of(std::begin(_stations_nearby_list), std::end(_stations_nearby_list), [](StationID s) {
return s != NEW_STATION; }));
2442 if (StationJoinerNeeded<T>(ta, proc)) {
2446 proc(
false, INVALID_STATION);
2457 ShowSelectBaseStationIfNeeded<Station>(ta, std::move(proc));
2467 ShowSelectBaseStationIfNeeded<Waypoint>(ta, std::move(proc));
@ VEH_AIRCRAFT
Aircraft vehicle type.
int grouping_index
Currently selected entry in the grouping drop down.
static bool StationJoinerNeeded(TileArea ta, const StationPickerCmdProc &proc)
Check whether we need to show the station selection window.
void HandleCargoWaitingClick(CargoDataEntry *filter, Tid next)
Expand or collapse a specific row.
static debug_inline uint TileY(TileIndex tile)
Get the Y component of a tile.
StationFacility facilities
The facilities that this station has.
static constexpr CargoID CF_SELECT_ALL
Select all items (station list)
constexpr uint ToPercent8(uint i)
Converts a "fract" value 0..255 to "percent" value 0..100.
void SetTimeout()
Set the timeout flag of the window and initiate the timer.
StationCargoPacketMap ::const_iterator ConstIterator
The const iterator for our container.
@ WC_ROADVEH_LIST
Road vehicle list; Window numbers:
static const uint64_t AIRPORT_CLOSED_block
Dummy block for indicating a closed airport.
Point size
Size, in tile "units", of the white/red selection area.
uint64_t flags
stores which blocks on the airport are taken. was 16 bit earlier on, then 32
GoodsEntry goods[NUM_CARGO]
Goods at this station.
uint8_t rating
Station rating for this cargo.
constexpr T SetBit(T &x, const uint8_t y)
Set a bit in a variable.
uint8_t station_gui_sort_order
the sort order of entries in the station gui - ascending or descending
bool station_show_coverage
whether to highlight coverage area
bool ScrollMainWindowToTile(TileIndex tile, bool instant)
Scrolls the viewport of the main window to a given location.
StationSettings station
settings related to station management
@ ALH_ACCEPTS
Height of the accepted cargo view.
void UpdateTileSelection()
Updates tile highlighting for all cases.
A connected component of a link graph.
void ShowExtraViewportWindow(TileIndex tile=INVALID_TILE)
Show a new Extra Viewport window.
CargoDataEntry * filter
Parent of the cargo entry belonging to the row.
CargoArray GetAcceptanceAroundTiles(TileIndex center_tile, int w, int h, int rad, CargoTypes *always_accepted)
Get the acceptance of cargoes around the tile in 1/8.
CargoTypes cargoes
bitmap of cargo types to include
Dimensions (a width and height) of a rectangle in 2D.
static Titem * GetIfValid(size_t index)
Returns Titem with given index.
@ WDF_CONSTRUCTION
This window is used for construction; close it whenever changing company.
Rect Shrink(int s) const
Copy and shrink Rect by s pixels.
The information about a vehicle list.
CargoDataEntry * InsertOrRetrieve(StationID station)
Insert a new child or retrieve an existing child using a station ID as ID.
uint8_t station_gui_group_order
the order of grouping cargo entries in the station gui
static debug_inline uint MaxX()
Gets the maximum X coordinate within the map, including MP_VOID.
std::vector< const CargoSpec * > _sorted_cargo_specs
Cargo specifications sorted alphabetically by name.
@ INV_FLOWS
The planned flows have been recalculated and everything has to be updated.
const Tcont * Packets() const
Returns a pointer to the cargo packet list (so you can iterate over it etc).
CargoID cargo
ID of the cargo this entry is associated with.
Town * town
The town this station is associated with.
The list of stations per company.
@ FACIL_TRUCK_STOP
Station with truck stops.
void BuildStationsList(const Owner owner)
(Re)Build station list
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 constexpr CargoID CF_EXPAND_LIST
Expand list to show all items (station list)
uint32_t StringID
Numeric value that represents a string, independent of the selected language.
void OnRealtimeTick([[maybe_unused]] uint delta_ms) override
Called periodically.
void OnResize() override
Called after the window got resized.
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.
Tindex index
Index of this pool item.
static CargoSpec * Get(size_t index)
Retrieve cargo details for the given cargo ID.
CargoTypes GetAcceptanceMask(const Station *st)
Get a mask of the cargo types that the station accepts.
Class for storing amounts of cargo.
static bool StationWaitingTotalSorter(const Station *const &a, const Station *const &b, const CargoTypes &cargo_filter)
Sort stations by their waiting cargo.
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.
@ DT_MANUAL
Manual distribution. No link graph calculations are run.
CargoDataEntry cached_destinations
Cache for the flows passing through this station.
A row being displayed in the cargo view (as opposed to being "hidden" behind a plus sign).
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.
CargoID GetCargo() const
Get the cargo ID for this entry.
void SelectSortBy(int index)
Select a new sort criterium for the cargo view.
bool _ctrl_pressed
Is Ctrl pressed?
CargoList that is used for stations.
void FindStationsAroundSelection()
Find stations adjacent to the current tile highlight area, so that existing coverage area can be draw...
void BuildCargoList(CargoID i, const StationCargoList &packets, CargoDataEntry *cargo)
Build up the cargo view for WAITING mode and a specific cargo.
static void DrawCargoIcons(CargoID i, uint waiting, int left, int right, int y)
Draws icons of waiting cargo in the StationView window.
TextColour
Colour of the strings, see _string_colourmap in table/string_colours.h or docs/ottd-colourtext-palett...
void SetSortType(uint8_t n_type)
Set the sorttype of the list.
@ FACIL_NONE
The station has no facilities at all.
static const uint TILE_SIZE
Tile size in world coordinates.
int StrNaturalCompare(std::string_view s1, std::string_view s2, bool ignore_garbage_at_front)
Compares two strings using case insensitive natural sort.
void BuildCargoList(CargoDataEntry *cargo, const Station *st)
Build up the cargo view for all cargoes.
int DrawCargoRatings(const Rect &r) const
Draw cargo ratings in the WID_SV_ACCEPT_RATING_LIST widget.
void ShowCompanyStations(CompanyID company)
Opens window with list of company's stations.
static bool AddNearbyStation(TileIndex tile, void *user_data)
Add station on this tile to _stations_nearby_list if it's fully within the station spread.
constexpr uint CeilDiv(uint a, uint b)
Computes ceil(a / b) for non-negative a and b.
static Station * Get(size_t index)
Gets station with given index.
ClientSettings _settings_client
The current settings for this game.
Specification of a cargo type.
static bool IsValidID(size_t index)
Tests whether given index is a valid index for station of this type.
uint GetCount() const
Get the cargo count for this entry.
static bool UsingWallclockUnits(bool newgame=false)
Check if we are using wallclock units.
Owner owner
The owner of the content shown in this window. Company colour is acquired from this variable.
@ WC_STATION_VIEW
Station view; Window numbers:
SpriteID GetCargoIcon() const
Get sprite for showing cargo of this type.
static const StringID _sort_names[]
Names of the sorting options in the dropdown.
@ VEH_ROAD
Road vehicle type.
@ CC_PASSENGERS
Passengers.
void OnPaint() override
The window must be repainted.
@ GR_DESTINATION
Group by estimated final destination ("to").
StringID SearchNonStop(CargoDataEntry *cd, StationID station, int column)
Determine if we need to show the special "non-stop" string.
TileArea area
Location of new station.
static bool StationTypeSorter(const Station *const &a, const Station *const &b, const CargoTypes &)
Sort stations by their type.
Owner
Enum for all companies/owners.
const Scrollbar * GetScrollbar(WidgetID widnum) const
Return the Scrollbar to a widget index.
Owner owner
The owner of this station.
uint expand_shrink_width
The width allocated to the expand/shrink 'button'.
@ MODE_PLANNED
Show cargo planned to pass through the station.
CargoDataSet * children
the children of this entry.
uint16_t h
The height of the area.
@ GR_SOURCE
Group by source of cargo ("from").
bool NeedRebuild() const
Check if a rebuild is needed.
AcceptListHeight
Height of the WID_SV_ACCEPT_RATING_LIST widget for different views.
bool include_no_rating
Whether we should include stations with no cargo rating.
void ShowStationViewWindow(StationID station)
Opens StationViewWindow for given station.
#define Debug(category, level, format_string,...)
Ouptut a line of debugging information.
uint TotalCount() const
Returns total count of cargo at the station, including cargo which is already reserved for loading.
@ INV_CARGO
Some cargo has been added or removed.
@ QSF_LEN_IN_CHARS
the length of the string is counted in characters
CargoDataEntry * InsertOrRetrieve(CargoID cargo)
Insert a new child or retrieve an existing child using a cargo ID as ID.
static Pool::IterateWrapper< Station > Iterate(size_t from=0)
Returns an iterable ensemble of all valid stations of type T.
Mode current_mode
Currently selected display mode of cargo view.
static const int NUM_COLUMNS
Number of "columns" in the cargo view: cargo, from, via, to.
High level window description.
StationID GetFirstStation() const
Gets the ID of the station where the cargo was loaded for the first time.
void OnResize() override
Called after the window got resized.
StationCargoList cargo
The cargo packets of cargo waiting in this station.
uint num_children
the number of subentries belonging to this entry.
int ScaleGUITrad(int value)
Scale traditional pixel dimensions to GUI zoom level.
@ FACIL_BUS_STOP
Station with bus stops.
CargoArray GetProductionAroundTiles(TileIndex north_tile, int w, int h, int rad)
Get the cargo types being produced around the tile (in a rectangle).
std::span< const CargoSpec * > _sorted_standard_cargo_specs
Standard cargo specifications sorted alphabetically by name.
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.
static const uint8_t PC_GREEN
Green palette colour.
static bool StationNameSorter(const Station *const &a, const Station *const &b, const CargoTypes &)
Sort stations by their name.
StringID GetEntryString(StationID station, StringID here, StringID other_station, StringID any)
Select the correct string for an entry referring to the specified station.
static bool StationRatingMinSorter(const Station *const &a, const Station *const &b, const CargoTypes &cargo_filter)
Sort stations by their rating.
bool NeedResort()
Check if a resort is needed next loop If used the resort timer will decrease every call till 0.
@ WDP_AUTO
Find a place automatically.
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.
CargoSortType sortings[NUM_COLUMNS]
Sort types of the different 'columns'.
Iterable ensemble of each set bit in a value.
uint GetNumChildren() const
Get the number of children for this entry.
bool CircularTileSearch(TileIndex *tile, uint size, TestTileOnSearchProc proc, void *user_data)
Function performing a search around a center tile and going outward, thus in circle.
int32_t WindowNumber
Number to differentiate different windows of the same class.
void OnInvalidateData([[maybe_unused]] int data=0, [[maybe_unused]] bool gui_scope=true) override
Some data on this window has become invalid.
@ FS_NORMAL
Index of the normal font in the font tables.
int DrawAcceptedCargo(const Rect &r) const
Draw accepted cargo in the WID_SV_ACCEPT_RATING_LIST widget.
StationCoverageType
Types of cargo to display for station coverage.
void SetDisplayedRow(const CargoDataEntry *data)
Mark a specific row, characterized by its CargoDataEntry, as expanded.
void ShowCargo(CargoDataEntry *data, CargoID cargo, StationID source, StationID next, StationID dest, uint count)
Show a certain cargo entry characterized by source/next/dest station, cargo ID and amount of cargo at...
StationID next_station
ID of the station belonging to the entry actually displayed if it's to/from/via.
bool HasRating() const
Does this cargo have a rating at this station?
void OnResize() override
Called after the window got resized.
bool IsValid() const
Tests for validity of this cargospec.
void SetDirty() const
Mark entire window as dirty (in need of re-paint)
std::conditional_t< std::is_same_v< const CargoTypes &, std::nullptr_t >, bool(const const Station * &, const const Station * &), bool(const const Station * &, const const Station * &, const const CargoTypes &)> SortFunction
Signature of sort function.
void HandleCargoWaitingClick(int row)
Handle a click on a specific row in the cargo view.
void ForceResort()
Force a resort next Sort call Reset the resort timer if used too.
@ FS_SMALL
Index of the small font in the font tables.
void OnPaint() override
The window must be repainted.
static bool StationRatingMaxSorter(const Station *const &a, const Station *const &b, const CargoTypes &cargo_filter)
Sort stations by their rating.
NodeID node
ID of node in link graph referring to this goods entry.
static void StationsWndShowStationRating(int left, int right, int y, CargoID type, uint amount, byte rating)
Draw small boxes of cargo amount and ratings data at the given coordinates.
void ToggleSortOrder()
Toggle the sort order Since that is the worst condition for the sort function reverse the list here.
CargoTypes _cargo_mask
Bitmask of cargo types available.
Airport airport
Tile area the airport covers.
Represents the covered area of e.g.
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.
void BuildFlowList(CargoID i, const FlowStatMap &flows, CargoDataEntry *cargo)
Build up the cargo view for PLANNED mode and a specific cargo.
Window for selecting stations/waypoints to (distant) join to.
Window * parent
Parent window.
bool IsDescSortOrder() const
Check if the sort order is descending.
CompanyID _local_company
Company controlled by the human player at this client. Can also be COMPANY_SPECTATOR.
@ Count
by amount of cargo
void ShowQueryString(StringID str, StringID caption, uint maxsize, Window *parent, CharSetFilter afilter, QueryStringFlags flags)
Show a query popup window with a textbox in it.
void LowerWidget(WidgetID widget_index)
Marks a widget as lowered.
CargoDataEntry * Retrieve(CargoID cargo) const
Retrieve a child for the given cargo.
void ShowSelectWaypointIfNeeded(TileArea ta, StationPickerCmdProc proc)
Show the waypoint selection window when needed.
Rect Indent(int indent, bool end) const
Copy Rect and indent it from its position.
@ WC_SHIPS_LIST
Ships list; Window numbers:
StationID station
ID of the station this entry is associated with.
Grouping groupings[NUM_COLUMNS]
Grouping modes for the different columns.
void RecalcDestinations(CargoID i)
Rebuild the cache for estimated destinations which is used to quickly show the "destination" entries ...
Rect WithWidth(int width, bool end) const
Copy Rect and set its width.
static bool StationWaitingAvailableSorter(const Station *const &a, const Station *const &b, const CargoTypes &cargo_filter)
Sort stations by their available waiting cargo.
Owner GetTileOwner(Tile tile)
Returns the owner of a tile.
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.
@ MODE_WAITING
Show cargo waiting at the station.
void Remove(StationID station)
Remove a child associated with the given station.
byte CargoID
Cargo slots to indicate a cargo type within a game.
Coordinates of a point in 2D.
LinkGraphSettings linkgraph
settings for link graph calculations
@ WC_TRAINS_LIST
Trains list; Window numbers:
uint AvailableCount() const
Returns sum of cargo still available for loading at the sation.
CargoDataEntry * GetParent() const
Get the parent entry for this entry.
int DivideApprox(int a, int b)
Deterministic approximate division.
@ FACIL_DOCK
Station with a dock.
void ShowDropDownMenu(Window *w, const StringID *strings, int selected, WidgetID button, uint32_t disabled_mask, uint32_t hidden_mask, uint width)
Show a dropdown menu window near a widget of the parent window.
byte station_spread
amount a station may spread
WindowNumber window_number
Window number within the window class.
TileIndex TileAddByDir(TileIndex tile, Direction dir)
Adds a Direction to a tile.
VehicleType
Available vehicle types.
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.
LinkGraphID link_graph
Link graph this station belongs to.
uint32_t SpriteID
The number of a sprite, without mapping bits and colourtables.
constexpr uint CountBits(T value)
Counts the number of set bits in a variable.
@ CS_ALPHANUMERAL
Both numeric and alphabetic and spaces and stuff.
void SortStationsList()
Sort the stations list.
@ WC_NONE
No window, redirects to WC_MAIN_WINDOW.
static const StringID _group_names[]
Names of the grouping options in the dropdown.
void SetWidgetLoweredState(WidgetID widget_index, bool lowered_stat)
Sets the lowered/raised status of a widget.
@ FACIL_WAYPOINT
Station is a waypoint.
uint DistanceMax(TileIndex t0, TileIndex t1)
Gets the biggest distance component (x or y) between the two given tiles.
void SetWidgetDisabledState(WidgetID widget_index, bool disab_stat)
Sets the enabled/disabled status of a widget.
uint ReservedCount() const
Returns sum of cargo reserved for loading onto vehicles.
static const uint MAX_LENGTH_STATION_NAME_CHARS
The maximum length of a station name in characters including '\0'.
byte dirty
Whether the build station window needs to redraw due to the changed selection.
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)
std::array< uint16_t, NUM_CARGO > stations_per_cargo_type
Number of stations with a rating for each cargo type.
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.
@ SBS_DOWN
Sort ascending.
void SetTransfers(bool value)
Set the transfers state.
int DrawStringMultiLine(int left, int right, int top, int bottom, std::string_view str, TextColour colour, StringAlignment align, bool underline, FontSize fontsize)
Draw string, possibly over multiple lines.
Stores station stats for a single cargo.
void DrawSortButtonState(WidgetID widget, SortButtonState state) const
Draw a sort button's up or down arrow symbol.
@ WC_SELECT_STATION
Select station (when joining stations); Window numbers:
static Pool::IterateWrapper< Titem > Iterate(size_t from=0)
Returns an iterable ensemble of all valid Titem.
void CreateNestedTree()
Perform the first part of the initialization of a nested widget tree.
static uint MaxY()
Gets the maximum Y coordinate within the map, including MP_VOID.
Invalidation
Type of data invalidation.
CargoDataVector displayed_rows
Parent entry of currently displayed rows (including collapsed ones).
bool IsShaded() const
Is window shaded currently?
void Update(uint count)
Update the count for this entry and propagate the change to the parent entry if there is one.
Listing GetListing() const
Export current sort conditions.
CargoDataEntry * Retrieve(StationID station) const
Retrieve a child for the given station.
void Clear()
Delete all subentries, reset count and num_children and adapt parent's count.
StationID GetStation() const
Get the station ID for this entry.
@ FACIL_TRAIN
Station with train station.
void CloseChildWindows(WindowClass wc=WC_INVALID) const
Close all children a window might have in a head-recursive manner.
CargoID next_cargo
ID of the cargo belonging to the entry actually displayed if it's cargo.
static debug_inline uint Size()
Get the size of the map.
FlowStatMap flows
Planned flows through this station.
void SetDParam(size_t n, uint64_t v)
Set a string parameter v at index n in the global string parameter array.
SortOrder sort_orders[NUM_COLUMNS]
Sort order (ascending/descending) for the 'columns'.
@ SCT_NON_PASSENGERS_ONLY
Draw all non-passenger class cargoes.
StationID GetStationIndex(Tile t)
Get StationID from a tile.
@ StationString
by station name
TileIndex tile
The base tile of the area.
Flow descriptions by origin stations.
StationID station
StationID.
@ OWNER_NONE
The tile has no ownership.
int ScaleSpriteTrad(int value)
Scale traditional pixel dimensions to GUI zoom level, for drawing sprites.
@ MP_STATION
A tile of a station.
@ HT_RECT
rectangle (stations, depots, ...)
uint16_t stations_per_cargo_type_no_rating
Number of stations without a rating.
Mode
Display mode of the cargo view.
StringID name
Name of this type of cargo.
void FinishInitNested(WindowNumber window_number=0)
Perform the second part of the initialization of a nested widget tree.
TileIndex xy
Base tile of the station.
void ShowDropDownList(Window *w, DropDownList &&list, int selected, WidgetID button, uint width, bool instant_close, bool persist)
Show a drop down list.
Base class for all station-ish types.
bool HasStationInUse(StationID station, bool include_company, CompanyID company)
Tests whether the company's vehicles have this station in orders.
void SetViewportCatchmentStation(const Station *st, bool sel)
Select or deselect station for coverage area highlight.
bool HasTransfers() const
Has this entry transfers.
StringID abbrev
Two letter abbreviation for this cargo type.
#define TILE_ADDXY(tile, x, y)
Adds a given offset to a tile.
uint16_t w
The width of the area.
void RaiseWidget(WidgetID widget_index)
Marks a widget as raised.
byte facilities
types of stations of interest
bool distant_join_stations
allow to join non-adjacent stations
void OnInvalidateData([[maybe_unused]] int data=0, [[maybe_unused]] bool gui_scope=true) override
Some data on this window has become invalid.
@ GR_NEXT
Group by next station ("via").
@ ALH_RATING
Height of the cargo ratings view.
uint8_t SortType() const
Get the sorttype of the list.
bool adjacent_stations
allow stations to be built directly adjacent to other stations
A cargo data entry representing one possible row in the station view window's top part.
@ SA_CENTER
Center both horizontally and vertically.
int GetCharacterHeight(FontSize size)
Get height of a character for a given font size.
int width
width of the window (number of pixels to the right in x direction)
Container for cargo from the same location and time.
static debug_inline TileIndex TileXY(uint x, uint y)
Returns the TileIndex of a coordinate.
static int SortButtonWidth()
Get width of up/down arrow of sort button state.
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.
void SelectSortOrder(SortOrder order)
Select a new sort order for the cargo view.
void SelectGroupBy(int index)
Select a new grouping mode for the cargo view.
uint count
sum of counts of all children or amount of cargo for this entry.
@ AsGrouping
by the same principle the entries are being grouped
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.
int accepts_lines
Number of lines in the accepted cargo view.
CargoDataEntry * parent
the parent of this entry.
int scroll_to_row
If set, scroll the main viewport to the station pointed to by this row.
Drop down checkmark component.
static debug_inline TileIndex TileVirtXY(uint x, uint y)
Get a tile from the virtual XY-coordinate.
void Remove(CargoID cargo)
Remove a child associated with the given cargo.
uint16_t Count() const
Gets the number of 'items' in this packet.
bool IsInUse() const
Check whether the base station currently is in use; in use means that it is not scheduled for deletio...
@ GR_CARGO
Group by cargo type.
Data structure for an opened window.
static debug_inline bool IsTileType(Tile tile, TileType type)
Checks if a tile is a given tiletype.
@ VEH_TRAIN
Train vehicle type.
void OnGameTick() override
Called once per (game) tick.
static bool IsValidID(size_t index)
Tests whether given index can be used to get valid (non-nullptr) Titem.
int rating_lines
Number of lines in the cargo ratings view.
const Station * _viewport_highlight_station
Currently selected station for coverage area highlight.
static const uint8_t PC_RED
Red palette colour.
void DrawWidgets() const
Paint all widgets of a window.
CargoDataEntry expanded_rows
Parent entry of currently expanded rows.
@ FACIL_AIRPORT
Station with an airport.
static debug_inline uint TileX(TileIndex tile)
Get the X component of a tile.
static const CargoID NUM_CARGO
Maximum number of cargo types in a game.
Grouping
Type of grouping used in each of the "columns".
static constexpr CargoID CF_NO_RATING
Show items with no rating (station list)
void EstimateDestinations(CargoID cargo, StationID source, StationID next, uint count, CargoDataEntry *dest)
Estimate the amounts of cargo per final destination for a given cargo, source station and next hop an...
@ VEH_SHIP
Ship vehicle type.
Specification of a rectangle with absolute coordinates of all edges.
bool IsCargoInClass(CargoID c, CargoClass cc)
Does cargo c have cargo class cc?
void ToggleWidgetLoweredState(WidgetID widget_index)
Invert the lowered/raised status of a widget.
@ WC_DROPDOWN_MENU
Drop down menu; Window numbers:
Struct containing TileIndex and StationID.
CompanyID exclusivity
which company has exclusivity
bool Sort(Comp compare)
Sort the list.
@ WC_AIRCRAFT_LIST
Aircraft list; Window numbers:
Drop down string component.
static const T * FindStationsNearby(TileArea ta, bool distant_join)
Circulate around the to-be-built station to find stations we could join.
@ QSF_ENABLE_DEFAULT
enable the 'Default' button ("\0" is returned)
@ WC_STATION_LIST
Station list; Window numbers:
void ResetObjectToPlace()
Reset the cursor and mouse mode handling back to default (normal cursor, only clicking in windows).
@ TD_RTL
Text is written right-to-left by default.
uint8_t exclusive_counter
months till the exclusivity expires
TextDirection _current_text_dir
Text direction of the currently selected language.
TextColour GetContrastColour(uint8_t background, uint8_t threshold)
Determine a contrasty text colour for a coloured background.
bool freeze
Freeze highlight in place.
Dimension GetLargestCargoIconSize()
Get dimensions of largest cargo icon.
constexpr T ToggleBit(T &x, const uint8_t y)
Toggles a bit in a variable.
Dimension GetStringBoundingBox(std::string_view str, FontSize start_fontsize)
Return the string dimension in pixels.
uint8_t station_gui_sort_by
sort cargo entries in the station gui by station name or amount
CargoDataSet::iterator Begin() const
Get an iterator pointing to the begin of the set of children.
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
uint Monthly(uint base) const
Scale a value to its monthly equivalent, based on last compression.
bool transfers
If there are transfers for this cargo.
void OnInvalidateData([[maybe_unused]] int data=0, [[maybe_unused]] bool gui_scope=true) override
Some data on this window has become invalid.
bool persistent_buildingtools
keep the building tools active after usage
void SetListing(Listing l)
Import sort conditions.
int DrawEntries(CargoDataEntry *entry, const Rect &r, int pos, int maxrows, int column, CargoID cargo=INVALID_CARGO)
Draw the given cargo entries in the station GUI.
void ShowSelectBaseStationIfNeeded(TileArea ta, StationPickerCmdProc &&proc)
Show the station selection window when needed.
void IncrementSize()
Increment.
CargoDataSet::iterator End() const
Get an iterator pointing to the end of the set of children.
constexpr uint8_t FindFirstBit(T x)
Search the first set bit in a value.
constexpr debug_inline bool HasBit(const T x, const uint8_t y)
Checks if a bit in a value is set.