script_info.hpp

Go to the documentation of this file.
00001 /* $Id: script_info.hpp 26057 2013-11-23 13:12:19Z rubidium $ */
00002 
00003 /*
00004  * This file is part of OpenTTD.
00005  * 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.
00006  * 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.
00007  * 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/>.
00008  */
00009 
00012 #ifndef SCRIPT_INFO_HPP
00013 #define SCRIPT_INFO_HPP
00014 
00015 #include <squirrel.h>
00016 #include "../misc/countedptr.hpp"
00017 
00018 #include "script_config.hpp"
00019 
00021 static const int MAX_SL_OPS             = 100000;
00023 static const int MAX_CONSTRUCTOR_OPS    = 100000;
00025 static const int MAX_CREATEINSTANCE_OPS = 100000;
00027 static const int MAX_GET_OPS            =   1000;
00029 static const int MAX_GET_SETTING_OPS    = 100000;
00030 
00032 class ScriptInfo : public SimpleCountedObject {
00033 public:
00034   ScriptInfo() :
00035     engine(NULL),
00036     SQ_instance(NULL),
00037     main_script(NULL),
00038     tar_file(NULL),
00039     author(NULL),
00040     name(NULL),
00041     short_name(NULL),
00042     description(NULL),
00043     date(NULL),
00044     instance_name(NULL),
00045     version(0),
00046     url(NULL),
00047     scanner(NULL)
00048   {}
00049   ~ScriptInfo();
00050 
00054   const char *GetAuthor() const { return this->author; }
00055 
00059   const char *GetName() const { return this->name; }
00060 
00064   const char *GetShortName() const { return this->short_name; }
00065 
00069   const char *GetDescription() const { return this->description; }
00070 
00074   int GetVersion() const { return this->version; }
00075 
00079   const char *GetDate() const { return this->date; }
00080 
00084   const char *GetInstanceName() const { return this->instance_name; }
00085 
00089   const char *GetURL() const { return this->url; }
00090 
00094   const char *GetMainScript() const { return this->main_script; }
00095 
00099   const char *GetTarFile() const { return this->tar_file; }
00100 
00104   bool CheckMethod(const char *name) const;
00105 
00109   static SQInteger Constructor(HSQUIRRELVM vm, ScriptInfo *info);
00110 
00114   virtual class ScriptScanner *GetScanner() { return this->scanner; }
00115 
00119   bool GetSettings();
00120 
00124   const ScriptConfigItemList *GetConfigList() const;
00125 
00129   const ScriptConfigItem *GetConfigItem(const char *name) const;
00130 
00134   SQInteger AddSetting(HSQUIRRELVM vm);
00135 
00139   SQInteger AddLabels(HSQUIRRELVM vm);
00140 
00144   int GetSettingDefaultValue(const char *name) const;
00145 
00149   virtual bool IsDeveloperOnly() const { return false; }
00150 
00151 protected:
00152   class Squirrel *engine;           
00153   HSQOBJECT *SQ_instance;           
00154   ScriptConfigItemList config_list; 
00155 
00156 private:
00157   char *main_script;            
00158   char *tar_file;               
00159   const char *author;           
00160   const char *name;             
00161   const char *short_name;       
00162   const char *description;      
00163   const char *date;             
00164   const char *instance_name;    
00165   int version;                  
00166   const char *url;              
00167 
00168   class ScriptScanner *scanner; 
00169 };
00170 
00171 #endif /* SCRIPT_INFO_HPP */