| 700 | } |
| 701 | |
| 702 | void PickerWindow::EnsureSelectedTypeIsValid() |
| 703 | { |
| 704 | int class_index = this->callbacks.GetSelectedClass(); |
| 705 | int index = this->callbacks.GetSelectedType(); |
| 706 | if (std::any_of(std::begin(this->types), std::end(this->types), [class_index, index](const auto &item) { return item.class_index == class_index && item.index == index; })) return; |
| 707 | |
| 708 | if (!this->types.empty()) { |
| 709 | class_index = this->types.front().class_index; |
| 710 | index = this->types.front().index; |
| 711 | } else { |
| 712 | /* Types can be empty if filters are enabled, find the first usable type. */ |
| 713 | int count = this->callbacks.GetTypeCount(class_index); |
| 714 | for (int i = 0; i < count; i++) { |
| 715 | if (this->callbacks.GetTypeName(class_index, i) == INVALID_STRING_ID) continue; |
| 716 | index = i; |
| 717 | break; |
| 718 | } |
| 719 | } |
| 720 | this->callbacks.SetSelectedClass(class_index); |
| 721 | this->callbacks.SetSelectedType(index); |
| 722 | } |
| 723 | |
| 724 | void PickerWindow::EnsureSelectedTypeIsVisible() |
| 725 | { |
no test coverage detected