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/>.
10 /** @file news_type.h Types related to news. */
15 #include "core/enum_type.hpp"
16 #include "date_type.h"
17 #include "strings_type.h"
18 #include "sound_type.h"
24 NT_ARRIVAL_COMPANY
, ///< Cargo arrived for company
25 NT_ARRIVAL_OTHER
, ///< Cargo arrived for competitor
26 NT_ACCIDENT
, ///< An accident or disaster has occurred
27 NT_COMPANY_INFO
, ///< Company info (new companies, bankruptcy messages)
28 NT_INDUSTRY_OPEN
, ///< Opening of industries
29 NT_INDUSTRY_CLOSE
, ///< Closing of industries
30 NT_ECONOMY
, ///< Economic changes (recession, industry up/dowm)
31 NT_INDUSTRY_COMPANY
,///< Production changes of industry serviced by local company
32 NT_INDUSTRY_OTHER
, ///< Production changes of industry serviced by competitor(s)
33 NT_INDUSTRY_NOBODY
, ///< Other industry production changes
34 NT_ADVICE
, ///< Bits of news about vehicles of the company
35 NT_NEW_VEHICLES
, ///< New vehicle has become available
36 NT_ACCEPTANCE
, ///< A type of cargo is (no longer) accepted
37 NT_SUBSIDIES
, ///< News about subsidies (announcements, expirations, acceptance)
38 NT_GENERAL
, ///< General news (from towns)
39 NT_END
, ///< end-of-array marker
46 NS_ARRIVAL_COMPANY
, ///< NT_ARRIVAL_COMPANY
47 NS_ARRIVAL_OTHER
, ///< NT_ARRIVAL_OTHER
48 NS_ACCIDENT
, ///< NT_ACCIDENT
49 NS_COMPANY_TROUBLE
, ///< NT_COMPANY_INFO (trouble)
50 NS_COMPANY_MERGER
, ///< NT_COMPANY_INFO (merger)
51 NS_COMPANY_BANKRUPT
, ///< NT_COMPANY_INFO (bankrupt)
52 NS_COMPANY_NEW
, ///< NT_COMPANY_INFO (new company)
53 NS_INDUSTRY_OPEN
, ///< NT_INDUSTRY_OPEN
54 NS_INDUSTRY_CLOSE
, ///< NT_INDUSTRY_CLOSE
55 NS_ECONOMY
, ///< NT_ECONOMY
56 NS_INDUSTRY_COMPANY
, ///< NT_INDUSTRY_COMPANY
57 NS_INDUSTRY_OTHER
, ///< NT_INDUSTRY_OTHER
58 NS_INDUSTRY_NOBODY
, ///< NT_INDUSTRY_NOBODY
59 NS_ADVICE
, ///< NT_ADVICE
60 NS_NEW_VEHICLES
, ///< NT_NEW_VEHICLES
61 NS_ACCEPTANCE
, ///< NT_ACCEPTANCE
62 NS_SUBSIDIES
, ///< NT_SUBSIDIES
63 NS_GENERAL
, ///< NT_GENERAL
64 NS_END
, ///< end-of-array marker
68 * References to objects in news.
72 * Vehicles are a special case, as news are kept when vehicles are autoreplaced/renewed.
73 * You have to make sure, #ChangeVehicleNews catches the DParams of your message.
74 * This is NOT ensured by the references.
76 enum NewsReferenceType
{
77 NR_NONE
, ///< Empty reference
78 NR_TILE
, ///< Reference tile. Scroll to tile when clicking on the news.
79 NR_VEHICLE
, ///< Reference vehicle. Scroll to vehicle when clicking on the news. Delete news when vehicle is deleted.
80 NR_STATION
, ///< Reference station. Scroll to station when clicking on the news. Delete news when station is deleted.
81 NR_INDUSTRY
, ///< Reference industry. Scroll to industry when clicking on the news. Delete news when industry is deleted.
82 NR_TOWN
, ///< Reference town. Scroll to town when clicking on the news.
83 NR_ENGINE
///< Reference engine.
87 * Various OR-able news-item flags.
88 * @note #NF_INCOLOUR is set automatically if needed.
91 NFB_INCOLOUR
= 0, ///< News item is shown in colour (otherwise it is shown in black & white).
92 NFB_NO_TRANSPARENT
= 1, ///< News item disables transparency in the viewport.
93 NFB_SHADE
= 2, ///< News item uses shaded colours.
95 NF_NONE
= 0, ///< No flag is set.
96 NF_INCOLOUR
= 1 << 0, ///< Bit value for coloured news.
97 NF_NO_TRANSPARENT
= 1 << 1, ///< Bit value for disabling transparency.
98 NF_SHADE
= 1 << 2, ///< Bit value for enabling shading.
100 DECLARE_ENUM_AS_BIT_SET(NewsFlag
)
104 * News display options
107 ND_OFF
, ///< Only show a reminder in the status bar
108 ND_SUMMARY
, ///< Show ticker
109 ND_FULL
, ///< Show newspaper
115 struct NewsTypeData
{
116 const char * const name
; ///< Name
117 const byte age
; ///< Maximum age of news items (in days)
118 const SoundFx sound
; ///< Sound
119 NewsDisplay display
; ///< Display mode (off, summary, full)
120 const StringID description
; ///< Description of the news type in news settings window
123 * Construct this entry.
124 * @param name The name of the type.
125 * @param age The maximum age for these messages.
126 * @param sound The sound to play.
127 * @param description The description for this type of messages.
129 NewsTypeData(const char *name
, byte age
, SoundFx sound
, NewsDisplay display
, StringID description
) :
134 description(description
)
139 /** Information about a single item of news. */
141 NewsItem
*prev
; ///< Previous news item
142 NewsItem
*next
; ///< Next news item
143 StringID string_id
; ///< Message text
144 Date date
; ///< Date of the news
145 NewsSubtype subtype
; ///< News subtype @see NewsSubtype
146 NewsFlag flags
; ///< NewsFlags bits @see NewsFlag
148 NewsReferenceType reftype1
; ///< Type of ref1
149 NewsReferenceType reftype2
; ///< Type of ref2
150 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.
151 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.
153 void *free_data
; ///< Data to be freed when the news item has reached its end.
157 free(this->free_data
);
160 uint64 params
[10]; ///< Parameters for string resolving.
164 * Data that needs to be stored for company news messages.
165 * The problem with company news messages are the custom name
166 * of the companies and the fact that the company data is reset,
167 * resulting in wrong names and such.
169 struct CompanyNewsInformation
{
170 char company_name
[64]; ///< The name of the company
171 char president_name
[64]; ///< The name of the president
172 char other_company_name
[64]; ///< The name of the company taking over this one
174 uint32 face
; ///< The face of the president
175 byte colour
; ///< The colour related to the company
177 void FillData(const struct Company
*c
, const struct Company
*other
= NULL
);
180 #endif /* NEWS_TYPE_H */