| 34 | AgentAssignment::AgentAssignment(sp<GameState> state) : Form(), state(state) {} |
| 35 | |
| 36 | void AgentAssignment::init(sp<Form> form, Vec2<int> location, Vec2<int> size) |
| 37 | { |
| 38 | form->copyControlData(shared_from_this()); |
| 39 | Location = location; |
| 40 | Size = size; |
| 41 | |
| 42 | draggedList = findControlTyped<MultilistBox>("DRAGGED_AGENT_BOX"); |
| 43 | draggedList->setVisible(false); |
| 44 | |
| 45 | // update the vehicle's icon |
| 46 | funcVehicleUpdate = [this](sp<Control> c) |
| 47 | { |
| 48 | if (auto vehicle = c->getData<Vehicle>()) |
| 49 | { |
| 50 | auto icon = c->findControl(ControlGenerator::VEHICLE_ICON_NAME); |
| 51 | if (icon && *icon->getData<int>() != std::min(13, vehicle->getPassengers())) |
| 52 | { |
| 53 | auto newIcon = ControlGenerator::createVehicleIcon(*state, vehicle); |
| 54 | c->replaceChildByName(newIcon); |
| 55 | } |
| 56 | } |
| 57 | }; |
| 58 | |
| 59 | // update the agent's icon |
| 60 | funcAgentUpdate = [this](sp<Control> c) |
| 61 | { |
| 62 | if (!c->isVisible()) |
| 63 | { |
| 64 | return; |
| 65 | } |
| 66 | if (auto agent = c->getData<Agent>()) |
| 67 | { |
| 68 | auto icon = c->findControl(ControlGenerator::AGENT_ICON_NAME); |
| 69 | if (icon && |
| 70 | *icon->getData<CityUnitState>() != ControlGenerator::getCityUnitState(agent)) |
| 71 | { |
| 72 | auto newIcon = ControlGenerator::createAgentIcon( |
| 73 | *state, agent, UnitSelectionState::Unselected, false); |
| 74 | c->replaceChildByName(newIcon); |
| 75 | } |
| 76 | } |
| 77 | }; |
| 78 | |
| 79 | // select/deselect individual agent |
| 80 | funcHandleAgentSelection = [this](Event *e, sp<Control> c, bool select) |
| 81 | { |
| 82 | if (!e) |
| 83 | return select; |
| 84 | |
| 85 | auto agent = c->getData<Agent>(); |
| 86 | if (agent) |
| 87 | { |
| 88 | this->currentAgent = agent; |
| 89 | } |
| 90 | auto icon = c->findControl(ControlGenerator::AGENT_ICON_NAME); |
| 91 | if (config().getBool("OpenApoc.NewFeature.LeftClickIconEquip")) |
| 92 | { |
| 93 | if (agent && icon && c->isPointInsideControlBounds(e, icon) && |
no test coverage detected