Simplify timetable time/duration string management

pull/519/head
Jonathan G Rennison 1 year ago
parent 8e2319ad68
commit e7f7cd06bd

@ -2,19 +2,7 @@
STR_NEWS_VEHICLE_AUTORENEW_FAILED :{WHITE}Autorenew failed on {VEHICLE}{}{STRING1}
STR_NEWGRF_ERROR_FATAL_POPUP :{WHITE}The NewGRF "{RAW_STRING}" has returned a fatal error: {}{STRING7}
STR_NEWGRF_ERROR_POPUP :{WHITE}The NewGRF "{RAW_STRING}" has returned an error: {}{STRING7}
STR_ORDER_TEXT :{STRING6} {STRING4} {STRING}
STR_TIMETABLE_TRAVEL_FOR :Travel for {STRING3}
STR_TIMETABLE_TRAVEL_FOR_SPEED :Travel for {STRING3} with at most {VELOCITY}
STR_TIMETABLE_TRAVEL_FOR_ESTIMATED :Travel (for {STRING3}, not timetabled)
STR_TIMETABLE_TRAVEL_FOR_SPEED_ESTIMATED :Travel (for {STRING3}, not timetabled) with at most {VELOCITY}
STR_TIMETABLE_STAY_FOR_ESTIMATED :(stay for {STRING3}, not timetabled)
STR_TIMETABLE_AND_TRAVEL_FOR_ESTIMATED :(travel for {STRING3}, not timetabled)
STR_TIMETABLE_STAY_FOR :and stay for {STRING3}
STR_TIMETABLE_AND_TRAVEL_FOR :and travel for {STRING3}
STR_TIMETABLE_TOTAL_TIME :{BLACK}This timetable will take {STRING3} to complete
STR_TIMETABLE_TOTAL_TIME_INCOMPLETE :{BLACK}This timetable will take at least {STRING3} to complete (not all timetabled)
STR_TIMETABLE_STATUS_LATE :{BLACK}This vehicle is currently running {STRING3} late
STR_TIMETABLE_STATUS_EARLY :{BLACK}This vehicle is currently running {STRING3} early
STR_ORDER_TEXT :{STRING6} {STRING2} {STRING}
##override off
##after STR_CONFIG_SETTING_TREE_PLACER_IMPROVED
@ -1391,8 +1379,8 @@ STR_VEHICLE_LIST_LENGTH :{STRING2}, Leng
STR_VEHICLE_LIST_TIME_TO_LIVE :{STRING2}, Lifetime: {COMMA} year{P "" s} remaining
STR_VEHICLE_LIST_TIME_TO_LIVE_RED :{STRING2}, Lifetime: {RED}{COMMA} {BLACK}year{P "" s} remaining
STR_VEHICLE_LIST_TIME_TO_LIVE_OVERDUE :{STRING2}, Lifetime: {RED}{COMMA} {BLACK}year{P "" s} overdue
STR_VEHICLE_LIST_TIMETABLE_DELAY_LATE :{STRING2}, Timetable status: {RED}{STRING3} late
STR_VEHICLE_LIST_TIMETABLE_DELAY_EARLY :{STRING2}, Timetable status: {STRING3} early
STR_VEHICLE_LIST_TIMETABLE_DELAY_LATE :{STRING2}, Timetable status: {RED}{STRING1} late
STR_VEHICLE_LIST_TIMETABLE_DELAY_EARLY :{STRING2}, Timetable status: {STRING1} early
STR_VEHICLE_LIST_TIMETABLE_DELAY_ON_TIME :{STRING2}, Timetable status: On time
STR_VEHICLE_LIST_ORDER_OCCUPANCY_AVERAGE :{STRING2}, Average order occupancy: {COMMA}%
@ -1634,7 +1622,7 @@ STR_TIMETABLE_HOURS_MINUTES :{COMMA}{NBSP}ho
STR_TIMETABLE_LEFTOVER_TICKS :{STRING1} + {COMMA} tick{P "" s}
STR_TIMETABLE_MINUTES_LONG :{COMMA}{NBSP}minute{P "" s} ({STRING2}){STRING3}
STR_TIMETABLE_MINUTES_LONG :{COMMA}{NBSP}minute{P "" s} ({STRING2})
STR_TIMETABLE_AUTOMATE :{BLACK}Automate
STR_TIMETABLE_AUTOMATE_TOOLTIP :{BLACK}Manage the timetables automatically by updating the values for each journey
@ -1818,6 +1806,9 @@ STR_JUST_STRING3 :{STRING3}
STR_JUST_VELOCITY :{VELOCITY}
STR_JUST_TT_TICKS :{TT_TICKS}
STR_JUST_TT_TICKS_LONG :{TT_TICKS_LONG}
STR_BLACK_DECIMAL :{BLACK}{DECIMAL}
STR_WHITE_DATE_WALLCLOCK_LONG :{WHITE}{DATE_WALLCLOCK_LONG}
STR_WHITE_DATE_WALLCLOCK_SHORT :{WHITE}{DATE_WALLCLOCK_SHORT}
@ -2038,9 +2029,9 @@ STR_ERROR_CAN_T_RENAME_SCHEDULE :{WHITE}Can't na
STR_SCHDISPATCH_SUMMARY_LAST_DEPARTURE_PAST :{BLACK}Last departure at {DATE_WALLCLOCK_TINY}.
STR_SCHDISPATCH_SUMMARY_LAST_DEPARTURE_FUTURE :{BLACK}Last departure has not left yet, it will depart at {DATE_WALLCLOCK_TINY}.
STR_SCHDISPATCH_SUMMARY_L1 :{BLACK}This schedule requires {COMMA} vehicle{P "" s}.
STR_SCHDISPATCH_SUMMARY_L2 :{BLACK}This schedule repeats every {STRING8}.
STR_SCHDISPATCH_SUMMARY_L2 :{BLACK}This schedule repeats every {STRING1}.
STR_SCHDISPATCH_SUMMARY_L3 :{BLACK}This schedule began at {DATE_WALLCLOCK_TINY}, and ends at {DATE_WALLCLOCK_TINY}.
STR_SCHDISPATCH_SUMMARY_L4 :{BLACK}Maximum delay of {STRING3} is allowed before the slot is skipped.
STR_SCHDISPATCH_SUMMARY_L4 :{BLACK}Maximum delay of {STRING1} is allowed before the slot is skipped.
STR_SCHDISPATCH_SUMMARY_NOT_ENABLED :{BLACK}This schedule is not active.
STR_SCHDISPATCH_SLOT_OUTSIDE_SCHEDULE :{BLACK}One or more departure slots are outside the schedule duration.

@ -1578,7 +1578,7 @@ STR_TIMETABLE_HOURS_MINUTES :{COMMA}{NBSP}ho
STR_TIMETABLE_LEFTOVER_TICKS :{STRING} + {COMMA} tick{P "" s}
STR_TIMETABLE_MINUTES_LONG :{COMMA}{NBSP}minuto{P "" s} ({STRING}){STRING}
STR_TIMETABLE_MINUTES_LONG :{COMMA}{NBSP}minuto{P "" s} ({STRING})
STR_TIMETABLE_AUTOMATE :{BLACK}Automatizar
STR_TIMETABLE_AUTOMATE_TOOLTIP :{BLACK}Xestiona os horarios automáticamente actualizando os valores para cada viaxe

@ -1471,7 +1471,7 @@ STR_TIMETABLE_HOURS_MINUTES :{COMMA}{NBSP}St
STR_TIMETABLE_LEFTOVER_TICKS :{STRING} + {COMMA} Tick{P "" s}
STR_TIMETABLE_MINUTES_LONG :{COMMA}{NBSP}Minute{P "" n} ({STRING}){STRING}
STR_TIMETABLE_MINUTES_LONG :{COMMA}{NBSP}Minute{P "" n} ({STRING})
STR_TIMETABLE_AUTOMATE :{BLACK}Automatisieren
STR_TIMETABLE_AUTOMATE_TOOLTIP :{BLACK}Verwaltet den Fahrplan durch automatisches Erfassen der Werte jeder Fahrt

@ -1583,7 +1583,7 @@ STR_TIMETABLE_HOURS_MINUTES :{COMMA}시간 {
STR_TIMETABLE_LEFTOVER_TICKS :{STRING} + {COMMA} 틱
STR_TIMETABLE_MINUTES_LONG :{COMMA}분 ({STRING}){STRING}
STR_TIMETABLE_MINUTES_LONG :{COMMA}분 ({STRING})
STR_TIMETABLE_AUTOMATE :{BLACK}자동
STR_TIMETABLE_AUTOMATE_TOOLTIP :{BLACK}각 운행마다 자동으로 값을 얻어 시간표를 만듭니다.

@ -1552,7 +1552,7 @@ STR_TIMETABLE_HOURS_MINUTES :{COMMA}{NBSP}
STR_TIMETABLE_LEFTOVER_TICKS :{STRING} + {COMMA} 刻
STR_TIMETABLE_MINUTES_LONG :{COMMA}{NBSP}分({STRING}{STRING}
STR_TIMETABLE_MINUTES_LONG :{COMMA}{NBSP}分({STRING})
STR_TIMETABLE_AUTOMATE :{BLACK}自动
STR_TIMETABLE_AUTOMATE_TOOLTIP :{BLACK}通过更新每次运行的值来自动管理时间表

@ -867,12 +867,12 @@ void DrawOrderString(const Vehicle *v, const Order *order, int order_index, int
DrawString(left, rtl ? right - 2 * sprite_size.width - 3 : middle, y, STR_ORDER_INDEX, colour, SA_RIGHT | SA_FORCE);
SetDParam(7, STR_EMPTY);
SetDParam(12, STR_EMPTY);
SetDParam(10, STR_EMPTY);
/* Check range for aircraft. */
if (v->type == VEH_AIRCRAFT && Aircraft::From(v)->GetRange() > 0 && order->IsGotoOrder()) {
const Order *next = order->next != nullptr ? order->next : v->GetFirstOrder();
if (GetOrderDistance(order, next, v) > Aircraft::From(v)->acache.cached_max_range_sqr) SetDParam(11, STR_ORDER_OUT_OF_RANGE);
if (GetOrderDistance(order, next, v) > Aircraft::From(v)->acache.cached_max_range_sqr) SetDParam(10, STR_ORDER_OUT_OF_RANGE);
}
bool timetable_wait_time_valid = false;

@ -1573,18 +1573,33 @@ static char *FormatString(char *buff, const char *str_arg, StringParameters *arg
buff = FormatTimeHHMMString(buff, args->GetInt64(SCC_TIME_HHMM), last, next_substr_case_index);
break;
case SCC_TT_TICKS: // {TT_TICKS}
case SCC_TT_TICKS: // {TT_TICKS}
case SCC_TT_TICKS_LONG: // {TT_TICKS_LONG}
if (_settings_client.gui.timetable_in_ticks) {
int64 args_array[1] = { args->GetInt64(SCC_TT_TICKS) };
int64 args_array[1] = { args->GetInt64(b) };
StringParameters tmp_params(args_array);
buff = FormatString(buff, GetStringPtr(STR_TIMETABLE_TICKS), &tmp_params, last);
} else {
StringID str = _settings_time.time_in_minutes ? STR_TIMETABLE_MINUTES : STR_TIMETABLE_DAYS;
int64 ticks = args->GetInt64(SCC_TT_TICKS);
int64 ticks = args->GetInt64(b);
int64 ratio = DATE_UNIT_SIZE;
int64 units = ticks / ratio;
int64 leftover = ticks % ratio;
if (leftover) {
int64 leftover = _settings_client.gui.timetable_leftover_ticks ? ticks % ratio : 0;
if (b == SCC_TT_TICKS_LONG && _settings_time.time_in_minutes && units > 59) {
int64 hours = units / 60;
int64 minutes = units % 60;
int64 args_array[4] = {
units,
(minutes != 0) ? STR_TIMETABLE_HOURS_MINUTES : STR_TIMETABLE_HOURS,
hours,
minutes
};
StringParameters tmp_params(args_array);
buff = FormatString(buff, GetStringPtr(STR_TIMETABLE_MINUTES_LONG), &tmp_params, last);
if (leftover == 0) break;
str = STR_EMPTY;
}
if (leftover != 0) {
int64 args_array[3] = { str, units, leftover };
StringParameters tmp_params(args_array);
buff = FormatString(buff, GetStringPtr(STR_TIMETABLE_LEFTOVER_TICKS), &tmp_params, last);

@ -81,6 +81,7 @@ enum StringControlCode {
SCC_TIME_HHMM,
SCC_TT_TICKS,
SCC_TT_TICKS_LONG,
/* Must be consecutive */
SCC_STRING1,

@ -104,6 +104,7 @@ static const CmdStruct _cmd_structs[] = {
{"TIME_HHMM", EmitSingleChar, SCC_TIME_HHMM, 1, -1, C_NONE},
{"TT_TICKS", EmitSingleChar, SCC_TT_TICKS, 1, -1, C_NONE},
{"TT_TICKS_LONG", EmitSingleChar, SCC_TT_TICKS_LONG, 1, -1, C_NONE},
{"STRING", EmitSingleChar, SCC_STRING, 1, -1, C_CASE | C_GENDER},
{"RAW_STRING", EmitSingleChar, SCC_RAW_STRING_POINTER, 1, -1, C_NONE | C_GENDER},

@ -58,35 +58,8 @@ struct TimetableArrivalDeparture {
*/
void SetTimetableParams(int first_param, Ticks ticks, bool long_mode)
{
if (_settings_client.gui.timetable_in_ticks) {
SetDParam(first_param, STR_TIMETABLE_TICKS);
SetDParam(first_param + 1, ticks);
} else {
StringID str = _settings_time.time_in_minutes ? STR_TIMETABLE_MINUTES : STR_TIMETABLE_DAYS;
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);
SetDParam(first_param + 2, units);
SetDParam(first_param + 3, leftover);
} else {
SetDParam(first_param, str);
SetDParam(first_param + 1, units);
}
}
SetDParam(first_param, long_mode ? STR_JUST_TT_TICKS_LONG : STR_JUST_TT_TICKS);
SetDParam(first_param + 1, ticks);
}
/**
@ -720,7 +693,7 @@ struct TimetableWindow : GeneralVehicleWindow {
string = order->GetMaxSpeed() != UINT16_MAX ?
STR_TIMETABLE_TRAVEL_FOR_SPEED : STR_TIMETABLE_TRAVEL_FOR;
}
SetDParam(string == STR_TIMETABLE_TRAVEL_NOT_TIMETABLED_SPEED ? 2 : 4, PackVelocity(order->GetMaxSpeed(), v->type));
SetDParam(2, PackVelocity(order->GetMaxSpeed(), v->type));
int edge = DrawString(rtl ? tr.left : middle, rtl ? middle : tr.right, tr.top, string, colour);

Loading…
Cancel
Save