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

Method onDraw

src/openrct2-ui/windows/LoadSave.cpp:738–797  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

736 }
737
738 void onDraw(RenderTarget& rt) override
739 {
740 drawWidgets(rt);
741
742 if (ShowPreviews())
743 DrawPreview(rt);
744
745 {
746 const auto& widget = widgets[WIDX_PARENT_FOLDER];
747 const auto pathWidth = widget.left - 8;
748 const auto shortPath = shortenPath(_directory, pathWidth, FontStyle::medium);
749
750 // Format text
751 std::string buffer;
752 buffer.assign("{BLACK}");
753 buffer += shortPath;
754
755 // Draw path text
756 const auto normalisedPath = Platform::StrDecompToPrecomp(buffer.data());
757 auto pathPos = windowPos + ScreenCoordsXY{ 4, widget.top + 4 };
758 drawTextEllipsised(rt, pathPos, pathWidth, normalisedPath);
759 }
760
761 const auto drawButtonCaption =
762 [rt, this](Widget& widget, StringId strId, FileBrowserSort ascSort, FileBrowserSort descSort) {
763 StringId indicatorId = kStringIdNone;
764 if (Config::Get().general.loadSaveSort == ascSort)
765 indicatorId = STR_UP;
766 else if (Config::Get().general.loadSaveSort == descSort)
767 indicatorId = STR_DOWN;
768
769 auto ft = Formatter();
770 ft.Add<StringId>(indicatorId);
771
772 auto cRT = const_cast<const RenderTarget&>(rt);
773 drawTextEllipsised(
774 cRT, windowPos + ScreenCoordsXY{ widget.left + 5, widget.top + 1 }, widget.width() - 1, strId, ft,
775 { Drawing::Colour::grey });
776 };
777
778 auto& config = Config::Get().general;
779 drawButtonCaption(
780 widgets[WIDX_SORT_NAME], STR_NAME_COLUMN, FileBrowserSort::nameAscending, FileBrowserSort::nameDescending);
781
782 if (config.fileBrowserShowSizeColumn)
783 drawButtonCaption(
784 widgets[WIDX_SORT_SIZE], STR_FILEBROWSER_SIZE_COLUMN, FileBrowserSort::sizeAscending,
785 FileBrowserSort::sizeDescending);
786
787 if (config.fileBrowserShowDateColumn)
788 drawButtonCaption(
789 widgets[WIDX_SORT_DATE], STR_DATE_COLUMN, FileBrowserSort::dateAscending, FileBrowserSort::dateDescending);
790
791 // 'Filename:' label
792 if (action == LoadSaveAction::save)
793 {
794 auto& widget = widgets[WIDX_FILENAME_TEXTBOX];
795 drawText(rt, windowPos + ScreenCoordsXY{ 5, widget.top + 2 }, STR_FILENAME_LABEL, { Drawing::Colour::grey });

Callers

nothing calls this directly

Calls 7

shortenPathFunction · 0.85
drawTextEllipsisedFunction · 0.85
drawTextFunction · 0.85
widthMethod · 0.80
FormatterClass · 0.70
StrDecompToPrecompFunction · 0.50
dataMethod · 0.45

Tested by

no test coverage detected