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);
 
  213   int GetOrderFromTimetableWndPt(
int y, 
const Vehicle *v)
 
  221     return (sel < v->GetNumOrders() * 2 && sel >= 0) ? sel : 
INVALID_ORDER;
 
  239         if (this->sel_index == -1) 
break;
 
  242         this->sel_index = -1;
 
  246         if (!gui_scope) 
break;
 
  252         if (gui_scope) 
break; 
 
  256         if (this->sel_index == -1) 
break;
 
  261         if (from == to) 
break; 
 
  267         if (selected_order == old_num_orders) selected_order = 0; 
 
  269         bool travel = 
HasBit(this->sel_index, 0);
 
  271         if (from != selected_order) {
 
  273           selected_order -= (int)(from <= selected_order);
 
  275           selected_order += (int)(to   <= selected_order);
 
  281             this->sel_index = -1;
 
  290         this->sel_index = 2 * selected_order - (int)travel;
 
  302     int selected = this->sel_index;
 
  308       if (selected != -1) {
 
  310         if (selected % 2 == 1) {
 
  311           disable = order != NULL && (order->
IsType(OT_CONDITIONAL) || order->
IsType(OT_IMPLICIT));
 
  316       bool disable_speed = disable || selected % 2 != 1 || v->
type == 
VEH_AIRCRAFT;
 
  354     int selected = this->sel_index;
 
  361         bool final_order = 
false;
 
  369         while (order != NULL) {
 
  386             TextColour colour = (i == selected) ? TC_WHITE : TC_BLACK;
 
  387             if (order->
IsType(OT_CONDITIONAL)) {
 
  388               string = STR_TIMETABLE_NO_TRAVEL;
 
  389             } 
else if (order->
IsType(OT_IMPLICIT)) {
 
  390               string = STR_TIMETABLE_NOT_TIMETABLEABLE;
 
  391               colour = ((i == selected) ? TC_SILVER : TC_GREY) | 
TC_NO_SHADE;
 
  396                     STR_TIMETABLE_TRAVEL_FOR_SPEED_ESTIMATED  :
 
  397                     STR_TIMETABLE_TRAVEL_FOR_ESTIMATED;
 
  400                     STR_TIMETABLE_TRAVEL_NOT_TIMETABLED_SPEED :
 
  401                     STR_TIMETABLE_TRAVEL_NOT_TIMETABLED;
 
  406                   STR_TIMETABLE_TRAVEL_FOR_SPEED : STR_TIMETABLE_TRAVEL_FOR;
 
  412             if (final_order) 
break;
 
  451               DrawString(abbr_left, abbr_right, y, STR_TIMETABLE_ARRIVAL_ABBREVIATION, i == selected ? TC_WHITE : TC_BLACK);
 
  454                 DrawString(time_left, time_right, y, STR_JUST_DATE_TINY, TC_GREEN);
 
  457                 DrawString(time_left, time_right, y, STR_JUST_DATE_TINY,
 
  458                     show_late ? TC_RED : i == selected ? TC_WHITE : TC_BLACK);
 
  463               DrawString(abbr_left, abbr_right, y, STR_TIMETABLE_DEPARTURE_ABBREVIATION, i == selected ? TC_WHITE : TC_BLACK);
 
  465               DrawString(time_left, time_right, y, STR_JUST_DATE_TINY,
 
  466                   show_late ? TC_RED : i == selected ? TC_WHITE : TC_BLACK);
 
  478         if (total_time != 0) {
 
  505   static inline uint32 PackTimetableArgs(
const Vehicle *v, uint selected, 
bool speed)
 
  507     uint order_number = (selected + 1) / 2;
 
  510     if (order_number >= v->
GetNumOrders()) order_number = 0;
 
  512     return v->
index | (order_number << 20) | (mtf << 28);
 
  525         int selected = GetOrderFromTimetableWndPt(pt.y, v);
 
  528         this->sel_index = (selected == 
INVALID_ORDER || selected == this->sel_index) ? -1 : selected;
 
  537         int selected = this->sel_index;
 
  551             current = STR_JUST_INT;
 
  561         int selected = this->sel_index;
 
  571             current = STR_JUST_INT;
 
  581         uint32 p1 = PackTimetableArgs(v, this->sel_index, 
false);
 
  587         uint32 p1 = PackTimetableArgs(v, this->sel_index, 
true);
 
  609         ShowVehicleListWindow(v);
 
  618     if (str == NULL) 
return;
 
  624     uint64 val = 
StrEmpty(str) ? 0 : strtoul(str, NULL, 10);
 
  631     uint32 p2 = 
minu(val, UINT16_MAX);
 
  652 static const NWidgetPart _nested_timetable_widgets[] = {
 
  662     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(),
 
  664       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(),
 
  699   WDP_AUTO, 
"view_vehicle_timetable", 400, 130,
 
  702   _nested_timetable_widgets, 
lengthof(_nested_timetable_widgets)
 
  713   AllocateWindowDescFront<TimetableWindow>(&_timetable_desc, v->
index);