MCPcopy Create free account
hub / github.com/OpenApoc/OpenApoc / setCurrentLabInfo

Method setCurrentLabInfo

game/ui/base/researchscreen.cpp:316–427  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

314}
315
316void ResearchScreen::setCurrentLabInfo()
317{
318 if (!this->viewFacility)
319 {
320 auto unassignedAgentList = form->findControlTyped<ListBox>("LIST_UNASSIGNED");
321 unassignedAgentList->clear();
322 auto assignedAgentList = form->findControlTyped<ListBox>("LIST_ASSIGNED");
323 assignedAgentList->clear();
324 form->findControlTyped<Label>("TEXT_LAB_TYPE")->setText("");
325 auto totalSkillLabel = form->findControlTyped<Label>("TEXT_TOTAL_SKILL");
326 totalSkillLabel->setText(format(tr("Total Skill: %d"), 0));
327 updateProgressInfo();
328 return;
329 }
330 this->state->current_base->selectedLab = viewFacility;
331 this->assigned_agent_count = 0;
332 auto labType = this->viewFacility->type->capacityType;
333 UString labTypeName = "UNKNOWN";
334 AgentType::Role listedAgentType = AgentType::Role::BioChemist;
335
336 if (labType == FacilityType::Capacity::Chemistry)
337 {
338 labTypeName = tr("Biochemistry");
339 listedAgentType = AgentType::Role::BioChemist;
340 }
341 else if (labType == FacilityType::Capacity::Physics)
342 {
343 labTypeName = tr("Quantum Physics");
344 listedAgentType = AgentType::Role::Physicist;
345 }
346 else if (labType == FacilityType::Capacity::Workshop)
347 {
348 labTypeName = tr("Engineering");
349 listedAgentType = AgentType::Role::Engineer;
350 }
351 else
352 {
353 LogError("Unexpected CapacityType in lab");
354 }
355
356 form->findControlTyped<Label>("TEXT_LAB_TYPE")->setText(labTypeName);
357
358 auto agentEntryHeight = ControlGenerator::getFontHeight(*state) * 3;
359
360 auto unassignedAgentList = form->findControlTyped<ListBox>("LIST_UNASSIGNED");
361 unassignedAgentList->clear();
362 auto assignedAgentList = form->findControlTyped<ListBox>("LIST_ASSIGNED");
363 assignedAgentList->clear();
364 for (auto &agent : state->agents)
365 {
366 bool assigned_to_current_lab = false;
367 if (agent.second->homeBuilding->base != this->state->current_base)
368 continue;
369
370 if (agent.second->type->role != listedAgentType)
371 continue;
372
373 if (agent.second->assigned_to_lab)

Callers 1

beginMethod · 0.95

Calls 9

formatFunction · 0.85
trFunction · 0.85
getSpMethod · 0.80
getTotalSkillMethod · 0.80
getSelectedItemMethod · 0.80
clearMethod · 0.45
setTextMethod · 0.45
addItemMethod · 0.45
sizeMethod · 0.45

Tested by

no test coverage detected