OpenTTD Source 20250205-master-gfd85ab1e2c
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 "gfx_type.h"
17#include "strings_type.h"
18#include "sound_type.h"
19
42
57
76
101
102
103
111
116 const char * const name;
117 const uint8_t age;
119
126 NewsTypeData(const char *name, uint8_t age, SoundFx sound) :
127 name(name),
128 age(age),
129 sound(sound)
130 {
131 }
132
133 NewsDisplay GetDisplay() const;
134};
135
138 virtual ~NewsAllocatedData() = default;
139};
140
141
162
170 std::string company_name;
171 std::string president_name;
172 std::string other_company_name;
173
174 uint32_t face;
175 Colours colour;
176
177 CompanyNewsInformation(const struct Company *c, const struct Company *other = nullptr);
178};
179
180using NewsContainer = std::list<NewsItem>;
181using NewsIterator = NewsContainer::const_iterator;
182
183#endif /* NEWS_TYPE_H */
Type (helpers) for enums.
#define DECLARE_ENUM_AS_BIT_SET(enum_type)
Operators to allow to work with enum as with type safe bit set in C++.
Definition enum_type.hpp:68
Types related to the graphics and/or input devices.
@ Invalid
GRF is unusable with this version of OpenTTD.
NewsType
Type of news.
Definition news_type.h:23
@ NT_INDUSTRY_NOBODY
Other industry production changes.
Definition news_type.h:34
@ NT_INDUSTRY_COMPANY
Production changes of industry serviced by local company.
Definition news_type.h:32
@ NT_INDUSTRY_OPEN
Opening of industries.
Definition news_type.h:29
@ NT_NEW_VEHICLES
New vehicle has become available.
Definition news_type.h:36
@ NT_ECONOMY
Economic changes (recession, industry up/dowm)
Definition news_type.h:31
@ NT_ACCEPTANCE
A type of cargo is (no longer) accepted.
Definition news_type.h:37
@ NT_END
end-of-array marker
Definition news_type.h:40
@ NT_INDUSTRY_CLOSE
Closing of industries.
Definition news_type.h:30
@ NT_ACCIDENT_OTHER
An accident or disaster has occurred.
Definition news_type.h:27
@ NT_SUBSIDIES
News about subsidies (announcements, expirations, acceptance)
Definition news_type.h:38
@ NT_ARRIVAL_COMPANY
First vehicle arrived for company.
Definition news_type.h:24
@ NT_ARRIVAL_OTHER
First vehicle arrived for competitor.
Definition news_type.h:25
@ NT_INDUSTRY_OTHER
Production changes of industry serviced by competitor(s)
Definition news_type.h:33
@ NT_ACCIDENT
An accident or disaster has occurred.
Definition news_type.h:26
@ NT_ADVICE
Bits of news about vehicles of the company.
Definition news_type.h:35
@ NT_COMPANY_INFO
Company info (new companies, bankruptcy messages)
Definition news_type.h:28
@ NT_GENERAL
General news (from towns)
Definition news_type.h:39
NewsReferenceType
References to objects in news.
Definition news_type.h:67
@ NR_TILE
Reference tile. Scroll to tile when clicking on the news.
Definition news_type.h:69
@ NR_STATION
Reference station. Scroll to station when clicking on the news. Delete news when station is deleted.
Definition news_type.h:71
@ NR_ENGINE
Reference engine.
Definition news_type.h:74
@ NR_TOWN
Reference town. Scroll to town when clicking on the news.
Definition news_type.h:73
@ NR_INDUSTRY
Reference industry. Scroll to industry when clicking on the news. Delete news when industry is delete...
Definition news_type.h:72
@ NR_NONE
Empty reference.
Definition news_type.h:68
@ NR_VEHICLE
Reference vehicle. Scroll to vehicle when clicking on the news. Delete news when vehicle is deleted.
Definition news_type.h:70
NewsContainer::const_iterator NewsIterator
Iterator type for news items.
Definition news_type.h:181
std::list< NewsItem > NewsContainer
Container type for storing news items.
Definition news_type.h:180
AdviceType
Sub type of the NT_ADVICE to be able to remove specific news items.
Definition news_type.h:44
@ TrainStuck
The train got stuck and needs to be unstuck manually.
@ VehicleLost
The vehicle has become lost.
@ VehicleWaiting
The vehicle is waiting in the depot.
@ Order
Something wrong with the order, e.g. invalid or duplicate entries, too few entries.
@ AutorenewFailed
Autorenew or autoreplace failed.
@ VehicleOld
The vehicle is starting to get old.
@ VehicleUnprofitable
The vehicle is costing you money.
@ AircraftDestinationTooFar
Next (order) destination is too far for the aircraft type.
@ RefitFailed
The refit order failed to execute.
NewsFlag
Various OR-able news-item flags.
Definition news_type.h:81
@ NF_NO_TRANSPARENT
Bit value for disabling transparency.
Definition news_type.h:90
@ NF_SHADE
Bit value for enabling shading.
Definition news_type.h:91
@ NFB_NO_TRANSPARENT
News item disables transparency in the viewport.
Definition news_type.h:83
@ NFB_INCOLOUR
News item is shown in colour (otherwise it is shown in black & white).
Definition news_type.h:82
@ NFB_SHADE
News item uses shaded colours.
Definition news_type.h:84
@ NF_VEHICLE_PARAM0
Bit value for specifying that string param 0 contains a vehicle ID. (special autoreplace behaviour)
Definition news_type.h:92
@ NFB_WINDOW_LAYOUT
First bit for window layout.
Definition news_type.h:85
@ NFB_VEHICLE_PARAM0
String param 0 contains a vehicle ID. (special autoreplace behaviour)
Definition news_type.h:87
@ NF_THIN
Thin news item. (Newspaper with headline and viewport)
Definition news_type.h:94
@ NF_COMPANY
Company news item. (Newspaper with face)
Definition news_type.h:98
@ NF_NORMAL
Normal news item. (Newspaper with text only)
Definition news_type.h:96
@ NF_VEHICLE
Vehicle news item. (new engine available)
Definition news_type.h:97
@ NF_INCOLOUR
Bit value for coloured news.
Definition news_type.h:89
@ NFB_WINDOW_LAYOUT_COUNT
Number of bits for window layout.
Definition news_type.h:86
@ NF_SMALL
Small news item. (Information window with text and viewport)
Definition news_type.h:95
NewsDisplay
News display options.
Definition news_type.h:106
@ ND_SUMMARY
Show ticker.
Definition news_type.h:108
@ ND_OFF
Only show a reminder in the status bar.
Definition news_type.h:107
@ ND_FULL
Show newspaper.
Definition news_type.h:109
Types related to sounds.
SoundFx
Sound effects from baseset.
Definition sound_type.h:45
Types related to strings.
uint32_t StringID
Numeric value that represents a string, independent of the selected language.
Data that needs to be stored for company news messages.
Definition news_type.h:169
uint32_t face
The face of the president.
Definition news_type.h:174
Colours colour
The colour related to the company.
Definition news_type.h:175
std::string president_name
The name of the president.
Definition news_type.h:171
std::string company_name
The name of the company.
Definition news_type.h:170
std::string other_company_name
The name of the company taking over this one.
Definition news_type.h:172
Container for any custom data that must be deleted after the news item has reached end-of-life.
Definition news_type.h:137
Information about a single item of news.
Definition news_type.h:143
TimerGameCalendar::Date date
Calendar date to show for the news.
Definition news_type.h:145
std::unique_ptr< NewsAllocatedData > data
Custom data for the news item that will be deallocated (deleted) when the news item has reached its e...
Definition news_type.h:156
std::vector< StringParameterData > params
Parameters for string resolving.
Definition news_type.h:158
NewsType type
Type of the news.
Definition news_type.h:147
uint32_t ref1
Reference 1 to some object: Used for a possible viewport, scrolling after clicking on the news,...
Definition news_type.h:153
NewsReferenceType reftype1
Type of ref1.
Definition news_type.h:151
AdviceType advice_type
The type of advice, to be able to remove specific advices later on.
Definition news_type.h:148
TimerGameEconomy::Date economy_date
Economy date of the news item, never shown but used to calculate age.
Definition news_type.h:146
uint32_t ref2
Reference 2 to some object: Used for scrolling after clicking on the news, and for deleting the news ...
Definition news_type.h:154
StringID string_id
Message text.
Definition news_type.h:144
NewsFlag flags
NewsFlags bits.
Definition news_type.h:149
NewsReferenceType reftype2
Type of ref2.
Definition news_type.h:152
Per-NewsType data.
Definition news_type.h:115
NewsDisplay GetDisplay() const
Return the news display option.
Definition news_gui.cpp:340
const char *const name
Name.
Definition news_type.h:116
NewsTypeData(const char *name, uint8_t age, SoundFx sound)
Construct this entry.
Definition news_type.h:126
const SoundFx sound
Sound.
Definition news_type.h:118
const uint8_t age
Maximum age of news items (in days)
Definition news_type.h:117
Templated helper to make a type-safe 'typedef' representing a single POD value.
Definition of the game-calendar-timer.
Definition of the game-economy-timer.