44#include "table/strings.h"
56 static bool IsAcceptableWaypointTile(
TileIndex) {
return false; }
57 static constexpr bool IsWaypoint() {
return false; }
60template <
bool ROAD, TileType TILE_TYPE>
67 static bool IsAcceptableWaypointTile(
TileIndex tile) {
return IsTileType(tile, TILE_TYPE); }
68 static constexpr bool IsWaypoint() {
return true; }
99 default: NOT_REACHED();
101 if (cargoes[cargo] >= (supplies ? 1U : 8U)) cargo_mask.
Set(cargo);
116 SetViewportCatchmentSpecializedStation<typename T::StationType>(
nullptr,
true);
125 typename T::StationType *st = T::StationType::GetByTile(location.
tile);
126 if (st !=
nullptr && T::IsValidBaseStation(st)) {
127 SetViewportCatchmentSpecializedStation<typename T::StationType>(st,
true);
137 int max_c = T::IsWaypoint() && !T::IsAcceptableWaypointTile(location.
tile) ? 0 : 1;
140 typename T::StationType *adjacent =
nullptr;
145 typename T::StationType *st = T::StationType::GetByTile(tile);
146 if (st ==
nullptr || !T::IsValidBaseStation(st))
continue;
147 if (adjacent !=
nullptr && st != adjacent) {
155 SetViewportCatchmentSpecializedStation<typename T::StationType>(adjacent,
true);
166 static bool _last_ctrl_pressed;
172 if (_thd.dirty & 1) {
183void CheckRedrawWaypointCoverage()
186 static bool _last_ctrl_pressed;
192 if (_thd.dirty & 1) {
195 if (_thd.drawstyle ==
HT_RECT) {
201void CheckRedrawRailWaypointCoverage(
const Window *)
203 CheckRedrawWaypointCoverage<RailWaypointTypeFilter>();
206void CheckRedrawRoadWaypointCoverage(
const Window *)
208 CheckRedrawWaypointCoverage<RoadWaypointTypeFilter>();
225 static const uint units_full = 576;
226 static const uint rating_full = 224;
232 int width = right - left;
235 uint w = std::min(amount + 5, units_full) * width / units_full;
241 GfxFillRect(left, y, left + w - 1, y + height, colour);
247 GfxFillRect(left, y + height - rest, left + padding - 1, y + height, colour);
254 y += height + padding + 1;
256 w = std::min<uint>(rating, rating_full) * (width - padding - padding) / rating_full;
265class CompanyStationsWindow :
public Window {
285 STR_SORT_BY_FACILITY,
286 STR_SORT_BY_WAITING_TOTAL,
287 STR_SORT_BY_WAITING_AVAILABLE,
288 STR_SORT_BY_RATING_MAX,
289 STR_SORT_BY_RATING_MIN,
291 static const std::initializer_list<GUIStationList::SortFunction * const>
sorter_funcs;
297 GUIStationList stations{filter.
cargoes};
298 Scrollbar *vscroll =
nullptr;
299 uint rating_width = 0;
300 bool filter_expanded =
false;
315 this->stations.clear();
316 this->stations_per_cargo_type.fill(0);
317 this->stations_per_cargo_type_no_rating = 0;
323 this->string_filter.AddLine(st->GetCachedName());
324 if (!this->string_filter.
GetState())
continue;
326 bool has_rating =
false;
329 if (st->goods[cargo].HasRating()) this->stations_per_cargo_type[cargo]++;
332 if (st->goods[cargo].HasRating()) {
335 this->stations.push_back(st);
343 this->stations_per_cargo_type_no_rating++;
351 this->vscroll->
SetCount(this->stations.size());
358 if (r == 0)
return a->index < b->index;
374 diff += a->
goods[cargo].TotalCount() - b->
goods[cargo].TotalCount();
386 diff += a->
goods[cargo].AvailableCount() - b->
goods[cargo].AvailableCount();
399 if (a->
goods[cargo].HasRating()) maxr1 = std::max(maxr1, a->
goods[cargo].rating);
400 if (b->
goods[cargo].HasRating()) maxr2 = std::max(maxr2, b->
goods[cargo].rating);
403 return maxr1 < maxr2;
413 if (a->
goods[cargo].HasRating()) minr1 = std::min(minr1, a->
goods[cargo].rating);
414 if (b->
goods[cargo].HasRating()) minr2 = std::min(minr2, b->
goods[cargo].rating);
417 return minr1 > minr2;
423 if (!this->stations.
Sort())
return;
433 this->filter = CompanyStationsWindow::initial_state;
436 this->stations.SetListing(this->filter.last_sorting);
438 this->stations.ForceRebuild();
439 this->stations.NeedResort();
440 this->SortStationsList();
442 this->CreateNestedTree();
445 this->owner = this->window_number;
453 this->LowerWidget(WID_STL_TRAIN + to_underlying(facil));
463 this->filter.last_sorting = this->stations.
GetListing();
464 CompanyStationsWindow::initial_state = this->filter;
473 d.
height += padding.height;
480 d.
width += padding.width;
481 d.
height += padding.height;
491 this->rating_width = 0;
496 this->rating_width = this->rating_width * 16 / 10;
527 for (
auto it = first; it != last; ++it) {
536 x += rtl ? -text_spacing : text_spacing;
541 if (st->
goods[cargo_type].HasRating()) {
547 x -= rating_width + rating_spacing;
548 if (x < tr.left)
break;
552 x += rating_width + rating_spacing;
553 if (x > tr.right)
break;
557 tr.top += line_height;
560 if (this->vscroll->
GetCount() == 0) {
572 return GetString(STR_STATION_LIST_CAPTION, this->window_number, this->vscroll->
GetCount());
579 return GetString(STR_STATION_LIST_CARGO_FILTER_MULTIPLE);
585 DropDownList BuildCargoDropDownList(
bool expanded)
const
594 bool any_hidden =
false;
596 uint16_t count = this->stations_per_cargo_type_no_rating;
597 if (count == 0 && !expanded) {
600 list.push_back(std::make_unique<DropDownString<DropDownListCheckedItem, FontSize::Small, true>>(fmt::format(
"{}", count), 0, this->filter.include_no_rating,
GetString(STR_STATION_LIST_CARGO_FILTER_NO_RATING),
CargoFilterCriteria::CF_NO_RATING,
false, count == 0));
606 if (count == 0 && !expanded) {
609 list.push_back(std::make_unique<DropDownListCargoItem>(this->filter.cargoes.Test(cs->Index()), fmt::format(
"{}", count), d, cs->GetCargoIcon(), PAL_NONE,
GetString(cs->name), cs->Index(),
false, count == 0));
613 if (!expanded && any_hidden) {
626 if (it == this->stations.end())
return;
680 static std::string cargo_filter;
681 this->filter_expanded =
false;
691 if (this->stations.
SortType() != index) {
722 this->filter_expanded =
true;
723 ReplaceDropDownList(
this, this->BuildCargoDropDownList(this->filter_expanded));
732 if (
IsCtrlPressed()) ReplaceDropDownList(
this, this->BuildCargoDropDownList(this->filter_expanded));
766 void OnInvalidateData([[maybe_unused]]
int data = 0, [[maybe_unused]]
bool gui_scope =
true)
override
787static constexpr std::initializer_list<NWidgetPart> _nested_company_stations_widgets = {
801 NWidget(
WWT_PUSHTXTBTN,
Colours::Grey,
WID_STL_FACILALL),
SetAspect(WidgetDimensions::ASPECT_VEHICLE_ICON),
SetStringTip(STR_ABBREV_ALL, STR_STATION_LIST_SELECT_ALL_FACILITIES_TOOLTIP),
SetTextStyle(
TextColour::Black,
FontSize::Small),
SetFill(0, 1),
812 NWidget(
WWT_PANEL,
Colours::Grey,
WID_STL_LIST),
SetMinimalSize(346, 125),
SetResize(1, 10),
SetToolTip(STR_STATION_LIST_TOOLTIP),
SetScrollbar(
WID_STL_SCROLLBAR),
EndContainer(),
823 WindowClass::StationList, WindowClass::None,
825 _nested_company_stations_widgets
840static constexpr std::initializer_list<NWidgetPart> _nested_station_view_widgets = {
852 NWidget(
WWT_DROPDOWN,
Colours::Grey,
WID_SV_GROUP_BY),
SetMinimalSize(168, 12),
SetResize(1, 0),
SetFill(0, 1),
SetToolTip(STR_TOOLTIP_GROUP_ORDER),
856 NWidget(
WWT_DROPDOWN,
Colours::Grey,
WID_SV_SORT_BY),
SetMinimalSize(168, 12),
SetResize(1, 0),
SetFill(0, 1),
SetToolTip(STR_TOOLTIP_SORT_CRITERIA),
865 SetStringTip(STR_STATION_VIEW_RATINGS_BUTTON, STR_STATION_VIEW_RATINGS_TOOLTIP),
868 SetStringTip(STR_STATION_VIEW_CLOSE_AIRPORT, STR_STATION_VIEW_CLOSE_AIRPORT_TOOLTIP),
870 NWidget(
WWT_TEXTBTN,
Colours::Grey,
WID_SV_CATCHMENT),
SetMinimalSize(45, 12),
SetResize(1, 0),
SetFill(1, 1),
SetStringTip(STR_BUTTON_CATCHMENT, STR_TOOLTIP_CATCHMENT),
879enum SortOrder : uint8_t {
897 using is_transparent = void;
901 bool operator()(
const CargoDataEntry &cd1,
const std::unique_ptr<CargoDataEntry> &cd2)
const {
return this->operator()(cd1, *cd2); }
902 bool operator()(
const std::unique_ptr<CargoDataEntry> &cd1,
const CargoDataEntry &cd2)
const {
return this->operator()(*cd1, cd2); }
903 bool operator()(
const std::unique_ptr<CargoDataEntry> &cd1,
const std::unique_ptr<CargoDataEntry> &cd2)
const {
return this->operator()(*cd1, *cd2); }
910 bool SortId(Tid st1, Tid st2)
const;
912 bool SortStation(StationID st1, StationID st2)
const;
915typedef std::set<std::unique_ptr<CargoDataEntry>,
CargoSorter> CargoDataSet;
922class CargoDataEntry {
965 CargoDataEntry t(
cargo);
987 CargoDataEntry t(
cargo);
1057 template <
class T
id>
1076CargoDataEntry::CargoDataEntry() :
1078 station(StationID::
Invalid()),
1089 children(std::make_unique<CargoDataSet>())
1092CargoDataEntry::CargoDataEntry(StationID station, uint count,
CargoDataEntry *parent) :
1097 children(std::make_unique<CargoDataSet>())
1100CargoDataEntry::CargoDataEntry(StationID station) :
1108CargoDataEntry::CargoDataEntry(
CargoType cargo) :
1128 if (this->
parent !=
nullptr) this->
parent->count -= this->count;
1141 CargoDataSet::iterator i = this->
children->find(entry);
1154 CargoDataEntry tmp(child_id);
1155 CargoDataSet::iterator i = this->
children->find(tmp);
1158 return **(this->
children->insert(std::make_unique<CargoDataEntry>(child_id, 0,
this)).first);
1172 this->count +=
count;
1182 if (this->
parent !=
nullptr) this->
parent->IncrementSize();
1185void CargoDataEntry::Resort(
CargoSortType type, SortOrder order)
1187 auto new_children = std::make_unique<CargoDataSet>(
CargoSorter(type, order));
1188 new_children->merge(*this->
children);
1189 this->
children = std::move(new_children);
1204 switch (this->type) {
1210 return this->SortCount(cd1, cd2);
1219bool CargoSorter::SortId(Tid st1, Tid st2)
const
1221 return (this->order == SO_ASCENDING) ? st1 < st2 : st2 < st1;
1230 }
else if (this->order == SO_ASCENDING) {
1237bool CargoSorter::SortStation(StationID st1, StationID st2)
const
1240 return Station::IsValidID(st2) ? this->order == SO_ASCENDING : this->SortId(st1, st2);
1242 return order == SO_DESCENDING;
1247 return this->SortId(st1, st2);
1249 return (this->order == SO_ASCENDING) ? res < 0 : res > 0;
1281 typedef std::vector<RowDisplay> CargoDataVector;
1324 STR_STATION_VIEW_WAITING_STATION,
1325 STR_STATION_VIEW_WAITING_AMOUNT,
1326 STR_STATION_VIEW_PLANNED_STATION,
1327 STR_STATION_VIEW_PLANNED_AMOUNT,
1331 STR_STATION_VIEW_GROUP_S_V_D,
1332 STR_STATION_VIEW_GROUP_S_D_V,
1333 STR_STATION_VIEW_GROUP_V_S_D,
1334 STR_STATION_VIEW_GROUP_V_D_S,
1335 STR_STATION_VIEW_GROUP_D_S_V,
1336 STR_STATION_VIEW_GROUP_D_V_S,
1371 this->sort_orders[0] = SO_ASCENDING;
1383 void Close([[maybe_unused]]
int data = 0)
override
1406 if (count == 0)
return;
1409 for (
int i = 0; i <
NUM_COLUMNS && expand !=
nullptr; ++i) {
1418 if (auto_distributed || source != this->window_number) {
1424 if (auto_distributed) {
1430 if (auto_distributed) {
1444 fill.height =
resize.height = this->line_height;
1480 const Rect r = wid->GetCurrentRect();
1483 if (lines > this->accepts_lines) {
1484 this->accepts_lines = lines;
1490 if (lines > this->rating_lines) {
1491 this->rating_lines = lines;
1509 this->
DrawEntries(cargo, waiting_rect, pos, maxrows, 0);
1535 if (!st->
goods[cargo].HasData())
return;
1537 for (
const auto &it : st->
goods[cargo].GetData().flows) {
1538 StationID from = it.first;
1540 uint32_t prev_count = 0;
1541 for (
const auto &flow_it : *it.second.GetShares()) {
1542 StationID via = flow_it.second;
1544 if (via == this->window_number) {
1549 prev_count = flow_it.first;
1571 FlowStatMap::const_iterator map_it = flowmap.find(source);
1572 if (map_it != flowmap.end()) {
1573 const FlowStat::SharesMap *shares = map_it->second.GetShares();
1574 uint32_t prev_count = 0;
1575 for (FlowStat::SharesMap::const_iterator i = shares->begin(); i != shares->end(); ++i) {
1577 prev_count = i->first;
1584 uint sum_estimated = 0;
1585 while (sum_estimated < count) {
1586 for (CargoDataSet::iterator i = tmp.
Begin(); i != tmp.
End() && sum_estimated < count; ++i) {
1589 if (estimate == 0) estimate = 1;
1591 sum_estimated += estimate;
1592 if (sum_estimated > count) {
1593 estimate -= sum_estimated - count;
1594 sum_estimated = count;
1622 for (FlowStatMap::const_iterator it = flows.begin(); it != flows.end(); ++it) {
1623 StationID from = it->first;
1625 const FlowStat::SharesMap *shares = it->second.GetShares();
1626 for (FlowStat::SharesMap::const_iterator flow_it = shares->begin(); flow_it != shares->end(); ++flow_it) {
1628 for (CargoDataSet::iterator dest_it = via_entry->
Begin(); dest_it != via_entry->
End(); ++dest_it) {
1647 StationID next = it.GetKey();
1650 if (source_entry ==
nullptr) {
1656 if (via_entry ==
nullptr) {
1661 uint remaining = cp->
Count();
1662 for (CargoDataSet::iterator dest_it = via_entry->
Begin(); dest_it != via_entry->
End();) {
1669 if (dest_it == via_entry->
End()) {
1693 if (this->cached_destinations.
Retrieve(cargo) ==
nullptr) {
1714 std::list<StationID> stations;
1716 if (
parent->GetParent() ==
nullptr) {
1722 while (
parent->GetParent()->GetParent() !=
nullptr) {
1723 stations.push_back(
parent->GetStation());
1729 while (!stations.empty()) {
1730 filter = filter->
Retrieve(stations.back());
1731 stations.pop_back();
1734 this->displayed_rows.push_back(
RowDisplay(filter, next));
1747 if (station == this->window_number) {
1749 }
else if (station == StationID::Invalid()) {
1751 }
else if (station == NEW_STATION) {
1752 return STR_STATION_VIEW_RESERVED;
1754 return other_station;
1761 case GR_SOURCE:
return this->
GetEntryString(station, STR_STATION_VIEW_FROM_HERE, STR_STATION_VIEW_FROM, STR_STATION_VIEW_FROM_ANY);
1762 case GR_NEXT:
return this->
GetEntryString(station, STR_STATION_VIEW_VIA_HERE, STR_STATION_VIEW_VIA, STR_STATION_VIEW_VIA_ANY);
1764 default: NOT_REACHED();
1779 for (
int i = column - 1; i > 0; --i) {
1781 if (
parent->GetStation() == station) {
1782 return STR_STATION_VIEW_NONSTOP;
1784 return STR_STATION_VIEW_VIA;
1791 CargoDataSet::iterator begin = cd.
Begin();
1792 CargoDataSet::iterator end = cd.
End();
1793 if (begin != end && ++(cd.
Begin()) == end && (*(begin))->GetStation() == station) {
1794 return STR_STATION_VIEW_NONSTOP;
1796 return STR_STATION_VIEW_VIA;
1800 return STR_STATION_VIEW_VIA;
1813 if (num == 0)
return;
1818 int y =
CentreBounds(r.top, r.bottom, this->cargo_icon_size.height);
1839 if (this->groupings[column] !=
GR_CARGO) {
1846 for (CargoDataSet::iterator i = entry.
Begin(); i != entry.
End(); ++i) {
1849 Grouping grouping = this->groupings[column];
1853 if (pos > -maxrows && pos <= 0) {
1855 StationID station = StationID::Invalid();
1856 int y = r.top - pos * this->line_height;
1857 if (this->groupings[column] ==
GR_CARGO) {
1858 str = STR_STATION_VIEW_WAITING_CARGO;
1861 if (!auto_distributed) grouping =
GR_SOURCE;
1863 str = this->GetGroupingString(grouping, station);
1864 if (grouping ==
GR_NEXT && str == STR_STATION_VIEW_VIA) str = this->
SearchNonStop(cd, station, column);
1878 std::string_view sym;
1881 }
else if (auto_distributed && str != STR_STATION_VIEW_RESERVED) {
1898 if ((auto_distributed || column == 0) && column <
NUM_COLUMNS - 1) {
1899 pos = this->
DrawEntries(cd, r, pos, maxrows, column + 1, cargo);
1944 GetString(STR_STATION_VIEW_CARGO_SUPPLY_RATING,
1946 lg !=
nullptr ? lg->
Monthly((*lg)[ge->
node].supply) : 0,
1947 STR_CARGO_RATING_APPALLING + (ge->
rating >> 5),
1959 template <
class T
id>
1962 if (filter->
Retrieve(next) !=
nullptr) {
1975 if (row < 0 || (uint)row >= this->displayed_rows.size())
return;
1977 this->scroll_to_row = row;
1979 RowDisplay &display = this->displayed_rows[row];
1980 if (display.
filter == &this->expanded_rows) {
2022 nwi->
SetStringTip(STR_STATION_VIEW_ACCEPTS_BUTTON, STR_STATION_VIEW_ACCEPTS_TOOLTIP);
2023 height_change = this->rating_lines - this->accepts_lines;
2025 nwi->
SetStringTip(STR_STATION_VIEW_RATINGS_BUTTON, STR_STATION_VIEW_RATINGS_TOOLTIP);
2026 height_change = this->accepts_lines - this->rating_lines;
2038 Command<Commands::OpenCloseAirport>::Post(this->window_number);
2067 this->
SelectSortOrder(this->sort_orders[1] == SO_ASCENDING ? SO_DESCENDING : SO_ASCENDING);
2081 this->sort_orders[1] = this->sort_orders[2] = this->sort_orders[3] = order;
2094 case STR_STATION_VIEW_WAITING_STATION.base():
2098 case STR_STATION_VIEW_WAITING_AMOUNT.base():
2102 case STR_STATION_VIEW_PLANNED_STATION.base():
2106 case STR_STATION_VIEW_PLANNED_AMOUNT.base():
2124 this->grouping_index = index;
2128 case STR_STATION_VIEW_GROUP_S_V_D.base():
2133 case STR_STATION_VIEW_GROUP_S_D_V.base():
2138 case STR_STATION_VIEW_GROUP_V_S_D.base():
2143 case STR_STATION_VIEW_GROUP_V_D_S.base():
2148 case STR_STATION_VIEW_GROUP_D_S_V.base():
2153 case STR_STATION_VIEW_GROUP_D_V_S.base():
2173 if (!str.has_value())
return;
2175 Command<Commands::RenameStation>::Post(STR_ERROR_CAN_T_RENAME_STATION, this->window_number, *str);
2188 void OnInvalidateData([[maybe_unused]]
int data = 0, [[maybe_unused]]
bool gui_scope =
true)
override
2203 WindowClass::StationView, WindowClass::None,
2205 _nested_station_view_widgets
2224static std::vector<TileAndStation> _deleted_stations_nearby;
2225static std::vector<StationID> _stations_nearby_list;
2238 for (
auto it = _deleted_stations_nearby.begin(); it != _deleted_stations_nearby.end(); ) {
2239 if (it->tile == tile) {
2240 _stations_nearby_list.push_back(it->station);
2241 it = _deleted_stations_nearby.erase(it);
2253 if (!T::IsValidID(sid))
return;
2256 if (st->
owner !=
_local_company || std::ranges::find(_stations_nearby_list, sid) != _stations_nearby_list.end())
return;
2259 _stations_nearby_list.push_back(sid);
2277 _stations_nearby_list.clear();
2278 _stations_nearby_list.push_back(NEW_STATION);
2279 _deleted_stations_nearby.clear();
2283 if (T::IsValidBaseStation(st) && !st->IsInUse() && st->owner ==
_local_company) {
2286 _deleted_stations_nearby.emplace_back(st->xy, st->index);
2305 if (distant_join && std::min(ta.
w, ta.
h) >=
_settings_game.station.station_spread)
return;
2306 uint max_dist = distant_join ?
_settings_game.station.station_spread - std::min(ta.
w, ta.
h) : 1;
2313static constexpr std::initializer_list<NWidgetPart> _nested_select_station_widgets = {
2334 StationPickerCmdProc select_station_proc{};
2340 select_station_proc(std::move(proc)),
2352 void Close([[maybe_unused]]
int data = 0)
override
2354 SetViewportCatchmentSpecializedStation<typename T::StationType>(
nullptr,
true);
2356 _thd.freeze =
false;
2366 for (
const auto &station : _stations_nearby_list) {
2367 if (station == NEW_STATION)
continue;
2370 ?
GetString(STR_STATION_LIST_WAYPOINT, st->index)
2376 d.
width += padding.width;
2377 d.
height += padding.height;
2387 for (
auto it = first; it != last; ++it, tr.top += this->
resize.step_height) {
2388 if (*it == NEW_STATION) {
2389 DrawString(tr, T::IsWaypoint() ? STR_JOIN_WAYPOINT_CREATE_SPLIT_WAYPOINT : STR_JOIN_STATION_CREATE_SPLIT_STATION);
2393 ?
GetString(STR_STATION_LIST_WAYPOINT, st->index)
2405 if (it == _stations_nearby_list.end())
return;
2408 this->select_station_proc(
false, *it);
2416 if (_thd.dirty & 2) {
2432 void OnInvalidateData([[maybe_unused]]
int data = 0, [[maybe_unused]]
bool gui_scope =
true)
override
2434 if (!gui_scope)
return;
2436 this->vscroll->
SetCount(_stations_nearby_list.size());
2443 SetViewportCatchmentSpecializedStation<typename T::StationType>(
nullptr,
true);
2449 const typename T::StationType *st = it == _stations_nearby_list.end() || *it == NEW_STATION ? nullptr : T::StationType::Get(*it);
2450 SetViewportCatchmentSpecializedStation<typename T::StationType>(st,
true);
2457 WindowClass::JoinStation, WindowClass::None,
2459 _nested_select_station_widgets
2476 if (selection_window !=
nullptr) {
2478 selection_window->
Close();
2486 return proc(
true, StationID::Invalid());
2503 proc(
false, StationID::Invalid());
@ AirportClosed
Dummy block for indicating a closed airport.
constexpr bool HasBit(const T x, const uint8_t y)
Checks if a bit in a value is set.
static constexpr CargoType INVALID_CARGO
Invalid marker for cargoes.
EnumBitSet< CargoType, uint64_t > CargoTypes
Bitset of CargoType elements.
static constexpr CargoType NUM_CARGO
Maximum number of cargo types in a game.
CargoType
Cargo slots to indicate a cargo type within a game.
Dimension GetLargestCargoIconSize()
Get dimensions of largest cargo icon.
std::span< const CargoSpec * > _sorted_standard_cargo_specs
Standard cargo specifications sorted alphabetically by name.
std::vector< const CargoSpec * > _sorted_cargo_specs
Cargo specifications sorted alphabetically by name.
CargoTypes _cargo_mask
Bitmask of cargo types available.
Types/functions related to cargoes.
bool IsCargoInClass(CargoType cargo, CargoClasses cc)
Does a given cargo have any cargo class from cc.
uint Count() const
Count the number of set bits.
constexpr bool Test(Tvalue_type value) const
Test if the value-th bit is set.
constexpr bool None() const
Test if none of the values are set.
constexpr Timpl & Flip()
Flip all bits.
constexpr Timpl & Reset()
Reset all bits.
constexpr Timpl & Set()
Set all bits.
auto begin() const
Returns an iterator to begin of the set bits.
constexpr bool Any(const Timpl &other) const
Test if any of the given values are set.
A cargo data entry representing one possible row in the station view window's top part.
uint count
sum of counts of all children or amount of cargo for this entry.
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.
void IncrementSize()
Increment.
void SetTransfers(bool value)
Set the transfers state.
~CargoDataEntry()
Remove ourselves from our parent.
CargoType GetCargo() const
Get the cargo type for this entry.
uint num_children
the number of subentries belonging to this entry.
void Remove(CargoType cargo)
Remove a child associated with the given cargo.
CargoDataEntry * Retrieve(StationID station) const
Retrieve a child for the given station.
uint GetCount() const
Get the cargo count for this entry.
CargoDataEntry * GetParent() const
Get the parent entry for this entry.
StationID station
ID of the station this entry is associated with.
CargoType cargo
ID of the cargo this entry is associated with.
CargoDataEntry & InsertOrRetrieve(StationID station)
Insert a new child or retrieve an existing child using a station ID as ID.
CargoDataEntry & InsertOrRetrieve(CargoType cargo)
Insert a new child or retrieve an existing child using a cargo type as ID.
CargoDataSet::iterator End() const
Get an iterator pointing to the end of the set of children.
void Update(uint count)
Update the count for this entry and propagate the change to the parent entry if there is one.
std::unique_ptr< CargoDataSet > children
the children of this entry.
bool transfers
If there are transfers for this cargo.
CargoDataSet::iterator Begin() const
Get an iterator pointing to the begin of the set of children.
bool HasTransfers() const
Has this entry transfers.
CargoDataEntry * Retrieve(CargoType cargo) const
Retrieve a child for the given cargo.
CargoDataEntry * parent
the parent of this entry.
void Remove(StationID station)
Remove a child associated with the given station.
uint GetNumChildren() const
Get the number of children for this entry.
const Tcont * Packets() const
Returns a pointer to the cargo packet list (so you can iterate over it etc).
StationCargoPacketMap::const_iterator ConstIterator
bool Succeeded() const
Did this command succeed?
The list of stations per company.
std::array< uint16_t, NUM_CARGO > stations_per_cargo_type
Number of stations with a rating for each cargo type.
static bool StationNameSorter(const Station *const &a, const Station *const &b, const CargoTypes &filter)
Sort stations by their name.
void UpdateWidgetSize(WidgetID widget, Dimension &size, const Dimension &padding, Dimension &fill, Dimension &resize) override
Update size and resize step of a widget in the window.
void OnEditboxChanged(WidgetID wid) override
The text in an editbox has been edited.
void OnResize() override
Called after the window got resized.
static bool StationWaitingAvailableSorter(const Station *const &a, const Station *const &b, const CargoTypes &filter)
Sort stations by their available waiting cargo.
void SortStationsList()
Sort the stations list.
void OnInvalidateData(int data=0, bool gui_scope=true) override
Some data on this window has become invalid.
StringFilter string_filter
Filter for name.
static const StringID sorter_names[]
Strings describing how stations are sorted.
void OnDropdownSelect(WidgetID widget, int index, int) override
A dropdown option associated to this window has been selected.
void OnClick(Point pt, WidgetID widget, int click_count) override
A click with the left mouse button has been made on the window.
static bool StationRatingMaxSorter(const Station *const &a, const Station *const &b, const CargoTypes &filter)
Sort stations by their rating.
std::string GetWidgetString(WidgetID widget, StringID stringid) const override
Get the raw string for a widget.
void OnPaint() override
The window must be repainted.
static bool StationWaitingTotalSorter(const Station *const &a, const Station *const &b, const CargoTypes &filter)
Sort stations by their waiting cargo.
void DrawWidget(const Rect &r, WidgetID widget) const override
Draw the contents of a nested widget.
QueryString name_editbox
Filter editbox.
static bool StationTypeSorter(const Station *const &a, const Station *const &b, const CargoTypes &filter)
Sort stations by their type.
void OnGameTick() override
Called once per (game) tick.
~CompanyStationsWindow() override
Save the last sorting state.
void BuildStationsList(const Owner owner)
(Re)Build station list
static const std::initializer_list< GUIStationList::SortFunction *const > sorter_funcs
Functions to sort stations.
uint16_t stations_per_cargo_type_no_rating
Number of stations without a rating.
static bool StationRatingMinSorter(const Station *const &a, const Station *const &b, const CargoTypes &filter)
Sort stations by their rating.
Drop down checkmark component.
Iterate a range of enum values.
Flow descriptions by origin stations.
List template of 'things' T to sort in a GUI.
void RebuildDone()
Notify the sortlist that the rebuild is done.
bool IsDescSortOrder() const
Check if the sort order is descending.
void ToggleSortOrder()
Toggle the sort order Since that is the worst condition for the sort function reverse the list here.
bool NeedRebuild() const
Check if a rebuild is needed.
void ForceRebuild()
Force that a rebuild is needed.
bool Sort(Comp compare)
Sort the list.
void ForceResort()
Force a resort next Sort call Reset the resort timer if used too.
uint8_t SortType() const
Get the sorttype of the list.
Listing GetListing() const
Export current sort conditions.
bool NeedResort()
Check if a resort is needed next loop If used the resort timer will decrease every call till 0.
void SetSortType(uint8_t n_type)
Set the sorttype of the list.
A connected component of a link graph.
uint Monthly(uint base) const
Scale a value to its monthly equivalent, based on last compression.
uint16_t w
The width of the area.
TileIndex tile
The base tile of the area.
uint16_t h
The height of the area.
Generate TileIndices around a center tile or tile area, with increasing distance.
CargoList that is used for stations.
uint ReservedCount() const
Returns sum of cargo reserved for loading onto vehicles.
static bool UsingWallclockUnits(bool newgame=false)
Check if we are using wallclock units.
Functions related to commands.
Definition of stuff that is very close to a company, like the company struct itself.
CompanyID _local_company
Company controlled by the human player at this client. Can also be COMPANY_SPECTATOR.
Functions related to companies.
static constexpr Owner OWNER_NONE
The tile has no ownership.
Functions related to debugging.
#define Debug(facility, severity, format_string,...)
Output a line of debugging information.
@ Misc
Misc message facility.
void ShowDropDownMenu(Window *w, std::span< const StringID > strings, int selected, WidgetID button, uint32_t disabled_mask, uint32_t hidden_mask, uint width, DropDownOptions options, std::string *const persistent_filter_text)
Show a dropdown menu window near a widget of the parent window.
std::unique_ptr< DropDownListItem > MakeDropDownListDividerItem()
Creates new DropDownListDividerItem.
std::unique_ptr< DropDownListItem > MakeDropDownListStringItem(StringID str, int value, bool masked, bool shaded)
Creates new DropDownListStringItem.
void ShowDropDownList(Window *w, DropDownList &&list, int selected, WidgetID button, uint width, DropDownOptions options, std::string *const persistent_filter_text)
Show a drop down list.
Common drop down list components.
Functions related to the drop down widget.
Types related to the drop down widget.
std::vector< std::unique_ptr< const DropDownListItem > > DropDownList
A drop down list is a collection of drop down list items.
@ Persist
Set if this dropdown should stay open after an option is selected.
@ Filterable
Set if the dropdown is filterable.
constexpr std::underlying_type_t< enum_type > to_underlying(enum_type e)
Implementation of std::to_underlying (from C++23).
int GetCharacterHeight(FontSize size)
Get height of a character for a given font size.
Dimension maxdim(const Dimension &d1, const Dimension &d2)
Compute bounding box of both dimensions.
int CentreBounds(int min, int max, int size)
Determine where to position a centred object.
Dimension GetStringBoundingBox(std::string_view str, FontSize start_fontsize)
Return the string dimension in pixels.
Dimension GetStringListBoundingBox(std::span< const StringID > list, FontSize fontsize)
Get maximum dimension of a list of strings.
void DrawSprite(SpriteID img, PaletteID pal, int x, int y, const SubSprite *sub, ZoomLevel zoom)
Draw a sprite, not in a viewport.
uint8_t GetCharacterWidth(FontSize size, char32_t key)
Return width of character glyph.
void GfxFillRect(int left, int top, int right, int bottom, const std::variant< PixelColour, PaletteID > &colour, FillRectMode mode)
Applies a certain FillRectMode-operation to a rectangle [left, right] x [top, bottom] on the screen.
int DrawStringMultiLine(int left, int right, int top, int bottom, std::string_view str, ExtendedTextColour colour, Alignment align, bool underline, FontSize fontsize)
Draw string, possibly over multiple lines.
int DrawString(int left, int right, int top, std::string_view str, ExtendedTextColour colour, Alignment align, bool underline, FontSize fontsize)
Draw string, possibly truncated to make it fit in its allocated space.
bool IsCtrlPressed()
Test if the ctrl key is pressed.
uint32_t SpriteID
The number of a sprite, without mapping bits and colourtables.
@ Small
Index of the small font in the font tables.
@ Normal
Index of the normal font in the font tables.
TextColour
Colour of the strings, see _string_colourmap in table/string_colours.h or docs/ottd-colourtext-palett...
void SetDirty() const
Mark entire window as dirty (in need of re-paint).
GUI functions that shouldn't be here.
void ShowExtraViewportWindow(TileIndex tile=INVALID_TILE)
Show a new Extra Viewport window.
Declaration of link graph classes used for cargo distribution.
@ Manual
Manual distribution. No link graph calculations are run.
#define Rect
Macro that prevents name conflicts between included headers.
#define Point
Macro that prevents name conflicts between included headers.
uint DistanceMax(TileIndex t0, TileIndex t1)
Gets the biggest distance component (x or y) between the two given tiles.
TileIndex TileAddXY(TileIndex tile, int x, int y)
Adds a given offset to a tile.
static TileIndex TileVirtXY(uint x, uint y)
Get a tile from the virtual XY-coordinate.
TileIndex TileAddByDir(TileIndex tile, Direction dir)
Adds a Direction to a tile.
static TileIndex TileXY(uint x, uint y)
Returns the TileIndex of a coordinate.
static uint TileY(TileIndex tile)
Get the Y component of a tile.
static uint TileX(TileIndex tile)
Get the X component of a tile.
int DivideApprox(int a, int b)
Deterministic approximate division.
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.
constexpr uint CeilDiv(uint a, uint b)
Computes ceil(a / b) for non-negative a and b.
constexpr uint ToPercent8(uint i)
Converts a "fract" value 0..255 to "percent" value 0..100.
void ShowQueryString(std::string_view str, StringID caption, uint maxsize, Window *parent, CharSetFilter afilter, QueryStringFlags flags)
Show a query popup window with a textbox in it.
static constexpr CargoType CF_EXPAND_LIST
Expand list to show all items (station list).
static constexpr CargoType CF_NO_RATING
Show items with no rating (station list).
static constexpr CargoType CF_SELECT_ALL
Select all items (station list).
TextColour GetContrastColour(PixelColour background, uint8_t threshold)
Determine a contrasty text colour for a coloured background.
static constexpr PixelColour PC_GREEN
Green palette colour.
static constexpr PixelColour PC_RED
Red palette colour.
Base for the GUIs that have an edit box in them.
A number of safeguards to prevent using unsafe methods.
@ Invalid
broken savegame (used internally)
GameSettings _settings_game
Game settings of a running game or the scenario editor.
ClientSettings _settings_client
The current settings for this game.
Base types for having sorted lists in GUIs.
void SndClickBeep()
Play a beep sound for a click event if enabled in settings.
Functions related to sound.
CommandCost CheckStationSpread(TileArea area, const TileArea &new_area)
Check if adding a new area to a station will exceed the maximum station spread.
Base classes/functions for stations.
std::pair< CargoArray, CargoTypes > GetAcceptanceAroundTiles(TileIndex center_tile, int w, int h, int rad)
Get the acceptance of cargoes around the tile in 1/8.
bool HasStationInUse(StationID station, bool include_company, CompanyID company)
Tests whether the company's vehicles have this station in orders.
CargoTypes GetAcceptanceMask(const Station *st)
Get a mask of the cargo types that the station accepts.
CargoArray GetProductionAroundTiles(TileIndex north_tile, int w, int h, int rad)
Get the cargo types being produced around the tile (in a rectangle).
Command definitions related to stations.
Functions related to stations.
static void StationsWndShowStationRating(int left, int right, int y, CargoType cargo, uint amount, uint8_t rating)
Draw small boxes of cargo amount and ratings data at the given coordinates.
void ShowSelectStationIfNeeded(TileArea ta, StationPickerCmdProc proc)
Show the station selection window when needed.
CargoSortType
Ways of sorting cargo in the UI.
@ AsGrouping
by the same principle the entries are being grouped
@ StationString
by station name
@ Count
by amount of cargo
void ShowSelectRailWaypointIfNeeded(TileArea ta, StationPickerCmdProc proc)
Show the rail waypoint selection window when needed.
void FindStationsAroundSelection()
Find stations adjacent to the current tile highlight area, so that existing coverage area can be draw...
static bool StationJoinerNeeded(const StationPickerCmdProc &proc)
Check whether we need to show the station selection window.
int DrawStationCoverageAreaText(const Rect &r, StationCoverageType sct, int rad, bool supplies)
Calculates and draws the accepted or supplied cargo around the selected tile(s).
void ShowStationViewWindow(StationID station)
Opens StationViewWindow for given station.
void CheckRedrawStationCoverage(const Window *w)
Check whether we need to redraw the station coverage text.
static WindowDesc _select_station_desc(WindowPosition::Automatic, "build_station_join", 200, 180, WindowClass::JoinStation, WindowClass::None, WindowDefaultFlag::Construction, _nested_select_station_widgets)
Window definition for the station selection window for (distant) joining.
void ShowCompanyStations(CompanyID company)
Opens window with list of company's stations.
void ShowSelectBaseStationIfNeeded(TileArea ta, StationPickerCmdProc &&proc)
Show the station selection window when needed.
static WindowDesc _station_view_desc(WindowPosition::Automatic, "view_station", 249, 117, WindowClass::StationView, WindowClass::None, {}, _nested_station_view_widgets)
Window definition for the station view window.
static void FindStationsNearby(TileArea ta, bool distant_join)
Circulate around the to-be-built station to find stations we could join.
static WindowDesc _company_stations_desc(WindowPosition::Automatic, "list_stations", 358, 162, WindowClass::StationList, WindowClass::None, {}, _nested_company_stations_widgets)
Window definition for the company stations window.
static void AddNearbyStation(TileIndex tile, TileArea *ctx)
Add station on this tile to _stations_nearby_list if it's fully within the station spread.
void ShowSelectRoadWaypointIfNeeded(TileArea ta, StationPickerCmdProc proc)
Show the road waypoint selection window when needed.
Contains enums and function declarations connected with stations GUI.
StationCoverageType
Types of cargo to display for station coverage.
@ SCT_NON_PASSENGERS_ONLY
Draw all non-passenger class cargoes.
@ SCT_PASSENGERS_ONLY
Draw only passenger class cargoes.
@ SCT_ALL
Draw all cargoes.
StationID GetStationIndex(Tile t)
Get StationID from a tile.
StationFacility
The facilities a station might be having.
@ Dock
Station with a dock.
@ TruckStop
Station with truck stops.
@ Train
Station with train station.
@ Airport
Station with an airport.
@ BusStop
Station with bus stops.
EnumBitSet< StationFacility, uint8_t > StationFacilities
Bitset of StationFacility elements.
static const uint MAX_LENGTH_STATION_NAME_CHARS
The maximum length of a station name in characters including '\0'.
Definition of base types and functions in a cross-platform compatible way.
int StrNaturalCompare(std::string_view s1, std::string_view s2, bool ignore_garbage_at_front)
Compares two strings using case insensitive natural sort.
Functions related to low-level strings.
@ CS_ALPHANUMERAL
Both numeric and alphabetic and spaces and stuff.
std::string GetString(StringID string)
Resolve the given StringID into a std::string with formatting but no parameters.
TextDirection _current_text_dir
Text direction of the currently selected language.
Functions related to OTTD's strings.
StrongType::Typedef< uint32_t, struct StringIDTag, StrongType::Compare, StrongType::Integer > StringID
Numeric value that represents a string, independent of the selected language.
@ TD_RTL
Text is written right-to-left by default.
static const int MAX_CHAR_LENGTH
Max. length of UTF-8 encoded unicode character.
AirportBlocks blocks
stores which blocks on the airport are taken. was 16 bit earlier on, then 32
Base class for all station-ish types.
TileIndex xy
Base tile of the station.
StationFacilities facilities
The facilities that this station has.
Owner owner
The owner of this station.
Town * town
The town this station is associated with.
TileArea spread
NOSAVE: Station spread tile area.
Class for storing amounts of cargo.
Container for cargo from the same location and time.
uint16_t Count() const
Gets the number of 'items' in this packet.
StationID GetFirstStation() const
Gets the ID of the station where the cargo was loaded for the first time.
Specification of a cargo type.
static CargoSpec * Get(size_t index)
Retrieve cargo details for the given cargo type.
StringID abbrev
Two letter abbreviation for this cargo type.
SpriteID GetCargoIcon() const
Get sprite for showing cargo of this type.
PixelColour rating_colour
Colour used for box representing the amount of cargo waiting at the station in the station rating vie...
bool IsValid() const
Tests for validity of this cargospec.
CargoTypes cargoes
bitmap of cargo types to include
StationFacilities facilities
types of stations of interest
bool include_no_rating
Whether we should include stations with no cargo rating.
Dimensions (a width and height) of a rectangle in 2D.
value_type height
The height of the rectangle.
value_type width
The width of the rectangle.
FlowStatMap flows
Planned flows through this station.
StationCargoList cargo
The cargo packets of cargo waiting in this station.
Stores station stats for a single cargo.
bool HasRating() const
Does this cargo have a rating at this station?
NodeID node
ID of node in link graph referring to this goods entry.
const GoodsEntryData & GetData() const
Get optional cargo packet/flow data.
LinkGraphID link_graph
Link graph this station belongs to.
uint8_t rating
Station rating for this cargo.
bool HasData() const
Test if this goods entry has optional cargo packet/flow data.
Data structure describing how to show the list (what sort direction and criteria).
static uint MaxY()
Gets the maximum Y coordinate within the map, including TileType::Void.
static uint MaxX()
Gets the maximum X coordinate within the map, including TileType::Void.
static uint Size()
Get the size of the map.
Colour for pixel/line drawing.
static Pool::IterateWrapper< BaseStation > Iterate(size_t from=0)
static BaseStation * Get(auto index)
static bool IsValidID(auto index)
static LinkGraph * GetIfValid(auto index)
Data stored about a string that can be modified in the GUI.
static const int ACTION_CLEAR
Clear editbox.
Specification of a rectangle with absolute coordinates of all edges.
Rect WithWidth(int width, bool end) const
Copy Rect and set its width.
int Width() const
Get width of Rect.
Rect Shrink(int s) const
Copy and shrink Rect by s pixels.
Rect Indent(int indent, bool end) const
Copy Rect and indent it from its position.
Window for selecting stations/waypoints to (distant) join to.
void DrawWidget(const Rect &r, WidgetID widget) const override
Draw the contents of a nested widget.
void OnRealtimeTick(uint delta_ms) override
Called periodically.
void OnClick(Point pt, WidgetID widget, int click_count) override
A click with the left mouse button has been made on the window.
void OnInvalidateData(int data=0, bool gui_scope=true) override
Some data on this window has become invalid.
void OnResize() override
Called after the window got resized.
void Close(int data=0) override
Hide the window and all its child windows, and mark them for a later deletion.
void OnMouseOver(Point pt, WidgetID widget) override
The mouse is currently moving over the window or has just moved outside of the window.
TileArea area
Location of new station.
void UpdateWidgetSize(WidgetID widget, Dimension &size, const Dimension &padding, Dimension &fill, Dimension &resize) override
Update size and resize step of a widget in the window.
static bool IsValidID(auto index)
static bool IsExpected(const BaseStation *st)
static Pool::IterateWrapper< Station > Iterate(size_t from=0)
static Waypoint * Get(auto index)
static Waypoint * From(BaseStation *st)
A row being displayed in the cargo view (as opposed to being "hidden" behind a plus sign).
StationID next_station
ID of the station belonging to the entry actually displayed if it's to/from/via.
CargoDataEntry * filter
Parent of the cargo entry belonging to the row.
CargoType next_cargo
ID of the cargo belonging to the entry actually displayed if it's cargo.
void HandleCargoWaitingClick(int row)
Handle a click on a specific row in the cargo view.
int DrawEntries(CargoDataEntry &entry, const Rect &r, int pos, int maxrows, int column, CargoType cargo=INVALID_CARGO)
Draw the given cargo entries in the station GUI.
void OnQueryTextFinished(std::optional< std::string > str) override
The query window opened from this window has closed.
void OnDropdownSelect(WidgetID widget, int index, int) override
A dropdown option associated to this window has been selected.
Mode
Display mode of the cargo view.
@ MODE_PLANNED
Show cargo planned to pass through the station.
@ MODE_WAITING
Show cargo waiting at the station.
std::array< Grouping, NUM_COLUMNS > groupings
Grouping modes for the different columns.
void EstimateDestinations(CargoType 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...
void SelectSortBy(int index)
Select a new sort criterium for the cargo view.
void OnResize() override
Called after the window got resized.
StringID SearchNonStop(CargoDataEntry &cd, StationID station, int column)
Determine if we need to show the special "non-stop" string.
void Close(int data=0) override
Hide the window and all its child windows, and mark them for a later deletion.
Grouping
Type of grouping used in each of the "columns".
@ GR_SOURCE
Group by source of cargo ("from").
@ GR_NEXT
Group by next station ("via").
@ GR_CARGO
Group by cargo type.
@ GR_DESTINATION
Group by estimated final destination ("to").
void BuildCargoList(CargoType cargo, const StationCargoList &packets, CargoDataEntry *entry)
Build up the cargo view for WAITING mode and a specific cargo.
int DrawCargoRatings(const Rect &r) const
Draw cargo ratings in the WID_SV_ACCEPT_RATING_LIST widget.
static const int NUM_COLUMNS
Number of "columns" in the cargo view: cargo, from, via, to.
void OnInit() override
Notification that the nested widget tree gets initialized.
void RecalcDestinations(CargoType cargo)
Rebuild the cache for estimated destinations which is used to quickly show the "destination" entries ...
int line_height
Height of a cargo line.
Dimension cargo_icon_size
Size of largest cargo icon.
Invalidation
Type of data invalidation.
@ INV_FLOWS
The planned flows have been recalculated and everything has to be updated.
@ INV_CARGO
Some cargo has been added or removed.
void BuildCargoList(CargoDataEntry *entry, const Station *st)
Build up the cargo view for all cargoes.
void SelectSortOrder(SortOrder order)
Select a new sort order for the cargo view.
CargoDataEntry expanded_rows
Parent entry of currently expanded rows.
void OnPaint() override
The window must be repainted.
static constexpr uint RATING_LINES
Height in lines of the cargo ratings view.
CargoDataVector displayed_rows
Parent entry of currently displayed rows (including collapsed ones).
static const StringID group_names[]
Names of the grouping options in the dropdown.
int grouping_index
Currently selected entry in the grouping drop down.
void UpdateWidgetSize(WidgetID widget, Dimension &size, const Dimension &padding, Dimension &fill, Dimension &resize) override
Update size and resize step of a widget in the window.
static constexpr uint ACCEPTS_LINES
Height in lines of the accepted cargo view.
void OnInvalidateData(int data=0, bool gui_scope=true) override
Some data on this window has become invalid.
StringID GetEntryString(StationID station, StringID here, StringID other_station, StringID any) const
Select the correct string for an entry referring to the specified station.
std::array< CargoSortType, NUM_COLUMNS > sortings
Sort types of the different 'columns'.
void SetDisplayedRow(const CargoDataEntry &entry)
Mark a specific row, characterized by its CargoDataEntry, as expanded.
std::string GetWidgetString(WidgetID widget, StringID stringid) const override
Get the raw string for a widget.
std::array< SortOrder, NUM_COLUMNS > sort_orders
Sort order (ascending/descending) for the 'columns'.
uint expand_shrink_width
The width allocated to the expand/shrink 'button'.
void HandleCargoWaitingClick(CargoDataEntry *filter, Tid next)
Expand or collapse a specific row.
int rating_lines
Number of lines in the cargo ratings view.
static const StringID sort_names[]
Names of the sorting options in the dropdown.
void DrawCargoIcons(CargoType cargo, uint waiting, const Rect &r) const
Draw icons of waiting cargo.
CargoDataEntry cached_destinations
Cache for the flows passing through this station.
int scroll_to_row
If set, scroll the main viewport to the station pointed to by this row.
Mode current_mode
Currently selected display mode of cargo view.
int accepts_lines
Number of lines in the accepted cargo view.
void BuildFlowList(CargoType cargo, const FlowStatMap &flows, CargoDataEntry *entry)
Build up the cargo view for PLANNED mode and a specific cargo.
void SelectGroupBy(int index)
Select a new grouping mode for the cargo view.
void OnClick(Point pt, WidgetID widget, int click_count) override
A click with the left mouse button has been made on the window.
int DrawAcceptedCargo(const Rect &r) const
Draw accepted cargo in the WID_SV_ACCEPT_RATING_LIST widget.
void ShowCargo(CargoDataEntry *data, CargoType cargo, StationID source, StationID next, StationID dest, uint count)
Show a certain cargo entry characterized by source/next/dest station, cargo type and amount of cargo ...
std::array< GoodsEntry, NUM_CARGO > goods
Goods at this station.
Airport airport
Tile area the airport covers.
void SetFilterTerm(std::string_view str)
Set the term to filter on.
void ResetState()
Reset the matching state to process a new item.
bool GetState() const
Get the matching state of the current item.
std::string_view GetText() const
Get the current text.
Struct containing TileIndex and StationID.
StationID station
StationID.
CompanyID exclusivity
which company has exclusivity
uint8_t exclusive_counter
months till the exclusivity expires
The information about a vehicle list.
Representation of a waypoint.
High level window description.
Number to differentiate different windows of the same class.
Data structure for an opened window.
void ReInit(int rx=0, int ry=0, bool reposition=false)
Re-initialize a window, and optionally change its size.
void CloseChildWindows(WindowClass wc=WindowClass::Invalid) const
Close all children a window might have in a head-recursive manner.
virtual void Close(int data=0)
Hide the window and all its child windows, and mark them for a later deletion.
static int SortButtonWidth()
Get width of up/down arrow of sort button state.
void FinishInitNested(WindowNumber window_number=0)
Perform the second part of the initialization of a nested widget tree.
void DrawWidgets() const
Paint all widgets of a window.
void InvalidateData(int data=0, bool gui_scope=true)
Mark this window's data as invalid (in need of re-computing).
Window * parent
Parent window.
void RaiseWidget(WidgetID widget_index)
Marks a widget as raised.
void SetWidgetDirty(WidgetID widget_index) const
Invalidate a widget, i.e.
virtual std::string GetWidgetString(WidgetID widget, StringID stringid) const
Get the raw string for a widget.
ResizeInfo resize
Resize information.
void DrawSortButton(WidgetID widget, bool descending) const
Draw a sort button's up or down arrow symbol.
void CreateNestedTree()
Perform the first part of the initialization of a nested widget tree.
WindowClass window_class
Window class.
bool IsWidgetLowered(WidgetID widget_index) const
Gets the lowered state of a widget.
Owner owner
The owner of the content shown in this window. Company colour is acquired from this variable.
void SetWidgetLoweredState(WidgetID widget_index, bool lowered_stat)
Sets the lowered/raised status of a widget.
bool IsShaded() const
Is window shaded currently?
void SetTimeout()
Set the timeout flag of the window and initiate the timer.
Window(WindowDesc &desc)
Empty constructor, initialization has been moved to InitNested() called from the constructor of the d...
const NWID * GetWidget(WidgetID widnum) const
Get the nested widget with number widnum from the nested widget tree.
void LowerWidget(WidgetID widget_index)
Marks a widget as lowered.
const Scrollbar * GetScrollbar(WidgetID widnum) const
Return the Scrollbar to a widget index.
void SetWidgetDisabledState(WidgetID widget_index, bool disab_stat)
Sets the enabled/disabled status of a widget.
int width
width of the window (number of pixels to the right in x direction)
void ToggleWidgetLoweredState(WidgetID widget_index)
Invert the lowered/raised status of a widget.
WindowNumber window_number
Window number within the window class.
Stuff related to the text buffer GUI.
@ EnableMove
enable the 'Move' button
@ EnableDefault
enable the 'Default' button ("\0" is returned)
@ LengthIsInChars
the length of the string is counted in characters
static bool IsTileType(Tile tile, TileType type)
Checks if a tile is a given tiletype.
Owner GetTileOwner(Tile tile)
Returns the owner of a tile.
StrongType::Typedef< uint32_t, struct TileIndexTag, StrongType::Compare, StrongType::Integer, StrongType::Compatible< int32_t >, StrongType::Compatible< int64_t > > TileIndex
The index/ID of a Tile.
constexpr TileIndex INVALID_TILE
The very nice invalid tile marker.
static constexpr uint TILE_SIZE
Tile size in world coordinates.
@ Station
A tile of a station or airport.
OrthogonalTileArea TileArea
Shorthand for the much more common orthogonal tile area.
Type for iterating a sprial tile area.
Functions related to tile highlights.
void ResetObjectToPlace()
Reset the cursor and mouse mode handling back to default (normal cursor, only clicking in windows).
void UpdateTileSelection()
Updates tile highlighting for all cases.
@ HT_RECT
rectangle (stations, depots, ...)
Functions related to the vehicle's GUIs.
VehicleType
Available vehicle types.
@ Aircraft
Aircraft vehicle type.
@ Train
Train vehicle type.
Functions and type for generating vehicle lists.
@ Station
Index is the station.
bool ScrollMainWindowToTile(TileIndex tile, bool instant)
Scrolls the viewport of the main window to a given location.
void SetViewportStationRect(const Station *st, bool sel)
Select or deselect station for rectangle area highlight.
void SetViewportCatchmentStation(const Station *st, bool sel)
Select or deselect station for coverage area highlight.
void SetViewportWaypointRect(const Waypoint *wp, bool sel)
Select or deselect waypoint for rectangle area highlight.
const Station * _viewport_highlight_station
Currently selected station for coverage area highlight.
Functions related to (drawing on) viewports.
@ WPF_ROAD
This is a road waypoint.
void CloseWindowById(WindowClass cls, WindowNumber number, bool force, int data)
Close a window by its class and window number (if it is open).
Window * FindWindowByClass(WindowClass cls)
Find any window by its class.
Window * FindWindowById(WindowClass cls, WindowNumber number)
Find a window by its class and window number.
Window functions not directly related to making/drawing windows.
@ Construction
This window is used for construction; close it whenever changing company.
Twindow * AllocateWindowDescFront(WindowDesc &desc, WindowNumber window_number, Targs... extra_arguments)
Open a new window.
@ Automatic
Find a place automatically.
Functions related to zooming.
int ScaleSpriteTrad(int value)
Scale traditional pixel dimensions to GUI zoom level, for drawing sprites.