|
| 1 | +/* |
| 2 | + * Copyright 2010-2012 OpenXcom Developers. |
| 3 | + * |
| 4 | + * This file is part of OpenXcom. |
| 5 | + * |
| 6 | + * OpenXcom is free software: you can redistribute it and/or modify |
| 7 | + * it under the terms of the GNU General Public License as published by |
| 8 | + * the Free Software Foundation, either version 3 of the License, or |
| 9 | + * (at your option) any later version. |
| 10 | + * |
| 11 | + * OpenXcom is distributed in the hope that it will be useful, |
| 12 | + * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 13 | + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 14 | + * GNU General Public License for more details. |
| 15 | + * |
| 16 | + * You should have received a copy of the GNU General Public License |
| 17 | + * along with OpenXcom. If not, see <http://www.gnu.org/licenses/>. |
| 18 | + */ |
| 19 | +#include "NewPossibleManufactureState.h" |
| 20 | +#include "../Engine/Game.h" |
| 21 | +#include "../Engine/Palette.h" |
| 22 | +#include "../Engine/Language.h" |
| 23 | +#include "../Resource/ResourcePack.h" |
| 24 | +#include "../Interface/TextButton.h" |
| 25 | +#include "../Interface/Window.h" |
| 26 | +#include "../Interface/Text.h" |
| 27 | +#include "../Interface/TextList.h" |
| 28 | +#include "../Ruleset/RuleManufacture.h" |
| 29 | +#include "../Basescape/ManufactureState.h" |
| 30 | + |
| 31 | +namespace OpenXcom |
| 32 | +{ |
| 33 | +/** |
| 34 | + * Initializes all the elements in the EndManufacture screen. |
| 35 | + * @param game Pointer to the core game. |
| 36 | + * @param base Pointer to the base to get info from. |
| 37 | + * @param possibilities List of newly possible ManufactureProject |
| 38 | + */ |
| 39 | +NewPossibleManufactureState::NewPossibleManufactureState(Game * game, Base * base, const std::vector<RuleManufacture *> & possibilities) : State (game), _base(base) |
| 40 | +{ |
| 41 | + _screen = false; |
| 42 | + |
| 43 | + // Create objects |
| 44 | + _window = new Window(this, 288, 180, 16, 10); |
| 45 | + _btnOk = new TextButton(160, 14, 80, 149); |
| 46 | + _btnManufacture = new TextButton(160, 14, 80, 165); |
| 47 | + _txtTitle = new Text(288, 40, 16, 20); |
| 48 | + _lstPossibilities = new TextList(288, 80, 16, 56); |
| 49 | + |
| 50 | + // Set palette |
| 51 | + _game->setPalette(_game->getResourcePack()->getPalette("BACKPALS.DAT")->getColors(Palette::blockOffset(6)), Palette::backPos, 16); |
| 52 | + |
| 53 | + add(_window); |
| 54 | + add(_btnOk); |
| 55 | + add(_btnManufacture); |
| 56 | + add(_txtTitle); |
| 57 | + add(_lstPossibilities); |
| 58 | + |
| 59 | + // Set up objects |
| 60 | + _window->setColor(Palette::blockOffset(15)-1); |
| 61 | + _window->setBackground(_game->getResourcePack()->getSurface("BACK17.SCR")); |
| 62 | + |
| 63 | + _btnOk->setColor(Palette::blockOffset(8)+5); |
| 64 | + _btnOk->setText(_game->getLanguage()->getString("STR_OK")); |
| 65 | + _btnOk->onMouseClick((ActionHandler)&NewPossibleManufactureState::btnOkClick); |
| 66 | + _btnManufacture->setColor(Palette::blockOffset(8)+5); |
| 67 | + _btnManufacture->setText(_game->getLanguage()->getString("STR_ALLOCATE_MANUFACTURE")); |
| 68 | + _btnManufacture->onMouseClick((ActionHandler)&NewPossibleManufactureState::btnManufactureClick); |
| 69 | + _txtTitle->setColor(Palette::blockOffset(15)-1); |
| 70 | + _txtTitle->setBig(); |
| 71 | + _txtTitle->setAlign(ALIGN_CENTER); |
| 72 | + _txtTitle->setText(_game->getLanguage()->getString("STR_WE_CAN_NOW_PRODUCE")); |
| 73 | + |
| 74 | + _lstPossibilities->setColor(Palette::blockOffset(8)+10); |
| 75 | + _lstPossibilities->setColumns(1, 288); |
| 76 | + _lstPossibilities->setBig(); |
| 77 | + _lstPossibilities->setAlign(ALIGN_CENTER); |
| 78 | + for(std::vector<RuleManufacture *>::const_iterator iter = possibilities.begin (); iter != possibilities.end (); ++iter) |
| 79 | + { |
| 80 | + _lstPossibilities->addRow (1, _game->getLanguage()->getString((*iter)->getName ()).c_str()); |
| 81 | + } |
| 82 | +} |
| 83 | + |
| 84 | +/** |
| 85 | + * Resets the palette. |
| 86 | + */ |
| 87 | +void NewPossibleManufactureState::init() |
| 88 | +{ |
| 89 | + _game->setPalette(_game->getResourcePack()->getPalette("BACKPALS.DAT")->getColors(Palette::blockOffset(6)), Palette::backPos, 16); |
| 90 | +} |
| 91 | + |
| 92 | +/** |
| 93 | + * return to the previous screen |
| 94 | + * @param action Pointer to an action. |
| 95 | + */ |
| 96 | +void NewPossibleManufactureState::btnOkClick(Action *action) |
| 97 | +{ |
| 98 | + _game->popState (); |
| 99 | +} |
| 100 | + |
| 101 | +/** |
| 102 | + * Open the ManufactureState so the player can dispatch available scientist. |
| 103 | + * @param action Pointer to an action. |
| 104 | + */ |
| 105 | +void NewPossibleManufactureState::btnManufactureClick(Action *action) |
| 106 | +{ |
| 107 | + _game->popState(); |
| 108 | + _game->pushState (new ManufactureState(_game, _base)); |
| 109 | +} |
| 110 | +} |
0 commit comments