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

Method SelectGroup

src/group_gui.cpp:1162–1185  ·  view source on GitHub ↗

* Selects the specified group in the list * * @param g_id The ID of the group to be selected */

Source from the content-addressed store, hash-verified

1160 * @param g_id The ID of the group to be selected
1161 */
1162 void SelectGroup(const GroupID g_id)
1163 {
1164 if (g_id == GroupID::Invalid() || g_id == this->vli.ToGroupID()) return;
1165
1166 this->vli.SetIndex(g_id);
1167 if (g_id != ALL_GROUP && g_id != DEFAULT_GROUP) {
1168 const Group *g = Group::Get(g_id);
1169
1170 auto found = std::ranges::find(this->groups, g, &GUIGroupListItem::group);
1171 if (found == std::end(this->groups)) {
1172 /* The group's branch is maybe collapsed, so try to expand it. */
1173 for (auto pg = Group::GetIfValid(g->parent); pg != nullptr; pg = Group::GetIfValid(pg->parent)) {
1174 pg->folded = false;
1175 }
1176 this->groups.ForceRebuild();
1177 this->BuildGroupList(this->owner);
1178 this->group_sb->SetCount(this->groups.size());
1179 found = std::ranges::find(this->groups, g, &GUIGroupListItem::group);
1180 }
1181 if (found != std::end(this->groups)) this->group_sb->ScrollTowards(std::distance(std::begin(this->groups), found));
1182 }
1183 this->vehgroups.ForceRebuild();
1184 this->SetDirty();
1185 }
1186
1187};
1188

Callers 2

OnClickMethod · 0.95
ShowCompanyGroupInternalFunction · 0.80

Calls 12

BuildGroupListMethod · 0.95
InvalidFunction · 0.85
ToGroupIDMethod · 0.80
ForceRebuildMethod · 0.80
ScrollTowardsMethod · 0.80
findFunction · 0.50
endFunction · 0.50
beginFunction · 0.50
SetIndexMethod · 0.45
SetCountMethod · 0.45
sizeMethod · 0.45
SetDirtyMethod · 0.45

Tested by

no test coverage detected