1 /* 2 * Copyright 2010-2014 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 "ArticleStateCraft.h" 24 #include "../Ruleset/ArticleDefinition.h" 25 #include "../Ruleset/Ruleset.h" 26 #include "../Ruleset/RuleCraft.h" 27 #include "../Engine/Game.h" 28 #include "../Engine/Palette.h" 29 #include "../Engine/Surface.h" 30 #include "../Engine/Language.h" 31 #include "../Resource/ResourcePack.h" 32 #include "../Interface/Text.h" 33 #include "../Interface/TextButton.h" 34 35 namespace OpenXcom 36 { 37 ArticleStateCraft(Game * game,ArticleDefinitionCraft * defs)38 ArticleStateCraft::ArticleStateCraft(Game *game, ArticleDefinitionCraft *defs) : ArticleState(game, defs->id) 39 { 40 RuleCraft *craft = _game->getRuleset()->getCraft(defs->id); 41 42 // add screen elements 43 _txtTitle = new Text(155, 32, 5, 24); 44 45 // Set palette 46 setPalette("PAL_UFOPAEDIA"); 47 48 ArticleState::initLayout(); 49 50 // add other elements 51 add(_txtTitle); 52 53 // Set up objects 54 _game->getResourcePack()->getSurface(defs->image_id)->blit(_bg); 55 _btnOk->setColor(Palette::blockOffset(15)-1); 56 _btnPrev->setColor(Palette::blockOffset(15)-1); 57 _btnNext->setColor(Palette::blockOffset(15)-1); 58 59 _txtTitle->setColor(Palette::blockOffset(14)+15); 60 _txtTitle->setBig(); 61 _txtTitle->setWordWrap(true); 62 _txtTitle->setText(tr(defs->title)); 63 64 _txtInfo = new Text(defs->rect_text.width, defs->rect_text.height, defs->rect_text.x, defs->rect_text.y); 65 add(_txtInfo); 66 67 _txtInfo->setColor(Palette::blockOffset(14)+15); 68 _txtInfo->setWordWrap(true); 69 _txtInfo->setText(tr(defs->text)); 70 71 _txtStats = new Text(defs->rect_stats.width, defs->rect_stats.height, defs->rect_stats.x, defs->rect_stats.y); 72 add(_txtStats); 73 74 _txtStats->setColor(Palette::blockOffset(14)+15); 75 _txtStats->setSecondaryColor(Palette::blockOffset(15)+4); 76 77 std::wostringstream ss; 78 ss << tr("STR_MAXIMUM_SPEED_UC").arg(Text::formatNumber(craft->getMaxSpeed())) << L'\n'; 79 ss << tr("STR_ACCELERATION").arg(craft->getAcceleration()) << L'\n'; 80 ss << tr("STR_FUEL_CAPACITY").arg(Text::formatNumber(craft->getMaxFuel())) << L'\n'; 81 ss << tr("STR_WEAPON_PODS").arg(craft->getWeapons()) << L'\n'; 82 ss << tr("STR_DAMAGE_CAPACITY_UC").arg(Text::formatNumber(craft->getMaxDamage())) << L'\n'; 83 ss << tr("STR_CARGO_SPACE").arg(craft->getSoldiers()) << L'\n'; 84 ss << tr("STR_HWP_CAPACITY").arg(craft->getVehicles()); 85 _txtStats->setText(ss.str()); 86 87 centerAllSurfaces(); 88 } 89 ~ArticleStateCraft()90 ArticleStateCraft::~ArticleStateCraft() 91 {} 92 93 } 94