OpenTTD GameScript API 20260206-master-g4d4e37dbf1
GSLeagueTable Class Reference

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

#include <script_league.hpp>

Inheritance diagram for GSLeagueTable:

Public Types

enum  LinkType : int {
  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.
static bool IsValidLeagueTableElement (LeagueTableElementID element_id)
 Check whether this is a valid league table element ID.
static LeagueTableID New (Text *title, Text *header, Text *footer)
 Create a new league table.
static LeagueTableElementID NewElement (LeagueTableID table, int rating, GSCompany::CompanyID company, Text *text, Text *score, LinkType link_type, int link_target)
 Create a new league table element.
static bool UpdateElementData (LeagueTableElementID element, GSCompany::CompanyID company, Text *text, LinkType link_type, int link_target)
 Update the attributes of a league table element.
static bool UpdateElementScore (LeagueTableElementID element, int rating, Text *score)
 Create a new league table element.
static bool RemoveElement (LeagueTableElementID element)
 Remove a league table element.

Static Public Attributes

static constexpr LeagueTableID LEAGUE_TABLE_INVALID = ::LeagueTableID::Invalid()
 An invalid league table id.
static constexpr LeagueTableElementID LEAGUE_TABLE_ELEMENT_INVALID = ::LeagueTableElementID::Invalid()
 An invalid league table element id.

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

◆ 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()

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()

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()

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()

LeagueTableElementID GSLeagueTable::NewElement ( LeagueTableID table,
int rating,
GSCompany::CompanyID company,
Text * text,
Text * score,
LinkType link_type,
int 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 colour blob for or COMPANY_INVALID.
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()

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()

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

Update the attributes of a league table element.

Parameters
elementId of the element to update
companyCompany to show the colour blob for or COMPANY_INVALID.
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()

bool GSLeagueTable::UpdateElementScore ( LeagueTableElementID element,
int 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.