OpenTTD Source 20241224-master-gf74b0cf984
|
All static information from an Script like name, version, etc. More...
#include <script_info.hpp>
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 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 (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 Squirrel * | engine |
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 |
Version of the script. | |
std::string | url |
URL of the script. | |
class ScriptScanner * | scanner |
ScriptScanner object that was used to scan this script info. | |
All static information from an Script like name, version, etc.
Definition at line 30 of file script_info.hpp.
|
inline |
Definition at line 32 of file script_info.hpp.
SQInteger ScriptInfo::AddLabels | ( | HSQUIRRELVM | vm | ) |
Add labels for a setting.
Definition at line 190 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().
SQInteger ScriptInfo::AddSetting | ( | HSQUIRRELVM | vm | ) |
Set a setting.
Definition at line 85 of file script_info.cpp.
References config_list, ScriptConfigItem::default_value, ScriptConfigItem::description, engine, ScriptConfigItem::flags, ScriptConfigItem::max_value, ScriptConfigItem::min_value, ScriptConfigItem::name, SCRIPTCONFIG_BOOLEAN, ScriptConfigItem::step_size, StrMakeValid(), and Squirrel::ThrowError().
Referenced by AIInfo::RegisterAPI(), and GameInfo::RegisterAPI().
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().
|
static |
Process the creation of a FileInfo object.
Definition at line 30 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().
|
inline |
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().
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().
|
inline |
Get the last-modified date of the script.
Definition at line 66 of file script_info.hpp.
References date.
|
inline |
Get the description of the script.
Definition at line 56 of file script_info.hpp.
References description.
Referenced by ScriptScanner::GetConsoleList().
|
inline |
Get the name of the instance of the script to create.
Definition at line 71 of file script_info.hpp.
References instance_name.
Referenced by AIScannerLibrary::GetScriptName(), GameScannerLibrary::GetScriptName(), AIInstance::Initialize(), and GameInstance::Initialize().
|
inline |
Get the filename of the main.nut script.
Definition at line 81 of file script_info.hpp.
References main_script.
Referenced by ScriptConfig::GetTextfile(), AIInstance::Initialize(), GameInstance::Initialize(), IsSameScript(), LoadTranslations(), and ScriptScanner::RegisterScript().
|
inline |
Get the Name of the script.
Definition at line 46 of file script_info.hpp.
References name.
Referenced by AIInfo::Constructor(), GameInfo::Constructor(), AIScannerInfo::FindInfo(), GameScannerInfo::FindInfo(), ScriptScanner::GetConsoleList(), AIScannerInfo::GetScriptName(), GameScannerInfo::GetScriptName(), ScriptScanner::RegisterScript(), ScriptDebugWindow::SetStringParameters(), and AI::StartNew().
|
inlinevirtual |
Get the scanner which has found this ScriptInfo.
Definition at line 101 of file script_info.hpp.
References scanner.
Referenced by AIInfo::Constructor(), AILibrary::Constructor(), GameInfo::Constructor(), GameLibrary::Constructor(), and AIInfo::DummyConstructor().
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().
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().
|
inline |
Get the 4 character long short name of the script.
Definition at line 51 of file script_info.hpp.
References short_name.
Referenced by IsSameScript(), and ScriptScanner::RegisterScript().
|
inline |
Get the filename of the tar the script is in.
Definition at line 86 of file script_info.hpp.
References tar_file.
Referenced by IsSameScript(), and LoadTranslations().
|
inline |
Get the website for this script.
Definition at line 76 of file script_info.hpp.
References url.
Referenced by AIInstance::Died(), GameInstance::Died(), and GSConfigWindow::OnInvalidateData().
|
inline |
Get the version of the script.
Definition at line 61 of file script_info.hpp.
References version.
Referenced by AIInfo::CanLoadFromVersion(), GameInfo::CanLoadFromVersion(), ScriptConfig::Change(), AIInfo::Constructor(), GameInfo::Constructor(), AIScannerInfo::FindInfo(), GameScannerInfo::FindInfo(), ScriptScanner::GetConsoleList(), ScriptScanner::RegisterScript(), and ScriptDebugWindow::SetStringParameters().
|
inlinevirtual |
Can this script be selected by developers only?
Reimplemented in GameInfo.
Definition at line 136 of file script_info.hpp.
Referenced by ScriptScanner::RegisterScript().
|
private |
Author of the script.
Definition at line 146 of file script_info.hpp.
Referenced by Constructor(), and GetAuthor().
|
protected |
List of settings from this Script.
Definition at line 141 of file script_info.hpp.
Referenced by AddLabels(), AddSetting(), GetConfigItem(), GetConfigList(), and GetSettingDefaultValue().
|
private |
The date the script was written at.
Definition at line 150 of file script_info.hpp.
Referenced by Constructor(), and GetDate().
|
private |
Small description of the script.
Definition at line 149 of file script_info.hpp.
Referenced by Constructor(), and GetDescription().
|
protected |
Engine used to register for Squirrel.
Definition at line 139 of file script_info.hpp.
Referenced by AddLabels(), AddSetting(), CheckMethod(), AIInfo::Constructor(), AILibrary::Constructor(), GameInfo::Constructor(), GameLibrary::Constructor(), Constructor(), GetSettings(), AIInfo::RegisterAPI(), AILibrary::RegisterAPI(), GameInfo::RegisterAPI(), and GameLibrary::RegisterAPI().
|
private |
Name of the main class in the script.
Definition at line 151 of file script_info.hpp.
Referenced by Constructor(), and GetInstanceName().
|
private |
The full path of the script.
Definition at line 144 of file script_info.hpp.
Referenced by Constructor(), and GetMainScript().
|
private |
Full name of the script.
Definition at line 147 of file script_info.hpp.
Referenced by CheckMethod(), Constructor(), GetConfigItem(), GetName(), and GetSettingDefaultValue().
|
private |
ScriptScanner object that was used to scan this script info.
Definition at line 155 of file script_info.hpp.
Referenced by Constructor(), and GetScanner().
|
private |
Short name (4 chars) which uniquely identifies the script.
Definition at line 148 of file script_info.hpp.
Referenced by Constructor(), and GetShortName().
|
protected |
The Squirrel instance created for this info.
Definition at line 140 of file script_info.hpp.
Referenced by AIInfo::Constructor(), AILibrary::Constructor(), GameInfo::Constructor(), GameLibrary::Constructor(), Constructor(), and GetSettings().
|
private |
If, which tar file the script was in.
Definition at line 145 of file script_info.hpp.
Referenced by Constructor(), and GetTarFile().
|
private |
URL of the script.
Definition at line 153 of file script_info.hpp.
Referenced by Constructor(), and GetURL().
|
private |
Version of the script.
Definition at line 152 of file script_info.hpp.
Referenced by AIInfo::CanLoadFromVersion(), GameInfo::CanLoadFromVersion(), Constructor(), and GetVersion().