* Initializes all the elements in the Abandon Game screen. * @param game Pointer to the core game. * @param origin Game section that originated this state. */
| 39 | * @param origin Game section that originated this state. |
| 40 | */ |
| 41 | AbandonGameState::AbandonGameState(Game *game, OptionsOrigin origin) : State(game), _origin(origin) |
| 42 | { |
| 43 | _screen = false; |
| 44 | |
| 45 | int x; |
| 46 | if (_origin == OPT_GEOSCAPE) |
| 47 | { |
| 48 | x = 20; |
| 49 | } |
| 50 | else |
| 51 | { |
| 52 | x = 52; |
| 53 | } |
| 54 | |
| 55 | // Create objects |
| 56 | _window = new Window(this, 216, 160, x, 20, POPUP_BOTH); |
| 57 | _btnYes = new TextButton(50, 20, x+18, 140); |
| 58 | _btnNo = new TextButton(50, 20, x+148, 140); |
| 59 | _txtTitle = new Text(206, 17, x+5, 70); |
| 60 | |
| 61 | // Set palette |
| 62 | if (_origin == OPT_BATTLESCAPE) |
| 63 | { |
| 64 | setPalette("PAL_BATTLESCAPE"); |
| 65 | } |
| 66 | else |
| 67 | { |
| 68 | setPalette("PAL_GEOSCAPE", 0); |
| 69 | } |
| 70 | |
| 71 | add(_window); |
| 72 | add(_btnYes); |
| 73 | add(_btnNo); |
| 74 | add(_txtTitle); |
| 75 | |
| 76 | centerAllSurfaces(); |
| 77 | |
| 78 | // Set up objects |
| 79 | _window->setColor(Palette::blockOffset(15)-1); |
| 80 | _window->setBackground(_game->getResourcePack()->getSurface("BACK01.SCR")); |
| 81 | |
| 82 | _btnYes->setColor(Palette::blockOffset(15)-1); |
| 83 | _btnYes->setText(tr("STR_YES")); |
| 84 | _btnYes->onMouseClick((ActionHandler)&AbandonGameState::btnYesClick); |
| 85 | _btnYes->onKeyboardPress((ActionHandler)&AbandonGameState::btnYesClick, Options::keyOk); |
| 86 | |
| 87 | _btnNo->setColor(Palette::blockOffset(15)-1); |
| 88 | _btnNo->setText(tr("STR_NO")); |
| 89 | _btnNo->onMouseClick((ActionHandler)&AbandonGameState::btnNoClick); |
| 90 | _btnNo->onKeyboardPress((ActionHandler)&AbandonGameState::btnNoClick, Options::keyCancel); |
| 91 | |
| 92 | _txtTitle->setColor(Palette::blockOffset(15)-1); |
| 93 | _txtTitle->setAlign(ALIGN_CENTER); |
| 94 | _txtTitle->setBig(); |
| 95 | _txtTitle->setText(tr("STR_ABANDON_GAME_QUESTION")); |
| 96 | |
| 97 | if (_origin == OPT_BATTLESCAPE) |
| 98 | { |
nothing calls this directly
no test coverage detected