OpenTTD Source 20250711-master-gaaf5d39b15
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 "company_type.h"
15#include "engine_type.h"
16#include "industry_type.h"
17#include "gfx_type.h"
18#include "sound_type.h"
19#include "station_type.h"
20#include "strings_type.h"
23#include "town_type.h"
24#include "vehicle_type.h"
25
49
64
74using NewsReference = std::variant<std::monostate, TileIndex, VehicleID, StationID, IndustryID, TownID, EngineID>;
75
77enum class NewsStyle : uint8_t {
78 Thin,
79 Small,
80 Normal,
81 Vehicle,
82 Company,
83};
84
89enum class NewsFlag : uint8_t {
90 InColour,
92 Shaded,
94};
96
100enum class NewsDisplay : uint8_t {
101 Off,
102 Summary,
103 Full,
104};
105
110 const std::string_view name;
111 const uint8_t age;
113
120 NewsTypeData(std::string_view name, uint8_t age, SoundFx sound) :
121 name(name),
122 age(age),
123 sound(sound)
124 {
125 }
126
127 NewsDisplay GetDisplay() const;
128};
129
132 virtual ~NewsAllocatedData() = default;
133};
134
135
155
163 std::string company_name;
164 std::string president_name;
165 std::string other_company_name;
166
167 StringID title;
169 Colours colour;
170
171 CompanyNewsInformation(StringID title, const struct Company *c, const struct Company *other = nullptr);
172};
173
174using NewsContainer = std::list<NewsItem>;
175using NewsIterator = NewsContainer::const_iterator;
176
177#endif /* NEWS_TYPE_H */
Container for an encoded string, created by GetEncodedString.
Types related to companies.
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:29
@ 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:175
std::list< NewsItem > NewsContainer
Container type for storing news items.
Definition news_type.h:174
NewsStyle
News Window Styles.
Definition news_type.h:77
@ 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:51
@ 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:74
NewsFlag
Various OR-able news-item flags.
Definition news_type.h:89
@ 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:100
@ 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:162
CompanyManagerFace face
The face of the president.
Definition news_type.h:168
Colours colour
The colour related to the company.
Definition news_type.h:169
std::string president_name
The name of the president.
Definition news_type.h:164
std::string company_name
The name of the company.
Definition news_type.h:163
std::string other_company_name
The name of the company taking over this one.
Definition news_type.h:165
Container for any custom data that must be deleted after the news item has reached end-of-life.
Definition news_type.h:131
Information about a single item of news.
Definition news_type.h:137
TimerGameCalendar::Date date
Calendar date to show for the news.
Definition news_type.h:139
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:149
NewsType type
Type of the news.
Definition news_type.h:141
EncodedString headline
Headline of news.
Definition news_type.h:138
AdviceType advice_type
The type of advice, to be able to remove specific advices later on.
Definition news_type.h:142
TimerGameEconomy::Date economy_date
Economy date of the news item, never shown but used to calculate age.
Definition news_type.h:140
NewsFlags flags
Window style for the news.
Definition news_type.h:144
NewsReference ref2
Reference 2 to some object: Used for scrolling after clicking on the news, and for deleting the news ...
Definition news_type.h:147
NewsReference ref1
Reference 1 to some object: Used for a possible viewport, scrolling after clicking on the news,...
Definition news_type.h:146
Per-NewsType data.
Definition news_type.h:109
NewsDisplay GetDisplay() const
Return the news display option.
Definition news_gui.cpp:346
NewsTypeData(std::string_view name, uint8_t age, SoundFx sound)
Construct this entry.
Definition news_type.h:120
const std::string_view name
Name.
Definition news_type.h:110
const SoundFx sound
Sound.
Definition news_type.h:112
const uint8_t age
Maximum age of news items (in days)
Definition news_type.h:111
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.