55 sel += w->vscroll.pos; |
56 sel += w->vscroll.pos; |
56 |
57 |
57 return (sel <= v->num_orders * 2 && sel >= 0) ? sel : INVALID_ORDER; |
58 return (sel <= v->num_orders * 2 && sel >= 0) ? sel : INVALID_ORDER; |
58 } |
59 } |
59 |
60 |
60 static inline void SetTimetableParams(int param1, int param2, uint32 time) |
61 void SetTimetableParams(int param1, int param2, uint32 time) |
61 { |
62 { |
62 if (_patches.timetable_in_ticks) { |
63 if (_patches.timetable_in_ticks) { |
63 SetDParam(param1, STR_TIMETABLE_TICKS); |
64 SetDParam(param1, STR_TIMETABLE_TICKS); |
64 SetDParam(param2, time); |
65 SetDParam(param2, time); |
65 } else { |
66 } else { |
114 while (order != NULL) { |
115 while (order != NULL) { |
115 /* Don't draw anything if it extends past the end of the window. */ |
116 /* Don't draw anything if it extends past the end of the window. */ |
116 if (i - w->vscroll.pos >= w->vscroll.cap) break; |
117 if (i - w->vscroll.pos >= w->vscroll.cap) break; |
117 |
118 |
118 if (i % 2 == 0) { |
119 if (i % 2 == 0) { |
119 SetDParam(5, STR_EMPTY); |
120 DrawOrderString(v, order, order_id, y, i == selected, true); |
120 |
|
121 switch (order->GetType()) { |
|
122 case OT_DUMMY: |
|
123 SetDParam(0, STR_INVALID_ORDER); |
|
124 break; |
|
125 |
|
126 case OT_GOTO_STATION: |
|
127 SetDParam(0, STR_GO_TO_STATION); |
|
128 SetDParam(1, STR_ORDER_GO_TO + order->GetNonStopType()); |
|
129 SetDParam(2, order->GetDestination()); |
|
130 SetDParam(3, STR_EMPTY); |
|
131 |
|
132 if (order->wait_time > 0) { |
|
133 SetDParam(5, STR_TIMETABLE_STAY_FOR); |
|
134 SetTimetableParams(6, 7, order->wait_time); |
|
135 } else { |
|
136 SetDParam(4, STR_EMPTY); |
|
137 } |
|
138 |
|
139 break; |
|
140 |
|
141 case OT_GOTO_DEPOT: |
|
142 SetDParam(4, STR_EMPTY); |
|
143 if (v->type == VEH_AIRCRAFT) { |
|
144 if (order->GetDepotActionType() & ODATFB_NEAREST_DEPOT) { |
|
145 SetDParam(0, STR_GO_TO_NEAREST_DEPOT); |
|
146 SetDParam(2, STR_ORDER_NEAREST_HANGAR); |
|
147 } else { |
|
148 SetDParam(0, STR_GO_TO_HANGAR); |
|
149 SetDParam(2, order->GetDestination()); |
|
150 } |
|
151 SetDParam(3, STR_EMPTY); |
|
152 } else { |
|
153 if (order->GetDepotActionType() & ODATFB_NEAREST_DEPOT) { |
|
154 SetDParam(0, STR_GO_TO_NEAREST_DEPOT); |
|
155 SetDParam(2, STR_ORDER_NEAREST_DEPOT); |
|
156 } else { |
|
157 SetDParam(0, STR_GO_TO_DEPOT); |
|
158 SetDParam(2, GetDepot(order->GetDestination())->town_index); |
|
159 } |
|
160 |
|
161 switch (v->type) { |
|
162 case VEH_TRAIN: SetDParam(3, STR_ORDER_TRAIN_DEPOT); break; |
|
163 case VEH_ROAD: SetDParam(3, STR_ORDER_ROAD_DEPOT); break; |
|
164 case VEH_SHIP: SetDParam(3, STR_ORDER_SHIP_DEPOT); break; |
|
165 default: NOT_REACHED(); |
|
166 } |
|
167 } |
|
168 |
|
169 if (order->GetDepotOrderType() & ODTFB_SERVICE) { |
|
170 SetDParam(1, (order->GetNonStopType() & ONSF_NO_STOP_AT_INTERMEDIATE_STATIONS) ? STR_ORDER_SERVICE_NON_STOP_AT : STR_ORDER_SERVICE_AT); |
|
171 } else { |
|
172 SetDParam(1, (order->GetNonStopType() & ONSF_NO_STOP_AT_INTERMEDIATE_STATIONS) ? STR_ORDER_GO_NON_STOP_TO : STR_ORDER_GO_TO); |
|
173 } |
|
174 break; |
|
175 |
|
176 case OT_GOTO_WAYPOINT: |
|
177 SetDParam(0, (order->GetNonStopType() != ONSF_STOP_EVERYWHERE) ? STR_GO_NON_STOP_TO_WAYPOINT : STR_GO_TO_WAYPOINT); |
|
178 SetDParam(1, order->GetDestination()); |
|
179 break; |
|
180 |
|
181 |
|
182 case OT_CONDITIONAL: |
|
183 SetDParam(1, order->GetConditionSkipToOrder() + 1); |
|
184 if (order->GetConditionVariable() == OCV_UNCONDITIONALLY) { |
|
185 SetDParam(0, STR_CONDITIONAL_UNCONDITIONAL); |
|
186 } else { |
|
187 extern uint ConvertSpeedToDisplaySpeed(uint speed); |
|
188 OrderConditionComparator occ = order->GetConditionComparator(); |
|
189 SetDParam(0, (occ == OCC_IS_TRUE || occ == OCC_IS_FALSE) ? STR_CONDITIONAL_TRUE_FALSE : STR_CONDITIONAL_NUM); |
|
190 SetDParam(2, STR_ORDER_CONDITIONAL_LOAD_PERCENTAGE + order->GetConditionVariable()); |
|
191 SetDParam(3, STR_ORDER_CONDITIONAL_COMPARATOR_EQUALS + occ); |
|
192 |
|
193 uint value = order->GetConditionValue(); |
|
194 if (order->GetConditionVariable() == OCV_MAX_SPEED) value = ConvertSpeedToDisplaySpeed(value); |
|
195 SetDParam(4, value); |
|
196 } |
|
197 break; |
|
198 |
|
199 default: break; |
|
200 } |
|
201 |
|
202 DrawString(2, y, STR_TIMETABLE_GO_TO, (i == selected) ? TC_WHITE : TC_BLACK); |
|
203 |
121 |
204 order_id++; |
122 order_id++; |
205 |
123 |
206 if (order_id >= v->num_orders) { |
124 if (order_id >= v->num_orders) { |
207 order = GetVehicleOrder(v, 0); |
125 order = GetVehicleOrder(v, 0); |