|
| 1 | +/* |
| 2 | + * Copyright 2011 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 | + |
| 20 | +#include <sstream> |
| 21 | + |
| 22 | +#include "Ufopaedia.h" |
| 23 | +#include "ArticleStateUfo.h" |
| 24 | +#include "../Ruleset/ArticleDefinition.h" |
| 25 | +#include "../Ruleset/RuleUfo.h" |
| 26 | +#include "../Engine/Game.h" |
| 27 | +#include "../Engine/Palette.h" |
| 28 | +#include "../Engine/Surface.h" |
| 29 | +#include "../Engine/Language.h" |
| 30 | +#include "../Resource/ResourcePack.h" |
| 31 | +#include "../Interface/Text.h" |
| 32 | +#include "../Interface/TextButton.h" |
| 33 | +#include "../Interface/TextList.h" |
| 34 | + |
| 35 | +namespace OpenXcom |
| 36 | +{ |
| 37 | + |
| 38 | + ArticleStateUfo::ArticleStateUfo(Game *game, ArticleDefinitionUfo *defs) : ArticleState(game, defs->id) |
| 39 | + { |
| 40 | + // add screen elements |
| 41 | + _txtTitle = new Text(140, 32, 5, 24); |
| 42 | + |
| 43 | + // Set palette |
| 44 | + _game->setPalette(_game->getResourcePack()->getPalette("PALETTES.DAT_0")->getColors()); |
| 45 | + |
| 46 | + ArticleState::initLayout(); |
| 47 | + |
| 48 | + // add other elements |
| 49 | + add(_txtTitle); |
| 50 | + |
| 51 | + // Set up objects |
| 52 | + _game->getResourcePack()->getSurface("BACK11.SCR")->blit(_bg); |
| 53 | + _btnOk->setColor(Palette::blockOffset(8)+8); |
| 54 | + _btnPrev->setColor(Palette::blockOffset(8)+8); |
| 55 | + _btnNext->setColor(Palette::blockOffset(8)+8); |
| 56 | + |
| 57 | + _txtTitle->setColor(Palette::blockOffset(8)+5); |
| 58 | + _txtTitle->setBig(); |
| 59 | + _txtTitle->setAlign(ALIGN_LEFT); |
| 60 | + _txtTitle->setWordWrap(true); |
| 61 | + _txtTitle->setText(Ufopaedia::buildText(_game, defs->title)); |
| 62 | + |
| 63 | + _image = new Surface(160, 52, 160, 6); |
| 64 | + add(_image); |
| 65 | + |
| 66 | + Surface *graphic = _game->getResourcePack()->getSurface("INTERWIN.DAT"); |
| 67 | + graphic->setX(0); |
| 68 | + graphic->setY(0); |
| 69 | + graphic->getCrop()->x = 0; |
| 70 | + graphic->getCrop()->y = 0; |
| 71 | + graphic->getCrop()->w = 160; |
| 72 | + graphic->getCrop()->h = 52; |
| 73 | + _image->drawRect(graphic->getCrop(), 15); |
| 74 | +/* |
| 75 | + graphic->getCrop()->y = 96; |
| 76 | + graphic->getCrop()->h = 15; |
| 77 | + graphic->blit(_image); |
| 78 | + graphic->setY(67); |
| 79 | + graphic->getCrop()->y = 111; |
| 80 | + graphic->getCrop()->h = 29; |
| 81 | + graphic->blit(_image); |
| 82 | +*/ |
| 83 | + graphic->getCrop()->y = 140 + 52 * defs->ufo->getSprite(); |
| 84 | + graphic->getCrop()->h = 52; |
| 85 | + graphic->blit(_image); |
| 86 | + |
| 87 | + _txtInfo = new Text(300, 50, 10, 140); |
| 88 | + add(_txtInfo); |
| 89 | + |
| 90 | + _txtInfo->setColor(Palette::blockOffset(8)+5); |
| 91 | + _txtInfo->setAlign(ALIGN_LEFT); |
| 92 | + _txtInfo->setWordWrap(true); |
| 93 | + _txtInfo->setText(Ufopaedia::buildText(_game, defs->text)); |
| 94 | + |
| 95 | + _lstInfo = new TextList(300, 60, 10, 68); |
| 96 | + add(_lstInfo); |
| 97 | + |
| 98 | + _lstInfo->setColor(Palette::blockOffset(8)+5); |
| 99 | + _lstInfo->setColumns(2, 180, 120); |
| 100 | +// _lstInfo->setCondensed(true); |
| 101 | + _lstInfo->setBig(); |
| 102 | + _lstInfo->setDot(true); |
| 103 | + |
| 104 | + std::wstringstream ss; |
| 105 | + ss.str(L"");ss.clear(); |
| 106 | + ss << defs->ufo->getMaxDamage(); |
| 107 | + _lstInfo->addRow(2, _game->getLanguage()->getString("STR_DAMAGE_CAPACITY").c_str(), ss.str().c_str()); |
| 108 | + |
| 109 | + ss.str(L"");ss.clear(); |
| 110 | + ss << defs->ufo->getWeaponPower(); |
| 111 | + _lstInfo->addRow(2, _game->getLanguage()->getString("STR_WEAPON_POWER").c_str(), ss.str().c_str()); |
| 112 | + |
| 113 | + ss.str(L"");ss.clear(); |
| 114 | + ss << defs->ufo->getWeaponRange(); |
| 115 | + _lstInfo->addRow(2, _game->getLanguage()->getString("STR_WEAPON_RANGE").c_str(), ss.str().c_str()); |
| 116 | + |
| 117 | + ss.str(L"");ss.clear(); |
| 118 | + ss << defs->ufo->getMaxSpeed(); |
| 119 | + ss << " "; |
| 120 | + ss << _game->getLanguage()->getString("STR_KNOTS"); |
| 121 | + _lstInfo->addRow(2, _game->getLanguage()->getString("STR_MAXIMUM_SPEED").c_str(), ss.str().c_str()); |
| 122 | + |
| 123 | + _lstInfo->draw(); |
| 124 | + } |
| 125 | + |
| 126 | + ArticleStateUfo::~ArticleStateUfo() |
| 127 | + {} |
| 128 | + |
| 129 | +} |
0 commit comments