MCPcopy Create free account
hub / github.com/OpenLoco/OpenLoco / drawScroll

Function drawScroll

src/OpenLoco/src/Ui/Windows/VehicleList.cpp:579–688  ·  view source on GitHub ↗

0x004C21CD

Source from the content-addressed store, hash-verified

577
578 // 0x004C21CD
579 static void drawScroll(Window& self, Gfx::DrawingContext& drawingCtx, [[maybe_unused]] const uint32_t scrollIndex)
580 {
581 const auto& rt = drawingCtx.currentRenderTarget();
582
583 auto tr = Gfx::TextRenderer(drawingCtx);
584
585 auto shade = Colours::getShade(self.getColour(WindowColour::secondary).c(), 1);
586 drawingCtx.clearSingle(shade);
587
588 auto yPos = 0;
589 for (auto i = 0; i < self.rowCount; i++)
590 {
591 const auto vehicleId = EntityId(self.rowInfo[i]);
592
593 // Item not in rendering context, or no vehicle available for this slot?
594 if (yPos + self.rowHeight < rt.y || vehicleId == EntityId::null)
595 {
596 yPos += self.rowHeight;
597 continue;
598 }
599 else if (yPos >= rt.y + rt.height + self.rowHeight)
600 {
601 break;
602 }
603
604 auto head = EntityManager::get<VehicleHead>(vehicleId);
605 if (head == nullptr)
606 {
607 removeTrainFromList(self, vehicleId);
608 continue;
609 }
610
611 // Highlight selection.
612 if (head->id == EntityId(self.rowHover))
613 {
614 drawingCtx.drawRect(0, yPos, self.width, self.rowHeight, Colours::getShade(self.getColour(WindowColour::secondary).c(), 0), Gfx::RectFlags::none);
615 }
616
617 auto vehicle = Vehicles::Vehicle(*head);
618 // Draw vehicle at the bottom of the row.
619 drawTrainInline(drawingCtx, vehicle, Ui::Point(0, yPos + (self.rowHeight - 28) / 2 + 6));
620
621 // Draw vehicle status
622 auto& statusHeader = self.widgets[Widx::sort_name];
623 {
624 // Prepare status for drawing
625 auto status = head->getStatus();
626 auto args = FormatArguments::common();
627 args.push(head->name);
628 args.push(head->ordinalNumber);
629 args.push(status.status1);
630 args.push(status.status1Args);
631 args.push(status.status2);
632 args.push(status.status2Args);
633
634 StringId format = StringIds::vehicle_list_status_2pos;
635 if (status.status2 != StringIds::null)
636 {

Callers

nothing calls this directly

Calls 15

TextRendererClass · 0.85
getShadeFunction · 0.85
EntityIdEnum · 0.85
drawTrainInlineFunction · 0.85
commonFunction · 0.85
getCurrentDayFunction · 0.85
cMethod · 0.80
getColourMethod · 0.80
clearSingleMethod · 0.80
drawStringLeftClippedMethod · 0.80
outlineMethod · 0.80
totalRecentProfitMethod · 0.80

Tested by

no test coverage detected