Also show hours and minutes for schdispatch duration in minutes mode

This commit is contained in:
Jonathan G Rennison
2021-11-24 02:12:19 +00:00
parent a7094fec3b
commit b02b154218
6 changed files with 35 additions and 13 deletions

View File

@@ -43,8 +43,9 @@ struct TimetableArrivalDeparture {
* Set the timetable parameters in the format as described by the setting.
* @param param the first DParam to fill
* @param ticks the number of ticks to 'draw'
* @param long_mode long output format
*/
void SetTimetableParams(int first_param, Ticks ticks)
void SetTimetableParams(int first_param, Ticks ticks, bool long_mode)
{
if (_settings_client.gui.timetable_in_ticks) {
SetDParam(first_param, STR_TIMETABLE_TICKS);
@@ -54,6 +55,17 @@ void SetTimetableParams(int first_param, Ticks ticks)
size_t ratio = DATE_UNIT_SIZE;
size_t units = ticks / ratio;
size_t leftover = ticks % ratio;
if (long_mode && _settings_time.time_in_minutes && units > 59) {
SetDParam(first_param, STR_TIMETABLE_MINUTES_LONG);
SetDParam(first_param + 1, units);
size_t hours = units / 60;
size_t minutes = units % 60;
SetDParam(first_param + 2, (minutes != 0) ? STR_TIMETABLE_HOURS_MINUTES : STR_TIMETABLE_HOURS);
SetDParam(first_param + 3, hours);
SetDParam(first_param + 4, minutes);
str = STR_EMPTY;
first_param += 5;
}
if (leftover && _settings_client.gui.timetable_leftover_ticks) {
SetDParam(first_param, STR_TIMETABLE_LEFTOVER_TICKS);
SetDParam(first_param + 1, str);