* Populating the UI lab list. * @listName - listbox's name in the form * @listLabs - list of existing labs */
| 291 | * @listLabs - list of existing labs |
| 292 | */ |
| 293 | void ResearchScreen::populateUILabList(const UString &listName, std::list<sp<Facility>> &listLabs) |
| 294 | { |
| 295 | auto uiListLabs = form->findControlTyped<ListBox>(listName); |
| 296 | uiListLabs->clear(); |
| 297 | |
| 298 | sp<Control> selectedItem = nullptr; |
| 299 | for (auto &facility : listLabs) |
| 300 | { |
| 301 | auto item = ControlGenerator::createLabControl(state, facility); |
| 302 | item->setData(facility); |
| 303 | |
| 304 | auto label = std::static_pointer_cast<Label>(item->Controls[0]); |
| 305 | label->setText(format("%d", facility->lab->assigned_agents.size())); |
| 306 | |
| 307 | uiListLabs->addItem(item); |
| 308 | if (facility == viewFacility) |
| 309 | { |
| 310 | selectedItem = item; |
| 311 | } |
| 312 | } |
| 313 | uiListLabs->setSelected(selectedItem); |
| 314 | } |
| 315 | |
| 316 | void ResearchScreen::setCurrentLabInfo() |
| 317 | { |