script_info.hpp

Go to the documentation of this file.
00001 /* $Id$ */
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     SQ_instance(NULL),
00036     main_script(NULL),
00037     tar_file(NULL),
00038     author(NULL),
00039     name(NULL),
00040     short_name(NULL),
00041     description(NULL),
00042     date(NULL),
00043     instance_name(NULL),
00044     version(0),
00045     url(NULL),
00046     scanner(NULL)
00047   {}
00048   ~ScriptInfo();
00049 
00053   const char *GetAuthor() const { return this->author; }
00054 
00058   const char *GetName() const { return this->name; }
00059 
00063   const char *GetShortName() const { return this->short_name; }
00064 
00068   const char *GetDescription() const { return this->description; }
00069 
00073   int GetVersion() const { return this->version; }
00074 
00078   const char *GetDate() const { return this->date; }
00079 
00083   const char *GetInstanceName() const { return this->instance_name; }
00084 
00088   const char *GetURL() const { return this->url; }
00089 
00093   const char *GetMainScript() const { return this->main_script; }
00094 
00098   const char *GetTarFile() const { return this->tar_file; }
00099 
00103   bool CheckMethod(const char *name) const;
00104 
00108   static SQInteger Constructor(HSQUIRRELVM vm, ScriptInfo *info);
00109 
00113   virtual class ScriptScanner *GetScanner() { return this->scanner; }
00114 
00118   bool GetSettings();
00119 
00123   const ScriptConfigItemList *GetConfigList() const;
00124 
00128   const ScriptConfigItem *GetConfigItem(const char *name) const;
00129 
00133   SQInteger AddSetting(HSQUIRRELVM vm);
00134 
00138   SQInteger AddLabels(HSQUIRRELVM vm);
00139 
00143   int GetSettingDefaultValue(const char *name) const;
00144 
00148   virtual bool IsDeveloperOnly() const { return false; }
00149 
00150 protected:
00151   class Squirrel *engine;           
00152   HSQOBJECT *SQ_instance;           
00153   ScriptConfigItemList config_list; 
00154 
00155 private:
00156   char *main_script;            
00157   char *tar_file;               
00158   const char *author;           
00159   const char *name;             
00160   const char *short_name;       
00161   const char *description;      
00162   const char *date;             
00163   const char *instance_name;    
00164   int version;                  
00165   const char *url;              
00166 
00167   class ScriptScanner *scanner; 
00168 };
00169 
00170 #endif /* SCRIPT_INFO_HPP */