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

Method RecruitScreen

game/ui/base/recruitscreen.cpp:34–132  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

32{
33
34RecruitScreen::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();

Callers

nothing calls this directly

Calls 12

setDisplayTypeMethod · 0.95
trFunction · 0.85
addCallbackMethod · 0.80
endMethod · 0.80
getUsageMethod · 0.80
stageQueueCommandMethod · 0.80
getFormMethod · 0.45
setVisibleMethod · 0.45
setCheckedMethod · 0.45
beginMethod · 0.45
removeItemMethod · 0.45
addItemMethod · 0.45

Tested by

no test coverage detected