Add ScriptStoryPageElementList to get the contents of a page
[openttd/fttd.git] / src / news_type.h
blobfee7ae38e364835f4da698c03186c33b00b08f9b
1 /* $Id$ */
3 /*
4 * This file is part of OpenTTD.
5 * OpenTTD is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, version 2.
6 * OpenTTD is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
7 * See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with OpenTTD. If not, see <http://www.gnu.org/licenses/>.
8 */
10 /** @file news_type.h Types related to news. */
12 #ifndef NEWS_TYPE_H
13 #define NEWS_TYPE_H
15 #include "core/enum_type.hpp"
16 #include "date_type.h"
17 #include "strings_type.h"
18 #include "sound_type.h"
20 /** Constants in the message options window. */
21 enum MessageOptionsSpace {
22 MOS_WIDG_PER_SETTING = 4, ///< Number of widgets needed for each news category, starting at widget #WID_MO_START_OPTION.
24 MOS_LEFT_EDGE = 6, ///< Number of pixels between left edge of the window and the options buttons column.
25 MOS_COLUMN_SPACING = 4, ///< Number of pixels between the buttons and the description columns.
26 MOS_RIGHT_EDGE = 6, ///< Number of pixels between right edge of the window and the options descriptions column.
27 MOS_BUTTON_SPACE = 10, ///< Additional space in the button with the option value (for better looks).
29 MOS_ABOVE_GLOBAL_SETTINGS = 6, ///< Number of vertical pixels between the categories and the global options.
30 MOS_BOTTOM_EDGE = 6, ///< Number of pixels between bottom edge of the window and bottom of the global options.
33 /**
34 * Type of news.
36 enum NewsType {
37 NT_ARRIVAL_COMPANY, ///< First vehicle arrived for company
38 NT_ARRIVAL_OTHER, ///< First vehicle arrived for competitor
39 NT_ACCIDENT, ///< An accident or disaster has occurred
40 NT_COMPANY_INFO, ///< Company info (new companies, bankruptcy messages)
41 NT_INDUSTRY_OPEN, ///< Opening of industries
42 NT_INDUSTRY_CLOSE, ///< Closing of industries
43 NT_ECONOMY, ///< Economic changes (recession, industry up/dowm)
44 NT_INDUSTRY_COMPANY,///< Production changes of industry serviced by local company
45 NT_INDUSTRY_OTHER, ///< Production changes of industry serviced by competitor(s)
46 NT_INDUSTRY_NOBODY, ///< Other industry production changes
47 NT_ADVICE, ///< Bits of news about vehicles of the company
48 NT_NEW_VEHICLES, ///< New vehicle has become available
49 NT_ACCEPTANCE, ///< A type of cargo is (no longer) accepted
50 NT_SUBSIDIES, ///< News about subsidies (announcements, expirations, acceptance)
51 NT_GENERAL, ///< General news (from towns)
52 NT_END, ///< end-of-array marker
55 /**
56 * References to objects in news.
58 * @warning
59 * Be careful!
60 * Vehicles are a special case, as news are kept when vehicles are autoreplaced/renewed.
61 * You have to make sure, #ChangeVehicleNews catches the DParams of your message.
62 * This is NOT ensured by the references.
64 enum NewsReferenceType {
65 NR_NONE, ///< Empty reference
66 NR_TILE, ///< Reference tile. Scroll to tile when clicking on the news.
67 NR_VEHICLE, ///< Reference vehicle. Scroll to vehicle when clicking on the news. Delete news when vehicle is deleted.
68 NR_STATION, ///< Reference station. Scroll to station when clicking on the news. Delete news when station is deleted.
69 NR_INDUSTRY, ///< Reference industry. Scroll to industry when clicking on the news. Delete news when industry is deleted.
70 NR_TOWN, ///< Reference town. Scroll to town when clicking on the news.
71 NR_ENGINE, ///< Reference engine.
74 /**
75 * Various OR-able news-item flags.
76 * @note #NF_INCOLOUR is set automatically if needed.
78 enum NewsFlag {
79 NFB_INCOLOUR = 0, ///< News item is shown in colour (otherwise it is shown in black & white).
80 NFB_NO_TRANSPARENT = 1, ///< News item disables transparency in the viewport.
81 NFB_SHADE = 2, ///< News item uses shaded colours.
82 NFB_WINDOW_LAYOUT = 3, ///< First bit for window layout.
83 NFB_WINDOW_LAYOUT_COUNT = 3, ///< Number of bits for window layout.
84 NFB_VEHICLE_PARAM0 = 6, ///< String param 0 contains a vehicle ID. (special autoreplace behaviour)
86 NF_INCOLOUR = 1 << NFB_INCOLOUR, ///< Bit value for coloured news.
87 NF_NO_TRANSPARENT = 1 << NFB_NO_TRANSPARENT, ///< Bit value for disabling transparency.
88 NF_SHADE = 1 << NFB_SHADE, ///< Bit value for enabling shading.
89 NF_VEHICLE_PARAM0 = 1 << NFB_VEHICLE_PARAM0, ///< Bit value for specifying that string param 0 contains a vehicle ID. (special autoreplace behaviour)
91 NF_THIN = 0 << NFB_WINDOW_LAYOUT, ///< Thin news item. (Newspaper with headline and viewport)
92 NF_SMALL = 1 << NFB_WINDOW_LAYOUT, ///< Small news item. (Information window with text and viewport)
93 NF_NORMAL = 2 << NFB_WINDOW_LAYOUT, ///< Normal news item. (Newspaper with text only)
94 NF_VEHICLE = 3 << NFB_WINDOW_LAYOUT, ///< Vehicle news item. (new engine available)
95 NF_COMPANY = 4 << NFB_WINDOW_LAYOUT, ///< Company news item. (Newspaper with face)
97 DECLARE_ENUM_AS_BIT_SET(NewsFlag)
101 * News display options
103 enum NewsDisplay {
104 ND_OFF, ///< Only show a reminder in the status bar
105 ND_SUMMARY, ///< Show ticker
106 ND_FULL, ///< Show newspaper
110 * Per-NewsType data
112 struct NewsTypeData {
113 const char * const name; ///< Name
114 const byte age; ///< Maximum age of news items (in days)
115 const SoundFx sound; ///< Sound
118 * Construct this entry.
119 * @param name The name of the type.
120 * @param age The maximum age for these messages.
121 * @param sound The sound to play.
123 NewsTypeData(const char *name, byte age, SoundFx sound) :
124 name(name),
125 age(age),
126 sound(sound)
130 NewsDisplay GetDisplay() const;
133 /** Information about a single item of news. */
134 struct NewsItem {
135 NewsItem *prev; ///< Previous news item
136 NewsItem *next; ///< Next news item
137 StringID string_id; ///< Message text
138 Date date; ///< Date of the news
139 NewsType type; ///< Type of the news
140 NewsFlag flags; ///< NewsFlags bits @see NewsFlag
142 NewsReferenceType reftype1; ///< Type of ref1
143 NewsReferenceType reftype2; ///< Type of ref2
144 uint32 ref1; ///< Reference 1 to some object: Used for a possible viewport, scrolling after clicking on the news, and for deleteing the news when the object is deleted.
145 uint32 ref2; ///< Reference 2 to some object: Used for scrolling after clicking on the news, and for deleteing the news when the object is deleted.
147 void *free_data; ///< Data to be freed when the news item has reached its end.
149 ~NewsItem()
151 free(this->free_data);
154 uint64 params[10]; ///< Parameters for string resolving.
158 * Data that needs to be stored for company news messages.
159 * The problem with company news messages are the custom name
160 * of the companies and the fact that the company data is reset,
161 * resulting in wrong names and such.
163 struct CompanyNewsInformation {
164 char company_name[64]; ///< The name of the company
165 char president_name[64]; ///< The name of the president
166 char other_company_name[64]; ///< The name of the company taking over this one
168 uint32 face; ///< The face of the president
169 byte colour; ///< The colour related to the company
171 void FillData(const struct Company *c, const struct Company *other = NULL);
174 #endif /* NEWS_TYPE_H */