31 #include "table/strings.h"
67 if (order->
IsType(OT_CONDITIONAL) || order->
IsType(OT_IMPLICIT))
return false;
90 assert(table != NULL);
92 assert(start < v->GetNumOrders());
109 if (!order->
IsType(OT_IMPLICIT)) {
110 if (travelling || i != start) {
125 assert(order == NULL);
128 }
while (i != start);
214 int GetOrderFromTimetableWndPt(
int y,
const Vehicle *v)
222 return (sel < v->GetNumOrders() * 2 && sel >= 0) ? sel :
INVALID_ORDER;
240 if (this->sel_index == -1)
break;
243 this->sel_index = -1;
247 if (!gui_scope)
break;
253 if (gui_scope)
break;
257 if (this->sel_index == -1)
break;
262 if (from == to)
break;
268 if (selected_order == old_num_orders) selected_order = 0;
270 bool travel =
HasBit(this->sel_index, 0);
272 if (from != selected_order) {
274 selected_order -= (int)(from <= selected_order);
276 selected_order += (int)(to <= selected_order);
282 this->sel_index = -1;
291 this->sel_index = 2 * selected_order - (int)travel;
303 int selected = this->sel_index;
309 if (selected != -1) {
311 if (selected % 2 == 1) {
312 disable = order != NULL && (order->
IsType(OT_CONDITIONAL) || order->
IsType(OT_IMPLICIT));
317 bool disable_speed = disable || selected % 2 != 1 || v->
type ==
VEH_AIRCRAFT;
355 int selected = this->sel_index;
362 bool final_order =
false;
370 while (order != NULL) {
387 TextColour colour = (i == selected) ? TC_WHITE : TC_BLACK;
388 if (order->
IsType(OT_CONDITIONAL)) {
389 string = STR_TIMETABLE_NO_TRAVEL;
390 }
else if (order->
IsType(OT_IMPLICIT)) {
391 string = STR_TIMETABLE_NOT_TIMETABLEABLE;
392 colour = ((i == selected) ? TC_SILVER : TC_GREY) |
TC_NO_SHADE;
397 STR_TIMETABLE_TRAVEL_FOR_SPEED_ESTIMATED :
398 STR_TIMETABLE_TRAVEL_FOR_ESTIMATED;
401 STR_TIMETABLE_TRAVEL_NOT_TIMETABLED_SPEED :
402 STR_TIMETABLE_TRAVEL_NOT_TIMETABLED;
407 STR_TIMETABLE_TRAVEL_FOR_SPEED : STR_TIMETABLE_TRAVEL_FOR;
413 if (final_order)
break;
452 DrawString(abbr_left, abbr_right, y, STR_TIMETABLE_ARRIVAL_ABBREVIATION, i == selected ? TC_WHITE : TC_BLACK);
455 DrawString(time_left, time_right, y, STR_JUST_DATE_TINY, TC_GREEN);
458 DrawString(time_left, time_right, y, STR_JUST_DATE_TINY,
459 show_late ? TC_RED : i == selected ? TC_WHITE : TC_BLACK);
464 DrawString(abbr_left, abbr_right, y, STR_TIMETABLE_DEPARTURE_ABBREVIATION, i == selected ? TC_WHITE : TC_BLACK);
466 DrawString(time_left, time_right, y, STR_JUST_DATE_TINY,
467 show_late ? TC_RED : i == selected ? TC_WHITE : TC_BLACK);
479 if (total_time != 0) {
506 static inline uint32 PackTimetableArgs(
const Vehicle *v, uint selected,
bool speed)
508 uint order_number = (selected + 1) / 2;
511 if (order_number >= v->
GetNumOrders()) order_number = 0;
513 return v->
index | (order_number << 20) | (mtf << 28);
526 int selected = GetOrderFromTimetableWndPt(pt.y, v);
529 this->sel_index = (selected ==
INVALID_ORDER || selected == this->sel_index) ? -1 : selected;
538 int selected = this->sel_index;
552 current = STR_JUST_INT;
562 int selected = this->sel_index;
572 current = STR_JUST_INT;
582 uint32 p1 = PackTimetableArgs(v, this->sel_index,
false);
588 uint32 p1 = PackTimetableArgs(v, this->sel_index,
true);
610 ShowVehicleListWindow(v);
619 if (str == NULL)
return;
625 uint64 val =
StrEmpty(str) ? 0 : strtoul(str, NULL, 10);
632 uint32 p2 =
minu(val, UINT16_MAX);
653 static const NWidgetPart _nested_timetable_widgets[] = {
663 NWidget(
WWT_PANEL, COLOUR_GREY,
WID_VT_TIMETABLE_PANEL),
SetMinimalSize(388, 82),
SetResize(1, 10),
SetDataTip(STR_NULL, STR_TIMETABLE_TOOLTIP),
SetScrollbar(
WID_VT_SCROLLBAR),
EndContainer(),
665 NWidget(
WWT_PANEL, COLOUR_GREY,
WID_VT_ARRIVAL_DEPARTURE_PANEL),
SetMinimalSize(110, 0),
SetFill(0, 1),
SetDataTip(STR_NULL, STR_TIMETABLE_TOOLTIP),
SetScrollbar(
WID_VT_SCROLLBAR),
EndContainer(),
700 WDP_AUTO,
"view_vehicle_timetable", 400, 130,
703 _nested_timetable_widgets,
lengthof(_nested_timetable_widgets)
714 AllocateWindowDescFront<TimetableWindow>(&_timetable_desc, v->
index);