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 #ifndef OPENXCOM_ARTICLEDEFINITION_H
21 #define OPENXCOM_ARTICLEDEFINITION_H
22 
23 #include <string>
24 #include <vector>
25 #include <yaml-cpp/yaml.h>
26 
27 namespace OpenXcom
28 {
29 	/// define article types
30 	enum UfopaediaTypeId {
31 		UFOPAEDIA_TYPE_UNKNOWN         = 0,
32 		UFOPAEDIA_TYPE_CRAFT           = 1,
33 		UFOPAEDIA_TYPE_CRAFT_WEAPON    = 2,
34 		UFOPAEDIA_TYPE_VEHICLE         = 3,
35 		UFOPAEDIA_TYPE_ITEM            = 4,
36 		UFOPAEDIA_TYPE_ARMOR           = 5,
37 		UFOPAEDIA_TYPE_BASE_FACILITY   = 6,
38 		UFOPAEDIA_TYPE_TEXTIMAGE       = 7,
39 		UFOPAEDIA_TYPE_TEXT            = 8,
40 		UFOPAEDIA_TYPE_UFO             = 9
41 	};
42 
43 	/**
44 	 * ArticleDefinition is the base class for all article types.
45 	 * This class is used to store all information about articles
46 	 * required to generate an ArticleState from.
47 	 */
48 
49 	class ArticleDefinition
50 	{
51 	protected:
52 		/// Constructor (protected, so this class cannot be instantiated directly).
53 		ArticleDefinition(UfopaediaTypeId type_id);
54 
55 	public:
56 		/// Destructor.
57 		virtual ~ArticleDefinition();
58 		/// Gets the type of article definition.
59 		UfopaediaTypeId getType() const;
60 		/// Loads the article from YAML.
61 		virtual void load(const YAML::Node& node, int listOrder);
62 		/// Gets the article's list weight.
63 		int getListOrder() const;
64 
65 		std::string id;
66 		std::string title;
67 		std::string section;
68 		std::vector<std::string> requires;
69 
70 	protected:
71 		UfopaediaTypeId _type_id;
72 	private:
73 		int _listOrder;
74 	};
75 
76 	class ArticleDefinitionRect
77 	{
78 	public:
79 		ArticleDefinitionRect();
80 
81 		void set(int set_x, int set_y, int set_width, int set_height);
82 
83 		int x;
84 		int y;
85 		int width;
86 		int height;
87 	};
88 
89 	/**
90 	 * ArticleDefinitionCraft defines articles for craft, e.g. SKYRANGER.
91 	 * They have a large background image, a stats block and a description positioned differently.
92 	 */
93 
94 	class ArticleDefinitionCraft : public ArticleDefinition
95 	{
96 	public:
97 		/// Constructor.
98 		ArticleDefinitionCraft();
99 		/// Loads the article from YAML.
100 		void load(const YAML::Node& node, int listOrder);
101 
102 		std::string image_id;
103 		ArticleDefinitionRect rect_stats;
104 		ArticleDefinitionRect rect_text;
105 		std::string text;
106 	};
107 
108 	/**
109 	 * ArticleDefinitionCraftWeapon defines articles for craft weapons, e.g. STINGRAY, AVALANCHE.
110 	 * They have a large background image and a stats block.
111 	 */
112 
113 	class ArticleDefinitionCraftWeapon : public ArticleDefinition
114 	{
115 	public:
116 		/// Constructor.
117 		ArticleDefinitionCraftWeapon();
118 		/// Loads the article from YAML.
119 		void load(const YAML::Node& node, int listOrder);
120 
121 		std::string image_id;
122 		std::string text;
123 	};
124 
125 	/**
126 	 * ArticleDefinitionText defines articles with only text, e.g. ALIEN RESEARCH.
127 	 */
128 
129 	class ArticleDefinitionText : public ArticleDefinition
130 	{
131 		public:
132 		/// Constructor.
133 		ArticleDefinitionText();
134 		/// Loads the article from YAML.
135 		void load(const YAML::Node& node, int listOrder);
136 
137 		std::string text;
138 	};
139 
140 	/**
141 	 * ArticleDefinitionTextImage defines articles with text on the left and
142 	 * an image on the right side of the screen, e.g. ALIEN LIFEFORMS, UFO COMPONENTS.
143 	 */
144 
145 	class ArticleDefinitionTextImage : public ArticleDefinition
146 	{
147 		public:
148 		/// Constructor.
149 		ArticleDefinitionTextImage();
150 		/// Loads the article from YAML.
151 		void load(const YAML::Node& node, int listOrder);
152 
153 		std::string image_id;
154 		std::string text;
155 		int text_width;
156 	};
157 
158 	/**
159 	 * ArticleDefinitionBaseFacility defines articles for base facilities, e.g. Access lift.
160 	 * They have an image (found in BASEBITS.PCK), a stats block and a description.
161 	 */
162 
163 	class ArticleDefinitionBaseFacility : public ArticleDefinition
164 	{
165 	public:
166 		/// Constructor.
167 		ArticleDefinitionBaseFacility();
168 		/// Loads the article from YAML.
169 		void load(const YAML::Node& node, int listOrder);
170 
171 		std::string text;
172 	};
173 
174 	/**
175 	 * ArticleDefinitionItem defines articles for all Items, e.g. Weapons, Ammo, Equipment, etc.
176 	 * They have an image (found in BIGOBS.PCK), an optional stats block, maybe ammo and a description.
177 	 */
178 
179 	class ArticleDefinitionItem : public ArticleDefinition
180 	{
181 	public:
182 		/// Constructor.
183 		ArticleDefinitionItem();
184 		/// Loads the article from YAML.
185 		void load(const YAML::Node& node, int listOrder);
186 
187 		std::string text;
188 	};
189 
190 	/**
191 	 * ArticleDefinitionUfo defines articles for UFOs, e.g. Small Scout, Terror Ship, etc.
192 	 * They have an image (found in INTERWIN.DAT), a stats block and a description.
193 	 */
194 
195 	class ArticleDefinitionUfo : public ArticleDefinition
196 	{
197 	public:
198 		/// Constructor.
199 		ArticleDefinitionUfo();
200 		/// Loads the article from YAML.
201 		void load(const YAML::Node& node, int listOrder);
202 
203 		std::string text;
204 	};
205 
206 	/**
207 	 * ArticleDefinitionArmor defines articles for Armor, e.g. Personal Armor, Flying Suit, etc.
208 	 * They have an image (found in MAN_*.SPK) and a stats block.
209 	 */
210 
211 	class ArticleDefinitionArmor : public ArticleDefinition
212 	{
213 	public:
214 		/// Constructor.
215 		ArticleDefinitionArmor();
216 		/// Loads the article from YAML.
217 		void load(const YAML::Node& node, int listOrder);
218 
219 		std::string text;
220 	};
221 
222 	/**
223 	 * ArticleDefinitionVehicle defines articles for Vehicles, e.g. Tanks, etc.
224 	 * They have a text description and a stats block.
225 	 */
226 
227 	class ArticleDefinitionVehicle : public ArticleDefinition
228 	{
229 	public:
230 		/// Constructor.
231 		ArticleDefinitionVehicle();
232 		/// Loads the article from YAML.
233 		void load(const YAML::Node& node, int listOrder);
234 
235 		std::string text;
236 		std::string weapon;
237 	};
238 
239 
240 }
241 
242 #endif
243