MCPcopy Create free account
hub / github.com/OpenTTD/OpenTTD / SetSelectedGroup

Method SetSelectedGroup

src/company_gui.cpp:718–743  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

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 {

Callers 2

ShowCompanyLiveryWindowFunction · 0.80

Calls 9

BuildGroupListMethod · 0.95
SetRowsMethod · 0.95
NOT_REACHEDFunction · 0.85
RaiseWidgetMethod · 0.80
LowerWidgetMethod · 0.80
ForceRebuildMethod · 0.80
SetPositionMethod · 0.80
baseMethod · 0.45
GetCapacityMethod · 0.45

Tested by

no test coverage detected