OpenTTD Source 20250312-master-gcdcc6b491d
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 "engine_type.h"
15#include "industry_type.h"
16#include "gfx_type.h"
17#include "sound_type.h"
18#include "station_type.h"
19#include "strings_type.h"
22#include "town_type.h"
23#include "vehicle_type.h"
24
48
63
73using NewsReference = std::variant<std::monostate, TileIndex, VehicleID, StationID, IndustryID, TownID, EngineID>;
74
76enum class NewsStyle : uint8_t {
77 Thin,
78 Small,
79 Normal,
80 Vehicle,
81 Company,
82};
83
88enum class NewsFlag : uint8_t {
89 InColour,
91 Shaded,
93};
95
99enum class NewsDisplay : uint8_t {
100 Off,
101 Summary,
102 Full,
103};
104
109 const char * const name;
110 const uint8_t age;
112
119 NewsTypeData(const char *name, uint8_t age, SoundFx sound) :
120 name(name),
121 age(age),
122 sound(sound)
123 {
124 }
125
126 NewsDisplay GetDisplay() const;
127};
128
131 virtual ~NewsAllocatedData() = default;
132};
133
134
154
162 std::string company_name;
163 std::string president_name;
164 std::string other_company_name;
165
166 StringID title;
167 uint32_t face;
168 Colours colour;
169
170 CompanyNewsInformation(StringID title, const struct Company *c, const struct Company *other = nullptr);
171};
172
173using NewsContainer = std::list<NewsItem>;
174using NewsIterator = NewsContainer::const_iterator;
175
176#endif /* NEWS_TYPE_H */
Container for an encoded string, created by GetEncodedString.
Types related to engines.
Type (helpers) for enums.
Types related to the graphics and/or input devices.
Types related to the industry.
@ Invalid
GRF is unusable with this version of OpenTTD.
NewsType
Type of news.
Definition news_type.h:28
@ Advice
Bits of news about vehicles of the company.
@ General
General news (from towns)
@ ArrivalCompany
First vehicle arrived for company.
@ CompanyInfo
Company info (new companies, bankruptcy messages)
@ AccidentOther
An accident or disaster has occurred.
@ IndustryCompany
Production changes of industry serviced by local company.
@ IndustryClose
Closing of industries.
@ IndustryOpen
Opening of industries.
@ NewVehicles
New vehicle has become available.
@ End
end-of-array marker
@ Economy
Economic changes (recession, industry up/dowm)
@ IndustryNobody
Other industry production changes.
@ Subsidies
News about subsidies (announcements, expirations, acceptance)
@ ArrivalOther
First vehicle arrived for competitor.
@ Accident
An accident or disaster has occurred.
@ Acceptance
A type of cargo is (no longer) accepted.
@ IndustryOther
Production changes of industry serviced by competitor(s)
NewsContainer::const_iterator NewsIterator
Iterator type for news items.
Definition news_type.h:174
std::list< NewsItem > NewsContainer
Container type for storing news items.
Definition news_type.h:173
NewsStyle
News Window Styles.
Definition news_type.h:76
@ Company
Company news item. (Newspaper with face)
@ Small
Small news item. (Information window with text and viewport)
@ Normal
Normal news item. (Newspaper with text only)
@ Thin
Thin news item. (Newspaper with headline and viewport)
@ Vehicle
Vehicle news item. (new engine available)
AdviceType
Sub type of the NewsType::Advice to be able to remove specific news items.
Definition news_type.h:50
@ 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.
std::variant< std::monostate, TileIndex, VehicleID, StationID, IndustryID, TownID, EngineID > NewsReference
References to objects in news.
Definition news_type.h:73
NewsFlag
Various OR-able news-item flags.
Definition news_type.h:88
@ NoTransparency
News item disables transparency in the viewport.
@ VehicleParam0
String param 0 contains a vehicle ID. (special autoreplace behaviour)
@ Shaded
News item uses shaded colours.
@ InColour
News item is shown in colour (otherwise it is shown in black & white).
NewsDisplay
News display options.
Definition news_type.h:99
@ Summary
Show ticker.
@ Full
Show newspaper.
@ Off
Only show a reminder in the status bar.
Types related to sounds.
SoundFx
Sound effects from baseset.
Definition sound_type.h:45
Types related to stations.
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:161
uint32_t face
The face of the president.
Definition news_type.h:167
Colours colour
The colour related to the company.
Definition news_type.h:168
std::string president_name
The name of the president.
Definition news_type.h:163
std::string company_name
The name of the company.
Definition news_type.h:162
std::string other_company_name
The name of the company taking over this one.
Definition news_type.h:164
Container for any custom data that must be deleted after the news item has reached end-of-life.
Definition news_type.h:130
Information about a single item of news.
Definition news_type.h:136
TimerGameCalendar::Date date
Calendar date to show for the news.
Definition news_type.h:138
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:148
NewsType type
Type of the news.
Definition news_type.h:140
EncodedString headline
Headline of news.
Definition news_type.h:137
AdviceType advice_type
The type of advice, to be able to remove specific advices later on.
Definition news_type.h:141
TimerGameEconomy::Date economy_date
Economy date of the news item, never shown but used to calculate age.
Definition news_type.h:139
NewsFlags flags
Window style for the news.
Definition news_type.h:143
NewsReference ref2
Reference 2 to some object: Used for scrolling after clicking on the news, and for deleting the news ...
Definition news_type.h:146
NewsReference ref1
Reference 1 to some object: Used for a possible viewport, scrolling after clicking on the news,...
Definition news_type.h:145
Per-NewsType data.
Definition news_type.h:108
NewsDisplay GetDisplay() const
Return the news display option.
Definition news_gui.cpp:346
const char *const name
Name.
Definition news_type.h:109
NewsTypeData(const char *name, uint8_t age, SoundFx sound)
Construct this entry.
Definition news_type.h:119
const SoundFx sound
Sound.
Definition news_type.h:111
const uint8_t age
Maximum age of news items (in days)
Definition news_type.h:110
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.
Types related to towns.
Types related to vehicles.