OpenTTD Source: ScriptInfo Class Reference

OpenTTD Source 15.0-RC2

Public Member Functions | Static Public Member Functions | Protected Attributes | Private Attributes
ScriptInfo Class Reference

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

`#include <script_info.hpp>`

Inheritance diagram for ScriptInfo:

## 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 ScriptScanner * | GetScanner ()
| Get the scanner which has found this ScriptInfo.
bool | GetSettings ()
| Get the settings of the Script.
const ScriptConfigItemList * | GetConfigList () const
| Get the config list for this Script.
const ScriptConfigItem * | GetConfigItem (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.
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 Squirrel * | engine = 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 ScriptScanner * | scanner = 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.

Definition at line 200 of file script_info.cpp.

References ScriptConfigItem::complete_labels, config_list, engine, ScriptConfigItem::labels, ScriptConfigItem::max_value, ScriptConfigItem::min_value, StrMakeValid(), and Squirrel::ThrowError().

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

## ◆ AddSetting()

SQInteger ScriptInfo::AddSetting | ( | HSQUIRRELVM | vm | ) |

Set a setting.

Definition at line 98 of file script_info.cpp.

References Boolean, config_list, ScriptConfigItem::default_value, ScriptConfigItem::description, engine, ScriptConfigItem::flags, ScriptConfigItem::max_value, ScriptConfigItem::min_value, ScriptConfigItem::name, BaseBitSet< Timpl, Tvalue_type, Tstorage, Tmask >::Set(), ScriptConfigItem::step_size, StrMakeValid(), BaseBitSet< Timpl, Tvalue_type, Tstorage, Tmask >::Test(), and Squirrel::ThrowError().

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

## ◆ CheckMethod()

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

Check if a given method exists.

Definition at line 22 of file script_info.cpp.

References engine, Squirrel::MethodExists(), name, and Squirrel::ThrowError().

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

## ◆ Constructor()

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

Process the creation of a FileInfo object.

Definition at line 31 of file script_info.cpp.

References author, CheckMethod(), date, description, engine, ScriptScanner::GetEngine(), Squirrel::GetGlobalPointer(), Squirrel::GetInstance(), ScriptScanner::GetMainScript(), GetSettings(), ScriptScanner::GetTarFile(), instance_name, main_script, MAX_CREATEINSTANCE_OPS, MAX_GET_OPS, Squirrel::MethodExists(), name, scanner, short_name, SQ_instance, tar_file, url, and version.

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

## ◆ GetAuthor()

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

Get the Author of the script.

Definition at line 35 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.

Definition at line 258 of file script_info.cpp.

References config_list, and name.

Referenced by ScriptConfig::ResetEditableSettings(), and ScriptConfig::SetSetting().

## ◆ GetConfigList()

const ScriptConfigItemList * ScriptInfo::GetConfigList | ( |  | ) | const

Get the config list for this Script.

Definition at line 253 of file script_info.cpp.

References config_list.

Referenced by ScriptConfig::GetConfigList().

## ◆ GetDate()

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

Get the last-modified date of the script.

Definition at line 60 of file script_info.hpp.

References date.

## ◆ GetDescription()

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

Get the description of the script.

Definition at line 50 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.

Definition at line 65 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.

Definition at line 75 of file script_info.hpp.

References main_script.

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

## ◆ GetName()

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

Get the Name of the script.

Definition at line 40 of file script_info.hpp.

References name.

Referenced by AIInfo::Constructor(), GameInfo::Constructor(), AIScannerInfo::FindInfo(), GameScannerInfo::FindInfo(), ScriptScanner::GetConsoleList(), AIScannerInfo::GetScriptName(), GameScannerInfo::GetScriptName(), ScriptTextfileWindow::GetWidgetString(), ScriptDebugWindow::GetWidgetString(), and AI::StartNew().

## ◆ GetScanner()

virtual class ScriptScanner * ScriptInfo::GetScanner | ( |  | ) |
| inlinevirtual

Get the scanner which has found this ScriptInfo.

Definition at line 95 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.

Definition at line 266 of file script_info.cpp.

References config_list, ScriptConfigItem::default_value, and name.

Referenced by ScriptConfig::GetSetting().

## ◆ GetSettings()

bool ScriptInfo::GetSettings | ( |  | ) |

Get the settings of the Script.

Definition at line 82 of file script_info.cpp.

References Squirrel::CallMethod(), 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.

Definition at line 45 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.

Definition at line 80 of file script_info.hpp.

References tar_file.

Referenced by IsSameScript(), and LoadTranslations().

## ◆ GetURL()

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

Get the website for this script.

Definition at line 70 of file script_info.hpp.

References url.

Referenced by AIInstance::Died(), GameInstance::Died(), ScriptListWindow::DrawWidget(), AIConfigWindow::OnClick(), GSConfigWindow::OnClick(), AIConfigWindow::OnInvalidateData(), and GSConfigWindow::OnInvalidateData().

## ◆ GetVersion()

int ScriptInfo::GetVersion | ( |  | ) | const
| inline

Get the version of the script.

Definition at line 55 of file script_info.hpp.

References version.

Referenced by AIInfo::CanLoadFromVersion(), GameInfo::CanLoadFromVersion(), ScriptConfig::Change(), AIInfo::Constructor(), GameInfo::Constructor(), ScriptListWindow::DrawWidget(), AIScannerInfo::FindInfo(), GameScannerInfo::FindInfo(), ScriptScanner::GetConsoleList(), ScriptDebugWindow::GetWidgetString(), and ScriptScanner::RegisterScript().

## ◆ IsDeveloperOnly()

virtual bool ScriptInfo::IsDeveloperOnly | ( |  | ) | const
| inlinevirtual

Can this script be selected by developers only?

Reimplemented in GameInfo.

Definition at line 130 of file script_info.hpp.

Referenced by ScriptScanner::RegisterScript().

## Field Documentation

## ◆ author

std::string ScriptInfo::author {}
| private

Author of the script.

Definition at line 140 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 135 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 144 of file script_info.hpp.

Referenced by Constructor(), and GetDate().

## ◆ description

std::string ScriptInfo::description {}
| private

Small description of the script.

Definition at line 143 of file script_info.hpp.

Referenced by Constructor(), and GetDescription().

## ◆ engine

class Squirrel* ScriptInfo::engine = nullptr
| protected

Engine used to register for Squirrel.

Definition at line 133 of file script_info.hpp.

Referenced by AddLabels(), AddSetting(), CheckMethod(), AIInfo::Constructor(), GameInfo::Constructor(), Constructor(), GetSettings(), AIInfo::RegisterAPI(), AILibrary::RegisterAPI(), GameInfo::RegisterAPI(), and GameLibrary::RegisterAPI().

## ◆ instance_name

std::string ScriptInfo::instance_name {}
| private

Name of the main class in the script.

Definition at line 145 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 138 of file script_info.hpp.

Referenced by Constructor(), and GetMainScript().

## ◆ name

std::string ScriptInfo::name {}
| private

Full name of the script.

Definition at line 141 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 149 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 142 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 134 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 139 of file script_info.hpp.

Referenced by Constructor(), and GetTarFile().

## ◆ url

std::string ScriptInfo::url {}
| private

URL of the script.

Definition at line 147 of file script_info.hpp.

Referenced by Constructor(), and GetURL().

## ◆ version

int ScriptInfo::version = 0
| private

Version of the script.

Definition at line 146 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:

- src/script/script_info.hpp
- src/script/script_info.cpp