Files
@ r26799:826b1c52a903
Branch filter:
Location: cpp/openttd-patchpack/source/src/script/api/script_league.hpp - annotation
r26799:826b1c52a903
5.2 KiB
text/x-c++hdr
Fix: no ScriptEvent sub class should export constructors to scripts
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 | r26612:e1c0fa463732 r26612:e1c0fa463732 r26612:e1c0fa463732 r26612:e1c0fa463732 r26612:e1c0fa463732 r26612:e1c0fa463732 r26612:e1c0fa463732 r26612:e1c0fa463732 r26612:e1c0fa463732 r26612:e1c0fa463732 r26612:e1c0fa463732 r26612:e1c0fa463732 r26612:e1c0fa463732 r26612:e1c0fa463732 r26612:e1c0fa463732 r26612:e1c0fa463732 r26612:e1c0fa463732 r26612:e1c0fa463732 r26612:e1c0fa463732 r26612:e1c0fa463732 r26612:e1c0fa463732 r26612:e1c0fa463732 r26612:e1c0fa463732 r26612:e1c0fa463732 r26612:e1c0fa463732 r26612:e1c0fa463732 r26612:e1c0fa463732 r26612:e1c0fa463732 r26612:e1c0fa463732 r26612:e1c0fa463732 r26612:e1c0fa463732 r26612:e1c0fa463732 r26612:e1c0fa463732 r26612:e1c0fa463732 r26612:e1c0fa463732 r26612:e1c0fa463732 r26612:e1c0fa463732 r26612:e1c0fa463732 r26612:e1c0fa463732 r26612:e1c0fa463732 r26612:e1c0fa463732 r26612:e1c0fa463732 r26612:e1c0fa463732 r26612:e1c0fa463732 r26612:e1c0fa463732 r26612:e1c0fa463732 r26612:e1c0fa463732 r26612:e1c0fa463732 r26612:e1c0fa463732 r26612:e1c0fa463732 r26612:e1c0fa463732 r26612:e1c0fa463732 r26612:e1c0fa463732 r26612:e1c0fa463732 r26612:e1c0fa463732 r26612:e1c0fa463732 r26612:e1c0fa463732 r26612:e1c0fa463732 r26612:e1c0fa463732 r26612:e1c0fa463732 r26612:e1c0fa463732 r26612:e1c0fa463732 r26612:e1c0fa463732 r26612:e1c0fa463732 r26612:e1c0fa463732 r26612:e1c0fa463732 r26612:e1c0fa463732 r26612:e1c0fa463732 r26612:e1c0fa463732 r26612:e1c0fa463732 r26612:e1c0fa463732 r26612:e1c0fa463732 r26612:e1c0fa463732 r26612:e1c0fa463732 r26612:e1c0fa463732 r26612:e1c0fa463732 r26612:e1c0fa463732 r26612:e1c0fa463732 r26612:e1c0fa463732 r26612:e1c0fa463732 r26612:e1c0fa463732 r26612:e1c0fa463732 r26612:e1c0fa463732 r26612:e1c0fa463732 r26612:e1c0fa463732 r26612:e1c0fa463732 r26612:e1c0fa463732 r26612:e1c0fa463732 r26612:e1c0fa463732 r26612:e1c0fa463732 r26612:e1c0fa463732 r26612:e1c0fa463732 r26612:e1c0fa463732 r26612:e1c0fa463732 r26612:e1c0fa463732 r26612:e1c0fa463732 r26612:e1c0fa463732 r26612:e1c0fa463732 r26612:e1c0fa463732 r26612:e1c0fa463732 r26612:e1c0fa463732 r26612:e1c0fa463732 r26612:e1c0fa463732 r26612:e1c0fa463732 r26612:e1c0fa463732 r26612:e1c0fa463732 r26612:e1c0fa463732 r26612:e1c0fa463732 r26612:e1c0fa463732 r26612:e1c0fa463732 r26612:e1c0fa463732 r26612:e1c0fa463732 r26612:e1c0fa463732 r26612:e1c0fa463732 r26612:e1c0fa463732 r26612:e1c0fa463732 r26612:e1c0fa463732 r26612:e1c0fa463732 r26612:e1c0fa463732 r26612:e1c0fa463732 r26612:e1c0fa463732 r26612:e1c0fa463732 r26612:e1c0fa463732 r26612:e1c0fa463732 r26612:e1c0fa463732 r26612:e1c0fa463732 r26612:e1c0fa463732 r26612:e1c0fa463732 r26612:e1c0fa463732 r26612:e1c0fa463732 r26612:e1c0fa463732 r26612:e1c0fa463732 r26612:e1c0fa463732 r26612:e1c0fa463732 | /*
* This file is part of OpenTTD.
* 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.
* 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.
* 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 <http://www.gnu.org/licenses/>.
*/
/** @file script_league.hpp Everything to manipulate league tables. */
#ifndef SCRIPT_LEAGUE_HPP
#define SCRIPT_LEAGUE_HPP
#include "script_company.hpp"
#include "script_text.hpp"
#include "../../league_type.h"
/**
* 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).
*
* @api game
*/
class ScriptLeagueTable : public ScriptObject {
public:
/**
* The league table IDs.
*/
enum LeagueTableID {
LEAGUE_TABLE_INVALID = ::INVALID_LEAGUE_TABLE, ///< An invalid league table id.
};
/**
* The league table element IDs.
*/
enum LeagueTableElementID {
LEAGUE_TABLE_ELEMENT_INVALID = ::INVALID_LEAGUE_TABLE_ELEMENT, ///< An invalid league table element id.
};
/**
* The type of a link.
*/
enum LinkType : byte {
LINK_NONE = ::LT_NONE, ///< No link
LINK_TILE = ::LT_TILE, ///< Link a tile
LINK_INDUSTRY = ::LT_INDUSTRY, ///< Link an industry
LINK_TOWN = ::LT_TOWN, ///< Link a town
LINK_COMPANY = ::LT_COMPANY, ///< Link a company
LINK_STORY_PAGE = ::LT_STORY_PAGE, ///< Link a story page
};
/**
* Check whether this is a valid league table ID.
* @param table_id The LeagueTableID to check.
* @return true iff this league table is valid.
*/
static bool IsValidLeagueTable(LeagueTableID table_id);
/**
* Check whether this is a valid league table element ID.
* @param element_id The LeagueTableElementID to check.
* @return true iff this league table element is valid.
*/
static bool IsValidLeagueTableElement(LeagueTableElementID element_id);
/**
* Create a new league table.
* @param title League table title (can be either a raw string, or ScriptText object).
* @return The new LeagueTableID, or LEAGUE_TABLE_INVALID if it failed.
* @pre No ScriptCompanyMode may be in scope.
* @pre title != nullptr && len(title) != 0.
*/
static LeagueTableID New(Text *title, Text *header, Text *footer);
/**
* Create a new league table element.
* @param table Id of the league table this element belongs to.
* @param rating Value that elements are ordered by.
* @param company Company to show the color blob for or INVALID_COMPANY.
* @param text Text of the element (can be either a raw string, or ScriptText object).
* @param score String representation of the score associated with the element (can be either a raw string, or ScriptText object).
* @param link_type Type of the referenced object.
* @param link_target Id of the referenced object.
* @return The new LeagueTableElementID, or LEAGUE_TABLE_ELEMENT_INVALID if it failed.
* @pre No ScriptCompanyMode may be in scope.
* @pre IsValidLeagueTable(table).
* @pre text != nullptr && len(text) != 0.
* @pre score != nullptr && len(score) != 0.
* @pre IsValidLink(Link(link_type, link_target)).
*/
static LeagueTableElementID NewElement(LeagueTableID table, int64 rating, ScriptCompany::CompanyID company, Text *text, Text *score, LinkType link_type, LinkTargetID link_target);
/**
* Update the attributes of a league table element.
* @param element Id of the element to update
* @param company Company to show the color blob for or INVALID_COMPANY.
* @param text Text of the element (can be either a raw string, or ScriptText object).
* @param link_type Type of the referenced object.
* @param link_target Id of the referenced object.
* @return True if the action succeeded.
* @pre No ScriptCompanyMode may be in scope.
* @pre IsValidLeagueTableElement(element).
* @pre text != nullptr && len(text) != 0.
* @pre IsValidLink(Link(link_type, link_target)).
*/
static bool UpdateElementData(LeagueTableElementID element, ScriptCompany::CompanyID company, Text *text, LinkType link_type, LinkTargetID link_target);
/**
* Create a new league table element.
* @param element Id of the element to update
* @param rating Value that elements are ordered by.
* @param score String representation of the score associated with the element (can be either a raw string, or ScriptText object).
* @return True if the action succeeded.
* @pre No ScriptCompanyMode may be in scope.
* @pre IsValidLeagueTableElement(element).
* @pre score != nullptr && len(score) != 0.
*/
static bool UpdateElementScore(LeagueTableElementID element, int64 rating, Text *score);
/**
* Remove a league table element.
* @param element Id of the element to update
* @return True if the action succeeded.
* @pre No ScriptCompanyMode may be in scope.
* @pre IsValidLeagueTableElement(element).
*/
static bool RemoveElement(LeagueTableElementID element);
};
#endif /* SCRIPT_LEAGUE_HPP */
|