cfg: fix combo boxes (#429)

## Link to GitHub Issue, if one exists
n/a

## Description of change
Combo boxes for options were not highlighting the currently selected
item. Also, when there were no description provided for an option, it
was still showing the empty `()` in the selected value.

## Testing
This commit is contained in:
bicarus-dev
2025-11-30 01:59:25 -08:00
committed by GitHub
parent d06b8bd731
commit 984b41a1ae
+5 -1
View File
@@ -2828,19 +2828,23 @@ namespace overlay::windows {
std::string current_item = option.value_text();
for (auto &element : definition.elements) {
if (element.first == current_item) {
if (!element.second.empty()) {
current_item += fmt::format(" ({})", element.second);
}
break;
}
}
if (current_item.empty()) {
current_item = "Default";
}
if (ImGui::BeginCombo("##combo", current_item.c_str(), 0)) {
for (auto &element : definition.elements) {
bool selected = current_item == element.first;
std::string label = element.first;
if (!element.second.empty()) {
label += fmt::format(" ({})", element.second);
}
bool selected = current_item == label;
if (ImGui::Selectable(label.c_str(), selected)) {
this->options_dirty = true;
option.value = element.first;