| 40 | } |
| 41 | |
| 42 | static void emitOptions(DynamicSetting<std::string>& setting, |
| 43 | const ConfigProto* config, |
| 44 | const std::set<int>& applicableOptions) |
| 45 | { |
| 46 | auto options = stringToOptions(setting); |
| 47 | |
| 48 | for (auto& it : config->option()) |
| 49 | { |
| 50 | if (!applicableOptions.empty() && |
| 51 | std::ranges::none_of(it.applicability(), |
| 52 | [&](int item) |
| 53 | { |
| 54 | return applicableOptions.contains(item); |
| 55 | })) |
| 56 | continue; |
| 57 | |
| 58 | bool selected = options.contains(it.name()); |
| 59 | |
| 60 | ImGui::TableNextRow(); |
| 61 | ImGui::TableNextColumn(); |
| 62 | ImGui::AlignTextToFramePadding(); |
| 63 | ImGui::TextWrapped( |
| 64 | "%s", wolv::util::capitalizeString(it.comment()).c_str()); |
| 65 | |
| 66 | ImGui::TableNextColumn(); |
| 67 | ImGui::SetNextItemWidth(-FLT_MIN); |
| 68 | if (ImGui::BeginCombo(fmt::format("##{}", it.comment()).c_str(), |
| 69 | selected ? "fluxengine.view.config.yes"_lang |
| 70 | : "fluxengine.view.config.no"_lang, |
| 71 | ImGuiComboFlags_None)) |
| 72 | { |
| 73 | ON_SCOPE_EXIT |
| 74 | { |
| 75 | ImGui::EndCombo(); |
| 76 | }; |
| 77 | |
| 78 | int value = -1; |
| 79 | if (ImGui::Selectable("fluxengine.view.config.no"_lang, !selected)) |
| 80 | value = 0; |
| 81 | if (ImGui::Selectable("fluxengine.view.config.yes"_lang, selected)) |
| 82 | value = 1; |
| 83 | if (value != -1) |
| 84 | { |
| 85 | options.erase(it.name()); |
| 86 | if (value) |
| 87 | options[it.name()] = "true"; |
| 88 | setting = optionsToString(options); |
| 89 | Datastore::reset(); |
| 90 | } |
| 91 | } |
| 92 | } |
| 93 | |
| 94 | for (auto& it : config->option_group()) |
| 95 | { |
| 96 | if (!applicableOptions.empty() && |
| 97 | std::ranges::none_of(it.applicability(), |
| 98 | [&](int item) |
| 99 | { |
no test coverage detected