| 33 | ResearchSelect::~ResearchSelect() = default; |
| 34 | |
| 35 | void ResearchSelect::begin() |
| 36 | { |
| 37 | current_topic = this->lab->current_project; |
| 38 | |
| 39 | form->findControlTyped<Label>("TEXT_FUNDS")->setText(state->getPlayerBalance()); |
| 40 | auto title = form->findControlTyped<Label>("TEXT_TITLE"); |
| 41 | auto progress = form->findControlTyped<Label>("TEXT_PROGRESS"); |
| 42 | auto skill = form->findControlTyped<Label>("TEXT_SKILL"); |
| 43 | switch (this->lab->type) |
| 44 | { |
| 45 | case ResearchTopic::Type::BioChem: |
| 46 | title->setText(tr("Select Biochemistry Project")); |
| 47 | progress->setText(tr("Progress")); |
| 48 | skill->setText(tr("Skill")); |
| 49 | break; |
| 50 | case ResearchTopic::Type::Physics: |
| 51 | title->setText(tr("Select Physics Project")); |
| 52 | progress->setText(tr("Progress")); |
| 53 | skill->setText(tr("Skill")); |
| 54 | break; |
| 55 | case ResearchTopic::Type::Engineering: |
| 56 | title->setText(tr("Select Manufacturing Project")); |
| 57 | progress->setText(tr("Unit Cost")); |
| 58 | skill->setText(tr("Skill Hours")); |
| 59 | break; |
| 60 | default: |
| 61 | title->setText(tr("Select Unknown Project")); |
| 62 | break; |
| 63 | } |
| 64 | this->populateResearchList(); |
| 65 | this->redrawResearchList(); |
| 66 | |
| 67 | auto research_list = form->findControlTyped<ListBox>("LIST"); |
| 68 | |
| 69 | research_list->addCallback(FormEventType::ListBoxChangeSelected, [this](FormsEvent *e) { |
| 70 | LogInfo("Research selection change"); |
| 71 | auto list = std::static_pointer_cast<ListBox>(e->forms().RaisedBy); |
| 72 | auto topic = list->getSelectedData<ResearchTopic>(); |
| 73 | if (topic->current_lab) |
| 74 | { |
| 75 | LogInfo("Topic already in progress"); |
| 76 | } |
| 77 | else |
| 78 | { |
| 79 | if (topic->isComplete()) |
| 80 | { |
| 81 | LogInfo("Topic already complete"); |
| 82 | auto message_box = mksp<MessageBox>(tr("PROJECT COMPLETE"), |
| 83 | tr("This project is already complete."), |
| 84 | MessageBox::ButtonOptions::Ok); |
| 85 | fw().stageQueueCommand({StageCmd::Command::PUSH, message_box}); |
| 86 | // Restore previous selection |
| 87 | list->setSelected(current_topic ? control_map[current_topic] : nullptr); |
| 88 | return; |
| 89 | } |
| 90 | if (topic->required_lab_size == ResearchTopic::LabSize::Large && |
| 91 | this->lab->size == ResearchTopic::LabSize::Small) |
| 92 | { |
nothing calls this directly
no test coverage detected