OpenTTD Source 20250312-master-gcdcc6b491d
|
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 = 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. | |
All static information from an Script like name, version, etc.
Definition at line 30 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 Boolean, config_list, ScriptConfigItem::default_value, ScriptConfigItem::description, engine, ScriptConfigItem::flags, ScriptConfigItem::max_value, ScriptConfigItem::min_value, ScriptConfigItem::name, ScriptConfigItem::step_size, StrMakeValid(), BaseBitSet< Timpl, Tvalue_type, Tstorage, Tmask >::Test(), 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 60 of file script_info.hpp.
References date.
|
inline |
Get the description of the script.
Definition at line 50 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 65 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 75 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 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(), ScriptScanner::RegisterScript(), and AI::StartNew().
|
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().
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 45 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 80 of file script_info.hpp.
References tar_file.
Referenced by IsSameScript(), and LoadTranslations().
|
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().
|
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(), AIScannerInfo::FindInfo(), GameScannerInfo::FindInfo(), ScriptScanner::GetConsoleList(), ScriptDebugWindow::GetWidgetString(), and ScriptScanner::RegisterScript().
|
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().
|
private |
Author of the script.
Definition at line 140 of file script_info.hpp.
Referenced by Constructor(), and GetAuthor().
|
protected |
List of settings from this Script.
Definition at line 135 of file script_info.hpp.
Referenced by AddLabels(), AddSetting(), GetConfigItem(), GetConfigList(), and GetSettingDefaultValue().
|
private |
The date the script was written at.
Definition at line 144 of file script_info.hpp.
Referenced by Constructor(), and GetDate().
|
private |
Small description of the script.
Definition at line 143 of file script_info.hpp.
Referenced by Constructor(), and GetDescription().
|
protected |
Engine used to register for Squirrel.
Definition at line 133 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 145 of file script_info.hpp.
Referenced by Constructor(), and GetInstanceName().
|
private |
The full path of the script.
Definition at line 138 of file script_info.hpp.
Referenced by Constructor(), and GetMainScript().
|
private |
Full name of the script.
Definition at line 141 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 149 of file script_info.hpp.
Referenced by Constructor(), and GetScanner().
|
private |
Short name (4 chars) which uniquely identifies the script.
Definition at line 142 of file script_info.hpp.
Referenced by Constructor(), and GetShortName().
|
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().
|
private |
If, which tar file the script was in.
Definition at line 139 of file script_info.hpp.
Referenced by Constructor(), and GetTarFile().
|
private |
URL of the script.
Definition at line 147 of file script_info.hpp.
Referenced by Constructor(), and GetURL().
|
private |
Version of the script.
Definition at line 146 of file script_info.hpp.
Referenced by AIInfo::CanLoadFromVersion(), GameInfo::CanLoadFromVersion(), Constructor(), and GetVersion().