| 716 | } |
| 717 | |
| 718 | void SetSelectedGroup(CompanyID company, GroupID group) |
| 719 | { |
| 720 | this->RaiseWidget(WID_SCL_CLASS_GENERAL + this->livery_class); |
| 721 | const Group *g = Group::Get(group); |
| 722 | switch (g->vehicle_type) { |
| 723 | case VEH_TRAIN: this->livery_class = LC_GROUP_RAIL; break; |
| 724 | case VEH_ROAD: this->livery_class = LC_GROUP_ROAD; break; |
| 725 | case VEH_SHIP: this->livery_class = LC_GROUP_SHIP; break; |
| 726 | case VEH_AIRCRAFT: this->livery_class = LC_GROUP_AIRCRAFT; break; |
| 727 | default: NOT_REACHED(); |
| 728 | } |
| 729 | this->sel = group.base(); |
| 730 | this->LowerWidget(WID_SCL_CLASS_GENERAL + this->livery_class); |
| 731 | |
| 732 | this->groups.ForceRebuild(); |
| 733 | this->BuildGroupList(company); |
| 734 | this->SetRows(); |
| 735 | |
| 736 | /* Position scrollbar to selected group */ |
| 737 | for (uint i = 0; i < this->rows; i++) { |
| 738 | if (this->groups[i].group->index == sel) { |
| 739 | this->vscroll->SetPosition(i - this->vscroll->GetCapacity() / 2); |
| 740 | break; |
| 741 | } |
| 742 | } |
| 743 | } |
| 744 | |
| 745 | void UpdateWidgetSize(WidgetID widget, Dimension &size, [[maybe_unused]] const Dimension &padding, [[maybe_unused]] Dimension &fill, [[maybe_unused]] Dimension &resize) override |
| 746 | { |
no test coverage detected