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

Method DrawSummaryPanel

src/timetable_gui.cpp:552–585  ·  view source on GitHub ↗

* Helper function to draw the summary panel. * @param r The rect to draw within. */

Source from the content-addressed store, hash-verified

550 * @param r The rect to draw within.
551 */
552 void DrawSummaryPanel(const Rect &r) const
553 {
554 const Vehicle *v = this->vehicle;
555 Rect tr = r.Shrink(WidgetDimensions::scaled.framerect);
556
557 TimerGameTick::Ticks total_time = v->orders != nullptr ? v->orders->GetTimetableDurationIncomplete() : 0;
558 if (total_time != 0) {
559 DrawString(tr, GetTimetableTotalTimeString(total_time));
560 }
561 tr.top += GetCharacterHeight(FS_NORMAL);
562
563 /* Draw the lateness display, or indicate that the timetable has not started yet. */
564 if (v->timetable_start != 0) {
565 /* We are running towards the first station so we can start the
566 * timetable at the given time. */
567 if (_settings_client.gui.timetable_mode == TimetableMode::Seconds) {
568 /* Real time units use seconds relative to now. */
569 DrawString(tr, GetString(STR_TIMETABLE_STATUS_START_IN_SECONDS, static_cast<TimerGameTick::Ticks>(v->timetable_start - TimerGameTick::counter) / Ticks::TICKS_PER_SECOND));
570 } else {
571 /* Other units use dates. */
572 DrawString(tr, GetString(STR_TIMETABLE_STATUS_START_AT_DATE, STR_JUST_DATE_TINY, GetDateFromStartTick(v->timetable_start)));
573 }
574 } else if (!v->vehicle_flags.Test(VehicleFlag::TimetableStarted)) {
575 /* We aren't running on a timetable yet. */
576 DrawString(tr, STR_TIMETABLE_STATUS_NOT_STARTED);
577 } else if (!VehicleIsAboveLatenessThreshold(abs(v->lateness_counter), false)) {
578 /* We are on time. */
579 DrawString(tr, STR_TIMETABLE_STATUS_ON_TIME);
580 } else {
581 /* We are late. */
582 auto [str, value] = GetTimetableParameters(abs(v->lateness_counter));
583 DrawString(tr, GetString(v->lateness_counter < 0 ? STR_TIMETABLE_STATUS_EARLY : STR_TIMETABLE_STATUS_LATE, str, value));
584 }
585 }
586
587 void DrawWidget(const Rect &r, WidgetID widget) const override
588 {

Callers 1

DrawWidgetMethod · 0.95

Calls 10

GetCharacterHeightFunction · 0.85
GetDateFromStartTickFunction · 0.85
absFunction · 0.85
GetTimetableParametersFunction · 0.85
ShrinkMethod · 0.80
TestMethod · 0.80
DrawStringFunction · 0.70
GetStringFunction · 0.70

Tested by

no test coverage detected