| 1649 | } |
| 1650 | |
| 1651 | void OnClick([[maybe_unused]] Point pt, WidgetID widget, [[maybe_unused]] int click_count) override |
| 1652 | { |
| 1653 | switch (widget) { |
| 1654 | case WID_BV_SORT_ASCENDING_DESCENDING: |
| 1655 | this->descending_sort_order ^= true; |
| 1656 | _engine_sort_last_order[this->vehicle_type] = this->descending_sort_order; |
| 1657 | this->eng_list.ForceRebuild(); |
| 1658 | this->SetDirty(); |
| 1659 | break; |
| 1660 | |
| 1661 | case WID_BV_SHOW_HIDDEN_ENGINES: |
| 1662 | this->show_hidden_engines ^= true; |
| 1663 | _engine_sort_show_hidden_engines[this->vehicle_type] = this->show_hidden_engines; |
| 1664 | this->eng_list.ForceRebuild(); |
| 1665 | this->SetWidgetLoweredState(widget, this->show_hidden_engines); |
| 1666 | this->SetDirty(); |
| 1667 | break; |
| 1668 | |
| 1669 | case WID_BV_LIST: { |
| 1670 | EngineID e = EngineID::Invalid(); |
| 1671 | const auto it = this->vscroll->GetScrolledItemFromWidget(this->eng_list, pt.y, this, WID_BV_LIST); |
| 1672 | if (it != this->eng_list.end()) { |
| 1673 | const auto &item = *it; |
| 1674 | const Rect r = this->GetWidget<NWidgetBase>(widget)->GetCurrentRect().Shrink(WidgetDimensions::scaled.matrix).WithWidth(WidgetDimensions::scaled.hsep_indent * (item.indent + 1), _current_text_dir == TD_RTL); |
| 1675 | if (item.flags.Test(EngineDisplayFlag::HasVariants) && IsInsideMM(r.left, r.right, pt.x)) { |
| 1676 | /* toggle folded flag on engine */ |
| 1677 | assert(item.variant_id != EngineID::Invalid()); |
| 1678 | Engine *engine = Engine::Get(item.variant_id); |
| 1679 | engine->display_flags.Flip(EngineDisplayFlag::IsFolded); |
| 1680 | |
| 1681 | InvalidateWindowData(WC_REPLACE_VEHICLE, this->vehicle_type, 0); // Update the autoreplace window |
| 1682 | InvalidateWindowClassesData(WC_BUILD_VEHICLE); // The build windows needs updating as well |
| 1683 | return; |
| 1684 | } |
| 1685 | if (!item.flags.Test(EngineDisplayFlag::Shaded)) e = item.engine_id; |
| 1686 | } |
| 1687 | this->SelectEngine(e); |
| 1688 | this->SetDirty(); |
| 1689 | if (_ctrl_pressed) { |
| 1690 | this->OnClick(pt, WID_BV_SHOW_HIDE, 1); |
| 1691 | } else if (click_count > 1 && !this->listview_mode) { |
| 1692 | this->OnClick(pt, WID_BV_BUILD, 1); |
| 1693 | } |
| 1694 | break; |
| 1695 | } |
| 1696 | |
| 1697 | case WID_BV_SORT_DROPDOWN: // Select sorting criteria dropdown menu |
| 1698 | DisplayVehicleSortDropDown(this, this->vehicle_type, this->sort_criteria, WID_BV_SORT_DROPDOWN); |
| 1699 | break; |
| 1700 | |
| 1701 | case WID_BV_CARGO_FILTER_DROPDOWN: // Select cargo filtering criteria dropdown menu |
| 1702 | ShowDropDownList(this, this->BuildCargoDropDownList(), this->cargo_filter_criteria, widget); |
| 1703 | break; |
| 1704 | |
| 1705 | case WID_BV_CONFIGURE_BADGES: |
| 1706 | if (this->badge_classes.GetClasses().empty()) break; |
| 1707 | ShowDropDownList(this, this->BuildBadgeConfigurationList(), -1, widget, 0, DropDownOption::Persist); |
| 1708 | break; |
nothing calls this directly
no test coverage detected