# news.h File Reference

`#include "window_type.h"`
`#include "vehicle_type.h"`
`#include "tile_type.h"`
`#include "date_type.h"`
`#include "strings_type.h"`

Go to the source code of this file.

## Data Structures

struct | NewsItem

## Defines

#define | NEWS_FLAGS(mode, flag, type, cb) ((cb) << 24 | (type) << 16 | (flag) << 8 | (mode))
| Macro for creating news flags.

## Typedefs

typedef bool | ValidationProc (uint data_a, uint data_b)
typedef void | DrawNewsCallbackProc (Window *w)
typedef StringID | GetNewsStringCallbackProc (const NewsItem *ni)

## Enumerations

enum | NewsType { NT_ARRIVAL_PLAYER, NT_ARRIVAL_OTHER, NT_ACCIDENT, NT_COMPANY_INFO, NT_OPENCLOSE, NT_ECONOMY, NT_INDUSTRY_PLAYER, NT_INDUSTRY_OTHER, NT_INDUSTRY_NOBODY, NT_ADVICE, NT_NEW_VEHICLES, NT_ACCEPTANCE, NT_SUBSIDIES, NT_GENERAL, NT_END }
| Type of news. More...
enum | NewsMode { NM_SMALL = 0, NM_NORMAL = 1, NM_THIN = 2, NM_CALLBACK = 3 }
| News mode. More...
enum | NewsFlags { NF_VIEWPORT = (1 << 1), NF_TILE = (1 << 2), NF_VEHICLE = (1 << 3), NF_FORCE_BIG = (1 << 4), NF_INCOLOR = (1 << 5) }
| Various OR-able news-item flags. More...
enum | NewsCallback { DNC_VEHICLEAVAIL = 0, DNC_BANKRUPCY = 1 }
| Special news items. More...
enum | NewsBankrupcy { NB_BTROUBLE = (1 << 4), NB_BMERGER = (2 << 4), NB_BBANKRUPT = (3 << 4), NB_BNEWCOMPANY = (4 << 4) }
| Kinds of bankrupcy. More...

## Functions

void | AddNewsItem (StringID string, uint32 flags, uint data_a, uint data_b)
| Add a new newsitem to be shown.
void | NewsLoop ()
void | DrawNewsBorder (const Window *w)
void | InitNewsItemStructs ()
| Initialize the news-items data structures.
void | DeleteVehicleNews (VehicleID, StringID news)
| Delete a news item type about a vehicle if the news item type is INVALID_STRING_ID all news about the vehicle get deleted.

## Variables

NewsItem | _statusbar_news_item
uint32 | _news_display_opt
bool | _news_ticker_sound
const char * | _news_display_name [NT_END]

## Detailed Description

Definition in file news.h.

## Define Documentation

#define NEWS_FLAGS | ( | mode,
|  | flag,
|  | type,
|  | cb |  | ) | ((cb) << 24 | (type) << 16 | (flag) << 8 | (mode))

Macro for creating news flags.

Parameters:

  | mode | (bits 0 - 7) Display_mode, one of the NewsMode enums (NM_)
  | flag | (bits 8 - 15) OR-able news flags, any of the NewsFlags enums (NF_)
  | type | (bits 16-23) News category, one of the NewsType enums (NT_)
  | cb | (bits 24-31) Call-back function, one of the NewsCallback enums (DNC_) or 0 if no callback

See also:
  NewsMode

  NewsFlags

  NewsType

  NewsCallback

  AddNewsItem

Definition at line 45 of file news.h.

Referenced by AircraftEntersTerminal(), ChangeIndustryProduction(), CheckOrders(), CheckSwitchToEuro(), CheckTrainCollision(), CmdBuildIndustry(), CmdPlayerCtrl(), Disaster_CoalMine_Init(), DisasterTick_Airplane(), DisasterTick_Big_Ufo(), DisasterTick_Helicopter(), DisasterTick_Ufo(), DisasterTick_Zeppeliner(), MaybeNewIndustry(), ReportNewsProductionChangeIndustry(), and ShowRejectOrAcceptNews().

## Enumeration Type Documentation

enum NewsBankrupcy

Kinds of bankrupcy.

Enumerator:

  NB_BTROUBLE | Company is in trouble (warning).
  NB_BMERGER | Company has been bought by another company.
  NB_BBANKRUPT | Company has gone bankrupt.
  NB_BNEWCOMPANY | A new company has been started.

Definition at line 108 of file news.h.

enum NewsCallback

Special news items.

Enumerator:

  DNC_VEHICLEAVAIL | Show new vehicle available message. StringID is EngineID.
  DNC_BANKRUPCY | Show bankrupcy message. StringID is PlayerID (0-3) and NewsBankrupcy (4-7).

Definition at line 102 of file news.h.

enum NewsFlags

Various OR-able news-item flags.

note: NF_INCOLOR is set automatically if needed

See also:
  NEWS_FLAGS

Enumerator:

  NF_VIEWPORT | Does the news message have a viewport? (ingame picture of happening).
  NF_TILE | When clicked on the news message scroll to a given tile? Tile is in data_a/data_b.
  NF_VEHICLE | When clicked on the message scroll to the vehicle? VehicleID is in data_a.
  NF_FORCE_BIG | Force the appearance of a news message if it has already been shown (internal).
  NF_INCOLOR | Show the newsmessage in colour, otherwise it defaults to black & white.

Definition at line 93 of file news.h.

enum NewsMode

News mode.

See also:
  NEWS_FLAGS

Enumerator:

  NM_SMALL | Show only a small popup informing us about vehicle age for example.
  NM_NORMAL | Show a simple news message (height 170 pixels).
  NM_THIN | Show a simple news message (height 130 pixels).
  NM_CALLBACK | Do some special processing before displaying news message. Which callback to call is in NewsCallback.

Definition at line 81 of file news.h.

enum NewsType

Type of news.

Enumerator:

  NT_ARRIVAL_PLAYER | Cargo arrived for player.
  NT_ARRIVAL_OTHER | Cargo arrived for competitor.
  NT_ACCIDENT | An accident or disaster has occurred.
  NT_COMPANY_INFO | Company info (new companies, bankrupcy messages).
  NT_OPENCLOSE | Opening and closing of industries.
  NT_ECONOMY | Economic changes (recession, industry up/dowm).
  NT_INDUSTRY_PLAYER | Production changes of industry serviced by local player.
  NT_INDUSTRY_OTHER | Production changes of industry serviced by competitor(s).
  NT_INDUSTRY_NOBODY | Other industry production changes.
  NT_ADVICE | Bits of news about vehicles of the player.
  NT_NEW_VEHICLES | New vehicle has become available.
  NT_ACCEPTANCE | A type of cargo is (no longer) accepted.
  NT_SUBSIDIES | News about subsidies (announcements, expirations, acceptance).
  NT_GENERAL | General news (from towns).
  NT_END | end-of-array marker

Definition at line 57 of file news.h.

## Function Documentation

void AddNewsItem | ( | StringID | string,
|  | uint32 | flags,
|  | uint | data_a,
|  | uint | data_b |
| ) |  |  |

Add a new newsitem to be shown.

Parameters:

  | string | String to display, can have special values based on parameter flags
  | flags | various control bits that will show various news-types. See macro NEWS_FLAGS()
  | data_a | news-specific value based on news type
  | data_b | news-specific value based on news type

Note:
  flags exists of 4 byte-sized extra parameters.
  1. Bits 0 - 7 display_mode, any of the NewsMode enums (NM_)
  2. Bits 8 - 15 news flags, any of the NewsFlags enums (NF_)
  3. Bits 16 - 23 news category, any of the NewsType enums (NT_)
  4. Bits 24 - 31 news callback function, any of the NewsCallback enums (DNC_)

If the display mode is NM_CALLBACK, special news is shown and parameter string has a special meaning.

- For DNC_TRAINAVAIL, DNC_ROADAVAIL, DNC_SHIPAVAIL, DNC_AIRCRAFTAVAIL messages: StringID is the index of the engine that is shown

- For DNC_BANKRUPCY: bytes 0-3 of StringID contains the player that is in trouble, and 4-7 contains what kind of bankrupcy message is shown.
  See also:
    NewsBankrupcy

    NewsMode

    NewsFlags

    NewsType

    NewsCallback

Definition at line 281 of file news_gui.cpp.

References _current_news, _forced_news, _latest_news, _news_items, _oldest_news, _total_news, increaseIndex(), MAX_NEWS, MoveToNextItem(), NF_INCOLOR, and SetWindowDirty().

Referenced by AircraftEntersTerminal(), ChangeIndustryProduction(), CheckOrders(), CheckSwitchToEuro(), CheckTrainCollision(), CmdBuildIndustry(), CmdPlayerCtrl(), Disaster_CoalMine_Init(), DisasterTick_Airplane(), DisasterTick_Big_Ufo(), DisasterTick_Helicopter(), DisasterTick_Ufo(), DisasterTick_Zeppeliner(), MaybeNewIndustry(), ReportNewsProductionChangeIndustry(), and ShowRejectOrAcceptNews().