OpenTTD: src/script/script_info.hpp Source File

OpenTTD

- Main Page
- Related Pages
- Modules
- Namespaces
- Data Structures
- Files

- File List
- Globals

script_info.hpp
Go to the documentation of this file.
1 /* $Id: script_info.hpp 26057 2013-11-23 13:12:19Z rubidium $ */
2
3 /*
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/>.
8 */
9
12 #ifndef SCRIPT_INFO_HPP
13 #define SCRIPT_INFO_HPP
14
15 #include <squirrel.h>
16 #include "../misc/countedptr.hpp"
17
18 #include "script_config.hpp"
19
21 static const int MAX_SL_OPS = 100000;
23 static const int MAX_CONSTRUCTOR_OPS = 100000;
25 static const int MAX_CREATEINSTANCE_OPS = 100000;
27 static const int MAX_GET_OPS = 1000;
29 static const int MAX_GET_SETTING_OPS = 100000;
30
32 class ScriptInfo : public SimpleCountedObject {
33 public:
34 ScriptInfo() :
35 engine(NULL),
36 SQ_instance(NULL),
37 main_script(NULL),
38 tar_file(NULL),
39 author(NULL),
40 name(NULL),
41 short_name(NULL),
42 description(NULL),
43 date(NULL),
44 instance_name(NULL),
45 version(0),
46 url(NULL),
47 scanner(NULL)
48 {}
49 ~ScriptInfo();
50
54 const char *GetAuthor() const { return this->author; }
55
59 const char *GetName() const { return this->name; }
60
64 const char *GetShortName() const { return this->short_name; }
65
69 const char *GetDescription() const { return this->description; }
70
74 int GetVersion() const { return this->version; }
75
79 const char *GetDate() const { return this->date; }
80
84 const char *GetInstanceName() const { return this->instance_name; }
85
89 const char *GetURL() const { return this->url; }
90
94 const char *GetMainScript() const { return this->main_script; }
95
99 const char *GetTarFile() const { return this->tar_file; }
100
104 bool CheckMethod(const char *name) const;
105
109 static SQInteger Constructor(HSQUIRRELVM vm, ScriptInfo *info);
110
114 virtual class ScriptScanner *GetScanner() { return this->scanner; }
115
119 bool GetSettings();
120
124 const ScriptConfigItemList *GetConfigList() const;
125
129 const ScriptConfigItem *GetConfigItem(const char *name) const;
130
134 SQInteger AddSetting(HSQUIRRELVM vm);
135
139 SQInteger AddLabels(HSQUIRRELVM vm);
140
144 int GetSettingDefaultValue(const char *name) const;
145
149 virtual bool IsDeveloperOnly() const { return false; }
150
151 protected:
152 class Squirrel *engine;
153 HSQOBJECT *SQ_instance;
154 ScriptConfigItemList config_list;
155
156 private:
157 char *main_script;
158 char *tar_file;
159 const char *author;
160 const char *name;
161 const char *short_name;
162 const char *description;
163 const char *date;
164 const char *instance_name;
165 int version;
166 const char *url;
167
168 class ScriptScanner *scanner;
169 };
170
171 #endif /* SCRIPT_INFO_HPP */