| 35 | } |
| 36 | |
| 37 | void BaseStage::begin() |
| 38 | { |
| 39 | changeBase(); |
| 40 | |
| 41 | textFunds = form->findControlTyped<Label>("TEXT_FUNDS"); |
| 42 | textFunds->setText(state->getPlayerBalance()); |
| 43 | |
| 44 | int b = 0; |
| 45 | for (auto &pair : state->player_bases) |
| 46 | { |
| 47 | auto &viewBase = pair.second; |
| 48 | auto viewName = format("BUTTON_BASE_%d", ++b); |
| 49 | auto view = form->findControlTyped<GraphicButton>(viewName); |
| 50 | if (!view) |
| 51 | { |
| 52 | // This screen doesn't have miniviews |
| 53 | return; |
| 54 | } |
| 55 | if (state->current_base == viewBase) |
| 56 | { |
| 57 | currentView = view; |
| 58 | } |
| 59 | view->setData(viewBase); |
| 60 | auto viewImage = drawMiniBase(*viewBase, viewHighlight, viewFacility); |
| 61 | view->setImage(viewImage); |
| 62 | view->setDepressedImage(viewImage); |
| 63 | wp<GraphicButton> weakView(view); |
| 64 | view->addCallback(FormEventType::ButtonClick, [this, weakView](FormsEvent *e) { |
| 65 | auto base = e->forms().RaisedBy->getData<Base>(); |
| 66 | if (this->state->current_base != base) |
| 67 | { |
| 68 | this->changeBase(base); |
| 69 | this->currentView = weakView.lock(); |
| 70 | } |
| 71 | }); |
| 72 | view->addCallback(FormEventType::MouseEnter, [this](FormsEvent *e) { |
| 73 | auto base = e->forms().RaisedBy->getData<Base>(); |
| 74 | this->textViewBase->setVisible(true); |
| 75 | this->textViewBase->setText(base->name); |
| 76 | }); |
| 77 | view->addCallback(FormEventType::MouseLeave, [this](FormsEvent *) { |
| 78 | this->textViewBase->setText(""); |
| 79 | this->textViewBase->setVisible(false); |
| 80 | }); |
| 81 | miniViews.push_back(view); |
| 82 | } |
| 83 | textViewBase = form->findControlTyped<Label>("TEXT_BUTTON_BASE"); |
| 84 | this->textViewBase->setVisible(false); |
| 85 | } |
| 86 | |
| 87 | void BaseStage::render() |
| 88 | { |
no test coverage detected