| 464 | } |
| 465 | |
| 466 | void ModMenu::mod_configure_requested() { |
| 467 | if (active_mod_index >= 0) { |
| 468 | // Record the context that was open when this function was called and close it. |
| 469 | ContextId prev_context = recompui::get_current_context(); |
| 470 | prev_context.close(); |
| 471 | |
| 472 | // Open the sub menu context and set up the element. |
| 473 | sub_menu_context.open(); |
| 474 | config_sub_menu->clear_options(); |
| 475 | |
| 476 | const recomp::mods::ConfigSchema &config_schema = recomp::mods::get_mod_config_schema(mod_details[active_mod_index].mod_id); |
| 477 | for (const recomp::mods::ConfigOption &option : config_schema.options) { |
| 478 | recomp::mods::ConfigValueVariant config_value = recomp::mods::get_mod_config_value(mod_details[active_mod_index].mod_id, option.id); |
| 479 | if (std::holds_alternative<std::monostate>(config_value)) { |
| 480 | continue; |
| 481 | } |
| 482 | |
| 483 | if (handle_special_config_options(option, config_value)) { |
| 484 | continue; |
| 485 | } |
| 486 | |
| 487 | switch (option.type) { |
| 488 | case recomp::mods::ConfigOptionType::Enum: { |
| 489 | const recomp::mods::ConfigOptionEnum &option_enum = std::get<recomp::mods::ConfigOptionEnum>(option.variant); |
| 490 | config_sub_menu->add_radio_option(option.id, option.name, option.description, std::get<uint32_t>(config_value), option_enum.options, |
| 491 | [this](const std::string &id, uint32_t value){ mod_enum_option_changed(id, value); }); |
| 492 | break; |
| 493 | } |
| 494 | case recomp::mods::ConfigOptionType::Number: { |
| 495 | const recomp::mods::ConfigOptionNumber &option_number = std::get<recomp::mods::ConfigOptionNumber>(option.variant); |
| 496 | config_sub_menu->add_slider_option(option.id, option.name, option.description, std::get<double>(config_value), option_number.min, option_number.max, option_number.step, option_number.percent, |
| 497 | [this](const std::string &id, double value){ mod_number_option_changed(id, value); }); |
| 498 | break; |
| 499 | } |
| 500 | case recomp::mods::ConfigOptionType::String: { |
| 501 | config_sub_menu->add_text_option(option.id, option.name, option.description, std::get<std::string>(config_value), |
| 502 | [this](const std::string &id, const std::string &value){ mod_string_option_changed(id, value); }); |
| 503 | break; |
| 504 | } |
| 505 | default: |
| 506 | assert(false && "Unknown config option type."); |
| 507 | break; |
| 508 | } |
| 509 | } |
| 510 | |
| 511 | config_sub_menu->enter(mod_details[active_mod_index].display_name); |
| 512 | sub_menu_context.close(); |
| 513 | |
| 514 | // Reopen the context that was open when this function was called. |
| 515 | prev_context.open(); |
| 516 | |
| 517 | // Hide the config menu and show the sub menu. |
| 518 | recompui::hide_context(recompui::get_config_context_id()); |
| 519 | recompui::show_context(sub_menu_context, ""); |
| 520 | } |
| 521 | } |
| 522 | |
| 523 | void ModMenu::mod_enum_option_changed(const std::string &id, uint32_t value) { |
nothing calls this directly
no test coverage detected