OpenTTD

news_type.h
Go to the documentation of this file.
1 /* $Id: news_type.h 24843 2012-12-23 21:07:12Z frosch $ */
2
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 */
9
12 #ifndef NEWS_TYPE_H
13 #define NEWS_TYPE_H
14
15 #include "core/enum_type.hpp"
16 #include "date_type.h"
17 #include "strings_type.h"
18 #include "sound_type.h"
19
21 enum MessageOptionsSpace {
22 MOS_WIDG_PER_SETTING = 4,
23
24 MOS_LEFT_EDGE = 6,
25 MOS_COLUMN_SPACING = 4,
26 MOS_RIGHT_EDGE = 6,
27 MOS_BUTTON_SPACE = 10,
28
29 MOS_ABOVE_GLOBAL_SETTINGS = 6,
30 MOS_BOTTOM_EDGE = 6,
31 };
32
36 enum NewsType {
37 NT_ARRIVAL_COMPANY,
38 NT_ARRIVAL_OTHER,
39 NT_ACCIDENT,
40 NT_COMPANY_INFO,
41 NT_INDUSTRY_OPEN,
42 NT_INDUSTRY_CLOSE,
43 NT_ECONOMY,
44 NT_INDUSTRY_COMPANY,
45 NT_INDUSTRY_OTHER,
46 NT_INDUSTRY_NOBODY,
47 NT_ADVICE,
48 NT_NEW_VEHICLES,
49 NT_ACCEPTANCE,
50 NT_SUBSIDIES,
51 NT_GENERAL,
52 NT_END,
53 };
54
64 enum NewsReferenceType {
65 NR_NONE,
66 NR_TILE,
67 NR_VEHICLE,
68 NR_STATION,
69 NR_INDUSTRY,
70 NR_TOWN,
71 NR_ENGINE,
72 };
73
78 enum NewsFlag {
79 NFB_INCOLOUR = 0,
80 NFB_NO_TRANSPARENT = 1,
81 NFB_SHADE = 2,
82 NFB_WINDOW_LAYOUT = 3,
83 NFB_WINDOW_LAYOUT_COUNT = 3,
84 NFB_VEHICLE_PARAM0 = 6,
85
86 NF_INCOLOUR = 1 << NFB_INCOLOUR,
87 NF_NO_TRANSPARENT = 1 << NFB_NO_TRANSPARENT,
88 NF_SHADE = 1 << NFB_SHADE,
89 NF_VEHICLE_PARAM0 = 1 << NFB_VEHICLE_PARAM0,
90
91 NF_THIN = 0 << NFB_WINDOW_LAYOUT,
92 NF_SMALL = 1 << NFB_WINDOW_LAYOUT,
93 NF_NORMAL = 2 << NFB_WINDOW_LAYOUT,
94 NF_VEHICLE = 3 << NFB_WINDOW_LAYOUT,
95 NF_COMPANY = 4 << NFB_WINDOW_LAYOUT,
96 };
97 DECLARE_ENUM_AS_BIT_SET(NewsFlag)
98
99
100
103 enum NewsDisplay {
104 ND_OFF,
105 ND_SUMMARY,
106 ND_FULL,
107 };
108
112 struct NewsTypeData {
113 const char * const name;
114 const byte age;
115 const SoundFx sound;
116
123 NewsTypeData(const char *name, byte age, SoundFx sound) :
124 name(name),
125 age(age),
126 sound(sound)
127 {
128 }
129
130 NewsDisplay GetDisplay() const;
131 };
132
134 struct NewsItem {
135 NewsItem *prev;
136 NewsItem *next;
137 StringID string_id;
138 Date date;
139 NewsType type;
140 NewsFlag flags;
141
142 NewsReferenceType reftype1;
143 NewsReferenceType reftype2;
144 uint32 ref1;
145 uint32 ref2;
146
147 void *free_data;
148
149 ~NewsItem()
150 {
151 free(this->free_data);
152 }
153
154 uint64 params[10];
155 };
156
163 struct CompanyNewsInformation {
164 char company_name[64];
165 char president_name[64];
166 char other_company_name[64];
167
168 uint32 face;
169 byte colour;
170
171 void FillData(const struct Company *c, const struct Company *other = NULL);
172 };
173
174 #endif /* NEWS_TYPE_H */
NT_INDUSTRY_CLOSE
Closing of industries.
Definition: news_type.h:42
DECLARE_ENUM_AS_BIT_SET
DECLARE_ENUM_AS_BIT_SET(GenderEthnicity) enum CompanyManagerFaceVariable
Bitgroups of the CompanyManagerFace variable.
Definition: company_manager_face.h:31
NT_ARRIVAL_OTHER
First vehicle arrived for competitor.
Definition: news_type.h:38
NT_SUBSIDIES
News about subsidies (announcements, expirations, acceptance)
Definition: news_type.h:50
NF_THIN
Thin news item. (Newspaper with headline and viewport)
Definition: news_type.h:91
ND_FULL
Show newspaper.
Definition: news_type.h:106
NR_STATION
Reference station. Scroll to station when clicking on the news. Delete news when station is deleted...
Definition: news_type.h:68
NT_END
end-of-array marker
Definition: news_type.h:52
MOS_BUTTON_SPACE
Additional space in the button with the option value (for better looks).
Definition: news_type.h:27
MOS_COLUMN_SPACING
Number of pixels between the buttons and the description columns.
Definition: news_type.h:25
NewsItem::reftype2
NewsReferenceType reftype2
Type of ref2.
Definition: news_type.h:143
NewsTypeData::name
const char *const name
Name.
Definition: news_type.h:113
NT_ADVICE
Bits of news about vehicles of the company.
Definition: news_type.h:47
MOS_RIGHT_EDGE
Number of pixels between right edge of the window and the options descriptions column.
Definition: news_type.h:26
NT_INDUSTRY_NOBODY
Other industry production changes.
Definition: news_type.h:46
NewsTypeData::NewsTypeData
NewsTypeData(const char *name, byte age, SoundFx sound)
Construct this entry.
Definition: news_type.h:123
NFB_WINDOW_LAYOUT
First bit for window layout.
Definition: news_type.h:82
NT_NEW_VEHICLES
New vehicle has become available.
Definition: news_type.h:48
NT_INDUSTRY_OPEN
Opening of industries.
Definition: news_type.h:41
CompanyNewsInformation
Data that needs to be stored for company news messages.
Definition: news_type.h:163
NewsItem::reftype1
NewsReferenceType reftype1
Type of ref1.
Definition: news_type.h:142
NewsTypeData
Per-NewsType data.
Definition: news_type.h:112
enum_type.hpp
Type (helpers) for enums.
NF_VEHICLE_PARAM0
Bit value for specifying that string param 0 contains a vehicle ID. (special autoreplace behaviour) ...
Definition: news_type.h:89
NewsItem::free_data
void * free_data
Data to be freed when the news item has reached its end.
Definition: news_type.h:147
NewsItem::date
Date date
Date of the news.
Definition: news_type.h:138
ND_OFF
Only show a reminder in the status bar.
Definition: news_type.h:104
NewsItem::string_id
StringID string_id
Message text.
Definition: news_type.h:137
NewsItem::ref1
uint32 ref1
Reference 1 to some object: Used for a possible viewport, scrolling after clicking on the news...
Definition: news_type.h:144
MOS_LEFT_EDGE
Number of pixels between left edge of the window and the options buttons column.
Definition: news_type.h:24
NewsDisplay
NewsDisplay
News display options.
Definition: news_type.h:103
NT_GENERAL
General news (from towns)
Definition: news_type.h:51
NF_NO_TRANSPARENT
Bit value for disabling transparency.
Definition: news_type.h:87
NewsFlag
NewsFlag
Various OR-able news-item flags.
Definition: news_type.h:78
NR_TILE
Reference tile. Scroll to tile when clicking on the news.
Definition: news_type.h:66
NR_NONE
Empty reference.
Definition: news_type.h:65
NF_NORMAL
Normal news item. (Newspaper with text only)
Definition: news_type.h:93
NewsItem::prev
NewsItem * prev
Previous news item.
Definition: news_type.h:135
NewsItem::ref2
uint32 ref2
Reference 2 to some object: Used for scrolling after clicking on the news, and for deleteing the news...
Definition: news_type.h:145
NF_INCOLOUR
Bit value for coloured news.
Definition: news_type.h:86
NFB_INCOLOUR
News item is shown in colour (otherwise it is shown in black & white).
Definition: news_type.h:79
MOS_ABOVE_GLOBAL_SETTINGS
Number of vertical pixels between the categories and the global options.
Definition: news_type.h:29
StringID
uint32 StringID
Numeric value that represents a string, independent of the selected language.
Definition: strings_type.h:18
NewsTypeData::GetDisplay
NewsDisplay GetDisplay() const
Return the news display option.
Definition: news_gui.cpp:249
NF_COMPANY
Company news item. (Newspaper with face)
Definition: news_type.h:95
Company
Definition: company_base.h:110
NFB_WINDOW_LAYOUT_COUNT
Number of bits for window layout.
Definition: news_type.h:83
CompanyNewsInformation::face
uint32 face
The face of the president.
Definition: news_type.h:168
ND_SUMMARY
Show ticker.
Definition: news_type.h:105
NewsItem::next
NewsItem * next
Next news item.
Definition: news_type.h:136
MOS_BOTTOM_EDGE
Number of pixels between bottom edge of the window and bottom of the global options.
Definition: news_type.h:30
NR_TOWN
Reference town. Scroll to town when clicking on the news.
Definition: news_type.h:70
NT_INDUSTRY_COMPANY
Production changes of industry serviced by local company.
Definition: news_type.h:44
NT_COMPANY_INFO
Company info (new companies, bankruptcy messages)
Definition: news_type.h:40
NT_ARRIVAL_COMPANY
First vehicle arrived for company.
Definition: news_type.h:37
NewsTypeData::sound
const SoundFx sound
Sound.
Definition: news_type.h:115
NT_ACCEPTANCE
A type of cargo is (no longer) accepted.
Definition: news_type.h:49
MOS_WIDG_PER_SETTING
Number of widgets needed for each news category, starting at widget #WID_MO_START_OPTION.
Definition: news_type.h:22
NewsItem::flags
NewsFlag flags
NewsFlags bits.
Definition: news_type.h:140
NT_ACCIDENT
An accident or disaster has occurred.
Definition: news_type.h:39
sound_type.h
Types related to sounds.
NFB_NO_TRANSPARENT
News item disables transparency in the viewport.
Definition: news_type.h:80
strings_type.h
Types related to strings.
date_type.h
Types related to the dates in OpenTTD.
NR_ENGINE
Reference engine.
Definition: news_type.h:71
NewsReferenceType
NewsReferenceType
References to objects in news.
Definition: news_type.h:64
NFB_VEHICLE_PARAM0
String param 0 contains a vehicle ID. (special autoreplace behaviour)
Definition: news_type.h:84
Date
int32 Date
The type to store our dates in.
Definition: date_type.h:16
free
static void free(const void *ptr)
Version of the standard free that accepts const pointers.
Definition: depend.cpp:114
NR_INDUSTRY
Reference industry. Scroll to industry when clicking on the news. Delete news when industry is delete...
Definition: news_type.h:69
NewsItem::type
NewsType type
Type of the news.
Definition: news_type.h:139
NF_SMALL
Small news item. (Information window with text and viewport)
Definition: news_type.h:92
MessageOptionsSpace
MessageOptionsSpace
Constants in the message options window.
Definition: news_type.h:21
NT_INDUSTRY_OTHER
Production changes of industry serviced by competitor(s)
Definition: news_type.h:45
NewsType
NewsType
Type of news.
Definition: news_type.h:36
NFB_SHADE
News item uses shaded colours.
Definition: news_type.h:81
NF_VEHICLE
Vehicle news item. (new engine available)
Definition: news_type.h:94
NewsTypeData::age
const byte age
Maximum age of news items (in days)
Definition: news_type.h:114
NR_VEHICLE
Reference vehicle. Scroll to vehicle when clicking on the news. Delete news when vehicle is deleted...
Definition: news_type.h:67
NF_SHADE
Bit value for enabling shading.
Definition: news_type.h:88
SoundFx
SoundFx
Sound effects from baseset.
Definition: sound_type.h:39
NewsItem
Information about a single item of news.
Definition: news_type.h:134
NT_ECONOMY
Economic changes (recession, industry up/dowm)
Definition: news_type.h:43
CompanyNewsInformation::colour
byte colour
The colour related to the company.
Definition: news_type.h:169