OpenTTD Source 20250312-master-gcdcc6b491d
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 (const char *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 (const 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 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)

◆ AddSetting()

◆ CheckMethod()

bool ScriptInfo::CheckMethod ( const char *  name) const

Check if a given method exists.

Definition at line 21 of file script_info.cpp.

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

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

◆ Constructor()

◆ 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.

◆ GetConfigItem()

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

Get the description of a certain Script config option.

Definition at line 247 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 242 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 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(), LoadTranslations(), and ScriptScanner::RegisterScript().

◆ GetName()

◆ 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(), AILibrary::Constructor(), GameInfo::Constructor(), GameLibrary::Constructor(), and AIInfo::DummyConstructor().

◆ GetSettingDefaultValue()

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

Get the default value for a setting.

Definition at line 255 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 80 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(), and ScriptScanner::RegisterScript().

◆ 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(), and GSConfigWindow::OnInvalidateData().

◆ GetVersion()

◆ 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

◆ 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 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(), AILibrary::Constructor(), GameInfo::Constructor(), GameLibrary::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: