* Add children to GUI group list to build a hierarchical tree. * @param list Destination list. * @param item Group item to add children to. * @param fold Whether to handle group folding/hiding. * @param indent Current tree indentation level (set by self with recursion). */
| 138 | * @param indent Current tree indentation level (set by self with recursion). |
| 139 | */ |
| 140 | static void GuiGroupListAddChildren(GUIGroupList &list, GUIGroupListItem &item, bool fold, uint8_t indent = 1) |
| 141 | { |
| 142 | if (fold && item.group->folded) { |
| 143 | Group::Get(item.group->index)->folded = !item.group->children.empty(); |
| 144 | return; |
| 145 | } |
| 146 | |
| 147 | if (item.group->children.empty()) return; |
| 148 | |
| 149 | std::vector<GUIGroupListItem> sublist; |
| 150 | for (const GroupID &group : item.group->children) { |
| 151 | sublist.emplace_back(Group::Get(group), indent); |
| 152 | } |
| 153 | SortGUIGroupList(sublist); |
| 154 | |
| 155 | for (const GUIGroupListItem &subitem : sublist) { |
| 156 | GuiGroupListAddChildren(list, list.emplace_back(subitem), fold, indent + 1); |
| 157 | } |
| 158 | } |
| 159 | |
| 160 | /** |
| 161 | * Build GUI group list, a sorted hierarchical list of groups for owner and vehicle type. |
no test coverage detected