Builds the filter list of classes. */
| 569 | |
| 570 | /** Builds the filter list of classes. */ |
| 571 | void PickerWindow::BuildPickerClassList() |
| 572 | { |
| 573 | if (!this->classes.NeedRebuild()) return; |
| 574 | |
| 575 | int count = this->callbacks.GetClassCount(); |
| 576 | |
| 577 | this->classes.clear(); |
| 578 | this->classes.reserve(count); |
| 579 | |
| 580 | bool filter_used = HasBit(this->callbacks.mode, PFM_USED); |
| 581 | bool filter_saved = HasBit(this->callbacks.mode, PFM_SAVED); |
| 582 | for (int i = 0; i < count; i++) { |
| 583 | if (this->callbacks.GetClassName(i) == INVALID_STRING_ID) continue; |
| 584 | if (filter_used && std::none_of(std::begin(this->callbacks.used), std::end(this->callbacks.used), [i](const PickerItem &item) { return item.class_index == i; })) continue; |
| 585 | if (filter_saved && std::none_of(std::begin(this->callbacks.saved), std::end(this->callbacks.saved), [i](const PickerItem &item) { return item.class_index == i; })) continue; |
| 586 | this->classes.emplace_back(i); |
| 587 | } |
| 588 | |
| 589 | this->classes.Filter(this->class_string_filter); |
| 590 | this->classes.RebuildDone(); |
| 591 | this->classes.Sort(); |
| 592 | |
| 593 | if (!this->has_class_picker) return; |
| 594 | this->GetScrollbar(WID_PW_CLASS_SCROLL)->SetCount(this->classes.size()); |
| 595 | } |
| 596 | |
| 597 | void PickerWindow::EnsureSelectedClassIsValid() |
| 598 | { |
no test coverage detected