MCPcopy Create free account
hub / github.com/OpenTTD/OpenTTD / GetTimetableTravelString

Method GetTimetableTravelString

src/timetable_gui.cpp:390–420  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

388 }
389
390 std::string GetTimetableTravelString(const Order &order, int i, TextColour &colour) const
391 {
392 colour = (i == this->sel_index) ? TC_WHITE : TC_BLACK;
393
394 if (order.IsType(OT_CONDITIONAL)) {
395 return GetString(STR_TIMETABLE_NO_TRAVEL);
396 }
397
398 if (order.IsType(OT_IMPLICIT)) {
399 colour = ((i == this->sel_index) ? TC_SILVER : TC_GREY) | TC_NO_SHADE;
400 return GetString(STR_TIMETABLE_NOT_TIMETABLEABLE);
401 }
402
403 if (order.IsTravelTimetabled()) {
404 auto [str, value] = GetTimetableParameters(order.GetTimetabledTravel());
405 return order.GetMaxSpeed() != UINT16_MAX
406 ? GetString(STR_TIMETABLE_TRAVEL_FOR_SPEED, str, value, PackVelocity(order.GetMaxSpeed(), this->vehicle->type))
407 : GetString(STR_TIMETABLE_TRAVEL_FOR, str, value);
408 }
409
410 if (order.GetTravelTime() > 0) {
411 auto [str, value] = GetTimetableParameters(order.GetTravelTime());
412 return order.GetMaxSpeed() != UINT16_MAX
413 ? GetString(STR_TIMETABLE_TRAVEL_FOR_SPEED_ESTIMATED, str, value, PackVelocity(order.GetMaxSpeed(), this->vehicle->type))
414 : GetString(STR_TIMETABLE_TRAVEL_FOR_ESTIMATED, str, value);
415 }
416
417 return order.GetMaxSpeed() != UINT16_MAX
418 ? GetString(STR_TIMETABLE_TRAVEL_NOT_TIMETABLED_SPEED, PackVelocity(order.GetMaxSpeed(), this->vehicle->type))
419 : GetString(STR_TIMETABLE_TRAVEL_NOT_TIMETABLED);
420 }
421
422 /**
423 * Helper function to draw the timetable panel.

Callers

nothing calls this directly

Calls 8

GetTimetableParametersFunction · 0.85
PackVelocityFunction · 0.85
IsTypeMethod · 0.80
IsTravelTimetabledMethod · 0.80
GetTimetabledTravelMethod · 0.80
GetTravelTimeMethod · 0.80
GetStringFunction · 0.70
GetMaxSpeedMethod · 0.45

Tested by

no test coverage detected