| 32 | { |
| 33 | |
| 34 | RecruitScreen::RecruitScreen(sp<GameState> state) |
| 35 | : BaseStage(state), bigUnitRanks(getBigUnitRanks()) |
| 36 | { |
| 37 | // Load resources |
| 38 | form = ui().getForm("recruitscreen"); |
| 39 | formAgentStats = form->findControlTyped<Form>("AGENT_STATS_VIEW"); |
| 40 | formPersonnelStats = form->findControlTyped<Form>("PERSONNEL_STATS_VIEW"); |
| 41 | formAgentStats->setVisible(false); |
| 42 | formPersonnelStats->setVisible(false); |
| 43 | |
| 44 | // Assign event handlers |
| 45 | onHover = [this](FormsEvent *e) |
| 46 | { |
| 47 | auto list = std::static_pointer_cast<ListBox>(e->forms().RaisedBy); |
| 48 | auto agent = list->getHoveredData<Agent>(); |
| 49 | if (agent) |
| 50 | displayAgentStats(*agent); |
| 51 | }; |
| 52 | |
| 53 | form->findControlTyped<ListBox>("LIST1")->addCallback(FormEventType::ListBoxChangeHover, |
| 54 | onHover); |
| 55 | form->findControlTyped<ListBox>("LIST2")->addCallback(FormEventType::ListBoxChangeHover, |
| 56 | onHover); |
| 57 | |
| 58 | arrow = form->findControlTyped<Graphic>("MAGIC_ARROW"); |
| 59 | textViewBaseStatic = form->findControlTyped<Label>("TEXT_BUTTON_BASE_STATIC"); |
| 60 | form->findControlTyped<RadioButton>("BUTTON_SOLDIERS")->setChecked(true); |
| 61 | type = AgentType::Role::Soldier; |
| 62 | viewHighlight = BaseGraphics::FacilityHighlight::Quarters; |
| 63 | |
| 64 | // Adding callbacks after checking the button because we don't need to |
| 65 | // have the callback be called since changeBase() will update display anyways |
| 66 | |
| 67 | form->findControlTyped<RadioButton>("BUTTON_SOLDIERS") |
| 68 | ->addCallback(FormEventType::CheckBoxSelected, |
| 69 | [this](Event *) { this->setDisplayType(AgentType::Role::Soldier); }); |
| 70 | form->findControlTyped<RadioButton>("BUTTON_BIOSCIS") |
| 71 | ->addCallback(FormEventType::CheckBoxSelected, |
| 72 | [this](Event *) { this->setDisplayType(AgentType::Role::BioChemist); }); |
| 73 | form->findControlTyped<RadioButton>("BUTTON_PHYSCIS") |
| 74 | ->addCallback(FormEventType::CheckBoxSelected, |
| 75 | [this](Event *) { this->setDisplayType(AgentType::Role::Physicist); }); |
| 76 | form->findControlTyped<RadioButton>("BUTTON_ENGINRS") |
| 77 | ->addCallback(FormEventType::CheckBoxSelected, |
| 78 | [this](Event *) { this->setDisplayType(AgentType::Role::Engineer); }); |
| 79 | |
| 80 | populateAgentList(); |
| 81 | |
| 82 | for (auto &list : agentLists) |
| 83 | { |
| 84 | for (auto &control : list) |
| 85 | { |
| 86 | // MouseClick - move an agent to opposite list |
| 87 | control->addCallback( |
| 88 | FormEventType::MouseClick, |
| 89 | [this](FormsEvent *e) |
| 90 | { |
| 91 | int leftIndex = getLeftIndex(); |
nothing calls this directly
no test coverage detected