OpenTTD GameScript API  13.0-beta2
Public Types | Static Public Member Functions
GSLeagueTable Class Reference

Class that handles league table related functions. More...

Inheritance diagram for GSLeagueTable:

Public Types

enum  LeagueTableID { LEAGUE_TABLE_INVALID }
 The league table IDs. More...
 
enum  LeagueTableElementID { LEAGUE_TABLE_ELEMENT_INVALID }
 The league table element IDs. More...
 
enum  LinkType : byte {
  LINK_NONE,
  LINK_TILE,
  LINK_INDUSTRY,
  LINK_TOWN,
  LINK_COMPANY,
  LINK_STORY_PAGE
}
 The type of a link. More...
 

Static Public Member Functions

static bool IsValidLeagueTable (LeagueTableID table_id)
 Check whether this is a valid league table ID. More...
 
static bool IsValidLeagueTableElement (LeagueTableElementID element_id)
 Check whether this is a valid league table element ID. More...
 
static LeagueTableID New (Text *title, Text *header, Text *footer)
 Create a new league table. More...
 
static LeagueTableElementID NewElement (LeagueTableID table, int64 rating, GSCompany::CompanyID company, Text *text, Text *score, LinkType link_type, LinkTargetID link_target)
 Create a new league table element. More...
 
static bool UpdateElementData (LeagueTableElementID element, GSCompany::CompanyID company, Text *text, LinkType link_type, LinkTargetID link_target)
 Update the attributes of a league table element. More...
 
static bool UpdateElementScore (LeagueTableElementID element, int64 rating, Text *score)
 Create a new league table element. More...
 
static bool RemoveElement (LeagueTableElementID element)
 Remove a league table element. More...
 

Detailed Description

Class that handles league table related functions.

To create a league table:

  1. Create the league table
  2. Create league table elements that will be shown in the table in the order of their rating (higher=better).

Member Enumeration Documentation

◆ LeagueTableElementID

The league table element IDs.

Enumerator
LEAGUE_TABLE_ELEMENT_INVALID 

An invalid league table element id.

◆ LeagueTableID

The league table IDs.

Enumerator
LEAGUE_TABLE_INVALID 

An invalid league table id.

◆ LinkType

The type of a link.

Enumerator
LINK_NONE 

No link.

LINK_TILE 

Link a tile.

LINK_INDUSTRY 

Link an industry.

LINK_TOWN 

Link a town.

LINK_COMPANY 

Link a company.

LINK_STORY_PAGE 

Link a story page.

Member Function Documentation

◆ IsValidLeagueTable()

static bool GSLeagueTable::IsValidLeagueTable ( LeagueTableID  table_id)
static

Check whether this is a valid league table ID.

Parameters
table_idThe LeagueTableID to check.
Returns
true iff this league table is valid.

◆ IsValidLeagueTableElement()

static bool GSLeagueTable::IsValidLeagueTableElement ( LeagueTableElementID  element_id)
static

Check whether this is a valid league table element ID.

Parameters
element_idThe LeagueTableElementID to check.
Returns
true iff this league table element is valid.

◆ New()

static LeagueTableID GSLeagueTable::New ( Text *  title,
Text *  header,
Text *  footer 
)
static

Create a new league table.

Parameters
titleLeague table title (can be either a raw string, or GSText object).
Returns
The new LeagueTableID, or LEAGUE_TABLE_INVALID if it failed.
Precondition
No GSCompanyMode may be in scope.
title != nullptr && len(title) != 0.

◆ NewElement()

static LeagueTableElementID GSLeagueTable::NewElement ( LeagueTableID  table,
int64  rating,
GSCompany::CompanyID  company,
Text *  text,
Text *  score,
LinkType  link_type,
LinkTargetID  link_target 
)
static

Create a new league table element.

Parameters
tableId of the league table this element belongs to.
ratingValue that elements are ordered by.
companyCompany to show the color blob for or INVALID_COMPANY.
textText of the element (can be either a raw string, or GSText object).
scoreString representation of the score associated with the element (can be either a raw string, or GSText object).
link_typeType of the referenced object.
link_targetId of the referenced object.
Returns
The new LeagueTableElementID, or LEAGUE_TABLE_ELEMENT_INVALID if it failed.
Precondition
No GSCompanyMode may be in scope.
IsValidLeagueTable(table).
text != nullptr && len(text) != 0.
score != nullptr && len(score) != 0.
IsValidLink(Link(link_type, link_target)).

◆ RemoveElement()

static bool GSLeagueTable::RemoveElement ( LeagueTableElementID  element)
static

Remove a league table element.

Parameters
elementId of the element to update
Returns
True if the action succeeded.
Precondition
No GSCompanyMode may be in scope.
IsValidLeagueTableElement(element).

◆ UpdateElementData()

static bool GSLeagueTable::UpdateElementData ( LeagueTableElementID  element,
GSCompany::CompanyID  company,
Text *  text,
LinkType  link_type,
LinkTargetID  link_target 
)
static

Update the attributes of a league table element.

Parameters
elementId of the element to update
companyCompany to show the color blob for or INVALID_COMPANY.
textText of the element (can be either a raw string, or GSText object).
link_typeType of the referenced object.
link_targetId of the referenced object.
Returns
True if the action succeeded.
Precondition
No GSCompanyMode may be in scope.
IsValidLeagueTableElement(element).
text != nullptr && len(text) != 0.
IsValidLink(Link(link_type, link_target)).

◆ UpdateElementScore()

static bool GSLeagueTable::UpdateElementScore ( LeagueTableElementID  element,
int64  rating,
Text *  score 
)
static

Create a new league table element.

Parameters
elementId of the element to update
ratingValue that elements are ordered by.
scoreString representation of the score associated with the element (can be either a raw string, or GSText object).
Returns
True if the action succeeded.
Precondition
No GSCompanyMode may be in scope.
IsValidLeagueTableElement(element).
score != nullptr && len(score) != 0.