Add client setting to show leftover ticks in timetable.

pull/8/head
Jonathan G Rennison 8 years ago
parent cf59b4fcab
commit 04b188bd7d

@ -1450,6 +1450,8 @@ STR_CONFIG_SETTING_TIMETABLE_AUTOMATED :Automatically m
STR_CONFIG_SETTING_TIMETABLE_AUTOMATED_HELPTEXT :Whether to enable automatic timetables
STR_CONFIG_SETTING_TIMETABLE_IN_TICKS :Show timetable in ticks rather than days: {STRING2}
STR_CONFIG_SETTING_TIMETABLE_IN_TICKS_HELPTEXT :Show travel times in time tables in game ticks instead of days
STR_CONFIG_SETTING_TIMETABLE_LEFTOVER_TICKS :Show leftover ticks in timetable: {STRING2}
STR_CONFIG_SETTING_TIMETABLE_LEFTOVER_TICKS_HELPTEXT :When converting from ticks to days/minutes in timetables, also show any leftover ticks
STR_CONFIG_SETTING_TIME_IN_MINUTES :Show time in minutes rather than days: {STRING2}
STR_CONFIG_SETTING_TIME_IN_MINUTES_HELPTEXT :Select whether to use hours and minutes instead of days
STR_CONFIG_SETTING_TICKS_PER_MINUTE :Ticks per minute: {STRING2}
@ -4248,7 +4250,7 @@ STR_ORDERS_TIMETABLE_VIEW_TOOLTIP :{BLACK}Switch t
STR_ORDERS_LIST_TOOLTIP :{BLACK}Order list - click on an order to highlight it. Ctrl+Click scrolls to the order's destination
STR_ORDER_INDEX :{COMMA}:{NBSP}
STR_ORDER_TEXT :{STRING4} {STRING2} {STRING}
STR_ORDER_TEXT :{STRING4} {STRING4} {STRING}
STR_ORDERS_END_OF_ORDERS :- - End of Orders - -
STR_ORDERS_END_OF_SHARED_ORDERS :- - End of Shared Orders - -
@ -4440,24 +4442,26 @@ STR_TIMETABLE_NO_TRAVEL :No travel
STR_TIMETABLE_NOT_TIMETABLEABLE :Travel (automatic; timetabled by next manual order)
STR_TIMETABLE_TRAVEL_NOT_TIMETABLED :Travel (not timetabled)
STR_TIMETABLE_TRAVEL_NOT_TIMETABLED_SPEED :Travel (not timetabled) with at most {2:VELOCITY}
STR_TIMETABLE_TRAVEL_FOR :Travel for {STRING1}
STR_TIMETABLE_TRAVEL_FOR_SPEED :Travel for {STRING1} with at most {VELOCITY}
STR_TIMETABLE_TRAVEL_FOR_ESTIMATED :Travel (for {STRING1}, not timetabled)
STR_TIMETABLE_TRAVEL_FOR_SPEED_ESTIMATED :Travel (for {STRING1}, not timetabled) with at most {VELOCITY}
STR_TIMETABLE_STAY_FOR_ESTIMATED :(stay for {STRING1}, not timetabled)
STR_TIMETABLE_AND_TRAVEL_FOR_ESTIMATED :(travel for {STRING1}, not timetabled)
STR_TIMETABLE_STAY_FOR :and stay for {STRING1}
STR_TIMETABLE_AND_TRAVEL_FOR :and travel for {STRING1}
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_DAYS :{COMMA}{NBSP}day{P "" s}
STR_TIMETABLE_TICKS :{COMMA}{NBSP}tick{P "" s}
STR_TIMETABLE_MINUTES :{COMMA}{NBSP}minute{P "" s}
STR_TIMETABLE_TOTAL_TIME :{BLACK}This timetable will take {STRING1} to complete
STR_TIMETABLE_TOTAL_TIME_INCOMPLETE :{BLACK}This timetable will take at least {STRING1} to complete (not all timetabled)
STR_TIMETABLE_LEFTOVER_TICKS :{STRING1} + {COMMA} tick{P "" s}
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_ON_TIME :{BLACK}This vehicle is currently running on time
STR_TIMETABLE_STATUS_LATE :{BLACK}This vehicle is currently running {STRING1} late
STR_TIMETABLE_STATUS_EARLY :{BLACK}This vehicle is currently running {STRING1} early
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_TIMETABLE_STATUS_NOT_STARTED :{BLACK}This timetable has not yet started
STR_TIMETABLE_STATUS_START_AT :{BLACK}This timetable will start at {STRING1}

@ -263,12 +263,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(5, STR_EMPTY);
SetDParam(8, 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 != NULL ? order->next : v->GetFirstOrder();
if (GetOrderDistance(order, next, v) > Aircraft::From(v)->acache.cached_max_range_sqr) SetDParam(8, 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);
}
switch (order->GetType()) {
@ -297,7 +297,7 @@ void DrawOrderString(const Vehicle *v, const Order *order, int order_index, int
if (order->GetWaitTime() > 0) {
SetDParam(5, order->IsWaitTimetabled() ? STR_TIMETABLE_STAY_FOR : STR_TIMETABLE_STAY_FOR_ESTIMATED);
SetTimetableParams(6, 7, order->GetWaitTime());
SetTimetableParams(6, order->GetWaitTime());
}
} else {
SetDParam(3, (order->GetNonStopType() & ONSF_NO_STOP_AT_DESTINATION_STATION) ? STR_EMPTY : _station_load_types[order->IsRefit()][unload][load]);
@ -345,7 +345,7 @@ void DrawOrderString(const Vehicle *v, const Order *order, int order_index, int
if (timetable) {
if (order->GetWaitTime() > 0) {
SetDParam(5, order->IsWaitTimetabled() ? STR_TIMETABLE_STAY_FOR : STR_TIMETABLE_STAY_FOR_ESTIMATED);
SetTimetableParams(6, 7, order->GetWaitTime());
SetTimetableParams(6, order->GetWaitTime());
}
}
break;
@ -402,7 +402,7 @@ void DrawOrderString(const Vehicle *v, const Order *order, int order_index, int
if (timetable && order->GetWaitTime() > 0) {
SetDParam(5, order->IsWaitTimetabled() ? STR_TIMETABLE_AND_TRAVEL_FOR : STR_TIMETABLE_AND_TRAVEL_FOR_ESTIMATED);
SetTimetableParams(6, 7, order->GetWaitTime());
SetTimetableParams(6, order->GetWaitTime());
} else {
SetDParam(5, STR_EMPTY);
}

@ -1589,6 +1589,7 @@ static SettingsContainer &GetSettingsTree()
interface->Add(new SettingEntry("gui.prefer_teamchat"));
interface->Add(new SettingEntry("gui.advanced_vehicle_list"));
interface->Add(new SettingEntry("gui.timetable_in_ticks"));
interface->Add(new SettingEntry("gui.timetable_leftover_ticks"));
interface->Add(new SettingEntry("gui.timetable_arrival_departure"));
interface->Add(new SettingEntry("gui.expenses_layout"));
interface->Add(new SettingEntry("gui.show_train_length_in_details"));

@ -143,6 +143,7 @@ struct GUISettings {
bool enable_signal_gui; ///< show the signal GUI when the signal button is pressed
Year coloured_news_year; ///< when does newspaper become coloured?
bool timetable_in_ticks; ///< whether to show the timetable in ticks rather than days
bool timetable_leftover_ticks; ///< whether to show leftover ticks after converting to minutes/days, in the timetable
bool time_in_minutes; ///< whether to use the hh:mm conversion when printing dates
bool timetable_start_text_entry; ///< whether to enter timetable start times as text (hhmm format)
uint8 ticks_per_minute; ///< how many ticks per minute

@ -3404,6 +3404,15 @@ strhelp = STR_CONFIG_SETTING_TIMETABLE_IN_TICKS_HELPTEXT
proc = InvalidateVehTimetableWindow
cat = SC_EXPERT
[SDTC_BOOL]
var = gui.timetable_leftover_ticks
flags = SLF_NOT_IN_SAVE | SLF_NO_NETWORK_SYNC
def = false
str = STR_CONFIG_SETTING_TIMETABLE_LEFTOVER_TICKS
strhelp = STR_CONFIG_SETTING_TIMETABLE_LEFTOVER_TICKS_HELPTEXT
proc = InvalidateVehTimetableWindow
cat = SC_EXPERT
[SDTC_BOOL]
var = gui.time_in_minutes
flags = SLF_NOT_IN_SAVE | SLF_NO_NETWORK_SYNC

@ -17,6 +17,6 @@
void ShowTimetableWindow(const Vehicle *v);
void UpdateVehicleTimetable(Vehicle *v, bool travelling);
void SetTimetableParams(int param1, int param2, Ticks ticks);
void SetTimetableParams(int first_param, Ticks ticks);
#endif /* TIMETABLE_H */

@ -41,21 +41,28 @@ struct TimetableArrivalDeparture {
/**
* Set the timetable parameters in the format as described by the setting.
* @param param1 the first DParam to fill
* @param param2 the second DParam to fill
* @param param the first DParam to fill
* @param ticks the number of ticks to 'draw'
*/
void SetTimetableParams(int param1, int param2, Ticks ticks)
void SetTimetableParams(int first_param, Ticks ticks)
{
if (_settings_client.gui.timetable_in_ticks) {
SetDParam(param2, ticks);
SetDParam(param1, STR_TIMETABLE_TICKS);
} else if (_settings_client.gui.time_in_minutes) {
SetDParam(param2, ticks / DATE_UNIT_SIZE);
SetDParam(param1, STR_TIMETABLE_MINUTES);
SetDParam(first_param, STR_TIMETABLE_TICKS);
SetDParam(first_param + 1, ticks);
} else {
SetDParam(param2, ticks / DATE_UNIT_SIZE);
SetDParam(param1, STR_TIMETABLE_DAYS);
StringID str = _settings_client.gui.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 (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);
}
}
}
@ -425,7 +432,7 @@ struct TimetableWindow : Window {
colour = ((i == selected) ? TC_SILVER : TC_GREY) | TC_NO_SHADE;
} else if (!order->IsTravelTimetabled()) {
if (order->GetTravelTime() > 0) {
SetTimetableParams(0, 1, order->GetTravelTime());
SetTimetableParams(0, order->GetTravelTime());
string = order->GetMaxSpeed() != UINT16_MAX ?
STR_TIMETABLE_TRAVEL_FOR_SPEED_ESTIMATED :
STR_TIMETABLE_TRAVEL_FOR_ESTIMATED;
@ -435,11 +442,11 @@ struct TimetableWindow : Window {
STR_TIMETABLE_TRAVEL_NOT_TIMETABLED;
}
} else {
SetTimetableParams(0, 1, order->GetTimetabledTravel());
SetTimetableParams(0, order->GetTimetabledTravel());
string = order->GetMaxSpeed() != UINT16_MAX ?
STR_TIMETABLE_TRAVEL_FOR_SPEED : STR_TIMETABLE_TRAVEL_FOR;
}
SetDParam(2, order->GetMaxSpeed());
SetDParam(string == STR_TIMETABLE_TRAVEL_NOT_TIMETABLED_SPEED ? 2 : 4, order->GetMaxSpeed());
DrawString(rtl ? r.left + WD_FRAMERECT_LEFT : middle, rtl ? middle : r.right - WD_FRAMERECT_LEFT, y, string, colour);
@ -510,7 +517,7 @@ struct TimetableWindow : Window {
Ticks total_time = v->orders.list != NULL ? v->orders.list->GetTimetableDurationIncomplete() : 0;
if (total_time != 0) {
SetTimetableParams(0, 1, total_time);
SetTimetableParams(0, total_time);
DrawString(r.left + WD_FRAMERECT_LEFT, r.right - WD_FRAMERECT_RIGHT, y, v->orders.list->IsCompleteTimetable() ? STR_TIMETABLE_TOTAL_TIME : STR_TIMETABLE_TOTAL_TIME_INCOMPLETE);
}
y += FONT_HEIGHT_NORMAL;
@ -528,7 +535,7 @@ struct TimetableWindow : Window {
} else if (v->lateness_counter == 0 || (!_settings_client.gui.timetable_in_ticks && v->lateness_counter / DATE_UNIT_SIZE == 0)) {
DrawString(r.left + WD_FRAMERECT_LEFT, r.right - WD_FRAMERECT_RIGHT, y, STR_TIMETABLE_STATUS_ON_TIME);
} else {
SetTimetableParams(0, 1, abs(v->lateness_counter));
SetTimetableParams(0, abs(v->lateness_counter));
DrawString(r.left + WD_FRAMERECT_LEFT, r.right - WD_FRAMERECT_RIGHT, y, v->lateness_counter < 0 ? STR_TIMETABLE_STATUS_EARLY : STR_TIMETABLE_STATUS_LATE);
}
break;

Loading…
Cancel
Save