4 * This file is part of OpenTTD.
5 * OpenTTD is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, version 2.
6 * OpenTTD is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
7 * See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with OpenTTD. If not, see <http://www.gnu.org/licenses/>.
10 /** @file script_info.hpp ScriptInfo keeps track of all information of a script, like Author, Description, ... */
12 #ifndef SCRIPT_INFO_HPP
13 #define SCRIPT_INFO_HPP
16 #include "../misc/countedptr.hpp"
18 #include "script_config.hpp"
20 /** The maximum number of operations for saving or loading the data of a script. */
21 static const int MAX_SL_OPS
= 100000;
22 /** The maximum number of operations for initial start of a script. */
23 static const int MAX_CONSTRUCTOR_OPS
= 100000;
24 /** Number of operations to create an instance of a script. */
25 static const int MAX_CREATEINSTANCE_OPS
= 100000;
26 /** Number of operations to get the author and similar information. */
27 static const int MAX_GET_OPS
= 1000;
28 /** Maximum number of operations allowed for getting a particular setting. */
29 static const int MAX_GET_SETTING_OPS
= 100000;
31 /** All static information from an Script like name, version, etc. */
32 class ScriptInfo
: public SimpleCountedObject
{
52 * Get the Author of the script.
54 const char *GetAuthor() const { return this->author
; }
57 * Get the Name of the script.
59 const char *GetName() const { return this->name
; }
62 * Get the 4 character long short name of the script.
64 const char *GetShortName() const { return this->short_name
; }
67 * Get the description of the script.
69 const char *GetDescription() const { return this->description
; }
72 * Get the version of the script.
74 int GetVersion() const { return this->version
; }
77 * Get the last-modified date of the script.
79 const char *GetDate() const { return this->date
; }
82 * Get the name of the instance of the script to create.
84 const char *GetInstanceName() const { return this->instance_name
; }
87 * Get the website for this script.
89 const char *GetURL() const { return this->url
; }
92 * Get the filename of the main.nut script.
94 const char *GetMainScript() const { return this->main_script
; }
97 * Get the filename of the tar the script is in.
99 const char *GetTarFile() const { return this->tar_file
; }
102 * Check if a given method exists.
104 bool CheckMethod(const char *name
) const;
107 * Process the creation of a FileInfo object.
109 static SQInteger
Constructor(HSQUIRRELVM vm
, ScriptInfo
*info
);
112 * Get the scanner which has found this ScriptInfo.
114 virtual class ScriptScanner
*GetScanner() { return this->scanner
; }
117 * Get the settings of the Script.
122 * Get the config list for this Script.
124 const ScriptConfigItemList
*GetConfigList() const;
127 * Get the description of a certain Script config option.
129 const ScriptConfigItem
*GetConfigItem(const char *name
) const;
134 SQInteger
AddSetting(HSQUIRRELVM vm
);
137 * Add labels for a setting.
139 SQInteger
AddLabels(HSQUIRRELVM vm
);
142 * Get the default value for a setting.
144 int GetSettingDefaultValue(const char *name
) const;
147 * Can this script be selected by developers only?
149 virtual bool IsDeveloperOnly() const { return false; }
152 class Squirrel
*engine
; ///< Engine used to register for Squirrel.
153 HSQOBJECT
*SQ_instance
; ///< The Squirrel instance created for this info.
154 ScriptConfigItemList config_list
; ///< List of settings from this Script.
157 char *main_script
; ///< The full path of the script.
158 char *tar_file
; ///< If, which tar file the script was in.
159 const char *author
; ///< Author of the script.
160 const char *name
; ///< Full name of the script.
161 const char *short_name
; ///< Short name (4 chars) which uniquely identifies the script.
162 const char *description
; ///< Small description of the script.
163 const char *date
; ///< The date the script was written at.
164 const char *instance_name
; ///< Name of the main class in the script.
165 int version
; ///< Version of the script.
166 const char *url
; ///< URL of the script.
168 class ScriptScanner
*scanner
; ///< ScriptScanner object that was used to scan this script info.
171 #endif /* SCRIPT_INFO_HPP */