OpenTTD Source 20261112-master-gbcbec5e63f
league_base.h
Go to the documentation of this file.
1/*
2 * This file is part of OpenTTD.
3 * OpenTTD is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, version 2.
4 * OpenTTD is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
5 * See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with OpenTTD. If not, see <https://www.gnu.org/licenses/old-licenses/gpl-2.0>.
6 */
7
9
10#ifndef LEAGUE_BASE_H
11#define LEAGUE_BASE_H
12
13#include "company_type.h"
14#include "league_type.h"
15#include "core/pool_type.hpp"
16#include "strings_type.h"
17
18bool IsValidLink(Link link);
19
20using LeagueTableElementPool = Pool<LeagueTableElement, LeagueTableElementID, 64>;
21extern LeagueTableElementPool _league_table_element_pool;
22
23using LeagueTablePool = Pool<LeagueTable, LeagueTableID, 4>;
24extern LeagueTablePool _league_table_pool;
25
26
31struct LeagueTableElement : LeagueTableElementPool::PoolItem<&_league_table_element_pool> {
32 LeagueTableID table = LeagueTableID::Invalid();
33 int64_t rating = 0;
34 CompanyID company = CompanyID::Invalid();
38
39 LeagueTableElement(LeagueTableElementID index) : LeagueTableElementPool::PoolItem<&_league_table_element_pool>(index) { }
40 LeagueTableElement(LeagueTableElementID index, LeagueTableID table, int64_t rating, CompanyID company, const EncodedString &text, const EncodedString &score, const Link &link) :
41 LeagueTableElementPool::PoolItem<&_league_table_element_pool>(index), table(table), rating(rating), company(company), text(text), score(score), link(link) {}
42};
43
44
46struct LeagueTable : LeagueTablePool::PoolItem<&_league_table_pool> {
50
51 LeagueTable(LeagueTableID index, const EncodedString &title = {}, const EncodedString &header = {}, const EncodedString &footer = {}) :
52 LeagueTablePool::PoolItem<&_league_table_pool>(index), title(title), header(header), footer(footer) { }
53};
54
55#endif /* LEAGUE_BASE_H */
Container for an encoded string, created by GetEncodedString.
Types related to companies.
bool IsValidLink(Link link)
Checks whether a link is valid, i.e.
Basic types related to league tables.
PoolID< uint16_t, struct LeagueTableElementIDTag, 64000, 0xFFFF > LeagueTableElementID
ID of a league table.
Definition league_type.h:38
PoolID< uint8_t, struct LeagueTableIDTag, 255, 0xFF > LeagueTableID
ID of a league table.
Definition league_type.h:35
Definition of Pool, structure used to access PoolItems, and PoolItem, base structure for Vehicle,...
Types related to strings.
Struct about league table elements.
Definition league_base.h:31
int64_t rating
Value that determines ordering of elements in the table (higher=better).
Definition league_base.h:33
EncodedString score
String representation of the score associated with the element.
Definition league_base.h:36
Link link
What opens when element is clicked.
Definition league_base.h:37
EncodedString text
Text of the element.
Definition league_base.h:35
LeagueTableID table
Id of the table which this element belongs to.
Definition league_base.h:32
CompanyID company
Company Id to show the colour blob for or CompanyID::Invalid().
Definition league_base.h:34
Struct about custom league tables.
Definition league_base.h:46
EncodedString header
Text to show above the table.
Definition league_base.h:48
EncodedString title
Title of the table.
Definition league_base.h:47
EncodedString footer
Text to show below the table.
Definition league_base.h:49
Base class for all pools.