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 "ArticleStateUfo.h"
24 #include "../Ruleset/ArticleDefinition.h"
25 #include "../Ruleset/Ruleset.h"
26 #include "../Ruleset/RuleUfo.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 #include "../Interface/TextList.h"
35 
36 namespace OpenXcom
37 {
38 
ArticleStateUfo(Game * game,ArticleDefinitionUfo * defs)39 	ArticleStateUfo::ArticleStateUfo(Game *game, ArticleDefinitionUfo *defs) : ArticleState(game, defs->id)
40 	{
41 		RuleUfo *ufo = _game->getRuleset()->getUfo(defs->id);
42 
43 		// add screen elements
44 		_txtTitle = new Text(155, 32, 5, 24);
45 
46 		// Set palette
47 		setPalette("PAL_GEOSCAPE");
48 
49 		ArticleState::initLayout();
50 
51 		// add other elements
52 		add(_txtTitle);
53 
54 		// Set up objects
55 		_game->getResourcePack()->getSurface("BACK11.SCR")->blit(_bg);
56 		_btnOk->setColor(Palette::blockOffset(8)+5);
57 		_btnPrev->setColor(Palette::blockOffset(8)+5);
58 		_btnNext->setColor(Palette::blockOffset(8)+5);
59 
60 		_txtTitle->setColor(Palette::blockOffset(8)+5);
61 		_txtTitle->setBig();
62 		_txtTitle->setWordWrap(true);
63 		_txtTitle->setText(tr(defs->title));
64 
65 		_image = new Surface(160, 52, 160, 6);
66 		add(_image);
67 
68 		Surface *graphic = _game->getResourcePack()->getSurface("INTERWIN.DAT");
69 		graphic->setX(0);
70 		graphic->setY(0);
71 		graphic->getCrop()->x = 0;
72 		graphic->getCrop()->y = 0;
73 		graphic->getCrop()->w = 160;
74 		graphic->getCrop()->h = 52;
75 		_image->drawRect(graphic->getCrop(), 15);
76 /*
77 		graphic->getCrop()->y = 96;
78 		graphic->getCrop()->h = 15;
79 		graphic->blit(_image);
80 		graphic->setY(67);
81 		graphic->getCrop()->y = 111;
82 		graphic->getCrop()->h = 29;
83 		graphic->blit(_image);
84 */
85 		if (ufo->getModSprite() == "")
86 		{
87 			graphic->getCrop()->y = 140 + 52 * ufo->getSprite();
88 			graphic->getCrop()->h = 52;
89 		}
90 		else
91 		{
92 			graphic = _game->getResourcePack()->getSurface(ufo->getModSprite());
93 			graphic->setX(0);
94 			graphic->setY(0);
95 		}
96 		graphic->blit(_image);
97 
98 		_txtInfo = new Text(300, 50, 10, 140);
99 		add(_txtInfo);
100 
101 		_txtInfo->setColor(Palette::blockOffset(8)+5);
102 		_txtInfo->setWordWrap(true);
103 		_txtInfo->setText(tr(defs->text));
104 
105 		_lstInfo = new TextList(310, 64, 10, 68);
106 		add(_lstInfo);
107 
108 		centerAllSurfaces();
109 
110 		_lstInfo->setColor(Palette::blockOffset(8)+5);
111 		_lstInfo->setColumns(2, 200, 110);
112 //		_lstInfo->setCondensed(true);
113 		_lstInfo->setBig();
114 		_lstInfo->setDot(true);
115 
116 		_lstInfo->addRow(2, tr("STR_DAMAGE_CAPACITY").c_str(), Text::formatNumber(ufo->getMaxDamage()).c_str());
117 
118 		_lstInfo->addRow(2, tr("STR_WEAPON_POWER").c_str(), Text::formatNumber(ufo->getWeaponPower()).c_str());
119 
120 		_lstInfo->addRow(2, tr("STR_WEAPON_RANGE").c_str(), tr("STR_KILOMETERS").arg(ufo->getWeaponRange()).c_str());
121 
122 		_lstInfo->addRow(2, tr("STR_MAXIMUM_SPEED").c_str(), tr("STR_KNOTS").arg(Text::formatNumber(ufo->getMaxSpeed())).c_str());
123 	}
124 
~ArticleStateUfo()125 	ArticleStateUfo::~ArticleStateUfo()
126 	{}
127 
128 }
129