OpenTTD Game API
Public Types | Static Public Member Functions
GSNews Class Reference

Class that handles news messages. More...

Inheritance diagram for GSNews:

Public Types

enum  NewsType {
  NT_ACCIDENT,
  NT_COMPANY_INFO,
  NT_ECONOMY,
  NT_ADVICE,
  NT_ACCEPTANCE,
  NT_SUBSIDIES,
  NT_GENERAL
}
 Enumeration for the news types that a script can create news for. More...
 
enum  NewsReferenceType {
  NR_NONE,
  NR_TILE,
  NR_STATION,
  NR_INDUSTRY,
  NR_TOWN
}
 Reference to a game element. More...
 

Static Public Member Functions

static bool Create (NewsType type, Text *text, GSCompany::CompanyID company, NewsReferenceType ref_type, uint32 reference)
 Create a news message for everybody, or for one company. More...
 

Detailed Description

Class that handles news messages.

Member Enumeration Documentation

◆ NewsReferenceType

Reference to a game element.

Enumerator
NR_NONE 

No reference supplied.

NR_TILE 

Reference location, scroll to the location when clicking on the news.

NR_STATION 

Reference station, scroll to the station when clicking on the news. Delete news when the station is deleted.

NR_INDUSTRY 

Reference industry, scrolls to the industry when clicking on the news. Delete news when the industry is deleted.

NR_TOWN 

Reference town, scroll to the town when clicking on the news.

◆ NewsType

Enumeration for the news types that a script can create news for.

Enumerator
NT_ACCIDENT 

Category accidents.

NT_COMPANY_INFO 

Category company info.

NT_ECONOMY 

Category economy.

NT_ADVICE 

Category vehicle advice.

NT_ACCEPTANCE 

Category acceptance changes.

NT_SUBSIDIES 

Category subsidies.

NT_GENERAL 

Category general.

Member Function Documentation

◆ Create()

static bool GSNews::Create ( NewsType  type,
Text *  text,
GSCompany::CompanyID  company,
NewsReferenceType  ref_type,
uint32  reference 
)
static

Create a news message for everybody, or for one company.

Parameters
typeThe type of the news.
textThe text message to show (can be either a raw string, or a GSText object).
companyThe company, or COMPANY_INVALID for all companies.
ref_typeType of referred game element.
referenceThe referenced game element of ref_type.
Returns
True if the action succeeded.
Precondition
type must be NT_ECONOMY, NT_SUBSIDIES, or NT_GENERAL.
text != NULL.
company == COMPANY_INVALID || ResolveCompanyID(company) != COMPANY_INVALID.
The reference condition must be fulfilled.