OpenTTD Source 20250312-master-gcdcc6b491d
NewsItem Struct Reference

Information about a single item of news. More...

#include <news_type.h>

Public Member Functions

 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.
 
std::string GetStatusText () const
 

Data Fields

EncodedString headline
 Headline of news.
 
TimerGameCalendar::Date date
 Calendar date to show for the news.
 
TimerGameEconomy::Date economy_date
 Economy date of the news item, never shown but used to calculate age.
 
NewsType type
 Type of the news.
 
AdviceType advice_type
 The type of advice, to be able to remove specific advices later on.
 
NewsStyle style
 
NewsFlags flags
 Window style for the news.
 
NewsReference ref1
 Reference 1 to some object: Used for a possible viewport, scrolling after clicking on the news, and for deleting the news when the object is deleted.
 
NewsReference ref2
 Reference 2 to some object: Used for scrolling after clicking on the news, and for deleting the news when the object is deleted.
 
std::unique_ptr< NewsAllocatedDatadata
 Custom data for the news item that will be deallocated (deleted) when the news item has reached its end.
 

Detailed Description

Information about a single item of news.

Definition at line 136 of file news_type.h.

Constructor & Destructor Documentation

◆ NewsItem()

NewsItem::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.

Parameters
string_idString to display.
typeThe type of news.
flagsFlags related to how to display the news.
ref1Reference 1 to some object: Used for a possible viewport, scrolling after clicking on the news, and for deleting the news when the object is deleted.
ref2Reference 2 to some object: Used for scrolling after clicking on the news, and for deleting the news when the object is deleted.
dataPointer to data that must be released once the news message is cleared.
advice_typeSub-type in case the news type is NewsType::Advice.
See also
NewsSubtype

Definition at line 872 of file news_gui.cpp.

References _settings_client, GUISettings::coloured_news_year, ClientSettings::gui, InColour, BaseBitSet< Timpl, Tvalue_type, Tstorage, Tmask >::Set(), and TimerGameCalendar::year.

Member Function Documentation

◆ GetStatusText()

std::string NewsItem::GetStatusText ( ) const

Definition at line 879 of file news_gui.cpp.

Field Documentation

◆ advice_type

AdviceType NewsItem::advice_type

The type of advice, to be able to remove specific advices later on.

Definition at line 141 of file news_type.h.

Referenced by DeleteVehicleNews().

◆ data

std::unique_ptr<NewsAllocatedData> NewsItem::data

Custom data for the news item that will be deallocated (deleted) when the news item has reached its end.

Definition at line 148 of file news_type.h.

Referenced by NewsWindow::DrawWidget(), NewsWindow::GetWidgetString(), and NewsWindow::OnResize().

◆ date

TimerGameCalendar::Date NewsItem::date

Calendar date to show for the news.

Definition at line 138 of file news_type.h.

Referenced by MessageHistoryWindow::DrawWidget(), and NewsWindow::GetWidgetString().

◆ economy_date

TimerGameEconomy::Date NewsItem::economy_date

Economy date of the news item, never shown but used to calculate age.

Definition at line 139 of file news_type.h.

◆ flags

NewsFlags NewsItem::flags

Window style for the news.

NewsFlags bits

See also
NewsFlag

Definition at line 143 of file news_type.h.

Referenced by ChangeVehicleNews().

◆ headline

EncodedString NewsItem::headline

Headline of news.

Definition at line 137 of file news_type.h.

Referenced by ChangeVehicleNews(), NewsWindow::DrawWidget(), and NewsWindow::UpdateWidgetSize().

◆ ref1

NewsReference NewsItem::ref1

Reference 1 to some object: Used for a possible viewport, scrolling after clicking on the news, and for deleting the news when the object is deleted.

Definition at line 145 of file news_type.h.

Referenced by ChangeVehicleNews(), DeleteInvalidEngineNews(), NewsWindow::DrawWidget(), NewsWindow::OnClick(), NewsWindow::OnResize(), and NewsWindow::UpdateWidgetSize().

◆ ref2

NewsReference NewsItem::ref2

Reference 2 to some object: Used for scrolling after clicking on the news, and for deleting the news when the object is deleted.

Definition at line 146 of file news_type.h.

Referenced by ChangeVehicleNews(), DeleteInvalidEngineNews(), and NewsWindow::OnClick().

◆ style

NewsStyle NewsItem::style

Definition at line 142 of file news_type.h.

◆ type

NewsType NewsItem::type

Type of the news.

Definition at line 140 of file news_type.h.

Referenced by ShowNewspaper().


The documentation for this struct was generated from the following files: