MCPcopy Create free account
hub / github.com/OpenRCT2/OpenRCT2 / onDraw

Method onDraw

src/openrct2-ui/windows/TrackList.cpp:452–670  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

450 }
451
452 void onDraw(RenderTarget& rt) override
453 {
454 drawWidgets(rt);
455
456 int32_t listItemIndex = selectedListItem;
457 if ((gLegacyScene == LegacyScene::trackDesignsManager) == 0)
458 {
459 // Because the first item in the list is "Build a custom design", lower the index by one
460 listItemIndex--;
461 }
462
463 if (_filteredTrackIds.empty() || listItemIndex == -1)
464 return;
465
466 int32_t trackIndex = _filteredTrackIds[listItemIndex];
467
468 // Track preview
469 auto& tdWidget = widgets[WIDX_TRACK_PREVIEW];
470 auto colour = getColourMap(colours[0].colour).darkest;
471 u8string path = _trackDesigns[trackIndex].path;
472
473 // Show track file path (in debug mode)
474 if (Config::Get().general.debuggingTools)
475 {
476 const auto shortPath = shortenPath(path, width, FontStyle::medium);
477 drawText(
478 rt, windowPos + ScreenCoordsXY{ 0, height - kDebugPathHeight - 3 }, shortPath,
479 { colours[1] }); // TODO Check dpi
480 }
481
482 auto screenPos = windowPos + ScreenCoordsXY{ tdWidget.left + 1, tdWidget.top + 1 };
483 Rectangle::fill(rt, { screenPos, screenPos + ScreenCoordsXY{ 369, 216 } }, colour); // TODO Check dpi
484
485 if (_loadedTrackDesignIndex != trackIndex)
486 {
487 if (loadDesignPreview(path))
488 {
489 _loadedTrackDesignIndex = trackIndex;
490 }
491 else
492 {
493 _loadedTrackDesignIndex = kTrackDesignIndexUnloaded;
494 }
495 }
496
497 if (!_loadedTrackDesign)
498 {
499 return;
500 }
501
502 auto trackPreview = screenPos;
503 screenPos = windowPos + ScreenCoordsXY{ tdWidget.midX(), tdWidget.midY() };
504
505 G1Element g1temp = {};
506 g1temp.offset = reinterpret_cast<uint8_t*>(
507 _trackDesignPreviewPixels.data() + (_currentTrackPieceDirection * kTrackPreviewImageSize));
508 g1temp.width = 370;
509 g1temp.height = 217;

Callers

nothing calls this directly

Calls 15

getColourMapFunction · 0.85
shortenPathFunction · 0.85
drawTextFunction · 0.85
fillFunction · 0.85
GfxSetG1ElementFunction · 0.85
GfxDrawSpriteFunction · 0.85
drawTextEllipsisedFunction · 0.85
ToHumanReadableSpeedFunction · 0.85
ToHumanReadableAirTimeFunction · 0.85
midXMethod · 0.80
midYMethod · 0.80

Tested by

no test coverage detected