| 722 | } |
| 723 | |
| 724 | void PickerWindow::EnsureSelectedTypeIsVisible() |
| 725 | { |
| 726 | if (!this->has_type_picker) return; |
| 727 | if (this->types.empty()) { |
| 728 | this->GetWidget<NWidgetMatrix>(WID_PW_TYPE_MATRIX)->SetClicked(-1); |
| 729 | return; |
| 730 | } |
| 731 | |
| 732 | int class_index = this->callbacks.GetSelectedClass(); |
| 733 | int index = this->callbacks.GetSelectedType(); |
| 734 | |
| 735 | auto it = std::ranges::find_if(this->types, [class_index, index](const auto &item) { return item.class_index == class_index && item.index == index; }); |
| 736 | int pos = -1; |
| 737 | if (it != std::end(this->types)) { |
| 738 | pos = static_cast<int>(std::distance(std::begin(this->types), it)); |
| 739 | } |
| 740 | |
| 741 | this->GetWidget<NWidgetMatrix>(WID_PW_TYPE_MATRIX)->SetClicked(pos); |
| 742 | } |
| 743 | |
| 744 | /** Create nested widgets for the class picker widgets. */ |
| 745 | std::unique_ptr<NWidgetBase> MakePickerClassWidgets() |
no test coverage detected