| 332 | }; |
| 333 | |
| 334 | DropDownList BuildBadgeClassConfigurationList(const GUIBadgeClasses &gui_classes, uint columns, std::span<const StringID> column_separators, Colours bg_colour) |
| 335 | { |
| 336 | DropDownList list; |
| 337 | |
| 338 | list.push_back(MakeDropDownListStringItem(STR_BADGE_CONFIG_RESET, INT_MAX)); |
| 339 | if (gui_classes.GetClasses().empty()) return list; |
| 340 | list.push_back(MakeDropDownListDividerItem()); |
| 341 | list.push_back(std::make_unique<DropDownUnselectable<DropDownListStringItem>>(GetString(STR_BADGE_CONFIG_ICONS), -1)); |
| 342 | |
| 343 | const BadgeClassID front = gui_classes.GetClasses().front().class_index; |
| 344 | const BadgeClassID back = gui_classes.GetClasses().back().class_index; |
| 345 | |
| 346 | for (uint i = 0; i < columns; ++i) { |
| 347 | for (const auto &gc : gui_classes.GetClasses()) { |
| 348 | if (gc.column_group != i) continue; |
| 349 | if (gc.size.width == 0) continue; |
| 350 | |
| 351 | bool first = (i == 0 && gc.class_index == front); |
| 352 | bool last = (i == columns - 1 && gc.class_index == back); |
| 353 | list.push_back(std::make_unique<DropDownListToggleMoverItem>(first ? 0 : BADGE_CLICK_MOVE_UP, last ? 0 : BADGE_CLICK_MOVE_DOWN, COLOUR_YELLOW, gc.visible, BADGE_CLICK_TOGGLE_ICON, COLOUR_YELLOW, bg_colour, GetString(GetClassBadge(gc.class_index)->name), gc.class_index.base())); |
| 354 | } |
| 355 | |
| 356 | if (i >= column_separators.size()) continue; |
| 357 | |
| 358 | if (column_separators[i] == STR_NULL) { |
| 359 | list.push_back(MakeDropDownListDividerItem()); |
| 360 | } else { |
| 361 | list.push_back(MakeDropDownListStringItem(column_separators[i], INT_MIN + i, false, true)); |
| 362 | } |
| 363 | } |
| 364 | |
| 365 | list.push_back(MakeDropDownListDividerItem()); |
| 366 | list.push_back(std::make_unique<DropDownUnselectable<DropDownListStringItem>>(GetString(STR_BADGE_CONFIG_FILTERS), -1)); |
| 367 | |
| 368 | for (const BadgeClassID &badge_class_index : gui_classes.Classes()) { |
| 369 | const Badge *badge = GetClassBadge(badge_class_index); |
| 370 | if (!badge->flags.Test(BadgeFlag::HasText)) continue; |
| 371 | |
| 372 | const auto [config, _] = GetBadgeClassConfigItem(gui_classes.GetFeature(), badge->label); |
| 373 | list.push_back(std::make_unique<DropDownListToggleItem>(config.show_filter, BADGE_CLICK_TOGGLE_FILTER, COLOUR_YELLOW, bg_colour, GetString(badge->name), badge_class_index.base())); |
| 374 | } |
| 375 | |
| 376 | return list; |
| 377 | } |
| 378 | |
| 379 | /** |
| 380 | * Toggle badge class visibility. |
no test coverage detected