OpenTTD Source 20261112-master-gbcbec5e63f
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 <https://www.gnu.org/licenses/old-licenses/gpl-2.0>.
6 */
7
9
10#ifndef NEWS_TYPE_H
11#define NEWS_TYPE_H
12
13#include "core/enum_type.hpp"
14#include "company_type.h"
15#include "engine_type.h"
16#include "industry_type.h"
17#include "gfx_type.h"
18#include "settings_type.h"
19#include "sound_type.h"
20#include "station_type.h"
21#include "strings_type.h"
24#include "town_type.h"
25#include "vehicle_type.h"
26
52
67
77using NewsReference = std::variant<std::monostate, TileIndex, VehicleID, StationID, IndustryID, TownID, EngineID>;
78
80enum class NewsStyle : uint8_t {
86};
87
98
101
106 const std::string_view name;
107 const uint8_t age;
109
116 constexpr NewsTypeData(std::string_view name, uint8_t age, SoundFx sound) :
117 name(name),
118 age(age),
119 sound(sound)
120 {
121 }
122
123 NewsDisplay GetDisplay() const;
124};
125
129 virtual ~NewsAllocatedData() = default;
130};
131
132
152
160 std::string company_name;
161 std::string president_name;
162 std::string other_company_name;
163
164 StringID title;
167
168 CompanyNewsInformation(StringID title, const struct Company *c, const struct Company *other = nullptr);
169};
170
171using NewsContainer = std::list<NewsItem>;
172using NewsIterator = NewsContainer::const_iterator;
173
174#endif /* NEWS_TYPE_H */
Container for an encoded string, created by GetEncodedString.
Enum-as-bit-set wrapper.
StrongType::Typedef< int32_t, DateTag< struct Calendar >, StrongType::Compare, StrongType::Integer > Date
Types related to companies.
Types related to engines.
Type (helpers) for enums.
Types related to the graphics and/or input devices.
Colours
One of 16 base colours used for companies and windows/widgets.
Definition gfx_type.h:283
Types related to the industry.
NewsType
Type of news.
Definition news_type.h:30
@ Advice
Bits of news about vehicles of the company.
Definition news_type.h:44
@ General
General news (from towns).
Definition news_type.h:48
@ ArrivalCompany
First vehicle arrived for company.
Definition news_type.h:31
@ CompanyInfo
Company info (new companies, bankruptcy messages).
Definition news_type.h:35
@ IndustryCloseCompany
Closing of industries serviced by local company.
Definition news_type.h:37
@ AccidentOther
An accident or disaster has occurred.
Definition news_type.h:34
@ IndustryCompany
Production changes of industry serviced by local company.
Definition news_type.h:41
@ IndustryOpen
Opening of industries.
Definition news_type.h:36
@ NewVehicles
New vehicle has become available.
Definition news_type.h:45
@ End
end-of-array marker
Definition news_type.h:50
@ IndustryNobody
Other industry production changes.
Definition news_type.h:43
@ Subsidies
News about subsidies (announcements, expirations, acceptance).
Definition news_type.h:47
@ ArrivalOther
First vehicle arrived for competitor.
Definition news_type.h:32
@ Accident
An accident or disaster has occurred.
Definition news_type.h:33
@ Acceptance
A type of cargo is (no longer) accepted.
Definition news_type.h:46
@ IndustryOther
Production changes of industry serviced by competitor(s).
Definition news_type.h:42
@ IndustryCloseNobody
Other industry closing.
Definition news_type.h:39
@ IndustryCloseOther
Closing of industries serviced by competitor(s).
Definition news_type.h:38
NewsContainer::const_iterator NewsIterator
Iterator type for news items.
Definition news_type.h:172
EnumBitSet< NewsFlag, uint8_t > NewsFlags
Bitset of NewsFlag elements.
Definition news_type.h:100
std::list< NewsItem > NewsContainer
Container type for storing news items.
Definition news_type.h:171
NewsStyle
News Window Styles.
Definition news_type.h:80
@ Small
Small news item. (Information window with text and viewport).
Definition news_type.h:82
@ Normal
Normal news item. (Newspaper with text only).
Definition news_type.h:83
@ Thin
Thin news item. (Newspaper with headline and viewport).
Definition news_type.h:81
AdviceType
Sub type of the NewsType::Advice to be able to remove specific news items.
Definition news_type.h:54
@ TrainStuck
The train got stuck and needs to be unstuck manually.
Definition news_type.h:59
@ VehicleLost
The vehicle has become lost.
Definition news_type.h:60
@ VehicleWaiting
The vehicle is waiting in the depot.
Definition news_type.h:63
@ AutorenewFailed
Autorenew or autoreplace failed.
Definition news_type.h:56
@ VehicleOld
The vehicle is starting to get old.
Definition news_type.h:61
@ VehicleUnprofitable
The vehicle is costing you money.
Definition news_type.h:62
@ AircraftDestinationTooFar
Next (order) destination is too far for the aircraft type.
Definition news_type.h:55
@ RefitFailed
The refit order failed to execute.
Definition news_type.h:58
std::variant< std::monostate, TileIndex, VehicleID, StationID, IndustryID, TownID, EngineID > NewsReference
References to objects in news.
Definition news_type.h:77
NewsFlag
Various OR-able news-item flags.
Definition news_type.h:92
@ NoTransparency
News item disables transparency in the viewport.
Definition news_type.h:94
@ VehicleParam0
String param 0 contains a vehicle ID. (special autoreplace behaviour).
Definition news_type.h:96
@ Shaded
News item uses shaded colours.
Definition news_type.h:95
@ InColour
News item is shown in colour (otherwise it is shown in black & white).
Definition news_type.h:93
@ Invalid
broken savegame (used internally)
Definition saveload.h:438
Types related to global configuration settings.
NewsDisplay
News display style.
Types related to sounds.
SoundFx
Sound effects from baseset.
Definition sound_type.h:45
Types related to stations.
Types related to strings.
StrongType::Typedef< uint32_t, struct StringIDTag, StrongType::Compare, StrongType::Integer > StringID
Numeric value that represents a string, independent of the selected language.
CompanyManagerFace face
The face of the president.
Definition news_type.h:165
Colours colour
The colour related to the company.
Definition news_type.h:166
CompanyNewsInformation(StringID title, const struct Company *c, const struct Company *other=nullptr)
Fill the CompanyNewsInformation struct with the required data.
std::string president_name
The name of the president.
Definition news_type.h:161
std::string company_name
The name of the company.
Definition news_type.h:160
std::string other_company_name
The name of the company taking over this one.
Definition news_type.h:162
Data of the economy.
Container for any custom data that must be deleted after the news item has reached end-of-life.
Definition news_type.h:127
virtual ~NewsAllocatedData()=default
Ensure the destructor of the sub classes are called as well.
TimerGameCalendar::Date date
Calendar date to show for the news.
Definition news_type.h:136
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:146
NewsType type
Type of the news.
Definition news_type.h:138
EncodedString headline
Headline of news.
Definition news_type.h:135
AdviceType advice_type
The type of advice, to be able to remove specific advices later on.
Definition news_type.h:139
TimerGameEconomy::Date economy_date
Economy date of the news item, never shown but used to calculate age.
Definition news_type.h:137
NewsItem(EncodedString &&headline, NewsType type, NewsStyle style, NewsFlags flags, NewsReference ref1, NewsReference ref2, std::unique_ptr< NewsAllocatedData > &&data, AdviceType advice_type)
Create a new newsitem to be shown.
Definition news_gui.cpp:888
NewsFlags flags
NewsFlags bits.
Definition news_type.h:141
NewsStyle style
Window style for the news.
Definition news_type.h:140
NewsReference ref2
Reference 2 to some object: Used for scrolling after clicking on the news, and for deleting the news ...
Definition news_type.h:144
NewsReference ref1
Reference 1 to some object: Used for a possible viewport, scrolling after clicking on the news,...
Definition news_type.h:143
NewsDisplay GetDisplay() const
Return the news display option.
Definition news_gui.cpp:353
const std::string_view name
Name.
Definition news_type.h:106
constexpr NewsTypeData(std::string_view name, uint8_t age, SoundFx sound)
Construct this entry.
Definition news_type.h:116
const SoundFx sound
Sound.
Definition news_type.h:108
const uint8_t age
Maximum age of news items (in days).
Definition news_type.h:107
If you change this, keep in mind that it is also saved in 2 other places:
Definition order_base.h:33
Vehicle data structure.
Definition of the game-calendar-timer.
Definition of the game-economy-timer.
Types related to towns.
Types related to vehicles.