* Initializes all the elements in the Multiple Targets window. * @param game Pointer to the core game. * @param targets List of targets to display. * @param craft Pointer to craft to retarget (NULL if none). * @param state Pointer to the Geoscape state. */
| 48 | * @param state Pointer to the Geoscape state. |
| 49 | */ |
| 50 | MultipleTargetsState::MultipleTargetsState(Game *game, std::vector<Target*> targets, Craft *craft, GeoscapeState *state) : State(game), _targets(targets), _craft(craft), _state(state) |
| 51 | { |
| 52 | _screen = false; |
| 53 | |
| 54 | if (_targets.size() > 1) |
| 55 | { |
| 56 | int winHeight = BUTTON_HEIGHT * _targets.size() + SPACING * (_targets.size() - 1) + MARGIN * 2; |
| 57 | int winY = (200 - winHeight) / 2; |
| 58 | int btnY = winY + MARGIN; |
| 59 | |
| 60 | // Create objects |
| 61 | _window = new Window(this, 136, winHeight, 60, winY, POPUP_VERTICAL); |
| 62 | |
| 63 | // Set palette |
| 64 | setPalette("PAL_GEOSCAPE", 7); |
| 65 | |
| 66 | add(_window); |
| 67 | |
| 68 | // Set up objects |
| 69 | _window->setColor(Palette::blockOffset(8) + 5); |
| 70 | _window->setBackground(_game->getResourcePack()->getSurface("BACK15.SCR")); |
| 71 | |
| 72 | int y = btnY; |
| 73 | for (size_t i = 0; i < _targets.size(); ++i) |
| 74 | { |
| 75 | TextButton *button = new TextButton(116, BUTTON_HEIGHT, 70, y); |
| 76 | button->setColor(Palette::blockOffset(8) + 5); |
| 77 | button->setText(_targets[i]->getName(_game->getLanguage())); |
| 78 | button->onMouseClick((ActionHandler)&MultipleTargetsState::btnTargetClick); |
| 79 | add(button); |
| 80 | |
| 81 | _btnTargets.push_back(button); |
| 82 | |
| 83 | y += button->getHeight() + SPACING; |
| 84 | } |
| 85 | _btnTargets[0]->onKeyboardPress((ActionHandler)&MultipleTargetsState::btnCancelClick, Options::keyCancel); |
| 86 | |
| 87 | centerAllSurfaces(); |
| 88 | } |
| 89 | } |
| 90 | |
| 91 | /** |
| 92 | * |
nothing calls this directly
no test coverage detected