| 300 | } |
| 301 | |
| 302 | void ModMenu::mod_selected(uint32_t mod_index) { |
| 303 | if (active_mod_index >= 0) { |
| 304 | mod_entry_buttons[active_mod_index]->set_selected(false); |
| 305 | } |
| 306 | |
| 307 | active_mod_index = mod_index; |
| 308 | |
| 309 | if (active_mod_index >= 0) { |
| 310 | std::string thumbnail_src = generate_thumbnail_src_for_mod(mod_details[mod_index].mod_id); |
| 311 | const recomp::mods::ConfigSchema &config_schema = recomp::mods::get_mod_config_schema(mod_details[active_mod_index].mod_id); |
| 312 | bool toggle_checked = is_mod_enabled_or_auto(mod_details[mod_index].mod_id); |
| 313 | bool auto_enabled = recomp::mods::is_mod_auto_enabled(mod_details[mod_index].mod_id); |
| 314 | bool toggle_enabled = !auto_enabled && (mod_details[mod_index].runtime_toggleable || !ultramodern::is_game_started()); |
| 315 | bool configure_enabled = !config_schema.options.empty(); |
| 316 | mod_details_panel->set_mod_details(mod_details[mod_index], thumbnail_src, toggle_checked, toggle_enabled, auto_enabled, configure_enabled); |
| 317 | mod_entry_buttons[active_mod_index]->set_selected(true); |
| 318 | |
| 319 | mod_details_panel->setup_mod_navigation(mod_entry_buttons[mod_index]); |
| 320 | |
| 321 | // Navigation from the bottom bar. |
| 322 | Button *configure_button = mod_details_panel->get_configure_button(); |
| 323 | Toggle *enable_toggle = mod_details_panel->get_enable_toggle(); |
| 324 | if (configure_enabled) { |
| 325 | refresh_button->set_nav(NavDirection::Up, configure_button); |
| 326 | mods_folder_button->set_nav(NavDirection::Up, configure_button); |
| 327 | } |
| 328 | else if (toggle_enabled) { |
| 329 | refresh_button->set_nav(NavDirection::Up, enable_toggle); |
| 330 | mods_folder_button->set_nav(NavDirection::Up, enable_toggle); |
| 331 | } |
| 332 | else { |
| 333 | refresh_button->set_nav_manual(NavDirection::Up, mod_tab_id); |
| 334 | mods_folder_button->set_nav_manual(NavDirection::Up, mod_tab_id); |
| 335 | } |
| 336 | |
| 337 | // Navigation from the mod list. |
| 338 | if (toggle_enabled) { |
| 339 | mod_entry_buttons[active_mod_index]->set_nav(NavDirection::Right, enable_toggle); |
| 340 | } |
| 341 | else if (configure_enabled) { |
| 342 | mod_entry_buttons[active_mod_index]->set_nav(NavDirection::Right, configure_button); |
| 343 | } |
| 344 | else { |
| 345 | mod_entry_buttons[active_mod_index]->set_nav_none(NavDirection::Right); |
| 346 | } |
| 347 | } |
| 348 | } |
| 349 | |
| 350 | void ModMenu::mod_dragged(uint32_t mod_index, EventDrag drag) { |
| 351 | constexpr float spacer_height = modEntryHeight + modEntryPadding * 2.0f; |
nothing calls this directly
no test coverage detected