OpenTTD Source 20260311-master-g511d3794ce
ScriptInfo Class Reference

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

#include <script_info.hpp>

Inheritance diagram for ScriptInfo:
AIInfo AILibrary GameInfo GameLibrary

Public Member Functions

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 ()
 Does this script have a 'GetSettings' function?
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)
 Add 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.
virtual bool IsDeveloperOnly () const
 Can this script be selected by developers only?

Static Public Member Functions

static SQInteger Constructor (HSQUIRRELVM vm, ScriptInfo &info)
 Process the creation of a FileInfo object.

Protected Attributes

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.

Private Attributes

std::string main_script {}
 The full path of the script.
std::string tar_file {}
 If, which tar file the script was in.
std::string author {}
 Author of the script.
std::string name {}
 Full name of the script.
std::string short_name {}
 Short name (4 chars) which uniquely identifies the script.
std::string description {}
 Small description of the script.
std::string date {}
 The date the script was written at.
std::string instance_name {}
 Name of the main class in the script.
int version = 0
 Version of the script.
std::string url {}
 URL of the script.
class ScriptScannerscanner = nullptr
 ScriptScanner object that was used to scan this script info.

Detailed Description

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

Definition at line 30 of file script_info.hpp.

Member Function Documentation

◆ AddLabels()

SQInteger ScriptInfo::AddLabels ( HSQUIRRELVM vm)

Add labels for a setting.

Parameters
vmThe virtual machine to work on.
Returns
0 upon success, or anything other on failure.

Definition at line 201 of file script_info.cpp.

References ScriptConfigItem::complete_labels, config_list, engine, ScriptConfigItem::labels, ScriptConfigItem::min_value, ParseInteger(), and StrMakeValid().

Referenced by AIInfo::RegisterAPI(), and GameInfo::RegisterAPI().

◆ AddSetting()

◆ CheckMethod()

bool ScriptInfo::CheckMethod ( std::string_view name) const

Check if a given method exists.

Parameters
nameThe method name to look for.
Returns
true iff the method exists.

Definition at line 22 of file script_info.cpp.

References engine, and name.

Referenced by GameInfo::Constructor(), and Constructor().

◆ Constructor()

SQInteger ScriptInfo::Constructor ( HSQUIRRELVM vm,
ScriptInfo & info )
static

◆ GetAuthor()

const std::string & ScriptInfo::GetAuthor ( ) const
inline

Get the Author of the script.

Returns
The author's name.

Definition at line 36 of file script_info.hpp.

References author.

Referenced by ScriptListWindow::DrawWidget().

◆ GetConfigItem()

const ScriptConfigItem * ScriptInfo::GetConfigItem ( std::string_view name) const

Get the description of a certain Script config option.

Parameters
nameThe name of the setting.
Returns
The configuration item, or nullptr.

Definition at line 259 of file script_info.cpp.

References config_list, and name.

◆ GetConfigList()

const ScriptConfigItemList * ScriptInfo::GetConfigList ( ) const

Get the config list for this Script.

Returns
The configuration list.

Definition at line 254 of file script_info.cpp.

References config_list.

◆ GetDate()

const std::string & ScriptInfo::GetDate ( ) const
inline

Get the last-modified date of the script.

Returns
The date.

Definition at line 66 of file script_info.hpp.

References date.

◆ GetDescription()

const std::string & ScriptInfo::GetDescription ( ) const
inline

Get the description of the script.

Returns
The description.

Definition at line 54 of file script_info.hpp.

References description.

Referenced by ScriptListWindow::DrawWidget(), and ScriptScanner::GetConsoleList().

◆ GetInstanceName()

const std::string & ScriptInfo::GetInstanceName ( ) const
inline

Get the name of the instance of the script to create.

Returns
Name of the instance.

Definition at line 72 of file script_info.hpp.

References instance_name.

Referenced by AIScannerLibrary::GetScriptName(), GameScannerLibrary::GetScriptName(), AIInstance::Initialize(), and GameInstance::Initialize().

◆ GetMainScript()

const std::string & ScriptInfo::GetMainScript ( ) const
inline

Get the filename of the main.nut script.

Returns
The path to the main script.

Definition at line 84 of file script_info.hpp.

References main_script.

Referenced by AIInstance::Initialize(), GameInstance::Initialize(), IsSameScript(), and LoadTranslations().

◆ GetName()

const std::string & ScriptInfo::GetName ( ) const
inline

◆ GetScanner()

virtual class ScriptScanner * ScriptInfo::GetScanner ( )
inlinevirtual

Get the scanner which has found this ScriptInfo.

Returns
The scanner for scripts.

Definition at line 111 of file script_info.hpp.

References scanner.

Referenced by AIInfo::Constructor(), GameInfo::Constructor(), and AIInfo::DummyConstructor().

◆ GetSettingDefaultValue()

int ScriptInfo::GetSettingDefaultValue ( const std::string & name) const

Get the default value for a setting.

Parameters
nameThe name of the setting to get the default for.
Returns
The default value for the setting, or -1 when the setting does not exist.
Note
-1 can be a valid default setting.

Definition at line 267 of file script_info.cpp.

References config_list, and name.

◆ GetSettings()

bool ScriptInfo::GetSettings ( )

Does this script have a 'GetSettings' function?

Returns
true iff the script has the GetSettings function.

Definition at line 82 of file script_info.cpp.

References engine, MAX_GET_SETTING_OPS, and SQ_instance.

Referenced by Constructor().

◆ GetShortName()

const std::string & ScriptInfo::GetShortName ( ) const
inline

Get the 4 character long short name of the script.

Returns
The short name.

Definition at line 48 of file script_info.hpp.

References short_name.

Referenced by IsSameScript().

◆ GetTarFile()

const std::string & ScriptInfo::GetTarFile ( ) const
inline

Get the filename of the tar the script is in.

Returns
The tar file the script is in, or an empty string.

Definition at line 90 of file script_info.hpp.

References tar_file.

Referenced by IsSameScript(), and LoadTranslations().

◆ GetURL()

const std::string & ScriptInfo::GetURL ( ) const
inline

◆ GetVersion()

◆ IsDeveloperOnly()

virtual bool ScriptInfo::IsDeveloperOnly ( ) const
inlinevirtual

Can this script be selected by developers only?

Returns
true iff the script should only be shown to script developers.

Reimplemented in GameInfo.

Definition at line 158 of file script_info.hpp.

Referenced by ScriptScanner::RegisterScript().

Field Documentation

◆ author

std::string ScriptInfo::author {}
private

Author of the script.

Definition at line 168 of file script_info.hpp.

Referenced by Constructor(), and GetAuthor().

◆ config_list

ScriptConfigItemList ScriptInfo::config_list {}
protected

List of settings from this Script.

Definition at line 163 of file script_info.hpp.

Referenced by AddLabels(), AddSetting(), GetConfigItem(), GetConfigList(), and GetSettingDefaultValue().

◆ date

std::string ScriptInfo::date {}
private

The date the script was written at.

Definition at line 172 of file script_info.hpp.

Referenced by Constructor(), and GetDate().

◆ description

std::string ScriptInfo::description {}
private

Small description of the script.

Definition at line 171 of file script_info.hpp.

Referenced by Constructor(), and GetDescription().

◆ engine

◆ instance_name

std::string ScriptInfo::instance_name {}
private

Name of the main class in the script.

Definition at line 173 of file script_info.hpp.

Referenced by Constructor(), and GetInstanceName().

◆ main_script

std::string ScriptInfo::main_script {}
private

The full path of the script.

Definition at line 166 of file script_info.hpp.

Referenced by Constructor(), and GetMainScript().

◆ name

std::string ScriptInfo::name {}
private

Full name of the script.

Definition at line 169 of file script_info.hpp.

Referenced by CheckMethod(), Constructor(), GetConfigItem(), GetName(), and GetSettingDefaultValue().

◆ scanner

class ScriptScanner* ScriptInfo::scanner = nullptr
private

ScriptScanner object that was used to scan this script info.

Definition at line 177 of file script_info.hpp.

Referenced by AILibrary::Constructor(), GameLibrary::Constructor(), Constructor(), and GetScanner().

◆ short_name

std::string ScriptInfo::short_name {}
private

Short name (4 chars) which uniquely identifies the script.

Definition at line 170 of file script_info.hpp.

Referenced by Constructor(), and GetShortName().

◆ SQ_instance

HSQOBJECT ScriptInfo::SQ_instance {}
protected

The Squirrel instance created for this info.

Definition at line 162 of file script_info.hpp.

Referenced by AIInfo::Constructor(), GameInfo::Constructor(), Constructor(), and GetSettings().

◆ tar_file

std::string ScriptInfo::tar_file {}
private

If, which tar file the script was in.

Definition at line 167 of file script_info.hpp.

Referenced by Constructor(), and GetTarFile().

◆ url

std::string ScriptInfo::url {}
private

URL of the script.

Definition at line 175 of file script_info.hpp.

Referenced by Constructor(), and GetURL().

◆ version

int ScriptInfo::version = 0
private

Version of the script.

Definition at line 174 of file script_info.hpp.

Referenced by AIInfo::CanLoadFromVersion(), GameInfo::CanLoadFromVersion(), Constructor(), and GetVersion().


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