diff --git a/src/station_gui.cpp b/src/station_gui.cpp index aac2c0546c..ee30ab4f51 100644 --- a/src/station_gui.cpp +++ b/src/station_gui.cpp @@ -516,9 +516,7 @@ public: * when the order had been removed and the station list hasn't been removed yet */ assert(st->owner == owner || st->owner == OWNER_NONE); - SetDParam(0, st->index); - SetDParam(1, st->facilities); - int x = DrawString(tr.left, tr.right, tr.top + (line_height - GetCharacterHeight(FS_NORMAL)) / 2, STR_STATION_LIST_STATION); + int x = DrawString(tr.left, tr.right, tr.top + (line_height - GetCharacterHeight(FS_NORMAL)) / 2, GetString(STR_STATION_LIST_STATION, st->index, st->facilities)); x += rtl ? -text_spacing : text_spacing; /* show cargo waiting and station ratings */ @@ -1738,7 +1736,7 @@ struct StationViewWindow : public Window { * @param any String to be shown if the entry refers to "any station". * @return One of the three given strings or STR_STATION_VIEW_RESERVED, depending on what station the entry refers to. */ - StringID GetEntryString(StationID station, StringID here, StringID other_station, StringID any) + StringID GetEntryString(StationID station, StringID here, StringID other_station, StringID any) const { if (station == this->window_number) { return here; @@ -1747,11 +1745,20 @@ struct StationViewWindow : public Window { } else if (station == NEW_STATION) { return STR_STATION_VIEW_RESERVED; } else { - SetDParam(2, station); return other_station; } } + StringID GetGroupingString(Grouping grouping, StationID station) const + { + switch (grouping) { + case GR_SOURCE: return this->GetEntryString(station, STR_STATION_VIEW_FROM_HERE, STR_STATION_VIEW_FROM, STR_STATION_VIEW_FROM_ANY); + case GR_NEXT: return this->GetEntryString(station, STR_STATION_VIEW_VIA_HERE, STR_STATION_VIEW_VIA, STR_STATION_VIEW_VIA_ANY); + case GR_DESTINATION: return this->GetEntryString(station, STR_STATION_VIEW_TO_HERE, STR_STATION_VIEW_TO, STR_STATION_VIEW_TO_ANY); + default: NOT_REACHED(); + } + } + /** * Determine if we need to show the special "non-stop" string. * @param cd Entry we are going to show. @@ -1814,31 +1821,17 @@ struct StationViewWindow : public Window { if (pos > -maxrows && pos <= 0) { StringID str = STR_EMPTY; + StationID station = StationID::Invalid(); int y = r.top - pos * GetCharacterHeight(FS_NORMAL); - SetDParam(0, cargo); - SetDParam(1, cd->GetCount()); - if (this->groupings[column] == GR_CARGO) { str = STR_STATION_VIEW_WAITING_CARGO; DrawCargoIcons(cd->GetCargo(), cd->GetCount(), r.left + this->expand_shrink_width, r.right - this->expand_shrink_width, y); } else { if (!auto_distributed) grouping = GR_SOURCE; - StationID station = cd->GetStation(); + station = cd->GetStation(); + str = this->GetGroupingString(grouping, station); + if (grouping == GR_NEXT && str == STR_STATION_VIEW_VIA) str = this->SearchNonStop(cd, station, column); - switch (grouping) { - case GR_SOURCE: - str = this->GetEntryString(station, STR_STATION_VIEW_FROM_HERE, STR_STATION_VIEW_FROM, STR_STATION_VIEW_FROM_ANY); - break; - case GR_NEXT: - str = this->GetEntryString(station, STR_STATION_VIEW_VIA_HERE, STR_STATION_VIEW_VIA, STR_STATION_VIEW_VIA_ANY); - if (str == STR_STATION_VIEW_VIA) str = this->SearchNonStop(cd, station, column); - break; - case GR_DESTINATION: - str = this->GetEntryString(station, STR_STATION_VIEW_TO_HERE, STR_STATION_VIEW_TO, STR_STATION_VIEW_TO_ANY); - break; - default: - NOT_REACHED(); - } if (pos == -this->scroll_to_row && Station::IsValidID(station)) { ScrollMainWindowToTile(Station::Get(station)->xy); } @@ -1848,7 +1841,7 @@ struct StationViewWindow : public Window { Rect text = r.Indent(column * WidgetDimensions::scaled.hsep_indent, rtl).Indent(this->expand_shrink_width, !rtl); Rect shrink = r.WithWidth(this->expand_shrink_width, !rtl); - DrawString(text.left, text.right, y, str); + DrawString(text.left, text.right, y, GetString(str, cargo, cd->GetCount(), station)); if (column < NUM_COLUMNS - 1) { const char *sym = nullptr; @@ -1888,8 +1881,7 @@ struct StationViewWindow : public Window { const Station *st = Station::Get(this->window_number); Rect tr = r.Shrink(WidgetDimensions::scaled.framerect); - SetDParam(0, GetAcceptanceMask(st)); - int bottom = DrawStringMultiLine(tr.left, tr.right, tr.top, INT32_MAX, STR_STATION_VIEW_ACCEPTS_CARGO); + int bottom = DrawStringMultiLine(tr.left, tr.right, tr.top, INT32_MAX, GetString(STR_STATION_VIEW_ACCEPTS_CARGO, GetAcceptanceMask(st))); return CeilDiv(bottom - r.top - WidgetDimensions::scaled.framerect.top, GetCharacterHeight(FS_NORMAL)); } @@ -1905,8 +1897,7 @@ struct StationViewWindow : public Window { Rect tr = r.Shrink(WidgetDimensions::scaled.framerect); if (st->town->exclusive_counter > 0) { - SetDParam(0, st->town->exclusivity); - tr.top = DrawStringMultiLine(tr, st->town->exclusivity == st->owner ? STR_STATION_VIEW_EXCLUSIVE_RIGHTS_SELF : STR_STATION_VIEW_EXCLUSIVE_RIGHTS_COMPANY); + tr.top = DrawStringMultiLine(tr, GetString(st->town->exclusivity == st->owner ? STR_STATION_VIEW_EXCLUSIVE_RIGHTS_SELF : STR_STATION_VIEW_EXCLUSIVE_RIGHTS_COMPANY, st->town->exclusivity)); tr.top += WidgetDimensions::scaled.vsep_wide; } @@ -1918,11 +1909,12 @@ struct StationViewWindow : public Window { if (!ge->HasRating()) continue; const LinkGraph *lg = LinkGraph::GetIfValid(ge->link_graph); - SetDParam(0, cs->name); - SetDParam(1, lg != nullptr ? lg->Monthly((*lg)[ge->node].supply) : 0); - SetDParam(2, STR_CARGO_RATING_APPALLING + (ge->rating >> 5)); - SetDParam(3, ToPercent8(ge->rating)); - DrawString(tr.Indent(WidgetDimensions::scaled.hsep_indent, rtl), STR_STATION_VIEW_CARGO_SUPPLY_RATING); + DrawString(tr.Indent(WidgetDimensions::scaled.hsep_indent, rtl), + GetString(STR_STATION_VIEW_CARGO_SUPPLY_RATING, + cs->name, + lg != nullptr ? lg->Monthly((*lg)[ge->node].supply) : 0, + STR_CARGO_RATING_APPALLING + (ge->rating >> 5), + ToPercent8(ge->rating))); tr.top += GetCharacterHeight(FS_NORMAL); } return CeilDiv(tr.top - r.top - WidgetDimensions::scaled.framerect.top, GetCharacterHeight(FS_NORMAL)); @@ -2338,9 +2330,9 @@ struct SelectStationWindow : Window { for (const auto &station : _stations_nearby_list) { if (station == NEW_STATION) continue; const BaseStation *st = BaseStation::Get(station); - SetDParam(0, st->index); - SetDParam(1, st->facilities); - d = maxdim(d, GetStringBoundingBox(T::IsWaypoint() ? STR_STATION_LIST_WAYPOINT : STR_STATION_LIST_STATION)); + d = maxdim(d, GetStringBoundingBox(T::IsWaypoint() + ? GetString(STR_STATION_LIST_WAYPOINT, st->index) + : GetString(STR_STATION_LIST_STATION, st->index, st->facilities))); } resize.height = d.height; @@ -2361,9 +2353,9 @@ struct SelectStationWindow : Window { DrawString(tr, T::IsWaypoint() ? STR_JOIN_WAYPOINT_CREATE_SPLITTED_WAYPOINT : STR_JOIN_STATION_CREATE_SPLITTED_STATION); } else { const BaseStation *st = BaseStation::Get(*it); - SetDParam(0, st->index); - SetDParam(1, st->facilities); - DrawString(tr, T::IsWaypoint() ? STR_STATION_LIST_WAYPOINT : STR_STATION_LIST_STATION); + DrawString(tr, T::IsWaypoint() + ? GetString(STR_STATION_LIST_WAYPOINT, st->index) + : GetString(STR_STATION_LIST_STATION, st->index, st->facilities)); } }