| 464 | } |
| 465 | |
| 466 | std::unique_ptr<NWidgetBase> MakeCargoesLegendLinkGraphGUI() |
| 467 | { |
| 468 | uint num_cargo = static_cast<uint>(_sorted_cargo_specs.size()); |
| 469 | static const uint ENTRIES_PER_COL = 5; |
| 470 | auto panel = std::make_unique<NWidgetHorizontal>(NWidContainerFlag::EqualSize); |
| 471 | std::unique_ptr<NWidgetVertical> col = nullptr; |
| 472 | |
| 473 | for (uint i = 0; i < num_cargo; ++i) { |
| 474 | if (i % ENTRIES_PER_COL == 0) { |
| 475 | if (col != nullptr) panel->Add(std::move(col)); |
| 476 | col = std::make_unique<NWidgetVertical>(NWidContainerFlag::EqualSize); |
| 477 | } |
| 478 | auto wid = std::make_unique<NWidgetBackground>(WWT_PANEL, COLOUR_GREY, i + WID_LGL_CARGO_FIRST); |
| 479 | wid->SetMinimalSize(25, 0); |
| 480 | wid->SetMinimalTextLines(1, 0, FS_SMALL); |
| 481 | wid->SetFill(1, 1); |
| 482 | wid->SetResize(0, 0); |
| 483 | col->Add(std::move(wid)); |
| 484 | } |
| 485 | /* Fill up last row */ |
| 486 | for (uint i = num_cargo; i < Ceil(num_cargo, ENTRIES_PER_COL); ++i) { |
| 487 | auto spc = std::make_unique<NWidgetSpacer>(25, 0); |
| 488 | spc->SetMinimalTextLines(1, 0, FS_SMALL); |
| 489 | spc->SetFill(1, 1); |
| 490 | spc->SetResize(0, 0); |
| 491 | col->Add(std::move(spc)); |
| 492 | } |
| 493 | /* If there are no cargo specs defined, then col won't have been created so don't add it. */ |
| 494 | if (col != nullptr) panel->Add(std::move(col)); |
| 495 | return panel; |
| 496 | } |
| 497 | |
| 498 | |
| 499 | static constexpr std::initializer_list<NWidgetPart> _nested_linkgraph_legend_widgets = { |
nothing calls this directly
no test coverage detected