Skip to content

Commit eb6afd3

Browse files
author
Guido Pinkas
committed
Ufopedia section UFOs added
1 parent 5649e8f commit eb6afd3

10 files changed

Lines changed: 256 additions & 18 deletions

‎src/Ruleset/ArticleDefinition.cpp‎

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,4 +83,11 @@ namespace OpenXcom
8383
*/
8484
ArticleDefinitionTextImage::ArticleDefinitionTextImage() : ArticleDefinition(UFOPAEDIA_TYPE_TEXTIMAGE)
8585
{}
86+
87+
/**
88+
* Constructor (only setting type of base class)
89+
*/
90+
ArticleDefinitionUfo::ArticleDefinitionUfo() : ArticleDefinition(UFOPAEDIA_TYPE_UFO), ufo(0)
91+
{}
92+
8693
}

‎src/Ruleset/ArticleDefinition.h‎

Lines changed: 26 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -27,19 +27,20 @@ namespace OpenXcom
2727
{
2828
class RuleCraft;
2929
class RuleCraftWeapon;
30+
class RuleUfo;
3031

3132
/// define article types
3233
enum UfopaediaTypeId {
33-
UFOPAEDIA_TYPE_UNKNOWN = 0,
34-
UFOPAEDIA_TYPE_CRAFT = 1,
35-
UFOPAEDIA_TYPE_CRAFT_WEAPON = 2,
36-
UFOPAEDIA_TYPE_HWP = 3,
37-
UFOPAEDIA_TYPE_EQUIPMENT = 4,
38-
UFOPAEDIA_TYPE_WEAPON = 5,
39-
UFOPAEDIA_TYPE_FACILITY = 6,
40-
UFOPAEDIA_TYPE_TEXTIMAGE = 7,
41-
UFOPAEDIA_TYPE_TEXT = 8,
42-
UFOPAEDIA_TYPE_UFO = 9
34+
UFOPAEDIA_TYPE_UNKNOWN = 0,
35+
UFOPAEDIA_TYPE_CRAFT = 1,
36+
UFOPAEDIA_TYPE_CRAFT_WEAPON = 2,
37+
UFOPAEDIA_TYPE_HWP = 3,
38+
UFOPAEDIA_TYPE_EQUIPMENT = 4,
39+
UFOPAEDIA_TYPE_WEAPON = 5,
40+
UFOPAEDIA_TYPE_FACILITY = 6,
41+
UFOPAEDIA_TYPE_TEXTIMAGE = 7,
42+
UFOPAEDIA_TYPE_TEXT = 8,
43+
UFOPAEDIA_TYPE_UFO = 9
4344
};
4445

4546
/**
@@ -145,6 +146,21 @@ namespace OpenXcom
145146
int text_width;
146147
};
147148

149+
/**
150+
* ArticleDefinitionUfo defines articles for UFOs, e.g. Small Scout, Terror Ship, etc.
151+
* They have an image (found in INTERWIN.DAT), a stats block and a description.
152+
*/
153+
154+
class ArticleDefinitionUfo : public ArticleDefinition
155+
{
156+
public:
157+
/// Constructor
158+
ArticleDefinitionUfo();
159+
160+
RuleUfo *ufo;
161+
std::string text;
162+
};
163+
148164
}
149165

150166
#endif

‎src/Ruleset/XcomRuleset.cpp‎

Lines changed: 19 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1314,47 +1314,47 @@ XcomRuleset::XcomRuleset() : Ruleset()
13141314
article_craft_weapon.title = "STR_STINGRAY";
13151315
article_craft_weapon.image_id = "UP006.SPK";
13161316
article_craft_weapon.weapon = _craftWeapons[article_craft_weapon.id];
1317-
article_craft.sort_key = sort_key++;
1317+
article_craft_weapon.sort_key = sort_key++;
13181318

13191319
_ufopaediaArticles[article_craft_weapon.id] = new ArticleDefinitionCraftWeapon(article_craft_weapon);
13201320

13211321
article_craft_weapon.id = "STR_AVALANCHE";
13221322
article_craft_weapon.title = "STR_AVALANCHE";
13231323
article_craft_weapon.image_id = "UP007.SPK";
13241324
article_craft_weapon.weapon = _craftWeapons[article_craft_weapon.id];
1325-
article_craft.sort_key = sort_key++;
1325+
article_craft_weapon.sort_key = sort_key++;
13261326

13271327
_ufopaediaArticles[article_craft_weapon.id] = new ArticleDefinitionCraftWeapon(article_craft_weapon);
13281328

13291329
article_craft_weapon.id = "STR_CANNON_UC";
13301330
article_craft_weapon.title = "STR_CANNON_UC";
13311331
article_craft_weapon.image_id = "UP008.SPK";
13321332
article_craft_weapon.weapon = _craftWeapons[article_craft_weapon.id];
1333-
article_craft.sort_key = sort_key++;
1333+
article_craft_weapon.sort_key = sort_key++;
13341334

13351335
_ufopaediaArticles[article_craft_weapon.id] = new ArticleDefinitionCraftWeapon(article_craft_weapon);
13361336

13371337
article_craft_weapon.id = "STR_FUSION_BALL_UC";
13381338
article_craft_weapon.title = "STR_FUSION_BALL_UC";
13391339
article_craft_weapon.image_id = "UP009.SPK";
13401340
article_craft_weapon.weapon = _craftWeapons[article_craft_weapon.id];
1341-
article_craft.sort_key = sort_key++;
1341+
article_craft_weapon.sort_key = sort_key++;
13421342

13431343
_ufopaediaArticles[article_craft_weapon.id] = new ArticleDefinitionCraftWeapon(article_craft_weapon);
13441344

13451345
article_craft_weapon.id = "STR_LASER_CANNON_UC";
13461346
article_craft_weapon.title = "STR_LASER_CANNON_UC";
13471347
article_craft_weapon.image_id = "UP010.SPK";
13481348
article_craft_weapon.weapon = _craftWeapons[article_craft_weapon.id];
1349-
article_craft.sort_key = sort_key++;
1349+
article_craft_weapon.sort_key = sort_key++;
13501350

13511351
_ufopaediaArticles[article_craft_weapon.id] = new ArticleDefinitionCraftWeapon(article_craft_weapon);
13521352

13531353
article_craft_weapon.id = "STR_PLASMA_BEAM_UC";
13541354
article_craft_weapon.title = "STR_PLASMA_BEAM_UC";
13551355
article_craft_weapon.image_id = "UP011.SPK";
13561356
article_craft_weapon.weapon = _craftWeapons[article_craft_weapon.id];
1357-
article_craft.sort_key = sort_key++;
1357+
article_craft_weapon.sort_key = sort_key++;
13581358

13591359
_ufopaediaArticles[article_craft_weapon.id] = new ArticleDefinitionCraftWeapon(article_craft_weapon);
13601360

@@ -1391,6 +1391,19 @@ XcomRuleset::XcomRuleset() : Ruleset()
13911391

13921392
_ufopaediaArticles[article_text.id] = new ArticleDefinitionText(article_text);
13931393

1394+
// UFOs
1395+
ArticleDefinitionUfo article_ufo;
1396+
article_ufo.section = UFOPAEDIA_UFOS;
1397+
1398+
article_ufo.id = "STR_SMALL_SCOUT";
1399+
article_ufo.title = "STR_SMALL_SCOUT";
1400+
article_ufo.text = "STR_SMALL_SCOUT_UFOPEDIA";
1401+
article_ufo.ufo = _ufos[article_ufo.id];
1402+
article_ufo.sort_key = sort_key++;
1403+
1404+
_ufopaediaArticles[article_text.id] = new ArticleDefinitionUfo(article_ufo);
1405+
1406+
13941407
_costSoldier = 20000;
13951408
_costEngineer = 25000;
13961409
_costScientist = 30000;

‎src/Ufopaedia/ArticleStateCraft.cpp‎

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -71,14 +71,13 @@ namespace OpenXcom
7171
_lstInfo = new TextList(defs->rect_stats.width, defs->rect_stats.height, defs->rect_stats.x, defs->rect_stats.y);
7272
add(_lstInfo);
7373

74-
std::wstringstream ss;
7574
_lstInfo->setColor(Palette::blockOffset(14)+15);
7675
_lstInfo->setColumns(2, 82, 40);
7776
_lstInfo->setCondensed(true);
7877

78+
std::wstringstream ss;
7979
ss.str(L"");ss.clear();
8080
ss << defs->craft->getMaxSpeed();
81-
8281
_lstInfo->addRow(2, _game->getLanguage()->getString("STR_MAXIMUM_SPEED_UC").c_str(), ss.str().c_str());
8382
_lstInfo->getCell(0, 1)->setColor(Palette::blockOffset(15)+4);
8483

‎src/Ufopaedia/ArticleStateUfo.cpp‎

Lines changed: 129 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,129 @@
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+
}

‎src/Ufopaedia/ArticleStateUfo.h‎

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
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+
#ifndef OPENXCOM_ARTICLESTATEUFO_H
21+
#define OPENXCOM_ARTICLESTATEUFO_H
22+
23+
#include <string>
24+
#include "ArticleState.h"
25+
26+
namespace OpenXcom
27+
{
28+
class Game;
29+
class Surface;
30+
class Text;
31+
class TextList;
32+
class ArticleDefinitionUfo;
33+
34+
/**
35+
* ArticleStateUfo has a caption, text, preview image and a stats block.
36+
* The UFO image is found using the RuleUfo class.
37+
*/
38+
39+
class ArticleStateUfo : public ArticleState
40+
{
41+
public:
42+
ArticleStateUfo(Game *game, ArticleDefinitionUfo *article_defs);
43+
virtual ~ArticleStateUfo();
44+
45+
protected:
46+
Surface *_image;
47+
Text *_txtTitle;
48+
Text *_txtInfo;
49+
TextList *_lstInfo;
50+
};
51+
}
52+
53+
#endif

‎src/Ufopaedia/Ufopaedia.cpp‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626
#include "ArticleStateCraftWeapon.h"
2727
#include "ArticleStateText.h"
2828
#include "ArticleStateTextImage.h"
29+
#include "ArticleStateUfo.h"
2930
#include "../Engine/Game.h"
3031
#include "../Engine/Language.h"
3132

@@ -68,6 +69,9 @@ namespace OpenXcom
6869
case UFOPAEDIA_TYPE_TEXTIMAGE:
6970
return new ArticleStateTextImage(game, static_cast<ArticleDefinitionTextImage *> (article));
7071
break;
72+
case UFOPAEDIA_TYPE_UFO:
73+
return new ArticleStateUfo(game, static_cast<ArticleDefinitionUfo *> (article));
74+
break;
7175
}
7276
return 0;
7377
}

‎src/Ufopaedia/Ufopaedia.h‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ namespace OpenXcom
3535
static const std::string UFOPAEDIA_XCOM_CRAFT_ARMAMENT = "XCOM_CRAFT_ARMAMENT";
3636
static const std::string UFOPAEDIA_ALIEN_LIFE_FORMS = "ALIEN_LIFE_FORMS";
3737
static const std::string UFOPAEDIA_ALIEN_RESEARCH = "ALIEN_RESEARCH";
38+
static const std::string UFOPAEDIA_UFOS = "UFOS";
3839

3940
/**
4041
* This static class encapsulates all functions related to Ufopaedia

0 commit comments

Comments
 (0)