Departure board: Add support for dual via
This commit is contained in:
@@ -463,6 +463,7 @@ DepartureList* MakeDepartureList(StationID station, const std::vector<const Vehi
|
||||
/* We keep track of potential via stations along the way. If we call at a station immediately after going via it, then it is the via station. */
|
||||
StationID candidate_via = INVALID_STATION;
|
||||
StationID pending_via = INVALID_STATION;
|
||||
StationID pending_via2 = INVALID_STATION;
|
||||
|
||||
/* Go through the order list, looping if necessary, to find a terminus. */
|
||||
/* Get the next order, which may be the vehicle's first order. */
|
||||
@@ -534,6 +535,10 @@ DepartureList* MakeDepartureList(StationID station, const std::vector<const Vehi
|
||||
|
||||
if (order->GetType() == OT_LABEL && order->GetLabelSubType() == OLST_DEPARTURES_VIA && d->via == INVALID_STATION && pending_via == INVALID_STATION) {
|
||||
pending_via = (StationID)order->GetDestination();
|
||||
const Order *next = (order->next == nullptr) ? least_order->v->GetFirstOrder() : order->next;
|
||||
if (next->GetType() == OT_LABEL && next->GetLabelSubType() == OLST_DEPARTURES_VIA && (StationID)next->GetDestination() != pending_via) {
|
||||
pending_via2 = (StationID)next->GetDestination();
|
||||
}
|
||||
}
|
||||
|
||||
if (c.scheduled_date != 0 && (order->GetTravelTime() != 0 || order->IsTravelTimetabled())) {
|
||||
@@ -569,6 +574,7 @@ DepartureList* MakeDepartureList(StationID station, const std::vector<const Vehi
|
||||
order->GetNonStopType() != ONSF_NO_STOP_AT_DESTINATION_STATION) {
|
||||
if (d->via == INVALID_STATION && pending_via != INVALID_STATION) {
|
||||
d->via = pending_via;
|
||||
d->via2 = pending_via2;
|
||||
}
|
||||
if (d->via == INVALID_STATION && candidate_via == (StationID)order->GetDestination()) {
|
||||
d->via = (StationID)order->GetDestination();
|
||||
@@ -618,7 +624,11 @@ DepartureList* MakeDepartureList(StationID station, const std::vector<const Vehi
|
||||
|
||||
if (d_first->terminus >= c && d_first->calling_at.size() >= 2) {
|
||||
d_first->terminus = CallAt(d_first->calling_at[k]);
|
||||
if (d_first->via == d_first->terminus.station) d_first->via = INVALID_STATION;
|
||||
if (d_first->via2 == d_first->terminus.station) d_first->via2 = INVALID_STATION;
|
||||
if (d_first->via == d_first->terminus.station) {
|
||||
d_first->via = d_first->via2;
|
||||
d_first->via2 = INVALID_STATION;
|
||||
}
|
||||
|
||||
if (k == 0) break;
|
||||
|
||||
|
@@ -812,7 +812,6 @@ void DeparturesWindow<Twaypoint>::DrawDeparturesListItems(const Rect &r) const
|
||||
|
||||
/* The icons to show with the destination and via stations. */
|
||||
StringID icon = STR_DEPARTURES_STATION_NONE;
|
||||
StringID icon_via = STR_DEPARTURES_STATION_NONE;
|
||||
|
||||
if (_settings_client.gui.departure_destination_type) {
|
||||
Station *t = Station::Get(d->terminus.station);
|
||||
@@ -832,24 +831,12 @@ void DeparturesWindow<Twaypoint>::DrawDeparturesListItems(const Rect &r) const
|
||||
}
|
||||
|
||||
StationID via = d->via;
|
||||
if (via == d->terminus.station || via == this->station) via = INVALID_STATION;
|
||||
|
||||
if (_settings_client.gui.departure_destination_type && via != INVALID_STATION && Station::IsValidID(via)) {
|
||||
Station *t = Station::Get(via);
|
||||
|
||||
if (t->facilities & FACIL_DOCK &&
|
||||
t->facilities & FACIL_AIRPORT &&
|
||||
d->vehicle->type != VEH_SHIP &&
|
||||
d->vehicle->type != VEH_AIRCRAFT) {
|
||||
icon_via = STR_DEPARTURES_STATION_PORTAIRPORT;
|
||||
} else if (t->facilities & FACIL_DOCK &&
|
||||
d->vehicle->type != VEH_SHIP) {
|
||||
icon_via = STR_DEPARTURES_STATION_PORT;
|
||||
} else if (t->facilities & FACIL_AIRPORT &&
|
||||
d->vehicle->type != VEH_AIRCRAFT) {
|
||||
icon_via = STR_DEPARTURES_STATION_AIRPORT;
|
||||
}
|
||||
StationID via2 = d->via2;
|
||||
if (via == d->terminus.station || via == this->station) {
|
||||
via = via2;
|
||||
via2 = INVALID_STATION;
|
||||
}
|
||||
if (via2 == d->terminus.station || via2 == this->station) via2 = INVALID_STATION;
|
||||
|
||||
/* Destination */
|
||||
if (via == INVALID_STATION) {
|
||||
@@ -860,18 +847,49 @@ void DeparturesWindow<Twaypoint>::DrawDeparturesListItems(const Rect &r) const
|
||||
: DrawString(text_left + status_width + (toc_width + veh_width + group_width + 2) + 2, text_right - time_width - type_width - 6, y + 1, STR_DEPARTURES_TERMINUS);
|
||||
} else {
|
||||
auto set_via_dparams = [&](uint offset) {
|
||||
if (Waypoint::IsValidID(via)) {
|
||||
SetDParam(offset, STR_WAYPOINT_NAME);
|
||||
} else {
|
||||
SetDParam(offset, STR_STATION_NAME);
|
||||
auto get_single_via_string = [&](uint temp_str, StationID id) {
|
||||
StringID icon_via = STR_DEPARTURES_STATION_NONE;
|
||||
if (_settings_client.gui.departure_destination_type && Station::IsValidID(id)) {
|
||||
Station *st = Station::Get(id);
|
||||
|
||||
if (st->facilities & FACIL_DOCK &&
|
||||
st->facilities & FACIL_AIRPORT &&
|
||||
d->vehicle->type != VEH_SHIP &&
|
||||
d->vehicle->type != VEH_AIRCRAFT) {
|
||||
icon_via = STR_DEPARTURES_STATION_PORTAIRPORT;
|
||||
} else if (st->facilities & FACIL_DOCK &&
|
||||
d->vehicle->type != VEH_SHIP) {
|
||||
icon_via = STR_DEPARTURES_STATION_PORT;
|
||||
} else if (st->facilities & FACIL_AIRPORT &&
|
||||
d->vehicle->type != VEH_AIRCRAFT) {
|
||||
icon_via = STR_DEPARTURES_STATION_AIRPORT;
|
||||
}
|
||||
}
|
||||
|
||||
char buf[256];
|
||||
int64 args_array[] = { Waypoint::IsValidID(id) ? STR_WAYPOINT_NAME : STR_STATION_NAME, id, icon_via };
|
||||
StringParameters tmp_params(args_array);
|
||||
char *end = GetStringWithArgs(buf, STR_DEPARTURES_VIA_DESCRIPTOR, &tmp_params, lastof(buf));
|
||||
_temp_special_strings[temp_str].assign(buf, end);
|
||||
};
|
||||
get_single_via_string(0, via);
|
||||
|
||||
if (via2 != INVALID_STATION) {
|
||||
get_single_via_string(1, via2);
|
||||
|
||||
char buf[512];
|
||||
int64 args_array[] = { SPECSTR_TEMP_START, SPECSTR_TEMP_START + 1 };
|
||||
StringParameters tmp_params(args_array);
|
||||
char *end = GetStringWithArgs(buf, STR_DEPARTURES_VIA_AND, &tmp_params, lastof(buf));
|
||||
_temp_special_strings[0].assign(buf, end);
|
||||
}
|
||||
SetDParam(offset + 1, via);
|
||||
|
||||
SetDParam(offset, SPECSTR_TEMP_START);
|
||||
};
|
||||
/* Show the terminus and the via station. */
|
||||
SetDParam(0, d->terminus.station);
|
||||
SetDParam(1, icon);
|
||||
set_via_dparams(2);
|
||||
SetDParam(4, icon_via);
|
||||
int text_width = (GetStringBoundingBox(STR_DEPARTURES_TERMINUS_VIA_STATION)).width;
|
||||
|
||||
if (text_width < text_right - status_width - (toc_width + veh_width + group_width + 2) - 2 - (text_left + time_width + type_width + 6)) {
|
||||
@@ -879,14 +897,12 @@ void DeparturesWindow<Twaypoint>::DrawDeparturesListItems(const Rect &r) const
|
||||
SetDParam(0, d->terminus.station);
|
||||
SetDParam(1, icon);
|
||||
set_via_dparams(2);
|
||||
SetDParam(4, icon_via);
|
||||
ltr ? DrawString( text_left + time_width + type_width + 6, text_right - status_width - (toc_width + veh_width + group_width + 2) - 2, y + 1, STR_DEPARTURES_TERMINUS_VIA_STATION)
|
||||
: DrawString(text_left + status_width + (toc_width + veh_width + group_width + 2) + 2, text_right - time_width - type_width - 6, y + 1, STR_DEPARTURES_TERMINUS_VIA_STATION);
|
||||
} else {
|
||||
/* They won't both fit, so switch between showing the terminus and the via station approximately every 4 seconds. */
|
||||
if ((this->elapsed_ms >> 12) & 1) {
|
||||
set_via_dparams(0);
|
||||
SetDParam(2, icon_via);
|
||||
ltr ? DrawString( text_left + time_width + type_width + 6, text_right - status_width - (toc_width + veh_width + group_width + 2) - 2, y + 1, STR_DEPARTURES_VIA)
|
||||
: DrawString(text_left + status_width + (toc_width + veh_width + group_width + 2) + 2, text_right - time_width - type_width - 6, y + 1, STR_DEPARTURES_VIA);
|
||||
} else {
|
||||
|
@@ -69,13 +69,14 @@ struct Departure {
|
||||
Ticks lateness; ///< How delayed the departure is expected to be
|
||||
CallAt terminus; ///< The station at which the vehicle will terminate following this departure
|
||||
StationID via; ///< The station the departure should list as going via
|
||||
StationID via2; ///< Secondary station the departure should list as going via
|
||||
std::vector<CallAt> calling_at; ///< The stations both called at and unloaded at by the vehicle after this departure before it terminates
|
||||
DepartureStatus status; ///< Whether the vehicle has arrived yet for this departure
|
||||
DepartureType type; ///< The type of the departure (departure or arrival)
|
||||
const Vehicle *vehicle; ///< The vehicle performing this departure
|
||||
const Order *order; ///< The order corresponding to this departure
|
||||
uint scheduled_waiting_time; ///< Scheduled waiting time if scheduled dispatch is used
|
||||
Departure() : terminus(INVALID_STATION), via(INVALID_STATION), vehicle(nullptr), order(nullptr) { }
|
||||
Departure() : terminus(INVALID_STATION), via(INVALID_STATION), via2(INVALID_STATION), vehicle(nullptr), order(nullptr) { }
|
||||
|
||||
inline bool operator==(const Departure& d) const {
|
||||
if (this->calling_at.size() != d.calling_at.size()) return false;
|
||||
@@ -88,6 +89,7 @@ struct Departure {
|
||||
(this->scheduled_date / DATE_UNIT_SIZE) == (d.scheduled_date / DATE_UNIT_SIZE) &&
|
||||
this->vehicle->type == d.vehicle->type &&
|
||||
this->via == d.via &&
|
||||
this->via2 == d.via2 &&
|
||||
this->type == d.type
|
||||
;
|
||||
}
|
||||
|
@@ -1282,9 +1282,9 @@ STR_DEPARTURES_TIME_DEP :{ORANGE}{DATE_W
|
||||
STR_DEPARTURES_TIME_ARR :{ORANGE}{DATE_WALLCLOCK_TINY} {RED}{DOWN_ARROW}
|
||||
STR_DEPARTURES_TIME_BOTH :{ORANGE}{1:DATE_WALLCLOCK_TINY} {RED}{DOWN_ARROW} {ORANGE}{0:DATE_WALLCLOCK_TINY} {GREEN}{UP_ARROW}
|
||||
STR_DEPARTURES_TERMINUS :{ORANGE}{STATION}{STRING}
|
||||
STR_DEPARTURES_TERMINUS_VIA_STATION :{ORANGE}{STATION}{STRING} via {STRING1}{STRING}
|
||||
STR_DEPARTURES_TERMINUS_VIA_STATION :{ORANGE}{STATION}{STRING} via {STRING}
|
||||
STR_DEPARTURES_TERMINUS_VIA :{ORANGE}{STATION}{STRING} via
|
||||
STR_DEPARTURES_VIA :{ORANGE}via {STRING1}{STRING}
|
||||
STR_DEPARTURES_VIA :{ORANGE}via {STRING}
|
||||
STR_DEPARTURES_TOC :{ORANGE}{COMPANY}
|
||||
STR_DEPARTURES_GROUP :{ORANGE}{GROUP}
|
||||
STR_DEPARTURES_VEH :{ORANGE}{VEHICLE}
|
||||
@@ -1295,6 +1295,8 @@ STR_DEPARTURES_CALLING_AT_LAST_STATION :{RAW_STRING} an
|
||||
STR_DEPARTURES_CALLING_AT_LIST :{ORANGE}{RAW_STRING}.
|
||||
STR_DEPARTURES_CALLING_AT_LIST_SMART_TERMINUS :{ORANGE}{RAW_STRING}. This service continues to {STATION}.
|
||||
STR_DEPARTURES_TINY :{TINY_FONT}{STRING2}
|
||||
STR_DEPARTURES_VIA_DESCRIPTOR :{STRING1}{STRING}
|
||||
STR_DEPARTURES_VIA_AND :{STRING} and {STRING}
|
||||
|
||||
STR_DEPARTURES_TYPE_TRAIN :{ORANGE}{TRAIN}
|
||||
STR_DEPARTURES_TYPE_TRAIN_SILVER :{SILVER}{TRAIN}
|
||||
|
@@ -1235,9 +1235,9 @@ STR_DEPARTURES_TIME_DEP :{ORANGE}{DATE_W
|
||||
STR_DEPARTURES_TIME_ARR :{ORANGE}{DATE_WALLCLOCK_TINY} {RED}{DOWN_ARROW}
|
||||
STR_DEPARTURES_TIME_BOTH :{ORANGE}{1:DATE_WALLCLOCK_TINY} {RED}{DOWN_ARROW} {ORANGE}{0:DATE_WALLCLOCK_TINY} {GREEN}{UP_ARROW}
|
||||
STR_DEPARTURES_TERMINUS :{ORANGE}{STATION}{STRING}
|
||||
STR_DEPARTURES_TERMINUS_VIA_STATION :{ORANGE}{STATION}{STRING} vía {STRING}{STRING}
|
||||
STR_DEPARTURES_TERMINUS_VIA_STATION :{ORANGE}{STATION}{STRING} vía {STRING}
|
||||
STR_DEPARTURES_TERMINUS_VIA :{ORANGE}{STATION}{STRING} vía
|
||||
STR_DEPARTURES_VIA :{ORANGE}vía {STRING}{STRING}
|
||||
STR_DEPARTURES_VIA :{ORANGE}vía {STRING}
|
||||
STR_DEPARTURES_TOC :{ORANGE}{COMPANY}
|
||||
STR_DEPARTURES_GROUP :{ORANGE}{GROUP}
|
||||
STR_DEPARTURES_VEH :{ORANGE}{VEHICLE}
|
||||
|
@@ -1158,9 +1158,9 @@ STR_DEPARTURES_TIME_DEP :{ORANGE}{DATE_W
|
||||
STR_DEPARTURES_TIME_ARR :{ORANGE}{DATE_WALLCLOCK_TINY} {RED}{DOWN_ARROW}
|
||||
STR_DEPARTURES_TIME_BOTH :{ORANGE}{1:DATE_WALLCLOCK_TINY} {RED}{DOWN_ARROW} {ORANGE}{0:DATE_WALLCLOCK_TINY} {GREEN}{UP_ARROW}
|
||||
STR_DEPARTURES_TERMINUS :{ORANGE}{STATION}{STRING}
|
||||
STR_DEPARTURES_TERMINUS_VIA_STATION :{ORANGE}{STATION}{STRING} über {STRING}{STRING}
|
||||
STR_DEPARTURES_TERMINUS_VIA_STATION :{ORANGE}{STATION}{STRING} über {STRING}
|
||||
STR_DEPARTURES_TERMINUS_VIA :{ORANGE}{STATION}{STRING} über
|
||||
STR_DEPARTURES_VIA :{ORANGE}über {STRING}{STRING}
|
||||
STR_DEPARTURES_VIA :{ORANGE}über {STRING}
|
||||
STR_DEPARTURES_TOC :{ORANGE}{COMPANY}
|
||||
STR_DEPARTURES_GROUP :{ORANGE}{GROUP}
|
||||
STR_DEPARTURES_VEH :{ORANGE}{VEHICLE}
|
||||
|
@@ -51,9 +51,9 @@ STR_DEPARTURES_TIME_DEP :{ORANGE}{DATE_W
|
||||
STR_DEPARTURES_TIME_ARR :{ORANGE}{DATE_WALLCLOCK_TINY} {RED}{DOWN_ARROW}
|
||||
STR_DEPARTURES_TIME_BOTH :{ORANGE}{1:DATE_WALLCLOCK_TINY} {RED}{DOWN_ARROW} {ORANGE}{0:DATE_WALLCLOCK_TINY} {GREEN}{UP_ARROW}
|
||||
STR_DEPARTURES_TERMINUS :{ORANGE}{STATION}{STRING}
|
||||
STR_DEPARTURES_TERMINUS_VIA_STATION :{ORANGE}{STATION}{STRING} 経由 {STRING}{STRING}経由
|
||||
STR_DEPARTURES_TERMINUS_VIA_STATION :{ORANGE}{STATION}{STRING} 経由 {STRING}経由
|
||||
STR_DEPARTURES_TERMINUS_VIA :{ORANGE}{STATION}{STRING} 経由
|
||||
STR_DEPARTURES_VIA :{ORANGE} {STRING}{STRING} 経由
|
||||
STR_DEPARTURES_VIA :{ORANGE} {STRING} 経由
|
||||
STR_DEPARTURES_TOC :{ORANGE}{COMPANY}
|
||||
STR_DEPARTURES_GROUP :{ORANGE}{GROUP}
|
||||
STR_DEPARTURES_VEH :{ORANGE}{VEHICLE}
|
||||
|
@@ -1235,8 +1235,8 @@ STR_DEPARTURES_TIME_DEP :{ORANGE}{DATE_W
|
||||
STR_DEPARTURES_TIME_ARR :{ORANGE}{DATE_WALLCLOCK_TINY} {RED}{DOWN_ARROW}
|
||||
STR_DEPARTURES_TIME_BOTH :{ORANGE}{1:DATE_WALLCLOCK_TINY} {RED}{DOWN_ARROW} {ORANGE}{0:DATE_WALLCLOCK_TINY} {GREEN}{UP_ARROW}
|
||||
STR_DEPARTURES_TERMINUS :{ORANGE}{STATION}{STRING}
|
||||
STR_DEPARTURES_TERMINUS_VIA_STATION :{ORANGE}{STATION}{STRING} 경유 {STRING}{STRING}
|
||||
STR_DEPARTURES_TERMINUS_VIA :{ORANGE}{STATION}{STRING} 경유
|
||||
STR_DEPARTURES_TERMINUS_VIA_STATION :{ORANGE}{STATION}{STRING} 경유 {STRING}
|
||||
STR_DEPARTURES_TERMINUS_VIA :{ORANGE}{STATION} 경유
|
||||
STR_DEPARTURES_VIA :{ORANGE}경유 {STRING}{STRING}
|
||||
STR_DEPARTURES_TOC :{ORANGE}{COMPANY}
|
||||
STR_DEPARTURES_GROUP :{ORANGE}{GROUP}
|
||||
|
@@ -1225,9 +1225,9 @@ STR_DEPARTURES_TIME_DEP :{ORANGE}{DATE_W
|
||||
STR_DEPARTURES_TIME_ARR :{ORANGE}{DATE_WALLCLOCK_TINY} {RED}{DOWN_ARROW}
|
||||
STR_DEPARTURES_TIME_BOTH :{ORANGE}{1:DATE_WALLCLOCK_TINY} {RED}{DOWN_ARROW} {ORANGE}{0:DATE_WALLCLOCK_TINY} {GREEN}{UP_ARROW}
|
||||
STR_DEPARTURES_TERMINUS :{ORANGE}{STATION}{STRING}
|
||||
STR_DEPARTURES_TERMINUS_VIA_STATION :{ORANGE}{STATION}{STRING}经由{STRING}{STRING}
|
||||
STR_DEPARTURES_TERMINUS_VIA_STATION :{ORANGE}{STATION}{STRING}经由{STRING}
|
||||
STR_DEPARTURES_TERMINUS_VIA :{ORANGE}{STATION}{STRING}经由
|
||||
STR_DEPARTURES_VIA :{ORANGE}经由{STRING}{STRING}
|
||||
STR_DEPARTURES_VIA :{ORANGE}经由{STRING}
|
||||
STR_DEPARTURES_TOC :{ORANGE}{COMPANY}
|
||||
STR_DEPARTURES_GROUP :{ORANGE}{GROUP}
|
||||
STR_DEPARTURES_VEH :{ORANGE}{VEHICLE}
|
||||
|
Reference in New Issue
Block a user