OpenTTD Source: src/news_func.h Source File

OpenTTD Source 15.0-RC2

news_func.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
10#ifndef NEWS_FUNC_H
11#define NEWS_FUNC_H
12
13#include "news_type.h"
14#include "vehicle_type.h"
15#include "station_type.h"
16#include "industry_type.h"
17
18void AddNewsItem(EncodedString &&headline, NewsType type, NewsStyle style, NewsFlags flags, NewsReference ref1 = {}, NewsReference ref2 = {}, std::unique_ptr<NewsAllocatedData> &&data = nullptr, AdviceType advice_type = AdviceType::Invalid);
19
20inline void AddCompanyNewsItem(EncodedString &&headline, std::unique_ptr<CompanyNewsInformation> cni)
21{
22 AddNewsItem(std::move(headline), NewsType::CompanyInfo, NewsStyle::Company, {}, {}, {}, std::move(cni));
23}
24
30 inline void AddVehicleNewsItem(EncodedString &&headline, NewsType type, VehicleID vehicle, StationID station = StationID::Invalid())
31{
32 AddNewsItem(std::move(headline), type, NewsStyle::Thin, {NewsFlag::NoTransparency, NewsFlag::Shaded}, vehicle, station == StationID::Invalid() ? NewsReference{} : station);
33}
34
40 inline void AddVehicleAdviceNewsItem(AdviceType advice_type, EncodedString &&headline, VehicleID vehicle)
41{
42 AddNewsItem(std::move(headline), NewsType::Advice, NewsStyle::Small, {NewsFlag::InColour, NewsFlag::VehicleParam0}, vehicle, {}, nullptr, advice_type);
43}
44
45inline void AddTileNewsItem(EncodedString &&headline, NewsType type, TileIndex tile, StationID station = StationID::Invalid())
46{
47 AddNewsItem(std::move(headline), type, NewsStyle::Thin, {NewsFlag::NoTransparency, NewsFlag::Shaded}, tile, station == StationID::Invalid() ? NewsReference{} : station);
48}
49
50inline void AddIndustryNewsItem(EncodedString &&headline, NewsType type, IndustryID industry)
51{
52 AddNewsItem(std::move(headline), type, NewsStyle::Thin, {NewsFlag::NoTransparency, NewsFlag::Shaded}, industry, {});
53}
54
55void NewsLoop();
56void InitNewsItemStructs();
57
58const NewsItem *GetStatusbarNews();
59
60void DeleteInvalidEngineNews();
61void DeleteVehicleNews(VehicleID vid, AdviceType advice_type = AdviceType::Invalid);
62void DeleteStationNews(StationID sid);
63void DeleteIndustryNews(IndustryID iid);
64
65uint32_t SerialiseNewsReference(const NewsReference &reference);
66
67#endif /* NEWS_FUNC_H */
EncodedString
Container for an encoded string, created by GetEncodedString.
Definition strings_type.h:98
EnumBitSet< NewsFlag, uint8_t >
industry_type.h
Types related to the industry.
AddVehicleNewsItem
void AddVehicleNewsItem(EncodedString &&headline, NewsType type, VehicleID vehicle, StationID station=StationID::Invalid())
Adds a newsitem referencing a vehicle.
Definition news_func.h:30
DeleteIndustryNews
void DeleteIndustryNews(IndustryID iid)
Remove news regarding given industry.
Definition news_gui.cpp:1038
DeleteStationNews
void DeleteStationNews(StationID sid)
Remove news regarding given station so there are no 'unknown station now accepts Mail' or 'First trai...
Definition news_gui.cpp:1027
AddVehicleAdviceNewsItem
void AddVehicleAdviceNewsItem(AdviceType advice_type, EncodedString &&headline, VehicleID vehicle)
Adds a vehicle-advice news item.
Definition news_func.h:40
SerialiseNewsReference
uint32_t SerialiseNewsReference(const NewsReference &reference)
Encode a NewsReference for serialisation, e.g.
Definition news_gui.cpp:920
DeleteInvalidEngineNews
void DeleteInvalidEngineNews()
Remove engine announcements for invalid engines.
Definition news_gui.cpp:1056
InitNewsItemStructs
void InitNewsItemStructs()
Initialize the news-items data structures.
Definition news_gui.cpp:714
AddNewsItem
void AddNewsItem(EncodedString &&headline, NewsType type, NewsStyle style, NewsFlags flags, NewsReference ref1={}, NewsReference ref2={}, std::unique_ptr< NewsAllocatedData > &&data=nullptr, AdviceType advice_type=AdviceType::Invalid)
Add a new newsitem to be shown.
Definition news_gui.cpp:900
GetStatusbarNews
const NewsItem * GetStatusbarNews()
Get pointer to the current status bar news item.
Definition news_gui.cpp:70
DeleteVehicleNews
void DeleteVehicleNews(VehicleID vid, AdviceType advice_type=AdviceType::Invalid)
Delete news with a given advice type about a vehicle.
Definition news_gui.cpp:1015
news_type.h
Types related to news.
NewsType
NewsType
Type of news.
Definition news_type.h:29
NewsType::Advice
@ Advice
Bits of news about vehicles of the company.
NewsType::CompanyInfo
@ CompanyInfo
Company info (new companies, bankruptcy messages)
NewsStyle
NewsStyle
News Window Styles.
Definition news_type.h:77
NewsStyle::Company
@ Company
Company news item. (Newspaper with face)
NewsStyle::Small
@ Small
Small news item. (Information window with text and viewport)
NewsStyle::Thin
@ Thin
Thin news item. (Newspaper with headline and viewport)
AdviceType
AdviceType
Sub type of the NewsType::Advice to be able to remove specific news items.
Definition news_type.h:51
NewsReference
std::variant< std::monostate, TileIndex, VehicleID, StationID, IndustryID, TownID, EngineID > NewsReference
References to objects in news.
Definition news_type.h:74
NewsFlag::NoTransparency
@ NoTransparency
News item disables transparency in the viewport.
NewsFlag::VehicleParam0
@ VehicleParam0
String param 0 contains a vehicle ID. (special autoreplace behaviour)
NewsFlag::Shaded
@ Shaded
News item uses shaded colours.
NewsFlag::InColour
@ InColour
News item is shown in colour (otherwise it is shown in black & white).
station_type.h
Types related to stations.
NewsItem
Information about a single item of news.
Definition news_type.h:137
PoolID< uint32_t, struct VehicleIDTag, 0xFF000, 0xFFFFF >
StrongType::Typedef< uint32_t, struct TileIndexTag, StrongType::Compare, StrongType::Integer, StrongType::Compatible< int32_t >, StrongType::Compatible< int64_t > >
vehicle_type.h
Types related to vehicles.