| 40 | const Vec2<int> AEquipScreen::EQUIP_GRID_SLOTS{16, 16}; |
| 41 | |
| 42 | AEquipScreen::AEquipScreen(sp<GameState> state, sp<Agent> firstAgent) |
| 43 | : Stage(), firstAgent(firstAgent), formMain(ui().getForm("aequipscreen")), |
| 44 | pal(fw().data->loadPalette("xcom3/ufodata/agenteqp.pcx")), state(state), |
| 45 | labelFont(ui().getFont("smalfont")), bigUnitRanks(RecruitScreen::getBigUnitRanks()) |
| 46 | { |
| 47 | this->state = state; |
| 48 | formAgentStats = formMain->findControlTyped<Form>("AGENT_STATS_VIEW"); |
| 49 | formAgentItem = formMain->findControlTyped<Form>("AGENT_ITEM_VIEW"); |
| 50 | |
| 51 | auto paperDollPlaceholder = formMain->findControlTyped<Graphic>("PAPER_DOLL"); |
| 52 | |
| 53 | this->paperDoll = formMain->createChild<EquipmentPaperDoll>( |
| 54 | paperDollPlaceholder->Location, paperDollPlaceholder->Size, EQUIP_GRID_SLOT_SIZE); |
| 55 | |
| 56 | inventoryControl = formMain->findControlTyped<Graphic>("INVENTORY"); |
| 57 | |
| 58 | for (int i = 12; i <= 18; i++) |
| 59 | { |
| 60 | bigUnitRanks.push_back( |
| 61 | fw().data->loadImage(format("PCK:xcom3/tacdata/tacbut.pck:xcom3/tacdata/" |
| 62 | "tacbut.tab:%d:xcom3/tacdata/tactical.pal", |
| 63 | i))); |
| 64 | } |
| 65 | |
| 66 | // Agent list functionality |
| 67 | auto agentList = formMain->findControlTyped<ListBox>("AGENT_SELECT_BOX"); |
| 68 | agentList->addCallback( |
| 69 | FormEventType::ListBoxChangeSelected, |
| 70 | [this](FormsEvent *e) |
| 71 | { |
| 72 | auto list = std::static_pointer_cast<ListBox>(e->forms().RaisedBy); |
| 73 | auto agent = list->getSelectedData<Agent>(); |
| 74 | if (!agent) |
| 75 | { |
| 76 | LogError("No agent in selected data"); |
| 77 | return; |
| 78 | } |
| 79 | if (agent->unit && !agent->unit->isConscious()) |
| 80 | { |
| 81 | return; |
| 82 | } |
| 83 | selectAgent(agent, |
| 84 | Event::isPressed(e->forms().MouseInfo.Button, Event::MouseButton::Right), |
| 85 | modifierLCtrl || modifierRCtrl); |
| 86 | }); |
| 87 | |
| 88 | // Agent name edit |
| 89 | formAgentStats->findControlTyped<TextEdit>("AGENT_NAME") |
| 90 | ->addCallback( |
| 91 | FormEventType::TextEditFinish, |
| 92 | [this](FormsEvent *e) |
| 93 | { |
| 94 | auto currentAgent = selectedAgents.empty() ? nullptr : selectedAgents.front(); |
| 95 | if (currentAgent) |
| 96 | { |
| 97 | currentAgent->name = |
| 98 | std::dynamic_pointer_cast<TextEdit>(e->forms().RaisedBy)->getText(); |
| 99 | } |
nothing calls this directly
no test coverage detected