OpenTTD GameScript API  20240429-master-gb852a3f408
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 : uint8_t {
  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, SQInteger 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, SQInteger 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

enum GSLeagueTable::LinkType : uint8_t

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).
headerThe optional header text for the table (null is allowed).
footerThe optional footer text for the table (null is allowed).
Returns
The new LeagueTableID, or LEAGUE_TABLE_INVALID if it failed.
Precondition
GSCompanyMode::IsDeity.
title != null && len(title) != 0.

◆ NewElement()

static LeagueTableElementID GSLeagueTable::NewElement ( LeagueTableID  table,
SQInteger  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
GSCompanyMode::IsDeity.
IsValidLeagueTable(table).
text != null && len(text) != 0.
score != null && 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
GSCompanyMode::IsDeity.
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
GSCompanyMode::IsDeity.
IsValidLeagueTableElement(element).
text != null && len(text) != 0.
IsValidLink(Link(link_type, link_target)).

◆ UpdateElementScore()

static bool GSLeagueTable::UpdateElementScore ( LeagueTableElementID  element,
SQInteger  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
GSCompanyMode::IsDeity.
IsValidLeagueTableElement(element).
score != null && len(score) != 0.