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

Function drawScroll

src/OpenLoco/src/Ui/Windows/PromptBrowseWindow.cpp:637–690  ·  view source on GitHub ↗

0x00446314

Source from the content-addressed store, hash-verified

635
636 // 0x00446314
637 static void drawScroll(Ui::Window& window, Gfx::DrawingContext& drawingCtx, [[maybe_unused]] const uint32_t scrollIndex)
638 {
639 const auto& rt = drawingCtx.currentRenderTarget();
640 auto tr = Gfx::TextRenderer(drawingCtx);
641
642 // Background
643 drawingCtx.clearSingle(Colours::getShade(window.getColour(WindowColour::secondary).c(), 4));
644
645 // Directories / files
646 auto i = 0;
647 auto y = 0;
648 auto lineHeight = window.rowHeight;
649 for (const auto& entry : _files)
650 {
651 if (y + lineHeight < rt.y)
652 {
653 y += lineHeight;
654 i++;
655 continue;
656 }
657 else if (y > rt.y + rt.height)
658 {
659 break;
660 }
661
662 // Draw the row highlight
663 auto stringId = StringIds::black_stringid;
664 if (i == window.var_85A)
665 {
666 drawingCtx.drawRect(0, y, window.width, lineHeight, enumValue(ExtColour::unk30), Gfx::RectFlags::transparent);
667 stringId = StringIds::wcolour2_stringid;
668 }
669
670 // Draw the folder icon (TODO: draw a drive for rootPath)
671 auto x = 1;
672 if (isRootPath(entry) || fs::is_directory(entry))
673 {
674 drawingCtx.drawImage(x, y, ImageIds::icon_folder);
675 x += 14;
676 }
677
678 // Copy name to our work buffer (if drive letter use the full path)
679 auto nameBuffer = isRootPath(entry) ? entry.u8string() : entry.stem().u8string();
680 nameBuffer = Localisation::convertUnicodeToLoco(nameBuffer);
681
682 // Draw the name
683 auto args = getStringPtrFormatArgs(nameBuffer.c_str());
684 auto point = Point(x, y);
685 tr.drawStringLeft(point, Colour::black, stringId, args);
686
687 y += lineHeight;
688 i++;
689 }
690 }
691
692 // 0x0044685C
693 static bool keyUp(Window& w, uint32_t charCode, uint32_t keyCode)

Callers

nothing calls this directly

Calls 12

TextRendererClass · 0.85
getShadeFunction · 0.85
enumValueFunction · 0.85
isRootPathFunction · 0.85
convertUnicodeToLocoFunction · 0.85
getStringPtrFormatArgsFunction · 0.85
clearSingleMethod · 0.80
cMethod · 0.80
getColourMethod · 0.80
drawStringLeftMethod · 0.80
drawRectMethod · 0.45
drawImageMethod · 0.45

Tested by

no test coverage detected