OpenTTD Source: src/news_gui.cpp File Reference

OpenTTD Source 15.0-RC2

Data Structures | Functions | Variables
news_gui.cpp File Reference

GUI functions related to news messages. More...

`#include "stdafx.h"`
`#include "gui.h"`
`#include "viewport_func.h"`
`#include "strings_func.h"`
`#include "window_func.h"`
`#include "vehicle_base.h"`
`#include "vehicle_func.h"`
`#include "vehicle_gui.h"`
`#include "roadveh.h"`
`#include "station_base.h"`
`#include "industry.h"`
`#include "town.h"`
`#include "sound_func.h"`
`#include "string_func.h"`
`#include "statusbar_gui.h"`
`#include "company_manager_face.h"`
`#include "company_func.h"`
`#include "engine_base.h"`
`#include "engine_gui.h"`
`#include "core/geometry_func.hpp"`
`#include "command_func.h"`
`#include "company_base.h"`
`#include "settings_internal.h"`
`#include "group_gui.h"`
`#include "zoom_func.h"`
`#include "news_cmd.h"`
`#include "news_func.h"`
`#include "timer/timer.h"`
`#include "timer/timer_window.h"`
`#include "timer/timer_game_calendar.h"`
`#include "widgets/news_widget.h"`
`#include "table/strings.h"`
`#include "safeguards.h"`

Go to the source code of this file.

## Data Structures
struct | NewsWindow
| Window class displaying a news item. More...
struct | MessageHistoryWindow

## Functions
const NewsItem * | GetStatusbarNews ()
| Get pointer to the current status bar news item.
const NewsContainer & | GetNews ()
| Get read-only reference to all news items.
static TileIndex | GetReferenceTile (const NewsReference &reference)
| Get the position a news-reference is referencing.
static WindowDesc & | GetNewsWindowLayout (NewsStyle style)
static void | ShowNewspaper (const NewsItem *ni)
| Open up an own newspaper window for the news item.
static void | ShowTicker (NewsIterator ni)
| Show news item in the ticker.
void | InitNewsItemStructs ()
| Initialize the news-items data structures.
static bool | ReadyForNextTickerItem ()
| Are we ready to show another ticker item? Only if nothing is in the newsticker is displayed.
static bool | ReadyForNextNewsItem ()
| Are we ready to show another news item? Only if no newspaper is displayed.
static void | MoveToNextTickerItem ()
| Move to the next ticker item.
static void | MoveToNextNewsItem ()
| Move to the next news item.
static std::list< NewsItem >::iterator | DeleteNewsItem (std::list< NewsItem >::iterator ni)
| Delete a news item from the queue.
void | AddNewsItem (EncodedString &&headline, NewsType type, NewsStyle style, NewsFlags flags, NewsReference ref1, NewsReference ref2, std::unique_ptr< NewsAllocatedData > &&data, AdviceType advice_type)
| Add a new newsitem to be shown.
uint32_t | SerialiseNewsReference (const NewsReference &reference)
| Encode a NewsReference for serialisation, e.g.
CommandCost | CmdCustomNewsItem (DoCommandFlags flags, NewsType type, CompanyID company, NewsReference reference, const EncodedString &text)
| Create a new custom news item.
template<size_t Tmin = 0, class Tpredicate >
void | DeleteNews (Tpredicate predicate)
| Delete news items by predicate, and invalidate the message history if necessary.
template<typename T >
static bool | IsReferenceObject (const NewsReference &reference, T id)
template<typename T >
static bool | HasReferenceObject (const NewsItem &ni, T id)
void | DeleteVehicleNews (VehicleID vid, AdviceType advice_type)
| Delete news with a given advice type about a vehicle.
void | DeleteStationNews (StationID sid)
| Remove news regarding given station so there are no 'unknown station now accepts Mail' or 'First train arrived at unknown station' news items.
void | DeleteIndustryNews (IndustryID iid)
| Remove news regarding given industry.
bool | IsInvalidEngineNews (const NewsReference &reference)
void | DeleteInvalidEngineNews ()
| Remove engine announcements for invalid engines.
static void | RemoveOldNewsItems ()
template<typename T >
static void | ChangeObject (NewsReference reference, T from, T to)
void | ChangeVehicleNews (VehicleID from_index, VehicleID to_index)
| Report a change in vehicle IDs (due to autoreplace) to affected vehicle news.
void | NewsLoop ()
static void | ShowNewsMessage (NewsIterator ni)
| Do a forced show of a specific message.
bool | HideActiveNewsMessage ()
| Close active news message window.
void | ShowLastNewsMessage ()
| Show previous news item.
static void | DrawNewsString (uint left, uint right, int y, TextColour colour, const NewsItem &ni)
| Draw an unformatted news message truncated to a maximum length.
void | ShowMessageHistory ()
| Display window with news messages history.

## Variables
static const uint | MIN_NEWS_AMOUNT = 30
| preferred minimum amount of news messages.
static const uint | MAX_NEWS_AMOUNT = 1U << 10
| Do not exceed this number of news messages.
static NewsContainer | _news
| List of news, with newest items at the start.
static NewsIterator | _forced_news = std::end(_news)
| Forced news item.
static NewsIterator | _current_news = std::end(_news)
| Current news item (last item shown regularly).
static NewsIterator | _statusbar_news = std::end(_news)
| Current status bar news item.
static constexpr std::initializer_list< NWidgetPart > | _nested_normal_news_widgets
static WindowDesc | _normal_news_desc (WDP_MANUAL, {}, 0, 0, WC_NEWS_WINDOW, WC_NONE, {}, _nested_normal_news_widgets)
static constexpr std::initializer_list< NWidgetPart > | _nested_vehicle_news_widgets
static WindowDesc | _vehicle_news_desc (WDP_MANUAL, {}, 0, 0, WC_NEWS_WINDOW, WC_NONE, {}, _nested_vehicle_news_widgets)
static constexpr std::initializer_list< NWidgetPart > | _nested_company_news_widgets
static WindowDesc | _company_news_desc (WDP_MANUAL, {}, 0, 0, WC_NEWS_WINDOW, WC_NONE, {}, _nested_company_news_widgets)
static constexpr std::initializer_list< NWidgetPart > | _nested_thin_news_widgets
static WindowDesc | _thin_news_desc (WDP_MANUAL, {}, 0, 0, WC_NEWS_WINDOW, WC_NONE, {}, _nested_thin_news_widgets)
static constexpr std::initializer_list< NWidgetPart > | _nested_small_news_widgets
static WindowDesc | _small_news_desc (WDP_MANUAL, {}, 0, 0, WC_NEWS_WINDOW, WC_NONE, {}, _nested_small_news_widgets)
static WindowDesc * | _news_window_layout []
| Window layouts for news items.
static const NewsTypeData | _news_type_data []
| Per-NewsType data.
static constexpr std::initializer_list< NWidgetPart > | _nested_message_history
static WindowDesc | _message_history_desc (WDP_AUTO, "list_news", 400, 140, WC_MESSAGE_HISTORY, WC_NONE, {}, _nested_message_history)

## Detailed Description

GUI functions related to news messages.

Definition in file news_gui.cpp.

## Function Documentation

## ◆ AddNewsItem()

void AddNewsItem | ( | EncodedString && | headline,
|  | NewsType | type,
|  | NewsStyle | style,
|  | NewsFlags | flags,
|  | NewsReference | ref1,
|  | NewsReference | ref2,
|  | std::unique_ptr< NewsAllocatedData > && | data,
|  | AdviceType | advice_type
| ) |  |

Add a new newsitem to be shown.

Parameters

  string | String to display
  type | news category
  flags | display flags for the news
  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.
  ref2 | Reference 2 to some object: Used for scrolling after clicking on the news, and for deleting the news when the object is deleted.
  data | Pointer to data that must be released once the news message is cleared.
  advice_type | Sub-type in case the news type is NewsType::Advice.

See also
  NewsSubtype

Definition at line 900 of file news_gui.cpp.

References _news, DeleteNewsItem(), InvalidateWindowData(), MAX_NEWS_AMOUNT, and WC_MESSAGE_HISTORY.

Referenced by AddVehicleAdviceNewsItem(), AddVehicleNewsItem(), Subsidy::AwardTo(), CmdCustomNewsItem(), CreateSubsidy(), GenerateCompanyName(), NewVehicleAvailable(), ShowRejectOrAcceptNews(), TownActionBuyRights(), and TownActionRoadRebuild().

## ◆ ChangeObject()

template<typename T >

static void ChangeObject | ( | NewsReference | reference,
|  | T | from,
|  | T | to
| ) |  |
| static

Definition at line 1071 of file news_gui.cpp.

## ◆ ChangeVehicleNews()

void ChangeVehicleNews | ( | VehicleID | from_index,
|  | VehicleID | to_index
| ) |  |

Report a change in vehicle IDs (due to autoreplace) to affected vehicle news.

Note
  Viewports of currently displayed news is changed via ChangeVehicleViewports

Parameters

  from_index | the old vehicle ID
  to_index | the new vehicle ID

Definition at line 1083 of file news_gui.cpp.

References _news, NewsItem::flags, NewsItem::headline, NewsItem::ref1, NewsItem::ref2, EncodedString::ReplaceParam(), BaseBitSet< Timpl, Tvalue_type, Tstorage, Tmask >::Test(), and VehicleParam0.

Referenced by CopyHeadSpecificThings().

## ◆ CmdCustomNewsItem()

CommandCost CmdCustomNewsItem | ( | DoCommandFlags | flags,
|  | NewsType | type,
|  | CompanyID | company,
|  | NewsReference | reference,
|  | const EncodedString & | text
| ) |  |

Create a new custom news item.

Parameters

  flags | type of operation @aram type NewsType of the message.
  reftype1 | NewsReferenceType of first reference.
  company | Company this news message is for.
  reference_id | First reference of the news message.
  text | The text of the news message.

Returns
  the cost of this operation or an error

Definition at line 945 of file news_gui.cpp.

References _current_company, _local_company, AddNewsItem(), CMD_ERROR, End, Execute, INVALID_OWNER, SpecializedStation< Station, false >::IsValidID(), Pool< Titem, Tindex, Tgrowth_step, Tpool_type, Tcache >::PoolItem<&_town_pool >::IsValidID(), Pool< Titem, Tindex, Tgrowth_step, Tpool_type, Tcache >::PoolItem<&_company_pool >::IsValidID(), Pool< Titem, Tindex, Tgrowth_step, Tpool_type, Tcache >::PoolItem<&_vehicle_pool >::IsValidID(), Pool< Titem, Tindex, Tgrowth_step, Tpool_type, Tcache >::PoolItem<&_industry_pool >::IsValidID(), Pool< Titem, Tindex, Tgrowth_step, Tpool_type, Tcache >::PoolItem<&_engine_pool >::IsValidID(), IsValidTile(), Normal, OWNER_DEITY, and BaseBitSet< Timpl, Tvalue_type, Tstorage, Tmask >::Test().

## ◆ DeleteIndustryNews()

void DeleteIndustryNews | ( | IndustryID | iid | ) |

Remove news regarding given industry.

Parameters

  iid | industry to remove news about

Definition at line 1038 of file news_gui.cpp.

References DeleteNews().

## ◆ DeleteInvalidEngineNews()

void DeleteInvalidEngineNews | ( |  | ) |

Remove engine announcements for invalid engines.

Definition at line 1056 of file news_gui.cpp.

References DeleteNews(), NewsItem::ref1, and NewsItem::ref2.

Referenced by ReloadNewGRFData().

## ◆ DeleteNews()

template<size_t Tmin = 0, class Tpredicate >

void DeleteNews | ( | Tpredicate | predicate | ) |

Delete news items by predicate, and invalidate the message history if necessary.

Template Parameters

  Tmin | Stop if the number of news items remaining reaches min items.
  Tpredicate | Condition for a news item to be deleted.

Definition at line 980 of file news_gui.cpp.

References _news, DeleteNewsItem(), InvalidateWindowData(), and WC_MESSAGE_HISTORY.

Referenced by DeleteIndustryNews(), DeleteInvalidEngineNews(), DeleteStationNews(), and DeleteVehicleNews().

## ◆ DeleteNewsItem()

static std::list< NewsItem >::iterator DeleteNewsItem | ( | std::list< NewsItem >::iterator | ni | ) |
| static

Delete a news item from the queue.

Definition at line 822 of file news_gui.cpp.

References _current_news, _forced_news, _news, _statusbar_news, InvalidateWindowData(), MoveToNextNewsItem(), MoveToNextTickerItem(), SBI_NEWS_DELETED, and WC_STATUS_BAR.

Referenced by AddNewsItem(), and DeleteNews().

## ◆ DeleteStationNews()

void DeleteStationNews | ( | StationID | sid | ) |

Remove news regarding given station so there are no 'unknown station now accepts Mail' or 'First train arrived at unknown station' news items.

Parameters

  sid | station to remove news about

Definition at line 1027 of file news_gui.cpp.

References DeleteNews().

Referenced by Station::~Station().

## ◆ DeleteVehicleNews()

void DeleteVehicleNews | ( | VehicleID | vid,
|  | AdviceType | advice_type
| ) |  |

Delete news with a given advice type about a vehicle.

When the advice_type is AdviceType::Invalid all news about the vehicle gets deleted.

Parameters

  vid | The vehicle to remove the news for.
  advice_type | The advice type to remove for.

Definition at line 1015 of file news_gui.cpp.

References NewsItem::advice_type, and DeleteNews().

Referenced by AircraftHandleDestTooFar(), CmdStartStopVehicle(), DeleteOrderWarnings(), Vehicle::HandlePathfindingResult(), and Vehicle::~Vehicle().

## ◆ DrawNewsString()

static void DrawNewsString | ( | uint | left,
|  | uint | right,
|  | int | y,
|  | TextColour | colour,
|  | const NewsItem & | ni
| ) |  |
| static

Draw an unformatted news message truncated to a maximum length.

If length exceeds maximum length it will be postfixed by '...'

Parameters

  left | the left most location for the string
  right | the right most location for the string
  y | position of the string
  colour | the colour the string will be shown in
  *ni | NewsItem being printed

Definition at line 1188 of file news_gui.cpp.

References DrawString(), ReplaceTabCrNlWithSpace, and StrMakeValid().

Referenced by MessageHistoryWindow::DrawWidget().

## ◆ GetNews()

const NewsContainer & GetNews | ( |  | ) |

Get read-only reference to all news items.

Returns
  Read-only reference to all news items.

Definition at line 79 of file news_gui.cpp.

References _news.

Referenced by SurveyRecentNews().

## ◆ GetNewsWindowLayout()

static WindowDesc & GetNewsWindowLayout | ( | NewsStyle | style | ) |
| static

Definition at line 312 of file news_gui.cpp.

## ◆ GetReferenceTile()

static TileIndex GetReferenceTile | ( | const NewsReference & | reference | ) |
| static

Get the position a news-reference is referencing.

Parameters

  reference | The reference.

Returns
  A tile for the referenced object, or INVALID_TILE if none.

Definition at line 89 of file news_gui.cpp.

References SpecializedStation< Station, false >::Get(), Pool< Titem, Tindex, Tgrowth_step, Tpool_type, Tcache >::PoolItem<&_industry_pool >::Get(), Pool< Titem, Tindex, Tgrowth_step, Tpool_type, Tcache >::PoolItem<&_town_pool >::Get(), INVALID_TILE, TileDiffXY(), and BaseStation::xy.

Referenced by NewsWindow::OnClick(), and NewsWindow::OnResize().

## ◆ GetStatusbarNews()

const NewsItem * GetStatusbarNews | ( |  | ) |

Get pointer to the current status bar news item.

Returns
  Pointer to the current status bar news item, or nullptr if there is none.

Definition at line 70 of file news_gui.cpp.

References _news, and _statusbar_news.

Referenced by StatusBarWindow::DrawWidget(), and ReadyForNextTickerItem().

## ◆ HasReferenceObject()

template<typename T >

static bool HasReferenceObject | ( | const NewsItem & | ni,
|  | T | id
| ) |  |
| static

Definition at line 1004 of file news_gui.cpp.

## ◆ HideActiveNewsMessage()

bool HideActiveNewsMessage | ( |  | ) |

Close active news message window.

Returns
  true if a window was closed.

Definition at line 1129 of file news_gui.cpp.

References Window::Close(), FindWindowById(), and WC_NEWS_WINDOW.

Referenced by MainWindow::OnHotkey().

## ◆ InitNewsItemStructs()

void InitNewsItemStructs | ( |  | ) |

Initialize the news-items data structures.

Definition at line 714 of file news_gui.cpp.

References _current_news, _forced_news, _news, _statusbar_news, and NewsWindow::duration.

Referenced by DeleteAllMessages().

## ◆ IsInvalidEngineNews()

bool IsInvalidEngineNews | ( | const NewsReference & | reference | ) |

Definition at line 1045 of file news_gui.cpp.

## ◆ IsReferenceObject()

template<typename T >

static bool IsReferenceObject | ( | const NewsReference & | reference,
|  | T | id
| ) |  |
| static

Definition at line 998 of file news_gui.cpp.

## ◆ MoveToNextNewsItem()

static void MoveToNextNewsItem | ( |  | ) |
| static

Move to the next news item.

Definition at line 785 of file news_gui.cpp.

References _current_news, _forced_news, _news, _news_type_data, CloseWindowById(), TimerGameEconomy::date, FindWindowById(), Full, Off, ShowNewspaper(), Summary, to_underlying(), WC_NEWS_WINDOW, and WC_STATUS_BAR.

Referenced by DeleteNewsItem().

## ◆ MoveToNextTickerItem()

static void MoveToNextTickerItem | ( |  | ) |
| static

Move to the next ticker item.

Definition at line 750 of file news_gui.cpp.

References _news, _news_type_data, _statusbar_news, TimerGameEconomy::date, FindWindowById(), Full, InvalidateWindowData(), Off, SBI_SHOW_REMINDER, ShowTicker(), Summary, to_underlying(), and WC_STATUS_BAR.

Referenced by DeleteNewsItem().

## ◆ NewsLoop()

void NewsLoop | ( |  | ) |

Definition at line 1092 of file news_gui.cpp.

## ◆ ReadyForNextNewsItem()

static bool ReadyForNextNewsItem | ( |  | ) |
| static

Are we ready to show another news item? Only if no newspaper is displayed.

Definition at line 741 of file news_gui.cpp.

References _current_news, _forced_news, _news, NewsWindow::duration, FindWindowById(), and WC_NEWS_WINDOW.

## ◆ ReadyForNextTickerItem()

static bool ReadyForNextTickerItem | ( |  | ) |
| static

Are we ready to show another ticker item? Only if nothing is in the newsticker is displayed.

Definition at line 727 of file news_gui.cpp.

References GetStatusbarNews(), and IsNewsTickerShown().

## ◆ RemoveOldNewsItems()

static void RemoveOldNewsItems | ( |  | ) |
| static

Definition at line 1063 of file news_gui.cpp.

## ◆ SerialiseNewsReference()

uint32_t SerialiseNewsReference | ( | const NewsReference & | reference | ) |

Encode a NewsReference for serialisation, e.g.

for writing in the crash log.

Parameters

  reference | The reference to serialise.

Returns
  Reference serialised into a single uint32_t.

Definition at line 920 of file news_gui.cpp.

Referenced by SurveyRecentNews().

## ◆ ShowLastNewsMessage()

void ShowLastNewsMessage | ( |  | ) |

Show previous news item.

Definition at line 1138 of file news_gui.cpp.

References _current_news, _forced_news, _news, _news_type_data, FindWindowById(), NewsTypeData::GetDisplay(), Off, ShowNewsMessage(), to_underlying(), and WC_NEWS_WINDOW.

Referenced by MenuClickNewspaper(), and StatusBarWindow::OnClick().

## ◆ ShowMessageHistory()

void ShowMessageHistory | ( |  | ) |

Display window with news messages history.

Definition at line 1303 of file news_gui.cpp.

References CloseWindowById(), and WC_MESSAGE_HISTORY.

Referenced by MenuClickNewspaper().

## ◆ ShowNewsMessage()

static void ShowNewsMessage | ( | NewsIterator | ni | ) |
| static

Do a forced show of a specific message.

Definition at line 1109 of file news_gui.cpp.

References _forced_news, _news, CloseWindowById(), ShowNewspaper(), and WC_NEWS_WINDOW.

Referenced by MessageHistoryWindow::OnClick(), and ShowLastNewsMessage().

## ◆ ShowNewspaper()

static void ShowNewspaper | ( | const NewsItem * | ni | ) |
| static

Open up an own newspaper window for the news item.

Definition at line 696 of file news_gui.cpp.

References _news_type_data, _settings_client, SoundSettings::news_full, NewsTypeData::sound, ClientSettings::sound, to_underlying(), and NewsItem::type.

Referenced by MoveToNextNewsItem(), and ShowNewsMessage().

## ◆ ShowTicker()

static void ShowTicker | ( | NewsIterator | ni | ) |
| static

Show news item in the ticker.

Definition at line 705 of file news_gui.cpp.

References _settings_client, _statusbar_news, InvalidateWindowData(), SoundSettings::news_ticker, SBI_SHOW_TICKER, SND_16_NEWS_TICKER, ClientSettings::sound, and WC_STATUS_BAR.

Referenced by MoveToNextTickerItem().

## Variable Documentation

## ◆ _current_news

NewsIterator _current_news = std::end(_news)
| static

Current news item (last item shown regularly).

Definition at line 61 of file news_gui.cpp.

Referenced by DeleteNewsItem(), InitNewsItemStructs(), MoveToNextNewsItem(), ReadyForNextNewsItem(), and ShowLastNewsMessage().

## ◆ _forced_news

NewsIterator _forced_news = std::end(_news)
| static

Forced news item.

Users can force an item by accessing the history or "last message". If the message being shown was forced by the user, an iterator is stored in _forced_news. Otherwise, _forced_news variable is the end of _news.

Definition at line 58 of file news_gui.cpp.

Referenced by DeleteNewsItem(), InitNewsItemStructs(), MoveToNextNewsItem(), NewsWindow::OnClick(), ReadyForNextNewsItem(), ShowLastNewsMessage(), and ShowNewsMessage().

## ◆ _nested_company_news_widgets

constexpr std::initializer_list<NWidgetPart> _nested_company_news_widgets
| staticconstexpr

Definition at line 185 of file news_gui.cpp.

## ◆ _nested_message_history

constexpr std::initializer_list<NWidgetPart> _nested_message_history
| staticconstexpr

Initial value:
= {
NWidget(NWID_HORIZONTAL),
NWidget(WWT_CLOSEBOX, COLOUR_BROWN),
NWidget(WWT_CAPTION, COLOUR_BROWN), SetStringTip(STR_MESSAGE_HISTORY, STR_TOOLTIP_WINDOW_TITLE_DRAG_THIS),
NWidget(WWT_SHADEBOX, COLOUR_BROWN),
NWidget(WWT_DEFSIZEBOX, COLOUR_BROWN),
NWidget(WWT_STICKYBOX, COLOUR_BROWN),
EndContainer(),
NWidget(NWID_HORIZONTAL),
NWidget(WWT_PANEL, COLOUR_BROWN, WID_MH_BACKGROUND), SetMinimalSize(200, 125), SetToolTip(STR_MESSAGE_HISTORY_TOOLTIP), SetResize(1, 12), SetScrollbar(WID_MH_SCROLLBAR),
EndContainer(),
NWidget(NWID_VERTICAL),
NWidget(NWID_VSCROLLBAR, COLOUR_BROWN, WID_MH_SCROLLBAR),
NWidget(WWT_RESIZEBOX, COLOUR_BROWN),
EndContainer(),
EndContainer(),
}
SetScrollbar
constexpr NWidgetPart SetScrollbar(WidgetID index)
Attach a scrollbar to a widget.
Definition widget_type.h:1399
SetStringTip
constexpr NWidgetPart SetStringTip(StringID string, StringID tip={})
Widget part function for setting the string and tooltip.
Definition widget_type.h:1240
SetMinimalSize
constexpr NWidgetPart SetMinimalSize(int16_t x, int16_t y)
Widget part function for setting the minimal size.
Definition widget_type.h:1156
SetToolTip
constexpr NWidgetPart SetToolTip(StringID tip)
Widget part function for setting tooltip and clearing the widget data.
Definition widget_type.h:1318
EndContainer
constexpr NWidgetPart EndContainer()
Widget part function for denoting the end of a container (horizontal, vertical, WWT_FRAME,...
Definition widget_type.h:1229
NWidget
constexpr NWidgetPart NWidget(WidgetType tp, Colours col, WidgetID idx=INVALID_WIDGET)
Widget part function for starting a new 'real' widget.
Definition widget_type.h:1424
SetResize
constexpr NWidgetPart SetResize(int16_t dx, int16_t dy)
Widget part function for setting the resize step.
Definition widget_type.h:1145
WID_MH_SCROLLBAR
@ WID_MH_SCROLLBAR
Scrollbar for the list.
Definition news_widget.h:42
WID_MH_BACKGROUND
@ WID_MH_BACKGROUND
Background of the window.
Definition news_widget.h:41
NWID_HORIZONTAL
@ NWID_HORIZONTAL
Horizontal container.
Definition widget_type.h:66
WWT_PANEL
@ WWT_PANEL
Simple depressed panel.
Definition widget_type.h:39
WWT_STICKYBOX
@ WWT_STICKYBOX
Sticky box (at top-right of a window, after WWT_DEFSIZEBOX)
Definition widget_type.h:57
WWT_SHADEBOX
@ WWT_SHADEBOX
Shade box (at top-right of a window, between WWT_DEBUGBOX and WWT_DEFSIZEBOX)
Definition widget_type.h:55
WWT_CAPTION
@ WWT_CAPTION
Window caption (window title between closebox and stickybox)
Definition widget_type.h:52
NWID_VSCROLLBAR
@ NWID_VSCROLLBAR
Vertical scrollbar.
Definition widget_type.h:76
NWID_VERTICAL
@ NWID_VERTICAL
Vertical container.
Definition widget_type.h:68
WWT_CLOSEBOX
@ WWT_CLOSEBOX
Close box (at top-left of a window)
Definition widget_type.h:60
WWT_RESIZEBOX
@ WWT_RESIZEBOX
Resize box (normally at bottom-right of a window)
Definition widget_type.h:59
WWT_DEFSIZEBOX
@ WWT_DEFSIZEBOX
Default window size box (at top-right of a window, between WWT_SHADEBOX and WWT_STICKYBOX)
Definition widget_type.h:56

Definition at line 1276 of file news_gui.cpp.

## ◆ _nested_normal_news_widgets

constexpr std::initializer_list<NWidgetPart> _nested_normal_news_widgets
| staticconstexpr

Initial value:
= {
NWidget(WWT_PANEL, COLOUR_WHITE, WID_N_PANEL),
NWidget(NWID_VERTICAL), SetPadding(WidgetDimensions::unscaled.fullbevel),
NWidget(NWID_LAYER, INVALID_COLOUR),
NWidget(NWID_VERTICAL), SetPIPRatio(0, 0, 1),
NWidget(NWID_HORIZONTAL), SetPIPRatio(0, 1, 0),
NWidget(WWT_CLOSEBOX, COLOUR_WHITE, WID_N_CLOSEBOX),
NWidget(WWT_LABEL, INVALID_COLOUR, WID_N_DATE),
SetTextStyle(TC_BLACK, FS_SMALL),
SetAlignment(SA_RIGHT | SA_TOP),
EndContainer(),
EndContainer(),
NWidget(WWT_EMPTY, INVALID_COLOUR, WID_N_MESSAGE),
SetMinimalTextLines(8, 0, FS_LARGE),
SetMinimalSize(400, 0),
SetPadding(WidgetDimensions::unscaled.hsep_indent, WidgetDimensions::unscaled.vsep_wide),
SetTextStyle(TC_BLACK, FS_LARGE),
EndContainer(),
EndContainer(),
EndContainer(),
}
WidgetDimensions::unscaled
static const WidgetDimensions unscaled
Unscaled widget dimensions.
Definition window_gui.h:93
FS_SMALL
@ FS_SMALL
Index of the small font in the font tables.
Definition gfx_type.h:250
FS_LARGE
@ FS_LARGE
Index of the large font in the font tables.
Definition gfx_type.h:251
SA_TOP
@ SA_TOP
Top align the text.
Definition gfx_type.h:393
SA_RIGHT
@ SA_RIGHT
Right align the text (must be a single bit).
Definition gfx_type.h:390
SetPadding
constexpr NWidgetPart SetPadding(uint8_t top, uint8_t right, uint8_t bottom, uint8_t left)
Widget part function for setting additional space around a widget.
Definition widget_type.h:1332
SetTextStyle
constexpr NWidgetPart SetTextStyle(TextColour colour, FontSize size=FS_NORMAL)
Widget part function for setting the text style.
Definition widget_type.h:1198
SetMinimalTextLines
constexpr NWidgetPart SetMinimalTextLines(uint8_t lines, uint8_t spacing, FontSize size=FS_NORMAL)
Widget part function for setting the minimal text lines.
Definition widget_type.h:1187
SetAlignment
constexpr NWidgetPart SetAlignment(StringAlignment align)
Widget part function for setting the alignment of text/images.
Definition widget_type.h:1208
SetPIPRatio
constexpr NWidgetPart SetPIPRatio(uint8_t ratio_pre, uint8_t ratio_inter, uint8_t ratio_post)
Widget part function for setting a pre/inter/post ratio.
Definition widget_type.h:1387
WID_N_DATE
@ WID_N_DATE
Date of the news item.
Definition news_widget.h:21
WID_N_PANEL
@ WID_N_PANEL
Panel of the window.
Definition news_widget.h:17
WID_N_CLOSEBOX
@ WID_N_CLOSEBOX
Close the window.
Definition news_widget.h:20
WID_N_MESSAGE
@ WID_N_MESSAGE
Space for displaying the message. Only used in small news items.
Definition news_widget.h:26
WWT_LABEL
@ WWT_LABEL
Centered label.
Definition widget_type.h:48
WWT_EMPTY
@ WWT_EMPTY
Empty widget, place holder to reserve space in widget tree.
Definition widget_type.h:37
NWID_LAYER
@ NWID_LAYER
Layered widgets, all visible together.
Definition widget_type.h:72

Definition at line 105 of file news_gui.cpp.

## ◆ _nested_small_news_widgets

constexpr std::initializer_list<NWidgetPart> _nested_small_news_widgets
| staticconstexpr

Initial value:
= {
NWidget(NWID_HORIZONTAL),
NWidget(WWT_CLOSEBOX, COLOUR_LIGHT_BLUE, WID_N_CLOSEBOX),
NWidget(WWT_EMPTY, INVALID_COLOUR, WID_N_CAPTION),
NWidget(NWID_SELECTION, INVALID_COLOUR, WID_N_SHOW_GROUP_SEL),
NWidget(WWT_TEXTBTN, COLOUR_LIGHT_BLUE, WID_N_SHOW_GROUP),
SetAspect(WidgetDimensions::ASPECT_VEHICLE_ICON),
SetResize(1, 0),
SetToolTip(STR_NEWS_SHOW_VEHICLE_GROUP_TOOLTIP),
EndContainer(),
EndContainer(),
NWidget(WWT_PANEL, COLOUR_LIGHT_BLUE, WID_N_HEADLINE),
NWidget(NWID_VERTICAL),
SetPIP(0, WidgetDimensions::unscaled.vsep_normal, 0),
SetPadding(2),
NWidget(WWT_INSET, COLOUR_LIGHT_BLUE, WID_N_INSET),
NWidget(NWID_VIEWPORT, INVALID_COLOUR, WID_N_VIEWPORT),
SetMinimalSize(274, 47),
EndContainer(),
NWidget(WWT_EMPTY, INVALID_COLOUR, WID_N_MESSAGE),
SetMinimalTextLines(2, 0),
SetMinimalSize(275, 0),
SetTextStyle(TC_WHITE, FS_NORMAL),
EndContainer(),
EndContainer(),
}
FS_NORMAL
@ FS_NORMAL
Index of the normal font in the font tables.
Definition gfx_type.h:249
SetPIP
constexpr NWidgetPart SetPIP(uint8_t pre, uint8_t inter, uint8_t post)
Widget part function for setting a pre/inter/post spaces.
Definition widget_type.h:1375
SetAspect
constexpr NWidgetPart SetAspect(float ratio, AspectFlags flags=AspectFlag::ResizeX)
Widget part function for setting the aspect ratio.
Definition widget_type.h:1410
WID_N_SHOW_GROUP
@ WID_N_SHOW_GROUP
Show vehicle's group.
Definition news_widget.h:34
WID_N_CAPTION
@ WID_N_CAPTION
Title bar of the window. Only used in small news items.
Definition news_widget.h:22
WID_N_HEADLINE
@ WID_N_HEADLINE
The news headline.
Definition news_widget.h:19
WID_N_INSET
@ WID_N_INSET
Inset around the viewport in the window. Only used in small news items.
Definition news_widget.h:23
WID_N_SHOW_GROUP_SEL
@ WID_N_SHOW_GROUP_SEL
Selector for showing vehicle group, which can be hidden.
Definition news_widget.h:35
WID_N_VIEWPORT
@ WID_N_VIEWPORT
Viewport in the window.
Definition news_widget.h:24
WWT_INSET
@ WWT_INSET
Pressed (inset) panel, most commonly used as combo box text area.
Definition widget_type.h:40
WWT_TEXTBTN
@ WWT_TEXTBTN
(Toggle) Button with text
Definition widget_type.h:44
NWID_VIEWPORT
@ NWID_VIEWPORT
Nested widget containing a viewport.
Definition widget_type.h:73
NWID_SELECTION
@ NWID_SELECTION
Stacked widgets, only one visible at a time (eg in a panel with tabs).
Definition widget_type.h:71

Definition at line 264 of file news_gui.cpp.

## ◆ _nested_thin_news_widgets

constexpr std::initializer_list<NWidgetPart> _nested_thin_news_widgets
| staticconstexpr

Initial value:
= {
NWidget(WWT_PANEL, COLOUR_WHITE, WID_N_PANEL),
NWidget(NWID_VERTICAL), SetPadding(WidgetDimensions::unscaled.fullbevel),
NWidget(NWID_LAYER, INVALID_COLOUR),
NWidget(NWID_VERTICAL), SetPIPRatio(0, 0, 1),
NWidget(NWID_HORIZONTAL), SetPIPRatio(0, 1, 0),
NWidget(WWT_CLOSEBOX, COLOUR_WHITE, WID_N_CLOSEBOX),
NWidget(WWT_LABEL, INVALID_COLOUR, WID_N_DATE),
SetTextStyle(TC_BLACK, FS_SMALL),
SetAlignment(SA_RIGHT | SA_TOP),
EndContainer(),
EndContainer(),
NWidget(WWT_EMPTY, INVALID_COLOUR, WID_N_MESSAGE),
SetMinimalTextLines(3, 0, FS_LARGE),
SetMinimalSize(400, 0),
SetPadding(WidgetDimensions::unscaled.hsep_indent, WidgetDimensions::unscaled.vsep_normal),
SetTextStyle(TC_BLACK, FS_LARGE),
EndContainer(),
NWidget(NWID_VIEWPORT, INVALID_COLOUR, WID_N_VIEWPORT), SetMinimalSize(426, 70),
SetPadding(WidgetDimensions::unscaled.fullbevel),
EndContainer(),
EndContainer(),
}

Definition at line 230 of file news_gui.cpp.

## ◆ _nested_vehicle_news_widgets

constexpr std::initializer_list<NWidgetPart> _nested_vehicle_news_widgets
| staticconstexpr

Definition at line 137 of file news_gui.cpp.

## ◆ _news

NewsContainer _news
| static

List of news, with newest items at the start.

Definition at line 50 of file news_gui.cpp.

Referenced by AddNewsItem(), ChangeVehicleNews(), DeleteNews(), DeleteNewsItem(), MessageHistoryWindow::DrawWidget(), GetNews(), GetStatusbarNews(), InitNewsItemStructs(), MoveToNextNewsItem(), MoveToNextTickerItem(), NewsWindow::OnClick(), MessageHistoryWindow::OnClick(), MessageHistoryWindow::OnInvalidateData(), ReadyForNextNewsItem(), ShowLastNewsMessage(), and ShowNewsMessage().

## ◆ _news_type_data

const NewsTypeData _news_type_data[]
| static

Initial value:
= {
NewsTypeData("news_display.arrival_player", 60, SND_1D_APPLAUSE ),
NewsTypeData("news_display.arrival_other", 60, SND_1D_APPLAUSE ),
NewsTypeData("news_display.accident", 90, SND_BEGIN ),
NewsTypeData("news_display.accident_other", 90, SND_BEGIN ),
NewsTypeData("news_display.company_info", 60, SND_BEGIN ),
NewsTypeData("news_display.open", 90, SND_BEGIN ),
NewsTypeData("news_display.close", 90, SND_BEGIN ),
NewsTypeData("news_display.economy", 30, SND_BEGIN ),
NewsTypeData("news_display.production_player", 30, SND_BEGIN ),
NewsTypeData("news_display.production_other", 30, SND_BEGIN ),
NewsTypeData("news_display.production_nobody", 30, SND_BEGIN ),
NewsTypeData("news_display.advice", 150, SND_BEGIN ),
NewsTypeData("news_display.new_vehicles", 30, SND_1E_NEW_ENGINE),
NewsTypeData("news_display.acceptance", 90, SND_BEGIN ),
NewsTypeData("news_display.subsidies", 180, SND_BEGIN ),
NewsTypeData("news_display.general", 60, SND_BEGIN ),
}
SND_1D_APPLAUSE
@ SND_1D_APPLAUSE
27 == 0x1B News: first vehicle at station
Definition sound_type.h:74
SND_1E_NEW_ENGINE
@ SND_1E_NEW_ENGINE
28 == 0x1C News: new engine available
Definition sound_type.h:75
NewsTypeData
Per-NewsType data.
Definition news_type.h:109

Per-NewsType data.

Definition at line 322 of file news_gui.cpp.

Referenced by MoveToNextNewsItem(), MoveToNextTickerItem(), ShowLastNewsMessage(), and ShowNewspaper().

## ◆ _news_window_layout

WindowDesc* _news_window_layout[]
| static

Initial value:
= {
&_thin_news_desc,
&_small_news_desc,
&_normal_news_desc,
&_vehicle_news_desc,
&_company_news_desc,
}

Window layouts for news items.

Definition at line 304 of file news_gui.cpp.

## ◆ _statusbar_news

NewsIterator _statusbar_news = std::end(_news)
| static

Current status bar news item.

Definition at line 64 of file news_gui.cpp.

Referenced by DeleteNewsItem(), GetStatusbarNews(), InitNewsItemStructs(), MoveToNextTickerItem(), and ShowTicker().

## ◆ MAX_NEWS_AMOUNT

const uint MAX_NEWS_AMOUNT = 1U << 10
| static

Do not exceed this number of news messages.

Definition at line 48 of file news_gui.cpp.

Referenced by AddNewsItem().

## ◆ MIN_NEWS_AMOUNT

const uint MIN_NEWS_AMOUNT = 30
| static

preferred minimum amount of news messages.

Definition at line 47 of file news_gui.cpp.