OpenTTD Source 20260218-master-g2123fca5ea
game_info.hpp
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 GAME_INFO_HPP
11#define GAME_INFO_HPP
12
14
16class GameInfo : public ScriptInfo {
17public:
19 static constexpr std::string_view ApiVersions[]{ "1.2", "1.3", "1.4", "1.5", "1.6", "1.7", "1.8", "1.9", "1.10", "1.11", "12", "13", "14", "15", "16" };
20
21 GameInfo();
22
27 static void RegisterAPI(Squirrel &engine);
28
34 static SQInteger Constructor(HSQUIRRELVM vm);
35
41 bool CanLoadFromVersion(int version) const;
42
47 const std::string &GetAPIVersion() const { return this->api_version; }
48
49 bool IsDeveloperOnly() const override { return this->is_developer_only; }
50
51private:
54 std::string api_version;
55};
56
58class GameLibrary : public ScriptInfo {
59public:
60 GameLibrary() : ScriptInfo() {};
61
66 static void RegisterAPI(Squirrel &engine);
67
73 static SQInteger Constructor(HSQUIRRELVM vm);
74
79 const std::string &GetCategory() const { return this->category; }
80
81private:
82 std::string category;
83};
84
85#endif /* GAME_INFO_HPP */
All static information from an Game like name, version, etc.
Definition game_info.hpp:16
bool IsDeveloperOnly() const override
Can this script be selected by developers only?
Definition game_info.hpp:49
std::string api_version
API version used by this Game.
Definition game_info.hpp:54
static SQInteger Constructor(HSQUIRRELVM vm)
Create an Game, using this GameInfo as start-template.
Definition game_info.cpp:49
bool CanLoadFromVersion(int version) const
Check if we can start this Game.
Definition game_info.cpp:92
static void RegisterAPI(Squirrel &engine)
Register the functions of this class.
Definition game_info.cpp:31
bool is_developer_only
Is the script selectable by non-developers?
Definition game_info.hpp:53
static constexpr std::string_view ApiVersions[]
All valid GameScript API versions, in order.
Definition game_info.hpp:19
const std::string & GetAPIVersion() const
Get the API version this Game is written for.
Definition game_info.hpp:47
int min_loadable_version
The Game can load savegame data if the version is equal or greater than this.
Definition game_info.hpp:52
static void RegisterAPI(Squirrel &engine)
Register the functions of this class.
Definition game_info.cpp:99
const std::string & GetCategory() const
Get the category this library is in.
Definition game_info.hpp:79
std::string category
The category this library is in.
Definition game_info.hpp:82
static SQInteger Constructor(HSQUIRRELVM vm)
Create an GSLibrary, using this GSInfo as start-template.
All static information from an Script like name, version, etc.
int version
Version of the script.
class Squirrel * engine
Engine used to register for Squirrel.
ScriptInfo keeps track of all information of a script, like Author, Description, ....