OpenTTD Source: src/news_type.h Source File

OpenTTD Source 1.11.0-RC1

news_type.h
Go to the documentation of this file.
1 /*
2 * This file is part of OpenTTD.
3 * 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.
4 * 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.
5 * 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/>.
6 */
7
10 #ifndef NEWS_TYPE_H
11 #define NEWS_TYPE_H
12
13 #include "core/enum_type.hpp"
14 #include "date_type.h"
15 #include "strings_type.h"
16 #include "sound_type.h"
17
21 enum NewsType {
22 NT_ARRIVAL_COMPANY,
23 NT_ARRIVAL_OTHER,
24 NT_ACCIDENT,
25 NT_COMPANY_INFO,
26 NT_INDUSTRY_OPEN,
27 NT_INDUSTRY_CLOSE,
28 NT_ECONOMY,
29 NT_INDUSTRY_COMPANY,
30 NT_INDUSTRY_OTHER,
31 NT_INDUSTRY_NOBODY,
32 NT_ADVICE,
33 NT_NEW_VEHICLES,
34 NT_ACCEPTANCE,
35 NT_SUBSIDIES,
36 NT_GENERAL,
37 NT_END,
38 };
39
49 enum NewsReferenceType {
50 NR_NONE,
51 NR_TILE,
52 NR_VEHICLE,
53 NR_STATION,
54 NR_INDUSTRY,
55 NR_TOWN,
56 NR_ENGINE,
57 };
58
63 enum NewsFlag {
64 NFB_INCOLOUR = 0,
65 NFB_NO_TRANSPARENT = 1,
66 NFB_SHADE = 2,
67 NFB_WINDOW_LAYOUT = 3,
68 NFB_WINDOW_LAYOUT_COUNT = 3,
69 NFB_VEHICLE_PARAM0 = 6,
70
71 NF_INCOLOUR = 1 << NFB_INCOLOUR,
72 NF_NO_TRANSPARENT = 1 << NFB_NO_TRANSPARENT,
73 NF_SHADE = 1 << NFB_SHADE,
74 NF_VEHICLE_PARAM0 = 1 << NFB_VEHICLE_PARAM0,
75
76 NF_THIN = 0 << NFB_WINDOW_LAYOUT,
77 NF_SMALL = 1 << NFB_WINDOW_LAYOUT,
78 NF_NORMAL = 2 << NFB_WINDOW_LAYOUT,
79 NF_VEHICLE = 3 << NFB_WINDOW_LAYOUT,
80 NF_COMPANY = 4 << NFB_WINDOW_LAYOUT,
81 };
82 DECLARE_ENUM_AS_BIT_SET(NewsFlag)
83
84
85
88 enum NewsDisplay {
89 ND_OFF,
90 ND_SUMMARY,
91 ND_FULL,
92 };
93
97 struct NewsTypeData {
98 const char * const name;
99 const byte age;
100 const SoundFx sound;
101
108 NewsTypeData(const char *name, byte age, SoundFx sound) :
109 name(name),
110 age(age),
111 sound(sound)
112 {
113 }
114
115 NewsDisplay GetDisplay() const;
116 };
117
119 struct NewsItem {
120 NewsItem *prev;
121 NewsItem *next;
122 StringID string_id;
123 Date date;
124 NewsType type;
125 NewsFlag flags;
126
127 NewsReferenceType reftype1;
128 NewsReferenceType reftype2;
129 uint32 ref1;
130 uint32 ref2;
131
132 void *free_data;
133
134 ~NewsItem()
135 {
136 free(this->free_data);
137 }
138
139 uint64 params[10];
140 };
141
148 struct CompanyNewsInformation {
149 char company_name[64];
150 char president_name[64];
151 char other_company_name[64];
152
153 uint32 face;
154 byte colour;
155
156 void FillData(const struct Company *c, const struct Company *other = nullptr);
157 };
158
159 #endif /* NEWS_TYPE_H */
NT_INDUSTRY_NOBODY
@ NT_INDUSTRY_NOBODY
Other industry production changes.
Definition: news_type.h:31
NT_INDUSTRY_OPEN
@ NT_INDUSTRY_OPEN
Opening of industries.
Definition: news_type.h:26
NT_NEW_VEHICLES
@ NT_NEW_VEHICLES
New vehicle has become available.
Definition: news_type.h:33
NT_INDUSTRY_CLOSE
@ NT_INDUSTRY_CLOSE
Closing of industries.
Definition: news_type.h:27
CompanyNewsInformation::colour
byte colour
The colour related to the company.
Definition: news_type.h:154
NT_ARRIVAL_OTHER
@ NT_ARRIVAL_OTHER
First vehicle arrived for competitor.
Definition: news_type.h:23
NF_THIN
@ NF_THIN
Thin news item. (Newspaper with headline and viewport)
Definition: news_type.h:76
NFB_SHADE
@ NFB_SHADE
News item uses shaded colours.
Definition: news_type.h:66
NT_SUBSIDIES
@ NT_SUBSIDIES
News about subsidies (announcements, expirations, acceptance)
Definition: news_type.h:35
NewsItem
Information about a single item of news.
Definition: news_type.h:119
NewsItem::ref2
uint32 ref2
Reference 2 to some object: Used for scrolling after clicking on the news, and for deleting the news ...
Definition: news_type.h:130
NewsTypeData
Per-NewsType data.
Definition: news_type.h:97
NR_STATION
@ NR_STATION
Reference station. Scroll to station when clicking on the news. Delete news when station is deleted.
Definition: news_type.h:53
NT_ADVICE
@ NT_ADVICE
Bits of news about vehicles of the company.
Definition: news_type.h:32
NewsTypeData::NewsTypeData
NewsTypeData(const char *name, byte age, SoundFx sound)
Construct this entry.
Definition: news_type.h:108
sound_type.h
ND_FULL
@ ND_FULL
Show newspaper.
Definition: news_type.h:91
NFB_WINDOW_LAYOUT
@ NFB_WINDOW_LAYOUT
First bit for window layout.
Definition: news_type.h:67
NewsItem::reftype2
NewsReferenceType reftype2
Type of ref2.
Definition: news_type.h:128
NF_VEHICLE_PARAM0
@ NF_VEHICLE_PARAM0
Bit value for specifying that string param 0 contains a vehicle ID. (special autoreplace behaviour)
Definition: news_type.h:74
strings_type.h
CompanyNewsInformation::company_name
char company_name[64]
The name of the company.
Definition: news_type.h:149
NT_GENERAL
@ NT_GENERAL
General news (from towns)
Definition: news_type.h:36
NewsItem::flags
NewsFlag flags
NewsFlags bits.
Definition: news_type.h:125
NF_NO_TRANSPARENT
@ NF_NO_TRANSPARENT
Bit value for disabling transparency.
Definition: news_type.h:72
NewsTypeData::age
const byte age
Maximum age of news items (in days)
Definition: news_type.h:99
NewsTypeData::sound
const SoundFx sound
Sound.
Definition: news_type.h:100
NewsItem::type
NewsType type
Type of the news.
Definition: news_type.h:124
CompanyNewsInformation::president_name
char president_name[64]
The name of the president.
Definition: news_type.h:150
NF_INCOLOUR
@ NF_INCOLOUR
Bit value for coloured news.
Definition: news_type.h:71
NewsTypeData::name
const char *const name
Name.
Definition: news_type.h:98
Date
int32 Date
The type to store our dates in.
Definition: date_type.h:14
NewsType
NewsType
Type of news.
Definition: news_type.h:21
NewsTypeData::GetDisplay
NewsDisplay GetDisplay() const
Return the news display option.
Definition: news_gui.cpp:254
NewsItem::string_id
StringID string_id
Message text.
Definition: news_type.h:122
NewsItem::prev
NewsItem * prev
Previous news item.
Definition: news_type.h:120
CompanyNewsInformation::FillData
void FillData(const struct Company *c, const struct Company *other=nullptr)
Fill the CompanyNewsInformation struct with the required data.
Definition: company_cmd.cpp:759
ND_OFF
@ ND_OFF
Only show a reminder in the status bar.
Definition: news_type.h:89
NewsItem::next
NewsItem * next
Next news item.
Definition: news_type.h:121
NR_NONE
@ NR_NONE
Empty reference.
Definition: news_type.h:50
SoundFx
SoundFx
Sound effects from baseset.
Definition: sound_type.h:37
NF_NORMAL
@ NF_NORMAL
Normal news item. (Newspaper with text only)
Definition: news_type.h:78
NewsDisplay
NewsDisplay
News display options.
Definition: news_type.h:88
NFB_INCOLOUR
@ NFB_INCOLOUR
News item is shown in colour (otherwise it is shown in black & white).
Definition: news_type.h:64
NewsItem::free_data
void * free_data
Data to be freed when the news item has reached its end.
Definition: news_type.h:132
date_type.h
ND_SUMMARY
@ ND_SUMMARY
Show ticker.
Definition: news_type.h:90
NewsReferenceType
NewsReferenceType
References to objects in news.
Definition: news_type.h:49
NR_TOWN
@ NR_TOWN
Reference town. Scroll to town when clicking on the news.
Definition: news_type.h:55
NR_TILE
@ NR_TILE
Reference tile. Scroll to tile when clicking on the news.
Definition: news_type.h:51
StringID
uint32 StringID
Numeric value that represents a string, independent of the selected language.
Definition: strings_type.h:16
CompanyNewsInformation
Data that needs to be stored for company news messages.
Definition: news_type.h:148
NT_INDUSTRY_COMPANY
@ NT_INDUSTRY_COMPANY
Production changes of industry serviced by local company.
Definition: news_type.h:29
NF_COMPANY
@ NF_COMPANY
Company news item. (Newspaper with face)
Definition: news_type.h:80
CompanyNewsInformation::face
uint32 face
The face of the president.
Definition: news_type.h:153
NFB_WINDOW_LAYOUT_COUNT
@ NFB_WINDOW_LAYOUT_COUNT
Number of bits for window layout.
Definition: news_type.h:68
NT_ACCIDENT
@ NT_ACCIDENT
An accident or disaster has occurred.
Definition: news_type.h:24
NT_COMPANY_INFO
@ NT_COMPANY_INFO
Company info (new companies, bankruptcy messages)
Definition: news_type.h:25
NT_ARRIVAL_COMPANY
@ NT_ARRIVAL_COMPANY
First vehicle arrived for company.
Definition: news_type.h:22
enum_type.hpp
NFB_VEHICLE_PARAM0
@ NFB_VEHICLE_PARAM0
String param 0 contains a vehicle ID. (special autoreplace behaviour)
Definition: news_type.h:69
NR_VEHICLE
@ NR_VEHICLE
Reference vehicle. Scroll to vehicle when clicking on the news. Delete news when vehicle is deleted.
Definition: news_type.h:52
DECLARE_ENUM_AS_BIT_SET
DECLARE_ENUM_AS_BIT_SET(GenderEthnicity) enum CompanyManagerFaceVariable
Bitgroups of the CompanyManagerFace variable.
Definition: company_manager_face.h:29
NewsItem::date
Date date
Date of the news.
Definition: news_type.h:123
NF_VEHICLE
@ NF_VEHICLE
Vehicle news item. (new engine available)
Definition: news_type.h:79
NT_ECONOMY
@ NT_ECONOMY
Economic changes (recession, industry up/dowm)
Definition: news_type.h:28
NF_SMALL
@ NF_SMALL
Small news item. (Information window with text and viewport)
Definition: news_type.h:77
NF_SHADE
@ NF_SHADE
Bit value for enabling shading.
Definition: news_type.h:73
NT_ACCEPTANCE
@ NT_ACCEPTANCE
A type of cargo is (no longer) accepted.
Definition: news_type.h:34
NewsItem::params
uint64 params[10]
Parameters for string resolving.
Definition: news_type.h:139
NewsFlag
NewsFlag
Various OR-able news-item flags.
Definition: news_type.h:63
NT_INDUSTRY_OTHER
@ NT_INDUSTRY_OTHER
Production changes of industry serviced by competitor(s)
Definition: news_type.h:30
NFB_NO_TRANSPARENT
@ NFB_NO_TRANSPARENT
News item disables transparency in the viewport.
Definition: news_type.h:65
free
static void free(const void *ptr)
Version of the standard free that accepts const pointers.
Definition: stdafx.h:454
NewsItem::ref1
uint32 ref1
Reference 1 to some object: Used for a possible viewport, scrolling after clicking on the news,...
Definition: news_type.h:129
NR_INDUSTRY
@ NR_INDUSTRY
Reference industry. Scroll to industry when clicking on the news. Delete news when industry is delete...
Definition: news_type.h:54
Company
Definition: company_base.h:110
NT_END
@ NT_END
end-of-array marker
Definition: news_type.h:37
NR_ENGINE
@ NR_ENGINE
Reference engine.
Definition: news_type.h:56
NewsItem::reftype1
NewsReferenceType reftype1
Type of ref1.
Definition: news_type.h:127
CompanyNewsInformation::other_company_name
char other_company_name[64]
The name of the company taking over this one.
Definition: news_type.h:151