| 579 | } |
| 580 | |
| 581 | void OnPaint() override |
| 582 | { |
| 583 | /* If we select the all vehicles, this->list will contain all vehicles of the owner |
| 584 | * else this->list will contain all vehicles which belong to the selected group */ |
| 585 | this->BuildVehicleList(); |
| 586 | this->SortVehicleList(); |
| 587 | |
| 588 | this->BuildGroupList(this->owner); |
| 589 | |
| 590 | this->group_sb->SetCount(this->groups.size()); |
| 591 | this->vscroll->SetCount(this->vehgroups.size()); |
| 592 | |
| 593 | /* The drop down menu is out, *but* it may not be used, retract it. */ |
| 594 | if (this->vehicles.empty() && this->IsWidgetLowered(WID_GL_MANAGE_VEHICLES_DROPDOWN)) { |
| 595 | this->RaiseWidget(WID_GL_MANAGE_VEHICLES_DROPDOWN); |
| 596 | this->CloseChildWindows(WC_DROPDOWN_MENU); |
| 597 | } |
| 598 | |
| 599 | /* Disable all lists management button when the list is empty */ |
| 600 | this->SetWidgetsDisabledState(this->vehicles.empty() || _local_company != this->vli.company, |
| 601 | WID_GL_STOP_ALL, |
| 602 | WID_GL_START_ALL, |
| 603 | WID_GL_MANAGE_VEHICLES_DROPDOWN); |
| 604 | |
| 605 | /* Disable the group specific function when we select the default group or all vehicles */ |
| 606 | GroupID group = this->vli.ToGroupID(); |
| 607 | this->SetWidgetsDisabledState(IsDefaultGroupID(group) || IsAllGroupID(group) || _local_company != this->vli.company, |
| 608 | WID_GL_DELETE_GROUP, |
| 609 | WID_GL_RENAME_GROUP, |
| 610 | WID_GL_LIVERY_GROUP, |
| 611 | WID_GL_REPLACE_PROTECTION); |
| 612 | |
| 613 | /* Disable remaining buttons for non-local companies |
| 614 | * Needed while changing _local_company, eg. by cheats |
| 615 | * All procedures (eg. move vehicle to another group) |
| 616 | * verify, whether you are the owner of the vehicle, |
| 617 | * so it doesn't have to be disabled |
| 618 | */ |
| 619 | this->SetWidgetsDisabledState(_local_company != this->vli.company, |
| 620 | WID_GL_CREATE_GROUP, |
| 621 | WID_GL_AVAILABLE_VEHICLES); |
| 622 | |
| 623 | /* If not a default group and the group has replace protection, show an enabled replace sprite. */ |
| 624 | uint16_t protect_sprite = SPR_GROUP_REPLACE_OFF_TRAIN; |
| 625 | if (!IsDefaultGroupID(group) && !IsAllGroupID(group) && Group::Get(group)->flags.Test(GroupFlag::ReplaceProtection)) protect_sprite = SPR_GROUP_REPLACE_ON_TRAIN; |
| 626 | this->GetWidget<NWidgetCore>(WID_GL_REPLACE_PROTECTION)->SetSprite(protect_sprite + this->vli.vtype); |
| 627 | |
| 628 | /* Set text of "group by" dropdown widget. */ |
| 629 | this->GetWidget<NWidgetCore>(WID_GL_GROUP_BY_DROPDOWN)->SetString(std::data(this->vehicle_group_by_names)[this->grouping]); |
| 630 | |
| 631 | /* Set text of "sort by" dropdown widget. */ |
| 632 | this->GetWidget<NWidgetCore>(WID_GL_SORT_BY_DROPDOWN)->SetString(this->GetVehicleSorterNames()[this->vehgroups.SortType()]); |
| 633 | |
| 634 | this->DrawWidgets(); |
| 635 | } |
| 636 | |
| 637 | void DrawWidget(const Rect &r, WidgetID widget) const override |
| 638 | { |
nothing calls this directly
no test coverage detected