OpenTTD Source 20260218-master-g2123fca5ea
GameInfo Class Reference

All static information from an Game like name, version, etc. More...

#include <game_info.hpp>

Inheritance diagram for GameInfo:
ScriptInfo

Public Member Functions

bool CanLoadFromVersion (int version) const
 Check if we can start this Game.
const std::string & GetAPIVersion () const
 Get the API version this Game is written for.
bool IsDeveloperOnly () const override
 Can this script be selected by developers only?
Public Member Functions inherited from ScriptInfo
const std::string & GetAuthor () const
 Get the Author of the script.
const std::string & GetName () const
 Get the Name of the script.
const std::string & GetShortName () const
 Get the 4 character long short name of the script.
const std::string & GetDescription () const
 Get the description of the script.
int GetVersion () const
 Get the version of the script.
const std::string & GetDate () const
 Get the last-modified date of the script.
const std::string & GetInstanceName () const
 Get the name of the instance of the script to create.
const std::string & GetURL () const
 Get the website for this script.
const std::string & GetMainScript () const
 Get the filename of the main.nut script.
const std::string & GetTarFile () const
 Get the filename of the tar the script is in.
bool CheckMethod (std::string_view name) const
 Check if a given method exists.
virtual class ScriptScannerGetScanner ()
 Get the scanner which has found this ScriptInfo.
bool GetSettings ()
 Get the settings of the Script.
const ScriptConfigItemListGetConfigList () const
 Get the config list for this Script.
const ScriptConfigItemGetConfigItem (std::string_view name) const
 Get the description of a certain Script config option.
SQInteger AddSetting (HSQUIRRELVM vm)
 Set a setting.
SQInteger AddLabels (HSQUIRRELVM vm)
 Add labels for a setting.
int GetSettingDefaultValue (const std::string &name) const
 Get the default value for a setting.

Static Public Member Functions

static void RegisterAPI (Squirrel &engine)
 Register the functions of this class.
static SQInteger Constructor (HSQUIRRELVM vm)
 Create an Game, using this GameInfo as start-template.
Static Public Member Functions inherited from ScriptInfo
static SQInteger Constructor (HSQUIRRELVM vm, ScriptInfo &info)
 Process the creation of a FileInfo object.

Static Public Attributes

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" }
 All valid GameScript API versions, in order.

Private Attributes

int min_loadable_version
 The Game can load savegame data if the version is equal or greater than this.
bool is_developer_only
 Is the script selectable by non-developers?
std::string api_version
 API version used by this Game.

Additional Inherited Members

Protected Attributes inherited from ScriptInfo
class Squirrelengine = nullptr
 Engine used to register for Squirrel.
HSQOBJECT SQ_instance {}
 The Squirrel instance created for this info.
ScriptConfigItemList config_list {}
 List of settings from this Script.

Detailed Description

All static information from an Game like name, version, etc.

Definition at line 16 of file game_info.hpp.

Constructor & Destructor Documentation

◆ GameInfo()

GameInfo::GameInfo ( )

Definition at line 86 of file game_info.cpp.

Member Function Documentation

◆ CanLoadFromVersion()

bool GameInfo::CanLoadFromVersion ( int version) const

Check if we can start this Game.

Parameters
versionThe version to check.
Returns
true if this script can load the data from that version.

Definition at line 92 of file game_info.cpp.

References ScriptInfo::GetVersion(), min_loadable_version, and ScriptInfo::version.

Referenced by GameScannerInfo::FindInfo().

◆ Constructor()

SQInteger GameInfo::Constructor ( HSQUIRRELVM vm)
static

Create an Game, using this GameInfo as start-template.

Parameters
vmThe virtual machine to push the instance to.
Returns
The number of stack places occupied.

Definition at line 49 of file game_info.cpp.

References api_version, CheckAPIVersion(), ScriptInfo::CheckMethod(), ScriptInfo::Constructor(), ScriptInfo::engine, ScriptInfo::GetName(), ScriptInfo::GetScanner(), ScriptInfo::GetVersion(), is_developer_only, MAX_GET_OPS, Squirrel::MethodExists(), min_loadable_version, ScriptScanner::RegisterScript(), and ScriptInfo::SQ_instance.

Referenced by RegisterAPI().

◆ GetAPIVersion()

const std::string & GameInfo::GetAPIVersion ( ) const
inline

Get the API version this Game is written for.

Returns
The API version.

Definition at line 47 of file game_info.hpp.

References api_version.

Referenced by GameInstance::Initialize().

◆ IsDeveloperOnly()

bool GameInfo::IsDeveloperOnly ( ) const
inlineoverridevirtual

Can this script be selected by developers only?

Reimplemented from ScriptInfo.

Definition at line 49 of file game_info.hpp.

References is_developer_only.

◆ RegisterAPI()

void GameInfo::RegisterAPI ( Squirrel & engine)
static

Register the functions of this class.

Parameters
engineThe engine to register to.

Definition at line 31 of file game_info.cpp.

References ScriptInfo::AddLabels(), ScriptInfo::AddSetting(), Boolean, Constructor(), DefSQClass< CL, ST >::DefSQAdvancedMethod(), Developer, ScriptInfo::engine, and InGame.

Referenced by GameScannerInfo::RegisterAPI().

Field Documentation

◆ api_version

std::string GameInfo::api_version
private

API version used by this Game.

Definition at line 54 of file game_info.hpp.

Referenced by Constructor(), and GetAPIVersion().

◆ ApiVersions

std::string_view GameInfo::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" }
staticconstexpr

All valid GameScript API versions, in order.

Definition at line 19 of file game_info.hpp.

Referenced by CheckAPIVersion(), and GameInstance::RegisterAPI().

◆ is_developer_only

bool GameInfo::is_developer_only
private

Is the script selectable by non-developers?

Definition at line 53 of file game_info.hpp.

Referenced by Constructor(), and IsDeveloperOnly().

◆ min_loadable_version

int GameInfo::min_loadable_version
private

The Game can load savegame data if the version is equal or greater than this.

Definition at line 52 of file game_info.hpp.

Referenced by CanLoadFromVersion(), and Constructor().


The documentation for this class was generated from the following files: