Departures: Show no date at all in date mode with a frozen calendar

This commit is contained in:
Jonathan G Rennison 2024-09-08 22:51:07 +01:00
parent ed9a5392ed
commit 7b1f6b81b1
2 changed files with 30 additions and 21 deletions

View File

@ -585,7 +585,8 @@ public:
} }
/* Recompute the minimum date display width if the cached one is no longer valid. */ /* Recompute the minimum date display width if the cached one is no longer valid. */
if (cached_date_width == 0 || if (cached_status_width == 0 ||
((cached_date_width == 0) != (!_settings_time.time_in_minutes && CalTime::IsCalendarFrozen())) ||
_settings_time.time_in_minutes != cached_date_display_method) { _settings_time.time_in_minutes != cached_date_display_method) {
this->RecomputeDateWidth(); this->RecomputeDateWidth();
} }
@ -686,6 +687,7 @@ public:
} }
if (!_settings_time.time_in_minutes && this->show_arrival_times) { if (!_settings_time.time_in_minutes && this->show_arrival_times) {
this->show_arrival_times = false; this->show_arrival_times = false;
this->RaiseWidget(WID_DB_SHOW_TIMES);
} }
this->SetWidgetDisabledState(WID_DB_SHOW_TIMES, this->mode == DM_ARRIVALS || !_settings_time.time_in_minutes); this->SetWidgetDisabledState(WID_DB_SHOW_TIMES, this->mode == DM_ARRIVALS || !_settings_time.time_in_minutes);
this->SetupValues(); this->SetupValues();
@ -749,7 +751,8 @@ void DeparturesWindow::RecomputeDateWidth()
if (_settings_time.time_in_minutes) { if (_settings_time.time_in_minutes) {
StateTicks tick = _settings_time.FromTickMinutes(_settings_time.NowInTickMinutes().ToSameDayClockTime(GetBroadestHourDigitsValue(), (int)GetBroadestDigitsValue(2))); StateTicks tick = _settings_time.FromTickMinutes(_settings_time.NowInTickMinutes().ToSameDayClockTime(GetBroadestHourDigitsValue(), (int)GetBroadestDigitsValue(2)));
eval_tick(tick); eval_tick(tick);
} else { } else if (!CalTime::IsCalendarFrozen()) {
/* If the calendar is frozen, all dates are the same, so just don't show anything */
for (uint i = 0; i < 365; ++i) { for (uint i = 0; i < 365; ++i) {
eval_tick(INT_MAX - (i * DAY_TICKS)); eval_tick(INT_MAX - (i * DAY_TICKS));
} }
@ -901,6 +904,7 @@ void DeparturesWindow::DrawDeparturesListItems(const Rect &r) const
if (d->terminus == INVALID_STATION) continue; if (d->terminus == INVALID_STATION) continue;
if (time_width > 0) {
StringID time_str; StringID time_str;
TextColour time_colour = d->show_as_via ? TC_YELLOW : TC_ORANGE; TextColour time_colour = d->show_as_via ? TC_YELLOW : TC_ORANGE;
if (this->mode == DM_COMBINED) { if (this->mode == DM_COMBINED) {
@ -921,8 +925,12 @@ void DeparturesWindow::DrawDeparturesListItems(const Rect &r) const
SetDParam(1, STR_JUST_TT_TIME_ABS); SetDParam(1, STR_JUST_TT_TIME_ABS);
SetDParam(2, d->scheduled_tick); SetDParam(2, d->scheduled_tick);
} }
ltr ? DrawString( text_left, text_left + time_width, y + 1, time_str) if (ltr) {
: DrawString(text_right - time_width, text_right, y + 1, time_str); DrawString( text_left, text_left + time_width, y + 1, time_str);
} else {
DrawString(text_right - time_width, text_right, y + 1, time_str);
}
}
if (_settings_client.gui.departure_show_vehicle_type) { if (_settings_client.gui.departure_show_vehicle_type) {
StringID type = STR_DEPARTURES_TYPE_TRAIN; StringID type = STR_DEPARTURES_TYPE_TRAIN;

View File

@ -1383,6 +1383,7 @@ static void ChangeMinutesPerYear(int32_t new_value)
} }
UpdateEffectiveDayLengthFactor(); UpdateEffectiveDayLengthFactor();
InvalidateWindowClassesData(WC_DEPARTURES_BOARD, 1);
/* If the setting value is not the default, force the game to use wallclock timekeeping units. /* If the setting value is not the default, force the game to use wallclock timekeeping units.
* This can only happen in the menu, since the pre_cb ensures this setting can only be changed there, or if we're already using wallclock units. * This can only happen in the menu, since the pre_cb ensures this setting can only be changed there, or if we're already using wallclock units.