From c0d3088817f02bf7dc7fb07cb6051088ffad22a9 Mon Sep 17 00:00:00 2001 From: cakepie Date: Fri, 2 Dec 2022 23:26:16 +0800 Subject: [PATCH 1/8] Departure boards: Fix "show via" widget needs redrawn when changed as a side effect of "show deps" toggled --- src/departures_gui.cpp | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/src/departures_gui.cpp b/src/departures_gui.cpp index fb64250ff3..3ba3984995 100644 --- a/src/departures_gui.cpp +++ b/src/departures_gui.cpp @@ -365,16 +365,19 @@ public: this->RaiseWidget(widget); } - if (!this->departure_types[0]) { - this->RaiseWidget(WID_DB_SHOW_VIA); - this->DisableWidget(WID_DB_SHOW_VIA); - } else { - this->EnableWidget(WID_DB_SHOW_VIA); - - if (this->departure_types[2]) { - this->LowerWidget(WID_DB_SHOW_VIA); + /* Side effects */ + if (widget == WID_DB_SHOW_DEPS) { + if (!this->departure_types[0]) { + this->RaiseWidget(WID_DB_SHOW_VIA); + this->DisableWidget(WID_DB_SHOW_VIA); + } else { + this->EnableWidget(WID_DB_SHOW_VIA); + this->SetWidgetLoweredState(WID_DB_SHOW_VIA,this->departure_types[2]); } + /* Redraw required. */ + this->SetWidgetDirty(WID_DB_SHOW_VIA); } + /* We need to recompute the departures list. */ this->calc_tick_countdown = 0; /* We need to redraw the button that was pressed. */ From 87aa379aa9bb1433a451bfbdf1e7419a14e356c1 Mon Sep 17 00:00:00 2001 From: cakepie Date: Sat, 3 Dec 2022 00:08:16 +0800 Subject: [PATCH 2/8] Departure boards: Refactor widget toggling --- src/departures_gui.cpp | 15 +++------------ 1 file changed, 3 insertions(+), 12 deletions(-) diff --git a/src/departures_gui.cpp b/src/departures_gui.cpp index 3ba3984995..98174d359e 100644 --- a/src/departures_gui.cpp +++ b/src/departures_gui.cpp @@ -336,12 +336,7 @@ public: } } else { this->show_types[widget - WID_DB_SHOW_TRAINS] = !this->show_types[widget - WID_DB_SHOW_TRAINS]; - if (this->show_types[widget - WID_DB_SHOW_TRAINS]) { - this->LowerWidget(widget); - } - else { - this->RaiseWidget(widget); - } + this->SetWidgetLoweredState(widget, this->show_types[widget - WID_DB_SHOW_TRAINS]); this->SetWidgetDirty(widget); } /* We need to recompute the departures list. */ @@ -359,11 +354,7 @@ public: case WID_DB_SHOW_VIA: this->departure_types[widget - WID_DB_SHOW_DEPS] = !this->departure_types[widget - WID_DB_SHOW_DEPS]; - if (this->departure_types[widget - WID_DB_SHOW_DEPS]) { - this->LowerWidget(widget); - } else { - this->RaiseWidget(widget); - } + this->SetWidgetLoweredState(widget, this->departure_types[widget - WID_DB_SHOW_DEPS]); /* Side effects */ if (widget == WID_DB_SHOW_DEPS) { @@ -372,7 +363,7 @@ public: this->DisableWidget(WID_DB_SHOW_VIA); } else { this->EnableWidget(WID_DB_SHOW_VIA); - this->SetWidgetLoweredState(WID_DB_SHOW_VIA,this->departure_types[2]); + this->SetWidgetLoweredState(WID_DB_SHOW_VIA, this->departure_types[2]); } /* Redraw required. */ this->SetWidgetDirty(WID_DB_SHOW_VIA); From 821be47a6072ebb465ba7b753ed42beb01220e23 Mon Sep 17 00:00:00 2001 From: cakepie Date: Sat, 3 Dec 2022 00:12:09 +0800 Subject: [PATCH 3/8] Departure boards: cleanup: move misplaced comment --- src/departures_gui.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/departures_gui.cpp b/src/departures_gui.cpp index 98174d359e..4172eada4c 100644 --- a/src/departures_gui.cpp +++ b/src/departures_gui.cpp @@ -337,11 +337,11 @@ public: } else { this->show_types[widget - WID_DB_SHOW_TRAINS] = !this->show_types[widget - WID_DB_SHOW_TRAINS]; this->SetWidgetLoweredState(widget, this->show_types[widget - WID_DB_SHOW_TRAINS]); + /* We need to redraw the button that was pressed. */ this->SetWidgetDirty(widget); } /* We need to recompute the departures list. */ this->RefreshVehicleList(); - /* We need to redraw the button that was pressed. */ if (_pause_mode != PM_UNPAUSED) this->OnGameTick(); break; } From 6b6a0adeb440de2f3fe8fba7477b15ccfd94d0cf Mon Sep 17 00:00:00 2001 From: cakepie Date: Sat, 3 Dec 2022 00:47:06 +0800 Subject: [PATCH 4/8] Departure boards: Fix swapped ship/acft tooltips, use dedicated strings with more appropriate wording instead of repurposing from WID_SV_* widgets' tooltips in station_gui --- src/departures_gui.cpp | 4 ++-- src/lang/english.txt | 6 +++++- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/src/departures_gui.cpp b/src/departures_gui.cpp index 4172eada4c..2e74b38a62 100644 --- a/src/departures_gui.cpp +++ b/src/departures_gui.cpp @@ -307,8 +307,8 @@ public: case WID_DB_SHOW_SHIPS: case WID_DB_SHOW_PLANES: { uint64 params[1]; - params[0] = STR_STATION_VIEW_SCHEDULED_TRAINS_TOOLTIP + (widget - WID_DB_SHOW_TRAINS); - GuiShowTooltips(this, STR_STATION_VIEW_SCHEDULED_TOOLTIP_CTRL_SUFFIX, 1, params, close_cond); + params[0] = STR_DEPARTURES_SHOW_TRAINS_TOOLTIP + (widget - WID_DB_SHOW_TRAINS); + GuiShowTooltips(this, STR_DEPARTURES_SHOW_TYPE_TOOLTIP_CTRL_SUFFIX, 1, params, close_cond); return true; } default: diff --git a/src/lang/english.txt b/src/lang/english.txt index 9ef0918d65..9562f22086 100644 --- a/src/lang/english.txt +++ b/src/lang/english.txt @@ -4662,7 +4662,6 @@ STR_STATION_VIEW_SCHEDULED_TRAINS_TOOLTIP :{BLACK}Show all STR_STATION_VIEW_SCHEDULED_ROAD_VEHICLES_TOOLTIP :{BLACK}Show all road vehicles which have this station on their schedule STR_STATION_VIEW_SCHEDULED_AIRCRAFT_TOOLTIP :{BLACK}Show all aircraft which have this station on their schedule STR_STATION_VIEW_SCHEDULED_SHIPS_TOOLTIP :{BLACK}Show all ships which have this station on their schedule -STR_STATION_VIEW_SCHEDULED_TOOLTIP_CTRL_SUFFIX :{BLACK}{STRING}. Ctrl+Click to show exclusively. STR_STATION_VIEW_RENAME_STATION_CAPTION :Rename station/loading area STR_STATION_VIEW_CLOSE_AIRPORT :{BLACK}Close airport @@ -4681,6 +4680,11 @@ STR_DEPARTURES_FREIGHT_TOOLTIP :{BLACK}Show fre STR_DEPARTURES_DEPARTURES_TOOLTIP :{BLACK}Show timetabled departures STR_DEPARTURES_ARRIVALS_TOOLTIP :{BLACK}Show timetabled arrivals STR_DEPARTURES_VIA_TOOLTIP :{BLACK}Show timetabled vehicles that do not stop here +STR_DEPARTURES_SHOW_TRAINS_TOOLTIP :{BLACK}Show upcoming trains on this station's timetable +STR_DEPARTURES_SHOW_ROAD_VEHICLES_TOOLTIP :{BLACK}Show upcoming road vehicles on this station's timetable +STR_DEPARTURES_SHOW_SHIPS_TOOLTIP :{BLACK}Show upcoming ships on this station's timetable +STR_DEPARTURES_SHOW_AIRCRAFT_TOOLTIP :{BLACK}Show upcoming aircraft on this station's timetable +STR_DEPARTURES_SHOW_TYPE_TOOLTIP_CTRL_SUFFIX :{BLACK}{STRING}. Ctrl+Click to show exclusively. STR_DEPARTURES_EMPTY :{ORANGE}No vehicles are currently timetabled for this station. STR_DEPARTURES_NONE_SELECTED :{ORANGE}No timetable information has been requested. STR_DEPARTURES_TIME :{ORANGE}{DATE_WALLCLOCK_TINY} From b76359d4852f6ae08f35f01631d52417ec02f714 Mon Sep 17 00:00:00 2001 From: cakepie Date: Sat, 3 Dec 2022 09:51:03 +0800 Subject: [PATCH 5/8] Departure boards: Fix no entries shown if "show both" setting turned on while window already open with "Show Deps" false --- src/departures_gui.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/departures_gui.cpp b/src/departures_gui.cpp index 2e74b38a62..32f560a754 100644 --- a/src/departures_gui.cpp +++ b/src/departures_gui.cpp @@ -467,7 +467,7 @@ public: this->DeleteDeparturesList(this->arrivals); bool show_pax = _settings_client.gui.departure_only_passengers ? true : this->show_pax; bool show_freight = _settings_client.gui.departure_only_passengers ? false : this->show_freight; - this->departures = (this->departure_types[0] ? MakeDepartureList(this->station, this->vehicles, D_DEPARTURE, Twaypoint || this->departure_types[2], show_pax, show_freight) : new DepartureList()); + this->departures = (this->departure_types[0] || _settings_client.gui.departure_show_both ? MakeDepartureList(this->station, this->vehicles, D_DEPARTURE, Twaypoint || this->departure_types[2], show_pax, show_freight) : new DepartureList()); this->arrivals = (this->departure_types[1] && !_settings_client.gui.departure_show_both ? MakeDepartureList(this->station, this->vehicles, D_ARRIVAL, false, show_pax, show_freight) : new DepartureList()); this->departures_invalid = false; this->SetWidgetDirty(WID_DB_LIST); From 5fa9e5efb124293a35ce25646ad9f1ae65542e46 Mon Sep 17 00:00:00 2001 From: cakepie Date: Sat, 3 Dec 2022 10:03:16 +0800 Subject: [PATCH 6/8] Departure boards: Fix unintuitive "A"/"D" widget lowered states when disabled by departure_show_both --- src/departures_gui.cpp | 31 +++++++++++++++++++++++-------- 1 file changed, 23 insertions(+), 8 deletions(-) diff --git a/src/departures_gui.cpp b/src/departures_gui.cpp index 32f560a754..96dfad916d 100644 --- a/src/departures_gui.cpp +++ b/src/departures_gui.cpp @@ -98,6 +98,7 @@ protected: int calc_tick_countdown; ///< The number of ticks to wait until recomputing the departure list. Signed in case it goes below zero. bool show_types[4]; ///< The vehicle types to show in the departure list. bool departure_types[3]; ///< The types of departure to show in the departure list. + bool departure_types_both; ///< Arrivals and departures buttons disabled (shown combined as single entry) bool show_pax; ///< Show passenger vehicles bool show_freight; ///< Show freight vehicles bool cargo_buttons_disabled;///< Show pax/freight buttons disabled @@ -136,6 +137,20 @@ protected: } } + void SetDepartureTypesDisabledState() + { + this->departure_types_both = _settings_client.gui.departure_show_both; + this->SetWidgetDisabledState(WID_DB_SHOW_DEPS, departure_types_both); + this->SetWidgetDisabledState(WID_DB_SHOW_ARRS, departure_types_both); + if (this->departure_types_both) { + this->LowerWidget(WID_DB_SHOW_DEPS); + this->LowerWidget(WID_DB_SHOW_ARRS); + } else { + this->SetWidgetLoweredState(WID_DB_SHOW_DEPS, this->departure_types[0]); + this->SetWidgetLoweredState(WID_DB_SHOW_ARRS, this->departure_types[1]); + } + } + void FillVehicleList() { this->vehicles.clear(); @@ -237,6 +252,7 @@ public: this->RaiseWidget(WID_DB_SHOW_VIA); this->LowerWidget(WID_DB_SHOW_PAX); this->LowerWidget(WID_DB_SHOW_FREIGHT); + this->SetDepartureTypesDisabledState(); this->SetCargoFilterDisabledState(); for (uint i = 0; i < 4; ++i) { @@ -453,6 +469,13 @@ public: this->SetWidgetDirty(WID_DB_SHOW_FREIGHT); } + if (!Twaypoint && this->departure_types_both != _settings_client.gui.departure_show_both) { + this->SetDepartureTypesDisabledState(); + this->calc_tick_countdown = 0; + this->SetWidgetDirty(WID_DB_SHOW_DEPS); + this->SetWidgetDirty(WID_DB_SHOW_ARRS); + } + /* We need to redraw the scrolling text in its new position. */ this->SetWidgetDirty(WID_DB_LIST); @@ -498,14 +521,6 @@ public: virtual void OnPaint() override { - if (Twaypoint || _settings_client.gui.departure_show_both) { - this->DisableWidget(WID_DB_SHOW_ARRS); - this->DisableWidget(WID_DB_SHOW_DEPS); - } else { - this->EnableWidget(WID_DB_SHOW_ARRS); - this->EnableWidget(WID_DB_SHOW_DEPS); - } - this->vscroll->SetCount(std::min(_settings_client.gui.max_departures, (uint)this->departures->size() + (uint)this->arrivals->size())); this->DrawWidgets(); } From d5e1954e3b2a2c331199433121210b5359418b48 Mon Sep 17 00:00:00 2001 From: cakepie Date: Sun, 4 Dec 2022 14:17:51 +0800 Subject: [PATCH 7/8] Departure boards: ignore departure_show_both setting for waypoints --- src/departures_gui.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/departures_gui.cpp b/src/departures_gui.cpp index 96dfad916d..3dabdc9b33 100644 --- a/src/departures_gui.cpp +++ b/src/departures_gui.cpp @@ -252,7 +252,7 @@ public: this->RaiseWidget(WID_DB_SHOW_VIA); this->LowerWidget(WID_DB_SHOW_PAX); this->LowerWidget(WID_DB_SHOW_FREIGHT); - this->SetDepartureTypesDisabledState(); + if (!Twaypoint) this->SetDepartureTypesDisabledState(); this->SetCargoFilterDisabledState(); for (uint i = 0; i < 4; ++i) { From a6965cf854ba4f1deffd15b0de79a385367acb76 Mon Sep 17 00:00:00 2001 From: cakepie Date: Sun, 4 Dec 2022 14:22:08 +0800 Subject: [PATCH 8/8] Departure boards: reword strings to better reflect that both arrivals and departures may be displayed --- src/lang/english.txt | 44 ++++++++++++++++++++++---------------------- 1 file changed, 22 insertions(+), 22 deletions(-) diff --git a/src/lang/english.txt b/src/lang/english.txt index 9562f22086..c7ad5b599b 100644 --- a/src/lang/english.txt +++ b/src/lang/english.txt @@ -4675,8 +4675,8 @@ STR_DEPARTURES_FREIGHT :{BLACK}{TINY_FO STR_DEPARTURES_DEPARTURES :{BLACK}{TINY_FONT}D STR_DEPARTURES_ARRIVALS :{BLACK}{TINY_FONT}A STR_DEPARTURES_VIA_BUTTON :{BLACK}{TINY_FONT}via -STR_DEPARTURES_PAX_TOOLTIP :{BLACK}Show passenger departures -STR_DEPARTURES_FREIGHT_TOOLTIP :{BLACK}Show freight departures +STR_DEPARTURES_PAX_TOOLTIP :{BLACK}Show passenger arrivals/departures +STR_DEPARTURES_FREIGHT_TOOLTIP :{BLACK}Show freight arrivals/departures STR_DEPARTURES_DEPARTURES_TOOLTIP :{BLACK}Show timetabled departures STR_DEPARTURES_ARRIVALS_TOOLTIP :{BLACK}Show timetabled arrivals STR_DEPARTURES_VIA_TOOLTIP :{BLACK}Show timetabled vehicles that do not stop here @@ -4733,20 +4733,20 @@ STR_DEPARTURES_CANCELLED :{RED}Cancelled ############ config settings STR_CONFIG_SETTING_DEPARTUREBOARDS :{ORANGE}Departure boards -STR_CONFIG_MAX_DEPARTURES :Show at most {STRING2} departures at each station -STR_CONFIG_MAX_DEPARTURES_HELPTEXT :The maximum number of departures to show on a departure board -STR_CONFIG_MAX_DEPARTURE_TIME :Show departures at most {STRING2} days in advance -STR_CONFIG_MAX_DEPARTURE_TIME_HELPTEXT :How far in advance to show departures, in days -STR_CONFIG_DEPARTURE_CALC_FREQUENCY :Calculate departures every {STRING2} ticks -STR_CONFIG_DEPARTURE_CALC_FREQUENCY_HELPTEXT :How frequently to refresh a list of departures, in ticks -STR_CONFIG_DEPARTURE_VEHICLE_NAME :Show vehicle name with departures: {STRING2} -STR_CONFIG_DEPARTURE_VEHICLE_NAME_HELPTEXT :Whether to show vehicle names next to their departures -STR_CONFIG_DEPARTURE_GROUP_NAME :Show group name with departures: {STRING2} -STR_CONFIG_DEPARTURE_GROUP_NAME_HELPTEXT :Whether to show names of groups that a vehicle belongs to next to its departures -STR_CONFIG_DEPARTURE_COMPANY_NAME :Show company name with departures: {STRING2} -STR_CONFIG_DEPARTURE_COMPANY_NAME_HELPTEXT :Whether to show a company's name next to its vehicles' departures -STR_CONFIG_DEPARTURE_VEHICLE_TYPE :Show vehicle type icon with departures: {STRING2} -STR_CONFIG_DEPARTURE_VEHICLE_TYPE_HELPTEXT :Whether to show a vehicle's type as an icon next to its departures +STR_CONFIG_MAX_DEPARTURES :Show at most {STRING2} departure board entries for each station +STR_CONFIG_MAX_DEPARTURES_HELPTEXT :The maximum number of entries to show on a departure board +STR_CONFIG_MAX_DEPARTURE_TIME :Show arrivals/departures at most {STRING2} days in advance +STR_CONFIG_MAX_DEPARTURE_TIME_HELPTEXT :How far in advance to show arrivals and departures, in days +STR_CONFIG_DEPARTURE_CALC_FREQUENCY :Calculate departure board entries every {STRING2} ticks +STR_CONFIG_DEPARTURE_CALC_FREQUENCY_HELPTEXT :How frequently to refresh a list of arrivals/departures, in ticks +STR_CONFIG_DEPARTURE_VEHICLE_NAME :Show vehicle name in entries: {STRING2} +STR_CONFIG_DEPARTURE_VEHICLE_NAME_HELPTEXT :Whether to show vehicle names in their departure board entries +STR_CONFIG_DEPARTURE_GROUP_NAME :Show group name in entries: {STRING2} +STR_CONFIG_DEPARTURE_GROUP_NAME_HELPTEXT :Whether to show names of groups that a vehicle belongs to in its departure board entries +STR_CONFIG_DEPARTURE_COMPANY_NAME :Show company name in entries: {STRING2} +STR_CONFIG_DEPARTURE_COMPANY_NAME_HELPTEXT :Whether to show a company's name in its vehicles' departure board entries +STR_CONFIG_DEPARTURE_VEHICLE_TYPE :Show vehicle type icon in entries: {STRING2} +STR_CONFIG_DEPARTURE_VEHICLE_TYPE_HELPTEXT :Whether to show a vehicle's type as an icon in its departure board entries STR_CONFIG_DEPARTURE_VEHICLE_COLOR :Show vehicle type icon in silver: {STRING2} STR_CONFIG_DEPARTURE_VEHICLE_COLOR_HELPTEXT :Whether to show vehicle type icons in silver STR_CONFIG_DEPARTURE_LARGER_FONT :Use larger font for stations called at on departure boards: {STRING2} @@ -4754,20 +4754,20 @@ STR_CONFIG_DEPARTURE_LARGER_FONT_HELPTEXT :Whether to use STR_CONFIG_DEPARTURE_DESTINATION_TYPE :Show icons for destinations that are docks or airports: {STRING2} STR_CONFIG_DEPARTURE_DESTINATION_TYPE_HELPTEXT :Whether to show icons next to destinations that are docks or airports STR_CONFIG_DEPARTURE_SHOW_BOTH :Show arrival and departure times on the same line: {STRING2} -STR_CONFIG_DEPARTURE_SHOW_BOTH_HELPTEXT :Whether to show both arrival and departure times next to departures -STR_CONFIG_DEPARTURE_ONLY_PASSENGERS :Only show departures for vehicles that can carry passengers: {STRING2} -STR_CONFIG_DEPARTURE_ONLY_PASSENGERS_HELPTEXT :Whether to only show departures of vehicles that can carry passengers +STR_CONFIG_DEPARTURE_SHOW_BOTH_HELPTEXT :Whether arrival and departure times for a vehicle are combined into a single entry instead of being listed separately +STR_CONFIG_DEPARTURE_ONLY_PASSENGERS :Only show entries for vehicles that can carry passengers: {STRING2} +STR_CONFIG_DEPARTURE_ONLY_PASSENGERS_HELPTEXT :Whether to only show arrivals and departures of vehicles that can carry passengers STR_CONFIG_DEPARTURE_SMART_TERMINUS :Don't show termini that can be reached sooner on a later vehicle: {STRING2} STR_CONFIG_DEPARTURE_SMART_TERMINUS_HELPTEXT :Whether to show termini that can be reached sooner on another vehicle that departs later STR_CONFIG_DEPARTURE_CONDITIONALS :Handle conditional order jumps by: {STRING2} -STR_CONFIG_DEPARTURE_CONDITIONALS_HELPTEXT :How conditional orders should be dealt with when calculating departures +STR_CONFIG_DEPARTURE_CONDITIONALS_HELPTEXT :How conditional orders should be dealt with when calculating departure board entries STR_CONFIG_DEPARTURE_CONDITIONALS_1 :giving up STR_CONFIG_DEPARTURE_CONDITIONALS_2 :assuming they will be taken STR_CONFIG_DEPARTURE_CONDITIONALS_3 :assuming they will not be taken STR_CONFIG_DEPARTURE_SHOW_ALL_STOPS :Show all stations called at regardless of loading/unloading: {STRING2} STR_CONFIG_DEPARTURE_SHOW_ALL_STOPS_HELPTEXT :Whether stations that a vehicle only loads from will be shown in the calling at list -STR_CONFIG_DEPARTURE_MERGE_IDENTICAL :Merge identical departures: {STRING2} -STR_CONFIG_DEPARTURE_MERGE_IDENTICAL_HELPTEXT :Whether identical departures should be merged into a single departure +STR_CONFIG_DEPARTURE_MERGE_IDENTICAL :Merge identical entries: {STRING2} +STR_CONFIG_DEPARTURE_MERGE_IDENTICAL_HELPTEXT :Whether identical departure board entries should be merged into a single one # Waypoint/buoy view window STR_WAYPOINT_VIEW_CAPTION :{WHITE}{WAYPOINT}