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_SCANNER_HPP 00013 #define SCRIPT_SCANNER_HPP 00014 00015 #include <map> 00016 #include "../fileio_func.h" 00017 #include "../core/string_compare_type.hpp" 00018 00019 typedef std::map<const char *, class ScriptInfo *, StringCompare> ScriptInfoList; 00020 00022 class ScriptScanner : public FileScanner { 00023 public: 00024 ScriptScanner(); 00025 virtual ~ScriptScanner(); 00026 00031 virtual void Initialize(const char *name); 00032 00036 class Squirrel *GetEngine() { return this->engine; } 00037 00041 const char *GetMainScript() { return this->main_script; } 00042 00046 const char *GetTarFile() { return this->tar_file; } 00047 00051 const ScriptInfoList *GetInfoList() { return &this->info_list; } 00052 00056 const ScriptInfoList *GetUniqueInfoList() { return &this->info_single_list; } 00057 00061 void RegisterScript(class ScriptInfo *info); 00062 00066 char *GetConsoleList(char *p, const char *last, bool newest_only) const; 00067 00074 bool HasScript(const struct ContentInfo *ci, bool md5sum); 00075 00076 /* virtual */ bool AddFile(const char *filename, size_t basepath_length, const char *tar_filename); 00077 00081 void RescanDir(); 00082 00083 protected: 00084 class Squirrel *engine; 00085 char *main_script; 00086 char *tar_file; 00087 00088 ScriptInfoList info_list; 00089 ScriptInfoList info_single_list; 00090 00094 virtual void GetScriptName(ScriptInfo *info, char *name, int len) = 0; 00095 00099 virtual const char *GetFileName() const = 0; 00100 00104 virtual Subdirectory GetDirectory() const = 0; 00105 00109 virtual void RegisterAPI(class Squirrel *engine) = 0; 00110 00114 virtual const char *GetScannerName() const = 0; 00115 00119 void Reset(); 00120 00121 }; 00122 00123 #endif /* SCRIPT_SCANNER_HPP */