| 550 | } |
| 551 | |
| 552 | void ModMenu::create_mod_list() { |
| 553 | ContextId context = get_current_context(); |
| 554 | |
| 555 | // Clear the contents of the list scroll. |
| 556 | list_scroll_container->clear_children(); |
| 557 | mod_entry_buttons.clear(); |
| 558 | mod_entry_spacers.clear(); |
| 559 | |
| 560 | Toggle* enable_toggle = mod_details_panel->get_enable_toggle(); |
| 561 | |
| 562 | // Create the child elements for the list scroll. |
| 563 | for (size_t mod_index = 0; mod_index < mod_details.size(); mod_index++) { |
| 564 | const std::vector<char> &thumbnail = recomp::mods::get_mod_thumbnail(mod_details[mod_index].mod_id); |
| 565 | std::string thumbnail_name = generate_thumbnail_src_for_mod(mod_details[mod_index].mod_id); |
| 566 | if (!thumbnail.empty()) { |
| 567 | recompui::queue_image_from_bytes_file(thumbnail_name, thumbnail); |
| 568 | loaded_thumbnails.emplace(thumbnail_name); |
| 569 | } |
| 570 | |
| 571 | ModEntrySpacer *spacer = context.create_element<ModEntrySpacer>(list_scroll_container); |
| 572 | mod_entry_spacers.emplace_back(spacer); |
| 573 | |
| 574 | ModEntryButton *mod_entry = context.create_element<ModEntryButton>(list_scroll_container, mod_index); |
| 575 | mod_entry->set_mod_selected_callback([this](uint32_t mod_index){ mod_selected(mod_index); }); |
| 576 | mod_entry->set_mod_drag_callback([this](uint32_t mod_index, recompui::EventDrag drag){ mod_dragged(mod_index, drag); }); |
| 577 | mod_entry->set_mod_details(mod_details[mod_index]); |
| 578 | mod_entry->set_mod_thumbnail(thumbnail_name); |
| 579 | mod_entry->set_mod_enabled(is_mod_enabled_or_auto(mod_details[mod_index].mod_id)); |
| 580 | mod_entry_buttons.emplace_back(mod_entry); |
| 581 | } |
| 582 | |
| 583 | if (!mod_entry_buttons.empty()) { |
| 584 | mod_entry_buttons.front()->set_nav_manual(NavDirection::Up, mod_tab_id); |
| 585 | mod_entry_buttons.back()->set_nav(NavDirection::Down, install_mods_button); |
| 586 | install_mods_button->set_nav(NavDirection::Up, mod_entry_buttons.back()); |
| 587 | } |
| 588 | else { |
| 589 | install_mods_button->set_nav_manual(NavDirection::Up, mod_tab_id); |
| 590 | } |
| 591 | |
| 592 | Rml::ElementTabSet* tabset = recompui::get_config_tabset(); |
| 593 | if (tabset && tabset->GetActiveTab() == recompui::config_tab_to_index(ConfigTab::Mods)) { |
| 594 | recompui::set_config_tabset_mod_nav(); |
| 595 | } |
| 596 | |
| 597 | // Add one extra spacer at the bottom. |
| 598 | ModEntrySpacer *spacer = context.create_element<ModEntrySpacer>(list_scroll_container); |
| 599 | mod_entry_spacers.emplace_back(spacer); |
| 600 | |
| 601 | mod_entry_middles.resize(mod_entry_buttons.size()); |
| 602 | |
| 603 | bool mods_available = !mod_details.empty(); |
| 604 | body_container->set_display(mods_available ? Display::Flex : Display::None); |
| 605 | body_empty_container->set_display(mods_available ? Display::None : Display::Flex); |
| 606 | if (mods_available) { |
| 607 | mod_selected(0); |
| 608 | } |
| 609 | } |
nothing calls this directly
no test coverage detected